ATLAS Offline Software
Loading...
Searching...
No Matches
L1CaloPprChanStrategyContainer.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3*/
5
6#include <algorithm>
7#include <memory>
8
9#include "CoralBase/AttributeListSpecification.h"
12
13//#include "TrigT1CaloCalibConditions/L1CaloPprChanStrategy.h"
14
16 : AbstractL1CaloPersistentCondition("CondAttrListCollection")
17{
18 this->addSpecification(eStrategy, "Strategy", "string");
19 this->addSpecification(eCode, "Code", "unsigned int");
20 this->addSpecification(eTimingRegime, "TimingRegime", "string");
21 this->addSpecification(eDescription, "Description", "string");
22}
23
25 : L1CaloPprChanStrategyContainer() // delegating constructor
26{
27 // cppcheck-suppress useInitializationList
28 m_coolFolderKey = folderKey;
29}
30
31
33{
34 using std::make_unique;
35
36 if(m_coolFolderKey.empty()) return nullptr;
37
38 auto* attrSpecification = this->createAttributeListSpecification();
39 if(!attrSpecification || !attrSpecification->size()) return nullptr;
40
41 auto attrListCollection = make_unique<CondAttrListCollection>(true);
42 for(const auto& item : m_pprChanStrategys) {
43 AthenaAttributeList attrList(*attrSpecification);
44 attrList[specificationName(eStrategy)].setValue(item.strategy());
45 attrList[specificationName(eCode)].setValue(item.code());
46 attrList[specificationName(eTimingRegime)].setValue(item.timingRegime());
47 attrList[specificationName(eDescription)].setValue(item.description());
48
49 attrListCollection->add(item.channelId(), attrList);
50 }
51 return static_cast<DataObject*>(attrListCollection.release());
52}
53
54void L1CaloPprChanStrategyContainer::makeTransient(const std::map<std::string, const CondAttrListCollection*>& condAttrListCollectionMap)
55{
56 clear();
57
58 auto it = condAttrListCollectionMap.find(m_coolFolderKey);
59 if(it == std::end(condAttrListCollectionMap)) return;
60
61 auto attrListCollection = it->second;
62 for(const auto& item : *attrListCollection) {
63 auto chanNum = item.first;
64 const auto& attrList = item.second;
65
66 const auto & strategy = attrList[specificationName(eStrategy)].data<std::string>();
67 auto code = attrList[specificationName(eCode)].data<unsigned int>();
68 const auto & timingRegime = attrList[specificationName(eTimingRegime)].data<std::string>();
69 const auto & description = attrList[specificationName(eDescription)].data<std::string>();
70
71 addPprChanStrategy(L1CaloPprChanStrategy(chanNum, strategy, code, timingRegime, description));
72 }
73}
74
76{
77 auto it = std::lower_bound(std::begin(m_pprChanStrategys),
78 std::end(m_pprChanStrategys),
79 channelId,
80 [](const L1CaloPprChanStrategy& el, unsigned int val) -> bool {
81 return el.channelId() < val;
82 });
83 if(it == std::end(m_pprChanStrategys)) return nullptr;
84 return &(*it);
85}
86
88{
89 // insert into the correct position mainting the sorted vector
90 m_pprChanStrategys.insert(std::lower_bound(std::begin(m_pprChanStrategys),
91 std::end(m_pprChanStrategys),
92 pprChanStrategy.channelId(),
93 [](const L1CaloPprChanStrategy& el, unsigned int va) -> bool {
94 return el.channelId() < va;
95 }),
97}
98
101 for(;it!=this->end();++it) {
102 std::cout << " * item: " << *it <<std::endl;
103 }
104}
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.
void addPprChanStrategy(const L1CaloPprChanStrategy &pprChanStrategy)
std::vector< L1CaloPprChanStrategy >::const_iterator const_iterator
const L1CaloPprChanStrategy * pprChanStrategy(unsigned int channelId) const
std::vector< L1CaloPprChanStrategy > m_pprChanStrategys
virtual void makeTransient(const std::map< std::string, const CondAttrListCollection * > &)
Folder <-> Object mapping for /TRIGGER/L1Calo/V2/Configuration/PprChanStrategy .
std::string description
glabal timer - how long have I taken so far?
Definition hcg.cxx:91