ATLAS Offline Software
Loading...
Searching...
No Matches
L1CaloPprChanCalibV1Container.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
3*/
4
6
7#include <algorithm>
8#include <memory>
9
10#include "CoralBase/AttributeListSpecification.h"
13
15
17 : AbstractL1CaloPersistentCondition("CondAttrListCollection")
18{
19 this->addSpecification(eErrorCode, "ErrorCode", "unsigned int");
20 this->addSpecification(ePedMean, "PedMean", "double");
21 this->addSpecification(ePedValue, "PedValue", "unsigned int");
22 this->addSpecification(eExtBcidThreshold, "ExtBcidThreshold", "unsigned short");
23 this->addSpecification(eSatBcidThreshLow, "SatBcidThreshLow", "unsigned short");
24 this->addSpecification(eSatBcidThreshHigh, "SatBcidThreshHigh", "unsigned short");
25 this->addSpecification(eSatBcidLevel, "SatBcidLevel", "unsigned short");
26 this->addSpecification(eBcidEnergyRangeLow, "BcidEnergyRangeLow", "unsigned short");
27 this->addSpecification(eBcidEnergyRangeHigh, "BcidEnergyRangeHigh", "unsigned short");
28 this->addSpecification(eFirStartBit, "FirStartBit", "unsigned short");
29 this->addSpecification(eFirCoeff1, "FirCoeff1", "short");
30 this->addSpecification(eFirCoeff2, "FirCoeff2", "short");
31 this->addSpecification(eFirCoeff3, "FirCoeff3", "short");
32 this->addSpecification(eFirCoeff4, "FirCoeff4", "short");
33 this->addSpecification(eFirCoeff5, "FirCoeff5", "short");
34 this->addSpecification(eLutStrategy, "LutStrategy", "unsigned short");
35 this->addSpecification(eLutOffset, "LutOffset", "unsigned short");
36 this->addSpecification(eLutNoiseCut, "LutNoiseCut", "unsigned short");
37 this->addSpecification(eLutSlope, "LutSlope", "unsigned short");
38}
39
41 : L1CaloPprChanCalibV1Container() // delegating constructor
42{
43 // cppcheck-suppress useInitializationList
44 m_coolFolderKey = folderKey;
45}
46
50
52{
53 using std::make_unique;
54
55 if(m_coolFolderKey.empty()) return nullptr;
56
57 auto* attrSpecification = this->createAttributeListSpecification();
58 if(!attrSpecification || !attrSpecification->size()) return nullptr;
59
60 auto attrListCollection = make_unique<CondAttrListCollection>(true);
61 for(const auto& item : m_pprChanCalibs) {
62 AthenaAttributeList attrList(*attrSpecification);
63 attrList[specificationName(eErrorCode)].setValue(item.errorCode());
64 attrList[specificationName(ePedMean)].setValue(item.pedMean());
65 attrList[specificationName(ePedValue)].setValue(item.pedValue());
66 attrList[specificationName(eExtBcidThreshold)].setValue(item.extBcidThreshold());
67 attrList[specificationName(eSatBcidThreshLow)].setValue(item.satBcidThreshLow());
68 attrList[specificationName(eSatBcidThreshHigh)].setValue(item.satBcidThreshHigh());
69 attrList[specificationName(eSatBcidLevel)].setValue(item.satBcidLevel());
70 attrList[specificationName(eBcidEnergyRangeLow)].setValue(item.bcidEnergyRangeLow());
71 attrList[specificationName(eBcidEnergyRangeHigh)].setValue(item.bcidEnergyRangeHigh());
72 attrList[specificationName(eFirStartBit)].setValue(item.firStartBit());
73 attrList[specificationName(eFirCoeff1)].setValue(item.firCoeff1());
74 attrList[specificationName(eFirCoeff2)].setValue(item.firCoeff2());
75 attrList[specificationName(eFirCoeff3)].setValue(item.firCoeff3());
76 attrList[specificationName(eFirCoeff4)].setValue(item.firCoeff4());
77 attrList[specificationName(eFirCoeff5)].setValue(item.firCoeff5());
78 attrList[specificationName(eLutStrategy)].setValue(item.lutStrategy());
79 attrList[specificationName(eLutOffset)].setValue(item.lutOffset());
80 attrList[specificationName(eLutNoiseCut)].setValue(item.lutNoiseCut());
81 attrList[specificationName(eLutSlope)].setValue(item.lutSlope());
82
83 attrListCollection->add(item.channelId(), attrList);
84 }
85 return static_cast<DataObject*>(attrListCollection.release());
86}
87
88void L1CaloPprChanCalibV1Container::makeTransient(const std::map<std::string, const CondAttrListCollection*>& condAttrListCollectionMap)
89{
90 clear();
91
92 auto it = condAttrListCollectionMap.find(m_coolFolderKey);
93 if(it == std::end(condAttrListCollectionMap)) return;
94
95 auto attrListCollection = it->second;
96 for(const auto& item : *attrListCollection) {
97 auto chanNum = item.first;
98 const auto& attrList = item.second;
99
100 auto errorCode = attrList[specificationName(eErrorCode)].data<unsigned int>();
101 auto pedMean = attrList[specificationName(ePedMean)].data<double>();
102 auto pedValue = attrList[specificationName(ePedValue)].data<unsigned int>();
103 auto extBcidThreshold = attrList[specificationName(eExtBcidThreshold)].data<unsigned short>();
104 auto satBcidThreshLow = attrList[specificationName(eSatBcidThreshLow)].data<unsigned short>();
105 auto satBcidThreshHigh = attrList[specificationName(eSatBcidThreshHigh)].data<unsigned short>();
106 auto satBcidLevel = attrList[specificationName(eSatBcidLevel)].data<unsigned short>();
107 auto bcidEnergyRangeLow = attrList[specificationName(eBcidEnergyRangeLow)].data<unsigned short>();
108 auto bcidEnergyRangeHigh = attrList[specificationName(eBcidEnergyRangeHigh)].data<unsigned short>();
109 auto firStartBit = attrList[specificationName(eFirStartBit)].data<unsigned short>();
110 auto firCoeff1 = attrList[specificationName(eFirCoeff1)].data<short>();
111 auto firCoeff2 = attrList[specificationName(eFirCoeff2)].data<short>();
112 auto firCoeff3 = attrList[specificationName(eFirCoeff3)].data<short>();
113 auto firCoeff4 = attrList[specificationName(eFirCoeff4)].data<short>();
114 auto firCoeff5 = attrList[specificationName(eFirCoeff5)].data<short>();
115 auto lutStrategy = attrList[specificationName(eLutStrategy)].data<unsigned short>();
116 auto lutOffset = attrList[specificationName(eLutOffset)].data<unsigned short>();
117 auto lutNoiseCut = attrList[specificationName(eLutNoiseCut)].data<unsigned short>();
118 auto lutSlope = attrList[specificationName(eLutSlope)].data<unsigned short>();
119
120 addPprChanCalibV1(L1CaloPprChanCalibV1(chanNum, errorCode, pedMean, pedValue, extBcidThreshold, satBcidThreshLow, satBcidThreshHigh, satBcidLevel, bcidEnergyRangeLow, bcidEnergyRangeHigh, firStartBit, firCoeff1, firCoeff2, firCoeff3, firCoeff4, firCoeff5, lutStrategy, lutOffset, lutNoiseCut, lutSlope));
121 }
122}
123
125{
126 auto it = std::lower_bound(std::begin(m_pprChanCalibs),
127 std::end(m_pprChanCalibs),
128 channelId,
129 [](const L1CaloPprChanCalibV1& el, unsigned int val) -> bool {
130 return el.channelId() < val;
131 });
132 if(it == std::end(m_pprChanCalibs)) return nullptr;
133 return &(*it);
134}
135
137{
138 // insert into the correct position mainting the sorted vector
139 m_pprChanCalibs.insert(std::lower_bound(std::begin(m_pprChanCalibs),
140 std::end(m_pprChanCalibs),
141 pprChanCalib.channelId(),
142 [](const L1CaloPprChanCalibV1& el, unsigned int va) -> bool {
143 return el.channelId() < va;
144 }),
145 pprChanCalib);
146}
147
This file defines the class for a collection of AttributeLists where each one is associated with a ch...
AbstractL1CaloPersistentCondition(const std::string &condType)
void addSpecification(int specId, const std::string &specName, const std::string &specType)
coral::AttributeListSpecification * createAttributeListSpecification() const
An AttributeList represents a logical row of attributes in a metadata table.
virtual DataObject * makePersistent() const
virtual void makeTransient(const std::map< std::string, const CondAttrListCollection * > &)
void addPprChanCalibV1(const L1CaloPprChanCalibV1 &pprChanCalib)
std::vector< L1CaloPprChanCalibV1 > m_pprChanCalibs
const L1CaloPprChanCalibV1 * pprChanCalibV1(unsigned int channelId) const
Folder <-> Object mapping for /TRIGGER/L1Calo/V1/Calibration/Physics/PprChanCalib .
unsigned int channelId() const