@@ -53,6 +53,7 @@ struct DalitzMuMuQCMC {
5353 OutputObj<THashList> fOutputEvent {" Event" };
5454 OutputObj<THashList> fOutputTrack {" Track" };
5555 OutputObj<THashList> fOutputDalitzMuMu {" DalitzMuMu" };
56+ OutputObj<THashList> fOutputGen {" Generated" };
5657 THashList* fMainList = new THashList();
5758
5859 void addhistograms ()
@@ -71,6 +72,10 @@ struct DalitzMuMuQCMC {
7172 o2::aod::emphotonhistograms::AddHistClass (fMainList , " DalitzMuMu" );
7273 THashList* list_dalitzmumu = reinterpret_cast <THashList*>(fMainList ->FindObject (" DalitzMuMu" ));
7374
75+ o2::aod::emphotonhistograms::AddHistClass (fMainList , " Generated" );
76+ THashList* list_gen = reinterpret_cast <THashList*>(fMainList ->FindObject (" Generated" ));
77+ o2::aod::emphotonhistograms::DefineHistograms (list_gen, " Generated" , " dimuon" );
78+
7479 for (const auto & cut : fDalitzMuMuCuts ) {
7580 const char * cutname = cut.GetName ();
7681 o2::aod::emphotonhistograms::AddHistClass (list_track, cutname);
@@ -114,6 +119,7 @@ struct DalitzMuMuQCMC {
114119 fOutputEvent .setObject (reinterpret_cast <THashList*>(fMainList ->FindObject (" Event" )));
115120 fOutputTrack .setObject (reinterpret_cast <THashList*>(fMainList ->FindObject (" Track" )));
116121 fOutputDalitzMuMu .setObject (reinterpret_cast <THashList*>(fMainList ->FindObject (" DalitzMuMu" )));
122+ fOutputGen .setObject (reinterpret_cast <THashList*>(fMainList ->FindObject (" Generated" )));
117123 }
118124
119125 template <typename TTrack, typename TMCTracks>
@@ -177,6 +183,8 @@ struct DalitzMuMuQCMC {
177183 auto posmc = pos.template emmcparticle_as <aod::EMMCParticles>();
178184 auto elemc = ele.template emmcparticle_as <aod::EMMCParticles>();
179185
186+ // LOGF(info, "posmc.pdgCode() = %d, , posmc.has_mothers()() = %d | elemc.pdgCode() = %d, elemc.has_mothers() = %d", posmc.pdgCode(), posmc.has_mothers(), elemc.pdgCode(), elemc.has_mothers());
187+
180188 int mother_id = FindLF (posmc, elemc, mcparticles);
181189 if (mother_id < 0 ) {
182190 continue ;
@@ -209,6 +217,66 @@ struct DalitzMuMuQCMC {
209217 } // end of process
210218 PROCESS_SWITCH (DalitzMuMuQCMC, processQCMC, " run Dalitz QC" , true );
211219
220+ Configurable<float > min_mcPt{" min_mcPt" , 0.05 , " min. MC pT" };
221+ Configurable<float > max_mcPt{" max_mcPt" , 0.6 , " max. MC pT" };
222+ Configurable<float > max_mcEta{" max_mcEta" , 0.9 , " max. MC eta" };
223+ Partition<aod::EMMCParticles> posTracks = o2::aod::mcparticle::pdgCode == -13 ; // mu+
224+ Partition<aod::EMMCParticles> negTracks = o2::aod::mcparticle::pdgCode == +13 ; // mu-
225+ PresliceUnsorted<aod::EMMCParticles> perMcCollision = aod::emmcparticle::emreducedmceventId;
226+ void processGen (MyCollisions const & collisions, aod::EMReducedMCEvents const &, aod::EMMCParticles const & mcparticles)
227+ {
228+ // loop over mc stack and fill histograms for pure MC truth signals
229+ // all MC tracks which belong to the MC event corresponding to the current reconstructed event
230+ for (auto & collision : collisions) {
231+ auto mccollision = collision.emreducedmcevent ();
232+ // LOGF(info, "mccollision.globalIndex() = %d", mccollision.globalIndex());
233+ // auto mctracks_coll = mcparticles.sliceBy(perMcCollision, mccollision.globalIndex());
234+
235+ reinterpret_cast <TH1F*>(fMainList ->FindObject (" Generated" )->FindObject (" hCollisionCounter" ))->Fill (1.0 );
236+ reinterpret_cast <TH1F*>(fMainList ->FindObject (" Generated" )->FindObject (" hZvtx_before" ))->Fill (mccollision.posZ ());
237+ if (!collision.sel8 ()) {
238+ continue ;
239+ }
240+ reinterpret_cast <TH1F*>(fMainList ->FindObject (" Generated" )->FindObject (" hCollisionCounter" ))->Fill (2.0 );
241+
242+ if (collision.numContrib () < 0.5 ) {
243+ continue ;
244+ }
245+ reinterpret_cast <TH1F*>(fMainList ->FindObject (" Generated" )->FindObject (" hCollisionCounter" ))->Fill (3.0 );
246+
247+ if (abs (collision.posZ ()) > 10.0 ) {
248+ continue ;
249+ }
250+ reinterpret_cast <TH1F*>(fMainList ->FindObject (" Generated" )->FindObject (" hCollisionCounter" ))->Fill (4.0 );
251+ reinterpret_cast <TH1F*>(fMainList ->FindObject (" Generated" )->FindObject (" hZvtx_after" ))->Fill (mccollision.posZ ());
252+ auto posTracks_per_coll = posTracks->sliceByCachedUnsorted (o2::aod::emmcparticle::emreducedmceventId, mccollision.globalIndex (), cache);
253+ auto negTracks_per_coll = negTracks->sliceByCachedUnsorted (o2::aod::emmcparticle::emreducedmceventId, mccollision.globalIndex (), cache);
254+ for (auto & [t1, t2] : combinations (CombinationsFullIndexPolicy (posTracks_per_coll, negTracks_per_coll))) {
255+ // LOGF(info, "pdg1 = %d, pdg2 = %d", t1.pdgCode(), t2.pdgCode());
256+
257+ if (t1.pt () < min_mcPt || max_mcPt < t1.pt () || abs (t1.eta ()) > max_mcEta) {
258+ continue ;
259+ }
260+ if (t2.pt () < min_mcPt || max_mcPt < t2.pt () || abs (t2.eta ()) > max_mcEta) {
261+ continue ;
262+ }
263+
264+ int mother_id = FindLF (t1, t2, mcparticles);
265+ if (mother_id < 0 ) {
266+ continue ;
267+ }
268+ auto mcmother = mcparticles.iteratorAt (mother_id);
269+ if (IsPhysicalPrimary (mcmother.emreducedmcevent (), mcmother, mcparticles)) {
270+ ROOT::Math::PtEtaPhiMVector v1 (t1.pt (), t1.eta (), t1.phi (), o2::constants::physics::MassMuon);
271+ ROOT::Math::PtEtaPhiMVector v2 (t2.pt (), t2.eta (), t2.phi (), o2::constants::physics::MassMuon);
272+ ROOT::Math::PtEtaPhiMVector v12 = v1 + v2;
273+ reinterpret_cast <TH2F*>(fMainList ->FindObject (" Generated" )->FindObject (" hMvsPt" ))->Fill (v12.M (), v12.Pt ());
274+ } // end of LF
275+ } // end of true ULS pair loop
276+ } // end of collision loop
277+ }
278+ PROCESS_SWITCH (DalitzMuMuQCMC, processGen, " run genrated info" , true );
279+
212280 void processDummy (MyCollisions const & collisions) {}
213281 PROCESS_SWITCH (DalitzMuMuQCMC, processDummy, " Dummy function" , false );
214282};
0 commit comments