diff --git a/source/Utils/include/FilterTracks.h b/source/Utils/include/FilterTracks.h index 3e5cfc9..92e2950 100644 --- a/source/Utils/include/FilterTracks.h +++ b/source/Utils/include/FilterTracks.h @@ -61,6 +61,7 @@ class FilterTracks : public marlin::Processor std::string _OutputTrackCollection {}; bool _BarrelOnly = false; + bool _HasCaloState = false; //! Cut off for total number of hits int _NHitsTotal = 7; @@ -71,6 +72,9 @@ class FilterTracks : public marlin::Processor //! Cut off for number of hits in outer tracker (barrel and endcap combined) int _NHitsOuter = 1; + //! Cut off for maximum number of holes on track + int _MaxHoles = 0; + //! Cut off for momentum (GeV) float _MinPt = 1.0; //units GeV diff --git a/source/Utils/src/FilterTracks.cc b/source/Utils/src/FilterTracks.cc index 4e28536..4074751 100644 --- a/source/Utils/src/FilterTracks.cc +++ b/source/Utils/src/FilterTracks.cc @@ -25,6 +25,12 @@ FilterTracks::FilterTracks() _BarrelOnly ); + registerProcessorParameter("HasCaloState", + "If true, just keep tracks that have a TrackState at the Calorimeter surface", + _HasCaloState, + _HasCaloState + ); + registerProcessorParameter("NHitsTotal", "Minimum number of hits on track", _NHitsTotal, @@ -49,6 +55,12 @@ FilterTracks::FilterTracks() _NHitsOuter ); + registerProcessorParameter("MaxHoles", + "Maximum number of holes on track", + _MaxHoles, + _MaxHoles + ); + registerProcessorParameter("MinPt", "Minimum transverse momentum", _MinPt, @@ -132,25 +144,36 @@ void FilterTracks::processEvent( LCEvent * evt ) float chi2spatial = trk->getChi2(); + int nholes = trk->getNholes(); + + // Check if a TrackState at the calo surface exists + const std::vector& trackStates = trk->getTrackStates(); + const auto foundCaloState = std::find_if(trackStates.begin(), trackStates.end(), + [](const auto ts) { return ts->getLocation() == EVENT::TrackState::AtCalorimeter; }) != trackStates.end(); + if (_HasCaloState && !foundCaloState) { continue; } + if(_BarrelOnly == true) { bool endcaphits = false; for(int j=0; jgetTrackerHits()[j])["system"]; - if(systemID == 2 || systemID == 4 || systemID == 6) { - endcaphits = true; - break; - } + //Find what subdetector the hit is on + uint32_t systemID = decoder(trk->getTrackerHits()[j])["system"]; + if(systemID == 2 || systemID == 4 || systemID == 6) { + endcaphits = true; + break; + } } if(endcaphits == false) { OutputTrackCollection->addElement(trk); } } else { // track property cuts if(nhittotal > _NHitsTotal && - nhitvertex > _NHitsVertex && - nhitinner > _NHitsInner && - nhitouter > _NHitsOuter && - pt > _MinPt && - chi2spatial > _Chi2Spatial) - { OutputTrackCollection->addElement(trk); } + nhitvertex > _NHitsVertex && + nhitinner > _NHitsInner && + nhitouter > _NHitsOuter && + pt > _MinPt && + chi2spatial > _Chi2Spatial && + nholes <= _MaxHoles) + { + OutputTrackCollection->addElement(trk); + } } }