ATLAS Offline Software
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 
13 PixelSiPropertiesCondAlg::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 
23 
28 
29  return StatusCode::SUCCESS;
30 }
31 
32 StatusCode 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 *= 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 
python.PyKernel.retrieve
def retrieve(aClass, aKey=None)
Definition: PyKernel.py:110
IdentifierHash::value_type
unsigned int value_type
Definition: IdentifierHash.h:48
ATH_MSG_FATAL
#define ATH_MSG_FATAL(x)
Definition: AthMsgStreamMacros.h:34
PixelSiPropertiesCondAlg::m_writeKey
SG::WriteCondHandleKey< InDet::SiliconPropertiesVector > m_writeKey
Definition: PixelSiPropertiesCondAlg.h:48
SG::ReadCondHandle::getRange
const EventIDRange & getRange()
Definition: ReadCondHandle.h:241
SG::ReadCondHandle::fullKey
const DataObjID & fullKey() const
Definition: ReadCondHandle.h:60
PixelSiPropertiesCondAlg::PixelSiPropertiesCondAlg
PixelSiPropertiesCondAlg(const std::string &name, ISvcLocator *pSvcLocator)
Definition: PixelSiPropertiesCondAlg.cxx:13
InDetDD::SiDetectorElementCollection
Definition: SiDetectorElementCollection.h:30
SG::ReadCondHandle
Definition: ReadCondHandle.h:44
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
SG::WriteCondHandle::getRange
const EventIDRange & getRange() const
Definition: WriteCondHandle.h:89
IOVInfiniteRange::infiniteMixed
static EventIDRange infiniteMixed()
Produces an mixed EventIDRange that is infinite in Time and RunLumi.
Definition: IOVInfiniteRange.h:55
SG::ReadCondHandle::isValid
bool isValid()
Definition: ReadCondHandle.h:205
PixelSiPropertiesCondAlg.h
PixelDCSTempData
Definition: PixelDCSTempData.h:19
SG::WriteCondHandle::record
StatusCode record(const EventIDRange &range, T *t)
record handle, with explicit range DEPRECATED
Definition: WriteCondHandle.h:157
PixelDCSHVData
Definition: PixelDCSHVData.h:19
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
PixelSiPropertiesCondAlg::m_pixelDetEleCollKey
SG::ReadCondHandleKey< InDetDD::SiDetectorElementCollection > m_pixelDetEleCollKey
Definition: PixelSiPropertiesCondAlg.h:45
SG::WriteCondHandle::fullKey
const DataObjID & fullKey() const
Definition: WriteCondHandle.h:41
InDet::SiliconPropertiesVector::resize
void resize(IdentifierHash::value_type size)
Definition: SiliconPropertiesVector.cxx:21
InDetDD::SolidStateDetectorElementBase::thickness
double thickness() const
InDet::SiliconPropertiesVector::setConditions
void setConditions(const IdentifierHash &elementHash, const double temperature, const double electricField)
Definition: SiliconPropertiesVector.cxx:30
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
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
python.SystemOfUnits.volt
int volt
Definition: SystemOfUnits.py:204
PixelSiPropertiesCondAlg::m_readKeyTemp
SG::ReadCondHandleKey< PixelDCSTempData > m_readKeyTemp
Definition: PixelSiPropertiesCondAlg.h:39
PixelSiPropertiesCondAlg::finalize
virtual StatusCode finalize() override
Definition: PixelSiPropertiesCondAlg.cxx:105
IOVInfiniteRange.h
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
PixelSiPropertiesCondAlg::m_readKeyHV
SG::ReadCondHandleKey< PixelDCSHVData > m_readKeyHV
Definition: PixelSiPropertiesCondAlg.h:42
SG::WriteCondHandle::key
const std::string & key() const
Definition: WriteCondHandle.h:40
InDetDD::SiDetectorElement
Definition: SiDetectorElement.h:109
SG::CondHandleKey::initialize
StatusCode initialize(bool used=true)
PixelID::wafer_hash_max
size_type wafer_hash_max(void) const
Definition: PixelID.cxx:912
SiDetectorElement.h
PixelSiPropertiesCondAlg::m_pixelIDName
Gaudi::Property< std::string > m_pixelIDName
Definition: PixelSiPropertiesCondAlg.h:36
CaloCondBlobAlgs_fillNoiseFromASCII.hash
dictionary hash
Definition: CaloCondBlobAlgs_fillNoiseFromASCII.py:109
PixelDCSHVData::getBiasVoltage
float getBiasVoltage(const int chanNum) const
Definition: PixelDCSHVData.cxx:11
SG::WriteCondHandle::isValid
bool isValid() const
Definition: WriteCondHandle.h:248
PixelSiPropertiesCondAlg::initialize
virtual StatusCode initialize() override
Definition: PixelSiPropertiesCondAlg.cxx:19
PixelSiPropertiesCondAlg::m_pixid
const PixelID * m_pixid
Definition: PixelSiPropertiesCondAlg.h:34
PixelID::size_type
Identifier::size_type size_type
Definition: PixelID.h:71
PixelSiPropertiesCondAlg::execute
virtual StatusCode execute(const EventContext &ctx) const override
Definition: PixelSiPropertiesCondAlg.cxx:32
IdentifierHash
Definition: IdentifierHash.h:38
SG::WriteCondHandle
Definition: WriteCondHandle.h:26
InDetDD::SiDetectorElementCollection::getDetectorElement
const SiDetectorElement * getDetectorElement(const IdentifierHash &hash) const
Definition: SiDetectorElementCollection.cxx:15
PixelDCSTempData::getTemperature
float getTemperature(const int chanNum) const
Definition: PixelDCSTemp.cxx:11
SG::WriteCondHandle::addDependency
void addDependency(const EventIDRange &range)
Definition: WriteCondHandle.h:275