ATLAS Offline Software
L1CaloRxLayersContainer.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(eNLayers, std::string("NLayers"), std::string("unsigned char"));
17  this->addSpecification(eName1, std::string("Name1"), std::string("unsigned char"));
18  this->addSpecification(eName2, std::string("Name2"), std::string("unsigned char"));
19  this->addSpecification(eName3, std::string("Name3"), std::string("unsigned char"));
20  this->addSpecification(eName4, std::string("Name4"), std::string("unsigned char"));
21  this->addSpecification(eNCells1, std::string("NCells1"), std::string("unsigned char"));
22  this->addSpecification(eNCells2, std::string("NCells2"), std::string("unsigned char"));
23  this->addSpecification(eNCells3, std::string("NCells3"), std::string("unsigned char"));
24  this->addSpecification(eNCells4, std::string("NCells4"), std::string("unsigned char"));
25 
26  m_mCoolFoldersKeysMap[L1CaloRxLayersContainer::eRxLayers] = std::string("/TRIGGER/L1Calo/V1/Results/RxLayers");
27 }
28 
29 L1CaloRxLayersContainer::L1CaloRxLayersContainer(const std::map<L1CaloRxLayersContainer::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(eNLayers, std::string("NLayers"), std::string("unsigned char"));
35  this->addSpecification(eName1, std::string("Name1"), std::string("unsigned char"));
36  this->addSpecification(eName2, std::string("Name2"), std::string("unsigned char"));
37  this->addSpecification(eName3, std::string("Name3"), std::string("unsigned char"));
38  this->addSpecification(eName4, std::string("Name4"), std::string("unsigned char"));
39  this->addSpecification(eNCells1, std::string("NCells1"), std::string("unsigned char"));
40  this->addSpecification(eNCells2, std::string("NCells2"), std::string("unsigned char"));
41  this->addSpecification(eNCells3, std::string("NCells3"), std::string("unsigned char"));
42  this->addSpecification(eNCells4, std::string("NCells4"), std::string("unsigned char"));
43 }
44 
46 
47  std::map<L1CaloRxLayersContainer::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> L1CaloRxLayersContainer::coolInputKeys() const {
56  std::vector<std::string> v;
58  return v;
59 }
60 
63 }
64 
66  if(m_mRxLayersMap.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  L1CaloRxLayersMap::const_iterator pos = m_mRxLayersMap.begin();
76  L1CaloRxLayersMap::const_iterator end = m_mRxLayersMap.end();
77  for(; pos!=end; ++pos) {
78  const unsigned int channelId = pos->first;
79  const L1CaloRxLayers& p = pos->second;
80  const std::vector<int>& names(p.names());
81  const std::vector<int>& ncells(p.ncells());
82  const unsigned char nlayers = names.size();
83  const unsigned char name1 = (nlayers > 0) ? names[0] : 0;
84  const unsigned char name2 = (nlayers > 1) ? names[1] : 0;
85  const unsigned char name3 = (nlayers > 2) ? names[2] : 0;
86  const unsigned char name4 = (nlayers > 3) ? names[3] : 0;
87  const unsigned char ncells1 = (nlayers > 0) ? ncells[0] : 0;
88  const unsigned char ncells2 = (nlayers > 1) ? ncells[1] : 0;
89  const unsigned char ncells3 = (nlayers > 2) ? ncells[2] : 0;
90  const unsigned char ncells4 = (nlayers > 3) ? ncells[3] : 0;
91 
92  AthenaAttributeList attrList(*attrSpecification);
93 
94  // Set value of each row for the current channel
95  attrList[ this->specificationName(eNLayers) ].setValue(nlayers);
96  attrList[ this->specificationName(eName1) ].setValue(name1);
97  attrList[ this->specificationName(eName2) ].setValue(name2);
98  attrList[ this->specificationName(eName3) ].setValue(name3);
99  attrList[ this->specificationName(eName4) ].setValue(name4);
100  attrList[ this->specificationName(eNCells1) ].setValue(ncells1);
101  attrList[ this->specificationName(eNCells2) ].setValue(ncells2);
102  attrList[ this->specificationName(eNCells3) ].setValue(ncells3);
103  attrList[ this->specificationName(eNCells4) ].setValue(ncells4);
104 
105  attrListCollection->add(channelId, attrList);
106  }
107 
108  return (DataObject*) attrListCollection;
109 }
110 
111 void L1CaloRxLayersContainer::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(L1CaloRxLayersContainer::eRxLayers)));
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  unsigned char nlayers = attrList[ this->specificationName(eNLayers) ].data<unsigned char>();
133  std::vector<int> names;
134  std::vector<int> ncells;
135  if (nlayers > 0) {
136  names.push_back((int)attrList[ this->specificationName(eName1) ].data<unsigned char>());
137  ncells.push_back((int)attrList[ this->specificationName(eNCells1) ].data<unsigned char>());
138  }
139  if (nlayers > 1) {
140  names.push_back((int)attrList[ this->specificationName(eName2) ].data<unsigned char>());
141  ncells.push_back((int)attrList[ this->specificationName(eNCells2) ].data<unsigned char>());
142  }
143  if (nlayers > 2) {
144  names.push_back((int)attrList[ this->specificationName(eName3) ].data<unsigned char>());
145  ncells.push_back((int)attrList[ this->specificationName(eNCells3) ].data<unsigned char>());
146  }
147  if (nlayers > 3) {
148  names.push_back((int)attrList[ this->specificationName(eName4) ].data<unsigned char>());
149  ncells.push_back((int)attrList[ this->specificationName(eNCells4) ].data<unsigned char>());
150  }
151 
152  L1CaloRxLayers l1CaloRxLayers(chanNum, std::move(names), std::move(ncells));
153  m_mRxLayersMap[chanNum] = std::move(l1CaloRxLayers);
154  }
155  } else {
156  std::cout << "L1CaloRxLayersContainer : Could not find requested CondAttrListCollection "
157  << this->coolFolderKey(L1CaloRxLayersContainer::eRxLayers) << std::endl;
158  }
159 }
160 
162  L1CaloRxLayersMap::const_iterator pos = m_mRxLayersMap.find(channelId);
163  if(pos==m_mRxLayersMap.end()) return 0;
164  else return &(pos->second);
165 }
166 
168  return this->rxLayers(channelId.id());
169 }
170 
172  m_mRxLayersMap[channelId] = std::move(rxLayers);
173 }
174 
176  this->addRxLayers(channelId.id(), std::move(rxLayers));
177 }
178 
180  m_mRxLayersMap.clear();
181 }
L1CaloRxLayersContainer::m_mCoolFoldersKeysMap
std::map< L1CaloRxLayersContainer::eCoolFolders, std::string > m_mCoolFoldersKeysMap
Definition: L1CaloRxLayersContainer.h:70
CondAttrListCollection::end
const_iterator end() const
Definition: CondAttrListCollection.h:315
ReadCellNoiseFromCool.name1
name1
Definition: ReadCellNoiseFromCool.py:233
CondAttrListCollection.h
This file defines the class for a collection of AttributeLists where each one is associated with a ch...
L1CaloRxLayersContainer::eNCells4
@ eNCells4
Definition: L1CaloRxLayersContainer.h:32
L1CaloRxLayersContainer::eName1
@ eName1
Definition: L1CaloRxLayersContainer.h:32
skel.it
it
Definition: skel.GENtoEVGEN.py:396
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
L1CaloRxLayersContainer::eName3
@ eName3
Definition: L1CaloRxLayersContainer.h:32
python.PyKernel.AttributeList
AttributeList
Definition: PyKernel.py:36
L1CaloRxLayersContainer::m_mRxLayersMap
L1CaloRxLayersMap m_mRxLayersMap
Definition: L1CaloRxLayersContainer.h:69
CondAttrListCollection
This class is a collection of AttributeLists where each one is associated with a channel number....
Definition: CondAttrListCollection.h:52
L1CaloRxLayersContainer::eCoolFolders
eCoolFolders
Definition: L1CaloRxLayersContainer.h:39
AthenaAttributeList.h
L1CaloRxLayersContainer.h
L1CaloRxLayersContainer::eRxLayers
@ eRxLayers
Definition: L1CaloRxLayersContainer.h:39
AbstractL1CaloPersistentCondition::createAttributeListSpecification
coral::AttributeListSpecification * createAttributeListSpecification() const
Definition: AbstractL1CaloPersistentCondition.cxx:31
L1CaloRxLayersContainer::coolInputKeys
virtual std::vector< std::string > coolInputKeys() const
Definition: L1CaloRxLayersContainer.cxx:55
L1CaloRxLayersContainer::rxLayers
const L1CaloRxLayers * rxLayers(unsigned int channelId) const
Definition: L1CaloRxLayersContainer.cxx:161
python.utils.AtlRunQueryDQUtils.p
p
Definition: AtlRunQueryDQUtils.py:210
L1CaloRxCoolChannelId
Definition: L1CaloRxCoolChannelId.h:10
checkCoolLatestUpdate.chanNum
chanNum
Definition: checkCoolLatestUpdate.py:27
python.subdetectors.mmg.names
names
Definition: mmg.py:8
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
L1CaloRxLayersContainer::L1CaloRxLayersContainer
L1CaloRxLayersContainer()
Definition: L1CaloRxLayersContainer.cxx:14
L1CaloRxLayersContainer::makePersistent
virtual DataObject * makePersistent() const
Definition: L1CaloRxLayersContainer.cxx:65
CaloCondBlobAlgs_fillNoiseFromASCII.channelId
channelId
Definition: CaloCondBlobAlgs_fillNoiseFromASCII.py:122
CondAttrListCollection::ChanNum
unsigned int ChanNum
Definition: CondAttrListCollection.h:55
L1CaloRxLayersContainer::coolFolderKey
std::string coolFolderKey(L1CaloRxLayersContainer::eCoolFolders efolder) const
Definition: L1CaloRxLayersContainer.cxx:45
L1CaloRxLayersContainer::eNCells3
@ eNCells3
Definition: L1CaloRxLayersContainer.h:32
L1CaloRxLayersContainer::eNCells2
@ eNCells2
Definition: L1CaloRxLayersContainer.h:32
L1CaloRxLayersContainer::makeTransient
virtual void makeTransient(const std::map< std::string, const CondAttrListCollection * > &condAttrListCollectionMap)
Definition: L1CaloRxLayersContainer.cxx:111
L1CaloRxLayersContainer::eName4
@ eName4
Definition: L1CaloRxLayersContainer.h:32
AbstractL1CaloPersistentCondition::specificationName
std::string specificationName(int specId) const
Definition: AbstractL1CaloPersistentCondition.cxx:44
python.LumiBlobConversion.pos
pos
Definition: LumiBlobConversion.py:18
python.PyAthena.v
v
Definition: PyAthena.py:154
L1CaloRxLayersContainer::end
const_iterator end() const
Definition: L1CaloRxLayersContainer.h:59
CondAttrListCollection::const_iterator
ChanAttrListMap::const_iterator const_iterator
Definition: CondAttrListCollection.h:63
L1CaloRxLayersContainer::eNCells1
@ eNCells1
Definition: L1CaloRxLayersContainer.h:32
L1CaloRxLayersContainer::eName2
@ eName2
Definition: L1CaloRxLayersContainer.h:32
L1CaloRxLayers
Class that holds information about calo layers that make up receivers.
Definition: L1CaloRxLayers.h:19
L1CaloRxLayersContainer::coolOutputKey
virtual std::string coolOutputKey() const
Definition: L1CaloRxLayersContainer.cxx:61
L1CaloRxLayersContainer::eNLayers
@ eNLayers
Definition: L1CaloRxLayersContainer.h:32
L1CaloRxLayersContainer::addRxLayers
void addRxLayers(unsigned int channelId, L1CaloRxLayers &&rxLayers)
Definition: L1CaloRxLayersContainer.cxx:171
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
L1CaloRxLayersContainer::clear
virtual void clear()
Definition: L1CaloRxLayersContainer.cxx:179