StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
doEEmcSmd.C
1 //
3 // $Id: doEEmcSmd.C,v 1.2 2006/08/15 21:41:37 jeromel Exp $
4 //
5 // Description:
6 // Run StEEmcSmdAnalysisMaker.
7 // Heavily based on doEvents.C.
8 //
10 
11 #include "iostream"
12 using namespace std;
13 
14 class StChain;
15 StChain *chain=0;
16 Int_t iEvt=0,istat=0,nEvents=0;
17 void doEEmcSmd()
18 {
19  cout << "Usage: doEEmcSmd.C(2) // work with default event.root file" << endl;
20  cout << " doEEmcSmd.C(startEvent,nEvents,\"path/somefile.event.root\")" << endl;
21  cout << " doEEmcSmd.C(nEvents,\"path/*.event.root\")" << endl;
22  cout << " doEEmcSmd.C(nEvents,\"path/file.dst.root\",\"evout\") //Write out StEvent" << endl;
23  cout << " doEEmcSmd.C(nEvents,\"path/file.dst.root\",\"display\") //EventDispay" << endl;
24 }
25 
26 // ProtoTypes
27 void doEEmcSmd(Int_t nEvents, const Char_t ** fileList, const Char_t *qaflag =0);
28 void doEEmcSmd(Int_t startEvent, Int_t nEvents, const Char_t ** fileList, const Char_t *qaflag =0);
29 
30 void doEEmcSmd(Int_t nEvents,
31  const Char_t *file="AuPb200-100.event.root",
32  const Char_t *qaflag = 0);
33 
34 void doEEmcSmd(Int_t startEvent,Int_t nEvents,
35  const Char_t *file="/afs/rhic.bnl.gov/star/data/samples/example.event.root",
36  const Char_t *qaflag = 0);
37 
38 void doEEmcSmd(const Int_t nEvents,
39  const Char_t *path,
40  const Char_t *file,
41  const Char_t *qaflag, int flag);
42 
43 
44 
45 
46 // ------------------ Here is the actual method -----------------------------------------
47 void doEEmcSmd(Int_t startEvent, Int_t nEventsQQ, const Char_t **fileList, const Char_t *qaflag)
48 {
49 
50  nEvents = nEventsQQ;
51  TString tflag = qaflag;
52  int eventDisplay = tflag.Contains("disp",TString::kIgnoreCase);
53 
54  cout << endl << endl <<" doEEmcSmd - input # events = " << nEvents << endl;
55  Int_t ilist=0;
56  while(fileList[ilist]){
57  cout << " doEEmcSmd - input fileList = " << fileList[ilist] << endl;
58  ilist++;
59  }
60 // cout << " doEEmcSmd - input qaflag = " << qaflag << endl;
61 
62  //
63  // First load some shared libraries we need
64  //
65 
66  gSystem->Load("St_base");
67  gSystem->Load("StChain");
68 
69  gSystem->Load("libgen_Tables");
70  gSystem->Load("libsim_Tables");
71  gSystem->Load("libglobal_Tables");
72 
73  gSystem->Load("StUtilities");
74  gSystem->Load("StIOMaker");
75  gSystem->Load("StTreeMaker");
76  gSystem->Load("StarClassLibrary");
77  gSystem->Load("StEvent");
78  gSystem->Load("StEventUtilities");
79  gSystem->Load("StMagF");
80  gSystem->Load("libtpc_Tables");
81 
82  gSystem->Load("StTpcDb");
83  gSystem->Load("StEEmcSmdAnalysisMaker");
84  gSystem->Load("StEEmcUtil");
85 
86  // dbase related libraries
87  gSystem->Load("St_Tables.so");
88  gSystem->Load("StDbLib.so");
89  gSystem->Load("StDbBroker.so");
90  gSystem->Load("libStDb_Tables.so");
91 
92  gSystem->Load("St_db_Maker.so");
93 
94 // Special libraries for EventDisplay
95  if (eventDisplay) {//EventDisplay on
96  gSystem->Load("St_g2t");
97  gSystem->Load("geometry");
98  gSystem->Load("St_geant_Maker");
99  gSystem->Load("StTableUtilities");
100  gSystem->Load("StEventDisplayMaker");
101  }
102 
103  //
104  // Handling depends on whether file is a ROOT file or XDF file
105  //
106  chain = new StChain("StChain");
107  StFileI *setFiles =0;
108  if (fileList) { //Normal case
109  setFiles= new StFile(fileList);
110  } else { //Grand Challenge
111  gSystem->Load("StChallenger");
112  setFiles = StChallenger::Challenge();
113  setFiles->SetDebug();
114  const char *Argv[]= {
115  "-s","dst runco", // list of components needed
116  "-q","numberOfPrimaryTracks>1500", // example of user query
117  "-c","/afs/rhic.bnl.gov/star/incoming/GCA/daq/stacs.rc" // pointer to GC servers for daq
118  };
119  Int_t Argc=sizeof(Argv)/4;
120  setFiles->Init(Argc,Argv);
121  }
122 
123 // Geant maker for EventDisplay
124  if (eventDisplay) {
125  int NwGeant=5000000, IwType=0, NwPaw=0;
126  St_geant_Maker *geantMk = new St_geant_Maker("geant",NwGeant,NwPaw,IwType);
127  geantMk->LoadGeometry("detp geometry year2001");
128  geantMk->SetActive(kFALSE);
129  }
130 
131 
132  TString mainBranch;
133  if (fileList && fileList[0] && strstr(fileList[0],".root")) {
134  mainBranch = fileList[0];
135  printf("fileList[0] %s %s\n",fileList[0],mainBranch.Data());
136  mainBranch.ReplaceAll(".root","");
137  int idot = strrchr((char*)mainBranch,'.') - mainBranch.Data();
138  mainBranch.Replace(0,idot+1,"");
139  mainBranch+="Branch";
140  printf("*** mainBranch=%s ***\n",mainBranch.Data());
141  }
142 
143  StIOMaker *IOMk = new StIOMaker("IO","r",setFiles,"bfcTree");
144  IOMk->SetIOMode("r");
145  IOMk->SetBranch("*",0,"0"); //deactivate all branches
146  if(!mainBranch.IsNull()) IOMk->SetBranch(mainBranch,0,"r");
147  IOMk->SetBranch("dstBranch",0,"r");
148 
149  IOMk->SetDebug();
150 
151  //
152  // Maker to read events from file or database into StEvent
153  //
154  if (!mainBranch.Contains("eventBranch")) {
155  gSystem->Load("StTpcDb");
156  gSystem->Load("StEventMaker");
157  StEventMaker *readerMaker = new StEventMaker("events","title");
158  }
159 
160  //
161  // Db Maker
162  //
163  char *db2 = "StarDb";
164  if (gSystem->AccessPathName(db2) !=0) {
165  printf("File %s does not exist\n",db2);
166  db2 = "";
167  }
168  St_db_Maker *dbMk = new St_db_Maker("dbName","MySQL:StarDb","$STAR/StarDb",db2);
169  dbMk->SetDateTime(010102,000);
170  //
171  // EEmc SMD Analysis maker
172  //
173  StEEmcSmdAnalysisMaker *analysisMaker = new StEEmcSmdAnalysisMaker("EEmcSmdAna");
174 // analysisMaker->setHistoFileName("MySmdAdc.root");
175 // analysisMaker->setSectors(5,6,7,0);
176  analysisMaker->setOuterTrackGeometry();
177  analysisMaker->setAnalysisSectorId(6);
178  analysisMaker->setMinMomentum(1.0);
179  analysisMaker->setMaxGapForMatch(3);
180 
181 
182  // WriteOut StEvent
183  Int_t wrStEOut = tflag.Contains("evout",TString::kIgnoreCase);
184  if (wrStEOut) {
185  cout << "!!!! doEEmcSmd: will write out .event.root file !!" << endl << endl;
186  StTreeMaker *outMk = new StTreeMaker("EvOut","","bfcTree");
187  outMk->SetIOMode("w");
188  outMk->SetBranch("eventBranch","test.event.root","w");
189  outMk->IntoBranch("eventBranch","StEvent");
190  }
191 
192 
193 // StEventDisplayMaker
194  if (eventDisplay) {
195 
196  StEventDisplayMaker *displayMk = new StEventDisplayMaker();
197  displayMk->AddName("StEvent(All Tracks)");
198  displayMk->AddFilter(new StFilterDef("MainFilter"));
199 
200  }
201 
202  //
203  // Initialize chain
204  //
205  Int_t iInit = chain->Init();
206  if (iInit) chain->Fatal(iInit,"on init");
207  chain->PrintInfo();
208  if (startEvent > 1) IOMk->Skip(startEvent-1);
209 
210 
211 
212 //----- added 6/20/00 by Kathy
213  TTable *tabl=0;
214  TDataSet *obj=0;
215  TDataSet *ddb=0;
216  TDataSet *ddstBranch=0;
217 //------
218 
219  //
220  // Event loop
221  //
222  istat=0,iEvt=1;
223 
224  EventLoop: if (iEvt <= nEvents && istat!=2) {
225 
226  cout << endl << "=== Event " << iEvt << " start ===" << endl;
227 
228  chain->Clear();
229  istat = chain->Make(iEvt);
230 
231  if (istat==2)
232  {cout << "Last event processed. Status = " << istat << endl;}
233  if (istat==3)
234  {cout << "Error event processed. Status = " << istat << endl;}
235 
236 
237  iEvt++;
238  goto EventLoop;
239  }
240 
241  iEvt--;
242  cout << endl << "=== Event " << iEvt << " finish ===" << endl;
243 
244 }
245 
246 //--------------------------------------------------------------------------
247 
248 void doEEmcSmd(const Int_t startEvent, const Int_t nEvents, const Char_t *file, const Char_t *qaflag)
249 {
250  printf("*file = %s\n",file);
251  const char *fileListQQ[]={0,0};
252  if (strncmp(file,"GC",2)==0) {
253  fileListQQ=0;
254  } else {
255  fileListQQ[0]=file;
256  }
257  doEEmcSmd(startEvent,nEvents,fileListQQ,qaflag);
258 }
259 //--------------------------------------------------------------------------
260 void doEEmcSmd(const Int_t nEvents, const Char_t *file, const Char_t *qaflag)
261 {
262  doEEmcSmd(1,nEvents,file,qaflag);
263 }
264 
265 //--------------------------------------------------------------------------
266 void doEEmcSmd(const Int_t nEvents, const Char_t *path,const Char_t *file, const Char_t *qaflag, int flag)
267 {
268  TString F;
269  if (path && path[0] && path[0]!='-') F = path;
270  if (file && file[0] && file[0]!='-')
271  {
272  if (!F.IsNull()) F +="/";
273  F += file;
274  }
275  TString opt = qaflag;
276  if (flag) opt += " evout";
277 
278 
279  doEEmcSmd(1,nEvents,F.Data(),opt.Data());
280 }
281 
282 //--------------------------------------------------------------------------
283 void doEEmcSmd(Int_t nEvents, const Char_t **fileList, const Char_t *qaflag)
284 { doEEmcSmd(1,nEvents,fileList,qaflag); }
285 
287 //
288 // $Log: doEEmcSmd.C,v $
289 // Revision 1.2 2006/08/15 21:41:37 jeromel
290 // Fix rhic -> rhic.bnl.gov
291 //
292 // Revision 1.1 2003/11/25 20:12:32 wzhang
293 // first version
294 //
295 
297 
Definition: StTree.h:125
virtual void SetIOMode(Option_t *iomode="w")
number of transactions
Definition: StIOInterFace.h:35
virtual void Clear(Option_t *option="")
User defined functions.
Definition: StChain.cxx:77
virtual Int_t Make()
Definition: StChain.cxx:110
Definition: TTable.h:48
virtual void SetActive(Bool_t k=kTRUE)
Setters for flags and switches.
Definition: StMaker.h:208
virtual void LoadGeometry(const Char_t *option="detp geometry field_only")
Specifies GEANT3 geometry command.