33 #include <TCollection.h>
49 #define USE_DB_METHOD 1
67 , containerList(new TList())
70 , secondInput(nullptr)
74 , versionsChanged(kFALSE)
75 , isRootFileOutput(kFALSE)
77 , ioType(UNKNOWN_Type)
92 while ((cont = static_cast<FairParSet*>(next()))) {
93 Text_t* name =
const_cast<char*
>(cont->
GetName());
110 if (!(contFactories.FindObject(fact->GetName()))) {
111 LOG(debug) <<
"- RTDB container factory " << fact->GetName() <<
"\n";
112 contFactories.Add(fact);
119 if ((contFactories.Remove(fact))) {
120 LOG(debug) <<
"removed RTDB container factory " << fact->GetName();
126 return (static_cast<FairContFact*>(contFactories.FindObject(FactName)));
133 Bool_t found = kFALSE;
134 TIter next(&contFactories);
136 while ((fact = static_cast<FairContFact*>(next()))) {
141 Error(
"addParamContext(const char*)",
"Unknown context");
149 TIter next(&contFactories);
151 while ((fact = static_cast<FairContFact*>(next()))) {
161 Text_t* name =
const_cast<char*
>(container->
GetName());
168 while ((run = static_cast<FairRtdbRun*>(next()))) {
179 Warning(
"addContainer(FairParSet*)",
"Container %s already exists!", name);
192 TIter next(&contFactories);
195 while (!c && (fact = static_cast<FairContFact*>(next()))) {
199 Error(
"getContainer(Text_t*)",
"Container %s not created!", name);
245 while ((cont = static_cast<FairParSet*>(next()))) {
252 Warning(
"addRun(Int_t,Int_t)",
"Run already exists");
261 sprintf(name,
"%i",
id);
274 TObject* c =
runs->FindObject(name);
292 if (gFile->IsWritable()) {
311 if (strlen(refRunName) > 0) {
314 while ((cont = static_cast<FairParSet*>(next()))) {
319 Error(
"writeContainers()",
"Error in write of containers to output");
330 const Text_t* name = cont->
GetName();
332 if (in1 == -1 && in2 == -1) {
355 while ((run = static_cast<FairRtdbRun*>(next()))) {
367 #if (USE_DB_METHOD == 0)
373 const Text_t* c = cont->
GetName();
374 LOG(debug) <<
"RuntimeDb: write container: " << cont->
GetName();
379 cout <<
" CHECK OUTPUT DONE " << endl;
386 LOG(info) <<
"*** " << c <<
" written to ROOT file version: " << cv;
387 }
else if (cv == -1) {
406 cout <<
"*** " << c <<
" written to output" <<
'\n';
427 #if (USE_DB_METHOD > 0)
434 const Text_t* c = cont->
GetName();
435 LOG(debug) <<
"RuntimeDb: write container: " << cont->
GetName();
447 LOG(info) <<
"*** " << c <<
" written to ROOT file version: " << cv;
448 }
else if (cv == -1) {
480 cout <<
"*** " << c <<
" written to output" <<
'\n';
485 Error(
"writeContainer()",
"Unknown output file type.");
515 run =
addRun(runId, refId);
518 if (refId != -1 && !
getRun(refId)) {
532 cout <<
"***********************************************************" << endl;
533 cout <<
"********************* W A R N I N G *********************" << endl;
534 cout <<
"********************* no output ! *********************" << endl;
535 cout <<
"***********************************************************" << endl;
540 while ((
currentRun = static_cast<FairRtdbRun*>(next())) != 0) {
549 Bool_t FairRuntimeDb::initContainers(
void)
553 Int_t len = strlen(refRunName);
573 cout <<
'\n' <<
"************************************************************* " <<
'\n';
575 cout <<
" initialisation for run id " <<
currentRun->GetName();
577 cout <<
" initialisation for event file " <<
currentFileName.Data() <<
'\n';
581 cout <<
" --> " << refRunName;
583 cout <<
'\n' <<
"************************************************************* " <<
'\n';
584 while ((cont = static_cast<FairParSet*>(next()))) {
585 cout <<
"-I- FairRunTimeDB::InitContainer() " << cont->
GetName() << endl;
587 rc = cont->
init() && rc;
591 Error(
"initContainers()",
"Error occured during initialization");
603 while ((cont = static_cast<FairParSet*>(next()))) {
620 Error(
"setInputVersion",
"Container not found");
623 Error(
"setInputVersion",
"Run not found");
640 Error(
"setRootOutputVersion",
"Container not found");
643 Error(
"setRootOutputVersion",
"Run not found");
652 cout <<
"--------------------------------------------------------------------------------\n";
653 cout <<
"-------------- actual containers in runtime database -------------------------\n";
656 cout.setf(ios::left, ios::adjustfield);
657 while ((cont = static_cast<FairParSet*>(nextCont()))) {
658 cout << setw(45) << cont->
GetName() <<
" " << cont->
GetTitle() <<
'\n';
662 cout <<
"-------------- runs, versions ------------------------------------------------\n";
664 cout <<
" " << setw(45) <<
"container";
665 cout.setf(ios::right, ios::adjustfield);
666 cout << setw(11) <<
"1st-inp" << setw(11) <<
" 2nd-inp" << setw(11) <<
" output\n";
667 while ((run = static_cast<FairRtdbRun*>(next()))) {
670 cout <<
"-------------- input/output --------------------------------------------------\n";
672 cout <<
"first Input:\n";
675 cout <<
"first input: none" <<
'\n';
678 cout <<
"second Input:\n";
681 cout <<
"second input: none" <<
'\n';
687 cout <<
"output: none" <<
'\n';
697 while ((run = static_cast<FairRtdbRun*>(nextRun()))) {
702 while ((cont = static_cast<FairParSet*>(nextCont()))) {
716 while ((run = static_cast<FairRtdbRun*>(next()))) {
733 if (inp1->
check() == kTRUE) {
741 Error(
"setFirstInput(FairParIo*)",
"no connection to input");
750 if (inp2->
check() == kTRUE) {
758 Error(
"setSecondInput(FairParIo*)",
"no connection to input");
763 #if (USE_DB_METHOD == 0)
770 if (strcmp(
output->IsA()->GetName(),
"FairParRootFileIo") == 0) {
775 Error(
"setOutput(FairParIo*)",
"no connection to output");
780 #if (USE_DB_METHOD > 0)
788 if (strcmp(
output->IsA()->GetName(),
"FairParRootFileIo") == 0) {
791 }
else if (strcmp(
output->IsA()->GetName(),
"FairParTSQLIo") == 0) {
798 Error(
"setOutput(FairParIo*)",
"no connection to output");
859 Error(
"saveOutput()",
"Error occured during write");
880 const char* ioName = io->IsA()->GetName();
883 if (strcmp(ioName,
"FairParRootFileIo") == 0) {
887 }
else if (strcmp(ioName,
"FairParAsciiFileIo") == 0) {
898 TIter next(&contFactories);
900 while ((fact = static_cast<FairContFact*>(next()))) {
FairRtdbRun * getRun(Int_t)
void setInputNumber(Int_t)
list of container factories
virtual const char * GetName() const
void resetOutputVersions()
void activateParIo(FairParIo *)
void addParVersion(FairParVersion *pv)
void removeAllContainers(void)
Bool_t setInputVersion(Int_t run, Text_t *container, Int_t version, Int_t inputNumber)
void setStatic(Bool_t flag=kTRUE)
Bool_t writeContainer(FairParSet *, FairRtdbRun *, FairRtdbRun *refRun=0)
static FairRuntimeDb * instance(void)
FairParVersion * getParVersion(const Text_t *name)
FairParSet * getContainer(const char *)
void closeSecondInput(void)
void resetInputVersions()
void setChanged(Bool_t flag=kTRUE)
const Text_t * getRefRun()
FairParSet * findContainer(const char *)
virtual const char * GetTitle() const
Bool_t setSecondInput(FairParIo *)
ClassImp(FairEventBuilder)
void resetAllVersions(void)
void setInputVersion(Int_t v=-1, Int_t i=0)
Int_t getInputVersion(Int_t i)
void setRefRun(Text_t *s)
Int_t findOutputVersion(FairParSet *)
void setContainersStatic(Bool_t f=kTRUE)
FairParSet * getContainer(const Text_t *)
Bool_t writeContainers(void)
Bool_t initContainers(Int_t runId, Int_t refId=-1, const Text_t *fileName="")
Int_t getInputVersion(Int_t i)
virtual void activateParIo(FairParIo *)
void setRootVersion(Int_t v)
Bool_t addContainer(FairParSet *)
void removeContainer(Text_t *)
void printParamContexts()
void addContFactory(FairContFact *)
FairParIo * getSecondInput(void)
virtual FairDetParIo * getDetParIo(const Text_t *)
Bool_t addContext(const char *name)
FairParIo * getOutput(void)
virtual void readVersions(FairRtdbRun *)
Bool_t setOutput(FairParIo *)
void resetInputVersions()
void removeContFactory(FairContFact *fact)
FairContFact * getContFactory(const Text_t *)
FairRtdbRun * addRun(Int_t runId, Int_t refId=-1)
void closeFirstInput(void)
virtual void setDetParIo(FairDetParIo *)
void resetOutputVersions(void)
Bool_t setRootOutputVersion(Int_t run, Text_t *container, Int_t version)
Bool_t addParamContext(const char *)
void resetInputVersions(void)
Bool_t setFirstInput(FairParIo *)
FairParIo * getFirstInput(void)