ATLAS Offline Software
Loading...
Searching...
No Matches
L1CaloEnergyScanResultsContainer.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(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
29L1CaloEnergyScanResultsContainer::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
53std::vector<std::string> L1CaloEnergyScanResultsContainer::coolInputKeys() const {
54 std::vector<std::string> v;
56 return v;
57}
58
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 attrListCollection;
94}
95
96void 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
115 CondAttrListCollection::ChanNum chanNum(pos->first);
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
143
147
151
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.
ChanFitErrorCode stores information about the calibration fit quality.
This class is a collection of AttributeLists where each one is associated with a channel number.
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
std::map< L1CaloEnergyScanResultsContainer::eCoolFolders, std::string > m_mCoolFoldersKeysMap
std::string coolFolderKey(L1CaloEnergyScanResultsContainer::eCoolFolders efolder) const
virtual void makeTransient(const std::map< std::string, const CondAttrListCollection * > &condAttrListCollectionMap)
void addEnergyScanResults(unsigned int channelId, const L1CaloEnergyScanResults &energyScanResults)
const L1CaloEnergyScanResults * energyScanResults(unsigned int channelId) const
virtual std::vector< std::string > coolInputKeys() const
Class that holds transient information about the calibration for trigger towers.
double chi2(TH1 *h0, TH1 *h1)