StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
bfc.C
1 // //
3 // Macro for running chain with different inputs //
4 // owner: Yuri Fisyak //
5 // //
6 // $Id: bfc.C,v 1.3 2011/04/08 22:35:02 balewski Exp $
8 class StBFChain;
9 class StMessMgr;
10 #if !defined(__CINT__) || defined(__MAKECINT__)
11 #include "Stiostream.h"
12 #include "TSystem.h"
13 #include "TClassTable.h"
14 #include "TApplication.h"
15 #include "TInterpreter.h"
16 #include "StBFChain.h"
17 #include "StMessMgr.h"
18 #else
19 #endif
20 #define UseLogger
21 StBFChain *chain=0;
22 //_____________________________________________________________________
23 //_________________ Prototypes _______________________________________________
24 void Usage();
25 void Load(const Char_t *options="");
26 TString defChain("y2005h,Test.default.ITTF");
27 void bfc(Int_t First, Int_t Last,const Char_t *Chain = defChain + ",Display",
28  const Char_t *infile=0, const Char_t *outfile=0, const Char_t *TreeFile=0);
29 // const Char_t *Chain="gstar,y2005h,MakeEvent,trs,sss,svt,ssd,fss,bbcSim,emcY2,tpcI,fcf,ftpc,SvtCL,svtDb,ssdDb,svtIT,ssdIT,ITTF,genvtx,Idst,event,analysis,EventQA,tags,Tree,EvOut,McEvOut,GeantOut,IdTruth,miniMcMk,StarMagField,FieldOn,McAna,Display",//,,NoSimuDb, display, //McQa,
30 void bfc(Int_t Last, const Char_t *Chain = defChain,
31  const Char_t *infile=0, const Char_t *outfile=0, const Char_t *TreeFile=0);
32  // const Char_t *Chain="gstar,y2005h,tpcDb,trs,tpc,Physics,Cdst,Kalman,tags,Tree,EvOut,McEvOut,IdTruth,miniMcMk,StarMagField,FieldOn,McAna", // McQA
33 //_____________________________________________________________________
34 void Load(const Char_t *options){
35  cout << "Load system libraries" << endl;
36  if ( gClassTable->GetID("TGiant3") < 0) { // ! root4star
37  cout << endl << "Load ";
38  if (!TString(options).Contains("nodefault",TString::kIgnoreCase) ||
39  TString(options).Contains("pgf77",TString::kIgnoreCase)) {
40  const Char_t *pgf77 = "libpgf77VMC";
41  if (gSystem->DynamicPathName(pgf77,kTRUE) ) {
42  gSystem->Load(pgf77); cout << " " << pgf77 << " + ";
43  }
44  }
45  if (!TString(options).Contains("nodefault",TString::kIgnoreCase) ||
46  TString(options).Contains("cern",TString::kIgnoreCase)) {
47  gSystem->Load("libminicern"); cout << "libminicern";
48  }
49  if (!TString(options).Contains("nodefault",TString::kIgnoreCase) ||
50  TString(options).Contains("mysql",TString::kIgnoreCase)) {
51  Char_t *mysql = "libmysqlclient";
52  //
53  // ATTENTION: The below will FAIL for 64 bits systems (JL 2009/10/22)
54  //
55  Char_t *libs[] = {"", "/usr/mysql/lib/","/usr/lib/", 0}; // "$ROOTSYS/mysql-4.1.20/lib/",
56  //Char_t *libs[] = {"/usr/lib/", 0};
57  Int_t i = 0;
58  while ((libs[i])) {
59  TString lib(libs[i]);
60  lib += mysql;
61  lib = gSystem->ExpandPathName(lib.Data());
62  if (gSystem->DynamicPathName(lib,kTRUE)) {
63  gSystem->Load(lib.Data()); cout << " + " << lib.Data() << endl;
64  break;
65  }
66  i++;
67  }
68  }
69  }
70  // if (gClassTable->GetID("TMatrix") < 0) gSystem->Load("StarRoot");// moved to rootlogon.C StMemStat::PrintMem("load StarRoot");
71 #ifdef UseLogger
72  // Look up for the logger option
73  Bool_t needLogger = kFALSE;
74  if (!TString(options).Contains("-logger",TString::kIgnoreCase)) {
75  needLogger = gSystem->Load("liblog4cxx.so") <= 0; // StMemStat::PrintMem("load log4cxx");
76  }
77 #endif
78  gSystem->Load("libSt_base"); // StMemStat::PrintMem("load St_base");
79 #ifdef UseLogger
80  if (needLogger) {
81  gSystem->Load("libStStarLogger.so");
82  gROOT->ProcessLine("StLoggerManager::StarLoggerInit();"); // StMemStat::PrintMem("load StStarLogger");
83  }
84 #endif
85  gSystem->Load("libHtml");
86  gSystem->Load("libStChain"); // StMemStat::PrintMem("load StChain");
87  gSystem->Load("libStUtilities"); // StMemStat::PrintMem("load StUtilities");
88  gSystem->Load("libStBFChain"); // StMemStat::PrintMem("load StBFChain");
89  gSystem->Load("libStChallenger"); // StMemStat::PrintMem("load StChallenger");
90 }
91 //_____________________________________________________________________
92 void bfc(Int_t First, Int_t Last,
93  const Char_t *Chain,
94  const Char_t *infile,
95  const Char_t *outfile,
96  const Char_t *TreeFile)
97 { // Chain variable define the chain configuration
98  // All symbols are significant (regardless of case)
99  // "-" sign before requiest means that this option is disallowed
100  // Chain = "gstar" run GEANT on flight with 10 muons in range |eta| < 1 amd pT = 1GeV/c (default)
101  // Dynamically link some shared libs
102  if (gClassTable->GetID("StBFChain") < 0) Load(Chain);
103  chain = new StBFChain(); cout << "Create chain " << chain->GetName() << endl;
104  TString tChain(Chain);
105  chain->cd();
106  chain->SetDebug(1);
107  if (Last < -3) return;
108  chain->SetFlags(Chain);
109  if (tChain == "" || ! tChain.CompareTo("ittf",TString::kIgnoreCase)) Usage();
110  chain->Set_IO_Files(infile,outfile);
111  if (TreeFile) chain->SetTFile(new TFile(TreeFile,"RECREATE"));
112  gMessMgr->QAInfo() << Form("Process [First=%6i/Last=%6i/Total=%6i] Events",First,Last,Last-First+1) << endm;
113  if (Last < -2) return;
114  if (chain->Load() > kStOk) {
115  gMessMgr->Error() << "Problems with loading of shared library(ies)" << endm;
116  gSystem->Exit(1);
117  }
118  if (Last < -1) return;
119  if (chain->Instantiate() > kStOk) {
120  gMessMgr->Error() << "Problems with instantiation of Maker(s)" << endm;
121  gSystem->Exit(1);
122  }
123  if (Last < 0) return;
124  StMaker *dbMk = chain->GetMaker("db");
125  if (dbMk) dbMk->SetDebug(1);
126 #if 0
127  // Insert your maker before "tpc_hits"
128  Char_t *myMaker = "St_TLA_Maker";
129  if (gClassTable->GetID(myMaker) < 0) {
130  gSystem->Load(myMaker);// TString ts("load "; ts+=myMaker; StMemStat::PrintMem(ts.Data());
131  }
132  StMaker *myMk = chain->GetMaker(myMaker);
133  if (myMk) delete myMk;
134  myMk = chain->New(myMaker,"before");
135  if (myMk) {
136  Char_t *before = "tpc_hits";
137  StMaker *tclmk = chain->GetMaker(before);
138  if (tclmk) chain->AddBefore(before,myMk);
139  }
140  // Insert your maker after "tpc_hits"
141  myMk = chain->New(myMaker,"after");
142  if (myMk) {
143  Char_t *after = "tpc_hits";
144  StMaker *tclmk = chain->GetMaker(after);
145  if (tclmk) chain->AddAfter(after,myMk);
146  }
147  // this block is meant as an example ONLY
148  // The default values are set in StRoot/StPass0CalibMaker/ StTpcT0Maker
149  // constructor and are suitable for production. You can change it here
150  // for test purposes.
151  if (chain->GetOption("TpcT0")) {
152  StTpcT0Maker *t0mk = (StTpcT0Maker *) chain->GetMaker("TpcT0");
153  if (t0mk) t0mk->SetDesiredEntries(10);
154  }
155 #endif
156  {
157  TDatime t;
158  gMessMgr->QAInfo() << Form("Run is started at Date/Time %i/%i",t.GetDate(),t.GetTime()) << endm;
159  }
160  gMessMgr->QAInfo() << Form("Run on %s in %s",gSystem->HostName(),gSystem->WorkingDirectory()) << endm;
161  gMessMgr->QAInfo() << Form("with %s", chain->GetCVS()) << endm;
162  // Init the chain and all its makers
163  TAttr::SetDebug(0);
164  chain->SetAttr(".Privilege",0,"*" ); //All makers are NOT priviliged
165  chain->SetAttr(".Privilege",1,"StIOInterFace::*" ); //All IO makers are priviliged
166  chain->SetAttr(".Privilege",1,"St_geant_Maker::*"); //It is also IO maker
167  chain->SetAttr(".Privilege",1,"StTpcDbMaker::*"); //It is also TpcDb maker to catch trips
168  chain->SetAttr(".Privilege",1,"*::tpc_hits"); //May be allowed to act upon excessive events
169  chain->SetAttr(".Privilege",1,"*::tpx_hits"); //May be allowed to act upon excessive events
170  chain->SetAttr(".Privilege",1,"StTpcHitMover::*"); //May be allowed to act upon corrupt events
171  chain->SetAttr(".Privilege",1,"*::tpcChain"); //May pass on messages from sub-makers
172  chain->SetAttr(".Privilege",1,"StTriggerDataMaker::*"); //TriggerData could reject event based on corrupt triggers
173 
174  // add FGT stuff - jan
175  TString &fnameOut1=chain->GetFileOut();
176  cout<<"AAA"<<fnameOut1<<endl;
177  TString fnameOut2=fnameOut1;
178  fnameOut2.ReplaceAll(".root",".fgt");
179  //fnameOut2+=".fgt";
180  cout<<"FGT output core="<<fnameOut2<<endl;
181 
182  gSystem->Load("libStEEmcPoolFgtSandbox1");
186  // ... position FGT maker in the chain
187  Char_t *after = "geant"; StMaker *xMk = chain->GetMaker(after); assert(xMk);
188  // note , the lines should be in reversed order
189  chain->AddAfter(after,myMkEV); //position #3
190  chain->AddAfter(after,myMkCL); //position #2
191  chain->AddAfter(after,myMkSM); //position #1
192 
193  //...... auxiliary initialization
194  HList=new TObjArray;
195  myMkSM->setHList(HList); myMkCL->setHList(HList); myMkEV->setHList(HList);
196  myMkSM->initFrankModel("StRoot/StEEmcPool/FgtSandbox1/macros/BichselELossProbHighBG.dat");
197  // myMkSM->forcePerpTracks(); //only for testing,all tracks will go perp through the GEM gas volume
198 // myMkSM->useOnlyDisk(1); //only for testing, disk # 1...6
199  myMkSM->useOnlyDisk(0); //All disks
200  myMkSM->setRadStripGain(1.00,0.03); //relative gain variation: mean=1 & sigma=0.03
201  myMkSM->setPhiStripGain(1.00,0.03); //relative gain variation: mean=1.5 & sigma=0.03
202  myMkSM->setStripThresh(1.); // a.u.
203  myMkSM->setHexGemLatice(0.014, 60.); // (cm) pitch=0.014, (deg) 1st axis angle/deg
204  myMkSM->setTransDiffusion(0.017); // (cm per 1 cm of path), default=0.017 cm/cm
205 
206  myMkCL->setSeedStripThres(30.); // a.u.
207  myMkCL->setStripNoiseSigma(12.); // a.u. , default=12=10%
208 
209  // chain is ready
210  chain->ls(3);
211 
212 
213  Int_t iInit = chain->Init();
214 
215 
216 
217 
218  if (iInit >= kStEOF) {chain->FatalErr(iInit,"on init"); return;}
219  if (Last == 0) return;
220  StEvtHddr *hd = (StEvtHddr*)chain->GetDataSet("EvtHddr");
221  if (hd) hd->SetRunNumber(-2); // to be sure that InitRun calls at least once
222  // skip if any
223  chain->EventLoop(First,Last,0);
224  gMessMgr->QAInfo() << "Run completed " << endm;
225  gSystem->Exec("date");
226 
227 
228  //FGT end....
229  {
230  TDatime t;
231  gMessMgr->QAInfo() << Form("Run is finished at Date/Time %i/%i",
232  t.GetDate(),t.GetTime()) << endm;
233  }
234  myMkSM->saveHisto(fnameOut2);// one is enough, all histos are merged
235 
236 
237 
238 
239 }
240 //_____________________________________________________________________
241 void bfc(Int_t Last,
242  const Char_t *Chain,
243  const Char_t *infile,
244  const Char_t *outfile,
245  const Char_t *TreeFile)
246 {
247  bfc(1,Last,Chain,infile,outfile,TreeFile);
248 }
249 //____________________________________________________________
250 void Usage() {
251  printf ("============= \t U S A G E =============\n");
252  printf ("bfc(Int_t First,Int_t Last,const Char_t *Chain,const Char_t *infile,const Char_t *outfile,const Char_t *TreeFile)\n");
253  printf ("bfc(Int_t Last,const Char_t *Chain,const Char_t *infile,const Char_t *outfile,const Char_t *TreeFile)\n");
254  printf ("bfc(const Char_t *ChainShort,Int_t Last,const Char_t *infile,const Char_t *outfile)\n");
255  printf ("where\n");
256  printf (" First \t- First event to process\t(Default = 1)\n");
257  printf (" Last \t- Last event to process\t(Default = 1)\n");
258  printf (" Chain \t- Chain specification \t(without First & Last: Default is \"\" which gives this message)\n");
259  printf (" \t \t with First || Last: Default is \"gstar tfs\")\n");
260  printf (" infile \t- Name of Input file \t(Default = 0, i.e. use preset file names depending on Chain)\n");
261  printf (" outfile \t- Name of Output file \t(Default = 0, i.e. define Output file name from Input one)\n");
262  printf (" outfile \t- Name of Tree File \t(Default = 0, i.e. define Output file name from Input one (tags TNtuple))\n");
263  printf (" ChainShort\t- Short cut for chain \t(Default = \"\" -> print out of this message)\n");
264  gSystem->Exit(1);
265 }
266 //_____________________________________________________________________
267 void bfc(const Char_t *Chain="ittf") {
268  bfc(-2,Chain);
269 }
virtual Int_t Instantiate()
Maker-instantiation handler.
Definition: StBFChain.cxx:214
void SetFlags(const Char_t *Chain="gstar tfs")
Scan all flags, check if they are correct, manipulate the comment if necessary.
Definition: StBFChain.cxx:1512
virtual void ls(Option_t *option="") const
Definition: TDataSet.cxx:495
Definition: Stypes.h:43
virtual const char * GetName() const
special overload
Definition: StMaker.cxx:237
virtual Int_t Load()
Routine handling library loading depending on chain options.
Definition: StBFChain.cxx:117
Definition: Stypes.h:41