Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
quickHIJING.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file quickHIJING.cc
1 #include "quickHIJING.h"
2 
4 
6 #include <phool/getClass.h>
7 
9 
11 #include <g4main/PHG4Particle.h>
12 
15 #pragma GCC diagnostic push
16 #pragma GCC diagnostic ignored "-Wdeprecated-declarations"
17 #include <HepMC/GenEvent.h>
18 #include <HepMC/GenParticle.h>
19 #include <HepMC/GenVertex.h>
20 #include <HepMC/IteratorRange.h>
21 #include <HepMC/SimpleVector.h>
22 #include <HepMC/GenParticle.h>
23 #pragma GCC diagnostic pop
24 
25 //____________________________________________________________________________..
27  SubsysReco(name)
28  ,Outfile(name)
29 {
30  std::cout << "quickHIJING::quickHIJING(const std::string &name) Calling ctor" << std::endl;
31 }
32 //____________________________________________________________________________..
34 {
35  std::cout << "quickHIJING::~quickHIJING() Calling dtor" << std::endl;
36 }
37 
38 //____________________________________________________________________________..
40 {
41  std::cout << "quickHIJING::Init(PHCompositeNode *topNode) Initializing" << std::endl;
42 
43  out = new TFile("qhTest.root","RECREATE");
44 
45  T = new TTree("T","T");
46  T -> Branch("pid",&m_pid);
47  T -> Branch("pt",&m_pt);
48  T -> Branch("eta",&m_eta);
49  T -> Branch("phi",&m_phi);
50  T -> Branch("e",&m_e);
51  T -> Branch("psi2",&m_psi2);
52  T -> Branch("b",&m_b);
53  T -> Branch("cent",&m_cent);
54  T -> Branch("p",&m_p);
55 
56 
58 }
59 
60 //____________________________________________________________________________..
62 {
63  std::cout << "quickHIJING::InitRun(PHCompositeNode *topNode) Initializing for Run XXX" << std::endl;
65 }
66 
67 //____________________________________________________________________________..
69 {
70 
71  CentralityInfo *cent_node = findNode::getClass<CentralityInfo>(topNode, "CentralityInfo");
72  if(!cent_node)
73  {
74  std::cout << "No cent node" << std::endl;
76  }
77 
78  m_cent = cent_node -> get_centile(CentralityInfo::PROP::bimp);
79  m_b = cent_node -> get_quantity(CentralityInfo::PROP::bimp);
80 
81  //truth particle information
82  PHG4TruthInfoContainer *truthinfo = findNode::getClass<PHG4TruthInfoContainer>(topNode, "G4TruthInfo");
83  if(!truthinfo)
84  {
85  std::cout << PHWHERE << "hijingTruthCheck::process_event Could not find node G4TruthInfo" << std::endl;
87  }
88 
89 
90 
91  //For pythia ancestory information
92  PHHepMCGenEventMap *genEventMap = findNode::getClass<PHHepMCGenEventMap>(topNode, "PHHepMCGenEventMap");
93  if(!genEventMap)
94  {
95  std::cout << PHWHERE << "cemc::process_event Could not find PHHepMCGenEventMap" << std::endl;
97  }
98  //event level information of the above
99  PHHepMCGenEvent *genEvent = genEventMap -> get(0);
100  if(!genEvent)
101  {
102  std::cout << PHWHERE << "cemc::process_event Could not find PHHepMCGenEvent" << std::endl;
104  }
105 
106  HepMC::GenEvent *evt = genEvent -> getEvent();
107 
108  HepMC::HeavyIon *hi = evt -> heavy_ion();
109 
110  m_psi2 = hi -> event_plane_angle();
111 
112 
113  PHG4TruthInfoContainer::Range truthRange = truthinfo -> GetPrimaryParticleRange();
115 
116  for(truthIter = truthRange.first; truthIter != truthRange.second; truthIter++)
117  {
118  PHG4Particle *truthPar = truthIter->second;
119 
120  if(abs(truthPar -> get_pid()) >= 12 && abs(truthPar -> get_pid()) <= 16) continue;
121 
122  m_pid.push_back(truthPar -> get_pid());
123 
124  m_p.push_back(getP(truthPar));
125 
126  m_e.push_back(truthPar -> get_e());
127 
128  m_eta.push_back(getEta(truthPar));
129 
130  m_phi.push_back(getPhi(truthPar));
131 
132  m_pt.push_back(getpT(truthPar));
133 
134  //if(getpT(truthPar) < 0 || getpT(truthPar) > 10)std::cout << "Found particle with pt: " << getpT(truthPar) << std::endl;
135 
136  }
137  //std::cout << "Saw " << npart << " particles" << std::endl;
138  T -> Fill();
139 
141 }
142 
143 //____________________________________________________________________________..
145 {
146 
147  m_pid.clear();
148  m_e.clear();
149  m_eta.clear();
150  m_pt.clear();
151  m_phi.clear();
152 
154 }
155 
156 //____________________________________________________________________________..
158 {
159  std::cout << "quickHIJING::EndRun(const int runnumber) Ending Run for Run " << runnumber << std::endl;
161 }
162 
163 //____________________________________________________________________________..
165 {
166  out -> cd();
167  T -> Write();
168  out -> Close();
169 
170  std::cout << "quickHIJING::End(PHCompositeNode *topNode) This is the End..." << std::endl;
172 }
173 
174 //____________________________________________________________________________..
176 {
177  std::cout << "quickHIJING::Reset(PHCompositeNode *topNode) being Reset" << std::endl;
179 }
180 
181 //____________________________________________________________________________..
182 void quickHIJING::Print(const std::string &what) const
183 {
184  std::cout << "quickHIJING::Print(const std::string &what) const Printing info for " << what << std::endl;
185 }
186 //____________________________________________________________________________..
188 {
189  float px = particle -> get_px();
190  float py = particle -> get_py();
191  float pz = particle -> get_pz();
192  float p = sqrt(pow(px,2) + pow(py,2) + pow(pz,2));
193 
194  return 0.5*log((p+pz)/(p-pz));
195 }
196 //____________________________________________________________________________..
198 {
199  float phi = atan2(particle -> get_py(),particle -> get_px());
200  return phi;
201 }
202 //____________________________________________________________________________..
204 {
205  float px = particle -> get_px();
206  float py = particle -> get_py();
207 
208  float pt = sqrt(pow(px,2) + pow(py,2));
209  return pt;
210 }
211 //____________________________________________________________________________..
213 {
214  float px = particle -> get_px();
215  float py = particle -> get_py();
216  float pz = particle -> get_pz();
217  float p = sqrt(pow(px,2) + pow(py,2) + pow(pz,2));
218 
219  return p;
220 }