17#include "GaudiKernel/ConcurrencyFlags.h"
27 const std::string& name,
28 ISvcLocator* pSvcLocator)
47 <<
" has been succesfully registered ");
50 (
m_useDCS ?
"conditions" :
"parameters"));
52 ATH_MSG_INFO(
"Initialize: useDCS, useSoleCurrent, useToroCurrent. "
57 return StatusCode::SUCCESS;
72 << writeHandle.
fullKey() <<
" is already valid. "
73 <<
" May happen if multiple concurrent events are being "
74 "processed out of order.");
75 return StatusCode::SUCCESS;
91 if (mapCondObj ==
nullptr) {
92 ATH_MSG_ERROR(
"execute: Could not access conditions map for key: "
94 return StatusCode::FAILURE;
107 auto fieldCondObj = std::make_unique<AtlasFieldCacheCondObj>();
111 fieldCondObj->initialize(
119 "execute: Could not record AtlasFieldCacheCondObj object with "
121 <<
" into Conditions Store");
122 return StatusCode::FAILURE;
126 "execute: initialized AtlasFieldCacheCondObj and cache with SFs - sol/tor "
135 return StatusCode::SUCCESS;
140 const EventContext& ctx,
147 if (attrListColl ==
nullptr) {
148 ATH_MSG_ERROR(
"updateCurrentFromConditions: Failed to retrieve "
149 "CondAttributeListCollection with key "
151 return StatusCode::FAILURE;
156 if (!readHandle.
range(rangeW)) {
158 "updateCurrentFromConditions: Failed to retrieve validity range for "
159 << readHandle.
key());
160 return StatusCode::FAILURE;
163 ATH_MSG_INFO(
"UpdateCurrentFromConditions: Range of input/output is "
169 bool gotsol{
false };
170 bool gottor{
false };
177 bool hasChanNames{
false };
178 ATH_MSG_INFO(
"UpdateCurrentFromConditions: Attempt 1 at reading currents "
179 "from DCS (using channel name)");
181 itr != attrListColl->
end();
183 const std::string& name = attrListColl->
chanName(itr->first);
184 ATH_MSG_INFO(
"UpdateCurrentFromConditions: Trying to read from DCS: "
185 "[channel name, index, value] "
186 << name <<
" , " << itr->first <<
" , "
187 << itr->second[
"value"].data<
float>());
188 if (name.compare(
"") != 0) {
191 if (name.compare(
"CentralSol_Current") == 0) {
193 solcur = itr->second[
"value"].data<
float>();
195 }
else if (name.compare(
"Toroids_Current") == 0) {
197 torcur = itr->second[
"value"].data<
float>();
202 ATH_MSG_INFO(
"UpdateCurrentFromConditions: Attempt 2 at reading currents "
203 "from DCS (using channel index)");
206 itr != attrListColl->
end();
209 if (itr->first == 1) {
211 solcur = itr->second[
"value"].data<
float>();
213 }
else if (itr->first == 3) {
215 torcur = itr->second[
"value"].data<
float>();
220 if (!gotsol || !gottor) {
222 ATH_MSG_ERROR(
"UpdateCurrentFromConditions: Missing solenoid current in "
225 ATH_MSG_ERROR(
"UpdateCurrentFromConditions: Missing toroid current in "
227 return StatusCode::FAILURE;
230 ATH_MSG_INFO(
"UpdateCurrentFromConditions: Currents read from DCS - solenoid "
231 << solcur <<
" toroid " << torcur);
236 ATH_MSG_INFO(
"UpdateCurrentFromConditions: Solenoid is off");
240 ATH_MSG_INFO(
"UpdateCurrentFromConditions: Toroids are off");
246 return StatusCode::SUCCESS;
251 const EventContext& ctx,
260 ATH_MSG_INFO(
"updateCurrentFromParameters: Solenoid is off");
264 ATH_MSG_INFO(
"updateCurrentFromParameters: Toroids are off");
271 EventIDBase start, stop;
272 start.set_run_number(ctx.eventID().run_number());
273 start.set_lumi_block(0);
274 stop.set_run_number(ctx.eventID().run_number() + 1);
275 stop.set_lumi_block(0);
278 ATH_MSG_INFO(
"updateCurrentFromParameters: Update from job options: Range of "
282 return StatusCode::SUCCESS;
296 bool mapHasToroid = fieldMap && (fieldMap->
toroidCurrent()>0);
303 if (mapHasSolenoid &&
311 <<
". Desired current and map current: "
320 <<
". Desired current and map current: "
337 <<
". Desired current and map current: "
344 <<
". Desired current and map current: "
350 if (mapHasToroid && !mapHasSolenoid) {
355 if (!mapHasToroid && mapHasSolenoid) {
#define ATH_CHECK
Evaluate an expression and check for errors.
Base class for conditions algorithms.
const MagField::AtlasFieldMap * fieldMap() const
This class is a collection of AttributeLists where each one is associated with a channel number.
const_iterator end() const
const_iterator begin() const
Access to Chan/AttributeList pairs via iterators.
const std::string & chanName(ChanNum chanNum) const
find name for particular channel
ChanAttrListMap::const_iterator const_iterator
virtual ~AtlasFieldCacheCondAlg()
void scaleField(Cache &cache, const MagField::AtlasFieldMap *fieldMap) const
Gaudi::Property< double > m_useSoleCurrent
Gaudi::Property< double > m_useToroCurrent
SG::WriteCondHandleKey< AtlasFieldCacheCondObj > m_condObjOutputKey
Gaudi::Property< double > m_soleMinCurrent
StatusCode updateCurrentFromConditions(const EventContext &ctx, Cache &cache) const
StatusCode updateCurrentFromParameters(const EventContext &ctx, Cache &cache) const
SG::ReadCondHandleKey< CondAttrListCollection > m_currInputKey
Gaudi::Property< double > m_toroMinCurrent
Gaudi::Property< bool > m_useDCS
StatusCode initialize() override final
AtlasFieldCacheCondAlg(const std::string &name, ISvcLocator *pSvcLocator)
Gaudi::Property< bool > m_lockMapCurrents
SG::ReadCondHandleKey< AtlasFieldMapCondObj > m_mapCondObjInputKey
StatusCode execute(const EventContext &ctx) const override final
int solenoidZoneId() const
float toroidCurrent() const
float solenoidCurrent() const
bool range(EventIDRange &r)
const std::string & key() const
const std::string & key() const
StatusCode record(const EventIDRange &range, T *t)
record handle, with explicit range DEPRECATED
const DataObjID & fullKey() const
EventIDRange m_condObjOutputRange