37 #include "TClonesArray.h"
40 #include "StChainOpt.h"
41 #include "TObjectSet.h"
44 #include "StMemStat.h"
47 #include "StMessMgr.h"
53 Int_t StMaker::fgTallyMaker[
kStFatal+1] = {0,0,0,0,0};
54 Int_t MaxWarnings = 26;
58 typedef void (*MyDelete_t)(
void *p);
177 #include "GeometryDbAliases.h"
179 #define TURN_LOGGER(maker) \
180 if (!fLogger) fLogger = StMessMgr::Instance(ClassName()); \
181 StTurnLogger SaveRestoreLogger(maker->GetLogger());
189 m_Number(0), m_LastRun(-3),
190 m_DebugLevel(0),m_MakeReturn(0),fStatus(0),
191 fLogger(0),fLoggerHold(0),m_Mode(0)
196 fgTopChain = fgStChain =
this;
197 gROOT->GetListOfBrowsables()->Add(
this,GetName());
200 fgStChain->AddData(
this,
".make");
202 m_DataSet =
new TObjectSet(
".data") ;Add(m_DataSet);
203 m_ConstSet =
new TObjectSet(
".const");Add(m_ConstSet);
204 m_GarbSet =
new TObjectSet(
".garb" );Add(m_GarbSet);
205 m_Inputs =
new TObjectSet(
".aliases" );Add(m_Inputs);
206 m_Runco =
new TObjectSet(
".runco" );Add(m_Runco);
207 AddHist(0); m_Histograms = GetHistList();
208 StMemStat::doPs(GetName(),
"Construct");
212 memset(fTallyMaker,0,(
kStFatal+1)*
sizeof(Int_t));
214 StMkDeb::Register(
this);
218 void StMaker::AddMaker(
StMaker *mk)
221 if (!dotmk) dotmk =
new TDataSet(
".make",
this);
233 StMkDeb::Cancel(
this);
239 static Int_t occ = 0;
240 const Char_t *name = TNamed::GetName();
241 if (name && *name )
return name;
242 TString ts(ClassName());
243 ts+=
"#"; ts+=(occ++);
244 ((TNamed*)
this)->SetName(ts.Data());
248 void StMaker::SetNumber(Int_t number)
250 StMaker *par = GetParentMaker();
251 if (par) par->SetNumber(number);
253 SetIventNumber(number);
258 StMaker *par = GetParentMaker();
263 StMaker *StMaker::GetParentMaker()
const
265 TDataSet *par = GetParent();
if (!par)
return 0;
266 return (
StMaker*)par->GetParent();
269 StMaker *StMaker::GetMaker(
const Char_t *mkname)
271 TString path(
".make/"); path+=mkname;
272 return (
StMaker*)GetDataSet((
const char*)path);
275 TObject *StMaker::GetDirObj(
const Char_t *dir)
const
282 void StMaker::SetDirObj(TObject *obj,
const Char_t *dir)
290 TDataSet *StMaker::AddObj(TObject *obj,
const Char_t *dir,
int owner)
292 assert (dir[0]==
'.');
293 if (strcmp(
".hist",dir)==0) {
294 AddHist((TH1*)obj);
return 0;
295 }
else if (strcmp(
".data",dir)==0) {
296 return ToWhiteBoard(obj->GetName(),obj,owner);
298 }
else if (strcmp(
".const",dir)==0) {
299 return ToWhiteConst(obj->GetName(),obj);
300 }
else { assert(0 &&
"No .data || .const ||.hist");}
303 void StMaker::AddHist(TH1 *h,
const Char_t *)
311 list =
new TList(); set->
SetObject(list);}
314 if(!list->FindObject(h)) list->Add(h);
315 if (h->InheritsFrom(TH1::Class())) h->SetDirectory(0);
318 void StMaker::AddRunco (Double_t par,
const Char_t *name,
const Char_t *comment)
320 assert (name && name && comment[0]);
323 TString ts(
" // "); ts += comment;
325 sprintf(buf,
"%f",par);
327 dp->SetTitle((
const char*)ts);
334 assert (dir); assert(dir[0]==
'.');
339 Int_t dotMake = (strcmp(dir,
".make")==0);
340 Int_t inhMake = ds->InheritsFrom(StMaker::Class());
341 if (dotMake!=inhMake) {
342 Error(
"AddData",
"Add to %s is NOT allowed: %s.%s\n"
343 ,dir,ds->ClassName(),ds->GetName());
346 TList *tl = set->GetList();
347 if (!tl || !tl->FindObject(ds->GetName())) {
350 Error(
"AddData",
"Data %s/%s is not added. ***Name clash***",dir,ds->GetName());
356 TDataSet *StMaker::GetData(
const Char_t *name,
const Char_t *dir)
const
360 if (!name || !name[0])
return set;
361 return set->
Find(name);
364 TDataSet *StMaker::ToWhiteBoard(
const Char_t *name,
void *dat)
367 envelop->SetTitle(
".envelop");
372 TDataSet *StMaker::ToWhiteBoard(
const Char_t *name,
void *dat,
void *owner)
375 envelop->SetTitle(
".envelop");
380 TDataSet *StMaker::ToWhiteBoard(
const Char_t *name, TObject *dat, Int_t owner)
383 envelop->SetTitle(
".envelop");
388 TDataSet *StMaker::ToWhiteConst(
const Char_t *name,
void *dat)
391 envelop->SetTitle(
".envelop");
396 TDataSet *StMaker::ToWhiteConst(
const Char_t *name, TObject *dat)
399 envelop->SetTitle(
".envelop");
404 TDataSet *StMaker::WhiteBoard(
const Char_t *name,
void *v)
const
406 void **dat = (
void **)v;
410 if (strcmp(
".envelop",ds->GetTitle())==0) {*dat = ds->
GetObject();}
415 void StMaker::AddAlias(
const Char_t *log,
const Char_t *act,
const Char_t *dir)
422 void StMaker::SetNotify(
const Char_t *about,
StMaker *mk)
428 void StMaker::NotifyEm(
const Char_t *about,
const void *ptr)
438 if (strcmp(about,os->GetName()))
continue;
442 mk->NotifyMe(about,ptr);
447 void StMaker::SetAlias(
const Char_t *log,
const Char_t *act,
const Char_t *dir)
451 if (!strcmp(act,ali->GetTitle()))
return;
459 LOG_DEBUG <<
"<" << ClassName() <<
"(" <<
GetName() <<
"::SetAlias> "
460 << log <<
" = " << act << endm;
462 printf(
"<%s(%s)::SetAlias> %s = %s\n",ClassName(),
GetName(),log,act);
467 void StMaker::SetOutput(
const Char_t *log,
TDataSet *ds)
470 const Char_t *logname = log;
471 if (!logname || !logname[0]) logname = ds->GetName();
472 TString act = ds->
Path();
473 while ((idx=act.Index(
".make/"))>=0) act.Replace(0,idx+6,
"");
474 SetOutput(logname,act);
478 void StMaker::SetOutputAll(
TDataSet *ds, Int_t level)
482 while ((set = next())) SetOutput(set);
486 TList *StMaker::GetMakeList()
const
489 return ds->GetList();
492 TString StMaker::GetAlias(
const Char_t *log,
const Char_t *dir)
const
494 Int_t nspn = strcspn(log,
" /");
495 TString act(log,nspn);
498 if (in) {act = in->GetTitle(); act += log+nspn;}
502 TDataSet *StMaker::FindDataSet(
const Char_t *logInput,
509 TString actInput,findString,tmp;
514 for (
int itry=0;itry<2;itry++) {
515 actInput = (!itry)? GetInput(logInput).Data():logInput;
517 if (actInput.IsNull())
continue;
522 if (strchr(actInput.Data(),
'.')) dataset =
Find(actInput);
523 if (dataset)
goto FOUND;
525 if (actInput==
GetName()) dataset = m_DataSet;
526 if (dataset)
goto FOUND;
531 icol = actInput.Index(
":");
534 tmp.Replace(0,0,
".make/"); icol +=6;
535 tmp.Replace(icol,1,
"/.data/");
536 dataset =
Find((
const char*)tmp);
537 if (dataset)
goto FOUND;
538 dataset =
Find((
const char*)tmp+6);
539 if (dataset)
goto FOUND;
540 tmp.Replace(icol,7,
"/.const/");
541 dataset =
Find((
const char*)tmp);
542 if (dataset)
goto FOUND;
543 dataset =
Find((
const char*)tmp+6);
544 if (dataset)
goto FOUND;
549 islas = actInput.Index(
"/");
551 tmp.Replace(0,999,actInput,islas);
554 tmp.Replace(0,islas+1,
"");
555 dataset = m_DataSet->
Find(tmp);
556 if (dataset)
goto FOUND;
557 dataset = m_ConstSet->
Find(tmp);
558 if (dataset)
goto FOUND;
562 dataset = m_DataSet->
Find(actInput);
563 if (dataset)
goto FOUND;
564 dataset = m_ConstSet->
Find(actInput);
565 if (dataset)
goto FOUND;
569 DOWN:
if (!(dir =
Find(
".make")))
goto UP;
572 while ((mk = (
StMaker* )nextMk()))
574 if (mk==dowMk)
continue;
575 dataset = mk->FindDataSet(actInput,
this,0);
576 if (dataset)
goto FOUND;
580 UP:
if (uppMk)
return 0;
582 parent = GetMaker(
this);
if (!parent)
goto NOTFOUND;
583 dataset = parent->FindDataSet(actInput,0,
this);
584 if (dataset)
goto FOUND;
588 if (!dowMk && GetDebug()>1)
589 if ((MaxWarnings--) > 0) Warning(
"GetDataSet",
" \"%s\" Not Found ***\n",(
const char*)actInput);
590 dataset = 0;
continue;
593 FOUND:
if (uppMk || dowMk)
return dataset;
594 if (GetDebug()<2)
return dataset;
596 LOG_DEBUG << Form(
"<%s::%s> DataSet %s FOUND in %s\n"
597 ,ClassName(),
"GetDataSet",logInput,(
const char*)dataset->
Path()) << endm;
599 printf(
"Remark: <%s::%s> DataSet %s FOUND in %s\n"
600 ,ClassName(),
"GetDataSet",logInput,(
const char*)dataset->
Path());
608 TDataSet *StMaker::GetDataBase(
const Char_t *logInput,
const TDatime *td)
612 StMaker *mk = GetMakerInheritsFrom(
"St_db_Maker");
613 if (mk) ds = mk->GetDataBase(logInput,td);
617 StMaker *StMaker::GetMakerInheritsFrom (
const Char_t *mktype)
const
622 while ((mk = mkiter.NextMaker())) {
623 if (mk->InheritsFrom(mktype))
break;
628 void StMaker::SetFlavor(
const Char_t *flav,
const Char_t *tabname)
630 StMaker *mk = GetMakerInheritsFrom(
"St_db_Maker");
631 if (mk) mk->SetFlavor(flav,tabname);
640 if (m_DataSet) m_DataSet->
Delete();
644 TIter next(GetMakeList(),kIterBackward);
646 Int_t curr = StMkDeb::GetCurrent();
647 while ((maker = (
StMaker* )next())) {
648 assert(maker->TestBIT(kCleaBeg)==0);
649 StMkDeb::SetCurrent(maker,3);
654 maker->
Clear(option);
657 maker->ResetBIT(kCleaBeg);
658 StMkDeb::SetCurrent(curr);
660 TCollection::EmptyGarbageCollection();
661 StMemStat::doPs(
GetName(),
"Clear");
670 Int_t StMaker::Init()
673 TObject *objLast,*objHist;
674 TList *tl = GetMakeList();
675 if (!tl)
return kStOK;
679 Int_t curr = StMkDeb::GetCurrent();
680 while ((maker = (
StMaker* )nextMaker())) {
685 objLast = gDirectory->GetList()->Last();
689 assert( !( maker->TestBIT(kInitBeg) || maker->TestBIT(kInitEnd) ));
690 StMkDeb::SetCurrent(maker,1);
695 LOG_DEBUG <<
"*** Call << " << maker->ClassName() <<
":Init() ***" << endm;
697 TString ts1(maker->ClassName()); ts1+=
"("; ts1+=maker->
GetName(); ts1+=
")::";
698 TString ts2 = ts1; ts2+=
"Make ";
700 ts2 = ts1; ts2+=
"Clear";
703 if ( maker->Init()) {
704 LOG_ERROR <<
" Maker "<< maker->
GetName() <<
" failed in Init" << endm;
712 TIter nextHist(gDirectory->GetList());
713 Int_t ready = !objLast;
714 while((objHist=nextHist())) {
715 if (!ready && objHist!=objLast)
continue;
717 if (objHist==objLast)
continue;
718 if (!objHist->InheritsFrom(
"TH1"))
continue;
721 ((TH1*)objHist)->SetDirectory(0);
722 maker->AddHist((TH1*)objHist);
724 StMemStat::doPs(maker->
GetName(),
"Init");
725 maker->ResetBIT(kInitBeg);
727 StMkDeb::SetCurrent(curr);
732 void StMaker::StartMaker()
735 if (!fLoggerHold) fLoggerHold =
new StTurnLogger(GetLogger());
737 m_DataSet =
Find(
".data");
738 if (!m_DataSet) {m_DataSet =
new TObjectSet(
".data"); Add(m_DataSet);}
748 void StMaker::EndMaker(Int_t ierr)
759 if (m_GarbSet) m_GarbSet->
Delete();
760 StMemStat::doPs(
GetName(),
"EndMaker");
767 if (fLoggerHold) {
delete fLoggerHold; fLoggerHold = 0;}
778 if (TestBIT(kFiniEnd))
return 1;
783 if (run>-1) FinishRun(run);
785 TIter next(GetMakeList(),kIterBackward);
787 Double_t totalCpuTime = 0;
788 Double_t totalRealTime = 0;
789 while ((maker = (
StMaker* )next()))
791 totalCpuTime += maker->CpuTime();
792 totalRealTime += maker->RealTime();
796 if (!totalRealTime) totalRealTime = 1;
797 if (!totalCpuTime ) totalCpuTime = 1;
801 while ((maker = (
StMaker*)next())) {
808 Form(
"=================================================================================") << endm;
810 Form(
"QAInfo:Chain %20s::%-20s Ast =%6.2f Cpu =%6.2f "
811 ,ClassName(),
GetName(),totalRealTime,totalCpuTime) << endm;
814 Form(
"QAInfo:Maker %20s::%-20s Ast =%6.2f(%4.1f%%) Cpu =%6.2f(%4.1f%%) "
815 ,maker->ClassName(),maker->
GetName()
817 ,100*maker->RealTime()/totalRealTime
819 ,100*maker->CpuTime()/totalCpuTime) << endm;
821 static const Char_t *ee[]={
"nStOK",
"nStWarn",
"nStEOF",
"nStErr",
"nStFatal"};
825 if (tail !=
"") LOG_QA << (
const Char_t *) tail << endm;
829 Printf(
"=================================================================================\n");
830 Printf(
"QAInfo: Chain %20s::%-20s Ast =%6.2f Cpu =%6.2f "
831 ,ClassName(),
GetName(),totalRealTime,totalCpuTime);
833 printf(
"QAInfo: Maker %20s::%-20s Ast =%6.2f(%4.1f%%) Cpu =%6.2f(%4.1f%%) "
834 ,maker->ClassName(),maker->
GetName()
836 ,100*maker->RealTime()/totalRealTime
838 ,100*maker->CpuTime()/totalCpuTime);
840 static const Char_t *ee[]={
"nStOK",
"nStWarn",
"nStEOF",
"nStErr",
"nStFatal"};
848 Int_t curr = StMkDeb::GetCurrent();
849 while ((maker = (
StMaker* )next()))
853 if (maker->TestBIT(kFiniEnd)) {
854 maker->Warning(
"Finish",
"maker %s.%s Finished twice"
855 ,maker->
GetName(),maker->ClassName());
857 StMkDeb::SetCurrent(maker,4);
859 if ( maker->
Finish() ) nerr++;
860 maker->ResetBIT(kFiniBeg);
862 StMkDeb::SetCurrent(curr);
866 LOG_INFO <<
"--------------Error Codes-------------------------" << endm;
867 LOG_INFO <<
" nStOK nStWarn nStEOF nStErr nStFatal" << endm;
869 for( Int_t i=0; i<=
kStFatal; i++) tail += Form(
"%10d",fgTallyMaker[i]);
871 LOG_INFO << (
const Char_t *)tail << endm;
872 LOG_INFO <<
"--------------------------------------------------" << endm;
874 printf(
"\n--------------Error Codes-------------------------\n");
875 printf(
" nStOK nStWarn nStEOF nStErr nStFatal \n");
876 for( Int_t i=0; i<=
kStFatal; i++) printf(
"%10d",fgTallyMaker[i]);
877 printf(
"\n--------------------------------------------------\n");
903 Int_t ret,run=-1,oldrun;
904 TList *tl = GetMakeList();
905 if (!tl)
return kStOK;
910 Int_t curr = StMkDeb::GetCurrent();
911 while ((maker = (
StMaker* )nextMaker())) {
912 if (!maker->IsActive())
continue;
914 assert(!maker->TestBIT(kMakeBeg));
916 StMkDeb::SetCurrent(maker,2);
918 if (hd && hd->GetRunNumber()!=oldrun) {
919 if (oldrun>-1) maker->FinishRun(oldrun);
920 run = hd->GetRunNumber();
924 LOG_INFO <<
" +++ New RunNumber found=" << run <<
" (previous = " << oldrun <<
")" << endm;
926 printf(
" +++ New RunNumber found=%d (previous = %d)\n",run,oldrun);
938 assert((ret%10)>=0 && (ret%10)<=
kStFatal);
939 maker->EndMaker(ret);
941 if (Debug() || ret) {
943 LOG_INFO <<
"*** " << maker->ClassName() <<
"::Make() == "
944 << RetCodeAsString(ret) <<
"(" << ret <<
") ***"
947 printf(
"*** %s::Make() == %s(%d) ***\n"
948 ,maker->ClassName(),RetCodeAsString(ret),ret);
951 maker->ResetBIT(kMakeBeg);
952 StMkDeb::SetCurrent(curr);
954 if ((ret%10) !=
kStERR)
return ret;
957 if (maker->IAttr(
".Privilege"))
return ret;
965 void StMaker::FatalErr(Int_t Ierr,
const Char_t *com)
968 LOG_QA << Form(
"QAInfo:%s::Fatal: Error %d %s",
GetName(),Ierr,com) << endm;
969 LOG_FATAL << Form(
"QAInfo:%s::Fatal: Error %d %s",
GetName(),Ierr,com) << endm;
971 printf(
"QAInfo:%s::Fatal: Error %d %s\n",
GetName(),Ierr,com);
974 if (parent) ((
StMaker*)parent)->FatalErr(Ierr,com);
983 while (par && (par = par->GetParent()) && strncmp(
".maker",par->GetTitle(),6)) {}
995 if (ds->InheritsFrom(TTable::Class())){
1002 table->Warning(
"ReAllocate",
" Table %s has purged from %d to %d "
1003 ,table->GetName(),setSize,(Int_t) table->
GetTableSize());
1010 void StMaker::PrintInfo()
1012 const char *cvs = GetCVS();
1013 const char *built = 0;
1014 if (cvs && cvs[0]) built = strstr(cvs,
"built");
1015 else cvs =
"No CVS tag was defined";
1017 if (built > cvs) { LOG_QA << Form(
"QAInfo:%-20s %s from %.*s",ClassName(),built,built-cvs,cvs)<< endm; }
1018 else { LOG_QA << Form(
"QAInfo:%-20s from %s",ClassName(),cvs) << endm; }
1020 if (built > cvs) printf(
"QAInfo:%-20s %s from %.*s\n",ClassName(),built,built-cvs,cvs);
1021 else printf(
"QAInfo:%-20s from %s\n",ClassName(),cvs);
1024 TIter next(GetMakeList());
1026 while ((maker = (
StMaker* )next())) {
1036 return hd->GetIventNumber();
1040 void StMaker::SetIventNumber(Int_t iv)
1043 hd->SetIventNumber(iv);
1046 Int_t StMaker::GetEventNumber()
const
1049 return hd->GetEventNumber();
1057 return hd->GetRunNumber();
1060 StMaker *StMaker::GetParentChain()
const
1062 const StMaker *mk = GetParentMaker();
1063 while(mk && !mk->IsChain()) {mk = mk->GetParentMaker();}
1067 const TDatime &StMaker::GetDateTime()
const
1070 return hd->GetDateTime();
1073 const TDatime &StMaker::GetDBTime()
const
1075 StMaker *mk = GetMakerInheritsFrom(
"St_db_Maker");
1077 return mk->GetDateTime();
1082 Int_t StMaker::GetDate()
const {
return GetDateTime().GetDate();}
1084 Int_t StMaker::GetTime()
const {
return GetDateTime().GetTime();}
1086 const Char_t *StMaker::GetEventType()
const
1089 return hd->GetEventType();
1102 LOG_QA << Form(
"QAInfo:%-20s: Real Time = %6.2f seconds Cpu Time = %6.2f seconds, Entries = %d",
GetName()
1105 Printf(
"QAInfo:%-20s: Real Time = %6.2f seconds Cpu Time = %6.2f seconds, Entries = %d",
GetName()
1109 void StMaker::lsMakers(
const StMaker *top)
1113 for(
const TDataSet *mk=top;mk;mk = iter.Next()) {
1114 if (! mk->InheritsFrom(
"StMaker"))
continue;
1115 Int_t l=iter.GetDepth();
1117 Char_t space[20]; memset(space,
' ',
sizeof(space));space[l]=0;
1119 LOG_QA << Form(
"%s %s::%s",space,mk->ClassName(),mk->
GetName()) << endm;
1121 printf(
"%3d(%d) - %s %s::%s\n",N,l/2,space,mk->ClassName(),mk->
GetName());
1130 static void MakeAssociatedClassList(
const TObject *obj,
const Char_t *classDir=0)
1149 const Char_t *thisDir = classDir;
1150 if (thisDir == 0 || thisDir[0] == 0)
1151 thisDir = gSystem->DirName(obj->IsA()->GetImplFileName());
1152 const Char_t *thisClassName = obj->IsA()->GetName();
1155 void *dirhandle = 0;
1157 if ( (dirhandle = gSystem->OpenDirectory(thisDir)) )
1159 const Char_t *n = 0;
1160 ifstream headerFile;
1161 Char_t inBuffer[128] = {0};
1162 Int_t lBuf =
sizeof(inBuffer);
1163 Char_t *nextSym = inBuffer;
1165 const Char_t keyWord[] =
"class";
1166 const Int_t lKeyWord =
sizeof(keyWord);
1168 while ( (n = gSystem->GetDirEntry(dirhandle)) ) {
1170 if (!strstr(n,
".h") || strstr(n,
"Cint.h") )
continue;
1171 Char_t *fullFile = gSystem->ConcatFileName(thisDir,n);
1172 headerFile.open(fullFile);
1173 if (headerFile.fail())
continue;
1174 while (headerFile.getline(inBuffer,lBuf) && !headerFile.eof()) {
1176 if (status==0) status = 1;
1204 if (*nextSym ==
' ' || *nextSym ==
'\t')
break;
1205 const Char_t *classFound = strstr(nextSym,keyWord);
1206 if ( classFound && classFound == nextSym){
1208 nextSym += lKeyWord-2;
1214 if (*nextSym ==
' ' || *nextSym ==
'\t') status = 3;
1217 if (*nextSym ==
' ' || *nextSym ==
'\t')
break;
1219 if (isalpha(*nextSym)) {
1220 className = *nextSym;
1222 while (isalnum(*nextSym) || *nextSym ==
'_' ) {
1223 className += *nextSym++; status = 4;
1229 if (*nextSym ==
' ' || *nextSym ==
'\t')
break;
1231 if (*nextSym == 0 || *nextSym ==
':' || *nextSym ==
'{' ||
1232 ( *nextSym ==
'/' &&
1233 (*(nextSym+1) ==
'/' || *(nextSym+1) ==
'*')
1238 if (strcmp(thisClassName,className.Data())) {
1239 printf(
" MakeDoc: %s\n", className.Data());
1240 TClass *cl = gROOT->GetClass(className.Data());
1241 if (cl && !cl->InheritsFrom(
"StMaker") ) {
1242 gHtml->MakeClass((Text_t *)className.Data());
1245 default: status = 1;
1248 }
while (*(++nextSym) && status );
1256 void StMaker::MakeDoc(
const TString &stardir,
const TString &outdir, Bool_t baseClasses)
1288 TString STAR = stardir;
1289 TString delim =
":";
1292 if (strcmp(gSystem->GetName(),
"WinNT") == 0 ) {
1295 STAR.ReplaceAll(
"$(afs)",
"//sol/afs");
1298 STAR.ReplaceAll(
"$(afs)",
"/afs");
1300 TString classname = IsA()->GetName();
1310 const Char_t *source[] = {
"StRoot/St_base" ,
"TDataSet" ,
"St_base"
1311 ,
"StRoot/StChain" ,
"StMaker" ,
"StChain"
1313 ,
"StRoot/StarClassLibrary",
"" ,
""
1314 ,
"StRoot/StEvent" ,
"StEvent" ,
"StEvent"
1315 ,
"StRoot/St_TLA_Maker" ,
"St_TLA_Maker",
"St_TLA_Maker"
1316 ,
"include" ,
"" ,
""
1317 ,
"include/tables" ,
"" ,
""
1320 const Int_t lsource =
sizeof(source)/
sizeof(
const Char_t *);
1322 TString classDir = gSystem->DirName(IsA()->GetImplFileName());
1323 TString lookup = STAR;
1332 lookup +=
"/StRoot/";
1333 lookup += classname;
1338 for (i=0;i<lsource-3;i+=3) {
1342 lookup += source[i];
1344 const Char_t *cl = source[i+1];
1345 const Char_t *so = source[i+2];
1346 if (cl && cl[0] && so && so[0] && !gROOT->GetClass(cl))
1348 if (gSystem->Load(so))
1349 printf(
" Failed to load the share library %s for class %s\n",so,cl);
1357 lookup.ReplaceAll(
"//StRoot/",
"/StRoot/");
1358 thisHtml.SetSourceDir(lookup);
1360 TString odir = outdir;
1362 gSystem->ExpandPathName(odir);
1363 thisHtml.SetOutputDir(odir);
1367 Char_t *classes[] = {
1368 "St_Module",
"TTable"
1369 ,
"TDataSet",
"TDataSetIter",
"TFileSet"
1370 ,
"StMaker",
"StChain"
1373 Int_t nclass =
sizeof(classes)/4;
1375 TString header =
"$STAF/inc/table_header.h";
1377 gSystem->ExpandPathName(header);
1378 header.ReplaceAll(
"//inc/",
"/inc/");
1379 gROOT->LoadMacro(header);
1381 TClass header1(
"table_head_st",1,
"table_header.h",
"table_header.h");
1384 static Bool_t makeAllAtOnce = kTRUE;
1385 if (makeAllAtOnce && baseClasses) {
1386 makeAllAtOnce = kFALSE;
1388 for (i=0;i<nclass;i++) thisHtml.MakeClass(classes[i]);
1389 thisHtml.MakeIndex();
1393 if (baseClasses) {gHtml= &thisHtml; MakeAssociatedClassList(
this, classDir.Data()); }
1395 printf(
" Making html for <%s>\n",classname.Data());
1396 thisHtml.MakeClass((Char_t *)classname.Data());
1399 TList *tl = GetMakeList();
1401 TIter nextMaker(tl);
1403 while ((maker = (
StMaker* )nextMaker()))
1404 maker->MakeDoc(stardir,outdir,kFALSE);
1410 void StMaker::Streamer(TBuffer &)
1411 { LOG_FATAL << Form(
"%s::Streamer - attempt to write %s",ClassName(),
GetName()) << endm;
1415 StMaker *StMaker::New(
const Char_t *classname,
const Char_t *name,
void *title)
1422 TClass *cl = gROOT->GetClass(classname);
1426 if (name && strlen(name)) maker->SetName(name);
1427 if (title) maker->SetTitle((Char_t *) title);
1434 void StMaker::SetDebug(Int_t l)
1438 if (log) log->SetLevel(Debug());
1442 void StMaker::SetDEBUG(Int_t l)
1446 TList *tl = GetMakeList();
1449 TIter nextMaker(tl);
1451 while ((maker = (
StMaker* )nextMaker())) maker->SetDEBUG(l);
1467 Int_t StMaker::SetAttr(
const Char_t *key,
const Char_t *val,
const Char_t *to)
1471 TString tk(key);tk.ToLower();tk.ReplaceAll(
" ",
"");tk.ReplaceAll(
"\t",
"");
1473 TString tv(val);tv = tv.Strip(TString::kBoth) ;tv.ReplaceAll(
"\t",
"");
1474 if (!to || !to[0]) to =
".";
1475 TString tt(to ); tt.ReplaceAll(
" ",
"");tt.ReplaceAll(
"\t",
"");
1476 TString tn(tt),tc(
"*");
1477 Int_t idx = tt.Index(
"::");
1479 tn.Replace(0 ,idx+2,
"");
if (!tn.Length()) tn =
"*";
1481 tc.Replace(idx,999 ,
"");
if (!tc.Length()) tc =
"*";
1484 if (tn==
".") {act = 1;}
1485 else if (tn==
"*") {act = 5;}
1486 else if (tn==
GetName()) {act = 1;}
1489 if (tc==
"*") {act |=2;}
1490 else if (InheritsFrom(tc.Data())) {act |=2;}
1492 TString fullName(ClassName()); fullName+=
"::"; fullName+=
GetName();
1496 if (tk ==
".call") {
1497 TString command(
"(("); command += ClassName(); command+=
"*)";
1498 Char_t buf[20]; sprintf(buf,
"%p",(
void*)
this);
1499 command +=buf; command +=
")->"; command+=tv;command+=
";";
1500 gROOT->ProcessLineFast(command.Data(),0);}
1503 m_Attr->
SetAttr(tk.Data(), tv.Data());
1505 LOG_DEBUG << Form(
"SetAttr(\"%s\",\"%s\",\"%s\")",tk.Data(),tv.Data(),fullName.Data()) << endm;
1509 if (!(act&4))
return count;
1512 TList *tl = GetMakeList();
1513 if (!tl)
return count;
1515 TIter nextMaker(tl);
1517 while ((maker = (
StMaker*)nextMaker())) count += maker->SetAttr(tk.Data(),tv.Data(),to);
1520 Int_t StMaker::SetAttr(
const StMaker *mk)
1523 if (!mk->m_Attr)
return 0;
1524 if (!m_Attr) m_Attr =
new TAttr;
1525 return m_Attr->
SetAttr(mk->m_Attr);
1528 Int_t StMaker::SetAttr(
const Char_t *key, Int_t val,
const Char_t *to)
1530 TString ts; ts+=val;
return SetAttr(key, ts.Data(), to);
1533 Int_t StMaker::SetAttr(
const Char_t *key, UInt_t val,
const Char_t *to)
1535 TString ts; ts+=val;
return SetAttr(key, ts.Data(), to);
1538 Int_t StMaker::SetAttr(
const Char_t *key, Double_t val,
const Char_t *to)
1540 TString ts; ts+=val;
return SetAttr(key, ts.Data(), to);
1544 const Char_t *StMaker::SAttr(
const Char_t *key)
const
1546 if (!m_Attr)
return "";
1547 return m_Attr->SAttr(key);
1550 Int_t StMaker::IAttr(
const Char_t *key)
const
1552 if (!m_Attr)
return 0;
1553 return m_Attr->IAttr(key);
1556 UInt_t StMaker::UAttr(
const Char_t *key)
const
1558 if (!m_Attr)
return 0;
1559 return m_Attr->UAttr(key);
1562 Double_t StMaker::DAttr(
const Char_t *key)
const
1564 if (!m_Attr)
return 0;
1565 return m_Attr->DAttr(key);
1568 void StMaker::PrintAttr()
const
1570 if (!m_Attr) return ;
1571 m_Attr->PrintAttr();
1575 Int_t StMaker::InitRun (Int_t runumber) {
return 0;}
1577 Int_t StMaker::FinishRun(Int_t runumber) {
return 0;}
1580 Int_t StMaker::Cleanup(
TDataSet *&ds)
1583 if (!ds->TObject::TestBit(TObject::kNotDeleted)) {ds=0;
return 0;}
1584 TSeqCollection *list = ds->TDataSet::GetCollection();
1585 if (!list)
return 0;
1586 assert(list->IsA()==TList::Class() || list->IsA()==TObjArray::Class());
1591 Int_t num = list->Capacity();
1592 for (Int_t i=0; i<num; i++) {
1595 if (!son->TObject::TestBit(TObject::kNotDeleted)) {list->Remove(son);
continue;}
1596 TDataSet* par = son->TDataSet::GetParent();
1597 if ( par != ds) {list->
Remove(son);
continue;}
1598 assert (son->InheritsFrom(TDataSet::Class()));
1599 if (son->InheritsFrom(StMaker::Class()))
continue;
1600 kount = Cleanup(son) + 1;
1602 if (!ds->InheritsFrom(TObjectSet::Class()))
return kount;
1605 if (!to)
return kount;
1606 if (!to->TObject::TestBit(TObject::kNotDeleted)) {
1608 if (!os->IsOwner()) {os->
SetObject(0);
return kount;}
1609 if (!to->InheritsFrom(TDataSet::Class()))
return kount;
1611 return kount + Cleanup(t);
1621 void StMaker::SetDateTime(Int_t idat,Int_t itim)
1624 hddr->SetDateTime(idat,itim);
1628 const Char_t *StMaker::RetCodeAsString(Int_t kode)
1630 static const Char_t *retCodes[] = {
1631 "StOK" ,
"StWarn" ,
"StEOF" ,
"StERR" ,
"StFATAL" ,0,0,0,0,0,
1632 "StOK!" ,
"StWarn!" ,
"StEOF!" ,
"StSKIP" ,
"StSTOP" ,0,0,0,0,0,
1633 "StOK!!",
"StWarn!!",
"StEOF!!",
"StSKIP!",
"StSTOP!" ,0,0,0,0,0};
1636 if (kode>=30) kode = kode%10+20;
1637 const Char_t *res = retCodes[kode];
1638 if (!res) res =
"StUNKNOWN";
1644 StMakerIter::StMakerIter(
const StMaker *mk,Int_t secondary)
1651 fSecond = secondary;
1655 StMakerIter::~StMakerIter()
1657 delete fIter; fIter = 0;
1658 delete fMakerIter; fMakerIter = 0;
1659 fMaker=0; fState = 0;
1662 StMaker *StMakerIter::NextMaker()
1665 if (!fMaker)
return 0;
1667 AGAIN:
switch (fState) {
1671 if (ds == fItWas)
goto AGAIN;
1672 fState = 2;
if (!ds)
goto AGAIN;
1679 ds = fMakerIter->NextMaker();
1681 fState = 0;
goto AGAIN;
1684 delete fMakerIter; fMakerIter=0;
1685 delete fIter; fIter = 0;
1690 if (fSecond)
return 0;
1691 TDataSet *par = fMaker->GetParent();
1692 fItWas = fMaker; fMaker = 0;
1694 if (strcmp(
".make",par->GetName()))
return 0;
1695 fMaker = (
StMaker* )par->GetParent();
1696 if (!fMaker)
return 0;
1698 fState = 0;
goto AGAIN;
1700 assert(0);
return 0;
1703 Int_t StMaker::AliasDate(
const Char_t *alias)
1707 Int_t n = strcspn(alias,
" .");
if (n<3)
return 0;
1709 for (i=0;fDbAlias[i].tag && strncmp(alias,fDbAlias[i].tag,n);i++) {}
1710 return fDbAlias[i].date;
1713 Int_t StMaker::AliasTime(
const Char_t *alias)
1717 Int_t n = strcspn(alias,
" .");
if (n<3)
return 0;
1719 for (i=0;fDbAlias[i].tag && strncmp(alias,fDbAlias[i].tag,n);i++) {}
1720 return fDbAlias[i].time;
1723 const Char_t *StMaker::AliasGeometry(
const Char_t *alias)
1727 Int_t n = strcspn(alias,
" .");
if (n<3)
return 0;
1729 for (i=0;fDbAlias[i].tag && strncmp(alias,fDbAlias[i].tag,n);i++) {}
1730 return fDbAlias[i].geometry;
1733 const DbAlias_t *StMaker::GetDbAliases() {
return fDbAlias;}
1735 const StChainOpt *StMaker::GetChainOpt()
const
1739 return mk->GetChainOpt();
1742 TFile *StMaker::GetTFile()
const
1744 const static Char_t *mktype =
"StBFChain";
1746 if (this->InheritsFrom(mktype)) {mk = (
StMaker *)
this;}
1749 while ((mk = mkiter.NextMaker())) {
1750 if (mk->InheritsFrom(mktype)) {
1753 if (opt->GetTFile())
break;
1760 return opt->GetTFile();
1768 if (fgStChain ==
this ) {fgStChain=0;}
1773 void StTestMaker::SetNext(
StMaker *mk)
1779 void StTestMaker::Print(
const Char_t *)
const
1782 if (fLast) { LOG_INFO << Form(
"%s: Last Maker %s::%s(%p)",
1783 ClassName(),fLast->ClassName(),fLast->
GetName(),(
void*)fLast)<< endm;}
1784 if (fNext) { LOG_INFO << Form(
"%s: Next Maker %s::%s(%p)",
1785 ClassName(),fNext->ClassName(),fNext->
GetName(),(
void*)fNext) << endm;}
1787 if (fLast) printf(
"%s: Last Maker %s::%s(%p)\n",
1788 ClassName(),fLast->ClassName(),fLast->
GetName(),(
void*)fLast);
1789 if (fNext) printf(
"%s: Next Maker %s::%s(%p)\n",
1790 ClassName(),fNext->ClassName(),fNext->
GetName(),(
void*)fNext);
1794 Int_t StMaker::Skip(Int_t NoEventSkip)
1798 TList *tl = GetMakeList();
1799 if (!tl)
return kStOK;
1800 TIter nextMaker(tl);
1803 while ((maker = (
StMaker* )nextMaker())) {
1804 if (!maker->IsActive())
continue;
1805 maker->Skip(NoEventSkip);
static StMaker * fgFailedMaker
current pointer to StChain
void * ReAllocate(Int_t newsize)
Int_t fTallyMaker[kStFatal+1]
counters
virtual EDataSetPass Pass(EDataSetPass(*callback)(TDataSet *), Int_t depth=0)
virtual Long_t GetRowSize() const
Returns the size (in bytes) of one table row.
virtual void AddData(TDataSet *data, const char *dir=".data")
User methods.
virtual Bool_t DoOwner(Bool_t done=kTRUE)
virtual TDataSet * Next(TDataSet::EDataSetPass mode=TDataSet::kContinue)
virtual Int_t GetNumber() const
STAR methods.
virtual void Delete(Option_t *opt="")
virtual void Remove(TDataSet *set)
Remiove the "set" from this TDataSet.
static StTestMaker * fgTestMaker
current pointer to failed maker
virtual void Clear(Option_t *option="")
User defined functions.
Int_t m_Number
Integer mode of maker.
TDataSet * m_Runco
list of logOuput:ActualOuput
StMemStat * fMemStatMake
Timer object.
Int_t m_DebugLevel
Last Run number.
TObjectSet(const Char_t *name, TObject *obj=0, Bool_t makeOwner=kTRUE)
to be documented
Int_t m_MakeReturn
Debug level.
virtual void SetBIT(EMakerStatus k)
Maker Status Bits.
virtual void SetObject(TObject *obj)
The depricated method (left here for the sake of the backward compatibility)
static StMaker * fgTopChain
list of Histograms
static StMaker * fgStChain
pointer to top StChain
virtual Long_t GetNRows() const
Returns the number of the used rows for the wrapped table.
TStopwatch m_Timer
Make() return flag.
StMemStat * fMemStatClear
StMemStat for Make.
virtual TObject * GetObject() const
The depricated method (left here for the sake of the backward compatibility)
void SetAttr(const char *key, const char *val)
virtual const char * GetName() const
special overload
virtual Int_t GetRunNumber() const
Returns the current RunNumber.
static EDataSetPass ClearDS(TDataSet *ds, void *user)
virtual void Shunt(TDataSet *newParent=0)
virtual Long_t GetTableSize() const
Returns the number of the allocated rows.
virtual Int_t GetIventNumber() const
Returns the current event number.
const void * At(Int_t i) const
Returns a pointer to the i-th row of the table.
virtual TString Path() const
return the full path of this data set
Int_t m_LastRun
Serial event number.
virtual TObject * GetObject() const
The depricated method (left here for the sake of the backward compatibility)
virtual TDataSet * Find(const char *path) const
virtual void PrintTimer(Option_t *option="")