ATLAS Offline Software
Loading...
Searching...
No Matches
L1CaloPprConditionsContainerRun2.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3*/
4
6
7#include <iostream>
8
9#include "CoralBase/AttributeListSpecification.h"
12
14
16
18 : AbstractL1CaloPersistentCondition("CondAttrListCollection"),
21 "/TRIGGER/L1Calo/V2/Calibration/Physics/PprChanCalib"},
23 "/TRIGGER/L1Calo/V2/Configuration/PprChanDefaults"}}) {
24 this->addSpecification(eBcidDecision1, std::string("CR12_BcidDecision1"),
25 std::string("Int32"));
26 this->addSpecification(eSatOverride1, std::string("CR12_SatOverride1"),
27 std::string("Int32"));
28 this->addSpecification(eBcidDecision2, std::string("CR13_BcidDecision2"),
29 std::string("Int32"));
30 this->addSpecification(eSatOverride2, std::string("CR13_SatOverride2"),
31 std::string("Int32"));
32 this->addSpecification(eBcidDecision3, std::string("CR14_BcidDecision3"),
33 std::string("Int32"));
34 this->addSpecification(eSatOverride3, std::string("CR14_SatOverride3"),
35 std::string("Int32"));
36 this->addSpecification(ePeakFinderCond, std::string("CR15_PeakFinderCond"),
37 std::string("Int32"));
38 this->addSpecification(eDecisionSource, std::string("CR15_DecisionSource"),
39 std::string("Int32"));
40
41 // ------------------------------------------------------------------------------------------------------------------
42 // Common
43 // ------------------------------------------------------------------------------------------------------------------
44 // Define DB rows names and types in order to construct the
45 // AttributeListSpecification object
46 this->addSpecification(eExtBcidThreshold, std::string("ExtBcidThreshold"),
47 std::string("UInt16"));
48 this->addSpecification(eSatBcidThreshLow, std::string("SatBcidThreshLow"),
49 std::string("UInt16"));
50 this->addSpecification(eSatBcidThreshHigh, std::string("SatBcidThreshHigh"),
51 std::string("UInt16"));
52 this->addSpecification(eSatBcidLevel, std::string("SatBcidLevel"),
53 std::string("UInt16"));
54 this->addSpecification(eBcidEnergyRangeLow, std::string("BcidEnergyRangeLow"),
55 std::string("UInt16"));
56 this->addSpecification(eBcidEnergyRangeHigh,
57 std::string("BcidEnergyRangeHigh"),
58 std::string("UInt16"));
59
60 this->addSpecification(ePedValue, std::string("PedValue"),
61 std::string("UInt32"));
62 this->addSpecification(ePedMean, std::string("PedMean"),
63 std::string("Double"));
64
65 this->addSpecification(eLutCpStrategy, std::string("LutCpStrategy"),
66 std::string("UInt16"));
67
68 this->addSpecification(eLutCpScale, std::string("LutCpScale"),
69 std::string("UInt16"));
70 this->addSpecification(eLutCpPar1, std::string("LutCpPar1"),
71 std::string("UInt16"));
72 this->addSpecification(eLutCpPar2, std::string("LutCpPar2"),
73 std::string("UInt16"));
74 this->addSpecification(eLutCpPar3, std::string("LutCpPar3"),
75 std::string("UInt16"));
76 this->addSpecification(eLutCpPar4, std::string("LutCpPar4"),
77 std::string("UInt16"));
78
79 this->addSpecification(eLutJepStrategy, std::string("LutJepStrategy"),
80 std::string("UInt16"));
81
82 this->addSpecification(eLutJepScale, std::string("LutJepScale"),
83 std::string("UInt16"));
84 this->addSpecification(eLutJepPar1, std::string("LutJepPar1"),
85 std::string("UInt16"));
86 this->addSpecification(eLutJepPar2, std::string("LutJepPar2"),
87 std::string("UInt16"));
88 this->addSpecification(eLutJepPar3, std::string("LutJepPar3"),
89 std::string("UInt16"));
90 this->addSpecification(eLutJepPar4, std::string("LutJepPar4"),
91 std::string("UInt16"));
92
93 // Missing attributes in model with strategy
94 this->addSpecification(ePedFirSum, std::string("PedFirSum"),
95 std::string("UInt32"));
96 this->addSpecification(eLutCpOffset, std::string("LutCpOffset"),
97 std::string("UInt16"));
98 this->addSpecification(eLutJepOffset, std::string("LutJepOffset"),
99 std::string("UInt16"));
100 // ------------------------------------------------------------------------------------------------------------------
101 // Strategy
102 // ------------------------------------------------------------------------------------------------------------------
103 this->addSpecification(eFirStartBit, std::string("FirStartBit"),
104 std::string("UInt16"));
105 this->addSpecification(eFirCoeff1, std::string("FirCoeff1"),
106 std::string("short"));
107 this->addSpecification(eFirCoeff2, std::string("FirCoeff2"),
108 std::string("short"));
109 this->addSpecification(eFirCoeff3, std::string("FirCoeff3"),
110 std::string("short"));
111 this->addSpecification(eFirCoeff4, std::string("FirCoeff4"),
112 std::string("short"));
113 this->addSpecification(eFirCoeff5, std::string("FirCoeff5"),
114 std::string("short"));
115 this->addSpecification(eLutCpNoiseCut, std::string("LutCpNoiseCut"),
116 std::string("UInt16"));
117 this->addSpecification(eLutCpSlope, std::string("LutCpSlope"),
118 std::string("UInt16"));
119 this->addSpecification(eLutJepNoiseCut, std::string("LutJepNoiseCut"),
120 std::string("UInt16"));
121 this->addSpecification(eLutJepSlope, std::string("LutJepSlope"),
122 std::string("UInt16"));
123 // ------------------------------------------------------------------------------------------------------------------
124
125 m_pprConditionsVec.reserve(s_vectorSize);
126 this->clear();
127}
128
130 const std::map<L1CaloPprConditionsContainerRun2::eCoolFolders, std::string>&
131 folderKeysMap)
132 : L1CaloPprConditionsContainerRun2() // delegating constructor
133{
134 m_coolFoldersKeysMap = folderKeysMap;
135}
136
140
143 auto it = m_coolFoldersKeysMap.find(efolder);
144 if (it != m_coolFoldersKeysMap.end()) {
145 return it->second;
146 } else {
147 return std::string("");
148 }
149}
150
152 const {
153 std::vector<std::string> result{
155 std::string calibKey =
157
158 if (!calibKey.empty()) {
159 result.push_back(std::move(calibKey));
160 } else {
161 result.push_back(this->coolFolderKey(
163 result.push_back(this->coolFolderKey(
165 }
166
167 return result;
168}
169
173
175 // this container is not supposed to be saved to COOL
176 return 0;
177}
178
179void L1CaloPprConditionsContainerRun2::makeTransient(const std::map<std::string, const CondAttrListCollection*>& condAttrListCollectionMap) {
180 this->clear();
181 // --------------------------------------------------------------------------
182 // Folder names
183 std::string chanCalibFolderKey;
184 std::string chanCalibCommonFolderKey;
185 std::string chanCalibStrategyFolderKey;
186 std::string chanDefaultsFolderKey;
187
188 // cppcheck-suppress duplicateAssignExpression
189 auto it_pprChanCalibAttrListCollection = condAttrListCollectionMap.end();
190
191 auto it_pprChanCalibStrategyAttrListCollection = condAttrListCollectionMap.end();
192
193 // --------------------------------------------------------------------------
194
195 if (condAttrListCollectionMap.empty()) return;
196
197 // Reading cool paths
198 for (const auto& [name, coll] : condAttrListCollectionMap) {
199 if (name.find("PprChanDefaults")!=std::string::npos){
200 chanDefaultsFolderKey=name;}
201 if(name.find("PprChanCalib")!=std::string::npos){
202 chanCalibFolderKey=name;
203 }
204 if(name.find("PprChanCommon")!=std::string::npos){
205 chanCalibCommonFolderKey=name;
206 }
207 if(name.find("Mu")!=std::string::npos){
208 chanCalibStrategyFolderKey=name;
209 }
210 }
211
212
213 // Check that folders exist
214 bool isUseStrategy = false;
215 if (!chanCalibFolderKey.empty()) {
216 it_pprChanCalibAttrListCollection =
217 condAttrListCollectionMap.find(chanCalibFolderKey);
218 }
219 else {
220 isUseStrategy = true;
221 it_pprChanCalibAttrListCollection = condAttrListCollectionMap.find(chanCalibCommonFolderKey);
222 it_pprChanCalibStrategyAttrListCollection = condAttrListCollectionMap.find(chanCalibStrategyFolderKey);
223 }
224
225
226
227
228 // --------------------------------------------------------------------------
229 if (isUseStrategy) {
230 // Check that strategy folder exists
231 if (it_pprChanCalibStrategyAttrListCollection ==
232 condAttrListCollectionMap.end()) {
233 std::cout << "L1CaloPprConditionsContainerRun2 : Could not find "
234 "requested CondAttrListCollection"
235 << chanCalibStrategyFolderKey << std::endl;
236 return;
237 }
238
239 // Check that common folder exists
240 if (it_pprChanCalibAttrListCollection == condAttrListCollectionMap.end()) {
241 std::cout << "L1CaloPprConditionsContainerRun2 : Could not find "
242 "requested CondAttrListCollection "
243 << chanCalibCommonFolderKey << std::endl;
244 return;
245 }
246 } else{
247 if (it_pprChanCalibAttrListCollection == condAttrListCollectionMap.end()) {
248 std::cout << "L1CaloPprConditionsContainerRun2 : Could not find "
249 "requested CondAttrListCollection"
250 << chanCalibCommonFolderKey << std::endl;
251 return;
252 }
253 }
254 // --------------------------------------------------------------------------
255 const CondAttrListCollection* chanCalibAttrListCollection =
256 it_pprChanCalibAttrListCollection->second;
257
258
259 auto it_pprChanDefaultsAttrListCollection =
260 condAttrListCollectionMap.find(chanDefaultsFolderKey);
261 if (it_pprChanDefaultsAttrListCollection == condAttrListCollectionMap.end()) {
262 std::cout << "L1CaloPprConditionsContainerRun2 : Could not find requested "
263 "CondAttrListCollection" << chanDefaultsFolderKey
264 << std::endl;
265 return;
266 }
267 // --------------------------------------------------------------------------
268 const CondAttrListCollection* chanDefaultsAttrListCollection =
269 it_pprChanDefaultsAttrListCollection->second;
270
271 // There should be only one channel (channel#1 in data, #0 in MC) in the Default folder
272 const coral::AttributeList& chanDefaultAttrList = std::cbegin(*chanDefaultsAttrListCollection)->second;
273
275 chanDefaultAttrList[this->specificationName(eBcidDecision1)].data<int>();
277 chanDefaultAttrList[this->specificationName(eSatOverride1)].data<int>();
279 chanDefaultAttrList[this->specificationName(eBcidDecision2)].data<int>();
281 chanDefaultAttrList[this->specificationName(eSatOverride2)].data<int>();
283 chanDefaultAttrList[this->specificationName(eBcidDecision3)].data<int>();
285 chanDefaultAttrList[this->specificationName(eSatOverride3)].data<int>();
287 chanDefaultAttrList[this->specificationName(ePeakFinderCond)].data<int>();
289 chanDefaultAttrList[this->specificationName(eDecisionSource)].data<int>();
290 // ------------------------------------------------------------------------
291 // loop over CondAttrListCollection
292 auto it_AttrListColl = chanCalibAttrListCollection->begin();
293 auto it_AttrListCollE = chanCalibAttrListCollection->end();
294 // --------------------------------------------------------------------------
295 for (; it_AttrListColl != it_AttrListCollE; ++it_AttrListColl) {
296 // ------------------------------------------------------------------------
297 L1CaloCoolChannelId coolId(it_AttrListColl->first);
298 unsigned int index = (coolId.crate() << 10) + (coolId.module() << 6) +
299 (coolId.subModule() << 2) + coolId.channel();
300 // ------------------------------------------------------------------------
301 if (index >= s_vectorSize) {
302 continue;
303 }
304 // ------------------------------------------------------------------------
305 const coral::AttributeList& chanCalibAttrList(it_AttrListColl->second);
306 // ------------------------------------------------------------------------
307 unsigned short extBcidThreshold =
308 chanCalibAttrList[this->specificationName(eExtBcidThreshold)]
309 .data<unsigned short>();
310 unsigned short satBcidThreshLow =
311 chanCalibAttrList[this->specificationName(eSatBcidThreshLow)]
312 .data<unsigned short>();
313 unsigned short satBcidThreshHigh =
314 chanCalibAttrList[this->specificationName(eSatBcidThreshHigh)]
315 .data<unsigned short>();
316 unsigned short satBcidLevel =
317 chanCalibAttrList[this->specificationName(eSatBcidLevel)]
318 .data<unsigned short>();
319
320 unsigned short bcidEnergyRangeLow =
321 chanCalibAttrList[this->specificationName(eBcidEnergyRangeLow)]
322 .data<unsigned short>();
323 unsigned short bcidEnergyRangeHigh =
324 chanCalibAttrList[this->specificationName(eBcidEnergyRangeHigh)]
325 .data<unsigned short>();
326 unsigned short lutCpStrategy =
327 chanCalibAttrList[this->specificationName(eLutCpStrategy)]
328 .data<unsigned short>();
329
330 short lutCpPar1 =
331 chanCalibAttrList[this->specificationName(eLutCpPar1)].data<short>();
332 short lutCpPar2 =
333 chanCalibAttrList[this->specificationName(eLutCpPar2)].data<short>();
334 short lutCpPar3 =
335 chanCalibAttrList[this->specificationName(eLutCpPar3)].data<short>();
336 short lutCpPar4 =
337 chanCalibAttrList[this->specificationName(eLutCpPar4)].data<short>();
338 unsigned short lutJepStrategy =
339 chanCalibAttrList[this->specificationName(eLutJepStrategy)]
340 .data<unsigned short>();
341
342 unsigned short lutCpScale =
343 chanCalibAttrList[this->specificationName(eLutCpScale)]
344 .data<unsigned short>();
345 unsigned short lutJepScale =
346 chanCalibAttrList[this->specificationName(eLutJepScale)]
347 .data<unsigned short>();
348 short lutJepPar1 =
349 chanCalibAttrList[this->specificationName(eLutJepPar1)].data<short>();
350 short lutJepPar2 =
351 chanCalibAttrList[this->specificationName(eLutJepPar2)].data<short>();
352 short lutJepPar3 =
353 chanCalibAttrList[this->specificationName(eLutJepPar3)].data<short>();
354 short lutJepPar4 =
355 chanCalibAttrList[this->specificationName(eLutJepPar4)].data<short>();
356 unsigned int pedValue =
357 chanCalibAttrList[this->specificationName(ePedValue)]
358 .data<unsigned int>();
359 float pedMean =
360 (float)
361 chanCalibAttrList[this->specificationName(ePedMean)].data<double>();
362
363 unsigned short lutJepOffset =
364 isUseStrategy
365 ? 0
366 : chanCalibAttrList[this->specificationName(eLutJepOffset)]
367 .data<unsigned short>();
368 unsigned short lutCpOffset =
369 isUseStrategy ? 0
370 : chanCalibAttrList[this->specificationName(eLutCpOffset)]
371 .data<unsigned short>();
372 unsigned int pedFirSum =
373 isUseStrategy ? 0
374 : chanCalibAttrList[this->specificationName(ePedFirSum)]
375 .data<unsigned int>();
376
377 unsigned short firStartBit =
378 isUseStrategy ? 0
379 : chanCalibAttrList[this->specificationName(eFirStartBit)]
380 .data<unsigned short>();
381 short int firCoeff1 =
382 isUseStrategy ? 0
383 : chanCalibAttrList[this->specificationName(eFirCoeff1)]
384 .data<short>();
385 short int firCoeff2 =
386 isUseStrategy ? 0
387 : chanCalibAttrList[this->specificationName(eFirCoeff2)]
388 .data<short>();
389 short int firCoeff3 =
390 isUseStrategy ? 0
391 : chanCalibAttrList[this->specificationName(eFirCoeff3)]
392 .data<short>();
393 short int firCoeff4 =
394 isUseStrategy ? 0
395 : chanCalibAttrList[this->specificationName(eFirCoeff4)]
396 .data<short>();
397 short int firCoeff5 =
398 isUseStrategy ? 0
399 : chanCalibAttrList[this->specificationName(eFirCoeff5)]
400 .data<short>();
401
402 unsigned short lutCpSlope =
403 isUseStrategy ? 0
404 : chanCalibAttrList[this->specificationName(eLutCpSlope)]
405 .data<unsigned short>();
406 unsigned short lutCpNoiseCut =
407 isUseStrategy
408 ? 0
409 : chanCalibAttrList[this->specificationName(eLutCpNoiseCut)]
410 .data<unsigned short>();
411 unsigned short lutJepSlope =
412 isUseStrategy ? 0
413 : chanCalibAttrList[this->specificationName(eLutJepSlope)]
414 .data<unsigned short>();
415 unsigned short lutJepNoiseCut =
416 isUseStrategy
417 ? 0
418 : chanCalibAttrList[this->specificationName(eLutJepNoiseCut)]
419 .data<unsigned short>();
420 // ------------------------------------------------------------------------
422 extBcidThreshold, satBcidThreshLow, satBcidThreshHigh, satBcidLevel,
423 bcidEnergyRangeLow, bcidEnergyRangeHigh, firStartBit, firCoeff1,
424 firCoeff2, firCoeff3, firCoeff4, firCoeff5, lutCpStrategy, lutCpOffset,
425 lutCpSlope, lutCpNoiseCut, lutCpPar1, lutCpPar2, lutCpPar3, lutCpPar4,
426 lutCpScale, lutJepStrategy, lutJepOffset, lutJepSlope, lutJepNoiseCut,
427 lutJepPar1, lutJepPar2, lutJepPar3, lutJepPar4, lutJepScale, pedValue,
428 pedMean, pedFirSum);
429 }
430 // --------------------------------------------------------------------------
431 if (isUseStrategy){
432 // ------------------------------------------------------------------------
433 const CondAttrListCollection* chanCalibAttrListCollection =
434 it_pprChanCalibStrategyAttrListCollection->second;
435 auto it_AttrListColl = chanCalibAttrListCollection->begin();
436 auto it_AttrListCollE = chanCalibAttrListCollection->end();
437 // ------------------------------------------------------------------------
438 for (; it_AttrListColl != it_AttrListCollE; ++it_AttrListColl) {
439 L1CaloCoolChannelId coolId(it_AttrListColl->first);
440 unsigned int index = (coolId.crate() << 10) + (coolId.module() << 6) +
441 (coolId.subModule() << 2) + coolId.channel();
442
443 if (index >= s_vectorSize) {
444 continue;
445 }
446
447 const coral::AttributeList& chanCalibAttrList(it_AttrListColl->second);
448
449 if (m_pprConditionsVec[index] == nullptr){
450 std::cout << "L1CaloPprConditionsContainerRun2 : Could not find channel "
451 << " with index " << index << std::endl;
452 return;
453 }
454
455 unsigned short firStartBit =
456 chanCalibAttrList[this->specificationName(eFirStartBit)]
457 .data<unsigned short>();
458 short int firCoeff1 =
459 chanCalibAttrList[this->specificationName(eFirCoeff1)].data<short>();
460 short int firCoeff2 =
461 chanCalibAttrList[this->specificationName(eFirCoeff2)].data<short>();
462 short int firCoeff3 =
463 chanCalibAttrList[this->specificationName(eFirCoeff3)].data<short>();
464 short int firCoeff4 =
465 chanCalibAttrList[this->specificationName(eFirCoeff4)].data<short>();
466 short int firCoeff5 =
467 chanCalibAttrList[this->specificationName(eFirCoeff5)].data<short>();
468
469 unsigned short lutCpSlope =
470 chanCalibAttrList[this->specificationName(eLutCpSlope)]
471 .data<unsigned short>();
472 unsigned short lutCpNoiseCut =
473 chanCalibAttrList[this->specificationName(eLutCpNoiseCut)]
474 .data<unsigned short>();
475 unsigned short lutJepSlope =
476 chanCalibAttrList[this->specificationName(eLutJepSlope)]
477 .data<unsigned short>();
478 unsigned short lutJepNoiseCut =
479 chanCalibAttrList[this->specificationName(eLutJepNoiseCut)]
480 .data<unsigned short>();
481 m_pprConditionsVec[index]->initializeByStrategy(
482 firStartBit, firCoeff1, firCoeff2, firCoeff3, firCoeff4, firCoeff5,
483 lutCpSlope, lutCpNoiseCut, lutJepSlope, lutJepNoiseCut);
484
485 } // end for
486 // ------------------------------------------------------------------------
487 } // end isUseStrategy
488 // --------------------------------------------------------------------------
489
490}
491
493 unsigned int channelId) const {
494 L1CaloCoolChannelId coolId(channelId);
495 return pprConditions(coolId);
496}
497
499 const L1CaloCoolChannelId& channelId) const {
500 unsigned int index = (channelId.crate() << 10) + (channelId.module() << 6) +
501 (channelId.subModule() << 2) + channelId.channel();
502 if (index < s_vectorSize)
504 else
505 return 0;
506}
507
509 std::cout << "bcidDecision1: " << m_bcidDecision1 << ", "
510 << "satOverride1: " << m_satOverride1 << ", "
511 << "bcidDecision2: " << m_bcidDecision2 << ", "
512 << "satOverride2: " << m_satOverride2 << ", "
513 << "bcidDecision3: " << m_bcidDecision3 << ", "
514 << "satOverride3: " << m_satOverride3 << ", "
515 << "peakFinderCond: " << m_peakFinderCond << ", "
516 << "decisionSource: " << m_decisionSource << std::endl;
517 std::size_t index(0);
518 for (auto* C : m_pprConditionsVec) {
519 if (C) std::cout << "index " << index++ << " * item: " << *C << std::endl;
520 }
521}
522
525 if (p) delete p;
526 }
527 m_pprConditionsVec.assign(s_vectorSize, nullptr);
528}
This file defines the class for a collection of AttributeLists where each one is associated with a ch...
AbstractL1CaloPersistentCondition(const std::string &condType)
This class is a collection of AttributeLists where each one is associated with a channel number.
const_iterator end() const
const_iterator begin() const
Access to Chan/AttributeList pairs via iterators.
Encapsulates the ID of one channel of conditions data in COOL, ie the ID of a row in a table.
unsigned int subModule() const
unsigned int module(bool logical=true) const
Convert a typeId to a L1CaloModuleType.
unsigned int crate() const
unsigned int channel() const
std::string coolFolderKey(L1CaloPprConditionsContainerRun2::eCoolFolders efolder) const
virtual void makeTransient(const std::map< std::string, const CondAttrListCollection * > &condAttrListCollectionMap)
const L1CaloPprConditionsRun2 * pprConditions(unsigned int channelId) const
std::map< L1CaloPprConditionsContainerRun2::eCoolFolders, std::string > m_coolFoldersKeysMap
virtual std::vector< std::string > coolInputKeys() const
Transient conditions class for objects defined by the online framework and retrieved from COOL for th...
struct color C
Definition index.py:1