ATLAS Offline Software
Classes | Public Member Functions | Protected Member Functions | Private Types | Private Member Functions | Private Attributes | List of all members
MagField::AtlasFieldCacheCondAlg Class Reference

#include <AtlasFieldCacheCondAlg.h>

Inheritance diagram for MagField::AtlasFieldCacheCondAlg:
Collaboration diagram for MagField::AtlasFieldCacheCondAlg:

Classes

struct  Cache
 

Public Member Functions

 AtlasFieldCacheCondAlg (const std::string &name, ISvcLocator *pSvcLocator)
 
virtual ~AtlasFieldCacheCondAlg ()
 
StatusCode initialize () override final
 
StatusCode execute (const EventContext &ctx) const override final
 
virtual bool isReEntrant () const override final
 
virtual StatusCode sysInitialize () override
 Override sysInitialize. More...
 
virtual bool isClonable () const override
 Specify if the algorithm is clonable. More...
 
virtual unsigned int cardinality () const override
 Cardinality (Maximum number of clones that can exist) special value 0 means that algorithm is reentrant. More...
 
virtual StatusCode sysExecute (const EventContext &ctx) override
 Execute an algorithm. More...
 
virtual const DataObjIDColl & extraOutputDeps () const override
 Return the list of extra output dependencies. More...
 
virtual bool filterPassed (const EventContext &ctx) const
 
virtual void setFilterPassed (bool state, const EventContext &ctx) const
 
ServiceHandle< StoreGateSvc > & evtStore ()
 The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc. More...
 
const ServiceHandle< StoreGateSvc > & evtStore () const
 The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc. More...
 
const ServiceHandle< StoreGateSvc > & detStore () const
 The standard StoreGateSvc/DetectorStore Returns (kind of) a pointer to the StoreGateSvc. More...
 
virtual StatusCode sysStart () override
 Handle START transition. More...
 
virtual std::vector< Gaudi::DataHandle * > inputHandles () const override
 Return this algorithm's input handles. More...
 
virtual std::vector< Gaudi::DataHandle * > outputHandles () const override
 Return this algorithm's output handles. More...
 
Gaudi::Details::PropertyBase & declareProperty (Gaudi::Property< T > &t)
 
Gaudi::Details::PropertyBase * declareProperty (const std::string &name, SG::VarHandleKey &hndl, const std::string &doc, const SG::VarHandleKeyType &)
 Declare a new Gaudi property. More...
 
Gaudi::Details::PropertyBase * declareProperty (const std::string &name, SG::VarHandleBase &hndl, const std::string &doc, const SG::VarHandleType &)
 Declare a new Gaudi property. More...
 
Gaudi::Details::PropertyBase * declareProperty (const std::string &name, SG::VarHandleKeyArray &hndArr, const std::string &doc, const SG::VarHandleKeyArrayType &)
 
Gaudi::Details::PropertyBase * declareProperty (const std::string &name, T &property, const std::string &doc, const SG::NotHandleType &)
 Declare a new Gaudi property. More...
 
Gaudi::Details::PropertyBase * declareProperty (const std::string &name, T &property, const std::string &doc="none")
 Declare a new Gaudi property. More...
 
void updateVHKA (Gaudi::Details::PropertyBase &)
 
MsgStream & msg () const
 
MsgStream & msg (const MSG::Level lvl) const
 
bool msgLvl (const MSG::Level lvl) const
 

Protected Member Functions

void renounceArray (SG::VarHandleKeyArray &handlesArray)
 remove all handles from I/O resolution More...
 
std::enable_if_t< std::is_void_v< std::result_of_t< decltype(&T::renounce)(T)> > &&!std::is_base_of_v< SG::VarHandleKeyArray, T > &&std::is_base_of_v< Gaudi::DataHandle, T >, void > renounce (T &h)
 
void extraDeps_update_handler (Gaudi::Details::PropertyBase &ExtraDeps)
 Add StoreName to extra input/output deps as needed. More...
 

Private Types

typedef ServiceHandle< StoreGateSvcStoreGateSvc_t
 

Private Member Functions

StatusCode updateCurrentFromConditions (const EventContext &ctx, Cache &cache) const
 
StatusCode updateCurrentFromParameters (const EventContext &ctx, Cache &cache) const
 
void scaleField (Cache &cache, const MagField::AtlasFieldMap *fieldMap) const
 
Gaudi::Details::PropertyBase & declareGaudiProperty (Gaudi::Property< T > &hndl, const SG::VarHandleKeyType &)
 specialization for handling Gaudi::Property<SG::VarHandleKey> More...
 
Gaudi::Details::PropertyBase & declareGaudiProperty (Gaudi::Property< T > &hndl, const SG::VarHandleKeyArrayType &)
 specialization for handling Gaudi::Property<SG::VarHandleKeyArray> More...
 
Gaudi::Details::PropertyBase & declareGaudiProperty (Gaudi::Property< T > &hndl, const SG::VarHandleType &)
 specialization for handling Gaudi::Property<SG::VarHandleBase> More...
 
Gaudi::Details::PropertyBase & declareGaudiProperty (Gaudi::Property< T > &t, const SG::NotHandleType &)
 specialization for handling everything that's not a Gaudi::Property<SG::VarHandleKey> or a <SG::VarHandleKeyArray> More...
 

Private Attributes

Gaudi::Property< double > m_soleMinCurrent
 
Gaudi::Property< double > m_toroMinCurrent
 
Gaudi::Property< bool > m_useDCS
 
Gaudi::Property< bool > m_lockMapCurrents
 
SG::ReadCondHandleKey< CondAttrListCollectionm_currInputKey
 
SG::ReadCondHandleKey< AtlasFieldMapCondObjm_mapCondObjInputKey
 
SG::WriteCondHandleKey< AtlasFieldCacheCondObjm_condObjOutputKey
 
Gaudi::Property< double > m_useSoleCurrent
 
Gaudi::Property< double > m_useToroCurrent
 
DataObjIDColl m_extendedExtraObjects
 Extra output dependency collection, extended by AthAlgorithmDHUpdate to add symlinks. More...
 
StoreGateSvc_t m_evtStore
 Pointer to StoreGate (event store by default) More...
 
StoreGateSvc_t m_detStore
 Pointer to StoreGate (detector store by default) More...
 
std::vector< SG::VarHandleKeyArray * > m_vhka
 
bool m_varHandleArraysDeclared
 

Detailed Description

Definition at line 23 of file AtlasFieldCacheCondAlg.h.

Member Typedef Documentation

◆ StoreGateSvc_t

typedef ServiceHandle<StoreGateSvc> AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::StoreGateSvc_t
privateinherited

Definition at line 388 of file AthCommonDataStore.h.

Constructor & Destructor Documentation

◆ AtlasFieldCacheCondAlg()

AtlasFieldCacheCondAlg::AtlasFieldCacheCondAlg ( const std::string &  name,
ISvcLocator *  pSvcLocator 
)

Definition at line 26 of file AtlasFieldCacheCondAlg.cxx.

29  : AthReentrantAlgorithm(name, pSvcLocator)
30 {}

◆ ~AtlasFieldCacheCondAlg()

AtlasFieldCacheCondAlg::~AtlasFieldCacheCondAlg ( )
virtualdefault

Member Function Documentation

◆ cardinality()

unsigned int AthReentrantAlgorithm::cardinality ( ) const
overridevirtualinherited

Cardinality (Maximum number of clones that can exist) special value 0 means that algorithm is reentrant.

Override this to return 0 for reentrant algorithms.

Override this to return 0 for reentrant algorithms.

Definition at line 55 of file AthReentrantAlgorithm.cxx.

56 {
57  return 0;
58 }

◆ declareGaudiProperty() [1/4]

Gaudi::Details::PropertyBase& AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::declareGaudiProperty ( Gaudi::Property< T > &  hndl,
const SG::VarHandleKeyArrayType  
)
inlineprivateinherited

specialization for handling Gaudi::Property<SG::VarHandleKeyArray>

Definition at line 170 of file AthCommonDataStore.h.

172  {
173  return *AthCommonDataStore<PBASE>::declareProperty(hndl.name(),
174  hndl.value(),
175  hndl.documentation());
176 
177  }

◆ declareGaudiProperty() [2/4]

Gaudi::Details::PropertyBase& AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::declareGaudiProperty ( Gaudi::Property< T > &  hndl,
const SG::VarHandleKeyType  
)
inlineprivateinherited

specialization for handling Gaudi::Property<SG::VarHandleKey>

Definition at line 156 of file AthCommonDataStore.h.

158  {
159  return *AthCommonDataStore<PBASE>::declareProperty(hndl.name(),
160  hndl.value(),
161  hndl.documentation());
162 
163  }

◆ declareGaudiProperty() [3/4]

Gaudi::Details::PropertyBase& AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::declareGaudiProperty ( Gaudi::Property< T > &  hndl,
const SG::VarHandleType  
)
inlineprivateinherited

specialization for handling Gaudi::Property<SG::VarHandleBase>

Definition at line 184 of file AthCommonDataStore.h.

186  {
187  return *AthCommonDataStore<PBASE>::declareProperty(hndl.name(),
188  hndl.value(),
189  hndl.documentation());
190  }

◆ declareGaudiProperty() [4/4]

Gaudi::Details::PropertyBase& AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::declareGaudiProperty ( Gaudi::Property< T > &  t,
const SG::NotHandleType  
)
inlineprivateinherited

specialization for handling everything that's not a Gaudi::Property<SG::VarHandleKey> or a <SG::VarHandleKeyArray>

Definition at line 199 of file AthCommonDataStore.h.

200  {
201  return PBASE::declareProperty(t);
202  }

◆ declareProperty() [1/6]

Gaudi::Details::PropertyBase* AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::declareProperty ( const std::string &  name,
SG::VarHandleBase hndl,
const std::string &  doc,
const SG::VarHandleType  
)
inlineinherited

Declare a new Gaudi property.

Parameters
nameName of the property.
hndlObject holding the property value.
docDocumentation string for the property.

This is the version for types that derive from SG::VarHandleBase. The property value object is put on the input and output lists as appropriate; then we forward to the base class.

Definition at line 245 of file AthCommonDataStore.h.

249  {
250  this->declare(hndl.vhKey());
251  hndl.vhKey().setOwner(this);
252 
253  return PBASE::declareProperty(name,hndl,doc);
254  }

◆ declareProperty() [2/6]

Gaudi::Details::PropertyBase* AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::declareProperty ( const std::string &  name,
SG::VarHandleKey hndl,
const std::string &  doc,
const SG::VarHandleKeyType  
)
inlineinherited

Declare a new Gaudi property.

Parameters
nameName of the property.
hndlObject holding the property value.
docDocumentation string for the property.

This is the version for types that derive from SG::VarHandleKey. The property value object is put on the input and output lists as appropriate; then we forward to the base class.

Definition at line 221 of file AthCommonDataStore.h.

225  {
226  this->declare(hndl);
227  hndl.setOwner(this);
228 
229  return PBASE::declareProperty(name,hndl,doc);
230  }

◆ declareProperty() [3/6]

Gaudi::Details::PropertyBase* AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::declareProperty ( const std::string &  name,
SG::VarHandleKeyArray hndArr,
const std::string &  doc,
const SG::VarHandleKeyArrayType  
)
inlineinherited

Definition at line 259 of file AthCommonDataStore.h.

263  {
264 
265  // std::ostringstream ost;
266  // ost << Algorithm::name() << " VHKA declareProp: " << name
267  // << " size: " << hndArr.keys().size()
268  // << " mode: " << hndArr.mode()
269  // << " vhka size: " << m_vhka.size()
270  // << "\n";
271  // debug() << ost.str() << endmsg;
272 
273  hndArr.setOwner(this);
274  m_vhka.push_back(&hndArr);
275 
276  Gaudi::Details::PropertyBase* p = PBASE::declareProperty(name, hndArr, doc);
277  if (p != 0) {
278  p->declareUpdateHandler(&AthCommonDataStore<PBASE>::updateVHKA, this);
279  } else {
280  ATH_MSG_ERROR("unable to call declareProperty on VarHandleKeyArray "
281  << name);
282  }
283 
284  return p;
285 
286  }

◆ declareProperty() [4/6]

Gaudi::Details::PropertyBase* AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::declareProperty ( const std::string &  name,
T &  property,
const std::string &  doc,
const SG::NotHandleType  
)
inlineinherited

Declare a new Gaudi property.

Parameters
nameName of the property.
propertyObject holding the property value.
docDocumentation string for the property.

This is the generic version, for types that do not derive from SG::VarHandleKey. It just forwards to the base class version of declareProperty.

Definition at line 333 of file AthCommonDataStore.h.

337  {
338  return PBASE::declareProperty(name, property, doc);
339  }

◆ declareProperty() [5/6]

Gaudi::Details::PropertyBase* AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::declareProperty ( const std::string &  name,
T &  property,
const std::string &  doc = "none" 
)
inlineinherited

Declare a new Gaudi property.

Parameters
nameName of the property.
propertyObject holding the property value.
docDocumentation string for the property.

This dispatches to either the generic declareProperty or the one for VarHandle/Key/KeyArray.

Definition at line 352 of file AthCommonDataStore.h.

355  {
356  typedef typename SG::HandleClassifier<T>::type htype;
357  return declareProperty (name, property, doc, htype());
358  }

◆ declareProperty() [6/6]

Gaudi::Details::PropertyBase& AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::declareProperty ( Gaudi::Property< T > &  t)
inlineinherited

Definition at line 145 of file AthCommonDataStore.h.

145  {
146  typedef typename SG::HandleClassifier<T>::type htype;
148  }

◆ detStore()

const ServiceHandle<StoreGateSvc>& AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::detStore ( ) const
inlineinherited

The standard StoreGateSvc/DetectorStore Returns (kind of) a pointer to the StoreGateSvc.

Definition at line 95 of file AthCommonDataStore.h.

95 { return m_detStore; }

◆ evtStore() [1/2]

ServiceHandle<StoreGateSvc>& AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::evtStore ( )
inlineinherited

The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc.

Definition at line 85 of file AthCommonDataStore.h.

85 { return m_evtStore; }

◆ evtStore() [2/2]

const ServiceHandle<StoreGateSvc>& AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::evtStore ( ) const
inlineinherited

The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc.

Definition at line 90 of file AthCommonDataStore.h.

90 { return m_evtStore; }

◆ execute()

StatusCode AtlasFieldCacheCondAlg::execute ( const EventContext &  ctx) const
finaloverride

Definition at line 61 of file AtlasFieldCacheCondAlg.cxx.

62 {
63 
64  ATH_MSG_DEBUG("execute: entering");
65 
66  // Check if output conditions object with field cache object is still valid,
67  // if not replace it with new current scale factors
69  ctx };
70  if (writeHandle.isValid()) {
71  ATH_MSG_DEBUG("execute: CondHandle "
72  << writeHandle.fullKey() << " is already valid. "
73  << " May happen if multiple concurrent events are being "
74  "processed out of order.");
75  return StatusCode::SUCCESS;
76  }
77 
78  // This will need to be filled before we construct the condition object
79  Cache cache{};
80 
81  if (m_useDCS) {
83  } else {
85  }
86 
87  // Must read map cond object to get previously created map
89  ctx };
90  const AtlasFieldMapCondObj* mapCondObj{ *mapReadHandle };
91  if (mapCondObj == nullptr) {
92  ATH_MSG_ERROR("execute: Could not access conditions map for key: "
93  << m_mapCondObjInputKey.fullKey());
94  return StatusCode::FAILURE;
95  }
96 
97  // simple pointer to the map, to be give to the AtlasFieldCacheCondObj, used
98  // for the cache field map access
99  const MagField::AtlasFieldMap* fieldMap = mapCondObj->fieldMap();
100 
101  // calculate the scale factors
102  if (!m_lockMapCurrents) {
103  scaleField(cache, fieldMap);
104  }
105 
106  // save current scale factor in conditions object
107  auto fieldCondObj = std::make_unique<AtlasFieldCacheCondObj>();
108 
109  // initialize cond obj with current scale factors and the field svc (needed to
110  // setup cache)
111  fieldCondObj->initialize(
112  cache.m_solScaleFactor, cache.m_torScaleFactor, fieldMap);
113 
114  // Record in conditions store the conditions object with scale factors and map
115  // pointer for cache
116  if (writeHandle.record(cache.m_condObjOutputRange, std::move(fieldCondObj))
117  .isFailure()) {
119  "execute: Could not record AtlasFieldCacheCondObj object with "
120  << writeHandle.key() << " with EventRange " << cache.m_condObjOutputRange
121  << " into Conditions Store");
122  return StatusCode::FAILURE;
123  }
124 
125  ATH_MSG_INFO(
126  "execute: initialized AtlasFieldCacheCondObj and cache with SFs - sol/tor "
127  << cache.m_solScaleFactor << "/" << cache.m_torScaleFactor
128  << ", EventRange " << cache.m_condObjOutputRange);
129  if (fieldMap) {
130  ATH_MSG_INFO("execute: solenoid zone id " << fieldMap->solenoidZoneId());
131  } else {
132  ATH_MSG_INFO("execute: no map read (currents == 0");
133  }
134 
135  return StatusCode::SUCCESS;
136 }

◆ extraDeps_update_handler()

void AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::extraDeps_update_handler ( Gaudi::Details::PropertyBase &  ExtraDeps)
protectedinherited

Add StoreName to extra input/output deps as needed.

use the logic of the VarHandleKey to parse the DataObjID keys supplied via the ExtraInputs and ExtraOuputs Properties to add the StoreName if it's not explicitly given

◆ extraOutputDeps()

const DataObjIDColl & AthReentrantAlgorithm::extraOutputDeps ( ) const
overridevirtualinherited

Return the list of extra output dependencies.

This list is extended to include symlinks implied by inheritance relations.

Definition at line 79 of file AthReentrantAlgorithm.cxx.

80 {
81  // If we didn't find any symlinks to add, just return the collection
82  // from the base class. Otherwise, return the extended collection.
83  if (!m_extendedExtraObjects.empty()) {
85  }
86  return Algorithm::extraOutputDeps();
87 }

◆ filterPassed()

virtual bool AthReentrantAlgorithm::filterPassed ( const EventContext &  ctx) const
inlinevirtualinherited

Definition at line 135 of file AthReentrantAlgorithm.h.

135  {
136  return execState( ctx ).filterPassed();
137  }

◆ initialize()

StatusCode AtlasFieldCacheCondAlg::initialize ( )
finaloverride

Definition at line 35 of file AtlasFieldCacheCondAlg.cxx.

36 {
37  // Read Handle for the current
39 
40  // Read handle for the field map cond object
42 
43  // Output handle for scale factors/cache
45 
46  ATH_MSG_DEBUG("Initialize: Key " << m_condObjOutputKey.fullKey()
47  << " has been succesfully registered ");
48 
49  ATH_MSG_INFO("Initialize: Will update current from " <<
50  (m_useDCS ? "conditions" : "parameters"));
51 
52  ATH_MSG_INFO("Initialize: useDCS, useSoleCurrent, useToroCurrent. "
53  << (int)m_useDCS << ", " << m_useSoleCurrent << ", "
54  << m_useToroCurrent << " LockMapCurrents "
55  << (int)m_lockMapCurrents);
56 
57  return StatusCode::SUCCESS;
58 }

◆ inputHandles()

virtual std::vector<Gaudi::DataHandle*> AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::inputHandles ( ) const
overridevirtualinherited

Return this algorithm's input handles.

We override this to include handle instances from key arrays if they have not yet been declared. See comments on updateVHKA.

◆ isClonable()

bool AthReentrantAlgorithm::isClonable ( ) const
overridevirtualinherited

◆ isReEntrant()

virtual bool MagField::AtlasFieldCacheCondAlg::isReEntrant ( ) const
inlinefinaloverridevirtual

Definition at line 31 of file AtlasFieldCacheCondAlg.h.

31 { return false; }

◆ msg() [1/2]

MsgStream& AthCommonMsg< Gaudi::Algorithm >::msg ( ) const
inlineinherited

Definition at line 24 of file AthCommonMsg.h.

24  {
25  return this->msgStream();
26  }

◆ msg() [2/2]

MsgStream& AthCommonMsg< Gaudi::Algorithm >::msg ( const MSG::Level  lvl) const
inlineinherited

Definition at line 27 of file AthCommonMsg.h.

27  {
28  return this->msgStream(lvl);
29  }

◆ msgLvl()

bool AthCommonMsg< Gaudi::Algorithm >::msgLvl ( const MSG::Level  lvl) const
inlineinherited

Definition at line 30 of file AthCommonMsg.h.

30  {
31  return this->msgLevel(lvl);
32  }

◆ outputHandles()

virtual std::vector<Gaudi::DataHandle*> AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::outputHandles ( ) const
overridevirtualinherited

Return this algorithm's output handles.

We override this to include handle instances from key arrays if they have not yet been declared. See comments on updateVHKA.

◆ renounce()

std::enable_if_t<std::is_void_v<std::result_of_t<decltype(&T::renounce)(T)> > && !std::is_base_of_v<SG::VarHandleKeyArray, T> && std::is_base_of_v<Gaudi::DataHandle, T>, void> AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::renounce ( T &  h)
inlineprotectedinherited

Definition at line 380 of file AthCommonDataStore.h.

381  {
382  h.renounce();
383  PBASE::renounce (h);
384  }

◆ renounceArray()

void AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::renounceArray ( SG::VarHandleKeyArray handlesArray)
inlineprotectedinherited

remove all handles from I/O resolution

Definition at line 364 of file AthCommonDataStore.h.

364  {
365  handlesArray.renounce();
366  }

◆ scaleField()

void AtlasFieldCacheCondAlg::scaleField ( Cache cache,
const MagField::AtlasFieldMap fieldMap 
) const
private

Definition at line 286 of file AtlasFieldCacheCondAlg.cxx.

289 {
290  // Calculate the scale factor for solenoid and toroid.
291 
292  // We have one piece of information coming from the map.
293  // Do we have a map including both Toroid/Solenoid or only one.
294  // The values are typically the nominal value for the map
295  // or 0.
296  bool mapHasToroid = fieldMap && (fieldMap->toroidCurrent()>0);
297  bool mapHasSolenoid = fieldMap && (fieldMap->solenoidCurrent()>0);
298 
299  // Then we have the info we get on the actual current we have
300  // So we might need to scale the map with it.
301  // Set the SF for the solenoid
302  if (cache.m_solenoidCurrent > 0.0) {
303  if (mapHasSolenoid &&
304  std::abs(cache.m_solenoidCurrent / fieldMap->solenoidCurrent() - 1.0) >
305  0.001) {
306  cache.m_solScaleFactor =
307  cache.m_solenoidCurrent / fieldMap->solenoidCurrent();
308  }
309  ATH_MSG_INFO("scaleField: Solenoid field scale factor "
310  << cache.m_solScaleFactor
311  << ". Desired current and map current: "
312  << cache.m_solenoidCurrent << ","
313  << (fieldMap ? fieldMap->solenoidCurrent() : 0));
314  } else {
315  // No SF set, set it to 0 - current was set to zero either here or for the
316  // map, or the map was not read in
317  cache.m_solScaleFactor = 0;
318  ATH_MSG_INFO("scaleField: Solenoid field scale factor "
319  << cache.m_solScaleFactor
320  << ". Desired current and map current: "
321  << cache.m_solenoidCurrent << ","
322  << ((fieldMap) ? fieldMap->solenoidCurrent() : 0));
323  }
324 
325 
326  // Set the SF for the toroid
327  if (cache.m_toroidCurrent > 0.0) {
328  if (mapHasToroid &&
329  std::abs(cache.m_toroidCurrent / fieldMap->toroidCurrent() - 1.0) >
330  0.001) {
331  // scale the field in all zones except for the solenoid zone
332  cache.m_torScaleFactor =
333  cache.m_toroidCurrent / fieldMap->toroidCurrent();
334  }
335  ATH_MSG_INFO("scaleField: Toroid field scale factor "
336  << cache.m_torScaleFactor
337  << ". Desired current and map current: "
338  << cache.m_toroidCurrent << ","
339  << (fieldMap ? fieldMap->toroidCurrent() : 0));
340  } else {
341  cache.m_torScaleFactor = 0;
342  ATH_MSG_INFO("scaleField: Toroid field scale factor "
343  << cache.m_torScaleFactor
344  << ". Desired current and map current: "
345  << cache.m_toroidCurrent << ","
346  << ((fieldMap) ? fieldMap->toroidCurrent() : 0));
347  }
348  // If the map was toroid only set both to the toroid
349  // the 0s in the solenoid should be covered by the map
350  if (mapHasToroid && !mapHasSolenoid) {
351  cache.m_solScaleFactor = cache.m_torScaleFactor;
352  }
353  // if the map is solenoid only set both to the solenoid
354  // the 0s in the toroid should be covered by the map
355  if (!mapHasToroid && mapHasSolenoid) {
356  cache.m_torScaleFactor = cache.m_solScaleFactor;
357  }
358 }

◆ setFilterPassed()

virtual void AthReentrantAlgorithm::setFilterPassed ( bool  state,
const EventContext &  ctx 
) const
inlinevirtualinherited

Definition at line 139 of file AthReentrantAlgorithm.h.

139  {
140  execState( ctx ).setFilterPassed( state );
141  }

◆ sysExecute()

StatusCode AthReentrantAlgorithm::sysExecute ( const EventContext &  ctx)
overridevirtualinherited

Execute an algorithm.

We override this in order to work around an issue with the Algorithm base class storing the event context in a member variable that can cause crashes in MT jobs.

Definition at line 67 of file AthReentrantAlgorithm.cxx.

68 {
69  return Gaudi::Algorithm::sysExecute (ctx);
70 }

◆ sysInitialize()

StatusCode AthReentrantAlgorithm::sysInitialize ( )
overridevirtualinherited

Override sysInitialize.

Override sysInitialize from the base class.

Loop through all output handles, and if they're WriteCondHandles, automatically register them and this Algorithm with the CondSvc

Scan through all outputHandles, and if they're WriteCondHandles, register them with the CondSvc

Reimplemented from AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >.

Reimplemented in InputMakerBase, and HypoBase.

Definition at line 96 of file AthReentrantAlgorithm.cxx.

96  {
98 
99  if (sc.isFailure()) {
100  return sc;
101  }
102 
103  ServiceHandle<ICondSvc> cs("CondSvc",name());
104  for (auto h : outputHandles()) {
105  if (h->isCondition() && h->mode() == Gaudi::DataHandle::Writer) {
106  // do this inside the loop so we don't create the CondSvc until needed
107  if ( cs.retrieve().isFailure() ) {
108  ATH_MSG_WARNING("no CondSvc found: won't autoreg WriteCondHandles");
109  return StatusCode::SUCCESS;
110  }
111  if (cs->regHandle(this,*h).isFailure()) {
112  sc = StatusCode::FAILURE;
113  ATH_MSG_ERROR("unable to register WriteCondHandle " << h->fullKey()
114  << " with CondSvc");
115  }
116  }
117  }
118  return sc;
119 }

◆ sysStart()

virtual StatusCode AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::sysStart ( )
overridevirtualinherited

Handle START transition.

We override this in order to make sure that conditions handle keys can cache a pointer to the conditions container.

◆ updateCurrentFromConditions()

StatusCode AtlasFieldCacheCondAlg::updateCurrentFromConditions ( const EventContext &  ctx,
Cache cache 
) const
private

Definition at line 139 of file AtlasFieldCacheCondAlg.cxx.

142 {
143 
144  // readin current value
146  const CondAttrListCollection* attrListColl{ *readHandle };
147  if (attrListColl == nullptr) {
148  ATH_MSG_ERROR("updateCurrentFromConditions: Failed to retrieve "
149  "CondAttributeListCollection with key "
150  << m_currInputKey.key());
151  return StatusCode::FAILURE;
152  }
153 
154  // Get the validitiy range
155  EventIDRange rangeW;
156  if (!readHandle.range(rangeW)) {
158  "updateCurrentFromConditions: Failed to retrieve validity range for "
159  << readHandle.key());
160  return StatusCode::FAILURE;
161  }
162  cache.m_condObjOutputRange = rangeW;
163  ATH_MSG_INFO("UpdateCurrentFromConditions: Range of input/output is "
164  << cache.m_condObjOutputRange);
165 
166  // get magnet currents from DCS
167  double solcur{ 0. };
168  double torcur{ 0. };
169  bool gotsol{ false };
170  bool gottor{ false };
171 
172  /*
173  * due to inconsistencies between CONDBR2 and OFLP200/COMP200 (the former
174  * includes channel names in the /EXT/DCS/MAGNETS/SENSORDATA folder, the
175  * latter don't), we try to read currents in both ways
176  */
177  bool hasChanNames{ false };
178  ATH_MSG_INFO("UpdateCurrentFromConditions: Attempt 1 at reading currents "
179  "from DCS (using channel name)");
180  for (CondAttrListCollection::const_iterator itr = attrListColl->begin();
181  itr != attrListColl->end();
182  ++itr) {
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) {
189  hasChanNames = true;
190  }
191  if (name.compare("CentralSol_Current") == 0) {
192  // channel 1 is solenoid current
193  solcur = itr->second["value"].data<float>();
194  gotsol = true;
195  } else if (name.compare("Toroids_Current") == 0) {
196  // channel 3 is toroid current
197  torcur = itr->second["value"].data<float>();
198  gottor = true;
199  }
200  }
201  if (!hasChanNames) {
202  ATH_MSG_INFO("UpdateCurrentFromConditions: Attempt 2 at reading currents "
203  "from DCS (using channel index)");
204  // in no channel is named, try again using channel index instead
205  for (CondAttrListCollection::const_iterator itr = attrListColl->begin();
206  itr != attrListColl->end();
207  ++itr) {
208 
209  if (itr->first == 1) {
210  // channel 1 is solenoid current
211  solcur = itr->second["value"].data<float>();
212  gotsol = true;
213  } else if (itr->first == 3) {
214  // channel 3 is toroid current
215  torcur = itr->second["value"].data<float>();
216  gottor = true;
217  }
218  }
219  }
220  if (!gotsol || !gottor) {
221  if (!gotsol)
222  ATH_MSG_ERROR("UpdateCurrentFromConditions: Missing solenoid current in "
223  "DCS information");
224  if (!gottor)
225  ATH_MSG_ERROR("UpdateCurrentFromConditions: Missing toroid current in "
226  "DCS information");
227  return StatusCode::FAILURE;
228  }
229 
230  ATH_MSG_INFO("UpdateCurrentFromConditions: Currents read from DCS - solenoid "
231  << solcur << " toroid " << torcur);
232 
233  // round to zero if close to zero
234  if (solcur < m_soleMinCurrent) {
235  solcur = 0.0;
236  ATH_MSG_INFO("UpdateCurrentFromConditions: Solenoid is off");
237  }
238  if (torcur < m_toroMinCurrent) {
239  torcur = 0.0;
240  ATH_MSG_INFO("UpdateCurrentFromConditions: Toroids are off");
241  }
242 
243  cache.m_solenoidCurrent = solcur;
244  cache.m_toroidCurrent = torcur;
245 
246  return StatusCode::SUCCESS;
247 }

◆ updateCurrentFromParameters()

StatusCode AtlasFieldCacheCondAlg::updateCurrentFromParameters ( const EventContext &  ctx,
Cache cache 
) const
private

Definition at line 250 of file AtlasFieldCacheCondAlg.cxx.

253 {
254 
255  // take the current values from JobOptions
256  double solcur{ m_useSoleCurrent };
257  double torcur{ m_useToroCurrent };
258  if (solcur < m_soleMinCurrent) {
259  solcur = 0.0;
260  ATH_MSG_INFO("updateCurrentFromParameters: Solenoid is off");
261  }
262  if (torcur < m_toroMinCurrent) {
263  torcur = 0.0;
264  ATH_MSG_INFO("updateCurrentFromParameters: Toroids are off");
265  }
266  cache.m_solenoidCurrent = solcur;
267  cache.m_toroidCurrent = torcur;
268 
269  // in case of reading from DB or from FILE, the EventID range is always the
270  // current run
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);
276  cache.m_condObjOutputRange = EventIDRange(start, stop);
277 
278  ATH_MSG_INFO("updateCurrentFromParameters: Update from job options: Range of "
279  "input/output is "
280  << cache.m_condObjOutputRange);
281 
282  return StatusCode::SUCCESS;
283 }

◆ updateVHKA()

void AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::updateVHKA ( Gaudi::Details::PropertyBase &  )
inlineinherited

Definition at line 308 of file AthCommonDataStore.h.

308  {
309  // debug() << "updateVHKA for property " << p.name() << " " << p.toString()
310  // << " size: " << m_vhka.size() << endmsg;
311  for (auto &a : m_vhka) {
312  std::vector<SG::VarHandleKey*> keys = a->keys();
313  for (auto k : keys) {
314  k->setOwner(this);
315  }
316  }
317  }

Member Data Documentation

◆ m_condObjOutputKey

SG::WriteCondHandleKey<AtlasFieldCacheCondObj> MagField::AtlasFieldCacheCondAlg::m_condObjOutputKey
private
Initial value:
{
this,
"AtlasFieldCacheCondObj",
"fieldCondObj",
"Name of the key for the Magnetic Field conditions object with currents "
"for scaling"
}

Definition at line 106 of file AtlasFieldCacheCondAlg.h.

◆ m_currInputKey

SG::ReadCondHandleKey<CondAttrListCollection> MagField::AtlasFieldCacheCondAlg::m_currInputKey
private
Initial value:
{
this,
"COOLCurrentsFolderName",
"/EXT/DCS/MAGNETS/SENSORDATA",
"Name of the COOL folder containing magnet currents"
}

Definition at line 87 of file AtlasFieldCacheCondAlg.h.

◆ m_detStore

StoreGateSvc_t AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::m_detStore
privateinherited

Pointer to StoreGate (detector store by default)

Definition at line 393 of file AthCommonDataStore.h.

◆ m_evtStore

StoreGateSvc_t AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::m_evtStore
privateinherited

Pointer to StoreGate (event store by default)

Definition at line 390 of file AthCommonDataStore.h.

◆ m_extendedExtraObjects

DataObjIDColl AthReentrantAlgorithm::m_extendedExtraObjects
privateinherited

Extra output dependency collection, extended by AthAlgorithmDHUpdate to add symlinks.

Empty if no symlinks were found.

Definition at line 153 of file AthReentrantAlgorithm.h.

◆ m_lockMapCurrents

Gaudi::Property<bool> MagField::AtlasFieldCacheCondAlg::m_lockMapCurrents
private
Initial value:
{
this,
"LockMapCurrents",
false,
"Skip current rescale and use map currents as they are"
}

Definition at line 78 of file AtlasFieldCacheCondAlg.h.

◆ m_mapCondObjInputKey

SG::ReadCondHandleKey<AtlasFieldMapCondObj> MagField::AtlasFieldCacheCondAlg::m_mapCondObjInputKey
private
Initial value:
{
this,
"AtlasFieldMapCondObj",
"fieldMapCondObj",
"Name of key for the Magnetic Field conditions object with the map file "
"names"
}

Definition at line 96 of file AtlasFieldCacheCondAlg.h.

◆ m_soleMinCurrent

Gaudi::Property<double> MagField::AtlasFieldCacheCondAlg::m_soleMinCurrent
private
Initial value:
{
this,
"SoleMinCurrent",
1.0,
"Minimum solenoid current (A) for which solenoid is considered ON"
}

Definition at line 56 of file AtlasFieldCacheCondAlg.h.

◆ m_toroMinCurrent

Gaudi::Property<double> MagField::AtlasFieldCacheCondAlg::m_toroMinCurrent
private
Initial value:
{
this,
"ToroMinCurrent",
1.0,
"Minimum toroid current (A) for which toroid is considered ON"
}

Definition at line 62 of file AtlasFieldCacheCondAlg.h.

◆ m_useDCS

Gaudi::Property<bool> MagField::AtlasFieldCacheCondAlg::m_useDCS
private
Initial value:
{
this,
"UseDCS",
false,
"Get magnet currents from DCS through ConditionsSvc"
}

Definition at line 70 of file AtlasFieldCacheCondAlg.h.

◆ m_useSoleCurrent

Gaudi::Property<double> MagField::AtlasFieldCacheCondAlg::m_useSoleCurrent
private
Initial value:
{ this,
"UseSoleCurrent",
7730.,
"Set actual solenoid current (A)" }

Definition at line 115 of file AtlasFieldCacheCondAlg.h.

◆ m_useToroCurrent

Gaudi::Property<double> MagField::AtlasFieldCacheCondAlg::m_useToroCurrent
private
Initial value:
{ this,
"UseToroCurrent",
20400.,
"Set actual toroid current (A)" }

Definition at line 119 of file AtlasFieldCacheCondAlg.h.

◆ m_varHandleArraysDeclared

bool AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::m_varHandleArraysDeclared
privateinherited

Definition at line 399 of file AthCommonDataStore.h.

◆ m_vhka

std::vector<SG::VarHandleKeyArray*> AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::m_vhka
privateinherited

Definition at line 398 of file AthCommonDataStore.h.


The documentation for this class was generated from the following files:
MagField::AtlasFieldCacheCondAlg::scaleField
void scaleField(Cache &cache, const MagField::AtlasFieldMap *fieldMap) const
Definition: AtlasFieldCacheCondAlg.cxx:286
ATH_MSG_FATAL
#define ATH_MSG_FATAL(x)
Definition: AthMsgStreamMacros.h:34
AtlasFieldMapCondObj
Definition: AtlasFieldMapCondObj.h:12
SG::ReadCondHandle
Definition: ReadCondHandle.h:44
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
AthCommonDataStore::declareProperty
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T > &t)
Definition: AthCommonDataStore.h:145
mergePhysValFiles.start
start
Definition: DataQuality/DataQualityUtils/scripts/mergePhysValFiles.py:14
AthCommonDataStore::renounce
std::enable_if_t< std::is_void_v< std::result_of_t< decltype(&T::renounce)(T)> > &&!std::is_base_of_v< SG::VarHandleKeyArray, T > &&std::is_base_of_v< Gaudi::DataHandle, T >, void > renounce(T &h)
Definition: AthCommonDataStore.h:380
MagField::AtlasFieldCacheCondAlg::m_toroMinCurrent
Gaudi::Property< double > m_toroMinCurrent
Definition: AtlasFieldCacheCondAlg.h:62
AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::m_evtStore
StoreGateSvc_t m_evtStore
Pointer to StoreGate (event store by default)
Definition: AthCommonDataStore.h:390
AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::m_vhka
std::vector< SG::VarHandleKeyArray * > m_vhka
Definition: AthCommonDataStore.h:398
MagField::AtlasFieldCacheCondAlg::m_lockMapCurrents
Gaudi::Property< bool > m_lockMapCurrents
Definition: AtlasFieldCacheCondAlg.h:78
PixelModuleFeMask_create_db.stop
int stop
Definition: PixelModuleFeMask_create_db.py:76
read_hist_ntuple.t
t
Definition: read_hist_ntuple.py:5
SG::VarHandleKey::key
const std::string & key() const
Return the StoreGate ID for the referenced object.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleKey.cxx:141
CondAttrListCollection
This class is a collection of AttributeLists where each one is associated with a channel number....
Definition: CondAttrListCollection.h:52
MagField::AtlasFieldCacheCondAlg::m_currInputKey
SG::ReadCondHandleKey< CondAttrListCollection > m_currInputKey
Definition: AtlasFieldCacheCondAlg.h:87
AthenaPoolTestRead.sc
sc
Definition: AthenaPoolTestRead.py:27
SG::VarHandleKeyArray::setOwner
virtual void setOwner(IDataHandleHolder *o)=0
IDTPMcnv.htype
htype
Definition: IDTPMcnv.py:27
MagField::AtlasFieldCacheCondAlg::m_useDCS
Gaudi::Property< bool > m_useDCS
Definition: AtlasFieldCacheCondAlg.h:70
python.utils.AtlRunQueryDQUtils.p
p
Definition: AtlRunQueryDQUtils.py:210
AthCommonDataStore
Definition: AthCommonDataStore.h:52
AthReentrantAlgorithm::AthReentrantAlgorithm
AthReentrantAlgorithm()
Default constructor:
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::outputHandles
virtual std::vector< Gaudi::DataHandle * > outputHandles() const override
Return this algorithm's output handles.
MagField::AtlasFieldCacheCondAlg::m_mapCondObjInputKey
SG::ReadCondHandleKey< AtlasFieldMapCondObj > m_mapCondObjInputKey
Definition: AtlasFieldCacheCondAlg.h:96
MagField::AtlasFieldCacheCondAlg::m_useToroCurrent
Gaudi::Property< double > m_useToroCurrent
Definition: AtlasFieldCacheCondAlg.h:119
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
MagField::AtlasFieldMap::toroidCurrent
float toroidCurrent() const
Definition: AtlasFieldMap.h:61
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
MagField::AtlasFieldCacheCondAlg::m_soleMinCurrent
Gaudi::Property< double > m_soleMinCurrent
Definition: AtlasFieldCacheCondAlg.h:56
AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::m_detStore
StoreGateSvc_t m_detStore
Pointer to StoreGate (detector store by default)
Definition: AthCommonDataStore.h:393
MagField::AtlasFieldCacheCondAlg::m_useSoleCurrent
Gaudi::Property< double > m_useSoleCurrent
Definition: AtlasFieldCacheCondAlg.h:115
AthReentrantAlgorithm::m_extendedExtraObjects
DataObjIDColl m_extendedExtraObjects
Extra output dependency collection, extended by AthAlgorithmDHUpdate to add symlinks.
Definition: AthReentrantAlgorithm.h:153
SG::VarHandleKeyArray::renounce
virtual void renounce()=0
SG::HandleClassifier::type
std::conditional< std::is_base_of< SG::VarHandleKeyArray, T >::value, VarHandleKeyArrayType, type2 >::type type
Definition: HandleClassifier.h:54
merge_scale_histograms.doc
string doc
Definition: merge_scale_histograms.py:9
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:221
AthReentrantAlgorithm::sysInitialize
virtual StatusCode sysInitialize() override
Override sysInitialize.
Definition: AthReentrantAlgorithm.cxx:96
SG::CondHandleKey::initialize
StatusCode initialize(bool used=true)
MagField::AtlasFieldMap
Map for magnetic field.
Definition: AtlasFieldMap.h:39
MagField::AtlasFieldMap::m_solenoidCurrent
float m_solenoidCurrent
Definition: AtlasFieldMap.h:88
MagField::AtlasFieldCacheCondAlg::m_condObjOutputKey
SG::WriteCondHandleKey< AtlasFieldCacheCondObj > m_condObjOutputKey
Definition: AtlasFieldCacheCondAlg.h:106
a
TList * a
Definition: liststreamerinfos.cxx:10
h
MagField::AtlasFieldCacheCondAlg::updateCurrentFromParameters
StatusCode updateCurrentFromParameters(const EventContext &ctx, Cache &cache) const
Definition: AtlasFieldCacheCondAlg.cxx:250
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
CondAttrListCollection::const_iterator
ChanAttrListMap::const_iterator const_iterator
Definition: CondAttrListCollection.h:63
MagField::AtlasFieldMap::solenoidZoneId
int solenoidZoneId() const
Definition: AtlasFieldMap.h:62
SG::VarHandleBase::vhKey
SG::VarHandleKey & vhKey()
Return a non-const reference to the HandleKey.
Definition: StoreGate/src/VarHandleBase.cxx:623
python.Bindings.keys
keys
Definition: Control/AthenaPython/python/Bindings.py:798
LHEF::Writer
Pythia8::Writer Writer
Definition: Prophecy4fMerger.cxx:12
MagField::AtlasFieldCacheCondAlg::updateCurrentFromConditions
StatusCode updateCurrentFromConditions(const EventContext &ctx, Cache &cache) const
Definition: AtlasFieldCacheCondAlg.cxx:139
SG::WriteCondHandle
Definition: WriteCondHandle.h:26
AthCommonDataStore::declareGaudiProperty
Gaudi::Details::PropertyBase & declareGaudiProperty(Gaudi::Property< T > &hndl, const SG::VarHandleKeyType &)
specialization for handling Gaudi::Property<SG::VarHandleKey>
Definition: AthCommonDataStore.h:156
MagField::AtlasFieldMap::solenoidCurrent
float solenoidCurrent() const
Definition: AtlasFieldMap.h:60
fitman.k
k
Definition: fitman.py:528
ServiceHandle< ICondSvc >