StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
bfcMixer_Hft.C
1 //_____________________________________________________________________
2 class StChain;
3 StChain *Chain=0;
4 class StBFChain;
5 StBFChain *chain1, *chain2, *chain3;
6 //_____________________________________________________________________
7 void bfcMixer_Hft(Int_t Nevents=1 ,
8  const Char_t *daqfile="/star/data100/GRID/daq/2014/st_zerobias_adc_15167009_raw_0000011.daq",
9  const Char_t *tagfile="/star/data100/GRID/daq/2014/st_physics_adc_15167009_raw_1000012.tags.root",
10  Double_t pt_low=0.1,
11  Double_t pt_high=10.0,
12  Double_t eta_low=-1.5,
13  Double_t eta_high=1.5,
14  Double_t vzlow = -150.0,
15  Double_t vzhigh = 150.0,
16  Double_t vr = 100.0,
17  Int_t pid=9,
18  Double_t mult=100,
19  std::vector<Int_t> triggers = 0,
20  const Char_t *prodName = "P16idAuAu200hftZB",
21  const Char_t* type = "FlatPt",
22  const bool bPythia = true,
23  const Char_t *fzdfile="test_full_field_pos.fzd"
24  ){
25 
26  // Run14 AuAu 200 st_physics chain (P15ic) w/ HFT tracking, StiCA, ...
27  // TString prodP15icAuAu200hft ( "DbV20150316 P2014a PxlHit IstHit btof mtd mtdCalib BEmcChkStat CorrX OSpaceZ2 OGridLeak3D -hitfilt -vfminuit vfmce tpxclu pxlslowsim istslowsim nosvtit nossdit picoWrite PicoVtxDefault"); // pxlslowsim istslowsi // DbV20150316 P2014a pxlHit istHit btof mtd mtdCalib BEmcChkStat CorrX OSpaceZ2 OGridLeak3D -hitfilt
28  TString prodP16idAuAu200hft ( "DbV20160418 P2014a pxlHit istHit btof mtd mtdCalib BEmcChkStat CorrX OSpaceZ2 OGridLeak3D ODistoSmear -hitfilt -vfminuit vfmce tpxclu pxlslowsim istslowsim nosvtit nossdit" ); // picoWrite PicoVtxDefault DbV20150316 P2014a pxlHit istHit btof mtd mtdCalib BEmcChkStat CorrX OSpaceZ2 OGridLeak3D -hitfilt
29  //TString prodP16idAuAu200hft ( "DbV20160418 P2014a pxlHit istHit btof mtd mtdCalib BEmcChkStat CorrX OSpaceZ2 OGridLeak3D ODistoSmear -hitfilt -vfminuit vfmce tpxclu pxlslowsim istslowsim nosvtit nossdit" ); // picoWrite PicoVtxDefault DbV20150316 P2014a pxlHit istHit btof mtd mtdCalib BEmcChkStat CorrX OSpaceZ2 OGridLeak3D -hitfilt
30  TString prodP16idAuAu200hftZB( "DbV20160418 P2014a pxlHit istHit btof mtd mtdCalib BEmcChkStat CorrX OSpaceZ2 OGridLeak3D ODistoSmear -hitfilt vfminuit -vfmce tpxclu pxlslowsim istslowsim nosvtit nossdit" ); // picoWrite PicoVtxDefault DbV20150316 P2014a pxlHit istHit btof mtd mtdCalib BEmcChkStat CorrX OSpaceZ2 OGridLeak3D -hitfilt
31  //$$$TString prodP15icAuAu200hft ( "DbV20150316 P2014a PxlHit IstHit btof mtd mtdCalib BEmcChkStat CorrX OSpaceZ2 OGridLeak3D -hitfilt -vfminuit vfmce tpxclu pxlslowsim istslowsim nosvtit nossdit "); // pxlslowsim istslowsi // DbV20150316 P2014a pxlHit istHit btof mtd mtdCalib BEmcChkStat CorrX OSpaceZ2 OGridLeak3D -hitfilt
32 
33  // Run 16 AuAu200 HFT chain
34  TString prodP16ijAuAu200hft ( "DbV20161018 P2016a StiCA mtd mtdCalib btof PxlHit IstHit BEmcChkStat CorrX OSpaceZ2 OGridLeak3D ODistoSmear -hitfilt -vfminuit vfmce tpxclu pxlslowsim istslowsim nosvtit nossdit "); // remove sstHits picoWrite PicoVtxDefault
35  TString prodP16ijAuAu200hftZB( "DbV20161018 P2016a StiCA mtd mtdCalib btof PxlHit IstHit BEmcChkStat CorrX OSpaceZ2 OGridLeak3D ODistoSmear -hitfilt vfminuit -vfmce tpxclu pxlslowsim istslowsim nosvtit nossdit "); // remove sstHits picoWrite PicoVtxDefault
36 
37  // Run 16 dAu200 HFT chain
38  TString prodP17iddAu200hft ( "DbV20161216 P2016a StiCA mtd mtdCalib btof PxlHit IstHit BEmcChkStat CorrX OSpaceZ2 OGridLeak3D ODistoSmear -hitfilt -vfminuit vfmce tpxclu pxlslowsim istslowsim nosvtit nossdit "); // remove sstHits picoWrite PicoVtxDefault
39 
40  // Run 16 dAu62 HFT chain
41  TString prodP17iddAu62hft ( "DbV20170426 P2016a StiCA mtd mtdCalib btof PxlHit IstHit BEmcChkStat CorrX OSpaceZ2 OGridLeak3D ODistoSmear -hitfilt -vfminuit vfmce tpxclu pxlslowsim istslowsim nosvtit nossdit "); // remove sstHits picoWrite PicoVtxDefault
42 
43  //TString geomP16ij("ry2016x"); // little hack... sets y2016x as the chain2 geometry... loaded by geant... thinking this might be needed to get the geant reader correct...
44  TString geomP16ij("ry2016x"); // this is consistent with chain option... but may cause problem with geant reader...
45  TString geomP16id("ry2014x"); // this is consistent with chain option... but may cause problem with geant reader...
46  TString geomP17id("ry2016x"); // this is consistent with chain option... but may cause problem with geant reader...
47 
48  TString chain1Opt(" in magF tpcDb NoDefault TpxRaw -ittf NoOutput"); // chain1 reads event from daq file
49  TString chain2Opt(" gen_T geomT sim_T TpcRS -ittf -tpc_daq nodefault"); // chain2 runs simu or reads from mc file
50  TString chain3Opt(""); // chain3 runs event reconstruction and mixing
51 
52  if(bPythia){ chain2Opt += ",fzin bigbig "; }
53  else { chain2Opt += ",NoInput,PrepEmbed "; }
54 
55  if (prodName == "P16idAuAu200hft"){
56  chain2Opt += geomP16id; // done in analogy to P16ijAuAu200hft... need to understand "little hack" above...
57  chain3Opt += prodP16idAuAu200hft; // nix chain3Opt += " btofSim -vpdSim btofMixer ";
58  }
59  else if (prodName == "P16idAuAu200hftZB"){
60  chain2Opt += geomP16id; // done in analogy to P16ijAuAu200hft... need to understand "little hack" above...
61  chain3Opt += prodP16idAuAu200hftZB; // nix chain3Opt += " btofSim -vpdSim btofMixer ";
62  }
63  else if (prodName == "P16ijAuAu200hft" ) {
64  chain2Opt += geomP16ij;
65  chain3Opt += prodP16ijAuAu200hft; //chain3Opt += " btofSim vpdSim btofMixer ";
66  }
67  else if (prodName == "P16ijAuAu200hftZB" ) {
68  chain2Opt += geomP16ij;
69  chain3Opt += prodP16ijAuAu200hftZB; // nix chain3Opt += " btofSim -vpdSim btofMixer StiPulls ";
70  }
71  else if (prodName == "P17iddAu200hft" ) {
72  chain2Opt += geomP17id;
73  chain3Opt += prodP17iddAu200hft; //chain3Opt += " btofSim vpdSim btofMixer ";
74  }
75  else if (prodName == "P17iddAu62hft" ) {
76  chain2Opt += geomP17id;
77  chain3Opt += prodP17iddAu62hft; //chain3Opt += " btofSim vpdSim btofMixer ";
78  }
79 
80  else {
81  cout << "Choice prodName " << prodName << " does not correspond to known chain. Processing impossible. " << endl;
82  return;
83  }
84  chain3Opt += ",TpcMixer,GeantOut,MiniMcMk,McAna,-in,NoInput,useInTracker";
85  chain3Opt += ",mcevout";
86 
87  // Dynamically link some shared libs
88  gROOT->LoadMacro("bfc.C");
89  if (gClassTable->GetID("StBFChain") < 0) Load();
90  //______________Create the main chain object______________________________________
91  Chain = new StChain("Embedding");
92  //________________________________________________________________________________
93  bfc(-1,chain1Opt,daqfile);
94  chain1 = chain;
95  chain1->SetName("One");
96  Chain->cd();
97  //________________________________________________________________________________
98  if(bPythia){
99  bfc(-1,chain2Opt,fzdfile);
100  chain2 = chain;
101  chain2->SetName("Two");
102  Chain->cd();
103  if (chain2->GetOption("TRS")){
104  StTrsMaker *trsMk = (StTrsMaker *) chain2->GetMaker("Trs");
105  if (! trsMk) {
106  cout << "Cannot find Trs in chain2" << endl;
107  return;
108  }
109  trsMk->setNormalFactor(1.32);
110  }
111  }
112  else {
113  bfc(-1,chain2Opt);
114  chain2 = chain;
115  chain2->SetName("Two");
116  Chain->cd();
117  }
118 
119 
120 #if 0
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 #endif
131  //________________________________________________________________________________
132  // gSystem->Load("StFtpcMixerMaker");
133  // StFtpcMixerMaker *ftpcmixer = new StFtpcMixerMaker("FtpcMixer","daq","trs");
134  //________________________________________________________________________________
135  TString OutputFileName(gSystem->BaseName(daqfile)); {
136  OutputFileName.ReplaceAll("*","");
137  OutputFileName.ReplaceAll(".daq","");
138  // OutputFileName.Append("_emb.root");
139  OutputFileName.Append(".root");
140  }
141  bfc(-1,chain3Opt,0,OutputFileName);
142  chain3 = chain;
143  chain3->SetName("Three");
144  Chain->cd();
145  //________________________________________________________________________________
146  StTpcMixerMaker *mixer = (StTpcMixerMaker *) chain3->Maker("TpcMixer");
147  if( prodName == "P08icAuAu200")
148  {
149  mixer->SetInput("Input1","MixerEvent");
150  }
151  else
152  {
153  mixer->SetInput("Input1","TpxRaw/.data/Event");
154  }
155 
156  if (chain2Opt.Contains("TpcRS",TString::kIgnoreCase)) {
157  mixer->SetInput("Input2","TpcRS/Event");
158  } else {
159  mixer->SetInput("Input2","Trs/.const/Event");
160  }
161  Chain->cd();
162 
164  //
165  //
166  // IST Slow Simulator setup
167  //
168  //
170  StIstRawHitMaker *istRawHitMaker = (StIstRawHitMaker *)chain3->GetMaker("ist_raw_hit");
171  istRawHitMaker->setDataType(1); // no-zs data
172  istRawHitMaker->setDoEmbedding(kTRUE);
173 
174  //
175  // Verbose printout for position
176  //
177  //AgPosition::SetDebug(2);
178 
179 
180  //............. begin of EMC embedding makers................
181 
182  //.............. Add BEmc stuff here ....................
183  gSystem->Load("StEmcSimulatorMaker");
184  gSystem->Load("StEmcMixerMaker");
185  gSystem->Load("StEEmcSimulatorMaker");
186 
187  StMcEventMaker* mcEventMaker = new StMcEventMaker();
188  StEmcSimulatorMaker *bemcSim = new StEmcSimulatorMaker();
189  StEmcMixerMaker *bemcMixer = new StEmcMixerMaker();
190  chain3->AddAfter("emcRaw",bemcMixer);
191  chain3->AddAfter("emcRaw",bemcSim);
192  chain3->AddAfter("emcRaw",mcEventMaker);
193  bemcMixer->SetDebug(0); // set it to 1 for more printouts
194  // note, Barrel slow sim is always ON, said Adam
195 
196  //........... Add EEmc Stuff ( Simu, and Mixer) here ..............
197  StEEmcFastMaker *eemcFastSim = new StEEmcFastMaker();
198  StEEmcMixerMaker *eemcMixer = new StEEmcMixerMaker();
199 
200  /* position B+E EMC makers in the chain
201  (order is reverse because 'After' is used - looks funny but is right)
202  */
203  chain3->AddAfter("emcRaw",eemcMixer);
204  chain3->AddAfter("emcRaw",eemcFastSim);
205 
206  eemcFastSim->SetEmbeddingMode(); // eemcFastSim->SetDebug(); // eemcMixer->SetDebug();
207 
208  bool useEndcapSlowSim = true; if(useEndcapSlowSim) { // turn Endcap slow simu On/Off
209  StEEmcSlowMaker *slowSim=new StEEmcSlowMaker();
210  chain3->AddAfter("EEmcFastSim",slowSim);
211  slowSim->setEmbeddingMode();
212  }
213 
214 
215 
216  //________________________________________________________________________________
217  {
218  TDatime t;
219  gMessMgr->QAInfo() << Form("Run is started at Date/Time %i/%i",t.GetDate(),t.GetTime()) << endm;
220  }
221  gMessMgr->QAInfo() << Form("Run on %s in %s",gSystem->HostName(),gSystem->WorkingDirectory()) << endm;
222  gMessMgr->QAInfo() << Form("with %s", Chain->GetCVS()) << endm;
223 
224  // embedded particle set
225  if(!bPythia){
226  StPrepEmbedMaker *embMk = (StPrepEmbedMaker *) Chain->Maker("PrepEmbed");
227  if (! embMk) return;
228  cout << "bfcMixer: Setting PID: "<<pid<<endl;
229  embMk->SetTagFile(tagfile);
230  // pTlow,ptHigh,etaLow,etaHigh,phiLow,phiHigh
231  embMk->SetOpt( pt_low, pt_high, eta_low, eta_high, 0., 6.283185, type);
232  // pid, mult
233  embMk->SetPartOpt( pid,mult);
234 
235  // Default is no event selections
236  embMk->SetSkipMode(kTRUE);
237 
238  embMk->SetTemp(0.35);
239 
240  //embMk->SetRapidityMode(kFALSE); //default is 'kTRUE'
241 
242  //Switch to prime mode for nucleus (with geantID > 10000) embedding, default is 'kFALSE'
243  //embMk->SetPrimeMode(kTRUE);
244 
245  // Make trigger and z-vertex cuts (only if SkipMode is true)
246  // Trigger cut
247  // Can put multiple trigger id's
248  if ( !triggers.empty() ){
249  for(std::vector<Int_t>::iterator iter = triggers.begin(); iter != triggers.end(); iter++){
250  embMk->SetTrgOpt((*iter)) ;
251  }
252  }
253  // z-vertex cuts
254  embMk->SetZVertexCut(vzlow, vzhigh) ;
255  // vr = sqrt{vx^2 + vy^2} cut
256  embMk->SetVrCut(vr);
257 
258  //cut on VpdVz, need moretags.root
259  //embMk->SetVpdVzCutMode(kTRUE);
260  //embMk->SetVpdVzCut(3);
261 
262  //cut on PVranking, need moretags.root
263  //embMk->SetPVRankCutMode(kTRUE);
264  //embMk->SetPVRankCut(0); // pvrank > 0
265 
266  }
267 
268 #if 1
269  TString checkProdName( prodName );
270  if ( checkProdName == "P16idAuAu200hft" || checkProdName == "P16ijAuAu200hft" || checkProdName == "P17iddAu200hft") {
271  //________________________________________________________________________________
272  // Setup StarEmbedMaker
273  gSystem->Load( "StarGeneratorUtil.so" );
274  gSystem->Load( "StarGeneratorEvent.so" );
275  gSystem->Load( "StarGeneratorBase.so" );
276  gSystem->Load( "StarGeneratorEmbed.so" );
277  StarEmbedMaker* mk = new StarEmbedMaker();
278  mk->SetFileName( "starembed.genevt.root" );
279  mk->SetInputFile( tagfile );
280  chain2 -> AddBefore( "geant", mk );
281  //________________________________________________________________________________
282  }
283 #endif
284 
285  TAttr::SetDebug(0);
286  Chain->SetAttr(".Privilege",0,"*" ); //All makers are NOT priviliged
287  Chain->SetAttr(".Privilege",1,"StBFChain::*" ); //StBFChain is priviliged
288  Chain->SetAttr(".Privilege",1,"StIOInterFace::*" ); //All IO makers are priviliged
289  Chain->SetAttr(".Privilege",1,"St_geant_Maker::*"); //It is also IO maker
290  if(!bPythia)Chain->SetAttr(".Privilege",1,"StPrepEmbedMaker::*"); //It is also IO maker
291  // Chain->SetDEBUG(0);
292 
293  if (Nevents < 0) return;
294 
295  Int_t iInit = Chain->Init();
296  if (iInit >= kStEOF) {Chain->FatalErr(iInit,"on init"); return;}
297  StMaker *treeMk = Chain->GetMaker("outputStream");
298 
299  //
300  // File splitting from SUMS... skip events along the daq chain...
301  //
302  TString START(gSystem->Getenv("EVENTS_START"));
303  if ( START != "" ) {
304  int nskip = START.Atoi();
305 if (nskip>0) {
306  gMessMgr->QAInfo() << "SUMS is splitting this file" << endm;
307  gMessMgr->QAInfo() << "EVENTS_START = " << nskip << endm;
308  chain1->Skip(nskip-1);
309  gMessMgr->QAInfo() << "... chain 1 has been advanced... allons y" << endm;
310 }
311  }
312 
313  Chain->EventLoop(Nevents,treeMk);
314 
315  gMessMgr->QAInfo() << "Run completed " << endm;
316  gSystem->Exec("date");
317 
318 }
319 //________________________________________________________________________________
320 void bfcMixer_Hft(Int_t Nevents, const Char_t *daqfile, Char_t *tagfile,
321  Double_t pt_low, Double_t pt_high, Double_t eta_low, Double_t eta_high,
322  Double_t vzlow, Double_t vzhigh, Double_t vr, Int_t pid, Double_t mult,
323  const Char_t *triggersC, const Char_t *prodName, const Char_t* type) {
324  std::vector<Int_t> triggers;
325  if (triggersC) {
326  TPMERegexp pm(":");
327  Int_t N = pm.Split(triggersC);
328  for (Int_t i = 0; i < N; i++) {
329  TString num(pm[i]);
330  triggers.push_back(num.Atoi());
331  }
332  }
333  bfcMixer_Hft(Nevents, daqfile, tagfile, pt_low, pt_high, eta_low, eta_high, vzlow, vzhigh, vr, pid, mult, triggers, prodName, type);
334 }
336 //
337 // Macro for running chain with different inputs
338 //
339 // Owner: Yuri Fisyak
340 //
341 // $Id: bfcMixer_Hft.C,v 1.2 2020/01/22 15:02:56 starembd Exp $
342 //
343 // $Log: bfcMixer_Hft.C,v $
344 // Revision 1.2 2020/01/22 15:02:56 starembd
345 // added options for Run16 dAu200 and dAu62 HFT embedding
346 //
347 // Revision 1.1 2018/09/26 05:21:16 zhux
348 // initial version from Jason Webb
349 //
350 // Revision 1.1 2018/07/06 17:32:32 jwebb
351 //
352 // Committing SUMS workflow and ROOT macros used in the QM2018 hft embedding
353 // productions.
354 //
Prepare GEANT Maker with input from embedding settings and DAQ event.
void SetFileName(const Char_t *name)
Set the filename of the output TTree.
void setDataType(int nDataType=0)
0 - All data; 1 - non-ZS data; 2 - ZS data; 3 - ZS first data
Filling of all StMcEvent classes from g2t tables Transform all the data in the g2t tables into the co...
Definition: Stypes.h:43
void SetOpt(const Double_t ptlow, const Double_t pthigh, const Double_t etalow, const Double_t etahigh, const Double_t philow, const Double_t phihigh, const TString type="FlatPt")
Set geantid(pid) and multiplicity.
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.