3 #include <qa_modules/QAHistManagerDef.h>
11 #include <calobase/RawCluster.h>
12 #include <calobase/RawClusterContainer.h>
13 #include <calobase/RawTower.h>
14 #include <calobase/RawTowerContainer.h>
15 #include <calobase/RawTowerGeomContainer.h>
36 #include <CLHEP/Vector/ThreeVector.h>
49 :
SubsysReco(
"QAG4SimulationEicCalorimeter_" + calo_name)
50 , _calo_name(calo_name)
52 , _calo_hit_container(nullptr)
53 , _calo_abs_hit_container(nullptr)
54 , _truth_container(nullptr)
70 cout <<
"QAG4SimulationEicCalorimeter::InitRun - Fatal Error - "
71 <<
"unable to find DST node "
80 cout <<
"QAG4SimulationEicCalorimeter::InitRun - Fatal Error - "
81 <<
"unable to find DST node "
92 cout <<
"QAG4SimulationEicCalorimeter::InitRun - Fatal Error - "
93 <<
"unable to find DST node "
94 <<
"G4TruthInfo" << endl;
119 TString(
_calo_name) +
" Normalization;Items;Count", 10, .5, 10.5);
121 h->GetXaxis()->SetBinLabel(i++,
"Event");
122 h->GetXaxis()->SetBinLabel(i++,
"G4Hit Active");
123 h->GetXaxis()->SetBinLabel(i++,
"G4Hit Absor.");
124 h->GetXaxis()->SetBinLabel(i++,
"Tower");
125 h->GetXaxis()->SetBinLabel(i++,
"Tower Hit");
126 h->GetXaxis()->SetBinLabel(i++,
"Cluster");
127 h->GetXaxis()->LabelsOption(
"v");
133 cout <<
"QAG4SimulationEicCalorimeter::Init - Process sampling fraction"
140 cout <<
"QAG4SimulationEicCalorimeter::Init - Process tower occupancies"
147 cout <<
"QAG4SimulationEicCalorimeter::Init - Process tower occupancies"
158 cout <<
"QAG4SimulationEicCalorimeter::process_event() entered" << endl;
190 TH1D *h_norm =
dynamic_cast<TH1D *
>(hm->
getHisto(
193 h_norm->Fill(
"Event", 1);
211 TString(
_calo_name) +
" RZ projection;G4 Hit Z (cm);G4 Hit R (cm)", 1200, -300, 300,
216 TString(
_calo_name) +
" XY projection;G4 Hit X (cm);G4 Hit Y (cm)", 1200, -300, 300,
221 TString(
_calo_name) +
" shower lateral projection (last primary);Polar direction (cm);Azimuthal direction (cm)",
222 200, -30, 30, 200, -30, 30));
225 TString(
_calo_name) +
" sampling fraction;Sampling fraction", 1000, 0, .2));
229 TString(
_calo_name) +
" visible sampling fraction;Visible sampling fraction", 1000, 0,
234 TString(
_calo_name) +
" hit time (edep weighting);Hit time - T0 (ns);Geant4 energy density",
241 TString(
_calo_name) +
" fraction truth energy ;G4 edep / particle energy",
246 TString(
_calo_name) +
" fraction visible energy from EM; visible energy from e^{#pm} / total visible energy",
255 cout <<
"QAG4SimulationEicCalorimeter::process_event_G4Hit() entered" << endl;
262 TH1D *h_norm =
dynamic_cast<TH1D *
>(hm->
getHisto(
270 double total_primary_energy = 1
e-9;
272 particle_iter != primary_range.second; ++particle_iter)
276 total_primary_energy += particle->
get_e();
282 assert(last_primary);
287 <<
"QAG4SimulationEicCalorimeter::process_event_G4Hit() handle this truth particle"
289 last_primary->identify();
297 <<
"QAG4SimulationEicCalorimeter::process_event_G4Hit() handle this vertex"
302 const double t0 = primary_vtx->
get_t();
303 const TVector3 vertex(primary_vtx->
get_x(), primary_vtx->
get_y(),
304 primary_vtx->
get_z());
307 TVector3 axis_proj(last_primary->get_px(), last_primary->get_py(),
308 last_primary->get_pz());
309 if (axis_proj.Mag() == 0)
310 axis_proj.SetXYZ(0, 0, 1);
311 axis_proj = axis_proj.Unit();
314 TVector3 axis_azimuth = axis_proj.Cross(TVector3(0, 0, 1));
315 if (axis_azimuth.Mag() == 0)
316 axis_azimuth.SetXYZ(1, 0, 0);
317 axis_azimuth = axis_azimuth.Unit();
320 TVector3 axis_polar = axis_proj.Cross(axis_azimuth);
321 assert(axis_polar.Mag() > 0);
322 axis_polar = axis_polar.Unit();
325 double ev_calo = 0.0;
326 double ea_calo = 0.0;
327 double ev_calo_em = 0.0;
331 TH2F *hrz =
dynamic_cast<TH2F *
>(hm->
getHisto(
334 TH2F *hxy =
dynamic_cast<TH2F *
>(hm->
getHisto(
337 TH1F *ht =
dynamic_cast<TH1F *
>(hm->
getHisto(
340 TH2F *hlat =
dynamic_cast<TH2F *
>(hm->
getHisto(
348 hit_iter != calo_hit_range.second; hit_iter++)
350 PHG4Hit *this_hit = hit_iter->second;
361 cout << __PRETTY_FUNCTION__ <<
" - Error - this PHG4hit missing particle: ";
371 hrz->Fill(hit.Z(), hit.Perp(), this_hit->
get_edep());
372 hxy->Fill(hit.X(), hit.Y(), this_hit->
get_edep());
375 const double hit_azimuth = axis_azimuth.Dot(hit - vertex);
376 const double hit_polar = axis_polar.Dot(hit - vertex);
377 hlat->Fill(hit_polar, hit_azimuth, this_hit->
get_edep());
388 hit_iter != calo_abs_hit_range.second; hit_iter++)
390 PHG4Hit *this_hit = hit_iter->second;
398 cout <<
"QAG4SimulationEicCalorimeter::process_event_G4Hit::" <<
_calo_name
399 <<
" - SF = " << e_calo / (e_calo + ea_calo + 1
e-9) <<
", VSF = "
400 << ev_calo / (e_calo + ea_calo + 1
e-9) << endl;
402 if (e_calo + ea_calo > 0)
406 h->Fill(e_calo / (e_calo + ea_calo));
410 h->Fill(ev_calo / (e_calo + ea_calo));
413 h =
dynamic_cast<TH1F *
>(hm->
getHisto(
416 h->Fill((e_calo + ea_calo) / total_primary_energy);
420 h =
dynamic_cast<TH1F *
>(hm->
getHisto(
423 h->Fill(ev_calo_em / (ev_calo));
427 cout <<
"QAG4SimulationEicCalorimeter::process_event_G4Hit::" <<
_calo_name
428 <<
" - histogram " << h->GetName() <<
" Get Sum = " << h->GetSum()
440 TString(
_calo_name) +
" 1x1 tower;1x1 TOWER Energy (GeV)", 100, 9
e-4, 100);
446 TString(
_calo_name) +
" 1x1 tower max per event;1x1 tower max per event (GeV)", 5000,
450 TString(
_calo_name) +
" 2x2 tower;2x2 TOWER Energy (GeV)", 100, 9
e-4, 100);
455 TString(
_calo_name) +
" 2x2 tower max per event;2x2 tower max per event (GeV)", 5000,
459 TString(
_calo_name) +
" 3x3 tower;3x3 TOWER Energy (GeV)", 100, 9
e-4, 100);
464 TString(
_calo_name) +
" 3x3 tower max per event;3x3 tower max per event (GeV)", 5000,
468 TString(
_calo_name) +
" 4x4 tower;4x4 TOWER Energy (GeV)", 100, 9
e-4, 100);
473 TString(
_calo_name) +
" 4x4 tower max per event;4x4 tower max per event (GeV)", 5000,
477 TString(
_calo_name) +
" 5x5 tower;5x5 TOWER Energy (GeV)", 100, 9
e-4, 100);
482 TString(
_calo_name) +
" 5x5 tower max per event;5x5 tower max per event (GeV)", 5000,
493 cout <<
"QAG4SimulationEicCalorimeter::process_event_Tower() entered" << endl;
497 TH1D *h_norm =
dynamic_cast<TH1D *
>(hm->
getHisto(
501 string towernodename =
"TOWER_CALIB_" + detector;
504 towernodename.c_str());
507 std::cout <<
PHWHERE <<
": Could not find node " << towernodename.c_str()
511 string towergeomnodename =
"TOWERGEOM_" + detector;
513 topNode, towergeomnodename.c_str());
516 cout <<
PHWHERE <<
": Could not find node " << towergeomnodename.c_str()
521 static const int max_size = 5;
522 map<int, string> size_label;
523 size_label[1] =
"1x1";
524 size_label[2] =
"2x2";
525 size_label[3] =
"3x3";
526 size_label[4] =
"4x4";
527 size_label[5] =
"5x5";
528 map<int, double> max_energy;
529 map<int, TH1F *> energy_hist_list;
530 map<int, TH1F *> max_energy_hist_list;
532 for (
int size = 1; size <= max_size; ++size)
534 max_energy[size] = 0;
536 TH1F *
h =
dynamic_cast<TH1F *
>(hm->
getHisto(
539 energy_hist_list[size] =
h;
540 h =
dynamic_cast<TH1F *
>(hm->
getHisto(
543 max_energy_hist_list[size] =
h;
546 h_norm->Fill(
"Tower", towergeom->
size());
547 h_norm->Fill(
"Tower Hit", towers->
size());
549 for (
int binphi = 0; binphi < towergeom->
get_phibins(); ++binphi)
551 for (
int bineta = 0; bineta < towergeom->
get_etabins(); ++bineta)
553 for (
int size = 1; size <= max_size; ++size)
556 if ((size == 2 or size == 4) and ((binphi % 2 != 0) and (bineta % 2 != 0)))
562 for (
int iphi = binphi; iphi < binphi + size; ++iphi)
564 for (
int ieta = bineta; ieta < bineta + size; ++ieta)
571 assert(wrapphi >= 0);
588 energy_hist_list[size]->Fill(energy == 0 ? 9.1
e-4 : energy);
590 if (energy > max_energy[size])
591 max_energy[size] = energy;
597 for (
int size = 1; size <= max_size; ++size)
599 max_energy_hist_list[size]->Fill(max_energy[size]);
611 TString(
_calo_name) +
" best matched cluster E/E_{Truth};E_{Cluster}/E_{Truth}", 150,
616 TString(
_calo_name) +
" best cluster lateral projection (last primary);Polar direction (cm);Azimuthal direction (cm)",
617 200, -15, 15, 200, -15, 15));
625 cout <<
"QAG4SimulationEicCalorimeter::process_event_Cluster() entered"
630 string towergeomnodename =
"TOWERGEOM_" +
_calo_name;
632 topNode, towergeomnodename.c_str());
635 cout <<
PHWHERE <<
": Could not find node " << towergeomnodename.c_str()
641 TH1D *h_norm =
dynamic_cast<TH1D *
>(hm->
getHisto(
645 std::string nodename =
"CLUSTER_" +
_calo_name;
647 topNode, nodename.c_str());
649 h_norm->Fill(
"Cluster", clusters->
size());
655 assert(last_primary);
660 <<
"QAG4SimulationEicCalorimeter::process_event_Cluster() handle this truth particle"
662 last_primary->identify();
669 TH1F *
h =
dynamic_cast<TH1F *
>(hm->
getHisto(
679 cout <<
"QAG4SimulationEicCalorimeter::process_event_Cluster::"
680 <<
_calo_name <<
" - get cluster with energy "
681 << cluster->
get_energy() <<
" VS primary energy "
682 << last_primary->get_e() << endl;
684 h->Fill(cluster->
get_energy() / (last_primary->get_e() + 1
e-9));
695 <<
"QAG4SimulationEicCalorimeter::process_event_Cluster() handle this vertex"
697 primary_vtx->identify();
700 const CLHEP::Hep3Vector vertex(primary_vtx->get_x(), primary_vtx->get_y(),
701 primary_vtx->get_z());
704 CLHEP::Hep3Vector axis_proj(last_primary->get_px(), last_primary->get_py(),
705 last_primary->get_pz());
706 if (axis_proj.mag() == 0)
707 axis_proj.set(0, 0, 1);
708 axis_proj = axis_proj.unit();
711 CLHEP::Hep3Vector axis_azimuth = axis_proj.cross(CLHEP::Hep3Vector(0, 0, 1));
712 if (axis_azimuth.mag() == 0)
713 axis_azimuth.set(1, 0, 0);
714 axis_azimuth = axis_azimuth.unit();
717 CLHEP::Hep3Vector axis_polar = axis_proj.cross(axis_azimuth);
718 assert(axis_polar.mag() > 0);
719 axis_polar = axis_polar.unit();
721 TH2F *hlat =
dynamic_cast<TH2F *
>(hm->
getHisto(
725 const double hit_azimuth = axis_azimuth.dot(hit - vertex);
726 const double hit_polar = axis_polar.dot(hit - vertex);
727 hlat->Fill(hit_polar, hit_azimuth);
732 cout <<
"QAG4SimulationEicCalorimeter::process_event_Cluster::"