Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions source/Utils/include/FilterTracks.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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

Expand Down
47 changes: 35 additions & 12 deletions source/Utils/src/FilterTracks.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -49,6 +55,12 @@ FilterTracks::FilterTracks()
_NHitsOuter
);

registerProcessorParameter("MaxHoles",
"Maximum number of holes on track",
_MaxHoles,
_MaxHoles
);

registerProcessorParameter("MinPt",
"Minimum transverse momentum",
_MinPt,
Expand Down Expand Up @@ -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<EVENT::TrackState*>& 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; j<nhittotal; ++j) {
//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;
}
//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);
}
}
}

Expand Down