2 #include <qautils/QAHistManagerDef.h>
35 #include <TDatabasePDG.h>
39 #include <TParticlePDG.h>
64 m_vertexMap = findNode::getClass<GlobalVertexMap>(topNode,
"GlobalVertexMap");
65 m_trackMap = findNode::getClass<SvtxTrackMap>(topNode,
"SvtxTrackMap");
69 std::cout <<
PHWHERE <<
" missing track related container(s). Quitting"
86 ";Reco p_{T}/Truth p_{T}", 500, 0, 2);
90 ";Truth p_{T} [GeV/c];Reco p_{T}/Truth p_{T}", 200, 0, 50, 500, 0, 2);
96 "Gen tracks at reco p_{T}; Reco p_{T} [GeV/c]", 200, 0.1, 50.5);
100 ";Gen p_{T} [GeV/c];Track count / bin", 200, 0.1, 50.5);
103 h =
new TH2F(TString(
get_histo_prefix()) +
"pTRecoTruthMatchedRatio_pTReco",
104 ";Reco p_{T} [GeV/c];Matched p_{T}/Reco p_{T}", 200, 0, 50, 500, 0, 2);
109 "Gen tracks at reco p_{T} (#geq 2 MVTX, #geq 1 INTT, #geq 20 TPC); Reco p_{T} [GeV/c]", 200, 0.1, 50.5);
113 ";Gen p_{T} [GeV/c];Track count / bin", 200, 0.1, 50.5);
116 h =
new TH2F(TString(
get_histo_prefix()) +
"pTRecoTruthMatchedRatio_pTReco_cuts",
117 ";Reco p_{T} [GeV/c];Matched p_{T}/Reco p_{T}", 200, 0, 50, 500, 0, 2);
122 "Reco tracks at truth p_{T};Truth p_{T} [GeV/c]", 200, 0.1, 50.5);
128 "Reco tracks at truth p_{T};Truth p_{T} [GeV/c];nCluster_{MVTX}", 200, 0.1, 50.5, 6, -.5, 5.5);
132 "Reco tracks at truth p_{T};Truth p_{T} [GeV/c];nCluster_{INTT}", 200, 0.1, 50.5, 6, -.5, 5.5);
136 "Reco tracks at truth p_{T};Truth p_{T} [GeV/c];nCluster_{TPC}", 200, 0.1, 50.5, 60, -.5, 59.5);
142 "DCA resolution at truth p_{T};Truth p_{T} [GeV/c];DCA(r#phi) resolution [cm]", 200, 0.1, 50.5, 500, -0.05, 0.05);
146 "DCA resolution at truth p_{T};Truth p_{T} [GeV/c];DCA(Z) resolution [cm]", 200, 0.1, 50.5, 500, -0.05, 0.05);
152 "DCA Resolution (#geq 2 MVTX, #geq 1 INTT, #geq 20 TPC);Truth p_{T} [GeV/c];DCA(r#phi) resolution [cm]", 200, 0.1, 50.5, 500, -0.05, 0.05);
156 "DCA Resolution (#geq 2 MVTX, #geq 1 INTT, #geq 20 TPC);Truth p_{T} [GeV/c];DCA(Z) resolution [cm]", 200, 0.1, 50.5, 500, -0.05, 0.05);
160 "Sigmalized DCA (#geq 2 MVTX, #geq 1 INTT, #geq 20 TPC);Truth p_{T} [GeV/c];Sigmalized DCA(r#phi) [cm]", 200, 0.1, 50.5, 500, -5., 5.);
164 "Sigmalized DCA (#geq 2 MVTX, #geq 1 INTT, #geq 20 TPC);Truth p_{T} [GeV/c];Sigmalized DCA(Z) [cm]", 200, 0.1, 50.5, 500, -5., 5.);
170 ";Truth p_{T} [GeV/c];Track count / bin", 200, 0.1, 50.5);
176 "Reco tracks at truth #eta;Truth #eta", 200, -2, 2);
181 ";Truth #eta;Track count / bin", 200, -2, 2);
186 h =
new TH1F(TString(
get_histo_prefix()) +
"nClus_layer",
"Reco Clusters per layer per track;Layer;nCluster", 64, 0, 64);
190 h =
new TH1F(TString(
get_histo_prefix()) +
"nClus_layerGen",
"Reco Clusters per layer per truth track;Layer;nCluster", 64, 0, 64);
197 h->GetXaxis()->SetBinLabel(i++,
"Event");
198 h->GetXaxis()->SetBinLabel(i++,
"Truth Track");
199 h->GetXaxis()->SetBinLabel(i++,
"Truth Track+");
200 h->GetXaxis()->SetBinLabel(i++,
"Truth Track-");
201 h->GetXaxis()->SetBinLabel(i++,
"Reco Track");
202 h->GetXaxis()->LabelsOption(
"v");
217 std::cout <<
"QAG4SimulationTracking::process_event" << std::endl;
250 TH2 *h_pTRecoTruthMatchedRatio_pTReco =
dynamic_cast<TH2 *
>(hm->
getHisto(
get_histo_prefix() +
"pTRecoTruthMatchedRatio_pTReco"));
251 assert(h_pTRecoTruthMatchedRatio_pTReco);
255 assert(h_nGen_pTReco_cuts);
258 assert(h_nReco_pTReco_cuts);
260 TH2 *h_pTRecoTruthMatchedRatio_pTReco_cuts =
dynamic_cast<TH2 *
>(hm->
getHisto(
get_histo_prefix() +
"pTRecoTruthMatchedRatio_pTReco_cuts"));
261 assert(h_pTRecoTruthMatchedRatio_pTReco_cuts);
269 assert(h_nMVTX_nReco_pTGen);
272 assert(h_nINTT_nReco_pTGen);
275 assert(h_nTPC_nReco_pTGen);
286 assert(h_DCArPhi_pT_cuts);
292 assert(h_SigmalizedDCArPhi_pT);
295 assert(h_SigmalizedDCAZ_pT);
320 h_norm->Fill(
"Event", 1);
325 std::cout <<
"QAG4SimulationTracking::process_event - fatal error - missing m_truthContainer! ";
331 using KeySet = std::set<TrkrDefs::cluskey>;
332 using ParticleMap = std::map<int, KeySet>;
333 ParticleMap g4particle_map;
341 for (
auto clusterIter = range.first; clusterIter != range.second; ++clusterIter)
344 const auto &key = clusterIter->first;
349 const int trkid = g4hit->get_trkid();
350 auto iter = g4particle_map.lower_bound(trkid);
351 if (iter != g4particle_map.end() && iter->first == trkid)
353 iter->second.insert(key);
357 g4particle_map.insert(iter, std::make_pair(trkid, KeySet({key})));
377 const double px = track->
get_px();
378 const double py = track->
get_py();
379 const double pz = track->
get_pz();
380 const TVector3
v(px, py, pz);
381 const double pt = v.Pt();
382 h_nReco_pTReco->Fill(pt);
395 const auto &cluster_key = *cluster_iter;
408 const auto &cluster_key = *cluster_iter;
415 if (MVTX_hits >= 2 && INTT_hits >= 1 && TPC_hits >= 20)
417 h_nReco_pTReco_cuts->Fill(pt);
421 if (g4particle_match)
428 h_nGen_pTReco->Fill(pt);
430 const double gpx = g4particle_match->get_px();
431 const double gpy = g4particle_match->get_py();
432 TVector3 gv(gpx, gpy, 0);
433 const double gpt = gv.Pt();
435 const double pt_ratio = (pt != 0) ? gpt / pt : 0;
436 h_pTRecoTruthMatchedRatio_pTReco->Fill(pt, pt_ratio);
438 if (MVTX_hits >= 2 && INTT_hits >= 1 && TPC_hits >= 20)
440 h_nGen_pTReco_cuts->Fill(pt);
441 h_pTRecoTruthMatchedRatio_pTReco_cuts->Fill(pt, pt_ratio);
450 std::cout << __PRETTY_FUNCTION__ <<
" : Fatal error: missing SvtxTrackMap" << std::endl;
462 std::cout <<
"QAG4SimulationTracking::process_event - processing ";
469 int candidate_embedding_id = trutheval->
get_embed(g4particle);
470 if (candidate_embedding_id <=
m_embed_id_cut) candidate_embedding_id = -1;
482 if (gpx != 0 && gpy != 0)
484 TVector3 gv(gpx, gpy, gpz);
493 std::cout <<
"QAG4SimulationTracking::process_event - accept particle eta = " << geta << std::endl;
499 std::cout <<
"QAG4SimulationTracking::process_event - ignore particle eta = " << geta << std::endl;
504 TParticlePDG *pdg_p = TDatabasePDG::Instance()->GetParticle(pid);
507 std::cout <<
"QAG4SimulationTracking::process_event - Error - invalid particle ID = " << pid << std::endl;
511 const double gcharge = pdg_p->Charge() / 3;
514 h_norm->Fill(
"Truth Track+", 1);
516 else if (gcharge < 0)
518 h_norm->Fill(
"Truth Track-", 1);
523 std::cout <<
"QAG4SimulationTracking::process_event - invalid particle ID = " << pid << std::endl;
526 h_norm->Fill(
"Truth Track", 1);
528 h_nGen_pTGen->Fill(gpt);
529 h_nGen_etaGen->Fill(geta);
533 const auto mapIter = g4particle_map.find(iter->first);
534 if (mapIter != g4particle_map.cend())
536 for (
const auto &cluster_key : mapIter->second)
543 std::cout <<
"QAG4SimulationTracking::process_event - could nof find clusters associated to G4Particle " << iter->first << std::endl;
550 bool match_found(
false);
555 if (g4particle_matched)
561 std::cout <<
"QAG4SimulationTracking::process_event - found unique match for g4 particle " << g4particle->
get_track_id() << std::endl;
566 std::cout <<
"QAG4SimulationTracking::process_event - none unique match for g4 particle " << g4particle->
get_track_id()
567 <<
". The track belong to g4 particle " << g4particle_matched->
get_track_id() << std::endl;
573 std::cout <<
"QAG4SimulationTracking::process_event - none unique match for g4 particle " << g4particle->
get_track_id()
574 <<
". The track belong to no g4 particle!" << std::endl;
580 h_nReco_etaGen->Fill(geta);
581 h_nReco_pTGen->Fill(gpt);
585 float dca3dxysigma = NAN;
586 float dca3dzsigma = NAN;
587 get_dca(track, dca3dxy, dca3dz, dca3dxysigma, dca3dzsigma);
589 double px = track->
get_px();
590 double py = track->
get_py();
591 double pz = track->
get_pz();
593 TVector3
v(px, py, pz);
598 float pt_ratio = (gpt != 0) ? pt / gpt : 0;
599 h_pTRecoGenRatio->Fill(pt_ratio);
600 h_pTRecoGenRatio_pTGen->Fill(gpt, pt_ratio);
601 h_DCArPhi_pT->Fill(pt, dca3dxy);
602 h_DCAZ_pT->Fill(pt, dca3dz);
603 h_norm->Fill(
"Reco Track", 1);
614 for (
auto cluster_iter = silSeed->begin_cluster_keys();
615 cluster_iter != silSeed->end_cluster_keys(); ++cluster_iter)
617 const auto &cluster_key = *cluster_iter;
621 h_nClus_layer->Fill(
layer);
631 for (
auto cluster_iter = tpcSeed->begin_cluster_keys(); cluster_iter != tpcSeed->end_cluster_keys(); ++cluster_iter)
633 const auto &cluster_key = *cluster_iter;
637 h_nClus_layer->Fill(
layer);
642 if (MVTX_hits >= 2 && INTT_hits >= 1 && TPC_hits >= 20)
644 h_DCArPhi_pT_cuts->Fill(pt, dca3dxy);
645 h_DCAZ_pT_cuts->Fill(pt, dca3dz);
646 h_SigmalizedDCArPhi_pT->Fill(pt, dca3dxy / dca3dxysigma);
647 h_SigmalizedDCAZ_pT->Fill(pt, dca3dz / dca3dzsigma);
650 h_nMVTX_nReco_pTGen->Fill(gpt, MVTX_hits);
651 h_nINTT_nReco_pTGen->Fill(gpt, INTT_hits);
652 h_nTPC_nReco_pTGen->Fill(gpt, TPC_hits);
661 float &dca3dz,
float &dca3dxysigma,
667 if (!glVertex)
return;
668 Acts::Vector3 vert(glVertex->get_x(), glVertex->get_y(), glVertex->get_z());
670 dca3dxy = pair.first.first;
671 dca3dxysigma = pair.first.second;
672 dca3dz = pair.second.first;
673 dca3dzsigma = pair.second.second;
680 m_truthContainer = findNode::getClass<PHG4TruthInfoContainer>(topNode,
"G4TruthInfo");
683 std::cout <<
"QAG4SimulationTracking::load_nodes - Fatal Error - "
684 <<
"unable to find DST node "
685 <<
"G4TruthInfo" << std::endl;
690 m_cluster_map = findNode::getClass<TrkrClusterContainer>(topNode,
"TRKR_CLUSTER");
694 m_cluster_hit_map = findNode::getClass<TrkrClusterHitAssoc>(topNode,
"TRKR_CLUSTERHITASSOC");
698 m_hit_truth_map = findNode::getClass<TrkrHitTruthAssoc>(topNode,
"TRKR_HITTRUTHASSOC");
702 m_g4hits_tpc = findNode::getClass<PHG4HitContainer>(topNode,
"G4HIT_TPC");
703 m_g4hits_intt = findNode::getClass<PHG4HitContainer>(topNode,
"G4HIT_INTT");
704 m_g4hits_mvtx = findNode::getClass<PHG4HitContainer>(topNode,
"G4HIT_MVTX");
726 for (
auto iter = range.first; iter != range.second; ++iter)
729 const auto &hit_key = iter->second;
736 for (
auto truth_iter = g4hit_map.begin(); truth_iter != g4hit_map.end(); ++truth_iter)
738 const auto g4hit_key = truth_iter->second.second;
767 if (g4hit) out.insert(g4hit);