1 #include "numuCC4piSelection.hxx" 2 #include "baseSelection.hxx" 3 #include "CutUtils.hxx" 4 #include "EventBoxUtils.hxx" 5 #include "VersioningUtils.hxx" 6 #include "SystematicUtils.hxx" 7 #include "trackerSelectionUtils.hxx" 8 #include "numuCC4piUtils.hxx" 12 numuCC4piSelection::numuCC4piSelection(
bool forceBreak):
SelectionBase(forceBreak,
EventBoxId::kEventBoxTracker) {
26 AddStep(StepBase::kCut,
"quality+fiducial",
new TrackGQandFVCut(),
true);
27 AddStep(StepBase::kAction,
"veto Action",
new VetoAction());
28 AddStep(StepBase::kAction,
"muon PID Action",
new PIDAction());
34 AddStep(0, StepBase::kCut,
"Fwd Quality Cut",
new Fwd_Quality());
35 AddStep(0, StepBase::kCut,
"Fwd Veto Cut",
new Fwd_Veto());
39 AddStep(0, 0, StepBase::kCut,
"Fwd PID Cut",
new Fwd_PID());
40 AddStep(0, 0, StepBase::kCut,
"Fwd 4pi Cut",
new Fwd_4pi());
41 AddStep(0, 1, StepBase::kCut,
"CSFGD2 PID Cut",
new CSFGD2_PID());
42 AddStep(0, 1, StepBase::kCut,
"CSFGD2 4pi Cut",
new CSFGD2_4pi());
43 AddStep(0, 2, StepBase::kCut,
"CSECAL PID Cut",
new CSECAL_PID());
44 AddStep(0, 2, StepBase::kCut,
"CSECAL 4pi Cut",
new CSECAL_4pi());
46 AddStep(1, StepBase::kCut,
"Bwd Quality Cut",
new Bwd_Quality());
47 AddStep(1, StepBase::kCut,
"Bwd Veto Cut",
new Bwd_Veto());
48 AddStep(1, StepBase::kCut,
"Bwd PID Cut",
new Bwd_PID());
49 AddStep(1, StepBase::kCut,
"Bwd 4pi Cut",
new Bwd_4pi());
51 AddStep(2, StepBase::kCut,
"HAFwd Quality Cut",
new HAFwd_Quality());
52 AddStep(2, StepBase::kCut,
"HAFwd Veto Cut",
new HAFwd_Veto());
53 AddStep(2, StepBase::kCut,
"HAFwd PID Cut",
new HAFwd_PID());
54 AddStep(2, StepBase::kCut,
"HAFwd 4pi Cut",
new HAFwd_4pi());
56 AddStep(3, StepBase::kCut,
"HABwd Quality Cut",
new HABwd_Quality());
57 AddStep(3, StepBase::kCut,
"HABwd Veto Cut",
new HABwd_Veto());
58 AddStep(3, StepBase::kCut,
"HABwd PID Cut",
new HABwd_PID());
59 AddStep(3, StepBase::kCut,
"HABwd 4pi Cut",
new HABwd_4pi());
61 SetBranchAlias(0,
"Fwd", 0, 0);
62 SetBranchAlias(1,
"Bwd", 1);
63 SetBranchAlias(2,
"HAFwd", 2);
64 SetBranchAlias(3,
"HABwd", 3);
65 SetBranchAlias(4,
"CSFGD2", 0, 1);
66 SetBranchAlias(5,
"CSECAL", 0, 2);
69 SetPreSelectionAccumLevel(2);
79 FVDef::FVdefminFGD1[2] = 0;
80 FVDef::FVdefmaxFGD1[2] = 0;
83 SetDetectorFV(SubDetId::kFGD1);
94 if (!event.EventBoxes[EventBoxId::kEventBoxTracker])
event.EventBoxes[EventBoxId::kEventBoxTracker] =
new EventBoxTracker();
96 boxUtils::FillTracksWithTPC(event, static_cast<SubDetId::SubDetEnum>(GetDetectorFV()));
97 boxUtils::FillTracksWithFGD(event, static_cast<SubDetId::SubDetEnum>(GetDetectorFV()));
98 boxUtils::FillTracksWithECal(event);
100 boxUtils::FillTrajsChargedInTPC(event);
101 boxUtils::FillTrajsChargedInFGDAndNoTPC(event, static_cast<SubDetId::SubDetEnum>(GetDetectorFV()));
102 boxUtils::FillTrajsChargedHATracker(event, static_cast<SubDetId::SubDetEnum>(GetDetectorFV()));
103 boxUtils::FillTrajsInECal(event);
108 bool numuCC4piSelection::FillEventSummary(
AnaEventC& event, Int_t allCutsPassed[]){
111 if(allCutsPassed[0])
static_cast<AnaEventSummaryB*
>(
event.Summary)->EventSample = SampleId::kFGD1NuMuCC;
112 if(allCutsPassed[1])
static_cast<AnaEventSummaryB*
>(
event.Summary)->EventSample = SampleId::kFGD1NuMuCC;
113 if(allCutsPassed[2])
static_cast<AnaEventSummaryB*
>(
event.Summary)->EventSample = SampleId::kFGD1NuMuCC;
114 if(allCutsPassed[3])
static_cast<AnaEventSummaryB*
>(
event.Summary)->EventSample = SampleId::kFGD1NuMuCC;
115 if(allCutsPassed[4])
static_cast<AnaEventSummaryB*
>(
event.Summary)->EventSample = SampleId::kFGD1NuMuCC;
116 if(allCutsPassed[5])
static_cast<AnaEventSummaryB*
>(
event.Summary)->EventSample = SampleId::kFGD1NuMuCC;
118 return (static_cast<AnaEventSummaryB*>(event.
Summary)->EventSample != SampleId::kFGD1NuMuCC);
128 EventBoxB* EventBox =
event.EventBoxes[EventBoxId::kEventBoxTracker];
140 EventBoxB* EventBox =
event.EventBoxes[EventBoxId::kEventBoxTracker];
143 int nTPC=EventBox->
nRecObjectsInGroup[EventBoxTracker::kTracksWithGoodQualityTPCInFGD1FV];
144 for (Int_t i=0;i<nTPC; ++i){
145 AnaTrackB* track =
static_cast<AnaTrackB*
>(EventBox->RecObjectsInGroup[EventBoxTracker::kTracksWithGoodQualityTPCInFGD1FV][i]);
146 if ( track->
Charge!=-1 )
continue;
147 cc4pibox->LowAngle.push_back(track);
150 std::sort(cc4pibox->LowAngle.begin(), cc4pibox->LowAngle.end(), numuCC4pi_utils::HGlobalMomFirst);
153 for(
int i=0;i<nECALTracks;i++){
154 AnaTrackB* track =
static_cast<AnaTrackB*
>(EventBox->RecObjectsInGroup[EventBoxTracker::kTracksWithECal][i]);
156 if ( cutUtils::TrackQualityCut(*track) )
continue;
157 if ( cutUtils::StoppingBrECALorSMRDCut(track->
PositionEnd)==-1 )
continue;
158 cc4pibox->HighAngle.push_back(track);
162 std::sort(cc4pibox->HighAngle.begin(), cc4pibox->HighAngle.end(), numuCC4pi_utils::HRangeMomFirst);
174 for(UInt_t i=0;i<cc4pibox->LowAngle.size();i++ ){
177 else cc4pibox->BwdTracks.push_back(cc4pibox->LowAngle[i]);
182 for(UInt_t i=0;i<cc4pibox->HighAngle.size();i++){
185 else cc4pibox->HABwdTracks.push_back(cc4pibox->HighAngle[i]);
189 if ( cc4pibox->FwdTracks.size()>0 ) { cc4pibox->
MainTrack = cc4pibox->FwdTracks[0];
return true; }
190 else if ( cc4pibox->BwdTracks.size()>0 ) { cc4pibox->
MainTrack = cc4pibox->BwdTracks[0];
return true; }
191 else if ( cc4pibox->HAFwdTracks.size()>0 ) { cc4pibox->
MainTrack = cc4pibox->HAFwdTracks[0];
return true; }
192 else if ( cc4pibox->HABwdTracks.size()>0 ) { cc4pibox->
MainTrack = cc4pibox->HABwdTracks[0];
return true; }
206 for (UInt_t i=0;i<cc4pibox->FwdTracks.size();i++){
207 if ( numuCC4pi_utils::VetoCut(0,eventB,*(cc4pibox->FwdTracks[i])) ) {
208 if ( numuCC4pi_utils::ExternalCut(0,event,*(cc4pibox->FwdTracks[i])) ) cc4pibox->FwdTracks_Veto.push_back(cc4pibox->FwdTracks[i]);
212 for (UInt_t i=0;i<cc4pibox->BwdTracks.size();i++){
213 cc4pibox->BwdTracks_Veto.push_back(cc4pibox->BwdTracks[i]);
216 for (UInt_t i=0;i<cc4pibox->HAFwdTracks.size();i++){
217 if ( numuCC4pi_utils::VetoCut(2,eventB,*(cc4pibox->HAFwdTracks[i])) ) cc4pibox->HAFwdTracks_Veto.push_back(cc4pibox->HAFwdTracks[i]);
220 for (UInt_t i=0;i<cc4pibox->HABwdTracks.size();i++){
221 if ( numuCC4pi_utils::VetoCut(3,eventB,*(cc4pibox->HABwdTracks[i])) ) cc4pibox->HABwdTracks_Veto.push_back(cc4pibox->HABwdTracks[i]);
224 if ( cc4pibox->FwdTracks_Veto.size()>0 ) cc4pibox->
MainTrack = cc4pibox->FwdTracks_Veto[0];
225 else if ( cc4pibox->BwdTracks_Veto.size()>0 ) cc4pibox->
MainTrack = cc4pibox->BwdTracks_Veto[0];
226 else if ( cc4pibox->HAFwdTracks_Veto.size()>0 ) cc4pibox->
MainTrack = cc4pibox->HAFwdTracks_Veto[0];
227 else if ( cc4pibox->HABwdTracks_Veto.size()>0 ) cc4pibox->
MainTrack = cc4pibox->HABwdTracks_Veto[0];
241 for (UInt_t i=0;i<cc4pibox->FwdTracks_Veto.size();i++){
242 if ( numuCC4pi_utils::PIDCut(0,*(cc4pibox->FwdTracks_Veto[i]))==1 ) cc4pibox->FwdTracks_PID.push_back(cc4pibox->FwdTracks_Veto[i]);
245 for (UInt_t i=0;i<cc4pibox->BwdTracks_Veto.size();i++){
246 if ( numuCC4pi_utils::PIDCut(1,*(cc4pibox->BwdTracks_Veto[i]))==1 ) cc4pibox->BwdTracks_PID.push_back(cc4pibox->BwdTracks_Veto[i]);
249 for (UInt_t i=0;i<cc4pibox->HAFwdTracks_Veto.size();i++){
250 if ( numuCC4pi_utils::PIDCut(2,*(cc4pibox->HAFwdTracks_Veto[i]))==1 ) cc4pibox->HAFwdTracks_PID.push_back(cc4pibox->HAFwdTracks_Veto[i]);
253 for (UInt_t i=0;i<cc4pibox->HABwdTracks_Veto.size();i++){
254 if ( numuCC4pi_utils::PIDCut(3,*(cc4pibox->HABwdTracks_Veto[i]))==1 ) cc4pibox->HABwdTracks_PID.push_back(cc4pibox->HABwdTracks_Veto[i]);
257 for (UInt_t i=0;i<cc4pibox->FwdTracks_Veto.size();i++){
258 if ( numuCC4pi_utils::PIDCut(0,*(cc4pibox->FwdTracks_Veto[i]))==2 ) cc4pibox->CSFD2Tracks_PID.push_back(cc4pibox->FwdTracks_Veto[i]);
261 for (UInt_t i=0;i<cc4pibox->FwdTracks_Veto.size();i++){
262 if ( numuCC4pi_utils::PIDCut(0,*(cc4pibox->FwdTracks_Veto[i]))==3 ) cc4pibox->CSECALTracks_PID.push_back(cc4pibox->FwdTracks_Veto[i]);
265 if ( cc4pibox->FwdTracks_PID.size()>0 ) cc4pibox->
MainTrack = cc4pibox->FwdTracks_PID[0];
266 else if ( cc4pibox->BwdTracks_PID.size()>0 ) cc4pibox->
MainTrack = cc4pibox->BwdTracks_PID[0];
267 else if ( cc4pibox->HAFwdTracks_PID.size()>0 ) cc4pibox->
MainTrack = cc4pibox->HAFwdTracks_PID[0];
268 else if ( cc4pibox->HABwdTracks_PID.size()>0 ) cc4pibox->
MainTrack = cc4pibox->HABwdTracks_PID[0];
269 else if ( cc4pibox->CSFD2Tracks_PID.size()>0 ) cc4pibox->
MainTrack = cc4pibox->CSFD2Tracks_PID[0];
270 else if ( cc4pibox->CSECALTracks_PID.size()>0 ) cc4pibox->
MainTrack = cc4pibox->CSECALTracks_PID[0];
290 if ( !cc4pibox->
MainTrack )
return false;
296 box.
Vertex->nParticles = 0;
331 if (cc4pibox->FwdTracks.size()>0)
return true;
339 if (cc4pibox->FwdTracks_Veto.size()>0)
return true;
347 if (cc4pibox->FwdTracks_PID.size()>0)
return true;
355 if (cc4pibox->FwdTracks_PID.size()>0)
return true;
364 if (cc4pibox->BwdTracks.size()>0)
return true;
372 if (cc4pibox->BwdTracks_Veto.size()>0)
return true;
380 if (cc4pibox->BwdTracks_PID.size()>0)
return true;
388 if (cc4pibox->BwdTracks_PID.size()>0 && cc4pibox->FwdTracks_PID.size()==0)
return true;
397 if (cc4pibox->HAFwdTracks.size()>0)
return true;
405 if (cc4pibox->HAFwdTracks_Veto.size()>0)
return true;
413 if (cc4pibox->HAFwdTracks_PID.size()>0)
return true;
421 if (cc4pibox->HAFwdTracks_PID.size()>0 && cc4pibox->FwdTracks_PID.size()==0 && cc4pibox->BwdTracks_PID.size()==0)
return true;
430 if (cc4pibox->HABwdTracks.size()>0)
return true;
438 if (cc4pibox->HABwdTracks_Veto.size()>0)
return true;
446 if (cc4pibox->HABwdTracks_PID.size()>0)
return true;
454 if (cc4pibox->HABwdTracks_PID.size()>0 && cc4pibox->FwdTracks_PID.size()==0 && cc4pibox->BwdTracks_PID.size()==0 && cc4pibox->HAFwdTracks_PID.size()==0)
return true;
463 if (cc4pibox->CSFD2Tracks_PID.size()>0)
return true;
471 if (cc4pibox->CSFD2Tracks_PID.size()>0 && cc4pibox->FwdTracks_PID.size()==0 && cc4pibox->BwdTracks_PID.size()==0 && cc4pibox->HAFwdTracks_PID.size()==0 && cc4pibox->HABwdTracks_PID.size()==0)
return true;
480 if (cc4pibox->CSECALTracks_PID.size()>0)
return true;
488 if (cc4pibox->CSECALTracks_PID.size()>0 && cc4pibox->FwdTracks_PID.size()==0 && cc4pibox->BwdTracks_PID.size()==0 && cc4pibox->HAFwdTracks_PID.size()==0 && cc4pibox->HABwdTracks_PID.size()==0 && cc4pibox->CSFD2Tracks_PID.size()==0)
return true;
499 if(systId == SystId::kPileUp){
500 if (branch==1)
return false;
516 if (!track)
return false;
532 if (!trueTrack)
return false;
549 if(systId == SystId::kOOFV){
550 if (branch==1 || branch==3)
return false;
552 if(systId == SystId::kTpcClusterEff){
556 if (tpcTrack->
NNodes > 16 && tpcTrack->
NNodes < 19)
return true;
561 if(systId == SystId::kChargeIDEff){
562 if (track == cc4pibox.
MainTrack)
return true;
565 if(systId == SystId::kTpcFgdMatchEff){
566 if (track == cc4pibox.
MainTrack)
return true;
569 if(systId == SystId::kECalPID){
571 if (branch==2 || branch==3)
return true;
572 else if (branch==0 || branch==4 || branch==5) {
597 if(systId == SystId::kTpcTrackEff){
602 if(systId == SystId::kECalTrackEff){
604 if (branch==2 || branch==3) {
611 if(systId == SystId::kTpcECalMatchEff){
615 if(systId == SystId::kTpcP0dMatchEff){
619 if(systId == SystId::kFgdECalMatchEff){
623 if(systId == SystId::kFgdECalSmrdMatchEff){
627 if(systId == SystId::kSIPion){
641 if(systId == SystId::kSIProton){
660 (void)PreviousToyBox;
bool IsRelevantSystematic(const AnaEventC &event, const ToyBoxB &box, SystId_h systId, Int_t branch) const
Is this systematic relevant for this selection.
AnaTrueVertexB * TrueVertex
Pointer to the AnaTrueVertexB of the interaction that created this AnaTrueParticleB.
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 Apply(AnaEventC &event, ToyBoxB &box) const
Float_t PositionStart[4]
The reconstructed start position of the particle.
bool Apply(AnaEventC &event, ToyBoxB &box) const
AnaTrueVertexB * TrueVertex
bool Apply(AnaEventC &event, ToyBoxB &box) const
bool CheckRedoSelection(const AnaEventC &event, const ToyBoxB &PreviousToyBox, Int_t &redoFromStep)
static bool IsForward(const AnaTrackB &track)
Check whether a track is forward going.
bool Apply(AnaEventC &event, ToyBoxB &box) const
Float_t Position[4]
The identified position of the global vertex.
bool Apply(AnaEventC &event, ToyBoxB &box) const
bool Apply(AnaEventC &event, ToyBoxB &box) const
Int_t NNodes
The number of nodes in the reconstructed object.
Int_t GParentPDG
The PDG code of this particle's grandparent, or 0 if there is no grandparent.
AnaTrackB * MainTrack
For storing the Main Track (The lepton candidate in geranal: HMN or HMP track)
bool Apply(AnaEventC &event, ToyBoxB &box) const
bool Apply(AnaEventC &event, ToyBoxB &box) const
AnaTrueObjectC * TrueObject
The link to the true oject that most likely generated this reconstructed object.
bool Apply(AnaEventC &event, ToyBoxB &box) const
bool Apply(AnaEventC &event, ToyBoxB &box) const
Float_t Momentum
The initial momentum of the true particle.
AnaTrueVertexB * TrueVertex
For storing the true vertex, for analyses with no reconstructed primary vertex.
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...
bool Apply(AnaEventC &event, ToyBoxB &box) const
void DefineSteps()
Define all steps in the selection.
bool Apply(AnaEventC &event, ToyBoxB &box) const
Int_t nRecObjectsInGroup[NMAXRECOBJECTGROUPS]
----—— RecObjects and TrueRecObjects used in the selection and systematics ------------—— ...
bool Apply(AnaEventC &event, ToyBoxB &box) const
bool Apply(AnaEventC &event, ToyBoxB &box) const
Float_t Momentum
The reconstructed momentum of the particle, at the start position.
AnaVertexB * Vertex
For storing the reconstructed vertex.
virtual const ToyBoxTracker & box(Int_t isel=-1) const
Returns the ToyBoxTracker.
int nTPCSegments
How many TPC tracks are associated with this track.
Representation of a true Monte Carlo trajectory/particle.
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) ...
Int_t PDG
The PDG code of this particle.
bool Apply(AnaEventC &event, ToyBoxB &box) const
Int_t ParentPDG
The PDG code of this particle's immediate parent, or 0 if there is no parent.
void InitializeEvent(AnaEventC &event)
Fill the EventBox with the objects needed by this selection.
bool Apply(AnaEventC &event, ToyBoxB &box) const
Representation of a global track.
Representation of a TPC segment of a global track.
AnaParticleB ** Particles
AnaTrackB * MainTrack
For storing tracks information in the bunch.
Representation of a global vertex.
bool Apply(AnaEventC &event, ToyBoxB &box) const
void DefineDetectorFV()
Define the detector Fiducial Volume in which this selection is applied.
AnaEventSummaryC * Summary
A summary of the event with high level quantities.
bool Apply(AnaEventC &event, ToyBoxB &box) const
bool Apply(AnaEventC &event, ToyBoxB &box) const
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...
bool Apply(AnaEventC &event, ToyBoxB &box) const
Find the Vertex. For the moment it's just the Star position of the HM track.
bool Apply(AnaEventC &event, ToyBoxB &box) const
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 InFiducialVolume(SubDetId::SubDetEnum det, const Float_t *pos, const Float_t *FVdefmin, const Float_t *FVdefmax)
bool Apply(AnaEventC &event, ToyBoxB &box) const
bool Apply(AnaEventC &event, ToyBoxB &box) const
bool Apply(AnaEventC &event, ToyBoxB &box) const
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 Apply(AnaEventC &event, ToyBoxB &box) const
A cut on event quality. Requires good beam and ND280 data quality flags.
Float_t PositionEnd[4]
The reconstructed end position of the particle.
bool Apply(AnaEventC &event, ToyBoxB &box) const