ATLAS Offline Software
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 
14 SCTSiPropertiesCondAlg::SCTSiPropertiesCondAlg(const std::string& name, ISvcLocator* pSvcLocator)
15  : ::AthReentrantAlgorithm(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
33  if (m_forceGeoModel){
34  ATH_MSG_INFO("Configured to use GeoModel values of HV and Temp, not conditions");
35  }
36  // Write Cond Handle
38 
39  return StatusCode::SUCCESS;
40 }
41 
42 StatusCode 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 *= 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 }
python.PyKernel.retrieve
def retrieve(aClass, aKey=None)
Definition: PyKernel.py:110
SCT_DCSFloatCondData
Class for data object used in SCT_DCSConditions{HV,Temp}CondAlg, SCT_DCSConditionsTool,...
Definition: SCT_DCSFloatCondData.h:30
ATH_MSG_FATAL
#define ATH_MSG_FATAL(x)
Definition: AthMsgStreamMacros.h:34
SCT_ID.h
This is an Identifier helper class for the SCT subdetector. This class is a factory for creating comp...
InDetDD::SiDetectorElementCollection
Definition: SiDetectorElementCollection.h:30
SG::ReadCondHandle
Definition: ReadCondHandle.h:44
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
SCTSiPropertiesCondAlg::m_siCondTool
ToolHandle< ISiliconConditionsTool > m_siCondTool
Definition: SCTSiPropertiesCondAlg.h:42
SCTSiPropertiesCondAlg::m_temperatureMax
DoubleProperty m_temperatureMax
Definition: SCTSiPropertiesCondAlg.h:34
IdentifierHash::value_type
unsigned int value_type
Definition: IdentifierHash.h:27
SCTSiPropertiesCondAlg::m_pHelper
const SCT_ID * m_pHelper
ID helper for SCT.
Definition: SCTSiPropertiesCondAlg.h:43
AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::detStore
const ServiceHandle< StoreGateSvc > & detStore() const
The standard StoreGateSvc/DetectorStore Returns (kind of) a pointer to the StoreGateSvc.
Definition: AthCommonDataStore.h:95
AthReentrantAlgorithm
An algorithm that can be simultaneously executed in multiple threads.
Definition: AthReentrantAlgorithm.h:83
SG::ReadCondHandle::retrieve
const_pointer_type retrieve()
Definition: ReadCondHandle.h:162
InDetDD::SolidStateDetectorElementBase::thickness
double thickness() const
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
SCT_ID::size_type
Identifier::size_type size_type
Definition: SCT_ID.h:72
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
python.SystemOfUnits.volt
int volt
Definition: SystemOfUnits.py:204
SCTSiPropertiesCondAlg::m_readKeyTemp
SG::ReadCondHandleKey< SCT_DCSFloatCondData > m_readKeyTemp
Definition: SCTSiPropertiesCondAlg.h:37
SCTSiPropertiesCondAlg::m_writeKey
SG::WriteCondHandleKey< InDet::SiliconPropertiesVector > m_writeKey
Definition: SCTSiPropertiesCondAlg.h:40
SCTSiPropertiesCondAlg::finalize
virtual StatusCode finalize() override final
Definition: SCTSiPropertiesCondAlg.cxx:132
SCTSiPropertiesCondAlg.h
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
SCT_ID::wafer_hash_max
size_type wafer_hash_max(void) const
Definition: SCT_ID.cxx:645
IdentifierHash.h
InDetDD::SiDetectorElement
Definition: SiDetectorElement.h:109
SG::CondHandleKey::initialize
StatusCode initialize(bool used=true)
SCTSiPropertiesCondAlg::m_temperatureDefault
DoubleProperty m_temperatureDefault
Definition: SCTSiPropertiesCondAlg.h:35
SCTSiPropertiesCondAlg::m_SCTDetEleCollKey
SG::ReadCondHandleKey< InDetDD::SiDetectorElementCollection > m_SCTDetEleCollKey
Definition: SCTSiPropertiesCondAlg.h:39
SiDetectorElement.h
SCTSiPropertiesCondAlg::initialize
virtual StatusCode initialize() override final
Definition: SCTSiPropertiesCondAlg.cxx:20
CaloCondBlobAlgs_fillNoiseFromASCII.hash
dictionary hash
Definition: CaloCondBlobAlgs_fillNoiseFromASCII.py:109
SCTSiPropertiesCondAlg::m_readKeyHV
SG::ReadCondHandleKey< SCT_DCSFloatCondData > m_readKeyHV
Definition: SCTSiPropertiesCondAlg.h:38
SCTSiPropertiesCondAlg::execute
virtual StatusCode execute(const EventContext &ctx) const override
Definition: SCTSiPropertiesCondAlg.cxx:42
SCTSiPropertiesCondAlg::m_temperatureMin
DoubleProperty m_temperatureMin
Definition: SCTSiPropertiesCondAlg.h:33
IdentifierHash
This is a "hash" representation of an Identifier. This encodes a 32 bit index which can be used to lo...
Definition: IdentifierHash.h:25
SG::WriteCondHandle
Definition: WriteCondHandle.h:26
InDetDD::SiDetectorElementCollection::getDetectorElement
const SiDetectorElement * getDetectorElement(const IdentifierHash &hash) const
Definition: SiDetectorElementCollection.cxx:15
SCTSiPropertiesCondAlg::m_forceGeoModel
BooleanProperty m_forceGeoModel
Definition: SCTSiPropertiesCondAlg.h:36
SCTSiPropertiesCondAlg::SCTSiPropertiesCondAlg
SCTSiPropertiesCondAlg(const std::string &name, ISvcLocator *pSvcLocator)
Definition: SCTSiPropertiesCondAlg.cxx:14