ATLAS Offline Software
L1CaloHVCorrectionsContainer.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 
15  // Define DB rows names and types in order to construct the AttributeListSpecification object
16  this->addSpecification(eRxMean, std::string("RxMean"), std::string("float"));
17  this->addSpecification(eAffectedCells1, std::string("AffectedCells1"), std::string("unsigned char"));
18  this->addSpecification(eAffectedCells2, std::string("AffectedCells2"), std::string("unsigned char"));
19  this->addSpecification(eAffectedCells3, std::string("AffectedCells3"), std::string("unsigned char"));
20  this->addSpecification(eAffectedCells4, std::string("AffectedCells4"), std::string("unsigned char"));
21  this->addSpecification(eLayerMean1, std::string("LayerMean1"), std::string("float"));
22  this->addSpecification(eLayerMean2, std::string("LayerMean2"), std::string("float"));
23  this->addSpecification(eLayerMean3, std::string("LayerMean3"), std::string("float"));
24  this->addSpecification(eLayerMean4, std::string("LayerMean4"), std::string("float"));
25 
26  m_mCoolFoldersKeysMap[L1CaloHVCorrectionsContainer::eHVCorrections] = std::string("/TRIGGER/L1Calo/V1/Results/HVCorrections");
27 }
28 
29 L1CaloHVCorrectionsContainer::L1CaloHVCorrectionsContainer(const std::map<L1CaloHVCorrectionsContainer::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(eRxMean, std::string("RxMean"), std::string("float"));
35  this->addSpecification(eAffectedCells1, std::string("AffectedCells1"), std::string("unsigned char"));
36  this->addSpecification(eAffectedCells2, std::string("AffectedCells2"), std::string("unsigned char"));
37  this->addSpecification(eAffectedCells3, std::string("AffectedCells3"), std::string("unsigned char"));
38  this->addSpecification(eAffectedCells4, std::string("AffectedCells4"), std::string("unsigned char"));
39  this->addSpecification(eLayerMean1, std::string("LayerMean1"), std::string("float"));
40  this->addSpecification(eLayerMean2, std::string("LayerMean2"), std::string("float"));
41  this->addSpecification(eLayerMean3, std::string("LayerMean3"), std::string("float"));
42  this->addSpecification(eLayerMean4, std::string("LayerMean4"), std::string("float"));
43 }
44 
46 
47  std::map<L1CaloHVCorrectionsContainer::eCoolFolders, std::string>::const_iterator it = m_mCoolFoldersKeysMap.find(efolder);
48  if(it!=m_mCoolFoldersKeysMap.end()) {
49  return it->second;
50  } else {
51  return std::string("");
52  }
53 }
54 
55 std::vector<std::string> L1CaloHVCorrectionsContainer::coolInputKeys() const {
56  std::vector<std::string> v;
58  return v;
59 }
60 
63 }
64 
66  if(m_mHVCorrectionsMap.size()==0) return 0;
67 
68  // Create AttributeListSpecification according to the attributes to be recorded
69  // this is required to create the AttributeList objs
70  coral::AttributeListSpecification* attrSpecification = this->createAttributeListSpecification();
71  if(!attrSpecification->size()) return NULL;
72 
73  CondAttrListCollection* attrListCollection = new CondAttrListCollection(true);
74 
75  L1CaloHVCorrectionsMap::const_iterator pos = m_mHVCorrectionsMap.begin();
76  L1CaloHVCorrectionsMap::const_iterator end = m_mHVCorrectionsMap.end();
77  for(; pos!=end; ++pos) {
78  const unsigned int channelId = pos->first;
79  const L1CaloHVCorrections& p = pos->second;
80  const std::vector<int>& affectedCells(p.affectedCells());
81  const std::vector<float>& layerMeans(p.layerMeans());
82  const unsigned char nlayers = affectedCells.size();
83  const unsigned char affectedCells1 = (nlayers > 0) ? affectedCells[0] : 0;
84  const unsigned char affectedCells2 = (nlayers > 1) ? affectedCells[1] : 0;
85  const unsigned char affectedCells3 = (nlayers > 2) ? affectedCells[2] : 0;
86  const unsigned char affectedCells4 = (nlayers > 3) ? affectedCells[3] : 0;
87  const float layerMean1 = (nlayers > 0) ? layerMeans[0] : 0.;
88  const float layerMean2 = (nlayers > 1) ? layerMeans[1] : 0.;
89  const float layerMean3 = (nlayers > 2) ? layerMeans[2] : 0.;
90  const float layerMean4 = (nlayers > 3) ? layerMeans[3] : 0.;
91 
92  AthenaAttributeList attrList(*attrSpecification);
93 
94  // Set value of each row for the current channel
95  attrList[ this->specificationName(eRxMean) ].setValue(p.rxMean());
96  attrList[ this->specificationName(eAffectedCells1) ].setValue(affectedCells1);
97  attrList[ this->specificationName(eAffectedCells2) ].setValue(affectedCells2);
98  attrList[ this->specificationName(eAffectedCells3) ].setValue(affectedCells3);
99  attrList[ this->specificationName(eAffectedCells4) ].setValue(affectedCells4);
100  attrList[ this->specificationName(eLayerMean1) ].setValue(layerMean1);
101  attrList[ this->specificationName(eLayerMean2) ].setValue(layerMean2);
102  attrList[ this->specificationName(eLayerMean3) ].setValue(layerMean3);
103  attrList[ this->specificationName(eLayerMean4) ].setValue(layerMean4);
104 
105  attrListCollection->add(channelId, attrList);
106  }
107 
108  return (DataObject*) attrListCollection;
109 }
110 
111 void L1CaloHVCorrectionsContainer::makeTransient(const std::map<std::string, const CondAttrListCollection*>& condAttrListCollectionMap) {
112 
113  this->clear();
114 
115  std::map<std::string, const CondAttrListCollection*>::const_iterator
116  it_map(condAttrListCollectionMap.find(this->coolFolderKey(L1CaloHVCorrectionsContainer::eHVCorrections)));
117 
118  if(it_map!=condAttrListCollectionMap.end()) {
119 
120  const CondAttrListCollection* attrListCollection = it_map->second;
121 
122  //loop over CondAttrListCollection
123  CondAttrListCollection::const_iterator pos = attrListCollection->begin();
124  CondAttrListCollection::const_iterator end = attrListCollection->end();
125  for(; pos!= end; ++pos) {
126 
127  const coral::AttributeList& attrList = pos->second;
128 
129  // Get value of each row for the current channel
131 
132  float rxMean = attrList[ this->specificationName(eRxMean) ].data<float>();
133  std::vector<int> affectedCells;
134  std::vector<float> layerMeans;
135  float layerMean1 = attrList[ this->specificationName(eLayerMean1) ].data<float>();
136  if (layerMean1 >= 1.) {
137  layerMeans.push_back(layerMean1);
138  affectedCells.push_back((int)attrList[ this->specificationName(eAffectedCells1) ].data<unsigned char>());
139  float layerMean2 = attrList[ this->specificationName(eLayerMean2) ].data<float>();
140  if (layerMean2 >= 1.) {
141  layerMeans.push_back(layerMean2);
142  affectedCells.push_back((int)attrList[ this->specificationName(eAffectedCells2) ].data<unsigned char>());
143  float layerMean3 = attrList[ this->specificationName(eLayerMean3) ].data<float>();
144  if (layerMean3 >= 1.) {
145  layerMeans.push_back(layerMean3);
146  affectedCells.push_back((int)attrList[ this->specificationName(eAffectedCells3) ].data<unsigned char>());
147  float layerMean4 = attrList[ this->specificationName(eLayerMean4) ].data<float>();
148  if (layerMean4 >= 1.) {
149  layerMeans.push_back(layerMean4);
150  affectedCells.push_back((int)attrList[ this->specificationName(eAffectedCells4) ].data<unsigned char>());
151  }
152  }
153  }
154  }
155 
156  L1CaloHVCorrections l1CaloHVCorrections(chanNum, rxMean, std::move(affectedCells), std::move(layerMeans));
157  m_mHVCorrectionsMap[chanNum] = std::move(l1CaloHVCorrections);
158  }
159  } else {
160  std::cout << "L1CaloHVCorrectionsContainer : Could not find requested CondAttrListCollection "
162  }
163 }
164 
166  L1CaloHVCorrectionsMap::const_iterator pos = m_mHVCorrectionsMap.find(channelId);
167  if(pos==m_mHVCorrectionsMap.end()) return 0;
168  else return &(pos->second);
169 }
170 
172  return this->hvCorrections(channelId.id());
173 }
174 
177 }
178 
180  this->addHVCorrections(channelId.id(), std::move(hvCorrections));
181 }
182 
184  m_mHVCorrectionsMap.clear();
185 }
L1CaloHVCorrectionsContainer::coolFolderKey
std::string coolFolderKey(L1CaloHVCorrectionsContainer::eCoolFolders efolder) const
Definition: L1CaloHVCorrectionsContainer.cxx:45
L1CaloHVCorrections::rxMean
float rxMean() const
Definition: L1CaloHVCorrections.h:35
CondAttrListCollection::end
const_iterator end() const
Definition: CondAttrListCollection.h:315
L1CaloHVCorrectionsContainer::m_mCoolFoldersKeysMap
std::map< L1CaloHVCorrectionsContainer::eCoolFolders, std::string > m_mCoolFoldersKeysMap
Definition: L1CaloHVCorrectionsContainer.h:71
python.PerfMonSerializer.p
def p
Definition: PerfMonSerializer.py:743
CondAttrListCollection.h
This file defines the class for a collection of AttributeLists where each one is associated with a ch...
L1CaloHVCorrectionsContainer::coolInputKeys
virtual std::vector< std::string > coolInputKeys() const
Definition: L1CaloHVCorrectionsContainer.cxx:55
L1CaloHVCorrectionsContainer::eHVCorrections
@ eHVCorrections
Definition: L1CaloHVCorrectionsContainer.h:40
L1CaloHVCorrectionsContainer::clear
virtual void clear()
Definition: L1CaloHVCorrectionsContainer.cxx:183
skel.it
it
Definition: skel.GENtoEVGEN.py:423
L1CaloRxCoolChannelId::id
unsigned int id() const
Definition: L1CaloRxCoolChannelId.h:27
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
CondAttrListCollection
This class is a collection of AttributeLists where each one is associated with a channel number....
Definition: CondAttrListCollection.h:52
AthenaAttributeList.h
AbstractL1CaloPersistentCondition::createAttributeListSpecification
coral::AttributeListSpecification * createAttributeListSpecification() const
Definition: AbstractL1CaloPersistentCondition.cxx:31
L1CaloHVCorrectionsContainer::hvCorrections
const L1CaloHVCorrections * hvCorrections(unsigned int channelId) const
Definition: L1CaloHVCorrectionsContainer.cxx:165
L1CaloHVCorrectionsContainer::eAffectedCells3
@ eAffectedCells3
Definition: L1CaloHVCorrectionsContainer.h:32
L1CaloHVCorrectionsContainer::eAffectedCells4
@ eAffectedCells4
Definition: L1CaloHVCorrectionsContainer.h:32
L1CaloRxCoolChannelId
Definition: L1CaloRxCoolChannelId.h:10
checkCoolLatestUpdate.chanNum
chanNum
Definition: checkCoolLatestUpdate.py:27
L1CaloHVCorrectionsContainer::end
const_iterator end() const
Definition: L1CaloHVCorrectionsContainer.h:60
L1CaloHVCorrectionsContainer.h
L1CaloHVCorrections
Class that holds mean HV corrections for receivers.
Definition: L1CaloHVCorrections.h:19
L1CaloHVCorrectionsContainer::eRxMean
@ eRxMean
Definition: L1CaloHVCorrectionsContainer.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
L1CaloHVCorrectionsContainer::makePersistent
virtual DataObject * makePersistent() const
Definition: L1CaloHVCorrectionsContainer.cxx:65
CaloCondBlobAlgs_fillNoiseFromASCII.channelId
channelId
Definition: CaloCondBlobAlgs_fillNoiseFromASCII.py:122
CondAttrListCollection::ChanNum
unsigned int ChanNum
Definition: CondAttrListCollection.h:55
L1CaloHVCorrectionsContainer::eAffectedCells2
@ eAffectedCells2
Definition: L1CaloHVCorrectionsContainer.h:32
L1CaloHVCorrectionsContainer::eCoolFolders
eCoolFolders
Definition: L1CaloHVCorrectionsContainer.h:40
L1CaloHVCorrectionsContainer::eLayerMean1
@ eLayerMean1
Definition: L1CaloHVCorrectionsContainer.h:33
AbstractL1CaloPersistentCondition::specificationName
std::string specificationName(int specId) const
Definition: AbstractL1CaloPersistentCondition.cxx:44
python.LumiBlobConversion.pos
pos
Definition: LumiBlobConversion.py:18
L1CaloHVCorrectionsContainer::makeTransient
virtual void makeTransient(const std::map< std::string, const CondAttrListCollection * > &condAttrListCollectionMap)
Definition: L1CaloHVCorrectionsContainer.cxx:111
L1CaloHVCorrectionsContainer::L1CaloHVCorrectionsContainer
L1CaloHVCorrectionsContainer()
Definition: L1CaloHVCorrectionsContainer.cxx:14
L1CaloHVCorrectionsContainer::eLayerMean2
@ eLayerMean2
Definition: L1CaloHVCorrectionsContainer.h:33
python.PyAthena.v
v
Definition: PyAthena.py:157
L1CaloHVCorrectionsContainer::eLayerMean4
@ eLayerMean4
Definition: L1CaloHVCorrectionsContainer.h:33
L1CaloHVCorrectionsContainer::eLayerMean3
@ eLayerMean3
Definition: L1CaloHVCorrectionsContainer.h:33
CondAttrListCollection::const_iterator
ChanAttrListMap::const_iterator const_iterator
Definition: CondAttrListCollection.h:63
L1CaloHVCorrectionsContainer::addHVCorrections
void addHVCorrections(unsigned int channelId, L1CaloHVCorrections &&hvCorrections)
Definition: L1CaloHVCorrectionsContainer.cxx:175
L1CaloHVCorrectionsContainer::coolOutputKey
virtual std::string coolOutputKey() const
Definition: L1CaloHVCorrectionsContainer.cxx:61
CondAttrListCollection::add
bool add(ChanNum chanNum, const AttributeList &attributeList)
Adding in chan/attrList pairs.
Definition: CondAttrListCollection.h:452
L1CaloHVCorrectionsContainer::eAffectedCells1
@ eAffectedCells1
Definition: L1CaloHVCorrectionsContainer.h:32
AbstractL1CaloPersistentCondition
AbstractL1CaloConditionContainer abstract base class for L1Calo persistent conditions container objec...
Definition: AbstractL1CaloPersistentCondition.h:22
L1CaloHVCorrectionsContainer::m_mHVCorrectionsMap
L1CaloHVCorrectionsMap m_mHVCorrectionsMap
Definition: L1CaloHVCorrectionsContainer.h:70