Commit 7836bd3d authored by Frank Winklmeier's avatar Frank Winklmeier
Browse files

Merge branch 'magfieldcondreader' into 'master'

MagFieldUtils: Add field reader test algorithm

See merge request !35408
parents 37b3275a 490721d2
......@@ -14,9 +14,7 @@ atlas_add_component( MagFieldUtils
src/*.cxx
src/components/*.cxx
INCLUDE_DIRS ${ROOT_INCLUDE_DIRS} ${XERCESC_INCLUDE_DIRS} ${GEANT4_INCLUDE_DIRS} ${CLHEP_INCLUDE_DIRS}
LINK_LIBRARIES ${ROOT_LIBRARIES} ${XERCESC_LIBRARIES} ${GEANT4_LIBRARIES} ${CLHEP_LIBRARIES} AthenaBaseComps GaudiKernel MagFieldInterfaces )
LINK_LIBRARIES ${ROOT_LIBRARIES} ${XERCESC_LIBRARIES} ${GEANT4_LIBRARIES} ${CLHEP_LIBRARIES} AthenaBaseComps GaudiKernel MagFieldConditions MagFieldInterfaces )
# Install files from the package:
atlas_install_headers( MagFieldUtils )
atlas_install_joboptions( share/*.py )
/*
Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
*/
#include "MagFieldCondReader.h"
MagField::CondReader::CondReader(const std::string& name, ISvcLocator* pSvcLocator) :
AthReentrantAlgorithm(name, pSvcLocator)
{}
StatusCode MagField::CondReader::initialize()
{
ATH_CHECK(m_fieldCacheKey.initialize());
return StatusCode::SUCCESS;
}
StatusCode MagField::CondReader::execute(const EventContext& ctx) const
{
SG::ReadCondHandle<AtlasFieldCacheCondObj> rh{m_fieldCacheKey, ctx};
const AtlasFieldCacheCondObj* fieldCondObj{*rh};
if (fieldCondObj == nullptr) {
ATH_MSG_ERROR("Failed to retrieve AtlasFieldCacheCondObj with key " << m_fieldCacheKey.key());
return StatusCode::FAILURE;
}
MagField::AtlasFieldCache fieldCache;
fieldCondObj->getInitializedCache(fieldCache);
ATH_MSG_INFO("Field status: solenoid=" << fieldCache.solenoidOn() << ", toroids=" << fieldCache.toroidOn());
return StatusCode::SUCCESS;
}
/*
Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
*/
#ifndef MAGFIELDUTILS_MAGFIELDCONDREADER_H
#define MAGFIELDUTILS_MAGFIELDCONDREADER_H
#include "AthenaBaseComps/AthReentrantAlgorithm.h"
#include "MagFieldConditions/AtlasFieldCacheCondObj.h"
#include "StoreGate/ReadHandleKey.h"
namespace MagField {
/**
* Testing algorithm to read magnetic field
*/
class CondReader : public AthReentrantAlgorithm {
public:
CondReader(const std::string& name, ISvcLocator* pSvcLocator);
StatusCode initialize() override;
StatusCode execute(const EventContext& ctx) const override;
private:
SG::ReadCondHandleKey<AtlasFieldCacheCondObj> m_fieldCacheKey{
this, "AtlasFieldCacheCondObj", "fieldCondObj", "Magnetic Field conditions object key"};
};
} // namespace MagField
#endif
#include "MagFieldUtils/MagFieldTestbedAlg.h"
#include "MagFieldUtils/SolenoidTest.h"
#include "MagFieldUtils/IdentityManipulator.h"
#include "../MagFieldCondReader.h"
DECLARE_COMPONENT( MagField::MagFieldTestbedAlg )
DECLARE_COMPONENT( MagField::SolenoidTest )
DECLARE_COMPONENT( MagField::IdentityManipulator )
DECLARE_COMPONENT( MagField::CondReader )
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment