23 #include <calobase/RawCluster.h>
24 #include <calobase/RawTower.h>
25 #include <calobase/RawTowerContainer.h>
26 #include <calobase/RawTowerGeomContainer.h>
29 #include <mvtx/MvtxDefs.h>
55 #include <HepMC/GenEvent.h>
56 #include <HepMC/GenParticle.h>
57 #include <HepMC/GenVertex.h>
58 #include <HepMC/IteratorRange.h>
59 #include <HepMC/SimpleVector.h>
60 #include <HepMC/Units.h>
62 #include <gsl/gsl_const.h>
63 #include <gsl/gsl_randist.h>
64 #include <gsl/gsl_rng.h>
67 #include <TDatabasePDG.h>
96 cout <<
"SynRadAna::SynRadAna(const std::string &name) Calling ctor" << endl;
103 cout <<
"SynRadAna::~SynRadAna() Calling dtor" << endl;
110 cout <<
"SynRadAna::Init(PHCompositeNode *topNode) Initializing" << endl;
121 h->GetXaxis()->SetBinLabel(i++,
"Event");
122 h->GetXaxis()->SetBinLabel(i++,
"Photon");
123 h->GetXaxis()->SetBinLabel(i++,
"Flux");
124 h->GetXaxis()->SetBinLabel(i++,
"G4Particle");
125 h->GetXaxis()->SetBinLabel(i++,
"G4PrimaryParticle");
126 h->GetXaxis()->SetBinLabel(i++,
"G4Vertex");
127 h->GetXaxis()->LabelsOption(
"v");
136 "Hit sum;Sum number of hits", 2000, -.5, 2000 - .5, 2, .5, 2.5);
138 h2->GetYaxis()->SetBinLabel(1,
"Flux");
139 h2->GetYaxis()->SetBinLabel(2,
"Photon");
143 "Hit sum energy distribution;Ionizing energy deposition [keV]", 2000, 0, 100, 2, .5, 2.5);
145 h2->GetYaxis()->SetBinLabel(1,
"Flux");
146 h2->GetYaxis()->SetBinLabel(2,
"Photon");
150 "Hit source photon;Photon energy [keV]", 2000, 0, 100, 2, .5, 2.5);
152 h2->GetYaxis()->SetBinLabel(1,
"Flux");
153 h2->GetYaxis()->SetBinLabel(2,
"Photon");
157 "#gamma z crossing interface facet [cm]", 800, -400, 400, 2, .5, 2.5);
159 h2->GetYaxis()->SetBinLabel(1,
"Flux");
160 h2->GetYaxis()->SetBinLabel(2,
"Photon");
172 "Source photon;Photon energy [keV]", 2000, 0, 100, 2, .5, 2.5);
174 h2->GetYaxis()->SetBinLabel(1,
"Flux");
175 h2->GetYaxis()->SetBinLabel(2,
"Photon");
179 "#gamma z crossing interface facet [cm]", 800, -400, 400, 2, .5, 2.5);
181 h2->GetYaxis()->SetBinLabel(1,
"Flux");
182 h2->GetYaxis()->SetBinLabel(2,
"Photon");
191 "Hit sum;Sum number of hits", 2000, -.5, 2000 - .5, 2, .5, 2.5);
193 h2->GetYaxis()->SetBinLabel(1,
"Flux");
194 h2->GetYaxis()->SetBinLabel(2,
"Photon");
198 "Hit sum;Sum number of hits;layer", 2000, -.5, 2000 - .5, 3, -.5, 2.5);
207 "Hit sum;Sum number of hits", 2000, -.5, 2000 - .5, 2, .5, 2.5);
209 h2->GetYaxis()->SetBinLabel(1,
"Flux");
210 h2->GetYaxis()->SetBinLabel(2,
"Photon");
214 "Hit sum;Sum number of hits;layer", 2000, -.5, 2000 - .5, 61, -.5, 60.5);
225 cout <<
"SynRadAna::InitRun(PHCompositeNode *topNode) Initializing for Run XXX" << endl;
234 cout <<
"SynRadAna::process_event(PHCompositeNode *topNode) Processing Event" << endl;
236 static const double GeV2keV = 1e6;
244 h_norm->Fill(
"Event", 1);
249 h_norm->Fill(
"G4Particle", truthInfoList->
size());
254 PHHepMCGenEventMap *genevtmap = findNode::getClass<PHHepMCGenEventMap>(topNode,
"PHHepMCGenEventMap");
258 HepMC::GenEvent *hepmc_evt = genev->
getEvent();
267 const auto &weightcontainer = hepmc_evt->weights();
268 assert(weightcontainer.size() >= 2);
269 h_norm->Fill(
"Flux", weightcontainer[0]);
270 h_norm->Fill(
"Photon", weightcontainer[1]);
271 if (weightcontainer[1] != 1)
273 cout << __PRETTY_FUNCTION__ <<
"- warning - weightcontainer[1] = " << weightcontainer[1]
274 <<
" != 1. Can not precisely pin point each photon's flux!"
292 particle_iter != primary_range.second;
295 const auto particle = particle_iter->second;
300 const double photon_e_keV =
particle->get_e() * GeV2keV;
302 h_photonEnergy->Fill(photon_e_keV,
"Photon", 1);
307 const double photon_z = vtx->
get_z();
309 h_photonZ->Fill(photon_z,
"Photon", 1);
313 cout << __PRETTY_FUNCTION__ <<
"- warning - non-photon source!";
322 string(
"G4HIT_" + hitnode));
325 cout << __PRETTY_FUNCTION__ <<
" - Fatal Error - missing " <<
string(
"G4HIT_" + hitnode) << endl;
332 cout <<
"SynRadAna::process_event - processing "
333 << hitnode <<
" and received " << hits->
size() <<
" hits"
337 double sumEdep_keV(0);
339 map<PHG4Particle *, pair<double, double> > primary_photon_map;
341 hit_iter != hit_range.second; hit_iter++)
343 PHG4Hit *hit = hit_iter->second;
348 const double eion_keV = hit->
get_eion() * GeV2keV;
349 sumEdep_keV += eion_keV;
357 if (primary_particle->
get_pid() != 22)
359 cout <<
"SynRadAna::process_event - WARNING - unexpected primary particle that is not photon: ";
364 const double photon_e_keV = primary_particle->
get_e() * GeV2keV;
368 const double photon_z = vtx->
get_z();
370 primary_photon_map.insert(
371 make_pair(primary_particle,
372 make_pair(photon_e_keV, photon_z)));
388 h_nHit->Fill(nhit,
"Photon", 1);
392 if (primary_photon_map.size() != 1)
394 cout <<
"SynRadAna::process_event - WARNING - primary_photon_map.size() = " << primary_photon_map.size() << endl;
399 for (
auto &pair : primary_photon_map)
401 const std::pair<double, double> & e_z = pair.second;
404 h_photonEnergy->Fill(e_z.first,
"Photon", 1);
407 h_photonZ->Fill(e_z.second,
"Photon", 1);
411 h_sumEdep->Fill(sumEdep_keV,
"Photon", 1);
419 TrkrHitSetContainer *trkrhitsetcontainer = findNode::getClass<TrkrHitSetContainer>(topNode,
"TRKR_HITSET");
420 if (!trkrhitsetcontainer)
422 cout <<
"Could not locate TRKR_HITSET node, quit! " << endl;
427 map<int, int> layer_nhit{{0, 0}, {0, 0}, {0, 0}};
431 hitset_iter != hitset_range.second;
438 if (
Verbosity() >= 2) cout << __PRETTY_FUNCTION__ <<
": found MVTX hitset with key: " << hitsetkey <<
" in layer " << layer << endl;
443 hit_iter != hit_range.second;
446 TrkrHit *hit = hit_iter->second;
450 cout << hit->
getAdc() <<
"ADC hit: ";
458 layer_nhit[
layer] += 1;
470 h_nHit->Fill(nhit,
"Photon", 1);
472 for (
auto &pair : layer_nhit)
475 cout << __PRETTY_FUNCTION__ <<
": MVTX Summary: found " << pair.second <<
" hits in layer " << pair.first << endl;
485 TrkrHitSetContainer *trkrhitsetcontainer = findNode::getClass<TrkrHitSetContainer>(topNode,
"TRKR_HITSET");
486 if (!trkrhitsetcontainer)
488 cout <<
"Could not locate TRKR_HITSET node, quit! " << endl;
493 map<int, int> layer_nhit{};
497 hitset_iter != hitset_range.second;
504 if (
Verbosity() >= 2) cout << __PRETTY_FUNCTION__ <<
": found TPC hitset with key: " << hitsetkey <<
" in layer " << layer << endl;
509 hit_iter != hit_range.second;
512 TrkrHit *hit = hit_iter->second;
516 cout << hit->
getAdc() <<
" ADC hit. " << endl;
523 if (layer_nhit.find(layer) == layer_nhit.end())
524 layer_nhit.insert(make_pair(layer, 0));
526 layer_nhit[
layer] += 1;
538 h_nHit->Fill(nhit,
"Photon", 1);
540 for (
auto &pair : layer_nhit)
543 cout << __PRETTY_FUNCTION__ <<
": TPC summary: found " << pair.second <<
" hits in layer " << pair.first << endl;
557 cout <<
"SynRadAna::ResetEvent(PHCompositeNode *topNode) Resetting internal structures, prepare for next event" << endl;
565 cout <<
"SynRadAna::EndRun(const int runnumber) Ending Run for Run " << runnumber << endl;
573 cout <<
"SynRadAna::End(PHCompositeNode *topNode) This is the End..." << endl;
584 cout <<
"SynRadAna::Reset(PHCompositeNode *topNode) being Reset" << endl;
591 cout <<
"SynRadAna::Print(const std::string &what) const Printing info for " << what << endl;