1 #include "antiNumuCCMultiPiSelection.hxx" 2 #include "antiNumuCCSelection.hxx" 3 #include "baseSelection.hxx" 4 #include "CutUtils.hxx" 5 #include "EventBoxUtils.hxx" 6 #include "SubDetId.hxx" 8 #include "VersioningUtils.hxx" 9 #include "SystematicUtils.hxx" 10 #include "SystematicTuning.hxx" 14 antiNumuCCMultiPiSelection::antiNumuCCMultiPiSelection(
bool forceBreak):
SelectionBase(forceBreak,
EventBoxId::kEventBoxTracker) {
24 CopySteps(_antiNumuCCSelection);
47 SetBranchAlias(0,
"CC-0pi", 0);
48 SetBranchAlias(1,
"CC-1pi", 1);
49 SetBranchAlias(2,
"CC-Other",2);
52 SetPreSelectionAccumLevel(2);
55 _MuonPIDCutIndex = GetCutNumber(
"muon PID");
56 _FindPionsStepIndex = GetStepNumber(
"find_pions");
65 SetDetectorFV(SubDetId::kFGD1);
69 bool antiNumuCCMultiPiSelection::FillEventSummary(
AnaEventC& event, Int_t allCutsPassed[]){
75 static_cast<AnaEventSummaryB*
>(
event.Summary)->EventSample = SampleId::kFGD1AntiNuMuCC0Pi;
78 else if (allCutsPassed[1]){
79 static_cast<AnaEventSummaryB*
>(
event.Summary)->EventSample = SampleId::kFGD1AntiNuMuCC1Pi;
82 else if (allCutsPassed[2]){
83 static_cast<AnaEventSummaryB*
>(
event.Summary)->EventSample = SampleId::kFGD1AntiNuMuCCOther;
87 return (static_cast<AnaEventSummaryB*>(event.
Summary)->EventSample != SampleId::kUnassigned);
101 static_cast<AnaEventSummaryB*>(event.
Summary)->LeptonCandidate[SampleId::kFGD1AntiNuMuCC1Pi] = box.
HMPtrack;
104 for(
int i = 0; i < 4; ++i){
126 if (useTPCPions) antinumuCCMultiPiUtils::FindTPCPions(event, box, det, useOldSecondaryPID);
127 if (useME) antinumuCCMultiPiUtils::FindMEPions(event,det, prod5Cut);
128 if (useFGDPions) antinumuCCMultiPiUtils::FindIsoFGDPions(event, box, det);
130 int nnegpions = ccmultipibox->nNegativePionTPCtracks;
131 int npospions = ccmultipibox->nPositivePionTPCtracks;
132 int nisofgdpions = ccmultipibox->nIsoFGDPiontracks;
133 int nmichelelectrons = EventBox->nFGDMichelElectrons[det];
134 int npi0 = ccmultipibox->nPosPi0TPCtracks + ccmultipibox->nElPi0TPCtracks;
137 if (!nmichelelectrons && nisofgdpions>0) pionFGD = 1;
143 ccmultipibox->nPosPions = npospions + nmichelelectrons;
144 ccmultipibox->nNegPions = nnegpions + pionFGD;
145 ccmultipibox->nOtherPions = ccmultipibox->nPosPions+npi0;
159 EventBoxTracker::RecObjectGroupEnum groupID;
160 groupID = EventBoxTracker::kTracksWithECal;
161 EventBoxB* EventBox =
event.EventBoxes[EventBoxId::kEventBoxTracker];
164 double higherEnergyObject = 0;
168 AnaTrackB *allECALObjects =
static_cast<AnaTrackB*
>(EventBox->RecObjectsInGroup[groupID][i]);
180 ccmultipibox->ISOEcal.push_back(
object);
183 if(ecalBase->
EMEnergy > higherEnergyObject){
184 higherEnergyObject = ecalBase->
EMEnergy;
185 highestObject = object;
191 ccmultipibox->HObject = highestObject;
193 if( antinumuCCMultiPiUtils::ECALPi0Selection(event, box, highestObject, MostUpstreamLayerHitCut, det) ) {
194 ccmultipibox->Pi0Ecaltrack = highestObject;
195 ccmultipibox->nPi0Ecaltracks = ccmultipibox->nPi0Ecaltracks+1;
210 if( ccmultipibox->nNegPions + ccmultipibox->nOtherPions == 0 )
return true;
224 if( ccmultipibox->nOtherPions != 0 )
return false;
225 if( ccmultipibox->nNegPions == 1 )
return true;
239 if( ccmultipibox->nOtherPions != 0 )
return true;
240 if( ccmultipibox->nNegPions > 1 )
return true;
241 if( ccmultipibox->nPi0Ecaltracks > 0)
return true;
252 ccmultipibox->nPositivePionTPCtracks = 0;
253 ccmultipibox->nPosPi0TPCtracks = 0;
254 ccmultipibox->nNegativePionTPCtracks = 0;
255 ccmultipibox->nElPi0TPCtracks = 0;
257 EventBoxTracker::RecObjectGroupEnum groupID;
258 if (det==SubDetId::kFGD1) groupID = EventBoxTracker::kTracksWithGoodQualityTPCInFGD1FV;
259 else if (det==SubDetId::kFGD2) groupID = EventBoxTracker::kTracksWithGoodQualityTPCInFGD2FV;
262 EventBoxB* EventBox =
event.EventBoxes[EventBoxId::kEventBoxTracker];
269 if( ccmultipibox->
HMPtrack == ptrack )
continue;
271 if(useOldSecondaryPID){
272 if ( antinumuCCMultiPiUtils::TPCpionSelection(ptrack) ) {
273 ccmultipibox->PositivePionTPCtracks[ccmultipibox->nPositivePionTPCtracks] = ptrack;
274 ccmultipibox->nPositivePionTPCtracks++;
276 else if ( antinumuCCMultiPiUtils::TPCElPi0Selection(ptrack) ) {
277 ccmultipibox->PosPi0TPCtracks[ccmultipibox->nPosPi0TPCtracks] = ptrack;
278 ccmultipibox->nPosPi0TPCtracks++;
282 Float_t PIDLikelihood[4];
286 double ElLklh = PIDLikelihood[1];
287 double ProtonLklh = PIDLikelihood[2];
288 double PionLklh = PIDLikelihood[3];
289 double norm = ElLklh+ProtonLklh+PionLklh;
294 if( ProtonLklh > ElLklh && ProtonLklh > PionLklh )
continue;
297 if( PionLklh > ElLklh ){
298 ccmultipibox->PositivePionTPCtracks[ccmultipibox->nPositivePionTPCtracks] = ptrack;
299 ccmultipibox->nPositivePionTPCtracks++;
302 if( ptrack->
Momentum > 900. )
continue;
303 ccmultipibox->PosPi0TPCtracks[ccmultipibox->nPosPi0TPCtracks] = ptrack;
304 ccmultipibox->nPosPi0TPCtracks++;
311 if(useOldSecondaryPID) {
312 if ( antinumuCCMultiPiUtils::TPCpionSelection(ptrack) ) {
313 ccmultipibox->NegativePionTPCtracks[ccmultipibox->nNegativePionTPCtracks] = ptrack;
314 ccmultipibox->nNegativePionTPCtracks++;
316 else if ( antinumuCCMultiPiUtils::TPCElPi0Selection(ptrack) ) {
317 ccmultipibox->ElPi0TPCtracks[ccmultipibox->nElPi0TPCtracks] = ptrack;
318 ccmultipibox->nElPi0TPCtracks++;
323 Float_t PIDLikelihood[4];
327 double ElLklh = PIDLikelihood[1];
328 double PionLklh = PIDLikelihood[3];
329 double norm = ElLklh+PionLklh;
333 if( PionLklh > 0.8 ){
334 ccmultipibox->NegativePionTPCtracks[ccmultipibox->nNegativePionTPCtracks] = ptrack;
335 ccmultipibox->nNegativePionTPCtracks++;
338 ccmultipibox->ElPi0TPCtracks[ccmultipibox->nElPi0TPCtracks] = ptrack;
339 ccmultipibox->nElPi0TPCtracks++;
352 ccmultipibox->nIsoFGDPiontracks = 0;
353 ccmultipibox->nIsoFGDElPi0tracks = 0;
355 EventBoxTracker::RecObjectGroupEnum groupID;
356 if (det==SubDetId::kFGD1) groupID = EventBoxTracker::kTracksWithFGD1AndNoTPC;
357 else if (det==SubDetId::kFGD2) groupID = EventBoxTracker::kTracksWithFGD2AndNoTPC;
360 EventBoxB* EventBox =
event.EventBoxes[EventBoxId::kEventBoxTracker];
366 if( antinumuCCMultiPiUtils::FGDpionSelection(track,det) ){
367 ccmultipibox->IsoFGDPiontracks[ccmultipibox->nIsoFGDPiontracks] = track;
368 ccmultipibox->nIsoFGDPiontracks++;
370 else if( antinumuCCMultiPiUtils::FGDElPi0Selection(event,box,track,det) ){
371 ccmultipibox->IsoFGDElPi0tracks[ccmultipibox->nIsoFGDElPi0tracks] = track;
372 ccmultipibox->nIsoFGDElPi0tracks++;
390 anaUtils::ResizeArray(EventBox->
FGDMichelElectrons[det], EventBox->nFGDMichelElectrons[det]);
395 bool antinumuCCMultiPiUtils::TPCpionSelection(
AnaTrackB *track){
398 Float_t PIDLikelihood[4];
401 if ( PIDLikelihood[3] < 0.3 )
return false;
403 double cut1 = (PIDLikelihood[0]+PIDLikelihood[3])/(1.-PIDLikelihood[2]);
405 if( track->
Momentum < 500. && cut1 < 0.8 )
return false;
412 bool antinumuCCMultiPiUtils::TPCElPi0Selection(
AnaTrackB *track){
417 bool seltrack =
false;
421 if( track->
Momentum < 50. )
return seltrack;
431 if( !tpcTrack )
continue;
436 if (TMath::Abs(pulls[0]) > 1.e+6
437 || TMath::Abs(pulls[1]) > 1.e+6
438 || TMath::Abs(pulls[2]) > 1.e+6
439 || TMath::Abs(pulls[3]) > 1.e+6)
continue;
441 if( pulls[1] < -2.0 || pulls[1] > 2.0 )
break;
443 if( track->
Charge > 0. && ( pulls[2] > -4.0 && pulls[2] < 8.0 ) )
break;
458 if( !fgdTrack )
return false;
460 if( TMath::Abs(fgdTrack->
Pullp) > 1.e+6 || TMath::Abs(fgdTrack->
Pullmu) > 1.e+6 || TMath::Abs(fgdTrack->
Pullpi) > 1.e+6 )
return false;
465 if( fgdTrack->
Pullno == 1 )
return false;
471 if ( det == SubDetId::kFGD1 && fgdTrack->
Containment != 1 )
return false;
472 else if( det == SubDetId::kFGD2 && fgdTrack->
Containment != 2 )
return false;
477 if(cosFGDpion > -0.3 && cosFGDpion < 0.3)
return false;
479 if( fgdTrack->
Pullpi < 2.5 && fgdTrack->
Pullpi > -2.0 )
return true;
498 if( !fgdTrack )
return false;
500 if( TMath::Abs(fgdTrack->
Pullp) > 1.e+6 || TMath::Abs(fgdTrack->
Pullmu) > 1.e+6 || TMath::Abs(fgdTrack->
Pullpi) > 1.e+6 )
return false;
505 if( fgdTrack->
Pullno == 1 )
return false;
511 if ( det == SubDetId::kFGD1 && fgdTrack->
Containment != 1 )
return false;
512 else if( det == SubDetId::kFGD2 && fgdTrack->
Containment != 2 )
return false;
517 if(EventBox->nFGDMichelElectrons[det] > 0 && fgdTrack->
Pullpi < -3.0 )
return true;
518 if(EventBox->nFGDMichelElectrons[det] == 0 && fgdTrack->
Pullpi < -1.5 )
return true;
537 bool Ecalpi0 =
false;
539 double EMENERGY = -9999.;
540 double MIPEM = -9999.;
541 double EM_UPSTREAM = -9999;
543 if( !EcalSegment )
return false;
549 if (EMENERGY > 30. && MIPEM > 0.) Ecalpi0 =
true;
555 if(EM_UPSTREAM > MostUpstreamLayerHitCut ) Ecalpi0 =
false;
566 return _antiNumuCCSelection.IsRelevantRecObjectForSystematic(event,track,systId,branch);
573 return _antiNumuCCSelection.IsRelevantTrueObjectForSystematic(event,trueTrack,systId,branch);
585 case SystId::kFgdTrackEff:
return false;
588 default:
return true;
596 _antiNumuCCSelection.InitializeEvent(event);
604 if( _antiNumuCCSelection.CheckRedoSelection(event,PreviousToyBox,redoFromStep))
return true;
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 IsRelevantSystematic(const AnaEventC &event, const ToyBoxB &box, SystId_h systId, Int_t branch) const
Is this systematic relevant for this selection.
int GetFGDMichelElectrons(const AnaEventB &event, const SubDetId::SubDetEnum det, AnaFgdTimeBinB **arr, bool prod5Cut=0)
Get all delayed time bins as Michel Electron candidates.
AnaECALParticleB * ECALSegments[NMAXECALS]
The ECAL segments that contributed to this global track.
int nECALSegments
How many ECAL tracks are associated with this track.
Float_t Pullp
Proton pull, according to FGD information.
Float_t Pullno
Dummy pull. If the FGD pulls weren't set, this is set to 1.
SubDetId_h DetectorFV
Indicate the FV we are interested in.
void InitializeEvent(AnaEventC &event)
Fill the EventBox with the objects needed by this selection.
Representation of an ECAL segment of a global track.
Float_t Pullpi
Pion pull, according to FGD information.
AnaTPCParticleB * TPCSegments[NMAXTPCS]
The TPC segments that contributed to this global track.
bool Apply(AnaEventC &event, ToyBoxB &box) const
AnaTrackB * HMPtrack
For storing the highest momentum positive track.
void DefineSteps()
Define all steps in the selection.
Float_t Pullmu
Muon pull, according to FGD information.
Float_t Charge
The reconstructed charge of the particle.
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.
int nTPCSegments
How many TPC tracks are associated with this track.
bool CheckRedoSelection(const AnaEventC &event, const ToyBoxB &PreviousToyBox, Int_t &redoFromStep)
SubDetEnum
Enumeration of all detector systems and subdetectors.
AnaFgdTimeBinB ** FGDMichelElectrons[2]
----------— Michel Electron candidates -------------------------------—
Representation of a global track.
Float_t ComputeTPCPull(const AnaTPCParticleB &track, const std::string &particle)
Function to recompute the pull for a TPC track segment.
Representation of a TPC segment of a global track.
bool APPLY_SYST_FINE_TUNING
General tuning, the concept of apply the systematic for only the "relevant" objects.
Float_t DirectionStart[3]
The reconstructed start direction of the particle.
AnaEventSummaryC * Summary
A summary of the event with high level quantities.
Representation of a FGD segment of a global track.
void DefineDetectorFV()
Define the detector Fiducial Volume in which this selection is applied.
bool Apply(AnaEventC &event, ToyBoxB &box) const
int nFGDSegments
How many FGD tracks are associated with this track.
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 Containment
Containment flag required for proper PID analysis.
Int_t MostUpStreamLayerHit
Innermost layer hit of the ecal object (used in ecal pi0 veto)
bool Apply(AnaEventC &event, ToyBoxB &box) const
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...
AnaTrueParticleB * GetTrueParticle() const
Return a casted version of the AnaTrueObject associated.
bool Apply(AnaEventC &event, ToyBoxB &box) const
bool TrackUsesOnlyDet(const AnaTrackB &track, SubDetId::SubDetEnum det)
AnaFGDParticleB * FGDSegments[NMAXFGDS]
The FGD segments that contributed to this global track.