@@ -52,6 +52,14 @@ static const std::array<std::string, 2> originNames = {"Prompt", "NonPrompt"};
5252// / - Momentum Conservation for these particles
5353
5454struct ValidationGenLevel {
55+
56+ Configurable<double > xVertexMin{" xVertexMin" , -100 ., " min. x of generated primary vertex [cm]" };
57+ Configurable<double > xVertexMax{" xVertexMax" , 100 ., " max. x of generated primary vertex [cm]" };
58+ Configurable<double > yVertexMin{" yVertexMin" , -100 ., " min. y of generated primary vertex [cm]" };
59+ Configurable<double > yVertexMax{" yVertexMax" , 100 ., " max. y of generated primary vertex [cm]" };
60+ Configurable<double > zVertexMin{" zVertexMin" , -10 ., " min. z of generated primary vertex [cm]" };
61+ Configurable<double > zVertexMax{" zVertexMax" , 10 ., " max. z of generated primary vertex [cm]" };
62+
5563 std::shared_ptr<TH1 > hPromptCharmHadronsPtDistr, hPromptCharmHadronsYDistr, hNonPromptCharmHadronsPtDistr, hNonPromptCharmHadronsYDistr, hPromptCharmHadronsDecLenDistr, hNonPromptCharmHadronsDecLenDistr, hQuarkPerEvent;
5664
5765 HistogramRegistry registry{
@@ -101,6 +109,26 @@ struct ValidationGenLevel {
101109 }
102110 }
103111
112+ // / Primary-vertex selection
113+ // / \param collision mccollision table row
114+ template <typename Col>
115+ bool selectVertex (const Col& collision)
116+ {
117+ // x position
118+ if (collision.posX () < xVertexMin || collision.posX () > xVertexMax) {
119+ return false ;
120+ }
121+ // y position
122+ if (collision.posY () < yVertexMin || collision.posY () > yVertexMax) {
123+ return false ;
124+ }
125+ // z position
126+ if (collision.posZ () < zVertexMin || collision.posZ () > zVertexMax) {
127+ return false ;
128+ }
129+ return true ;
130+ }
131+
104132 void process (aod::McCollision const & mccollision, aod::McParticles const & particlesMC)
105133 {
106134 int cPerCollision = 0 ;
@@ -115,6 +143,9 @@ struct ValidationGenLevel {
115143 std::vector<int > listDaughters{};
116144
117145 for (auto & particle : particlesMC) {
146+ if (!selectVertex (mccollision))
147+ continue ;
148+
118149 int particlePdgCode = particle.pdgCode ();
119150 if (!particle.has_mothers ()) {
120151 continue ;
@@ -242,13 +273,15 @@ struct ValidationRecLevel {
242273 std::array<std::shared_ptr<TH1 >, nCharmHadrons> histDeltaPt, histDeltaPx, histDeltaPy, histDeltaPz, histDeltaSecondaryVertexX, histDeltaSecondaryVertexY, histDeltaSecondaryVertexZ, histDeltaDecayLength;
243274 std::array<std::array<std::array<std::shared_ptr<TH1 >, 3 >, 2 >, nCharmHadrons> histPtDau, histEtaDau, histImpactParameterDau;
244275 std::array<std::array<std::shared_ptr<TH1 >, 2 >, nCharmHadrons> histPtReco;
245- std::array<std::shared_ptr<TH2 >, 2 > histOriginTracks;
276+ std::array<std::shared_ptr<TH2 >, 4 > histOriginTracks;
246277
247278 HistogramRegistry registry{" registry" , {}};
248279 void init (o2::framework::InitContext&)
249280 {
250- histOriginTracks[0 ] = registry.add <TH2 >(" histOriginNonAssociatedTracks" , " ;origin;#it{p}_{T}^{reco} (GeV/#it{c})" , HistType::kTH2F , {{4 , -1.5 , 2.5 }, {50 , 0 ., 10 .}});
251- histOriginTracks[1 ] = registry.add <TH2 >(" histOriginAssociatedTracks" , " ;origin;#it{p}_{T}^{reco} (GeV/#it{c})" , HistType::kTH2F , {{4 , -1.5 , 2.5 }, {50 , 0 ., 10 .}});
281+ histOriginTracks[0 ] = registry.add <TH2 >(" histOriginNonAssociatedTracks" , " ;origin;#it{p}_{T}^{reco} (GeV/#it{c})" , HistType::kTH2F , {{4 , -1.5 , 2.5 }, {50 , 0 ., 10 .}}); // tracks not associated to any collision
282+ histOriginTracks[1 ] = registry.add <TH2 >(" histOriginAssociatedTracks" , " ;origin;#it{p}_{T}^{reco} (GeV/#it{c})" , HistType::kTH2F , {{4 , -1.5 , 2.5 }, {50 , 0 ., 10 .}}); // tracks associasted to a collision
283+ histOriginTracks[2 ] = registry.add <TH2 >(" histOriginGoodAssociatedTracks" , " ;origin;#it{p}_{T}^{reco} (GeV/#it{c})" , HistType::kTH2F , {{4 , -1.5 , 2.5 }, {50 , 0 ., 10 .}}); // tracks associated to the correct collision (considering the MC collision index)
284+ histOriginTracks[3 ] = registry.add <TH2 >(" histOriginWrongAssociatedTracks" , " ;origin;#it{p}_{T}^{reco} (GeV/#it{c})" , HistType::kTH2F , {{4 , -1.5 , 2.5 }, {50 , 0 ., 10 .}}); // tracks associated to the wrong collision (considering the MC collision index)
252285 for (std::size_t iHist{0 }; iHist < histOriginTracks.size (); ++iHist) {
253286 histOriginTracks[iHist]->GetXaxis ()->SetBinLabel (1 , " no MC particle" );
254287 histOriginTracks[iHist]->GetXaxis ()->SetBinLabel (2 , " no quark" );
@@ -277,8 +310,9 @@ struct ValidationRecLevel {
277310
278311 using HfCandProng2WithMCRec = soa::Join<aod::HfCandProng2, aod::HfCandProng2MCRec>;
279312 using HfCandProng3WithMCRec = soa::Join<aod::HfCandProng3, aod::HfCandProng3MCRec>;
313+ using CollisionsWithMCLabels = soa::Join<aod::Collisions, aod::McCollisionLabels>;
280314
281- void process (HfCandProng2WithMCRec const & cand2Prongs, HfCandProng3WithMCRec const & cand3Prongs, aod::BigTracksMC const & tracks, aod::McParticles const & particlesMC)
315+ void process (HfCandProng2WithMCRec const & cand2Prongs, HfCandProng3WithMCRec const & cand3Prongs, aod::BigTracksMC const & tracks, aod::McParticles const & particlesMC, aod::McCollisions const & mcCollisions, CollisionsWithMCLabels const & collisions )
282316 {
283317 // loop over tracks
284318 for (auto & track : tracks) {
@@ -287,6 +321,15 @@ struct ValidationRecLevel {
287321 auto particle = track.mcParticle (); // get corresponding MC particle to check origin
288322 auto origin = RecoDecay::getCharmHadronOrigin (particlesMC, particle, true );
289323 histOriginTracks[index]->Fill (origin, track.pt ());
324+ if (index) {
325+ auto collision = collisions.rawIteratorAt (track.collisionId ());
326+ auto mcCollision = particle.mcCollision ();
327+ uint index2 = 2 ;
328+ if (collision.mcCollisionId () - particle.mcCollisionId () == 0 && std::abs (collision.posZ () - mcCollision.posZ ()) < 0.02 ) { // 200 microns compatibility of Z vertex position also required
329+ index2 = 1 ;
330+ }
331+ histOriginTracks[index + index2]->Fill (origin, track.pt ());
332+ }
290333 } else {
291334 histOriginTracks[index]->Fill (-1 ., track.pt ());
292335 }
0 commit comments