6 #include "Identifier/Identifier.h"
8 #include "GaudiKernel/EventIDRange.h"
28 ATH_MSG_ERROR(
"The database is set to be input source (2) but the ReadKey is empty.");
34 return StatusCode::SUCCESS;
44 ATH_MSG_DEBUG(
"CondHandle " << writeHandle.
fullKey() <<
" is already valid.. In theory this should not be called, but may happen if multiple concurrent events are being processed out of order.");
45 return StatusCode::SUCCESS;
49 std::unique_ptr<PixelOfflineCalibData> writeCdo(std::make_unique<PixelOfflineCalibData>());
53 return StatusCode::FAILURE;
56 ATH_MSG_WARNING(
"Pixel ITk constants read from text file. Only supported for local developments and debugging!");
58 auto calibData = std::make_unique<PixelOfflineCalibData>();
62 ATH_MSG_INFO(
"Load ITkPixelErrorData constants from text file");
68 std::vector<float>
constants = calibData->getConstants();
73 const EventIDBase
start{EventIDBase::UNDEFNUM, EventIDBase::UNDEFEVT, 0, 0, EventIDBase::UNDEFNUM, EventIDBase::UNDEFNUM};
74 const EventIDBase
stop {EventIDBase::UNDEFNUM, EventIDBase::UNDEFEVT, EventIDBase::UNDEFNUM-1, EventIDBase::UNDEFNUM-1, EventIDBase::UNDEFNUM, EventIDBase::UNDEFNUM};
80 ATH_MSG_DEBUG(
"Found constants with new-style Identifier key");
84 if (writeHandle.
record(rangeW, std::move(writeCdo)).isFailure()) {
85 ATH_MSG_FATAL(
"Could not record PixelCalib::ITkPixelOfflineCalibData " << writeHandle.
key() <<
" with EventRange " << rangeW <<
" into Conditions Store");
86 return StatusCode::FAILURE;
88 ATH_MSG_DEBUG(
"recorded new CDO " << writeHandle.
key() <<
" with range " << rangeW <<
" into Conditions Store");
100 if (readCdo==
nullptr) {
102 return StatusCode::FAILURE;
107 if (not readHandle.range(rangeW)) {
108 ATH_MSG_FATAL(
"Failed to retrieve validity range for " << readHandle.key());
109 return StatusCode::FAILURE;
116 for(
const auto & attrList : *readCdo){
118 std::ostringstream attrStr;
119 attrList.second.toOutputStream(attrStr);
120 ATH_MSG_DEBUG(
"ChanNum " << attrList.first <<
" Attribute list " << attrStr.str() );
122 std::string stringData = attrList.second[
"data_array"].data<std::string>();
125 std::vector<std::string> component;
127 while ((
pos = stringData.find(
delimiter)) != std::string::npos) {
129 component.push_back(
buffer);
132 component.push_back(stringData);
135 for (
auto &
i : component) {
136 std::string checkModule =
i;
137 std::vector<std::string> moduleString;
140 while ((
pos = checkModule.find(
delimiter)) != std::string::npos) {
142 moduleString.push_back(
buffer);
145 moduleString.push_back(checkModule);
147 if (moduleString.size()!=2) {
148 ATH_MSG_FATAL(
"String size (moduleString) is not 2. " << moduleString.size() <<
" in " <<
i <<
" channel " << attrList.first <<
" read from " << readHandle.fullKey());
149 return StatusCode::FAILURE;
152 std::stringstream checkModuleHash(moduleString[0]);
153 std::vector<std::string> moduleStringHash;
154 while (std::getline(checkModuleHash,
buffer,
'"')) { moduleStringHash.push_back(
buffer); }
156 int waferHash =
std::atoi(moduleStringHash[1].c_str());
161 std::stringstream moduleConstants(moduleString[1]);
162 std::vector<float> moduleConstantsVec;
163 while (std::getline(moduleConstants,
buffer,
',')) { moduleConstantsVec.emplace_back(
std::atof(
buffer.c_str())); }
166 if(moduleConstantsVec.size()==4){
170 constants.emplace_back(moduleConstantsVec[0]);
171 constants.emplace_back(moduleConstantsVec[1]);
173 constants.emplace_back(moduleConstantsVec[2]);
174 constants.emplace_back(moduleConstantsVec[3]);
177 else if(moduleConstantsVec.size()==7){
178 constants.emplace_back(moduleConstantsVec[0]);
179 for(
auto&
x : moduleConstantsVec )
constants.emplace_back(
x);
183 else if(moduleConstantsVec.size()==8){
184 for(
auto&
x : moduleConstantsVec )
constants.emplace_back(
x);
193 if (writeHandle.
record(rangeW, std::move(writeCdo)).isFailure()) {
194 ATH_MSG_FATAL(
"Could not record PixelCalib::ITkPixelOfflineCalibData " << writeHandle.
key() <<
" with EventRange " << rangeW <<
" into Conditions Store");
195 return StatusCode::FAILURE;
197 ATH_MSG_DEBUG(
"recorded new CDO " << writeHandle.
key() <<
" with range " << rangeW <<
" into Conditions Store");
201 return StatusCode::SUCCESS;