ATLAS Offline Software
Loading...
Searching...
No Matches
PixelSiPropertiesCondAlg.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
7#include <cmath>
8#include <memory>
9
12
13PixelSiPropertiesCondAlg::PixelSiPropertiesCondAlg(const std::string& name, ISvcLocator* pSvcLocator):
14 ::AthReentrantAlgorithm(name, pSvcLocator),
15 m_pixid(nullptr)
16{
17}
18
20 ATH_MSG_DEBUG("PixelSiPropertiesCondAlg::initialize()");
21
22 ATH_CHECK(detStore()->retrieve(m_pixid, m_pixelIDName.value()));
23
24 ATH_CHECK(m_readKeyTemp.initialize());
25 ATH_CHECK(m_readKeyHV.initialize());
26 ATH_CHECK(m_pixelDetEleCollKey.initialize());
27 ATH_CHECK(m_writeKey.initialize());
28
29 return StatusCode::SUCCESS;
30}
31
32StatusCode PixelSiPropertiesCondAlg::execute(const EventContext& ctx) const {
33 ATH_MSG_DEBUG("PixelSiPropertiesCondAlg::execute()");
34
36 if (writeHandle.isValid()) {
37 ATH_MSG_DEBUG("CondHandle " << writeHandle.fullKey() << " is already valid." << " In theory this should not be called, but may happen" << " if multiple concurrent events are being processed out of order.");
38 return StatusCode::SUCCESS;
39 }
40
42
43
44 // Read Cond Handle (temperature)
46 const PixelDCSTempData* readCdoTemp(*readHandleTemp);
47 if (readCdoTemp==nullptr) {
48 ATH_MSG_FATAL("Null pointer to the read conditions object");
49 return StatusCode::FAILURE;
50 }
51 writeHandle.addDependency(readHandleTemp);
52 ATH_MSG_INFO("Input is " << readHandleTemp.fullKey() << " with the range of " << readHandleTemp.getRange() <<", intersection " << writeHandle.getRange());
53
54 // Read Cond Handle (HV)
56 const PixelDCSHVData* readCdoHV(*readHandleHV);
57 if (readCdoHV==nullptr) {
58 ATH_MSG_FATAL("Null pointer to the read conditions object");
59 return StatusCode::FAILURE;
60 }
61 writeHandle.addDependency(readHandleHV);
62 ATH_MSG_INFO("Input is " << readHandleHV.fullKey() << " with the range of " << readHandleHV.getRange() <<", intersection " << writeHandle.getRange());
63
64
66 const InDetDD::SiDetectorElementCollection* elements(*pixelDetEleHandle);
67 if (not pixelDetEleHandle.isValid() or elements==nullptr) {
68 ATH_MSG_FATAL(m_pixelDetEleCollKey.fullKey() << " is not available.");
69 return StatusCode::FAILURE;
70 }
71
72 // Construct the output Cond Object and fill it in
73 std::unique_ptr<InDet::SiliconPropertiesVector> writeCdo(std::make_unique<InDet::SiliconPropertiesVector>());
74 const PixelID::size_type wafer_hash_max = m_pixid->wafer_hash_max();
75 writeCdo->resize(wafer_hash_max);
76 for (PixelID::size_type hash=0; hash<wafer_hash_max; hash++) {
77 const IdentifierHash elementHash = static_cast<IdentifierHash::value_type>(hash);
78
79 double temperature = readCdoTemp->getTemperature(elementHash)+273.15;
80 double deplVoltage = 0.0*CLHEP::volt;
81 double biasVoltage = readCdoHV->getBiasVoltage(elementHash)*CLHEP::volt;
82
83 const InDetDD::SiDetectorElement* element = elements->getDetectorElement(elementHash);
84 double depletionDepth = element->thickness();
85 if (std::abs(biasVoltage) < std::abs(deplVoltage)) {
86 depletionDepth *= std::sqrt(std::abs(biasVoltage/deplVoltage));
87 }
88
89 double meanElectricField = 0;
90 if (depletionDepth) { meanElectricField = biasVoltage/depletionDepth; }
91
92 writeCdo->setConditions(hash, temperature, meanElectricField);
93 }
94
95 // Record the output cond object
96 if (writeHandle.record(std::move(writeCdo)).isFailure()) {
97 ATH_MSG_FATAL("Could not record PixelSiliconPropertiesVector " << writeHandle.key() << " with EventRange " << writeHandle.getRange() << " into Conditions Store");
98 return StatusCode::FAILURE;
99 }
100 ATH_MSG_INFO("recorded new CDO " << writeHandle.key() << " with range " << writeHandle.getRange() << " into Conditions Store");
101
102 return StatusCode::SUCCESS;
103}
104
106 ATH_MSG_DEBUG("PixelSiPropertiesCondAlg::finalize()");
107 return StatusCode::SUCCESS;
108}
109
#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)
const ServiceHandle< StoreGateSvc > & detStore() const
An algorithm that can be simultaneously executed in multiple threads.
static EventIDRange infiniteMixed()
Produces an mixed EventIDRange that is infinite in Time and RunLumi.
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.
float getBiasVoltage(const int chanNum) const
float getTemperature(int chanNum) const
Identifier::size_type size_type
Definition PixelID.h:71
SG::ReadCondHandleKey< PixelDCSHVData > m_readKeyHV
SG::WriteCondHandleKey< InDet::SiliconPropertiesVector > m_writeKey
SG::ReadCondHandleKey< InDetDD::SiDetectorElementCollection > m_pixelDetEleCollKey
PixelSiPropertiesCondAlg(const std::string &name, ISvcLocator *pSvcLocator)
virtual StatusCode initialize() override
virtual StatusCode execute(const EventContext &ctx) const override
Gaudi::Property< std::string > m_pixelIDName
virtual StatusCode finalize() override
SG::ReadCondHandleKey< PixelDCSTempData > m_readKeyTemp
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