6 #include "Identifier/Identifier.h"
8 #include "GaudiKernel/EventIDRange.h"
29 ATH_MSG_ERROR(
"The database is set to be input source (2) but the ReadKey is empty.");
35 return StatusCode::SUCCESS;
45 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.");
46 return StatusCode::SUCCESS;
50 std::unique_ptr<PixelOfflineCalibData> writeCdo(std::make_unique<PixelOfflineCalibData>());
54 return StatusCode::FAILURE;
57 ATH_MSG_WARNING(
"Pixel ITk constants read from text file. Only supported for local developments and debugging!");
59 auto calibData = std::make_unique<PixelOfflineCalibData>();
63 ATH_MSG_INFO(
"Load ITkPixelErrorData constants from text file");
69 std::vector<float>
constants = calibData->getConstants();
74 const EventIDBase
start{EventIDBase::UNDEFNUM, EventIDBase::UNDEFEVT, 0, 0, EventIDBase::UNDEFNUM, EventIDBase::UNDEFNUM};
75 const EventIDBase
stop {EventIDBase::UNDEFNUM, EventIDBase::UNDEFEVT, EventIDBase::UNDEFNUM-1, EventIDBase::UNDEFNUM-1, EventIDBase::UNDEFNUM, EventIDBase::UNDEFNUM};
81 ATH_MSG_DEBUG(
"Found constants with new-style Identifier key");
85 if (writeHandle.
record(rangeW, std::move(writeCdo)).isFailure()) {
86 ATH_MSG_FATAL(
"Could not record PixelCalib::ITkPixelOfflineCalibData " << writeHandle.
key() <<
" with EventRange " << rangeW <<
" into Conditions Store");
87 return StatusCode::FAILURE;
89 ATH_MSG_DEBUG(
"recorded new CDO " << writeHandle.
key() <<
" with range " << rangeW <<
" into Conditions Store");
101 if (readCdo==
nullptr) {
103 return StatusCode::FAILURE;
108 if (not readHandle.range(rangeW)) {
109 ATH_MSG_FATAL(
"Failed to retrieve validity range for " << readHandle.key());
110 return StatusCode::FAILURE;
117 for(
const auto & attrList : *readCdo){
119 std::ostringstream attrStr;
120 attrList.second.toOutputStream(attrStr);
121 ATH_MSG_DEBUG(
"ChanNum " << attrList.first <<
" Attribute list " << attrStr.str() );
123 std::string stringData = attrList.second[
"data_array"].data<std::string>();
126 std::vector<std::string> component;
128 while ((
pos = stringData.find(
delimiter)) != std::string::npos) {
130 component.push_back(
buffer);
133 component.push_back(stringData);
136 for (
auto &
i : component) {
137 std::string checkModule =
i;
138 std::vector<std::string> moduleString;
141 while ((
pos = checkModule.find(
delimiter)) != std::string::npos) {
143 moduleString.push_back(
buffer);
146 moduleString.push_back(checkModule);
148 if (moduleString.size()!=2) {
149 ATH_MSG_FATAL(
"String size (moduleString) is not 2. " << moduleString.size() <<
" in " <<
i <<
" channel " << attrList.first <<
" read from " << readHandle.fullKey());
150 return StatusCode::FAILURE;
153 std::stringstream checkModuleHash(moduleString[0]);
154 std::vector<std::string> moduleStringHash;
155 while (std::getline(checkModuleHash,
buffer,
'"')) { moduleStringHash.push_back(
buffer); }
157 int waferHash =
std::atoi(moduleStringHash[1].c_str());
162 std::stringstream moduleConstants(moduleString[1]);
163 std::vector<float> moduleConstantsVec;
164 while (std::getline(moduleConstants,
buffer,
',')) { moduleConstantsVec.emplace_back(
std::atof(
buffer.c_str())); }
167 if(moduleConstantsVec.size()==4){
171 constants.emplace_back(moduleConstantsVec[0]);
172 constants.emplace_back(moduleConstantsVec[1]);
174 constants.emplace_back(moduleConstantsVec[2]);
175 constants.emplace_back(moduleConstantsVec[3]);
178 else if(moduleConstantsVec.size()==7){
179 constants.emplace_back(moduleConstantsVec[0]);
180 for(
auto&
x : moduleConstantsVec )
constants.emplace_back(
x);
184 else if(moduleConstantsVec.size()==8){
185 for(
auto&
x : moduleConstantsVec )
constants.emplace_back(
x);
194 if (writeHandle.
record(rangeW, std::move(writeCdo)).isFailure()) {
195 ATH_MSG_FATAL(
"Could not record PixelCalib::ITkPixelOfflineCalibData " << writeHandle.
key() <<
" with EventRange " << rangeW <<
" into Conditions Store");
196 return StatusCode::FAILURE;
198 ATH_MSG_DEBUG(
"recorded new CDO " << writeHandle.
key() <<
" with range " << rangeW <<
" into Conditions Store");
202 return StatusCode::SUCCESS;