Commit b1e98714 authored by Jens Kroeger's avatar Jens Kroeger
Browse files

AnalysisTimingATLASpix: Improved reading of correction files and graphs, now...

AnalysisTimingATLASpix: Improved reading of correction files and graphs, now we throw a proper error if they don't exist. Also, we're not using a pointer to the TFile object anymore such that we don't need to delete it by hand.
parent fef58ef0
......@@ -317,27 +317,37 @@ void AnalysisTimingATLASpix::initialise() {
if(m_pointwise_correction_row) {
// Import TGraphErrors for row corection:
std::string fileName = m_correctionFile_row;
TFile* file = TFile::Open(fileName.c_str());
if(!file->IsOpen()) {
LOG(ERROR) << "Cannot open " << fileName << "!\n";
TFile file(m_correctionFile_row.c_str());
if(!file.IsOpen()) {
throw InvalidValueError(m_config,
"correction_file_row",
"ROOT file doesn't exist. If no row correction shall be applied, remove this parameter "
"from the configuration file.");
}
gRowCorr = static_cast<TGraphErrors*>(file->Get(m_correctionGraph_row.c_str()));
file->Close();
delete file;
// Check if graph exists in ROOT file:
if(!file.GetListOfKeys()->Contains(m_correctionGraph_row.c_str())) {
throw InvalidValueError(
m_config, "correction_graph_row", "Graph doesn't exist in ROOT file. Use full/path/to/graph.");
}
gRowCorr = static_cast<TGraphErrors*>(file.Get(m_correctionGraph_row.c_str()));
} else {
LOG(STATUS) << "----> NO POINTWISE ROW CORRECTION!!!";
}
if(m_pointwise_correction_timewalk) {
// Import TGraphErrors for timewalk corection:
std::string fileName = m_correctionFile_timewalk;
TFile* file = TFile::Open(fileName.c_str());
if(!file->IsOpen()) {
LOG(ERROR) << "Cannot open " << fileName << "!\n";
TFile file(m_correctionFile_timewalk.c_str());
if(!file.IsOpen()) {
throw InvalidValueError(m_config,
"correction_file_timewalk",
"ROOT file doesn't exist. If no row correction shall be applied, remove this parameter "
"from the configuration file.");
}
// Check if graph exists in ROOT file:
if(!file.GetListOfKeys()->Contains(m_correctionGraph_timewalk.c_str())) {
throw InvalidValueError(
m_config, "correction_graph_timewalk", "Graph doesn't exist in ROOT file. Use full/path/to/graph.");
}
gTimeWalkCorr = static_cast<TGraphErrors*>(file->Get(m_correctionGraph_timewalk.c_str()));
file->Close();
delete file;
gTimeWalkCorr = static_cast<TGraphErrors*>(file.Get(m_correctionGraph_timewalk.c_str()));
} else {
LOG(STATUS) << "----> NO POINTWISE TIMEWALK CORRECTION!!!";
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment