@@ -69,6 +69,7 @@ struct UccZdc {
6969
7070 static constexpr float kCollEnergy {2.68 };
7171 static constexpr float kZero {0 .};
72+ static constexpr float minCharge{3 .f };
7273
7374 // Configurables Event Selection
7475 Configurable<bool > isNoCollInTimeRangeStrict{" isNoCollInTimeRangeStrict" , true , " use isNoCollInTimeRangeStrict?" };
@@ -819,6 +820,7 @@ struct UccZdc {
819820
820821 // Preslice<aod::McParticles> perMCCollision = aod::mcparticle::mcCollisionId;
821822 Preslice<TheFilteredSimTracks> perCollision = aod::track::collisionId;
823+ Service<o2::framework::O2DatabasePDG> pdg;
822824 TRandom* randPointer = new TRandom();
823825 void processMCclosure (aod::McCollisions::iterator const & mccollision, soa::SmallGroups<o2::aod::SimCollisions> const & collisions, o2::aod::BCsRun3 const & /* bcs*/ , aod::FT0s const & /* ft0s*/ , aod::McParticles const & mcParticles, TheFilteredSimTracks const & simTracks)
824826 {
@@ -879,9 +881,10 @@ struct UccZdc {
879881 return ;
880882 }
881883
882- std::vector<float > pTs;
883- std::vector<float > vecFD;
884- std::vector<float > vecOneOverEff;
884+ std::vector<double > pTs;
885+ std::vector<double > vecFD;
886+ std::vector<double > vecEff;
887+ std::vector<double > vecOneOverEffXFD;
885888 // std::vector<float> wIs;
886889 const auto & groupedTracks{simTracks.sliceBy (perCollision, collision.globalIndex ())};
887890
@@ -901,6 +904,8 @@ struct UccZdc {
901904 }
902905
903906 // Calculates the event weight, W_k
907+ const int foundNchBin{efficiency->GetXaxis ()->FindBin (nchRaw)};
908+
904909 for (const auto & track : groupedTracks) {
905910 // Track Selection
906911 if (track.eta () < minEta || track.eta () > maxEta) {
@@ -912,32 +917,51 @@ struct UccZdc {
912917 if (!track.isGlobalTrack ()) {
913918 continue ;
914919 }
920+ if (!track.has_mcParticle ()) {
921+ continue ;
922+ }
923+ const auto & particle{track.mcParticle ()};
924+
925+ auto charge{0 .};
926+ // Get the MC particle
927+ auto * pdgParticle = pdg->GetParticle (particle.pdgCode ());
928+ if (pdgParticle != nullptr ) {
929+ charge = pdgParticle->Charge ();
930+ } else {
931+ continue ;
932+ }
915933
916- float pt{track.pt ()};
917- int foundNchBin{efficiency->GetXaxis ()->FindBin (nchRaw)};
918- int foundPtBin{efficiency->GetYaxis ()->FindBin (pt)};
919- float effValue{1 .};
920- float fdValue{1 .};
934+ // Is it a charged particle?
935+ if (std::abs (charge) < minCharge) {
936+ continue ;
937+ }
938+ // Is it a primary particle?
939+ // if (!particle.isPhysicalPrimary()) { continue; }
940+
941+ const double pt{static_cast <double >(track.pt ())};
942+ const int foundPtBin{efficiency->GetYaxis ()->FindBin (pt)};
943+ double effValue{1 .};
944+ double fdValue{1 .};
921945
922946 if (applyEff) {
923947 effValue = efficiency->GetBinContent (foundNchBin, foundPtBin);
924948 fdValue = fd->GetBinContent (fd->FindBin (pt));
925949 }
926950 if ((effValue > 0 .) && (fdValue > 0 .)) {
927951 pTs.emplace_back (pt);
928- vecOneOverEff .emplace_back (1 . / effValue);
952+ vecEff .emplace_back (effValue);
929953 vecFD.emplace_back (fdValue);
954+ vecOneOverEffXFD.emplace_back (fdValue / effValue);
930955 }
931956 }
932-
933- nchMult = std::accumulate (vecOneOverEff.begin (), vecOneOverEff.end (), 0 );
957+ nchMult = std::accumulate (vecOneOverEffXFD.begin (), vecOneOverEffXFD.end (), 0 );
934958 if (nchMult < minNchSel) {
935959 return ;
936960 }
937961
938962 double p1, p2, p3, p4, w1, w2, w3, w4;
939963 p1 = p2 = p3 = p4 = w1 = w2 = w3 = w4 = 0.0 ;
940- getPTpowers (pTs, vecOneOverEff , vecFD, p1, w1, p2, w2, p3, w3, p4, w4);
964+ getPTpowers (pTs, vecEff , vecFD, p1, w1, p2, w2, p3, w3, p4, w4);
941965
942966 const double denTwoParCorr{std::pow (w1, 2 .) - w2};
943967 const double numTwoParCorr{std::pow (p1, 2 .) - p2};
@@ -971,6 +995,21 @@ struct UccZdc {
971995 if (particle.pt () < minPt || particle.pt () > maxPt) {
972996 continue ;
973997 }
998+
999+ auto charge{0 .};
1000+ // Get the MC particle
1001+ auto * pdgParticle = pdg->GetParticle (particle.pdgCode ());
1002+ if (pdgParticle != nullptr ) {
1003+ charge = pdgParticle->Charge ();
1004+ } else {
1005+ continue ;
1006+ }
1007+
1008+ // Is it a charged particle?
1009+ if (std::abs (charge) < minCharge) {
1010+ continue ;
1011+ }
1012+ // Is it a primary particle?
9741013 if (!particle.isPhysicalPrimary ()) {
9751014 continue ;
9761015 }
@@ -1044,9 +1083,23 @@ struct UccZdc {
10441083 if (!track.has_mcParticle ()) {
10451084 continue ;
10461085 }
1047- registry.fill (HIST (" Pt_all_ch" ), nchRaw, track.pt ());
1048-
1086+ // Get the MC particle
10491087 const auto & particle{track.mcParticle ()};
1088+ auto charge{0 .};
1089+ auto * pdgParticle = pdg->GetParticle (particle.pdgCode ());
1090+ if (pdgParticle != nullptr ) {
1091+ charge = pdgParticle->Charge ();
1092+ } else {
1093+ continue ;
1094+ }
1095+
1096+ // Is it a charged particle?
1097+ if (std::abs (charge) < minCharge) {
1098+ continue ;
1099+ }
1100+ // All charged particles
1101+ registry.fill (HIST (" Pt_all_ch" ), nchRaw, track.pt ());
1102+ // Is it a primary particle?
10501103 if (!particle.isPhysicalPrimary ()) {
10511104 continue ;
10521105 }
@@ -1075,6 +1128,21 @@ struct UccZdc {
10751128 if (particle.pt () < minPt || particle.pt () > maxPt) {
10761129 continue ;
10771130 }
1131+
1132+ auto charge{0 .};
1133+ // Get the MC particle
1134+ auto * pdgParticle = pdg->GetParticle (particle.pdgCode ());
1135+ if (pdgParticle != nullptr ) {
1136+ charge = pdgParticle->Charge ();
1137+ } else {
1138+ continue ;
1139+ }
1140+
1141+ // Is it a charged particle?
1142+ if (std::abs (charge) < minCharge) {
1143+ continue ;
1144+ }
1145+ // Is it a primary particle?
10781146 if (!particle.isPhysicalPrimary ()) {
10791147 continue ;
10801148 }
@@ -1101,14 +1169,14 @@ struct UccZdc {
11011169 PROCESS_SWITCH (UccZdc, processMCclosure, " Process MC closure" , false );
11021170
11031171 template <typename T, typename U>
1104- void getPTpowers (const T& pTs, const T& vecOneOverEff , const T& vecFD, U& pOne, U& wOne, U& pTwo, U& wTwo, U& pThree, U& wThree, U& pFour, U& wFour)
1172+ void getPTpowers (const T& pTs, const T& vecEff , const T& vecFD, U& pOne, U& wOne, U& pTwo, U& wTwo, U& pThree, U& wThree, U& pFour, U& wFour)
11051173 {
11061174 pOne = wOne = pTwo = wTwo = pThree = wThree = pFour = wFour = 0 .;
11071175 for (std::size_t i = 0 ; i < pTs.size (); ++i) {
1108- const float pTi{pTs.at (i)};
1109- const float eFFi{vecOneOverEff .at (i)};
1110- const float fDi {vecFD.at (i)};
1111- const float wEighti{eFFi * fDi };
1176+ const double pTi{pTs.at (i)};
1177+ const double eFFi{vecEff .at (i)};
1178+ const double fDi {vecFD.at (i)};
1179+ const double wEighti{pow ( eFFi, - 1 .) * fDi };
11121180 pOne += wEighti * pTi;
11131181 wOne += wEighti;
11141182 pTwo += std::pow (wEighti * pTi, 2 .);
0 commit comments