@@ -267,6 +267,61 @@ struct qaEventTrack {
267267 const auto & tracksUnfilteredColl = tracksUnfiltered.sliceBy (perRecoCollision, collision.globalIndex ());
268268 fillRecoHistogramsGroupedTracks<true >(collision, tracksColl, tracksUnfilteredColl);
269269 }
270+
271+ // / check correct track-to-vertex matching exploiting MC info
272+ for (auto & track : tracks) {
273+ histos.fill (HIST (" Tracks/TestMCtrackToVtxMatch/ptAllTracks" ), track.pt ());
274+ bool has_MCparticle = track.has_mcParticle ();
275+ if (track.collisionId () >= 0 ) {
276+ // / track associated to a reconstructed collision
277+ histos.fill (HIST (" Tracks/TestMCtrackToVtxMatch/ptAllTracksInColl" ), track.pt ());
278+ if (has_MCparticle) {
279+ // / the track is not fake
280+ auto particle = track.mcParticle ();
281+ auto collReco = track.collision_as <CollisionTableMC>();
282+ auto collMC = particle.mcCollision ();
283+ auto mcCollID_recoColl = collReco.mcCollisionId ();
284+ auto mcCollID_particle = particle.mcCollisionId ();
285+ bool indexMatchOK = (mcCollID_recoColl == mcCollID_particle);
286+ double pvZdiff = collReco.posZ () - collMC.posZ ();
287+ if (indexMatchOK) {
288+ // / mc collision indices from the two sides match
289+ if (particle.isPhysicalPrimary ()) {
290+ histos.fill (HIST (" Tracks/TestMCtrackToVtxMatch/ptVsDpvZgoodMatchPhysPrim" ), pvZdiff, track.pt ());
291+ } else if (particle.getProcess () == 4 ) {
292+ histos.fill (HIST (" Tracks/TestMCtrackToVtxMatch/ptVsDpvZgoodMatchSecondary" ), pvZdiff, track.pt ());
293+ } else {
294+ histos.fill (HIST (" Tracks/TestMCtrackToVtxMatch/ptVsDpvZgoodMatchMaterial" ), pvZdiff, track.pt ());
295+ }
296+ } else {
297+ // / mc collision indices from the two sides do not match
298+ if (particle.isPhysicalPrimary ()) {
299+ histos.fill (HIST (" Tracks/TestMCtrackToVtxMatch/ptVsDpvZbadMatchPhysPrim" ), pvZdiff, track.pt ());
300+ } else if (particle.getProcess () == 4 ) {
301+ histos.fill (HIST (" Tracks/TestMCtrackToVtxMatch/ptVsDpvZbadMatchSecondary" ), pvZdiff, track.pt ());
302+ } else {
303+ histos.fill (HIST (" Tracks/TestMCtrackToVtxMatch/ptVsDpvZbadMatchMaterial" ), pvZdiff, track.pt ());
304+ }
305+ }
306+ }
307+
308+ } else {
309+ // / track not associated to any reconstructed collision
310+ histos.fill (HIST (" Tracks/TestMCtrackToVtxMatch/ptAllTracksWoColl" ), track.pt ());
311+ if (track.has_mcParticle ()) {
312+ auto particle = track.mcParticle ();
313+ int prodProcess = -1 ;
314+ if (particle.isPhysicalPrimary ()) {
315+ prodProcess = 0 ;
316+ } else if (particle.getProcess () == 4 ) {
317+ prodProcess = 1 ;
318+ } else {
319+ prodProcess = 2 ;
320+ }
321+ histos.fill (HIST (" Tracks/TestMCtrackToVtxMatch/ptVsOriginUnmatchedwithMCpart" ), prodProcess, track.pt ());
322+ }
323+ }
324+ }
270325 }
271326 PROCESS_SWITCH (qaEventTrack, processMC, " process mc" , true ); // FIXME: would like to disable this by default and swich on via --processMC but currently this crashes -> ask experts
272327
@@ -501,6 +556,22 @@ void qaEventTrack::init(InitContext const&)
501556 histos.add (" Tracks/KineUnmatchTracks/eta" , " #eta" , kTH1D , {axisEta});
502557 histos.add (" Tracks/KineUnmatchTracks/phi" , " #varphi" , kTH1D , {axisPhi});
503558
559+ // / check correct track-to-vertex matching
560+ histos.add (" Tracks/TestMCtrackToVtxMatch/ptAllTracks" , " all tracks (MC)" , kTH1D , {axisPt});
561+ histos.add (" Tracks/TestMCtrackToVtxMatch/ptAllTracksInColl" , " all tracks in collision (MC)" , kTH1D , {axisPt});
562+ histos.add (" Tracks/TestMCtrackToVtxMatch/ptAllTracksWoColl" , " all tracks w/o collision (MC)" , kTH1D , {axisPt});
563+ auto hUnmatched = histos.add <TH2 >(" Tracks/TestMCtrackToVtxMatch/ptVsOriginUnmatchedwithMCpart" , " tracks with part. not matched to reco. coll. (MC)" , kTH2D , {{4 , -1.5 , 2.5 }, axisPt});
564+ hUnmatched->GetXaxis ()->SetBinLabel (hUnmatched->GetXaxis ()->FindBin (-1 .), " not found" );
565+ hUnmatched->GetXaxis ()->SetBinLabel (hUnmatched->GetXaxis ()->FindBin (0 .), " Phys. prim." );
566+ hUnmatched->GetXaxis ()->SetBinLabel (hUnmatched->GetXaxis ()->FindBin (1 .), " Secondary" );
567+ hUnmatched->GetXaxis ()->SetBinLabel (hUnmatched->GetXaxis ()->FindBin (2 .), " Material" );
568+ histos.add (" Tracks/TestMCtrackToVtxMatch/ptVsDpvZgoodMatchPhysPrim" , " good track-to-vtx matching phys. prim. (MC)" , kTH2D , {{100 , -0.1 , 0.1 , " pvZ(reco coll.) - pvZ(MC coll.)" }, axisPt});
569+ histos.add (" Tracks/TestMCtrackToVtxMatch/ptVsDpvZbadMatchPhysPrim" , " bad track-to-vtx matching phys. prim. (MC)" , kTH2D , {{100 , -0.1 , 0.1 , " pvZ(reco coll.) - pvZ(MC coll.)" }, axisPt});
570+ histos.add (" Tracks/TestMCtrackToVtxMatch/ptVsDpvZgoodMatchSecondary" , " good track-to-vtx matching secondary (MC)" , kTH2D , {{100 , -0.1 , 0.1 , " pvZ(reco coll.) - pvZ(MC coll.)" }, axisPt});
571+ histos.add (" Tracks/TestMCtrackToVtxMatch/ptVsDpvZbadMatchSecondary" , " bad track-to-vtx matching secondary (MC)" , kTH2D , {{100 , -0.1 , 0.1 , " pvZ(reco coll.) - pvZ(MC coll.)" }, axisPt});
572+ histos.add (" Tracks/TestMCtrackToVtxMatch/ptVsDpvZgoodMatchMaterial" , " good track-to-vtx matching material (MC)" , kTH2D , {{100 , -0.1 , 0.1 , " pvZ(reco coll.) - pvZ(MC coll.)" }, axisPt});
573+ histos.add (" Tracks/TestMCtrackToVtxMatch/ptVsDpvZbadMatchMaterial" , " bad track-to-vtx matching material (MC)" , kTH2D , {{100 , -0.1 , 0.1 , " pvZ(reco coll.) - pvZ(MC coll.)" }, axisPt});
574+
504575 // track histograms
505576 auto hselAxis = histos.add <TH1 >(" Tracks/selection" , " trackSelection" , kTH1F , {{40 , 0.5 , 40.5 }})->GetXaxis ();
506577 hselAxis->SetBinLabel (1 , " Tracks read" );
@@ -958,4 +1029,4 @@ void qaEventTrack::fillRecoHistogramsGroupedTracks(const C& collision, const T&
9581029 histos.fill (HIST (" Tracks/ITS/hasITSANDhasTPC" ), track.pt ());
9591030 }
9601031 }
961- }
1032+ }
0 commit comments