StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
doPhoton.C
1 #include "TString.h"
2 #include "assert.h"
3 void doPhoton(unsigned long nEvents, char *infile,char *jobid,char *flag,char *coll,Int_t nFiles=0,char *timestampfile)
4 {
5  Bool_t debug=kFALSE;//macro debug
6  Bool_t debugg=kFALSE;
7 
8  Bool_t USERANDOMIZER=kFALSE;
9 
10  gSystem->Load("StarRoot");
11  gSystem->Load("St_base");
12 
13  //for logger
14  gSystem->Load("liblog4cxx.so");
15  gSystem->Load("StStarLogger.so");
16  StLoggerManager::StarLoggerInit();
17  //--
18 
19  gSystem->Load("StChain");
20  gSystem->Load("St_Tables");
21  gSystem->Load("StarMagField");
22  gSystem->Load("StMagF");
23  gSystem->Load("StUtilities");
24  gSystem->Load("StTreeMaker");
25  gSystem->Load("StIOMaker");
26  gSystem->Load("StarClassLibrary");
27  gSystem->Load("StTpcDb");
28  gSystem->Load("StDetectorDbMaker");
29  gSystem->Load("StDbUtilities");
30  gSystem->Load("StEvent");
31  gSystem->Load("StEventUtilities");
32  gSystem->Load("StMcEvent");
33  gSystem->Load("StMcEventMaker");
34  gSystem->Load("StAssociationMaker");
35  gSystem->Load("StStrangeMuDstMaker");
36  gSystem->Load("StEmcUtil");
37  gSystem->Load("StEEmcUtil");
38  gSystem->Load("StMuDSTMaker");
39 
40  gSystem->Load("StBichsel");
41 
42  gROOT->LoadMacro("$STAR/StRoot/StMuDSTMaker/COMMON/macros/loadSharedLibraries.C");
43  loadSharedLibraries();
44 
45  // libraries for the DB
46  gSystem->Load("StDaqLib");
47  gSystem->Load("StDbLib");
48  gSystem->Load("StDbBroker");
49  gSystem->Load("St_db_Maker");
50 
51  //gSystem->Load("StEmcDecoder");
52  gSystem->Load("StEmcRawMaker");
53  gSystem->Load("StEmcADCtoEMaker");
54  gSystem->Load("StPreEclMaker");
55  gSystem->Load("StEpcMaker");
56 
57  gSystem->Load("StEmcSimulatorMaker");
58  gSystem->Load("StEmcMixerMaker");
59 
60  gSystem->Load("StEmcTriggerMaker");
61 
62  //load timerandomizer:
63  gSystem->Load("StTimeRandomizerMaker");
64 
65  gSystem->Load("/star/u/russcher/MyEvent/MyEvent");
66  gSystem->Load("StPhotonMaker");
67 
68  cout<<"Finished loading libraries"<<endl;
69 
70  StChain* chain = new StChain("bfc");
71 
72  StEmcADCtoEMaker* adcMaker=0;
73  StPreEclMaker* preEcl=0;
74 
75  StTimeRandomizerMaker* rndMaker=0;
76  St_db_Maker* dbMk=0;
77 
78  StDetectorDbMaker* detDbMk=0;
79 
80  TString output(jobid);
81  output.Append("_");
82  output.Append(coll);
83  output.Append("_");
84  output.Append(flag);
85  output.Append(".root");
86 
87  TString input(infile);
88  if(strcmp(flag,"mc")==0||strcmp(flag,"realembed")==0||strcmp(flag,"embed")==0){
89  if(input.EndsWith("list")){
90  cout<<endl<<"running on event.root, prepend @ on "<<input.Data()<<endl;
91  input.Prepend("@");
92  }
93  }
94 
95  StIOMaker* ioMaker=0;
96  StMcEventMaker* mcEventMaker=0;
97  StEmcSimulatorMaker* emcSim=0;
98 
99  //real data chain, for mudst
100  if(strcmp(flag,"real")==0){
101  cout << "Processing REAL data" << endl;
102 
103  if(nFiles==0){
104  cout<<"running on MuDst without number of files specified!!!"<<endl;
105  return;
106  }
107  StMuDstMaker* mudstMaker = new StMuDstMaker(0,0,"",input.Data(),"",nFiles);
108  dbMk = new St_db_Maker("db","MySQL:StarDb", "$STAR/StarDb");
109  detDbMk = new StDetectorDbMaker();
110  StMuDbReader* dbReader = StMuDbReader::instance();
112  }
113 
114  //real data chain, for event.root
115  if(strcmp(flag,"realembed")==0){
116  cout << "Processing REALEMBED data" << endl;
117 
118  ioMaker = new StIOMaker("IO","r",input.Data());
119  ioMaker->SetIOMode("r");
120  ioMaker->SetBranch("*",0,"0");
121  ioMaker->SetBranch("eventBranch", 0, "r");
122 
123  dbMk = new St_db_Maker("db","MySQL:StarDb", "$STAR/StarDb");
124  }
125 
126  //plain monte carlo chain
127  if(strcmp(flag,"mc")==0)
128  {
129  ioMaker = new StIOMaker("IO","r",input.Data());
130  ioMaker->SetIOMode("r");
131  ioMaker->SetBranch("*",0,"0");
132  ioMaker->SetBranch("eventBranch", 0, "r");
133  ioMaker->SetBranch("geantBranch",0,"r");
134 
135  //Oleksandr's timerandomizer:
136  if(USERANDOMIZER){
137  rndMaker=new StTimeRandomizerMaker();
138  rndMaker->setRunTimesFilename(timestampfile);
139  rndMaker->setNormalizeEventsTotal(3000);
140  rndMaker->setDatasetNameStEvent("IO_Root/.data/bfcTree/eventBranch/StEvent");
141  rndMaker->setSeed(0);
142  rndMaker->setBaseEventId(0);
143  }
144 
145  dbMk = new St_db_Maker("db","MySQL:StarDb", "$STAR/StarDb");
146  if(strcmp(coll,"dAu")==0 && !USERANDOMIZER){
147  dbMk->SetDateTime(20030313,000000);
148  }
149  if(strcmp(coll,"pp05")==0 && !USERANDOMIZER){
150  int date=20050508;
151  int time=000001;
152  dbMk->SetDateTime(date,time);
153  }
154  mcEventMaker = new StMcEventMaker();
155  mcEventMaker->doPrintEventInfo=debug;
156  mcEventMaker->doPrintMemoryInfo=debug;
157  mcEventMaker->doPrintCpuInfo=debug;
158 
159  cout << "Processing MC data" << endl;
160 
161  // for MC data StEmcSimulatorMaker should be used instead of StEmcADCtoEMaker
162  emcSim = new StEmcSimulatorMaker();
163  emcSim->setCalibOffset(kBarrelEmcTowerId,0.0);//bemc
164  emcSim->setCalibOffset(kBarrelSmdEtaStripId,0.0);//bsmde
165  emcSim->setCalibOffset(kBarrelSmdPhiStripId,0.0);//bsmdp
166  emcSim->setCalibSpread(kBarrelSmdEtaStripId,0.2);
167  emcSim->setCalibSpread(kBarrelSmdPhiStripId,0.2);
168  if(strcmp(coll,"dAu")==0){
169  emcSim->setCalibSpread(kBarrelEmcTowerId,0.1);
170  }
171  if(strcmp(coll,"pp05")==0){
172  emcSim->setCalibSpread(kBarrelEmcTowerId,0.07);
173  }
174  //set bsmd ADC saturation:
175  //emcSim->setMaximumAdc(kBarrelSmdEtaStripId,650.);
176  //emcSim->setMaximumAdc(kBarrelSmdPhiStripId,650.);
177  }
178  //embedding chain
179  if(strcmp(flag,"embed")==0){
180  ioMaker = new StIOMaker("IO","r",input.Data());
181  ioMaker->SetDebug(debug);
182  ioMaker->SetIOMode("r");
183  ioMaker->SetBranch("*",0,"0");
184  ioMaker->SetBranch("eventBranch", 0, "r");
185  ioMaker->SetBranch("geantBranch",0,"r");
186 
187  cout << "Processing EMBED data" << endl;
188 
189  dbMk=new St_db_Maker("db","MySQL:StarDb", "$STAR/StarDb");
190  cout<<"database done"<<endl;
191 
192  adcMaker=new StEmcADCtoEMaker();
193  adcMaker->setPrint(debug);
194  adcMaker->saveAllStEvent(kTRUE);
195  cout<<"first adcmaker done"<<endl;
196 
197  StEmcPreMixerMaker* preMixer=new StEmcPreMixerMaker("preEmbed");
198  cout<<"added premixer"<<endl;
199 
200  mcEventMaker=new StMcEventMaker();
201  mcEventMaker->doPrintEventInfo=debug;
202  mcEventMaker->doPrintMemoryInfo=debug;
203  mcEventMaker->doPrintCpuInfo=debug;
204  cout<<"added mcEventmaker"<<endl;
205 
206  emcSim = new StEmcSimulatorMaker();
207  cout<<"adjust for new simulator!"<<endl;
208  return;
209 
210  StEmcMixerMaker* emcMix=new StEmcMixerMaker();
211  emcMix->setEmbedAll(kTRUE);//save all embed. hits, if no real hits too
212  emcMix->setPrint(debug);
213  cout<<"mixer done"<<endl;
214 
215  }
216 
217  StEmcADCtoEMaker *adc=0;
218  //in case of embed. rerun, for "real data" first run.
219  if(strcmp(flag,"mc")!=0){
220  adc=new StEmcADCtoEMaker("EReadEmbed2");
221  adc->setPrint(debug);
222  if(strcmp(flag,"embed")==0) adc->setEmbeddingMode(kTRUE);
223  }
224 
225  preEcl = new StPreEclMaker();
226  StEpcMaker *epc = new StEpcMaker();
227  //preEcl->setAlgorithm(kEmcClOld);
228  preEcl->setPrint(debug);
229  epc->setPrint(debug);
230 
232  emcTrigger->setDbMaker(dbMk);
233 
234  StPhotonMaker* photonMaker = new StPhotonMaker("photonMaker",output.Data(),flag,coll,debugg);
235  photonMaker->setDbMaker(dbMk);
236  if(strcmp(flag,"mc")!=0) photonMaker->setAdcMaker(adc);
237 
238  chain->Init();
239 
240  if(preEcl){
241  cout<<endl<<"Using old clustering, setting parameters now!"<<endl;
242  preEcl->SetClusterConditions("bemc", 4, .35, .0350, 0.02, kFALSE);
243  preEcl->SetClusterConditions("bprs", 1, 500., 500., 501., kFALSE);
244  preEcl->SetClusterConditions("bsmde", 5, .20, .0005, 0.10, kFALSE);
245  preEcl->SetClusterConditions("bsmdp", 5, .20, .0005, 0.10, kFALSE);
246  }
247 
248  cout<<endl<<"******** Starting to loop over chain->Make()!!!! *********"<<endl<<endl;
249 
250  for(unsigned long iev=0;iev<nEvents; iev++){
251  if(iev%100==0) cout<<"processing event: "<<iev<<endl;
252  chain->Clear();
253  Int_t iret = chain->Make(iev);
254  if(iev%100==0){
255  //gObjectTable.Print();
256  photonMaker->saveHistograms();
257  }
258  if(iret==2) cout<<"### Last Event Processed. Status = "<<iret<<endl;
259  if(iret==3) cout<<"### Error Event Processed. Status = "<<iret<<endl;
260  if(iret==4) cout<<"### Fatal Event Processed. Status = "<<iret<<endl;
261 
262  if(iret>1) break;
263  }
264 
265 
266  chain->Finish();
267 
268 }
269 
270 
271 
272 
273 
274 
275 
276 
void setEmbeddingMode(Bool_t a)
Set embedding mode (default is kFALSE)
void setPrint(Bool_t)
Obsolete function; users can control messages with logger config file.
virtual void SetIOMode(Option_t *iomode="w")
number of transactions
Definition: StIOInterFace.h:35
void setCalibOffset(StDetectorId det, float offset)
scale simulator calibration coefficients by 1.0 + offset. Default is zero
virtual void Clear(Option_t *option="")
User defined functions.
Definition: StChain.cxx:77
void setPrint(Bool_t a)
Obsolete function; users can control messages with logger config file.
Definition: StPreEclMaker.h:36
void setPrint(Bool_t a)
Obsolete function; users can control messages with logger config file.
virtual Int_t Finish()
Definition: StChain.cxx:85
void SetClusterConditions(char *, Int_t, Float_t, Float_t, Float_t, Bool_t=kFALSE)
this is for background compatibility with the old finder
Filling of all StMcEvent classes from g2t tables Transform all the data in the g2t tables into the co...
Bool_t doPrintMemoryInfo
lots of screen output
void setEmbedAll(Bool_t a)
Set kTRUE to embedd all hits even if the first emcCollection has no hits.
virtual Int_t Make()
Definition: StChain.cxx:110
void setPrint(Bool_t a)
Obsolete function; users can control messages with logger config file.
Definition: StEpcMaker.h:89
void saveAllStEvent(Bool_t a)
Set to kTRUE if all hits are to be saved on StEvent.
void setCalibSpread(StDetectorId det, float spread)
smear simulator calibration coefficients using Gaussian with this RMS.