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>
29 #include <g4vertex/GlobalVertex.h>
30 #include <g4vertex/GlobalVertexMap.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)
86 std::cout <<
"pi0ClusterAna::pi0ClusterAna(const std::string &name) Calling ctor" << std::endl;
92 std::cout <<
"pi0ClusterAna::~pi0ClusterAna() Calling dtor" << std::endl;
99 clusters_Towers =
new TTree(
"TreeClusterTower",
"Tree for cluster and tower information");
110 truth_photon =
new TTree(
"TreeTruthPhoton",
"Tree for truth photons");
120 truth_pi0 =
new TTree(
"TreeTruthPi0",
"Tree for Truth pi0");
127 se ->
Print(
"NODETREE");
130 se -> registerHistoManager(
hm);
138 std::cout <<
"pi0ClusterAna::Init(PHCompositeNode *topNode) Initializing" << std::endl;
145 std::cout <<
"pi0ClusterAna::InitRun(PHCompositeNode *topNode) Initializing for Run XXX" << std::endl;
155 RawClusterContainer *clusterContainer = findNode::getClass<RawClusterContainer>(topNode,
"CLUSTER_POS_COR_CEMC");
157 if(!clusterContainer)
159 std::cout <<
PHWHERE <<
"pi0Efficiency::process_event - Fatal Error - CLUSTER_CEMC node is missing. " << std::endl;
166 GlobalVertexMap *vtxContainer = findNode::getClass<GlobalVertexMap>(topNode,
"GlobalVertexMap");
169 std::cout <<
PHWHERE <<
"pi0Efficiency::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;
175 if (vtxContainer->
empty())
177 std::cout <<
PHWHERE <<
"pi0Efficiency::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;
186 std::cout <<
PHWHERE <<
"pi0Efficiency::process_event Could not find vtx from vtxContainer" << std::endl;
191 RawTowerGeomContainer *towergeom = findNode::getClass<RawTowerGeomContainer>(topNode,
"TOWERGEOM_CEMC");
194 std::cout <<
PHWHERE <<
"pi0Efficiency::process_event Could not find node TOWERGEOM_CEMC" << std::endl;
199 RawTowerContainer *towerContainer = findNode::getClass<RawTowerContainer>(topNode,
"TOWER_CALIB_CEMC");
202 std::cout <<
PHWHERE <<
"pi0Efficiency::process_event Could not find node TOWER_CALIB_CEMC" << std::endl;
210 std::cout <<
PHWHERE <<
"pi0Efficiency::process_event Could not find node G4TruthInfo" << std::endl;
215 float pi0Eta = -99999;
216 float photonEtaMax = 1.1;
217 float mesonEtaMax = 0.3;
224 for(truthIter = truthRange.first; truthIter != truthRange.second; truthIter++)
226 truthPar = truthIter->second;
228 if(truthPar -> get_pid() == 111 && truthPar -> get_parent_id() == 0)
230 pi0Eta =
getEta(truthPar);
231 if(abs(pi0Eta) >= mesonEtaMax)
238 int firstphotonflag = 0;
239 int firstfirstphotonflag = 0;
240 int secondphotonflag = 0;
248 TLorentzVector photon1;
249 TLorentzVector photon2;
256 for(truthIterDecay1 = truthRangeDecay1.first; truthIterDecay1 != truthRangeDecay1.second; truthIterDecay1++)
260 int dumtruthpid = decay -> get_pid();
261 int dumparentid = decay -> get_parent_id();
264 if(dumparentid == 1 && dumtruthpid == 22 && !firstphotonflag)
266 if(abs(
getEta(decay)) > photonEtaMax)
270 photon1.SetPxPyPzE(decay -> get_px(), decay -> get_py(), decay -> get_pz(), decay -> get_e());
275 if(dumparentid == 1 && dumtruthpid == 22 && firstphotonflag && firstfirstphotonflag)
277 if(abs(
getEta(decay)) > photonEtaMax)
281 photon2.SetPxPyPzE(decay -> get_px(), decay -> get_py(), decay -> get_pz(), decay -> get_e()) ;
283 secondphotonflag = 1;
287 if(firstphotonflag) firstfirstphotonflag = 1;
288 if(dumparentid == 1)nParticles ++;
291 if((!firstphotonflag || !secondphotonflag) && nParticles > 1)
295 else if((!firstphotonflag || !secondphotonflag) && nParticles == 1)
299 else if((!firstphotonflag || !secondphotonflag) && nParticles == 0)
306 pi0.SetPxPyPzE(truthPar -> get_px(), truthPar -> get_py(), truthPar -> get_pz(), truthPar -> get_e());
307 TLorentzVector leadPho, subLeadPho;
308 if(photon1.Energy() >= photon2.Energy())
311 subLeadPho = photon2;
316 subLeadPho = photon1;
319 float asym = abs(photon1.Energy() - photon2.Energy())/(photon1.Energy() + photon2.Energy());
323 float deltaR = photon1.DeltaR(photon2);
330 m_lead_eta.push_back(leadPho.PseudoRapidity());
333 m_lead_E.push_back(leadPho.Energy());
336 m_pi0_E.push_back(pi0.Energy());
338 m_pi0_eta.push_back(pi0.PseudoRapidity());
344 int phibin = tower_iter -> second -> get_binphi();
345 int etabin = tower_iter -> second -> get_bineta();
346 double phi = towergeom -> get_phicenter(phibin);
347 double eta = towergeom -> get_etacenter(etabin);
348 double energy = tower_iter -> second -> get_energy();
359 for(clusterIter = clusterEnd.first; clusterIter != clusterEnd.second; clusterIter++)
361 RawCluster *recoCluster = clusterIter -> second;
365 float clusE = E_vec_cluster.mag();
366 float clus_eta = E_vec_cluster.pseudoRapidity();
367 float clus_phi = E_vec_cluster.phi();
418 std::cout <<
"pi0ClusterAna::EndRun(const int runnumber) Ending Run for Run " << runnumber << std::endl;
425 std::cout <<
"pi0ClusterAna::End(PHCompositeNode *topNode) This is the End..." << std::endl;
435 hm -> dumpHistos(
Outfile.c_str(),
"UPDATE");
444 std::cout <<
"pi0ClusterAna::Reset(PHCompositeNode *topNode) being Reset" << std::endl;
451 std::cout <<
"pi0ClusterAna::Print(const std::string &what) const Printing info for " << what << std::endl;
456 float px = particle -> get_px();
457 float py = particle -> get_py();
458 float pz = particle -> get_pz();
459 float p = sqrt(pow(px,2) + pow(py,2) + pow(pz,2));
461 return 0.5*log((p+pz)/(p-pz));