Skip to content

Commit 92c09ac

Browse files
feat(parbase): Improve logging around FairParSet::init
And re-arrange some if statements
1 parent 44694f1 commit 92c09ac

File tree

3 files changed

+49
-34
lines changed

3 files changed

+49
-34
lines changed

fairroot/parbase/FairParSet.cxx

Lines changed: 24 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/********************************************************************************
2-
* Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH *
2+
* Copyright (C) 2014-2024 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH *
33
* *
44
* This software is distributed under the terms of the *
55
* GNU Lesser General Public Licence (LGPL) version 3, *
@@ -40,38 +40,39 @@ FairParSet::FairParSet(const char* name, const char* title, const char* context,
4040
}
4141
}
4242

43+
bool FairParSet::CallInitIO(FairParIo* io, const char* context)
44+
{
45+
if (!io) {
46+
return false;
47+
}
48+
bool retval = init(io);
49+
if (!retval) {
50+
LOGP(warn, "{}({})::init(io) failed for {}", ClassName(), GetName(), context);
51+
}
52+
return retval;
53+
}
54+
4355
Bool_t FairParSet::init()
4456
{
4557
// intitializes the container from an input in run time
4658
// database. If this is not successful it is initialized from
4759
// the second input. If this failes too, it returns an error.
4860
// (calls internally the init function in the derived class)
4961
FairRuntimeDb* rtdb = FairRuntimeDb::instance();
50-
// FairRunAna* fRun =FairRunAna::Instance();
51-
// cout << "-I- FairParSet::init() " << GetName() << endl;
52-
53-
bool allFound = false;
54-
FairParIo* io = 0;
55-
if (rtdb) {
56-
io = rtdb->getFirstInput();
57-
if (io) {
58-
allFound = init(io);
59-
}
60-
if (!allFound) {
61-
io = rtdb->getSecondInput();
62-
// cout << "-I FairParSet::init() 2 " << io << std::endl;
63-
if (io) {
64-
allFound = init(io);
65-
}
66-
} else {
67-
setInputVersion(-1, 2);
68-
}
62+
if (!rtdb) {
63+
LOG(error) << "FairParSet::init()/" << GetName() << ": No RTDB";
64+
return false;
6965
}
66+
67+
bool allFound = CallInitIO(rtdb->getFirstInput(), "first input");
7068
if (allFound) {
71-
return kTRUE;
69+
setInputVersion(-1, 2);
70+
return allFound;
7271
}
73-
LOG(error) << "init() " << GetName() << " not initialized";
74-
return kFALSE;
72+
73+
allFound = CallInitIO(rtdb->getSecondInput(), "second input");
74+
75+
return allFound;
7576
}
7677

7778
Int_t FairParSet::write()

fairroot/parbase/FairParSet.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,9 @@ class FairParSet : public TObject
9292
FairParSet& operator=(const FairParSet&);
9393
FairParSet(const FairParSet&);
9494

95+
private:
96+
bool CallInitIO(FairParIo* io, const char* context);
97+
9598
ClassDefOverride(FairParSet, 2); // Base class for all parameter containers
9699
};
97100

fairroot/parbase/FairRuntimeDb.cxx

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -526,24 +526,35 @@ Bool_t FairRuntimeDb::initContainers()
526526
secondInput->readVersions(refRun);
527527
}
528528
}
529-
TIter next(containerList);
530-
FairParSet* cont;
531-
Bool_t rc = kTRUE;
532-
cout << '\n' << "************************************************************* " << '\n';
529+
LOG(info) << "*************************************************************";
533530
if (currentFileName.IsNull()) {
534-
cout << " initialisation for run id " << currentRun->GetName();
531+
LOG(info) << " initialisation for run id " << currentRun->GetName();
535532
} else {
536-
cout << " initialisation for event file " << currentFileName.Data() << '\n';
537-
cout << " run id " << currentRun->GetName();
533+
LOG(info) << " initialisation for event file " << currentFileName.Data();
534+
LOG(info) << " run id " << currentRun->GetName();
538535
}
539536
if (len > 0) {
540-
cout << " --> " << refRunName;
537+
LOG(info) << " --> " << refRunName;
538+
}
539+
LOG(info) << "*************************************************************";
540+
if (firstInput) {
541+
LOG(info) << "First Input:";
542+
firstInput->print();
541543
}
542-
cout << '\n' << "************************************************************* " << '\n';
544+
if (secondInput) {
545+
LOG(info) << "Second Input:";
546+
secondInput->print();
547+
}
548+
bool rc = true;
549+
TIter next(containerList);
550+
FairParSet* cont;
543551
while ((cont = static_cast<FairParSet*>(next()))) {
544-
cout << "-I- FairRunTimeDB::InitContainer() " << cont->GetName() << endl;
552+
LOG(info) << "-I- FairRunTimeDB::initContainers() for " << cont->GetName();
545553
if (!cont->isStatic()) {
546-
rc = cont->init() && rc;
554+
if (!cont->init()) {
555+
LOGP(error, "{}({})::init(): failed", cont->ClassName(), cont->GetName());
556+
rc = false;
557+
}
547558
}
548559
}
549560
if (!rc) {

0 commit comments

Comments
 (0)