00001
00002
00003
00004
00005
00006
00007
00008
00010 class StBFChain;
00011 class StMessMgr;
00012 #if !defined(__CINT__) || defined(__MAKECINT__)
00013 #include "Stiostream.h"
00014 #include "TSystem.h"
00015 #include "TClassTable.h"
00016 #include "TApplication.h"
00017 #include "TInterpreter.h"
00018 #include "StBFChain.h"
00019 #include "StMessMgr.h"
00020 #include "TROOT.h"
00021 #endif
00022 StBFChain *chain=0;
00023
00024
00025 void Usage();
00026 void Load(const Char_t *options="");
00027
00028 TString defChain("y2010,gstar,Test.default.ITTF,NosvtIT,NossdIT,-sfs,-ssdFast,sdt20100107.110000");
00029 void bfc(Int_t First, Int_t Last,const Char_t *Chain = defChain + ",Display",
00030 const Char_t *infile=0, const Char_t *outfile=0, const Char_t *TreeFile=0);
00031
00032 void bfc(Int_t Last, const Char_t *Chain = defChain,
00033 const Char_t *infile=0, const Char_t *outfile=0, const Char_t *TreeFile=0);
00034
00035
00036 void Load(const Char_t *options){
00037 cout << "Load system libraries\t";
00038 if ( gClassTable->GetID("TGiant3") < 0) {
00039 if (!TString(options).Contains("nodefault",TString::kIgnoreCase) ||
00040 TString(options).Contains("pgf77",TString::kIgnoreCase)) {
00041 const Char_t *pgf77 = "libpgf77VMC";
00042 if (gSystem->DynamicPathName(pgf77,kTRUE) ) {
00043 gSystem->Load(pgf77); cout << " " << pgf77 << " + ";
00044 }
00045 }
00046 if (!TString(options).Contains("nodefault",TString::kIgnoreCase) ||
00047 TString(options).Contains("cern",TString::kIgnoreCase)) {
00048 gSystem->Load("libminicern");
00049 cout << "libminicern" ;
00050 }
00051
00052
00053 if (!strstr(gProgName,"root4star") ||
00054 !TString(options).Contains("nodefault",TString::kIgnoreCase) ||
00055 TString(options).Contains("mysql",TString::kIgnoreCase)) {
00056 Char_t *mysql = "libmysqlclient";
00057
00058
00059
00060
00061
00062 Char_t *libsLocal[]= {"",
00063 "$OPTSTAR/lib/",
00064 "$OPTSTAR/lib/mysql/",
00065 "/usr/lib/",
00066 "/usr/lib/mysql/",
00067 "/usr/mysql/lib/",
00068 NULL};
00069 Char_t *libsGlbal[]= {"",
00070 "/usr/lib/",
00071 "/usr/lib/mysql/",
00072 "/usr/mysql/lib/",
00073 "$OPTSTAR/lib/",
00074 "$OPTSTAR/lib/mysql/",
00075 NULL};
00076
00077 Char_t **libs;
00078
00079 if ( gSystem->Getenv("USE_LOCAL_MYSQL") ){
00080 libs = libsLocal;
00081 } else {
00082 libs = libsGlbal;
00083 }
00084
00085
00086 TString Arch( gSystem->GetBuildArch() );
00087 Bool_t i64 = kFALSE;
00088 if ( gSystem->Getenv("USE_64BITS")==1 || Arch.Contains("x8664")) i64 = kTRUE;
00089
00090 Int_t i = 0;
00091 while ((libs[i])) {
00092 TString lib(libs[i]);
00093
00094 if (i64) lib.ReplaceAll("/lib","/lib64");
00095 lib += mysql;
00096 lib = gSystem->ExpandPathName(lib.Data());
00097 if (gSystem->DynamicPathName(lib,kTRUE)) {
00098 gSystem->Load(lib.Data());
00099 cout << " + " << mysql << " from " << lib.Data();
00100 break;
00101 }
00102 i++;
00103 }
00104 }
00105 cout << endl;
00106 }
00107 gSystem->Load("libSt_base");
00108
00109 Bool_t needLogger = kFALSE;
00110 if (gSystem->Load("liblog4cxx.so") >= 0) {
00111 cout << " + liblog4cxx.so";
00112 if(gSystem->Load("libStStarLogger.so") >= 0) {
00113 cout << " + libStStarLogger.so";
00114 gROOT->ProcessLine("StLoggerManager::StarLoggerInit();");
00115 }
00116 }
00117 gSystem->Load("libHtml");
00118 gSystem->Load("libStChain");
00119 gSystem->Load("libStUtilities");
00120 gSystem->Load("libStBFChain");
00121 gSystem->Load("libStChallenger");
00122 cout << endl;
00123 }
00124
00125 void bfc(Int_t First, Int_t Last,
00126 const Char_t *Chain,
00127 const Char_t *infile,
00128 const Char_t *outfile,
00129 const Char_t *TreeFile)
00130 {
00131
00132
00133
00134
00135 if (gClassTable->GetID("StBFChain") < 0) Load(Chain);
00136 chain = new StBFChain(); cout << "Create chain " << chain->GetName() << endl;
00137 TString tChain(Chain);
00138 chain->cd();
00139 chain->SetDebug(1);
00140 if (Last < -3) return;
00141 chain->SetFlags(Chain);
00142 if (tChain == "" || ! tChain.CompareTo("ittf",TString::kIgnoreCase)) Usage();
00143 chain->Set_IO_Files(infile,outfile);
00144 if (TreeFile) chain->SetTFile(new TFile(TreeFile,"RECREATE"));
00145 gMessMgr->QAInfo() << Form("Process [First=%6i/Last=%6i/Total=%6i] Events",First,Last,Last-First+1) << endm;
00146 if (Last < -2) return;
00147 if (chain->Load() > kStOk) {
00148 gMessMgr->Error() << "Problems with loading of shared library(ies)" << endm;
00149 gSystem->Exit(1);
00150 }
00151 if (Last < -1) return;
00152 if (chain->Instantiate() > kStOk) {
00153 gMessMgr->Error() << "Problems with instantiation of Maker(s)" << endm;
00154 gSystem->Exit(1);
00155 }
00156 StMaker::lsMakers(chain);
00157 if (Last < 0) return;
00158 StMaker *dbMk = chain->GetMaker("db");
00159 if (dbMk) dbMk->SetDebug(1);
00160 #if 0
00161
00162 Char_t *myMaker = "St_TLA_Maker";
00163 if (gClassTable->GetID(myMaker) < 0) {
00164 gSystem->Load(myMaker);
00165 }
00166 StMaker *myMk = chain->GetMaker(myMaker);
00167 if (myMk) delete myMk;
00168 myMk = chain->New(myMaker,"before");
00169 if (myMk) {
00170 Char_t *before = "tpc_hits";
00171 StMaker *tclmk = chain->GetMaker(before);
00172 if (tclmk) chain->AddBefore(before,myMk);
00173 }
00174
00175 myMk = chain->New(myMaker,"after");
00176 if (myMk) {
00177 Char_t *after = "tpc_hits";
00178 StMaker *tclmk = chain->GetMaker(after);
00179 if (tclmk) chain->AddAfter(after,myMk);
00180 }
00181
00182
00183
00184
00185 if (chain->GetOption("TpcT0")) {
00186 StTpcT0Maker *t0mk = (StTpcT0Maker *) chain->GetMaker("TpcT0");
00187 if (t0mk) t0mk->SetDesiredEntries(10);
00188 }
00189 #endif
00190 {
00191 TDatime t;
00192 gMessMgr->QAInfo() << Form("Run is started at Date/Time %i/%i",t.GetDate(),t.GetTime()) << endm;
00193 }
00194 gMessMgr->QAInfo() << Form("Run on %s in %s",gSystem->HostName(),gSystem->WorkingDirectory()) << endm;
00195 gMessMgr->QAInfo() << Form("with %s", chain->GetCVS()) << endm;
00196
00197 TAttr::SetDebug(0);
00198 chain->SetAttr(".Privilege",0,"*" );
00199 chain->SetAttr(".Privilege",1,"StIOInterFace::*" );
00200 chain->SetAttr(".Privilege",1,"St_geant_Maker::*");
00201 chain->SetAttr(".Privilege",1,"StTpcDbMaker::*");
00202 chain->SetAttr(".Privilege",1,"*::tpc_hits");
00203 chain->SetAttr(".Privilege",1,"*::tpx_hits");
00204 chain->SetAttr(".Privilege",1,"StTpcHitMover::*");
00205 chain->SetAttr(".Privilege",1,"*::tpcChain");
00206 chain->SetAttr(".Privilege",1,"StTriggerDataMaker::*");
00207 Int_t iInit = chain->Init();
00208 if (iInit >= kStEOF) {chain->FatalErr(iInit,"on init"); return;}
00209 if (Last == 0) return;
00210 StEvtHddr *hd = (StEvtHddr*)chain->GetDataSet("EvtHddr");
00211 if (hd) hd->SetRunNumber(-2);
00212
00213 chain->EventLoop(First,Last,0);
00214 gMessMgr->QAInfo() << "Run completed " << endm;
00215 }
00216
00217 void bfc(Int_t Last,
00218 const Char_t *Chain,
00219 const Char_t *infile,
00220 const Char_t *outfile,
00221 const Char_t *TreeFile) {
00222 bfc(1,Last,Chain,infile,outfile,TreeFile);
00223 }
00224
00225 void Usage() {
00226 printf ("============= \t U S A G E =============\n");
00227 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");
00228 printf ("bfc(Int_t Last,const Char_t *Chain,const Char_t *infile,const Char_t *outfile,const Char_t *TreeFile)\n");
00229 printf ("bfc(const Char_t *ChainShort,Int_t Last,const Char_t *infile,const Char_t *outfile)\n");
00230 printf ("where\n");
00231 printf (" First \t- First event to process\t(Default = 1)\n");
00232 printf (" Last \t- Last event to process\t(Default = 1)\n");
00233 printf (" Chain \t- Chain specification \t(without First & Last: Default is \"\" which gives this message)\n");
00234 printf (" \t \t with First || Last: Default is \"gstar tfs\")\n");
00235 printf (" infile \t- Name of Input file \t(Default = 0, i.e. use preset file names depending on Chain)\n");
00236 printf (" outfile \t- Name of Output file \t(Default = 0, i.e. define Output file name from Input one)\n");
00237 printf (" outfile \t- Name of Tree File \t(Default = 0, i.e. define Output file name from Input one (tags TNtuple))\n");
00238 printf (" ChainShort\t- Short cut for chain \t(Default = \"\" -> print out of this message)\n");
00239 gSystem->Exit(1);
00240 }
00241
00242 void bfc(const Char_t *Chain="ittf") {
00243 bfc(-2,Chain);
00244 }