ATLAS Offline Software
L1CaloPprLutContainer.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 
12 
13 #include <string>
14 #include <iostream>
15 
17  // Define DB rows names and types in order to construct the AttributeListSpecification object
18  this->addSpecification(eLutStrategy, std::string("LutStrategy"), std::string("UInt16"));
19  this->addSpecification(eLutOffset, std::string("LutOffset"), std::string("UInt16"));
20  this->addSpecification(eLutSlope, std::string("LutSlope"), std::string("UInt16"));
21  this->addSpecification(eLutNoiseCut, std::string("LutNoiseCut"), std::string("UInt16"));
22  this->addSpecification(eLutParameters, std::string("LutParameters"), std::string("Blob64k"));
23  this->addSpecification(ePedValue, std::string("PedValue"), std::string("UInt32"));
24  this->addSpecification(ePedMean, std::string("PedMean"), std::string("Double"));
25  this->addSpecification(eErrorCode, std::string("ErrorCode"), std::string("UInt32"));
26 
27  m_mCoolFoldersKeysMap[L1CaloPprLutContainer::ePprLutChanCalib] = std::string("/TRIGGER/L1Calo/V1/Calibration/Physics/PprChanCalib");
28 }
29 
30 L1CaloPprLutContainer::L1CaloPprLutContainer(const std::map<L1CaloPprLutContainer::eCoolFolders, std::string>& folderKeysMap):AbstractL1CaloPersistentCondition("CondAttrListCollection"),
31  m_mCoolFoldersKeysMap(folderKeysMap)
32 {
33  // Define DB rows names and types in order to construct the AttributeListSpecification object
34  this->addSpecification(eLutStrategy, std::string("LutStrategy"), std::string("UInt16"));
35  this->addSpecification(eLutOffset, std::string("LutOffset"), std::string("UInt16"));
36  this->addSpecification(eLutSlope, std::string("LutSlope"), std::string("UInt16"));
37  this->addSpecification(eLutNoiseCut, std::string("LutNoiseCut"), std::string("UInt16"));
38  this->addSpecification(eLutParameters, std::string("LutParameters"), std::string("Blob64k"));
39  this->addSpecification(ePedValue, std::string("PedValue"), std::string("UInt32"));
40  this->addSpecification(ePedMean, std::string("PedMean"), std::string("Double"));
41  this->addSpecification(eErrorCode, std::string("ErrorCode"), std::string("UInt32"));
42 }
43 
45 
46  std::map<L1CaloPprLutContainer::eCoolFolders, std::string>::const_iterator it = m_mCoolFoldersKeysMap.find(efolder);
47  if(it!=m_mCoolFoldersKeysMap.end()) {
48  return it->second;
49  } else {
50  return std::string("");
51  }
52 }
53 
54 std::vector<std::string> L1CaloPprLutContainer::coolInputKeys() const {
55  std::vector<std::string> v;
57  return v;
58 }
59 
62 }
63 
65  if(m_mPprLutMap.size()==0) return 0;
66 
67  // Create AttributeListSpecification according to the attributes to be recorded
68  // this is required to create the AttributeList objs
69  coral::AttributeListSpecification* attrSpecification = this->createAttributeListSpecification();
70  if(!attrSpecification->size()) return NULL;
71 
72  CondAttrListCollection* attrListCollection = new CondAttrListCollection(true);
73 
74  L1CaloPprLutMap::const_iterator pos = m_mPprLutMap.begin();
75  for(;pos!=m_mPprLutMap.end();++pos) {
76  const unsigned int channelId = pos->first;
77  const L1CaloPprLut& p = pos->second;
78 
79  AthenaAttributeList attrList(*attrSpecification);
80 
81  // Set value of each row for the current channel
82  attrList[ this->specificationName(eLutStrategy) ].setValue(p.lutStrategy());
83  attrList[ this->specificationName(eLutOffset) ].setValue(p.lutOffset());
84  attrList[ this->specificationName(eLutSlope) ].setValue(p.lutSlope());
85  attrList[ this->specificationName(eLutNoiseCut) ].setValue(p.lutNoiseCut());
86  attrList[ this->specificationName(eLutParameters) ].setValue(p.lutParameters());
87  //attrList[ this->specificationName(ePedValue) ].setValue(p.pedValue());
88  //attrList[ this->specificationName(eErrorCode) ].setValue(p.errorCode().errorCode());
89 
90  attrListCollection->add(channelId, attrList);
91  }
92 
93  return (DataObject*) attrListCollection;
94 }
95 
96 void L1CaloPprLutContainer::makeTransient(const std::map<std::string, const CondAttrListCollection*>& condAttrListCollectionMap) {
97 
98  this->clear();
99 
100  std::map<std::string, const CondAttrListCollection*>::const_iterator it_map;
101 
102  it_map = condAttrListCollectionMap.find(this->coolFolderKey(L1CaloPprLutContainer::ePprLutChanCalib));
103  if(it_map!=condAttrListCollectionMap.end()) {
104 
105  const CondAttrListCollection* attrListCollection = it_map->second;
106 
107  //loop over CondAttrListCollection
108  CondAttrListCollection::const_iterator it = attrListCollection->begin();
109  for(;it!=attrListCollection->end();++it) {
110 
111  const coral::AttributeList& attrList = it->second;
112 
113  // Get value of each row for the current channel
115 
116  unsigned short lutStrategy = attrList[ this->specificationName(eLutStrategy) ].data<unsigned short>();
117  unsigned short lutOffset = attrList[ this->specificationName(eLutOffset) ].data<unsigned short>();
118  unsigned short lutSlope = attrList[ this->specificationName(eLutSlope) ].data<unsigned short>();
119  unsigned short lutNoiseCut = attrList[ this->specificationName(eLutNoiseCut) ].data<unsigned short>();
120  coral::Blob lutParameters = attrList[ this->specificationName(eLutParameters) ].data<coral::Blob>();
121  unsigned int pedValue = attrList[ this->specificationName(ePedValue) ].data<unsigned int>();
122  double pedMean = attrList[ this->specificationName(ePedMean) ].data<double>();
123  ChanCalibErrorCode errorCode(attrList[ this->specificationName(eErrorCode) ].data<unsigned int>());
124 
125  L1CaloPprLut l1caloPptLut(chanNum, lutStrategy, lutOffset, lutSlope, lutNoiseCut, lutParameters, pedValue, pedMean, errorCode);
126  m_mPprLutMap[chanNum] = l1caloPptLut;
127  }
128  } else {
129  std::cout<<"L1CaloPprLutContainer : Could not find requested CondAttrListCollection "<< this->coolFolderKey(L1CaloPprLutContainer::ePprLutChanCalib) << std::endl;
130  }
131 }
132 
134  L1CaloPprLutMap::const_iterator pos = m_mPprLutMap.find(channelId);
135  if(pos==m_mPprLutMap.end()) return 0;
136  else return &(pos->second);
137 }
138 
140  return this->pprLut(channelId.id());
141 }
142 
143 void L1CaloPprLutContainer::addPprLut(unsigned int channelId, const L1CaloPprLut& pprLut) {
145 }
146 
148  return this->addPprLut(channelId.id(), pprLut);
149 }
150 
153  for(;it!=this->end();++it) {
154  std::cout << " * item: " <<it->first << " => "<<it->second <<std::endl;
155  }
156 }
157 
159  m_mPprLutMap.clear();
160 }
L1CaloPprLutContainer::coolFolderKey
std::string coolFolderKey(L1CaloPprLutContainer::eCoolFolders efolder) const
Definition: L1CaloPprLutContainer.cxx:44
L1CaloPprLut::lutNoiseCut
unsigned short lutNoiseCut(void) const
Definition: L1CaloPprLut.h:39
L1CaloPprLutContainer::pprLut
const L1CaloPprLut * pprLut(unsigned int channelId) const
Definition: L1CaloPprLutContainer.cxx:133
L1CaloPprLutContainer::ePedValue
@ ePedValue
Definition: L1CaloPprLutContainer.h:30
CondAttrListCollection::end
const_iterator end() const
Definition: CondAttrListCollection.h:315
L1CaloPprLutContainer::eLutSlope
@ eLutSlope
Definition: L1CaloPprLutContainer.h:30
CondAttrListCollection.h
This file defines the class for a collection of AttributeLists where each one is associated with a ch...
L1CaloPprLutContainer::begin
L1CaloPprLutMap::const_iterator begin() const
Definition: L1CaloPprLutContainer.h:55
L1CaloPprLutContainer::end
L1CaloPprLutMap::const_iterator end() const
Definition: L1CaloPprLutContainer.h:56
L1CaloPprLutContainer::L1CaloPprLutContainer
L1CaloPprLutContainer()
Definition: L1CaloPprLutContainer.cxx:16
L1CaloPprLutContainer.h
L1CaloPprLutContainer::eErrorCode
@ eErrorCode
Definition: L1CaloPprLutContainer.h:30
skel.it
it
Definition: skel.GENtoEVGEN.py:396
AbstractL1CaloPersistentCondition::addSpecification
void addSpecification(int specId, const std::string &specName, const std::string &specType)
Definition: AbstractL1CaloPersistentCondition.cxx:26
L1CaloPprLut::lutParameters
coral::Blob lutParameters(void) const
Definition: L1CaloPprLut.h:40
CondAttrListCollection::begin
const_iterator begin() const
Access to Chan/AttributeList pairs via iterators.
Definition: CondAttrListCollection.h:309
python.subdetectors.tile.Blob
Blob
Definition: tile.py:17
L1CaloPprLutContainer::ePedMean
@ ePedMean
Definition: L1CaloPprLutContainer.h:30
ChanCalibErrorCode
ChanCalibErrorCode class for L1Calo error codes Adapted from /LVL1/l1calo/coolL1Calo/coolL1Calo/ChanE...
Definition: ChanCalibErrorCode.h:20
python.PyKernel.AttributeList
AttributeList
Definition: PyKernel.py:36
L1CaloPprLutContainer::coolInputKeys
virtual std::vector< std::string > coolInputKeys() const
Definition: L1CaloPprLutContainer.cxx:54
CondAttrListCollection
This class is a collection of AttributeLists where each one is associated with a channel number....
Definition: CondAttrListCollection.h:52
AthenaAttributeList.h
L1CaloPprLutContainer::makePersistent
virtual DataObject * makePersistent() const
Definition: L1CaloPprLutContainer.cxx:64
AbstractL1CaloPersistentCondition::createAttributeListSpecification
coral::AttributeListSpecification * createAttributeListSpecification() const
Definition: AbstractL1CaloPersistentCondition.cxx:31
L1CaloPprLut
Transient class defining the PPM lookup table objects.
Definition: L1CaloPprLut.h:24
L1CaloPprLut::lutOffset
unsigned short lutOffset(void) const
Definition: L1CaloPprLut.h:37
L1CaloPprLutContainer::eCoolFolders
eCoolFolders
Definition: L1CaloPprLutContainer.h:34
L1CaloPprLutContainer::ePprLutChanCalib
@ ePprLutChanCalib
Definition: L1CaloPprLutContainer.h:34
python.utils.AtlRunQueryDQUtils.p
p
Definition: AtlRunQueryDQUtils.py:210
checkCoolLatestUpdate.chanNum
chanNum
Definition: checkCoolLatestUpdate.py:27
L1CaloPprLutContainer::addPprLut
void addPprLut(unsigned int channelId, const L1CaloPprLut &pprLut)
Definition: L1CaloPprLutContainer.cxx:143
L1CaloPprLutContainer::eLutParameters
@ eLutParameters
Definition: L1CaloPprLutContainer.h:30
L1CaloCoolChannelId::id
unsigned int id() const
Definition: L1CaloCoolChannelId.h:32
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
CaloCondBlobAlgs_fillNoiseFromASCII.channelId
channelId
Definition: CaloCondBlobAlgs_fillNoiseFromASCII.py:122
CondAttrListCollection::ChanNum
unsigned int ChanNum
Definition: CondAttrListCollection.h:55
L1CaloPprLutContainer::m_mCoolFoldersKeysMap
std::map< L1CaloPprLutContainer::eCoolFolders, std::string > m_mCoolFoldersKeysMap
Definition: L1CaloPprLutContainer.h:69
AbstractL1CaloPersistentCondition::specificationName
std::string specificationName(int specId) const
Definition: AbstractL1CaloPersistentCondition.cxx:44
python.LumiBlobConversion.pos
pos
Definition: LumiBlobConversion.py:18
python.PyAthena.v
v
Definition: PyAthena.py:154
L1CaloCoolChannelId
Definition: L1CaloCoolChannelId.h:10
L1CaloPprLut::lutStrategy
unsigned short lutStrategy(void) const
Definition: L1CaloPprLut.h:36
L1CaloPprLutContainer::makeTransient
virtual void makeTransient(const std::map< std::string, const CondAttrListCollection * > &condAttrListCollectionMap)
Definition: L1CaloPprLutContainer.cxx:96
CondAttrListCollection::const_iterator
ChanAttrListMap::const_iterator const_iterator
Definition: CondAttrListCollection.h:63
L1CaloPprLutContainer::dump
void dump() const
Definition: L1CaloPprLutContainer.cxx:151
L1CaloPprLutContainer::eLutNoiseCut
@ eLutNoiseCut
Definition: L1CaloPprLutContainer.h:30
L1CaloPprLutContainer::clear
virtual void clear()
Definition: L1CaloPprLutContainer.cxx:158
L1CaloPprLutContainer::coolOutputKey
virtual std::string coolOutputKey() const
Definition: L1CaloPprLutContainer.cxx:60
L1CaloPprLutContainer::m_mPprLutMap
L1CaloPprLutMap m_mPprLutMap
Definition: L1CaloPprLutContainer.h:68
L1CaloPprLut::lutSlope
unsigned short lutSlope(void) const
Definition: L1CaloPprLut.h:38
CondAttrListCollection::add
bool add(ChanNum chanNum, const AttributeList &attributeList)
Adding in chan/attrList pairs.
Definition: CondAttrListCollection.h:452
ChanCalibErrorCode.h
AbstractL1CaloPersistentCondition
AbstractL1CaloConditionContainer abstract base class for L1Calo persistent conditions container objec...
Definition: AbstractL1CaloPersistentCondition.h:22
L1CaloPprLutContainer::const_iterator
std::map< unsigned int, L1CaloPprLut >::const_iterator const_iterator
Definition: L1CaloPprLutContainer.h:36
L1CaloPprLutContainer::eLutOffset
@ eLutOffset
Definition: L1CaloPprLutContainer.h:30
L1CaloPprLutContainer::eLutStrategy
@ eLutStrategy
Definition: L1CaloPprLutContainer.h:30