StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
StPythiaEventMaker.cxx
1 //
2 // Pibero Djawotho <pibero@tamu.edu>
3 // Texas A&M University
4 // 4 May 2010
5 //
6 
7 // ROOT
8 #include "TFile.h"
9 #include "TTree.h"
10 
11 // STAR
12 #include "StSpinPool/StJetSkimEvent/StPythiaEvent.h"
13 #include "tables/St_g2t_event_Table.h"
14 #include "tables/St_g2t_pythia_Table.h"
15 #include "tables/St_g2t_vertex_Table.h"
16 #include "tables/St_particle_Table.h"
17 #include "StSpinPool/StMCAsymMaker/StMCAsymMaker.h"
18 
19 // Local
20 #include "StPythiaEventMaker.h"
21 
22 ClassImp(StPythiaEventMaker);
23 
24 void StPythiaEventMaker::Clear(Option_t* option)
25 {
26  mPythiaEvent->Clear(option);
27 }
28 
29 int StPythiaEventMaker::Init()
30 {
31  assert(!mFileName.IsNull());
32  mFile = TFile::Open(mFileName,"recreate");
33  assert(mFile);
34  mPythiaEvent = new StPythiaEvent;
35  mTree = new TTree("PythiaTree","Pythia Record");
36  mTree->Branch("PythiaBranch","StPythiaEvent",&mPythiaEvent);
37  return kStOk;
38 }
39 
41 {
42  getEvent();
43  getPythia();
44  getVertex();
45  getParticles();
46  //getAsymmetries();
47 
48  if (Debug()) { LOG_DEBUG << *mPythiaEvent << endm; }
49 
50  mTree->Fill();
51 
52  return kStOk;
53 }
54 
56 {
57  mFile->Write();
58  mFile->Close();
59  return kStOk;
60 }
61 
62 void StPythiaEventMaker::getEvent()
63 {
64  TDataSet* geant = GetDataSet("geant");
65  if (geant) {
66  TDataSetIter iter(geant);
67  St_g2t_event* eventDescriptor = (St_g2t_event*)iter("g2t_event");
68  if (eventDescriptor) {
69  g2t_event_st* eventTable = (g2t_event_st*)eventDescriptor->GetTable();
70  if (eventTable) {
71  mPythiaEvent->setRunId(eventTable->n_run);
72  mPythiaEvent->setEventId(eventTable->n_event);
73  }
74  }
75  }
76 
77 // mPythiaEvent->setRunId(GetRunNumber());
78 // mPythiaEvent->setEventId(GetEventNumber());
79 }
80 
81 void StPythiaEventMaker::getPythia()
82 {
83  TDataSet* geant = GetDataSet("geant");
84  if (geant) {
85  TDataSetIter iter(geant);
86  St_g2t_pythia* pythiaDescriptor = (St_g2t_pythia*)iter("g2t_pythia");
87  if (pythiaDescriptor) {
88  g2t_pythia_st* pythiaTable = (g2t_pythia_st*)pythiaDescriptor->GetTable();
89  if (pythiaTable) {
90  mPythiaEvent->setProcessId(pythiaTable->subprocess_id);
91  mPythiaEvent->setS(pythiaTable->mand_s);
92  mPythiaEvent->setT(pythiaTable->mand_t);
93  mPythiaEvent->setU(pythiaTable->mand_u);
94  mPythiaEvent->setPt(pythiaTable->hard_p);
95  mPythiaEvent->setCosTheta(pythiaTable->cos_th);
96  mPythiaEvent->setX1(pythiaTable->bjor_1);
97  mPythiaEvent->setX2(pythiaTable->bjor_2);
98  mPythiaEvent->setMstu72(pythiaTable->mstu72);
99  mPythiaEvent->setMstu73(pythiaTable->mstu73);
100  mPythiaEvent->setMstp111(pythiaTable->mstp111);
101  }
102  }
103  }
104 }
105 
106 void StPythiaEventMaker::getVertex()
107 {
108  TDataSet* geant = GetDataSet("geant");
109  if (geant) {
110  TDataSetIter iter(geant);
111  St_g2t_vertex* vertexDescriptor = (St_g2t_vertex*)iter("g2t_vertex");
112  if (vertexDescriptor) {
113  g2t_vertex_st* vertexTable = (g2t_vertex_st*)vertexDescriptor->GetTable();
114  if (vertexTable) {
115  mPythiaEvent->setVertex(TVector3(vertexTable[0].ge_x));
116  }
117  }
118  }
119 }
120 
121 void StPythiaEventMaker::getParticles()
122 {
123  TDataSet* geant = GetDataSet("geant");
124  if (geant) {
125  TDataSetIter iter(geant);
126  St_particle* particleDescriptor = (St_particle*)iter("particle");
127  if (particleDescriptor) {
128  particle_st* particleTable = (particle_st*)particleDescriptor->GetTable();
129  if (particleTable) {
130  for (int i = 0; i < particleDescriptor->GetNRows(); ++i) {
131  mPythiaEvent->addParticle(TParticle(particleTable[i].idhep, // pdg
132  particleTable[i].isthep, // status
133  particleTable[i].jmohep[0], // mother1
134  particleTable[i].jmohep[1], // mother2
135  particleTable[i].jdahep[0], // daughter1
136  particleTable[i].jdahep[1], // daughter2
137  TLorentzVector(particleTable[i].phep), // momentum and energy
138  TLorentzVector(particleTable[i].vhep))); // production vertex and time
139  }
140  }
141  }
142  }
143 }
144 
145 void StPythiaEventMaker::getAsymmetries()
146 {
147  float s = mPythiaEvent->s();
148  float t = mPythiaEvent->t();
149  float u = mPythiaEvent->u();
150  int pid = mPythiaEvent->processId();
151  int flavor1 = mPythiaEvent->particle(4)->GetPdgCode();
152  int flavor2 = mPythiaEvent->particle(5)->GetPdgCode();
153  int flavor3 = mPythiaEvent->particle(6)->GetPdgCode();
154  int flavor4 = mPythiaEvent->particle(7)->GetPdgCode();
155  float x1 = mPythiaEvent->x1();
156  float x2 = mPythiaEvent->x2();
157  float Q2 = mPythiaEvent->Q2();
158 
159  mPythiaEvent->setDF1(StPythiaEvent::LO,StMCAsymMaker::get_polPDF_LO(flavor1,x1,Q2));
160  mPythiaEvent->setDF1(StPythiaEvent::NLO,StMCAsymMaker::get_polPDF_NLO(flavor1,x1,Q2));
161  mPythiaEvent->setDF1(StPythiaEvent::ZERO,StMCAsymMaker::get_polPDF_NLO_g0(flavor1,x1,Q2));
162  mPythiaEvent->setDF1(StPythiaEvent::MAX,StMCAsymMaker::get_polPDF_NLO_gmax(flavor1,x1,Q2));
163  mPythiaEvent->setDF1(StPythiaEvent::MIN,StMCAsymMaker::get_polPDF_NLO_gmin(flavor1,x1,Q2));
164  mPythiaEvent->setDF1(StPythiaEvent::M015,StMCAsymMaker::get_polPDF_NLO_m015(flavor1,x1,Q2));
165  mPythiaEvent->setDF1(StPythiaEvent::M030,StMCAsymMaker::get_polPDF_NLO_m030(flavor1,x1,Q2));
166  mPythiaEvent->setDF1(StPythiaEvent::M045,StMCAsymMaker::get_polPDF_NLO_m045(flavor1,x1,Q2));
167  mPythiaEvent->setDF1(StPythiaEvent::M060,StMCAsymMaker::get_polPDF_NLO_m060(flavor1,x1,Q2));
168  mPythiaEvent->setDF1(StPythiaEvent::M075,StMCAsymMaker::get_polPDF_NLO_m075(flavor1,x1,Q2));
169  mPythiaEvent->setDF1(StPythiaEvent::M090,StMCAsymMaker::get_polPDF_NLO_m090(flavor1,x1,Q2));
170  mPythiaEvent->setDF1(StPythiaEvent::M105,StMCAsymMaker::get_polPDF_NLO_m105(flavor1,x1,Q2));
171  mPythiaEvent->setDF1(StPythiaEvent::P030,StMCAsymMaker::get_polPDF_NLO_p030(flavor1,x1,Q2));
172  mPythiaEvent->setDF1(StPythiaEvent::P045,StMCAsymMaker::get_polPDF_NLO_p045(flavor1,x1,Q2));
173  mPythiaEvent->setDF1(StPythiaEvent::P060,StMCAsymMaker::get_polPDF_NLO_p060(flavor1,x1,Q2));
174  mPythiaEvent->setDF1(StPythiaEvent::P070,StMCAsymMaker::get_polPDF_NLO_p070(flavor1,x1,Q2));
175  mPythiaEvent->setDF1(StPythiaEvent::GS_NLOA,StMCAsymMaker::get_polPDF_NLO_GSA(flavor1,x1,Q2));
176  mPythiaEvent->setDF1(StPythiaEvent::GS_NLOB,StMCAsymMaker::get_polPDF_NLO_GSB(flavor1,x1,Q2));
177  mPythiaEvent->setDF1(StPythiaEvent::GS_NLOC,StMCAsymMaker::get_polPDF_NLO_GSC(flavor1,x1,Q2));
178  mPythiaEvent->setDF1(StPythiaEvent::DSSV,StMCAsymMaker::get_polPDF_NLO_DSSV(flavor1,x1,Q2));
179  mPythiaEvent->setDF1(StPythiaEvent::LSS1,StMCAsymMaker::get_polPDF_NLO_LSS1(flavor1,x1,Q2));
180  mPythiaEvent->setDF1(StPythiaEvent::LSS2,StMCAsymMaker::get_polPDF_NLO_LSS2(flavor1,x1,Q2));
181  mPythiaEvent->setDF1(StPythiaEvent::LSS3,StMCAsymMaker::get_polPDF_NLO_LSS3(flavor1,x1,Q2));
182  mPythiaEvent->setDF1(StPythiaEvent::AAC1,StMCAsymMaker::get_polPDF_NLO_AAC1(flavor1,x1,Q2));
183  mPythiaEvent->setDF1(StPythiaEvent::AAC2,StMCAsymMaker::get_polPDF_NLO_AAC2(flavor1,x1,Q2));
184  mPythiaEvent->setDF1(StPythiaEvent::AAC3,StMCAsymMaker::get_polPDF_NLO_AAC3(flavor1,x1,Q2));
185  mPythiaEvent->setDF1(StPythiaEvent::BB1,StMCAsymMaker::get_polPDF_NLO_BB1(flavor1,x1,Q2));
186  mPythiaEvent->setDF1(StPythiaEvent::BB2,StMCAsymMaker::get_polPDF_NLO_BB2(flavor1,x1,Q2));
187  mPythiaEvent->setDF1(StPythiaEvent::DNS1,StMCAsymMaker::get_polPDF_NLO_DNS1(flavor1,x1,Q2));
188  mPythiaEvent->setDF1(StPythiaEvent::DNS2,StMCAsymMaker::get_polPDF_NLO_DNS2(flavor1,x1,Q2));
189 
190  mPythiaEvent->setDF2(StPythiaEvent::LO,StMCAsymMaker::get_polPDF_LO(flavor2,x2,Q2));
191  mPythiaEvent->setDF2(StPythiaEvent::NLO,StMCAsymMaker::get_polPDF_NLO(flavor2,x2,Q2));
192  mPythiaEvent->setDF2(StPythiaEvent::ZERO,StMCAsymMaker::get_polPDF_NLO_g0(flavor2,x2,Q2));
193  mPythiaEvent->setDF2(StPythiaEvent::MAX,StMCAsymMaker::get_polPDF_NLO_gmax(flavor2,x2,Q2));
194  mPythiaEvent->setDF2(StPythiaEvent::MIN,StMCAsymMaker::get_polPDF_NLO_gmin(flavor2,x2,Q2));
195  mPythiaEvent->setDF2(StPythiaEvent::M015,StMCAsymMaker::get_polPDF_NLO_m015(flavor2,x2,Q2));
196  mPythiaEvent->setDF2(StPythiaEvent::M030,StMCAsymMaker::get_polPDF_NLO_m030(flavor2,x2,Q2));
197  mPythiaEvent->setDF2(StPythiaEvent::M045,StMCAsymMaker::get_polPDF_NLO_m045(flavor2,x2,Q2));
198  mPythiaEvent->setDF2(StPythiaEvent::M060,StMCAsymMaker::get_polPDF_NLO_m060(flavor2,x2,Q2));
199  mPythiaEvent->setDF2(StPythiaEvent::M075,StMCAsymMaker::get_polPDF_NLO_m075(flavor2,x2,Q2));
200  mPythiaEvent->setDF2(StPythiaEvent::M090,StMCAsymMaker::get_polPDF_NLO_m090(flavor2,x2,Q2));
201  mPythiaEvent->setDF2(StPythiaEvent::M105,StMCAsymMaker::get_polPDF_NLO_m105(flavor2,x2,Q2));
202  mPythiaEvent->setDF2(StPythiaEvent::P030,StMCAsymMaker::get_polPDF_NLO_p030(flavor2,x2,Q2));
203  mPythiaEvent->setDF2(StPythiaEvent::P045,StMCAsymMaker::get_polPDF_NLO_p045(flavor2,x2,Q2));
204  mPythiaEvent->setDF2(StPythiaEvent::P060,StMCAsymMaker::get_polPDF_NLO_p060(flavor2,x2,Q2));
205  mPythiaEvent->setDF2(StPythiaEvent::P070,StMCAsymMaker::get_polPDF_NLO_p070(flavor2,x2,Q2));
206  mPythiaEvent->setDF2(StPythiaEvent::GS_NLOA,StMCAsymMaker::get_polPDF_NLO_GSA(flavor2,x2,Q2));
207  mPythiaEvent->setDF2(StPythiaEvent::GS_NLOB,StMCAsymMaker::get_polPDF_NLO_GSB(flavor2,x2,Q2));
208  mPythiaEvent->setDF2(StPythiaEvent::GS_NLOC,StMCAsymMaker::get_polPDF_NLO_GSC(flavor2,x2,Q2));
209  mPythiaEvent->setDF2(StPythiaEvent::DSSV,StMCAsymMaker::get_polPDF_NLO_DSSV(flavor2,x2,Q2));
210  mPythiaEvent->setDF2(StPythiaEvent::LSS1,StMCAsymMaker::get_polPDF_NLO_LSS1(flavor2,x2,Q2));
211  mPythiaEvent->setDF2(StPythiaEvent::LSS2,StMCAsymMaker::get_polPDF_NLO_LSS2(flavor2,x2,Q2));
212  mPythiaEvent->setDF2(StPythiaEvent::LSS3,StMCAsymMaker::get_polPDF_NLO_LSS3(flavor2,x2,Q2));
213  mPythiaEvent->setDF2(StPythiaEvent::AAC1,StMCAsymMaker::get_polPDF_NLO_AAC1(flavor2,x2,Q2));
214  mPythiaEvent->setDF2(StPythiaEvent::AAC2,StMCAsymMaker::get_polPDF_NLO_AAC2(flavor2,x2,Q2));
215  mPythiaEvent->setDF2(StPythiaEvent::AAC3,StMCAsymMaker::get_polPDF_NLO_AAC3(flavor2,x2,Q2));
216  mPythiaEvent->setDF2(StPythiaEvent::BB1,StMCAsymMaker::get_polPDF_NLO_BB1(flavor2,x2,Q2));
217  mPythiaEvent->setDF2(StPythiaEvent::BB2,StMCAsymMaker::get_polPDF_NLO_BB2(flavor2,x2,Q2));
218  mPythiaEvent->setDF2(StPythiaEvent::DNS1,StMCAsymMaker::get_polPDF_NLO_DNS1(flavor2,x2,Q2));
219  mPythiaEvent->setDF2(StPythiaEvent::DNS2,StMCAsymMaker::get_polPDF_NLO_DNS2(flavor2,x2,Q2));
220 
221  mPythiaEvent->setF1(StPythiaEvent::LO,StMCAsymMaker::get_unpolPDF_LO(flavor1,x1,Q2));
222  mPythiaEvent->setF1(StPythiaEvent::NLO,StMCAsymMaker::get_unpolPDF_NLO(flavor1,x1,Q2));
223 
224  mPythiaEvent->setF2(StPythiaEvent::LO,StMCAsymMaker::get_unpolPDF_LO(flavor2,x2,Q2));
225  mPythiaEvent->setF2(StPythiaEvent::NLO,StMCAsymMaker::get_unpolPDF_NLO(flavor2,x2,Q2));
226 
227  mPythiaEvent->setPartonALL(StMCAsymMaker::getPartonicALL(s,t,u,pid,flavor1,flavor2,flavor3,flavor4));
228 }
229 
230 ostream& operator<<(ostream& out, const TVector3& v)
231 {
232  return out << v.x() << '\t' << v.y() << '\t' << v.z();
233 }
234 
235 ostream& operator<<(ostream& out, const TParticle& particle)
236 {
237  out << " name=" << particle.GetName()
238  << " pdg=" << particle.GetPdgCode()
239  << " sta=" << particle.GetStatusCode()
240  << " mo1=" << particle.GetMother(0)
241  << " mo2=" << particle.GetMother(1)
242  << " da1=" << particle.GetDaughter(0)
243  << " da2=" << particle.GetDaughter(1)
244  << " pt=" << particle.Pt()
245  << " pz=" << particle.Pz()
246  << " eta=" << particle.Eta()
247  << " phi=" << particle.Phi()
248  << " e=" << particle.Energy();
249  return out;
250 }
251 
252 ostream& operator<<(ostream& out, const StPythiaEvent& pythiaEvent)
253 {
254  out << "Pythia Record\n"
255  << "run:\t" << pythiaEvent.runId() << '\n'
256  << "event:\t" << pythiaEvent.eventId() << '\n'
257  << "vertex:\t" << pythiaEvent.vertex() << '\n'
258  << "pid:\t" << pythiaEvent.processId() << '\n'
259  << "s:\t" << pythiaEvent.s() << '\n'
260  << "t:\t" << pythiaEvent.t() << '\n'
261  << "u:\t" << pythiaEvent.u() << '\n'
262  << "pt:\t" << pythiaEvent.pt() << '\n'
263  << "cosTheta:\t" << pythiaEvent.cosTheta() << '\n'
264  << "x1:\t" << pythiaEvent.x1() << '\n'
265  << "x2:\t" << pythiaEvent.x2() << '\n';
266  out << Form("%5s%14s%7s%9s%7s%9s%9s%9s%9s%9s\n",
267  "line","particle/jet","status","PDG","mother","pt","eta","phi","E","m");
268  for (int i = 0; i < pythiaEvent.numberOfParticles(); ++i) {
269  const TParticle* particle = pythiaEvent.particle(i);
270  out << Form("%5d%14s%7d%9d%7d%9.3f%9.3f%9.3f%9.3f%9.3f\n",
271  i+1,particle->GetName(),particle->GetStatusCode(),particle->GetPdgCode(),particle->GetFirstMother(),
272  particle->Pt(),particle->Eta(),particle->Phi(),particle->Energy(),particle->GetCalcMass());
273  }
274  return out;
275 }
void Clear(Option_t *option="")
User defined functions.
Definition: Stypes.h:41