ATLAS Offline Software
Loading...
Searching...
No Matches
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
51void 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),
75 std::end(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),
88 std::end(m_ppmDeadChannelss),
89 ppmDeadChannels.channelId(),
90 [](const L1CaloPpmDeadChannels& el, unsigned int va) -> bool {
91 return el.channelId() < va;
92 }),
94}
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.
std::vector< L1CaloPpmDeadChannels > m_ppmDeadChannelss
const L1CaloPpmDeadChannels * ppmDeadChannels(unsigned int channelId) const
virtual void makeTransient(const std::map< std::string, const CondAttrListCollection * > &)
void addPpmDeadChannels(const L1CaloPpmDeadChannels &ppmDeadChannels)
Folder <-> Object mapping for /TRIGGER/L1Calo/V1/Calibration/PpmDeadChannels .