ATLAS Offline Software
L1CaloEnergyScanResultsContainer.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(eOffset, std::string("Offset"), std::string("double"));
19  this->addSpecification(eSlope, std::string("Slope"), std::string("double"));
20  this->addSpecification(eChi2, std::string("Chi2"), std::string("double"));
21  this->addSpecification(eNdf, std::string("Ndf"), std::string("unsigned char"));
22  this->addSpecification(eBlob, std::string("Blob"), std::string("blob"));
23  this->addSpecification(eBlobStrategy,std::string("BlobStrategy"),std::string("unsigned char"));
24  this->addSpecification(eErrorCode, std::string("ErrorCode"), std::string("unsigned int"));
25 
26  m_mCoolFoldersKeysMap[L1CaloEnergyScanResultsContainer::eEnergyScanResults] = std::string("/TRIGGER/L1Calo/V1/Results/EnergyScanResults");
27 }
28 
29 L1CaloEnergyScanResultsContainer::L1CaloEnergyScanResultsContainer(const std::map<L1CaloEnergyScanResultsContainer::eCoolFolders, std::string>& folderKeysMap) :
30  AbstractL1CaloPersistentCondition("CondAttrListCollection"),
31  m_mCoolFoldersKeysMap(folderKeysMap)
32 {
33  // Define DB rows names and types in order to construct the AttributeListSpecification object
34  this->addSpecification(eOffset, std::string("Offset"), std::string("double"));
35  this->addSpecification(eSlope, std::string("Slope"), std::string("double"));
36  this->addSpecification(eChi2, std::string("Chi2"), std::string("double"));
37  this->addSpecification(eNdf, std::string("Ndf"), std::string("unsigned char"));
38  this->addSpecification(eBlob, std::string("Blob"), std::string("blob"));
39  this->addSpecification(eBlobStrategy,std::string("BlobStrategy"),std::string("unsigned char"));
40  this->addSpecification(eErrorCode, std::string("ErrorCode"), std::string("unsigned int"));
41 }
42 
44 
45  std::map<L1CaloEnergyScanResultsContainer::eCoolFolders, std::string>::const_iterator it = m_mCoolFoldersKeysMap.find(efolder);
46  if(it!=m_mCoolFoldersKeysMap.end()) {
47  return it->second;
48  } else {
49  return std::string("");
50  }
51 }
52 
53 std::vector<std::string> L1CaloEnergyScanResultsContainer::coolInputKeys() const {
54  std::vector<std::string> v;
56  return v;
57 }
58 
61 }
62 
64  if(m_mEnergyScanResultsMap.size()==0) return 0;
65 
66  // Create AttributeListSpecification according to the attributes to be recorded
67  // this is required to create the AttributeList objs
68  coral::AttributeListSpecification* attrSpecification = this->createAttributeListSpecification();
69  if(!attrSpecification->size()) return NULL;
70 
71  CondAttrListCollection* attrListCollection = new CondAttrListCollection(true);
72 
73  L1CaloEnergyScanResultsMap::const_iterator pos = m_mEnergyScanResultsMap.begin();
74  L1CaloEnergyScanResultsMap::const_iterator end = m_mEnergyScanResultsMap.end();
75  for(; pos!=end; ++pos) {
76  const unsigned int channelId = pos->first;
77  const L1CaloEnergyScanResults& p = pos->second;
78 
79  AthenaAttributeList attrList(*attrSpecification);
80 
81  // Set value of each row for the current channel
82  attrList[ this->specificationName(eOffset) ].setValue(p.offset());
83  attrList[ this->specificationName(eSlope) ].setValue(p.slope());
84  attrList[ this->specificationName(eChi2) ].setValue(p.chi2());
85  attrList[ this->specificationName(eNdf) ].setValue(p.ndf());
86  attrList[ this->specificationName(eBlob) ].setValue(p.blob());
87  attrList[ this->specificationName(eBlobStrategy) ].setValue(p.blobStrategy());
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 L1CaloEnergyScanResultsContainer::makeTransient(const std::map<std::string, const CondAttrListCollection*>& condAttrListCollectionMap) {
97 
98  this->clear();
99 
100  std::map<std::string, const CondAttrListCollection*>::const_iterator
101  it_map(condAttrListCollectionMap.find(this->coolFolderKey(L1CaloEnergyScanResultsContainer::eEnergyScanResults)));
102 
103  if(it_map!=condAttrListCollectionMap.end()) {
104 
105  const CondAttrListCollection* attrListCollection = it_map->second;
106 
107  //loop over CondAttrListCollection
108  CondAttrListCollection::const_iterator pos = attrListCollection->begin();
109  CondAttrListCollection::const_iterator end = attrListCollection->begin();
110  for(; pos!= end; ++pos) {
111 
112  const coral::AttributeList& attrList = pos->second;
113 
114  // Get value of each row for the current channel
116 
117  double offset = attrList[ this->specificationName(eOffset) ].data<double>();
118  double slope = attrList[ this->specificationName(eSlope) ].data<double>();
119  double chi2 = attrList[ this->specificationName(eChi2) ].data<double>();
120  unsigned char ndf = attrList[ this->specificationName(eNdf) ].data<unsigned char>();
121  coral::Blob blob = attrList[ this->specificationName(eBlob) ].data<coral::Blob>();
122  unsigned char blobStrategy = attrList[ this->specificationName(eBlobStrategy) ].data<unsigned char>();
123  ChanFitErrorCode errorCode(attrList[ this->specificationName(eErrorCode) ].data<unsigned int>());
124 
125  L1CaloEnergyScanResults l1CaloEnergyScanResults(chanNum, offset, slope, chi2, ndf, blob, blobStrategy, errorCode);
126  m_mEnergyScanResultsMap[chanNum] = l1CaloEnergyScanResults;
127  }
128  } else {
129  std::cout << "L1CaloEnergyScanResultsContainer : Could not find requested CondAttrListCollection "
131  }
132 }
133 
135  L1CaloEnergyScanResultsMap::const_iterator pos = m_mEnergyScanResultsMap.find(channelId);
136  if(pos==m_mEnergyScanResultsMap.end()) return 0;
137  else return &(pos->second);
138 }
139 
141  return this->energyScanResults(channelId.id());
142 }
143 
146 }
147 
149  return this->addEnergyScanResults(channelId.id(), energyScanResults);
150 }
151 
153  m_mEnergyScanResultsMap.clear();
154 }
covarianceTool.ndf
ndf
Definition: covarianceTool.py:678
L1CaloEnergyScanResultsContainer::eBlob
@ eBlob
Definition: L1CaloEnergyScanResultsContainer.h:30
ChanFitErrorCode.h
L1CaloEnergyScanResultsContainer::m_mCoolFoldersKeysMap
std::map< L1CaloEnergyScanResultsContainer::eCoolFolders, std::string > m_mCoolFoldersKeysMap
Definition: L1CaloEnergyScanResultsContainer.h:68
L1CaloEnergyScanResultsContainer::energyScanResults
const L1CaloEnergyScanResults * energyScanResults(unsigned int channelId) const
Definition: L1CaloEnergyScanResultsContainer.cxx:134
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
L1CaloEnergyScanResultsContainer::L1CaloEnergyScanResultsContainer
L1CaloEnergyScanResultsContainer()
Definition: L1CaloEnergyScanResultsContainer.cxx:16
L1CaloEnergyScanResultsContainer::eChi2
@ eChi2
Definition: L1CaloEnergyScanResultsContainer.h:30
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
L1CaloEnergyScanResultsContainer::coolInputKeys
virtual std::vector< std::string > coolInputKeys() const
Definition: L1CaloEnergyScanResultsContainer.cxx:53
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
L1CaloEnergyScanResultsContainer::eSlope
@ eSlope
Definition: L1CaloEnergyScanResultsContainer.h:30
L1CaloEnergyScanResults
Class that holds transient information about the calibration for trigger towers.
Definition: L1CaloEnergyScanResults.h:19
AbstractL1CaloPersistentCondition::createAttributeListSpecification
coral::AttributeListSpecification * createAttributeListSpecification() const
Definition: AbstractL1CaloPersistentCondition.cxx:31
L1CaloEnergyScanResults::blob
const coral::Blob & blob() const
Definition: L1CaloEnergyScanResults.h:51
L1CaloEnergyScanResultsContainer::makePersistent
virtual DataObject * makePersistent() const
Definition: L1CaloEnergyScanResultsContainer.cxx:63
L1CaloEnergyScanResultsContainer::addEnergyScanResults
void addEnergyScanResults(unsigned int channelId, const L1CaloEnergyScanResults &energyScanResults)
Definition: L1CaloEnergyScanResultsContainer.cxx:144
python.utils.AtlRunQueryDQUtils.p
p
Definition: AtlRunQueryDQUtils.py:210
L1CaloEnergyScanResultsContainer::eErrorCode
@ eErrorCode
Definition: L1CaloEnergyScanResultsContainer.h:30
L1CaloEnergyScanResults::errorCode
const ChanFitErrorCode & errorCode() const
Definition: L1CaloEnergyScanResults.h:52
checkCoolLatestUpdate.chanNum
chanNum
Definition: checkCoolLatestUpdate.py:27
chi2
double chi2(TH1 *h0, TH1 *h1)
Definition: comparitor.cxx:522
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
ChanFitErrorCode::errorCode
unsigned int errorCode() const
Definition: AbstractErrorCode.h:21
L1CaloEnergyScanResultsContainer::m_mEnergyScanResultsMap
L1CaloEnergyScanResultsMap m_mEnergyScanResultsMap
Definition: L1CaloEnergyScanResultsContainer.h:67
L1CaloEnergyScanResults::ndf
unsigned char ndf() const
Definition: L1CaloEnergyScanResults.h:50
CaloCondBlobAlgs_fillNoiseFromASCII.channelId
channelId
Definition: CaloCondBlobAlgs_fillNoiseFromASCII.py:122
CondAttrListCollection::ChanNum
unsigned int ChanNum
Definition: CondAttrListCollection.h:55
L1CaloEnergyScanResultsContainer.h
L1CaloEnergyScanResultsContainer::eOffset
@ eOffset
Definition: L1CaloEnergyScanResultsContainer.h:30
L1CaloEnergyScanResultsContainer::eEnergyScanResults
@ eEnergyScanResults
Definition: L1CaloEnergyScanResultsContainer.h:37
L1CaloEnergyScanResults::offset
double offset() const
Definition: L1CaloEnergyScanResults.h:47
AbstractL1CaloPersistentCondition::specificationName
std::string specificationName(int specId) const
Definition: AbstractL1CaloPersistentCondition.cxx:44
L1CaloEnergyScanResultsContainer::coolOutputKey
virtual std::string coolOutputKey() const
Definition: L1CaloEnergyScanResultsContainer.cxx:59
L1CaloEnergyScanResultsContainer::eNdf
@ eNdf
Definition: L1CaloEnergyScanResultsContainer.h:30
python.LumiBlobConversion.pos
pos
Definition: LumiBlobConversion.py:18
python.PyAthena.v
v
Definition: PyAthena.py:154
L1CaloCoolChannelId
Definition: L1CaloCoolChannelId.h:10
L1CaloEnergyScanResults::blobStrategy
unsigned char blobStrategy() const
Definition: L1CaloEnergyScanResults.h:46
CondAttrListCollection::const_iterator
ChanAttrListMap::const_iterator const_iterator
Definition: CondAttrListCollection.h:63
L1CaloEnergyScanResultsContainer::end
const_iterator end() const
Definition: L1CaloEnergyScanResultsContainer.h:57
L1CaloEnergyScanResultsContainer::coolFolderKey
std::string coolFolderKey(L1CaloEnergyScanResultsContainer::eCoolFolders efolder) const
Definition: L1CaloEnergyScanResultsContainer.cxx:43
convertTimingResiduals.offset
offset
Definition: convertTimingResiduals.py:71
L1CaloEnergyScanResultsContainer::makeTransient
virtual void makeTransient(const std::map< std::string, const CondAttrListCollection * > &condAttrListCollectionMap)
Definition: L1CaloEnergyScanResultsContainer.cxx:96
L1CaloEnergyScanResultsContainer::eBlobStrategy
@ eBlobStrategy
Definition: L1CaloEnergyScanResultsContainer.h:30
L1CaloEnergyScanResultsContainer::eCoolFolders
eCoolFolders
Definition: L1CaloEnergyScanResultsContainer.h:37
L1CaloEnergyScanResults::chi2
double chi2() const
Definition: L1CaloEnergyScanResults.h:49
CondAttrListCollection::add
bool add(ChanNum chanNum, const AttributeList &attributeList)
Adding in chan/attrList pairs.
Definition: CondAttrListCollection.h:452
L1CaloEnergyScanResultsContainer::clear
virtual void clear()
Definition: L1CaloEnergyScanResultsContainer.cxx:152
AbstractL1CaloPersistentCondition
AbstractL1CaloConditionContainer abstract base class for L1Calo persistent conditions container objec...
Definition: AbstractL1CaloPersistentCondition.h:22
ChanFitErrorCode
ChanFitErrorCode stores information about the calibration fit quality.
Definition: ChanFitErrorCode.h:17
L1CaloEnergyScanResults::slope
double slope() const
Definition: L1CaloEnergyScanResults.h:48
CaloCondBlobAlgs_fillNoiseFromASCII.blob
blob
Definition: CaloCondBlobAlgs_fillNoiseFromASCII.py:96