ATLAS Offline Software
L1CaloPprChanDefaultsContainer.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2020 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(eBcidDecision1, "CR12_BcidDecision1", "int");
20  this->addSpecification(eSatOverride1, "CR12_SatOverride1", "int");
21  this->addSpecification(eBcidDecision2, "CR13_BcidDecision2", "int");
22  this->addSpecification(eSatOverride2, "CR13_SatOverride2", "int");
23  this->addSpecification(eBcidDecision3, "CR14_BcidDecision3", "int");
24  this->addSpecification(eSatOverride3, "CR14_SatOverride3", "int");
25  this->addSpecification(ePeakFinderCond, "CR15_PeakFinderCond", "int");
26  this->addSpecification(eDecisionSource, "CR15_DecisionSource", "int");
27 
28  this->addSpecification(eBypassLutCp, "CR00_BypassLutCp", "int");
29  this->addSpecification(eBypassLutJep, "CR00_BypassLutJep", "int");
30  this->addSpecification(eInDataSample, "CR00_InDataSample", "int");
31  this->addSpecification(eReadOut80Active, "CR00_ReadOut80Active", "int");
32  this->addSpecification(eFirCoeff1, "CR04_FirCoeff1", "int");
33  this->addSpecification(eFirCoeff2, "CR04_FirCoeff2", "int");
34  this->addSpecification(eFirCoeff3, "CR05_FirCoeff3", "int");
35  this->addSpecification(eFirCoeff4, "CR06_FirCoeff4", "int");
36  this->addSpecification(eFirCoeff5, "CR06_FirCoeff5", "int");
37  this->addSpecification(eSatHigh, "CR07_SatHigh", "int");
38  this->addSpecification(eSatLow, "CR08_SatLow", "int");
39  this->addSpecification(eSatLevel, "CR09_SatLevel", "int");
40  this->addSpecification(eEnergyLevelLow, "CR10_EnergyLevelLow", "int");
41  this->addSpecification(eEnergyLevelHigh, "CR11_EnergyLevelHigh", "int");
42  this->addSpecification(eStartBit, "CR15_StartBit", "int");
43  this->addSpecification(eSaturationValue, "CR33_SaturationValue", "int");
44  this->addSpecification(eNumBcRaw, "CR16_NumBcRaw", "int");
45  this->addSpecification(eNumBcBcid, "CR16_NumBcBcid", "int");
46  this->addSpecification(ePedCorrEnable, "CR43_PedCorrEnable", "int");
47  // this->addSpecification(eSat80High, "CR52_Sat80High", "int");
48  // this->addSpecification(eSat80Low, "CR53_Sat80Low", "int");
49 }
50 
52  : L1CaloPprChanDefaultsContainer() // delegating constructor
53 {
54  // cppcheck-suppress useInitializationList
55  m_coolFolderKey = folderKey;
56 }
57 
58 
60 {
61  using std::make_unique;
62 
63  if(m_coolFolderKey.empty()) return nullptr;
64 
65  auto* attrSpecification = this->createAttributeListSpecification();
66  if(!attrSpecification || !attrSpecification->size()) return nullptr;
67 
68  auto attrListCollection = make_unique<CondAttrListCollection>(true);
69  for(const auto& item : m_pprChanDefaultss) {
70  AthenaAttributeList attrList(*attrSpecification);
71  attrList[specificationName(eBcidDecision1)].setValue(item.bcidDecision1());
72  attrList[specificationName(eSatOverride1)].setValue(item.satOverride1());
73  attrList[specificationName(eBcidDecision2)].setValue(item.bcidDecision2());
74  attrList[specificationName(eSatOverride2)].setValue(item.satOverride2());
75  attrList[specificationName(eBcidDecision3)].setValue(item.bcidDecision3());
76  attrList[specificationName(eSatOverride3)].setValue(item.satOverride3());
77  attrList[specificationName(ePeakFinderCond)].setValue(item.peakFinderCond());
78  attrList[specificationName(eDecisionSource)].setValue(item.decisionSource());
79  attrList[specificationName(eBypassLutCp)].setValue(item.bypassLutCp());
80  attrList[specificationName(eBypassLutJep)].setValue(item.bypassLutJep());
81  attrList[specificationName(eInDataSample)].setValue(item.inDataSample());
82  attrList[specificationName(eReadOut80Active)].setValue(item.readOut80Active());
83  try {
84  attrList[specificationName(eFirCoeff1)].setValue(item.firCoeff1());
85  attrList[specificationName(eFirCoeff2)].setValue(item.firCoeff2());
86  attrList[specificationName(eFirCoeff3)].setValue(item.firCoeff3());
87  attrList[specificationName(eFirCoeff4)].setValue(item.firCoeff4());
88  attrList[specificationName(eFirCoeff5)].setValue(item.firCoeff5());
89  } catch(...) {
90  // unfortunately the online database uses FIRCoeff and the offline database FirCoeff
91  attrList[specificationName(eFirCoeff1).replace(5, 3, "FIR")].setValue(item.firCoeff1());
92  attrList[specificationName(eFirCoeff2).replace(5, 3, "FIR")].setValue(item.firCoeff2());
93  attrList[specificationName(eFirCoeff3).replace(5, 3, "FIR")].setValue(item.firCoeff3());
94  attrList[specificationName(eFirCoeff4).replace(5, 3, "FIR")].setValue(item.firCoeff4());
95  attrList[specificationName(eFirCoeff5).replace(5, 3, "FIR")].setValue(item.firCoeff5());
96  }
97  attrList[specificationName(eSatHigh)].setValue(item.satHigh());
98  attrList[specificationName(eSatLow)].setValue(item.satLow());
99  attrList[specificationName(eStartBit)].setValue(item.startBit());
100  attrList[specificationName(eEnergyLevelHigh)].setValue(item.energyLevelHigh());
101  attrList[specificationName(eEnergyLevelLow)].setValue(item.energyLevelLow());
102  attrList[specificationName(eSatLevel)].setValue(item.satLevel());
103  attrList[specificationName(eSaturationValue)].setValue(item.saturationValue());
104  attrList[specificationName(eNumBcRaw)].setValue(item.numBcRaw());
105  attrList[specificationName(eNumBcBcid)].setValue(item.numBcBcid());
106  attrList[specificationName(ePedCorrEnable)].setValue(item.pedCorrEnable());
107  // attrList[specificationName(eSat80High)].setValue(item.sat80High());
108  // attrList[specificationName(eSat80Low)].setValue(item.sat80Low());
109 
110  attrListCollection->add(item.channelId(), attrList);
111  }
112  return static_cast<DataObject*>(attrListCollection.release());
113 }
114 
115 void L1CaloPprChanDefaultsContainer::makeTransient(const std::map<std::string, const CondAttrListCollection*>& condAttrListCollectionMap)
116 {
117  clear();
118 
119  // In the case of overlay, we need multiple instances of L1CaloPprChanDefaultsContainer
120  // Take the last element in the map
121  if (condAttrListCollectionMap.empty()) return;
122  auto it = condAttrListCollectionMap.rbegin();
123 
124  auto attrListCollection = it->second;
125  for(const auto& item : *attrListCollection) {
126  auto chanNum = item.first;
127  const auto& attrList = item.second;
128 
129  auto bcidDecision1 = attrList[specificationName(eBcidDecision1)].data<int>();
130  auto satOverride1 = attrList[specificationName(eSatOverride1)].data<int>();
131  auto bcidDecision2 = attrList[specificationName(eBcidDecision2)].data<int>();
132  auto satOverride2 = attrList[specificationName(eSatOverride2)].data<int>();
133  auto bcidDecision3 = attrList[specificationName(eBcidDecision3)].data<int>();
134  auto satOverride3 = attrList[specificationName(eSatOverride3)].data<int>();
135  auto peakFinderCond = attrList[specificationName(ePeakFinderCond)].data<int>();
136  auto decisionSource = attrList[specificationName(eDecisionSource)].data<int>();
137 
138  auto bypassLutCp = attrList[specificationName(eBypassLutCp)].data<int>();
139  auto bypassLutJep = attrList[specificationName(eBypassLutJep)].data<int>();
140  auto inDataSample = attrList[specificationName(eInDataSample)].data<int>();
141  auto readOut80Active = attrList[specificationName(eReadOut80Active)].data<int>();
142  auto satHigh = attrList[specificationName(eSatHigh)].data<int>();
143  auto satLow = attrList[specificationName(eSatLow)].data<int>();
144  auto startBit = attrList[specificationName(eStartBit)].data<int>();
145  auto energyLevelHigh = attrList[specificationName(eEnergyLevelHigh)].data<int>();
146  auto energyLevelLow = attrList[specificationName(eEnergyLevelLow)].data<int>();
147  auto satLevel = attrList[specificationName(eSatLevel)].data<int>();
148  auto saturationValue = attrList[specificationName(eSaturationValue)].data<int>();
149  auto numBcRaw = attrList[specificationName(eNumBcRaw)].data<int>();
150  auto numBcBcid = attrList[specificationName(eNumBcBcid)].data<int>();
151  auto pedCorrEnable = attrList[specificationName(ePedCorrEnable)].data<int>();
152  // auto sat80High = attrList[specificationName(eSat80High)].data<int>();
153  // auto sat80Low = attrList[specificationName(eSat80Low)].data<int>();
154 
155  int firCoeff1, firCoeff2, firCoeff3, firCoeff4, firCoeff5;
156  try {
157  firCoeff1 = attrList[specificationName(eFirCoeff1)].data<int>();
158  firCoeff2 = attrList[specificationName(eFirCoeff2)].data<int>();
159  firCoeff3 = attrList[specificationName(eFirCoeff3)].data<int>();
160  firCoeff4 = attrList[specificationName(eFirCoeff4)].data<int>();
161  firCoeff5 = attrList[specificationName(eFirCoeff5)].data<int>();
162  } catch(...) {
163  // unfortunately the online database uses FIRCoeff and the offline database FirCoeff
164  firCoeff1 = attrList[specificationName(eFirCoeff1).replace(5, 3, "FIR")].data<int>();
165  firCoeff2 = attrList[specificationName(eFirCoeff2).replace(5, 3, "FIR")].data<int>();
166  firCoeff3 = attrList[specificationName(eFirCoeff3).replace(5, 3, "FIR")].data<int>();
167  firCoeff4 = attrList[specificationName(eFirCoeff4).replace(5, 3, "FIR")].data<int>();
168  firCoeff5 = attrList[specificationName(eFirCoeff5).replace(5, 3, "FIR")].data<int>();
169  }
170 
171  addPprChanDefaults(L1CaloPprChanDefaults(chanNum, bcidDecision1, satOverride1, bcidDecision2, satOverride2, bcidDecision3, satOverride3, peakFinderCond, decisionSource, bypassLutCp, bypassLutJep, inDataSample, readOut80Active, firCoeff1, firCoeff2, firCoeff3, firCoeff4, firCoeff5, satHigh, satLow, startBit, energyLevelHigh, energyLevelLow, satLevel, saturationValue, numBcRaw, numBcBcid, pedCorrEnable /*, sat80High, sat80Low */ ));
172  }
173 }
174 
176 {
177  auto it = std::lower_bound(std::begin(m_pprChanDefaultss),
179  channelId,
180  [](const L1CaloPprChanDefaults& el, unsigned int val) -> bool {
181  return el.channelId() < val;
182  });
183  if(it == std::end(m_pprChanDefaultss)) return nullptr;
184  return &(*it);
185 }
186 
188 {
189  // insert into the correct position mainting the sorted vector
190  m_pprChanDefaultss.insert(std::lower_bound(std::begin(m_pprChanDefaultss),
193  [](const L1CaloPprChanDefaults& el, unsigned int va) -> bool {
194  return el.channelId() < va;
195  }),
197 }
L1CaloPprChanDefaultsContainer::eDecisionSource
@ eDecisionSource
Definition: L1CaloPprChanDefaultsContainer.h:37
L1CaloPprChanDefaults::channelId
unsigned int channelId() const
Definition: L1CaloPprChanDefaults.h:22
L1CaloPprChanDefaultsContainer::eEnergyLevelLow
@ eEnergyLevelLow
Definition: L1CaloPprChanDefaultsContainer.h:37
CondAttrListCollection.h
This file defines the class for a collection of AttributeLists where each one is associated with a ch...
L1CaloPprChanDefaultsContainer::eBcidDecision1
@ eBcidDecision1
Definition: L1CaloPprChanDefaultsContainer.h:37
L1CaloPprChanDefaultsContainer::eSatOverride2
@ eSatOverride2
Definition: L1CaloPprChanDefaultsContainer.h:37
make_unique
std::unique_ptr< T > make_unique(Args &&... args)
Definition: SkimmingToolEXOT5.cxx:23
L1CaloPprChanDefaultsContainer::eNumBcBcid
@ eNumBcBcid
Definition: L1CaloPprChanDefaultsContainer.h:37
PlotCalibFromCool.begin
begin
Definition: PlotCalibFromCool.py:94
skel.it
it
Definition: skel.GENtoEVGEN.py:396
AbstractL1CaloPersistentCondition::addSpecification
void addSpecification(int specId, const std::string &specName, const std::string &specType)
Definition: AbstractL1CaloPersistentCondition.cxx:26
L1CaloPprChanDefaultsContainer
Definition: L1CaloPprChanDefaultsContainer.h:27
L1CaloPprChanDefaultsContainer::eFirCoeff5
@ eFirCoeff5
Definition: L1CaloPprChanDefaultsContainer.h:37
L1CaloPprChanDefaultsContainer::eStartBit
@ eStartBit
Definition: L1CaloPprChanDefaultsContainer.h:37
L1CaloPprChanDefaultsContainer::eFirCoeff2
@ eFirCoeff2
Definition: L1CaloPprChanDefaultsContainer.h:37
AthenaAttributeList.h
L1CaloPprChanDefaultsContainer::ePedCorrEnable
@ ePedCorrEnable
Definition: L1CaloPprChanDefaultsContainer.h:37
AbstractL1CaloPersistentCondition::createAttributeListSpecification
coral::AttributeListSpecification * createAttributeListSpecification() const
Definition: AbstractL1CaloPersistentCondition.cxx:31
mergePhysValFiles.end
end
Definition: DataQuality/DataQualityUtils/scripts/mergePhysValFiles.py:93
L1CaloPprChanDefaultsContainer::eReadOut80Active
@ eReadOut80Active
Definition: L1CaloPprChanDefaultsContainer.h:37
L1CaloPprChanDefaultsContainer::eBcidDecision3
@ eBcidDecision3
Definition: L1CaloPprChanDefaultsContainer.h:37
L1CaloPprChanDefaultsContainer::ePeakFinderCond
@ ePeakFinderCond
Definition: L1CaloPprChanDefaultsContainer.h:37
L1CaloPprChanDefaultsContainer::addPprChanDefaults
void addPprChanDefaults(const L1CaloPprChanDefaults &pprChanDefaults)
Definition: L1CaloPprChanDefaultsContainer.cxx:187
checkCoolLatestUpdate.chanNum
chanNum
Definition: checkCoolLatestUpdate.py:27
L1CaloPprChanDefaultsContainer::eBypassLutJep
@ eBypassLutJep
Definition: L1CaloPprChanDefaultsContainer.h:37
L1CaloPprChanDefaultsContainer::eSatLevel
@ eSatLevel
Definition: L1CaloPprChanDefaultsContainer.h:37
L1CaloPprChanDefaultsContainer::eFirCoeff3
@ eFirCoeff3
Definition: L1CaloPprChanDefaultsContainer.h:37
plotIsoValidation.el
el
Definition: plotIsoValidation.py:197
AthenaAttributeList
An AttributeList represents a logical row of attributes in a metadata table. The name and type of eac...
Definition: PersistentDataModel/PersistentDataModel/AthenaAttributeList.h:45
L1CaloPprChanDefaultsContainer::eNumBcRaw
@ eNumBcRaw
Definition: L1CaloPprChanDefaultsContainer.h:37
L1CaloPprChanDefaultsContainer::eSatOverride1
@ eSatOverride1
Definition: L1CaloPprChanDefaultsContainer.h:37
CaloCondBlobAlgs_fillNoiseFromASCII.channelId
channelId
Definition: CaloCondBlobAlgs_fillNoiseFromASCII.py:122
L1CaloPprChanDefaults.h
L1CaloPprChanDefaultsContainer::eFirCoeff1
@ eFirCoeff1
Definition: L1CaloPprChanDefaultsContainer.h:37
L1CaloPprChanDefaultsContainer::makePersistent
virtual DataObject * makePersistent() const
Definition: L1CaloPprChanDefaultsContainer.cxx:59
item
Definition: ItemListSvc.h:43
AbstractL1CaloPersistentCondition::specificationName
std::string specificationName(int specId) const
Definition: AbstractL1CaloPersistentCondition.cxx:44
L1CaloPprChanDefaultsContainer::clear
virtual void clear()
Definition: L1CaloPprChanDefaultsContainer.h:46
L1CaloPprChanDefaultsContainer::makeTransient
virtual void makeTransient(const std::map< std::string, const CondAttrListCollection * > &)
Definition: L1CaloPprChanDefaultsContainer.cxx:115
L1CaloPprChanDefaultsContainer::pprChanDefaults
const L1CaloPprChanDefaults * pprChanDefaults(unsigned int channelId) const
Definition: L1CaloPprChanDefaultsContainer.cxx:175
L1CaloPprChanDefaultsContainer::eSatOverride3
@ eSatOverride3
Definition: L1CaloPprChanDefaultsContainer.h:37
Pythia8_RapidityOrderMPI.val
val
Definition: Pythia8_RapidityOrderMPI.py:14
L1CaloPprChanDefaultsContainer::eSatHigh
@ eSatHigh
Definition: L1CaloPprChanDefaultsContainer.h:37
L1CaloPprChanDefaultsContainer::eInDataSample
@ eInDataSample
Definition: L1CaloPprChanDefaultsContainer.h:37
L1CaloPprChanDefaultsContainer::eSaturationValue
@ eSaturationValue
Definition: L1CaloPprChanDefaultsContainer.h:37
L1CaloPprChanDefaultsContainer::L1CaloPprChanDefaultsContainer
L1CaloPprChanDefaultsContainer()
Definition: L1CaloPprChanDefaultsContainer.cxx:16
L1CaloPprChanDefaultsContainer::eBcidDecision2
@ eBcidDecision2
Definition: L1CaloPprChanDefaultsContainer.h:37
L1CaloPprChanDefaultsContainer::eEnergyLevelHigh
@ eEnergyLevelHigh
Definition: L1CaloPprChanDefaultsContainer.h:37
L1CaloPprChanDefaultsContainer::eBypassLutCp
@ eBypassLutCp
Definition: L1CaloPprChanDefaultsContainer.h:37
L1CaloPprChanDefaults
Folder <-> Object mapping for /TRIGGER/L1Calo/V2/Configuration/PprChanDefaults .
Definition: L1CaloPprChanDefaults.h:17
L1CaloPprChanDefaultsContainer::m_coolFolderKey
std::string m_coolFolderKey
Definition: L1CaloPprChanDefaultsContainer.h:67
L1CaloPprChanDefaultsContainer::m_pprChanDefaultss
std::vector< L1CaloPprChanDefaults > m_pprChanDefaultss
Definition: L1CaloPprChanDefaultsContainer.h:66
AbstractL1CaloPersistentCondition
AbstractL1CaloConditionContainer abstract base class for L1Calo persistent conditions container objec...
Definition: AbstractL1CaloPersistentCondition.h:22
L1CaloPprChanDefaultsContainer::eFirCoeff4
@ eFirCoeff4
Definition: L1CaloPprChanDefaultsContainer.h:37
L1CaloPprChanDefaultsContainer.h
L1CaloPprChanDefaultsContainer::eSatLow
@ eSatLow
Definition: L1CaloPprChanDefaultsContainer.h:37