StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
TpcRS.C
1 #if !defined(__CINT__) && !defined(__CLING__)
2 #include "Riostream.h"
3 #include "TROOT.h"
4 #include "TSystem.h"
5 #include "TH2.h"
6 #include "TH3.h"
7 #include "TF1.h"
8 #include "TProfile.h"
9 #include "TString.h"
10 #include "TTree.h"
11 #include "TChain.h"
12 #include "TCanvas.h"
13 #include "TClassTable.h"
14 #include "TFileSet.h"
15 #include "TDataSetIter.h"
16 #include "StBFChain.h"
17 void bfc (const Int_t Last,
18  const Char_t *Chain,
19  const Char_t *infile,
20  const Char_t *outfile,
21  const Char_t *TreeFile);
22 //R__EXTERN StBFChain *chain;
23 #else
24 #define SETBIT(n,i) ((n) |= (1 << i))
25 #define CLRBIT(n,i) ((n) &= ~(1 << i))
26 class StBFChain;
27 StBFChain *chain;
28 class St_db_Maker;
29 St_db_Maker *dbMk = 0;
30 #endif
31 //________________________________________________________________________________
32 void TpcRS(Int_t First, Int_t Last, const Char_t *Run = "y2011,TpcRS",
33  const Char_t *fileIn = 0, const Char_t *opt = "Bichsel", const Char_t *kuip = 0,
34  const Char_t *fileOut = 0) {
35  gROOT->LoadMacro("bfc.C");
36  TString ChainOpt("");
37  TString RootFile(fileOut);
38  TString Opt(opt);
39  TString RunOpt(Run);
40  // RunOpt.ToLower();
41  //ChainOpt = "MakeEvent,ITTF,ForceGeometry,NoSsdIt,NoSvtIt,Idst,VFMinuit,analysis,dEdxY2,";
42  if (RunOpt.Contains("y2005",TString::kIgnoreCase)) {
43  // ChainOpt = "ry2005b,in,tpcI,svt_daq,SvtD,Physics,Idst,l0,tags,Tree,evout,ssdDb,IAna,fcf,VFMinuit,emcDY2,";
44  ChainOpt = "ry2005b,in,tpcI,Physics,Idst,l0,tags,Tree,evout,IAna,fcf,VFMinuit,emcDY2,";
45  ChainOpt+= "ftpc,trgd,ZDCvtx,Corr3,DbV20060421,useCDV,ITTF,tofDat,NosstIT,NosvtIT,SCEbyE,OGridLeak,OShortR,OSpaceZ2,TpxClu,TpxRaw";//-VFMinuit,";
46  ChainOpt+= ",useInTracker";
47  ChainOpt += ",McTpcAna,";
48  } else if ( RunOpt.Contains("RC.y",TString::kIgnoreCase) ||
49  RunOpt.Contains("MC.y",TString::kIgnoreCase)) {
50  ChainOpt = RunOpt;
51  ChainOpt += ",MakeEvent,ITTF,NoSsdIt,NoSvtIt,Idst,VFMinuit,analysis,dEdxY2";
52  // ChainOpt += "Corr4";// no dynamical distortion ! ,OSpaceZ2,OGridLeak3D,"; // check that StTpcRSMaker::kDistortion bit is set
53  // ChainOpt += "EvOut,MuDST,MiniMcMk,McTpcAna,IdTruth,useInTracker,-hitfilt,";
54  // ChainOpt += ",CMuDst,MiniMcMk,IdTruth,useInTracker,tree,";
55  // ChainOpt += ",CMuDst,McAna,IdTruth,useInTracker,tree,KFVertex,xgeometry,";
56  ChainOpt += ",CMuDst,IdTruth,useInTracker,tree,StiKFVertex,xgeometry,";
57  ChainOpt += "bbcSim,btofsim,btofMatch,btofCalib,";
58  ChainOpt += "EvOut,-hitfilt,";
59  ChainOpt += "McTpcAna,";
60  // ChainOpt += ",tree,";
61 #if 1
62  if (TString(gSystem->Getenv("STAR_VERSION")) == ".DEV2" ||
63  TString(gSystem->Getenv("STAR_VERSION")) == "SL11d_embed") ChainOpt += "NoHistos,NoRunco,noTags,";
64  else ChainOpt += "tags,";
65 #endif
66  }
67  // ChainOpt += "MiniMcMk,IdTruth,useInTracker,-hitfilt,CMuDst,Tree,tags,evout,";
68  if (RunOpt.Contains("fcf",TString::kIgnoreCase)) {
69  ChainOpt += "tpl,tpcI,";
70  RunOpt.ReplaceAll("TpcRS,","");
71  RunOpt.ReplaceAll("trs,","");
72  } else {
73  ChainOpt += ",tpcDB,TpcHitMover,TpxClu,";
74  }
75  // Bool_t needAlias = kFALSE;
76  TString FileIn(fileIn);
77  if (FileIn == "" && fileOut == 0) {
78  if (RunOpt.Contains("pythia",TString::kIgnoreCase)) {
79  RootFile += "pythia";
80  } else if (RunOpt.Contains("hijing",TString::kIgnoreCase)) {
81  RootFile += "hijing";
82  } else {
83  ChainOpt += "gstar,"; RootFile += "gstar";
84  }
85  if (RunOpt.Contains("hadr_of",TString::kIgnoreCase) ||
86  Opt.Contains("hadr_of",TString::kIgnoreCase)) ChainOpt += "hadr_off,";
87  if (RunOpt.Contains("phys_of",TString::kIgnoreCase) ||
88  Opt.Contains("phys_of",TString::kIgnoreCase)) ChainOpt += "phys_off,";
89  if (RunOpt.Contains("PhysicsOff",TString::kIgnoreCase) ||
90  Opt.Contains("PhysicsOff",TString::kIgnoreCase)) ChainOpt += "phys_off,";
91  if (Opt.Contains("FieldOff" ,TString::kIgnoreCase)) ChainOpt += "FieldOff,";
92  else if (Opt.Contains("HalfField",TString::kIgnoreCase)) ChainOpt += "HalfField,";
93  else ChainOpt += "FieldOn,";
94  } else {
95  RootFile += Form("%s",gSystem->BaseName(FileIn.Data()));
96  if (FileIn.Contains(".daq",TString::kIgnoreCase)) {
97  ChainOpt += "in,TpxRaw,";
98  RootFile.ReplaceAll(".daq","");
99  } else if (FileIn.Contains(".fz",TString::kIgnoreCase)) {
100  ChainOpt += "fzin,";
101  RootFile.ReplaceAll(".fzd","");
102  RootFile.ReplaceAll(".fz","");
103  } else if (FileIn.Contains(".nt",TString::kIgnoreCase)) {
104  ChainOpt += "ntin,";
105  RootFile.ReplaceAll(".nt","");
106  RootFile.ReplaceAll(".","_");
107  } else if (FileIn.Contains(".geant.root",TString::kIgnoreCase)) {
108  ChainOpt += "in,";
109  RootFile.ReplaceAll(".geant.root","");
110  } else if (FileIn.Contains(".MuDst",TString::kIgnoreCase)) {
111  ChainOpt += "mtin,";
112  RootFile.ReplaceAll(".MuDst.root","");
113  } else {
114  if (gSystem->AccessPathName(FileIn.Data())) FileIn ="";
115  }
116  }
117  ChainOpt += RunOpt;
118  RootFile += Form("_%s_%i_%i",Opt.Data(),First,Last);
119  RootFile.ReplaceAll(".root","");
120  RootFile.ReplaceAll(",","_");
121  if (RootFile.Contains(";")) {
122  Int_t index = RootFile.Index(";");
123  RootFile = RootFile(0,index);
124  }
125  RootFile += ".root";
126  RootFile.ReplaceAll(" ","");
127  cout << "ChainOpt : " << ChainOpt.Data() << "\tOuput file " << RootFile.Data() << endl;
128  if (Last < 0) {
129  bfc(-1,ChainOpt.Data(),0,0,0);
130  return;
131  }
132 
133  TString output = RootFile;
134  output = RootFile;
135  output.ReplaceAll(".root","O.root");
136  output.ReplaceAll("*","");
137  if (RunOpt.Contains("devT,",TString::kIgnoreCase)) ChainOpt += ",useXgeom";
138  bfc(-1,ChainOpt.Data(),fileIn,output.Data(),RootFile.Data());
139  if (ChainOpt.Contains("TpcRS",TString::kIgnoreCase)) {
140  StTpcRSMaker *tpcRS = (StTpcRSMaker *) chain->Maker("TpcRS");
141  if (tpcRS) {
142  // if (needAlias) tpcRS->SetInput("geant","bfc/.make/inputStream/.make/inputStream_Root/.data/bfcTree/geantBranch");
143  Int_t m_Mode = tpcRS->GetMode();
144  if (Opt.Contains("heed",TString::kIgnoreCase)) {SETBIT(m_Mode,StTpcRSMaker::kHEED); CLRBIT(m_Mode,StTpcRSMaker::kBICHSEL);}
145  if (Opt.Contains("bichsel",TString::kIgnoreCase)) {SETBIT(m_Mode,StTpcRSMaker::kBICHSEL); CLRBIT(m_Mode,StTpcRSMaker::kHEED);}
146  if (! ChainOpt.Contains("Corr",TString::kIgnoreCase)) {CLRBIT(m_Mode,StTpcRSMaker::kDistortion);} // Check that distorton are IN chain
147  tpcRS->SetMode(m_Mode);
148  // tpcRS->SetDebug(13);
149  }
150  }
151  else {
152  if (ChainOpt.Contains("trs",TString::kIgnoreCase)) {
153  StMaker *mk = chain->Maker("tpcDB"); // simulation mode
154  if (! mk) return;
155  mk->SetMode(1);
156  }
157  }
158 #if 0 /* not enough memory for dE/dx plots */
159  StMaker *dEdxY2 = chain->GetMaker("dEdxY2");
160  if (dEdxY2) {
161  StdEdxY2Maker *dEdx = (StdEdxY2Maker *) dEdxY2;
162  Int_t mask = 0;
163 #if 0
164  // SETBIT(mask,StTpcdEdxCorrection::ktpcPressure);
165  // SETBIT(mask,StTpcdEdxCorrection::kAdcCorrection);
166  // SETBIT(mask,StTpcdEdxCorrection::kTpcSecRow);
167  // SETBIT(mask,StTpcdEdxCorrection::kDrift);
168  // SETBIT(mask,StTpcdEdxCorrection::kzCorrection);
169  // SETBIT(mask,StTpcdEdxCorrection::kdXCorrection);
170  // SETBIT(mask,StTpcdEdxCorrection::kTpcdEdxCor);
171  // SETBIT(mask,StTpcdEdxCorrection::kTpcLengthCorrection);
172  // from dEdx 06/20/04
173  SETBIT(mask,StTpcdEdxCorrection::ktpcPressure);
174  // SETBIT(mask,StTpcdEdxCorrection::ktpcMethaneIn);
175  // SETBIT(mask,StTpcdEdxCorrection::ktpcGasTemperature);
176  // SETBIT(mask,StTpcdEdxCorrection::ktpcWaterOut);
177  SETBIT(mask,StTpcdEdxCorrection::kAdcCorrection);
178  SETBIT(mask,StTpcdEdxCorrection::kTpcSecRow);
179  SETBIT(mask,StTpcdEdxCorrection::kDrift);
180  SETBIT(mask,StTpcdEdxCorrection::kzCorrection);
181  SETBIT(mask,StTpcdEdxCorrection::kdXCorrection);
182  // SETBIT(mask,StTpcdEdxCorrection::kTpcdEdxCor);
183  // SETBIT(mask,StTpcdEdxCorrection::kTpcLengthCorrection);
184  SETBIT(mask,StTpcdEdxCorrection::kAdcCorrection);
185  SETBIT(mask,StTpcdEdxCorrection::kTpcLast);
186  // SETBIT(Mode,StdEdxY2Maker::kOldClusterFinder);
187  // SETBIT(Mode,StdEdxY2Maker::kDoNotCorrectdEdx);
188 
189  SETBIT(Mode,StdEdxY2Maker::kPadSelection);
190  SETBIT(Mode,StdEdxY2Maker::kCalibration);
191  // if (TString(gSystem->Getenv("STAR_VERSION")) == ".DEV2")
192  SETBIT(Mode,StdEdxY2Maker::kZBGX);
193  SETBIT(Mode,StdEdxY2Maker::kGASHISTOGRAMS);
194 #endif
195  Int_t Mode = 2;
196  if (Mode) {
197  dEdx->SetDebug(1);
198  cout << " set dEdxY2 Mode" << Mode << " =======================================" << endl;
199  dEdx->SetMode(Mode);
200  }
201  if (mask) {
202  cout << " set dEdxY2 mask " << mask << " =======================================" << endl;
203  dEdx->SetMask(mask);
204  }
205  }
206 #endif
207  if (Last < 0) return;
208  Int_t initStat = chain->Init(); // This should call the Init() method in ALL makers
209  if (initStat) {
210  cout << "Chain initiation has failed" << endl;
211  chain->Fatal(initStat, "during Init()");
212  }
213  if (gClassTable->GetID("TGiant3") >= 0) {
214  St_geant_Maker *geant = (St_geant_Maker *) chain->GetMakerInheritsFrom("St_geant_Maker");
215  // NTRACK ID PTLOW PTHIGH YLOW YHIGH PHILOW PHIHIGH ZLOW ZHIGH
216  // geant->Do("gkine 100 14 0.1 10. -1 1 0 6.28 0. 0.;");
217  cout << "Options: " << Opt.Data() << "=========================================================" << endl;
218  if (FileIn == "") {
219  if (kuip) {
220  TString Kuip(kuip);
221  geant->Do(kuip);
222  } else if ( RunOpt.Contains("Mickey",TString::kIgnoreCase)) {
223  } else if ( Opt.Contains("laser",TString::kIgnoreCase)) {
224  gSystem->Load("gstar.so");
225  geant->Do("call gstar");
226  geant->Do("gkine 1 170 1 1 0 0 0 0 180.00 180.00;");
227  geant->Do("gprint kine");
228  geant->Do("gvert 0 54 0");
229  geant->Do("mode TRAC prin 15");
230  } else if (TString(geant->SAttr("GeneratorFile")) == "") {
231  Int_t NTRACK = 100;
232  Int_t ID = 5;
233  Double_t Ylow = -1;
234  Double_t Yhigh = 1;
235  Double_t Philow = 0;
236  Double_t Phihigh= 2*TMath::Pi();
237  Double_t Zlow = -50;
238  Double_t Zhigh = 50;
239  Double_t mass = 0.1057;
240  Double_t bgMin = 1e-1; // 3.5;// 1e2; // 1e-2;
241  Double_t bgMax = 1e6; // 1e2;// 1e5;
242  Double_t pTmin = -1;
243  Double_t pTmax = -1;
244  if (Opt.Contains("muon",TString::kIgnoreCase)) {ID = 5;
245  if (Opt.Contains("muon-",TString::kIgnoreCase)) ID = 6;}
246  else if (Opt.Contains("electron",TString::kIgnoreCase)) {ID = 3; mass = 0.5110E-03;}
247  else if (Opt.Contains("positron",TString::kIgnoreCase)) {ID = 2; mass = 0.5110E-03;}
248  else if (Opt.Contains("pion",TString::kIgnoreCase)) {ID = 8; mass = 0.1396;
249  if (Opt.Contains("pion-",TString::kIgnoreCase)) ID = 9;}
250  else if (Opt.Contains("kaon",TString::kIgnoreCase)) {ID = 11; mass = 0.4937;
251  if (Opt.Contains("kaon-",TString::kIgnoreCase)) ID = 12;}
252  else if (Opt.Contains("proton",TString::kIgnoreCase)) {ID = 14; mass = 0.9383;
253  if (Opt.Contains("antiproton",TString::kIgnoreCase) ||
254  Opt.Contains("pbar",TString::kIgnoreCase)) ID = 15;}
255  else if (Opt.Contains("deuteron",TString::kIgnoreCase)) {ID = 45; mass = 1.876;}
256  else if (Opt.Contains("triton",TString::kIgnoreCase)) {ID = 46; mass = 2.80925;}
257  else if (Opt.Contains("He3",TString::kIgnoreCase)) {ID = 49; mass = 2.80925;}
258  else if (Opt.Contains("alpha",TString::kIgnoreCase)) {ID = 47; mass = 3.727;}
259  else if (Opt.Contains("phi",TString::kIgnoreCase)) {ID = 10151; mass = 1.0194; NTRACK = 1; pTmin = 0.010, pTmax = 2.000;}
260  if (Opt.Contains("MIP",TString::kIgnoreCase)) { pTmin = 0.2; pTmax = 0.5; bgMin = 3; bgMax = 5;}
261  if (Opt.Contains("MIP1",TString::kIgnoreCase)) {NTRACK = 5;pTmin = 0.2; pTmax = 0.5; bgMin = 3; bgMax = 5;}
262  if (Opt.Contains("1GeV",TString::kIgnoreCase)) {pTmin = pTmax = 1.0;}
263  if (Opt.Contains("0.5GeV",TString::kIgnoreCase)) {pTmin = pTmax = 0.5;}
264  if (Opt.Contains("50",TString::kIgnoreCase)) {NTRACK = 50;}
265  if (Opt.Contains("1000",TString::kIgnoreCase)) {NTRACK = 1000;}
266  if (Opt.Contains("1muon",TString::kIgnoreCase)) NTRACK = 1;
267  if (Opt.Contains("Single",TString::kIgnoreCase)) NTRACK = 1;
268  if (Opt.Contains("LamXi2430",TString::kIgnoreCase)) {NTRACK = 50; ID = 60002; pTmin = 0.1; pTmax = 10.0;}
269  if (RunOpt.Contains("gstarLib",TString::kIgnoreCase)) {geant->Do("call gstar");}
270  if (pTmin < 0) pTmin = mass*bgMin; if (pTmin < 0.01) pTmin = 0.01;
271  if (pTmax < 0) pTmax = mass*bgMax; if (pTmax > 1000.00) pTmax = 1000.00;
272  TRandom3 R(0);
273  Double_t bgMin10 = TMath::Log10(bgMin);
274  Double_t bgMax10 = TMath::Log10(bgMax);
275  TString Kine(Form("gkine %i %i %f %f -2 2 0 %f -50 50;",NTRACK,ID,pTmin,pTmax,TMath::TwoPi()));
276  cout << "Set kinematics: " << Kine.Data() << endl;
277  geant->Do(Kine.Data());
278  }
279  }
280  } else { // VMC
281  if (! StVMCMaker::instance()) return 0;
282  if (! StarVMCApplication::Instance()) return 0;
283  StarMCSimplePrimaryGenerator *gener = (StarMCSimplePrimaryGenerator *) StarVMCApplication::Instance()->GetPrimaryGenerator();
284  if ( gener && ! gener->IsA()->InheritsFrom( "StarMCSimplePrimaryGenerator" ) ) {
285  delete gener; gener = 0;
286  }
287  const Char_t *names[15] = {"muon+", "muon-", "electron", "positron", "pion+", "pion-", "kaon+", "kaon-", "proton", "pbar", "deuteron", "triton", "He3", "alpha", "pionMIP"};
288  Int_t Ids[15] = { 5, 6, 3, 2, 8, 9, 11, 12, 14, 15, 45, 46, 49, 47, 8};
289  Int_t NTRACK = 100;
290  Int_t ID = 5;
291  Double_t Ylow = -1;
292  Double_t Yhigh = 1;
293  Double_t Philow = 0;
294  Double_t Phihigh= 2*TMath::Pi();
295  Double_t Zlow = -50;
296  Double_t Zhigh = 50;
297  Double_t bgMinL10 = -1; // 3.5;// 1e2; // 1e-2;
298  Double_t bgMaxL10 = 6; // 1e2;// 1e5;
299  for (Int_t i = 0; i < 15; i++) {
300  if (Opt.Contains(names[i])) {
301  ID = Ids[i];
302  if (i == 14) {bgMinL10 = 0.544; bgMaxL10 = 0.653;}
303  break;
304  }
305  }
306  if (! gener) gener = new
307  StarMCSimplePrimaryGenerator( NTRACK, ID, bgMinL10, bgMaxL10,Ylow, Yhigh, Philow, Phihigh, Zlow, Zhigh, "GBL");
308  else
309  gener->SetGenerator( NTRACK, ID, bgMinL10, bgMaxL10,Ylow, Yhigh, Philow, Phihigh, Zlow, Zhigh, "GBL");
310  StarVMCApplication::Instance()->SetPrimaryGenerator(gener);
311  cout << "Set StarMCSimplePrimaryGenerator" << endl;
312  }
313  if (Last > 0) chain->EventLoop(First,Last);
314 }
315 //________________________________________________________________________________
316 void TpcRS(Int_t Last=100,
317  const Char_t *Run = "y2009,TpcRS",//trs,fcf", // "TpcRS,fcf",
318  const Char_t *fileIn = 0,
319  const Char_t *opt = "Bichsel", const Char_t *kuip = 0,
320  const Char_t *fileOut = 0) {
321  // /star/data03/daq/2004/093/st_physics_adc_5093007_raw_2050001.daq
322  // /star/data03/daq/2004/fisyak/st_physics_adc_5114043_raw_2080001.daq
323  // nofield /star/data03/daq/2004/076/st_physics_adc_5076061_raw_2060001.daq
324  // st_physics_adc_5076061_raw_4050001.daq
325  TpcRS(1,Last,Run,fileIn,opt,kuip,fileOut);
326 }
Int_t m_Mode
counters
Definition: StMaker.h:81
virtual TDataSet * First() const
Return the first object in the list. Returns 0 when list is empty.
Definition: TDataSet.cxx:403
virtual TDataSet * Last() const
Return the last object in the list. Returns 0 when list is empty.
Definition: TDataSet.cxx:437
virtual void Do(const Char_t *option="dcut cave x 0.1 10 10 0.03 0.03")
Executes a KUIP command.