1 #include "numuCC4piSelection.hxx" 2 #include "baseSelection.hxx" 3 #include "SystematicTuning.hxx" 4 #include "CutUtils.hxx" 5 #include "EventBoxUtils.hxx" 6 #include "Parameters.hxx" 7 #include "SubDetId.hxx" 9 #include "SystematicUtils.hxx" 13 numuCC4piSelection::numuCC4piSelection(
bool forceBreak):
SelectionBase(forceBreak,
EventBoxId::kEventBoxTracker) {
17 systTuning::Initialize();
70 FVDef::FVdefminFGD1[2] = 0;
71 FVDef::FVdefmaxFGD1[2] = 0;
85 if (!event.EventBoxes[EventBoxId::kEventBoxTracker])
event.EventBoxes[EventBoxId::kEventBoxTracker] =
new EventBoxTracker();
87 boxUtils::FillTracksWithTPC(event, static_cast<SubDetId::SubDetEnum>(
GetDetectorFV()));
88 boxUtils::FillTracksWithFGD(event, static_cast<SubDetId::SubDetEnum>(
GetDetectorFV()));
89 boxUtils::FillTracksWithECal(event);
91 boxUtils::FillTrajsChargedInTPC(event);
92 boxUtils::FillTrajsChargedInFGDAndNoTPC(event, static_cast<SubDetId::SubDetEnum>(
GetDetectorFV()));
93 boxUtils::FillTrajsChargedHATracker(event, static_cast<SubDetId::SubDetEnum>(
GetDetectorFV()));
97 bool numuCC4piSelection::FillEventSummary(
AnaEventC& event, Int_t allCutsPassed[]){
100 if(allCutsPassed[0])
static_cast<AnaEventSummaryB*
>(
event.Summary)->EventSample = SampleId::kFGD1NuMuCC;
101 if(allCutsPassed[1])
static_cast<AnaEventSummaryB*
>(
event.Summary)->EventSample = SampleId::kFGD1NuMuCC;
102 if(allCutsPassed[2])
static_cast<AnaEventSummaryB*
>(
event.Summary)->EventSample = SampleId::kFGD1NuMuCC;
103 if(allCutsPassed[3])
static_cast<AnaEventSummaryB*
>(
event.Summary)->EventSample = SampleId::kFGD1NuMuCC;
105 return (static_cast<AnaEventSummaryB*>(event.
Summary)->EventSample != SampleId::kFGD1NuMuCC);
115 EventBoxB* EventBox =
event.EventBoxes[EventBoxId::kEventBoxTracker];
127 EventBoxB* EventBox =
event.EventBoxes[EventBoxId::kEventBoxTracker];
130 int nTPC=EventBox->
nRecObjectsInGroup[EventBoxTracker::kTracksWithGoodQualityTPCInFGD1FV];
131 for (Int_t i=0;i<nTPC; ++i){
132 AnaTrackB* track =
static_cast<AnaTrackB*
>(EventBox->RecObjectsInGroup[EventBoxTracker::kTracksWithGoodQualityTPCInFGD1FV][i]);
133 if ( track->
Charge!=-1 )
continue;
134 cc4pibox->LowAngle.push_back(track);
137 std::sort(cc4pibox->LowAngle.begin(), cc4pibox->LowAngle.end(), numuCC4pi_utils::HGlobalMomFirst);
140 for(
int i=0;i<nECALTracks;i++){
141 AnaTrackB* track =
static_cast<AnaTrackB*
>(EventBox->RecObjectsInGroup[EventBoxTracker::kTracksWithECal][i]);
143 if ( cutUtils::TrackQualityCut(*track) )
continue;
144 if ( cutUtils::StoppingBrECALorSMRDCut(track->
PositionEnd)==-1 )
continue;
145 cc4pibox->HighAngle.push_back(track);
149 std::sort(cc4pibox->HighAngle.begin(), cc4pibox->HighAngle.end(), numuCC4pi_utils::HRangeMomFirst);
163 for(UInt_t i=0;i<cc4pibox->LowAngle.size();i++ ){
164 if (
anaUtils::InFiducialVolume(SubDetId::kFGD1, cc4pibox->LowAngle[i]->PositionStart, numuCC4pi_utils::LAFVmin, numuCC4pi_utils::LAFVmax) ){
166 else cc4pibox->BwdTracks.push_back(cc4pibox->LowAngle[i]);
171 for(UInt_t i=0;i<cc4pibox->HighAngle.size();i++){
172 if (
anaUtils::InFiducialVolume(SubDetId::kFGD1, cc4pibox->HighAngle[i]->PositionStart, numuCC4pi_utils::HAFVmin, numuCC4pi_utils::HAFVmax) ) {
174 else cc4pibox->HABwdTracks.push_back(cc4pibox->HighAngle[i]);
178 if ( cc4pibox->FwdTracks.size()>0 ) { cc4pibox->
MainTrack = cc4pibox->FwdTracks[0];
return true; }
179 else if ( cc4pibox->BwdTracks.size()>0 ) { cc4pibox->
MainTrack = cc4pibox->BwdTracks[0];
return true; }
180 else if ( cc4pibox->HAFwdTracks.size()>0 ) { cc4pibox->
MainTrack = cc4pibox->HAFwdTracks[0];
return true; }
181 else if ( cc4pibox->HABwdTracks.size()>0 ) { cc4pibox->
MainTrack = cc4pibox->HABwdTracks[0];
return true; }
195 for (UInt_t i=0;i<cc4pibox->FwdTracks.size();i++){
196 if ( numuCC4pi_utils::VetoCut(0,eventB,*(cc4pibox->FwdTracks[i])) ) {
197 if ( numuCC4pi_utils::ExternalCut(0,event,*(cc4pibox->FwdTracks[i])) ) cc4pibox->FwdTracks_Veto.push_back(cc4pibox->FwdTracks[i]);
201 for (UInt_t i=0;i<cc4pibox->BwdTracks.size();i++){
202 cc4pibox->BwdTracks_Veto.push_back(cc4pibox->BwdTracks[i]);
205 for (UInt_t i=0;i<cc4pibox->HAFwdTracks.size();i++){
206 if ( numuCC4pi_utils::VetoCut(2,eventB,*(cc4pibox->HAFwdTracks[i])) ) cc4pibox->HAFwdTracks_Veto.push_back(cc4pibox->HAFwdTracks[i]);
209 for (UInt_t i=0;i<cc4pibox->HABwdTracks.size();i++){
210 if ( numuCC4pi_utils::VetoCut(3,eventB,*(cc4pibox->HABwdTracks[i])) ) cc4pibox->HABwdTracks_Veto.push_back(cc4pibox->HABwdTracks[i]);
213 if ( cc4pibox->FwdTracks_Veto.size()>0 ) cc4pibox->
MainTrack = cc4pibox->FwdTracks_Veto[0];
214 else if ( cc4pibox->BwdTracks_Veto.size()>0 ) cc4pibox->
MainTrack = cc4pibox->BwdTracks_Veto[0];
215 else if ( cc4pibox->HAFwdTracks_Veto.size()>0 ) cc4pibox->
MainTrack = cc4pibox->HAFwdTracks_Veto[0];
216 else if ( cc4pibox->HABwdTracks_Veto.size()>0 ) cc4pibox->
MainTrack = cc4pibox->HABwdTracks_Veto[0];
230 for (UInt_t i=0;i<cc4pibox->FwdTracks_Veto.size();i++){
231 if ( numuCC4pi_utils::PIDCut(0,*(cc4pibox->FwdTracks_Veto[i]))==1 ) cc4pibox->FwdTracks_PID.push_back(cc4pibox->FwdTracks_Veto[i]);
234 for (UInt_t i=0;i<cc4pibox->BwdTracks_Veto.size();i++){
235 if ( numuCC4pi_utils::PIDCut(1,*(cc4pibox->BwdTracks_Veto[i]))==1 ) cc4pibox->BwdTracks_PID.push_back(cc4pibox->BwdTracks_Veto[i]);
238 for (UInt_t i=0;i<cc4pibox->HAFwdTracks_Veto.size();i++){
239 if ( numuCC4pi_utils::PIDCut(2,*(cc4pibox->HAFwdTracks_Veto[i]))==1 ) cc4pibox->HAFwdTracks_PID.push_back(cc4pibox->HAFwdTracks_Veto[i]);
242 for (UInt_t i=0;i<cc4pibox->HABwdTracks_Veto.size();i++){
243 if ( numuCC4pi_utils::PIDCut(2,*(cc4pibox->HABwdTracks_Veto[i]))==1 ) cc4pibox->HABwdTracks_PID.push_back(cc4pibox->HABwdTracks_Veto[i]);
246 if ( cc4pibox->FwdTracks_PID.size()>0 ) cc4pibox->
MainTrack = cc4pibox->FwdTracks_PID[0];
247 else if ( cc4pibox->BwdTracks_PID.size()>0 ) cc4pibox->
MainTrack = cc4pibox->BwdTracks_PID[0];
248 else if ( cc4pibox->HAFwdTracks_PID.size()>0 ) cc4pibox->
MainTrack = cc4pibox->HAFwdTracks_PID[0];
249 else if ( cc4pibox->HABwdTracks_PID.size()>0 ) cc4pibox->
MainTrack = cc4pibox->HABwdTracks_PID[0];
268 if ( !cc4pibox->
MainTrack )
return false;
273 box.
Vertex->nParticles = 0;
294 anaUtils::CopyArray( cc4pibox->
MainTrack->
PositionStart, static_cast<AnaEventSummaryB*>(event.
Summary)->VertexPosition[SampleId::kFGD1NuMuCC], 4);
306 if (cc4pibox->FwdTracks.size()>0)
return true;
314 if (cc4pibox->FwdTracks_Veto.size()>0)
return true;
322 if (cc4pibox->FwdTracks_PID.size()>0)
return true;
330 if (cc4pibox->FwdTracks_PID.size()>0)
return true;
339 if (cc4pibox->BwdTracks.size()>0)
return true;
347 if (cc4pibox->BwdTracks_Veto.size()>0)
return true;
355 if (cc4pibox->BwdTracks_PID.size()>0)
return true;
363 if (cc4pibox->BwdTracks_PID.size()>0 && cc4pibox->FwdTracks_PID.size()==0)
return true;
372 if (cc4pibox->HAFwdTracks.size()>0)
return true;
380 if (cc4pibox->HAFwdTracks_Veto.size()>0)
return true;
388 if (cc4pibox->HAFwdTracks_PID.size()>0)
return true;
396 if (cc4pibox->HAFwdTracks_PID.size()>0 && cc4pibox->FwdTracks_PID.size()==0 && cc4pibox->BwdTracks_PID.size()==0)
return true;
405 if (cc4pibox->HABwdTracks.size()>0)
return true;
413 if (cc4pibox->HABwdTracks_Veto.size()>0)
return true;
421 if (cc4pibox->HABwdTracks_PID.size()>0)
return true;
429 if (cc4pibox->HABwdTracks_PID.size()>0 && cc4pibox->FwdTracks_PID.size()==0 && cc4pibox->BwdTracks_PID.size()==0 && cc4pibox->HAFwdTracks_PID.size()==0)
return true;
434 int numuCC4pi_utils::GetFgdLayer(Float_t* pos){
439 Float_t barCenter[30];
441 for (Int_t i=0; i<30; i++) {
442 barCenter[i] = DetDef::fgd1BarCenter[i];
443 if (i==0) initZ = barCenter[0]-(DetDef::fgdXYBarWidth/2)-DetDef::fgdXYGlueWidth-DetDef::fgdXYSkinWidth-DetDef::fgdXYAirWidth;
445 if (i%2==0) finalZ = barCenter[i]+(DetDef::fgdXYBarWidth/2)+(DetDef::fgdXYMiddleGlueWidth/2);
446 else if (i%2==1) finalZ = barCenter[i]+(DetDef::fgdXYBarWidth/2)+DetDef::fgdXYGlueWidth+DetDef::fgdXYSkinWidth+(DetDef::fgdXYAirWidth/2);
447 if (i==29) finalZ += (DetDef::fgdXYAirWidth/2);
448 if (pos[2]>initZ && pos[2]<finalZ)
return i;
472 bool numuCC4pi_utils::VetoCut(
int topo,
const AnaEventB& event,
AnaTrackB& candidate){
476 AnaTrackB* VetoTrack = cutUtils::FindVetoTrack(event, candidate);
483 AnaTrackB* VetoTrack = cutUtils::FindVetoTrack(event, candidate);
490 AnaTrackB* VetoTrack = cutUtils::FindVetoTrack(event, candidate);
501 bool numuCC4pi_utils::ExternalCut(
int topo,
const AnaEventC& event,
AnaTrackB& candidate){
505 EventBoxB* EventBox =
event.EventBoxes[EventBoxId::kEventBoxTracker];
506 int nFgdTracks=EventBox->
nRecObjectsInGroup[EventBoxTracker::kTracksWithFGD1AndNoTPC];
507 for (Int_t i=0;i<nFgdTracks;i++){
508 AnaTrackB* track =
static_cast<AnaTrackB*
>(EventBox->RecObjectsInGroup[EventBoxTracker::kTracksWithFGD1AndNoTPC][i]);
510 if( !fgdTrack )
continue;
521 int numuCC4pi_utils::PIDCut(
int topo,
const AnaTrackB& candidate) {
525 if (cutUtils::MuonPIDCut(candidate,
false)){
527 if ( candidate.
Momentum>280. )
return 2;
539 else if ( topo==1 ) {
543 else if ( topo==2 ) {
544 if ( cutUtils::MuonECALPIDCut(candidate) )
return 1;
560 if (systId == SystId::kPileUp){
561 if (branch == 1)
return false;
579 if (!track)
return false;
596 if (!trueTrack)
return false;
613 if(systId == SystId::kTpcClusterEff){
616 if (!tpcTrack)
return false;
617 if (tpcTrack->
NNodes != 17 && tpcTrack->
NNodes != 18)
return false;
619 if(systId == SystId::kChargeIDEff){
620 if (track != cc4pibox.
MainTrack)
return false;
622 if(systId == SystId::kTpcFgdMatchEff){
623 if (track != cc4pibox.
MainTrack)
return false;
625 if(systId == SystId::kECalPID){
626 if (branch==1)
return false;
627 else {
if (track != cc4pibox.
MainTrack)
return false; }
645 if(systId == SystId::kTpcTrackEff){
648 if (branch>1 && branch<4)
return false;
652 if(systId == SystId::kECalTrackEff){
659 if(systId == SystId::kTpcP0dMatchEff){
665 if(systId == SystId::kTpcECalMatchEff){
671 if(systId == SystId::kFgdECalMatchEff){
687 (void)PreviousToyBoxB;
bool Apply(AnaEventC &event, ToyBoxB &box) const
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.
AnaTrueVertexB * TrueVertex
bool Apply(AnaEventC &event, ToyBoxB &box) const
bool CheckRedoSelection(const AnaEventC &event, const ToyBoxB &PreviousToyBox, Int_t &redoFromStep)
void SetPreSelectionAccumLevel(Int_t presel)
Set the pre-selection accum level.
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.
Float_t Position[4]
The identified position of the global vertex.
bool Apply(AnaEventC &event, ToyBoxB &box) const
Int_t NNodes
The number of nodes in the reconstructed object.
bool Apply(AnaEventC &event, ToyBoxB &box) const
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
AnaTrueVertexB * TrueVertex
For storing the true vertex, for analyses with no reconstructed primary vertex.
bool Apply(AnaEventC &event, ToyBoxB &box) const
void AddSplit(UInt_t nbranches, Int_t b0=-1, Int_t b1=-1, Int_t b2=-1, Int_t b3=-1, Int_t b4=-1, Int_t b5=-1, Int_t b6=-1, Int_t b7=-1)
Add a split in the step sequence. The user should specify the number of branches in this split and th...
Float_t RangeMomentumMuon
Momentum by range calculated with muon hypothesis.
bool TrackUsesDet(const AnaTrackB &track, SubDetId::SubDetEnum det)
bool Apply(AnaEventC &event, ToyBoxB &box) const
Float_t Charge
The reconstructed charge of the particle.
bool Apply(AnaEventC &event, ToyBoxB &box) const
Int_t ID
The ID of the trueObj, which corresponds to the ID of the TTruthParticle that created it...
void DefineSteps()
Define all steps in the selection.
bool Apply(AnaEventC &event, ToyBoxB &box) const
bool Apply(AnaEventC &event, ToyBoxB &box) const
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 ------------—— ...
Float_t Momentum
The reconstructed momentum of the particle, at the start position.
AnaVertexB * Vertex
For storing the reconstructed vertex.
int nTPCSegments
How many TPC tracks are associated with this track.
Representation of a true Monte Carlo trajectory/particle.
bool Apply(AnaEventC &event, ToyBoxB &box) const
bool Apply(AnaEventC &event, ToyBoxB &box) const
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.
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.
bool Apply(AnaEventC &event, ToyBoxB &box) const
bool Apply(AnaEventC &event, ToyBoxB &box) const
Representation of a TPC segment of a global track.
AnaParticleB ** Particles
bool Apply(AnaEventC &event, ToyBoxB &box) const
AnaTrackB * MainTrack
For storing tracks information in the bunch.
Representation of a global vertex.
void DefineDetectorFV()
Define the detector Fiducial Volume in which this selection is applied.
AnaEventSummaryC * Summary
A summary of the event with high level quantities.
Representation of a FGD segment of a global track.
void SetBranchAlias(Int_t ID, const std::string &name, Int_t b0=-1, Int_t b1=-1, Int_t b2=-1, Int_t b3=-1, Int_t b4=-1, Int_t b5=-1, Int_t b6=-1, Int_t b7=-1)
Set the branch alias and unique ID provided the branch sequence.
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...
void SetDetectorFV(SubDetId_h det, Int_t ibranch=-1)
Set the detector in which the Fiducial Volume is defined.
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...
bool Apply(AnaEventC &event, ToyBoxB &box) const
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
SubDetId_h GetDetectorFV(Int_t ibranch=0) const
Get the detector in which the Fiducial Volume is defined.
AnaFGDParticleB * FGDSegments[NMAXFGDS]
The FGD segments that contributed to this global track.
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) ...
A cut on event quality. Requires good beam and ND280 data quality flags.
bool Apply(AnaEventC &event, ToyBoxB &box) const
void AddStep(StepBase::TypeEnum type, const std::string &title, StepBase *step, bool cut_break=false)
Float_t PositionEnd[4]
The reconstructed end position of the particle.
bool Apply(AnaEventC &event, ToyBoxB &box) const