@@ -78,6 +78,8 @@ std::array<std::shared_ptr<TH2>, NpCharge> hDecayLengthMCNotHF; // Decay Length
7878
7979std::array<std::shared_ptr<TH2>, NpCharge> hPtNumTOFMatchWithPIDSignalPrm; // Pt distribution of particles with a hit in the TOF and a compatible signal
8080
81+ std::array<std::array<std::shared_ptr<TH3>, NpCharge>, 3 > hMCpdg_nsigmaTPC; // 2D array of nsigmaTPC histograms [Selection: pi,K,p][True PDG: 18 species]
82+
8183// Spectra task
8284struct tofSpectra {
8385 struct : ConfigurableGroup {
@@ -585,6 +587,14 @@ struct tofSpectra {
585587 histos.add (" MC/MultiplicityMCINELgt0" , " MC multiplicity" , kTH1D , {multAxis});
586588 histos.add (" MC/MultiplicityMCINELgt1" , " MC multiplicity" , kTH1D , {multAxis});
587589 }
590+
591+ if (doprocessTrackMCLabels){
592+ for (int par = 2 ; par <= 4 ; par++){
593+ for (int i = 0 ; i < NpCharge; i++){
594+ hMCpdg_nsigmaTPC[par-2 ][i] = histos.add <TH3>(Form (" test_mclabels/nsigmatpc/%s/%s/pdg_%i" , (i < Np) ? " pos" : " neg" , pN[par], PDGs[i%Np]), Form (" True %s (%i) in %s selection" , pTCharge[i], PDGs[i], (i < Np) ? pTCharge[par] : pTCharge[par+Np]), kTH3D , {ptAxis, nsigmaTPCAxisOccupancy, multAxis});
595+ }
596+ }
597+ }
588598
589599 hMultiplicityvsPercentile = histos.add <TH2>(" Mult/vsPercentile" , " Multiplicity vs percentile" , HistType::kTH2D , {{150 , 0 , 150 }, {100 , 0 , 100 , " Track multiplicity" }});
590600
@@ -2785,6 +2795,47 @@ struct tofSpectra {
27852795 }
27862796 }
27872797 PROCESS_SWITCH (tofSpectra, processMCgen_RecoEvs, " process generated MC (reconstructed events)" , false );
2798+
2799+ void processTrackMCLabels (CollisionCandidates::iterator const & collisions,
2800+ soa::Join<TrackCandidates,
2801+ aod::pidTPCFullPi, aod::pidTPCFullKa, aod::pidTPCFullPr,
2802+ aod::pidTOFFullPi, aod::pidTOFFullKa, aod::pidTOFFullPr> const & tracks,
2803+ aod::McTrackLabels const & mcTrackLabels, aod::McParticles const & mcParticles)
2804+ {
2805+ const float multiplicity = getMultiplicity (collisions);
2806+
2807+ for (const auto & track : tracks) {
2808+ if (!track.has_collision ()) {
2809+ continue ;
2810+ }
2811+ const auto & collision = track.collision_as <CollisionCandidates>();
2812+ if (!isEventSelected<false , false >(collision)) {
2813+ continue ;
2814+ }
2815+ if (!isTrackSelected<true >(track, collision)) {
2816+ continue ;
2817+ }
2818+ const auto & mcLabel = mcTrackLabels.iteratorAt (track.globalIndex ());
2819+ const auto & mcParticle = mcParticles.iteratorAt (mcLabel.mcParticleId ());
2820+ int pdgCode = mcParticle.pdgCode ();
2821+
2822+ static_for<2 ,4 >([&](auto par){
2823+ const auto & nsigmaTPCpar = o2::aod::pidutils::tpcNSigma<par>(track);
2824+ bool isTPCpar = std::abs (nsigmaTPCpar) < trkselOptions.cfgCutNsigma ;
2825+ // Precompute rapidity values to avoid redundant calculations
2826+ double rapiditypar = std::abs (track.rapidity (PID::getMass (par)));
2827+ // TPC Selection and histogram filling
2828+ if (isTPCpar && rapiditypar <= trkselOptions.cfgCutY ){
2829+ static_for<0 , 17 >([&](auto i){
2830+ if (pdgCode == PDGs[i]){
2831+ hMCpdg_nsigmaTPC[par-2 ][i]->Fill (track.pt (), nsigmaTPCpar, multiplicity);
2832+ }
2833+ });
2834+ }
2835+ });
2836+ }
2837+ }
2838+ PROCESS_SWITCH (tofSpectra, processTrackMCLabels, " Fill track histograms using MC matched PDG labels" , false );
27882839
27892840}; // end of spectra task
27902841
0 commit comments