17 #include <TLorentzVector.h>
21 #include <calobase/RawCluster.h>
22 #include <calobase/RawClusterContainer.h>
23 #include <calobase/RawClusterUtility.h>
24 #include <calobase/RawTowerGeomContainer.h>
25 #include <calobase/RawTower.h>
26 #include <calobase/RawTowerContainer.h>
35 #include <trackbase_historic/SvtxVertex.h>
36 #include <trackbase_historic/SvtxVertexMap.h>
42 #pragma GCC diagnostic push
43 #pragma GCC diagnostic ignored "-Wdeprecated-declarations"
44 #include <HepMC/GenEvent.h>
45 #include <HepMC/GenParticle.h>
46 #include <HepMC/GenVertex.h>
47 #include <HepMC/IteratorRange.h>
48 #include <HepMC/SimpleVector.h>
49 #include <HepMC/GenParticle.h>
50 #pragma GCC diagnostic pop
51 #include <CLHEP/Geometry/Point3D.h>
57 , clusters_Towers(nullptr)
58 , truth_photon(nullptr)
85 , m_isConversionEvent()
91 std::cout <<
"singlePhotonClusterAna::singlePhotonClusterAna(const std::string &name) Calling ctor" << std::endl;
97 std::cout <<
"singlePhotonClusterAna::~singlePhotonClusterAna() Calling dtor" << std::endl;
104 clusters_Towers =
new TTree(
"TreeClusterTower",
"Tree for cluster and tower information");
116 truth_photon =
new TTree(
"TreeTruthPhoton",
"Tree for Truth Photon");
121 conversion =
new TTree(
"TreeConversion",
"Tree for Photon Conversion Info");
137 se ->
Print(
"NODETREE");
140 se -> registerHistoManager(
hm);
147 std::cout <<
"singlePhotonClusterAna::Init(PHCompositeNode *topNode) Initializing" << std::endl;
154 std::cout <<
"singlePhotonClusterAna::InitRun(PHCompositeNode *topNode) Initializing for Run XXX" << std::endl;
164 RawClusterContainer *clusterContainer = findNode::getClass<RawClusterContainer>(topNode,
"CLUSTER_POS_COR_CEMC");
166 if(!clusterContainer)
168 std::cout <<
PHWHERE <<
"singlePhotonClusterAna::process_event - Fatal Error - CLUSTER_CEMC node is missing. " << std::endl;
175 GlobalVertexMap *vtxContainer = findNode::getClass<GlobalVertexMap>(topNode,
"GlobalVertexMap");
178 std::cout <<
PHWHERE <<
"singlePhotonClusterAna::process_event - Fatal Error - GlobalVertexMap node is missing. Please turn on the do_global flag in the main macro in order to reconstruct the global vertex." << std::endl;
184 if (vtxContainer->
empty())
186 std::cout <<
PHWHERE <<
"singlePhotonClusterAna::process_event - Fatal Error - GlobalVertexMap node is empty. Please turn on the do_global flag in the main macro in order to reconstruct the global vertex." << std::endl;
195 std::cout <<
PHWHERE <<
"singlePhotonClusterAna::process_event Could not find vtx from vtxContainer" << std::endl;
200 RawTowerGeomContainer *towergeom = findNode::getClass<RawTowerGeomContainer>(topNode,
"TOWERGEOM_CEMC");
203 std::cout <<
PHWHERE <<
"singlePhotonClusterAna::process_event Could not find node TOWERGEOM_CEMC" << std::endl;
208 RawTowerContainer *towerContainer = findNode::getClass<RawTowerContainer>(topNode,
"TOWER_CALIB_CEMC");
211 std::cout <<
PHWHERE <<
"singlePhotonClusterAna::process_event Could not find node TOWER_CALIB_CEMC" << std::endl;
219 std::cout <<
PHWHERE <<
"singlePhotonClusterAna::process_event Could not find node G4TruthInfo" << std::endl;
224 float photonEta = -99999;
225 float photonEtaMax = 1.1;
226 TLorentzVector photon;
233 for(truthIter = truthRange.first; truthIter != truthRange.second; truthIter++)
235 truthPar = truthIter->second;
238 if(truthPar -> get_pid() == 22 && truthPar -> get_parent_id() == 0)
240 photonEta =
getEta(truthPar);
241 if(abs(photonEta) >= photonEtaMax)
252 photon.SetPxPyPzE(truthPar -> get_px(), truthPar -> get_py(), truthPar -> get_pz(), truthPar -> get_e());
257 int decay_vtx_idx = 0;
258 int decay_vtx_idx1 = 0;
259 int decay_vtx_idx2 = 0;
260 bool first_decay_particle =
false;
261 bool second_decay_particle =
false;
262 bool decay_electron =
false;
263 bool decay_positron =
false;
266 TLorentzVector positron;
267 bool isGoodEvent =
true;
274 for(truthIterDecay1 = truthRangeDecay1.first; truthIterDecay1 != truthRangeDecay1.second; truthIterDecay1++)
278 int dumparentid = decay -> get_parent_id();
279 if(dumparentid == 1) {
281 if (! first_decay_particle) {
282 first_decay_particle =
true;
286 second_decay_particle =
true;
298 if (n_children != 2) isGoodEvent =
false;
299 if (!(first_decay_particle && second_decay_particle)) isGoodEvent =
false;
300 if (decay_vtx_idx1 != decay_vtx_idx2) isGoodEvent =
false;
303 for(truthIterDecay1 = truthRangeDecay1.first; truthIterDecay1 != truthRangeDecay1.second; truthIterDecay1++)
307 int dumtruthpid = decay -> get_pid();
308 int dumparentid = decay -> get_parent_id();
309 if(dumparentid == 1) {
310 if (dumtruthpid == 11) {
312 decay_electron =
true;
313 electron.SetPxPyPzE(decay -> get_px(), decay -> get_py(), decay -> get_pz(), decay -> get_e());
315 if (dumtruthpid == -11) {
317 decay_positron =
true;
318 positron.SetPxPyPzE(decay -> get_px(), decay -> get_py(), decay -> get_pz(), decay -> get_e());
323 if (!(decay_electron && decay_positron)) isGoodEvent =
false;
342 decay_vtx_idx = decay_vtx_idx1;
348 float vtx_x = decay_vtx->
get_x();
349 float vtx_y = decay_vtx->
get_y();
350 float vtx_r = sqrt(vtx_x*vtx_x + vtx_y*vtx_y);
352 bool isConversionEvent =
false;
353 float EMCal_inner_radius = 95;
354 if (vtx_r < EMCal_inner_radius) isConversionEvent =
true;
361 std::cout <<
"\nGreg info:\nBad conversion event\n";
362 std::cout <<
"n_children = " << n_children <<
"\n";
363 std::cout <<
"first_decay_particle = " << first_decay_particle <<
"; second_decay_particle = " << second_decay_particle <<
"\n";
364 std::cout <<
"decay_vtx_idx1 = " << decay_vtx_idx1 <<
"; decay_vtx_idx2 = " << decay_vtx_idx2 <<
"\n";
365 std::cout <<
"decay_electron = " << decay_electron <<
"; decay_positron = " << decay_positron <<
"\n";
443 int phibin = tower_iter -> second -> get_binphi();
444 int etabin = tower_iter -> second -> get_bineta();
445 double phi = towergeom -> get_phicenter(phibin);
446 double eta = towergeom -> get_etacenter(etabin);
447 double energy = tower_iter -> second -> get_energy();
458 for(clusterIter = clusterEnd.first; clusterIter != clusterEnd.second; clusterIter++)
460 RawCluster *recoCluster = clusterIter -> second;
465 float clusE = E_vec_cluster.mag();
466 float clusEcore = recoCluster->
get_ecore();
467 float clus_eta = E_vec_cluster.pseudoRapidity();
468 float clus_phi = E_vec_cluster.phi();
524 std::cout <<
"singlePhotonClusterAna::EndRun(const int runnumber) Ending Run for Run " << runnumber << std::endl;
531 std::cout <<
"singlePhotonClusterAna::End(PHCompositeNode *topNode) This is the End..." << std::endl;
541 hm -> dumpHistos(
Outfile.c_str(),
"UPDATE");
550 std::cout <<
"singlePhotonClusterAna::Reset(PHCompositeNode *topNode) being Reset" << std::endl;
557 std::cout <<
"singlePhotonClusterAna::Print(const std::string &what) const Printing info for " << what << std::endl;
562 float px = particle -> get_px();
563 float py = particle -> get_py();
564 float pz = particle -> get_pz();
565 float p = sqrt(pow(px,2) + pow(py,2) + pow(pz,2));
567 return 0.5*log((p+pz)/(p-pz));