17 #include <TLorentzVector.h>
20 #include <calobase/RawCluster.h>
21 #include <calobase/RawClusterContainer.h>
22 #include <calobase/RawClusterUtility.h>
23 #include <calobase/RawTowerGeomContainer.h>
24 #include <calobase/RawTower.h>
25 #include <calobase/RawTowerContainer.h>
32 #include <g4vertex/GlobalVertex.h>
33 #include <g4vertex/GlobalVertexMap.h>
38 #include <trackbase_historic/SvtxVertex.h>
39 #include <trackbase_historic/SvtxVertexMap.h>
44 #include </gpfs/mnt/gpfs02/sphenix/user/ahodges/macros_git/coresoftware/generators/phhepmc/PHHepMCGenEvent.h>
45 #include </gpfs/mnt/gpfs02/sphenix/user/ahodges/macros_git/coresoftware/generators/phhepmc/PHHepMCGenEventMap.h>
47 #include <HepMC/GenEvent.h>
48 #include <HepMC/GenParticle.h>
49 #include <HepMC/GenVertex.h>
50 #include <HepMC/IteratorRange.h>
51 #include <HepMC/SimpleVector.h>
52 #include <HepMC/GenParticle.h>
53 #include <CLHEP/Geometry/Point3D.h>
60 std::cout <<
"pi0Efficiency::pi0Efficiency(const std::string &name) Calling ctor" << std::endl;
83 std::cout <<
"pi0Efficiency::~pi0Efficiency() Calling dtor" << std::endl;
89 std::cout <<
"pi0Efficiency::Init(PHCompositeNode *topNode) Initializing" << std::endl;
95 ePi0InvMassEcut[
j] =
new TH3F(Form(
"ePi0InvMassEcut_Eta%d",
j),Form(
"Pi0 energy vs. Inv Mass vs. Min pho Energy Eta%d",
j), 500,0,50,500,-0.1,1,200,0,20);
98 clusterE =
new TH1F(
"clusterE",
"Cluster Energy",200,0,20);
100 for(
int i = 0;
i <
nEtaBins;
i++)
prim_pi0_E[
i] =
new TH1F(Form(
"primPi0E_Eta%d",
i),
"Primary pi0 Energy",200,0,20);
102 photonE =
new TH1F(
"photonE",
"Decay Photon Energy",200,0,20);
104 pi0EScale =
new TH2F(
"pi0EScale",
"Pi0 energy fraction",200,0,2,200,0,20);
106 truthPi0EDeltaR =
new TH2F(
"truthPi0EDeltaR",
"truth pi0 energy versus decay opening angle",200,0,20,100,0,.5);
108 truthPi0EAsym =
new TH2F(
"truthPi0EAsym",
"truth pi0 energy vs. decay energy asymmetry",200,0,20,200,0,1);
110 hMassRat =
new TH1F(
"hMassRat",
"ratio of pi0 mass reco from truth photons to primary mass",200,0,2);
113 se ->
Print(
"NODETREE");
116 se -> registerHistoManager(
hm);
140 std::cout <<
"pi0Efficiency::InitRun(PHCompositeNode *topNode) Initializing for Run XXX" << std::endl;
147 std::cout <<
"pi0Efficiency::process_event(PHCompositeNode *topNode) Processing Event" << std::endl;
151 RawClusterContainer *clusterContainer = findNode::getClass<RawClusterContainer>(topNode,
"CLUSTER_POS_COR_CEMC");
153 if(!clusterContainer)
155 std::cout <<
PHWHERE <<
"pi0Efficiency::process_event - Fatal Error - CLUSTER_POS_COR_CEMC node is missing. " << std::endl;
162 GlobalVertexMap *vtxContainer = findNode::getClass<GlobalVertexMap>(topNode,
"GlobalVertexMap");
165 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;
171 if (vtxContainer->
empty())
173 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;
182 std::cout <<
PHWHERE <<
"pi0Efficiency::process_event Could not find vtx from vtxContainer" << std::endl;
187 RawTowerGeomContainer *towergeom = findNode::getClass<RawTowerGeomContainer>(topNode,
"TOWERGEOM_CEMC");
190 std::cout <<
PHWHERE <<
"pi0Efficiency::process_event Could not find node TOWERGEOM_CEMC" << std::endl;
195 RawTowerContainer *towerContainer = findNode::getClass<RawTowerContainer>(topNode,
"TOWER_CALIB_CEMC");
198 std::cout <<
PHWHERE <<
"pi0Efficiency::process_event Could not find node TOWER_CALIB_CEMC" << std::endl;
206 std::cout <<
PHWHERE <<
"pi0Efficiency::process_event Could not find node G4TruthInfo" << std::endl;
210 int firstphotonflag = 0;
211 int firstfirstphotonflag = 0;
212 int secondphotonflag = 0;
213 int secondsecondphotonflag = 0;
218 float photonEtaMax = 1.1;
219 float mesonEtaMax = 0.3;
220 TLorentzVector photon1;
221 TLorentzVector photon2;
223 for(truthIterDecay1 = truthRangeDecay1.first; truthIterDecay1 != truthRangeDecay1.second; truthIterDecay1++)
228 int dumtruthpid = decay -> get_pid();
229 int dumparentid = decay -> get_parent_id();
232 if(dumparentid == 1 && dumtruthpid == 22 && !firstphotonflag)
234 if(abs(
getEta(decay)) > photonEtaMax)
236 std::cout <<
"Photon 1 outside acceptance " << std::endl;
239 photon1.SetPxPyPzE(decay -> get_px(), decay -> get_py(), decay -> get_pz(), decay -> get_e());
244 if(dumparentid == 1 && dumtruthpid == 22 && firstphotonflag && firstfirstphotonflag)
246 if(abs(
getEta(decay)) > photonEtaMax)
248 std::cout <<
"Photon 2 outside acceptance " << std::endl;
251 photon2.SetPxPyPzE(decay -> get_px(), decay -> get_py(), decay -> get_pz(), decay -> get_e()) ;
253 secondphotonflag = 1;
257 if(dumparentid == 1 && firstphotonflag && secondphotonflag && secondsecondphotonflag)
259 std::cout <<
"Dalitz decay, skipping event" << std::endl;
270 if(firstphotonflag) firstfirstphotonflag = 1;
271 if(secondphotonflag) secondsecondphotonflag = 1;
275 float asym = abs(photon1.Energy() - photon2.Energy())/(photon1.Energy() + photon2.Energy());
276 float deltaR = photon1.DeltaR(photon2);
281 std::vector<int> mPi0Barcode;
282 Double_t pi0Mass = 0;
284 TLorentzVector truePi0;
286 for(truthIter = truthRange.first; truthIter != truthRange.second; truthIter++)
288 truthPar = truthIter->second;
290 if(truthPar -> get_pid() == 111 && truthPar -> get_parent_id() == 0)
293 if(
getEta(truthPar) >= mesonEtaMax)
295 std::cout <<
"Parent outside allowed spatial limit" << std::endl;
299 if(photon1.Energy() >= photon2.Energy())etaBin =
getEtaBin(photon1.PseudoRapidity());
300 else etaBin =
getEtaBin(photon2.PseudoRapidity());
304 mPi0Barcode.push_back(truthPar -> get_barcode());
305 truePi0.SetPxPyPzE(truthPar -> get_px(), truthPar -> get_py(), truthPar -> get_pz(), truthPar -> get_e());
306 pi0Mass = truePi0.M();
321 std::vector<RawCluster*> goodRecoCluster;
325 for(clusterIter = clusterEnd.first; clusterIter != clusterEnd.second; clusterIter++)
327 RawCluster *recoCluster = clusterIter -> second;
330 float clusE = E_vec_cluster.mag();
332 if(clusE < minE)
continue;
334 goodRecoCluster.push_back(recoCluster);
337 for(
int i = 0;
i < (int)goodRecoCluster.size(); ++
i)
343 TLorentzVector pho1, pho2, pi0;
344 pho1.SetPtEtaPhiE(E_vec_cluster.perp(), E_vec_cluster.pseudoRapidity(), E_vec_cluster.getPhi(), E_vec_cluster.mag());
346 for(
int j = 0;
j <(int)goodRecoCluster.size(); ++
j)
352 pho2.SetPtEtaPhiE(E_vec_cluster2.perp(), E_vec_cluster2.pseudoRapidity(), E_vec_cluster2.getPhi(), E_vec_cluster2.mag());
356 pi0EScale ->
Fill(pi0.Energy()/truePi0.Energy(), truePi0.Energy());
361 if(abs(pho1.PseudoRapidity()) < photonEtaMax && abs(pho2.PseudoRapidity()) < photonEtaMax && abs(pi0.PseudoRapidity()) < mesonEtaMax)
365 if(pho1.Energy() >= pho2.Energy()) etaBin =
getEtaBin(pho1.PseudoRapidity());
366 else etaBin =
getEtaBin(pho2.PseudoRapidity());
378 TLorentzVector pi0fromTruPhoton = photon1 + photon2;
501 goodRecoCluster.clear();
514 std::cout <<
"pi0Efficiency::EndRun(const int runnumber) Ending Run for Run " << runnumber << std::endl;
521 std::cout <<
"pi0Efficiency::End(PHCompositeNode *topNode) This is the End..." << std::endl;
546 std::cout <<
"pi0Efficiency::Reset(PHCompositeNode *topNode) being Reset" << std::endl;
553 std::cout <<
"pi0Efficiency::Print(const std::string &what) const Printing info for " << what << std::endl;
558 float px = particle -> get_px();
559 float py = particle -> get_py();
560 float pz = particle -> get_pz();
561 float p = sqrt(pow(px,2) + pow(py,2) + pow(pz,2));
563 return 0.5*log((p+pz)/(p-pz));
570 if(abs(eta) < (
i+1)/(
float)(nEtaBins-1) * 1.1 && abs(eta) >= (
i+1-1)/(
float)(nEtaBins-1) * 1.1)
return i;