ATLAS Offline Software
L1CaloPpmDeadChannelsContainer.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(eErrorCode, "ErrorCode", "unsigned int");
20  this->addSpecification(eNoiseCut, "NoiseCut", "unsigned int");
21 }
22 
24  : L1CaloPpmDeadChannelsContainer() // delegating constructor
25 {
26  // cppcheck-suppress useInitializationList
27  m_coolFolderKey = folderKey;
28 }
29 
30 
32 {
33  using std::make_unique;
34 
35  if(m_coolFolderKey.empty()) return nullptr;
36 
37  auto* attrSpecification = this->createAttributeListSpecification();
38  if(!attrSpecification || !attrSpecification->size()) return nullptr;
39 
40  auto attrListCollection = make_unique<CondAttrListCollection>(true);
41  for(const auto& item : m_ppmDeadChannelss) {
42  AthenaAttributeList attrList(*attrSpecification);
43  attrList[specificationName(eErrorCode)].setValue(item.errorCode());
44  attrList[specificationName(eNoiseCut)].setValue(item.noiseCut());
45 
46  attrListCollection->add(item.channelId(), attrList);
47  }
48  return static_cast<DataObject*>(attrListCollection.release());
49 }
50 
51 void L1CaloPpmDeadChannelsContainer::makeTransient(const std::map<std::string, const CondAttrListCollection*>& condAttrListCollectionMap)
52 {
53  clear();
54 
55  // In the case of overlay, we need multiple instances of L1CaloPpmDeadChannelsContainer
56  // Take the last element in the map
57  if (condAttrListCollectionMap.empty()) return;
58  auto it = condAttrListCollectionMap.rbegin();
59 
60  auto attrListCollection = it->second;
61  for(const auto& item : *attrListCollection) {
62  auto chanNum = item.first;
63  const auto& attrList = item.second;
64 
65  auto errorCode = attrList[specificationName(eErrorCode)].data<unsigned int>();
66  auto noiseCut = attrList[specificationName(eNoiseCut)].data<unsigned int>();
67 
68  addPpmDeadChannels(L1CaloPpmDeadChannels(chanNum, errorCode, noiseCut));
69  }
70 }
71 
73 {
74  auto it = std::lower_bound(std::begin(m_ppmDeadChannelss),
76  channelId,
77  [](const L1CaloPpmDeadChannels& el, unsigned int val) -> bool {
78  return el.channelId() < val;
79  });
80  if(it == std::end(m_ppmDeadChannelss)) return nullptr;
81  return &(*it);
82 }
83 
85 {
86  // insert into the correct position mainting the sorted vector
87  m_ppmDeadChannelss.insert(std::lower_bound(std::begin(m_ppmDeadChannelss),
90  [](const L1CaloPpmDeadChannels& el, unsigned int va) -> bool {
91  return el.channelId() < va;
92  }),
94 }
L1CaloPpmDeadChannels
Folder <-> Object mapping for /TRIGGER/L1Calo/V1/Calibration/PpmDeadChannels .
Definition: L1CaloPpmDeadChannels.h:17
L1CaloPpmDeadChannelsContainer::m_coolFolderKey
std::string m_coolFolderKey
Definition: L1CaloPpmDeadChannelsContainer.h:62
CondAttrListCollection.h
This file defines the class for a collection of AttributeLists where each one is associated with a ch...
make_unique
std::unique_ptr< T > make_unique(Args &&... args)
Definition: SkimmingToolEXOT5.cxx:23
PlotCalibFromCool.begin
begin
Definition: PlotCalibFromCool.py:94
L1CaloPpmDeadChannelsContainer::eErrorCode
@ eErrorCode
Definition: L1CaloPpmDeadChannelsContainer.h:37
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
L1CaloPpmDeadChannelsContainer::m_ppmDeadChannelss
std::vector< L1CaloPpmDeadChannels > m_ppmDeadChannelss
Definition: L1CaloPpmDeadChannelsContainer.h:61
AthenaAttributeList.h
AbstractL1CaloPersistentCondition::createAttributeListSpecification
coral::AttributeListSpecification * createAttributeListSpecification() const
Definition: AbstractL1CaloPersistentCondition.cxx:31
mergePhysValFiles.end
end
Definition: DataQuality/DataQualityUtils/scripts/mergePhysValFiles.py:93
checkCoolLatestUpdate.chanNum
chanNum
Definition: checkCoolLatestUpdate.py:27
L1CaloPpmDeadChannelsContainer::ppmDeadChannels
const L1CaloPpmDeadChannels * ppmDeadChannels(unsigned int channelId) const
Definition: L1CaloPpmDeadChannelsContainer.cxx:72
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
L1CaloPpmDeadChannelsContainer::makePersistent
virtual DataObject * makePersistent() const
Definition: L1CaloPpmDeadChannelsContainer.cxx:31
L1CaloPpmDeadChannelsContainer::eNoiseCut
@ eNoiseCut
Definition: L1CaloPpmDeadChannelsContainer.h:37
L1CaloPpmDeadChannelsContainer::makeTransient
virtual void makeTransient(const std::map< std::string, const CondAttrListCollection * > &)
Definition: L1CaloPpmDeadChannelsContainer.cxx:51
CaloCondBlobAlgs_fillNoiseFromASCII.channelId
channelId
Definition: CaloCondBlobAlgs_fillNoiseFromASCII.py:122
item
Definition: ItemListSvc.h:43
AbstractL1CaloPersistentCondition::specificationName
std::string specificationName(int specId) const
Definition: AbstractL1CaloPersistentCondition.cxx:44
L1CaloPpmDeadChannelsContainer
Definition: L1CaloPpmDeadChannelsContainer.h:27
L1CaloPpmDeadChannelsContainer.h
Pythia8_RapidityOrderMPI.val
val
Definition: Pythia8_RapidityOrderMPI.py:14
L1CaloPpmDeadChannels.h
L1CaloPpmDeadChannelsContainer::L1CaloPpmDeadChannelsContainer
L1CaloPpmDeadChannelsContainer()
Definition: L1CaloPpmDeadChannelsContainer.cxx:16
L1CaloPpmDeadChannelsContainer::addPpmDeadChannels
void addPpmDeadChannels(const L1CaloPpmDeadChannels &ppmDeadChannels)
Definition: L1CaloPpmDeadChannelsContainer.cxx:84
L1CaloPpmDeadChannels::channelId
unsigned int channelId() const
Definition: L1CaloPpmDeadChannels.h:22
L1CaloPpmDeadChannelsContainer::clear
virtual void clear()
Definition: L1CaloPpmDeadChannelsContainer.h:45
AbstractL1CaloPersistentCondition
AbstractL1CaloConditionContainer abstract base class for L1Calo persistent conditions container objec...
Definition: AbstractL1CaloPersistentCondition.h:22