ATLAS Offline Software
L1CaloRunParametersContainer.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
3 */
5 
6 #include <algorithm>
7 #include <memory>
8 
9 #include "CoralBase/AttributeListSpecification.h"
12 
14 
16  : AbstractL1CaloPersistentCondition("CondAttrListCollection")
17 {
18  this->addSpecification(erunType, "runType", "string");
19  this->addSpecification(erunActionName, "runActionName", "string");
20  this->addSpecification(erunActionVersion, "runActionVersion", "unsigned int");
21  this->addSpecification(ereadoutConfig, "readoutConfig", "string");
22  this->addSpecification(ereadoutConfigID, "readoutConfigID", "unsigned int");
23  this->addSpecification(ettcConfiguration, "ttcConfiguration", "string");
24  this->addSpecification(ettcConfigurationID, "ttcConfigurationID", "unsigned int");
25  this->addSpecification(etriggerMenu, "triggerMenu", "string");
26  this->addSpecification(ecalibration, "calibration", "string");
27  this->addSpecification(econditions, "conditions", "string");
28 }
29 
31  : L1CaloRunParametersContainer() // delegating constructor
32 {
33  // cppcheck-suppress useInitializationList
34  m_coolFolderKey = folderKey;
35 }
36 
37 
39 {
40  using std::make_unique;
41 
42  if(m_coolFolderKey.empty()) return nullptr;
43 
44  auto* attrSpecification = this->createAttributeListSpecification();
45  if(!attrSpecification || !attrSpecification->size()) return nullptr;
46 
47  auto attrListCollection = make_unique<CondAttrListCollection>(true);
48  for(const auto& item : m_runParameterss) {
49  AthenaAttributeList attrList(*attrSpecification);
50  attrList[specificationName(erunType)].setValue(item.runType());
51  attrList[specificationName(erunActionName)].setValue(item.runActionName());
52  attrList[specificationName(erunActionVersion)].setValue(item.runActionVersion());
53  attrList[specificationName(ereadoutConfig)].setValue(item.readoutConfig());
54  attrList[specificationName(ereadoutConfigID)].setValue(item.readoutConfigID());
55  attrList[specificationName(ettcConfiguration)].setValue(item.ttcConfiguration());
56  attrList[specificationName(ettcConfigurationID)].setValue(item.ttcConfigurationID());
57  attrList[specificationName(etriggerMenu)].setValue(item.triggerMenu());
58  attrList[specificationName(ecalibration)].setValue(item.calibration());
59  attrList[specificationName(econditions)].setValue(item.conditions());
60 
61  attrListCollection->add(item.channelId(), attrList);
62  }
63  return static_cast<DataObject*>(attrListCollection.release());
64 }
65 
66 void L1CaloRunParametersContainer::makeTransient(const std::map<std::string, const CondAttrListCollection*>& condAttrListCollectionMap)
67 {
68  clear();
69 
70  auto it = condAttrListCollectionMap.find(m_coolFolderKey);
71  if(it == std::end(condAttrListCollectionMap)) return;
72 
73  auto attrListCollection = it->second;
74  for(const auto& item : *attrListCollection) {
75  auto chanNum = item.first;
76  const auto& attrList = item.second;
77 
78  auto runType = attrList[specificationName(erunType)].data<std::string>();
79  auto runActionName = attrList[specificationName(erunActionName)].data<std::string>();
80  auto runActionVersion = attrList[specificationName(erunActionVersion)].data<unsigned int>();
81  auto readoutConfig = attrList[specificationName(ereadoutConfig)].data<std::string>();
82  auto readoutConfigID = attrList[specificationName(ereadoutConfigID)].data<unsigned int>();
83  auto ttcConfiguration = attrList[specificationName(ettcConfiguration)].data<std::string>();
84  auto ttcConfigurationID = attrList[specificationName(ettcConfigurationID)].data<unsigned int>();
85  auto triggerMenu = attrList[specificationName(etriggerMenu)].data<std::string>();
86  auto calibration = attrList[specificationName(ecalibration)].data<std::string>();
87  auto conditions = attrList[specificationName(econditions)].data<std::string>();
88 
89  addRunParameters(L1CaloRunParameters(chanNum, runType, runActionName, runActionVersion, readoutConfig, readoutConfigID, ttcConfiguration, ttcConfigurationID, triggerMenu, calibration, conditions));
90  }
91 }
92 
94 {
95  auto it = std::lower_bound(std::begin(m_runParameterss),
97  channelId,
98  [](const L1CaloRunParameters& el, unsigned int val) -> bool {
99  return el.channelId() < val;
100  });
101  if(it == std::end(m_runParameterss)) return nullptr;
102  return &(*it);
103 }
104 
106 {
107  // insert into the correct position mainting the sorted vector
108  m_runParameterss.insert(std::lower_bound(std::begin(m_runParameterss),
111  [](const L1CaloRunParameters& el, unsigned int va) -> bool {
112  return el.channelId() < va;
113  }),
114  runParameters);
115 }
116 
119  for(;it!=this->end();++it) {
120  std::cout << " * item: " << *it <<std::endl;
121  }
122 }
CondAttrListCollection.h
This file defines the class for a collection of AttributeLists where each one is associated with a ch...
make_unique
std::unique_ptr< T > make_unique(Args &&... args)
Definition: SkimmingToolEXOT5.cxx:23
L1CaloRunParameters::channelId
unsigned int channelId() const
Definition: L1CaloRunParameters.h:24
PlotCalibFromCool.begin
begin
Definition: PlotCalibFromCool.py:94
L1CaloRunParametersContainer::ereadoutConfigID
@ ereadoutConfigID
Definition: L1CaloRunParametersContainer.h:36
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
L1CaloRunParametersContainer::etriggerMenu
@ etriggerMenu
Definition: L1CaloRunParametersContainer.h:36
L1CaloRunParametersContainer::m_coolFolderKey
std::string m_coolFolderKey
Definition: L1CaloRunParametersContainer.h:63
AthenaAttributeList.h
L1CaloRunParametersContainer::L1CaloRunParametersContainer
L1CaloRunParametersContainer()
Definition: L1CaloRunParametersContainer.cxx:15
AbstractL1CaloPersistentCondition::createAttributeListSpecification
coral::AttributeListSpecification * createAttributeListSpecification() const
Definition: AbstractL1CaloPersistentCondition.cxx:31
mergePhysValFiles.end
end
Definition: DataQuality/DataQualityUtils/scripts/mergePhysValFiles.py:93
L1CaloRunParametersContainer::addRunParameters
void addRunParameters(const L1CaloRunParameters &runParameters)
Definition: L1CaloRunParametersContainer.cxx:105
L1CaloRunParametersContainer::erunActionVersion
@ erunActionVersion
Definition: L1CaloRunParametersContainer.h:36
checkCoolLatestUpdate.chanNum
chanNum
Definition: checkCoolLatestUpdate.py:27
L1CaloRunParametersContainer::runParameters
const L1CaloRunParameters * runParameters(unsigned int channelId) const
Definition: L1CaloRunParametersContainer.cxx:93
L1CaloRunParametersContainer::econditions
@ econditions
Definition: L1CaloRunParametersContainer.h:36
L1CaloRunParametersContainer::dump
void dump() const
Definition: L1CaloRunParametersContainer.cxx:117
L1CaloRunParameters
Folder <-> Object mapping for /TRIGGER/L1Calo/V1/Conditions/RunParameters .
Definition: L1CaloRunParameters.h:18
L1CaloRunParametersContainer.h
L1CaloRunParametersContainer::const_iterator
std::vector< L1CaloRunParameters >::const_iterator const_iterator
Definition: L1CaloRunParametersContainer.h:52
plotIsoValidation.el
el
Definition: plotIsoValidation.py:197
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
L1CaloRunParametersContainer::ettcConfigurationID
@ ettcConfigurationID
Definition: L1CaloRunParametersContainer.h:36
python.OnlineISConfiguration.runType
def runType
Definition: OnlineISConfiguration.py:112
L1CaloRunParameters.h
L1CaloRunParametersContainer::begin
const_iterator begin() const
Definition: L1CaloRunParametersContainer.h:53
L1CaloRunParametersContainer::clear
virtual void clear()
Definition: L1CaloRunParametersContainer.h:44
L1CaloRunParametersContainer::ereadoutConfig
@ ereadoutConfig
Definition: L1CaloRunParametersContainer.h:36
L1CaloRunParametersContainer::ettcConfiguration
@ ettcConfiguration
Definition: L1CaloRunParametersContainer.h:36
item
Definition: ItemListSvc.h:43
AbstractL1CaloPersistentCondition::specificationName
std::string specificationName(int specId) const
Definition: AbstractL1CaloPersistentCondition.cxx:44
L1CaloRunParametersContainer::end
const_iterator end() const
Definition: L1CaloRunParametersContainer.h:54
L1CaloRunParametersContainer::makeTransient
virtual void makeTransient(const std::map< std::string, const CondAttrListCollection * > &)
Definition: L1CaloRunParametersContainer.cxx:66
Pythia8_RapidityOrderMPI.val
val
Definition: Pythia8_RapidityOrderMPI.py:14
L1CaloRunParametersContainer::erunType
@ erunType
Definition: L1CaloRunParametersContainer.h:36
L1CaloRunParametersContainer::erunActionName
@ erunActionName
Definition: L1CaloRunParametersContainer.h:36
L1CaloRunParametersContainer::ecalibration
@ ecalibration
Definition: L1CaloRunParametersContainer.h:36
L1CaloRunParametersContainer::makePersistent
virtual DataObject * makePersistent() const
Definition: L1CaloRunParametersContainer.cxx:38
L1CaloRunParametersContainer::m_runParameterss
std::vector< L1CaloRunParameters > m_runParameterss
Definition: L1CaloRunParametersContainer.h:62
AbstractL1CaloPersistentCondition
AbstractL1CaloConditionContainer abstract base class for L1Calo persistent conditions container objec...
Definition: AbstractL1CaloPersistentCondition.h:22
L1CaloRunParametersContainer
Definition: L1CaloRunParametersContainer.h:26