ATLAS Offline Software
Loading...
Searching...
No Matches
L1CaloDisabledTowersContainer.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2022 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(edisabledBits, "disabledBits", "unsigned int");
20}
21
23 : L1CaloDisabledTowersContainer() // delegating constructor
24{
25 // cppcheck-suppress useInitializationList
26 m_coolFolderKey = folderKey;
27}
28
29
31{
32 using std::make_unique;
33
34 if(m_coolFolderKey.empty()) return nullptr;
35
36 auto* attrSpecification = this->createAttributeListSpecification();
37 if(!attrSpecification || !attrSpecification->size()) return nullptr;
38
39 auto attrListCollection = make_unique<CondAttrListCollection>(true);
40 for(const auto& item : m_disabledTowerss) {
41 AthenaAttributeList attrList(*attrSpecification);
42 attrList[specificationName(edisabledBits)].setValue(item.disabledBits());
43
44 attrListCollection->add(item.channelId(), attrList);
45 }
46 return static_cast<DataObject*>(attrListCollection.release());
47}
48
49void L1CaloDisabledTowersContainer::makeTransient(const std::map<std::string, const CondAttrListCollection*>& condAttrListCollectionMap)
50{
51 clear();
52
53 // In the case of overlay, we need multiple instances of L1CaloPprChanDefaultsContainer
54 // Take the last element in the map
55 if (condAttrListCollectionMap.empty()) return;
56 auto it = condAttrListCollectionMap.rbegin();
57
58 auto attrListCollection = it->second;
59 for(const auto& item : *attrListCollection) {
60 auto chanNum = item.first;
61 const auto& attrList = item.second;
62
63 auto disabledBits = attrList[specificationName(edisabledBits)].data<unsigned int>();
64
65 addDisabledTowers(L1CaloDisabledTowers(chanNum, disabledBits));
66 }
67}
68
70{
71 auto it = std::lower_bound(std::begin(m_disabledTowerss),
72 std::end(m_disabledTowerss),
73 channelId,
74 [](const L1CaloDisabledTowers& el, unsigned int val) -> bool {
75 return el.channelId() < val;
76 });
77 if(it == std::end(m_disabledTowerss)) return nullptr;
78 return &(*it);
79}
80
82{
83 // insert into the correct position mainting the sorted vector
84 m_disabledTowerss.insert(std::lower_bound(std::begin(m_disabledTowerss),
85 std::end(m_disabledTowerss),
86 disabledTowers.channelId(),
87 [](const L1CaloDisabledTowers& el, unsigned int va) -> bool {
88 return el.channelId() < va;
89 }),
91}
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.
const L1CaloDisabledTowers * disabledTowers(unsigned int channelId) const
virtual DataObject * makePersistent() const
std::vector< L1CaloDisabledTowers > m_disabledTowerss
virtual void makeTransient(const std::map< std::string, const CondAttrListCollection * > &)
void addDisabledTowers(const L1CaloDisabledTowers &disabledTowers)
Folder <-> Object mapping for /TRIGGER/L1Calo/V1/Conditions/DisabledTowers .