ATLAS Offline Software
Loading...
Searching...
No Matches
SCT_DCSConditionsTool.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2026 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 "SCT_IdConverter.h"
15
17const float SCT_DCSConditionsTool::s_defaultHV{-30.};
19
20SCT_DCSConditionsTool::SCT_DCSConditionsTool(const std::string& type, const std::string& name, const IInterface* parent) :
21 base_class(type, name, parent)
22{
23}
24
26 if (detStore()->retrieve(m_pHelper,"SCT_ID").isFailure()) {
27 ATH_MSG_ERROR("SCT helper failed to retrieve ");
28 return StatusCode::FAILURE;
29 }
30
31 // Read Cond Handle Keys
34
35 const bool useState = (m_readAllDBFolders and m_returnHVTemp) or (not m_readAllDBFolders and not m_returnHVTemp);
36 ATH_CHECK(m_condKeyState.initialize(useState));
37
38 return StatusCode::SUCCESS;
39}
40
42 return StatusCode::SUCCESS;
43}
44
45//Can report about the module as a whole or the wafer
49
50//returns the module ID (int), or returns -1 if not able to report
52 if (not canReportAbout(h)) return s_invalidId;
53
54 Identifier moduleId;
55
57 moduleId = elementId;
58 } else if (h==InDetConditions::SCT_SIDE) {
59 moduleId = m_pHelper->module_id(elementId);
60 } else if (h==InDetConditions::SCT_STRIP) {
61 Identifier waferId = m_pHelper->wafer_id(elementId);
62 moduleId = m_pHelper->module_id(waferId);
63 }
64 return moduleId;
65}
66
67//Returns if element Id is good or bad
68bool SCT_DCSConditionsTool::isGood(const Identifier& elementId, const EventContext& ctx, InDetConditions::Hierarchy h) const {
69 Identifier moduleId{getModuleID(elementId, h)};
70 if (not moduleId.is_valid()) return true; // not canreportabout
71
73 const SCT_DCSStatCondData* condDataState{getCondDataState(ctx)};
74 if (condDataState==nullptr) return false; // no cond data
75 else if (condDataState->output(castId(moduleId))==0) return true; //No params are listed as bad
76 else return false;
77 } else {
78 return true;
79 }
80}
81
82//Does the same for hashIds
83bool SCT_DCSConditionsTool::isGood(const IdentifierHash& hashId, const EventContext& ctx) const {
84 Identifier waferId{m_pHelper->wafer_id(hashId)};
85 Identifier moduleId{m_pHelper->module_id(waferId)};
86 return isGood(moduleId, ctx, InDetConditions::SCT_MODULE);
87}
88
93 if (not condDataHandle.isValid()) {
94 ATH_MSG_ERROR("Failed to get " << m_condKeyState.key());
95 return;
96 }
97 if (whandle) {
98 whandle->addDependency (condDataHandle);
99 }
100 const SCT_DCSStatCondData* condDataState{ condDataHandle.cptr() };
101 if (condDataState==nullptr) return;
102 std::vector<bool> &status = element_status.getElementStatus();
103 if (status.empty()) {
104 status.resize(m_pHelper->wafer_hash_max(),true);
105 }
106 std::vector<InDet::ChipFlags_t> &chip_status = element_status.getElementChipStatus();
107 constexpr unsigned int N_CHIPS_PER_SIDE = 6;
108 constexpr unsigned int N_SIDES = 2;
109 constexpr InDet::ChipFlags_t all_flags_set = static_cast<InDet::ChipFlags_t>((1ul<<(N_CHIPS_PER_SIDE*N_SIDES)) - 1ul);
110 if (chip_status.empty()) {
111 chip_status.resize(status.size(), all_flags_set);
112 }
113 for ( const std::pair< const CondAttrListCollection::ChanNum, std::vector<std::string> > & dcs_state : condDataState->badChannelsMap() ) {
114 Identifier moduleId{ Identifier32{dcs_state.first} };
115 //find the corresponding hash
116 for (unsigned int side_i=0; side_i<2; ++side_i) {
117 Identifier waferId(m_pHelper->wafer_id(m_pHelper->barrel_ec (moduleId),
118 m_pHelper->layer_disk(moduleId),
119 m_pHelper->phi_module(moduleId),
120 m_pHelper->eta_module(moduleId),
121 side_i) );
122 const IdentifierHash hashId{m_pHelper->wafer_hash(waferId)};
123 status.at(hashId.value() ) = status.at(hashId.value() ) && dcs_state.second.empty();
124 chip_status.at(hashId.value()) = chip_status.at(hashId.value()) & ( dcs_state.second.empty() ? all_flags_set : 0 );
125 }
126 }
127 }
128}
129
131
132// some lame helper methods:
133// returns HV (s_defaultHV(-30) if there is no information)
134float SCT_DCSConditionsTool::modHV(const Identifier& elementId, const EventContext& ctx, InDetConditions::Hierarchy h) const {
135 Identifier moduleId{getModuleID(elementId, h)};
136 if (not moduleId.is_valid()) return s_defaultHV; // not canreportabout, return s_defaultHV(-30)
137
138 const SCT_DCSFloatCondData* condDataHV{getCondDataHV(ctx)};
139 if (condDataHV==nullptr) return s_defaultHV; // no cond data
140
141 float hvval{s_defaultHV};
142 if (condDataHV->getValue(castId(moduleId), hvval) and isGood(elementId, ctx, h)) {
143 return hvval;
144 }
145 return s_defaultHV; //didn't find the module, return s_defaultHV(-30)
146}
147
148//Does the same for hashIds
149float SCT_DCSConditionsTool::modHV(const IdentifierHash& hashId, const EventContext& ctx) const {
150 Identifier waferId{m_pHelper->wafer_id(hashId)};
151 Identifier moduleId{m_pHelper->module_id(waferId)};
152 return modHV(moduleId, ctx, InDetConditions::SCT_MODULE);
153}
154
155//Returns temp0 (s_defaultTemperature(-40) if there is no information)
156float SCT_DCSConditionsTool::hybridTemperature(const Identifier& elementId, const EventContext& ctx, InDetConditions::Hierarchy h) const {
157 Identifier moduleId{getModuleID(elementId, h)};
158 if (not moduleId.is_valid()) return s_defaultTemperature; // not canreportabout
159
160 const SCT_DCSFloatCondData* condDataTemp0{getCondDataTemp0(ctx)};
161 if (condDataTemp0==nullptr) return s_defaultTemperature; // no cond data
162
163 float temperature{s_defaultTemperature};
164 if (condDataTemp0->getValue(castId(moduleId), temperature) and isGood(elementId, ctx, h)) {
165 return temperature;
166 }
167 return s_defaultTemperature;//didn't find the module, return -40.
168}
169
170//Does the same for hashIds
171float SCT_DCSConditionsTool::hybridTemperature(const IdentifierHash& hashId, const EventContext& ctx) const {
172 Identifier waferId{m_pHelper->wafer_id(hashId)};
173 Identifier moduleId{m_pHelper->module_id(waferId)};
174 return hybridTemperature(moduleId, ctx, InDetConditions::SCT_MODULE);
175}
176
177//Returns temp0 + correction for Lorentz angle calculation (s_defaultTemperature(-40) if there is no information)
178float SCT_DCSConditionsTool::sensorTemperature(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, ctx, h)) {
187 int bec{m_pHelper->barrel_ec(moduleId)};
188 if (bec==0) { // Barrel
189 return ( temperature + m_barrel_correction); //return the temp+correction
190 } else { // Endcaps
191 int modeta{m_pHelper->eta_module(moduleId)};
192 if (modeta==2) {
193 return (temperature + m_ecInner_correction); //return the temp+correction
194 } else {
195 return (temperature + m_ecOuter_correction); //return the temp+correction
196 }
197 }
198 }
199 return s_defaultTemperature; //didn't find the module, return s_defaultTemperature(-40).
200}
201
202//Does the same for hashIds
203float SCT_DCSConditionsTool::sensorTemperature(const IdentifierHash& hashId, const EventContext& ctx) const {
204 Identifier waferId{m_pHelper->wafer_id(hashId)};
205 Identifier moduleId{m_pHelper->module_id(waferId)};
206 return sensorTemperature(moduleId, ctx, InDetConditions::SCT_MODULE);
207}
208
210
212SCT_DCSConditionsTool::getCondDataState(const EventContext& ctx) const {
214 return condData.retrieve();
215}
216
218SCT_DCSConditionsTool::getCondDataHV(const EventContext& ctx) const {
220 return condData.retrieve();
221}
222
224SCT_DCSConditionsTool::getCondDataTemp0(const EventContext& ctx) const {
226 return condData.retrieve();
227}
#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.
constexpr 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)