ATLAS Offline Software
Loading...
Searching...
No Matches
EventInfoPixelModuleStatusMonitoring.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
10
11namespace DerivationFramework {
12
14
15 if (m_prefix.empty()) {
16 ATH_MSG_WARNING("No decoration prefix name provided for the output of EventInfoPixelModuleStatusMonitoring!");
17 }
18
19 ATH_CHECK(m_eventInfoKey.initialize());
20 ATH_CHECK(detStore()->retrieve(m_pixelID,"PixelID"));
21
22 ATH_CHECK(m_readKeyTemp.initialize());
23 ATH_CHECK(m_readKeyHV.initialize());
24 ATH_CHECK(m_condDCSStateKey.initialize());
25 ATH_CHECK(m_condDCSStatusKey.initialize());
26 ATH_CHECK(m_condDeadMapKey.initialize());
27 ATH_CHECK(m_pixelSummary.retrieve());
28
33
34
35 {
36 std::vector<std::string> moduleConditionList;
37 moduleConditionList.emplace_back("PixelBiasVoltagePerLB");
38 moduleConditionList.emplace_back("PixelTemperaturePerLB");
39 createDecoratorKeys(*this,m_eventInfoKey,m_prefix.value(),moduleConditionList,m_moduleConditionKeys);
40 }
41
42 {
43 std::vector<std::string> moduleFEmaskList;
44 moduleFEmaskList.emplace_back("PixelFEmaskIndex");
45 moduleFEmaskList.emplace_back("PixelFEmaskPerLB");
46 moduleFEmaskList.emplace_back("PixelDCSStatePerLB");
47 moduleFEmaskList.emplace_back("PixelDCSStatusPerLB");
48 createDecoratorKeys(*this,m_eventInfoKey,m_prefix.value(),moduleFEmaskList,m_moduleFEmaskKeys);
49 }
50
51 {
52 std::vector<std::string> moduleBSErrList;
53 moduleBSErrList.emplace_back("PixelBSErrIndex");
54 moduleBSErrList.emplace_back("PixelBSErrWord");
55 createDecoratorKeys(*this,m_eventInfoKey,m_prefix.value(),moduleBSErrList,m_moduleBSErrKeys);
56 }
57
58 return StatusCode::SUCCESS;
59 }
60
61
62 StatusCode EventInfoPixelModuleStatusMonitoring::addBranches(const EventContext& ctx) const {
63
64 ATH_MSG_DEBUG("Adding Pixel module status in EventInfo");
65
67 ATH_CHECK(eventInfo.isValid() ? StatusCode::SUCCESS : StatusCode::FAILURE);
68
69 const xAOD::EventInfo *eventInfoLB = nullptr;
70 ATH_CHECK(evtStore()->retrieve(eventInfoLB, "EventInfo"));
71 int LB = eventInfoLB->lumiBlock();
72 int chkLB = m_lbCounter;
73 if (chkLB==0) { chkLB=-1; }
74
75 bool isMC = false;
76 if (eventInfo->eventType(xAOD::EventInfo::IS_SIMULATION)) { isMC=true; }
77
83
84 int maxHash = m_pixelID->wafer_hash_max();
85 std::vector<float> biasVoltage;
86 std::vector<float> temperature;
87 std::vector<int> activeState;
88 std::vector<int> activeStatus;
89 std::vector<int> feMaskIndex;
90 std::vector<int> feMaskStatus;
91 bool storeLB = false;
92 if (!isMC) {
93 if (chkLB!=LB) {
94 storeLB = true;
95 m_lbCounter = LB;
96 }
97 }
98 else {
99 if (chkLB==-1) {
100 storeLB = true;
101 m_lbCounter = 1;
102 }
103 }
104
105 if (storeLB) {
106 for (int ihash=0; ihash<maxHash; ihash++) {
107 biasVoltage.push_back(dcsHV->getBiasVoltage(ihash));
108 temperature.push_back(dcsTemp->getTemperature(ihash));
109 activeState.push_back(dcsState->getModuleStatus(ihash));
110 activeStatus.push_back(dcsStatus->getModuleStatus(ihash));
111
112 int moduleStatus = deadMap->getModuleStatus(ihash);
113 int chipStatus = deadMap->getChipStatus(ihash);
114 if (moduleStatus || chipStatus) {
115 feMaskIndex.push_back(ihash);
116 if (moduleStatus) {
117 feMaskStatus.push_back(0);
118 }
119 else {
120 feMaskStatus.push_back(chipStatus);
121 }
122 }
123 }
124 }
125
126 //====================================================================================
127 // This is an example how to read the Error informaiton.
128 //
129 // The Error word is defined in
130 // InDetConditions/PixelConditionsData/PixelConditionsData/PixelByteStreamErrors.h
131 //
132 // The IDCInDetBSErrContainer can be accessed through
133 // m_pixelCondSummaryTool->getBSErrorWord(i,ctx)
134 // where
135 // i= [ 0, 2047] : module error
136 // ( [0, 11] - DBMC, [12, 155] - ECC, [156, 435] - IBL,
137 // [436, 721] - B0, [722, 1215] - B1, [1216, 1891] - B2,
138 // [1892, 2035] - ECA, [2036, 2047] - DBMA )
139 //
140 // for PIXEL(FEI3):
141 // = [ 2048, 4095] : FE-0 error
142 // = [ 4096, 6143] : FE-1 error
143 // = [ 6144, 8191] : FE-2 error
144 // ... ... ...
145 // ... ... ...
146 // = [30720, 32767] : FE-14 error
147 // = [32768, 34815] : FE-15 error
148 //
149 // for IBL(FEI4):
150 // = [ 2048, 4095] : FE-0 error
151 // = [ 4096, 6143] : FE-1 error
152 // = [34816, 35375] : Error counter in bit#=0 from ServiceRecords (shift: modHash*nFE+iFE)
153 // = [35376, 35935] : Error counter in bit#=1 from ServiceRecords
154 // ... ... ...
155 // ... ... ...
156 // = [52176, 52735] : Error counter in bit#=31 from ServiceRecords
157 //
158 //====================================================================================
159 std::vector<uint64_t> bsErrIndex;
160 std::vector<uint64_t> bsErrWord;
161 if (!isMC) {
166 if (!idcErrCont.isValid()) {
167 ATH_MSG_FATAL("Faled to get BS error container" << m_idcErrContKey.key());
168 }
169 }
170
171 if (maxHash==2048) { // only valid for RUN2/3
172 // First, access BS error for each FE chip
173 for (int ihash=0; ihash<maxHash; ihash++) {
174 for (int chFE=0; chFE<16; chFE++) {
175 int indexFE = (1+chFE)*maxHash+ihash; // (FE_channel+1)*2048 + moduleHash
176 uint64_t word = (!m_pixelDetElStatusActiveOnly.empty() && m_readoutTechnologyMask
177 ? InDet::getBSErrorWord(*pixel_active,*idcErrCont,ihash,indexFE,m_readoutTechnologyMask)
178 : m_pixelSummary->getBSErrorWord(ihash,indexFE,ctx));
180 InDet::getBSErrorWord(*pixel_active,*idcErrCont,ihash,indexFE,m_readoutTechnologyMask),
181 m_pixelSummary->getBSErrorWord(ihash,indexFE,ctx));
182
183 if (word>0) {
184 bsErrIndex.push_back(indexFE);
185 bsErrWord.push_back(word);
186 }
187 }
188 }
189 // Next, access IBL service record
190 int indexOffset = 17*maxHash;
191 for (int ihash=156; ihash<436; ihash++) {
192 for (int chFE=0; chFE<2; chFE++) {
193 for (int serviceCode=0; serviceCode<32; serviceCode++) {
194 int indexSvcCounter = indexOffset+serviceCode*280*2+2*(ihash-156)+chFE;
195 uint64_t word = (!m_pixelDetElStatusActiveOnly.empty() && m_readoutTechnologyMask
196 ? InDet::getBSErrorWord(*pixel_active,*idcErrCont,ihash,indexSvcCounter,m_readoutTechnologyMask)
197 : m_pixelSummary->getBSErrorWord(ihash,indexSvcCounter,ctx));
199 InDet::getBSErrorWord(*pixel_active,*idcErrCont,ihash,indexSvcCounter,m_readoutTechnologyMask),
200 m_pixelSummary->getBSErrorWord(ihash,indexSvcCounter,ctx));
201
202 if (word>0) {
203 bsErrIndex.push_back(indexSvcCounter);
204 bsErrWord.push_back(word);
205 }
206 }
207 }
208 }
209 }
210 }
211 std::vector<SG::WriteDecorHandle<xAOD::EventInfo,std::vector<float>>> decorModuleCondition(createDecorators<xAOD::EventInfo,std::vector<float>>(m_moduleConditionKeys,ctx));
212 assert(decorModuleCondition.size()==2);
213 decorModuleCondition[0](*eventInfo) = std::move(biasVoltage);
214 decorModuleCondition[1](*eventInfo) = std::move(temperature);
215
216 std::vector<SG::WriteDecorHandle<xAOD::EventInfo,std::vector<int>>> decorModuleFEmask(createDecorators<xAOD::EventInfo,std::vector<int>>(m_moduleFEmaskKeys,ctx));
217 assert(decorModuleFEmask.size()==2);
218 decorModuleFEmask[0](*eventInfo) = std::move(feMaskIndex);
219 decorModuleFEmask[1](*eventInfo) = std::move(feMaskStatus);
220 decorModuleFEmask[2](*eventInfo) = std::move(activeState);
221 decorModuleFEmask[3](*eventInfo) = std::move(activeStatus);
222
223 std::vector<SG::WriteDecorHandle<xAOD::EventInfo,std::vector<uint64_t>>> decorModuleBSErr(createDecorators<xAOD::EventInfo,std::vector<uint64_t>>(m_moduleBSErrKeys,ctx));
224 assert(decorModuleBSErr.size()==2);
225 decorModuleBSErr[0](*eventInfo) = std::move(bsErrIndex);
226 decorModuleBSErr[1](*eventInfo) = std::move(bsErrWord);
227
228 return StatusCode::SUCCESS;
229 }
230
231}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_FATAL(x)
#define ATH_MSG_WARNING(x)
#define ATH_MSG_DEBUG(x)
#define VALIDATE_STATUS_ARRAY(use_info, info_val, summary_val)
SG::ReadHandle< InDet::SiDetectorElementStatus > getPixelDetElStatus(const SG::ReadHandleKey< InDet::SiDetectorElementStatus > &key, const EventContext &ctx) const
std::vector< SG::WriteDecorHandleKey< xAOD::EventInfo > > m_moduleBSErrKeys
std::vector< SG::WriteDecorHandleKey< xAOD::EventInfo > > m_moduleFEmaskKeys
virtual StatusCode addBranches(const EventContext &ctx) const override final
SG::ReadHandleKey< InDet::SiDetectorElementStatus > m_pixelDetElStatusActiveOnly
std::vector< SG::WriteDecorHandleKey< xAOD::EventInfo > > m_moduleConditionKeys
virtual bool isValid() override final
Can the handle be successfully dereferenced?
uint32_t lumiBlock() const
The current event's luminosity block number.
@ IS_SIMULATION
true: simulation, false: data
THE reconstruction tool.
std::vector< SG::WriteDecorHandle< T_Cont, T > > createDecorators(const std::vector< SG::WriteDecorHandleKey< T_Cont > > &keys, const EventContext &ctx)
void createDecoratorKeys(T_Parent &parent, const SG::ReadHandleKey< T_Cont > &container_key, const std::string &prefix, const std::vector< std::string > &decor_names, std::vector< SG::WriteDecorHandleKey< T_Cont > > &decor_out)
unsigned int getBSErrorWord(const InDet::SiDetectorElementStatus &elementStatus, const IDCInDetBSErrContainer &bsErrorContainer, const IdentifierHash &moduleIdHash, unsigned int index, unsigned int readOutTechnologyMask=(Pixel::makeReadoutTechnologyBit(InDetDD::PixelReadoutTechnology::FEI4)|(Pixel::makeReadoutTechnologyBit(InDetDD::PixelReadoutTechnology::FEI3))))
Retrieve the bytestream error word for the given module if the readout technology of the module is co...
unsigned int makeReadoutTechnologyBit(InDetDD::PixelReadoutTechnology technology, unsigned int bit_val=1)
Create a word with a bit representing the given readout technology to the given value.
EventInfo_v1 EventInfo
Definition of the latest event info version.