ATLAS Offline Software
Loading...
Searching...
No Matches
SCT_DCSConditionsTool.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3*/
4
5// New SCT_DCSConditions Tool, based on existing tool in SCT_ConditionsAlgs
6// A. R-Veronneau 26/02/08
7
12
13#include "GaudiKernel/ThreadLocalContext.h"
14
15#include "SCT_IdConverter.h"
17
19const float SCT_DCSConditionsTool::s_defaultHV{-30.};
21
22SCT_DCSConditionsTool::SCT_DCSConditionsTool(const std::string& type, const std::string& name, const IInterface* parent) :
23 base_class(type, name, parent)
24{
25}
26
28 if (detStore()->retrieve(m_pHelper,"SCT_ID").isFailure()) {
29 ATH_MSG_ERROR("SCT helper failed to retrieve ");
30 return StatusCode::FAILURE;
31 }
32
33 // Read Cond Handle Keys
36
37 const bool useState = (m_readAllDBFolders and m_returnHVTemp) or (not m_readAllDBFolders and not m_returnHVTemp);
38 ATH_CHECK(m_condKeyState.initialize(useState));
39
40 return StatusCode::SUCCESS;
41}
42
44 return StatusCode::SUCCESS;
45}
46
47//Can report about the module as a whole or the wafer
51
52//returns the module ID (int), or returns -1 if not able to report
54 if (not canReportAbout(h)) return s_invalidId;
55
56 Identifier moduleId;
57
59 moduleId = elementId;
60 } else if (h==InDetConditions::SCT_SIDE) {
61 moduleId = m_pHelper->module_id(elementId);
62 } else if (h==InDetConditions::SCT_STRIP) {
63 Identifier waferId = m_pHelper->wafer_id(elementId);
64 moduleId = m_pHelper->module_id(waferId);
65 }
66 return moduleId;
67}
68
69//Returns if element Id is good or bad
70bool SCT_DCSConditionsTool::isGood(const Identifier& elementId, const EventContext& ctx, InDetConditions::Hierarchy h) const {
71 Identifier moduleId{getModuleID(elementId, h)};
72 if (not moduleId.is_valid()) return true; // not canreportabout
73
75 const SCT_DCSStatCondData* condDataState{getCondDataState(ctx)};
76 if (condDataState==nullptr) return false; // no cond data
77 else if (condDataState->output(castId(moduleId))==0) return true; //No params are listed as bad
78 else return false;
79 } else {
80 return true;
81 }
82}
83
85 const EventContext& ctx{Gaudi::Hive::currentContext()};
86 return isGood(elementId, ctx, h);
87}
88
89//Does the same for hashIds
90bool SCT_DCSConditionsTool::isGood(const IdentifierHash& hashId, const EventContext& ctx) const {
91 Identifier waferId{m_pHelper->wafer_id(hashId)};
92 Identifier moduleId{m_pHelper->module_id(waferId)};
93 return isGood(moduleId, ctx, InDetConditions::SCT_MODULE);
94}
95
100 if (not condDataHandle.isValid()) {
101 ATH_MSG_ERROR("Failed to get " << m_condKeyState.key());
102 return;
103 }
104 if (whandle) {
105 whandle->addDependency (condDataHandle);
106 }
107 const SCT_DCSStatCondData* condDataState{ condDataHandle.cptr() };
108 if (condDataState==nullptr) return;
109 std::vector<bool> &status = element_status.getElementStatus();
110 if (status.empty()) {
111 status.resize(m_pHelper->wafer_hash_max(),true);
112 }
113 std::vector<InDet::ChipFlags_t> &chip_status = element_status.getElementChipStatus();
114 constexpr unsigned int N_CHIPS_PER_SIDE = 6;
115 constexpr unsigned int N_SIDES = 2;
116 constexpr InDet::ChipFlags_t all_flags_set = static_cast<InDet::ChipFlags_t>((1ul<<(N_CHIPS_PER_SIDE*N_SIDES)) - 1ul);
117 if (chip_status.empty()) {
118 chip_status.resize(status.size(), all_flags_set);
119 }
120 for ( const std::pair< const CondAttrListCollection::ChanNum, std::vector<std::string> > & dcs_state : condDataState->badChannelsMap() ) {
121 Identifier moduleId{ Identifier32{dcs_state.first} };
122 //find the corresponding hash
123 for (unsigned int side_i=0; side_i<2; ++side_i) {
124 Identifier waferId(m_pHelper->wafer_id(m_pHelper->barrel_ec (moduleId),
125 m_pHelper->layer_disk(moduleId),
126 m_pHelper->phi_module(moduleId),
127 m_pHelper->eta_module(moduleId),
128 side_i) );
129 const IdentifierHash hashId{m_pHelper->wafer_hash(waferId)};
130 status.at(hashId.value() ) = status.at(hashId.value() ) && dcs_state.second.empty();
131 chip_status.at(hashId.value()) = chip_status.at(hashId.value()) & ( dcs_state.second.empty() ? all_flags_set : 0 );
132 }
133 }
134 }
135}
136
138 const EventContext& ctx{Gaudi::Hive::currentContext()};
139 return isGood(hashId, ctx);
140}
141
143
144// some lame helper methods:
145// returns HV (s_defaultHV(-30) if there is no information)
146float SCT_DCSConditionsTool::modHV(const Identifier& elementId, const EventContext& ctx, InDetConditions::Hierarchy h) const {
147 Identifier moduleId{getModuleID(elementId, h)};
148 if (not moduleId.is_valid()) return s_defaultHV; // not canreportabout, return s_defaultHV(-30)
149
150 const SCT_DCSFloatCondData* condDataHV{getCondDataHV(ctx)};
151 if (condDataHV==nullptr) return s_defaultHV; // no cond data
152
153 float hvval{s_defaultHV};
154 if (condDataHV->getValue(castId(moduleId), hvval) and isGood(elementId, h)) {
155 return hvval;
156 }
157 return s_defaultHV; //didn't find the module, return s_defaultHV(-30)
158}
159
161 const EventContext& ctx{Gaudi::Hive::currentContext()};
162 return modHV(elementId, ctx, h);
163}
164
165//Does the same for hashIds
166float SCT_DCSConditionsTool::modHV(const IdentifierHash& hashId, const EventContext& ctx) const {
167 Identifier waferId{m_pHelper->wafer_id(hashId)};
168 Identifier moduleId{m_pHelper->module_id(waferId)};
169 return modHV(moduleId, ctx, InDetConditions::SCT_MODULE);
170}
171
173 const EventContext& ctx{Gaudi::Hive::currentContext()};
174 return modHV(hashId, ctx);
175}
176
177//Returns temp0 (s_defaultTemperature(-40) if there is no information)
178float SCT_DCSConditionsTool::hybridTemperature(const Identifier& elementId, const EventContext& ctx, InDetConditions::Hierarchy h) const {
179 Identifier moduleId{getModuleID(elementId, h)};
180 if (not moduleId.is_valid()) return s_defaultTemperature; // not canreportabout
181
182 const SCT_DCSFloatCondData* condDataTemp0{getCondDataTemp0(ctx)};
183 if (condDataTemp0==nullptr) return s_defaultTemperature; // no cond data
184
185 float temperature{s_defaultTemperature};
186 if (condDataTemp0->getValue(castId(moduleId), temperature) and isGood(elementId, h)) {
187 return temperature;
188 }
189 return s_defaultTemperature;//didn't find the module, return -40.
190}
191
193 const EventContext& ctx{Gaudi::Hive::currentContext()};
194 return hybridTemperature(elementId, ctx, h);
195}
196
197//Does the same for hashIds
198float SCT_DCSConditionsTool::hybridTemperature(const IdentifierHash& hashId, const EventContext& ctx) const {
199 Identifier waferId{m_pHelper->wafer_id(hashId)};
200 Identifier moduleId{m_pHelper->module_id(waferId)};
201 return hybridTemperature(moduleId, ctx, InDetConditions::SCT_MODULE);
202}
203
205 const EventContext& ctx{Gaudi::Hive::currentContext()};
206 return hybridTemperature(hashId, ctx);
207}
208
209//Returns temp0 + correction for Lorentz angle calculation (s_defaultTemperature(-40) if there is no information)
210float SCT_DCSConditionsTool::sensorTemperature(const Identifier& elementId, const EventContext& ctx, InDetConditions::Hierarchy h) const {
211 Identifier moduleId{getModuleID(elementId, h)};
212 if (not moduleId.is_valid()) return s_defaultTemperature; // not canreportabout
213
214 const SCT_DCSFloatCondData* condDataTemp0{getCondDataTemp0(ctx)};
215 if (condDataTemp0==nullptr) return s_defaultTemperature; // no cond data
216
217 float temperature{s_defaultTemperature};
218 if (condDataTemp0->getValue(castId(moduleId), temperature) and isGood(elementId, h)) {
219 int bec{m_pHelper->barrel_ec(moduleId)};
220 if (bec==0) { // Barrel
221 return ( temperature + m_barrel_correction); //return the temp+correction
222 } else { // Endcaps
223 int modeta{m_pHelper->eta_module(moduleId)};
224 if (modeta==2) {
225 return (temperature + m_ecInner_correction); //return the temp+correction
226 } else {
227 return (temperature + m_ecOuter_correction); //return the temp+correction
228 }
229 }
230 }
231 return s_defaultTemperature; //didn't find the module, return s_defaultTemperature(-40).
232}
233
235 const EventContext& ctx{Gaudi::Hive::currentContext()};
236 return sensorTemperature(elementId, ctx, h);
237}
238
239//Does the same for hashIds
240float SCT_DCSConditionsTool::sensorTemperature(const IdentifierHash& hashId, const EventContext& ctx) const {
241 Identifier waferId{m_pHelper->wafer_id(hashId)};
242 Identifier moduleId{m_pHelper->module_id(waferId)};
243 return sensorTemperature(moduleId, ctx, InDetConditions::SCT_MODULE);
244}
245
247 const EventContext& ctx{Gaudi::Hive::currentContext()};
248 return sensorTemperature(hashId, ctx);
249}
250
252
254SCT_DCSConditionsTool::getCondDataState(const EventContext& ctx) const {
256 return condData.retrieve();
257}
258
260SCT_DCSConditionsTool::getCondDataHV(const EventContext& ctx) const {
262 return condData.retrieve();
263}
264
266SCT_DCSConditionsTool::getCondDataTemp0(const EventContext& ctx) const {
268 return condData.retrieve();
269}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
unsigned int castId(const Identifier &identifier)
Header file for the SCT_DCSConditionsTool class in package SCT_ConditionsTools.
This is an Identifier helper class for the SCT subdetector.
Header file for AthHistogramAlgorithm.
This is a "hash" representation of an Identifier.
value_type value() const
bool is_valid() const
Check if id is in a valid state.
const std::vector< bool > & getElementStatus() const
const std::vector< ChipFlags_t > & getElementChipStatus() const
SCT_DCSConditionsTool(const std::string &type, const std::string &name, const IInterface *parent)
SG::ReadCondHandleKey< SCT_DCSFloatCondData > m_condKeyHV
static const float s_defaultHV
SG::ReadCondHandleKey< SCT_DCSStatCondData > m_condKeyState
virtual float sensorTemperature(const Identifier &elementId, const EventContext &ctx, InDetConditions::Hierarchy h=InDetConditions::DEFAULT) const override
virtual StatusCode finalize() override
const SCT_DCSFloatCondData * getCondDataHV(const EventContext &ctx) const
static const float s_defaultTemperature
virtual float modHV(const Identifier &elementId, const EventContext &ctx, InDetConditions::Hierarchy h=InDetConditions::DEFAULT) const override
virtual void getDetectorElementStatus(const EventContext &ctx, InDet::SiDetectorElementStatus &element_status, SG::WriteCondHandle< InDet::SiDetectorElementStatus > *whandle) const override
const SCT_DCSFloatCondData * getCondDataTemp0(const EventContext &ctx) const
virtual bool isGood(const Identifier &elementId, const EventContext &ctx, InDetConditions::Hierarchy h=InDetConditions::DEFAULT) const override
Summarise the result from the service as good/bad.
virtual bool canReportAbout(InDetConditions::Hierarchy h) const override
Return whether this service can report on the hierarchy level (e.g. module, chip.....
const SCT_DCSStatCondData * getCondDataState(const EventContext &ctx) const
SG::ReadCondHandleKey< SCT_DCSFloatCondData > m_condKeyTemp0
virtual Identifier getModuleID(const Identifier &elementId, InDetConditions::Hierarchy h) const
virtual float hybridTemperature(const Identifier &elementId, const EventContext &ctx, InDetConditions::Hierarchy h=InDetConditions::DEFAULT) const override
virtual StatusCode initialize() override
BooleanProperty m_readAllDBFolders
static const Identifier s_invalidId
Class for data object used in SCT_DCSConditions{HV,Temp}CondAlg, SCT_DCSConditionsTool,...
bool getValue(const CondAttrListCollection::ChanNum &chanNum, float &value) const
Get the float value for a channel.
Classs for data object used in SCT_DCSConditionsStatCondAlg, SCT_DCSConditionsTool,...
const DCSConditions & badChannelsMap() const
int output(const CondAttrListCollection::ChanNum &chanNum, std::vector< std::string > &usersVector) const
Copy all defects to a users vector, the return value is the size.
const_pointer_type retrieve()
const_pointer_type cptr()
void addDependency(const EventIDRange &range)
unsigned int castId(const Identifier &identifier)