StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
bfcMixer_pp2006.C
1 //
3 // Macro for embedding on TPC+BEMC+EEMC
4 // - has not yet gone through peer review
5 //
6 // - setup for pp2006 production
7 //
8 // \author Wei-Ming Zhang, KSU
9 // \author Jan Balewski, IUCF
10 // \author Adam Kocoloski, MIT
11 //
12 // $Id: bfcMixer_pp2006.C,v 1.3 2007/09/12 21:47:47 kocolosk Exp $
13 //
15 
16 
17 class StBFChain;
18 StBFChain *chain=0;
19 class StMaker;
20 class StEvent;
21 
22 StBFChain *chain1, *chain2, *chain3;
23 //_____________________________________________________________________
24 void bfcMixer_pp2006( Int_t Nevents=10,
25  Char_t *file1="star/data03/daq/2006/120/7120049/st_physics_adc_7120049_raw_1050001.daq", // probably ppLong 2006 run, NOT for real embedding - just for testing
26  //Char_t *file1="st_zerobias_7118049_raw_1110001.daq",// contains 127 events, good foor real embedding
27  // Char_t *file2="eleB.fzd", // one-particle events from Naresh
28  Char_t *file2="mcpi0_hipt_run140_gid7_1000evts.fzd",
29  Int_t useEndcapSlowSim=1
30  // note, Barrel slow sim is always ON, said Adam
31  ){
32  TString path1="/";
33  //TString path2="/star/data04/sim/subbanly/electron2006/oneTrack2Keve/fzd/";
34  TString path2="/star/u/wzhang/links/gc2002/EEmc/embedData/fzd/";
35 
36  // Dynamically link some shared libs
37  if (gClassTable->GetID("StBFChain") < 0) Load();
38 
39  // Create the main chain object
40  chain = new StBFChain("Embedding");
41 
42  StMaker *saveMk = 0;
43  chain->SetFlags("-ittf,NoDefault");
44  // Create chain1 object
45  chain1 = new StBFChain("One");
46 
47  saveMk = chain1->cd();
48  chain1->SetFlags("in Physics NoDefault -ittf -trg"); //Akio said OK for '-trg'.
49  chain1->Set_IO_Files(path1+file1);
50  chain1->Load();
51  chain1->Instantiate();
52 
53  saveMk->cd();
54 
55  // Create chain2 object
56  chain2 = new StBFChain("Two");
57  saveMk = chain2->cd();
58  chain2->SetFlags("fzin gen_T geomT sim_T tpc trs -tcl -tpt -PreVtx -tpc_daq -ittf ");
59  chain2->Set_IO_Files(path2+file2);
60  chain2->Load();
61  chain2->Instantiate();
62  St_geant_Maker *geantMk = chain2->GetMaker("geant");
63  if (geantMk) geantMk->SetMode(1); // Mixer mode - do not modify EvtHddr
64 
65  // do not rescale dEdx in TRS, it leads to wrong cluster formation, from Jamie
66 
67  saveMk->cd();
68 
69  // Mixer for TPC
70  gSystem->Load("StMixerMaker");
71  StMixerMaker *mixer = new StMixerMaker("Mixer","daq","trs");
72  chain1->SetInput("Input1","StDAQReader");
73  chain2->SetInput("Input2","Event");
74  mixer->writeFile("mixer.trs",Nevents);
75 
76 
77  // Create chain3 object
78  chain3 = new StBFChain("Three");
79  saveMk = chain3->cd();
80 
81  // options for 2006pp, production=DbV20060915,pp2006b,ITTF,hitfilt
82  chain3->SetFlags("Simu NoDefault NoInput onlraw -onlcl ry2006,tpc_daq,tpcI,svt_daq,SvtD,Physics,Idst,l0,Tree,evout l3onl fcf emcDY2 fpd trgd ZDCvtx useCDV ITTF tofDat -SvtIT MuDST -trg VFPPVnoCTB beamline GeantOut CMuDst dEdxY2 -EventQA");
83  // Note, do not freez the DB time stamp or you will not see the latest gains/peds/stat
84 
85  TString tt1=file1;
86  TString tt2=file2;
87  tt1.ReplaceAll(".daq","");
88  tt2.ReplaceAll(".fzd","");
89  TString OutputFileName=tt1+"_"+tt2+".root";
90  cout <<"BFC: Setting file output to: " <<OutputFileName.Data()<<endl;
91 
92  chain3->Set_IO_Files(0,OutputFileName.Data());
93  chain3->Load();
94  chain3->Instantiate();
95 
96  //............. begin of EMC embedding makers................
97 
98  //.............. Add BEmc stuff here ....................
99  StMcEventMaker* mcEventMaker = new StMcEventMaker();
100  StEmcSimulatorMaker *bemcSim = new StEmcSimulatorMaker();
101  StEmcMixerMaker *bemcMixer = new StEmcMixerMaker();
102  chain3->AddAfter("emcRaw",bemcMixer);
103  chain3->AddAfter("emcRaw",bemcSim);
104  chain3->AddAfter("emcRaw",mcEventMaker);
105  bemcMixer->SetDebug(0); // set it to 1 for more printouts
106  // note, Barrel slow sim is always ON, said Adam
107 
108  //........... Add EEmc Stuff ( Simu, and Mixer) here ..............
109  StEEmcFastMaker *eemcFastSim = new StEEmcFastMaker();
110  StEEmcMixerMaker *eemcMixer = new StEEmcMixerMaker();
111 
112  /* position B+E EMC makers in the chain
113  (order is reverse because 'After' is used - looks funny but is right)
114  */
115  chain3->AddAfter("emcRaw",eemcMixer);
116  chain3->AddAfter("emcRaw",eemcFastSim);
117 
118 
119  eemcFastSim->SetEmbeddingMode();
120  // eemcFastSim->SetDebug();
121  // eemcMixer->SetDebug();
122 
123  if(useEndcapSlowSim) { // turn Endcap slow simu On/Off
124  StEEmcSlowMaker *slowSim=new StEEmcSlowMaker();
125  chain3->AddAfter("EEmcFastSim",slowSim);
126  slowSim->setEmbeddingMode();
127  }
128 
129  //............. end of EMC embedding makers................
130 
131  St_geant_Maker *geantMk = (St_geant_Maker *) chain->GetMaker("geant");
132  geantMk->SetActive(kTRUE);
133  StMaker *tpcdaqMk = chain3->GetMaker("tpc_raw");
134  if(!tpcdaqMk ) {
135  cout <<" Error: no tpc daq maker. End. "<<endl;
136  return;
137  }
138  tpcdaqMk->SetMode(1); // Trs
139  tpcdaqMk->SetInput("Event","MixerEvent");
140 
141  saveMk->cd(); {
142  TDatime t;
143  printf ("QAInfo:Run is started at Date/Time%i/%i\n",t.GetDate(),t.GetTime());
144  }
145  printf ("QAInfo:Run on %s in %s\n",
146  gSystem->HostName(),
147  gSystem->WorkingDirectory());
148  printf ("QAInfo: with %s\n", chain->GetCVS());
149 
150  // Init the chain and all its makers
151 
152  if (Nevents >= 0) {
153  Int_t iInit = chain->Init();
154  chain->ls(5); // list the final chain
155  }
156 
157 
158  // chain->SetDEBUG();
159  treeMk = chain->GetMaker("tree");
160  TBenchmark evnt;
161  Int_t iMake = 0, i = 1, iBad = 0;
162 
163 
164  StIOMaker *inpMk = (StIOMaker *)chain1->GetMaker("inputStream");
165  Int_t ncols, eventnumber, mult, skip=0, oldskip = 0, skiptest=0;
166 
167  cout <<"BFC - Entering Event Loop"<<endl;
168  EventLoop: if (i <= Nevents && iMake != kStEOF && iMake != kStFatal) {
169  evnt.Reset();
170  evnt.Start("QAInfo:");
171  chain->Clear();
172 
173  iMake = chain->Make(i);
174  if (treeMk && iMake == kStErr) {treeMk->Make(i); iBad++;}
175  StEvtHddr *fEvtHddr = (StEvtHddr*)chain->GetDataSet("EvtHddr");
176  StEvtHddr *fEvtHddrDaq = (StEvtHddr*)chain1->GetDataSet("EvtHddr");
177  *fEvtHddr = *fEvtHddrDaq;
178  // gSystem->Exec("ps ux");
179  evnt.Stop("QAInfo:");
180  // evnt->Show("QAInfo:");
181  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(),
182  iMake,evnt.GetRealTime("QAInfo:"),evnt.GetCpuTime("QAInfo:"));
183 
184  i++;
185  goto EventLoop;
186  }
187 
188  fflush(stdout);
189  printf ("QAInfo:Run completed ");
190  gSystem->Exec("date");
191 
192 }
193 
194 
195 //_____________________________________________________________________
196 void Load(){
197  gSystem->Load("St_base");
198  gSystem->Load("StChain");
199  gSystem->Load("StUtilities");
200  gSystem->Load("StBFChain");
201  gSystem->Load("StAnalysisUtilities");
202 
203  // required by StEEmcSimulatorMaker
204  gROOT->LoadMacro("$STAR/StRoot/StMuDSTMaker/COMMON/macros/loadSharedLibraries.C");
205  loadSharedLibraries();
206  gSystem->Load("StEEmcUtil");
207  gSystem->Load("StEEmcSimulatorMaker");
208  gSystem->Load("StMcEvent");
209  gSystem->Load("StMcEventMaker");
210  gSystem->Load("StEmcSimulatorMaker");
211  gSystem->Load("StEmcMixerMaker");
212 
213  // use this powerfull Logger from Valeri
214  gROOT->Macro("LoadLogger.C");
215  if (chain) delete chain;
216 }
217 
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
Filling of all StMcEvent classes from g2t tables Transform all the data in the g2t tables into the co...
virtual void ls(Option_t *option="") const
Definition: TDataSet.cxx:495
Definition: Stypes.h:43
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
void setEmbeddingMode(Bool_t e=true)
Sets all switches required to perform embedding.
Slow simulator for EEMC.
virtual void SetActive(Bool_t k=kTRUE)
Setters for flags and switches.
Definition: StMaker.h:208
Definition: Stypes.h:44