43 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.");
44 return StatusCode::SUCCESS;
48 std::unique_ptr<PixelOfflineCalibData> writeCdo(std::make_unique<PixelOfflineCalibData>());
52 return StatusCode::FAILURE;
55 ATH_MSG_WARNING(
"Pixel ITk constants read from text file. Only supported for local developments and debugging!");
57 auto calibData = std::make_unique<PixelOfflineCalibData>();
60 ATH_MSG_INFO(
"Load ITkPixelErrorData constants from text file");
62 if (fileName.empty()) {
ATH_MSG_WARNING(
"Input file " << fileName <<
" not found! Default (hardwired) values to be used!"); }
64 unsigned int n_entries = calibData->getClusterErrorData()->load(fileName);
65 ATH_MSG_DEBUG(
"Loaded " << n_entries <<
" from " << fileName <<
".");
68 const EventIDBase start{EventIDBase::UNDEFNUM, EventIDBase::UNDEFEVT, 0, 0, EventIDBase::UNDEFNUM, EventIDBase::UNDEFNUM};
69 const EventIDBase stop {EventIDBase::UNDEFNUM, EventIDBase::UNDEFEVT, EventIDBase::UNDEFNUM-1, EventIDBase::UNDEFNUM-1, EventIDBase::UNDEFNUM, EventIDBase::UNDEFNUM};
70 const EventIDRange rangeW{start, stop};
74 if (writeHandle.
record(rangeW, std::move(writeCdo)).isFailure()) {
75 ATH_MSG_FATAL(
"Could not record PixelCalib::ITkPixelOfflineCalibData " << writeHandle.
key() <<
" with EventRange " << rangeW <<
" into Conditions Store");
76 return StatusCode::FAILURE;
78 ATH_MSG_DEBUG(
"recorded new CDO " << writeHandle.
key() <<
" with range " << rangeW <<
" into Conditions Store");
90 if (readCdo==
nullptr) {
92 return StatusCode::FAILURE;
97 if (not readHandle.
range(rangeW)) {
99 return StatusCode::FAILURE;
104 for(
const auto & attrList : *readCdo){
106 std::ostringstream attrStr;
107 attrList.second.toOutputStream(attrStr);
108 ATH_MSG_DEBUG(
"ChanNum " << attrList.first <<
" Attribute list " << attrStr.str() );
110 std::string stringData = attrList.second[
"data_array"].data<std::string>();
111 std::string delimiter =
"],";
113 std::vector<std::string> component;
115 while ((pos = stringData.find(delimiter)) != std::string::npos) {
116 buffer = stringData.substr(0,pos);
117 component.push_back(buffer);
118 stringData.erase(0, pos + delimiter.length());
120 component.push_back(stringData);
123 for (
auto & i : component) {
124 std::string checkModule = i;
125 std::vector<std::string> moduleString;
128 while ((pos = checkModule.find(delimiter)) != std::string::npos) {
129 buffer = checkModule.substr(0,pos);
130 moduleString.push_back(buffer);
131 checkModule.erase(0, pos + delimiter.length());
133 moduleString.push_back(std::move(checkModule));
135 if (moduleString.size()!=2) {
136 ATH_MSG_FATAL(
"String size (moduleString) is not 2. " << moduleString.size() <<
" in " << i <<
" channel " << attrList.first <<
" read from " << readHandle.
fullKey());
137 return StatusCode::FAILURE;
140 std::stringstream checkModuleHash(moduleString[0]);
141 std::vector<std::string> moduleStringHash;
142 while (std::getline(checkModuleHash,buffer,
'"')) { moduleStringHash.push_back(buffer); }
144 int waferHash = std::atoi(moduleStringHash[1].c_str());
147 std::stringstream moduleConstants(moduleString[1]);
148 std::vector<double> moduleConstantsVec;
149 while (std::getline(moduleConstants,buffer,
',')) { moduleConstantsVec.emplace_back(std::atof(buffer.c_str())); }
152 std::array<double, ITk::PixelClusterErrorData::kNParam> param{};
153 std::span<double> param_src(param);
156 if(moduleConstantsVec.size()==4){
163 else if(moduleConstantsVec.size()==7){
167 param[0] = moduleConstantsVec[0];
168 for (
unsigned int idx=0; idx<moduleConstantsVec.size(); ++idx) {
169 param[idx+1] = moduleConstantsVec[idx];
174 else if(moduleConstantsVec.size()==8){
175 param_src = std::span<double>(moduleConstantsVec.begin(), moduleConstantsVec.end());
177 assert(writeCdo->getClusterErrorData());
178 writeCdo->getClusterErrorData()->setDeltaError(waferID_hash,param_src);
184 if (writeHandle.
record(rangeW, std::move(writeCdo)).isFailure()) {
185 ATH_MSG_FATAL(
"Could not record PixelCalib::ITkPixelOfflineCalibData " << writeHandle.
key() <<
" with EventRange " << rangeW <<
" into Conditions Store");
186 return StatusCode::FAILURE;
188 ATH_MSG_DEBUG(
"recorded new CDO " << writeHandle.
key() <<
" with range " << rangeW <<
" into Conditions Store");
192 return StatusCode::SUCCESS;