19 return StatusCode::SUCCESS;
33 if (!
file.is_open()) {
35 "Cannot open map output file for writing. Tried accessing file at \"./"
37 return StatusCode::FAILURE;
41 file <<
"# This file contains shift values for MDT tubes\n";
42 file <<
"# Each Identifier is mapped to a float\n";
43 file <<
"# Below are comma separated values with formatting\n";
44 file <<
"# Identifier.get_compact(),float\n";
45 file <<
"# ------------------------------------------------\n";
50 float shiftValue = shift.second;
51 file << identifierCompact;
57 return StatusCode::SUCCESS;
64 return StatusCode::SUCCESS;
69 if (fileWithPath.empty()) {
71 return StatusCode::FAILURE;
76 if (
stat(fileWithPath.c_str(), &
buffer) != 0) {
78 << fileWithPath.c_str()
79 <<
"\" -> map can not be initialized from this file.");
80 return StatusCode::FAILURE;
84 std::ifstream
fin(fileWithPath.c_str(), std::ios::in);
86 bool initializedWithWarnings =
false;
88 while (std::getline(
fin,
line)) {
90 if (
line.empty() ||
line.compare(0, 1,
"#") == 0 ||
91 line.compare(0, 2,
"//")) {
95 std::stringstream lineStream(
line);
98 std::vector<std::string> tokenVector;
99 while (std::getline(lineStream, token,
',')) {
100 tokenVector.push_back(token);
103 if (tokenVector.size() == 2) {
109 float shift = std::stof(tokenVector[1]);
113 << fileWithPath.c_str());
116 initializedWithWarnings =
true;
120 if (initializedWithWarnings) {
122 << fileWithPath.c_str() <<
"\"");
124 ATH_MSG_INFO(
"Successfully initialized shift map from file \""
125 << fileWithPath.c_str() <<
"\"");
127 return StatusCode::SUCCESS;
131 std::map<Identifier, float>::const_iterator itr =
m_shiftValues.find(
id);
134 throw std::runtime_error(
"MdtT0Calibration - Invalid identifier");