StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
bfcS.C
1 // //
3 // Macro for running chain with different inputs //
4 // owner: Yuri Fisyak //
5 // //
6 // $Id: bfcS.C,v 1.7 2006/08/15 21:42:29 jeromel Exp $
8 #ifndef __CINT__
9 #include "TSystem.h"
10 #include "TBrowser.h"
11 #include "TBenchmark.h"
12 #include "TClassTable.h"
13 #include "StBFChain.h"
14 #include "St_tcl_Maker/St_tcl_Maker.h"
15 #include "St_tpt_Maker/St_tpt_Maker.h"
16 #include "StEvent.h"
17 #include "St_geant_Maker/St_geant_Maker.h"
18 #include "StIOMaker/StIOMaker.h"
19 #include "StEventDisplayMaker/StEventDisplayMaker.h"
20 #include "StEventMaker/StEventMaker.h"
21 #include "StAssociationMaker/StMcParameterDB.h"
22 #include "St_dst_Maker/StV0Maker.h"
23 #include "xdf2root/St_XDFFile.h"
24 #include "StPass0CalibMaker/StTpcT0Maker.h"
25 void Usage();
26 void Load();
27 #else
28 class StMaker;
29 class StBFChain;
30 class StEvent;
31 class St_geant_Maker;
32 class StIOMaker;
33 class St_XDFFile;
34 class StEventDisplayMaker;
35 class StEventMaker;
36 class StTpcT0Maker;
37 #endif
38 TBrowser *b = 0;
39 StBFChain *chain=0;
40 StMaker *treeMk=0;
41 StEvent *Event;
42 St_geant_Maker *geant = 0;
43 StEventDisplayMaker *dsMk = 0;
44 StEventMaker *evMk = 0;
45 StTpcT0Maker *t0mk = 0;
46 //_____________________________________________________________________
47 void Load(){
48  if (gClassTable->GetID("TTable") < 0) gSystem->Load("libTable");
49  gSystem->Load("St_base");
50  gSystem->Load("StChain");
51  gSystem->Load("StUtilities");
52  gSystem->Load("StBFChain");
53  gSystem->Load("StChallenger");
54 }
55 //_____________________________________________________________________
56 void bfcS(const Int_t First,
57  const Int_t Last,
58  const Char_t *Chain="gstar Cy2b tfs -NoHits",
59  const Char_t *infile=0,
60  const Char_t *outfile=0,
61  const Char_t *TreeFile=0)
62 { // Chain variable define the chain configuration
63  // All symbols are significant (regardless of case)
64  // "-" sign before requiest means that this option is disallowed
65  // Chain = "gstar" run GEANT on flight with 10 muons in range |eta| < 1 amd pT = 1GeV/c (default)
66  // Chain = "" || "xdf" run STANDARD chain using xd-files as an input
67  // Chain = "minidaq" read miniDAQ xdf file and process
68  // Dynamically link some shared libs
69  if (gClassTable->GetID("StBFChain") < 0) Load();
70  if (chain) delete chain;
71  chain = new StBFChain; // Create the main chain object
72  if (!chain) gSystem->Exit(1);
73  chain->SetFlags(Chain);
74  if (TreeFile) chain->SetTFile(new TFile(TreeFile,"RECREATE"));
75  printf ("QAInfo:Process [First=%6i/Last=%6i/Total=%6i] Events\n",First,Last,Last-First+1);
76  chain->Set_IO_Files(infile,outfile);
77  if (chain->Load() > kStOk)
78  {printf("Error:Problems with loading of shared library(ies)\n"); gSystem->Exit(1);}
79  if (Last < -1) return;
80  if (chain->Instantiate() > kStOk)
81  {printf("Error:Problems with instantiation of Maker(s)\n"); gSystem->Exit(1);}
82  if (Last < 0) return;
83  if (chain->GetOption("DISPLAY")) dsMk = (StEventDisplayMaker *) chain->GetMaker("EventDisplay");
84 
85  // Insert your maker before "tpc_hits"
86  Char_t *myMaker = "StTpcHitFilterMaker";
87  if (gClassTable->GetID(myMaker) < 0) gSystem->Load(myMaker);
88  StMaker *myMk = chain->GetMaker(myMaker);
89  if (myMk) delete myMk;
90  // Insert your maker after "tpc_tracks"
91  myMk = chain->New(myMaker,"tpc_hit_filter");
92  if (myMk) {
93  Char_t *after = "tpc_tracks";
94  StMaker *tclmk = chain->GetMaker(after);
95  if (tclmk) chain->AddAfter(after,myMk);
96  }
97  StTpcHitFilterMaker* filter = (StTpcHitFilterMaker*)myMk;
98  filter->RidiculousErrorsInner();
99  filter->DoNotDeleteHits();
100 
101 #ifdef __CINT__
102  if (chain->GetOption("TCL") && chain->GetOption("Eval")) {
103  St_tcl_Maker *tclMk= (St_tcl_Maker *) chain->GetMaker("tpc_hits");
104  if (tclMk) {
105  tclMk->tclPixTransOn(); //Turn on flat adcxyz table
106  tclMk->tclEvalOn(); //Turn on the hit finder evaluation
107  }
108  }
109  if (chain->GetOption("TPT")) {
110  St_tpt_Maker *tptMk = (St_tpt_Maker *) chain->GetMaker("tpc_tracks");
111  if (tptMk && chain->GetOption("MINIDAQ")) tptMk->Set_final(kTRUE);// Turn on the final ntuple.
112  if (tptMk && chain->GetOption("Eval")) {
113  tptMk->tteEvalOn(); //Turn on the tpc evaluation
114  tptMk->tptResOn(); // Turn on the residual table
115  }
116  }
117  if (chain->GetOption("TpcT0")) {
118  StTpcT0Maker *t0mk = (StTpcT0Maker *) chain->GetMaker("TpcT0");
119  if (t0mk) t0mk->SetDesiredEntries(10);
120  }
121  if (chain->GetOption("McAss")) {
122  // Define the cuts for the Associations
123 
124  StMcParameterDB* parameterDB = StMcParameterDB::instance();
125  // TPC
126  parameterDB->setXCutTpc(.5); // 5 mm
127  parameterDB->setYCutTpc(.5); // 5 mm
128  parameterDB->setZCutTpc(.2); // 2 mm
129  parameterDB->setReqCommonHitsTpc(3); // Require 3 hits in common for tracks to be associated
130  // FTPC
131  parameterDB->setRCutFtpc(.3); // 3 mm
132  parameterDB->setPhiCutFtpc(5*(3.1415927/180.0)); // 5 degrees
133  parameterDB->setReqCommonHitsFtpc(3); // Require 3 hits in common for tracks to be associated
134  // SVT
135  parameterDB->setXCutSvt(.1); // 1 mm
136  parameterDB->setYCutSvt(.1); // 1 mm
137  parameterDB->setZCutSvt(.1); // 1 mm
138  parameterDB->setReqCommonHitsSvt(1); // Require 1 hits in common for tracks to be associated
139  }
140  if (chain->GetOption("V0") && chain->GetOption("Eval")) {
141  StV0Maker *v0Mk = (StV0Maker *) chain->GetMaker("v0");
142  if (v0Mk) v0Mk->ev0EvalOn(); //Turn on the ev0 evaluatio
143  }
144 #endif
145  {
146  TDatime t;
147  printf ("QAInfo:Run is started at Date/Time %i/%i\n",t.GetDate(),t.GetTime());
148  }
149  printf ("QAInfo:Run on %s in %s\n",
150  gSystem->HostName(),
151  gSystem->WorkingDirectory());
152  printf ("QAInfo: with %s\n", chain->GetCVS());
153 
154  // Init the chain and all its makers
155  Int_t iTotal = 0, iBad = 0;
156  St_XDFFile *xdf_out = 0;
157  TBenchmark evnt;
158  Int_t iMake = 0, i = First;
159  if (Last >= 0) {
160  Int_t iInit = chain->Init();
161  if (iInit >= kStEOF) {
162  chain->Fatal(iInit,"on init");
163  goto END;
164  }
165  StEvtHddr *hd = (StEvtHddr*)chain->GetDataSet("EvtHddr");
166  if (hd) hd->SetRunNumber(-2); // to be sure that InitRun calls at least once
167  // skip if any
168  if (First > 1) {
169  if (chain->GetOption("fzin")) {
170  geant = (St_geant_Maker *) chain->GetMaker("geant");
171  if (geant) {
172  if (geant->IsActive()) geant->Skip(First-1);
173  }
174  }
175  else {
176  StIOMaker *inpMk = (StIOMaker *) chain->GetMaker("inputStream");
177  if (inpMk) {printf ("Skip %i Events\n",First-1);inpMk->Skip(First-1);}
178  }
179  }
180  }
181  xdf_out = chain->GetXdfOut();
182  if (chain->GetOption("Event")) evMk = (StEventMaker *) chain->GetMaker("StEventMaker");
183  treeMk = chain->GetMaker("OutputStream");
184  EventLoop: if (i <= Last && iMake != kStEOF && iMake != kStFatal) {
185  evnt.Reset();
186  evnt.Start("QAInfo:");
187  chain->Clear();
188  iMake = chain->Make(i);
189  if (iMake <kStEOF) {
190  if (xdf_out){
191  St_DataSet *dstSet = chain->GetInputDS("dst");
192  if (dstSet) xdf_out->NextEventPut(dstSet); // xdf output
193  }
194  iTotal++;
195  if (treeMk && iMake == kStErr) {treeMk->Make(i); iBad++;}
196  // gSystem->Exec("ps ux");
197  evnt.Stop("QAInfo:");
198  // evnt.Show("QAInfo:");
199  printf ("QAInfo: Done with Event [no. %d/run %d/evt. %d/Date.Time %d.%d/sta %d] Real Time = %10.2f seconds Cpu Time = %10.2f seconds \n",
200  i,chain->GetRunNumber(),chain->GetEventNumber(),chain->GetDate(), chain->GetTime(),
201  iMake,evnt.GetRealTime("QAInfo:"),evnt.GetCpuTime("QAInfo:"));
202  }
203  i++; goto EventLoop;
204  }
205  END:
206  fflush(stdout);
207  printf ("QAInfo:Run completed ");
208  gSystem->Exec("date");
209  if (evMk) Event = (StEvent *) chain->GetInputDS("StEvent");
210  {
211  TDatime t;
212  printf ("\nQAInfo:Run is finished at Date/Time %i/%i; Total events processed :%i and not completed: %i\n",
213  t.GetDate(),t.GetTime(),iTotal,iBad);
214  }
215 }
216 //_____________________________________________________________________
217 void bfcS (const Int_t Last,
218  const Char_t *Chain="gstar Cy2b tfs evout -NoHits",
219  const Char_t *infile=0,
220  const Char_t *outfile=0,
221  const Char_t *TreeFile=0)
222 {
223  bfcS(1,Last,Chain,infile,outfile,TreeFile);
224 }
225 //_____________________________________________________________________
226 void bfcS (const Char_t *Chain="",
227  const Char_t *infile=0,
228  const Char_t *outfile=0,
229  const Char_t *TreeFile=0)
230 {
231  if (!Chain || !strlen(Chain)) {
232  Usage();
233  }
234 }
235 //____________________________________________________________
236 void Usage() {
237 #if 0
238  printf ("============= \tImportant two changes:\n"
239  " \tIt is required exact matching in Chain definition\n"
240  " \tAll Chain options set in supplyed order\n");
241 #endif
242  if (gClassTable->GetID("StBFChain") < 0) Load();
243  chain = new StBFChain;
244  chain->SetFlags("");
245  printf ("============= \t U S A G E =============\n");
246  printf ("bfc(Int_t First, Int_t Last, Char_t *Chain, Char_t *infile, Char_t *outfile,, Char_t *TreeFile)\n");
247  printf ("bfc(Int_t Last, Char_t *Chain, Char_t *infile, Char_t *outfile, Char_t *TreeFile)\n");
248  printf ("bfc(Char_t *Chain, Char_t *infile, Char_t *outfile)\n");
249  printf ("where\n");
250  printf (" First \t- First event to process \t(Default = 1)\n");
251  printf (" Last \t- Last event to process \t(Default = 1)\n");
252  printf (" Chain \t- Chain specification \t(without First & Last: Default is \"\" which gives this message)\n");
253  printf (" \t \t with First || Last: Default is \"gstar tfs\")\n");
254  printf (" infile \t- Name of Input file \t(Default = 0, i.e. use preset file names depending on Chain)\n");
255  printf (" outfile \t- Name of Output file \t(Default = 0, i.e. define Output file name from Input one)\n");
256  printf ("Examples:\n");
257  printf (" root4star bfc.C \t// Create this message\n");
258  printf (" root4star 'bfc.C(1)' \t// Run one event with default Chain=\"gstar tfs\"\n");
259  printf (" root4star 'bfc.C(1,1)' \t// the same\n");
260  printf ("\n root4star 'bfc.C(1,\"off tdaq tpc HalfField global dst display\",\"/star/rcf/daq/1999/12/st_cluster2_0351027_raw_0001.daq\")'\n");
261  printf (" \t// create a DST by processing a DAQ data from <st_cluster2_0351027_raw_0001.daq>\n\n");
262  printf (" root4star 'bfc.C(2,40,\"Cy1b fzin\")'\t// run for configuration year_1b, \n");
263  printf (" \t// reading /star/rcf/disk1/star/test/psc0050_01_40evts.fzd\n");
264  printf (" \t// skipping the 1-st event and processing the remaining 39 events\n");
265  printf (" root4star 'bfc.C(40,\"Cy1b fzin\",\"/star/rcf/disk1/star/test/psc0050_01_40evts.fzd\")'\n");
266  printf (" root4star 'bfc.C(40,\"Cy1b fzin\")'\t// the same as above\n");
267  printf (" root4star 'bfc.C(2,40,\"Cy1b fzin -l3t\")'//the as above but remove L3T from chain\n");
268  printf (" root4star 'bfc.C(40,\"Cy2a fzin\",\"/star/rcf/disk0/star/test/venus412/b0_3/year_2a/psc0208_01_40evts.fz\")'\n");
269  printf (" root4star 'bfc.C(40,\"Cy2a fzin\")'\t// the same as above\n");
270  printf (" root4star 'bfc.C(5,10,\"Cy1b in xout\",\"/afs/rhic.bnl.gov/star/tpc/data/tpc_s18e_981105_03h_cos_t22_f1.xdf\")'\n");
271  printf (" \t// skipping the 4 events and processing the remaining 6 events\n");
272  printf (" root4star 'bfc.C(1,\"off in tpc FieldOff sd97 eval\",\"Mini_Daq.xdf\")'\t// the same as Chain=\"minidaq\"\n");
273  printf (" root4star 'bfc.C(1,\"gstar Cy1a tfs allevent\")' \t// run gstar and write all event into file branches\n");
274  printf (" root4star 'bfc.C(1,\"off in Cy1a l3t\",\"gtrack.tpc_hits.root\")'\t// run l3t only with prepaired file\n");
275  printf (" root4star 'bfc.C(1,\"tdaq display\",\"/star/rcf/disk1/star/daq/990727.3002.01.daq\")' \n");
276  printf (" \t//Cosmics (56) events with full magnetic field, TPC only \n");
277  printf (" root4star 'bfc.C(1,\"tdaq FieldOn\",\"/star/rcf/disk1/star/daq/990624.306.daq\")' \n");
278  printf (" \t//Cosmics (56) events with full magnetic field \n");
279  printf (" root4star 'bfc.C(1,\"tdaq HalfField\",\"/star/rcf/disk1/star/daq/990630.602.daq\")' \n");
280  printf (" \t//Laser (10) events with half magnetic field \n");
281  printf (" root4star 'bfc.C(1,\"tdaq FieldOff\",\"/star/rcf/disk1/star/daq/990701.614.daq\")' \n");
282  printf (" \t//Laser (12) events with no magnetic field \n");
283  gSystem->Exit(1);
284 }
virtual Int_t Instantiate()
Maker-instantiation handler.
Definition: StBFChain.cxx:214
virtual void Clear(Option_t *option="")
User defined functions.
Definition: StChain.cxx:77
void SetFlags(const Char_t *Chain="gstar tfs")
Scan all flags, check if they are correct, manipulate the comment if necessary.
Definition: StBFChain.cxx:1512
virtual Int_t Make()
Definition: StMaker.cxx:898
Definition: Stypes.h:43
virtual Int_t GetRunNumber() const
Returns the current RunNumber.
Definition: StMaker.cxx:1054
Definition: AgUStep.h:26
virtual Int_t Load()
Routine handling library loading depending on chain options.
Definition: StBFChain.cxx:117
Definition: Stypes.h:44
Definition: Stypes.h:41