46 {
48
49 SG::WriteCondHandle<PixelChargeCalibCondData> writeHandle(
m_writeKey, ctx);
50 if (writeHandle.isValid()) {
51 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.");
52 return StatusCode::SUCCESS;
53 }
54
55 SG::ReadCondHandle<InDetDD::SiDetectorElementCollection> pixelDetEleHandle(
m_pixelDetEleCollKey, ctx);
56 const InDetDD::SiDetectorElementCollection* elements(*pixelDetEleHandle);
57 if (not pixelDetEleHandle.isValid() or elements==nullptr) {
59 return StatusCode::FAILURE;
60 }
61
64
65 SG::ReadCondHandle<PixelModuleData> configDataHandle(
m_configKey, ctx);
66 const PixelModuleData *configData = *configDataHandle;
67
68
69 std::unique_ptr<PixelChargeCalibCondData> writeCdo(std::make_unique<PixelChargeCalibCondData>(
m_pixelID->wafer_hash_max()));
70
71 const EventIDBase
start{EventIDBase::UNDEFNUM, EventIDBase::UNDEFEVT, 0, 0, EventIDBase::UNDEFNUM, EventIDBase::UNDEFNUM};
72 const EventIDBase
stop {EventIDBase::UNDEFNUM, EventIDBase::UNDEFEVT, EventIDBase::UNDEFNUM-1, EventIDBase::UNDEFNUM-1, EventIDBase::UNDEFNUM, EventIDBase::UNDEFNUM};
73
76 SG::ReadCondHandle<CondAttrListCollection> readHandle(
m_readKey, ctx);
77 const CondAttrListCollection* readCdo = *readHandle;
78 if (readCdo==nullptr) {
80 return StatusCode::FAILURE;
81 }
82
83 if (not readHandle.range(rangeW)) {
84 ATH_MSG_FATAL(
"Failed to retrieve validity range for " << readHandle.key());
85 return StatusCode::FAILURE;
86 }
87 ATH_MSG_INFO(
"Size of CondAttrListCollection " << readHandle.fullKey() <<
" readCdo->size()= " << readCdo->
size());
89 std::unique_ptr<IChargeCalibrationParser> pParser{};
90
91 for (const auto & attrList : *readCdo) {
93
94
95 if (
payload.exists(
"data_array") and not payload[
"data_array"].isNull()) {
97 pParser = std::make_unique<LUTChargeCalibParser>(configData, elements,
m_pixelID);
100 ATH_MSG_FATAL(
"Input file" << fileName <<
" not found! Change the inputSource!");
101 return StatusCode::FAILURE;
102 }
104
105 std::string fileContent((std::istreambuf_iterator<char>(infile)), std::istreambuf_iterator<char>());
108 nlohmann::json::parse(fileContent);
109 for (
const auto &[hash,
data] : jsonData.items()) {
110 const unsigned int moduleHash = std::stoul(hash);
111 IdentifierHash wafer_hash = IdentifierHash(moduleHash);
112 const InDetDD::SiDetectorElement *element = elements->getDetectorElement(wafer_hash);
113 const InDetDD::PixelModuleDesign *p_design =
static_cast<const InDetDD::PixelModuleDesign*
>(&element->
design());
117 return StatusCode::FAILURE;
118 }
119
120 if (!
b.tot2Charges.empty()) {
121 writeCdo -> setTot2Charges(moduleHash,
b.tot2Charges);
122 }
123
124 writeCdo -> setAllFromBundle(moduleHash, b);
125
126
131 } else {
135 }
136 }
137 }
138 }
139 } else {
140 for (
unsigned int moduleHash{}; moduleHash <
m_pixelID->wafer_hash_max(); moduleHash++) {
142 IdentifierHash wafer_hash = IdentifierHash(moduleHash);
143 const InDetDD::SiDetectorElement *element = elements->getDetectorElement(wafer_hash);
144 const InDetDD::PixelModuleDesign *p_design =
static_cast<const InDetDD::PixelModuleDesign*
>(&element->
design());
146 writeCdo -> setAllFromConfigData(moduleHash, configData, becLayer, numFE);
147 }
148 }
149
150
151
152 for (
unsigned int moduleHash{}; moduleHash <
m_pixelID->wafer_hash_max(); moduleHash++) {
153 IdentifierHash wafer_hash = IdentifierHash(moduleHash);
154 Identifier wafer_id =
m_pixelID->wafer_id(wafer_hash);
155 int barrel_ec =
m_pixelID->barrel_ec(wafer_id);
157 const InDetDD::SiDetectorElement *element = elements->getDetectorElement(wafer_hash);
158 const InDetDD::PixelModuleDesign *p_design =
static_cast<const InDetDD::PixelModuleDesign*
>(&element->
design());
159
165 writeCdo -> setThresholds(type, moduleHash, std::vector<Thresholds>(numFE, defaults));
166 }
167 }
168 }
169
170 if (writeHandle.record(rangeW, std::move(writeCdo)).isFailure()) {
171 ATH_MSG_FATAL(
"Could not record PixelChargeCalibCondData " << writeHandle.key() <<
" with EventRange " << rangeW <<
" into Conditions Store");
172 return StatusCode::FAILURE;
173 }
174 ATH_MSG_INFO(
"recorded new CDO " << writeHandle.key() <<
" with range " << rangeW <<
" into Conditions Store");
175
176 return StatusCode::SUCCESS;
177}
char data[hepevt_bytes_allocation_ATLAS]
constexpr std::size_t enum2uint(T n, std::string_view callingFunctionName="")
Convert an enum class to size_t for use as an array index.
size_type size() const
number of Chan/AttributeList pairs
coral::AttributeList AttributeList
PixelReadoutTechnology getReadoutTechnology() const
int numberOfCircuits() const
Total number of circuits:
virtual const SiDetectorDesign & design() const override final
access to the local description (inline):
static std::string find_file(const std::string &logical_file_name, const std::string &search_path)
Gaudi::Property< std::string > m_jsonFileName
const PixelID * m_pixelID
SG::WriteCondHandleKey< PixelChargeCalibCondData > m_writeKey
SG::ReadCondHandleKey< PixelModuleData > m_configKey
SG::ReadCondHandleKey< InDetDD::SiDetectorElementCollection > m_pixelDetEleCollKey
Gaudi::Property< int > m_inputSource
SG::ReadCondHandleKey< CondAttrListCollection > m_readKey
int getDefaultInTimeThreshold(int barrel_ec, int layer) const
int getDefaultAnalogThreshold(int barrel_ec, int layer) const
int getDefaultAnalogThresholdNoise(int barrel_ec, int layer) const
int getDefaultAnalogThresholdSigma(int barrel_ec, int layer) const
std::pair< int, int > getBecAndLayer(const PixelID *pPixelId, IdentifierHash hash)