StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
bfcZ.C
1 // //
3 // Macro for running chain with different inputs //
4 // owner: Yuri Fisyak //
5 // //
6 // $Id: bfcZ.C,v 1.1 2001/03/24 03:08:58 fisyak Exp $
8 #ifndef __CINT__
9 #include "iostream.h"
10 #include "TROOT.h"
11 #include "TSystem.h"
12 #include "TH2.h"
13 #include "TH3.h"
14 #include "TF1.h"
15 #include "TProfile.h"
16 #include "TTree.h"
17 #include "TChain.h"
18 #include "TCanvas.h"
19 #include "TClassTable.h"
20 #include "TFileSet.h"
21 #include "TDataSetIter.h"
22 #include "StBFChain.h"
23 #include "StIOMaker.h"
24 void bfc (const Int_t Last,
25  const Char_t *Chain,
26  const Char_t *infile,
27  const Char_t *outfile,
28  const Char_t *TreeFile);
29 //R__EXTERN StBFChain *chain;
30 #else
31 class StBFChain;
32 class TTree;
33 StBFChain *chain;
34 class StFlowSelection;
35 class StIOMaker;
36 #endif
37 //_____________________________________________________________________
38 void bfcZ(const Int_t First,
39  const Int_t Last,
40  const Char_t *Chain="gstar Cy2b tfs -NoHits TpcHitFilter",
41  const Char_t *infile=0,
42  const Double_t zmin=-200, const Double_t zmax=-100,
43  const Char_t *outfile=0,
44  const Char_t *TreeFile=0){
45  gROOT->LoadMacro("bfc.C");
46  bfc(-1,Chain,infile,outfile,TreeFile);
47  if (chain->GetOption("TpcHitFilter")) {
48  StTpcHitFilterMaker *filtMk = (StTpcHitFilterMaker *) chain->GetMaker("tpc_hit_filter");
49  if (filtMk) {
50  // St_tcl_Maker *tclMk= (St_tcl_Maker *) chain->GetMaker("tpc_hits");
51  if (zmin < 0 && zmax < 0) filtMk->WestOff();
52  if (zmin > 0 && zmax > 0) filtMk->EastOff();
53  filtMk->SetZrange(zmin,zmax);
54  }
55  }
56  {
57  TDatime t;
58  printf ("QAInfo:Run is started at Date/Time %i/%i\n",t.GetDate(),t.GetTime());
59  printf ("QAInfo:Run on %s in %s\n",
60  gSystem->HostName(),
61  gSystem->WorkingDirectory());
62  printf ("QAInfo: with %s\n", chain->GetCVS());
63  }
64  // Init the chain and all its makers
65  Int_t iTotal = 0, iBad = 0;
66  St_XDFFile *xdf_out = 0;
67  TBenchmark evnt;
68  Int_t iMake = 0, i = First;
69  if (Last >= 0) {
70  Int_t iInit = chain->Init();
71  if (iInit >= kStEOF) {
72  chain->Fatal(iInit,"on init");
73  goto END;
74  }
75  StEvtHddr *hd = (StEvtHddr*)chain->GetDataSet("EvtHddr");
76  if (hd) hd->SetRunNumber(-2); // to be sure that InitRun calls at least once
77  // skip if any
78  if (First > 1) {
79  if (chain->GetOption("fzin")) {
80  geant = (St_geant_Maker *) chain->GetMaker("geant");
81  if (geant) {
82  if (geant->IsActive()) geant->Skip(First-1);
83  }
84  }
85  else {
86  StIOMaker *inpMk = (StIOMaker *) chain->GetMaker("inputStream");
87  if (inpMk) {printf ("Skip %i Events\n",First-1);inpMk->Skip(First-1);}
88  }
89  }
90  }
91  xdf_out = chain->GetXdfOut();
92  if (chain->GetOption("Event")) evMk = (StEventMaker *) chain->GetMaker("StEventMaker");
93  treeMk = chain->GetMaker("OutputStream");
94  EventLoop: if (i <= Last && iMake != kStEOF && iMake != kStFatal) {
95  evnt.Reset();
96  evnt.Start("QAInfo:");
97  chain->Clear();
98  iMake = chain->Make(i);
99  if (iMake <kStEOF) {
100  if (xdf_out){
101  St_DataSet *dstSet = chain->GetInputDS("dst");
102  if (dstSet) xdf_out->NextEventPut(dstSet); // xdf output
103  }
104  iTotal++;
105  if (treeMk && iMake == kStErr) {treeMk->Make(i); iBad++;}
106  // gSystem->Exec("ps ux");
107  evnt.Stop("QAInfo:");
108  // evnt.Show("QAInfo:");
109  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",
110  i,chain->GetRunNumber(),chain->GetEventNumber(),chain->GetDate(), chain->GetTime(),
111  iMake,evnt.GetRealTime("QAInfo:"),evnt.GetCpuTime("QAInfo:"));
112  }
113  i++; goto EventLoop;
114  }
115  END:
116  fflush(stdout);
117  printf ("QAInfo:Run completed ");
118  gSystem->Exec("date");
119  if (evMk) Event = (StEvent *) chain->GetInputDS("StEvent");
120  {
121  TDatime t;
122  printf ("\nQAInfo:Run is finished at Date/Time %i/%i; Total events processed :%i and not completed: %i\n",
123  t.GetDate(),t.GetTime(),iTotal,iBad);
124  }
125 }
126 //_____________________________________________________________________
127 void bfcZ (const Int_t Last,
128  const Char_t *Chain="gstar Cy2b tfs evout TpcHitFilter -NoHits",
129  const Char_t *infile=0,
130  const Double_t zmin=-200, const Double_t zmax=-100,
131  const Char_t *outfile=0,
132  const Char_t *TreeFile=0)
133 {
134  bfcZ(1,Last,Chain,infile,zmin,zmax,outfile,TreeFile);
135 }
136 
virtual TDataSet * First() const
Return the first object in the list. Returns 0 when list is empty.
Definition: TDataSet.cxx:403
virtual TDataSet * Last() const
Return the last object in the list. Returns 0 when list is empty.
Definition: TDataSet.cxx:437
virtual void Clear(Option_t *option="")
User defined functions.
Definition: StChain.cxx:77
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
Definition: Stypes.h:44