diff --git a/InnerDetector/InDetConditions/SiLorentzAngleSvc/src/SCTSiLorentzAngleCondAlg.cxx b/InnerDetector/InDetConditions/SiLorentzAngleSvc/src/SCTSiLorentzAngleCondAlg.cxx index 32976664a9b84953780e2f645fd4080453419985..4a8da1451e577c304fce045663a16ad0bd767108 100644 --- a/InnerDetector/InDetConditions/SiLorentzAngleSvc/src/SCTSiLorentzAngleCondAlg.cxx +++ b/InnerDetector/InDetConditions/SiLorentzAngleSvc/src/SCTSiLorentzAngleCondAlg.cxx @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration */ /** @@ -18,39 +18,27 @@ // Gaudi include #include "GaudiKernel/PhysicalConstants.h" -#include "GaudiKernel/SystemOfUnits.h" // STL include SCTSiLorentzAngleCondAlg::SCTSiLorentzAngleCondAlg(const std::string& name, ISvcLocator* pSvcLocator): - ::AthAlgorithm(name, pSvcLocator), + ::AthReentrantAlgorithm(name, pSvcLocator), m_condSvc{"CondSvc", name}, m_magFieldSvc{"AtlasFieldSvc", name}, m_maxHash{0} { - // YOU NEED TO USE THE SAME PROPERTIES AS USED IN SCTLorentzAngleTool!!! declareProperty("MagFieldSvc", m_magFieldSvc); - declareProperty("Temperature", m_temperature = -7., "Default temperature in Celcius."); - declareProperty("DepletionVoltage", m_deplVoltage = 70., "Default depletion voltage in Volt."); - declareProperty("BiasVoltage", m_biasVoltage = 150., "Default bias voltage in Volt."); - declareProperty("NominalField", m_nominalField = 2.0834*Gaudi::Units::tesla); - declareProperty("UseMagFieldSvc", m_useMagFieldSvc = true); - declareProperty("UseMagFieldDcs", m_useMagFieldDcs = true); - declareProperty("useSctDefaults", m_sctDefaults = false); - declareProperty("UseGeoModel", m_useGeoModel = false); - declareProperty("TemperatureMin", m_temperatureMin = -80., "Minimum temperature allowed in Celcius."); - declareProperty("TemperatureMax", m_temperatureMax = 100., "Maximum temperature allowed in Celcius."); } StatusCode SCTSiLorentzAngleCondAlg::initialize() { - if (m_siConditionsTool.empty()) m_sctDefaults = true; + if (m_siConditionsTool.empty()) m_sctDefaults.setValue(true); - if (not m_sctDefaults) { + if (not m_sctDefaults.value()) { // SCTSiliconConditionsTool ATH_CHECK(m_siConditionsTool.retrieve()); // Read Cond handle - if (not m_useGeoModel) { + if (not m_useGeoModel.value()) { ATH_CHECK(m_readKeyTemp.initialize()); ATH_CHECK(m_readKeyHV.initialize()); } @@ -58,11 +46,11 @@ StatusCode SCTSiLorentzAngleCondAlg::initialize() m_siConditionsTool.disable(); } - if (m_useMagFieldSvc) { + if (m_useMagFieldSvc.value()) { // MagFieldSvc ATH_CHECK(m_magFieldSvc.retrieve()); // Read Cond handle - if (m_useMagFieldDcs) { + if (m_useMagFieldDcs.value()) { ATH_CHECK(m_readKeyBFieldSensor.initialize()); } } @@ -85,10 +73,10 @@ StatusCode SCTSiLorentzAngleCondAlg::initialize() return StatusCode::SUCCESS; } -StatusCode SCTSiLorentzAngleCondAlg::execute() +StatusCode SCTSiLorentzAngleCondAlg::execute(const EventContext& ctx) const { // Write Cond Handle - SG::WriteCondHandle<SiLorentzAngleCondData> writeHandle{m_writeKey}; + SG::WriteCondHandle<SiLorentzAngleCondData> writeHandle{m_writeKey, ctx}; // Do we have a valid Write Cond Handle for current time? if (writeHandle.isValid()) { ATH_MSG_DEBUG("CondHandle " << writeHandle.fullKey() << " is already valid." @@ -107,7 +95,7 @@ StatusCode SCTSiLorentzAngleCondAlg::execute() EventIDRange rangeBField{eidStart, eidStop}; // Get SCT_DetectorElementCollection - SG::ReadCondHandle<InDetDD::SiDetectorElementCollection> sctDetEle(m_SCTDetEleCollKey); + SG::ReadCondHandle<InDetDD::SiDetectorElementCollection> sctDetEle(m_SCTDetEleCollKey, ctx); const InDetDD::SiDetectorElementCollection* elements(sctDetEle.retrieve()); if (elements==nullptr) { ATH_MSG_FATAL(m_SCTDetEleCollKey.fullKey() << " could not be retrieved"); @@ -119,9 +107,9 @@ StatusCode SCTSiLorentzAngleCondAlg::execute() return StatusCode::FAILURE; } - if ((not m_sctDefaults) and (not m_useGeoModel)) { + if ((not m_sctDefaults.value()) and (not m_useGeoModel.value())) { // Read Cond Handle (temperature) - SG::ReadCondHandle<SCT_DCSFloatCondData> readHandleTemp{m_readKeyTemp}; + SG::ReadCondHandle<SCT_DCSFloatCondData> readHandleTemp{m_readKeyTemp, ctx}; const SCT_DCSFloatCondData* readCdoTemp{*readHandleTemp}; if (readCdoTemp==nullptr) { ATH_MSG_FATAL("Null pointer to the read conditions object"); @@ -135,7 +123,7 @@ StatusCode SCTSiLorentzAngleCondAlg::execute() ATH_MSG_INFO("Input is " << readHandleTemp.fullKey() << " with the range of " << rangeTemp); // Read Cond Handle (HV) - SG::ReadCondHandle<SCT_DCSFloatCondData> readHandleHV{m_readKeyHV}; + SG::ReadCondHandle<SCT_DCSFloatCondData> readHandleHV{m_readKeyHV, ctx}; const SCT_DCSFloatCondData* readCdoHV{*readHandleHV}; if (readCdoHV==nullptr) { ATH_MSG_FATAL("Null pointer to the read conditions object"); @@ -156,10 +144,10 @@ StatusCode SCTSiLorentzAngleCondAlg::execute() } } - if (m_useMagFieldSvc) { - if (m_useMagFieldDcs) { + if (m_useMagFieldSvc.value()) { + if (m_useMagFieldDcs.value()) { // Read Cond Handle (B field sensor) - SG::ReadCondHandle<CondAttrListCollection> readHandleBFieldSensor{m_readKeyBFieldSensor}; + SG::ReadCondHandle<CondAttrListCollection> readHandleBFieldSensor{m_readKeyBFieldSensor, ctx}; const CondAttrListCollection* readCdoBFieldSensor{*readHandleBFieldSensor}; if (readCdoBFieldSensor==nullptr) { ATH_MSG_FATAL("Null pointer to the read conditions object"); @@ -200,10 +188,10 @@ StatusCode SCTSiLorentzAngleCondAlg::execute() double deplVoltage{0.0}; double biasVoltage{0.0}; - if (m_sctDefaults) { - temperatureC = m_temperature; - deplVoltage = m_deplVoltage * CLHEP::volt; - biasVoltage = m_biasVoltage * CLHEP::volt; + if (m_sctDefaults.value()) { + temperatureC = m_temperature.value(); + deplVoltage = m_deplVoltage.value() * CLHEP::volt; + biasVoltage = m_biasVoltage.value() * CLHEP::volt; } else { temperatureC = m_siConditionsTool->temperature(elementHash); deplVoltage = m_siConditionsTool->depletionVoltage(elementHash) * CLHEP::volt; @@ -213,8 +201,8 @@ StatusCode SCTSiLorentzAngleCondAlg::execute() // Protect against invalid temperature if (not ((temperatureC>m_temperatureMin) and (temperatureC<m_temperatureMax))) { - temperatureC = m_temperature; - ATH_MSG_DEBUG("Invalid temperature: " << temperatureC << " C. " << "Setting to " << m_temperature << " C. " << "Detector element hash: " << elementHash); + temperatureC = m_temperature.value(); + ATH_MSG_DEBUG("Invalid temperature: " << temperatureC << " C. " << "Setting to " << m_temperature.value() << " C. " << "Detector element hash: " << elementHash); } double temperature{temperatureC + Gaudi::Units::STP_Temperature}; // C -> K @@ -293,7 +281,7 @@ StatusCode SCTSiLorentzAngleCondAlg::finalize() } Amg::Vector3D SCTSiLorentzAngleCondAlg::getMagneticField(const InDetDD::SiDetectorElement* element) const { - if (m_useMagFieldSvc) { + if (m_useMagFieldSvc.value()) { Amg::Vector3D pointvec{element->center()}; ATH_MSG_VERBOSE("Getting magnetic field from magnetic field service."); double point[3]; diff --git a/InnerDetector/InDetConditions/SiLorentzAngleSvc/src/SCTSiLorentzAngleCondAlg.h b/InnerDetector/InDetConditions/SiLorentzAngleSvc/src/SCTSiLorentzAngleCondAlg.h index 78783cd4c06ba3c4d4d1279a0d97fa8670517e02..28d389e2eccdb2e94af536d18e89515aee20d09a 100644 --- a/InnerDetector/InDetConditions/SiLorentzAngleSvc/src/SCTSiLorentzAngleCondAlg.h +++ b/InnerDetector/InDetConditions/SiLorentzAngleSvc/src/SCTSiLorentzAngleCondAlg.h @@ -10,7 +10,7 @@ #define SCTSiLorentzAngleCondAlg_h // Athena includes -#include "AthenaBaseComps/AthAlgorithm.h" +#include "AthenaBaseComps/AthReentrantAlgorithm.h" #include "AthenaPoolUtilities/CondAttrListCollection.h" #include "GeoPrimitives/GeoPrimitives.h" @@ -24,6 +24,7 @@ // Gaudi includes #include "GaudiKernel/ICondSvc.h" #include "GaudiKernel/ServiceHandle.h" +#include "GaudiKernel/SystemOfUnits.h" #include "GaudiKernel/ToolHandle.h" // forward declarations @@ -36,13 +37,13 @@ namespace MagField { * This class prepares SiLorentAngleCondData using SiPropertiesTool **/ -class SCTSiLorentzAngleCondAlg: public AthAlgorithm +class SCTSiLorentzAngleCondAlg: public AthReentrantAlgorithm { public: SCTSiLorentzAngleCondAlg(const std::string& name, ISvcLocator* pSvcLocator); virtual ~SCTSiLorentzAngleCondAlg() = default; virtual StatusCode initialize() override; - virtual StatusCode execute() override; + virtual StatusCode execute(const EventContext& ctx) const override; virtual StatusCode finalize() override; private: @@ -60,17 +61,18 @@ class SCTSiLorentzAngleCondAlg: public AthAlgorithm ToolHandle<ISiliconConditionsTool> m_siConditionsTool{this, "SiConditionsTool", "SCT_SiliconConditionsTool", "Tool to retrieve SCT silicon information"}; // Properties - double m_temperature; - double m_deplVoltage; - double m_biasVoltage; - double m_nominalField; - bool m_useMagFieldSvc; - bool m_useMagFieldDcs; - bool m_sctDefaults; - bool m_useGeoModel; + // YOU NEED TO USE THE SAME PROPERTIES AS USED IN SCTLorentzAngleTool!!! + DoubleProperty m_temperature{this, "Temperature", -7., "Default temperature in Celcius."}; + DoubleProperty m_temperatureMin{this, "TemperatureMin", -80., "Minimum temperature allowed in Celcius."}; + DoubleProperty m_temperatureMax{this, "TemperatureMax", 100., "Maximum temperature allowed in Celcius."}; + DoubleProperty m_deplVoltage{this, "DepletionVoltage", 70., "Default depletion voltage in Volt."}; + DoubleProperty m_biasVoltage{this, "BiasVoltage", 150., "Default bias voltage in Volt."}; + DoubleProperty m_nominalField{this, "NominalField", 2.0834*Gaudi::Units::tesla}; + BooleanProperty m_useMagFieldSvc{this, "UseMagFieldSvc", true}; + BooleanProperty m_useMagFieldDcs{this, "UseMagFieldDcs", true}; + BooleanProperty m_sctDefaults{this, "useSctDefaults", false}; + BooleanProperty m_useGeoModel{this, "UseGeoModel", false}; unsigned int m_maxHash; - double m_temperatureMin; - double m_temperatureMax; Amg::Vector3D getMagneticField(const InDetDD::SiDetectorElement* element) const; }; diff --git a/InnerDetector/InDetConditions/SiPropertiesSvc/src/SCTSiPropertiesCondAlg.cxx b/InnerDetector/InDetConditions/SiPropertiesSvc/src/SCTSiPropertiesCondAlg.cxx index 5b86f3999cd980899228961a07409b5e4e1abef3..8a5f159ecba266d20226a166d521010b4ea1b24f 100644 --- a/InnerDetector/InDetConditions/SiPropertiesSvc/src/SCTSiPropertiesCondAlg.cxx +++ b/InnerDetector/InDetConditions/SiPropertiesSvc/src/SCTSiPropertiesCondAlg.cxx @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration */ #include "SCTSiPropertiesCondAlg.h" @@ -14,7 +14,7 @@ #include <memory> SCTSiPropertiesCondAlg::SCTSiPropertiesCondAlg(const std::string& name, ISvcLocator* pSvcLocator) - : ::AthAlgorithm(name, pSvcLocator) + : ::AthReentrantAlgorithm(name, pSvcLocator) , m_condSvc{"CondSvc", name} , m_pHelper{nullptr} { @@ -37,7 +37,7 @@ StatusCode SCTSiPropertiesCondAlg::initialize() { ATH_CHECK(m_SCTDetEleCollKey.initialize()); // Write Cond Handle ATH_CHECK(m_writeKey.initialize()); - if(m_condSvc->regHandle(this, m_writeKey).isFailure()) { + if (m_condSvc->regHandle(this, m_writeKey).isFailure()) { ATH_MSG_FATAL("unable to register WriteCondHandle " << m_writeKey.fullKey() << " with CondSvc"); return StatusCode::FAILURE; } @@ -45,11 +45,11 @@ StatusCode SCTSiPropertiesCondAlg::initialize() { return StatusCode::SUCCESS; } -StatusCode SCTSiPropertiesCondAlg::execute() { +StatusCode SCTSiPropertiesCondAlg::execute(const EventContext& ctx) const { ATH_MSG_DEBUG("execute " << name()); // Write Cond Handle - SG::WriteCondHandle<InDet::SiliconPropertiesVector> writeHandle{m_writeKey}; + SG::WriteCondHandle<InDet::SiliconPropertiesVector> writeHandle{m_writeKey, ctx}; // Do we have a valid Write Cond Handle for current time? if (writeHandle.isValid()) { ATH_MSG_DEBUG("CondHandle " << writeHandle.fullKey() << " is already valid." @@ -59,7 +59,7 @@ StatusCode SCTSiPropertiesCondAlg::execute() { } // Read Cond Handle (temperature) - SG::ReadCondHandle<SCT_DCSFloatCondData> readHandleTemp{m_readKeyTemp}; + SG::ReadCondHandle<SCT_DCSFloatCondData> readHandleTemp{m_readKeyTemp, ctx}; const SCT_DCSFloatCondData* readCdoTemp{*readHandleTemp}; if (readCdoTemp==nullptr) { ATH_MSG_FATAL("Null pointer to the read conditions object"); @@ -73,7 +73,7 @@ StatusCode SCTSiPropertiesCondAlg::execute() { ATH_MSG_INFO("Input is " << readHandleTemp.fullKey() << " with the range of " << rangeTemp); // Read Cond Handle (HV) - SG::ReadCondHandle<SCT_DCSFloatCondData> readHandleHV{m_readKeyHV}; + SG::ReadCondHandle<SCT_DCSFloatCondData> readHandleHV{m_readKeyHV, ctx}; const SCT_DCSFloatCondData* readCdoHV{*readHandleHV}; if (readCdoHV==nullptr) { ATH_MSG_FATAL("Null pointer to the read conditions object"); @@ -94,7 +94,7 @@ StatusCode SCTSiPropertiesCondAlg::execute() { } // Get SCT_DetectorElementCollection - SG::ReadCondHandle<InDetDD::SiDetectorElementCollection> sctDetEle(m_SCTDetEleCollKey); + SG::ReadCondHandle<InDetDD::SiDetectorElementCollection> sctDetEle(m_SCTDetEleCollKey, ctx); const InDetDD::SiDetectorElementCollection* elements(sctDetEle.retrieve()); if (elements==nullptr) { ATH_MSG_FATAL(m_SCTDetEleCollKey.fullKey() << " could not be retrieved"); diff --git a/InnerDetector/InDetConditions/SiPropertiesSvc/src/SCTSiPropertiesCondAlg.h b/InnerDetector/InDetConditions/SiPropertiesSvc/src/SCTSiPropertiesCondAlg.h index d3f48ad02e0483965ed8792dfbe15b46e1eb423f..5c4d3bdcdf144059ccb8f6113924cf4f6c69861f 100644 --- a/InnerDetector/InDetConditions/SiPropertiesSvc/src/SCTSiPropertiesCondAlg.h +++ b/InnerDetector/InDetConditions/SiPropertiesSvc/src/SCTSiPropertiesCondAlg.h @@ -1,11 +1,11 @@ /* - Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration */ #ifndef SCTSIPROPERTIESCONDALG #define SCTSIPROPERTIESCONDALG -#include "AthenaBaseComps/AthAlgorithm.h" +#include "AthenaBaseComps/AthReentrantAlgorithm.h" #include "InDetConditionsSummaryService/ISiliconConditionsTool.h" #include "InDetReadoutGeometry/SiDetectorElementCollection.h" @@ -20,13 +20,13 @@ class SCT_ID; -class SCTSiPropertiesCondAlg : public AthAlgorithm +class SCTSiPropertiesCondAlg : public AthReentrantAlgorithm { public: SCTSiPropertiesCondAlg(const std::string& name, ISvcLocator* pSvcLocator); virtual ~SCTSiPropertiesCondAlg() = default; virtual StatusCode initialize() override; - virtual StatusCode execute() override; + virtual StatusCode execute(const EventContext& ctx) const override; virtual StatusCode finalize() override; private: