@@ -35,7 +35,7 @@ using namespace o2;
3535using namespace o2 ::framework;
3636using namespace o2 ::framework::expressions;
3737
38- struct LFNucleiDeuteronTask {
38+ struct LFNucleiBATask {
3939 HistogramRegistry histos{" Histos" , {}, OutputObjHandlingPolicy::AnalysisObject};
4040 HistogramRegistry spectraGen{" spectraGen" , {}, OutputObjHandlingPolicy::AnalysisObject, false , true };
4141
@@ -90,17 +90,18 @@ struct LFNucleiDeuteronTask {
9090
9191 // MC histograms
9292 AxisSpec ptAxis = {2000 , 0 .f , 20 .f , " #it{p}_{T} (GeV/#it{c})" };
93- spectraGen .add (" histGenVetxZ" , " PosZ generated events" , HistType::kTH1F , {{2000 , -20 .f , 20 .f , " Vertex Z (cm)" }});
94- spectraGen .add (" histGenPtPion" , " generated particles" , HistType::kTH1F , {ptAxis});
95- spectraGen .add (" histGenPtKaon" , " generated particles" , HistType::kTH1F , {ptAxis});
96- spectraGen .add (" histGenPtProton" , " generated particles" , HistType::kTH1F , {ptAxis});
97- spectraGen .add (" histGenPtD" , " generated particles" , HistType::kTH1F , {ptAxis});
98- spectraGen .add (" histGenPtantiD" , " generated particles" , HistType::kTH1F , {ptAxis});
99- spectraGen .add (" histGenPtHe" , " generated particles" , HistType::kTH1F , {ptAxis});
100- spectraGen .add (" histGenPtantiHe" , " generated particles" , HistType::kTH1F , {ptAxis});
93+ histos .add (" spectraGen/ histGenVetxZ" , " PosZ generated events" , HistType::kTH1F , {{2000 , -20 .f , 20 .f , " Vertex Z (cm)" }});
94+ histos .add (" spectraGen/ histGenPtPion" , " generated particles" , HistType::kTH1F , {ptAxis});
95+ histos .add (" spectraGen/ histGenPtKaon" , " generated particles" , HistType::kTH1F , {ptAxis});
96+ histos .add (" spectraGen/ histGenPtProton" , " generated particles" , HistType::kTH1F , {ptAxis});
97+ histos .add (" spectraGen/ histGenPtD" , " generated particles" , HistType::kTH1F , {ptAxis});
98+ histos .add (" spectraGen/ histGenPtantiD" , " generated particles" , HistType::kTH1F , {ptAxis});
99+ histos .add (" spectraGen/ histGenPtHe" , " generated particles" , HistType::kTH1F , {ptAxis});
100+ histos .add (" spectraGen/ histGenPtantiHe" , " generated particles" , HistType::kTH1F , {ptAxis});
101101 }
102102
103- void processData (o2::aod::LfCandNucleusFullEvents::iterator const & event, o2::aod::LfCandNucleusFull const & tracks)
103+ template <bool IsMC, typename CollisionType, typename TracksType>
104+ void fillHistograms (const CollisionType& event, const TracksType& tracks)
104105 {
105106 constexpr float fMassProton = 0 .938272088f ;
106107 constexpr float fMassDeuteron = 1 .87561f ;
@@ -173,55 +174,74 @@ struct LFNucleiDeuteronTask {
173174 if (std::abs (track.nsigTPC3He ()) < nsigmaTPCcut)
174175 histos.fill (HIST (" tracks/helium/h2TOFmass2HeliumVsPt" ), massTOF * massTOF - fMassHelium * fMassHelium , track.pt ());
175176 }
177+ if constexpr (IsMC) {
178+ track.pdgCode ();
179+ }
176180 }
177- // LOG(info)<<"Vertex Z ==="<<coll.posZ();
181+ }
182+
183+ void processData (o2::aod::LfCandNucleusFullEvents::iterator const & event,
184+ o2::aod::LfCandNucleusFull const & tracks)
185+ {
186+ fillHistograms<false >(event, tracks);
178187 } // CLOSING PROCESS DATA
188+ PROCESS_SWITCH (LFNucleiBATask, processData, " process data" , true );
179189
180- PROCESS_SWITCH (LFNucleiDeuteronTask, processData, " process data" , true );
190+ void processMCReco (o2::aod::LfCandNucleusFullEvents::iterator const & event,
191+ soa::Join<o2::aod::LfCandNucleusFull, o2::aod::LfCandNucleusMC> const & tracks)
192+ {
193+ fillHistograms<true >(event, tracks);
194+ } // CLOSING PROCESS MC RECO
195+ PROCESS_SWITCH (LFNucleiBATask, processMCReco, " process mc reco" , false );
181196 Int_t nCount = 0 ;
182197
183198 void processMCGen (aod::McCollision const & mcCollision, aod::McParticles_001& mcParticles)
184199 {
200+ constexpr int PDGPion = 211 ;
201+ constexpr int PDGKaon = 321 ;
202+ constexpr int PDGProton = 2212 ;
203+ constexpr int PDGDeuteron = 1000010020 ;
204+ constexpr int PDGHelium = 1000020030 ;
185205 nCount++;
186- spectraGen .fill (HIST (" histGenVetxZ" ), mcCollision.posZ ());
206+ histos .fill (HIST (" spectraGen/ histGenVetxZ" ), mcCollision.posZ ());
187207 for (auto & mcParticleGen : mcParticles) {
188208 if (abs (mcParticleGen.y ()) > std::abs (etaCut)) {
189209 continue ;
190210 }
191211
192- if (std::abs (mcParticleGen.pdgCode ()) == 211 ) {
193- spectraGen .fill (HIST (" histGenPtPion" ), mcParticleGen.pt ());
212+ if (std::abs (mcParticleGen.pdgCode ()) == PDGPion ) {
213+ histos .fill (HIST (" spectraGen/ histGenPtPion" ), mcParticleGen.pt ());
194214 }
195215
196- if (std::abs (mcParticleGen.pdgCode ()) == 321 ) {
197- spectraGen .fill (HIST (" histGenPtKaon" ), mcParticleGen.pt ());
216+ if (std::abs (mcParticleGen.pdgCode ()) == PDGKaon ) {
217+ histos .fill (HIST (" spectraGen/ histGenPtKaon" ), mcParticleGen.pt ());
198218 }
199219
200- if (std::abs (mcParticleGen.pdgCode ()) == 2212 ) {
201- spectraGen .fill (HIST (" histGenPtProton" ), mcParticleGen.pt ());
220+ if (std::abs (mcParticleGen.pdgCode ()) == PDGProton ) {
221+ histos .fill (HIST (" spectraGen/ histGenPtProton" ), mcParticleGen.pt ());
202222 }
203223
204- if (mcParticleGen.pdgCode () == 1000010020 ) {
205- spectraGen .fill (HIST (" histGenPtD" ), mcParticleGen.pt ());
224+ if (mcParticleGen.pdgCode () == PDGDeuteron ) {
225+ histos .fill (HIST (" spectraGen/ histGenPtD" ), mcParticleGen.pt ());
206226 }
207227
208- if (mcParticleGen.pdgCode () == -1000010020 ) {
209- spectraGen .fill (HIST (" histGenPtantiD" ), mcParticleGen.pt ());
228+ if (mcParticleGen.pdgCode () == -PDGDeuteron ) {
229+ histos .fill (HIST (" spectraGen/ histGenPtantiD" ), mcParticleGen.pt ());
210230 }
211231
212- if (mcParticleGen.pdgCode () == 1000020030 ) {
213- spectraGen .fill (HIST (" histGenPtHe" ), mcParticleGen.pt ());
232+ if (mcParticleGen.pdgCode () == PDGHelium ) {
233+ histos .fill (HIST (" spectraGen/ histGenPtHe" ), mcParticleGen.pt ());
214234 }
215235
216- if (mcParticleGen.pdgCode () == -1000020030 ) {
217- spectraGen .fill (HIST (" histGenPtantiHe" ), mcParticleGen.pt ());
236+ if (mcParticleGen.pdgCode () == -PDGHelium ) {
237+ histos .fill (HIST (" spectraGen/ histGenPtantiHe" ), mcParticleGen.pt ());
218238 }
219239 }
220- }
221- PROCESS_SWITCH (LFNucleiDeuteronTask , processMCGen, " process MC Generated" , true );
240+ } // Close processMCGen
241+ PROCESS_SWITCH (LFNucleiBATask , processMCGen, " process MC Generated" , true );
222242};
223243
224244WorkflowSpec defineDataProcessing (ConfigContext const & cfgc)
225245{
226- return WorkflowSpec{adaptAnalysisTask<LFNucleiDeuteronTask >(cfgc)};
246+ return WorkflowSpec{adaptAnalysisTask<LFNucleiBATask >(cfgc)};
227247}
0 commit comments