2 #include <qautils/QAUtil.h>
3 #include <qautils/QAHistManagerDef.h>
49 , m_truthContainer(nullptr)
73 std::cout <<
"QAG4SimulationTpc::InitRun - Fatal Error - "
74 <<
"unable to find node G4TruthInfo" << std::endl;
80 findNode::getClass<PHG4TpcCylinderGeomContainer>(topNode,
"CYLINDERCELLGEOM_SVTX");
84 std::cout <<
PHWHERE <<
" unable to find DST node CYLINDERCELLGEOM_SVTX" << std::endl;
89 std::vector<int> region_layer_low = {7, 23, 39};
91 std::vector<int> region_layer_high = {22, 38, 54};
96 for (
auto iter = range.first; iter != range.second; ++iter)
100 for (
int region = 0; region < 3; ++region)
102 if (iter->first >= region_layer_low[region] && iter->first <= region_layer_high[region])
115 auto h =
new TH1F(Form(
"%sefficiency_0",
get_histo_prefix().c_str()), Form(
"TPC_truth_clusters"), 48, 7, 54);
116 h->GetXaxis()->SetTitle(
"sPHENIX layer");
117 hm->registerHisto(
h);
121 auto h =
new TH1F(Form(
"%sefficiency_1",
get_histo_prefix().c_str()), Form(
"TPC_matched_clusters"), 48, 7, 54);
122 h->GetXaxis()->SetTitle(
"sPHENIX layer");
123 hm->registerHisto(
h);
127 for (
int region = 0; region < 3; ++region)
129 if (
Verbosity()) std::cout <<
PHWHERE <<
" adding region " << region <<
" with layers " << region_layer_low[region] <<
" to " << region_layer_high[region] << std::endl;
132 auto h =
new TH1F(Form(
"%sdrphi_%i",
get_histo_prefix().c_str(), region), Form(
"TPC r#Delta#phi_{cluster-truth} region_%i", region), 100, -0.079, 0.075);
133 h->GetXaxis()->SetTitle(
"r#Delta#phi_{cluster-truth} (cm)");
134 hm->registerHisto(
h);
139 auto h =
new TH1F(Form(
"%srphi_error_%i",
get_histo_prefix().c_str(), region), Form(
"TPC r#Delta#phi error region_%i", region), 100, 0, 0.075);
140 h->GetXaxis()->SetTitle(
"r#Delta#phi error (cm)");
141 hm->registerHisto(
h);
146 auto h =
new TH1F(Form(
"%sphi_pulls_%i",
get_histo_prefix().c_str(), region), Form(
"TPC #Delta#phi_{cluster-truth}/#sigma#phi region_%i", region), 100, -3, 3);
147 h->GetXaxis()->SetTitle(
"#Delta#phi_{cluster-truth}/#sigma#phi (cm)");
148 hm->registerHisto(
h);
153 auto h =
new TH1F(Form(
"%sdz_%i",
get_histo_prefix().c_str(), region), Form(
"TPC #Deltaz_{cluster-truth} region_%i", region), 100, -0.19, 0.19);
154 h->GetXaxis()->SetTitle(
"#Delta#z_{cluster-truth} (cm)");
155 hm->registerHisto(
h);
160 auto h =
new TH1F(Form(
"%sz_error_%i",
get_histo_prefix().c_str(), region), Form(
"TPC z error region_%i", region), 100, 0, 0.18);
161 h->GetXaxis()->SetTitle(
"z error (cm)");
162 hm->registerHisto(
h);
167 auto h =
new TH1F(Form(
"%sz_pulls_%i",
get_histo_prefix().c_str(), region), Form(
"TPC #Deltaz_{cluster-truth}/#sigmaz region_%i", region), 100, -3, 3);
168 h->GetXaxis()->SetTitle(
"#Delta#z_{cluster-truth}/#sigmaz (cm)");
169 hm->registerHisto(
h);
174 auto h =
new TH1F(Form(
"%sclus_size_%i",
get_histo_prefix().c_str(), region), Form(
"TPC cluster size region_%i", region), 30, 0, 30);
175 h->GetXaxis()->SetTitle(
"csize");
176 hm->registerHisto(
h);
181 auto h =
new TH1F(Form(
"%sclus_size_phi_%i",
get_histo_prefix().c_str(), region), Form(
"TPC cluster size (#phi) region_%i", region), 10, 0, 10);
182 h->GetXaxis()->SetTitle(
"csize_{#phi}");
183 hm->registerHisto(
h);
188 auto h =
new TH1F(Form(
"%sclus_size_z_%i",
get_histo_prefix().c_str(), region), Form(
"TPC cluster size (z) region_%i", region), 12, 0, 12);
189 h->GetXaxis()->SetTitle(
"csize_{z}");
190 hm->registerHisto(
h);
221 m_cluster_map = findNode::getClass<TrkrClusterContainer>(topNode,
"TRKR_CLUSTER");
224 std::cout <<
PHWHERE <<
" unable to find DST node TRKR_CLUSTER" << std::endl;
228 m_tGeometry = findNode::getClass<ActsGeometry>(topNode,
"ActsGeometry");
231 std::cout <<
PHWHERE <<
"No acts tracking geometry, exiting."
236 m_cluster_hit_map = findNode::getClass<TrkrClusterHitAssoc>(topNode,
"TRKR_CLUSTERHITASSOC");
239 std::cout <<
PHWHERE <<
" unable to find DST node TRKR_CLUSTERHITASSOC" << std::endl;
243 m_hit_truth_map = findNode::getClass<TrkrHitTruthAssoc>(topNode,
"TRKR_HITTRUTHASSOC");
246 std::cout <<
PHWHERE <<
" unable to find DST node TRKR_HITTRUTHASSOC" << std::endl;
250 m_g4hits_tpc = findNode::getClass<PHG4HitContainer>(topNode,
"G4HIT_TPC");
253 std::cout <<
PHWHERE <<
" unable to find DST node G4HIT_TPC" << std::endl;
273 TH1* h_eff0 =
dynamic_cast<TH1*
>(hm->getHisto(Form(
"%sefficiency_0",
get_histo_prefix().c_str())));
275 TH1* h_eff1 =
dynamic_cast<TH1*
>(hm->getHisto(Form(
"%sefficiency_1",
get_histo_prefix().c_str())));
281 TH1* drphi =
nullptr;
282 TH1* rphi_error =
nullptr;
283 TH1* phi_pulls =
nullptr;
286 TH1* z_error =
nullptr;
287 TH1* z_pulls =
nullptr;
289 TH1* csize =
nullptr;
290 TH1* csize_phi =
nullptr;
291 TH1* csize_z =
nullptr;
294 using HistogramMap = std::map<int, HistogramList>;
295 HistogramMap histograms;
297 for (
int region = 0; region < 3; ++region)
300 h.drphi =
dynamic_cast<TH1*
>(hm->getHisto(Form(
"%sdrphi_%i",
get_histo_prefix().c_str(), region)));
301 h.rphi_error =
dynamic_cast<TH1*
>(hm->getHisto(Form(
"%srphi_error_%i",
get_histo_prefix().c_str(), region)));
302 h.phi_pulls =
dynamic_cast<TH1*
>(hm->getHisto(Form(
"%sphi_pulls_%i",
get_histo_prefix().c_str(), region)));
304 h.dz =
dynamic_cast<TH1*
>(hm->getHisto(Form(
"%sdz_%i",
get_histo_prefix().c_str(), region)));
305 h.z_error =
dynamic_cast<TH1*
>(hm->getHisto(Form(
"%sz_error_%i",
get_histo_prefix().c_str(), region)));
306 h.z_pulls =
dynamic_cast<TH1*
>(hm->getHisto(Form(
"%sz_pulls_%i",
get_histo_prefix().c_str(), region)));
308 h.csize =
dynamic_cast<TH1*
>(hm->getHisto(Form(
"%sclus_size_%i",
get_histo_prefix().c_str(), region)));
309 h.csize_phi =
dynamic_cast<TH1*
>(hm->getHisto(Form(
"%sclus_size_phi_%i",
get_histo_prefix().c_str(), region)));
310 h.csize_z =
dynamic_cast<TH1*
>(hm->getHisto(Form(
"%sclus_size_z_%i",
get_histo_prefix().c_str(), region)));
312 histograms.insert(std::make_pair(region, h));
318 std::cout <<
PHWHERE <<
" get all truth clusters for primary particles " << std::endl;
324 iter != range.second;
331 float gembed = trutheval->
get_embed(g4particle);
335 std::cout <<
PHWHERE <<
" PHG4Particle ID " << gtrackID <<
" gembed " << gembed <<
" gflavor " << gflavor <<
" gprimary " << gprimary << std::endl;
344 for (
const auto& [gkey, gclus] : truth_clusters)
347 if (
layer < 7)
continue;
349 float gx = gclus->getX();
350 float gy = gclus->getY();
351 float gz = gclus->getZ();
353 xy_pts.emplace_back(gx, gy);
354 rz_pts.emplace_back(std::sqrt(gx * gx + gy * gy), gz);
361 if (std::isnan(
R))
continue;
364 for (
const auto& [gkey, gclus] : truth_clusters)
369 if (
layer < 7)
continue;
371 float gx = gclus->getX();
372 float gy = gclus->getY();
373 float gz = gclus->getZ();
374 float gedep = gclus->getError(0, 0);
375 float ng4hits = gclus->getAdc();
378 const auto gphi = std::atan2(gclus->getY(), gclus->getX());
382 std::cout <<
" gkey " << gkey <<
" detID " << detID <<
" tpcId " <<
TrkrDefs::tpcId <<
" layer " <<
layer <<
" truth clus " << gkey <<
" ng4hits " << ng4hits <<
" gr " <<
gr <<
" gx " << gx <<
" gy " << gy <<
" gz " << gz
383 <<
" gphi " << gphi <<
" gedep " << gedep << std::endl;
400 const auto z_cluster = global(2);
401 const auto phi_cluster = (float) std::atan2(global(1), global(0));
403 double phi_error = rclus->getRPhiError() / r_cluster;
404 double z_error = rclus->getZError();
407 const auto dz = z_cluster -
gz;
411 int region =
it->second;
415 std::cout <<
" Found match in layer " <<
layer <<
" region " << region <<
" for gtrackID " << gtrackID << std::endl;
416 std::cout <<
" x " << rclus->getX() <<
" y " << rclus->getY() <<
" z " << rclus->getZ() << std::endl;
417 std::cout <<
" gx " << gclus->getX() <<
" gy " << gclus->getY() <<
" gz " << gclus->getZ() << std::endl;
418 std::cout <<
" drphi " << r_cluster *
dphi <<
" rphi_error " << r_cluster * phi_error <<
" dz " <<
dz <<
" z_error " << z_error << std::endl;
421 const auto hiter = histograms.find(region);
422 if (hiter == histograms.end())
continue;
425 auto fill = [](TH1*
h,
float value)
426 {
if( h ) h->Fill(
value ); };
427 fill(hiter->second.drphi, r_cluster *
dphi);
428 fill(hiter->second.rphi_error, r_cluster * phi_error);
429 fill(hiter->second.phi_pulls, dphi / phi_error);
432 fill(hiter->second.dz,
dz);
433 fill(hiter->second.z_error, z_error);
434 fill(hiter->second.z_pulls,
dz / z_error);
439 fill(hiter->second.csize,
std::distance(hit_range.first, hit_range.second));
443 for (
auto hit_iter = hit_range.first; hit_iter != hit_range.second; ++hit_iter)
445 const auto& hit_key = hit_iter->second;
450 fill(hiter->second.csize_phi, phibins.size());
451 fill(hiter->second.csize_z, zbins.size());
466 for (
auto iter = range.first; iter != range.second; ++iter)
469 const auto& hit_key = iter->second;
476 for (
auto truth_iter = g4hit_map.begin(); truth_iter != g4hit_map.end(); ++truth_iter)
479 const auto g4hit_key = truth_iter->second.second;
485 if (g4hit) out.insert(g4hit);