StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
StLuminosityMaker.cxx
1 #include "StMessMgr.h"
2 #include "StLuminosityMaker.h"
3 #include "StLuminosityHolder.h"
4 #include "StDetectorDbMaker/StDetectorDbTriggerID.h"
5 #include "StDetectorDbMaker/StDetectorDbBeamInfo.h"
6 #include "StMuDSTMaker/COMMON/StMuDst.h"
7 #include "StMuDSTMaker/COMMON/StMuEvent.h"
8 #include "StEvent/StTriggerId.h"
9 #include "StSpinPool/StTriggerFilterMaker/StTriggerFilterMaker.h"
10 
11 ClassImp(StLuminosityMaker)
12 
13 StLuminosityMaker::StLuminosityMaker(const char* name):StMaker(name)
14 {
15  mTriggers.clear();
16  mNTotal.clear();
17  mNCuts.clear();
18  mPrescales.clear();
19  mLumTotal.clear();
20  mLumCuts.clear();
21  mXsec = -1.0;
22  runMode = "";
23  runNumber = 0;
24  mVertexCut = 0;
25  mOverrideMode = 0;
26  muDstMaker = NULL;
27  mTriggerSimuMaker = NULL;
28  mLumHolder = NULL;
29  mFilterMode = 0;
30 }
31 //_____________________________________________________________________________
32 Int_t StLuminosityMaker::Init()
33 {
34  muDstMaker = dynamic_cast<StMuDstMaker*>(GetMaker("MuDst"));
35  assert(muDstMaker);
36  mTriggerSimuMaker = dynamic_cast<StTriggerSimuMaker*>(GetMaker("StarTrigSimu"));
37  if(!strcmp(runMode,"")){
38  LOG_ERROR<<"runMode is not set"<<endm;
39  return kStErr;
40  }
41 
42  LOG_INFO<<"Using minbias cross-section: "<<getCrossSectionNB()<<" (nb)"<<endm;
43 
44  mLumHolder = new TClonesArray("StLuminosityHolder",20);
45 
46  return StMaker::Init();
47 }
48 //_____________________________________________________________________________
49 Int_t StLuminosityMaker::InitRun(int run)
50 {
51  if(runNumber != 0){
52  saveOutput();
53  printOutput();
54  }
55  LOG_INFO<<"Now starting Run#"<<run<<endm;
56  runNumber = run;
57  for(unsigned int i = 0; i < mTriggers.size(); i++){
58  mNTotal[i] = 0;
59  mNCuts[i] = 0;
60  mNVertex[i] = 0;
61  mPrescales[i] = 0.0;
62  }
63 
64  return kStOk;
65 
66 }
67 //_____________________________________________________________________________
69  saveOutput();
70  printOutput();
71  return StMaker::Finish();
72 }
73 //_____________________________________________________________________________
75  StDetectorDbTriggerID* dbtrig = StDetectorDbTriggerID::instance();
76  StMuDst* mudst = muDstMaker->muDst();assert(mudst);
77  StMuEvent* muevent = mudst->event();assert(muevent);
78 
79  int passtrig = 0;
80  int passvert = 0;
81 
82  const StTriggerId& trigs = muevent->triggerIdCollection().nominal();
83 
84  for(unsigned int i = 0; i < mTriggers.size(); i++){
85  if(trigs.isTrigger(mTriggers[i])){
86  float prs = dbtrig->getTotalPrescaleByTrgId(mTriggers[i]);
87  mPrescales[i] = prs;
88  mNTotal[i]++;
89  passtrig++;
90  float vertz = TMath::Abs(muevent->primaryVertexPosition().z());
91  if(vertz > 1e-5)mNVertex[i]++;
92  if(mTriggerSimuMaker && !mTriggerSimuMaker->isTrigger(mTriggers[i]))continue;
93  mNSoftTrig[i]++;
94  if(mVertexCut > vertz && vertz > 1e-5){
95  mNCuts[i]++;
96  passvert++;
97  }
98  }
99  }
100  if(mFilterMode && !passvert && !passtrig) return kStSkip;
101 
102  return kStOK;
103 }
104 //_____________________________________________________________________________
105 void StLuminosityMaker::addTrigger(unsigned int trigId)
106 {
107  mTriggers.push_back(trigId);
108  mNTotal.push_back(0);
109  mNCuts.push_back(0);
110  mNVertex.push_back(0);
111  mNSoftTrig.push_back(0);
112  mPrescales.push_back(0.0);
113  mLumTotal.push_back(0.0);
114  mLumCuts.push_back(0.0);
115  mLumVertex.push_back(0.0);
116  mLumSoftTrig.push_back(0.0);
117 }
118 //_____________________________________________________________________________
119 void StLuminosityMaker::setMode(const char* newMode)
120 {
121  float oldxsec = mXsec;
122 
123  if(!strcmp(newMode,"dAu2008")){
124  runMode = newMode;
125  mXsec = 13.8e3;
126  }else if(!strcmp(newMode,"pp2008")){
127  runMode = newMode;
128  mXsec = 26.1e6;
129  }else if(!strcmp(newMode,"AuAu2007")){
130  runMode = newMode;
131  mXsec = 10e9;
132  }else if(!strcmp(newMode,"pp2006")){
133  runMode = newMode;
134  mXsec = 26.1e6;
135  }else if(!strcmp(newMode,"pp2006_62GeV")){
136  runMode = newMode;
137  mXsec = 20e6;
138  }else if(!strcmp(newMode,"pp2005")){
139  runMode = newMode;
140  mXsec = 26.1e6;
141  }else if(!strcmp(newMode,"CuCu2005")){
142  runMode = newMode;
143  mXsec = 3.3e9;
144  }else if(!strcmp(newMode,"pp2004")){
145  runMode = newMode;
146  mXsec = 26.1e6;
147  }else if(!strcmp(newMode,"AuAu2004")){
148  runMode = newMode;
149  mXsec = 6.5e9;
150  }else if(!strcmp(newMode,"dAu2003")){
151  runMode = newMode;
152  mXsec = 2.2e9 * .2;
153  }else if(!strcmp(newMode,"pp2003")){
154  runMode = newMode;
155  mXsec = 26.1e6;
156  }else if(strcmp(newMode,"")){
157  LOG_ERROR<<"Invalid mode "<<newMode<<" passed to StLuminosityMaker"<<endm;
158  }else{
159  LOG_ERROR<<"StLuminosityMaker requires a running mode"<<endm;
160  }
161  if(mOverrideMode){
162  mXsec = oldxsec;
163  }
164 
165 }
166 //_____________________________________________________________________________
167 void StLuminosityMaker::setCrossSectionNB(float newXsec,int overRideMode)
168 {
169  mXsec = newXsec;
170  mOverrideMode = overRideMode;
171  runMode = "manual";
172 }
173 //_____________________________________________________________________________
174 void StLuminosityMaker::printOutput()
175 {
176  LOG_INFO<<"Luminosity analyzed for Run #"<<runNumber<<":"<<endm;
177  for(unsigned int i = 0; i < mTriggers.size(); i++){
178  float totalsampled = 0;
179  float cutsampled = 0;
180  if(mNTotal[i] > 0){
181  totalsampled = mPrescales[0]*mNTotal[0]/(mPrescales[i]*mXsec);
182  cutsampled = totalsampled * mNCuts[i] / mNTotal[i];
183  }
184 
185  LOG_INFO<<"Trigger "<<mTriggers[i]<<": "<<totalsampled<<" nb^-1 total and "<<cutsampled<<" nb^-1 after cuts, "<<mNTotal[i]<<" "<<mNCuts[i]<<endm;
186  }
187 }
188 //_____________________________________________________________________________
189 void StLuminosityMaker::getTriggersFromFilterMaker(const char* filtername)
190 {
191  StTriggerFilterMaker* filter = dynamic_cast<StTriggerFilterMaker*>(GetMaker(filtername));
192  assert(filter);
193  vector<unsigned int>filtertriggers = filter->getTriggers();
194  for(unsigned int i = 0; i < filtertriggers.size(); i++){
195  addTrigger(filtertriggers[i]);
196  }
197 }
198 //_____________________________________________________________________________
199 void StLuminosityMaker::saveOutput()
200 {
201  for(unsigned int i = 0; i < mTriggers.size(); i++){
202  float totalsampled = 0;
203  float vertsampled = 0;
204  float softtrigsampled = 0;
205  float cutsampled = 0;
206  if(mNTotal[i] > 0){
207  totalsampled = mPrescales[0]*mNTotal[0]/(mPrescales[i]*mXsec);
208  cutsampled = totalsampled * mNCuts[i] / mNTotal[i];
209  softtrigsampled = totalsampled * mNSoftTrig[i] / mNTotal[i];
210  vertsampled = totalsampled * mNVertex[i] / mNTotal[i];
211  }
212  mLumTotal[i] = totalsampled;
213  mLumCuts[i] = cutsampled;
214  mLumSoftTrig[i] = softtrigsampled;
215  mLumVertex[i] = vertsampled;
216  }
217 
218  StLuminosityHolder* lum = new StLuminosityHolder(runNumber);
219 
220  lum->setTriggers(mTriggers);
221  lum->setLumTotal(mLumTotal);
222  lum->setLumCuts(mLumCuts);
223  lum->setLumVertex(mLumVertex);
224  lum->setLumSoftTrig(mLumSoftTrig);
225  lum->setNTotal(mNTotal);
226  lum->setNCuts(mNCuts);
227  lum->setNVertex(mNVertex);
228  lum->setNSoftTrig(mNSoftTrig);
229  lum->setPrescales(mPrescales);
230  lum->setCrossSectionNB(mXsec);
231  lum->setVertexCutcm(mVertexCut);
232 
233  new ( (*mLumHolder)[mLumHolder->GetLast()+1] ) StLuminosityHolder(*lum);
234 
235 }
virtual Int_t Make()
StThreeVectorF primaryVertexPosition(int vtx_id=-1) const
The StMuDst is supposed to be structured in &#39;physical events&#39;. Therefore there is only 1 primary vert...
Definition: StMuEvent.cxx:221
StMuDst * muDst()
Definition: StMuDstMaker.h:425
Accessor to the database for trigger id information.
virtual Int_t Finish()
Definition: Stypes.h:49
static StMuEvent * event()
returns pointer to current StMuEvent (class holding the event wise information, e.g. event number, run number)
Definition: StMuDst.h:320
Definition: Stypes.h:40
virtual Int_t Finish()
Definition: StMaker.cxx:776
Float_t getTotalPrescaleByTrgId(Int_t trgId)
Definition: Stypes.h:44
Definition: Stypes.h:41