ATLAS Offline Software
L1CaloDerivedRunParsContainer.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2022 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(etimingRegime, "timingRegime", "string");
19  this->addSpecification(etierZeroTag, "tierZeroTag", "string");
20 }
21 
23  : L1CaloDerivedRunParsContainer() // delegating constructor
24 {
25  // cppcheck-suppress useInitializationList
26  m_coolFolderKey = folderKey;
27 }
28 
29 
31 {
32  using std::make_unique;
33 
34  if(m_coolFolderKey.empty()) return nullptr;
35 
36  auto* attrSpecification = this->createAttributeListSpecification();
37  if(!attrSpecification || !attrSpecification->size()) return nullptr;
38 
39  auto attrListCollection = make_unique<CondAttrListCollection>(true);
40  for(const auto& item : m_derivedRunParss) {
41  AthenaAttributeList attrList(*attrSpecification);
42  attrList[specificationName(etimingRegime)].setValue(item.timingRegime());
43  attrList[specificationName(etierZeroTag)].setValue(item.tierZeroTag());
44 
45  attrListCollection->add(item.channelId(), attrList);
46  }
47  return static_cast<DataObject*>(attrListCollection.release());
48 }
49 
50 void L1CaloDerivedRunParsContainer::makeTransient(const std::map<std::string, const CondAttrListCollection*>& condAttrListCollectionMap)
51 {
52  clear();
53 
54  auto it = condAttrListCollectionMap.find(m_coolFolderKey);
55  if(it == std::end(condAttrListCollectionMap)) return;
56 
57  auto attrListCollection = it->second;
58  for(const auto& item : *attrListCollection) {
59  auto chanNum = item.first;
60  const auto& attrList = item.second;
61 
62  auto timingRegime = attrList[specificationName(etimingRegime)].data<std::string>();
63  auto tierZeroTag = attrList[specificationName(etierZeroTag)].data<std::string>();
64 
65  addDerivedRunPars(L1CaloDerivedRunPars(chanNum, timingRegime, tierZeroTag));
66  }
67 }
68 
70 {
71  auto it = std::lower_bound(std::begin(m_derivedRunParss),
73  channelId,
74  [](const L1CaloDerivedRunPars& el, unsigned int val) -> bool {
75  return el.channelId() < val;
76  });
77  if(it == std::end(m_derivedRunParss)) return nullptr;
78  return &(*it);
79 }
80 
82 {
83  // insert into the correct position mainting the sorted vector
84  m_derivedRunParss.insert(std::lower_bound(std::begin(m_derivedRunParss),
87  [](const L1CaloDerivedRunPars& el, unsigned int va) -> bool {
88  return el.channelId() < va;
89  }),
91 }
92 
93 
96  for(;it!=this->end();++it) {
97  std::cout << " * item: " << *it <<std::endl;
98  }
99 }
L1CaloDerivedRunPars::channelId
unsigned int channelId() const
Definition: L1CaloDerivedRunPars.h:23
CondAttrListCollection.h
This file defines the class for a collection of AttributeLists where each one is associated with a ch...
L1CaloDerivedRunPars
Folder <-> Object mapping for /TRIGGER/L1Calo/V1/Conditions/DerivedRunPars .
Definition: L1CaloDerivedRunPars.h:17
make_unique
std::unique_ptr< T > make_unique(Args &&... args)
Definition: SkimmingToolEXOT5.cxx:23
PlotCalibFromCool.begin
begin
Definition: PlotCalibFromCool.py:94
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
L1CaloDerivedRunParsContainer::makeTransient
virtual void makeTransient(const std::map< std::string, const CondAttrListCollection * > &)
Definition: L1CaloDerivedRunParsContainer.cxx:50
L1CaloDerivedRunParsContainer::addDerivedRunPars
void addDerivedRunPars(const L1CaloDerivedRunPars &derivedRunPars)
Definition: L1CaloDerivedRunParsContainer.cxx:81
AthenaAttributeList.h
L1CaloDerivedRunParsContainer.h
L1CaloDerivedRunParsContainer::derivedRunPars
const L1CaloDerivedRunPars * derivedRunPars(unsigned int channelId) const
Definition: L1CaloDerivedRunParsContainer.cxx:69
L1CaloDerivedRunPars.h
AbstractL1CaloPersistentCondition::createAttributeListSpecification
coral::AttributeListSpecification * createAttributeListSpecification() const
Definition: AbstractL1CaloPersistentCondition.cxx:31
mergePhysValFiles.end
end
Definition: DataQuality/DataQualityUtils/scripts/mergePhysValFiles.py:93
L1CaloDerivedRunParsContainer::etimingRegime
@ etimingRegime
Definition: L1CaloDerivedRunParsContainer.h:36
L1CaloDerivedRunParsContainer::makePersistent
virtual DataObject * makePersistent() const
Definition: L1CaloDerivedRunParsContainer.cxx:30
L1CaloDerivedRunParsContainer::begin
const_iterator begin() const
Definition: L1CaloDerivedRunParsContainer.h:53
L1CaloDerivedRunParsContainer::L1CaloDerivedRunParsContainer
L1CaloDerivedRunParsContainer()
Definition: L1CaloDerivedRunParsContainer.cxx:15
checkCoolLatestUpdate.chanNum
chanNum
Definition: checkCoolLatestUpdate.py:27
L1CaloDerivedRunParsContainer::m_derivedRunParss
std::vector< L1CaloDerivedRunPars > m_derivedRunParss
Definition: L1CaloDerivedRunParsContainer.h:62
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
L1CaloDerivedRunParsContainer
Definition: L1CaloDerivedRunParsContainer.h:26
item
Definition: ItemListSvc.h:43
AbstractL1CaloPersistentCondition::specificationName
std::string specificationName(int specId) const
Definition: AbstractL1CaloPersistentCondition.cxx:44
L1CaloDerivedRunParsContainer::const_iterator
std::vector< L1CaloDerivedRunPars >::const_iterator const_iterator
Definition: L1CaloDerivedRunParsContainer.h:52
L1CaloDerivedRunParsContainer::clear
virtual void clear()
Definition: L1CaloDerivedRunParsContainer.h:44
Pythia8_RapidityOrderMPI.val
val
Definition: Pythia8_RapidityOrderMPI.py:14
L1CaloDerivedRunParsContainer::etierZeroTag
@ etierZeroTag
Definition: L1CaloDerivedRunParsContainer.h:36
L1CaloDerivedRunParsContainer::m_coolFolderKey
std::string m_coolFolderKey
Definition: L1CaloDerivedRunParsContainer.h:63
L1CaloDerivedRunParsContainer::end
const_iterator end() const
Definition: L1CaloDerivedRunParsContainer.h:54
AbstractL1CaloPersistentCondition
AbstractL1CaloConditionContainer abstract base class for L1Calo persistent conditions container objec...
Definition: AbstractL1CaloPersistentCondition.h:22
L1CaloDerivedRunParsContainer::dump
void dump() const
Definition: L1CaloDerivedRunParsContainer.cxx:94