ATLAS Offline Software
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 
11 namespace DerivationFramework {
12 
13  EventInfoPixelModuleStatusMonitoring::EventInfoPixelModuleStatusMonitoring(const std::string& type, const std::string& name, const IInterface* parent):
14  base_class(type,name,parent),
15  m_pixelID(nullptr) {
16  }
17 
19 
20  if (m_prefix.empty()) {
21  ATH_MSG_WARNING("No decoration prefix name provided for the output of EventInfoPixelModuleStatusMonitoring!");
22  }
23 
25  ATH_CHECK(detStore()->retrieve(m_pixelID,"PixelID"));
26 
32  ATH_CHECK(m_pixelSummary.retrieve());
33 
38 
39 
40  {
41  std::vector<std::string> moduleConditionList;
42  moduleConditionList.emplace_back("PixelBiasVoltagePerLB");
43  moduleConditionList.emplace_back("PixelTemperaturePerLB");
44  createDecoratorKeys(*this,m_eventInfoKey,m_prefix.value(),moduleConditionList,m_moduleConditionKeys);
45  }
46 
47  {
48  std::vector<std::string> moduleFEmaskList;
49  moduleFEmaskList.emplace_back("PixelFEmaskIndex");
50  moduleFEmaskList.emplace_back("PixelFEmaskPerLB");
51  moduleFEmaskList.emplace_back("PixelDCSStatePerLB");
52  moduleFEmaskList.emplace_back("PixelDCSStatusPerLB");
53  createDecoratorKeys(*this,m_eventInfoKey,m_prefix.value(),moduleFEmaskList,m_moduleFEmaskKeys);
54  }
55 
56  {
57  std::vector<std::string> moduleBSErrList;
58  moduleBSErrList.emplace_back("PixelBSErrIndex");
59  moduleBSErrList.emplace_back("PixelBSErrWord");
60  createDecoratorKeys(*this,m_eventInfoKey,m_prefix.value(),moduleBSErrList,m_moduleBSErrKeys);
61  }
62 
63  return StatusCode::SUCCESS;
64  }
65 
67  return StatusCode::SUCCESS;
68  }
69 
71 
72  ATH_MSG_DEBUG("Adding Pixel module status in EventInfo");
73 
75  ATH_CHECK(eventInfo.isValid() ? StatusCode::SUCCESS : StatusCode::FAILURE);
76 
77  const xAOD::EventInfo *eventInfoLB = nullptr;
78  ATH_CHECK(evtStore()->retrieve(eventInfoLB, "EventInfo"));
79  int LB = eventInfoLB->lumiBlock();
80  int chkLB = m_lbCounter;
81  if (chkLB==0) { chkLB=-1; }
82 
83  bool isMC = false;
84  if (eventInfo->eventType(xAOD::EventInfo::IS_SIMULATION)) { isMC=true; }
85 
91 
92  int maxHash = m_pixelID->wafer_hash_max();
93  std::vector<float> biasVoltage;
94  std::vector<float> temperature;
95  std::vector<int> activeState;
96  std::vector<int> activeStatus;
97  std::vector<int> feMaskIndex;
98  std::vector<int> feMaskStatus;
99  bool storeLB = false;
100  if (!isMC) {
101  if (chkLB!=LB) {
102  storeLB = true;
103  m_lbCounter = LB;
104  }
105  }
106  else {
107  if (chkLB==-1) {
108  storeLB = true;
109  m_lbCounter = 1;
110  }
111  }
112 
113  if (storeLB) {
114  for (int ihash=0; ihash<maxHash; ihash++) {
115  biasVoltage.push_back(dcsHV->getBiasVoltage(ihash));
116  temperature.push_back(dcsTemp->getTemperature(ihash));
117  activeState.push_back(dcsState->getModuleStatus(ihash));
118  activeStatus.push_back(dcsStatus->getModuleStatus(ihash));
119 
120  int moduleStatus = deadMap->getModuleStatus(ihash);
121  int chipStatus = deadMap->getChipStatus(ihash);
122  if (moduleStatus || chipStatus) {
123  feMaskIndex.push_back(ihash);
124  if (moduleStatus) {
125  feMaskStatus.push_back(0);
126  }
127  else {
128  feMaskStatus.push_back(chipStatus);
129  }
130  }
131  }
132  }
133 
134  //====================================================================================
135  // This is an example how to read the Error informaiton.
136  //
137  // The Error word is defined in
138  // InDetConditions/PixelConditionsData/PixelConditionsData/PixelByteStreamErrors.h
139  //
140  // The IDCInDetBSErrContainer can be accessed through
141  // m_pixelCondSummaryTool->getBSErrorWord(i,ctx)
142  // where
143  // i= [ 0, 2047] : module error
144  // ( [0, 11] - DBMC, [12, 155] - ECC, [156, 435] - IBL,
145  // [436, 721] - B0, [722, 1215] - B1, [1216, 1891] - B2,
146  // [1892, 2035] - ECA, [2036, 2047] - DBMA )
147  //
148  // for PIXEL(FEI3):
149  // = [ 2048, 4095] : FE-0 error
150  // = [ 4096, 6143] : FE-1 error
151  // = [ 6144, 8191] : FE-2 error
152  // ... ... ...
153  // ... ... ...
154  // = [30720, 32767] : FE-14 error
155  // = [32768, 34815] : FE-15 error
156  //
157  // for IBL(FEI4):
158  // = [ 2048, 4095] : FE-0 error
159  // = [ 4096, 6143] : FE-1 error
160  // = [34816, 35375] : Error counter in bit#=0 from ServiceRecords (shift: modHash*nFE+iFE)
161  // = [35376, 35935] : Error counter in bit#=1 from ServiceRecords
162  // ... ... ...
163  // ... ... ...
164  // = [52176, 52735] : Error counter in bit#=31 from ServiceRecords
165  //
166  //====================================================================================
167  std::vector<uint64_t> bsErrIndex;
168  std::vector<uint64_t> bsErrWord;
169  if (!isMC) {
174  if (!idcErrCont.isValid()) {
175  ATH_MSG_FATAL("Faled to get BS error container" << m_idcErrContKey.key());
176  }
177  }
178 
179  if (maxHash==2048) { // only valid for RUN2/3
180  // First, access BS error for each FE chip
181  for (int ihash=0; ihash<maxHash; ihash++) {
182  for (int chFE=0; chFE<16; chFE++) {
183  int indexFE = (1+chFE)*maxHash+ihash; // (FE_channel+1)*2048 + moduleHash
185  ? InDet::getBSErrorWord(*pixel_active,*idcErrCont,ihash,indexFE,m_readoutTechnologyMask)
186  : m_pixelSummary->getBSErrorWord(ihash,indexFE,ctx));
188  InDet::getBSErrorWord(*pixel_active,*idcErrCont,ihash,indexFE,m_readoutTechnologyMask),
189  m_pixelSummary->getBSErrorWord(ihash,indexFE,ctx));
190 
191  if (word>0) {
192  bsErrIndex.push_back(indexFE);
193  bsErrWord.push_back(word);
194  }
195  }
196  }
197  // Next, access IBL service record
198  int indexOffset = 17*maxHash;
199  for (int ihash=156; ihash<436; ihash++) {
200  for (int chFE=0; chFE<2; chFE++) {
201  for (int serviceCode=0; serviceCode<32; serviceCode++) {
202  int indexSvcCounter = indexOffset+serviceCode*280*2+2*(ihash-156)+chFE;
204  ? InDet::getBSErrorWord(*pixel_active,*idcErrCont,ihash,indexSvcCounter,m_readoutTechnologyMask)
205  : m_pixelSummary->getBSErrorWord(ihash,indexSvcCounter,ctx));
207  InDet::getBSErrorWord(*pixel_active,*idcErrCont,ihash,indexSvcCounter,m_readoutTechnologyMask),
208  m_pixelSummary->getBSErrorWord(ihash,indexSvcCounter,ctx));
209 
210  if (word>0) {
211  bsErrIndex.push_back(indexSvcCounter);
212  bsErrWord.push_back(word);
213  }
214  }
215  }
216  }
217  }
218  }
219  std::vector<SG::WriteDecorHandle<xAOD::EventInfo,std::vector<float>>> decorModuleCondition(createDecorators<xAOD::EventInfo,std::vector<float>>(m_moduleConditionKeys,ctx));
220  assert(decorModuleCondition.size()==2);
221  decorModuleCondition[0](*eventInfo) = std::move(biasVoltage);
222  decorModuleCondition[1](*eventInfo) = std::move(temperature);
223 
224  std::vector<SG::WriteDecorHandle<xAOD::EventInfo,std::vector<int>>> decorModuleFEmask(createDecorators<xAOD::EventInfo,std::vector<int>>(m_moduleFEmaskKeys,ctx));
225  assert(decorModuleFEmask.size()==2);
226  decorModuleFEmask[0](*eventInfo) = std::move(feMaskIndex);
227  decorModuleFEmask[1](*eventInfo) = std::move(feMaskStatus);
228  decorModuleFEmask[2](*eventInfo) = std::move(activeState);
229  decorModuleFEmask[3](*eventInfo) = std::move(activeStatus);
230 
231  std::vector<SG::WriteDecorHandle<xAOD::EventInfo,std::vector<uint64_t>>> decorModuleBSErr(createDecorators<xAOD::EventInfo,std::vector<uint64_t>>(m_moduleBSErrKeys,ctx));
232  assert(decorModuleBSErr.size()==2);
233  decorModuleBSErr[0](*eventInfo) = std::move(bsErrIndex);
234  decorModuleBSErr[1](*eventInfo) = std::move(bsErrWord);
235 
236  return StatusCode::SUCCESS;
237  }
238 
239 }
DecoratorUtils.h
python.PyKernel.retrieve
def retrieve(aClass, aKey=None)
Definition: PyKernel.py:110
DerivationFramework::EventInfoPixelModuleStatusMonitoring::m_pixelSummary
ToolHandle< IInDetConditionsTool > m_pixelSummary
Definition: EventInfoPixelModuleStatusMonitoring.h:70
DerivationFramework::EventInfoPixelModuleStatusMonitoring::m_condDCSStateKey
SG::ReadCondHandleKey< PixelDCSStateData > m_condDCSStateKey
Definition: EventInfoPixelModuleStatusMonitoring.h:61
DerivationFramework::EventInfoPixelModuleStatusMonitoring::m_useByteStreamFEI4
Gaudi::Property< bool > m_useByteStreamFEI4
Definition: EventInfoPixelModuleStatusMonitoring.h:76
ATH_MSG_FATAL
#define ATH_MSG_FATAL(x)
Definition: AthMsgStreamMacros.h:34
DerivationFramework::createDecoratorKeys
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)
Definition: DecoratorUtils.h:20
SG::ReadCondHandle
Definition: ReadCondHandle.h:40
AthMsgStreamMacros.h
DerivationFramework::EventInfoPixelModuleStatusMonitoring::m_pixelDetElStatusActiveOnly
SG::ReadHandleKey< InDet::SiDetectorElementStatus > m_pixelDetElStatusActiveOnly
Definition: EventInfoPixelModuleStatusMonitoring.h:93
DerivationFramework::EventInfoPixelModuleStatusMonitoring::m_condDCSStatusKey
SG::ReadCondHandleKey< PixelDCSStatusData > m_condDCSStatusKey
Definition: EventInfoPixelModuleStatusMonitoring.h:64
SG::ReadHandle
Definition: StoreGate/StoreGate/ReadHandle.h:67
DerivationFramework::EventInfoPixelModuleStatusMonitoring::m_pixelID
const PixelID * m_pixelID
Definition: EventInfoPixelModuleStatusMonitoring.h:82
Pixel::makeReadoutTechnologyBit
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.
Definition: PixelFEUtils.h:60
InDetDD::PixelReadoutTechnology::FEI3
@ FEI3
EventInfoPixelModuleStatusMonitoring.h
DerivationFramework::EventInfoPixelModuleStatusMonitoring::m_useByteStreamFEI3
Gaudi::Property< bool > m_useByteStreamFEI3
Definition: EventInfoPixelModuleStatusMonitoring.h:78
DerivationFramework::EventInfoPixelModuleStatusMonitoring::EventInfoPixelModuleStatusMonitoring
EventInfoPixelModuleStatusMonitoring(const std::string &type, const std::string &name, const IInterface *parent)
Definition: EventInfoPixelModuleStatusMonitoring.cxx:13
DerivationFramework::EventInfoPixelModuleStatusMonitoring::initialize
StatusCode initialize()
Definition: EventInfoPixelModuleStatusMonitoring.cxx:18
SG::VarHandleKey::key
const std::string & key() const
Return the StoreGate ID for the referenced object.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleKey.cxx:141
SG::VarHandleKey::empty
bool empty() const
Test if the key is blank.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleKey.cxx:150
xAOD::EventInfo_v1::IS_SIMULATION
@ IS_SIMULATION
true: simulation, false: data
Definition: EventInfo_v1.h:151
DerivationFramework::EventInfoPixelModuleStatusMonitoring::getPixelDetElStatus
SG::ReadHandle< InDet::SiDetectorElementStatus > getPixelDetElStatus(const SG::ReadHandleKey< InDet::SiDetectorElementStatus > &key, const EventContext &ctx) const
Definition: EventInfoPixelModuleStatusMonitoring.h:95
DerivationFramework::EventInfoPixelModuleStatusMonitoring::m_condDeadMapKey
SG::ReadCondHandleKey< PixelDeadMapCondData > m_condDeadMapKey
Definition: EventInfoPixelModuleStatusMonitoring.h:67
InDet::getBSErrorWord
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...
Definition: PixelBSUtils.h:16
python.CaloAddPedShiftConfig.type
type
Definition: CaloAddPedShiftConfig.py:42
DerivationFramework::EventInfoPixelModuleStatusMonitoring::m_moduleConditionKeys
std::vector< SG::WriteDecorHandleKey< xAOD::EventInfo > > m_moduleConditionKeys
Definition: EventInfoPixelModuleStatusMonitoring.h:86
InDetDD::PixelReadoutTechnology::RD53
@ RD53
DerivationFramework::EventInfoPixelModuleStatusMonitoring::finalize
StatusCode finalize()
Definition: EventInfoPixelModuleStatusMonitoring.cxx:66
DerivationFramework::EventInfoPixelModuleStatusMonitoring::m_moduleBSErrKeys
std::vector< SG::WriteDecorHandleKey< xAOD::EventInfo > > m_moduleBSErrKeys
Definition: EventInfoPixelModuleStatusMonitoring.h:88
VALIDATE_STATUS_ARRAY
#define VALIDATE_STATUS_ARRAY(use_info, info_val, summary_val)
Definition: SiDetectorElementStatus.h:51
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
DerivationFramework::EventInfoPixelModuleStatusMonitoring::m_prefix
Gaudi::Property< std::string > m_prefix
Definition: EventInfoPixelModuleStatusMonitoring.h:49
test_pyathena.parent
parent
Definition: test_pyathena.py:15
xAOD::uint64_t
uint64_t
Definition: EventInfo_v1.cxx:123
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
PixelDeadMapCondData::getChipStatus
int getChipStatus(const int chanNum) const
Definition: PixelDeadMapCondData.cxx:31
DerivationFramework
THE reconstruction tool.
Definition: ParticleSortingAlg.h:24
SG::VarHandleKey::initialize
StatusCode initialize(bool used=true)
If this object is used as a property, then this should be called during the initialize phase.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleKey.cxx:103
xAOD::EventInfo_v1::lumiBlock
uint32_t lumiBlock() const
The current event's luminosity block number.
SG::ReadHandle::isValid
virtual bool isValid() override final
Can the handle be successfully dereferenced?
PixelID::wafer_hash_max
size_type wafer_hash_max() const
Definition: PixelID.cxx:837
python.PyKernel.detStore
detStore
Definition: PyKernel.py:41
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:240
PixelDCSStateData::getModuleStatus
int getModuleStatus(const int chanNum) const
Definition: PixelDCSStateData.cxx:11
SG::CondHandleKey::initialize
StatusCode initialize(bool used=true)
InDetDD::PixelReadoutTechnology::FEI4
@ FEI4
DerivationFramework::EventInfoPixelModuleStatusMonitoring::m_readoutTechnologyMask
unsigned int m_readoutTechnologyMask
Definition: EventInfoPixelModuleStatusMonitoring.h:84
PixelDCSTempData::getTemperature
float getTemperature(int chanNum) const
Definition: PixelDCSTempData.h:22
DerivationFramework::EventInfoPixelModuleStatusMonitoring::m_moduleFEmaskKeys
std::vector< SG::WriteDecorHandleKey< xAOD::EventInfo > > m_moduleFEmaskKeys
Definition: EventInfoPixelModuleStatusMonitoring.h:87
EventInfo.h
xAOD::EventInfo_v1
Class describing the basic event information.
Definition: EventInfo_v1.h:43
DerivationFramework::EventInfoPixelModuleStatusMonitoring::m_lbCounter
std::atomic_uint m_lbCounter
Definition: EventInfoPixelModuleStatusMonitoring.h:83
PixelDCSStatusData::getModuleStatus
int getModuleStatus(const int chanNum) const
Definition: PixelDCSStatusData.cxx:11
DerivationFramework::EventInfoPixelModuleStatusMonitoring::m_useByteStreamRD53
Gaudi::Property< bool > m_useByteStreamRD53
Definition: EventInfoPixelModuleStatusMonitoring.h:80
DerivationFramework::EventInfoPixelModuleStatusMonitoring::m_readKeyHV
SG::ReadCondHandleKey< PixelDCSHVData > m_readKeyHV
Definition: EventInfoPixelModuleStatusMonitoring.h:58
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
PixelDCSHVData::getBiasVoltage
float getBiasVoltage(const int chanNum) const
Definition: PixelDCSHVData.h:26
DerivationFramework::createDecorators
std::vector< SG::WriteDecorHandle< T_Cont, T > > createDecorators(const std::vector< SG::WriteDecorHandleKey< T_Cont > > &keys, const EventContext &ctx)
Definition: DecoratorUtils.h:51
DerivationFramework::EventInfoPixelModuleStatusMonitoring::m_eventInfoKey
SG::ReadHandleKey< xAOD::EventInfo > m_eventInfoKey
Definition: EventInfoPixelModuleStatusMonitoring.h:52
PixelDeadMapCondData::getModuleStatus
int getModuleStatus(const int chanNum) const
Definition: PixelDeadMapCondData.cxx:20
EventInfoRead.isMC
isMC
Definition: EventInfoRead.py:11
DerivationFramework::EventInfoPixelModuleStatusMonitoring::m_readKeyTemp
SG::ReadCondHandleKey< PixelDCSTempData > m_readKeyTemp
Definition: EventInfoPixelModuleStatusMonitoring.h:55
DerivationFramework::EventInfoPixelModuleStatusMonitoring::addBranches
virtual StatusCode addBranches(const EventContext &ctx) const
Definition: EventInfoPixelModuleStatusMonitoring.cxx:70
DerivationFramework::EventInfoPixelModuleStatusMonitoring::m_idcErrContKey
SG::ReadHandleKey< IDCInDetBSErrContainer > m_idcErrContKey
Definition: EventInfoPixelModuleStatusMonitoring.h:73
xAOD::EventInfo_v1::eventType
bool eventType(EventType type) const
Check for one particular bitmask value.