StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
StjMCMuDst.cxx
1 // $Id: StjMCMuDst.cxx,v 1.12 2012/01/21 17:36:11 pibero Exp $
2 
3 #include <TDataSet.h>
4 #include <TDataSetIter.h>
5 #include <TLorentzVector.h>
6 
7 #include <StMaker.h>
8 #include <tables/St_g2t_event_Table.h>
9 #include <tables/St_g2t_vertex_Table.h>
10 #include <tables/St_g2t_pythia_Table.h>
11 #include <tables/St_particle_Table.h>
12 
13 #include <StjMCParticleCutParton.h>
14 #include <StjMCMuDst.h>
15 #include "StarGenerator/StarGenEventReader/StarGenEventReader.h"
16 #include "StarGenerator/EVENT/StarGenParticle.h"
17 
18 StjPrimaryVertex StjMCMuDst::getMCVertex() const
19 {
21  if (TDataSet* Event = _maker->GetDataSet("geant")) {
22  TDataSetIter geantDstI(Event);
23  if (const St_g2t_vertex* g2t_vertex_descriptor = (const St_g2t_vertex*)geantDstI("g2t_vertex"))
24  if (const g2t_vertex_st* g2t_vertex_table = g2t_vertex_descriptor->GetTable())
25  {
26  const float* geantvertex = g2t_vertex_table[0].ge_x;
27  vertex.mPosition.SetXYZ(geantvertex[0],geantvertex[1],geantvertex[2]);
28  }
29  }
30  return vertex;
31 }
32 
33 StjMCParticleList StjMCMuDst::getMCParticleList()
34 {
35  StjMCParticleList theList;
36 
37  if (TDataSet* Event = _maker->GetDataSet("geant")) {
38  TDataSetIter geantDstI(Event);
39 
40  // Get run number and event number from table g2t_event
41  int runNumber = -1;
42  int eventNumber = -1;
43 
44  if (const St_g2t_event* g2t_event_descriptor = (const St_g2t_event*)geantDstI("g2t_event")) {
45  if (const g2t_event_st* g2t_event_table = g2t_event_descriptor->GetTable()) {
46  runNumber = g2t_event_table->n_run;
47  eventNumber = g2t_event_table->n_event;
48  }
49  }
50 
51  // Get Pythia variables
52  if (St_g2t_pythia* g2t_pythia = (St_g2t_pythia*)geantDstI("g2t_pythia")) {
53  if (g2t_pythia_st* pythiaTable = g2t_pythia->GetTable()) {
54  StjMCParticleCutParton::mstu72 = pythiaTable->mstu72;
55  StjMCParticleCutParton::mstu73 = pythiaTable->mstu73;
56  }
57  }
58 
59  // Get particles from table particle
60  if (const St_particle* particle_descriptor = (const St_particle*)geantDstI("particle")) {
61  if (const particle_st* particle_table = particle_descriptor->GetTable()) {
62  for (int i = 0; i < particle_descriptor->GetNRows(); ++i) {
63  StjMCParticle particle;
64  particle.runNumber = runNumber;
65  particle.eventId = eventNumber;
66  particle.status = particle_table[i].isthep;
67  particle.mcparticleId = i+1;
68  particle.pdg = particle_table[i].idhep;
69  particle.firstMotherId = particle_table[i].jmohep[0];
70  particle.lastMotherId = particle_table[i].jmohep[1];
71  particle.firstDaughterId = particle_table[i].jdahep[0];
72  particle.lastDaughterId = particle_table[i].jdahep[1];
73  particle.vertexZ = particle_table[i].vhep[2];
74 
75  TLorentzVector p4(particle_table[i].phep);
76  particle.pt = p4.Pt();
77  particle.eta = p4.Eta();
78  particle.phi = p4.Phi();
79  particle.m = p4.M();
80  particle.e = p4.E();
81 
82  theList.push_back(particle);
83  }
84  }
85  }
86  }else if(genEvent){
87 
88  LOG_INFO <<"There is no geant in _maker. Proceed with Particle info from StarGenEventReader. " << endm;
89 
90  StarGenParticle* particle = 0;
91 
92  int nparts = genEvent->GetNumberOfParticles();
93 
94  int runNumber = -1;
95  int eventNumber = -1;
96 
97  runNumber = genEvent->GetRunNumber();
98  eventNumber = genEvent->GetEventNumber();
99 
100  for(int ipar = 0; ipar < nparts; ipar++){
101  particle = (StarGenParticle*)(genEvent->operator[](ipar));
102 
103  StjMCParticle mcParticle;
104  mcParticle.runNumber = runNumber;
105  mcParticle.eventId = eventNumber;
106 
107  mcParticle.status = particle->GetStatus();
108  mcParticle.mcparticleId = ipar+1;
109  mcParticle.pdg = particle->GetId();
110  mcParticle.firstMotherId = particle->GetFirstMother();
111  mcParticle.lastMotherId = particle->GetLastMother();
112  mcParticle.firstDaughterId = particle->GetFirstDaughter();
113  mcParticle.lastDaughterId = particle->GetLastDaughter();
114  mcParticle.vertexZ = particle->GetVz();
115 
116  TLorentzVector p4 = particle->momentum();
117  mcParticle.pt = p4.Pt();
118  mcParticle.eta = p4.Eta();
119  mcParticle.phi = p4.Phi();
120  mcParticle.m = p4.M();
121  mcParticle.e = p4.E();
122 
123  theList.push_back(mcParticle);
124  }
125  }
126  return theList;
127 }
Float_t GetVz()
Get the z-component of the start vertex.
Int_t GetNumberOfParticles()
Obtain the number of particles in the event record.
Definition: StarGenEvent.h:187
Yet another particle class.
Int_t GetStatus()
Get the status code of the particle according to the HEPEVT standard.
Int_t GetEventNumber()
Get the event number.
Definition: StarGenEvent.h:108
Int_t GetId()
Get the id code of the particle according to the PDG standard.
TLorentzVector momentum()
Return the 4-momentum of the particle.
Int_t GetLastMother()
Get the last mother particle.
Int_t GetFirstMother()
Get the first mother particle.
Int_t GetLastDaughter()
Get the last daughter particle.
Definition: AgUStep.h:26
Int_t GetFirstDaughter()
Get the first daughter particle.
Int_t GetRunNumber()
Get the run number for this event.
Definition: StarGenEvent.h:113