ATLAS Offline Software
SCT_SiliconConditionsTool.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
3 */
4 
6 
12 #include "InDetIdentifier/SCT_ID.h"
13 
14 // Constructor
15 SCT_SiliconConditionsTool::SCT_SiliconConditionsTool(const std::string& type, const std::string& name, const IInterface* parent):
16  base_class(type, name, parent)
17 {
18  // These will get overwritten if used but give them some initial value anyway.
22 }
23 
24 // Initialize
26  ATH_MSG_DEBUG("SCT_SiliconConditionsTool::initialize()");
27 
30  if (m_useGeoModel) {
31  ATH_MSG_INFO("Default conditions come from GeoModel.");
32  } else {
33  ATH_MSG_INFO("GeoModel requests to use Conditions DB.");
34  }
35  }
36 
39 
40  if (not m_useGeoModel) {
41  ATH_MSG_INFO("Will use temperature and voltages from this service (not from GeoModel).");
42 
43  // Get from Conditions database. Register callback, etc.
44  if (m_useDB) {
45  ATH_CHECK(detStore()->retrieve(m_sct_id, "SCT_ID"));
46 
47  ATH_MSG_INFO("SCTDCSSvc retrieved");
48  }
49  } else {
50  // Otherwise we use the GeoModel values
54  }
55  return StatusCode::SUCCESS;
56 }
57 
58 // Finalize
60  ATH_MSG_DEBUG("SCT_SiliconConditionsTool::finalize()");
61  return StatusCode::SUCCESS;
62 }
63 
64 // Silicon temperature (by Identifier)
65 float SCT_SiliconConditionsTool::temperature(const Identifier& elementId, const EventContext& ctx) const {
66  const IdentifierHash elementHash{m_sct_id->wafer_hash(elementId)};
67  return temperature(elementHash, ctx);
68 }
69 
70 // Silicon bias voltage (by Identifier)
71 float SCT_SiliconConditionsTool::biasVoltage(const Identifier& elementId, const EventContext& ctx) const {
72  const IdentifierHash elementHash{m_sct_id->wafer_hash(elementId)};
73  return biasVoltage(elementHash, ctx);
74 }
75 
76 // Silicon depletion voltage (by Identifier)
77 float SCT_SiliconConditionsTool::depletionVoltage(const Identifier& /*elementId*/, const EventContext& /*ctx*/) const {
79 }
80 
81 // Silicon temperature (by IdentifierHash)
82 float SCT_SiliconConditionsTool::temperature(const IdentifierHash& elementHash, const EventContext& ctx) const {
83  if (m_useDB and (not m_useGeoModel)) {
85  if (data==nullptr) return m_defaultTemperature;
87  if (not data->getValue(elementHash, temperature)) return m_defaultTemperature;
88  if (temperature <= -30.){
89  ATH_MSG_DEBUG( "Sensor temperature: "<< temperature <<" < -30 ");
90  return m_defaultTemperature;
91  }
92  return temperature;
93  }
94  return m_defaultTemperature;
95 }
96 
97 // Silicon bias voltage (by IdentifierHash)
98 float SCT_SiliconConditionsTool::biasVoltage(const IdentifierHash& elementHash, const EventContext& ctx) const {
99 
100  if (m_useDB and (not m_useGeoModel)) {
102  if (data==nullptr) return m_defaultBiasVoltage;
103  float hv{m_defaultBiasVoltage};
104  if (not data->getValue(elementHash, hv)) return m_defaultBiasVoltage;
105  if (hv < 0.) {
106  ATH_MSG_DEBUG("HV: "<< hv <<" < 0 ");
107  return m_defaultBiasVoltage;
108  }
109  return hv;
110  }
111  return m_defaultBiasVoltage;
112 }
113 
114 // Silicon deplition voltage (by IdentifierHash)
115 float SCT_SiliconConditionsTool::depletionVoltage(const IdentifierHash& /*elementHash*/, const EventContext& /*ctx*/) const {
117 }
118 
119 bool
121 {
122  bool conditionsPresent{false};
123  bool useCondDB{false};
124 
125  if (m_rdbSvc.retrieve().isFailure()) {
126  ATH_MSG_ERROR("Could not locate RDBAccessSvc");
127  return false;
128  }
129 
130  if (m_geoModelSvc.retrieve().isFailure()) {
131  ATH_MSG_ERROR("Could not locate GeoModelSvc");
132  return false;
133  }
134  DecodeVersionKey versionKey{&*m_geoModelSvc, "SCT"};
135  ATH_MSG_DEBUG("Checking GeoModel Version Tag: "<< versionKey.tag() << " at Node: " << versionKey.node());
136 
137  IRDBRecordset_ptr sctConditionsSet{m_rdbSvc->getRecordsetPtr("SctConditions", versionKey.tag(), versionKey.node())};
138  if (sctConditionsSet->size()) {
139  ATH_MSG_DEBUG("Default conditions available from GeoModel.");
140  const IRDBRecord* defaultConditions{(*sctConditionsSet)[0]};
141  m_geoModelTemperature = defaultConditions->getDouble("TEMPERATURE");
142  m_geoModelBiasVoltage = defaultConditions->getDouble("BIASVOLT");
143  m_geoModelDepletionVoltage = defaultConditions->getDouble("DEPLETIONVOLT");
144  conditionsPresent = true;
145  // If m_forceUseGeoModel set then we ignore the USECONDDB column and
146  // keep useCondDB = false
147  if ((not m_forceUseGeoModel) and (not defaultConditions->isFieldNull("USECONDDB"))) { // USECONDDB Not present in old SCT tables
148  useCondDB = (defaultConditions->getInt("USECONDDB"));
149  }
150  } else {
151  ATH_MSG_WARNING("Default conditions NOT available in GeoModel database. Using old GeoModel defaults");
152  // These are pre DC3 geometries. Probably never will be used.
154  m_geoModelBiasVoltage = 100;
156  conditionsPresent = true;
157  }
158 
159  return ((not useCondDB) and conditionsPresent);
160 
161 }
162 
163 const SCT_DCSFloatCondData* SCT_SiliconConditionsTool::getCondDataHV(const EventContext& ctx) const {
165  if (not condData.isValid()) {
166  ATH_MSG_ERROR("Failed to get " << m_condKeyHV.key());
167  return nullptr;
168  }
169  return *condData;
170 }
171 
174  if (not condData.isValid()) {
175  ATH_MSG_ERROR("Failed to get " << m_condKeyTemp.key());
176  return nullptr;
177  }
178  return *condData;
179 }
python.PyKernel.retrieve
def retrieve(aClass, aKey=None)
Definition: PyKernel.py:110
SCT_SiliconConditionsTool::m_sct_id
const SCT_ID * m_sct_id
Definition: SCT_SiliconConditionsTool.h:85
data
char data[hepevt_bytes_allocation_ATLAS]
Definition: HepEvt.cxx:11
SCT_SiliconConditionsTool.h
SCT_DCSFloatCondData
Class for data object used in SCT_DCSConditions{HV,Temp}CondAlg, SCT_DCSConditionsTool,...
Definition: SCT_DCSFloatCondData.h:30
SCT_SiliconConditionsTool::initialize
virtual StatusCode initialize() override
Initialise.
Definition: SCT_SiliconConditionsTool.cxx:25
SCT_ID.h
This is an Identifier helper class for the SCT subdetector. This class is a factory for creating comp...
SCT_SiliconConditionsTool::m_geoModelBiasVoltage
float m_geoModelBiasVoltage
Definition: SCT_SiliconConditionsTool.h:78
SCT_SiliconConditionsTool::m_useDB
BooleanProperty m_useDB
Definition: SCT_SiliconConditionsTool.h:70
SG::ReadCondHandle
Definition: ReadCondHandle.h:44
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
SCT_SiliconConditionsTool::getCondDataTemp
const SCT_DCSFloatCondData * getCondDataTemp(const EventContext &ctx) const
Definition: SCT_SiliconConditionsTool.cxx:172
SCT_SiliconConditionsTool::SCT_SiliconConditionsTool
SCT_SiliconConditionsTool(const std::string &type, const std::string &name, const IInterface *parent)
Constructor.
Definition: SCT_SiliconConditionsTool.cxx:15
SCT_SiliconConditionsTool::m_defaultTemperature
FloatProperty m_defaultTemperature
Definition: SCT_SiliconConditionsTool.h:67
SCT_SiliconConditionsTool::m_geoModelTemperature
float m_geoModelTemperature
Definition: SCT_SiliconConditionsTool.h:77
SCT_SiliconConditionsTool::finalize
virtual StatusCode finalize() override
Finalise.
Definition: SCT_SiliconConditionsTool.cxx:59
SCT_SiliconConditionsTool::m_forceUseGeoModel
BooleanProperty m_forceUseGeoModel
Definition: SCT_SiliconConditionsTool.h:72
SG::VarHandleKey::key
const std::string & key() const
Return the StoreGate ID for the referenced object.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleKey.cxx:141
SCT_SiliconConditionsTool::m_geoModelSvc
ServiceHandle< IGeoModelSvc > m_geoModelSvc
Definition: SCT_SiliconConditionsTool.h:74
SCT_SiliconConditionsTool::m_useGeoModel
bool m_useGeoModel
Definition: SCT_SiliconConditionsTool.h:80
IRDBAccessSvc.h
Definition of the abstract IRDBAccessSvc interface.
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
SCT_SiliconConditionsTool::temperature
virtual float temperature(const Identifier &elementId, const EventContext &ctx) const override
Silicon temperature by Identifier.
Definition: SCT_SiliconConditionsTool.cxx:65
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
DecodeVersionKey
This is a helper class to query the version tags from GeoModelSvc and determine the appropriate tag a...
Definition: DecodeVersionKey.h:18
test_pyathena.parent
parent
Definition: test_pyathena.py:15
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
SCT_SiliconConditionsTool::m_defaultDepletionVoltage
FloatProperty m_defaultDepletionVoltage
Definition: SCT_SiliconConditionsTool.h:69
SCT_ID::wafer_hash
IdentifierHash wafer_hash(const Identifier &wafer_id) const
wafer hash from id - optimized
Definition: SCT_ID.h:492
SCT_SiliconConditionsTool::m_geoModelDepletionVoltage
float m_geoModelDepletionVoltage
Definition: SCT_SiliconConditionsTool.h:79
SCT_SiliconConditionsTool::m_checkGeoModel
BooleanProperty m_checkGeoModel
Definition: SCT_SiliconConditionsTool.h:71
IRDBRecordset_ptr
std::shared_ptr< IRDBRecordset > IRDBRecordset_ptr
Definition: IRDBAccessSvc.h:25
SCT_SiliconConditionsTool::m_defaultBiasVoltage
FloatProperty m_defaultBiasVoltage
Definition: SCT_SiliconConditionsTool.h:68
python.PyKernel.detStore
detStore
Definition: PyKernel.py:41
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
SCT_SiliconConditionsTool::depletionVoltage
virtual float depletionVoltage(const Identifier &elementId, const EventContext &ctx) const override
Silicon depletion voltage by Identifier.
Definition: SCT_SiliconConditionsTool.cxx:77
SCT_SiliconConditionsTool::getCondDataHV
const SCT_DCSFloatCondData * getCondDataHV(const EventContext &ctx) const
Definition: SCT_SiliconConditionsTool.cxx:163
SG::CondHandleKey::initialize
StatusCode initialize(bool used=true)
DecodeVersionKey.h
IRDBRecord.h
Definition of the abstract IRDBRecord interface.
SCT_SiliconConditionsTool::m_rdbSvc
ServiceHandle< IRDBAccessSvc > m_rdbSvc
Definition: SCT_SiliconConditionsTool.h:75
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
IRDBRecord
IRDBRecord is one record in the IRDBRecordset object.
Definition: IRDBRecord.h:27
SCT_SiliconConditionsTool::setConditionsFromGeoModel
bool setConditionsFromGeoModel()
Definition: SCT_SiliconConditionsTool.cxx:120
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
SCT_SiliconConditionsTool::m_condKeyTemp
SG::ReadCondHandleKey< SCT_DCSFloatCondData > m_condKeyTemp
Definition: SCT_SiliconConditionsTool.h:83
SCT_SiliconConditionsTool::biasVoltage
virtual float biasVoltage(const Identifier &elementId, const EventContext &ctx) const override
Silicon bias voltage by Identifier.
Definition: SCT_SiliconConditionsTool.cxx:71
IRDBRecordset.h
Definition of the abstract IRDBRecordset interface.
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
IGeoModelSvc.h
SCT_SiliconConditionsTool::m_condKeyHV
SG::ReadCondHandleKey< SCT_DCSFloatCondData > m_condKeyHV
Definition: SCT_SiliconConditionsTool.h:82
Identifier
Definition: IdentifierFieldParser.cxx:14