StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
bfcMixer_v4.C
1 //
3 // Macro for running chain with different inputs
4 //
5 // Owner: Yuri Fisyak
6 //
7 // $Id: bfcMixer_v4.C,v 1.12 2013/04/28 14:41:31 fisyak Exp $
8 //
10 
11 //TBrowser *b = 0;
12 class StChain;
13 class StBFChain;
14 StChain *chain=0;
15 class StMaker;
16 StMaker *treeMk=0;
17 StBFChain *chain1, *chain2, *chain3;
18 class StEvent;
19 StEvent *Event;
20 class St_geant_Maker;
21 class StIOMaker;
22 class StEventDisplayMaker; StEventDisplayMaker *dsMk = 0;
23 class StEventMaker; StEventMaker *evMk = 0;
24 //class StFtpcMixerMaker;
25 class StEvtHddr;
26 //_____________________________________________________________________
27 void Load(){
28  gSystem->Load("St_base");
29  gSystem->Load("StChain");
30  gSystem->Load("StUtilities");
31  gSystem->Load("StBFChain");
32  //Extra things to load for the acceptance filter
33  gSystem->Load("StarClassLibrary");
34  gSystem->Load("StAnalysisUtilities");
35  gSystem->Load("StV0AccMaker.so");
36 
37  if (chain) delete chain;
38 }
39 //_____________________________________________________________________
40 void bfcMixer_v4(const Int_t Nevents=10,
41  const Char_t *file1="/auto/pdsfdv08/starprod/daq/2004/production62GeV/ReversedFullField/st_physics_adc_5090009_raw_2060002.daq",
42  const Char_t *file2="/home/starofl/embedding/GSTAR/gtest.fz",
43  const Char_t *file3="/home/starofl/embedding/GSTAR/st_physics_2270008_raw_0030.vertices.dat",
44  const Float_t zvertex_low=-175.0,
45  const Float_t zvertex_high=175.0,
46  const Char_t *mode="strange",
47  const Char_t *acc_mode="off" )
48 {
49  // Dynamically link some shared libs
50  if (gClassTable->GetID("StBFChain") < 0) Load();
51 
52  // Create the main chain object
53  chain = new StChain("Embedding");
54 
55  StMaker *saveMk = 0;
56 
57  // Create chain1 object
58  chain1 = new StBFChain("One");
59  saveMk = chain1->cd();
60  // chain1->SetFlags("in NoDefault");
61  // chain1->SetFlags("in alltrigger NoDefault");
62  // chain1->SetFlags("in Physics DbV20020226 NoDefault");
63  chain1->SetFlags("in Physics DbV20050515 NoDefault");
64  chain1->Set_IO_Files(file1);
65  chain1->Load();
66  chain1->Instantiate();
67 
68  saveMk->cd();
69 
70  // Create chain2 object
71  chain2 = new StBFChain("Two");
72  saveMk = chain2->cd();
73  // chain2->SetFlags("fzin DbV20020226 gen_T geomT sim_T tpc trs -tcl -tpt -PreVtx -tpc_daq"); //
74  chain2->SetFlags("fzin DbV20050515 gen_T geomT sim_T tpc trs -tcl -tpt -PreVtx -tpc_daq"); //
75  chain2->Set_IO_Files(file2);
76  chain2->Load();
77  chain2->Instantiate();
78  St_geant_Maker *geantMk = chain2->GetMaker("geant");
79  if (geantMk) geantMk->SetMode(1); // Mixer mode - do not modify EvtHddr
80 
81  if (chain2->GetOption("TRS")){
82  StTrsMaker *trsMk = (StTrsMaker *) chain2->GetMaker("Trs");
83  trsMk->setNormalFactor(1.22);
84  }
85 
86  // Add the acceptance filter maker before TRS
87  if (!strcmp(mode,"strange")){
88  if (!strcmp(acc_mode,"on")){
89 
90  Char_t *extraMaker = "StV0AccMaker";
91  if (gClassTable->GetID(extraMaker) < 0) gSystem->Load(extraMaker);
92  StMaker *extraMk = (StMaker *)chain1->GetMaker(extraMaker);
93  if(extraMk) delete extraMk;
94  extraMk = chain->New(extraMaker,"before");
95  if (extraMk) {
96  Char_t *before = "Trs";
97  StMaker *trsmk = chain1->GetMaker(before);
98  if (trsmk) chain1->AddBefore(before,extraMk);
99  StV0AccCuts *cuts = ((StV0AccMaker *)extraMk)->GetCutsPtr();
100  cuts->SetFilter();
101  cuts->SetV0MinDecayLen(0.);
102  cuts->SetV0DaughterMinImpact(0);
103  cuts->SetV0DaughterMinHit(10.);
104  cuts->SetXiV0MaxImpact(5);
105  cuts->SetXiMinDecayLen(2.);
106  cuts->SetXiV0PiMinImpact(0.);
107  cuts->SetXiDaughterMinHit(10.);
108  cuts->SetKinkMinDecayRad(128.);
109  cuts->SetKinkMaxDecayRad(184.);
110  }
111  }
112  }
113  // end additional maker code
114 
115  saveMk->cd();
116  // gSystem->Load("StFtpcMixerMaker");
117  // StFtpcMixerMaker *ftpcmixer = new StFtpcMixerMaker("FtpcMixer","daq","trs");
118 
119  // Create chain3 object
120  chain3 = new StBFChain("Three");
121  saveMk = chain3->cd();
122 
123  // use Simu NoDefault NoInput onlraw -onlcl and standard chain options
124  // then take apart e.g. P2004/B2004 and remove corrections as well as
125  // in, physics, analyis and Event QA from Cdst, tags, SCEbyE
126  // also don't use hitfilt
127  // took out svtdEdx, emcDY2 too
128 
129  // chain3->SetFlags("Simu NoDefault NoInput onlraw -onlcl DbV20050515 ry2005b tpc_daq tpc svt_daq SvtD event Kalman Tree evout useCDV SCEbyE tofdat EST xiSvt pmdRaw Xi2 V02 Kink2 CMuDst");
130 
131  chain3->SetFlags("TpcMixer Simu NoDefault NoInput onlraw -onlcl DbV20050515 ry2005b tpc_daq tpc emcDY2 global dst Kalman event evout QA Tree GeantOut fcf ctf -Prevtx -nohits CMuDST ZDCvtx tofDat Xi2 Kink2 EST ToF svt_daq SvtD svtdEdx xiSvt l3onl fpd eemcD pmdRaw EmbeddingShortCut");
132 
133  // StRTSClientFCF *fcfMk = (StRTSClientFCF *) chain3->GetMaker("");
134  // fcfMk->SetMode("0x1");
135 
136 
137  TString OutputFileName(gSystem->BaseName(file1));
138  OutputFileName.ReplaceAll("*","");
139  OutputFileName.ReplaceAll(".daq","");
140  OutputFileName.Append(".root");
141  chain3->Set_IO_Files(0,OutputFileName.Data());
142  chain3->Load();
143  chain3->Instantiate();
144  St_geant_Maker *geantMk = (St_geant_Maker *) chain->GetMaker("geant");
145  geantMk->SetActive(kTRUE);
146  // StMaker *ftpccluMk = chain3->GetMaker("ftpc_hits");
147  // ftpccluMk->SetInput("ftpc_raw","FtpcMixer");
148 
149  saveMk->cd();
150  {
151  TDatime t;
152  printf ("QAInfo:Run is started at Date/Time%i/%i\n",t.GetDate(),t.GetTime());
153  }
154  printf ("QAInfo:Run on %s in %s\n",
155  gSystem->HostName(),
156  gSystem->WorkingDirectory());
157  printf ("QAInfo: with %s\n", chain->GetCVS());
158 
159  // Init the chain and all its makers
160  if (Nevents >= 0) {
161  Int_t iInit = chain->Init();
162  }
163  // chain->SetDEBUG();
164  treeMk = chain->GetMaker("tree");
165  TBenchmark evnt;
166  Int_t iMake = 0, i = 1, iBad = 0;
167 
168  StIOMaker *inpMk = (StIOMaker *)chain1->GetMaker("inputStream");
169  FILE *fp = fopen(file3,"r");
170  Float_t x, y, z;
171  Int_t ncols, eventnumber, mult, skip=0, oldskip = 0, skiptest=0;
172  printf("zvertex_low = %f zvertex_high = %f\n",zvertex_low, zvertex_high);
173 
174  // vtxMk = (StVertexMaker*) chain3->GetMaker("vertex");
175 
176 EventLoop: if (i <= Nevents && iMake != kStEOF && iMake != kStFatal) {
177  evnt.Reset();
178  evnt.Start("QAInfo:");
179  printf ("ELH3\n");
180  chain->Clear();
181  printf ("ELH4\n");
182 
183  ncols = fscanf(fp,"%d %d %d %f %f %f",&eventnumber,&skip,&mult,&x,&y,&z);
184  if(ncols<0) break;
185 
186  printf("\nEvent number: %d Multiplicity = %d\n",eventnumber,mult);
187  printf("vertex in bfcMixer: %16f %16f %16f\n",x,y,z);
188 
189  // skip events in chain1 (daq file) only.
190  // fz file does not have these events.
191  // strange initialization due to details of inpMk->Skip
192  // ...not well understood. elh
193 
194  printf ("bfcMixer: i = %i\n",i);
195  printf ("bfcMixer: skip = %i\n",skip);
196  printf ("bfcMixer: oldskip = %i\n",oldskip);
197  if (inpMk && skip>0) {
198  if(i == 1) {skip++;}
199  skiptest = inpMk->Skip(skip-oldskip-1);
200  printf("bfcMixer: skiptest1 = %i\n",skiptest);
201  skiptest = inpMk->Skip();
202  printf("bfcMixer: skiptest2 = %i\n",skiptest);
203  if(i == 1) {skip--;}
204  }
205  oldskip = skip;
206 
207  use this to force the vertex position to match:
208  // vtxMk->FixVertex(x,y,z);
209 
210  iMake = chain->Make(i);
211  if (treeMk && iMake == kStErr) {treeMk->Make(i); iBad++;}
212  StEvtHddr *fEvtHddr = (StEvtHddr*)chain->GetDataSet("EvtHddr");
213  StEvtHddr *fEvtHddrDaq = (StEvtHddr*)chain1->GetDataSet("EvtHddr");
214  *fEvtHddr = *fEvtHddrDaq;
215  // gSystem->Exec("ps ux");
216  evnt.Stop("QAInfo:");
217  // evnt->Show("QAInfo:");
218  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", i,chain->GetRunNumber(),chain->GetEventNumber(),chain->GetDate(), chain->GetTime(),
219  iMake,evnt.GetRealTime("QAInfo:"),evnt.GetCpuTime("QAInfo:"));
220 
221 
222  // Be sure to get the same event from daq and fz files... elh
223  if(eventnumber == chain->GetEventNumber()){
224  printf("bfcMixer: Event number %d found in both .fz file and .daq file\n",eventnumber);
225  }else{
226  printf("bfcMixer: Error! Event number from .fz file: %d\n",eventnumber);
227  printf("bfcMixer: Error! Event number from .daq file: %d\n",chain->GetEventNumber());
228  printf("bfcMixer: Error! Events are out-of-sync, exiting!\n");
229  break;
230  }
231  i++;
232  goto EventLoop;
233  }
234 
235  fflush(stdout);
236  printf ("QAInfo:Run completed ");
237  gSystem->Exec("date");
238  if (evMk) Event = (StEvent *) chain->GetInputDS("StEvent");
239  {
240  TDatime t;
241  printf ("\nQAInfo:Run is finished at Date/Time%i/%i\n",t.GetDate(),t.GetTime());
242  }
243 }
244 
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 Make()
Definition: StChain.cxx:110
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
virtual void SetActive(Bool_t k=kTRUE)
Setters for flags and switches.
Definition: StMaker.h:208
Definition: Stypes.h:44