ATLAS Offline Software
MagFieldCondReader.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 #include "MagFieldCondReader.h"
6 
7 MagField::CondReader::CondReader(const std::string& name, ISvcLocator* pSvcLocator) :
8  AthReentrantAlgorithm(name, pSvcLocator)
9 {}
10 
12 {
13  ATH_CHECK(m_fieldCacheKey.initialize());
14 
15  return StatusCode::SUCCESS;
16 }
17 
18 StatusCode MagField::CondReader::execute(const EventContext& ctx) const
19 {
20  SG::ReadCondHandle<AtlasFieldCacheCondObj> rh{m_fieldCacheKey, ctx};
21  const AtlasFieldCacheCondObj* fieldCondObj{*rh};
22  if (fieldCondObj == nullptr) {
23  ATH_MSG_ERROR("Failed to retrieve AtlasFieldCacheCondObj with key " << m_fieldCacheKey.key());
24  return StatusCode::FAILURE;
25  }
26 
27  MagField::AtlasFieldCache fieldCache;
28  fieldCondObj->getInitializedCache(fieldCache);
29 
30  ATH_MSG_INFO("Field status: solenoid=" << fieldCache.solenoidOn() << ", toroids=" << fieldCache.toroidOn());
31 
32  // get field at 0,0,0
33  double xyz[3] = { 100, 100, 100 };
34  double bxyz[3];
35  fieldCache. getField(xyz, bxyz);
36 
37  ATH_MSG_INFO("Field xyz: " << xyz[0] << ", " << xyz[1] << ", " << xyz[2] << ", " << bxyz[0] << ", " << bxyz[1] << ", " << bxyz[2]);
38 
39 
40 
41 
42  return StatusCode::SUCCESS;
43 }
SG::ReadCondHandle
Definition: ReadCondHandle.h:44
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
AtlasFieldCacheCondObj
Definition: AtlasFieldCacheCondObj.h:19
MagFieldCondReader.h
xyz
#define xyz
MagField::AtlasFieldCache::toroidOn
bool toroidOn() const
AthReentrantAlgorithm
An algorithm that can be simultaneously executed in multiple threads.
Definition: AthReentrantAlgorithm.h:83
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_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
MagField::AtlasFieldCache::solenoidOn
bool solenoidOn() const
status of the magnets
MagField::CondReader::CondReader
CondReader(const std::string &name, ISvcLocator *pSvcLocator)
Definition: MagFieldCondReader.cxx:7
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
MagField::CondReader::initialize
StatusCode initialize() override
Definition: MagFieldCondReader.cxx:11
MagField::CondReader::execute
StatusCode execute(const EventContext &ctx) const override
Definition: MagFieldCondReader.cxx:18
MagField::AtlasFieldCache
Local cache for magnetic field (based on MagFieldServices/AtlasFieldSvcTLS.h)
Definition: AtlasFieldCache.h:43