1212// / \file identifiedBfFilter.cxx
1313// / \brief Filters collisions and tracks according to selection criteria
141415+
1516#include " PWGCF/TwoParticleCorrelations/TableProducer/identifiedBfFilter.h"
1617
1718#include < cmath>
@@ -156,8 +157,8 @@ TH2F* fhCompatibleCollisionsZVtxRms = nullptr;
156157TH2S* fhTruePIDMismatch = nullptr ;
157158TH1S* fhTruePIDCorrect = nullptr ;
158159
159- TH2F* fhTrueNSigmaTPC[ kIdBfNoOfSpecies ] = {nullptr };
160- TH2F* fhTrueNSigmaTOF[ kIdBfNoOfSpecies ] = {nullptr };
160+ std::vector<std::vector< TH2F*>> fhTrueNSigmaTPC = {o2::analysis::identifiedbffilter:: kIdBfNoOfSpecies , {o2::analysis::identifiedbffilter:: kIdBfNoOfSpecies , nullptr } };
161+ std::vector<std::vector< TH2F*>> fhTrueNSigmaTOF = {o2::analysis::identifiedbffilter:: kIdBfNoOfSpecies , {o2::analysis::identifiedbffilter:: kIdBfNoOfSpecies , nullptr } };
161162
162163TH1F* fhTrueCentMultB = nullptr ;
163164TH1F* fhTrueCentMultA = nullptr ;
@@ -1025,16 +1026,18 @@ struct IdentifiedBfFilterTracks {
10251026 79 , -39.5 , 39.5 );
10261027 }
10271028
1028- for (int sp = 0 ; sp < kIdBfNoOfSpecies ; ++sp) {
1029- fhTrueNSigmaTPC[sp] = new TH2F (TString::Format (" fhTrueNSigmaTPC_%s" , speciesName[sp]).Data (),
1030- TString::Format (" N #sigma from TPC vs P for generated %s;N #sigma;p (GeV/c)" , speciesTitle[sp]).Data (),
1031- 48 , -6 , 6 ,
1032- ptbins, ptlow, ptup);
1033-
1034- fhTrueNSigmaTOF[sp] = new TH2F (TString::Format (" fhTrueNSigmaTOF_%s" , speciesName[sp]).Data (),
1035- TString::Format (" N #sigma from TOF vs P for generated %s;N #sigma;p (GeV/c)" , speciesTitle[sp]).Data (),
1036- 48 , -6 , 6 ,
1037- ptbins, ptlow, ptup);
1029+ for (int sp1 = 0 ; sp1 < kIdBfNoOfSpecies ; ++sp1) {
1030+ for (int sp2 = 0 ; sp2 < kIdBfNoOfSpecies ; ++sp2) {
1031+ fhTrueNSigmaTPC[sp1][sp2] = new TH2F (TString::Format (" fhTrueNSigmaTPC%s_%s" , speciesName[sp1], speciesName[sp2]).Data (),
1032+ TString::Format (" N #sigma %s from TPC vs P for generated %s;N #sigma;p (GeV/c)" , speciesTitle[sp1], speciesTitle[sp2]).Data (),
1033+ 48 , -6 , 6 ,
1034+ ptbins, ptlow, ptup);
1035+
1036+ fhTrueNSigmaTOF[sp1][sp2] = new TH2F (TString::Format (" fhTrueNSigmaTOF%s_%s" , speciesName[sp1], speciesName[sp2]).Data (),
1037+ TString::Format (" N #sigma %s from TOF vs P for generated %s;N #sigma;p (GeV/c)" , speciesTitle[sp1], speciesTitle[sp2]).Data (),
1038+ 48 , -6 , 6 ,
1039+ ptbins, ptlow, ptup);
1040+ }
10381041 }
10391042
10401043 /* add the hstograms to the output list */
@@ -1073,9 +1076,11 @@ struct IdentifiedBfFilterTracks {
10731076 fOutputList ->Add (fhTrueNPosNegA[sp]);
10741077 fOutputList ->Add (fhTrueDeltaNA[sp]);
10751078 }
1076- for (int sp = 0 ; sp < kIdBfNoOfSpecies ; ++sp) {
1077- fOutputList ->Add (fhTrueNSigmaTPC[sp]);
1078- fOutputList ->Add (fhTrueNSigmaTOF[sp]);
1079+ for (int sp1 = 0 ; sp1 < kIdBfNoOfSpecies ; ++sp1) {
1080+ for (int sp2 = 0 ; sp2 < kIdBfNoOfSpecies ; ++sp2) {
1081+ fOutputList ->Add (fhTrueNSigmaTPC[sp1][sp2]);
1082+ fOutputList ->Add (fhTrueNSigmaTOF[sp1][sp2]);
1083+ }
10791084 }
10801085 }
10811086 /* initialize access to the CCDB */
@@ -1090,7 +1095,9 @@ struct IdentifiedBfFilterTracks {
10901095 template <typename CollisionObjects, typename TrackObject>
10911096 int8_t selectTrackAmbiguousCheck (CollisionObjects const & collisions, TrackObject const & track);
10921097 template <typename ParticleObject>
1093- inline void identifyPIDMismatch (ParticleObject const & particle, MatchRecoGenSpecies const & trkId, float tpcNSigma[kIdBfNoOfSpecies ], float tofNSigma[kIdBfNoOfSpecies ], float tpcInnerParam);
1098+ inline void identifyPIDMismatch (ParticleObject const & particle, MatchRecoGenSpecies const & trkId);
1099+ template <typename ParticleObject>
1100+ inline void identifyRealNSigma (ParticleObject const & particle, std::vector<float > tpcNSigma, std::vector<float > tofNSigma, float tpcInnerParam);
10941101 template <typename ParticleObject>
10951102 inline MatchRecoGenSpecies identifyParticle (ParticleObject const & particle);
10961103 template <typename TrackObject>
@@ -1338,7 +1345,7 @@ inline MatchRecoGenSpecies IdentifiedBfFilterTracks::identifyParticle(ParticleOb
13381345}
13391346
13401347template <typename ParticleObject>
1341- inline void IdentifiedBfFilterTracks::identifyPIDMismatch (ParticleObject const & particle, MatchRecoGenSpecies const & trkId, float tpcNSigma[ kIdBfNoOfSpecies ], float tofNSigma[ kIdBfNoOfSpecies ], float tpcInnerParam )
1348+ inline void IdentifiedBfFilterTracks::identifyPIDMismatch (ParticleObject const & particle, MatchRecoGenSpecies const & trkId)
13421349{
13431350 MatchRecoGenSpecies realPID = kWrongSpecies ;
13441351 int pdgcode = std::fabs (particle.pdgCode ());
@@ -1369,11 +1376,44 @@ inline void IdentifiedBfFilterTracks::identifyPIDMismatch(ParticleObject const&
13691376 } else {
13701377 fhTruePIDMismatch->Fill (realPID, trkId);
13711378 }
1379+ }
1380+ }
13721381
1373- fhTrueNSigmaTPC[realPID]->Fill (tpcNSigma[realPID], tpcInnerParam);
1374- fhTrueNSigmaTOF[realPID]->Fill (tofNSigma[realPID], tpcInnerParam);
1382+ template <typename ParticleObject>
1383+ inline void IdentifiedBfFilterTracks::identifyRealNSigma (ParticleObject const & particle, std::vector<float > tpcNSigma, std::vector<float > tofNSigma, float tpcInnerParam)
1384+ {
13751385
1376- // fill histo based on realTPC and tpcNSigma value for center align
1386+ MatchRecoGenSpecies realPID = kWrongSpecies ;
1387+ int pdgcode = std::fabs (particle.pdgCode ());
1388+ switch (pdgcode) {
1389+ case pdgcodeEl:
1390+ realPID = kIdBfElectron ;
1391+ break ;
1392+ case pdgcodePi:
1393+ realPID = kIdBfPion ;
1394+ break ;
1395+ case pdgcodeKa:
1396+ realPID = kIdBfKaon ;
1397+ break ;
1398+ case pdgcodePr:
1399+ realPID = kIdBfProton ;
1400+ break ;
1401+ default :
1402+ if (traceOutOfSpeciesParticles) {
1403+ LOGF (info, " Wrong particle passed selection cuts. PDG code: %d" , pdgcode);
1404+ }
1405+ realPID = kWrongSpecies ;
1406+ break ;
1407+ }
1408+ if (!(realPID < 0 )) {
1409+ fhTrueNSigmaTPC[kIdBfElectron ][realPID]->Fill (tpcNSigma[kIdBfElectron ], tpcInnerParam);
1410+ fhTrueNSigmaTOF[kIdBfElectron ][realPID]->Fill (tofNSigma[kIdBfElectron ], tpcInnerParam);
1411+ fhTrueNSigmaTPC[kIdBfPion ][realPID]->Fill (tpcNSigma[kIdBfPion ], tpcInnerParam);
1412+ fhTrueNSigmaTOF[kIdBfPion ][realPID]->Fill (tofNSigma[kIdBfPion ], tpcInnerParam);
1413+ fhTrueNSigmaTPC[kIdBfKaon ][realPID]->Fill (tpcNSigma[kIdBfKaon ], tpcInnerParam);
1414+ fhTrueNSigmaTOF[kIdBfKaon ][realPID]->Fill (tofNSigma[kIdBfKaon ], tpcInnerParam);
1415+ fhTrueNSigmaTPC[kIdBfProton ][realPID]->Fill (tpcNSigma[kIdBfProton ], tpcInnerParam);
1416+ fhTrueNSigmaTOF[kIdBfProton ][realPID]->Fill (tofNSigma[kIdBfProton ], tpcInnerParam);
13771417 }
13781418}
13791419
@@ -1409,8 +1449,8 @@ void fillNSigmaHistos(TrackObject const& track)
14091449
14101450 fhNSigmaTOF[kIdBfElectron ]->Fill (actualTOFNSigma[kIdBfElectron ], track.tpcInnerParam ());
14111451 fhNSigmaTOF[kIdBfPion ]->Fill (actualTOFNSigma[kIdBfPion ], track.tpcInnerParam ());
1412- fhNSigmaTOF[kIdBfKaon ]->Fill (track. tofNSigmaKa () , track.tpcInnerParam ());
1413- fhNSigmaTOF[kIdBfProton ]->Fill (track. tofNSigmaPr () , track.tpcInnerParam ());
1452+ fhNSigmaTOF[kIdBfKaon ]->Fill (actualTOFNSigma[ kIdBfKaon ] , track.tpcInnerParam ());
1453+ fhNSigmaTOF[kIdBfProton ]->Fill (actualTOFNSigma[ kIdBfProton ] , track.tpcInnerParam ());
14141454
14151455 fhNSigmaCombo[kIdBfElectron ]->Fill (sqrtf (actualTOFNSigma[kIdBfElectron ] * actualTOFNSigma[kIdBfElectron ] + actualTPCNSigma[kIdBfElectron ] * actualTPCNSigma[kIdBfElectron ]), track.tpcInnerParam ());
14161456 fhNSigmaCombo[kIdBfPion ]->Fill (sqrtf (actualTOFNSigma[kIdBfPion ] * actualTOFNSigma[kIdBfPion ] + actualTPCNSigma[kIdBfPion ] * actualTPCNSigma[kIdBfPion ]), track.tpcInnerParam ());
@@ -1429,14 +1469,14 @@ inline MatchRecoGenSpecies IdentifiedBfFilterTracks::identifyTrack(TrackObject c
14291469
14301470 fillNSigmaHistos (track);
14311471
1432- float actualTPCNSigma[ kIdBfNoOfSpecies ] ;
1472+ std::vector< float > actualTPCNSigma ( kIdBfNoOfSpecies , 0 .) ;
14331473
14341474 actualTPCNSigma[kIdBfElectron ] = track.tpcNSigmaEl ();
14351475 actualTPCNSigma[kIdBfPion ] = track.tpcNSigmaPi ();
14361476 actualTPCNSigma[kIdBfKaon ] = track.tpcNSigmaKa ();
14371477 actualTPCNSigma[kIdBfProton ] = track.tpcNSigmaPr ();
14381478
1439- float actualTOFNSigma[ kIdBfNoOfSpecies ] ;
1479+ std::vector< float > actualTOFNSigma ( kIdBfNoOfSpecies , 0 .) ;
14401480
14411481 actualTOFNSigma[kIdBfElectron ] = track.tofNSigmaEl ();
14421482 actualTOFNSigma[kIdBfPion ] = track.tofNSigmaPi ();
@@ -1445,6 +1485,10 @@ inline MatchRecoGenSpecies IdentifiedBfFilterTracks::identifyTrack(TrackObject c
14451485
14461486 float nsigmas[kIdBfNoOfSpecies ];
14471487
1488+ if constexpr (framework::has_type_v<aod::mctracklabel::McParticleId, typename TrackObject::all_columns>) {
1489+ identifyRealNSigma (track.template mcParticle_as <aod::McParticles>(), actualTPCNSigma, actualTOFNSigma, track.tpcInnerParam ());
1490+ }
1491+
14481492 if (loadfromccdb) {
14491493 for (int iSp = 0 ; iSp < kIdBfNoOfSpecies ; iSp++) {
14501494 actualTPCNSigma[iSp] = actualTPCNSigma[iSp] - fhNSigmaCorrection[iSp]->GetBinContent (fhNSigmaCorrection[iSp]->FindBin (track.tpcInnerParam ()));
@@ -1519,7 +1563,7 @@ inline MatchRecoGenSpecies IdentifiedBfFilterTracks::identifyTrack(TrackObject c
15191563 fhNSigmaTPCIdTrks[spMinNSigma]->Fill (actualTPCNSigma[spMinNSigma], track.tpcInnerParam ());
15201564
15211565 if constexpr (framework::has_type_v<aod::mctracklabel::McParticleId, typename TrackObject::all_columns>) {
1522- identifyPIDMismatch (track.template mcParticle_as <aod::McParticles>(), spMinNSigma, actualTPCNSigma, actualTOFNSigma, track. tpcInnerParam () );
1566+ identifyPIDMismatch (track.template mcParticle_as <aod::McParticles>(), spMinNSigma);
15231567 }
15241568 return spMinNSigma;
15251569 }
0 commit comments