ATLAS Offline Software
L1CaloPpmFineTimeRefsContainer.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 <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 
26 L1CaloPpmFineTimeRefsContainer::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 
46 std::vector<std::string> L1CaloPpmFineTimeRefsContainer::coolInputKeys() const {
47  std::vector<std::string> v;
49  return v;
50 }
51 
54 }
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 (DataObject*) attrListCollection;
84 }
85 
86 void 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
105 
106  FineTimeErrorCode errorCode(attrList[ this->specificationName(eErrorCode) ].data<unsigned int>());
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 
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 
145  m_mPpmFineTimeRefsMap.clear();
146 }
L1CaloPpmFineTimeRefsContainer::eRefValue
@ eRefValue
Definition: L1CaloPpmFineTimeRefsContainer.h:33
CondAttrListCollection::end
const_iterator end() const
Definition: CondAttrListCollection.h:315
L1CaloPpmFineTimeRefsContainer::L1CaloPpmFineTimeRefsContainer
L1CaloPpmFineTimeRefsContainer()
Definition: L1CaloPpmFineTimeRefsContainer.cxx:15
FineTimeErrorCode
FineTimeErrorCode class for L1Calo error codes.
Definition: FineTimeErrorCode.h:19
AbstractErrorCode::errorCode
unsigned int errorCode() const
Definition: AbstractErrorCode.h:21
L1CaloPpmFineTimeRefsContainer::ppmFineTimeRefs
const L1CaloPpmFineTimeRefs * ppmFineTimeRefs(unsigned int channelId) const
Definition: L1CaloPpmFineTimeRefsContainer.cxx:119
CondAttrListCollection.h
This file defines the class for a collection of AttributeLists where each one is associated with a ch...
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
CondAttrListCollection::begin
const_iterator begin() const
Access to Chan/AttributeList pairs via iterators.
Definition: CondAttrListCollection.h:309
python.PyKernel.AttributeList
AttributeList
Definition: PyKernel.py:36
L1CaloPpmFineTimeRefsContainer::eCriterion
@ eCriterion
Definition: L1CaloPpmFineTimeRefsContainer.h:33
CondAttrListCollection
This class is a collection of AttributeLists where each one is associated with a channel number....
Definition: CondAttrListCollection.h:52
AthenaAttributeList.h
L1CaloPpmFineTimeRefsContainer::dump
void dump() const
Definition: L1CaloPpmFineTimeRefsContainer.cxx:137
L1CaloPpmFineTimeRefs::criterion
double criterion(void) const
Definition: L1CaloPpmFineTimeRefs.h:39
AbstractL1CaloPersistentCondition::createAttributeListSpecification
coral::AttributeListSpecification * createAttributeListSpecification() const
Definition: AbstractL1CaloPersistentCondition.cxx:31
L1CaloPpmFineTimeRefsContainer::clear
virtual void clear()
Definition: L1CaloPpmFineTimeRefsContainer.cxx:144
L1CaloPpmFineTimeRefsContainer::coolInputKeys
virtual std::vector< std::string > coolInputKeys() const
Definition: L1CaloPpmFineTimeRefsContainer.cxx:46
python.utils.AtlRunQueryDQUtils.p
p
Definition: AtlRunQueryDQUtils.py:210
checkCoolLatestUpdate.chanNum
chanNum
Definition: checkCoolLatestUpdate.py:27
L1CaloPpmFineTimeRefsContainer::makeTransient
virtual void makeTransient(const std::map< std::string, const CondAttrListCollection * > &condAttrListCollectionMap)
Definition: L1CaloPpmFineTimeRefsContainer.cxx:86
L1CaloPpmFineTimeRefsContainer::const_iterator
std::map< unsigned int, L1CaloPpmFineTimeRefs >::const_iterator const_iterator
Definition: L1CaloPpmFineTimeRefsContainer.h:38
L1CaloPpmFineTimeRefsContainer::coolOutputKey
virtual std::string coolOutputKey() const
Definition: L1CaloPpmFineTimeRefsContainer.cxx:52
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
L1CaloPpmFineTimeRefsContainer::makePersistent
virtual DataObject * makePersistent() const
Definition: L1CaloPpmFineTimeRefsContainer.cxx:56
CondAttrListCollection::ChanNum
unsigned int ChanNum
Definition: CondAttrListCollection.h:55
L1CaloPpmFineTimeRefsContainer::ePpmFineTimeRefss
@ ePpmFineTimeRefss
Definition: L1CaloPpmFineTimeRefsContainer.h:36
L1CaloPpmFineTimeRefsContainer.h
AbstractL1CaloPersistentCondition::specificationName
std::string specificationName(int specId) const
Definition: AbstractL1CaloPersistentCondition.cxx:44
L1CaloPpmFineTimeRefs::refValue
double refValue(void) const
Definition: L1CaloPpmFineTimeRefs.h:38
python.LumiBlobConversion.pos
pos
Definition: LumiBlobConversion.py:18
L1CaloPpmFineTimeRefsContainer::m_mCoolFoldersKeysMap
std::map< L1CaloPpmFineTimeRefsContainer::eCoolFolders, std::string > m_mCoolFoldersKeysMap
Definition: L1CaloPpmFineTimeRefsContainer.h:68
python.PyAthena.v
v
Definition: PyAthena.py:154
L1CaloCoolChannelId
Definition: L1CaloCoolChannelId.h:10
L1CaloPpmFineTimeRefsContainer::eCalibValue
@ eCalibValue
Definition: L1CaloPpmFineTimeRefsContainer.h:33
L1CaloPpmFineTimeRefsContainer::eErrorCode
@ eErrorCode
Definition: L1CaloPpmFineTimeRefsContainer.h:33
CondAttrListCollection::const_iterator
ChanAttrListMap::const_iterator const_iterator
Definition: CondAttrListCollection.h:63
L1CaloPpmFineTimeRefsContainer::eCoolFolders
eCoolFolders
Definition: L1CaloPpmFineTimeRefsContainer.h:36
L1CaloPpmFineTimeRefsContainer::end
L1CaloPpmFineTimeRefsMap::const_iterator end() const
Definition: L1CaloPpmFineTimeRefsContainer.h:55
L1CaloPpmFineTimeRefsContainer::begin
L1CaloPpmFineTimeRefsMap::const_iterator begin() const
Definition: L1CaloPpmFineTimeRefsContainer.h:54
L1CaloPpmFineTimeRefsContainer::addPpmFineTimeRefs
void addPpmFineTimeRefs(unsigned int channelId, const L1CaloPpmFineTimeRefs &ppmFineTimeRefs)
Definition: L1CaloPpmFineTimeRefsContainer.cxx:129
L1CaloPpmFineTimeRefsContainer::m_mPpmFineTimeRefsMap
L1CaloPpmFineTimeRefsMap m_mPpmFineTimeRefsMap
Definition: L1CaloPpmFineTimeRefsContainer.h:67
L1CaloPpmFineTimeRefsContainer::coolFolderKey
std::string coolFolderKey(L1CaloPpmFineTimeRefsContainer::eCoolFolders efolder) const
Definition: L1CaloPpmFineTimeRefsContainer.cxx:36
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
L1CaloPpmFineTimeRefs::errorCode
FineTimeErrorCode errorCode(void) const
Definition: L1CaloPpmFineTimeRefs.h:37
L1CaloPpmFineTimeRefs
Definition: L1CaloPpmFineTimeRefs.h:23
L1CaloPpmFineTimeRefs::calibValue
double calibValue(void) const
Definition: L1CaloPpmFineTimeRefs.h:40