2 #include "numuCC4piFGD2Selection.hxx" 3 #include "baseSelection.hxx" 4 #include "SystematicTuning.hxx" 5 #include "CutUtils.hxx" 6 #include "EventBoxUtils.hxx" 7 #include "Parameters.hxx" 8 #include "SubDetId.hxx" 10 #include "SystematicUtils.hxx" 14 numuCC4piFGD2Selection::numuCC4piFGD2Selection(
bool forceBreak):
SelectionBase(forceBreak,
EventBoxId::kEventBoxTracker) {
18 systTuning::Initialize();
56 SetBranchAlias(0,
"Fwd", 0);
57 SetBranchAlias(1,
"Bwd", 1);
58 SetBranchAlias(2,
"HAFwd", 2);
59 SetBranchAlias(3,
"HABwd", 3);
61 SetPreSelectionAccumLevel(2);
71 FVDef::FVdefminFGD2[2] = 0;
72 FVDef::FVdefmaxFGD2[2] = 0;
75 SetDetectorFV(SubDetId::kFGD2);
86 if (!event.EventBoxes[EventBoxId::kEventBoxTracker])
event.EventBoxes[EventBoxId::kEventBoxTracker] =
new EventBoxTracker();
88 boxUtils::FillTracksWithTPC(event, static_cast<SubDetId::SubDetEnum>(GetDetectorFV()));
89 boxUtils::FillTracksWithFGD(event, static_cast<SubDetId::SubDetEnum>(GetDetectorFV()));
90 boxUtils::FillTracksWithECal(event);
92 boxUtils::FillTrajsChargedInTPC(event);
93 boxUtils::FillTrajsChargedInFGDAndNoTPC(event, static_cast<SubDetId::SubDetEnum>(GetDetectorFV()));
94 boxUtils::FillTrajsChargedHATracker(event, static_cast<SubDetId::SubDetEnum>(GetDetectorFV()));
98 bool numuCC4piFGD2Selection::FillEventSummary(
AnaEventC& event, Int_t allCutsPassed[]){
101 if(allCutsPassed[0])
static_cast<AnaEventSummaryB*
>(
event.Summary)->EventSample = SampleId::kFGD2NuMuCC;
102 if(allCutsPassed[1])
static_cast<AnaEventSummaryB*
>(
event.Summary)->EventSample = SampleId::kFGD2NuMuCC;
103 if(allCutsPassed[2])
static_cast<AnaEventSummaryB*
>(
event.Summary)->EventSample = SampleId::kFGD2NuMuCC;
104 if(allCutsPassed[3])
static_cast<AnaEventSummaryB*
>(
event.Summary)->EventSample = SampleId::kFGD2NuMuCC;
106 return (static_cast<AnaEventSummaryB*>(event.
Summary)->EventSample != SampleId::kFGD2NuMuCC);
116 EventBoxB* EventBox =
event.EventBoxes[EventBoxId::kEventBoxTracker];
128 EventBoxB* EventBox =
event.EventBoxes[EventBoxId::kEventBoxTracker];
131 int nTPC=EventBox->
nRecObjectsInGroup[EventBoxTracker::kTracksWithGoodQualityTPCInFGD2FV];
132 for (Int_t i=0;i<nTPC; ++i){
133 AnaTrackB* track =
static_cast<AnaTrackB*
>(EventBox->RecObjectsInGroup[EventBoxTracker::kTracksWithGoodQualityTPCInFGD2FV][i]);
134 if ( track->
Charge!=-1 )
continue;
135 cc4pibox->LowAngle.push_back(track);
138 std::sort(cc4pibox->LowAngle.begin(), cc4pibox->LowAngle.end(), numuCC4pi_utils::HGlobalMomFirst);
141 for(
int i=0;i<nECALTracks;i++){
142 AnaTrackB* track =
static_cast<AnaTrackB*
>(EventBox->RecObjectsInGroup[EventBoxTracker::kTracksWithECal][i]);
145 if ( cutUtils::TrackQualityCut(*track) )
continue;
146 if ( cutUtils::StoppingBrECALorSMRDCut(track->
PositionEnd)==-1 )
continue;
147 cc4pibox->HighAngle.push_back(track);
151 std::sort(cc4pibox->HighAngle.begin(), cc4pibox->HighAngle.end(), numuCC4pi_utils::HRangeMomFirst);
165 for(UInt_t i=0;i<cc4pibox->LowAngle.size();i++ ){
166 if (
anaUtils::InFiducialVolume(SubDetId::kFGD2, cc4pibox->LowAngle[i]->PositionStart, numuCC4piFGD2_utils::LAFVmin, numuCC4piFGD2_utils::LAFVmax) ){
168 else cc4pibox->BwdTracks.push_back(cc4pibox->LowAngle[i]);
173 for(UInt_t i=0;i<cc4pibox->HighAngle.size();i++){
174 if (
anaUtils::InFiducialVolume(SubDetId::kFGD2, cc4pibox->HighAngle[i]->PositionStart, numuCC4piFGD2_utils::HAFVmin, numuCC4piFGD2_utils::HAFVmax) ) {
176 else cc4pibox->HABwdTracks.push_back(cc4pibox->HighAngle[i]);
180 if ( cc4pibox->FwdTracks.size()>0 ) { cc4pibox->
MainTrack = cc4pibox->FwdTracks[0];
return true; }
181 else if ( cc4pibox->BwdTracks.size()>0 ) { cc4pibox->
MainTrack = cc4pibox->BwdTracks[0];
return true; }
182 else if ( cc4pibox->HAFwdTracks.size()>0 ) { cc4pibox->
MainTrack = cc4pibox->HAFwdTracks[0];
return true; }
183 else if ( cc4pibox->HABwdTracks.size()>0 ) { cc4pibox->
MainTrack = cc4pibox->HABwdTracks[0];
return true; }
197 for (UInt_t i=0;i<cc4pibox->FwdTracks.size();i++){
198 if ( numuCC4pi_utils::VetoCut(0,eventB,*(cc4pibox->FwdTracks[i])) ) {
199 if ( numuCC4piFGD2_utils::ExternalCut(0,event,*(cc4pibox->FwdTracks[i])) ) cc4pibox->FwdTracks_Veto.push_back(cc4pibox->FwdTracks[i]);
203 for (UInt_t i=0;i<cc4pibox->BwdTracks.size();i++){
204 cc4pibox->BwdTracks_Veto.push_back(cc4pibox->BwdTracks[i]);
207 for (UInt_t i=0;i<cc4pibox->HAFwdTracks.size();i++){
208 if ( numuCC4pi_utils::VetoCut(2,eventB,*(cc4pibox->HAFwdTracks[i])) ) cc4pibox->HAFwdTracks_Veto.push_back(cc4pibox->HAFwdTracks[i]);
211 for (UInt_t i=0;i<cc4pibox->HABwdTracks.size();i++){
212 if ( numuCC4pi_utils::VetoCut(3,eventB,*(cc4pibox->HABwdTracks[i])) ) cc4pibox->HABwdTracks_Veto.push_back(cc4pibox->HABwdTracks[i]);
215 if ( cc4pibox->FwdTracks_Veto.size()>0 ) cc4pibox->
MainTrack = cc4pibox->FwdTracks_Veto[0];
216 else if ( cc4pibox->BwdTracks_Veto.size()>0 ) cc4pibox->
MainTrack = cc4pibox->BwdTracks_Veto[0];
217 else if ( cc4pibox->HAFwdTracks_Veto.size()>0 ) cc4pibox->
MainTrack = cc4pibox->HAFwdTracks_Veto[0];
218 else if ( cc4pibox->HABwdTracks_Veto.size()>0 ) cc4pibox->
MainTrack = cc4pibox->HABwdTracks_Veto[0];
232 for (UInt_t i=0;i<cc4pibox->FwdTracks_Veto.size();i++){
233 if ( numuCC4piFGD2_utils::PIDCut(0,*(cc4pibox->FwdTracks_Veto[i]))==1 ) cc4pibox->FwdTracks_PID.push_back(cc4pibox->FwdTracks_Veto[i]);
236 for (UInt_t i=0;i<cc4pibox->BwdTracks_Veto.size();i++){
237 if ( numuCC4piFGD2_utils::PIDCut(1,*(cc4pibox->BwdTracks_Veto[i]))==1 ) cc4pibox->BwdTracks_PID.push_back(cc4pibox->BwdTracks_Veto[i]);
240 for (UInt_t i=0;i<cc4pibox->HAFwdTracks_Veto.size();i++){
241 if ( numuCC4piFGD2_utils::PIDCut(2,*(cc4pibox->HAFwdTracks_Veto[i]))==1 ) cc4pibox->HAFwdTracks_PID.push_back(cc4pibox->HAFwdTracks_Veto[i]);
244 for (UInt_t i=0;i<cc4pibox->HABwdTracks_Veto.size();i++){
245 if ( numuCC4piFGD2_utils::PIDCut(2,*(cc4pibox->HABwdTracks_Veto[i]))==1 ) cc4pibox->HABwdTracks_PID.push_back(cc4pibox->HABwdTracks_Veto[i]);
248 for (UInt_t i=0;i<cc4pibox->FwdTracks_Veto.size();i++){
249 if ( numuCC4piFGD2_utils::PIDCut(0,*(cc4pibox->FwdTracks_Veto[i]))==3 ) cc4pibox->CSECALTracks_PID.push_back(cc4pibox->FwdTracks_Veto[i]);
252 if ( cc4pibox->FwdTracks_PID.size()>0 ) cc4pibox->
MainTrack = cc4pibox->FwdTracks_PID[0];
253 else if ( cc4pibox->BwdTracks_PID.size()>0 ) cc4pibox->
MainTrack = cc4pibox->BwdTracks_PID[0];
254 else if ( cc4pibox->HAFwdTracks_PID.size()>0 ) cc4pibox->
MainTrack = cc4pibox->HAFwdTracks_PID[0];
255 else if ( cc4pibox->HABwdTracks_PID.size()>0 ) cc4pibox->
MainTrack = cc4pibox->HABwdTracks_PID[0];
272 anaUtils::CopyArray( cc4pibox->
MainTrack->
PositionStart, static_cast<AnaEventSummaryB*>(event.
Summary)->VertexPosition[SampleId::kFGD2NuMuCC], 4);
280 bool numuCC4piFGD2_utils::ExternalCut(
int topo,
const AnaEventC& event,
AnaTrackB& candidate){
283 if ( numuCC4pi_utils::GetFgdLayer(candidate.
PositionStart) > 27 ) {
284 EventBoxB* EventBox =
event.EventBoxes[EventBoxId::kEventBoxTracker];
285 int nFgdTracks=EventBox->
nRecObjectsInGroup[EventBoxTracker::kTracksWithFGD2AndNoTPC];
286 for (Int_t i=0;i<nFgdTracks;i++){
287 AnaTrackB* track =
static_cast<AnaTrackB*
>(EventBox->RecObjectsInGroup[EventBoxTracker::kTracksWithFGD2AndNoTPC][i]);
289 if( !fgdTrack )
continue;
300 int numuCC4piFGD2_utils::PIDCut(
int topo,
const AnaTrackB& candidate) {
304 if (cutUtils::MuonPIDCut(candidate,
false)){
315 else if ( topo==1 ) {
319 else if ( topo==2 ) {
320 if ( cutUtils::MuonECALPIDCut(candidate) )
return 1;
350 if (!track)
return false;
367 if (!trueTrack)
return false;
384 if(systId == SystId::kTpcClusterEff){
387 if (!tpcTrack)
return false;
388 if (tpcTrack->
NNodes != 17 && tpcTrack->
NNodes != 18)
return false;
390 if(systId == SystId::kChargeIDEff){
391 if (track != cc4pibox.
MainTrack)
return false;
393 if(systId == SystId::kTpcFgdMatchEff){
394 if (track != cc4pibox.
MainTrack)
return false;
396 if(systId == SystId::kECalPID){
397 if (branch==1)
return false;
398 else {
if (track != cc4pibox.
MainTrack)
return false; }
416 if(systId == SystId::kTpcTrackEff){
419 if (branch>1 && branch<4)
return false;
423 if(systId == SystId::kECalTrackEff){
430 if(systId == SystId::kTpcP0dMatchEff){
436 if(systId == SystId::kTpcECalMatchEff){
442 if(systId == SystId::kFgdECalMatchEff){
458 (void)PreviousToyBoxB;
AnaTrueVertexB * TrueVertex
Pointer to the AnaTrueVertexB of the interaction that created this AnaTrueParticleB.
Float_t PositionStart[4]
The reconstructed start position of the particle.
bool IsRelevantRecObjectForSystematicInToy(const AnaEventC &, const ToyBoxB &, AnaRecObjectC *, SystId_h systId, Int_t branch=0) const
Is this track relevant for a given systematic (after selection, called for each toy) ...
bool IsRelevantTrueObjectForSystematicInToy(const AnaEventC &, const ToyBoxB &, AnaTrueObjectC *, SystId_h systId, Int_t branch=0) const
Is this true track relevant for a given systematic (after selection, called for each toy) ...
void DefineSteps()
Define all steps in the selection.
bool Apply(AnaEventC &event, ToyBoxB &box) const
AnaECALParticleB * ECALSegments[NMAXECALS]
The ECAL segments that contributed to this global track.
int nECALSegments
How many ECAL tracks are associated with this track.
static bool IsForward(const AnaTrackB &track)
Check whether a track is forward going.
bool IsRelevantTrueObjectForSystematic(const AnaEventC &event, AnaTrueObjectC *trueObj, SystId_h systId, Int_t branch) const
Is this true track relevant for a given systematic (prior to selection, call when initializing the ev...
Int_t NNodes
The number of nodes in the reconstructed object.
bool IsRelevantSystematic(const AnaEventC &event, const ToyBoxB &box, SystId_h systId, Int_t branch) const
Is this systematic relevant for this selection.
void InitializeEvent(AnaEventC &event)
Fill the EventBox with the objects needed by this selection.
AnaTrueObjectC * TrueObject
The link to the true oject that most likely generated this reconstructed object.
static bool GetDetectorUsed(unsigned long BitField, SubDetId::SubDetEnum det)
Method to see if a certain subdetector or subdetector system is used.
bool Apply(AnaEventC &event, ToyBoxB &box) const
bool TrackUsesDet(const AnaTrackB &track, SubDetId::SubDetEnum det)
Float_t Charge
The reconstructed charge of the particle.
Int_t ID
The ID of the trueObj, which corresponds to the ID of the TTruthParticle that created it...
Float_t GetPIDLikelihood(const AnaTrackB &track, Int_t hypo, bool prod5Cut=0)
Int_t nRecObjectsInGroup[NMAXRECOBJECTGROUPS]
----—— RecObjects and TrueRecObjects used in the selection and systematics ------------—— ...
int nTPCSegments
How many TPC tracks are associated with this track.
Representation of a true Monte Carlo trajectory/particle.
bool CheckRedoSelection(const AnaEventC &event, const ToyBoxB &PreviousToyBox, Int_t &redoFromStep)
bool Apply(AnaEventC &event, ToyBoxB &box) const
bool Apply(AnaEventC &event, ToyBoxB &box) const
Int_t PDG
The PDG code of this particle.
Representation of a global track.
Representation of a TPC segment of a global track.
AnaTrackB * MainTrack
For storing tracks information in the bunch.
AnaEventSummaryC * Summary
A summary of the event with high level quantities.
Representation of a FGD segment of a global track.
AnaParticleB * GetSegmentWithMostNodesInClosestTpc(const AnaTrackB &track)
Combined function to address NuMu selection needs as efficiently as possible - gets the TPC segment w...
AnaTrueParticleB * GetTrueParticle() const
Return a casted version of the AnaTrueObject associated.
bool IsRelevantRecObjectForSystematic(const AnaEventC &event, AnaRecObjectC *recObj, SystId_h systId, Int_t branch) const
Is this track relevant for a given systematic (prior to selection, call when initializing the event...
bool InFiducialVolume(SubDetId::SubDetEnum det, const Float_t *pos, const Float_t *FVdefmin, const Float_t *FVdefmax)
bool Apply(AnaEventC &event, ToyBoxB &box) const
void DefineDetectorFV()
Define the detector Fiducial Volume in which this selection is applied.
AnaFGDParticleB * FGDSegments[NMAXFGDS]
The FGD segments that contributed to this global track.
A cut on event quality. Requires good beam and ND280 data quality flags.
bool Apply(AnaEventC &event, ToyBoxB &box) const
Float_t PositionEnd[4]
The reconstructed end position of the particle.