StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
bfcMixer_DaqFzd.C
1 //
3 // $Id: bfcMixer_DaqFzd.C,v 1.2 2012/02/17 20:47:36 fisyak Exp $
4 //
5 // $Log: bfcMixer_DaqFzd.C,v $
6 // Revision 1.2 2012/02/17 20:47:36 fisyak
7 // Remove nodefault option from chain3
8 //
9 // Revision 1.1 2011/10/14 20:05:23 jeromel
10 // Saved version ... floating aorund and being used or tested
11 //
12 //
13 // JET EMBEDDING MACRO
14 //
15 // Pibero Djawotho <pibero@tamu.edu>
16 // Texas A&M University
17 // 27 July 2011
18 //
20 
21 class StChain;
22 StChain* Chain = 0;
23 
24 class StBFChain;
25 StBFChain* chain1 = 0;
26 StBFChain* chain2 = 0;
27 StBFChain* chain3 = 0;
28 
29 //_____________________________________________________________________
30 void bfcMixer_Jet2(const Int_t Nevents = 1000,
31  const Char_t* daqfile = "/star/data03/daq/2009/WembAll/st_zerobias_adc_10085134_raw_4450001.daq",
32  const Char_t* fzdfile = "/star/institutions/uky/gdwebb/pp500Embedding2009/output/pTbin_4_5/st_zerobias_adc_10085134_raw_4450001.fzd",
33  const Char_t* prodName = "P09igpp500")
34 {
35  // Production chains for P08ic - p+p, Au+Au 9 GeV and d+Au
36  TString prodP08iepp("DbV20081117 B2008a ITTF IAna ppOpt l3onl emcDY2 fpd ftpc trgd ZDCvtx NosvtIT NossdIT Corr4 OSpaceZ2 OGridLeak3D VFMCE -hitfilt");
37  TString prodP08iedAu("DbV20090213 P2008 ITTF OSpaceZ2 OGridLeak3D beamLine VFMCE TpxClu -VFMinuit -hitfilt");
38  TString prodP10iapp("DbV20091001 pp2009c TpcRS ITTF OSpaceZ2 OGridLeak3D beamLine, VFMCE TpcRS -VFMinuit -hitfilt");
39 
40  // BES Run10 chains
41  TString prodP10ihAuAu39("DbV20100909 P2010a,btof,BEmcChkStat,Corr4,OSpaceZ2,OGridLeak3D,VFMCE TpxClu -VFMinuit -hitfilt");
42  TString prodP10ihAuAu11("DbV20100821 P2010a,btof,BEmcChkStat,Corr4,OSpaceZ2,OGridLeak3D,VFMCE TpxClu -VFMinuit -hitfilt");
43  TString prodP10ihAuAu7("DbV20100821 P2010a,btof,BEmcChkStat,Corr4,OSpaceZ2,OGridLeak3D,VFMCE TpxClu -VFMinuit -hitfilt");
44 
45  // Run 9 500 GeV chain for W from Jan Balewski
46  TString prodP09igpp500("DbV20091225 pp2009c ITTF VFPPVnoCTB beamLine BEmcChkStat btof Corr4 OSpaceZ2 OGridLeak3D -dstout -evout");
47 
48  // Run 9 200 GeV chain for jet embedding
49  TString prodP10icpp200("DbV20100130 pp2009c ITTF VFPPVnoCTB beamLine BEmcChkStat btof fmsdat Corr4 OSpaceZ2 OGridLeak3D");
50 
51  // Additional tags needed for embedding
52  prodP09igpp500 += " TpxClu -VFMinuit VFPPVnoCTB beamLine -hitfilt";
53  prodP10icpp200 += " TpxClu -VFMinuit VFPPVnoCTB beamLine -hitfilt";
54 
55  TString geomP08ic("ry2008");
56  TString geomP10ih("ry2010");
57  TString geomP09ig("ry2009a");
58  TString geomP10ic("ry2009a");
59  TString chain1Opt("in,magF,tpcDb,NoDefault,TpxRaw,-ittf,NoOutput");
60  TString chain2Opt("fzin,gen_T,geomT,sim_T,TpcRS,-ittf,-tpc_daq,nodefault");
61  chain2Opt += " ";
62 
63  TString chain3Opt;
64  if (prodName == "P08icpp") { chain3Opt = prodP08icpp; chain2Opt += geomP08ic; }
65  else if (prodName == "P08iepp") { chain3Opt = prodP08iepp; chain2Opt += geomP08ic; }
66  else if (prodName == "P08icAuAu9") { chain3Opt = prodP08icAuAu9; chain2Opt += geomP08ic; }
67  else if (prodName == "P08icdAu") { chain3Opt = prodP08icdAu; chain2Opt += geomP08ic; }
68  else if (prodName == "P08iedAu") { chain3Opt = prodP08iedAu; chain2Opt += geomP08ic; }
69  else if (prodName == "P08icAuAu200") { chain3Opt = prodP08icAuAu200; chain2Opt += geomP08ic; }
70  else if (prodName == "P10iapp") { chain3Opt = prodP10iapp; chain2Opt += geomP10ih; }
71  else if (prodName == "P10ihAuAu39") { chain3Opt = prodP10ihAuAu39; chain2Opt += geomP10ih; }
72  else if (prodName == "P10ihAuAu11") { chain3Opt = prodP10ihAuAu11; chain2Opt += geomP10ih; }
73  else if (prodName == "P10ihAuAu7") { chain3Opt = prodP10ihAuAu7; chain2Opt += geomP10ih; }
74  else if (prodName == "P09igpp500") { chain3Opt = prodP09igpp500; chain2Opt += geomP09ig; }
75  else if (prodName == "P10icpp200") { chain3Opt = prodP10icpp200; chain2Opt += geomP10ic; }
76  else {
77  cout << "Choice prodName " << prodName << " does not correspond to known chain. Processing impossible." << endl;
78  return;
79  }
80  chain3Opt += ",Embedding,TpcMixer,GeantOut,MiniMcMk,McAna,-in,NoInput,useInTracker";
81  chain3Opt += ",";
82 
83  if (prodName == "P08icpp") { chain3Opt += geomP08ic; }
84  else if (prodName == "P08iepp") { chain3Opt += geomP08ic; }
85  else if (prodName == "P08icAuAu9") { chain3Opt += geomP08ic; }
86  else if (prodName == "P08icdAu") { chain3Opt += geomP08ic; }
87  else if (prodName == "P08iedAu") { chain3Opt += geomP08ic; }
88  else if (prodName == "P08icAuAu200") { chain3Opt += geomP08ic; }
89  else if (prodName == "P10iapp") { chain3Opt += geomP10ih; }
90  else if (prodName == "P10ihAuAu39") { chain3Opt += geomP10ih; }
91  else if (prodName == "P10ihAuAu11") { chain3Opt += geomP10ih; }
92  else if (prodName == "P10ihAuAu7") { chain3Opt += geomP10ih; }
93  else if (prodName == "P09igpp500") { chain3Opt += geomP09ig; }
94  else if (prodName == "P10icpp200") { chain3Opt += geomP10ic; }
95  else {
96  cout << "Choice prodName " << prodName << " does not correspond to known chain. Processing impossible. " << endl;
97  return;
98  }
99 
100  // Add BEMC simulators to chain
101  chain3Opt += ",emcSim";
102 
103  // Add EEMC fast simulator to chain
104  chain3Opt += ",EEfs";
105 
106  // Dynamically link some shared libs
107  gROOT->LoadMacro("bfc.C");
108  if (gClassTable->GetID("StBFChain") < 0) Load();
109  //______________Create the main chain object______________________________________
110  Chain = new StChain("Embedding");
111  //________________________________________________________________________________
112  bfc(-1,chain1Opt,daqfile);
113  chain1 = chain;
114  chain1->SetName("One");
115  Chain->cd();
116  //________________________________________________________________________________
117  bfc(-1,chain2Opt,fzdfile);
118  chain2 = chain;
119  chain2->SetName("Two");
120  Chain->cd();
121  if (chain2->GetOption("TRS")){
122  StTrsMaker *trsMk = (StTrsMaker *) chain2->GetMaker("Trs");
123  if (!trsMk) {
124  cout << "Cannot find Trs in chain2" << endl;
125  return;
126  }
127  trsMk->setNormalFactor(1.32);
128  trsMk->SetMode(0);
129  }
130  //________________________________________________________________________________
131  // gSystem->Load("StFtpcMixerMaker");
132  // StFtpcMixerMaker *ftpcmixer = new StFtpcMixerMaker("FtpcMixer","daq","trs");
133  //________________________________________________________________________________
134  TString OutputFileName(gSystem->BaseName(fzdfile));
135  OutputFileName.ReplaceAll("*","");
136  OutputFileName.ReplaceAll(".fzd","");
137  // OutputFileName.Append("_emb.root");
138  OutputFileName.Append(".root");
139  bfc(-1,chain3Opt,0,OutputFileName);
140  chain3 = chain;
141  chain3->SetName("Three");
142  Chain->cd();
143  //________________________________________________________________________________
144  // Read raw TPX hits and generate simulated TPX hits AFTER
145  // the event pass the trigger filter
146  StTpcHitMaker* TpxRaw = (StTpcHitMaker*)chain1->GetMaker("TpxRaw");
147  StTpcRSMaker* TpcRS = (StTpcRSMaker*)chain2->GetMaker("TpcRS");
148  chain3->AddBefore("TpcMixer",TpcRS);
149  chain3->AddBefore("TpcMixer",TpxRaw);
150  //________________________________________________________________________________
151  StTpcMixerMaker *mixer = (StTpcMixerMaker *) chain3->Maker("TpcMixer");
152  if( prodName == "P08icAuAu200")
153  {
154  mixer->SetInput("Input1","MixerEvent");
155  }
156  else
157  {
158  mixer->SetInput("Input1","TpxRaw/.data/Event");
159  }
160 
161  if (chain2Opt.Contains("TpcRS",TString::kIgnoreCase)) {
162  mixer->SetInput("Input2","TpcRS/Event");
163  } else {
164  mixer->SetInput("Input2","Trs/.const/Event");
165  }
166  Chain->cd();
167 
168  //------------------------------------ EMC MIXERS ------------------------------------
169  // Add BEMC mixer to chain3
170  StEmcRawMaker* emcRaw = (StEmcRawMaker*)chain3->GetMaker("emcRaw");
171  emcRaw->getBemcRaw()->saveAllStEvent(true); // use all 4800 BEMC towers
172  gSystem->Load("StEmcMixerMaker");
173  StEmcMixerMaker* bemcMixer = new StEmcMixerMaker;
174  chain3->AddAfter("EmcSimulator",bemcMixer);
175  // Set EEMC fast and slow simulator in embedding mode
176  StEEmcFastMaker* eefs = (StEEmcFastMaker*)chain3->GetMaker("eefs");
177  eefs->SetEmcCollectionLocal(false); // don't create local StEmcCollection
178  eefs->UseFullTower(true); // Use full ETOW detector
179  StEEmcSlowMaker* eess = new StEEmcSlowMaker;
180  eess->setEmbeddingMode(false); // don't use local StEmcCollection
181  eess->setAddPed(true); // add pedestals
182  eess->setSmearPed(true); // smear pedestals
183  eess->setDropBad(true); // force bad channels to be dropped in db
184  eess->setOverwrite(true); // overwrite ADC values
185  eess->setSource("StEvent");
186  // Add EEMC mixer to chain3
187  //StEEmcMixerMaker* eemcMixer = new StEEmcMixerMaker;
188  //------------------------------------------------------------------------------------
189 
190  //----------------------------- TRIGGER FILTER -----------------------------
191  // We want to achieve the following ordering for makers:
192  // 1. BBC simulator
193  // 2. BEMC simulator
194  // 3. BEMC mixer
195  // 4. EEMC fast simulator
196  // 5. EEMC slow simulator
197  // 6. EEMC mixer
198  // 7. Pythia event maker
199  // 8. Trigger simulator
200  // 9. Trigger filter
201  // 10. TPC maker
202 
203  // Place TPC chain after EMC makers
204  chain3->AddAfter("eefs",chain3->GetMaker("tpcChain"));
205  //chain3->AddAfter("eefs",eemcMixer);
206  chain3->AddAfter("eefs",eess);
207 
208  // Place Pythia maker after GEANT maker
209  // and trigger filter after EMC makers
210  gSystem->Load("StJetSkimEvent");
211  gSystem->Load("StBfcTriggerFilterMaker");
212 
214  TString pyfile = gSystem->BaseName(fzdfile);
215  pyfile.ReplaceAll(".fzd",".pythia.root");
216  pythia->SetPythiaFile(pyfile);
217  chain3->AddAfter("geant",pythia);
218 
219  // Place trigger simulator after EMC makers
220  gSystem->Load("StTriggerUtilities");
222  trgsim->setMC(1);
223  // BBC was not used in Run 9 jet triggers
224  //trgsim->useBbc();
225  //trgsim->bbc->setSource("StEvent");
226  trgsim->useBemc();
227  trgsim->bemc->setConfig(StBemcTriggerSimu::kOnline);
228  trgsim->useEemc();
229  trgsim->eemc->setSource("StEvent");
230 
231  trgsim->bemc->setBarrelJetPatchTh0(19);
232  trgsim->bemc->setBarrelJetPatchTh1(26);
233  trgsim->bemc->setBarrelJetPatchTh2(34);
234 
235  trgsim->emc->setOverlapJetPatchTh0(18);
236  trgsim->emc->setOverlapJetPatchTh1(25);
237  trgsim->emc->setOverlapJetPatchTh2(33);
238 
239  trgsim->eemc->setEndcapJetPatchTh0(17);
240  trgsim->eemc->setEndcapJetPatchTh1(24);
241  trgsim->eemc->setEndcapJetPatchTh2(31);
242 
243  trgsim->bemc->setBarrelHighTowerTh0(11);
244  trgsim->bemc->setBarrelHighTowerTh1(15);
245  trgsim->bemc->setBarrelHighTowerTh2(18);
246  trgsim->bemc->setBarrelHighTowerTh3(24);
247 
248  trgsim->eemc->setEndcapHighTowerTh0(16);
249  trgsim->eemc->setEndcapHighTowerTh1(25);
250 
252  // The BFC trigger filter will select only JP1, AJP and BHT3 events
253  trgfilt->SetJP1();
254  trgfilt->SetAJP();
255  trgfilt->SetBHT3();
256  // Lower all jet patch thresholds by one unit from
257  // their values obtained from the database using
258  // the current timestamp.
259  //trgfilt->changeJPThresh(-1);
260  chain3->AddBefore("tpcChain",trgsim);
261  chain3->AddBefore("tpcChain",trgfilt);
262 #if 0
263  //--------------------------------------------------------------------------
264  {
265  TDatime t;
266  gMessMgr->QAInfo() << Form("Run is started at Date/Time %i/%i",t.GetDate(),t.GetTime()) << endm;
267  }
268  gMessMgr->QAInfo() << Form("Run on %s in %s",gSystem->HostName(),gSystem->WorkingDirectory()) << endm;
269  gMessMgr->QAInfo() << Form("with %s", Chain->GetCVS()) << endm;
270 
271  TAttr::SetDebug(0);
272  Chain->SetAttr(".Privilege",0,"*" ); //All makers are NOT priviliged
273  Chain->SetAttr(".Privilege",1,"StBFChain::*" ); //StBFChain is priviliged
274  Chain->SetAttr(".Privilege",1,"StIOInterFace::*" ); //All IO makers are priviliged
275  Chain->SetAttr(".Privilege",1,"St_geant_Maker::*"); //It is also IO maker
276  //Chain->SetAttr(".Privilege",1,"StPrepEmbedMaker::*"); //It is also IO maker
277  // Chain->SetDEBUG(0);
278  if (Nevents < 0) return;
279  Int_t iInit = Chain->Init();
280  if (iInit >= kStEOF) {Chain->FatalErr(iInit,"on init"); return;}
281  StMaker *treeMk = Chain->GetMaker("outputStream");
282  cout << "Order of makers in BFCMIXER:" << endl;
283  StMaker::lsMakers(Chain);
284  Chain->EventLoop(Nevents,treeMk);
285  gMessMgr->QAInfo() << "Run completed " << endm;
286  gSystem->Exec("date");
287 #endif
288 #if 0
289  // Run chain
290  int istat = chain->Init();
291  if (istat) {
292  cout << "Chain initialization failed" << endl;
293  chain->Fatal(istat,"during Init()");
294  }
295  // Detailed listing of makers in the chain
296  //chain->ls(0);
297  cout << "Order of makers in BFC:" << endl;
298  StMaker::lsMakers(chain);
299  chain->EventLoop(Nevents);
300 #endif
301  TString trgfile = gSystem->BaseName(fzdfile);
302  trgfile.ReplaceAll(".fzd",".trig.root");
303  TFile* ofile = TFile::Open(trgfile,"recreate");
304  assert(ofile);
305  TH2F* hBarrelHighTowerSimu = new TH2F("hBarrelHighTowerSimu","BEMC high tower simu;trigger patch;high tower",300,0,300,64,0,64);
306  TH2F* hBarrelPatchSumSimu = new TH2F("hBarrelPatchSumSimu","BEMC patch sum simu;trigger patch;patch sum",300,0,300,64,0,64);
307  TH2F* hEndcapHighTowerSimu = new TH2F("hEndcapHighTowerSimu","EEMC high tower simu;trigger patch;high tower",90,0,90,64,0,64);
308  TH2F* hEndcapPatchSumSimu = new TH2F("hEndcapPatchSumSimu","EEMC patch sum simu;trigger patch;patch sum",90,0,90,64,0,64);
309  TH2F* hBarrelJetPatchSimu = new TH2F("hBarrelJetPatchSimu",";jet patch;adc",18,0,18,160,0,160);
310  TH2F* hEndcapJetPatchSimu = new TH2F("hEndcapJetPatchSimu",";jet patch;adc",6,0,6,160,0,160);
311  TH2F* hOverlapJetPatchSimu = new TH2F("hOverlapJetPatchSimu",";jet patch;adc",6,0,6,160,0,160);
312  // Initialize chain
313  Chain->Init();
314  cout << "Order of makers in BFCMIXER:" << endl;
315  StMaker::lsMakers(Chain);
316  // Event loop
317  for (int iEvent = 1; iEvent <= Nevents; ++iEvent) {
318  Chain->Clear();
319  int status = Chain->Make(iEvent);
320  if (status == kStSkip) continue;
321  if (status % 10 == kStEOF || status % 10 == kStFatal) break;
322  // BEMC high towers and trigger patches
323  for (int triggerpatch = 0; triggerpatch < 300; ++triggerpatch) {
324  hBarrelHighTowerSimu->Fill(triggerpatch,trgsim->bemc->getBEMC_FEE_HT_ADC()[triggerpatch]);
325  hBarrelPatchSumSimu->Fill(triggerpatch,trgsim->bemc->getBEMC_FEE_TP_ADC()[triggerpatch]);
326  } // for triggerpatch
327  // BEMC jet patches
328  for (int jetpatch = 0; jetpatch < 18; ++jetpatch) {
329  hBarrelJetPatchSimu->Fill(jetpatch,trgsim->bemc->barrelJetPatchAdc(jetpatch));
330  } // for jetpatch
331  // EEMC high towers and trigger patches
332  for (int triggerpatch = 0; triggerpatch < 90; ++triggerpatch) {
333  hEndcapHighTowerSimu->Fill(triggerpatch,trgsim->eemc->getOutHT(triggerpatch));
334  hEndcapPatchSumSimu->Fill(triggerpatch,trgsim->eemc->getOutTPsum(triggerpatch));
335  } // for triggerpatch
336  // EEMC jet patches
337  for (int jetpatch = 0; jetpatch < 6; ++jetpatch) {
338  hEndcapJetPatchSimu->Fill(jetpatch,trgsim->eemc->endcapJetPatchAdc(jetpatch));
339  } // for jetpatch
340  // BEMC-EEMC-overlap jet patches
341  for (int i = 0; i < 2; ++i) {
342  int jetpatch, adc;
343  trgsim->emc->getOverlapJetPatchAdc(i,jetpatch,adc);
344  hOverlapJetPatchSimu->Fill(jetpatch,adc);
345  } // for i
346  } // for iEvent
347  ofile->Write();
348  ofile->Close();
349 }
void setAddPed(Bool_t a=true)
Add pedestal offsets from DB.
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:49
void setOverwrite(Bool_t o=true)
Overwrite the muDst values.
Definition: Stypes.h:43
virtual Int_t Make()
Definition: StChain.cxx:110
void setDropBad(Bool_t d=true)
Drop bad channels marked as &quot;fail&quot; in DB.
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;.
void setSmearPed(Bool_t s=true)
Smear the pedestal with sigma from DB.
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.
void setSource(const Char_t *name)
Set the source of ADC. Can be &quot;MuDst&quot; (default) or &quot;StEvent&quot;.