ATLAS Offline Software
Loading...
Searching...
No Matches
L1CaloPprLutContainer.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
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
30L1CaloPprLutContainer::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
54std::vector<std::string> L1CaloPprLutContainer::coolInputKeys() const {
55 std::vector<std::string> v;
57 return v;
58}
59
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 attrListCollection;
94}
95
96void 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
114 CondAttrListCollection::ChanNum chanNum(it->first);
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>();
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
133const L1CaloPprLut* L1CaloPprLutContainer::pprLut(unsigned int channelId) const {
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
143void L1CaloPprLutContainer::addPprLut(unsigned int channelId, const L1CaloPprLut& pprLut) {
144 m_mPprLutMap[channelId] = 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
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.
ChanCalibErrorCode class for L1Calo error codes Adapted from /LVL1/l1calo/coolL1Calo/coolL1Calo/ChanE...
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 channel of conditions data in COOL, ie the ID of a row in a table.
unsigned int id() const
L1CaloPprLutMap::const_iterator end() const
L1CaloPprLutMap::const_iterator begin() const
std::map< unsignedint, L1CaloPprLut >::const_iterator const_iterator
virtual void makeTransient(const std::map< std::string, const CondAttrListCollection * > &condAttrListCollectionMap)
virtual DataObject * makePersistent() const
const L1CaloPprLut * pprLut(unsigned int channelId) const
void addPprLut(unsigned int channelId, const L1CaloPprLut &pprLut)
virtual std::vector< std::string > coolInputKeys() const
virtual std::string coolOutputKey() const
std::string coolFolderKey(L1CaloPprLutContainer::eCoolFolders efolder) const
std::map< L1CaloPprLutContainer::eCoolFolders, std::string > m_mCoolFoldersKeysMap
Transient class defining the PPM lookup table objects.