StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
bfcMixer_v4_noFTPC.C
1 //
3 // Macro for running chain with different inputs
4 //
5 // Owner: Yuri Fisyak
6 //
7 // $Id: bfcMixer_v4_noFTPC.C,v 1.2 2006/08/23 22:30:06 fisyak Exp $
8 //
10 
11 //TBrowser *b = 0;
12 class StBFChain;
13 StBFChain *chain=0;
14 class StMaker;
15 StMaker *treeMk=0;
16 StBFChain *chain1, *chain2, *chain3;
17 class StEvent;
18 StEvent *Event;
19 class St_geant_Maker;
20 class StIOMaker;
21 class StEventDisplayMaker; StEventDisplayMaker *dsMk = 0;
22 class StEventMaker; StEventMaker *evMk = 0;
23 class StMixerMaker;
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_noFTPC(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 *file1="/star/data03/daq/2004/090/st_physics_adc_5090009_raw_2060002.daq",
43  // const Char_t *file2="/home/starofl/embedding/GSTAR/gtest.fz",
44  const Char_t *file2="./gtest.fz",
45  // const Char_t *file3="/home/starofl/embedding/GSTAR/st_physics_2270008_raw_0030.vertices.dat",
46  // const Char_t *file3="/home/starofl/embedding/GSTAR/st_physics_2270008_raw_0030.vertices.dat",
47  const Char_t *file3="./st_physics_adc_5090009_raw_2060002.vertices.dat",
48  const Float_t zvertex_low=-175.0,
49  const Float_t zvertex_high=175.0,
50  const Char_t *mode="strange",
51  const Char_t *acc_mode="off" )
52 {
53  // Dynamically link some shared libs
54  if (gClassTable->GetID("StBFChain") < 0) Load();
55 
56  // Create the main chain object
57  chain = new StBFChain("Embedding");
58 
59  StMaker *saveMk = 0;
60  chain->SetFlags("-ittf,NoDefault");
61  // Create chain1 object
62  chain1 = new StBFChain("One");
63 
64  saveMk = chain1->cd();
65  // chain1->SetFlags("in NoDefault");
66  // chain1->SetFlags("in alltrigger NoDefault");
67  // chain1->SetFlags("in Physics DbV20020226 NoDefault");
68  chain1->SetFlags("in Physics DbV20060421 NoDefault -ittf");
69  chain1->Set_IO_Files(file1);
70  chain1->Load();
71  chain1->Instantiate();
72 
73  saveMk->cd();
74 
75  // Create chain2 object
76  chain2 = new StBFChain("Two");
77  saveMk = chain2->cd();
78  // chain2->SetFlags("fzin DbV20020226 gen_T geomT sim_T tpc trs -tcl -tpt -PreVtx -tpc_daq"); //
79  chain2->SetFlags("fzin DbV20060421 gen_T geomT sim_T tpc trs -tcl -tpt -PreVtx -tpc_daq -ittf"); //
80  chain2->Set_IO_Files(file2);
81  chain2->Load();
82  chain2->Instantiate();
83  St_geant_Maker *geantMk = chain2->GetMaker("geant");
84  if (geantMk) geantMk->SetMode(1); // Mixer mode - do not modify EvtHddr
85 
86  if (chain2->GetOption("TRS")){
87  StTrsMaker *trsMk = (StTrsMaker *) chain2->GetMaker("Trs");
88  trsMk->setNormalFactor(1.15);
89  }
90 
91  // Add the acceptance filter maker before TRS
92  if (!strcmp(mode,"strange")){
93  if (!strcmp(acc_mode,"on")){
94 
95  Char_t *extraMaker = "StV0AccMaker";
96  if (gClassTable->GetID(extraMaker) < 0) gSystem->Load(extraMaker);
97  StMaker *extraMk = (StMaker *)chain1->GetMaker(extraMaker);
98  if(extraMk) delete extraMk;
99  extraMk = chain->New(extraMaker,"before");
100  if (extraMk) {
101  Char_t *before = "Trs";
102  StMaker *trsmk = chain1->GetMaker(before);
103  if (trsmk) chain1->AddBefore(before,extraMk);
104  StV0AccCuts *cuts = ((StV0AccMaker *)extraMk)->GetCutsPtr();
105  cuts->SetFilter();
106  cuts->SetV0MinDecayLen(0.);
107  cuts->SetV0DaughterMinImpact(0);
108  cuts->SetV0DaughterMinHit(10.);
109  cuts->SetXiV0MaxImpact(5);
110  cuts->SetXiMinDecayLen(2.);
111  cuts->SetXiV0PiMinImpact(0.);
112  cuts->SetXiDaughterMinHit(10.);
113  cuts->SetKinkMinDecayRad(128.);
114  cuts->SetKinkMaxDecayRad(184.);
115  }
116  }
117  }
118  // end additional maker code
119 
120  saveMk->cd();
121 
122  // Mixer
123  gSystem->Load("StMixerMaker");
124  StMixerMaker *mixer = new StMixerMaker("Mixer","daq","trs");
125  chain1->SetInput("Input1","StDAQReader");
126  chain2->SetInput("Input2","Event");
127  mixer->writeFile("mixer.trs",Nevents);
128 
129  // gSystem->Load("StFtpcMixerMaker");
130  // StFtpcMixerMaker *ftpcmixer = new StFtpcMixerMaker("FtpcMixer","daq","trs");
131 
132  // Create chain3 object
133  chain3 = new StBFChain("Three");
134  saveMk = chain3->cd();
135 
136  // Base CuCu chain, fails. ELH: standard P06ib cucu options:
137  //chain3->SetFlags("Simu NoDefault NoInput onlraw -onlcl P2005 DbV20060421 useCDV ITTF tofDat -SvtIT SCEbyE OGridLeak OShortR OSpaceZ2");
138 
139 // use Simu NoDefault NoInput onlraw -onlcl and standard chain options
140 // expand P2005, get rid of corrections and ftpc:
141 //chain3->SetFlags("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");
142 // chain3->SetFlags("Simu NoDefault NoInput onlraw -onlcl B2005 l3onl fcf emcDY2 fpd trgd ZDCvtx DbV20060421 useCDV ITTF tofDat -SvtIT SCEbyE");
143 
144  chain3->SetFlags("Simu NoDefault NoInput onlraw -onlcl ry2005b,tpc_daq,tpcI,svt_daq,SvtD,Physics,Idst,l0,tags,Tree,evout l3onl fcf emcDY2 fpd trgd ZDCvtx DbV20060421 useCDV ITTF tofDat -SvtIT MuDST -trg VFMinuit");
145  // chain3->SetFlags("Simu NoDefault NoInput onlraw -onlcl ry2005b,tpc_daq,tpcI,svt_daq,SvtD,Physics,Idst,l0,Tree,evout l3onl fcf emcDY2 fpd trgd ZDCvtx DbV20060421 useCDV ITTF tofDat -SvtIT MuDST -trg VFMinuit");
146 
147 
148 
149  // StRTSClientFCF *fcfMk = (StRTSClientFCF *) chain3->GetMaker("");
150  // fcfMk->SetMode("0x1");
151 
152 
153  TString OutputFileName(gSystem->BaseName(file1));
154  OutputFileName.ReplaceAll("*","");
155  OutputFileName.ReplaceAll(".daq","");
156  OutputFileName.Append(".root");
157  cout <<"AAR - Setting file output to: " <<OutputFileName.Data()<<endl;
158 
159  chain3->Set_IO_Files(0,OutputFileName.Data());
160  chain3->Load();
161  chain3->Instantiate();
162  St_geant_Maker *geantMk = (St_geant_Maker *) chain->GetMaker("geant");
163  geantMk->SetActive(kTRUE);
164  StMaker *tpcdaqMk = chain3->GetMaker("tpc_raw");
165  if(!tpcdaqMk )
166  {
167  cout <<" Error: no tpc daq maker. End. "<<endl;
168  return;
169  }
170  tpcdaqMk->SetMode(1); // Trs
171  tpcdaqMk->SetInput("Event","MixerEvent");
172 
173  // StMaker *ftpccluMk = chain3->GetMaker("ftpc_hits");
174  // ftpccluMk->SetInput("ftpc_raw","FtpcMixer");
175  cout <<"AAR - going to file"<<endl;
176 
177  saveMk->cd();
178  {
179  TDatime t;
180  printf ("QAInfo:Run is started at Date/Time%i/%i\n",t.GetDate(),t.GetTime());
181  }
182  printf ("QAInfo:Run on %s in %s\n",
183  gSystem->HostName(),
184  gSystem->WorkingDirectory());
185  printf ("QAInfo: with %s\n", chain->GetCVS());
186 
187  // Init the chain and all its makers
188  cout <<"AAR - initializing the chain"<<endl;
189 
190  chain->SetDEBUG(0);
191  if (Nevents >= 0) {
192  cout << "AAR - in init if"<<endl;
193  Int_t iInit = chain->Init();
194  cout <<"AAR - init value"<<iInit<<endl;
195  }
196 
197  cout <<"AAR - Getting Tree"<<endl;
198  // chain->SetDEBUG();
199  treeMk = chain->GetMaker("tree");
200  TBenchmark evnt;
201  Int_t iMake = 0, i = 1, iBad = 0;
202 
203  cout <<"AAR - Setting IOMaker"<<endl;
204 
205  StIOMaker *inpMk = (StIOMaker *)chain1->GetMaker("inputStream");
206  FILE *fp = fopen(file3,"r");
207  Float_t x, y, z;
208  Int_t ncols, eventnumber, mult, skip=0, oldskip = 0, skiptest=0;
209  printf("zvertex_low = %f zvertex_high = %f\n",zvertex_low, zvertex_high);
210 
211  // vtxMk = (StVertexMaker*) chain3->GetMaker("vertex");
212 
213 
214  cout <<"AAR - Entering Event Loop"<<endl;
215 EventLoop: if (i <= Nevents && iMake != kStEOF && iMake != kStFatal) {
216  evnt.Reset();
217  evnt.Start("QAInfo:");
218  printf ("ELH3\n");
219  chain->Clear();
220  printf ("ELH4\n");
221 
222  ncols = fscanf(fp,"%d %d %d %f %f %f",&eventnumber,&skip,&mult,&x,&y,&z);
223  if(ncols<0) break;
224 
225  printf("\nEvent number: %d Multiplicity = %d\n",eventnumber,mult);
226  printf("vertex in bfcMixer: %16f %16f %16f\n",x,y,z);
227 
228  // skip events in chain1 (daq file) only.
229  // fz file does not have these events.
230  // strange initialization due to details of inpMk->Skip
231  // ...not well understood. elh
232 
233  printf ("bfcMixer: i = %i\n",i);
234  printf ("bfcMixer: skip = %i\n",skip);
235  printf ("bfcMixer: oldskip = %i\n",oldskip);
236  if (inpMk && skip>0) {
237  if(i == 1) {skip++;}
238  skiptest = inpMk->Skip(skip-oldskip-1);
239  printf("bfcMixer: skiptest1 = %i\n",skiptest);
240  skiptest = inpMk->Skip();
241  printf("bfcMixer: skiptest2 = %i\n",skiptest);
242  if(i == 1) {skip--;}
243  }
244  oldskip = skip;
245 
246  use this to force the vertex position to match:
247  // vtxMk->FixVertex(x,y,z);
248 
249  iMake = chain->Make(i);
250  if (treeMk && iMake == kStErr) {treeMk->Make(i); iBad++;}
251  StEvtHddr *fEvtHddr = (StEvtHddr*)chain->GetDataSet("EvtHddr");
252  StEvtHddr *fEvtHddrDaq = (StEvtHddr*)chain1->GetDataSet("EvtHddr");
253  *fEvtHddr = *fEvtHddrDaq;
254  // gSystem->Exec("ps ux");
255  evnt.Stop("QAInfo:");
256  // evnt->Show("QAInfo:");
257  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(),
258  iMake,evnt.GetRealTime("QAInfo:"),evnt.GetCpuTime("QAInfo:"));
259 
260 
261  // Be sure to get the same event from daq and fz files... elh
262  if(eventnumber == chain->GetEventNumber()){
263  printf("bfcMixer: Event number %d found in both .fz file and .daq file\n",eventnumber);
264  }else{
265  printf("bfcMixer: Error! Event number from .fz file: %d\n",eventnumber);
266  printf("bfcMixer: Error! Event number from .daq file: %d\n",chain->GetEventNumber());
267  printf("bfcMixer: Error! Events are out-of-sync, exiting!\n");
268  break;
269  }
270  i++;
271  goto EventLoop;
272  }
273 
274  fflush(stdout);
275  printf ("QAInfo:Run completed ");
276  gSystem->Exec("date");
277  if (evMk) Event = (StEvent *) chain->GetInputDS("StEvent");
278  {
279  TDatime t;
280  printf ("\nQAInfo:Run is finished at Date/Time%i/%i\n",t.GetDate(),t.GetTime());
281  }
282 }
283 
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
virtual void SetActive(Bool_t k=kTRUE)
Setters for flags and switches.
Definition: StMaker.h:208
Definition: Stypes.h:44