ATLAS Offline Software
L1CaloCondAlg.cxx
Go to the documentation of this file.
1 // Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
2 
4 
5 
6 #include <iomanip>
11 
12 
13 L1CaloCondAlg :: L1CaloCondAlg ( const std::string &name,ISvcLocator *pSvcLocator): AthAlgorithm( name, pSvcLocator )
14 
15 
16 
17 {
18 
19 }
20 
21 
22 
23 
24 
26 {
27 
28  ATH_MSG_DEBUG( "initialize " << name() );
29 
30 
31 
32  // Disabled Towers
35 
36 
37  // Derived Run Pars
40 
41  // Ppr Channel Calib
43 
44  // Cond Container
46 
47 
48  // Ppr Defaults Calib
51 
52  // Ppr FineTime Refs
55 
56  // Run Parameters
59 
60  // PprChanStrategy
63 
64 
65  // Ppm Dead Channels
68 
69 
70  // Disabled Channel
72 
73  // Readout Config
76 
77  // Readout Config JSON (Run 3)
80 
84 
85  return StatusCode::SUCCESS;
86 
87 }
88 
89 template <typename T> StatusCode L1CaloCondAlg::updateCond(SG::WriteCondHandleKey<T>& wkey, std::vector<std::reference_wrapper<const SG::ReadCondHandleKey<CondAttrListCollection>>> rkeys, std::unique_ptr<T> obj) {
90  if(wkey.empty()) return StatusCode::SUCCESS; // no creation to do
92  if(wh.isValid()) return StatusCode::SUCCESS; // condition already valid, no update needed
93  std::map<std::string, const CondAttrListCollection *> listMap;
94  for(auto rkey : rkeys) { // note: rkey is a reference_wrapper round an actual sg key, hence the use of .get() below
95  if(rkey.get().empty()) continue;
97  CHECK(rh.isValid());
98  ATH_MSG_DEBUG("Size of CondAttrListCollection " << rh.fullKey() << " = " << rh->size());
99  wh.addDependency(rh); // will become invalid when read handle validity ends
100  listMap[rkey.get().key()] = *rh;
101  }
102  if (listMap.empty()) return StatusCode::SUCCESS;
103  if(!obj) obj = std::make_unique<T>();
104  obj->makeTransient(listMap);
105  CHECK(wh.record(std::move(obj)));
106  ATH_MSG_DEBUG("recorded new " << wkey.key() << " with range " << wh.getRange() << " into Conditions Store");
107  return StatusCode::SUCCESS;
108 }
109 
111 {
112 
113  ATH_MSG_DEBUG( "start execute " << name() );
114  ATH_MSG_DEBUG("readConditions() ");
115 
116  std::string timingRegime = m_timingRegime;
117  std::string strategy = m_strategy;
118 
119  if(!m_derivedRunPars.empty()) {
121  if(!writeHandleDerRunPars.isValid()) { // condition needs updating
123  CHECK(readHandleDerRunPars.isValid());
124  ATH_MSG_DEBUG("Size of CondAttrListCollection " << readHandleDerRunPars.fullKey() << " = " << readHandleDerRunPars->size());
125  writeHandleDerRunPars.addDependency(readHandleDerRunPars); // will become invalid when read handle validity ends
126  auto writeCdoDerRunPars = std::make_unique<L1CaloDerivedRunParsContainer>();
127  std::map<std::string, const CondAttrListCollection *> listMap;
128  listMap[m_derivedRunPars.key()] = *readHandleDerRunPars;
129  writeCdoDerRunPars->makeTransient(listMap);
130  if (timingRegime.empty()) {
131  timingRegime = std::cbegin(*writeCdoDerRunPars)->timingRegime();
132  }
133  CHECK(writeHandleDerRunPars.record(std::move(writeCdoDerRunPars)));
134  ATH_MSG_DEBUG("recorded new " << m_derivedRunParsContainer.key() << " with range " << writeHandleDerRunPars.getRange() << " into Conditions Store");
135 
136  ATH_MSG_DEBUG("timing regime --> "<< timingRegime );
137 
138  }
139  }
140 
141 
142  if(!m_pprChanStrategy.empty()) {
144  if(!writeHandlePprChanStrategy.isValid()) { // condition needs updating
146  CHECK(readHandlePprChanStrategy.isValid());
147  ATH_MSG_DEBUG("Size of CondAttrListCollection " << readHandlePprChanStrategy.fullKey() << " = " << readHandlePprChanStrategy->size());
148  writeHandlePprChanStrategy.addDependency(readHandlePprChanStrategy); // will become invalid when read handle validity ends
149  auto writeCdoPprChanStrategy = std::make_unique<L1CaloPprChanStrategyContainer>();
150  std::map<std::string, const CondAttrListCollection *> listMap;
151  listMap[m_pprChanStrategy.key()] = *readHandlePprChanStrategy;
152  writeCdoPprChanStrategy->makeTransient(listMap);
153  if (strategy.empty()) {
154  for(const auto& it: *writeCdoPprChanStrategy){
155  if (it.timingRegime() == timingRegime){
156  strategy = it.strategy();
157  }
158  }
159  }
160  CHECK(writeHandlePprChanStrategy.record(std::move(writeCdoPprChanStrategy)));
161  ATH_MSG_DEBUG("recorded new " << m_pprChanStrategyContainer.key() << " with range " << writeHandlePprChanStrategy.getRange() << " into Conditions Store");
162 
163  ATH_MSG_DEBUG("strategy selected --> " << strategy);
164 
165 
166 
167 
168  }
169  }
170 
178 
179  if (timingRegime == "") timingRegime="Physics"; // default to physics
180 
182  if (timingRegime == "Physics") {
183  pprKeys = &m_physicsKeys;
184  } else if (timingRegime == "Calib1") {
185  pprKeys = &m_calib1Keys;
186  } else if (timingRegime == "Calib2") {
187  pprKeys = &m_calib2Keys;
188  } else {
189  ATH_MSG_ERROR( "Bad timing regime " << timingRegime << "; must be one of Physics, Calib1, Calib2" );
190  return StatusCode::FAILURE;
191  }
192 
195 
196  // only need this logic if the conditionscontainerrun2 has expired ...
198  std::map <L1CaloPprConditionsContainerRun2::eCoolFolders, std::string> folderKeyMap;
200  if (strategy.empty()) {
201  folderKeyMap[L1CaloPprConditionsContainerRun2::ePprChanCalib] = pprKeys->at(PPRCHANCALIB).key();
202  auto obj = std::make_unique<L1CaloPprConditionsContainerRun2>(folderKeyMap); // must construct here to pass map to constructor
204  } else {
205  if (strategy != "HighMu" && strategy != "LowMu") {
206  ATH_MSG_ERROR("Invalid strategy: " << strategy << " (must be HighMu or LowMu)");
207  return StatusCode::FAILURE;
208  }
209  folderKeyMap[L1CaloPprConditionsContainerRun2::ePprChanCalibCommon] = pprKeys->at(PPRCHANCOMMON).key();
211  strategy == "HighMu" ? PPRCHANHIGHMU : PPRCHANLOWMU).key();
212 
213  auto obj = std::make_unique<L1CaloPprConditionsContainerRun2>(folderKeyMap);
214 
216  strategy == "HighMu" ? PPRCHANHIGHMU : PPRCHANLOWMU)}, std::move(obj)));
217  }
218  }
219 
220  return StatusCode::SUCCESS;
221 
222 }
xAOD::strategy
strategy
Definition: L2CombinedMuon_v1.cxx:107
L1CaloCondAlg::m_pprChanCalibContainer
SG::WriteCondHandleKey< L1CaloPprChanCalibContainer > m_pprChanCalibContainer
Definition: L1CaloCondAlg.h:83
IL1CaloPersistenceCapable.h
L1CaloCondAlg::m_pprChanDefaultsContainer
SG::WriteCondHandleKey< L1CaloPprChanDefaultsContainer > m_pprChanDefaultsContainer
Definition: L1CaloCondAlg.h:84
L1CaloCondAlg::m_readoutConfigContainerJSON
SG::WriteCondHandleKey< L1CaloReadoutConfigContainerJSON > m_readoutConfigContainerJSON
Definition: L1CaloCondAlg.h:92
SG::ReadCondHandle::fullKey
const DataObjID & fullKey() const
Definition: ReadCondHandle.h:60
CondAttrListCollection.h
This file defines the class for a collection of AttributeLists where each one is associated with a ch...
SG::ReadCondHandle
Definition: ReadCondHandle.h:44
L1CaloPprConditionsContainerRun2::ePprChanDefaults
@ ePprChanDefaults
Definition: L1CaloPprConditionsContainerRun2.h:45
L1CaloCondAlg::m_readoutConfigJSON
SG::ReadCondHandleKey< CondAttrListCollection > m_readoutConfigJSON
Definition: L1CaloCondAlg.h:77
skel.it
it
Definition: skel.GENtoEVGEN.py:396
SG::ReadCondHandle::isValid
bool isValid()
Definition: ReadCondHandle.h:206
L1CaloCondAlg::m_pprChanStrategy
SG::ReadCondHandleKey< CondAttrListCollection > m_pprChanStrategy
Definition: L1CaloCondAlg.h:75
SG::HandleKeyArray
Definition: StoreGate/StoreGate/HandleKeyArray.h:38
L1CaloCondAlg::m_pprDisabledChannelContainer
SG::WriteCondHandleKey< L1CaloPprDisabledChannelContainerRun2 > m_pprDisabledChannelContainer
Definition: L1CaloCondAlg.h:90
L1CaloCondAlg::PPRCHANHIGHMU
@ PPRCHANHIGHMU
Definition: L1CaloCondAlg.h:56
SG::VarHandleKey::key
const std::string & key() const
Return the StoreGate ID for the referenced object.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleKey.cxx:141
SG::VarHandleKey::empty
bool empty() const
Test if the key is blank.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleKey.cxx:150
L1CaloCondAlg::m_strategy
Gaudi::Property< std::string > m_strategy
Definition: L1CaloCondAlg.h:43
ReadCondHandle.h
L1CaloCondAlg::m_pprChanStrategyContainer
SG::WriteCondHandleKey< L1CaloPprChanStrategyContainer > m_pprChanStrategyContainer
Definition: L1CaloCondAlg.h:87
L1CaloCondAlg::m_useCalib1Regime
Gaudi::Property< bool > m_useCalib1Regime
Definition: L1CaloCondAlg.h:48
L1CaloCondAlg::m_ppmDeadChannelsContainer
SG::WriteCondHandleKey< L1CaloPpmDeadChannelsContainer > m_ppmDeadChannelsContainer
Definition: L1CaloCondAlg.h:88
L1CaloCondAlg::m_pprConditionsContainer
SG::WriteCondHandleKey< L1CaloPprConditionsContainerRun2 > m_pprConditionsContainer
Definition: L1CaloCondAlg.h:89
L1CaloCondAlg::m_timingRegime
Gaudi::Property< std::string > m_timingRegime
Definition: L1CaloCondAlg.h:42
L1CaloCondAlg::m_derivedRunParsContainer
SG::WriteCondHandleKey< L1CaloDerivedRunParsContainer > m_derivedRunParsContainer
Definition: L1CaloCondAlg.h:82
L1CaloCondAlg::m_useCalib2Regime
Gaudi::Property< bool > m_useCalib2Regime
Definition: L1CaloCondAlg.h:50
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
WriteCondHandle.h
L1CaloCondAlg::m_derivedRunPars
SG::ReadCondHandleKey< CondAttrListCollection > m_derivedRunPars
Definition: L1CaloCondAlg.h:69
L1CaloCondAlg::m_calib2Keys
SG::ReadCondHandleKeyArray< CondAttrListCollection > m_calib2Keys
Definition: L1CaloCondAlg.h:65
parseDir.wh
wh
Definition: parseDir.py:46
L1CaloCondAlg::execute
virtual StatusCode execute() override
Definition: L1CaloCondAlg.cxx:110
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
CHECK
#define CHECK(...)
Evaluate an expression and check for errors.
Definition: Control/AthenaKernel/AthenaKernel/errorcheck.h:422
L1CaloCondAlg::m_runParameters
SG::ReadCondHandleKey< CondAttrListCollection > m_runParameters
Definition: L1CaloCondAlg.h:72
L1CaloCondAlg::m_physicsKeys
SG::ReadCondHandleKeyArray< CondAttrListCollection > m_physicsKeys
Definition: L1CaloCondAlg.h:61
L1CaloPprConditionsContainerRun2::ePprChanCalib
@ ePprChanCalib
Definition: L1CaloPprConditionsContainerRun2.h:45
L1CaloCondAlg::m_calib1Keys
SG::ReadCondHandleKeyArray< CondAttrListCollection > m_calib1Keys
Definition: L1CaloCondAlg.h:63
L1CaloCondAlg::updateCond
StatusCode updateCond(SG::WriteCondHandleKey< T > &wkey, std::vector< std::reference_wrapper< const SG::ReadCondHandleKey< CondAttrListCollection >>> rkeys, std::unique_ptr< T > obj=nullptr)
Definition: L1CaloCondAlg.cxx:89
L1CaloCondAlg::m_usePhysicsRegime
Gaudi::Property< bool > m_usePhysicsRegime
Definition: L1CaloCondAlg.h:46
AthAlgorithm
Definition: AthAlgorithm.h:47
L1CaloCondAlg.h
L1CaloCondAlg::L1CaloCondAlg
L1CaloCondAlg(const std::string &name, ISvcLocator *pSvcLocator)
Definition: L1CaloCondAlg.cxx:13
L1CaloCondAlg::m_disabledTowersContainer
SG::WriteCondHandleKey< L1CaloDisabledTowersContainer > m_disabledTowersContainer
Definition: L1CaloCondAlg.h:81
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:221
L1CaloCondAlg::PPRCHANCALIB
@ PPRCHANCALIB
Definition: L1CaloCondAlg.h:54
SG::CondHandleKey::initialize
StatusCode initialize(bool used=true)
L1CaloCondAlg::PPRCHANLOWMU
@ PPRCHANLOWMU
Definition: L1CaloCondAlg.h:57
L1CaloCondAlg::m_readoutConfig
SG::ReadCondHandleKey< CondAttrListCollection > m_readoutConfig
Definition: L1CaloCondAlg.h:76
CondAttrListCollection::size
size_type size() const
number of Chan/AttributeList pairs
Definition: CondAttrListCollection.h:322
SG::ReadCondHandleKey< CondAttrListCollection >
L1CaloCondAlg::m_readoutConfigContainer
SG::WriteCondHandleKey< L1CaloReadoutConfigContainer > m_readoutConfigContainer
Definition: L1CaloCondAlg.h:91
L1CaloCondAlg::m_ppmFineTimeRefs
SG::ReadCondHandleKey< CondAttrListCollection > m_ppmFineTimeRefs
Definition: L1CaloCondAlg.h:71
L1CaloPprConditionsContainerRun2::ePprChanCalibStrategy
@ ePprChanCalibStrategy
Definition: L1CaloPprConditionsContainerRun2.h:45
L1CaloCondAlg::m_disabledTowers
SG::ReadCondHandleKey< CondAttrListCollection > m_disabledTowers
Definition: L1CaloCondAlg.h:68
SG::WriteCondHandle::isValid
bool isValid() const
Definition: WriteCondHandle.h:248
SG::WriteCondHandleKey
Definition: WriteCondHandleKey.h:20
L1CaloCondAlg::m_runParametersContainer
SG::WriteCondHandleKey< L1CaloRunParametersContainer > m_runParametersContainer
Definition: L1CaloCondAlg.h:86
L1CaloCondAlg::initialize
virtual StatusCode initialize() override
Definition: L1CaloCondAlg.cxx:25
L1CaloCondAlg::m_pprChanDefaults
SG::ReadCondHandleKey< CondAttrListCollection > m_pprChanDefaults
Definition: L1CaloCondAlg.h:74
python.PyAthena.obj
obj
Definition: PyAthena.py:132
L1CaloPprConditionsContainerRun2::ePprChanCalibCommon
@ ePprChanCalibCommon
Definition: L1CaloPprConditionsContainerRun2.h:45
SG::AllowEmpty
@ AllowEmpty
Definition: StoreGate/StoreGate/VarHandleKey.h:30
L1CaloCondAlg::m_ppmDeadChannels
SG::ReadCondHandleKey< CondAttrListCollection > m_ppmDeadChannels
Definition: L1CaloCondAlg.h:70
SG::WriteCondHandle
Definition: WriteCondHandle.h:26
L1CaloCondAlg::PPRCHANCOMMON
@ PPRCHANCOMMON
Definition: L1CaloCondAlg.h:55
L1CaloCondAlg::m_ppmFineTimeRefsContainer
SG::WriteCondHandleKey< L1CaloPpmFineTimeRefsContainer > m_ppmFineTimeRefsContainer
Definition: L1CaloCondAlg.h:85