StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
bfcMixer_Jet.C
1 //
3 // $Id: bfcMixer_Jet.C,v 1.1 2012/08/27 22:43:27 pibero Exp $
4 //
5 // $Log: bfcMixer_Jet.C,v $
6 // Revision 1.1 2012/08/27 22:43:27 pibero
7 // From PDSF
8 //
9 //
10 // JET EMBEDDING MACRO
11 //
12 // Pibero Djawotho <pibero@tamu.edu>
13 // Texas A&M University
14 // 27 July 2011
15 //
17 
18 class StChain;
19 StChain* Chain = 0;
20 
21 class StBFChain;
22 StBFChain* chain1 = 0;
23 StBFChain* chain2 = 0;
24 StBFChain* chain3 = 0;
25 
26 //_____________________________________________________________________
27 void bfcMixer_Jet(const Int_t Nevents = 1000,
28  const Char_t* daqfile = "@run10148002.list",
29  const Char_t* fzdfile = "eliza14/SL11d_embed/10148002/pt11_15_10148002_1.fzd",
30  const Char_t* prodName = "P11idpp200",
31  const Char_t* DbVoption = "DbV20120622,DbV20120622_EMC_Calibrations,DbV20120622_EEMC_Calibrations")
32 {
33  // Production chains for P08ic - p+p, Au+Au 9 GeV and d+Au
34  TString prodP08iepp("DbV20081117 B2008a ITTF IAna ppOpt l3onl emcDY2 fpd ftpc trgd ZDCvtx NosvtIT NossdIT Corr4 OSpaceZ2 OGridLeak3D VFMCE -hitfilt");
35  TString prodP08iedAu("DbV20090213 P2008 ITTF OSpaceZ2 OGridLeak3D beamLine VFMCE TpxClu -VFMinuit -hitfilt");
36  TString prodP10iapp("DbV20091001 pp2009c TpcRS ITTF OSpaceZ2 OGridLeak3D beamLine, VFMCE TpcRS -VFMinuit -hitfilt");
37 
38  // BES Run10 chains
39  TString prodP10ihAuAu39("DbV20100909 P2010a,btof,BEmcChkStat,Corr4,OSpaceZ2,OGridLeak3D,VFMCE TpxClu -VFMinuit -hitfilt");
40  TString prodP10ihAuAu11("DbV20100821 P2010a,btof,BEmcChkStat,Corr4,OSpaceZ2,OGridLeak3D,VFMCE TpxClu -VFMinuit -hitfilt");
41  TString prodP10ihAuAu7("DbV20100821 P2010a,btof,BEmcChkStat,Corr4,OSpaceZ2,OGridLeak3D,VFMCE TpxClu -VFMinuit -hitfilt");
42 
43  // Run 9 500 GeV chain for W from Jan Balewski
44  TString prodP09igpp500("DbV20101215 OGGVoltErr pp2009c ITTF VFPPVnoCTB BEmcChkStat beamLine Corr4 OSpaceZ2 OGridLeak3D -dstout -evout");
45 
46  // Run 9 200 GeV chain for jet embedding
47  TString prodP10icpp200("pp2009c ITTF VFPPVnoCTB beamLine BEmcChkStat btof fmsdat Corr4 OSpaceZ2 OGridLeak3D");
48 
49  // Run 9 200 GeV FF chain
50  // NOTE: "Sti" needs to be added for this chain to work !!!
51  TString prodP11idpp200("DbV20120622 pp2009d ITTF Sti VFPPVnoCTB beamLine BEmcChkStat btof fmsdat Corr4 OSpaceZ2 OGridLeak3D -hitfilt");
52 
53  // Additional tags needed for embedding
54  prodP09igpp500 += " TpxClu -VFMinuit VFPPVnoCTB beamLine -hitfilt";
55  prodP10icpp200 += " TpxClu -VFMinuit VFPPVnoCTB beamLine -hitfilt";
56  prodP11idpp200 += " TpxClu -VFMinuit VFPPVnoCTB beamLine -hitfilt";
57 
58  TString geomP08ic("ry2008");
59  TString geomP10ih("ry2010");
60  TString geomP09ig("ry2009a");
61  TString geomP10ic("ry2009a");
62  TString geomP11id("ry2009d");
63  TString chain1Opt("in,magF,tpcDb,NoDefault,TpxRaw,-ittf,NoOutput");
64  TString chain2Opt("fzin,gen_T,geomT,sim_T,TpcRS,-ittf,-tpc_daq,nodefault");
65  chain2Opt += " ";
66 
67  TString chain3Opt;
68  if (prodName == "P08icpp") { chain3Opt = prodP08icpp; chain2Opt += geomP08ic; }
69  else if (prodName == "P08iepp") { chain3Opt = prodP08iepp; chain2Opt += geomP08ic; }
70  else if (prodName == "P08icAuAu9") { chain3Opt = prodP08icAuAu9; chain2Opt += geomP08ic; }
71  else if (prodName == "P08icdAu") { chain3Opt = prodP08icdAu; chain2Opt += geomP08ic; }
72  else if (prodName == "P08iedAu") { chain3Opt = prodP08iedAu; chain2Opt += geomP08ic; }
73  else if (prodName == "P08icAuAu200") { chain3Opt = prodP08icAuAu200; chain2Opt += geomP08ic; }
74  else if (prodName == "P10iapp") { chain3Opt = prodP10iapp; chain2Opt += geomP10ih; }
75  else if (prodName == "P10ihAuAu39") { chain3Opt = prodP10ihAuAu39; chain2Opt += geomP10ih; }
76  else if (prodName == "P10ihAuAu11") { chain3Opt = prodP10ihAuAu11; chain2Opt += geomP10ih; }
77  else if (prodName == "P10ihAuAu7") { chain3Opt = prodP10ihAuAu7; chain2Opt += geomP10ih; }
78  else if (prodName == "P09igpp500") { chain3Opt = prodP09igpp500; chain2Opt += geomP09ig; }
79  else if (prodName == "P10icpp200") { chain3Opt = prodP10icpp200; chain2Opt += geomP10ic; }
80  else if (prodName == "P11idpp200") { chain3Opt = prodP11idpp200; chain2Opt += geomP11id; }
81  else {
82  cout << "Choice prodName " << prodName << " does not correspond to known chain. Processing impossible." << endl;
83  return;
84  }
85  chain3Opt.Prepend(' ');
86  chain3Opt.Prepend(DbVoption);
87  chain3Opt += ",Embedding,TpcMixer,GeantOut,MiniMcMk,McAna,-in,NoInput,useInTracker,nodefault";
88  chain3Opt += ",";
89 
90  if (prodName == "P08icpp") { chain3Opt += geomP08ic; }
91  else if (prodName == "P08iepp") { chain3Opt += geomP08ic; }
92  else if (prodName == "P08icAuAu9") { chain3Opt += geomP08ic; }
93  else if (prodName == "P08icdAu") { chain3Opt += geomP08ic; }
94  else if (prodName == "P08iedAu") { chain3Opt += geomP08ic; }
95  else if (prodName == "P08icAuAu200") { chain3Opt += geomP08ic; }
96  else if (prodName == "P10iapp") { chain3Opt += geomP10ih; }
97  else if (prodName == "P10ihAuAu39") { chain3Opt += geomP10ih; }
98  else if (prodName == "P10ihAuAu11") { chain3Opt += geomP10ih; }
99  else if (prodName == "P10ihAuAu7") { chain3Opt += geomP10ih; }
100  else if (prodName == "P09igpp500") { chain3Opt += geomP09ig; }
101  else if (prodName == "P10icpp200") { chain3Opt += geomP10ic; }
102  else if (prodName == "P11idpp200") { chain3Opt += geomP11id; }
103  else {
104  cout << "Choice prodName " << prodName << " does not correspond to known chain. Processing impossible. " << endl;
105  return;
106  }
107 
108  // Add BEMC simulators to chain
109  chain3Opt += ",emcSim";
110 
111  // Add EEMC fast simulator to chain
112  chain3Opt += ",EEfs";
113 
114  // Dynamically link some shared libs
115  gROOT->LoadMacro("bfc.C");
116  if (gClassTable->GetID("StBFChain") < 0) Load();
117  //______________Create the main chain object______________________________________
118  Chain = new StChain("Embedding");
119  //________________________________________________________________________________
120  bfc(-1,chain1Opt,daqfile);
121  chain1 = chain;
122  chain1->SetName("One");
123  chain1->SetAttr(".call","SetActive(0)","St_db_Maker::"); // Use DB cache to reduce overhead
124  Chain->cd();
125  //________________________________________________________________________________
126  bfc(-1,chain2Opt,fzdfile);
127  chain2 = chain;
128  chain2->SetName("Two");
129  Chain->cd();
130  if (chain2->GetOption("TRS")){
131  StTrsMaker *trsMk = (StTrsMaker *) chain2->GetMaker("Trs");
132  if (!trsMk) {
133  cout << "Cannot find Trs in chain2" << endl;
134  return;
135  }
136  trsMk->setNormalFactor(1.32);
137  trsMk->SetMode(0);
138  }
139  //________________________________________________________________________________
140  // gSystem->Load("StFtpcMixerMaker");
141  // StFtpcMixerMaker *ftpcmixer = new StFtpcMixerMaker("FtpcMixer","daq","trs");
142  //________________________________________________________________________________
143  TString OutputFileName(gSystem->BaseName(fzdfile));
144  OutputFileName.ReplaceAll("*","");
145  OutputFileName.ReplaceAll(".fzd","");
146  // OutputFileName.Append("_emb.root");
147  OutputFileName.Append(".root");
148  bfc(-1,chain3Opt,0,OutputFileName);
149  chain3 = chain;
150  chain3->SetName("Three");
151  Chain->cd();
152  //________________________________________________________________________________
153  StTpcMixerMaker *mixer = (StTpcMixerMaker *) chain3->Maker("TpcMixer");
154  if( prodName == "P08icAuAu200")
155  {
156  mixer->SetInput("Input1","MixerEvent");
157  }
158  else
159  {
160  mixer->SetInput("Input1","TpxRaw/.data/Event");
161  }
162 
163  if (chain2Opt.Contains("TpcRS",TString::kIgnoreCase)) {
164  mixer->SetInput("Input2","TpcRS/Event");
165  } else {
166  mixer->SetInput("Input2","Trs/.const/Event");
167  }
168  Chain->cd();
169 
170  //------------------------------------ EMC MIXERS ------------------------------------
171  // Add BEMC mixer to chain3
172  StEmcRawMaker* emcRaw = (StEmcRawMaker*)chain3->GetMaker("emcRaw");
173  emcRaw->getBemcRaw()->saveAllStEvent(true); // use all 4800 BEMC towers
174  gSystem->Load("StEmcMixerMaker");
175  StEmcMixerMaker* bemcMixer = new StEmcMixerMaker;
176  chain3->AddAfter("EmcSimulator",bemcMixer);
177  // Set EEMC fast and slow simulator in embedding mode
178  StEEmcFastMaker* eefs = (StEEmcFastMaker*)chain3->GetMaker("eefs");
179  eefs->SetEmbeddingMode(); // Use local StEmcCollection
180  eefs->UseFullTower(true); // Use full ETOW detector
181  StEEmcSlowMaker* eess = new StEEmcSlowMaker;
182  eess->setEmbeddingMode(true);
183  // Add EEMC mixer to chain3
184  StEEmcMixerMaker* eemcMixer = new StEEmcMixerMaker;
185  //------------------------------------------------------------------------------------
186 
187  //----------------------------- TRIGGER FILTER -----------------------------
188  // We want to achieve the following ordering for makers:
189  // 1. BBC simulator
190  // 2. BEMC simulator
191  // 3. BEMC mixer
192  // 4. EEMC fast simulator
193  // 5. EEMC slow simulator
194  // 6. EEMC mixer
195  // 7. Pythia event maker
196  // 8. Trigger simulator
197  // 9. Trigger filter
198  // 10. TPC maker
199 
200  // Place TPC chain after EMC makers
201  chain3->AddAfter("eefs",chain3->GetMaker("tpcChain"));
202  chain3->AddAfter("eefs",eemcMixer);
203  chain3->AddAfter("eefs",eess);
204 
205  // Place Pythia maker after GEANT maker
206  // and trigger filter after EMC makers
207  gSystem->Load("StJetSkimEvent");
208  gSystem->Load("StMCAsymMaker");
209  gSystem->Load("StBfcTriggerFilterMaker");
210 
212  TString pyfile = gSystem->BaseName(fzdfile);
213  pyfile.ReplaceAll(".fzd",".pythia.root");
214  pythia->SetPythiaFile(pyfile);
215  chain3->AddAfter("geant",pythia);
216 
217  // Place trigger simulator after EMC makers
218  gSystem->Load("StTriggerUtilities");
220  trgsim->setMC(1);
221  // BBC was not used in Run 9 jet triggers
222  //trgsim->useBbc();
223  //trgsim->bbc->setSource("StEvent");
224  trgsim->useBemc();
225  trgsim->bemc->setConfig(StBemcTriggerSimu::kOnline);
226  trgsim->useEemc();
227  trgsim->eemc->setSource("StEvent");
228 
229  trgsim->bemc->setBarrelJetPatchTh0(19);
230  trgsim->bemc->setBarrelJetPatchTh1(26);
231  trgsim->bemc->setBarrelJetPatchTh2(34);
232 
233  trgsim->emc->setOverlapJetPatchTh0(18);
234  trgsim->emc->setOverlapJetPatchTh1(25);
235  trgsim->emc->setOverlapJetPatchTh2(33);
236 
237  trgsim->eemc->setEndcapJetPatchTh0(17);
238  trgsim->eemc->setEndcapJetPatchTh1(24);
239  trgsim->eemc->setEndcapJetPatchTh2(31);
240 
241  trgsim->bemc->setBarrelHighTowerTh0(11);
242  trgsim->bemc->setBarrelHighTowerTh1(15);
243  trgsim->bemc->setBarrelHighTowerTh2(18);
244  trgsim->bemc->setBarrelHighTowerTh3(24);
245 
246  trgsim->eemc->setEndcapHighTowerTh0(16);
247  trgsim->eemc->setEndcapHighTowerTh1(25);
248 
250  // The BFC trigger filter will select only JP1, AJP and BHT3 events
251  trgfilt->SetJP1();
252  trgfilt->SetAJP();
253  trgfilt->SetBHT3();
254  // Lower all jet patch thresholds by one unit from
255  // their values obtained from the database using
256  // the current timestamp.
257  //trgfilt->changeJPThresh(-1);
258  chain3->AddBefore("tpcChain",trgsim);
259  chain3->AddBefore("tpcChain",trgfilt);
260 
261  // Move these makers after trigger decision
262  // *** VERY IMPORTANT ***
263  // The order of TpxRaw and TpcRS *must* be preserved
264  // or the embedding will *not* work. [RT# 2299]
265  // http://www.star.bnl.gov/rt2/Ticket/Display.html?id=2299
266  StTpcRSMaker* TpcRS = (StTpcRSMaker*)chain2->GetMaker("TpcRS");
267  StTpcHitMaker* TpxRaw = (StTpcHitMaker*)chain1->GetMaker("TpxRaw");
268  chain3->AddBefore("TpcMixer",TpxRaw);
269  chain3->AddBefore("TpcMixer",TpcRS);
270 
271 #if 0
272  // Turn on debugging of DB maker
273  St_db_Maker* db = (St_db_Maker*)chain1->GetMaker("db");
274  db->SetDebug(2);
275 #endif
276 
277  //--------------------------------------------------------------------------
278  TString trgfile = gSystem->BaseName(fzdfile);
279  trgfile.ReplaceAll(".fzd",".trig.root");
280  TFile* ofile = TFile::Open(trgfile,"recreate");
281  assert(ofile);
282  TH2F* hBarrelHighTowerSimu = new TH2F("hBarrelHighTowerSimu","BEMC high tower simu;trigger patch;high tower",300,0,300,64,0,64);
283  TH2F* hBarrelPatchSumSimu = new TH2F("hBarrelPatchSumSimu","BEMC patch sum simu;trigger patch;patch sum",300,0,300,64,0,64);
284  TH2F* hEndcapHighTowerSimu = new TH2F("hEndcapHighTowerSimu","EEMC high tower simu;trigger patch;high tower",90,0,90,64,0,64);
285  TH2F* hEndcapPatchSumSimu = new TH2F("hEndcapPatchSumSimu","EEMC patch sum simu;trigger patch;patch sum",90,0,90,64,0,64);
286  TH2F* hBarrelJetPatchSimu = new TH2F("hBarrelJetPatchSimu","BEMC jet patch;jet patch;adc",18,0,18,160,0,160);
287  TH2F* hEndcapJetPatchSimu = new TH2F("hEndcapJetPatchSimu","EEMC jet patch;jet patch;adc",6,0,6,160,0,160);
288  TH2F* hOverlapJetPatchSimu = new TH2F("hOverlapJetPatchSimu","BEMC-EEMC-overlap;jet patch;adc",6,0,6,160,0,160);
289  //--------------------------------------------------------------------------
290  // Initialize chain
291  Chain->Init();
292  PrintTimer(Chain);
293  puts("Order of makers in BFCMIXER:");
294  StMaker::lsMakers(Chain);
295  // Event loop
296  int mNTotal = 0;
297  int mNFailed = 0;
298  TBenchmark evnt;
299  StIOMaker* inputStream = (StIOMaker*)chain1->GetMaker("inputStream");
300  for (int iEvent = 1; iEvent <= Nevents; ++iEvent) {
301  evnt.Reset();
302  evnt.Start("QAInfo:");
303  Chain->Clear();
304  int iMake = Chain->Make(iEvent);
305  if (iMake == kStErr) ++mNFailed;
306  if (inputStream->GetMakeReturn() % 10 == kStEOF) {
307  inputStream->Rewind();
308  --iEvent;
309  continue;
310  }
311  //if (iMake == kStSkip) continue;
312  if (iMake % 10 == kStEOF || iMake % 10 == kStFatal) break;
313  ++mNTotal;
314  PrintTimer(Chain);
315  //--------------------------------------------------------------------------
316  // BEMC high towers and trigger patches
317  for (int triggerpatch = 0; triggerpatch < 300; ++triggerpatch) {
318  hBarrelHighTowerSimu->Fill(triggerpatch,trgsim->bemc->getBEMC_FEE_HT_ADC()[triggerpatch]);
319  hBarrelPatchSumSimu->Fill(triggerpatch,trgsim->bemc->getBEMC_FEE_TP_ADC()[triggerpatch]);
320  } // for triggerpatch
321  // BEMC jet patches
322  for (int jetpatch = 0; jetpatch < 18; ++jetpatch) {
323  hBarrelJetPatchSimu->Fill(jetpatch,trgsim->bemc->barrelJetPatchAdc(jetpatch));
324  } // for jetpatch
325  // EEMC high towers and trigger patches
326  for (int triggerpatch = 0; triggerpatch < 90; ++triggerpatch) {
327  hEndcapHighTowerSimu->Fill(triggerpatch,trgsim->eemc->getOutHT(triggerpatch));
328  hEndcapPatchSumSimu->Fill(triggerpatch,trgsim->eemc->getOutTPsum(triggerpatch));
329  } // for triggerpatch
330  // EEMC jet patches
331  for (int jetpatch = 0; jetpatch < 6; ++jetpatch) {
332  hEndcapJetPatchSimu->Fill(jetpatch,trgsim->eemc->endcapJetPatchAdc(jetpatch));
333  } // for jetpatch
334  // BEMC-EEMC-overlap jet patches
335  for (int i = 0; i < 2; ++i) {
336  int jetpatch, adc;
337  trgsim->emc->getOverlapJetPatchAdc(i,jetpatch,adc);
338  hOverlapJetPatchSimu->Fill(jetpatch,adc);
339  } // for i
340  //--------------------------------------------------------------------------
341  evnt.Stop("QAInfo:");
342  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",iEvent,Chain->GetRunNumber(),Chain->GetEventNumber(),Chain->GetDate(),Chain->GetTime(),chain3->GetMakeReturn(),evnt.GetRealTime("QAInfo:"),evnt.GetCpuTime("QAInfo:"));
343  } // End event loop
344  printf("QAInfo:EventLoop completed code %d\n",iMake);
345  gSystem->Exec("date");
346  TDatime t;
347  printf("QAInfo:Run is finished at Date/Time %i/%i; Total events processed: %i and not completed: %i\n",t.GetDate(),t.GetTime(),mNTotal,mNFailed);
348  //--------------------------------------------------------------------------
349  ofile->Write();
350  ofile->Close();
351  //--------------------------------------------------------------------------
352 }
353 
354 // Print timers for all makers in chain
355 class StMaker;
356 void PrintTimer(StMaker* chain)
357 {
358  TIter next(chain->GetMakeList());
359  StMaker* maker;
360  while (maker = (StMaker*)next()) {
361  maker->PrintTimer();
362  PrintTimer(maker);
363  // Hack to reset timer
364  maker->StartTimer(true);
365  maker->StopTimer();
366  }
367 }
virtual void Clear(Option_t *option="")
User defined functions.
Definition: StChain.cxx:77
StBemcRaw * getBemcRaw()
Return the StBemcRaw pointer.
Definition: StEmcRawMaker.h:95
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
void saveAllStEvent(Bool_t a)
Set to kTRUE if all hits are to be saved on StEvent.
Definition: StBemcRaw.h:178
virtual void setSource(const char *source)
Options are: &quot;MuDst&quot;, &quot;StEvent&quot;.
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.
Definition: Stypes.h:44
virtual void PrintTimer(Option_t *option="")
Definition: StMaker.cxx:1098