29 #include <TDatabasePDG.h>
33 #include <TParticlePDG.h>
58 m_trackMap = findNode::getClass<SvtxTrackMap>(topNode,
"SvtxTrackMap");
72 ";Reco p_{T}/Truth p_{T}", 500, 0, 2);
76 ";Truth p_{T} [GeV/c];Reco p_{T}/Truth p_{T}", 200, 0, 50, 500, 0, 2);
82 "Gen tracks at reco p_{T}; Reco p_{T} [GeV/c]", 200, 0.1, 50.5);
86 ";Gen p_{T} [GeV/c];Track count / bin", 200, 0.1, 50.5);
90 ";Reco p_{T} [GeV/c];Matched p_{T}/Reco p_{T}", 200, 0, 50, 500, 0, 2);
95 "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);
99 ";Gen p_{T} [GeV/c];Track count / bin", 200, 0.1, 50.5);
102 h =
new TH2F(TString(
get_histo_prefix()) +
"pTRecoTruthMatchedRatio_pTReco_cuts",
103 ";Reco p_{T} [GeV/c];Matched p_{T}/Reco p_{T}", 200, 0, 50, 500, 0, 2);
108 "Reco tracks at truth p_{T};Truth p_{T} [GeV/c]", 200, 0.1, 50.5);
114 "Reco tracks at truth p_{T};Truth p_{T} [GeV/c];nCluster_{MVTX}", 200, 0.1, 50.5, 6, -.5, 5.5);
118 "Reco tracks at truth p_{T};Truth p_{T} [GeV/c];nCluster_{INTT}", 200, 0.1, 50.5, 6, -.5, 5.5);
122 "Reco tracks at truth p_{T};Truth p_{T} [GeV/c];nCluster_{TPC}", 200, 0.1, 50.5, 60, -.5, 59.5);
128 "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);
132 "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);
138 "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);
142 "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);
146 "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.);
150 "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.);
156 ";Truth p_{T} [GeV/c];Track count / bin", 200, 0.1, 50.5);
162 "Reco tracks at truth #eta;Truth #eta", 200, -2, 2);
167 ";Truth #eta;Track count / bin", 200, -2, 2);
172 h =
new TH1F(TString(
get_histo_prefix()) +
"nClus_layer",
"Reco Clusters per layer per track;Layer;nCluster", 64, 0, 64);
176 h =
new TH1F(TString(
get_histo_prefix()) +
"nClus_layerGen",
"Reco Clusters per layer per truth track;Layer;nCluster", 64, 0, 64);
183 h->GetXaxis()->SetBinLabel(i++,
"Event");
184 h->GetXaxis()->SetBinLabel(i++,
"Truth Track");
185 h->GetXaxis()->SetBinLabel(i++,
"Truth Track+");
186 h->GetXaxis()->SetBinLabel(i++,
"Truth Track-");
187 h->GetXaxis()->SetBinLabel(i++,
"Reco Track");
188 h->GetXaxis()->LabelsOption(
"v");
202 std::cout <<
"QAG4SimulationTracking::process_event() entered" << std::endl;
221 assert(h_pTRecoGenRatio);
225 assert(h_pTRecoGenRatio);
229 assert(h_nGen_pTReco);
232 assert(h_nReco_pTReco);
234 TH2 *h_pTRecoTruthMatchedRatio_pTReco =
dynamic_cast<TH2 *
>(hm->
getHisto(
get_histo_prefix() +
"pTRecoTruthMatchedRatio_pTReco"));
235 assert(h_pTRecoTruthMatchedRatio_pTReco);
239 assert(h_nGen_pTReco_cuts);
242 assert(h_nReco_pTReco_cuts);
244 TH2 *h_pTRecoTruthMatchedRatio_pTReco_cuts =
dynamic_cast<TH2 *
>(hm->
getHisto(
get_histo_prefix() +
"pTRecoTruthMatchedRatio_pTReco_cuts"));
245 assert(h_pTRecoTruthMatchedRatio_pTReco_cuts);
249 assert(h_nReco_pTGen);
253 assert(h_nMVTX_nReco_pTGen);
256 assert(h_nINTT_nReco_pTGen);
259 assert(h_nTPC_nReco_pTGen);
263 assert(h_DCArPhi_pT);
270 assert(h_DCArPhi_pT_cuts);
273 assert(h_DCAZ_pT_cuts);
276 assert(h_SigmalizedDCArPhi_pT);
279 assert(h_SigmalizedDCAZ_pT);
283 assert(h_nGen_pTGen);
287 assert(h_nReco_etaGen);
291 assert(h_nGen_etaGen);
295 assert(h_nClus_layer);
299 assert(h_nClus_layer);
304 h_norm->Fill(
"Event", 1);
309 std::cout <<
"QAG4SimulationTracking::process_event - fatal error - missing m_truthContainer! ";
315 using KeySet = std::set<TrkrDefs::cluskey>;
316 using ParticleMap = std::map<int, KeySet>;
317 ParticleMap g4particle_map;
322 for (
auto hitsetitr = hitsetrange.first;
323 hitsetitr != hitsetrange.second;
327 for (
auto clusterIter = range.first; clusterIter != range.second; ++clusterIter)
330 const auto &key = clusterIter->first;
335 const int trkid = g4hit->get_trkid();
336 auto iter = g4particle_map.lower_bound(trkid);
337 if (iter != g4particle_map.end() && iter->first == trkid)
339 iter->second.insert(key);
343 g4particle_map.insert(iter, std::make_pair(trkid, KeySet({key})));
360 const double px = track->
get_px();
361 const double py = track->
get_py();
362 const double pz = track->
get_pz();
363 const TVector3
v(px, py, pz);
364 const double pt = v.Pt();
365 h_nReco_pTReco->Fill(pt);
372 const auto &cluster_key = *cluster_iter;
384 std::cout <<
"QAG4SimulationTracking::process_event - unkown tracker ID = " << trackerID <<
" from cluster " << cluster_key << std::endl;
387 if (MVTX_hits >= 2 && INTT_hits >= 1 && TPC_hits >= 20)
389 h_nReco_pTReco_cuts->Fill(pt);
392 if (g4particle_match)
400 h_nGen_pTReco->Fill(pt);
402 const double gpx = g4particle_match->
get_px();
403 const double gpy = g4particle_match->
get_py();
404 TVector3 gv(gpx, gpy, 0);
405 const double gpt = gv.Pt();
407 const double pt_ratio = (pt != 0) ? gpt / pt : 0;
408 h_pTRecoTruthMatchedRatio_pTReco->Fill(pt, pt_ratio);
410 if (MVTX_hits >= 2 && INTT_hits >= 1 && TPC_hits >= 20)
412 h_nGen_pTReco_cuts->Fill(pt);
413 h_pTRecoTruthMatchedRatio_pTReco_cuts->Fill(pt, pt_ratio);
422 std::cout << __PRETTY_FUNCTION__ <<
" : Fatal error: missing SvtxTrackMap" << std::endl;
434 std::cout <<
"QAG4SimulationTracking::process_event - processing ";
441 int candidate_embedding_id = trutheval->
get_embed(g4particle);
442 if (candidate_embedding_id < 0) candidate_embedding_id = -1;
448 double gpx = g4particle->
get_px();
449 double gpy = g4particle->
get_py();
450 double gpz = g4particle->
get_pz();
454 if (gpx != 0 && gpy != 0)
456 TVector3 gv(gpx, gpy, gpz);
465 std::cout <<
"QAG4SimulationTracking::process_event - accept particle eta = " << geta << std::endl;
471 std::cout <<
"QAG4SimulationTracking::process_event - ignore particle eta = " << geta << std::endl;
476 TParticlePDG *pdg_p = TDatabasePDG::Instance()->GetParticle(pid);
479 std::cout <<
"QAG4SimulationTracking::process_event - Error - invalid particle ID = " << pid << std::endl;
483 const double gcharge = pdg_p->Charge() / 3;
486 h_norm->Fill(
"Truth Track+", 1);
488 else if (gcharge < 0)
490 h_norm->Fill(
"Truth Track-", 1);
495 std::cout <<
"QAG4SimulationTracking::process_event - invalid particle ID = " << pid << std::endl;
498 h_norm->Fill(
"Truth Track", 1);
500 h_nGen_pTGen->Fill(gpt);
501 h_nGen_etaGen->Fill(geta);
505 const auto mapIter = g4particle_map.find(iter->first);
506 if (mapIter != g4particle_map.cend())
508 for (
const auto &cluster_key : mapIter->second)
515 std::cout <<
"QAG4SimulationTracking::process_event - could nof find clusters associated to G4Particle " << iter->first << std::endl;
523 bool match_found(
false);
529 if (g4particle_matched)
535 std::cout <<
"QAG4SimulationTracking::process_event - found unique match for g4 particle " << g4particle->
get_track_id() << std::endl;
540 std::cout <<
"QAG4SimulationTracking::process_event - none unique match for g4 particle " << g4particle->
get_track_id()
541 <<
". The track belong to g4 particle " << g4particle_matched->
get_track_id() << std::endl;
547 std::cout <<
"QAG4SimulationTracking::process_event - none unique match for g4 particle " << g4particle->
get_track_id()
548 <<
". The track belong to no g4 particle!" << std::endl;
554 h_nReco_etaGen->Fill(geta);
555 h_nReco_pTGen->Fill(gpt);
563 double px = track->
get_px();
564 double py = track->
get_py();
565 double pz = track->
get_pz();
567 TVector3
v(px, py, pz);
572 float pt_ratio = (gpt != 0) ? pt / gpt : 0;
573 h_pTRecoGenRatio->Fill(pt_ratio);
574 h_pTRecoGenRatio_pTGen->Fill(gpt, pt_ratio);
575 h_DCArPhi_pT->Fill(pt, dca3dxy);
576 h_DCAZ_pT->Fill(pt, dca3dz);
577 h_norm->Fill(
"Reco Track", 1);
584 const auto &cluster_key = *cluster_iter;
596 std::cout <<
"QAG4SimulationTracking::process_event - unkown tracker ID = " << trackerID <<
" from cluster " << cluster_key << std::endl;
599 if (MVTX_hits >= 2 && INTT_hits >= 1 && TPC_hits >= 20)
601 h_DCArPhi_pT_cuts->Fill(pt, dca3dxy);
602 h_DCAZ_pT_cuts->Fill(pt, dca3dz);
603 h_SigmalizedDCArPhi_pT->Fill(pt, dca3dxy / dca3dxysigma);
604 h_SigmalizedDCAZ_pT->Fill(pt, dca3dz / dca3dzsigma);
608 std::array<unsigned int, 3> nclusters = {{0, 0, 0}};
613 const auto &cluster_key = *cluster_iter;
617 h_nClus_layer->Fill(
layer);
628 std::cout <<
"QAG4SimulationTracking::process_event - unkown tracker ID = " << trackerID <<
" from cluster " << cluster_key << std::endl;
631 h_nMVTX_nReco_pTGen->Fill(gpt, nclusters[0]);
632 h_nINTT_nReco_pTGen->Fill(gpt, nclusters[1]);
633 h_nTPC_nReco_pTGen->Fill(gpt, nclusters[2]);
644 m_hitsets = findNode::getClass<TrkrHitSetContainer>(topNode,
"TRKR_HITSET");
647 std::cout <<
PHWHERE <<
" ERROR: Can't find TrkrHitSetContainer." << std::endl;
651 m_truthContainer = findNode::getClass<PHG4TruthInfoContainer>(topNode,
"G4TruthInfo");
654 std::cout <<
"QAG4SimulationTracking::load_nodes - Fatal Error - "
655 <<
"unable to find DST node "
656 <<
"G4TruthInfo" << std::endl;
661 m_cluster_map = findNode::getClass<TrkrClusterContainer>(topNode,
"TRKR_CLUSTER");
665 m_cluster_hit_map = findNode::getClass<TrkrClusterHitAssoc>(topNode,
"TRKR_CLUSTERHITASSOC");
669 m_hit_truth_map = findNode::getClass<TrkrHitTruthAssoc>(topNode,
"TRKR_HITTRUTHASSOC");
673 m_g4hits_tpc = findNode::getClass<PHG4HitContainer>(topNode,
"G4HIT_TPC");
674 m_g4hits_intt = findNode::getClass<PHG4HitContainer>(topNode,
"G4HIT_INTT");
675 m_g4hits_mvtx = findNode::getClass<PHG4HitContainer>(topNode,
"G4HIT_MVTX");
684 return std::string(
"h_") +
Name() + std::string(
"_");
695 for (
auto iter = range.first; iter != range.second; ++iter)
698 const auto &hit_key = iter->second;
705 for (
auto truth_iter = g4hit_map.begin(); truth_iter != g4hit_map.end(); ++truth_iter)
707 const auto g4hit_key = truth_iter->second.second;
732 if (g4hit) out.insert(g4hit);