ATLAS Offline Software
Loading...
Searching...
No Matches
L1CaloCondAlg.cxx
Go to the documentation of this file.
1// Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
2
4
5
6#include <iomanip>
11
12
13L1CaloCondAlg :: L1CaloCondAlg ( const std::string &name,ISvcLocator *pSvcLocator): AthCondAlgorithm( 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
89template <typename T> StatusCode L1CaloCondAlg::updateCond(const EventContext& ctx, const SG::WriteCondHandleKey<T>& wkey, const std::vector<std::reference_wrapper<const SG::ReadCondHandleKey<CondAttrListCollection>>>& rkeys, std::unique_ptr<T> obj) const {
90 if(wkey.empty()) return StatusCode::SUCCESS; // no creation to do
91 SG::WriteCondHandle<T> wh{wkey, ctx};
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;
96 SG::ReadCondHandle <CondAttrListCollection> rh(rkey.get(), ctx);
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
110StatusCode L1CaloCondAlg::execute (const EventContext& ctx) const
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
122 SG::ReadCondHandle <CondAttrListCollection> readHandleDerRunPars(m_derivedRunPars, ctx);
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 ...
197 if(!m_pprConditionsContainer.empty() && !SG::WriteCondHandle<L1CaloPprConditionsContainerRun2>{m_pprConditionsContainer, ctx}.isValid()) {
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
203 CHECK(updateCond(ctx, m_pprConditionsContainer, {m_pprChanDefaults, pprKeys->at(PPRCHANCALIB)}, std::move(obj)));
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 }
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}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
#define ATH_MSG_DEBUG(x)
This file defines the class for a collection of AttributeLists where each one is associated with a ch...
#define CHECK(...)
Evaluate an expression and check for errors.
Base class for conditions algorithms.
SG::ReadCondHandleKeyArray< CondAttrListCollection > m_calib2Keys
SG::WriteCondHandleKey< L1CaloPprChanStrategyContainer > m_pprChanStrategyContainer
SG::ReadCondHandleKey< CondAttrListCollection > m_ppmDeadChannels
Gaudi::Property< bool > m_useCalib2Regime
SG::ReadCondHandleKeyArray< CondAttrListCollection > m_physicsKeys
SG::WriteCondHandleKey< L1CaloDisabledTowersContainer > m_disabledTowersContainer
virtual StatusCode execute(const EventContext &ctx) const override
SG::ReadCondHandleKey< CondAttrListCollection > m_pprChanStrategy
SG::WriteCondHandleKey< L1CaloDerivedRunParsContainer > m_derivedRunParsContainer
SG::ReadCondHandleKey< CondAttrListCollection > m_ppmFineTimeRefs
SG::WriteCondHandleKey< L1CaloPprChanCalibContainer > m_pprChanCalibContainer
Gaudi::Property< std::string > m_strategy
SG::WriteCondHandleKey< L1CaloPpmFineTimeRefsContainer > m_ppmFineTimeRefsContainer
SG::WriteCondHandleKey< L1CaloPpmDeadChannelsContainer > m_ppmDeadChannelsContainer
SG::ReadCondHandleKey< CondAttrListCollection > m_derivedRunPars
SG::WriteCondHandleKey< L1CaloReadoutConfigContainerJSON > m_readoutConfigContainerJSON
SG::ReadCondHandleKey< CondAttrListCollection > m_runParameters
SG::WriteCondHandleKey< L1CaloPprDisabledChannelContainerRun2 > m_pprDisabledChannelContainer
virtual StatusCode initialize() override
StatusCode updateCond(const EventContext &ctx, const SG::WriteCondHandleKey< T > &wkey, const std::vector< std::reference_wrapper< const SG::ReadCondHandleKey< CondAttrListCollection > > > &rkeys, std::unique_ptr< T > obj=nullptr) const
SG::WriteCondHandleKey< L1CaloReadoutConfigContainer > m_readoutConfigContainer
SG::ReadCondHandleKey< CondAttrListCollection > m_disabledTowers
SG::ReadCondHandleKey< CondAttrListCollection > m_pprChanDefaults
Gaudi::Property< bool > m_useCalib1Regime
SG::ReadCondHandleKeyArray< CondAttrListCollection > m_calib1Keys
SG::WriteCondHandleKey< L1CaloRunParametersContainer > m_runParametersContainer
SG::WriteCondHandleKey< L1CaloPprConditionsContainerRun2 > m_pprConditionsContainer
SG::WriteCondHandleKey< L1CaloPprChanDefaultsContainer > m_pprChanDefaultsContainer
SG::ReadCondHandleKey< CondAttrListCollection > m_readoutConfig
Gaudi::Property< bool > m_usePhysicsRegime
Gaudi::Property< std::string > m_timingRegime
SG::ReadCondHandleKey< CondAttrListCollection > m_readoutConfigJSON
const DataObjID & fullKey() const
const std::string & key() const
Return the StoreGate ID for the referenced object.
bool empty() const
Test if the key is blank.
void addDependency(const EventIDRange &range)
const EventIDRange & getRange() const
StatusCode record(const EventIDRange &range, T *t)
record handle, with explicit range DEPRECATED
HandleKeyArray< ReadCondHandle< T >, CondHandleDefault::Key< ReadCondHandleKey< T > >, Gaudi::DataHandle::Reader > ReadCondHandleKeyArray