00001
00002
00003
00020
#define STAR_LOGGER 1
00021
#include "Stiostream.h"
00022
#include <stdio.h>
00023
#include <stdlib.h>
00024
00025
#include "TSystem.h"
00026
#include "TClass.h"
00027
#include "TROOT.h"
00028
#include "TError.h"
00029
#if 0
00030
#include "THtml.h"
00031
#endif
00032
#include "TH1.h"
00033
00034
#include "TChain.h"
00035
#include "TTree.h"
00036
#include "TList.h"
00037
#include "TClonesArray.h"
00038
#include "TBrowser.h"
00039
00040
#include "StMaker.h"
00041
#include "StChainOpt.h"
00042
#include "TObjectSet.h"
00043
#include "StChain.h"
00044
#include "TTable.h"
00045
00046
#include "StMemStat.h"
00047
#include "TAttr.h"
00048
#include "StMkDeb.h"
00049
#include "StMessMgr.h"
00050
00051 StMaker *
StMaker::fgTopChain = 0;
00052 StMaker *
StMaker::fgStChain = 0;
00053 StMaker *
StMaker::fgFailedMaker = 0;
00054 StTestMaker *
StMaker::fgTestMaker = 0;
00055 Int_t StMaker::fgTallyMaker[
kStFatal+1] = {0,0,0,0,0};
00056 Int_t MaxWarnings = 26;
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102
00103
00104
00105
00106
00107
00108
00109
00110
00111
00112
00113
00114
00115
00116
00117
00118
00119
00120
00121
00122
00123
00124
00125
00126
00127
00128
00129
00130
00131
00132
00133
00134
00135
static const DbAlias_t fDbAlias[] = {
00136 {
"sd97", 19970101, 0,
"year2000",
""},
00137 {
"sd98", 19980101, 0,
"year2000",
""},
00138 {
"y1a", 19990101, 0,
"year2000",
""},
00139 {
"year_1a", 19990101, 0,
"year2000",
""},
00140 {
"y1b", 19990501, 0,
"year2000",
""},
00141 {
"year_1b", 19990501, 0,
"year2000",
""},
00142 {
"y1s", 19990501, 0,
"year2000",
""},
00143 {
"year_1s", 19990501, 0,
"year2000",
""},
00144 {
"es99", 19990615, 0,
"year2000",
""},
00145 {
"er99", 19990616,120000,
"year2000",
""},
00146 {
"year_1c", 19991001, 0,
"year2000",
""},
00147 {
"y1d", 19991101, 0,
"year2000",
""},
00148 {
"year_1d", 19991101, 0,
"year2000",
""},
00149 {
"y1e", 19991201, 0,
"year2000",
""},
00150 {
"year_1e", 19991201, 0,
"year2000",
""},
00151 {
"dc99", 19991206, 80000,
"year2000",
""},
00152 {
"y1h", 20000614,175430,
"year2000",
""},
00153 {
"y2000", 20000614,175430,
"year2000",
""},
00154 {
"y2b", 20010501, 0,
"year_2b",
""},
00155 {
"y2001", 20010501, 0,
"year2001",
""},
00156 {
"year_2b", 20010501, 0,
"year_2b",
""},
00157 {
"year2002", 20010502, 0,
"year2002",
""},
00158 {
"y2a", 20010610, 0,
"year_2a",
""},
00159 {
"year_2a", 20010610, 0,
"year_2a",
""},
00160 {
"y2001n", 20010615, 0,
"year2001",
""},
00161 {
"year2001", 20010615, 0,
"year2001",
""},
00162 {
"y2003", 20021115, 0,
"year2003",
""},
00163 {
"year2003", 20021115, 0,
"year2003",
""},
00164 {
"y2003x", 20021115, 1,
"y2003x",
""},
00165 {
"y2003a", 20021115, 2,
"y2003a",
""},
00166 {
"y2003b", 20021115, 3,
"y2003b",
""},
00167 {
"y2003c", 20021115, 4,
"y2003c",
"new SVT"},
00168 {
"y2004", 20031120, 0,
"y2004",
""},
00169 {
"y2004x", 20031120, 1,
"y2004x",
""},
00170 {
"y2004y", 20031120, 2,
"y2004y",
""},
00171 {
"y2004a", 20031120, 3,
"y2004a",
""},
00172 {
"y2004b", 20031120, 4,
"y2004b",
""},
00173 {
"y2004c", 20031125, 0,
"y2004c",
""},
00174 {
"y2004d", 20031125, 1,
"y2004d",
"new SVT"},
00175
00176 {
"y2005x", 20041030, 0,
"y2005x",
""},
00177 {
"y2005", 20041030, 0,
"y2005",
""},
00178 {
"y2005b", 20041101, 0,
"y2005b",
""},
00179 {
"y2005c", 20041201, 0,
"y2005c",
""},
00180 {
"y2005d", 20041201, 1,
"y2005d",
"y2005c + new SVT"},
00181 {
"y2005e", 20041201, 2,
"y2005e",
"y2005d + new SSD"},
00182 {
"y2005f", 20041201, 3,
"y2005f",
"y2005e + SSD5/CALB2"},
00183 {
"y2005g", 20041201, 4,
"y2005g",
"y2005f + SVT dead material"},
00184
00185
00186 {
"y2006", 20051201, 0,
"y2006",
"base for y2006: y2005e+fixed TPC plane"},
00187 {
"y2006a", 20051201, 1,
"y2006a",
"y2006+new FPD"},
00188 {
"y2006b", 20051201, 2,
"y2006b",
"y2006+new FPD+SSD5/CALB2"},
00189 {
"y2006c", 20051201, 3,
"y2006c",
"y2006+new FPD+SSD5/CALB2+noPMD"},
00190 {
"y2006g", 20051201, 4,
"y2006g",
"y2006c + SVT dead material"},
00191
00192
00193 {
"y2007", 20061105, 0,
"y2007",
"base geometry for y2007"},
00194 {
"y2007a", 20061105, 1,
"y2007a",
"the material of the water channels is now carbon "},
00195 {
"y2007g", 20061105, 4,
"y2007g",
"y2007b + SVT dead material"},
00196
00197
00198 {
"y2008", 20071101, 0,
"y2008",
"base for y2008: SVT/SSD out, cone is lost"},
00199 {
"y2008a", 20071101, 1,
"y2008a",
"base for y2008: SVT/SSD out, cone in separate SCON"},
00200
00201 {
"y2009", 20081215, 0,
"y2009",
"Practically place holder yet(VP)"},
00202
00203
00204
00205
00206
00207
00208 {
"upgr01", 20190101, 4,
"upgr01",
""},
00209 {
"upgr02", 20190101, 5,
"upgr02",
""},
00210 {
"upgr03", 20190101, 6,
"upgr03",
""},
00211 {
"upgr04", 20190101, 7,
"upgr04",
""},
00212 {
"upgr05", 20190101, 8,
"upgr05",
""},
00213 {
"upgr06", 20190101, 9,
"upgr06",
""},
00214 {
"upgr07", 20190101, 10,
"upgr07",
""},
00215 {
"upgr08", 20190101, 11,
"upgr08",
""},
00216 {
"upgr09", 20190101, 12,
"upgr09",
""},
00217 {
"upgr10", 20190101, 13,
"upgr10",
""},
00218 {
"upgr11", 20190101, 14,
"upgr11",
""},
00219 {
"upgr12", 20190101, 15,
"upgr12",
""},
00220 {
"upgr13", 20190101, 16,
"upgr13",
""},
00221 {
"upgr14", 20190101, 17,
"upgr14",
""},
00222 {
"upgr15", 20190101, 18,
"upgr15",
""},
00223 {
"upgr16", 20190101, 19,
"upgr16",
""},
00224 {
"upgr17", 20190101, 20,
"upgr17",
""},
00225
00226 {
"simpletpc", 20200102, 16,
"simpletpc",
""},
00227 {
"upgr20", 20200102, 17,
"upgr20",
"y2007 + one TOF"},
00228 {
"upgr21", 20200102, 18,
"upgr21",
"y2007 + full TOF"},
00229 {0, 0, 0, 0, 0}
00230 };
00231
00232
00233
#define TURN_LOGGER(maker) \
00234
if (!fLogger) fLogger = StMessMgr::Instance(ClassName()); \
00235
StTurnLogger SaveRestoreLogger(maker->GetLogger());
00236
00237
00238 ClassImp(
StMaker)
00239
00240 static
void doPs(const Char_t *who,const Char_t *where);
00241
00242
00243 StMaker::
StMaker(const Char_t *name,const Char_t *):TDataSet(name,".maker"),
00244 m_Mode(0), m_Number(0), m_LastRun(-3),
00245 m_DebugLevel(0),m_MakeReturn(0),fStatus(0),
00246 fLogger(0),fLoggerHold(0)
00247 {
00248 m_Attr=0;
00249 m_Inputs = 0;
00250
if (!fgStChain) {
00251 fgTopChain = fgStChain =
this;
00252 gROOT->GetListOfBrowsables()->Add(
this,GetName());
00253 AddData(0,
".make");
00254 }
else {
00255 fgStChain->AddData(
this,
".make");
00256 }
00257 m_DataSet =
new TObjectSet(
".data") ;Add(m_DataSet);
00258 m_ConstSet =
new TObjectSet(
".const");Add(m_ConstSet);
00259 m_GarbSet =
new TObjectSet(
".garb" );Add(m_GarbSet);
00260 m_Inputs =
new TObjectSet(
".aliases" );Add(m_Inputs);
00261 m_Runco =
new TObjectSet(
".runco" );Add(m_Runco);
00262 AddHist(0); m_Histograms = GetHistList();
00263 ::doPs(GetName(),
"constructor");
00264 m_Timer.Stop();
00265 fMemStatMake = 0;
00266 fMemStatClear = 0;
00267 memset(fTallyMaker,0,(
kStFatal+1)*
sizeof(Int_t));
00268 SetActive();
00269 StMkDeb::Register(
this);
00270 }
00271
00272
00273
void StMaker::AddMaker(
StMaker *mk)
00274 {
00275 TDataSet *dotmk = Find(
".make");
00276
if (!dotmk) dotmk =
new TDataSet(
".make",
this);
00277 mk->Shunt(dotmk);
00278 }
00279
00280 StMaker::~StMaker()
00281 {
00282
if (
fgTopChain ==
this)
fgTopChain = 0;
00283
if (
fgStChain ==
this)
fgStChain = 0;
00284
delete fMemStatMake;
fMemStatMake = 0;
00285
delete fMemStatClear;
fMemStatClear = 0;
00286 TDataSet *ds =
this;
00287 Cleanup(ds);
00288 StMkDeb::Cancel(
this);
00289 }
00290
00291 const Char_t *
StMaker::GetName()
const
00292
{
00293
static Int_t occ = 0;
00294
const Char_t *name = TNamed::GetName();
00295
if (name && *name )
return name;
00296 TString ts(ClassName());
00297 ts+=
"#"; ts+=(occ++);
00298 ((TNamed*)
this)->SetName(ts.Data());
00299
return GetName();
00300 }
00301
00302
void StMaker::SetNumber(Int_t number)
00303 {
00304
StMaker *par = GetParentMaker();
00305
if (par) par->SetNumber(number);
00306 m_Number = number;
00307 SetIventNumber(number);
00308 }
00309
00310 Int_t
StMaker::GetNumber()
const
00311
{
00312
StMaker *par = GetParentMaker();
00313
if (par)
return par->GetNumber();
00314
return m_Number;
00315 }
00316
00317
StMaker *StMaker::GetParentMaker()
const
00318
{
00319 TDataSet *par = GetParent();
if (!par)
return 0;
00320
return (
StMaker*)par->GetParent();
00321 }
00322
00323
StMaker *StMaker::GetMaker(
const Char_t *mkname)
00324 {
00325 TString path(
".make/"); path+=mkname;
00326
return (
StMaker*)GetDataSet((
const char*)path);
00327 }
00328
00329 TObject *StMaker::GetDirObj(
const Char_t *dir)
const
00330
{
00331 TObjectSet *h = (TObjectSet*)Find(dir);
00332
if (!h)
return 0;
00333
return h->GetObject();
00334 }
00335
00336
void StMaker::SetDirObj(TObject *obj,
const Char_t *dir)
00337 {
00338 TObjectSet *set = (TObjectSet *)Find(dir);
00339
if (!set) {
00340 set =
new TObjectSet(dir); Add(set);}
00341 set->SetObject(obj);
00342 }
00343
00344 TObjectSet *StMaker::AddObj(TObject *obj,
const Char_t *dir)
00345 {
00346 assert (dir[0]==
'.');
00347 TObjectSet *set = (TObjectSet*)Find(dir);
00348
if (!set) {
00349 set =
new TObjectSet(dir); Add(set);}
00350
00351 TList *list = (TList *)set->GetObject();
00352
if (!list) {
00353 list =
new TList();
00354 set->SetObject((TObject*)list);}
00355
if (!obj)
return set;
00356
if(!list->FindObject(obj)) list->Add(obj);
00357
return set;
00358 }
00359
00360
void StMaker::AddHist(TH1 *h,
const Char_t *dir)
00361 {
00362
if (dir){}
00363
if (!h) {AddObj(0,
".hist");
return;}
00364
if (h->InheritsFrom(TH1::Class())) h->SetDirectory(0);
00365 AddObj(h,
".hist");
00366 }
00367
00368
void StMaker::AddRunco (Double_t par,
const Char_t *name,
const Char_t *comment)
00369 {
00370 assert (name && name && comment[0]);
00371
00372 TDataSet *dp =
new TDataSet(name,m_Runco);
00373 TString ts(
" // "); ts += comment;
00374 Char_t buf[40];
00375 sprintf(buf,
"%f",par);
00376 ts.Replace(0,0,buf);
00377 dp->SetTitle((
const char*)ts);
00378 }
00379
00380
00381
00382 TDataSet *
StMaker::AddData(TDataSet *ds,
const Char_t *dir)
00383 {
00384 assert (dir); assert(dir[0]==
'.');
00385 TDataSet *set = Find(dir);
00386
if (!set) {
00387 set =
new TObjectSet(dir); Add(set);}
00388
if (!ds)
return set;
00389 Int_t dotMake = (strcmp(dir,
".make")==0);
00390 Int_t inhMake = ds->InheritsFrom(StMaker::Class());
00391
if (dotMake!=inhMake) {
00392 Error(
"AddData",
"Add to %s is NOT allowed: %s.%s\n"
00393 ,dir,ds->ClassName(),ds->GetName());
00394
return 0;}
00395
00396 TList *tl = set->GetList();
00397
if (!tl || !tl->FindObject(ds->GetName())) {
00398 set->Add(ds);
00399 }
else {
00400 Error(
"AddData",
"Data %s/%s is not added. ***Name clash***",dir,ds->GetName());
00401
return 0;
00402 }
00403
return set;
00404 }
00405
00406 TDataSet *StMaker::GetData(
const Char_t *name,
const Char_t *dir)
const
00407
{
00408 TDataSet *set = Find(dir);
00409
if (!set)
return 0;
00410
return set->Find(name);
00411 }
00412
00413
void StMaker::ToWhiteBoard(
const Char_t *name,
void *dat)
00414 {
00415 TObjectSet *envelop =
new TObjectSet(name,(TObject*)dat,0);
00416 envelop->SetTitle(
".envelop");
00417
AddData(envelop,
".data");
00418 }
00419
00420
void StMaker::ToWhiteConst(
const Char_t *name,
void *dat)
00421 {
00422 TObjectSet *envelop =
new TObjectSet(name,(TObject*)dat,0);
00423 envelop->SetTitle(
".envelop");
00424
AddData(envelop,
".const");
00425 }
00426
00427
void StMaker::ToWhiteBoard(
const Char_t *name, TObject *dat, Int_t owner)
00428 {
00429 TObjectSet *envelop =
new TObjectSet(name,dat,owner);
00430 envelop->SetTitle(
".envelop");
00431
AddData(envelop,
".data");
00432 }
00433
00434
void StMaker::ToWhiteConst(
const Char_t *name, TObject *dat, Int_t owner)
00435 {
00436 TObjectSet *envelop =
new TObjectSet(name,dat,owner);
00437 envelop->SetTitle(
".envelop");
00438
AddData(envelop,
".const");
00439 }
00440
00441
void *StMaker::WhiteBoard(
const Char_t *name,
void *v)
const
00442
{
00443
void **dat = (
void **)v;
00444 *dat = 0;
00445 TDataSet *ds = GetDataSet(name);
00446
if (!ds)
return 0;
00447
if (strcmp(
".envelop",ds->GetTitle())==0) {*dat = ds->GetObject();}
00448
else {*dat = ds ;}
00449
return ds->GetObject();
00450 }
00451
00452
void StMaker::AddAlias(
const Char_t *log,
const Char_t *act,
const Char_t *dir)
00453 {
00454 TDataSet *ali =
new TDataSet(log);
00455 ali->SetTitle(act);
00456
AddData(ali,dir);
00457 }
00458
00459
void StMaker::SetNotify(
const Char_t *about,
StMaker *mk)
00460 {
00461 TDataSet *ali =
new TObjectSet(about,mk,0);
00462
AddData(ali,
".notify");
00463 }
00464
00465
void StMaker::NotifyEm(
const Char_t *about,
const void *ptr)
00466 {
00467
00468 TURN_LOGGER(
this);
00469
00470 TDataSet *set = Find(
".notify");
00471
if (!set)
return;
00472 TDataSetIter iter(set);
00473 TObjectSet *os=0;
00474
while((os=(TObjectSet*)iter())) {
00475
if (strcmp(about,os->GetName()))
continue;
00476
StMaker *mk=(
StMaker*)os->GetObject();
00477
if (!mk)
continue;
00478 TURN_LOGGER(mk);
00479 mk->
NotifyMe(about,ptr);
00480 }
00481
00482 }
00483
00484
void StMaker::SetAlias(
const Char_t *log,
const Char_t *act,
const Char_t *dir)
00485 {
00486 TDataSet *ali = GetData(log,dir);
00487
if (ali) {
00488
if (!strcmp(act,ali->GetTitle()))
return;
00489 }
else {
00490 ali =
new TDataSet(log);
AddData(ali,dir);
00491 }
00492 ali->SetTitle(act);
00493
00494
if (GetDebug()) {
00495
#ifdef STAR_LOGGER
00496
LOG_DEBUG <<
"<" << ClassName() <<
"(" <<
GetName() <<
"::SetAlias> "
00497 << log <<
" = " << act << endm;
00498
#else
00499
printf(
"<%s(%s)::SetAlias> %s = %s\n",ClassName(),
GetName(),log,act);
00500
#endif
00501
}
00502 }
00503
00504
void StMaker::SetOutput(
const Char_t *log,TDataSet *ds)
00505 {
00506 Int_t idx;
00507
const Char_t *logname = log;
00508
if (!logname || !logname[0]) logname = ds->GetName();
00509 TString act = ds->Path();
00510
while ((idx=act.Index(
".make/"))>=0) act.Replace(0,idx+6,
"");
00511 SetOutput(logname,act);
00512 }
00513
00514
00515
void StMaker::SetOutputAll(TDataSet *ds, Int_t level)
00516 {
00517 TDataSet *set;
00518 TDataSetIter next(ds,level);
00519
while ((set = next())) SetOutput(set);
00520 }
00521
00522
00523 TList *StMaker::GetMakeList()
const
00524
{ TDataSet *ds = Find(
".make");
00525
if (!ds)
return 0;
00526
return ds->GetList();
00527 }
00528
00529 TString StMaker::GetAlias(
const Char_t *log,
const Char_t *dir)
const
00530
{
00531 Int_t nspn = strcspn(log,
" /");
00532 TString act(log,nspn);
00533 TDataSet *in = GetData(act,dir);
00534 act =
"";
00535
if (in) {act = in->GetTitle(); act += log+nspn;}
00536
return act;
00537 }
00538
00539 TDataSet *StMaker::FindDataSet(
const Char_t *logInput,
00540
const StMaker *uppMk,
00541
const StMaker *dowMk)
const
00542
{
00543 TURN_LOGGER(
this);
00544
00545 TDataSetIter nextMk(0);
00546 TString actInput,findString,tmp;
00547 TDataSet *dataset,*dir;
00548
StMaker *parent,*mk;
00549 Int_t icol,islas;
00550
00551 actInput = GetInput(logInput);
00552
if (actInput.IsNull()) actInput = logInput;
00553
00554
00555
00556 dataset = 0;
00557
if (actInput.Contains(
".")) dataset = Find(actInput);
00558
if (dataset)
goto FOUND;
00559
00560
if (actInput==
GetName()) dataset = m_DataSet;
00561
if (dataset)
goto FOUND;
00562
00563
00564
00565
00566 icol = actInput.Index(
":");
00567
if (icol>=0) {
00568 tmp = actInput;
00569 tmp.Replace(0,0,
".make/"); icol +=6;
00570 tmp.Replace(icol,1,
"/.data/");
00571 dataset = Find((
const char*)tmp);
00572
if (dataset)
goto FOUND;
00573 dataset = Find((
const char*)tmp+6);
00574
if (dataset)
goto FOUND;
00575 tmp.Replace(icol,7,
"/.const/");
00576 dataset = Find((
const char*)tmp);
00577
if (dataset)
goto FOUND;
00578 dataset = Find((
const char*)tmp+6);
00579
if (dataset)
goto FOUND;
00580
goto DOWN;
00581 }
00582
00583
if (m_DataSet) {
00584 islas = actInput.Index(
"/");
00585
if (islas>0) {
00586 tmp.Replace(0,999,actInput,islas);
00587
if (tmp ==
GetName()) {
00588 tmp = actInput;
00589 tmp.Replace(0,islas+1,
"");
00590 dataset = m_DataSet->Find(tmp);
00591
if (dataset)
goto FOUND;
00592 dataset = m_ConstSet->Find(tmp);
00593
if (dataset)
goto FOUND;
00594 }
00595 }
00596
00597 dataset = m_DataSet->Find(actInput);
00598
if (dataset)
goto FOUND;
00599 dataset = m_ConstSet->Find(actInput);
00600
if (dataset)
goto FOUND;
00601 }
00602
00603
00604 DOWN:
if (!(dir = Find(
".make")))
goto UP;
00605
00606 nextMk.Reset(dir);
00607
while ((mk = (
StMaker* )nextMk()))
00608 {
00609
if (mk==dowMk)
continue;
00610 dataset = mk->
FindDataSet(actInput,
this,0);
00611
if (dataset)
goto FOUND;
00612 }
00613
00614
00615 UP:
if (uppMk)
return 0;
00616
00617 parent = GetMaker(
this);
if (!parent)
goto NOTFOUND;
00618 dataset = parent->
FindDataSet(actInput,0,
this);
00619
if (dataset)
goto FOUND;
00620
00621
00622 NOTFOUND:
00623
if (!dowMk && GetDebug()>1)
00624
if ((MaxWarnings--) > 0) Warning(
"GetDataSet",
" \"%s\" Not Found ***\n",(
const char*)actInput);
00625
return 0;
00626
00627
00628 FOUND:
if (uppMk || dowMk)
return dataset;
00629
if (GetDebug()<2)
return dataset;
00630 printf(
"Remark: <%s::%s> DataSet %s FOUND in %s\n"
00631 ,ClassName(),
"GetDataSet",logInput,(
const char*)dataset->Path());
00632
00633
return dataset;
00634
00635 }
00636
00637 TDataSet *StMaker::GetDataBase(
const Char_t *logInput,
const TDatime *td)
00638 {
00639 TURN_LOGGER(
this);
00640 TDataSet *ds = 0;
00641
StMaker *mk = GetMakerInheritsFrom(
"St_db_Maker");
00642
if (mk) ds = mk->
GetDataBase(logInput,td);
00643
return ds;
00644 }
00645
00646
StMaker *StMaker::GetMakerInheritsFrom (
const Char_t *mktype)
const
00647
{
00648 TURN_LOGGER(
this);
00649
StMaker *mk = 0;
00650 StMakerIter mkiter(
this);
00651
while ((mk = mkiter.NextMaker())) {
00652
if (mk->InheritsFrom(mktype))
break;
00653 }
00654
return mk;
00655 }
00656
00657
void StMaker::SetFlavor(
const Char_t *flav,
const Char_t *tabname)
00658 {
00659
StMaker *mk = GetMakerInheritsFrom(
"St_db_Maker");
00660
if (mk) mk->
SetFlavor(flav,tabname);
00661 }
00662
00663 Int_t StMaker::GetValidity(
const TTable *tb, TDatime *val)
const
00664
{
00665
StMaker *mk = GetMaker(tb);
00666
if (!mk)
return 10;
00667
if (!mk->InheritsFrom(
"St_db_Maker"))
return 11;
00668
return mk->
GetValidity(tb,val);
00669 }
00670
00671 void StMaker::Clear(Option_t *option)
00672 {
00673 TURN_LOGGER(
this);
00674
00675
m_MakeReturn = 0;
00676
if(option){};
00677
if (m_DataSet) m_DataSet->Delete();
00678
00679
00680
00681 TIter next(GetMakeList(),kIterBackward);
00682
StMaker *maker;
00683 Int_t curr = StMkDeb::GetCurrent();
00684
while ((maker = (
StMaker* )next())) {
00685 assert(maker->TestBIT(kCleaBeg)==0);
00686 StMkDeb::SetCurrent(maker,3);
00687 maker->SetBIT(kCleaBeg);
00688 maker->StartTimer();
00689
if (maker->fMemStatClear &&
GetNumber()>20) maker->fMemStatClear->Start();
00690 TURN_LOGGER(maker);
00691 maker->
Clear(option);
00692
if (maker->fMemStatClear &&
GetNumber()>20) maker->fMemStatClear->Stop();
00693 maker->StopTimer();
00694 maker->ResetBIT(kCleaBeg);
00695 StMkDeb::SetCurrent(curr);
00696 }
00697 TCollection::EmptyGarbageCollection();
00698 doPs(
GetName(),
"Clear");
00699
00700
00701
00702
00703
return;
00704
00705 }
00706
00707 Int_t StMaker::Init()
00708 {
00709 TURN_LOGGER(
this);
00710 TObject *objLast,*objHist;
00711 TList *tl = GetMakeList();
00712
if (!tl)
return kStOK;
00713
00714 TIter nextMaker(tl);
00715
StMaker *maker;
00716 Int_t curr = StMkDeb::GetCurrent();
00717
while ((maker = (
StMaker* )nextMaker())) {
00718
00719 TURN_LOGGER(maker);
00720
00721 gROOT->cd();
00722 objLast = gDirectory->GetList()->Last();
00723
00724
00725
00726 assert(maker->TestBIT(kInitBeg)|maker->TestBIT(kInitEnd)==0);
00727 StMkDeb::SetCurrent(maker,1);
00728 maker->SetBIT(kInitBeg);
00729 maker->StartTimer();
00730
00731
if (GetDebug()) {
00732
#ifdef STAR_LOGGER
00733
LOG_DEBUG <<
"*** Call << " << maker->ClassName() <<
":Init() ***" << endm;
00734
#else
00735
printf(
"\n*** Call %s::Init() ***\n\n",maker->ClassName());
00736
#endif
00737
}
00738 TString ts1(maker->ClassName()); ts1+=
"("; ts1+=maker->GetName(); ts1+=
")::";
00739 TString ts2 = ts1; ts2+=
"Make ";
00740 maker->fMemStatMake =
new StMemStat(ts2);
00741 ts2 = ts1; ts2+=
"Clear";
00742 maker->fMemStatClear =
new StMemStat(ts2);
00743
00744
if ( maker->
Init()) {
00745
#ifdef STAR_LOGGER
00746
LOG_ERROR <<
" Maker "<< maker->GetName() <<
" failed in Init" << endm;
00747
#else
00748
printf(
" Maker %s failed in Init\n", maker->GetName());
00749
#endif
00750
return kStErr;
00751 }
00752 maker->StopTimer();
00753
00754
00755
00756 gROOT->cd();
00757 TIter nextHist(gDirectory->GetList());
00758 Int_t ready = !objLast;
00759
while((objHist=nextHist())) {
00760
if (!ready && objHist!=objLast)
continue;
00761 ready = 1999;
00762
if (objHist==objLast)
continue;
00763
if (!objHist->InheritsFrom(
"TH1"))
continue;
00764
00765
00766 ((TH1*)objHist)->SetDirectory(0);
00767 maker->AddHist((TH1*)objHist);
00768 }
00769 ::doPs(maker->GetName(),
"Init");
00770 maker->ResetBIT(kInitBeg);
00771 maker->SetBIT (kInitEnd);
00772 StMkDeb::SetCurrent(curr);
00773 }
00774
return kStOK;
00775 }
00776
00777
void StMaker::StartMaker()
00778 {
00779
00780
if (!fLoggerHold) fLoggerHold =
new StTurnLogger(GetLogger());
00781
if (!m_DataSet) {
00782 m_DataSet = Find(
".data");
00783
if (!m_DataSet) {m_DataSet =
new TObjectSet(
".data"); Add(m_DataSet);}
00784 }
00785
00786
if (
fMemStatMake)
if (
GetNumber()>20)
fMemStatMake->
Start();
00787
else
00788
if (GetDebug()) {
00789
#ifdef STAR_LOGGER
00790
LOG_DEBUG <<
"StMaker::StartMaker : cannot use StMemStat (no Init()) in [" <<
00791
GetName() <<
"]" << endm;
00792
#else
00793
printf(
"StMaker::StartMaker : cannot use StMemStat (no Init()) in [%s]\n",
GetName());
00794
#endif
00795
}
00796
00797
00798
00799 StartTimer();
00800 }
00801
00802
void StMaker::EndMaker(Int_t ierr)
00803 {
00804 SetMakeReturn(ierr);
00805 fgTallyMaker[ierr%10]++;
00806
fTallyMaker [ierr%10]++;
00807
if (m_DataSet) m_DataSet->Pass(ClearDS,0);
00808
if (m_GarbSet) m_GarbSet->Delete();
00809 ::doPs(
GetName(),
"EndMaker");
00810
00811
00812
if (
fMemStatMake)
if (
GetNumber()>20)
fMemStatMake->
Stop();
00813
else
00814
if (GetDebug()) {
00815
#ifdef STAR_LOGGER
00816
LOG_DEBUG <<
"StMaker::EndMaker : cannot use StMemStat (no Init()) in ["
00817 <<
GetName()
00818 <<
"]"
00819 << endm ;
00820
#else
00821
printf(
"StMaker::EndMaker : cannot use StMemStat (no Init()) in [%s]\n",
GetName());
00822
#endif
00823
}
00824
00825
00826 StopTimer();
00827
00828
if (fLoggerHold) {
delete fLoggerHold; fLoggerHold = 0;}
00829
00830 }
00831
00832
00837 Int_t
StMaker::Finish()
00838 {
00839
if (TestBIT(kFiniEnd))
return 1;
00840 TURN_LOGGER(
this);
00841
00842 Int_t nerr = 0;
00843 Int_t run =
GetRunNumber();
00844
if (run>-1) FinishRun(run);
00845
00846 TIter next(GetMakeList(),kIterBackward);
00847
StMaker *maker;
00848 Double_t totalCpuTime = 0;
00849 Double_t totalRealTime = 0;
00850
while ((maker = (
StMaker* )next()))
00851 {
00852 totalCpuTime += maker->CpuTime();
00853 totalRealTime += maker->RealTime();
00854 }
00855
00856
00857
if (!totalRealTime) totalRealTime = 1;
00858
if (!totalCpuTime ) totalCpuTime = 1;
00859
00860 next.Reset();
00861 Int_t fst=1;
00862
while ((maker = (
StMaker*)next())) {
00863
#ifdef STAR_LOGGER
00864
TURN_LOGGER(maker);
00865
00866
if (fst) {
00867 fst=0;
00868 LOG_QA <<
00869 Form(
"=================================================================================") << endm;
00870 LOG_QA <<
00871 Form(
"QAInfo:Chain %20s::%-20s Ast =%6.2f Cpu =%6.2f "
00872 ,ClassName(),
GetName(),totalRealTime,totalCpuTime) << endm;
00873 }
00874 LOG_QA <<
00875 Form(
"QAInfo:Maker %20s::%-20s Ast =%6.2f(%4.1f%%) Cpu =%6.2f(%4.1f%%) "
00876 ,maker->ClassName(),maker->GetName()
00877 ,maker->RealTime()
00878 ,100*maker->RealTime()/totalRealTime
00879 ,maker->CpuTime()
00880 ,100*maker->CpuTime()/totalCpuTime) << endm;
00881
00882
static const Char_t *ee[]={
"nStOK",
"nStWarn",
"nStEOF",
"nStErr",
"nStFatal"};
00883 TString tail(
"");
00884
for (Int_t j=0;j<=
kStFatal;j++) {
00885
if (
fTallyMaker[j]) tail += Form(
" %s=%d",ee[j],
fTallyMaker[j]);}
00886
if (tail !=
"") LOG_QA << (
const Char_t *) tail << endm;
00887
#else
00888
if (fst) {
00889 fst=0;
00890 Printf(
"=================================================================================\n");
00891 Printf(
"QAInfo: Chain %20s::%-20s Ast =%6.2f Cpu =%6.2f "
00892 ,ClassName(),
GetName(),totalRealTime,totalCpuTime);
00893 }
00894 printf(
"QAInfo: Maker %20s::%-20s Ast =%6.2f(%4.1f%%) Cpu =%6.2f(%4.1f%%) "
00895 ,maker->ClassName(),maker->GetName()
00896 ,maker->RealTime()
00897 ,100*maker->RealTime()/totalRealTime
00898 ,maker->CpuTime()
00899 ,100*maker->CpuTime()/totalCpuTime);
00900
00901
static const Char_t *ee[]={
"nStOK",
"nStWarn",
"nStEOF",
"nStErr",
"nStFatal"};
00902
for (Int_t j=0;j<=
kStFatal;j++) {
00903
if (
fTallyMaker[j]) printf(
" %s=%d",ee[j],
fTallyMaker[j]);}
00904 printf(
"\n");
00905
#endif
00906
}
00907
00908 next.Reset();
00909 Int_t curr = StMkDeb::GetCurrent();
00910
while ((maker = (
StMaker* )next()))
00911 {
00912 TURN_LOGGER(maker);
00913
00914
if (maker->TestBIT(kFiniEnd)) {
00915 maker->Warning(
"Finish",
"maker %s.%s Finished twice"
00916 ,maker->GetName(),maker->ClassName());
00917
continue;}
00918 StMkDeb::SetCurrent(maker,4);
00919 maker->SetBIT(kFiniBeg);
00920
if ( maker->
Finish() ) nerr++;
00921 maker->ResetBIT(kFiniBeg);
00922 maker->SetBIT (kFiniEnd);
00923 StMkDeb::SetCurrent(curr);
00924 }
00925
if (!GetParent()) {
00926
#ifdef STAR_LOGGER
00927
LOG_INFO <<
"--------------Error Codes-------------------------" << endm;
00928 LOG_INFO <<
" nStOK nStWarn nStEOF nStErr nStFatal" << endm;
00929 TString tail(
"");
00930
for( Int_t i=0; i<=
kStFatal; i++) tail += Form(
"%10d",fgTallyMaker[i]);
00931
if (tail !=
"")
00932 LOG_INFO << (
const Char_t *)tail << endm;
00933 LOG_INFO <<
"--------------------------------------------------" << endm;
00934
#else
00935
printf(
"\n--------------Error Codes-------------------------\n");
00936 printf(
" nStOK nStWarn nStEOF nStErr nStFatal \n");
00937
for( Int_t i=0; i<=
kStFatal; i++) printf(
"%10d",fgTallyMaker[i]);
00938 printf(
"\n--------------------------------------------------\n");
00939
#endif
00940
}
00941
00942
00943
if (GetParent()==0)
StMemStat::Summary();
00944
return nerr;
00945 }
00946
00947
00958 Int_t
StMaker::Make()
00959 {
00960 TURN_LOGGER(
this);
00961
00962
00963 Int_t ret,run=-1,oldrun;
00964 TList *tl = GetMakeList();
00965
if (!tl)
return kStOK;
00966 StEvtHddr *hd = GetEvtHddr();
00967 TIter nextMaker(tl);
00968
StMaker *maker;
00969
fgFailedMaker = 0;
00970 Int_t curr = StMkDeb::GetCurrent();
00971
while ((maker = (
StMaker* )nextMaker())) {
00972
if (!maker->IsActive())
continue;
00973 TURN_LOGGER(maker);
00974 assert(maker->TestBIT(kMakeBeg)==0);
00975 maker->SetBIT(kMakeBeg);
00976 StMkDeb::SetCurrent(maker,2);
00977 oldrun = maker->m_LastRun;
00978
if (hd && hd->GetRunNumber()!=oldrun) {
00979
if (oldrun>-1) maker->FinishRun(oldrun);
00980 run = hd->GetRunNumber();
00981
if (Debug() &&
this ==
fgStChain &&
m_LastRun!=run){
00982
m_LastRun = run;
00983
#ifdef STAR_LOGGER
00984
LOG_INFO <<
" +++ New RunNumber found=" << run <<
" (previous = " << oldrun <<
")" << endm;
00985
#else
00986
printf(
" +++ New RunNumber found=%d (previous = %d)\n",run,oldrun);
00987
#endif
00988
hd->Print();
00989 }
00990 maker->InitRun(run);
00991 maker->m_LastRun=run;
00992 }
00993
00994
if (
fgTestMaker) {
fgTestMaker->SetNext(maker);
fgTestMaker->Make();}
00995
00996 maker->StartMaker();
00997 ret = maker->
Make();
00998 assert((ret%10)>=0 && (ret%10)<=
kStFatal);
00999 maker->EndMaker(ret);
01000
01001
if (Debug() || ret)
01002
#ifdef STAR_LOGGER
01003
LOG_INFO <<
"*** " << maker->ClassName() <<
"::Make() == "
01004 << RetCodeAsString(ret) <<
"(" << ret <<
") ***"
01005 << endm;
01006
#else
01007
printf(
"*** %s::Make() == %s(%d) ***\n"
01008 ,maker->ClassName(),RetCodeAsString(ret),ret);
01009
#endif
01010
maker->ResetBIT(kMakeBeg);
01011 StMkDeb::SetCurrent(curr);
01012
if ((ret%10)>
kStWarn) {
01013
if ((ret%10) !=
kStERR)
return ret;
01015
fgFailedMaker = maker;
01016
if (maker->IAttr(
".Privilege"))
return ret;
01017
continue;
01018 }
01019
01020 }
01021
return kStOK;
01022 }
01023
01024
void StMaker::FatalErr(Int_t Ierr,
const Char_t *com)
01025 {
01026
#ifdef STAR_LOGGER
01027
LOG_QA << Form(
"QAInfo:%s::Fatal: Error %d %s",
GetName(),Ierr,com) << endm;
01028 LOG_FATAL << Form(
"QAInfo:%s::Fatal: Error %d %s",
GetName(),Ierr,com) << endm;
01029
#else
01030
printf(
"QAInfo:%s::Fatal: Error %d %s\n",
GetName(),Ierr,com);
01031
#endif
01032
StMaker *parent = (
StMaker *)GetParent();
01033
if (parent) ((
StMaker*)parent)->FatalErr(Ierr,com);
01034
#ifndef STAR_LOGGER
01035
fflush(stdout);
01036
#endif
01037
}
01038
01039 StMaker *StMaker::GetMaker(
const TDataSet *ds)
01040 {
01041
const TDataSet *par = ds;
01042
while (par && (par = par->GetParent()) && strncmp(
".maker",par->GetTitle(),6)) {}
01043
return (
StMaker*) par;
01044 }
01045
01046
01052 EDataSetPass
StMaker::ClearDS (TDataSet* ds,
void * )
01053 {
01054
if (ds->InheritsFrom(TTable::Class())){
01055 TTable *table = (TTable *)ds;
01056 Int_t setSize = table->GetTableSize();
01057 table->ReAllocate();
01058 memset((
void *)table->At(table->GetNRows()),127,table->GetRowSize());
01059
01060
if (setSize && table->GetTableSize() == 0){
01061 table->Warning(
"ReAllocate",
" Table %s has purged from %d to %d "
01062 ,table->GetName(),setSize,table->GetTableSize());
01063 }
01064 table->NaN();
01065 }
01066
return kContinue;
01067 }
01068
01069
void StMaker::PrintInfo()
01070 {
01071
const char *cvs = GetCVS();
01072
const char *built = 0;
01073
if (cvs && cvs[0]) built = strstr(cvs,
"built");
01074
else cvs =
"No CVS tag was defined";
01075
#ifdef STAR_LOGGER
01076
if (built > cvs) LOG_QA << Form(
"QAInfo:%-20s %s from %.*s",ClassName(),built,built-cvs,cvs)<< endm;
01077
else LOG_QA << Form(
"QAInfo:%-20s from %s",ClassName(),cvs) << endm;
01078
#else
01079
if (built > cvs) printf(
"QAInfo:%-20s %s from %.*s\n",ClassName(),built,built-cvs,cvs);
01080
else printf(
"QAInfo:%-20s from %s\n",ClassName(),cvs);
01081
#endif
01082
01083 TIter next(GetMakeList());
01084
StMaker *maker;
01085
while ((maker = (
StMaker* )next())) {
01086 maker->PrintInfo();
01087 }
01088 }
01089
01090
01092 Int_t
StMaker::GetIventNumber()
const
01093
{
01094 StEvtHddr *hd = GetEvtHddr();
01095
return hd->GetIventNumber();
01096 }
01097
01098
01099
void StMaker::SetIventNumber(Int_t iv)
01100 {
01101 StEvtHddr *hd = GetEvtHddr();
01102 hd->SetIventNumber(iv);
01103 }
01104
01105 Int_t StMaker::GetEventNumber()
const
01106
{
01107 StEvtHddr *hd = GetEvtHddr();
01108
return hd->GetEventNumber();
01109 }
01110
01111
01113 Int_t
StMaker::GetRunNumber()
const
01114
{
01115 StEvtHddr *hd = GetEvtHddr();
01116
return hd->GetRunNumber();
01117 }
01118
01119
StMaker *StMaker::GetParentChain()
const
01120
{
01121
const StMaker *mk = GetParentMaker();
01122
while(mk && !mk->
IsChain()) {mk = mk->
GetParentMaker();}
01123
return (
StMaker*) mk;
01124 }
01125
01126 TDatime StMaker::GetDateTime()
const
01127
{
01128 StEvtHddr *hd = GetEvtHddr();
01129
return hd->GetDateTime();
01130 }
01131
01132 TDatime StMaker::GetDBTime()
const
01133
{
01134
StMaker *mk = GetMakerInheritsFrom(
"St_db_Maker");
01135 assert(mk);
01136
return mk->
GetDateTime();
01137 }
01138
01139
01140
01141 Int_t StMaker::GetDate() const {
return GetDateTime().GetDate();}
01142
01143 Int_t StMaker::GetTime() const {
return GetDateTime().GetTime();}
01144
01145
const Char_t *StMaker::GetEventType()
const
01146
{
01147 StEvtHddr *hd = GetEvtHddr();
01148
return hd->GetEventType();
01149 }
01150
01151
01157 void StMaker::PrintTimer(Option_t *option)
01158 {
01159
if(option){};
01160
#ifdef STAR_LOGGER
01161
LOG_QA << Form(
"QAInfo:%-20s: Real Time = %6.2f seconds Cpu Time = %6.2f seconds, Entries = %d",
GetName()
01162 ,
m_Timer.RealTime(),
m_Timer.CpuTime(),
m_Timer.Counter()) << endm;
01163
#else
01164
Printf(
"QAInfo:%-20s: Real Time = %6.2f seconds Cpu Time = %6.2f seconds, Entries = %d",
GetName()
01165 ,
m_Timer.RealTime(),
m_Timer.CpuTime(),
m_Timer.Counter());
01166
#endif
01167
}
01168
void StMaker::lsMakers(
const StMaker *top)
01169 {
01170 TDataSetIter iter((TDataSet*)top,20);
01171 Int_t N=0;
01172
for(
const TDataSet *mk=top;mk;mk = iter.Next()) {
01173
if(strncmp(
".maker",mk->GetTitle(),6)!=0)
continue;
01174 Int_t l=iter.GetDepth();
01175 N++;
01176 Char_t space[20]; memset(space,
' ',
sizeof(space));space[l]=0;
01177
01178 printf(
"%3d(%d) - %s %s::%s\n",N,l/2,space,mk->ClassName(),mk->GetName());
01179 }
01180 }
01181
01182
01183
01184
#if 0
01185
01186
static void MakeAssociatedClassList(
const TObject *obj,
const Char_t *classDir=0)
01187 {
01204
if (!obj)
return;
01205
const Char_t *thisDir = classDir;
01206
if (thisDir == 0 || thisDir[0] == 0)
01207 thisDir = gSystem->DirName(obj->IsA()->GetImplFileName());
01208
const Char_t *thisClassName = obj->IsA()->GetName();
01209
01210
01211
void *dirhandle = 0;
01212 TString className;
01213
if ( (dirhandle = gSystem->OpenDirectory(thisDir)) )
01214 {
01215
const Char_t *n = 0;
01216 ifstream headerFile;
01217 Char_t inBuffer[128] = {0};
01218 Int_t lBuf =
sizeof(inBuffer);
01219 Char_t *nextSym = inBuffer;
01220 Int_t status = 0;
01221
const Char_t keyWord[] =
"class";
01222
const Int_t lKeyWord =
sizeof(keyWord);
01223
01224
while ( (n = gSystem->GetDirEntry(dirhandle)) ) {
01225
01226
if (!strstr(n,
".h") || strstr(n,
"Cint.h") )
continue;
01227 Char_t *fullFile = gSystem->ConcatFileName(thisDir,n);
01228 headerFile.open(fullFile);
01229
if (headerFile.fail())
continue;
01230
while (headerFile.getline(inBuffer,lBuf) && !headerFile.eof()) {
01231 nextSym = inBuffer;
01232
if (status==0) status = 1;
01233
do {
01234
01235
01236
01237
01238
01239
01240
01241
01242
01243
01244
01245
01246
01247
01248
01249
01250
01251
01252
01253
01254
01255
01256
01257
01258
switch (status) {
01259
case 1: {
01260
if (*nextSym ==
' ' || *nextSym ==
'\t')
break;
01261
const Char_t *classFound = strstr(nextSym,keyWord);
01262
if ( classFound && classFound == nextSym){
01263 status = 2;
01264 nextSym += lKeyWord-2;
01265 }
01266
else status = 0;
01267
break;
01268 }
01269
case 2: status = 0;
01270
if (*nextSym ==
' ' || *nextSym ==
'\t') status = 3;
01271
break;
01272
case 3:
01273
if (*nextSym ==
' ' || *nextSym ==
'\t')
break;
01274 status = 0;
01275
if (isalpha(*nextSym)) {
01276 className = *nextSym;
01277 nextSym++;
01278
while (isalnum(*nextSym) || *nextSym ==
'_' ) {
01279 className += *nextSym++; status = 4;
01280 }
01281 nextSym--;
01282 }
01283
break;
01284
case 4:
01285
if (*nextSym ==
' ' || *nextSym ==
'\t')
break;
01286 status = 0;
01287
if (*nextSym == 0 || *nextSym ==
':' || *nextSym ==
'{' ||
01288 ( *nextSym ==
'/' &&
01289 (*(nextSym+1) ==
'/' || *(nextSym+1) ==
'*')
01290 )
01291 ) status = 5;
01292
break;
01293
case 5:
01294
if (strcmp(thisClassName,className.Data())) {
01295 printf(
" MakeDoc: %s\n", className.Data());
01296 TClass *cl = gROOT->GetClass(className.Data());
01297
if (cl && !cl->InheritsFrom(
"StMaker") ) {
01298 gHtml->MakeClass((Text_t *)className.Data());
01299 }
01300 }
01301
default: status = 1;
01302
break;
01303 };
01304 }
while (*(++nextSym) && status );
01305 }
01306 headerFile.close();
01307
delete [] fullFile;
01308 }
01309 }
01310 }
01311
01312
void StMaker::MakeDoc(
const TString &stardir,
const TString &outdir, Bool_t baseClasses)
01313 {
01343
01344 TString STAR = stardir;
01345 TString delim =
":";
01346
01347
01348
if (strcmp(gSystem->GetName(),
"WinNT") == 0 ) {
01349
01350 delim =
";";
01351 STAR.ReplaceAll(
"$(afs)",
"//sol/afs");
01352 }
01353
else
01354 STAR.ReplaceAll(
"$(afs)",
"/afs");
01355
01356 TString classname = IsA()->GetName();
01357
01358 THtml thisHtml;
01359
01360
01361
01362
01363
01364
01365
01366
const Char_t *source[] = {
"StRoot/St_base" ,
"TDataSet" ,
"St_base"
01367 ,
"StRoot/StChain" ,
"StMaker" ,
"StChain"
01368
01369 ,
"StRoot/StarClassLibrary",
"" ,
""
01370 ,
"StRoot/StEvent" ,
"StEvent" ,
"StEvent"
01371 ,
"StRoot/St_TLA_Maker" ,
"St_TLA_Maker",
"St_TLA_Maker"
01372 ,
"include" ,
"" ,
""
01373 ,
"include/tables" ,
"" ,
""
01374 };
01375
01376
const Int_t lsource =
sizeof(source)/
sizeof(
const Char_t *);
01377
01378 TString classDir = gSystem->DirName(IsA()->GetImplFileName());
01379 TString lookup = STAR;
01380 lookup += delim;
01381
01382 lookup += STAR;
01383 lookup +=
"/";
01384 lookup += classDir;
01385 lookup += delim;
01386
01387 lookup += STAR;
01388 lookup +=
"/StRoot/";
01389 lookup += classname;
01390
01391
01392
01393 Int_t i = 0;
01394
for (i=0;i<lsource-3;i+=3) {
01395 lookup += delim;
01396 lookup += STAR;
01397 lookup +=
"/";
01398 lookup += source[i];
01399
01400
const Char_t *cl = source[i+1];
01401
const Char_t *so = source[i+2];
01402
if (cl && cl[0] && so && so[0] && !gROOT->GetClass(cl))
01403 {
01404
if (gSystem->Load(so))
01405 printf(
" Failed to load the share library %s for class %s\n",so,cl);
01406 }
01407 }
01408
01409
01410
01411
01412
01413 lookup.ReplaceAll(
"//StRoot/",
"/StRoot/");
01414 thisHtml.SetSourceDir(lookup);
01415
01416 TString odir = outdir;
01417
01418 gSystem->ExpandPathName(odir);
01419 thisHtml.SetOutputDir(odir);
01420
01421
01422
01423 Char_t *classes[] = {
01424
"St_Module",
"TTable"
01425 ,
"TDataSet",
"TDataSetIter",
"TFileSet"
01426 ,
"StMaker",
"StChain"
01427 ,
"table_head_st"
01428 };
01429 Int_t nclass =
sizeof(classes)/4;
01430
01431 TString header =
"$STAF/inc/table_header.h";
01432
01433 gSystem->ExpandPathName(header);
01434 header.ReplaceAll(
"//inc/",
"/inc/");
01435 gROOT->LoadMacro(header);
01436
01437 TClass header1(
"table_head_st",1,
"table_header.h",
"table_header.h");
01438
01439
01440
static Bool_t makeAllAtOnce = kTRUE;
01441
if (makeAllAtOnce && baseClasses) {
01442 makeAllAtOnce = kFALSE;
01443
01444
for (i=0;i<nclass;i++) thisHtml.MakeClass(classes[i]);
01445 thisHtml.MakeIndex();
01446
01447 }
01448
01449
if (baseClasses) {gHtml= &thisHtml; MakeAssociatedClassList(
this, classDir.Data()); }
01450
01451 printf(
" Making html for <%s>\n",classname.Data());
01452 thisHtml.MakeClass((Char_t *)classname.Data());
01453
01454
01455 TList *tl = GetMakeList();
01456
if (tl) {
01457 TIter nextMaker(tl);
01458
StMaker *maker;
01459
while ((maker = (
StMaker* )nextMaker()))
01460 maker->MakeDoc(stardir,outdir,kFALSE);
01461 }
01462 }
01463
#endif
01464
01465
static void doPs(
const Char_t *who,
const Char_t *where)
01466 {
01467
static const Char_t *ps =0;
01468
if (!ps) {
01469
01470 ps = gSystem->Getenv(
"StarEndMakerShell");
01471 ps = (ps) ?
"yes" :
"";
01472 }
01473
if (!ps[0])
return;
01474
#ifdef STAR_LOGGER_BUG
01475
LOG_QA << Form(
"QAInfo: doPs for %20s:%12s \t",who,where);
01476
#else
01477
printf(
"QAInfo: doPs for %20s:%12s \t",who,where);
01478
#endif
01479
StMemStat::PrintMem(0);
01480
#if 0
01481
#ifdef STAR_LOGGER_BUG
01482
LOG_QA << endm;
01483
#else
01484
printf(
"\n");
01485
#endif
01486
#endif
01487
}
01488
01489
01490
void StMaker::Streamer(TBuffer &)
01491 { LOG_FATAL << Form(
"%s::Streamer - attempt to write %s",ClassName(),
GetName()) << endm;
01492 assert(0);
01493 }
01494
01495
StMaker *StMaker::New(
const Char_t *classname,
const Char_t *name,
void *title)
01496 {
01497
01498
01499
StMaker *maker = 0;
01500
if (classname)
01501 {
01502 TClass *cl = gROOT->GetClass(classname);
01503
if (cl) {
01504 maker = (
StMaker *)cl->New();
01505
if (maker) {
01506
if (name && strlen(name)) maker->SetName(name);
01507
if (title) maker->SetTitle((Char_t *) title);
01508 }
01509 }
01510 }
01511
return maker;
01512 }
01513
01514
void StMaker::SetDebug(Int_t l)
01515 {
01516
m_DebugLevel = l;
01517
StMessMgr *log = GetLogger();
01518
if (log) log->
SetLevel(m_DebugLevel);
01519 }
01520
01521
01522
void StMaker::SetDEBUG(Int_t l)
01523 {
01524 SetDebug(l);
01525
01526 TList *tl = GetMakeList();
01527
if (!tl)
return;
01528
01529 TIter nextMaker(tl);
01530
StMaker *maker;
01531
while ((maker = (
StMaker* )nextMaker())) maker->SetDEBUG(l);
01532 }
01533
01547 Int_t
StMaker::SetAttr(
const Char_t *key,
const Char_t *val,
const Char_t *to)
01548 {
01549
01550 Int_t count = 0;
01551 TString tk(key);tk.ToLower();tk.ReplaceAll(
" ",
"");tk.ReplaceAll(
"\t",
"");
01552
if (!val) val =
"";
01553 TString tv(val);tv = tv.Strip(TString::kBoth) ;tv.ReplaceAll(
"\t",
"");
01554
if (!to || !to[0]) to =
".";
01555 TString tt(to ); tt.ReplaceAll(
" ",
"");tt.ReplaceAll(
"\t",
"");
01556 TString tn(tt),tc(
"*");
01557 Int_t idx = tt.Index(
"::");
01558
if (idx>=0) {
01559 tn.Replace(0 ,idx+2,
"");
if (!tn.Length()) tn =
"*";
01560 tc=tt;
01561 tc.Replace(idx,999 ,
"");
if (!tc.Length()) tc =
"*";
01562 }
01563 Int_t act=0;
01564
if (tn==
".") {act = 1;}
01565
else if (tn==
"*") {act = 5;}
01566
else if (tn==
GetName()) {act = 1;}
01567
else {act = 4;}
01568
01569
if (tc==
"*") {act |=2;}
01570
else if (InheritsFrom(tc.Data())) {act |=2;}
01571
01572 TString fullName(ClassName()); fullName+=
"::"; fullName+=
GetName();
01573
01574
if ((act&3)==3) {
01575 count++;
01576
if (tk ==
".call") {
01577 TString command(
"(("); command += ClassName(); command+=
"*)";
01578 Char_t buf[20]; sprintf(buf,
"%p",(
void*)
this);
01579 command +=buf; command +=
")->"; command+=tv;command+=
";";
01580 gROOT->ProcessLineFast(command.Data(),0);}
01581
else {
01582
if (!m_Attr) m_Attr =
new TAttr(
GetName());
01583 m_Attr->SetAttr(tk.Data(), tv.Data());
01584
if (Debug() > 1) {
01585 LOG_DEBUG << Form(
"SetAttr",
"(\"%s\",\"%s\",\"%s\")",tk.Data(),tv.Data(),fullName.Data()) << endm;
01586 }
01587 }
01588 }
01589
if (!(act&4))
return count;
01590
01591
01592 TList *tl = GetMakeList();
01593
if (!tl)
return count;
01594
01595 TIter nextMaker(tl);
01596
StMaker *maker;
01597
while ((maker = (
StMaker*)nextMaker())) count += maker->SetAttr(tk.Data(),tv.Data(),to);
01598
return count;
01599 }
01600 Int_t StMaker::SetAttr(
const StMaker *mk)
01601 {
01602
if (!mk)
return 0;
01603
if (!mk->
m_Attr)
return 0;
01604
if (!m_Attr) m_Attr =
new TAttr;
01605
return m_Attr->SetAttr(mk->
m_Attr);
01606 }
01607
01608 Int_t
StMaker::SetAttr(
const Char_t *key, Int_t val,
const Char_t *to)
01609 {
01610 TString ts; ts+=val;
return SetAttr(key, ts.Data(), to);
01611 }
01612
01613 Int_t
StMaker::SetAttr(
const Char_t *key, UInt_t val,
const Char_t *to)
01614 {
01615 TString ts; ts+=val;
return SetAttr(key, ts.Data(), to);
01616 }
01617
01618 Int_t
StMaker::SetAttr(
const Char_t *key, Double_t val,
const Char_t *to)
01619 {
01620 TString ts; ts+=val;
return SetAttr(key, ts.Data(), to);
01621 }
01622
01623
01624
const Char_t *StMaker::SAttr(
const Char_t *key)
const
01625
{
01626
if (!m_Attr)
return "";
01627
return m_Attr->SAttr(key);
01628 }
01629
01630 Int_t StMaker::IAttr(
const Char_t *key)
const
01631
{
01632
if (!m_Attr)
return 0;
01633
return m_Attr->IAttr(key);
01634 }
01635
01636 UInt_t StMaker::UAttr(
const Char_t *key)
const
01637
{
01638
if (!m_Attr)
return 0;
01639
return m_Attr->UAttr(key);
01640 }
01641
01642 Double_t StMaker::DAttr(
const Char_t *key)
const
01643
{
01644
if (!m_Attr)
return 0;
01645
return m_Attr->DAttr(key);
01646 }
01647
01648
void StMaker::PrintAttr()
const
01649
{
01650
if (!m_Attr)
return ;
01651 m_Attr->PrintAttr();
01652 }
01653
01654
01655 Int_t StMaker::InitRun (Int_t runumber) {
return 0;}
01656
01657 Int_t StMaker::FinishRun(Int_t runumber) {
return 0;}
01658
01659
01660 Int_t StMaker::Cleanup(TDataSet *&ds)
01661 {
01662
01663
if (!ds->TObject::TestBit(TObject::kNotDeleted)) {ds=0;
return 0;}
01664 TSeqCollection *list = ds->TDataSet::GetCollection();
01665
if (!list)
return 0;
01666 assert(list->IsA()==TList::Class() || list->IsA()==TObjArray::Class());
01667
01668 Int_t kount = 0;
01669 TIter iter(list);
01670 TDataSet *son;
01671 Int_t num = list->Capacity();
01672
for (Int_t i=0; i<num; i++) {
01673 son = (TDataSet*)iter.Next();
01674
if (!son)
continue;
01675
if (!son->TObject::TestBit(TObject::kNotDeleted)) {list->Remove(son);
continue;}
01676 TDataSet* par = son->TDataSet::GetParent();
01677
if ( par != ds) {list->Remove(son);
continue;}
01678 assert (son->InheritsFrom(TDataSet::Class()));
01679
if (son->InheritsFrom(StMaker::Class()))
continue;
01680 kount = Cleanup(son) + 1;
01681 }
01682
if (!ds->InheritsFrom(TObjectSet::Class()))
return kount;
01683 TObjectSet *os = (TObjectSet*)ds;
01684 TObject *to = os->GetObject();
01685
if (!to)
return kount;
01686
if (!to->TObject::TestBit(TObject::kNotDeleted)) {
01687 os->DoOwner(0); os->SetObject(0);
return kount+1;}
01688
if (!os->IsOwner()) {os->SetObject(0);
return kount;}
01689
if (!to->InheritsFrom(TDataSet::Class()))
return kount;
01690 TDataSet *t = (TDataSet*)to;
01691
return kount + Cleanup(t);
01692 }
01693
01694 StEvtHddr *StMaker::GetEvtHddr()
const
01695
{
01696 StEvtHddr *hddr = (StEvtHddr*)GetDataSet(
"EvtHddr");
01697
if(!hddr) hddr =
new StEvtHddr((TDataSet*)m_ConstSet);
01698
return hddr;
01699 }
01700
01701
void StMaker::SetDateTime(Int_t idat,Int_t itim)
01702 {
01703 StEvtHddr *hddr = GetEvtHddr();
01704 hddr->SetDateTime(idat,itim);
01705 }
01706
01707
01708
const Char_t *StMaker::RetCodeAsString(Int_t kode)
01709 {
01710
static const Char_t *retCodes[] = {
01711
"StOK" ,
"StWarn" ,
"StEOF" ,
"StERR" ,
"StFATAL" ,0,0,0,0,0,
01712
"StOK!" ,
"StWarn!" ,
"StEOF!" ,
"StSKIP" ,
"StSTOP" ,0,0,0,0,0,
01713
"StOK!!",
"StWarn!!",
"StEOF!!",
"StSKIP!",
"StSTOP!" ,0,0,0,0,0};
01714
01715 assert(kode>=0);
01716
if (kode>=30) kode = kode%10+20;
01717
const Char_t *res = retCodes[kode];
01718
if (!res) res =
"StUNKNOWN";
01719
return res;
01720
01721 }
01722
01723
01724 StMakerIter::StMakerIter(
const StMaker *mk,Int_t secondary)
01725 {
01726 fState = 0;
01727 fMaker = mk;
01728 fMakerIter = 0;
01729 fIter =
new TDataSetIter(fMaker->Find(
".make"));
01730 fItWas = (TDataSet*)(-1);
01731 fSecond = secondary;
01732
01733 }
01734
01735 StMakerIter::~StMakerIter()
01736 {
01737
delete fIter; fIter = 0;
01738
delete fMakerIter; fMakerIter = 0;
01739 fMaker=0; fState = 0;
01740 }
01741
01742
StMaker *StMakerIter::NextMaker()
01743 {
01744 TDataSet *ds;
01745
if (!fMaker)
return 0;
01746
01747 AGAIN:
switch (fState) {
01748
01749
case 0:
01750 ds = fIter->Next();
01751
if (ds == fItWas)
goto AGAIN;
01752 fState = 2;
if (!ds)
goto AGAIN;
01753 fState = 1;
01754
delete fMakerIter;
01755 fMakerIter =
new StMakerIter((
StMaker*)ds,1);
01756
goto AGAIN;
01757
01758
case 1:
01759 ds = fMakerIter->NextMaker();
01760
if (ds)
return (
StMaker* )ds;
01761 fState = 0;
goto AGAIN;
01762
01763
case 2:
01764
delete fMakerIter; fMakerIter=0;
01765
delete fIter; fIter = 0;
01766 fState = 3;
01767
return (
StMaker*)fMaker;
01768
01769
case 3:
01770
if (fSecond)
return 0;
01771 TDataSet *par = fMaker->GetParent();
01772 fItWas = fMaker; fMaker = 0;
01773
if (!par)
return 0;
01774
if (strcmp(
".make",par->GetName()))
return 0;
01775 fMaker = (
StMaker* )par->GetParent();
01776
if (!fMaker)
return 0;
01777
delete fIter; fIter =
new TDataSetIter(par);
01778 fState = 0;
goto AGAIN;
01779 }
01780 assert(0);
return 0;
01781 }
01782
01783 Int_t StMaker::AliasDate(
const Char_t *alias)
01784
01785 {
01786
01787 Int_t n = strcspn(alias,
" .");
if (n<3)
return 0;
01788 Int_t i;
01789
for (i=0;fDbAlias[i].tag && strncmp(alias,fDbAlias[i].tag,n);i++) {}
01790
return fDbAlias[i].date;
01791 }
01792
01793 Int_t StMaker::AliasTime(
const Char_t *alias)
01794
01795 {
01796
01797 Int_t n = strcspn(alias,
" .");
if (n<3)
return 0;
01798 Int_t i;
01799
for (i=0;fDbAlias[i].tag && strncmp(alias,fDbAlias[i].tag,n);i++) {}
01800
return fDbAlias[i].time;
01801 }
01802
01803 Char_t *StMaker::AliasGeometry(
const Char_t *alias)
01804
01805 {
01806
01807 Int_t n = strcspn(alias,
" .");
if (n<3)
return 0;
01808 Int_t i;
01809
for (i=0;fDbAlias[i].tag && strncmp(alias,fDbAlias[i].tag,n);i++) {}
01810
return fDbAlias[i].geometry;
01811 }
01812
01813
const DbAlias_t *StMaker::GetDbAliases() {
return fDbAlias;}
01814
01815
const StChainOpt *StMaker::GetChainOpt() const
01816 {
01817
StMaker *mk = GetMaker(
this);
01818
if (!mk)
return 0;
01819
return mk->
GetChainOpt();
01820 }
01821
01822 TFile *StMaker::GetTFile()
const
01823
{
01824
const static Char_t *mktype =
"StBFChain";
01825
StMaker *mk = 0;
01826
if (this->InheritsFrom(mktype)) {mk = (
StMaker *)
this;}
01827
else {
01828 StMakerIter mkiter(GetChain());
01829
while ((mk = mkiter.NextMaker())) {
01830
if (mk->InheritsFrom(mktype)) {
01831
const StChainOpt *opt = mk->
GetChainOpt();
01832
if (!opt)
continue;
01833
if (opt->
GetTFile())
break;
01834 }
01835 }
01836 }
01837
if (! mk)
return 0;
01838
const StChainOpt *opt = mk->
GetChainOpt();
01839
if (!opt)
return 0;
01840
return opt->
GetTFile();
01841 }
01842
01843 ClassImp(StTestMaker)
01844
01845 StTestMaker::StTestMaker(const Char_t *name):
StMaker(name)
01846 {
01847 fNext=0; fLast=0;
01848
if (fgStChain ==
this ) {fgStChain=0;}
01849
else {Shunt() ;}
01850 fgTestMaker =
this;
01851 }
01852
01853
void StTestMaker::SetNext(
StMaker *mk)
01854 {
01855 fLast=fNext;
01856 fNext=mk;
01857 }
01858
01859
void StTestMaker::Print(
const Char_t *)
const
01860
{
01861
#ifdef STAR_LOGGER
01862
if (fLast) { LOG_INFO << Form(
"%s: Last Maker %s::%s(%p)",
01863 ClassName(),fLast->ClassName(),fLast->GetName(),(
void*)fLast)<< endm;}
01864
if (fNext) { LOG_INFO << Form(
"%s: Next Maker %s::%s(%p)",
01865 ClassName(),fNext->ClassName(),fNext->GetName(),(
void*)fNext) << endm;}
01866
#else
01867
if (fLast) printf(
"%s: Last Maker %s::%s(%p)\n",
01868 ClassName(),fLast->ClassName(),fLast->GetName(),(
void*)fLast);
01869
if (fNext) printf(
"%s: Next Maker %s::%s(%p)\n",
01870 ClassName(),fNext->ClassName(),fNext->GetName(),(
void*)fNext);
01871
#endif
01872
}
01873
01874 Int_t StMaker::Skip(Int_t NoEventSkip)
01875 {
01876 TURN_LOGGER(
this);
01877
01878 TList *tl = GetMakeList();
01879
if (!tl)
return kStOK;
01880 TIter nextMaker(tl);
01881
StMaker *maker;
01882
fgFailedMaker = 0;
01883
while ((maker = (
StMaker* )nextMaker())) {
01884
if (!maker->IsActive())
continue;
01885 maker->Skip(NoEventSkip);
01886 }
01887
return kStOK;
01888 }
01889
01890
01891
01892
01893
01894
01895
01896
01897
01898
01899
01900
01901
01902
01903
01904
01905
01906
01907
01908
01909
01910
01911
01912
01913
01914
01915
01916
01917
01918
01919
01920
01921
01922
01923
01924
01925
01926
01927
01928
01929
01930
01931
01932
01933
01934
01935
01936
01937
01938
01939
01940
01941
01942
01943
01944
01945
01946
01947
01948
01949
01950
01951
01952
01953
01954
01955
01956
01957
01958
01959
01960
01961
01962
01963
01964
01965
01966
01967
01968
01969
01970
01971
01972
01973
01974
01975
01976
01977
01978
01979
01980
01981
01982
01983
01984
01985
01986
01987
01988
01989
01990
01991
01992
01993
01994
01995
01996
01997
01998
01999
02000
02001
02002
02003
02004
02005
02006
02007
02008
02009
02010
02011
02012
02013
02014
02015
02016
02017
02018
02019
02020
02021
02022
02023
02024
02025
02026
02027
02028
02029
02030
02031
02032
02033
02034
02035
02036
02037
02038
02039
02040
02041
02042
02043
02044
02045
02046
02047
02048
02049
02050
02051
02052
02053
02054
02055
02056
02057
02058
02059
02060
02061
02062
02063
02064
02065
02066
02067
02068
02069
02070
02071
02072
02073
02074
02075
02076
02077
02078
02079
02080
02081
02082
02083
02084
02085
02086
02087
02088
02089
02090
02091
02092
02093
02094
02095
02096
02097
02098
02099
02100
02101
02102
02103
02104
02105
02106
02107
02108
02109
02110
02111
02112
02113
02114
02115
02116
02117
02118
02119
02120
02121
02122
02123
02124
02125
02126
02127
02128
02129
02130
02131
02132
02133
02134
02135
02136
02137
02138
02139
02140
02141
02142
02143
02144
02145
02146
02147
02148
02149
02150
02151
02152
02153
02154
02155
02156
02157
02158
02159
02160
02161
02162
02163
02164
02165
02166
02167
02168
02169
02170
02171
02172
02173
02174
02175
02176
02177
02178
02179
02180
02181
02182
02183
02184
02185
02186
02187
02188
02189
02190
02191
02192
02193
02194
02195
02196
02197
02198
02199
02200
02201
02202
02203
02204
02205
02206
02207
02208
02209
02210
02211
02212
02213
02214
02215
02216
02217
02218
02219
02220
02221
02222
02223
02224
02225
02226
02227
02228
02229
02230
02231
02232
02233
02234
02235
02236
02237
02238
02239
02240
02241
02242
02243
02244
02245
02246
02247
02248
02249
02250
02251
02252
02253
02254
02255
02256
02257
02258
02259
02260
02261
02262
02263
02264
02265
02266
02267
02268
02269
02270
02271
02272
02273
02274
02275
02276
02277
02278
02279
02280
02281
02282
02283
02284
02285
02286
02287
02288
02289
02290
02291
02292
02293
02294
02295
02296
02297
02298
02299
02300
02301
02302
02303
02304
02305
02306
02307
02308
02309
02310
02311
02312
02313
02314
02315
02316
02317
02318
02319
02320
02321
02322
02323
02324
02325
02326
02327
02328
02329
02330
02331
02332
02333
02334
02335
02336
02337
02338
02339
02340
02341
02342
02343
02344
02345
02346
02347
02348
02349
02350
02351
02352
02353
02354
02355
02356
02357
02358
02359
02360
02361
02362
02363
02364
02365
02366
02367
02368
02369
02370
02371
02372
02373
02374
02375
02376
02377
02378
02379
02380
02381
02382
02383
02384
02385
02386
02387
02388
02389
02390
02391
02392
02393
02394
02395
02396
02397
02398
02399
02400
02401
02402
02403
02404
02405
02406
02407
02408
02409
02410
02411
02412
02413
02414
02415
02416
02417
02418
02419
02420
02421
02422
02423
02424
02425
02426
02427
02428
02429
02430
02431
02432
02433
02434
02435
02436
02437
02438
02439
02440
02441
02442
02443
02444
02445
02446
02447
02448
02449
02450
02451
02452
02453
02454
02455
02456
02457
02458
02459
02460
02461
02462
02463
02464
02465
02466
02467
02468
02469
02470
02471
02472
02473
02474
02475
02476
02477
02478
02479
02480
02481
02482
02483
02484
02485
02486