ATLAS Offline Software
Loading...
Searching...
No Matches
SCTSiPropertiesCondAlg.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3*/
4
6
10
11#include <cmath>
12#include <memory>
13
14SCTSiPropertiesCondAlg::SCTSiPropertiesCondAlg(const std::string& name, ISvcLocator* pSvcLocator)
15 : ::AthCondAlgorithm(name, pSvcLocator)
16 , m_pHelper{nullptr}
17{
18}
19
21 ATH_MSG_DEBUG("initialize " << name());
22
23 // SCT silicon conditions tool
24 ATH_CHECK(m_siCondTool.retrieve());
25
26 // SCT ID helper
27 ATH_CHECK(detStore()->retrieve(m_pHelper, "SCT_ID"));
28
29 // Read Cond Handles
32 ATH_CHECK(m_SCTDetEleCollKey.initialize());
33 if (m_forceGeoModel){
34 ATH_MSG_INFO("Configured to use GeoModel values of HV and Temp, not conditions");
35 }
36 // Write Cond Handle
37 ATH_CHECK(m_writeKey.initialize());
38
39 return StatusCode::SUCCESS;
40}
41
42StatusCode SCTSiPropertiesCondAlg::execute(const EventContext& ctx) const {
43 ATH_MSG_DEBUG("execute " << name());
44
45 // Write Cond Handle
47 // Do we have a valid Write Cond Handle for current time?
48 if (writeHandle.isValid()) {
49 ATH_MSG_DEBUG("CondHandle " << writeHandle.fullKey() << " is already valid."
50 << " In theory this should not be called, but may happen"
51 << " if multiple concurrent events are being processed out of order.");
52 return StatusCode::SUCCESS;
53 }
54
55 if (!m_forceGeoModel){
56 // Read Cond Handle (temperature)
58 const SCT_DCSFloatCondData* readCdoTemp{*readHandleTemp};
59 if (readCdoTemp==nullptr) {
60 ATH_MSG_FATAL("Null pointer to the read conditions object");
61 return StatusCode::FAILURE;
62 }
63 writeHandle.addDependency(readHandleTemp);
64 ATH_MSG_INFO("Input is " << readHandleTemp.fullKey() << " with the range of " << readHandleTemp.getRange());
65
66 // Read Cond Handle (HV)
68 const SCT_DCSFloatCondData* readCdoHV{*readHandleHV};
69 if (readCdoHV==nullptr) {
70 ATH_MSG_FATAL("Null pointer to the read conditions object");
71 return StatusCode::FAILURE;
72 }
73 writeHandle.addDependency(readHandleHV);
74 ATH_MSG_INFO("Input is " << readHandleHV.fullKey() << " with the range of " << readHandleHV.getRange());
75 }
76
77 // Get SCT_DetectorElementCollection
79 const InDetDD::SiDetectorElementCollection* elements(sctDetEle.retrieve());
80 if (elements==nullptr) {
81 ATH_MSG_FATAL(m_SCTDetEleCollKey.fullKey() << " could not be retrieved");
82 return StatusCode::FAILURE;
83 }
84 writeHandle.addDependency(sctDetEle);
85
86 // Construct the output Cond Object and fill it in
87 std::unique_ptr<InDet::SiliconPropertiesVector> writeCdo{std::make_unique<InDet::SiliconPropertiesVector>()};
88 const SCT_ID::size_type wafer_hash_max{m_pHelper->wafer_hash_max()};
89 writeCdo->resize(wafer_hash_max);
90 for (SCT_ID::size_type hash{0}; hash<wafer_hash_max; hash++) {
91 const IdentifierHash elementHash{static_cast<IdentifierHash::value_type>(hash)};
92
93 double temperatureC{m_siCondTool->temperature(elementHash, ctx)};
94
95 if (not ((temperatureC>m_temperatureMin) and (temperatureC<m_temperatureMax))) {
96 ATH_MSG_DEBUG("Invalid temperature: "
97 << temperatureC << " C. "
98 << "Setting to " << m_temperatureDefault << " C. "
99 << "Detector element hash: " << elementHash);
100 temperatureC = m_temperatureDefault;
101 }
102
103 double temperature{temperatureC + 273.15};
104 double deplVoltage{m_siCondTool->depletionVoltage(elementHash, ctx) * CLHEP::volt};
105 double biasVoltage{m_siCondTool->biasVoltage(elementHash, ctx) * CLHEP::volt};
106
107 const InDetDD::SiDetectorElement* element{elements->getDetectorElement(elementHash)};
108 double depletionDepth{element->thickness()};
109 if (std::abs(biasVoltage)<std::abs(deplVoltage)) {
110 depletionDepth *= std::sqrt(std::abs(biasVoltage/deplVoltage));
111 }
112 double meanElectricField{0.};
113 if (depletionDepth>0.) {
114 meanElectricField = biasVoltage/depletionDepth;
115 }
116
117 writeCdo->setConditions(hash, temperature, meanElectricField);
118 }
119
120 // Record the output cond object
121 if (writeHandle.record(std::move(writeCdo)).isFailure()) {
122 ATH_MSG_FATAL("Could not record SCT_DCSFloatCondData " << writeHandle.key()
123 << " with EventRange " << writeHandle.getRange()
124 << " into Conditions Store");
125 return StatusCode::FAILURE;
126 }
127 ATH_MSG_INFO("recorded new CDO " << writeHandle.key() << " with range " << writeHandle.getRange() << " into Conditions Store");
128
129 return StatusCode::SUCCESS;
130}
131
133{
134 ATH_MSG_DEBUG("finalize " << name());
135 return StatusCode::SUCCESS;
136}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_FATAL(x)
#define ATH_MSG_INFO(x)
#define ATH_MSG_DEBUG(x)
This is an Identifier helper class for the SCT subdetector.
const ServiceHandle< StoreGateSvc > & detStore() const
Base class for conditions algorithms.
This is a "hash" representation of an Identifier.
unsigned int value_type
Class to hold the SiDetectorElement objects to be put in the detector store.
const SiDetectorElement * getDetectorElement(const IdentifierHash &hash) const
Class to hold geometrical description of a silicon detector element.
ToolHandle< ISiliconConditionsTool > m_siCondTool
const SCT_ID * m_pHelper
ID helper for SCT.
virtual StatusCode finalize() override final
SCTSiPropertiesCondAlg(const std::string &name, ISvcLocator *pSvcLocator)
SG::WriteCondHandleKey< InDet::SiliconPropertiesVector > m_writeKey
SG::ReadCondHandleKey< InDetDD::SiDetectorElementCollection > m_SCTDetEleCollKey
virtual StatusCode initialize() override final
SG::ReadCondHandleKey< SCT_DCSFloatCondData > m_readKeyHV
SG::ReadCondHandleKey< SCT_DCSFloatCondData > m_readKeyTemp
virtual StatusCode execute(const EventContext &ctx) const override
Class for data object used in SCT_DCSConditions{HV,Temp}CondAlg, SCT_DCSConditionsTool,...
Identifier::size_type size_type
Definition SCT_ID.h:72
const_pointer_type retrieve()
const DataObjID & fullKey() const
const EventIDRange & getRange()
const std::string & key() const
void addDependency(const EventIDRange &range)
const EventIDRange & getRange() const
StatusCode record(const EventIDRange &range, T *t)
record handle, with explicit range DEPRECATED
const DataObjID & fullKey() const