ATLAS Offline Software
Loading...
Searching...
No Matches
L1CaloRxGainContainer.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 "GaudiKernel/MsgStream.h"
12
13#include <string>
14
16 // Define DB rows names and types in order to construct the AttributeListSpecification object
17 //this->addSpecification(eIdentifier, std::string("Identifier"), std::string("unsigned int"));
18 //this->addSpecification(eCrate, std::string("RecCrate"), std::string("string"));
19 //this->addSpecification(eSlot, std::string("RecSlot"), std::string("unsigned int"));
20 //this->addSpecification(eChannel, std::string("RecChannel"), std::string("unsigned int"));
21 this->addSpecification(eGain, std::string("gains"), std::string("int"));
22 this->addSpecification(eComment, std::string("Comment"), std::string("string"));
23
24 m_mCoolFoldersKeysMap[L1CaloRxGainContainer::eRxGainFolder] = std::string("/receivers/Gains");
25}
26
27L1CaloRxGainContainer::L1CaloRxGainContainer(const std::map<L1CaloRxGainContainer::eCoolFolders, std::string>& folderKeysMap):AbstractL1CaloPersistentCondition("CondAttrListCollection"),
28 m_mCoolFoldersKeysMap(folderKeysMap)
29{
30 // Define DB rows names and types in order to construct the AttributeListSpecification object
31 //this->addSpecification(eIdentifier, std::string("Identifier"), std::string("unsigned int"));
32 //this->addSpecification(eCrate, std::string("RecCrate"), std::string("string"));
33 //this->addSpecification(eSlot, std::string("RecSlot"), std::string("unsigned int"));
34 //this->addSpecification(eChannel, std::string("RecChannel"), std::string("unsigned int"));
35 this->addSpecification(eGain, std::string("gains"), std::string("int"));
36 this->addSpecification(eComment, std::string("Comment"), std::string("string"));
37}
38
40
41 std::map<L1CaloRxGainContainer::eCoolFolders, std::string>::const_iterator it = m_mCoolFoldersKeysMap.find(efolder);
42 if(it!=m_mCoolFoldersKeysMap.end()) {
43 return it->second;
44 } else {
45 return std::string("");
46 }
47}
48
49std::vector<std::string> L1CaloRxGainContainer::coolInputKeys() const {
50 std::vector<std::string> v;
52 return v;
53}
54
58
60 if(m_mRxGainMap.size()==0) return 0;
61
62 // Create AttributeListSpecification according to the attributes to be recorded
63 // this is required to create the AttributeList objs
64 coral::AttributeListSpecification* attrSpecification = this->createAttributeListSpecification();
65 if(!attrSpecification->size()) return 0;
66
67
68 CondAttrListCollection* attrListCollection = new CondAttrListCollection(true);
69
70 L1CaloRxGainMap::const_iterator pos = m_mRxGainMap.begin();
71 for(;pos!=m_mRxGainMap.end();++pos) {
72 const unsigned int channelId = pos->first;
73 const L1CaloRxGain& p = pos->second;
74
75 AthenaAttributeList attrList(*attrSpecification);
76
77 //attrList[ this->specificationName(eIdentifier) ].setValue(p->identifier());
78 //attrList[ this->specificationName(eCrate) ].setValue(p->crate());
79 //attrList[ this->specificationName(eSlot) ].setValue(p->slot());
80 //attrList[ this->specificationName(eChannel) ].setValue(p->channel());
81 attrList[ this->specificationName(eGain) ].setValue(p.gain());
82 attrList[ this->specificationName(eComment) ].setValue(p.comment());
83
84 // add AttributeList corresponding to channel iChanNumber to the CondAttrListCollection
85 attrListCollection->add(channelId, attrList);
86 }
87
88 return attrListCollection;
89}
90
91void L1CaloRxGainContainer::makeTransient(const std::map<std::string, const CondAttrListCollection*>& condAttrListCollectionMap) {
92
93 this->clear();
94
95 std::map<std::string, const CondAttrListCollection*>::const_iterator it_map;
96
97 it_map = condAttrListCollectionMap.find(this->coolFolderKey(L1CaloRxGainContainer::eRxGainFolder));
98 if(it_map!=condAttrListCollectionMap.end()) {
99
100 const CondAttrListCollection* attrListCollection = it_map->second;
101
102 //loop over CondAttrListCollection
103 CondAttrListCollection::const_iterator it = attrListCollection->begin();
104 for(;it!=attrListCollection->end();++it) {
105
106 const coral::AttributeList& attrList = it->second;
107
108 // Get value of each row for the current channel
109 CondAttrListCollection::ChanNum chanNum = it->first;
110
111 //unsigned int identifier = attrList[ this->specificationName(eIdentifier) ].data<unsigned int>();
112 //std::string crate = attrList[ this->specificationName(eCrate) ].data<std::string>();
113 //unsigned int slot = attrList[ this->specificationName(eSlot) ].data<unsigned int>();
114 //unsigned int channel = attrList[ this->specificationName(eChannel) ].data<unsigned int>();
115 unsigned int gain = attrList[ this->specificationName(eGain) ].data<int>();
116 std::string comment = attrList[ this->specificationName(eComment) ].data<std::string>();
117
118 // Create transient L1CaloPedestal obj
119 //L1CaloRxGain* p = new L1CaloRxGain( chanNum, identifier, crate, slot, channel, gain, comment);
120 L1CaloRxGain l1caloRxGain(chanNum, gain, comment);
121 m_mRxGainMap[chanNum] = l1caloRxGain;
122 }
123 } else {
124 std::cout<<"L1CaloRxGainContainer : Could not find requested CondAttrListCollection "<< this->coolFolderKey(L1CaloRxGainContainer::eRxGainFolder) << std::endl;
125 }
126}
127
128const L1CaloRxGain* L1CaloRxGainContainer::rxGain(unsigned int channelId) const {
129 L1CaloRxGainMap::const_iterator pos = m_mRxGainMap.find(channelId);
130 if(pos==m_mRxGainMap.end()) return 0;
131 else return &(pos->second);
132}
133
135 return this->rxGain(channelId.id());
136}
137
138void L1CaloRxGainContainer::addRxGain(unsigned int channelId, const L1CaloRxGain& pprLut) {
139 m_mRxGainMap[channelId] = pprLut;
140}
141
143 return this->addRxGain(channelId.id(), pprLut);
144}
145
148 for(;it!=this->end();++it) {
149 std::cout << " * item: " <<it->first << " => "<<it->second <<std::endl;
150 }
151}
152
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.
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
virtual std::string coolOutputKey() const
std::map< L1CaloRxGainContainer::eCoolFolders, std::string > m_mCoolFoldersKeysMap
std::string coolFolderKey(L1CaloRxGainContainer::eCoolFolders efolder) const
L1CaloRxGainMap::const_iterator begin() const
L1CaloRxGainMap::const_iterator end() const
virtual std::vector< std::string > coolInputKeys() const
std::map< unsignedint, L1CaloRxGain >::const_iterator const_iterator
virtual void makeTransient(const std::map< std::string, const CondAttrListCollection * > &condAttrListCollectionMap)
void addRxGain(unsigned int channelId, const L1CaloRxGain &rxGain)
const L1CaloRxGain * rxGain(unsigned int channelId) const
virtual DataObject * makePersistent() const
Transient conditions class for objects defined by the online framework and retrieved from COOL.