StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
tpc.C
1 // $Id: tpc.C,v 1.9 1999/05/01 01:47:31 fisyak Exp $
2 // $Log: tpc.C,v $
3 // Revision 1.9 1999/05/01 01:47:31 fisyak
4 // Add new set of bfc s'
5 //
6 // Revision 1.16 1999/04/29 23:54:18 fisyak
7 // Add StRootEvent and test on existing of input file
8 //
9 // Revision 1.15 1999/04/27 21:01:11 snelling
10 // fixed a few switches
11 //
12 // Revision 1.14 1999/04/20 12:56:08 fisyak
13 // Add ctf/mwc
14 //
15 // Revision 1.12 1999/04/19 13:43:19 fisyak
16 // Take out L3
17 //
18 // Revision 1.11 1999/04/18 23:45:05 fisyak
19 // New schema
20 //
21 // macro to read fz files, xdf files and minidaq data
22 //
24 // //
25 // Macro for running chain with different inputs //
26 // //
28 // default is g2t data
29 #define MINIDAQ /* TPC minidaq data */
30 //#define FZIN /* GEANT fz-file */
31 //#define GTRACK /* GEANT simulation on flight */
32 #ifndef MINIDAQ
33 #endif /* GTRACK or FZIN */
34 #ifdef FZIN
35 #define GEANT
36 #endif /* FZIN */
37 #ifdef GTRACK
38 #define GEANT
39 #endif /* GTRACK */
40 #ifndef GEANT
41 #define StMagF
42 #endif
43 #ifdef MINIDAQ
44 #define CTEST
45 #define StMagF
46 #undef FZIN
47 #undef GTRACK
48 #endif /* MINIDAQ */
49 #define TPC
50 //#define tclPixTransOn // additional flat pixel table
51 //#define tptResOn // fill table with residuals from tracking
52 //#define TRS
53 //#define TSS
54 #if defined(FZIN) || defined(GTRACK)
55 #define FTPC
56 #define FSS
57 #define SVT
58 #define EMC
59 #define CTF
60 #define L3
61 #define GLOBAL
62 #define ANALYSIS
63 #endif /* new data only FZIN or GTRACK */
64 //#define XDFOUT
65 
66 TBrowser *b = 0;
67 class StChain;
68 StChain *chain=0;
69 class St_geant_Maker;
70 St_geant_Maker *geant;
71 void Load(){
72  gSystem->Load("St_base");
73  gSystem->Load("StChain");
74  gSystem->Load("xdf2root");
75  gSystem->Load("St_Tables");
76  gSystem->Load("libmsg");
77  gSystem->Load("libtls");
78  gSystem->Load("St_db_Maker");
79  gSystem->Load("St_xdfin_Maker");
80 #ifdef StMagF
81  gSystem->Load("StMagF");
82 #else /* no StMagF, GEANT field */
83  gSystem->Load("geometry");
84 #endif /* StMagF */
85  gSystem->Load("StarClassLibrary");
86 #ifdef TPC
87  gSystem->Load("St_tpc");
88  gSystem->Load("St_tcl_Maker");
89  gSystem->Load("St_tpt_Maker");
90  #ifdef TRS
91  gSystem->Load("StTrsMaker");
92  gSystem->Load("St_tpcdaq_Maker");
93  #else /* no TRS */
94  #ifdef TSS
95  gSystem->Load("St_tss_Maker");
96  #endif /* TSS */
97  #endif /* TRS */
98 #endif /* TPC */
99 #ifdef MINIDAQ
100  gSystem->Load("StMinidaqMaker");
101 #endif /* MINIDAQ */
102 #ifdef GEANT
103  gSystem->Load("St_g2r");
104  gSystem->Load("St_geant_Maker");
105 #endif /* GEANT */
106 #ifdef FTPC
107  gSystem->Load("St_ftpc");
108 #ifdef FSS
109  gSystem->Load("St_fss_Maker");
110 #endif /* FSS */
111  gSystem->Load("St_fcl_Maker");
112  gSystem->Load("St_fpt_Maker");
113 #endif /* FTPC */
114 #ifdef EMC
115  gSystem->Load("St_emc");
116  gSystem->Load("St_ems_Maker");
117 #if 0
118  gSystem->Load("St_emc_Maker");
119 #endif
120 #endif /* EMC */
121 #ifdef CTF
122  gSystem->Load("St_ctf");
123  gSystem->Load("St_ctf_Maker");
124  gSystem->Load("St_mwc");
125  gSystem->Load("St_mwc_Maker");
126  gSystem->Load("St_trg");
127  gSystem->Load("St_trg_Maker");
128 #endif /* CTF */
129 #ifdef L3
130  gSystem->Load("St_l3");
131  gSystem->Load("St_l3t_Maker");
132 #endif /* L3 */
133  // gSystem->Load("StRchMaker");
134 #if defined(SVT) || defined(GLOBAL)
135  gSystem->Load("St_svt");
136 #endif
137 #ifdef SVT
138  gSystem->Load("St_srs_Maker");
139  gSystem->Load("St_stk_Maker");
140 #endif /* SVT */
141 #ifdef GLOBAL
142  gSystem->Load("St_global");
143  gSystem->Load("StRootEvent");
144  gSystem->Load("St_dst_Maker");
145 #ifdef ANALYSIS
146  gSystem->Load("StRAnalysisMaker");
147 #endif
148  gSystem->Load("St_QA_Maker");
149  gSystem->Load("StTreeMaker");
150 #endif /* GLOBAL */
151 }
152 
153 void tpc (const Int_t Nevents=1,Char_t *infile=0, Char_t *outfile=0)
154 {
155  Int_t NoEvents = Nevents;
156  // define input file
157  if (!infile) {
158 #ifdef MINIDAQ
159  // laser data
160  infile ="/afs/rhic/star/tpc/data/tpc_s18e_981105_03h_cos_t22_f1.xdf";
161 #else /*not MINIDAQ */
162 #ifdef FZIN
163  // zebra file
164  // infile ="/afs/rhic/star/tpc/data/trs_muon_10cmdrift_good.fzd";
165  infile ="/disk1/star/test/psc0049_08_40evts.fzd";
166 #else
167 #ifndef GTRACK
168  // g2t xdf file
169  infile ="/afs/rhic/star/data/samples/hijet-g2t.xdf";
170 #endif /* no GTRACK */
171 #endif /* FZIN */
172 #endif /* MINIDAQ */
173  }
174 #ifdef GTRACK
175  if (!outfile) FileOut = new TString("gtrack.root");
176  else FileOut = new TString(outfile);
177  printf("Output root file name %s\n", FileOut.Data());
178  printf("==============================================\n");
179 #else /*not GTRACK */
180 #ifdef FZIN
181  // zebra file, set I/O for crs using "input_file" varaible if any
182  TString InFile = "$input_file";
183  gSystem->ExpandPathName(InFile);
184  Int_t NoEvents = Nevents;
185  if (!strcmp("$input_file",InFile.Data())) {
186  InFile = infile;
187  }
188  else {
189  Int_t NoEvents = atoi(strrchr(InFile.Data(),'_')+1);
190  if (NoEvents <=0) {NoEvents = Nevents;}
191  if (NoEvents > Nevents) {NoEvents = Nevents;}
192  }
193 #endif /* FZIN */
194  TString InFile(infile);
195 // Check the input file
196  if (gSystem->AccessPathName(InFile.Data())) {// file does not exist
197  printf(" *** NO FILE: %s, exit!\n", InFile.Data());
198  gSystem->Exit(1);
199  }
200  if (outfile) FileOut = new TString(outfile);
201  else {
202  FileOut = new TString(gSystem->BaseName(InFile.Data()));
203  FileOut->ReplaceAll(".fzd",".root");
204  FileOut->ReplaceAll(".fz",".root");
205  FileOut->ReplaceAll(".xdf",".root");
206  FileOut->Strip();
207  }
208  printf("==============================================\n");
209  printf("Input file name = %s with No. of Events to process = %i\n"
210  ,InFile.Data(),NoEvents);
211  printf("Output root file name %s\n", FileOut.Data());
212  printf("==============================================\n");
213 #endif /* GTRACK */
214  // Dynamically link some shared libs
215  if (gClassTable->GetID("StChain") < 0) Load();
216 
217 #ifdef XDFOUT
218  if (!FileOut) {
219  St_XDFFile *xdf_out = 0;
220  TString *XdfFile = new TString(FileOut->Data());
221  XdfFile->ReplaceAll(".root","_dst.xdf");
222  xdf_out = new St_XDFFile(XdfFile->Data(),"wb");
223  printf ("Open xdf file = %s \n +++++++++++++++++++++++++++++++++++++++++++++++\n",XdfFile->Data());
224  }
225 #endif
226  // Create the main chain object
227  chain = new StChain("bfc");
228  chain->SetDebug();
229  // Create the makers to be called by the current chain
230  const char *mainDB = "$STAR/StDb/params";
231  St_db_Maker *dbMk = new St_db_Maker("db",mainDB);
232  dbMk->SetDebug();
233  St_db_Maker *dbMktpc = 0;
234 #ifdef CTEST
235  // TPC test Data Base
236  cout<<"creating DB for TPC test"<<endl;
237  const char *tpcDB = "/afs/rhic/star/tpc/ctest/StDb";
238  dbMktpc = new St_db_Maker("tpcdb",tpcDB);
239  dbMktpc->SetDebug();
240 #endif /* CTEST */
241 
242  const char *calibDB = "$STAR_ROOT/calib";
243  St_db_Maker *calibMk = new St_db_Maker("calib",calibDB);
244  calibMk->SetDebug();
245 #ifndef GEANT
246  St_xdfin_Maker *xdfMk = new St_xdfin_Maker("xdfin",InFile.Data());
247 #ifdef MINIDAQ
248  // defined for MINIDAQ
249  chain->SetInput("BEGIN_RUN",".make/xdfin/.const/BEGIN_RUN");
250  chain->SetInput("TPC_DATA",".make/xdfin/.data/TPC_DATA");
251 #else /* no MINIDAQ */
252  // fix for xdf files to get geant input
253 #endif /* MINIDAQ */
254 #else /* GEANT */
255  geant = new St_geant_Maker("geant");
256  geant->SetNwGEANT(10 000 000);
257  chain->SetInput("geant",".make/geant/.data");
258 #ifdef GTRACK
259  // geant->SetIwtype(1);
260  // geant->SetDebug();
261  geant->LoadGeometry("detp geometry YEAR_1B");
262  geant->Do("subevent 0;");
263  // gkine #particles partid ptrange yrange phirange vertexrange
264  geant->Do("gkine 10 6 1. 1. -1. 1. 0 6.28 0. 0.;");
265  geant->Do("mode g2tm prin 1;");
266  // geant->Do("next;");
267  // geant->Do("dcut cave z 1 10 10 0.03 0.03;");
268  // geant->Do("debug on;");
269  geant->Do("swit 2 3;");
270  // geant->LoadGeometry("detp geometry field_only field_off");
271 #else /* no GTRACK */
272  geant->SetInputFile(InFile.Data());
273 #endif /* GTRACK */
274 #endif /* GEANT */
275 
276 #ifdef MINIDAQ
277  StMagF *field = new StMagFC("field","STAR no field",0.00002);
278  StMinidaqMaker *tpc_raw = new StMinidaqMaker("tpc_raw");
279  if (dbMktpc) {
280  cout<<"initializing input for the tpc DB"<<endl;
281  tpc_raw->SetInput("params","tpcdb:StDb/params");
282  }
283 #endif
284 #ifdef FSS
285 // fss
286  St_fss_Maker *fssMk = new St_fss_Maker("ftpc_raw");
287  fssMk->SetDebug();
288 #endif
289 
290 #ifdef TRS
291 // trs
292  StTrsMaker *trs = new StTrsMaker;
293  if (dbMktpc) {
294  cout<<"initializing input for the trs DB"<<endl;
295  trs->SetInput("params","tpcdb:StDb/params");
296  }
297  St_tpcdaq_Maker *tpc_raw = new St_tpcdaq_Maker;
298 #else /* not TRS */
299 #ifdef TSS
300 // tss
301  St_tss_Maker *tssMk = new St_tss_Maker("tpc_raw");
302  if (dbMktpc) {
303  cout<<"initializing input for the tpc DB"<<endl;
304  tssMk->SetInput("params","tpcdb:StDb/params");
305  }
306  // tssMk->SetDebug();
307 #endif /* TSS */
308 #endif /* TRS */
309 
310 #ifdef EMC
311 // emc
312  St_ems_Maker *emsMk = new St_ems_Maker("emc_raw" );
313  emsMk->SetDebug();
314 #if 0
315  St_emc_Maker *emcMk = new St_emc_Maker("emc_hits");
316  emcMk->SetDebug();
317 #endif
318 #endif /* EMC */
319 
320 #ifdef TPC
321 // tcl
322  St_tcl_Maker *tclMk = new St_tcl_Maker("tpc_hits");
323  if (dbMktpc){
324  cout<<"initializing input for the tpc DB"<<endl;
325  tclMk->SetInput("params","tpcdb:StDb/params");
326  }
327  tclMk->SetDebug();
328 #ifdef tclPixTransOn
329  tclMk->tclPixTransOn();
330 #endif /* tclPixTransOn */
331 #ifndef MINIDAQ
332  //Turn on the hit finder evaluation
333  tclMk->tclEvalOn();
334 #endif /* MINIDAQ */
335 #endif /* TPC */
336 
337 #ifdef SVT
338 // svt
339  St_srs_Maker *srsMk = new St_srs_Maker("svt_hits");
340  srsMk->SetDebug();
341 #endif /* SVT */
342 
343 #ifdef FTPC
344 // fcl
345 
346  St_fcl_Maker *fclMk = new St_fcl_Maker("ftpc_hits");
347  fclMk->SetDebug();
348 #endif /* FTPC */
349 
350 #ifdef TPC
351 // tpt
352  St_tpt_Maker *tptMk = new St_tpt_Maker("tpc_tracks");
353 #ifdef tptResOn
354  // Turn on the residual table
355  tptMk->tptResOn();
356 #endif /* tptResOn */
357 #ifdef MINIDAQ
358  // Turn on the final ntuple.
359  tptMk->Set_final(kTRUE);
360 #else /* not MINIDAQ */
361  //Turn on the tpc evaluation
362  tptMk->tteEvalOn();
363 #endif /* MINIDAQ */
364  tptMk->SetDebug();
365 #endif /* TPC */
366 
367 #ifdef L3
368 // l3t
369  St_l3t_Maker *l3tMk = new St_l3t_Maker("l3Tracks");
370  l3tMk->SetDebug();
371 #endif /* L3 */
372 
373 #ifdef SVT
374 // stk
375  St_stk_Maker *stkMk = new St_stk_Maker("svt_tracks");
376  stkMk->SetDebug();
377 #endif /* SVT */
378 
379 #ifdef FTPC
380 // fpt
381  St_fpt_Maker *fptMk = new St_fpt_Maker("ftpc_tracks");
382  fptMk->SetDebug();
383 #endif /* FTPC */
384 #ifdef CTF
385  St_ctf_Maker *ctf = new St_ctf_Maker("ctf");
386  St_mwc_Maker *mwc = new St_mwc_Maker("mwc");
387  St_trg_Maker *trg = new St_trg_Maker("trg");
388 #endif
389 #ifdef L3
390  St_l3t_Maker *l3Tracks = new St_l3t_Maker("l3Tracks");
391 #endif
392 #ifdef GLOBAL
393 // global
394  St_dst_Maker *dstMk = 0;
395  St_glb_Maker *glbMk = new St_glb_Maker("global");
396  glbMk->SetDebug();
397 // dst
398  dstMk = new St_dst_Maker("dst");
399  dstMk->SetDebug();
400 #ifdef ANALYSIS
401  StAnalysisMaker *anaMk = new StAnalysisMaker;
402 #endif
403  St_QA_Maker *qa = new St_QA_Maker;
404 // Tree
405  if (dstMk) {
406  StTreeMaker *treeMk = new StTreeMaker("tree",FileOut.Data());
407  treeMk->SetIOMode("w");
408  treeMk->SetDebug();
409  treeMk->IntoBranch("dstBranch","dst/.data/dst");
410  // treeMk->IntoBranch("geantBranch","geant/.data");
411  // treeMk->SetInput("global","global");
412  //treeMk->SetInput(".default","Others");
413 
414  }
415 #endif /* GLOBAL */
416 
417  // START the chain (may the force be with you)
418  // Create HTML docs of all Maker's involved
419  // chain->MakeDoc();
420 
421  chain->PrintInfo();
422 
423  // Init the chain and all its makers
424  // chain->SetDebug(1);
425  int iInit = chain->Init();
426  if (iInit) chain->Fatal(iInit,"on init");
427 
428  Int_t i=0;
429  for (Int_t i =1; i <= NoEvents; i++){
430  chain->Clear();
431  if (chain->Make(i)>=kStEOF) break;
432  // gSystem->Exec("ps ux");
433  printf ("=========================================== Done with Event no. %d\n",i);
434  }
435 
436  if (NoEvents > 1) {
437  chain->Finish();
438  printf ("Run completed ");
439  gSystem->Exec("date");
440  }
441  else {b = new TBrowser("BFC chain",chain);}
442 }
443 
444 
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 Finish()
Definition: StChain.cxx:85
A typical Analysis Class.
virtual void Do(const Char_t *option="dcut cave x 0.1 10 10 0.03 0.03")
Executes a KUIP command.
Definition: Stypes.h:43
virtual Int_t Make()
Definition: StChain.cxx:110
Definition: StMagF.h:9
virtual void LoadGeometry(const Char_t *option="detp geometry field_only")
Specifies GEANT3 geometry command.