ATLAS Offline Software
Loading...
Searching...
No Matches
L1CaloRxLayersContainer.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3*/
4
6
7#include "CoralBase/AttributeListSpecification.h"
10
11#include <string>
12#include <iostream>
13
15 // Define DB rows names and types in order to construct the AttributeListSpecification object
16 this->addSpecification(eNLayers, std::string("NLayers"), std::string("unsigned char"));
17 this->addSpecification(eName1, std::string("Name1"), std::string("unsigned char"));
18 this->addSpecification(eName2, std::string("Name2"), std::string("unsigned char"));
19 this->addSpecification(eName3, std::string("Name3"), std::string("unsigned char"));
20 this->addSpecification(eName4, std::string("Name4"), std::string("unsigned char"));
21 this->addSpecification(eNCells1, std::string("NCells1"), std::string("unsigned char"));
22 this->addSpecification(eNCells2, std::string("NCells2"), std::string("unsigned char"));
23 this->addSpecification(eNCells3, std::string("NCells3"), std::string("unsigned char"));
24 this->addSpecification(eNCells4, std::string("NCells4"), std::string("unsigned char"));
25
26 m_mCoolFoldersKeysMap[L1CaloRxLayersContainer::eRxLayers] = std::string("/TRIGGER/L1Calo/V1/Results/RxLayers");
27}
28
29L1CaloRxLayersContainer::L1CaloRxLayersContainer(const std::map<L1CaloRxLayersContainer::eCoolFolders, std::string>& folderKeysMap) :
30 AbstractL1CaloPersistentCondition("CondAttrListCollection"),
31 m_mCoolFoldersKeysMap(folderKeysMap)
32{
33 // Define DB rows names and types in order to construct the AttributeListSpecification object
34 this->addSpecification(eNLayers, std::string("NLayers"), std::string("unsigned char"));
35 this->addSpecification(eName1, std::string("Name1"), std::string("unsigned char"));
36 this->addSpecification(eName2, std::string("Name2"), std::string("unsigned char"));
37 this->addSpecification(eName3, std::string("Name3"), std::string("unsigned char"));
38 this->addSpecification(eName4, std::string("Name4"), std::string("unsigned char"));
39 this->addSpecification(eNCells1, std::string("NCells1"), std::string("unsigned char"));
40 this->addSpecification(eNCells2, std::string("NCells2"), std::string("unsigned char"));
41 this->addSpecification(eNCells3, std::string("NCells3"), std::string("unsigned char"));
42 this->addSpecification(eNCells4, std::string("NCells4"), std::string("unsigned char"));
43}
44
46
47 std::map<L1CaloRxLayersContainer::eCoolFolders, std::string>::const_iterator it = m_mCoolFoldersKeysMap.find(efolder);
48 if(it!=m_mCoolFoldersKeysMap.end()) {
49 return it->second;
50 } else {
51 return std::string("");
52 }
53}
54
55std::vector<std::string> L1CaloRxLayersContainer::coolInputKeys() const {
56 std::vector<std::string> v;
58 return v;
59}
60
64
66 if(m_mRxLayersMap.size()==0) return 0;
67
68 // Create AttributeListSpecification according to the attributes to be recorded
69 // this is required to create the AttributeList objs
70 coral::AttributeListSpecification* attrSpecification = this->createAttributeListSpecification();
71 if(!attrSpecification->size()) return NULL;
72
73 CondAttrListCollection* attrListCollection = new CondAttrListCollection(true);
74
75 L1CaloRxLayersMap::const_iterator pos = m_mRxLayersMap.begin();
76 L1CaloRxLayersMap::const_iterator end = m_mRxLayersMap.end();
77 for(; pos!=end; ++pos) {
78 const unsigned int channelId = pos->first;
79 const L1CaloRxLayers& p = pos->second;
80 const std::vector<int>& names(p.names());
81 const std::vector<int>& ncells(p.ncells());
82 const unsigned char nlayers = names.size();
83 const unsigned char name1 = (nlayers > 0) ? names[0] : 0;
84 const unsigned char name2 = (nlayers > 1) ? names[1] : 0;
85 const unsigned char name3 = (nlayers > 2) ? names[2] : 0;
86 const unsigned char name4 = (nlayers > 3) ? names[3] : 0;
87 const unsigned char ncells1 = (nlayers > 0) ? ncells[0] : 0;
88 const unsigned char ncells2 = (nlayers > 1) ? ncells[1] : 0;
89 const unsigned char ncells3 = (nlayers > 2) ? ncells[2] : 0;
90 const unsigned char ncells4 = (nlayers > 3) ? ncells[3] : 0;
91
92 AthenaAttributeList attrList(*attrSpecification);
93
94 // Set value of each row for the current channel
95 attrList[ this->specificationName(eNLayers) ].setValue(nlayers);
96 attrList[ this->specificationName(eName1) ].setValue(name1);
97 attrList[ this->specificationName(eName2) ].setValue(name2);
98 attrList[ this->specificationName(eName3) ].setValue(name3);
99 attrList[ this->specificationName(eName4) ].setValue(name4);
100 attrList[ this->specificationName(eNCells1) ].setValue(ncells1);
101 attrList[ this->specificationName(eNCells2) ].setValue(ncells2);
102 attrList[ this->specificationName(eNCells3) ].setValue(ncells3);
103 attrList[ this->specificationName(eNCells4) ].setValue(ncells4);
104
105 attrListCollection->add(channelId, attrList);
106 }
107
108 return attrListCollection;
109}
110
111void L1CaloRxLayersContainer::makeTransient(const std::map<std::string, const CondAttrListCollection*>& condAttrListCollectionMap) {
112
113 this->clear();
114
115 std::map<std::string, const CondAttrListCollection*>::const_iterator
116 it_map(condAttrListCollectionMap.find(this->coolFolderKey(L1CaloRxLayersContainer::eRxLayers)));
117
118 if(it_map!=condAttrListCollectionMap.end()) {
119
120 const CondAttrListCollection* attrListCollection = it_map->second;
121
122 //loop over CondAttrListCollection
123 CondAttrListCollection::const_iterator pos = attrListCollection->begin();
124 CondAttrListCollection::const_iterator end = attrListCollection->end();
125 for(; pos!= end; ++pos) {
126
127 const coral::AttributeList& attrList = pos->second;
128
129 // Get value of each row for the current channel
130 CondAttrListCollection::ChanNum chanNum(pos->first);
131
132 unsigned char nlayers = attrList[ this->specificationName(eNLayers) ].data<unsigned char>();
133 std::vector<int> names;
134 std::vector<int> ncells;
135 if (nlayers > 0) {
136 names.push_back((int)attrList[ this->specificationName(eName1) ].data<unsigned char>());
137 ncells.push_back((int)attrList[ this->specificationName(eNCells1) ].data<unsigned char>());
138 }
139 if (nlayers > 1) {
140 names.push_back((int)attrList[ this->specificationName(eName2) ].data<unsigned char>());
141 ncells.push_back((int)attrList[ this->specificationName(eNCells2) ].data<unsigned char>());
142 }
143 if (nlayers > 2) {
144 names.push_back((int)attrList[ this->specificationName(eName3) ].data<unsigned char>());
145 ncells.push_back((int)attrList[ this->specificationName(eNCells3) ].data<unsigned char>());
146 }
147 if (nlayers > 3) {
148 names.push_back((int)attrList[ this->specificationName(eName4) ].data<unsigned char>());
149 ncells.push_back((int)attrList[ this->specificationName(eNCells4) ].data<unsigned char>());
150 }
151
152 L1CaloRxLayers l1CaloRxLayers(chanNum, std::move(names), std::move(ncells));
153 m_mRxLayersMap[chanNum] = std::move(l1CaloRxLayers);
154 }
155 } else {
156 std::cout << "L1CaloRxLayersContainer : Could not find requested CondAttrListCollection "
158 }
159}
160
161const L1CaloRxLayers* L1CaloRxLayersContainer::rxLayers(unsigned int channelId) const {
162 L1CaloRxLayersMap::const_iterator pos = m_mRxLayersMap.find(channelId);
163 if(pos==m_mRxLayersMap.end()) return 0;
164 else return &(pos->second);
165}
166
168 return this->rxLayers(channelId.id());
169}
170
172 m_mRxLayersMap[channelId] = std::move(rxLayers);
173}
174
176 this->addRxLayers(channelId.id(), std::move(rxLayers));
177}
178
This file defines the class for a collection of AttributeLists where each one is associated with a ch...
char data[hepevt_bytes_allocation_ATLAS]
Definition HepEvt.cxx:11
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.
This class is a collection of AttributeLists where each one is associated with a channel number.
const_iterator end() const
bool add(ChanNum chanNum, const AttributeList &attributeList)
Adding in chan/attrList pairs.
const_iterator begin() const
Access to Chan/AttributeList pairs via iterators.
ChanAttrListMap::const_iterator const_iterator
Encapsulates the ID of one Rx channel of conditions data in COOL, ie the ID of a row in a table.
unsigned int id() const
const L1CaloRxLayers * rxLayers(unsigned int channelId) const
std::string coolFolderKey(L1CaloRxLayersContainer::eCoolFolders efolder) const
void addRxLayers(unsigned int channelId, L1CaloRxLayers &&rxLayers)
std::map< L1CaloRxLayersContainer::eCoolFolders, std::string > m_mCoolFoldersKeysMap
virtual std::vector< std::string > coolInputKeys() const
virtual void makeTransient(const std::map< std::string, const CondAttrListCollection * > &condAttrListCollectionMap)
virtual std::string coolOutputKey() const
virtual DataObject * makePersistent() const
Class that holds information about calo layers that make up receivers.