ATLAS Offline Software
Loading...
Searching...
No Matches
L1CaloHVCorrectionsContainer.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(eRxMean, std::string("RxMean"), std::string("float"));
17 this->addSpecification(eAffectedCells1, std::string("AffectedCells1"), std::string("unsigned char"));
18 this->addSpecification(eAffectedCells2, std::string("AffectedCells2"), std::string("unsigned char"));
19 this->addSpecification(eAffectedCells3, std::string("AffectedCells3"), std::string("unsigned char"));
20 this->addSpecification(eAffectedCells4, std::string("AffectedCells4"), std::string("unsigned char"));
21 this->addSpecification(eLayerMean1, std::string("LayerMean1"), std::string("float"));
22 this->addSpecification(eLayerMean2, std::string("LayerMean2"), std::string("float"));
23 this->addSpecification(eLayerMean3, std::string("LayerMean3"), std::string("float"));
24 this->addSpecification(eLayerMean4, std::string("LayerMean4"), std::string("float"));
25
26 m_mCoolFoldersKeysMap[L1CaloHVCorrectionsContainer::eHVCorrections] = std::string("/TRIGGER/L1Calo/V1/Results/HVCorrections");
27}
28
29L1CaloHVCorrectionsContainer::L1CaloHVCorrectionsContainer(const std::map<L1CaloHVCorrectionsContainer::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(eRxMean, std::string("RxMean"), std::string("float"));
35 this->addSpecification(eAffectedCells1, std::string("AffectedCells1"), std::string("unsigned char"));
36 this->addSpecification(eAffectedCells2, std::string("AffectedCells2"), std::string("unsigned char"));
37 this->addSpecification(eAffectedCells3, std::string("AffectedCells3"), std::string("unsigned char"));
38 this->addSpecification(eAffectedCells4, std::string("AffectedCells4"), std::string("unsigned char"));
39 this->addSpecification(eLayerMean1, std::string("LayerMean1"), std::string("float"));
40 this->addSpecification(eLayerMean2, std::string("LayerMean2"), std::string("float"));
41 this->addSpecification(eLayerMean3, std::string("LayerMean3"), std::string("float"));
42 this->addSpecification(eLayerMean4, std::string("LayerMean4"), std::string("float"));
43}
44
46
47 std::map<L1CaloHVCorrectionsContainer::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> L1CaloHVCorrectionsContainer::coolInputKeys() const {
56 std::vector<std::string> v;
58 return v;
59}
60
64
66 if(m_mHVCorrectionsMap.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 L1CaloHVCorrectionsMap::const_iterator pos = m_mHVCorrectionsMap.begin();
76 L1CaloHVCorrectionsMap::const_iterator end = m_mHVCorrectionsMap.end();
77 for(; pos!=end; ++pos) {
78 const unsigned int channelId = pos->first;
79 const L1CaloHVCorrections& p = pos->second;
80 const std::vector<int>& affectedCells(p.affectedCells());
81 const std::vector<float>& layerMeans(p.layerMeans());
82 const unsigned char nlayers = affectedCells.size();
83 const unsigned char affectedCells1 = (nlayers > 0) ? affectedCells[0] : 0;
84 const unsigned char affectedCells2 = (nlayers > 1) ? affectedCells[1] : 0;
85 const unsigned char affectedCells3 = (nlayers > 2) ? affectedCells[2] : 0;
86 const unsigned char affectedCells4 = (nlayers > 3) ? affectedCells[3] : 0;
87 const float layerMean1 = (nlayers > 0) ? layerMeans[0] : 0.;
88 const float layerMean2 = (nlayers > 1) ? layerMeans[1] : 0.;
89 const float layerMean3 = (nlayers > 2) ? layerMeans[2] : 0.;
90 const float layerMean4 = (nlayers > 3) ? layerMeans[3] : 0.;
91
92 AthenaAttributeList attrList(*attrSpecification);
93
94 // Set value of each row for the current channel
95 attrList[ this->specificationName(eRxMean) ].setValue(p.rxMean());
96 attrList[ this->specificationName(eAffectedCells1) ].setValue(affectedCells1);
97 attrList[ this->specificationName(eAffectedCells2) ].setValue(affectedCells2);
98 attrList[ this->specificationName(eAffectedCells3) ].setValue(affectedCells3);
99 attrList[ this->specificationName(eAffectedCells4) ].setValue(affectedCells4);
100 attrList[ this->specificationName(eLayerMean1) ].setValue(layerMean1);
101 attrList[ this->specificationName(eLayerMean2) ].setValue(layerMean2);
102 attrList[ this->specificationName(eLayerMean3) ].setValue(layerMean3);
103 attrList[ this->specificationName(eLayerMean4) ].setValue(layerMean4);
104
105 attrListCollection->add(channelId, attrList);
106 }
107
108 return attrListCollection;
109}
110
111void L1CaloHVCorrectionsContainer::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(L1CaloHVCorrectionsContainer::eHVCorrections)));
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 float rxMean = attrList[ this->specificationName(eRxMean) ].data<float>();
133 std::vector<int> affectedCells;
134 std::vector<float> layerMeans;
135 float layerMean1 = attrList[ this->specificationName(eLayerMean1) ].data<float>();
136 if (layerMean1 >= 1.) {
137 layerMeans.push_back(layerMean1);
138 affectedCells.push_back((int)attrList[ this->specificationName(eAffectedCells1) ].data<unsigned char>());
139 float layerMean2 = attrList[ this->specificationName(eLayerMean2) ].data<float>();
140 if (layerMean2 >= 1.) {
141 layerMeans.push_back(layerMean2);
142 affectedCells.push_back((int)attrList[ this->specificationName(eAffectedCells2) ].data<unsigned char>());
143 float layerMean3 = attrList[ this->specificationName(eLayerMean3) ].data<float>();
144 if (layerMean3 >= 1.) {
145 layerMeans.push_back(layerMean3);
146 affectedCells.push_back((int)attrList[ this->specificationName(eAffectedCells3) ].data<unsigned char>());
147 float layerMean4 = attrList[ this->specificationName(eLayerMean4) ].data<float>();
148 if (layerMean4 >= 1.) {
149 layerMeans.push_back(layerMean4);
150 affectedCells.push_back((int)attrList[ this->specificationName(eAffectedCells4) ].data<unsigned char>());
151 }
152 }
153 }
154 }
155
156 L1CaloHVCorrections l1CaloHVCorrections(chanNum, rxMean, std::move(affectedCells), std::move(layerMeans));
157 m_mHVCorrectionsMap[chanNum] = std::move(l1CaloHVCorrections);
158 }
159 } else {
160 std::cout << "L1CaloHVCorrectionsContainer : Could not find requested CondAttrListCollection "
162 }
163}
164
166 L1CaloHVCorrectionsMap::const_iterator pos = m_mHVCorrectionsMap.find(channelId);
167 if(pos==m_mHVCorrectionsMap.end()) return 0;
168 else return &(pos->second);
169}
170
172 return this->hvCorrections(channelId.id());
173}
174
178
182
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
virtual void makeTransient(const std::map< std::string, const CondAttrListCollection * > &condAttrListCollectionMap)
virtual std::vector< std::string > coolInputKeys() const
virtual std::string coolOutputKey() const
void addHVCorrections(unsigned int channelId, L1CaloHVCorrections &&hvCorrections)
const L1CaloHVCorrections * hvCorrections(unsigned int channelId) const
std::map< L1CaloHVCorrectionsContainer::eCoolFolders, std::string > m_mCoolFoldersKeysMap
std::string coolFolderKey(L1CaloHVCorrectionsContainer::eCoolFolders efolder) const
virtual DataObject * makePersistent() const
Class that holds mean HV corrections for receivers.
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