63 {
64
65
66 const std::map<CaloSampling::CaloSample, float> dynRange{
67 {CaloSampling::PreSamplerB, 2},
68 {CaloSampling::EMB1, 2},
69 {CaloSampling::EMB2, 10},
70 {CaloSampling::EMB3, 10},
71 {CaloSampling::PreSamplerE, 2},
72 {CaloSampling::EME1, 2},
73 {CaloSampling::EME2, 10},
74 {CaloSampling::EME3, 10},
75 {CaloSampling::HEC0, 2},
76 {CaloSampling::HEC1, 2},
77 {CaloSampling::HEC2, 2},
78 {CaloSampling::HEC3, 2,},
79 {CaloSampling::FCAL0, 10},
80 {CaloSampling::FCAL1, 10},
81 {CaloSampling::FCAL2, 10},
82 };
83
84
85
86 const std::map<CaloSampling::CaloSample, std::vector<std::pair<float, float> > > noiseMap{
87 {CaloSampling::PreSamplerB, {{5, 3.2}}},
88 {CaloSampling::EMB1, {{0.8, 1.8}, {5, 2.1}}},
89 {CaloSampling::EMB2, {{0.8, 1.4}, {5, 1.7}}},
90 {CaloSampling::EMB3, {{0.8, 1.4}, {5, 1.7}}},
91 {CaloSampling::PreSamplerE, {{5, 3.5}}},
92 {CaloSampling::EME1, {{2, 2.7}, {5, 2.9}}},
93 {CaloSampling::EME2, {{2, 1.3}, {5, 1.5}}},
94 {CaloSampling::EME3, {{2, 1.3}, {5, 1.5}}},
95 {CaloSampling::HEC0, {{5, 3.1}}},
96 {CaloSampling::HEC1, {{5, 3.1}}},
97 {CaloSampling::HEC2, {{5, 2.1}}},
98 {CaloSampling::HEC3, {{5, 2.1}}},
99
100 {CaloSampling::FCAL0, {{5, 4.3}}},
101 {CaloSampling::FCAL1, {{5, 4.6}}},
102 {CaloSampling::FCAL2, {{5, 4.5}}},
103 };
104
105 SG::ReadCondHandle<LArOnOffIdMapping> cablingHdl{
m_cablingKey};
106 SG::ReadCondHandle<LArMCSym> larMCsymHdl{
m_mcSym};
109
110 SG::ReadCondHandle<CaloDetDescrManager> caloMgrHandle{
m_caloMgrKey};
111
112 std::unique_ptr<LArRampMC> rampMC = std::make_unique<LArRampMC>();
115
116 const auto& symIDs = larMCsymHdl->symIds();
117
119
120
121
122
123 for (const HWIdentifier hwid : symIDs) {
124 const Identifier id = (*cablingHdl)->cnvToIdentifier(hwid);
126 const auto rangeIt = dynRange.find(sampling);
127 if (rangeIt == dynRange.end())[[
unlikely]]{
128 ATH_MSG_WARNING(
"LArR4ElecCalibCalculator::stop: sampling not found in dynRange.");
129 continue;
130 }
131 const double mARange = rangeIt->second;
132 const double uAperADC = 1000 * mARange / nUsableBits;
133 const double dac2uA = (*DAC2uAHdl)->DAC2UA(hwid);
134 const double ADC2DAC = uAperADC / dac2uA;
135
136
137 const double ADC2MeV = ADC2DAC * dac2uA * uA2MeVHdl->UA2MEV(hwid);
138 const double adc2uA = ADC2DAC * dac2uA;
140 << uAperADC << ", ADC/mA " << nUsableBits / mARange << ", DAC2uA " << dac2uA << ", Ramp " << ADC2DAC << ", ADC2MeV=" << ADC2MeV
141 << ", ADC2DAC*dac2uA=" << adc2uA);
142
143 std::vector<float> vRamp;
144 vRamp.push_back(0);
145 vRamp.push_back(ADC2DAC);
146
148
149 vRamp[1] /= 23.0;
151 }
152
153
154
155
156 std::unique_ptr<LArRampSym> rampSym = std::make_unique<LArRampSym>(*larMCsymHdl, rampMC.get());
157
159 if (
sc.isFailure()) {
161 }
163 if (
sc.isFailure()) {
164 ATH_MSG_ERROR(
"Failed to symlink LArRampMC to ILArRamp base-class");
165 }
166
169 if (
sc.isFailure()) {
171 }
173 if (
sc.isFailure()) {
174 ATH_MSG_ERROR(
"Failed to symlink LArRampSym to ILArRamp base-class");
175 }
176
177
178
179
180 std::vector<float> pedVec, pedRMSVec;
183 std::unique_ptr<LArPedestalMC> pedPtr = std::make_unique<LArPedestalMC>();
184 pedPtr->set(pedVec, pedRMSVec);
186
187
188
189
190 std::unique_ptr<LArNoiseMC> noisePtr = std::make_unique<LArNoiseMC>();
193
194 SG::ReadCondHandle<CaloDetDescrManager> caloDDM{
m_caloMgrKey};
195 for (const HWIdentifier hwid : symIDs) {
196 const Identifier id = (*cablingHdl)->cnvToIdentifier(hwid);
198 const CaloDetDescrElement* dde = caloDDM->get_element(id);
200
201 const auto&
pairs = noiseMap.find(sampling)->second;
203 for (auto [e, n] : pairs) {
206 ATH_MSG_DEBUG(
"Sampling: " << sampling <<
", eta=" <<
eta <<
", noise=" << noise);
207 break;
208 }
209 }
212 }
213
214 std::unique_ptr<LArNoiseSym> noiseSym = std::make_unique<LArNoiseSym>(*larMCsymHdl, noisePtr.get());
215
218 if (
sc.isFailure()) {
219 ATH_MSG_ERROR(
"Failed to symlink LArNoiseMC to ILArNoise base-class");
220 }
221
222 sc =
detStore()->record(std::move(noiseSym),
"LArNoiseSym");
223 if (
sc.isFailure()) {
225 }
227 if (
sc.isFailure()) {
228 ATH_MSG_ERROR(
"Failed to symlink LArNoiseSym to ILArNoise base-class");
229 }
230
231
232
233
234
235
236
238
239 chai::Tag::Metadata chaiMD{.iovType=chai::Tag::IovType::RunNumberLumiBlock,
240 .objectType="crest-json-single-iov",
241 .synchronization=chai::Tag::Synchronization::All,
242 .status=chai::Tag::Status::Unlocked,
243 .nodeDescription = chai::Tag::buildNodeDescription(chai::Tag::IovType::RunNumberLumiBlock, "CondAttrListCollection", 1238547719u)
244 };
245
246 std::vector<float> rampsHG, rampsMG, noiseHG, noiseMG,
ped, pedRMS;
247 const LArRampSym* rampsIn = nullptr;
249 const LArNoiseSym* noiseIn = nullptr;
251
253
254
257 for (
unsigned idx = 0;
idx < hashmax; ++
idx) {
258 IdentifierHash hIdx(idx);
260 if (!(*cablingHdl)->isOnlineConnectedFromHash(hIdx)) {
261 rampsHG.push_back(0);
262 rampsHG.push_back(-999);
263 rampsMG.push_back(0);
264 rampsMG.push_back(-999);
265 noiseHG.push_back(-999);
266 noiseMG.push_back(-999);
267 } else {
269 rampsHG.push_back(rampvecHG[0]);
270 rampsHG.push_back(rampvecHG[1]);
272 rampsMG.push_back(rampvecMG[0]);
273 rampsMG.push_back(rampvecMG[1]);
274
277 }
278 }
280 auto gt=
db.createGlobalTag(
"GlobalTestTag",
"test",
"MC");
281
282
283 {
284 chai::PayloadSpec
spec(chai::FieldSpec({{
"Pedestal", chai::Type::Blob}, {
"PedestalRMS", chai::Type::Blob}, {
"version", chai::Type::UInt32}}),
285
286 chai::ChannelSpec({
287 {0, "HIGHGain"},
288 {1, "MEDGain"},
289 }));
290
291 auto tag =
db.createTag(
"LARElecCalibPedestal-R4-00",
"Pedestal of FEB 2", spec, chaiMD);
292 gt->addTag("/LAR/ElecCalibMC/Pedestal","LARElecCalibPedestal-R4-00");
293
295 for (
size_t g = 0;
g < 2; ++
g) {
296 container[
g].push(std::move(vecToBlobData(ped)));
297 container[
g].push(std::move(vecToBlobData(pedRMS)));
299 }
300 tag->addPayload(container, 0);
301 }
302
303 {
304 chai::PayloadSpec
spec(chai::FieldSpec({{
"RampVec", chai::Type::Blob}, {
"nPoints", chai::Type::UInt32}, {
"version", chai::Type::UInt32}}),
305
306 chai::ChannelSpec({
307 {0, "HIGHGain"},
308 {1, "MEDGain"},
309 }));
310
311 auto tag =
db.createTag(
"LARElecCalibMCRamp-R4-00",
"Electronic gain of FEB 2", spec, chaiMD);
312 gt->addTag("/LAR/ElecCalibMC/Ramp", "LARElecCalibMCRamp-R4-00");
313
315 container[0].push(std::move(vecToBlobData(rampsHG)));
318
319 container[1].push(std::move(vecToBlobData(rampsMG)));
322
323 tag->addPayload(container, 0);
324 }
325
326 {
327 chai::PayloadSpec
spec(chai::FieldSpec({{
"Noise", chai::Type::Blob}, {
"version", chai::Type::UInt32}}),
328
329 chai::ChannelSpec({
330 {0, "HIGHGain"},
331 {1, "MEDGain"},
332 }));
333
334 auto tag =
db.createTag(
"LARElecCalibMCNoise-R4-00",
"Noise of FEB 2 (in ADC counts)", spec, chaiMD);
335 gt->addTag("/LAR/ElecCalibMC/Noise","LARElecCalibMCNoise-R4-00");
336
338
339 container[0].push(std::move(vecToBlobData(noiseHG)));
341
342 container[1].push(std::move(vecToBlobData(noiseMG)));
344 tag->addPayload(container, 0);
345 }
346 }
348 return StatusCode::SUCCESS;
349}
Scalar eta() const
pseudorapidity method
#define ATH_MSG_WARNING(x)
float eta_raw() const
cell eta_raw
virtual const float & noise(const HWIdentifier &hwid, int gain) const override
Gaudi::Property< float > m_pedestalRMS
Gaudi::Property< std::string > m_keyoutput
Gaudi::Property< std::string > m_pedkeyoutput
Gaudi::Property< float > m_pedestalValue
IntegerProperty m_nADCBits
Gaudi::Property< std::string > m_crestDBStr
virtual RampRef_t ADC2DAC(const HWIdentifier &CellID, int gain) const override
::StatusCode StatusCode
StatusCode definition for legacy code.
const SG::AuxVectorData * container() const
Return the container holding this element.
static constexpr CLID ID()