ATLAS Offline Software
Loading...
Searching...
No Matches
L1CaloPpmFineTimeRefsContainer.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
14
16 // Define DB rows names and types in order to construct the AttributeListSpecification object
17 this->addSpecification(eErrorCode, std::string("ErrorCode"), std::string("UInt32"));
18 this->addSpecification(eRefValue, std::string("referenceValue"), std::string("double"));
19 this->addSpecification(eCriterion, std::string("criterionValue"), std::string("double"));
20 this->addSpecification(eCalibValue, std::string("calibrationFactor"), std::string("double"));
21
22
23 m_mCoolFoldersKeysMap[L1CaloPpmFineTimeRefsContainer::ePpmFineTimeRefss] = std::string("/TRIGGER/L1Calo/V1/References/FineTimeReferences");
24}
25
26L1CaloPpmFineTimeRefsContainer::L1CaloPpmFineTimeRefsContainer(const std::map<L1CaloPpmFineTimeRefsContainer::eCoolFolders, std::string>& folderKeysMap):AbstractL1CaloPersistentCondition("CondAttrListCollection"),
27 m_mCoolFoldersKeysMap(folderKeysMap)
28{
29 // Define DB rows names and types in order to construct the AttributeListSpecification object
30 this->addSpecification(eErrorCode, std::string("ErrorCode"), std::string("UInt32"));
31 this->addSpecification(eRefValue, std::string("referenceValue"), std::string("double"));
32 this->addSpecification(eCriterion, std::string("criterionValue"), std::string("double"));
33 this->addSpecification(eCalibValue, std::string("calibrationFactor"), std::string("double"));
34}
35
37
38 std::map<L1CaloPpmFineTimeRefsContainer::eCoolFolders, std::string>::const_iterator it = m_mCoolFoldersKeysMap.find(efolder);
39 if(it!=m_mCoolFoldersKeysMap.end()) {
40 return it->second;
41 } else {
42 return std::string("");
43 }
44}
45
46std::vector<std::string> L1CaloPpmFineTimeRefsContainer::coolInputKeys() const {
47 std::vector<std::string> v;
49 return v;
50}
51
55
57
58 if(m_mPpmFineTimeRefsMap.size()==0) return 0;
59
60 // Create AttributeListSpecification according to the attributes to be recorded
61 // this is required to create the AttributeList objs
62 coral::AttributeListSpecification* attrSpecification = this->createAttributeListSpecification();
63 if(!attrSpecification->size()) return NULL;
64
65 CondAttrListCollection* attrListCollection = new CondAttrListCollection(true);
66
67 L1CaloPpmFineTimeRefsMap::const_iterator pos = m_mPpmFineTimeRefsMap.begin();
68 for(;pos!=m_mPpmFineTimeRefsMap.end();++pos) {
69 const unsigned int channelId = pos->first;
70 const L1CaloPpmFineTimeRefs& p = pos->second;
71
72 AthenaAttributeList attrList(*attrSpecification);
73
74 // Set value of each row for the current channel
75 attrList[ this->specificationName(eErrorCode) ].setValue(p.errorCode().errorCode());
76 attrList[ this->specificationName(eRefValue) ].setValue(p.refValue());
77 attrList[ this->specificationName(eCriterion) ].setValue(p.criterion());
78 attrList[ this->specificationName(eCalibValue) ].setValue(p.calibValue());
79
80 attrListCollection->add(channelId, attrList);
81 }
82
83 return attrListCollection;
84}
85
86void L1CaloPpmFineTimeRefsContainer::makeTransient(const std::map<std::string, const CondAttrListCollection*>& condAttrListCollectionMap) {
87
88 this->clear();
89
90 std::map<std::string, const CondAttrListCollection*>::const_iterator it_map;
91
92 it_map = condAttrListCollectionMap.find(this->coolFolderKey(L1CaloPpmFineTimeRefsContainer::ePpmFineTimeRefss));
93 if(it_map!=condAttrListCollectionMap.end()) {
94
95 const CondAttrListCollection* attrListCollection = it_map->second;
96
97 //loop over CondAttrListCollection
98 CondAttrListCollection::const_iterator it = attrListCollection->begin();
99 for(;it!=attrListCollection->end();++it) {
100
101 const coral::AttributeList& attrList = it->second;
102
103 // Get value of each row for the current channel
104 CondAttrListCollection::ChanNum chanNum = it->first;
105
107 double refVal = attrList[ this->specificationName(eRefValue) ].data<double>();
108 double criterion = attrList[ this->specificationName(eCriterion) ].data<double>();
109 double calibVal = attrList[ this->specificationName(eCalibValue) ].data<double>();
110
111 L1CaloPpmFineTimeRefs l1caloFineTimeRefs(chanNum, errorCode, refVal, criterion, calibVal);
112 m_mPpmFineTimeRefsMap[chanNum] = l1caloFineTimeRefs;
113 }
114 } else {
115 std::cout<<"L1CaloPpmFineTimeRefsContainer : Could not find requested CondAttrListCollection "<< this->coolFolderKey(L1CaloPpmFineTimeRefsContainer::ePpmFineTimeRefss) << std::endl;
116 }
117}
118
120 L1CaloPpmFineTimeRefsMap::const_iterator pos = m_mPpmFineTimeRefsMap.find(channelId);
121 if(pos==m_mPpmFineTimeRefsMap.end()) return 0;
122 else return &(pos->second);
123}
124
126 return this->ppmFineTimeRefs(channelId.id());
127}
128
130 m_mPpmFineTimeRefsMap[channelId] = fir;
131}
132
134 this->addPpmFineTimeRefs(channelId.id(), fir);
135}
136
139 for(;it!=this->end();++it) {
140 std::cout << " * item: " <<it->first << " => "<<it->second <<std::endl;
141 }
142}
143
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
FineTimeErrorCode class for L1Calo error codes.
Encapsulates the ID of one channel of conditions data in COOL, ie the ID of a row in a table.
unsigned int id() const
const L1CaloPpmFineTimeRefs * ppmFineTimeRefs(unsigned int channelId) const
L1CaloPpmFineTimeRefsMap::const_iterator begin() const
std::map< L1CaloPpmFineTimeRefsContainer::eCoolFolders, std::string > m_mCoolFoldersKeysMap
virtual void makeTransient(const std::map< std::string, const CondAttrListCollection * > &condAttrListCollectionMap)
std::string coolFolderKey(L1CaloPpmFineTimeRefsContainer::eCoolFolders efolder) const
void addPpmFineTimeRefs(unsigned int channelId, const L1CaloPpmFineTimeRefs &ppmFineTimeRefs)
std::map< unsignedint, L1CaloPpmFineTimeRefs >::const_iterator const_iterator
virtual std::vector< std::string > coolInputKeys() const
L1CaloPpmFineTimeRefsMap::const_iterator end() const