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.6 2009/01/26 14:35:21 fisyak 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("y2005e,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,y2005e,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,y2005e,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  Char_t *libs[] = {"", "/usr/mysql/lib/","/usr/lib/", 0}; // "$ROOTSYS/mysql-4.1.20/lib/",
53  //Char_t *libs[] = {"/usr/lib/", 0};
54  Int_t i = 0;
55  while ((libs[i])) {
56  TString lib(libs[i]);
57  lib += mysql;
58  lib = gSystem->ExpandPathName(lib.Data());
59  if (gSystem->DynamicPathName(lib,kTRUE)) {
60  gSystem->Load(lib.Data()); cout << " + " << lib.Data() << endl;
61  break;
62  }
63  i++;
64  }
65  }
66  }
67  // if (gClassTable->GetID("TMatrix") < 0) gSystem->Load("StarRoot");// moved to rootlogon.C StMemStat::PrintMem("load StarRoot");
68 #ifdef UseLogger
69  // Look up for the logger option
70  Bool_t needLogger = kFALSE;
71  if (!TString(options).Contains("-logger",TString::kIgnoreCase)) {
72  needLogger = gSystem->Load("liblog4cxx.so") <= 0; // StMemStat::PrintMem("load log4cxx");
73  }
74 #endif
75  gSystem->Load("libSt_base"); // StMemStat::PrintMem("load St_base");
76 #ifdef UseLogger
77  if (needLogger) {
78  gSystem->Load("libStStarLogger.so");
79  gROOT->ProcessLine("StLoggerManager::StarLoggerInit();"); // StMemStat::PrintMem("load StStarLogger");
80  }
81 #endif
82  gSystem->Load("libHtml");
83  gSystem->Load("libStChain"); // StMemStat::PrintMem("load StChain");
84  gSystem->Load("libStUtilities"); // StMemStat::PrintMem("load StUtilities");
85  gSystem->Load("libStBFChain"); // StMemStat::PrintMem("load StBFChain");
86  gSystem->Load("libStChallenger"); // StMemStat::PrintMem("load StChallenger");
87 }
88 //_____________________________________________________________________
89 void bfc(Int_t First, Int_t Last,
90  const Char_t *Chain,
91  const Char_t *infile,
92  const Char_t *outfile,
93  const Char_t *TreeFile)
94 { // Chain variable define the chain configuration
95  // All symbols are significant (regardless of case)
96  // "-" sign before requiest means that this option is disallowed
97  // Chain = "gstar" run GEANT on flight with 10 muons in range |eta| < 1 amd pT = 1GeV/c (default)
98  // Dynamically link some shared libs
99  if (gClassTable->GetID("StBFChain") < 0) Load(Chain);
100  chain = new StBFChain(); cout << "Create chain " << chain->GetName() << endl;
101  TString tChain(Chain);
102  chain->cd();
103  chain->SetDebug(1);
104  if (Last < -3) return;
105  chain->SetFlags(Chain);
106  if (tChain == "" || ! tChain.CompareTo("ittf",TString::kIgnoreCase)) Usage();
107  chain->Set_IO_Files(infile,outfile);
108  if (TreeFile) chain->SetTFile(new TFile(TreeFile,"RECREATE"));
109  gMessMgr->QAInfo() << Form("Process [First=%6i/Last=%6i/Total=%6i] Events",First,Last,Last-First+1) << endm;
110  if (Last < -2) return;
111  if (chain->Load() > kStOk) {
112  gMessMgr->Error() << "Problems with loading of shared library(ies)" << endm;
113  gSystem->Exit(1);
114  }
115  if (Last < -1) return;
116  if (chain->Instantiate() > kStOk) {
117  gMessMgr->Error() << "Problems with instantiation of Maker(s)" << endm;
118  gSystem->Exit(1);
119  }
120  if (Last < 0) return;
121  StMaker *dbMk = chain->GetMaker("db");
122  if (dbMk) dbMk->SetDebug(1);
123  //JAN
124  dbMk->SetFlavor("simfgt", "vertexSeed"); //to match kumac used for FGT simulations
125 
126  dbMk->SetFlavor("sim","eemcPMTcal");
127  dbMk->SetFlavor("sim","eemcPIXcal");//use ideal calibration w/o this line
128  dbMk->SetFlavor("sim","eemcPMTped");
129  dbMk->SetFlavor("sim","eemcPMTstat");
130  dbMk->SetFlavor("sim","eemcPMTname");
131  dbMk->SetFlavor("sim","eemcADCconf");
132 
133  dbMk->SetFlavor("sim","bemcPed");
134  dbMk->SetFlavor("sim","bemcStatus");
135  dbMk->SetFlavor("sim","bemcCalib");
136  dbMk->SetFlavor("sim","bemcGain");
137 
138 #if 1
139  gSystem->Load("StEEmcA2EMaker");
140  gSystem->Load("StEEmcPoolEEmcFilterMaker");
141 
142  StEEmcA2EMaker *EEa2eMK=new StEEmcA2EMaker("EE_A2E");
143  EEa2eMK->database("eeDb"); // sets db connection
144  EEa2eMK->source("StEventMaker",2);
145  EEa2eMK->scale(1.0); // scale reco Endcap energy by a factor
146 
147  /* this filter assumes fixed Zvertex,
148  needs only Endcap slow simu */
149  StEEmcFilterMaker *eeFlt1Mk=new StEEmcFilterMaker("EEmcFilterPreTPC");
150  eeFlt1Mk->setEtThres(14.);// (GeV), event-eta used
151  eeFlt1Mk->setFixedVertex(-60.); // (cm), Z0
152 
153  // this filter requires reco vertex
154  StEEmcFilterMaker *eeFlt2Mk=new StEEmcFilterMaker("EEmcFilterPostTPC");
155  eeFlt2Mk->setEtThres(16.);// (GeV), event-eta used
156  eeFlt2Mk->setZvertCut(-60.,15.); // (cm), Z0, delatZ
157 
158  // position makers at the right location in the chain
159  // WARN, order of operations below is important
160  StMaker *tpcMk = chain->GetMaker("tpcChain");
161  chain->AddAfter("eefs",tpcMk); // now TPC-chain is after EMC-makers
162 
163  chain->AddAfter("eefs",eeFlt1Mk);
164  chain->AddAfter("eefs",EEa2eMK); // filter 1 is before TPC-chain
165  chain->AddBefore("MuDst",eeFlt2Mk); // filter 2 is after vertex finder
166 
167 #endif
168  chain->ls(3);
169 
170 #if 0
171  // Insert your maker before "tpc_hits"
172  Char_t *myMaker = "St_TLA_Maker";
173  if (gClassTable->GetID(myMaker) < 0) {
174  gSystem->Load(myMaker);// TString ts("load "; ts+=myMaker; StMemStat::PrintMem(ts.Data());
175  }
176  StMaker *myMk = chain->GetMaker(myMaker);
177  if (myMk) delete myMk;
178  myMk = chain->New(myMaker,"before");
179  if (myMk) {
180  Char_t *before = "tpc_hits";
181  StMaker *tclmk = chain->GetMaker(before);
182  if (tclmk) chain->AddBefore(before,myMk);
183  }
184  // Insert your maker after "tpc_hits"
185  myMk = chain->New(myMaker,"after");
186  if (myMk) {
187  Char_t *after = "tpc_hits";
188  StMaker *tclmk = chain->GetMaker(after);
189  if (tclmk) chain->AddAfter(after,myMk);
190  }
191  // this block is meant as an example ONLY
192  // The default values are set in StRoot/StPass0CalibMaker/ StTpcT0Maker
193  // constructor and are suitable for production. You can change it here
194  // for test purposes.
195  if (chain->GetOption("TpcT0")) {
196  StTpcT0Maker *t0mk = (StTpcT0Maker *) chain->GetMaker("TpcT0");
197  if (t0mk) t0mk->SetDesiredEntries(10);
198  }
199 #endif
200  {
201  TDatime t;
202  gMessMgr->QAInfo() << Form("Run is started at Date/Time %i/%i",t.GetDate(),t.GetTime()) << endm;
203  }
204  gMessMgr->QAInfo() << Form("Run on %s in %s",gSystem->HostName(),gSystem->WorkingDirectory()) << endm;
205  gMessMgr->QAInfo() << Form("with %s", chain->GetCVS()) << endm;
206  // Init the chain and all its makers
207  TAttr::SetDebug(0);
208  chain->SetAttr(".Privilege",0,"*" ); //All makers are NOT priviliged
209  chain->SetAttr(".Privilege",1,"StIOInterFace::*" ); //All IO makers are priviliged
210  chain->SetAttr(".Privilege",1,"St_geant_Maker::*"); //It is also IO maker
211  Int_t iInit = chain->Init();
212  if (iInit >= kStEOF) {chain->FatalErr(iInit,"on init"); return;}
213  if (Last == 0) return;
214  StEvtHddr *hd = (StEvtHddr*)chain->GetDataSet("EvtHddr");
215  if (hd) hd->SetRunNumber(-2); // to be sure that InitRun calls at least once
216  // skip if any
217  chain->EventLoop(First,Last,0);
218  gMessMgr->QAInfo() << "Run completed " << endm;
219  gSystem->Exec("date");
220 }
221 //_____________________________________________________________________
222 void bfc(Int_t Last,
223  const Char_t *Chain,
224  const Char_t *infile,
225  const Char_t *outfile,
226  const Char_t *TreeFile)
227 {
228  bfc(1,Last,Chain,infile,outfile,TreeFile);
229 }
230 //____________________________________________________________
231 void Usage() {
232  printf ("============= \t U S A G E =============\n");
233  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");
234  printf ("bfc(Int_t Last,const Char_t *Chain,const Char_t *infile,const Char_t *outfile,const Char_t *TreeFile)\n");
235  printf ("bfc(const Char_t *ChainShort,Int_t Last,const Char_t *infile,const Char_t *outfile)\n");
236  printf ("where\n");
237  printf (" First \t- First event to process\t(Default = 1)\n");
238  printf (" Last \t- Last event to process\t(Default = 1)\n");
239  printf (" Chain \t- Chain specification \t(without First & Last: Default is \"\" which gives this message)\n");
240  printf (" \t \t with First || Last: Default is \"gstar tfs\")\n");
241  printf (" infile \t- Name of Input file \t(Default = 0, i.e. use preset file names depending on Chain)\n");
242  printf (" outfile \t- Name of Output file \t(Default = 0, i.e. define Output file name from Input one)\n");
243  printf (" outfile \t- Name of Tree File \t(Default = 0, i.e. define Output file name from Input one (tags TNtuple))\n");
244  printf (" ChainShort\t- Short cut for chain \t(Default = \"\" -> print out of this message)\n");
245  gSystem->Exit(1);
246 }
247 //_____________________________________________________________________
248 void bfc(const Char_t *Chain="ittf") {
249  bfc(-2,Chain);
250 }
EEmc ADC –&gt; energy maker.
virtual Int_t Instantiate()
Maker-instantiation handler.
Definition: StBFChain.cxx:214
void scale(Float_t s)
void source(const Char_t *, Int_t=0)
void SetFlags(const Char_t *Chain="gstar tfs")
Scan all flags, check if they are correct, manipulate the comment if necessary.
Definition: StBFChain.cxx:1510
virtual void ls(Option_t *option="") const
Definition: TDataSet.cxx:495
Definition: Stypes.h:43
aborts events based on Endcap response cuts: reco vertex in some Z-range and EEMC 2x1 cluster event-e...
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
void database(const Char_t *)
Set the name of the EEMC database, init obtains pointer.
Definition: Stypes.h:41