ATLAS Offline Software
L1CaloRxGainContainer.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 "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 
27 L1CaloRxGainContainer::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 
49 std::vector<std::string> L1CaloRxGainContainer::coolInputKeys() const {
50  std::vector<std::string> v;
52  return v;
53 }
54 
57 }
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 (DataObject*) attrListCollection;
89 }
90 
91 void 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
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 
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 
138 void 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 
154  m_mRxGainMap.clear();
155 }
L1CaloRxGainContainer::rxGain
const L1CaloRxGain * rxGain(unsigned int channelId) const
Definition: L1CaloRxGainContainer.cxx:128
L1CaloRxGainContainer::eCoolFolders
eCoolFolders
Definition: L1CaloRxGainContainer.h:33
CondAttrListCollection::end
const_iterator end() const
Definition: CondAttrListCollection.h:315
python.PerfMonSerializer.p
def p
Definition: PerfMonSerializer.py:743
CondAttrListCollection.h
This file defines the class for a collection of AttributeLists where each one is associated with a ch...
CaloCondBlobAlgs_fillNoiseFromASCII.gain
gain
Definition: CaloCondBlobAlgs_fillNoiseFromASCII.py:110
L1CaloRxGainContainer::clear
virtual void clear()
Definition: L1CaloRxGainContainer.cxx:153
skel.it
it
Definition: skel.GENtoEVGEN.py:423
L1CaloRxCoolChannelId::id
unsigned int id() const
Definition: L1CaloRxCoolChannelId.h:27
AbstractL1CaloPersistentCondition::addSpecification
void addSpecification(int specId, const std::string &specName, const std::string &specType)
Definition: AbstractL1CaloPersistentCondition.cxx:26
CondAttrListCollection::begin
const_iterator begin() const
Access to Chan/AttributeList pairs via iterators.
Definition: CondAttrListCollection.h:309
L1CaloRxGainContainer::eGain
@ eGain
Definition: L1CaloRxGainContainer.h:30
L1CaloRxGain::gain
int gain(void) const
Definition: L1CaloRxGain.h:44
python.PyKernel.AttributeList
AttributeList
Definition: PyKernel.py:36
CondAttrListCollection
This class is a collection of AttributeLists where each one is associated with a channel number....
Definition: CondAttrListCollection.h:52
AthenaAttributeList.h
L1CaloRxGainContainer.h
AbstractL1CaloPersistentCondition::createAttributeListSpecification
coral::AttributeListSpecification * createAttributeListSpecification() const
Definition: AbstractL1CaloPersistentCondition.cxx:31
L1CaloRxGainContainer::eComment
@ eComment
Definition: L1CaloRxGainContainer.h:30
L1CaloRxCoolChannelId
Definition: L1CaloRxCoolChannelId.h:10
checkCoolLatestUpdate.chanNum
chanNum
Definition: checkCoolLatestUpdate.py:27
L1CaloRxGainContainer::coolOutputKey
virtual std::string coolOutputKey() const
Definition: L1CaloRxGainContainer.cxx:55
L1CaloRxGainContainer::end
L1CaloRxGainMap::const_iterator end() const
Definition: L1CaloRxGainContainer.h:52
L1CaloRxGainContainer::coolFolderKey
std::string coolFolderKey(L1CaloRxGainContainer::eCoolFolders efolder) const
Definition: L1CaloRxGainContainer.cxx:39
AthenaAttributeList
An AttributeList represents a logical row of attributes in a metadata table. The name and type of eac...
Definition: PersistentDataModel/PersistentDataModel/AthenaAttributeList.h:45
L1CaloRxGainContainer::coolInputKeys
virtual std::vector< std::string > coolInputKeys() const
Definition: L1CaloRxGainContainer.cxx:49
CaloCondBlobAlgs_fillNoiseFromASCII.channelId
channelId
Definition: CaloCondBlobAlgs_fillNoiseFromASCII.py:122
CondAttrListCollection::ChanNum
unsigned int ChanNum
Definition: CondAttrListCollection.h:55
L1CaloRxGainContainer::const_iterator
std::map< unsigned int, L1CaloRxGain >::const_iterator const_iterator
Definition: L1CaloRxGainContainer.h:35
CaloCondBlobAlgs_fillNoiseFromASCII.comment
string comment
Definition: CaloCondBlobAlgs_fillNoiseFromASCII.py:27
L1CaloRxGainContainer::eRxGainFolder
@ eRxGainFolder
Definition: L1CaloRxGainContainer.h:33
AbstractL1CaloPersistentCondition::specificationName
std::string specificationName(int specId) const
Definition: AbstractL1CaloPersistentCondition.cxx:44
L1CaloRxGainContainer::addRxGain
void addRxGain(unsigned int channelId, const L1CaloRxGain &rxGain)
Definition: L1CaloRxGainContainer.cxx:138
python.LumiBlobConversion.pos
pos
Definition: LumiBlobConversion.py:18
L1CaloRxGainContainer::makePersistent
virtual DataObject * makePersistent() const
Definition: L1CaloRxGainContainer.cxx:59
python.PyAthena.v
v
Definition: PyAthena.py:157
L1CaloRxGain
Transient conditions class for objects defined by the online framework and retrieved from COOL.
Definition: L1CaloRxGain.h:24
L1CaloRxGainContainer::dump
void dump() const
Definition: L1CaloRxGainContainer.cxx:146
L1CaloRxGainContainer::L1CaloRxGainContainer
L1CaloRxGainContainer()
Definition: L1CaloRxGainContainer.cxx:15
CondAttrListCollection::const_iterator
ChanAttrListMap::const_iterator const_iterator
Definition: CondAttrListCollection.h:63
L1CaloRxGainContainer::m_mCoolFoldersKeysMap
std::map< L1CaloRxGainContainer::eCoolFolders, std::string > m_mCoolFoldersKeysMap
Definition: L1CaloRxGainContainer.h:66
L1CaloRxGain::comment
std::string comment(void) const
Definition: L1CaloRxGain.h:45
CondAttrListCollection::add
bool add(ChanNum chanNum, const AttributeList &attributeList)
Adding in chan/attrList pairs.
Definition: CondAttrListCollection.h:452
AbstractL1CaloPersistentCondition
AbstractL1CaloConditionContainer abstract base class for L1Calo persistent conditions container objec...
Definition: AbstractL1CaloPersistentCondition.h:22
L1CaloRxGainContainer::m_mRxGainMap
L1CaloRxGainMap m_mRxGainMap
Definition: L1CaloRxGainContainer.h:65
L1CaloRxGainContainer::makeTransient
virtual void makeTransient(const std::map< std::string, const CondAttrListCollection * > &condAttrListCollectionMap)
Definition: L1CaloRxGainContainer.cxx:91
L1CaloRxGainContainer::begin
L1CaloRxGainMap::const_iterator begin() const
Definition: L1CaloRxGainContainer.h:51