9 #include <calobase/RawTowerContainer.h>
10 #include <calobase/RawTowerGeomContainer.h>
11 #include <calobase/RawTower.h>
12 #include <calobase/RawClusterContainer.h>
13 #include <calobase/RawCluster.h>
35 #include <TLorentzVector.h>
53 _calo_name(calo_name),
54 _calo_hit_container(nullptr), _calo_abs_hit_container(nullptr), _truth_container(nullptr)
71 <<
"Proto4SampleFrac::get_HistoManager - Making Fun4AllHistoManager Proto4SampleFrac_HISTOS"
91 cout <<
"Proto4SampleFrac::InitRun" << endl;
95 "PHCompositeNode",
"DST"));
100 std::cerr <<
PHWHERE <<
"DST Node missing, doing nothing." << std::endl;
102 "Failed to find DST node in EmcRawTowerBuilder::CreateNodes");
109 cout <<
"Proto4SampleFrac::InitRun - Fatal Error - "
110 <<
"unable to find DST node " <<
"G4HIT_" +
_calo_name << endl;
118 cout <<
"Proto4SampleFrac::InitRun - Fatal Error - "
119 <<
"unable to find DST node " <<
"G4HIT_ABSORBER_" +
_calo_name
128 cout <<
"Proto4SampleFrac::InitRun - Fatal Error - "
129 <<
"unable to find DST node " <<
"G4TruthInfo" << endl;
138 cout <<
"Proto4SampleFrac::End - write to " <<
_filename << endl;
143 for (
unsigned int i = 0;
i < hm->
nHistos();
i++)
154 cout <<
"Proto4SampleFrac::get_HistoManager - Making PHTFileServer "
162 TString(
_calo_name) +
" Normalization;Items;Count", 10, .5, 10.5);
164 h_info->GetXaxis()->SetBinLabel(i++,
"Event");
165 h_info->GetXaxis()->SetBinLabel(i++,
"G4Hit Active");
166 h_info->GetXaxis()->SetBinLabel(i++,
"G4Hit Absor.");
167 h_info->GetXaxis()->LabelsOption(
"v");
172 TString(
_calo_name) +
" RZ projection;Z (cm);R (cm)", 1200, -300, 300,
177 TString(
_calo_name) +
" XY projection;X (cm);Y (cm)", 3000, 50, 350,
184 TString(
_calo_name) +
" XY projection;X (cm);Y (cm)", 3000, 50, 350,
189 TString(
_calo_name) +
" XY projection;X (cm);Y (cm)", 3000, 50, 350,
194 TString(
_calo_name) +
" XY projection;X (cm);Y (cm)", 3000, 50, 350,
200 +
" shower lateral projection (last primary);Polar direction (cm);Azimuthal direction (cm)",
201 200, -30, 30, 200, -30, 30));
204 TString(
_calo_name) +
" sampling fraction;Sampling fraction", 1000, 0, 1.0));
209 +
" visible sampling fraction;Visible sampling fraction", 1000, 0, 1.0));
214 +
" hit time (edep weighting);Hit time - T0 (ns);Geant4 energy density",
221 +
" fraction truth energy ;G4 energy (active + absorber) / total truth energy",
227 +
" fraction visible energy from EM; visible energy from e^{#pm} / total visible energy",
235 if (
Verbosity() > 2) cout <<
"Proto4SampleFrac::process_event() entered" << endl;
249 double total_primary_energy = 1
e-9;
251 particle_iter != primary_range.second; ++particle_iter)
255 total_primary_energy += particle->
get_e();
265 <<
"QAG4SimulationCalorimeter::process_event_G4Hit() handle this truth particle"
267 last_primary->identify();
275 <<
"QAG4SimulationCalorimeter::process_event_G4Hit() handle this vertex"
280 const double t0 = primary_vtx->
get_t();
282 primary_vtx->
get_z());
285 TVector3 axis_proj(last_primary->get_px(), last_primary->get_py(),
286 last_primary->get_pz());
287 if (axis_proj.Mag() == 0)
288 axis_proj.SetXYZ(0, 0, 1);
289 axis_proj = axis_proj.Unit();
292 TVector3 axis_azimuth = axis_proj.Cross(TVector3(0, 0, 1));
293 if (axis_azimuth.Mag() == 0)
294 axis_azimuth.SetXYZ(1, 0, 0);
295 axis_azimuth = axis_azimuth.Unit();
298 TVector3 axis_polar = axis_proj.Cross(axis_azimuth);
299 assert(axis_polar.Mag() > 0);
300 axis_polar = axis_polar.Unit();
303 double ev_calo = 0.0;
304 double ea_calo = 0.0;
305 double ev_calo_em = 0.0;
309 TH2F * hrz =
dynamic_cast<TH2F*
>(hm->
getHisto(
313 TH2F * hxy_cal =
dynamic_cast<TH2F*
>(hm->
getHisto(
317 TH2F * hmat_xy_cal =
dynamic_cast<TH2F*
>(hm->
getHisto(
321 TH1F * ht =
dynamic_cast<TH1F*
>(hm->
getHisto(
325 TH2F * hlat =
dynamic_cast<TH2F*
>(hm->
getHisto(
333 hit_iter != calo_hit_range.second; hit_iter++)
336 PHG4Hit *this_hit = hit_iter->second;
347 cout <<__PRETTY_FUNCTION__<<
" - Error - this PHG4hit missing particle: "; this_hit ->
identify();
350 if (abs(particle->
get_pid()) == 11)
356 hrz->Fill(hit.Z(), hit.Perp(), this_hit->
get_edep());
357 hxy_cal->Fill(hit.X(), hit.Y(), this_hit->
get_edep());
360 const double hit_azimuth = axis_azimuth.Dot(hit -
vertex);
361 const double hit_polar = axis_polar.Dot(hit -
vertex);
362 hlat->Fill(hit_polar, hit_azimuth, this_hit->
get_edep());
364 const TVector3 hit_entry(this_hit->
get_x(0), this_hit->
get_y(0), this_hit->
get_z(0));
365 const TVector3 hit_exit(this_hit->
get_x(1), this_hit->
get_y(1), this_hit->
get_z(1));
366 hmat_xy_cal->Fill(hit_entry.X(),hit_entry.Y());
367 hmat_xy_cal->Fill(hit_exit.X(),hit_exit.Y());
375 TH2F * hxy_abs =
dynamic_cast<TH2F*
>(hm->
getHisto(
379 TH2F * hmat_xy_abs =
dynamic_cast<TH2F*
>(hm->
getHisto(
386 hit_iter != calo_abs_hit_range.second; hit_iter++)
389 PHG4Hit *this_hit = hit_iter->second;
397 hxy_abs->Fill(hit.X(), hit.Y(), this_hit->
get_edep());
399 const TVector3 hit_entry(this_hit->
get_x(0), this_hit->
get_y(0), this_hit->
get_z(0));
400 const TVector3 hit_exit(this_hit->
get_x(1), this_hit->
get_y(1), this_hit->
get_z(1));
401 hmat_xy_abs->Fill(hit_entry.X(),hit_entry.Y());
402 hmat_xy_abs->Fill(hit_exit.X(),hit_exit.Y());
407 cout <<
"QAG4SimulationCalorimeter::process_event_G4Hit::" <<
_calo_name
408 <<
" - SF = " << e_calo / (e_calo + ea_calo + 1
e-9) <<
", VSF = "
409 << ev_calo / (e_calo + ea_calo + 1
e-9) << endl;
411 if (e_calo + ea_calo > 0)
415 h->Fill(e_calo / (e_calo + ea_calo));
419 h->Fill(ev_calo / (e_calo + ea_calo));
422 h =
dynamic_cast<TH1F*
>(hm->
getHisto(
425 h->Fill((e_calo + ea_calo) / total_primary_energy);
429 h =
dynamic_cast<TH1F*
>(hm->
getHisto(
432 h->Fill(ev_calo_em / (ev_calo));
436 cout <<
"QAG4SimulationCalorimeter::process_event_G4Hit::" <<
_calo_name
437 <<
" - histogram " << h->GetName() <<
" Get Sum = " << h->GetSum()
442 h_info->Fill(
"Event", 1);
450 const int clus_edge_size = (cluster_size - 1) / 2;
451 assert(clus_edge_size >= 0);
453 pair<int, int> max(-1000, -1000);
457 for (
int row = 0; row <
n_size; ++row)
461 for (
int dcol =
col - clus_edge_size; dcol <=
col + clus_edge_size;
463 for (
int drow = row - clus_edge_size; drow <= row + clus_edge_size;
466 if (dcol < 0 or drow < 0)
476 max = make_pair(
col, row);