StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
bfcMixer.C
1 //
3 // Macro for running chain with different inputs
4 //
5 // Owner: Yuri Fisyak
6 //
7 // $Id: bfcMixer.C,v 1.21 2005/08/31 19:47:14 perev Exp $
8 //
10 #if !defined(__CINT__) || defined(__MAKECINT__)
11 #include "Stiostream.h"
12 #include "TSystem.h"
13 #include "TClassTable.h"
14 #include "TApplication.h"
15 #include "TInterpreter.h"
16 #include "TBenchmark.h"
17 #include "StBFChain.h"
18 //#include "StEvent.h"
19 //#include "St_geant_Maker/St_geant_Maker.h"
20 #include "StIOMaker/StIOMaker.h"
21 //#include "StEventMaker/StEventMaker.h"
22 #include "StMixerMaker/StMixerMaker.h"
23 #include "StEvtHddr.h"
24 #include "StTrsMaker/StTrsMaker.h"
25 #else
26 class StMaker;
27 class StChain;
28 class StBFChain;
29 class StEvent;
30 //class St_geant_Maker;
31 class StIOMaker;
32 class StEventMaker;
33 class StMixerMaker;
34 class StEvtHddr;
35 class StMixerMaker;
36 //class StFtpcMixerMaker;
37 class StTrsMaker;
38 #endif
39 StChain *chain=0;
40 StMaker *treeMk=0;
41 StBFChain *chain1, *chain2, *chain3;
42 //StEvent *Event;
43 //StEventMaker *evMk = 0;
44 //_____________________________________________________________________
45 void Load(){
46  gSystem->Load("St_base");
47  Bool_t needLogger = gSystem->Load("liblog4cxx.so") <= 0;
48  if (needLogger) {
49  gSystem->Load("StStarLogger.so");
50  // gInterpreter->ProcessLine("StLoggerManager::StarLoggerInit();");// TMemStat::PrintMem("load StStarLogger");
51  gROOT->ProcessLine("StLoggerManager::StarLoggerInit();");// TMemStat::PrintMem("load StStarLogger");
52  }
53  gSystem->Load("StChain");
54  gSystem->Load("StUtilities");
55  gSystem->Load("StBFChain");
56  //Extra things to load for the acceptance filter
57 #if 0
58  gSystem->Load("StarClassLibrary");
59 #endif
60  gSystem->Load("StAnalysisUtilities");
61 
62  if (chain) delete chain;
63 }
64 //_____________________________________________________________________
65 void bfcMixer(const Int_t Nevents=100,
66  const Char_t *file1="/star/data03/daq/2004/090/st_physics_adc_5090009_raw_2060002.daq",
67  const Char_t *file2="./gtest.fz",
68  const Char_t *file3="./st_physics_adc_5090009_raw_2060002.vertices.dat",
69  const Float_t zvertex_low=-175.0,
70  const Float_t zvertex_high=175.0,
71  const Char_t *mode="strange",
72  const Char_t *acc_mode="off" )
73 {
74  // Dynamically link some shared libs
75  if (gClassTable->GetID("StBFChain") < 0) Load();
76  Int_t iV0Acc = 0;
77  if (! strcmp(mode,"strange") && !strcmp(acc_mode,"on") && gSystem->DynamicPathName("StV0AccMaker",1)) {
78  gSystem->Load("StV0AccMaker.so");
79  iV0Acc = 1;
80  }
81  // Create the main chain object
82  chain = new StChain("Embedding");
83 
84  StMaker *saveMk = 0;
85 
86  // Create chain1 object
87  chain1 = new StBFChain("One");
88  saveMk = chain1->cd();
89  // chain1->SetFlags("in NoDefault");
90  // chain1->SetFlags("in alltrigger NoDefault");
91  // chain1->SetFlags("in Physics DbV20020226 NoDefault");
92  chain1->SetFlags("in Physics DbV20050515 MagF NoDefault");
93  chain1->Set_IO_Files(file1);
94  chain1->Load();
95  chain1->Instantiate();
96 
97  saveMk->cd();
98 
99  // Create chain2 object
100  chain2 = new StBFChain("Two");
101  saveMk = chain2->cd();
102  // chain2->SetFlags("fzin DbV20020226 gen_T geomT sim_T tpc trs -tcl -tpt -PreVtx -tpc_daq"); //
103  chain2->SetFlags("fzin DbV20050515 gen_T geomT sim_T trs -tpc_daq"); //
104  chain2->Set_IO_Files(file2);
105  chain2->Load();
106  chain2->Instantiate();
107  StMaker *geantMk = chain2->GetMaker("geant");
108  if (geantMk) geantMk->SetMode(1); // Mixer mode - do not modify EvtHddr
109 
110  if (chain2->GetOption("TRS")){
111  StTrsMaker *trsMk = (StTrsMaker *) chain2->GetMaker("Trs");
112  trsMk->setNormalFactor(1.22);
113  }
114  // Add the acceptance filter maker before TRS
115  if (iV0Acc) {
116  Char_t *extraMaker = "StV0AccMaker";
117  if (gClassTable->GetID(extraMaker) < 0) gSystem->Load(extraMaker);
118  StMaker *extraMk = (StMaker *)chain1->GetMaker(extraMaker);
119  if(extraMk) delete extraMk;
120  extraMk = chain->New(extraMaker,"before");
121  if (extraMk) {
122  Char_t *before = "Trs";
123  StMaker *trsmk = chain1->GetMaker(before);
124  if (trsmk) chain1->AddBefore(before,extraMk);
125  StV0AccCuts *cuts = ((StV0AccMaker *)extraMk)->GetCutsPtr();
126  cuts->SetFilter();
127  cuts->SetV0MinDecayLen(0.);
128  cuts->SetV0DaughterMinImpact(0);
129  cuts->SetV0DaughterMinHit(10.);
130  cuts->SetXiV0MaxImpact(5);
131  cuts->SetXiMinDecayLen(2.);
132  cuts->SetXiV0PiMinImpact(0.);
133  cuts->SetXiDaughterMinHit(10.);
134  cuts->SetKinkMinDecayRad(128.);
135  cuts->SetKinkMaxDecayRad(184.);
136  }
137  }
138  // end additional maker code
139 
140  saveMk->cd();
141 
142  // Mixer
143  gSystem->Load("StMixerMaker");
144  StMixerMaker *mixer = new StMixerMaker("Mixer","daq","trs");
145  chain1->SetInput("Input1","StDAQReader");
146  chain2->SetInput("Input2","Event");
147  mixer->writeFile("mixer.trs",Nevents);
148 
149  // gSystem->Load("StFtpcMixerMaker");
150  // StFtpcMixerMaker *ftpcmixer = new StFtpcMixerMaker("FtpcMixer","daq","trs");
151 
152  // Create chain3 object
153  chain3 = new StBFChain("Three");
154  saveMk = chain3->cd();
155 
156  // use Simu NoDefault NoInput onlraw -onlcl and standard chain options
157  // then take apart e.g. P2004/B2004 and remove corrections as well as
158  // in, physics, analyis and Event QA from Cdst, tags, SCEbyE
159  // also don't use hitfilt
160  // took out svtdEdx, emcDY2 too
161 
162  // 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");
163 
164  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 analysis ");
165 
166  // StRTSClientFCF *fcfMk = (StRTSClientFCF *) chain3->GetMaker("");
167  // fcfMk->SetMode("0x1");
168 
169 
170  TString OutputFileName(gSystem->BaseName(file1));
171  OutputFileName.ReplaceAll("*","");
172  OutputFileName.ReplaceAll(".daq","");
173  OutputFileName.Append(".root");
174  chain3->Set_IO_Files(0,OutputFileName.Data());
175  chain3->Load();
176  chain3->Instantiate();
177 #if 0
178  geantMk = chain->GetMaker("geant");
179  geantMk->SetActive(kTRUE);
180 #endif
181  StMaker *tpcdaqMk = chain3->GetMaker("tpc_raw");
182  tpcdaqMk->SetMode(1); // Trs
183  tpcdaqMk->SetInput("Event","MixerEvent");
184 
185  // StMaker *ftpccluMk = chain3->GetMaker("ftpc_hits");
186  // ftpccluMk->SetInput("ftpc_raw","FtpcMixer");
187 
188  saveMk->cd();
189  {
190  TDatime t;
191  printf ("QAInfo:Run is started at Date/Time%i/%i\n",t.GetDate(),t.GetTime());
192  }
193  printf ("QAInfo:Run on %s in %s\n",
194  gSystem->HostName(),
195  gSystem->WorkingDirectory());
196  printf ("QAInfo: with %s\n", chain->GetCVS());
197 
198  // Init the chain and all its makers
199  if (Nevents >= 0) {
200  chain->Init();
201  }
202  // chain->SetDEBUG();
203  treeMk = chain->GetMaker("tree");
204  TBenchmark evnt;
205  Int_t iMake = 0, i = 1, iBad = 0;
206 
207  StIOMaker *inpMk = (StIOMaker *)chain1->GetMaker("inputStream");
208  FILE *fp = fopen(file3,"r");
209  Float_t x, y, z;
210  Int_t ncols, eventnumber, mult, skip=0, oldskip = 0, skiptest=0;
211  printf("zvertex_low = %f zvertex_high = %f\n",zvertex_low, zvertex_high);
212 
213  // vtxMk = (StVertexMaker*) chain3->GetMaker("vertex");
214 
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) goto EndLoop;;
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(); 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  goto EndLoop;;
269  }
270  i++;
271  goto EventLoop;
272  }
273  EndLoop:
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:1513
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
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