StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
StGammaEventMaker.cxx
1 #include "TChain.h"
2 
3 #include "StGammaPythiaEvent.h"
4 #include "StGammaPythiaEventMaker.h"
5 #include "StGammaEventMaker.h"
6 #include "StGammaEvent.h"
7 #include "StGammaScheduleMaker.h"
8 #include "StMuDSTMaker/COMMON/StMuDstMaker.h"
9 #include "StMuDSTMaker/COMMON/StMuDst.h"
10 #include "StMuDSTMaker/COMMON/StMuEvent.h"
11 #include "StMuDSTMaker/COMMON/StMuPrimaryVertex.h"
12 
13 #include "StTriggerUtilities/StTriggerSimuMaker.h"
14 #include "StSpinPool/StSpinDbMaker/StSpinDbMaker.h"
15 
16 ClassImp(StGammaEventMaker);
17 
19 // Constructor //
21 StGammaEventMaker::StGammaEventMaker(const char *name): StMaker(name)
22 {}
23 
25 // Destructor //
27 StGammaEventMaker::~StGammaEventMaker()
28 {}
29 
31 // Maker Init //
33 Int_t StGammaEventMaker::Init()
34 {
35 
36  // Instantaite a new StGammaEvent
37  mGammaEvent = new StGammaEvent();
38 
39  // Retrieve StGammaPythiaEventMaker from the chain
40  mPythia = 0;
41  mPythiaMaker = dynamic_cast<StGammaPythiaEventMaker*>(GetMakerInheritsFrom("StGammaPythiaEventMaker"));
42  if(mPythiaMaker)
43  {
44  mPythia = new StGammaPythiaEvent;
45  mPythiaMaker->SetPythia(mPythia);
46  mGammaEvent->SetPythia(mPythia);
47  }
48 
49  // Retrieve StMuDstMaker from the chain
50  muDstMaker = dynamic_cast<StMuDstMaker*>(GetMakerInheritsFrom("StMuDstMaker"));
51  assert(muDstMaker);
52 
53  return StMaker::Init();
54 }
55 
57 // Maker Clear //
59 void StGammaEventMaker::Clear(Option_t *opts)
60 {
61  mGammaEvent->Clear(opts);
62  StMaker::Clear(opts);
63 }
64 
65 
67 // Maker Make //
70 {
71 
72  // Retrieve MuDst
73  if(!GetDataSet("MuDst"))
74  {
75  LOG_WARN << "No MuDst" << endm;
76  return kStFatal;
77  }
78 
79  // Retrieve the primary vertex, or set
80  // vertex to zero if none is found
82  if(pv)
83  {
84  mGammaEvent->SetVertex(TVector3(pv->position().xyz()));
85  mGammaEvent->SetVertexRank(pv->ranking());
86  mGammaEvent->mFlags |= TPC_VERTEX;
87  }
88  else
89  {
90  mGammaEvent->SetVertex(TVector3(0.,0.,0.));
91  mGammaEvent->SetVertexRank(-100);
92  mGammaEvent->mFlags |= !(TPC_VERTEX);
93  }
94 
95  mGammaEvent->SetRunNumber( StMuDst::event()->runNumber() );
96  mGammaEvent->SetEventNumber( StMuDst::event()->eventNumber() );
97  mGammaEvent->SetMudstFileName( muDstMaker->chain()->GetFile()->GetName() );
98  mGammaEvent->SetMagneticField( StMuDst::event()->magneticField() );
99  mGammaEvent->SetTriggerIds( StMuDst::event()->triggerIdCollection().nominal().triggerIds() );
100  mGammaEvent->SetBunchCrossing48bit( StMuDst::event()->l0Trigger().bunchCrossingId() );
101  mGammaEvent->SetBunchCrossing7bit( StMuDst::event()->l0Trigger().bunchCrossingId7bit( mGammaEvent->runNumber() ) );
102 
103  // Store simulated triggers
104  vector<unsigned int> simuTriggers;
105 
106  StTriggerSimuMaker *triggerSimu = dynamic_cast<StTriggerSimuMaker*>(GetMakerInheritsFrom("StTriggerSimuMaker"));
107  if(triggerSimu)
108  {
109 
110  for(unsigned int i = 0; i < mRequestedTriggers.size(); ++i)
111  {
112 
113  if(triggerSimu->isTrigger(mRequestedTriggers.at(i)))
114  {
115  simuTriggers.push_back(mRequestedTriggers.at(i));
116  cout << "StGammaEventMaker::Make() - " << mRequestedTriggers.at(i) << " fired!" << endl;
117  }
118  else
119  {
120  cout << "StGammaEventMaker::Make() - " << mRequestedTriggers.at(i) << " did not fire!" << endl;
121  }
122 
123  }
124 
125  }
126 
127  mGammaEvent->SetSimuTriggerIds(simuTriggers);
128 
129  // Store spin information
130  StSpinDbMaker* spinDb = dynamic_cast<StSpinDbMaker*>(GetMakerInheritsFrom("StSpinDbMaker"));
131  if(spinDb)
132  {
133 
134  mGammaEvent->SetValidDb(spinDb->isValid());
135  mGammaEvent->SetSpin4( spinDb->spin4usingBX48( mGammaEvent->bunchCrossing48bit() ) );
136  mGammaEvent->SetBunchCrossingStar( spinDb->BXstarUsingBX48( mGammaEvent->bunchCrossing48bit() ) );
137 
138  if(spinDb->isPolDirLong()) mGammaEvent->SetPolarizationType(StGammaEvent::kLongLong);
139  else if(spinDb->isPolDirTrans()) mGammaEvent->SetPolarizationType(StGammaEvent::kTransTrans);
140 
141  }
142 
143 
144  // Store timestamp index in place of run number in simulation
145  // when dynamic timestamps have been specified in the GammaMaker
146  StGammaScheduleMaker *scheduler = dynamic_cast<StGammaScheduleMaker*>(GetMakerInheritsFrom("StGammaScheduleMaker"));
147  if(scheduler)
148  {
149  if(scheduler->nStamps()) mGammaEvent->SetRunNumber(scheduler->index());
150  }
151 
152  return kStOK;
153 
154 }
static StMuPrimaryVertex * primaryVertex()
return pointer to current primary vertex
Definition: StMuDst.h:322
Int_t runNumber() const
Return ith candidate.
Definition: StGammaEvent.h:73
bool isPolDirTrans()
true if all needed DB tables were found
Definition: StSpinDbMaker.h:54
bool isValid()
dump spinDb content for current time stamp
Definition: StSpinDbMaker.h:53
void Clear(Option_t *opts="")
User defined functions.
virtual void Clear(Option_t *option="")
User defined functions.
Definition: StMaker.cxx:634
int spin4usingBX48(int bx48)
8bit spin information
static StMuEvent * event()
returns pointer to current StMuEvent (class holding the event wise information, e.g. event number, run number)
Definition: StMuDst.h:320
void SetRunNumber(Int_t run)
Add a new gamma candidate.
Definition: StGammaEvent.h:107
Definition: Stypes.h:40
TChain * chain()
In read mode, returns pointer to the chain of .MuDst.root files that where selected.
Definition: StMuDstMaker.h:426
bool isPolDirLong()
Returns true if beams are transversely polarized, false otherwise.
Definition: StSpinDbMaker.h:55