Skip to content

Commit 2229402

Browse files
authored
FIT code crashing offline due to missing custom parameters (#2083)
* FIT code crashing offline due to missing custom parameters. It should catch the exception. * fix * format
1 parent fde0caa commit 2229402

9 files changed

Lines changed: 132 additions & 99 deletions

File tree

Framework/include/QualityControl/CustomParameters.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,8 @@ class CustomParameters
6464

6565
/**
6666
* Return all the parameters (key-value pairs) for the default runType and the default beamType.
67-
* @return
67+
* @return a map of the key-value pairs for
68+
* @throw std::out_of_range if no key-value pair correspond to these beamType and runType
6869
*/
6970
const std::unordered_map<std::string, std::string>& getAllDefaults();
7071

Modules/FIT/FDD/src/DigitQcTask.cxx

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -75,19 +75,23 @@ void DigitQcTask::rebinFromConfig()
7575

7676
const std::string rebinKeyword = "binning";
7777
const char* channelIdPlaceholder = "#";
78-
for (auto& param : mCustomParameters.getAllDefaults()) {
79-
if (param.first.rfind(rebinKeyword, 0) != 0)
80-
continue;
81-
std::string hName = param.first.substr(rebinKeyword.length() + 1);
82-
std::string binning = param.second.c_str();
83-
if (hName.find(channelIdPlaceholder) != std::string::npos) {
84-
for (const auto& chID : mSetAllowedChIDs) {
85-
std::string hNameCur = hName.substr(0, hName.find(channelIdPlaceholder)) + std::to_string(chID) + hName.substr(hName.find(channelIdPlaceholder) + 1);
86-
rebinHisto(hNameCur, binning);
78+
try {
79+
for (auto& param : mCustomParameters.getAllDefaults()) {
80+
if (param.first.rfind(rebinKeyword, 0) != 0)
81+
continue;
82+
std::string hName = param.first.substr(rebinKeyword.length() + 1);
83+
std::string binning = param.second.c_str();
84+
if (hName.find(channelIdPlaceholder) != std::string::npos) {
85+
for (const auto& chID : mSetAllowedChIDs) {
86+
std::string hNameCur = hName.substr(0, hName.find(channelIdPlaceholder)) + std::to_string(chID) + hName.substr(hName.find(channelIdPlaceholder) + 1);
87+
rebinHisto(hNameCur, binning);
88+
}
89+
} else {
90+
rebinHisto(hName, binning);
8791
}
88-
} else {
89-
rebinHisto(hName, binning);
9092
}
93+
} catch (std::out_of_range& oor) {
94+
ILOG(Error) << "Cannot access the default custom parameters : " << oor.what() << ENDM;
9195
}
9296
}
9397

Modules/FIT/FDD/src/DigitQcTaskLaser.cxx

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -71,23 +71,27 @@ void DigitQcTaskLaser::rebinFromConfig()
7171

7272
const std::string rebinKeyword = "binning";
7373
const char* channelIdPlaceholder = "#";
74-
for (auto& param : mCustomParameters.getAllDefaults()) {
75-
if (param.first.rfind(rebinKeyword, 0) != 0)
76-
continue;
77-
std::string hName = param.first.substr(rebinKeyword.length() + 1);
78-
std::string binning = param.second.c_str();
79-
if (hName.find(channelIdPlaceholder) != std::string::npos) {
80-
for (const auto& chID : mSetAllowedChIDs) {
81-
std::string hNameCur = hName.substr(0, hName.find(channelIdPlaceholder)) + std::to_string(chID) + hName.substr(hName.find(channelIdPlaceholder) + 1);
82-
rebinHisto(hNameCur, binning);
83-
}
84-
for (const auto& chID : mSetRefPMTChIDs) {
85-
std::string hNameCur = hName.substr(0, hName.find(channelIdPlaceholder)) + std::to_string(chID) + hName.substr(hName.find(channelIdPlaceholder) + 1);
86-
rebinHisto(hNameCur, binning);
74+
try {
75+
for (auto& param : mCustomParameters.getAllDefaults()) {
76+
if (param.first.rfind(rebinKeyword, 0) != 0)
77+
continue;
78+
std::string hName = param.first.substr(rebinKeyword.length() + 1);
79+
std::string binning = param.second.c_str();
80+
if (hName.find(channelIdPlaceholder) != std::string::npos) {
81+
for (const auto& chID : mSetAllowedChIDs) {
82+
std::string hNameCur = hName.substr(0, hName.find(channelIdPlaceholder)) + std::to_string(chID) + hName.substr(hName.find(channelIdPlaceholder) + 1);
83+
rebinHisto(hNameCur, binning);
84+
}
85+
for (const auto& chID : mSetRefPMTChIDs) {
86+
std::string hNameCur = hName.substr(0, hName.find(channelIdPlaceholder)) + std::to_string(chID) + hName.substr(hName.find(channelIdPlaceholder) + 1);
87+
rebinHisto(hNameCur, binning);
88+
}
89+
} else {
90+
rebinHisto(hName, binning);
8791
}
88-
} else {
89-
rebinHisto(hName, binning);
9092
}
93+
} catch (std::out_of_range& oor) {
94+
ILOG(Error) << "Cannot access the default custom parameters : " << oor.what() << ENDM;
9195
}
9296
}
9397

Modules/FIT/FDD/src/RecPointsQcTask.cxx

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -64,22 +64,26 @@ void RecPointsQcTask::rebinFromConfig()
6464
};
6565
const std::string rebinKeyword = "binning";
6666
const char* channelIdPlaceholder = "#";
67-
for (auto& param : mCustomParameters.getAllDefaults()) {
68-
if (param.first.rfind(rebinKeyword, 0) != 0)
69-
continue;
70-
std::string hName = param.first.substr(rebinKeyword.length() + 1);
71-
std::string binning = param.second.c_str();
72-
if (hName.find(channelIdPlaceholder) != std::string::npos) {
73-
for (const auto& chID : mSetAllowedChIDs) {
74-
std::string hNameCur = hName.substr(0, hName.find(channelIdPlaceholder)) + std::to_string(chID) + hName.substr(hName.find(channelIdPlaceholder) + 1);
75-
rebinHisto(hNameCur, binning);
67+
try {
68+
for (auto& param : mCustomParameters.getAllDefaults()) {
69+
if (param.first.rfind(rebinKeyword, 0) != 0)
70+
continue;
71+
std::string hName = param.first.substr(rebinKeyword.length() + 1);
72+
std::string binning = param.second.c_str();
73+
if (hName.find(channelIdPlaceholder) != std::string::npos) {
74+
for (const auto& chID : mSetAllowedChIDs) {
75+
std::string hNameCur = hName.substr(0, hName.find(channelIdPlaceholder)) + std::to_string(chID) + hName.substr(hName.find(channelIdPlaceholder) + 1);
76+
rebinHisto(hNameCur, binning);
77+
}
78+
} else if (!gROOT->FindObject(hName.data())) {
79+
ILOG(Warning) << "config: histogram named \"" << hName << "\" not found" << ENDM;
80+
continue;
81+
} else {
82+
rebinHisto(hName, binning);
7683
}
77-
} else if (!gROOT->FindObject(hName.data())) {
78-
ILOG(Warning) << "config: histogram named \"" << hName << "\" not found" << ENDM;
79-
continue;
80-
} else {
81-
rebinHisto(hName, binning);
8284
}
85+
} catch (std::out_of_range& oor) {
86+
ILOG(Error) << "Cannot access the default custom parameters : " << oor.what() << ENDM;
8387
}
8488
}
8589

Modules/FIT/FT0/src/DigitQcTask.cxx

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -72,19 +72,23 @@ void DigitQcTask::rebinFromConfig()
7272

7373
const std::string rebinKeyword = "binning";
7474
const char* channelIdPlaceholder = "#";
75-
for (auto& param : mCustomParameters.getAllDefaults()) {
76-
if (param.first.rfind(rebinKeyword, 0) != 0)
77-
continue;
78-
std::string hName = param.first.substr(rebinKeyword.length() + 1);
79-
std::string binning = param.second.c_str();
80-
if (hName.find(channelIdPlaceholder) != std::string::npos) {
81-
for (const auto& chID : mSetAllowedChIDs) {
82-
std::string hNameCur = hName.substr(0, hName.find(channelIdPlaceholder)) + std::to_string(chID) + hName.substr(hName.find(channelIdPlaceholder) + 1);
83-
rebinHisto(hNameCur, binning);
75+
try {
76+
for (auto& param : mCustomParameters.getAllDefaults()) {
77+
if (param.first.rfind(rebinKeyword, 0) != 0)
78+
continue;
79+
std::string hName = param.first.substr(rebinKeyword.length() + 1);
80+
std::string binning = param.second.c_str();
81+
if (hName.find(channelIdPlaceholder) != std::string::npos) {
82+
for (const auto& chID : mSetAllowedChIDs) {
83+
std::string hNameCur = hName.substr(0, hName.find(channelIdPlaceholder)) + std::to_string(chID) + hName.substr(hName.find(channelIdPlaceholder) + 1);
84+
rebinHisto(hNameCur, binning);
85+
}
86+
} else {
87+
rebinHisto(hName, binning);
8488
}
85-
} else {
86-
rebinHisto(hName, binning);
8789
}
90+
} catch (std::out_of_range& oor) {
91+
ILOG(Error) << "Cannot access the default custom parameters : " << oor.what() << ENDM;
8892
}
8993
}
9094

Modules/FIT/FT0/src/DigitQcTaskLaser.cxx

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -67,19 +67,23 @@ void DigitQcTaskLaser::rebinFromConfig()
6767

6868
const std::string rebinKeyword = "binning";
6969
const char* channelIdPlaceholder = "#";
70-
for (auto& param : mCustomParameters.getAllDefaults()) {
71-
if (param.first.rfind(rebinKeyword, 0) != 0)
72-
continue;
73-
std::string hName = param.first.substr(rebinKeyword.length() + 1);
74-
std::string binning = param.second.c_str();
75-
if (hName.find(channelIdPlaceholder) != std::string::npos) {
76-
for (const auto& chID : mSetAllowedChIDs) {
77-
std::string hNameCur = hName.substr(0, hName.find(channelIdPlaceholder)) + std::to_string(chID) + hName.substr(hName.find(channelIdPlaceholder) + 1);
78-
rebinHisto(hNameCur, binning);
70+
try {
71+
for (auto& param : mCustomParameters.getAllDefaults()) {
72+
if (param.first.rfind(rebinKeyword, 0) != 0)
73+
continue;
74+
std::string hName = param.first.substr(rebinKeyword.length() + 1);
75+
std::string binning = param.second.c_str();
76+
if (hName.find(channelIdPlaceholder) != std::string::npos) {
77+
for (const auto& chID : mSetAllowedChIDs) {
78+
std::string hNameCur = hName.substr(0, hName.find(channelIdPlaceholder)) + std::to_string(chID) + hName.substr(hName.find(channelIdPlaceholder) + 1);
79+
rebinHisto(hNameCur, binning);
80+
}
81+
} else {
82+
rebinHisto(hName, binning);
7983
}
80-
} else {
81-
rebinHisto(hName, binning);
8284
}
85+
} catch (std::out_of_range& oor) {
86+
ILOG(Error) << "Cannot access the default custom parameters : " << oor.what() << ENDM;
8387
}
8488
}
8589

Modules/FIT/FT0/src/RecPointsQcTask.cxx

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -65,22 +65,26 @@ void RecPointsQcTask::rebinFromConfig()
6565

6666
const std::string rebinKeyword = "binning";
6767
const char* channelIdPlaceholder = "#";
68-
for (auto& param : mCustomParameters.getAllDefaults()) {
69-
if (param.first.rfind(rebinKeyword, 0) != 0)
70-
continue;
71-
std::string hName = param.first.substr(rebinKeyword.length() + 1);
72-
std::string binning = param.second.c_str();
73-
if (hName.find(channelIdPlaceholder) != std::string::npos) {
74-
for (const auto& chID : mSetAllowedChIDs) {
75-
std::string hNameCur = hName.substr(0, hName.find(channelIdPlaceholder)) + std::to_string(chID) + hName.substr(hName.find(channelIdPlaceholder) + 1);
76-
rebinHisto(hNameCur, binning);
68+
try {
69+
for (auto& param : mCustomParameters.getAllDefaults()) {
70+
if (param.first.rfind(rebinKeyword, 0) != 0)
71+
continue;
72+
std::string hName = param.first.substr(rebinKeyword.length() + 1);
73+
std::string binning = param.second.c_str();
74+
if (hName.find(channelIdPlaceholder) != std::string::npos) {
75+
for (const auto& chID : mSetAllowedChIDs) {
76+
std::string hNameCur = hName.substr(0, hName.find(channelIdPlaceholder)) + std::to_string(chID) + hName.substr(hName.find(channelIdPlaceholder) + 1);
77+
rebinHisto(hNameCur, binning);
78+
}
79+
} else if (!gROOT->FindObject(hName.data())) {
80+
ILOG(Warning) << "config: histogram named \"" << hName << "\" not found" << ENDM;
81+
continue;
82+
} else {
83+
rebinHisto(hName, binning);
7784
}
78-
} else if (!gROOT->FindObject(hName.data())) {
79-
ILOG(Warning) << "config: histogram named \"" << hName << "\" not found" << ENDM;
80-
continue;
81-
} else {
82-
rebinHisto(hName, binning);
8385
}
86+
} catch (std::out_of_range& oor) {
87+
ILOG(Error) << "Cannot access the default custom parameters : " << oor.what() << ENDM;
8488
}
8589
}
8690

Modules/FIT/FV0/src/DigitQcTask.cxx

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -72,19 +72,23 @@ void DigitQcTask::rebinFromConfig()
7272

7373
const std::string rebinKeyword = "binning";
7474
const char* channelIdPlaceholder = "#";
75-
for (auto& param : mCustomParameters.getAllDefaults()) {
76-
if (param.first.rfind(rebinKeyword, 0) != 0)
77-
continue;
78-
std::string hName = param.first.substr(rebinKeyword.length() + 1);
79-
std::string binning = param.second.c_str();
80-
if (hName.find(channelIdPlaceholder) != std::string::npos) {
81-
for (const auto& chID : mSetAllowedChIDs) {
82-
std::string hNameCur = hName.substr(0, hName.find(channelIdPlaceholder)) + std::to_string(chID) + hName.substr(hName.find(channelIdPlaceholder) + 1);
83-
rebinHisto(hNameCur, binning);
75+
try {
76+
for (auto& param : mCustomParameters.getAllDefaults()) {
77+
if (param.first.rfind(rebinKeyword, 0) != 0)
78+
continue;
79+
std::string hName = param.first.substr(rebinKeyword.length() + 1);
80+
std::string binning = param.second.c_str();
81+
if (hName.find(channelIdPlaceholder) != std::string::npos) {
82+
for (const auto& chID : mSetAllowedChIDs) {
83+
std::string hNameCur = hName.substr(0, hName.find(channelIdPlaceholder)) + std::to_string(chID) + hName.substr(hName.find(channelIdPlaceholder) + 1);
84+
rebinHisto(hNameCur, binning);
85+
}
86+
} else {
87+
rebinHisto(hName, binning);
8488
}
85-
} else {
86-
rebinHisto(hName, binning);
8789
}
90+
} catch (std::out_of_range& oor) {
91+
ILOG(Error) << "Cannot access the default custom parameters : " << oor.what() << ENDM;
8892
}
8993
}
9094

Modules/FIT/FV0/src/DigitQcTaskLaser.cxx

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -67,19 +67,23 @@ void DigitQcTaskLaser::rebinFromConfig()
6767

6868
const std::string rebinKeyword = "binning";
6969
const char* channelIdPlaceholder = "#";
70-
for (auto& param : mCustomParameters.getAllDefaults()) {
71-
if (param.first.rfind(rebinKeyword, 0) != 0)
72-
continue;
73-
std::string hName = param.first.substr(rebinKeyword.length() + 1);
74-
std::string binning = param.second.c_str();
75-
if (hName.find(channelIdPlaceholder) != std::string::npos) {
76-
for (const auto& chID : mSetAllowedChIDs) {
77-
std::string hNameCur = hName.substr(0, hName.find(channelIdPlaceholder)) + std::to_string(chID) + hName.substr(hName.find(channelIdPlaceholder) + 1);
78-
rebinHisto(hNameCur, binning);
70+
try {
71+
for (auto& param : mCustomParameters.getAllDefaults()) {
72+
if (param.first.rfind(rebinKeyword, 0) != 0)
73+
continue;
74+
std::string hName = param.first.substr(rebinKeyword.length() + 1);
75+
std::string binning = param.second.c_str();
76+
if (hName.find(channelIdPlaceholder) != std::string::npos) {
77+
for (const auto& chID : mSetAllowedChIDs) {
78+
std::string hNameCur = hName.substr(0, hName.find(channelIdPlaceholder)) + std::to_string(chID) + hName.substr(hName.find(channelIdPlaceholder) + 1);
79+
rebinHisto(hNameCur, binning);
80+
}
81+
} else {
82+
rebinHisto(hName, binning);
7983
}
80-
} else {
81-
rebinHisto(hName, binning);
8284
}
85+
} catch (std::out_of_range& oor) {
86+
ILOG(Error) << "Cannot access the default custom parameters : " << oor.what() << ENDM;
8387
}
8488
}
8589

0 commit comments

Comments
 (0)