StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
StBFChain.cxx
1 // @(#)StRoot/StBFChain:$Name: $:$Id: StBFChain.cxx,v 1.670 2021/03/21 03:32:28 genevb Exp $
2 
3 #include "TROOT.h"
4 #include "TPRegexp.h"
5 #include "TString.h"
6 #include "TObjString.h"
7 #include "TSystem.h"
8 #include "TInterpreter.h"
9 #include "TClassTable.h"
10 #include "StMemStat.h"
11 #include "StBFChain.h"
12 #include "StBFChainOpt.h"
13 #include "St_db_Maker/St_db_Maker.h"
14 #include "StTreeMaker/StTreeMaker.h"
15 #include "StIOMaker/StIOMaker.h"
16 #include "StMessMgr.h"
17 #include "StShadowMaker/StShadowMaker.h"
18 #include "StEnumerations.h"
19 #include "TTree.h"
20 #include "TEnv.h"
21 #define STAR_LOGGER 1
22 // PLease, preserve the comment after = { . It is used for documentation formatting
23 //
24 #if 0
25 // Keep to be compatible with old documentaion
26 #define STR_OBSOLETE "WARNING *** Option is OBSOLETE ***"
27 
28 //#include "BFC.h"
29 // ITTF Chain will be put here. Option list starting from minimalistic requirements
30 // and may not initially work.
31 // Please, preserve the comment after = { . It is used for documentation formatting
32 //
33 // ITTF Chains
34 //#include "BFC2.h"
35 #endif
36 
37 // JL - define this once, use two places
38 #define BFC_DBREGEXP "(dbv|sdt)(\\d+)(_)(.*)(_)(.*)"
39 
40 
41 // NoChainOptions -> Number of chain options auto-calculated
42 TableImpl(Bfc);
43 ClassImp(StBFChain);
44 
45 StBFChain *chain = nullptr;
46 
47 //_____________________________________________________________________________
48 // Hack constructor.
59 void StBFChain::Setup(Int_t mode) {
60  static const Char_t *path = "./StRoot/StBFChain:$STAR/StRoot/StBFChain";
61  TString fileName("BFC.C");
62  Char_t *file = gSystem->Which(path,fileName,kReadPermission);
63 #ifdef STAR_LOGGER
64  if (! file) { LOG_FATAL << Form("StBFChain::Setup\tFile %s has not been found in path %s",fileName.Data(),path) << endm; }
65  else { LOG_WARN << Form("StBFChain::Setup\tFile %s has been found as %s",fileName.Data(),file) << endm; }
66 #else
67 
68  if (! file) Fatal("StBFChain::Setup","File %s has not been found in path %s",fileName.Data(),path);
69  else Warning("StBFChain::Setup","File %s has been found as %s",fileName.Data(),file);
70 #endif
71  TString cmd(".L ");
72  cmd += file;
73  gInterpreter->ProcessLine(cmd);
74  fchainOpt = (St_Bfc *) gInterpreter->Calc("CreateTable()");
75  cmd = ".U ";
76  cmd += file;
77  gInterpreter->ProcessLine(cmd);
78  assert(fchainOpt);
79  delete [] file;
80  fNoChainOptions = fchainOpt->GetNRows();
81  fBFC = fchainOpt->GetTable();
82  // add predifined time stamps and geometry versions
83  const DbAlias_t *DbAlias = GetDbAliases();
84  Bfc_st row = {"","","","db,detDb","","","",kFALSE};
85  for (Int_t i = 0; DbAlias[i].tag; i++) {
86  for (Int_t r = 0; r < 2; r++) {
87  TString dbTag("");
88  if (r) dbTag += "r";
89  dbTag += DbAlias[i].tag;
90  if (! kOpt(dbTag,kFALSE)) {
91  memset (&row.Key, 0, sizeof(row.Key));
92  memcpy (&row.Key, dbTag.Data(), dbTag.Length());
93  fchainOpt->AddAt(&row);
94  fNoChainOptions = fchainOpt->GetNRows();
95  fBFC = fchainOpt->GetTable();
96  }
97  }
98  }
99  FDate = FTime = 0;
100  FDateS = FTimeS = 0;
101  fFiltTrg = "";
102  fRunG = -1;
103  fFmsGainCorrTag="";
104  Gproperty.clear();
105  Gvalue.clear();
106  Gpattern.clear();
107 
108 
109 }
110 //_____________________________________________________________________________
113  Finish();
114 }
115 //_____________________________________________________________________________
118 {
119  static const Char_t *prefix[3] = {"lib_","lib",""};
120  Int_t status = kStOk;
121  Int_t i, iok;
122  TString lib(gSystem->GetLibraries(0,"D"));
123  TObjArray LoadedLibs;
124  ParseString(lib,LoadedLibs);
125  TIter next(&LoadedLibs);
126  TObjString *LoadedLib;
127  while ((LoadedLib = (TObjString *) next())){
128  TString Base(gSystem->BaseName(LoadedLib->GetName()));
129  Base.ReplaceAll(".so","");
130  Base.ReplaceAll(".sl","");
131  if (Base.BeginsWith("lib_")) Base.ReplaceAll("lib_","");
132  if (Base.BeginsWith("lib")) Base.ReplaceAll("lib","");
133  LoadedLib->SetString(Base);
134  }
135  for (i = 1; i< fNoChainOptions; i++) { // Load Libraries if any
136  if (fBFC[i].Flag) {
137  if (strlen(fBFC[i].Libs) > 0) {
138  TObjArray Libs;
139  ParseString(fBFC[i].Libs,Libs);
140  TIter nextL(&Libs);
141  TObjString *libe = 0;
142  Char_t *path = 0;
143  while ((libe = (TObjString *) nextL())) {
144  TString libN(libe->GetString());
145  if (libN.BeginsWith("lib_")) libN.ReplaceAll("lib_","");
146  if (libN.BeginsWith("lib")) libN.ReplaceAll("lib","");
147 
148  TString libL("");
149  for (Int_t j = 0; j < 3; j++) {
150  libL = prefix[j]; libL += libN;
151  //LOG_QA << " Checking " << libL << endm;
152  if ((path = gSystem->DynamicPathName(libL,kTRUE))) break;
153  }
154  iok = -1;
155  if (path) {
156  TIter next(&LoadedLibs);
157  TObjString *LoadedLib;
158  while ((LoadedLib = (TObjString *) next())){
159  TString Base(LoadedLib->GetName());
160  //LOG_QA << " Checking " << Base << endm;
161  if (Base == libN) {iok = 1; break;}
162  }
163  if (iok > 0) continue;
164 
165 
166  //LOG_QA << "Trying to load Library " << libL << endm;
167 
168 
169  iok = gSystem->Load(libL);
170  if (iok < 0) {
171 
172  LOG_FATAL << "problem with loading of " << libL.Data() << endm;
173  LOG_FATAL << fBFC[i].Key << " is switched off \t!!!!" << endm;
174 
175  //fBFC[i].Flag = kFALSE;
176  //status = kStErr;
177  //assert(iok >= 0); ?? obviously it is so, but not very specific
178  Int_t libraryload = kStErr;
179  assert(libraryload!=kStErr); // this is obvious and will display an explicit
180  break;
181  } else {
182  LOG_QA << Form("Library %-22s [%15s] (%s)\tis loaded",libL.Data(),fBFC[i].Key,path) << endm;
183  StMemStat::doPs(libL.Data(), "Load");
184  LoadedLibs.Add(new TObjString(libN));
185  }
186  } else {
187  if ( ! index(fBFC[i].Libs,',') || Debug() > 1 ) {
188  LOG_WARN << "No path for Key=" << fBFC[i].Key << "-> Searched for [" << libL
189  << "] from Libs=" << fBFC[i].Libs << " (will proceed)" << endm;
190  }
191  }
192  }
193  Libs.Delete();
194  }
195  }
196  }
197  LoadedLibs.Delete();
198  return status;
199 }
200 
201 //_____________________________________________________________________________
203 
215 {
216  Int_t status = kStOk;
217  Int_t i;
218  if (! fNoChainOptions) return status;
219  Long64_t maxsize = kMaxLong64;
220  TTree::SetMaxTreeSize(maxsize);
221  for (i = 1; i< fNoChainOptions; i++) {// Instantiate Makers if any
222  if (! fBFC[i].Flag) continue;
223  TString maker(fBFC[i].Maker);
224  if (maker == "") continue;
225  TString Key(fBFC[i].Key);
226  TString name(fBFC[i].Name);
227  Key.ToLower();
228  StMaker *myChain = 0;
229  StMaker *mk = 0;
230  // Require only instance for the following named makers
231  if (maker == "St_db_Maker" || maker == "StTpcDbMaker" ||
232  maker == "StSvtDbMaker" || maker == "StSsdDbMaker" || maker == "StSstDbMaker" ||
233  maker == "StDetectorDbMaker" ||
234  maker == "StMagFMaker" ||
235  maker == "StEEmcDbMaker" ||
236  maker == "St_geant_Maker" ||
237  maker == "StVMCMaker") {
238  mk = GetTopChain()->GetMakerInheritsFrom(maker);
239  if (mk) {
240  if (maker == "St_geant_Maker" || maker == "StVMCMaker") {
241  LOG_INFO << "StBFChain::Instantiate ignore request for instantiation of " << maker
242  << "(\"" << fBFC[i].Name << "\") because chain alreary has one." << endm;
243  continue;
244  }
245  if (name == "" || name == mk->GetName()) {
246  LOG_INFO << "StBFChain::Instantiate ignore request for instantiation of " << maker
247  << "(\"" << fBFC[i].Name << "\") because chain alreary has one"
248  << " but accumulate options" << endm;
249  //Accumulate option for these makers continue;
250  }
251  }
252  }
253  if (strlen(fBFC[i].Chain) > 0) myChain = GetMaker(fBFC[i].Chain);
254  if (maker == "St_db_Maker"){
255  if (Key.CompareTo("db",TString::kIgnoreCase) == 0) {
256  St_db_Maker* dbMk = (St_db_Maker *) mk;
257  if (! dbMk) {
258  TString MySQLDb("MySQL:StarDb");
259  TString MainCintDb("$STAR/StarDb");
260  TString MainCintDbObj("$STAR/.$STAR_HOST_SYS/obj/StarDb");
261  TString MyCintDb("$PWD/StarDb");
262  TString MyCintDbObj("$PWD/.$STAR_HOST_SYS/obj/StarDb");
263  if (GetOption("NoMySQLDb")) {MySQLDb = "";}
264  // Removed twice already and put back (start to be a bit boring)
265  // DO NOT REMOVE THE NEXT OPTION - Used in AutoCalibration
266  if (GetOption("NoLocalCintDb")) {MyCintDb = "";}
267  if (GetOption("NoStarCintDb") ) {MainCintDb = "";}
268  if (GetOption("NoCintDb") ) {MainCintDb = ""; MyCintDb = "";}
269 
270  TString Dirs[10];
271  Int_t j;
272  for (j = 0; j < 10; j++) Dirs[j] = "";
273  j = 0;
274  if (MySQLDb != "") {Dirs[j] = MySQLDb; j++;}
275  if (MainCintDb != "") {Dirs[j] = MainCintDb; j++;}
276  if (MainCintDbObj != "") {Dirs[j] = MainCintDbObj; j++;}
277  if (MyCintDb != "") {Dirs[j] = MyCintDb; j++;}
278  if (MyCintDbObj != "") {Dirs[j] = MyCintDbObj; j++;}
279  dbMk = new St_db_Maker(fBFC[i].Name,Dirs[0],Dirs[1],Dirs[2],Dirs[3],Dirs[4]);
280  if (!dbMk) goto Error;
281 
282  TString namec = dbMk->GetName();
283  int len = sizeof(fBFC[i].Name);
284  if ( namec.Length() <= len){
285  strncpy (fBFC[i].Name, namec.Data(),len);
286  } else {
287  gMessMgr->Error() << "Maker name [" << namec
288  << "] length is > " << len
289  << " - increase BFC Name field length" << endm;
290  }
291 
292  // Determine flavors
293  TString flavors = "ofl"; // default flavor for offline
294 
295  // fixed target flavor
296  if (GetOption("FXT")) flavors.Prepend("FXT+");
297 
298  // simulation flavors
299  if (GetOption("Simu") && ! GetOption("NoSimuDb")) flavors.Prepend("sim+");
300 
301  // filestream flavors
302  if (fSetFiles) {
303  TString firstFileName = fSetFiles->GetFileName(0);
304  firstFileName = firstFileName(firstFileName.Last('/')+1,firstFileName.Length());
305  if (firstFileName.BeginsWith("st_")) {
306  TString fileStream = firstFileName(3,firstFileName.Index('_',3)-3);
307  if (fileStream.Length()>0) flavors.Prepend(fileStream += '+');
308  }
309  }
310 
311  LOG_INFO << "Using DB flavors: " << flavors << endm;
312  dbMk->SetFlavor(flavors.Data());
313  mk = dbMk;
314  }
315  if (GetOption("dbSnapshot")) dbMk->SetAttr("dbSnapshot","dbSnapshot.root",dbMk->GetName());
316  SetDbOptions(dbMk);
317  }
318  goto Add2Chain;
319  }
320  if (!mk && maker == "StIOMaker" && fSetFiles) {
321  StIOMaker *inpMk=0;
322  if (GetOption("InTree")) {
323  Char_t line[80] = "bfcTree";
324  Int_t k = kOpt("InTree");
325  sscanf(fBFC[k].Comment,"%s",line);
326  inpMk = new StIOMaker("inputStream","r",fSetFiles,line);
327  }
328  else inpMk = new StIOMaker("inputStream","r",fSetFiles);
329  mk = inpMk;
330  if (mk) {
331  TString namec = mk->GetName();
332  int len = sizeof(fBFC[i].Name);
333  if ( namec.Length() <= len){
334  strncpy (fBFC[i].Name, namec.Data() , len);
335  } else {
336  gMessMgr->Error() << "Maker name [" << namec
337  << "] length is > " << len
338  << " - increase BFC Name field length" << endm;
339  }
340 
341  SetInput("StDAQReader",".make/inputStream/.make/inputStream_DAQ/.const/StDAQReader");
342  if (GetOption("ReadAll")) { //activate all branches
343  // inpMk->SetBranch("*",0,"r");
344  const Char_t *allBranches[] = {
345  "emc_rawBranch","eventBranch","ftpc_rawBranch",
346  "geantBranch","globalBranch","McEventBranch","svt_hitsBranch","svt_tracksBranch",
347  "tpc_hitsBranch","trgBranch",0};
348  for (Int_t i = 0; allBranches[i]; i++) inpMk->SetBranch(allBranches[i],0,"r");
349  }
350  if (GetOption("adcOnly")) mk->SetAttr("adcOnly",1); ;
351  goto Add2Chain;
352  }
353  goto Error;
354  }
355  if (!mk && maker == "StTreeMaker" && fFileOut != "") {
356  StTreeMaker *treeMk = 0;
357  if (GetOption("OutTree")) {
358  Char_t line[80] = "bfcTree";
359  Int_t k = kOpt("OutTree");
360  sscanf(fBFC[k].Comment,"%s",line);
361  treeMk = new StTreeMaker("outputStream",fFileOut.Data(),line);
362  }
363  else treeMk = new StTreeMaker("outputStream",fFileOut.Data());
364  mk = treeMk;
365  if (mk) {
366  TString namec = treeMk->GetName();
367  int len = sizeof(fBFC[i].Name);
368  if ( namec.Length() <= len ){
369  strncpy (fBFC[i].Name, namec.Data() , len);
370  } else {
371  gMessMgr->Error() << "Maker name [" << namec
372  << "] length is > " << len
373  << " - increase BFC Name field length" << endm;
374  }
375  treeMk->SetIOMode("w");
376  SetTreeOptions();
377  goto Add2Chain;
378  }
379  }
380  // Special makers already created or action which
381  // need to take place before 'maker' is created.
382  if (! mk) {
383  if (strlen(fBFC[i].Name) > 0) mk = New(fBFC[i].Maker,fBFC[i].Name);
384  else mk = New(fBFC[i].Maker);
385  if (! mk) {
386  LOG_FATAL << Form("StBFChain::Instantiate() problem with instantiation Maker=[%s] Name=[%s]",fBFC[i].Maker,fBFC[i].Name) << endm;
387  assert(mk);
388  }
389  }
390 
391  {
392  TString namec = mk->GetName();
393  int len = sizeof(fBFC[i].Name);
394  if ( namec.Length() <= len){
395  strncpy (fBFC[i].Name,namec.Data(),len);
396  } else {
397  gMessMgr->Error() << "Maker name [" << namec
398  << "] length is > " << len
399  << " - increase BFC Name field length" << endm;
400  }
401  }
402 
403  if (maker == "StTpcDbMaker" && GetOption("laserIT")) mk->SetAttr("laserIT" ,kTRUE);
404  if (maker == "StDAQMaker") {
405  if (GetOption("adcOnly")) mk->SetAttr("adcOnly",1); ;
406  }
407 
408  if (maker == "St_geant_Maker") { // takes only first request for geant, if it is active then it should be the first one
409  Int_t NwGeant = 10; // default geant parameters
410  if (!GetOption("fzin") &&
411  !GetOption("ntin") &&
412  !GetOption("gstar") &&
413  !GetOption("pythia")) NwGeant = 5;
414  if (GetOption("big")) NwGeant = 20;
415  if (GetOption("bigbig")) NwGeant = 40;
416  if (GetOption("huge")) NwGeant = 80;
417  ProcessLine(Form("((St_geant_Maker *) %p)->SetNwGEANT(%i);",mk,NwGeant));
418  if (GetOption("Higz")) ProcessLine(Form("((St_geant_Maker *) %p)->SetIwtype(1);",mk));
419  if (GetOption("paw")) ProcessLine(Form("((St_geant_Maker *) %p)->SetNwPAW(2);",mk));
420  if (GetOption("fzin") ||
421  GetOption("ntin") ||
422  GetOption("gstar") ||
423  GetOption("pythia") ||
424  GetOption("hijing") ||
425  GetOption("PrepEmbed") ||
426  GetOption("mtin")) {
427  mk->SetActive(kTRUE);
428  // if (GetOption("PrepEmbed")) mk->SetMode(10*(mk->GetMode()/10)+1);
429  if (GetOption("PrepEmbed") || GetOption("pythiaEmbed")) mk->SetAttr("Don'tTouchTimeStamp",kTRUE);
430  if (GetOption("flux")) mk->SetAttr("flux",kTRUE);
431  if (GetOption("pythia")) {
432  mk->SetAttr("Pythia",kTRUE);
433  if (GetOption("Wenu")) mk->SetAttr("Wenu",kTRUE);
434  if (GetOption("beamLine")) mk->SetAttr("beamLine",kTRUE);
435  }
436  if (GetOption("hijing")) {
437  mk->SetAttr("hijing",kTRUE);
438  }
439  }
440  else mk->SetActive(kFALSE);
441  //if (! mk) goto Error;
442  SetGeantOptions(mk);
443  }
444 
445  // special maker options
446  // m_Mode xyz
447  // x = 1 phys_off
448  // y = 1 Passive mode (do not call RunMC()
449  // z = 1 Mixer Mode
450  if (maker == "StVMCMaker") {
451  if (GetOption("VMCPassive")) {// don't use mk->SetActive(kFALSE) because we want to have InitRun
452  mk->SetAttr("VMCPassive",kTRUE);
453  }
454  else {
455  if (GetOption("phys_off")) mk->SetAttr("phys_off",kTRUE);
456  if (GetOption("hadr_off")) mk->SetAttr("hadr_off",kTRUE);
457  if (fInFile != "") {
458  if (ProcessLine(Form("((StVMCMaker *) %p)->SetInputFile(\"%s\")",mk,fInFile.Data())))
459  goto Error;
460  }
461  }
462  if (GetOption("Embedding")) mk->SetAttr("Embedding",kTRUE);
463  }
464 
465  // ---
466  // Sti(ITTF) start
467  // ---
468  if (maker == "StiMaker" || maker == "StiVMCMaker" ) {
469 
470  // When StiCA library is requested CA will be used as seed finder in StiMaker
471  if ( GetOption("StiCA") ) {
472  mk->SetAttr("seedFinders", "CA DEF");
473  }
474 
475  // Option to re-use hits in other tracks
476  if ( GetOption("hitreuseon") ){
477  mk->SetAttr("SetMaxTimes", 100);
478  }
479 
480  // By default iTpc hits are used in tracking
481  mk->SetAttr("activeiTpc", GetOption("iTpcIT") ? kTRUE : kFALSE);
482 
483  // old logic for svt and ssd
484  if (GetOption("NoSvtIT")){
485  mk->SetAttr("useSvt" ,kFALSE);
486  } else {
487  if (GetOption("SvtIT")){
488  mk->SetAttr("useSvt" ,kTRUE);
489  mk->SetAttr("activeSvt" ,kTRUE);
490  }
491  }
492  if ( GetOption("NoSsdIT") &&
493  !GetOption("SstIT") ){
494  mk->SetAttr("useSsd" ,kFALSE);
495  } else {
496  if (GetOption("SsdIT")){
497  mk->SetAttr("useSsd" ,kTRUE);
498  mk->SetAttr("activeSsd" ,kTRUE);
499  }
500  }
501 
502  // this was an R&D detector never implemented
503  // simulations were made nonetheless
504  if (GetOption("HpdIT")){
505  mk->SetAttr("useHpd" ,kTRUE);
506  mk->SetAttr("activeHpd" ,kTRUE);
507  }
508 
509  // back to the HFT sub-system
510  if (GetOption("NoPxlIT")) {
511  mk->SetAttr("usePxl" ,kTRUE);
512  mk->SetAttr("usePixel" ,kTRUE);
513  } else {
514  if (GetOption("PixelIT") || GetOption("PxlIT") ){
515  mk->SetAttr("usePxl" ,kTRUE);
516  mk->SetAttr("usePixel" ,kTRUE);
517  mk->SetAttr("activePxl" ,kTRUE);
518  mk->SetAttr("activePixel",kTRUE);
519  }
520  }
521  if (GetOption("NoIstIT")) {
522  mk->SetAttr("useIst" ,kTRUE);
523  } else {
524  if (GetOption("IstIT")){
525  mk->SetAttr("useIst" ,kTRUE);
526  mk->SetAttr("activeIst" ,kTRUE);
527  }
528  }
529  if (GetOption("NoSstIT")) {
530  mk->SetAttr("useSst" ,kTRUE);
531  } else {
532  if (GetOption("SstIT")){
533  mk->SetAttr("useSst" ,kTRUE);
534  mk->SetAttr("activeSst" ,kTRUE);
535  }
536  }
537 
538  // other sub-systems
539  if (GetOption("BTofIT")){
540  mk->SetAttr("useBTof" ,kTRUE);
541  mk->SetAttr("activeBTof" ,kTRUE);
542  }
543 
544  if (GetOption("StiPulls")) mk->SetAttr("makePulls" ,kTRUE);
545  if (GetOption("skip1row")) mk->SetAttr("skip1row" ,kTRUE);
546  if (GetOption("EastOff")) mk->SetAttr("EastOff" ,kTRUE);
547  if (GetOption("WestOff")) mk->SetAttr("WestOff" ,kTRUE);
548  if (GetOption("laserIT")) mk->SetAttr("laserIT" ,kTRUE);
549  if (GetOption("Alignment")) mk->SetAttr("Alignment" ,kTRUE);
550  if (GetOption("Cosmics")) mk->SetAttr("Cosmics" ,kTRUE);
551  mk->PrintAttr();
552  }
553  if (maker=="StKFVertexMaker" && GetOption("laserIT")) mk->SetAttr("laserIT" ,kTRUE);
554  // Sti(ITTF) end
555  if (maker=="StGenericVertexMaker") {
556  // VertexFinder methods
557  if (GetOption("Sti") || GetOption("StiCA") || GetOption("StiVMC" ) ) mk->SetAttr("ITTF" , kTRUE);
558  if (GetOption("VFMinuit" ) ) mk->SetAttr("VFMinuit" , kTRUE);
559  if (GetOption("VFppLMV" ) ) mk->SetAttr("VFppLMV" , kTRUE);
560  if (GetOption("VFppLMV5" ) ) mk->SetAttr("VFppLMV5" , kTRUE);
561  if ( GetOption("VFPPVEv") ) {
562  gSystem->Load("StBTofUtil.so");
563  mk->SetAttr("VFPPVEv" , kTRUE);
564  }
565  else if (GetOption("VFPPV") && GetOption("Sti")) mk->SetAttr( "VFPPV", kTRUE);
566  if (GetOption("VFPPVEvNoBtof")){
567  gSystem->Load("StBTofUtil.so"); //Not used but loaded to avoid fail
568  mk->SetAttr("VFPPVEvNoBtof", kTRUE);
569  }
570  if (GetOption("VFPPVnoCTB" ) ) mk->SetAttr("VFPPVnoCTB" , kTRUE);
571  if (GetOption("VFFV" ) ) mk->SetAttr("VFFV" , kTRUE);
572  if (GetOption("VFMCE" ) ) mk->SetAttr("VFMCE" , kTRUE);
573  if (GetOption("VFMinuit2" ) ) mk->SetAttr("VFMinuit2" , kTRUE);
574  if (GetOption("VFMinuit3" ) ) mk->SetAttr("VFMinuit3" , kTRUE);
575  if (GetOption("beamLine" ) ) mk->SetAttr("BeamLine" , kTRUE);
576  if (GetOption("beamLine3D" ) ) mk->SetAttr("BeamLine3D" , kTRUE);
577  if (GetOption("CtbMatchVtx") ) mk->SetAttr("CTB" , kTRUE);
578  if (GetOption("min2trkVtx" ) ) mk->SetAttr("minTracks" , 2);
579  if (GetOption("VtxSeedCalG") ) mk->SetAttr("calibBeamline" , kTRUE);
580  if (GetOption("usePct4Vtx" ) ) mk->SetAttr("PCT" , kTRUE);
581  if (GetOption("useBTOF4Vtx") ) mk->SetAttr("BTOF" , kTRUE);
582  if (GetOption("useBTOFmatchOnly") ) mk->SetAttr("useBTOFmatchOnly", kTRUE);
583  if (GetOption("FXT" ) ) mk->SetAttr("FXT" , kTRUE);
584 
585  // X-tended works only for VFPPV, VFPPVnoCTB, VFPPVev for now but could be re-used
586  // However, we will change this to a more flexible arbitrarry setting later
587  if (GetOption("VFStoreX") ) mk->SetAttr("VFStore" , 100);
588  //if (GetOption("VFStoreX") ) mk->SetAttr("VFStore" , 100);
589  mk->PrintAttr();
590  }
591  if (maker=="StKFVertexMaker") {
592  if (GetOption("beamLine" ) ) mk->SetAttr("BeamLine" , kTRUE);
593  }
594  if (maker=="StAssociationMaker") {
595 
596  LOG_QA << "StBFChain::Instantiate Setting the Parameters for the Association Maker" << endm;
597 
598  TString cmd("");
599  if (GetOption("ITTF") || GetOption("StiVMC") || GetOption("useInTracker"))
600  cmd = Form ("((StAssociationMaker *) %p)->useInTracker();",mk);
601  cmd += "StMcParameterDB* parameterDB = StMcParameterDB::instance();";
602  // TPC
603 #if 0
604  cmd += "parameterDB->setXCutTpc(.5);"; // 5 mm
605  cmd += "parameterDB->setYCutTpc(.5);"; // 5 mm
606  cmd += "parameterDB->setZCutTpc(.5);"; // 5 mm
607 #endif
608  cmd += "parameterDB->setReqCommonHitsTpc(3);"; // Require 3 hits in common for tracks to be associated
609  // FTPC
610 #if 0
611  cmd += "parameterDB->setRCutFtpc(.3);"; // 3 mm
612  cmd += "parameterDB->setPhiCutFtpc(5*(3.1415927/180.0));"; // 5 degrees
613 #endif
614  cmd += "parameterDB->setReqCommonHitsFtpc(3);"; // Require 3 hits in common for tracks to be associated
615  // SVT
616 #if 0
617  cmd += "parameterDB->setXCutSvt(.08);"; // 800 um
618  cmd += "parameterDB->setYCutSvt(.08);"; // 800 um
619  cmd += "parameterDB->setZCutSvt(.08);"; // 800 um
620 #endif
621  cmd += "parameterDB->setReqCommonHitsSvt(1);"; // Require 1 hits in common for tracks to be associated
622  if (GetOption("IdTruth")) cmd += Form("((StAssociationMaker *) %p)->useIdAssoc();",mk);
623  ProcessLine(cmd);
624  }
625  if (maker == "StMiniMcMaker" && GetOption("IdTruth") && ! GetOption("OldMiniMc")) {
626  mk->SetMode(1);
627  gMessMgr->QAInfo() << "StBFChain::Instantiate create simplified MiniMcTree in " << maker << endm;
628  }
629  // usually, we do maker first and option second but the
630  // logic is more readable with option first here (as it
631  // got a bit out of hand)
632  if (GetOption("ppOpt") ) { // pp specific stuff
633  if (maker == "StTrsMaker")
634  mk->SetMode(1); // Pile-up correction
635  }
636 
637  if (maker == "StStrangeMuDstMaker" && GetOption("CMuDST")&& GetOption("StrngMuDST") ) {
638 
639  mk -> SetAttr( "DoV0", 1 );
640  mk -> SetAttr( "DoXi", 1 );
641  mk -> SetAttr( "DoKink", 1 );
642  mk -> SetAttr( "SetNoKeep", 1 );
643 
644  }
645 
646  // Alex requested an option (not turned by default) to disable all
647  // hit reco cuts. This will make allm hits saved to MuDST /ezTree.
648  if ( maker == "StEmcRawMaker" && GetOption("BEmcDebug"))
649  mk->SetMode(1); // only one option now, bit a bitmask
650 
651  // Use status tables for raw BEMC data (helpful for QA)
652  if ( maker == "StEmcRawMaker" && GetOption("BEmcChkStat"))
653  mk->SetAttr("BEmcCheckStatus",kTRUE);
654 
655  // trigger simu maker
656  if ( maker == "StEmcRawMaker" && GetOption("picoWrite") ) {
657  mk->SetMode(10); // picoDst production - save all BTOW hits for triggerSimuMaker
658  }
659 
660  // trigger simu maker
661  if ( maker == "StTriggerSimuMaker" && GetOption("picoWrite") ) {
662  mk->SetMode(10); // picoDst production
663  }
664 
665  // MuDST and ezTree. Combinations are
666  // ezTree -> ezTree only
667  // CMuDST -> regular MuDST only
668  // ezTree,CMuDST -> both
669  if (maker == "StMuDstMaker" && GetOption("ezTree") ){
670  TString cmd(Form("StMuDstMaker *pMuMk = (StMuDstMaker *) %p;",mk));
671  if ( ! GetOption("CMuDST")) cmd += "pMuMk->SetStatus(\"*\",0);";
672  cmd += "pMuMk->SetStatus(\"EztAll\",1);";
673  ProcessLine(cmd);
674  }
675 
676  // FST Raw hits in StEvent
677  if (maker == "StFstRawHitMaker" && GetOption("fstEvtRawHit") ){
678  mk->SetAttr("fstEvtRawHit", kTRUE);
679  }
680 
681  // FST Raw hits in MuDST
682  if (maker == "StMuDstMaker" && GetOption("fstMuRawHit") ){
683  mk->SetAttr("fstMuRawHit", kTRUE);
684  }
685 
686  if ( maker == "StPicoDstMaker"){
687  if ( GetOption("picoWrite") ) mk->SetMode(1);
688  if ( GetOption("picoRead") ) mk->SetMode(2); // possibly more magic
689  if ( GetOption("PicoVtxVpd")) mk->SetAttr("PicoVtxMode", "PicoVtxVpd");
690  else if ( GetOption("PicoVtxFXT")) mk->SetAttr("PicoVtxMode", "PicoVtxFXT");
691  else if ( GetOption("PicoVtxMtd")) mk->SetAttr("PicoVtxMode", "PicoVtxMtd");
692  else if ( GetOption("PicoVtxVpdOrDefault")) mk->SetAttr("PicoVtxMode", "PicoVtxVpdOrDefault");
693  else if ( GetOption("PicoVtxDefault")) mk->SetAttr("PicoVtxMode", "PicoVtxDefault");
694  if ( GetOption("PicoCovMtxWrite")) mk->SetAttr("PicoCovMtxMode", "PicoCovMtxWrite");
695  else if ( GetOption("PicoCovMtxSkip")) mk->SetAttr("PicoCovMtxMode", "PicoCovMtxSkip"); // Default mode
696  if ( GetOption("PicoBEmcSmdWrite")) mk->SetAttr("PicoBEmcSmdMode", "PicoBEmcSmdWrite");
697  else if ( GetOption("PicoBEmcSmdSkip")) mk->SetAttr("PicoBEmcSmdMode", "PicoBEmcSmdSkip"); // Default mode
698  }
699 
700 
701  if (maker == "StLaserEventMaker"){
702  // Bill stuff - Empty place-holder
703  }
704  if (maker == "StDetectorDbMaker") {
705  if ( GetOption("DbRichSca") ) mk->SetMode(1);
706  }
707  if (maker == "StTpcRSMaker") {
708  if (! GetOption("TrsToF")) {
709  Int_t mode = mk->GetMode();
710  mode |= (1 << 10); // kNoToflight //10 don't account for particle time of flight
711  mk->SetMode(mode);
712  }
713  if (GetOption("EbyET0")) mk->SetAttr("EbyET0", kTRUE);
714  }
715  if (maker == "StTrsMaker") {
716  Int_t mode = 0;
717  if (GetOption("TrsPileUp")) mode += 1; // Pile-up correction
718  if (GetOption("TrsToF")) mode += 2; // account for particle time of flight
719  if (mode) mk->SetMode(mode);
720  }
721 
722  // Place-holder. Would possibly be a bitmask
723  if (maker == "StTofrMatchMaker"){
724  mk->SetMode(0);
725  }
726 
727  if (maker == "StSpaceChargeEbyEMaker") {
728  if ( GetOption("SpcChgCal") ||
729  GetOption("SpcChgCalG")) mk->SetMode(2);
730  if ( GetOption("SCScalerCal") ) mk->SetMode(4);
731  if ( GetOption("EastOff")) mk->SetAttr("EastOff",kTRUE);
732  if ( GetOption("WestOff")) mk->SetAttr("WestOff",kTRUE);
733  }
734  if (maker == "StEventQAMaker") {
735  if ( GetOption("QAalltrigs")) mk->SetAttr("allTrigs",kTRUE);
736  if ( GetOption("QAallevents")) mk->SetAttr("allEvents",kTRUE);
737  }
738  //Special options for V0s and Xis using estGlobal tracks
739  if(maker=="StV0FinderMaker" && Key=="v0svt"){
740  TString cmd(Form("StV0FinderMaker *V0mk=(StV0FinderMaker*) %p;",mk));
741  cmd += "V0mk->SetLanguageUsage(0);";
742  cmd += "V0mk->SetSVTUsage(1);";
743  cmd += "V0mk->SetV0LanguageUsage(3);";
744  ProcessLine(cmd);
745  }
746  if(maker=="StXiFinderMaker" && Key=="xisvt"){
747  TString cmd(Form("StXiFinderMaker *Ximk=(StXiFinderMaker*) %p;",mk));
748  cmd += "Ximk->SetLanguageUsage(0);";
749  cmd += "Ximk->SetSVTUsage(1);";
750  cmd += "Ximk->SetV0LanguageUsage(3);";
751  cmd += "Ximk->SetXiLanguageUsage(5);";
752  ProcessLine(cmd);
753  }
754 
755  // TPC
756  if (maker == "StTpcRTSHitMaker") {
757  if ( GetOption("TpxClu2D")) mk->SetAttr("TpxClu2D", kTRUE);
758  if ( GetOption("TPC23")) mk->SetAttr("TPC23", kTRUE);
759  }
760  if (maker == "StTpcDbMaker"){
761  if ( GetOption("Simu") && ! GetOption("NoSimuDb")) mk->SetAttr("Simu",kTRUE);
762  if ( GetOption("useLDV") ) mk->SetAttr("useLDV",kTRUE) ;// uses laserDV database
763  if ( GetOption("useCDV") ) mk->SetAttr("useCDV",kTRUE) ;// uses ofl database
764  if ( GetOption("useNewLDV") ) mk->SetAttr("useNewLDV",kTRUE);// uses new laserDV
765  if ( GetOption("shadow") ) mk->SetAttr("NoReset",kTRUE);// no resetting ExB
766  if ( GetOption("ExB")){
767  mk->SetAttr("ExB", kTRUE); // bit 0 is ExB ON or OFF
768  if ( GetOption("EB1") ) mk->SetAttr("EB1", kTRUE);
769  else if ( GetOption("EB2") ) mk->SetAttr("EB2", kTRUE);
770  else {
771  // depend on RY option i.e. take default for that RealYear data
772  // expectations.
773  if(GetOption("RY1H") ||
774  GetOption("RY2000") ||
775  GetOption("RY2001") ||
776  GetOption("RY2001N") ||
777  GetOption("RY2003") ||
778  GetOption("RY2003X")) mk->SetAttr("OldRuns", kTRUE);
779  }
780  // Other options introduced in October 2001 for distortion corrections
781  // studies and year1 re-production. Those are OR additive to the mask.
782  //(void) printf("StBFChain:: Options list : %d %d %d %d %d %d %d %d\n",
783  // kPadrow13,kTwist,kClock,kMembrane,kEndcap,
784  // kIFCShift,kSpaceCharge,kSpaceChargeR2);
785  if( GetOption("OBmap") ) mk->SetAttr("OBmap" , kTRUE);
786  if( GetOption("OPr13") ) mk->SetAttr("OPr13" , kTRUE);
787  if( GetOption("OPr40") ) mk->SetAttr("OPr40" , kTRUE);
788  if( GetOption("OTwist") ) mk->SetAttr("OTwist" , kTRUE);
789  if( GetOption("OClock") ) mk->SetAttr("OClock" , kTRUE);
790  if( GetOption("OCentm") ) mk->SetAttr("OCentm" , kTRUE);
791  if( GetOption("OECap") ) mk->SetAttr("OECap" , kTRUE);
792  if( GetOption("OIFC") ) mk->SetAttr("OIFC" , kTRUE);
793  if( GetOption("OSpaceZ") ) mk->SetAttr("OSpaceZ" , kTRUE);
794  if( GetOption("OSpaceZ2") ) {
795  if( GetOption("FXT") ) mk->SetAttr("OSpaceFXT" , kTRUE);
796  else mk->SetAttr("OSpaceZ2" , kTRUE);
797  }
798  if( GetOption("OShortR") ) mk->SetAttr("OShortR" , kTRUE);
799  if( GetOption("OBMap2d") ) mk->SetAttr("OBMap2d" , kTRUE);
800  if( GetOption("OGridLeak") ) mk->SetAttr("OGridLeak" , kTRUE);
801  if( GetOption("OGridLeak3D")) mk->SetAttr("OGridLeak3D", kTRUE);
802  if( GetOption("OGridLeakFull")) mk->SetAttr("OGridLeakFull", kTRUE);
803  if( GetOption("OGGVoltErr") ) mk->SetAttr("OGGVoltErr" , kTRUE);
804  if( GetOption("OSectorAlign"))mk->SetAttr("OSectorAlign",kTRUE);
805  if( GetOption("ODistoSmear")) mk->SetAttr("ODistoSmear", kTRUE);
806  if( GetOption("OAbortGap")) mk->SetAttr("OAbortGap" , kTRUE);
807  }
808  mk->PrintAttr();
809  }
810  if (maker == "StTpcHitMover" && GetOption("EbyET0")) {
811  mk->SetAttr("EbyET0", kTRUE);
812  }
813  if ((maker == "StdEdxY2Maker" || maker == "StTpcHitMover") &&
814  GetOption("EmbeddingShortCut")) {
815  mk->SetAttr("EmbeddingShortCut", kTRUE);
816  mk->PrintAttr();
817  }
818  if (maker == "StdEdxY2Maker" && !GetOption("CalcdNdx")) {
819  mk->SetAttr("SkipdNdx", kTRUE);
820  }
821  if (maker == "StSvtDbMaker" || maker == "StSsdDbMaker"){
822  mk->SetMode(0);
823  // If simulation running make sure pick up simu stuff from db
824  if (GetOption("Simu") && ! GetOption("NoSimuDb")) mk->SetMode(1);
825  }
826 
827  // FTPC
828  if ((maker == "StFtpcClusterMaker" ||
829  maker == "StFtpcTrackMaker" ) &&
830  GetOption("fdbg")) mk->SetMode(mk->GetMode()+2);
831  if ( ( maker == "StFtpcClusterMaker" || // ?
832  maker == "StFtpcTrackMaker" ) &&
833  GetOption("flaser")) mk->SetMode(mk->GetMode()+1);
834 
835  if ((maker == "StFtpcClusterMaker" ||
836  maker == "StFtpcTrackMaker" ) &&
837  GetOption("fgain")) mk->SetMode(mk->GetMode()+4);
838 
839 
840  // PMD
841  if ( maker == "StPmdReadMaker" &&
842  GetOption("pmdRaw")) mk->SetAttr("pmdRaw",kTRUE);
843 
844  // HFT
845  //if (maker == "StPxlSimMaker" &&
846  // GetOption("pxlSlowSim")) mk->SetAttr("useDIGMAPSSim",kTRUE);
847  // ... PXL
848  if (maker == "StPxlSimMaker") {
849  if (GetOption("pxlSlowSim")) mk->SetAttr("useDIGMAPSSim",kTRUE);
850  }
851 
852  //FMS GainCorrection flavors
853  if (maker == "StFmsDbMaker"){
854  if(fFmsGainCorrTag!="") mk->SetAttr("FmsGainCorr",fFmsGainCorrTag.Data());
855  }
856 
857  // Hit filtering will be made from a single maker in
858  // future with flexible filtering method
859  if (maker == "StHitFilterMaker") {
860  if (GetOption("SvtHitFilt")){
861  // Filter out SVT bad hits, TPC hits not on tracks and all hits if fabs(ZVert)>30
862  LOG_QA << "SVT hit filter is ON" << endm;
863  TString cmd(Form("StHitFilterMaker *Filtmk=(StHitFilterMaker*) %p;",mk));
864  cmd += "Filtmk->setPtLowerCut(-99.);";
865  cmd += "Filtmk->setPtUpperCut(-99.);";
866  cmd += "Filtmk->setAbsEtaCut(-99);";
867  cmd += "Filtmk->setAbsZVertCut(30);";
868  ProcessLine(cmd);
869  } else if (GetOption("TpcHitFilt")){
870  // Filter out TPC hits not on tracks
871  LOG_QA << "TPC hit filter is ON" << endm;
872  TString cmd(Form("StHitFilterMaker *Filtmk=(StHitFilterMaker*) %p;",mk));
873  cmd += "Filtmk->setPtLowerCut(-99.);";
874  cmd += "Filtmk->setPtUpperCut(-99.);";
875  cmd += "Filtmk->setAbsEtaCut(-99);";
876  cmd += "Filtmk->setAbsZVertCut(999);";
877  ProcessLine(cmd);
878  } else if (GetOption("HftHitFilt")){
879  // Filter out TPC hits not on tracks
880  LOG_QA << "HFT hit filter is ON" << endm;
881  TString cmd(Form("StHitFilterMaker *Filtmk=(StHitFilterMaker*) %p;",mk));
882  cmd += "Filtmk->setAbsZVertCut(-1);";
883  cmd += "Filtmk->setKeepWestHighEtaHitsForFgt(0);";
884  ProcessLine(cmd);
885  } else {
886  LOG_QA << "Default hit filtering is ON" << endm;
887  }
888  Int_t mode = 0;
889  if (GetOption("KeepTpcHit")) mode |= (1 << kTpcId);
890  if (GetOption("KeepSvtHit")) mode |= (1 << kSvtId);
891  mk->SetMode(mode);
892  // the m_Mode (Int_t is signed integer 4 bytes) mask is too short for the FGT
893  if (GetOption("KeepFgtHit")){
894  TString cmd(Form("StHitFilterMaker *Filtmk=(StHitFilterMaker*) %p;",mk));
895  cmd += "Filtmk->setKeepWestHighEtaHitsForFgt(1.0);";
896  ProcessLine(cmd);
897  }
898  }
899  if (maker == "StMiniMcMaker" && fFileOut != "") {
900  ProcessLine(Form("((StMiniMcMaker *) %p)->setFileName(\"%s\");", mk, fFileOut.Data()));
901  }
902  if (maker == "StMcAnalysisMaker") {
903  Int_t mode = 0;
904  if (GetOption("McAnaTpc")) mode += 0x1;
905  if (GetOption("McAnaSvt")) mode += 0x2;
906  if (GetOption("McAnaSsd")) mode += 0x4;
907  if (mode)
908  ProcessLine(Form("((StMaker *) %p)->SetMode(%i);", mk, mode));
909  }
910  if (maker == "StBTofCalibMaker") {
911  if (GetOption("UseProjectedVertex")) mk->SetAttr("UseProjectedVertex",kTRUE);
912  if (GetOption("setOutlierRej4BToft0")) mk->SetAttr("setPPPAOutlierRej", kTRUE);
913  if (GetOption("ImpBToFt0Mode")) mk->SetAttr("pppAMode", kTRUE);
914  if (GetOption("btofFXT")) mk->SetAttr("btofFXT", kTRUE);
915  }
916  if (maker == "StVpdCalibMaker" && GetOption("ImpBToFt0Mode")) mk->SetAttr("pppAMode", kTRUE);
917 
918  if (maker == "StEventMaker" && fFiltTrg.Length()) {
919  mk->SetAttr("FiltTrg",(Int_t) (fFiltTrg.BeginsWith('+') ? 1 : -1));
920  TString FiltTrgFlavor = fFiltTrg(1,128);
921  if (FiltTrgFlavor.Length())
922  SetFlavor((FiltTrgFlavor += "+ofl").Data(),"trgOfflineFilter");
923  }
924  if (maker == "StTagsMaker"){
925  if ( GetOption("shadow") ) mk->SetAttr("shadow",kTRUE);
926  }
927 
928  Add2Chain:
929  if (! mk) continue;
930  if (name == "") strncpy (fBFC[i].Name,(Char_t *) mk->GetName() , sizeof(fBFC[i].Name));
931  if (myChain) myChain->AddMaker(mk);
932  continue;
933  Error:
934  status = kStErr;
935  LOG_QA << " ======================================" << endm;
936  LOG_QA << " problem with Instantiation of " << fBFC[i].Maker << endm;
937  LOG_QA << " ======================================" << endm;
938  }
939  // PrintQAInfo();
940  PrintInfo();
941  // START the chain (may the force be with you)
942  // Create HTML docs of all Maker's inv
943 #if 0
944  if (GetOption("MakeDoc")) MakeDoc();
945 #endif
946  if (GetOption("Debug")) SetDEBUG(1);
947  if (GetOption("Debug1")) SetDEBUG(1);
948  if (GetOption("Debug2")) SetDEBUG(2);
949  if (GetOption("nohistos")) SetAttr(".histos",0,"*");
950  else SetAttr(".histos",1,"*");
951  if (GetOption("NoRepeat")) gMessMgr->IgnoreRepeats();
952 
953  if (GetOption("svt1hit")) SetAttr("minPrecHits",1,"Sti");
954  if (GetOption("svt1hit")) SetAttr("minPrecHits",1,"StiCA");
955  if (GetOption("svt1hit")) SetAttr("minPrecHits",1,"StiVMC");
956 
957  for ( unsigned int n=0 ; n < Gproperty.size() ; n++ ){
958  gMessMgr->QAInfo() << "+++ Setting attribute "
959  << (Gproperty.at(n)).Data() << " = " << (Gvalue.at(n)).Data() << " for "
960  << (Gpattern.at(n).Data()) << endm;
961 
962  SetAttr( (Gproperty.at(n)).Data(),
963  (Gvalue.at(n)).Data(),
964  (Gpattern.at(n)).Data() );
965  }
966 
967  return status;
968 }
969 //_____________________________________________________________________
970 Int_t StBFChain::Init() {
971 
972  TDatime td;
973  Info("Init","Time=%s Cwd=%s",td.AsString(),gSystem->pwd());
974 
975  SetChainOpt(new StBFChainOpt(this));
976  // SetDbOptions(); moved to Instantiation
977  if (fNoChainOptions) {
978  // SetGeantOptions(); move back to Init
979  if (GetOption("Simu") && ! (GetOption("mtin") || GetOption("PrepEmbed") || GetOption("pythiaEmbed"))) { // ! Simu
980  StEvtHddr *fEvtHddr = (StEvtHddr*)GetDataSet("EvtHddr");
981  if (!fEvtHddr) {
982  fEvtHddr = new StEvtHddr(m_ConstSet);
983  SetOutput(fEvtHddr); //Declare this "EvtHddr" for output
984  }
985  if (fEvtHddr->GetRunNumber() < 0 || fEvtHddr->GetRunNumber() >= 1000000) {
986  fEvtHddr->SetRunNumber(1); // to have run positive and < 1000000 (to avoid mess with RunLog)
987  }
988  }
989  }
990  if (fNoChainOptions) {
991  if (GetOption("NoOutput") || GetOption("EvOutOnly")) {
992  if (! GetOption("RMuDst"))
993  SetAttr(".call","SetActive(0)","MuDst"); //NO MuDst
994  if (! GetOption("EvOutOnly")) {
995  SetAttr(".call","SetActive(0)","outputStream"); //NO Out
996  }
997  SetAttr(".call","SetActive(0)","kink2");
998  SetAttr(".call","SetActive(0)","StTagsMaker::");
999  SetAttr(".call","SetActive(0)","StStrangeMuDstMaker::");
1000  }
1001 #if 1
1002 
1003 
1004  if (fNoChainOptions) {
1005  if (GetOption("misalign") && TClass::GetClass("AgPosition") )
1006  gROOT->ProcessLine("AgPosition::SetReal();");
1007  else if ( TClass::GetClass("AgPosition") )
1008  gROOT->ProcessLine("AgPosition::SetIdeal();");
1009  }
1010 
1011 
1012  // force load of geometry for VMC and Sti
1013 
1014  if (GetOption("Sti") || GetOption("StiCA") ||
1015  GetOption("StiVMC") ||GetOption("VMC") ||
1016  GetOption("VMCPassive")) {
1017  const DbAlias_t *DbAlias = GetDbAliases();
1018  for (Int_t i = 0; DbAlias[i].tag; i++) {
1019  TString dbTag("r");
1020  dbTag += DbAlias[i].tag;
1021  if (GetOption(dbTag)) {
1022  TString path("./StarDb/AgiGeometry:$STAR/StarDb/AgiGeometry");
1023  if (GetOption("AgML")) {
1024  path = "./StarDb/AgMLGeometry:$STAR/StarDb/AgMLGeometry";
1025  }
1026  if (GetOption("VmcGeo")) {
1027  path = "./StarDb/VmcGeo:$STAR/StarDb/VmcGeo";
1028  }
1029  TString geom("Geometry.");
1030  geom += DbAlias[i].geometry;
1031  geom += ".C";
1032  Char_t *file = gSystem->Which(path.Data(),geom,kReadPermission);
1033  if (file) {
1034  LOG_INFO << "StBFChain::Init force load of " << file << endm;
1035  TString command = ".L "; command += file;
1036  gInterpreter->ProcessLine(command);
1037  gInterpreter->Calc("CreateTable()");
1038  command.ReplaceAll(".L ",".U ");
1039  gInterpreter->ProcessLine(command);
1040  delete [] file;
1041  } else {
1042  LOG_INFO << "StBFChain::Init file for geometry tag " << geom << " has not been found in path" << path << endm;
1043  }
1044  break;
1045  }
1046  }
1047  }
1048 #endif
1049  }
1050  return StChain::Init();
1051 }
1052 //_____________________________________________________________________
1055 {
1056  TFile *tf = GetTFile();
1057  if (tf) {tf->Write(); tf->Flush(); tf->Close(); delete tf; SetTFile(0);}
1058  if (!fBFC) return kStOK;
1059  Int_t ians = StChain::Finish();
1060  SafeDelete(fchainOpt);
1061  fBFC = 0;
1062 // delete gMessMgr; gMessMgr = 0;
1063  return ians;
1064 }
1065 
1066 
1067 //_____________________________________________________________________
1068 Int_t StBFChain::AddAB (const Char_t *mkname,const StMaker *maker,const Int_t Opt) {
1069  if (! maker || strlen(mkname) == 0) return kStErr;
1070  StMaker *parent = maker->GetParentMaker();
1071  if (parent) {
1072  TList *list = parent->GetMakeList();
1073  list->Remove((StMaker *)maker);
1074  }
1075  StMaker *mk = GetMaker(mkname); if (!mk) return kStErr;
1076  parent = mk->GetParentMaker(); if (!parent) return kStErr;
1077  TList *list = parent->GetMakeList(); if (!list) return kStErr;
1078  if (Opt > 0) list->AddAfter (mk,(StMaker*)maker);
1079  else list->AddBefore(mk,(StMaker*)maker);
1080  return kStOk;
1081 }
1082 
1083 //_____________________________________________________________________
1084 Int_t StBFChain::ParseString (const TString &tChain, TObjArray &Opt, Bool_t Sort) {
1085  Opt.Clear();
1086  TObjArray *obj = tChain.Tokenize("[^ ;,]+");
1087  Int_t nParsed = obj->GetEntries();
1088  Int_t k, N = 0;
1089  if (GetChain() && GetChain()->Debug() > 2) {
1090  gMessMgr->QAInfo() << "ParseString " << tChain.Data() << endm;
1091  for (k = 0; k < nParsed; k++) {
1092  if (obj->At(k)) {
1093  gMessMgr->QAInfo() << k << "\t" << ((TObjString *) obj->At(k))->GetName() << endm;
1094  }
1095  }
1096  }
1097  for (k = 0; k < nParsed; k++) {if (obj->At(k)) {if (k != N) obj->AddAt(obj->At(k),N); N++;}}
1098  nParsed = N;
1099  // sort options
1100  StBFChain *curChain = (StBFChain *) StMaker::GetChain();
1101  if (curChain && Sort) {// sort options
1102  TArrayI idT(nParsed); Int_t *idx = idT.GetArray();
1103  TArrayI kdT(nParsed); Int_t *kdx = kdT.GetArray();
1104  for (k = 0; k < nParsed; k++) {
1105  TString string = ((TObjString *) obj->At(k))->GetString();
1106  kdx[k] = TMath::Abs(curChain->kOpt(string,kFALSE));
1107  }
1108  TMath::Sort(nParsed,kdx,idx,0);
1109  TString sChain;
1110  for (k = 0; k < nParsed; k++) {
1111  Opt.AddAtAndExpand(obj->At(idx[k]),k);
1112  if (k == 0) sChain = ((TObjString *)Opt[k])->GetString();
1113  else {sChain += ","; sChain += ((TObjString *)Opt[k])->GetString();}
1114  }
1115  if (N > 1 && curChain->Debug() > 2) {
1116  gMessMgr->QAInfo() << "Requested chain is :\t" << tChain.Data() << endm;
1117  gMessMgr->QAInfo() << "Sorted chain is :\t" << sChain.Data() << endm;
1118  }
1119  } else for (k = 0; k < nParsed; k++) Opt.AddAtAndExpand(obj->At(k),k);
1120  obj->SetOwner(kFALSE);
1121  delete obj;
1122  return nParsed;
1123 }
1124 
1125 //_____________________________________________________________________
1127 Int_t StBFChain::kOpt (const Char_t *tag, Bool_t Check) const {
1128  TString Tag(tag);
1129  Int_t kO = kOpt(&Tag, Check);
1130  return kO;
1131 }
1132 //_____________________________________________________________________
1134 
1140 Int_t StBFChain::kOpt (const TString *tag, Bool_t Check) const {
1141  TString Tag = *tag;
1142  Tag.ToLower();
1143  TString opt, nopt;
1144  for (Int_t i = 1; i< fNoChainOptions; i++) {
1145  opt = TString(fBFC[i].Key); //check nick name
1146  opt.ToLower();
1147  nopt = TString("-");
1148  nopt += opt;
1149  if (Tag == opt) {return i;}
1150  else {if (Tag == nopt) {return -i;}}
1151  opt = fBFC[i].Maker; //check full maker name2
1152  nopt = "-";
1153  nopt += opt;
1154  if (Tag == opt) {return i;}
1155  else {if (Tag == nopt) {return -i;}}
1156  }
1157  //
1158  // JL - sdt and dbv for timestamp
1159  //
1160  // Gopt for arbitrary property on 3 letter name (wildcard would be added) and length
1161  // 6 for a value. Not advertized / not used and implementation is not complete (needed
1162  // a case and do not have a clear one). TBD.
1163  //
1164  // 2011/11 added the possibility of detector sub-system specific timestamps.
1165  // DBV only for now, logic is similar if we equally parse.
1166  //
1167  // {sdt|dbv}YYYYMMDD -> {sdt|dbv} 3 / YYYYMMDD 8 => 11 || YYYYMMDD.HHMMSS = 15 => 18
1168  if (Tag.BeginsWith("dbv") || Tag.BeginsWith("sdt")) {
1169  Check = kTRUE;
1170 
1171  if (Tag.Length() == 11 || Tag.Length() == 18) return 0;
1172 
1173  // Else we need to parse some more - assume a pattern {dbv|sdt}YYYYMMDD[.HHMMSS]_XXX_ZZZZZ
1174  // First, detect it using quick counting
1175  Tag.ToLower();
1176  if ( TPRegexp(BFC_DBREGEXP).Match(Tag) == 7) return 0;
1177  }
1178  if (Tag.BeginsWith("rung")) {
1179  Check = kTRUE;
1180  return 0;
1181  }
1182 
1183  //FMS gaincorr
1184  if(Tag.BeginsWith("fmsGainCorr")){
1185  Check = kTRUE;
1186  return 0;
1187  }
1188 
1189  // GoptXXXvvvvvv -> Gopt 4 / XXX 3 / vvvvvv 6 = 13
1190  if ( Tag.BeginsWith("gopt") && Tag.Length() == 13 ) return 0;
1191 
1192  if ( Tag.BeginsWith("FiltTrg",TString::kIgnoreCase) ) {
1193  Check = kTRUE;
1194  if ( TPRegexp("^FiltTrg(Inc|Exc)?(_.*)*$").Match(Tag,"i") > 0) return 0;
1195  }
1196  if ( Tag.BeginsWith("VFStore",TString::kIgnoreCase) ||
1197  Tag.BeginsWith("TpcVpdVzDiffCut",TString::kIgnoreCase)
1198  ) {
1199  // need to match an ":" sign
1200  Check = kTRUE;
1201  if ( Tag.Index(':') != 0) return 0;
1202  }
1203 
1204 
1205  if (Check) {
1206  gMessMgr->Error() << "Option " << Tag.Data() << " has not been recognized" << endm;
1207  abort(); //assert(1);
1208  }
1209  return 0;
1210 }
1211 //_____________________________________________________________________
1212 void StBFChain::SetOptions(const Char_t *options, const Char_t *chainName) {
1213  TString tChain(options);
1214  TObjArray Opts;
1215  Int_t nParsed = ParseString(tChain,Opts,kTRUE);
1216  for (Int_t l = 0; l < nParsed; l++) {
1217  TString Tag = ((TObjString *)Opts[l])->GetString();
1218  Int_t kgo;
1219  Int_t in = Tag.Index("=");
1220  if (in > 0) {// string with "="
1221  TString subTag(Tag.Data(),in);
1222  subTag.ToLower(); //printf ("Chain %s\n",tChain.Data());
1223  kgo = kOpt(subTag.Data());
1224  if (kgo > 0) {
1225  int len= sizeof(fBFC[kgo].Comment);
1226  memset(fBFC[kgo].Comment,0,len); // be careful size of Comment
1227  TString Comment(Tag.Data()+in+1,Tag.Capacity()-in-1);
1228  if ( Comment.Length() <= len ){
1229  strncpy (fBFC[kgo].Comment, Comment.Data(),sizeof(fBFC[kgo].Comment));
1230  gMessMgr->QAInfo() << Form(" Set %s = %s", fBFC[kgo].Key,fBFC[kgo].Comment) << endm;
1231  } else {
1232  gMessMgr->Error() << Form(" Cpy problem [%s] is > %d - adjust BFC Comment field size",
1233  Comment.Data(),len) << endm;
1234  }
1235  }
1236  } else {
1237  Tag.ToLower();
1238  // printf ("Chain %s\n",tChain.Data());
1239  kgo = kOpt(Tag.Data(),kFALSE);
1240  if (kgo != 0) {
1241  SetOption(kgo,chainName);
1242  if (kgo > 0) {
1243  TString Comment(fBFC[kgo].Comment);
1244  TString Opts(fBFC[kgo].Opts);
1245  if (Tag.BeginsWith("Test.",TString::kIgnoreCase) && ! Comment.BeginsWith("/star/") &&
1246  Opts.BeginsWith("test_",TString::kIgnoreCase)) {
1247  SetOptions(Opts,Tag);
1248  } else {
1249  if ((Tag.BeginsWith("Test.",TString::kIgnoreCase) ||
1250  Tag.BeginsWith("test_",TString::kIgnoreCase) ||
1251  Tag.BeginsWith("eval_",TString::kIgnoreCase)) && Comment.BeginsWith("/star/") ) {
1252  fkChain = kgo;
1253  gMessMgr->QAInfo() << "Default Test chain set " << fBFC[fkChain].Key << " with input " << fBFC[fkChain].Comment << endm;
1254  }
1255  }
1256  }
1257  } else {
1258  // it is 0 i.e. was not recognized.
1259  // Check if it is a (dbv|sdt)YYYYMMDD or (dbv|sdt)YYYYMMDD.HHMMSS and derivative
1260  // We really set the options only once later in SetDbOptions() (removing the fBFC[i].Flag check)
1261  // but the goal here is to avoid user's histeria by displaying extra messages NOW.
1262  //
1263  // Note that kOpt() has already validated the pattern (so it has to be right here).
1264  //
1265  // !!! Debug: dbv20040917
1266  if (Tag.BeginsWith("dbv")) {
1267  if (Tag.Length() == 11) (void) sscanf(Tag.Data(),"dbv%8d",&FDate);
1268  if (Tag.Length() == 18) (void) sscanf(Tag.Data(),"dbv%8d.%6d",&FDate,&FTime);
1269  if (Tag.Length() == 11 || Tag.Length() == 18) {
1270  gMessMgr->QAInfo() << Tag.Data() << " ... but still will be considered as a dynamic timestamp (Max DB EntryTime) "
1271  << FDate << "." << FTime << endm;
1272 #ifdef USE_BFCTIMESTAMP
1273  } else {
1274  // we passed kOpt() parsing was fine
1275  //if ( TPRegexp(BFC_DBREGEXP).Match(Tag) == 7) return 0;
1276  TObjArray *subStrL = TPRegexp(BFC_DBREGEXP).MatchS(Tag);
1277  BFCTimeStamp TS;
1278  TString realm;
1279 
1280  TS.Type = 1;
1281  TS.Date = (((TObjString *) subStrL->At(2))->GetString()).Atoi();
1282  TS.Time = 0; // for now, avoid parsing this as user use simple TS 99% of the time
1283  TS.Detector = ((TObjString *) subStrL->At(4))->GetString();
1284  TS.Realm = ((TObjString *) subStrL->At(6))->GetString();
1285 
1286  if ( TS.Realm.IsNull() ){ realm = "*";}
1287  else { realm = TS.Realm;}
1288 
1289  GTSOptions.push_back(TS);
1290 
1291  LOG_WARN << "Override timestamp for detector requested\n\t"
1292  << "Detector " << TS.Detector << "\n\t"
1293  << "Realm " << realm << "\n\t"
1294  << "Date " << TS.Date << "\n\t"
1295  << "Time " << TS.Time << endm;
1296 #endif /* USE_BFCTIMESTAMP */
1297  }
1298 
1299  } else if (Tag.BeginsWith("sdt")) {
1300  if (Tag.Length() == 11) (void) sscanf(Tag.Data(),"sdt%8d",&FDateS);
1301  if (Tag.Length() == 18) (void) sscanf(Tag.Data(),"sdt%8d.%6d",&FDateS,&FTimeS);
1302  if (Tag.Length() == 11 || Tag.Length() == 18) {
1303  gMessMgr->QAInfo() << Tag.Data() << " ... but still will be considered as a dynamic timestamp (Event Time) "
1304  << FDateS << "." << FTimeS << endm;
1305 
1306  // <<< same logic for GTSOptions can be inserted here
1307  // <<< if so, use TS.Type = 2
1308  }
1309 
1310  } else if ( Tag.BeginsWith("gopt") && Tag.Length() == 13){
1311  // TODO option best as gopt.$ATTRR.$VAL for arbitrary attribute and value
1312  // parsing to extend
1313  char GOptName[4],GOptValue[7];
1314  TString property(".gopt.");
1315  //TString pattern("*");
1316 
1317  (void) sscanf(Tag.Data(),"gopt%3s%6s",GOptName,GOptValue);
1318  // sscanf adds null terminators for %s, so buffers need to be 1 longer
1319 
1320  // see StBFChain::Setup() for default values
1321  property += GOptName;
1322  Gproperty.push_back(property);
1323  Gvalue.push_back(GOptValue);
1324  Gpattern.push_back("*");
1325 
1326  // JL - this is not finished, see comment in kOpt()
1327 
1328  // pattern is case sensitive, need more checks on this before
1329  // setting to something else than "*"
1330  //Gpattern += GOptName;
1331  //Gpattern += "*";
1332 
1333 
1334  gMessMgr->QAInfo() << Tag.Data() << " ... this will set an general attribute "
1335  << property.Data() << " with value " << GOptValue << " to "
1336  << "*" << endm;
1337  // Attr() need to be set after the maker exist
1338  //SetAttr(property.Data(),GOptValue,pattern.Data());
1339  //SetAttr(property.Data(),GOptValue,pattern.Data());
1340 
1341  } else if (Tag.BeginsWith("rung")) {
1342  fRunG = 1;
1343  if (Tag.Length() > 4) (void) sscanf(Tag.Data(),"rung.%d",&fRunG);
1344  gMessMgr->QAInfo() << Tag.Data() << " will be considered as Run number (& rndm seed set) "
1345  << fRunG << " for simulation." << endm;
1346 
1347 
1348  // JL: super long options I could not accomomodate with gopt (also used ":")
1349  } else if (Tag.BeginsWith("VFStore" ,TString::kIgnoreCase) ||
1350  Tag.BeginsWith("TpcVpdVzDiffCut",TString::kIgnoreCase)
1351  ) {
1352  TString VFS = Tag;
1353  Ssiz_t idx = Tag.Index(':');
1354 
1355  //cout << "-+-+-+- DEBUG -+-+-+- position = " << idx << endl;
1356 
1357  if ( idx != 0){
1358  // exclude VFStoreX or options not containing "."
1359  Gproperty.push_back(Tag(0,idx));
1360  Gvalue.push_back(Tag(idx+1,64));
1361  // can use better patterns VFStore -> mk=StGenericVertexMaker
1362  Gpattern.push_back("*");
1363 
1364  gMessMgr->QAInfo() << "Detecting " << Tag(0,idx).Data() << " = " << Tag(idx+1,64).Data() << " as global property" << endm;
1365 
1366  // Attr() need to be set after the maker exist
1367 
1368  }
1369 
1370 
1371  } else if (Tag.BeginsWith("FiltTrg",TString::kIgnoreCase)) {
1372  TString filtTrgTag = Tag;
1373  Ssiz_t flavorIdx = Tag.Index('_');
1374  if (flavorIdx > 0) {
1375  filtTrgTag = Tag(0,flavorIdx);
1376  fFiltTrg = Tag(flavorIdx+1,64);
1377  }
1378  if (filtTrgTag.CompareTo("FiltTrgExc",TString::kIgnoreCase)==0) {
1379  gMessMgr->QAInfo() << "Trigger Filtering exclude with flavor=" << fFiltTrg << endm;
1380  fFiltTrg.Prepend('-');
1381  } else if (filtTrgTag.CompareTo("FiltTrgInc",TString::kIgnoreCase)==0 ||
1382  filtTrgTag.CompareTo("FiltTrg" ,TString::kIgnoreCase)==0) {
1383  gMessMgr->QAInfo() << "Trigger Filtering include with flavor=" << fFiltTrg << endm;
1384  fFiltTrg.Prepend('+');
1385  } else {
1386  // not a match, disable
1387  fFiltTrg = "";
1388  }
1389 
1390  } else if (Tag.BeginsWith("fmsGainCorr",TString::kIgnoreCase)) {
1391  fFmsGainCorrTag = Tag;
1392 
1393  } else { // Check for predefined db time stamps ?
1394  kgo = kOpt(Tag.Data(),kFALSE);
1395  if (kgo != 0){
1396  SetOption(kgo,chainName);
1397  } else {
1398  // Check that option can be library name or / and Maker
1399  static const Char_t *path = ".:.$STAR_HOST_SYS/lib::.$STAR_HOST_SYS/LIB:$STAR/.$STAR_HOST_SYS/lib:$STAR/.$STAR_HOST_SYS/LIB";
1400  TString File = Tag; File += ".so";
1401  Char_t *file = gSystem->Which(path,File.Data(),kReadPermission);
1402  if (file) {
1403  TString Maker("");
1404  Bfc_st row = {"","","","","","","",kTRUE};
1405  memcpy (&row.Key, Tag.Data(), Tag.Length());
1406  if (Tag.Contains("Maker")) memcpy (&row.Maker, Tag.Data(), Tag.Length());
1407  memcpy (&row.Libs, Tag.Data(), Tag.Length());
1408  fchainOpt->AddAt(&row);
1409  fNoChainOptions = fchainOpt->GetNRows();
1410  fBFC = fchainOpt->GetTable();
1411  delete [] file;
1412  }
1413  kgo = kOpt(Tag.Data(),kFALSE);
1414  if (kgo != 0) {
1415  SetOption(kgo,chainName);
1416  } else {
1417  gMessMgr->QAInfo() << " Invalid Option " << Tag.Data() << ". !! ABORT !! " << endm;
1418  abort(); //assert(1);
1419  return;
1420  }
1421  }
1422  }
1423  }
1424  }
1425  }
1426  Opts.Delete();
1427 }
1428 //_____________________________________________________________________
1430 void StBFChain::SetOption(const Int_t k, const Char_t *chainName) {
1431  if (k > 0) {
1432  assert(k<fNoChainOptions);
1433  Int_t n = strlen(fBFC[k].Opts);
1434  if (n > 0) SetOptions(fBFC[k].Opts,fBFC[k].Key);
1435  if (!fBFC[k].Flag) {
1436  fBFC[k].Flag = kTRUE;
1437  gMessMgr->QAInfo() << Form(" Switch On %20s by %s", fBFC[k].Key, chainName) << endm;
1438  }
1439  } else {
1440  assert(-k<fNoChainOptions);
1441  if (k < 0 && fBFC[-k].Flag) {
1442  fBFC[-k].Flag = kFALSE;
1443  gMessMgr->QAInfo() << Form(" Switch Off %20s by %s", fBFC[-k].Key, chainName) << endm;
1444  }
1445  }
1446 }
1447 
1448 //_____________________________________________________________________
1450 Bool_t StBFChain::GetOption(const Int_t k) const
1451 {
1452  return (k>0 && k <fNoChainOptions) ? fBFC[k].Flag : kFALSE;
1453 }
1454 
1456 
1475 Char_t *StBFChain::GetOptionString(const Char_t *Opt)
1476 {
1477  Int_t o = kOpt(Opt);
1478  if(!o) return NULL;
1479  else if(!GetOption(o)) return NULL;
1480  else return(fBFC[o].Comment);
1481 }
1482 
1483 
1484 //_____________________________________________________________________________
1486 
1513 void StBFChain::SetFlags(const Char_t *chainOpts)
1514 {
1515  TString tChain(chainOpts);
1516  Int_t mode = 1;
1517  Setup(mode);
1518  Int_t k=0;
1519  if (tChain == "" || tChain.CompareTo("ittf",TString::kIgnoreCase) == 0) {
1520  gMessMgr->QAInfo() << "\tPossible Chain Options are:" << endm;
1521  for (k=0;k<fNoChainOptions;k++)
1522  gMessMgr->QAInfo()
1523  << Form(" %3d: %-30s:%-12s:%-12s:%s:%s:%s:%s"
1524  ,k,fBFC[k].Key,fBFC[k].Name,fBFC[k].Chain,fBFC[k].Opts,fBFC[k].Maker,fBFC[k].Libs,fBFC[k].Comment)
1525  << endm;
1526 
1527  return;
1528  }
1529  TString STAR_VERSION("$STAR_VERSION");
1530  gSystem->ExpandPathName(STAR_VERSION);
1531  gMessMgr->QAInfo() << "==============================================" << endm;
1532  gMessMgr->QAInfo() << "============= You are in " << STAR_VERSION.Data() << " ===============" << endm;
1533  gMessMgr->QAInfo() << "Requested chain " << GetName() << " is :\t" << tChain.Data() << endm;
1534  SetOptions(tChain,"Chain");
1535  if (GetOption("NewTpcAlignment")) {
1536  gMessMgr->QAInfo() << "Set environment to use NewTpcAlignment" << endm;
1537  gEnv->SetValue("NewTpcAlignment",1);
1538  }
1539  if (!GetOption("NoDefault")) { // Default
1540  // Check flags consistency
1541  if (gClassTable->GetID("TGiant3") >= 0) { // root4star
1542  SetOption("-VMC","Default,TGiant3");
1543  SetOption("-VMCPassive","Default,TGiant3");
1544  SetOption("-VMCAppl","Default,TGiant3");
1545  SetOption("-RootVMC","Default,TGiant3");
1546  if (GetOption("xgeometry")) {
1547  SetOption("-geometry","Default,-xgeometry");
1548  SetOption("-geomNoField","Default,-xgeometry");
1549  }
1550  } else { // root
1551  if (GetOption("fzin")) {
1552  gMessMgr->Error() << "Option fzin cannot be used in root.exe. Use root4star" << endm;
1553  abort();
1554  }
1555  if (GetOption("ntin")) {
1556  gMessMgr->Error() << "Option ntin cannot be used in root.exe. Use root4star" << endm;
1557  abort();
1558  }
1559 
1560  if (GetOption("gstar") || GetOption("pythia")) {
1561  SetOption("VMC","Default,-TGiant3,gstar");
1562  SetOption("-gstar","Default,-TGiant3");
1563  SetOption("-pythia","Default,-TGiant3");
1564  }
1565 
1566  SetOption("-geant","Default,-TGiant3");
1567  SetOption("-geantL","Default,-TGiant3");
1568  SetOption("-geometry","Default,-TGiant3");
1569  SetOption("-geomNoField","Default,-TGiant3");
1570 
1571  if (! (GetOption("VMC") || GetOption("VMCPassive"))) {
1572  SetOption("VMCPassive","Default,-TGiant3");
1573  }
1574  SetOption("pgf77","Default,-TGiant3");
1575  SetOption("mysql","Default,-TGiant3");
1576  SetOption("StarMiniCern","Default,-TGiant3");
1577 
1578  }
1579  if (GetOption("ITTF") && ! (GetOption("Sti") || GetOption("StiCA") || GetOption("StiVMC"))) {
1580  TString STAR_LEVEL(gSystem->Getenv("STAR_LEVEL"));
1581  if (STAR_LEVEL == ".DEV2") SetOption("StiCA","Default,ITTF");
1582  else SetOption("Sti" ,"Default,ITTF");
1583  }
1584  }
1585  if (!GetOption("Eval") && GetOption("AllEvent")) SetOption("Eval","-Eval,AllEvent");
1586  // Print set values
1587  St_Bfc *Bfc = new St_Bfc("BFChain",fNoChainOptions);
1588  AddRunco(Bfc);
1589  for (k = 1; k<fNoChainOptions;k++) {
1590  if (GetOption(k)) {
1591  gMessMgr->QAInfo() << Form("================== %20s\tis ON \t: %s",
1592  (char *) fBFC[k].Key, (char *) fBFC[k].Comment) << endm;
1593  Bfc->AddAt(&fBFC[k]);
1594  }
1595  }
1596  // gSystem->Exit(1);
1597 }
1598 //_____________________________________________________________________
1599 void StBFChain::Set_IO_Files (const Char_t *infile, const Char_t *outfile){
1600  TString gc("");
1601  if (infile) {
1602  if (strlen(infile) > 2) {
1603  gc = TString(infile,3);
1604  gc.ToLower();
1605  }
1606  }
1607  SetInputFile(infile);
1608  if (! GetOption("NoOutput")) SetOutputFile(outfile);
1609 }
1610 //_____________________________________________________________________
1611 void StBFChain::SetInputFile (const Char_t *infile){
1612  // define input file
1613  if (infile) fInFile = infile;
1614  if (fInFile != "") {
1615  fInFile.ReplaceAll("\n",";");
1616  fInFile.ReplaceAll("#",";");
1617  fInFile.ReplaceAll(":",";");
1618  gMessMgr->QAInfo() << "Input file name = " << fInFile.Data() << endm;
1619  } else {
1620  if (fkChain >= 0) {
1621  fInFile = fBFC[fkChain].Comment;
1622  fInFile.ReplaceAll("\n",";");
1623  gMessMgr->QAInfo() << "Default Input file name = " << fInFile.Data() << " for chain : " << fBFC[fkChain].Key << endm;
1624  }
1625  }
1626  if (fInFile == "") {SetOption("-in","No Input File"); SetOption("-InTree","NoInput File"); return;}
1627  if (!GetOption("fzin") && !GetOption("ntin")) {
1628  fSetFiles= new StFile();
1629  TObjArray Files;
1630  ParseString(fInFile,Files);
1631  TIter next(&Files);
1632  TObjString *File;
1633  while ((File = (TObjString *) next())) {
1634  TString string = File->GetString();
1635  if (!string.Contains("*") && ! string.BeginsWith("@") &&
1636  gSystem->AccessPathName(string.Data())) {// file does not exist
1637  gMessMgr->Error() << "StBFChain::SetInputFile *** NO FILE: " << string.Data() << ", exit!" << endm;
1638  gSystem->Exit(1);
1639  }
1640  else fSetFiles->AddFile(File->String().Data());
1641  }
1642  Files.Delete();
1643  }
1644 }
1645 //_____________________________________________________________________
1647 void StBFChain::SetOutputFile (const Char_t *outfile){
1648  if (! GetOption("NoOutput")) {
1649  if (outfile) {
1650  fFileOut = outfile;
1651  } else {
1652  if (fInFile != "") {
1653  if (GetOption("fzin") || GetOption("ntin")) {
1654  TObjArray words;
1655  ParseString(fInFile,words);
1656  TIter nextL(&words);
1657  TObjString *word = 0;
1658  while ((word = (TObjString *) nextL())) {
1659  if (word->GetString().Contains(".fz") ||
1660  word->GetString().Contains(".nt")) {
1661  fFileOut = gSystem->BaseName(word->GetName());
1662  break;
1663  }
1664  }
1665  } else {
1666  fFileOut = gSystem->BaseName(fInFile.Data());
1667  if (GetOption("shadow")) {
1668  TObjArray* fileOutTokens = fFileOut.Tokenize("_.");
1669  TString& runToken = ((TObjString*) (fileOutTokens->At(2)))->String();
1670  TString& seqToken = ((TObjString*) (fileOutTokens->At(4)))->String();
1671  if (!(runToken.CompareTo("adc"))) {
1672  runToken = ((TObjString*) (fileOutTokens->At(3)))->String();
1673  seqToken = ((TObjString*) (fileOutTokens->At(5)))->String();
1674  }
1675  if (!(runToken.IsDigit())) {
1676  LOG_ERROR << "Unable to locate run number in filename for shadowing." << endm;
1677  } else {
1678  fFileOut.ReplaceAll(runToken,Form("%d",
1679  StShadowMaker::getRunNumber(runToken.Atoi())));
1680  }
1681  if (!(seqToken.IsDigit())) {
1682  LOG_ERROR << "Unable to locate file sequence number in filename for shadowing." << endm;
1683  } else {
1684  fFileOut.ReplaceAll(seqToken,Form("%07d",
1685  StShadowMaker::getFileSeq(seqToken.Atoi())));
1686  }
1687  delete fileOutTokens;
1688  }
1689  }
1690  }
1691  if (fFileOut == "") {
1692  if (GetOption("pythia")) fFileOut = "pythia.root";
1693  else if (GetOption("hijing")) fFileOut = "hijing.root";
1694  else if (GetOption("VMC")) fFileOut = "VMC.root";
1695  else if (GetOption("gstar")) fFileOut = "gtrack.root";
1696  }
1697  if ( fFileOut != "") {
1698  fFileOut.ReplaceAll("*","");
1699  fFileOut.ReplaceAll("@","");
1700  fFileOut.ReplaceAll("..",".");
1701  fFileOut.ReplaceAll(".daq","");
1702  fFileOut.ReplaceAll(".fzd","");
1703  fFileOut.ReplaceAll(".fz","");
1704  fFileOut.ReplaceAll(".nt","");
1705  fFileOut.ReplaceAll(".root","");
1706  fFileOut.ReplaceAll(".list","");
1707  fFileOut.ReplaceAll(".lis","");
1708  fFileOut.Strip();
1709  fFileOut.Append(".root");
1710  }
1711  }
1712  }
1713  if (fFileOut != "") gMessMgr->QAInfo() << "Output root file name " << fFileOut.Data() << endm;
1714  else SetOption("NoOutput","No Output File");
1715  if (!GetTFile()) {
1716  if ( ( GetOption("tags") || GetOption("lana") ) && (fFileOut != "") ){
1717  TString TagsName = fFileOut;
1718  if( GetOption("lana") ){
1719  TagsName.ReplaceAll(".root",".laser.root");
1720  } else if ( GetOption("mtdEvtFilt") ){
1721  TagsName.ReplaceAll(".root",".pretags.root");
1722  } else {
1723  TagsName.ReplaceAll(".root",".tags.root");
1724  }
1725  SetTFile(new TFile(TagsName.Data(),"RECREATE"));
1726  }
1727  }
1728 }
1729 //_____________________________________________________________________
1731 
1738  if (geantMk && geantMk->InheritsFrom("St_geant_Maker")) {
1739  SetInput("geant",".make/geant/.data");
1740  TString GeomVersion("");
1741  if (fRunG > 0) {
1742  geantMk->SetAttr("RunG",fRunG);
1743  }
1744  if (!GetOption("fzin") || GetOption("ForceGeometry")) {
1745  GeomVersion = "y2004x";
1746  const DbAlias_t *DbAlias = GetDbAliases();
1747  Int_t found = 0;
1748  for (Int_t i = 0; DbAlias[i].tag; i++) {
1749  TString r("r");
1750  r += DbAlias[i].tag;
1751  if ( !GetOption(DbAlias[i].tag,kFALSE) && !GetOption(r,kFALSE)) continue;
1752  GeomVersion = DbAlias[i].geometry;
1753  found = i;
1754  break;
1755  }
1756  if (! found) gMessMgr->QAInfo() << "StBFChain::SetGeantOptions() Chain has not found geometry tag. Use " << GeomVersion << endm;
1757  TString GeometryOpt;
1758  if (GetOption("phys_off")) {GeometryOpt += "detp phys_off=1;"; geantMk->SetAttr("phys_off",kTRUE);}
1759  if (GetOption("hadr_off")) {GeometryOpt += "detp hadr_off=1;"; geantMk->SetAttr("hadr_off",kTRUE);}
1760  GeometryOpt += ("detp geometry ");
1761  GeometryOpt += GeomVersion;
1762  ProcessLine(Form("((St_geant_Maker *) %p)->LoadGeometry(\"%s\");",geantMk,GeometryOpt.Data()));
1763  }
1764  if ((GetOption("fzin") || GetOption("ntin") || GetOption("mtin") || fInFile.Data()[0] == ';') && fInFile != "")
1765  ProcessLine(Form("((St_geant_Maker *) %p)->SetInputFile(\"%s\")",geantMk,fInFile.Data()));
1766  }
1767 }
1768 //_____________________________________________________________________
1770 
1783  if (! mk ) return;
1784  if (GetOption("Agi")) mk->SetAlias("VmcGeometry","db/.const/StarDb/AgiGeometry");
1785  else if (GetOption("AgML") ) mk->SetAlias("VmcGeometry","db/.const/StarDb/AgMLGeometry");
1786  else if (GetOption("VmcGeo")) mk->SetAlias("VmcGeometry","db/.const/StarDb/VmcGeo");
1787  else mk->SetAlias("VmcGeometry","db/.const/StarDb/AgiGeometry");
1788  Int_t i;
1789  Int_t Idate=0,Itime=0;
1790 
1791  // First possibility
1792  for (i = 1; i < fNoChainOptions; i++) {
1793  if (fBFC[i].Flag && !strncmp(fBFC[i].Key ,"DbV",3)){
1794  // JL - we use to set timestamp as a chain option (any) starting with dbv and followed
1795  // by an arbitrary set of numbers. The real stamp was taken from the comment.
1796  // This supports this old mode.
1797  gMessMgr->QAInfo() << "StBFChain::SetDbOptions Found time-stamp " << fBFC[i].Key << " [" << fBFC[i].Comment << "]" << endm;
1798  (void) sscanf(fBFC[i].Comment,"%d/%d",&Idate,&Itime);
1799  }
1800  }
1801 
1802  // If FDate is set and we do not have the old mode, then a dynamic timestamp was used
1803  // Overwrite
1804  if( ! Idate && FDate){
1805  gMessMgr->QAInfo() << "StBFChain::SetDbOptions Switching to user chosen dynamic time-stamp (MaxEntry) "
1806  << FDate << " " << FTime << endm;
1807  gMessMgr->QAInfo() << "Chain may crash if time-stamp is not validated by db interface" << endm;
1808 
1809  Idate = FDate;
1810  Itime = FTime;
1811  }
1812 
1813  St_db_Maker *db = (St_db_Maker *) mk;
1814  // Startup date over-write
1815  if (FDateS){
1816  gMessMgr->QAInfo() << "StBFChain::SetDbOptions Switching to user chosen dynamic time-stamp (Start)"
1817  << FDateS << " " << FTimeS << endm;
1818  gMessMgr->QAInfo() << "Chain may crash if time-stamp is not validated by db interface" << endm;
1819 
1820  db->SetDateTime(FDateS,FTimeS);
1821  } else {
1822  if (GetOption("simu")) {
1823  const DbAlias_t *DbAlias = GetDbAliases();
1824  Int_t found = 0;
1825  for (Int_t i = 0; DbAlias[i].tag; i++) {
1826  if (GetOption(DbAlias[i].tag,kFALSE)) {
1827  db->SetDateTime(DbAlias[i].tag);
1828  found = i;
1829  break;
1830  }
1831  }
1832  if (! found) {gMessMgr->QAInfo() << "StBFChain::SetDbOptions() Chain has not set a time-stamp" << endm;}
1833  // Show date settings
1834  gMessMgr->QAInfo() << db->GetName()
1835  << " Maker set time = "
1836  << db->GetDateTime().GetDate() << "."
1837  << db->GetDateTime().GetTime() << endm;
1838  if (GetOption("SIMU") && m_EvtHddr) {
1839  gMessMgr->QAInfo() << GetName() << " Chain set time from " << db->GetName() << endm;
1840  m_EvtHddr->SetDateTime(db->GetDateTime());
1841  }
1842  }
1843  }
1844 
1845  // MaxEntry over-write - default and global for all realm and detectors
1846  if (Idate) {
1847  db->SetMaxEntryTime(Idate,Itime);
1848  gMessMgr->Info() << "\tSet DataBase max entry time " << Idate << "/" << Itime
1849  << " for St_db_Maker(\"" << db->GetName() <<"\")" << endm;
1850  }
1851 #ifdef USE_BFCTIMESTAMP
1852  //
1853  // Now treat the detector specific options
1854  //
1855  TString realm;
1856  for (UInt_t i = 0; i < GTSOptions.size() ; i++){
1857  if ( (GTSOptions[i].Realm).IsNull() ){ realm = "*";}
1858  else { realm = GTSOptions[i].Realm;}
1859 
1860  //LOG_INFO << "DEBUG MORE [" << (GTSOptions[i].Realm).Data() << "]" << endm;
1861  //LOG_INFO << "DEBUG MORE [" << realm.Data() << "]" << endm;
1862 
1863  if ( GTSOptions[i].Type == 1){
1864  db->AddMaxEntryTimeOverride(GTSOptions[i].Date,0,
1865  (char *) realm.Data(),
1866  (char *) GTSOptions[i].Detector.Data());
1867 
1868  LOG_INFO << "Recovering override stamp " << i << " :: "
1869  << GTSOptions[i].Detector << ", " << realm << ", "
1870  << GTSOptions[i].Date << ", " << GTSOptions[i].Time << endm;
1871  } else {
1872  LOG_WARN << "Found override type " << GTSOptions[i].Type << " no treated yet"
1873  << GTSOptions[i].Detector << ", " << realm << ", "
1874  << GTSOptions[i].Date << ", " << GTSOptions[i].Time << endm;
1875  }
1876  }
1877 
1878  //abort();
1879 #endif /* USE_BFCTIMESTAMP */
1880 
1881  if (!GetOption("fzin")) {
1882  struct Field_t {
1883  const Char_t *name;
1884  Float_t scale;
1885  };
1886  Field_t FieldOptions[5] = {
1887  {"FullMagFNegative", -1.0},
1888  {"FullMagFPositive", 1.0},
1889  {"HalfMagFNegative", -0.5},
1890  {"HalfMagFPositive", 0.5},
1891  {"ZeroMagF", 0.0}
1892  };
1893  Int_t k = -1;
1894  if (GetOption("FieldON")) {
1895  if (GetOption("ReverseField")) k = 0;
1896  else k = 1;
1897  } else if (GetOption("HalfField")) {
1898  if (GetOption("ReverseField")) k = 2;
1899  else k = 3;
1900  } else if (GetOption("FieldOff")) k = 4;
1901  if (k >= 0) {
1902  SetFlavor(FieldOptions[k].name, "MagFactor");
1903  gMessMgr->QAInfo() << "StBFChain::SetDbOptions SetFlavor(\"" << FieldOptions[k].name
1904  << "\",\"MagFactor\")" << endm;
1905  if ( gClassTable->GetID("StarMagField") >= 0) {
1906  TString cmd =
1907  Form("if (!StarMagField::Instance()) new StarMagField( StarMagField::EBField::kMapped, %f, kTRUE);",
1908  FieldOptions[k].scale);
1909  ProcessLine(cmd);
1910  }
1911  }
1912  }
1913  if (this == GetTopChain()) {
1914  // Db blacklist (remove black listed system from St_Db_Maker Calibrations configuration)
1915  if (! GetOption("TpcDb") ) {mk->SetAttr("blacklist", "tpc"); gMessMgr->QAInfo() << "blacklist tpc" << endm;}
1916  if (!(GetOption("SvtDb")||GetOption("SvtCalDb"))) {mk->SetAttr("blacklist", "svt"); gMessMgr->QAInfo() << "blacklist svt" << endm;}
1917  if (!(GetOption("SsdDb")||GetOption("SsdCalDb"))) {mk->SetAttr("blacklist", "ssd"); gMessMgr->QAInfo() << "blacklist ssd" << endm;}
1918  if (!(GetOption("SstDb")||GetOption("SstCalDb"))) {mk->SetAttr("blacklist", "sst"); gMessMgr->QAInfo() << "blacklist sst" << endm;}
1919  if (! GetOption("EemcDb") ) {mk->SetAttr("blacklist", "eemc"); gMessMgr->QAInfo() << "blacklist eemc"<< endm;}
1920  if (! GetOption("FmsDb") ) {mk->SetAttr("blacklist", "fms"); gMessMgr->QAInfo() << "blacklist fms" << endm;}
1921  } else {// for Embedding chain trigger black list by NoSsdIT and NoSvtIT, could be some problems if you try to run svt or ssd clusters, ...
1922  if (GetOption("NoSvtIt")) {mk->SetAttr("blacklist", "svt"); gMessMgr->QAInfo() << "blacklist svt" << endm;}
1923  if (GetOption("NoSsdIt")) {mk->SetAttr("blacklist", "ssd"); gMessMgr->QAInfo() << "blacklist ssd" << endm;}
1924  if (GetOption("NoSstIt")) {mk->SetAttr("blacklist", "sst"); gMessMgr->QAInfo() << "blacklist sst" << endm;}
1925  }
1926 }
1927 //_____________________________________________________________________
1930 {
1931 
1932  StTreeMaker *treeMk = (StTreeMaker *) GetMaker("outputStream");
1933  if (!treeMk) return;
1934  if (GetOption("EvOut")){
1935  gMessMgr->QAInfo() << "Will Write StEvent out, treeMk->GetFile() = " << treeMk->GetFile() << endm;
1936  treeMk->IntoBranch("eventBranch","StEvent");
1937  if (GetOption("EvOutOnly")) return;
1938  }
1939  if (! GetOption("nohistos")) treeMk->SetBranch("histBranch");
1940  if (! GetOption("norunco")) treeMk->SetBranch("runcoBranch");
1941  if (GetOption("McEvent") && GetOption("McEvOut")){
1942  gMessMgr->QAInfo() << "Will Write StMcEvent out, treeMk->GetFile() = " << treeMk->GetFile() << endm;
1943  treeMk->IntoBranch("McEventBranch","StMcEvent");
1944  }
1945  if (GetOption("GeantOut")) treeMk->IntoBranch("geantBranch","geant");
1946  if (GetOption("AllEvent")) {
1947  if (GetOption("fzin") ||
1948  GetOption("ntin") ||
1949  GetOption("gstar") ||
1950  GetOption("pythia") ||
1951  GetOption("VMC") ||
1952  GetOption("PrepEmbed")) {
1953  treeMk->IntoBranch("geantBranch","geant");
1954  treeMk->IntoBranch("geantBranch","geant/.data/particle");
1955  treeMk->IntoBranch("geantBranch","geant/.data/g2t_rch_hit");
1956  }
1957  }
1958 }
1959 //________________________________________________________________________________
1960 Long_t StBFChain::ProcessLine(const char *line) {
1961  if (! line || !strlen(line)) return -1;
1962  if (Debug()) gMessMgr->QAInfo() << "ProcessLine " << line << endm;
1963  TInterpreter::EErrorCode error = TInterpreter::kNoError;
1964  Long_t res = gInterpreter->ProcessLine(line, &error);
1965  if (error != TInterpreter::kNoError) {
1966  gMessMgr->Error() << "StBFChain::ProcessLine command:" << line << " has failed. Quit job." << endm;
1967  gSystem->Exit(1);
1968  }
1969  return res;
1970 }
1971 //________________________________________________________________________________
1972 TString StBFChain::GetGeometry() const
1973 {
1974  Int_t n = fchainOpt->GetNRows();
1975  for (Int_t i=0;i<n;i++) {
1976  if (!fchainOpt->GetTable()[i].Flag) continue;
1977  TString k(fchainOpt->GetTable()[i].Key);
1978  k.ToLower();
1979  if (k[0]!='y') continue;
1980  if (k[1]!='2') continue;
1981  if (k[2] <'0' || k[2]>'9') continue;
1982  if (k[3] <'0' || k[3]>'9') continue;
1983  if (k[4] <'0' || k[4]>'9') continue;
1984  return k;
1985  }
1986  return TString("");
1987 }
Definition: FJcore.h:367
virtual Int_t Instantiate()
Maker-instantiation handler.
Definition: StBFChain.cxx:214
virtual Int_t Finish()
Really the destructor (close files, delete pointers etc ...)
Definition: StBFChain.cxx:1054
Definition: StTree.h:125
virtual Char_t * GetOptionString(const Char_t *)
Returns the comment string associated to an option.
Definition: StBFChain.cxx:1475
virtual void SetIOMode(Option_t *iomode="w")
number of transactions
Definition: StIOInterFace.h:35
void Setup(Int_t mode=1)
Definition: StBFChain.cxx:59
void SetFlags(const Char_t *Chain="gstar tfs")
Scan all flags, check if they are correct, manipulate the comment if necessary.
Definition: StBFChain.cxx:1513
virtual void SetTreeOptions()
Creates output-tree branches.
Definition: StBFChain.cxx:1929
virtual Int_t Finish()
Definition: StChain.cxx:85
virtual void SetGeantOptions(StMaker *geant=0)
Handles all geant options.
Definition: StBFChain.cxx:1737
virtual void SetDbOptions(StMaker *db=0)
Treats the DbV options used for database timestamp.
Definition: StBFChain.cxx:1782
Definition: Bfc.h:8
virtual Int_t kOpt(const TString *Tag, Bool_t Check=kTRUE) const
Check option if defined.
Definition: StBFChain.cxx:1140
virtual Long_t GetNRows() const
Returns the number of the used rows for the wrapped table.
Definition: TTable.cxx:1388
virtual Int_t AddAt(const void *c)
Definition: TTable.cxx:1122
virtual const char * GetName() const
special overload
Definition: StMaker.cxx:237
Definition: Stypes.h:40
virtual void SetOption(const Int_t k, const Char_t *chain="Chain")
Enable/disable valid command line options.
Definition: StBFChain.cxx:1430
virtual Int_t Load()
Routine handling library loading depending on chain options.
Definition: StBFChain.cxx:117
virtual ~StBFChain()
Destructor. Call Finish() . See this method for detail on what is cleaned.
Definition: StBFChain.cxx:112
void SetOutputFile(const Char_t *outfile=0)
Takes care of output file name (extension)
Definition: StBFChain.cxx:1647
virtual void SetActive(Bool_t k=kTRUE)
Setters for flags and switches.
Definition: StMaker.h:208
Definition: Stypes.h:44
Definition: Stypes.h:41
Definition: Bfc.h:28