-
Notifications
You must be signed in to change notification settings - Fork 63
/
bfc.C
254 lines (240 loc) · 10.9 KB
/
bfc.C
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
//////////////////////////////////////////////////////////////////////////
// //
// Macro for running chain with different inputs //
// owner: Yuri Fisyak //
// Modifications by J. Lauret, V, Prevotchikov, G.V. Buren, L. Didenko //
// and V. Fine //
// //
// $Id: bfc.C,v 1.194 2020/04/12 20:24:18 perev Exp $
//////////////////////////////////////////////////////////////////////////
class StBFChain;
class StMessMgr;
#pragma cling load("StarRoot")
#pragma cling load("St_base")
#pragma cling load("StChain")
#pragma cling load("StUtilities")
#pragma cling load("StBFChain")
#if !(defined(__CINT__) || defined(__CLING__)) || defined(__MAKECINT__)
#include "Stiostream.h"
#include "TSystem.h"
#include "TClassTable.h"
#include "TApplication.h"
#include "TInterpreter.h"
#include "StBFChain.h"
#include "StMessMgr.h"
#include "TROOT.h"
#include "TAttr.h"
#include "Rtypes.h"
#endif
StBFChain *chain=0;
//_____________________________________________________________________
//_________________ Prototypes _______________________________________________
void Usage();
void Load(const Char_t *options="");
//TString defChain("y2010,gstar,Test.default.Fast.ITTF,NosvtIT,NossdIT,-sfs,-ssdFast");
TString defChain("y2010,gstar,Test.default.ITTF,NosvtIT,NossdIT,-sfs,-ssdFast,sdt20100107.110000");
void bfc(Int_t First, Int_t Last,const Char_t *Chain = defChain + ",Display",
const Char_t *infile=0, const Char_t *outfile=0, const Char_t *TreeFile=0);
// 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,
void bfc(Int_t Last, const Char_t *Chain = defChain,
const Char_t *infile=0, const Char_t *outfile=0, const Char_t *TreeFile=0);
// const Char_t *Chain="gstar,y2005h,tpcDb,trs,tpc,Physics,Cdst,Kalman,tags,Tree,EvOut,McEvOut,IdTruth,miniMcMk,StarMagField,FieldOn,McAna", // McQA
//_____________________________________________________________________
void Load(const Char_t *options)
{
cout << "Load system libraries\t";
int nodefault = TString(options).Contains("nodefault",TString::kIgnoreCase);
if ( TString(gProgName)!="root4star") { // ! root4star
if (!nodefault || TString(options).Contains("pgf77",TString::kIgnoreCase)) {
const Char_t *pgf77 = "libpgf77VMC";
if (gSystem->DynamicPathName(pgf77,kTRUE) ) {
gSystem->Load(pgf77); cout << " " << pgf77 << " + ";
}
}
if (!nodefault || TString(options).Contains("cern" ,TString::kIgnoreCase)) {
gSystem->Load("libStarMiniCern");
cout << "libStarMiniCern" ;
}
if (!nodefault || TString(options).Contains("mysql",TString::kIgnoreCase)) {
const Char_t *mysql = "libmysqlclient";
//Char_t *mysql = "libmimerS"; // just to test it picks from OPTSTAR
//
// May use USE_64BITS - the x8664 work fine too
//
const Char_t *libsLocal[]= {"",
"$OPTSTAR/lib/",
"$OPTSTAR/lib/mysql/",
"/usr/lib/",
"/usr/lib/mysql/",
"/usr/mysql/lib/",
NULL};
const Char_t *libsGlbal[]= {"",
"/usr/lib/",
"/usr/lib/mysql/",
"/usr/mysql/lib/",
"$OPTSTAR/lib/",
"$OPTSTAR/lib/mysql/",
NULL};
const Char_t **libs;
if ( gSystem->Getenv("USE_LOCAL_MYSQL") ){
libs = libsLocal;
} else {
libs = libsGlbal;
}
TString Arch( gSystem->GetBuildArch() );
Bool_t i64 = kFALSE;
if ( gSystem->Getenv("USE_64BITS") || Arch.Contains("x8664")) i64 = kTRUE;
Int_t i = 0;
while ((libs[i])) {
TString lib(libs[i]);
//cout << "Found " << lib << endl;
if (i64) lib.ReplaceAll("/lib","/lib64");
lib += mysql;
lib = gSystem->ExpandPathName(lib.Data());
if (gSystem->DynamicPathName(lib,kTRUE)) {
gSystem->Load(lib.Data());
cout << " + " << mysql << " from " << lib.Data();
break;
}
i++;
}
}
cout << endl;
}
gSystem->Load("libSt_base"); // StMemStat::PrintMem("load St_base");
// Look up for the logger option
if (gSystem->Load("liblog4cxx.so") >= 0) { // StMemStat::PrintMem("load log4cxx");
cout << " + liblog4cxx.so";
if(gSystem->Load("libStStarLogger.so") >= 0) { // StMemStat::PrintMem("load log4cxx");
cout << " + libStStarLogger.so";
gROOT->ProcessLine("StLoggerManager::StarLoggerInit();");
}
}
// gSystem->Load("libHtml");
gSystem->Load("libStChain"); // StMemStat::PrintMem("load StChain");
gSystem->Load("libStUtilities"); // StMemStat::PrintMem("load StUtilities");
gSystem->Load("libStBFChain"); // StMemStat::PrintMem("load StBFChain");
cout << endl;
}
//_____________________________________________________________________
void bfc(Int_t First, Int_t Last,
const Char_t *Chain,
const Char_t *infile,
const Char_t *outfile,
const Char_t *TreeFile)
{ // Chain variable define the chain configuration
// All symbols are significant (regardless of case)
// "-" sign before requiest means that this option is disallowed
// Chain = "gstar" run GEANT on flight with 10 muons in range |eta| < 1 amd pT = 1GeV/c (default)
// Dynamically link some shared libs
if (gClassTable->GetID("StBFChain") < 0) Load(Chain);
chain = new StBFChain(); cout << "Create chain " << chain->GetName() << endl;
TString tChain(Chain);
chain->cd();
chain->SetDebug(1);
if (Last < -3) return;
chain->SetFlags(Chain);
if (tChain == "" || ! tChain.CompareTo("ittf",TString::kIgnoreCase)) Usage();
gMessMgr->QAInfo() << Form("Process [First=%6i/Last=%6i/Total=%6i] Events",First,Last,Last-First+1) << endm;
if (Last < -2) return;
if (chain->Load() > kStOk) {
gMessMgr->Error() << "Problems with loading of shared library(ies)" << endm;
gSystem->Exit(1);
}
chain->Set_IO_Files(infile,outfile);
if (TreeFile) chain->SetTFile(new TFile(TreeFile,"RECREATE"));
if (Last < -1) return;
if (chain->Instantiate() > kStOk) {
gMessMgr->Error() << "Problems with instantiation of Maker(s)" << endm;
gSystem->Exit(1);
}
StMaker::lsMakers(chain);
if (Last < 0) return;
StMaker *dbMk = chain->GetMaker("db");
if (dbMk) dbMk->SetDebug(1);
#if 0
// Insert your maker before "tpc_hits"
Char_t *myMaker = "St_TLA_Maker";
if (gClassTable->GetID(myMaker) < 0) {
gSystem->Load(myMaker);// TString ts("load "; ts+=myMaker; StMemStat::PrintMem(ts.Data());
}
StMaker *myMk = chain->GetMaker(myMaker);
if (myMk) delete myMk;
myMk = chain->New(myMaker,"before");
if (myMk) {
Char_t *before = "tpc_hits";
StMaker *tclmk = chain->GetMaker(before);
if (tclmk) chain->AddBefore(before,myMk);
}
// Insert your maker after "tpc_hits"
myMk = chain->New(myMaker,"after");
if (myMk) {
Char_t *after = "tpc_hits";
StMaker *tclmk = chain->GetMaker(after);
if (tclmk) chain->AddAfter(after,myMk);
}
// this block is meant as an example ONLY
// The default values are set in StRoot/StPass0CalibMaker/ StTpcT0Maker
// constructor and are suitable for production. You can change it here
// for test purposes.
if (chain->GetOption("TpcT0")) {
StTpcT0Maker *t0mk = (StTpcT0Maker *) chain->GetMaker("TpcT0");
if (t0mk) t0mk->SetDesiredEntries(10);
}
#endif
{
TDatime t;
gMessMgr->QAInfo() << Form("Run is started at Date/Time %i/%i",t.GetDate(),t.GetTime()) << endm;
}
gMessMgr->QAInfo() << Form("Run on %s in %s",gSystem->HostName(),gSystem->WorkingDirectory()) << endm;
gMessMgr->QAInfo() << Form("with %s", chain->GetCVS()) << endm;
// Init the chain and all its makers
TAttr::SetDebug(0);
chain->SetAttr(".Privilege",0,"*" ); //All makers are NOT priviliged
chain->SetAttr(".Privilege",1,"StIOInterFace::*" ); //All IO makers are priviliged
chain->SetAttr(".Privilege",1,"St_geant_Maker::*"); //It is also IO maker
chain->SetAttr(".Privilege",1,"StTpcDbMaker::*"); //It is also TpcDb maker to catch trips
chain->SetAttr(".Privilege",1,"*::tpc_hits"); //May be allowed to act upon excessive events
chain->SetAttr(".Privilege",1,"*::tpx_hits"); //May be allowed to act upon excessive events
chain->SetAttr(".Privilege",1,"StTpcHitMover::*"); //May be allowed to act upon corrupt events
chain->SetAttr(".Privilege",1,"*::tpcChain"); //May pass on messages from sub-makers
chain->SetAttr(".Privilege",1,"StTriggerDataMaker::*"); //TriggerData could reject event based on corrupt triggers
chain->SetAttr(".Privilege",1,"StEventMaker::*"); //May be allowed to act upon trigger IDs (filtering)
Int_t iInit = chain->Init();
if (iInit >= kStEOF) {chain->FatalErr(iInit,"on init"); return;}
if (Last == 0) return;
StEvtHddr *hd = (StEvtHddr*)chain->GetDataSet("EvtHddr");
if (hd) hd->SetRunNumber(-2); // to be sure that InitRun calls at least once
// skip if any
chain->EventLoop(First,Last,0);
gMessMgr->QAInfo() << "Run completed " << endm;
}
//_____________________________________________________________________
void bfc(Int_t Last,
const Char_t *Chain,
const Char_t *infile,
const Char_t *outfile,
const Char_t *TreeFile) {
bfc(1,Last,Chain,infile,outfile,TreeFile);
}
//____________________________________________________________
void Usage() {
printf ("============= \t U S A G E =============\n");
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");
printf ("bfc(Int_t Last,const Char_t *Chain,const Char_t *infile,const Char_t *outfile,const Char_t *TreeFile)\n");
printf ("bfc(const Char_t *ChainShort,Int_t Last,const Char_t *infile,const Char_t *outfile)\n");
printf ("where\n");
printf (" First \t- First event to process\t(Default = 1)\n");
printf (" Last \t- Last event to process\t(Default = 1)\n");
printf (" Chain \t- Chain specification \t(without First & Last: Default is \"\" which gives this message)\n");
printf (" \t \t with First || Last: Default is \"gstar tfs\")\n");
printf (" infile \t- Name of Input file \t(Default = 0, i.e. use preset file names depending on Chain)\n");
printf (" outfile \t- Name of Output file \t(Default = 0, i.e. define Output file name from Input one)\n");
printf (" outfile \t- Name of Tree File \t(Default = 0, i.e. define Output file name from Input one (tags TNtuple))\n");
printf (" ChainShort\t- Short cut for chain \t(Default = \"\" -> print out of this message)\n");
gSystem->Exit(1);
}
//_____________________________________________________________________
void bfc(const Char_t *Chain="ittf") {
bfc(-2,Chain);
}