diff --git a/CalPatRec/src/AgnosticHelixFinder_module.cc b/CalPatRec/src/AgnosticHelixFinder_module.cc index 900b44e7c..abb7b51bf 100644 --- a/CalPatRec/src/AgnosticHelixFinder_module.cc +++ b/CalPatRec/src/AgnosticHelixFinder_module.cc @@ -115,19 +115,19 @@ namespace mu2e { }; struct cHit { - int hitIndice; // index of point in _chColl - float circleError2; - float helixPhi; - float helixPhiError2; - int helixPhiCorrection; - bool inHelix; - bool used; // whether or not hit is used in fits - bool isolated; - bool averagedOut; - bool notOnLine; - bool uselessTripletSeed; - bool notOnSegment; - bool debugParticle; // only filled in debug mode -- true if mc particle, false if background + int hitIndice = 0; // index of point in _chColl + float circleError2 = 1.0; + float helixPhi = 0.0; + float helixPhiError2 = 0.0; + int helixPhiCorrection = 0; + bool inHelix = false; + bool used = false; // whether or not hit is used in fits + bool isolated = false; + bool averagedOut = false; + bool notOnLine = true; + bool uselessTripletSeed = false; + bool notOnSegment = true; + bool debugParticle = false; // only filled in debug mode -- true if mc particle, false if background }; struct tripletPoint { @@ -730,21 +730,9 @@ namespace mu2e { size_t sortStartIndex = 0; - cHit hit; - hit.circleError2 = 1.0; - hit.helixPhi = 0.0; - hit.helixPhiError2 = 0.0; - hit.helixPhiCorrection = 0; - hit.inHelix = false; - hit.used = false; - hit.isolated = false; - hit.averagedOut = false; - hit.notOnLine = true; - hit.uselessTripletSeed = false; - hit.notOnSegment = true; - // push back stopping target if it is to be used if (_useStoppingTarget == true) { + cHit hit; hit.hitIndice = HitType::STOPPINGTARGET; _tcHits.push_back(hit); sortStartIndex++; @@ -752,22 +740,27 @@ namespace mu2e { // push back calo cluster if it exists in time cluster if (_tcColl->at(tc).hasCaloCluster()) { - hit.hitIndice = HitType::CALOCLUSTER; - _tcHits.push_back(hit); const art::Ptr cl = _tcColl->at(tc).caloCluster(); - CLHEP::Hep3Vector gpos = _calorimeter->geomUtil().diskToMu2e(cl->diskID(), cl->cog3Vector()); - CLHEP::Hep3Vector tpos = _calorimeter->geomUtil().mu2eToTracker(gpos); - double offset = _calorimeter->caloInfo().getDouble("diskCaseZLength"); - offset += _calorimeter->caloInfo().getDouble("BPPipeZOffset"); - offset += _calorimeter->caloInfo().getDouble("BPHoleZLength"); - offset += _calorimeter->caloInfo().getDouble("FEEZLength"); - offset /= 2.0; - _caloPos.SetCoordinates(tpos.x(), tpos.y(), tpos.z() - offset); - sortStartIndex++; + const CaloCluster*cluster = cl.get(); + if (cluster != nullptr){ + cHit hit; + hit.hitIndice = HitType::CALOCLUSTER; + CLHEP::Hep3Vector gpos = _calorimeter->geomUtil().diskToMu2e(cl->diskID(), cl->cog3Vector()); + CLHEP::Hep3Vector tpos = _calorimeter->geomUtil().mu2eToTracker(gpos); + double offset = _calorimeter->caloInfo().getDouble("diskCaseZLength"); + offset += _calorimeter->caloInfo().getDouble("BPPipeZOffset"); + offset += _calorimeter->caloInfo().getDouble("BPHoleZLength"); + offset += _calorimeter->caloInfo().getDouble("FEEZLength"); + offset /= 2.0; + _caloPos.SetCoordinates(tpos.x(), tpos.y(), tpos.z() - offset); + _tcHits.push_back(hit); + sortStartIndex++; + } } // fill hits from time cluster for (size_t i = 0; i < _tcColl->at(tc)._strawHitIdxs.size(); i++) { + cHit hit; hit.hitIndice = _tcColl->at(tc)._strawHitIdxs[i]; if (_debug == 1) { std::vector shids; @@ -787,6 +780,7 @@ namespace mu2e { std::sort(_tcHits.begin() + sortStartIndex, _tcHits.end(), [&](const cHit& a, const cHit& b) { return _chColl->at(a.hitIndice).pos().z() > _chColl->at(b.hitIndice).pos().z(); }); + } //----------------------------------------------------------------------------- @@ -1083,7 +1077,7 @@ namespace mu2e { } } } - _tcHits[i].uselessTripletSeed = uselessSeed; + if (i<_tcHits.size()) {_tcHits[i].uselessTripletSeed = uselessSeed;} } }