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 
74  const EventContext& ctx = Gaudi::Hive::currentContext();
76  ATH_CHECK(eventInfo.isValid() ? StatusCode::SUCCESS : StatusCode::FAILURE);
77 
78  const xAOD::EventInfo *eventInfoLB = nullptr;
79  ATH_CHECK(evtStore()->retrieve(eventInfoLB, "EventInfo"));
80  int LB = eventInfoLB->lumiBlock();
81  int chkLB = m_lbCounter;
82  if (chkLB==0) { chkLB=-1; }
83 
84  bool isMC = false;
85  if (eventInfo->eventType(xAOD::EventInfo::IS_SIMULATION)) { isMC=true; }
86 
92 
93  int maxHash = m_pixelID->wafer_hash_max();
94  std::vector<float> biasVoltage;
95  std::vector<float> temperature;
96  std::vector<int> activeState;
97  std::vector<int> activeStatus;
98  std::vector<int> feMaskIndex;
99  std::vector<int> feMaskStatus;
100  bool storeLB = false;
101  if (!isMC) {
102  if (chkLB!=LB) {
103  storeLB = true;
104  m_lbCounter = LB;
105  }
106  }
107  else {
108  if (chkLB==-1) {
109  storeLB = true;
110  m_lbCounter = 1;
111  }
112  }
113 
114  if (storeLB) {
115  for (int ihash=0; ihash<maxHash; ihash++) {
116  biasVoltage.push_back(dcsHV->getBiasVoltage(ihash));
117  temperature.push_back(dcsTemp->getTemperature(ihash));
118  activeState.push_back(dcsState->getModuleStatus(ihash));
119  activeStatus.push_back(dcsStatus->getModuleStatus(ihash));
120 
121  int moduleStatus = deadMap->getModuleStatus(ihash);
122  int chipStatus = deadMap->getChipStatus(ihash);
123  if (moduleStatus || chipStatus) {
124  feMaskIndex.push_back(ihash);
125  if (moduleStatus) {
126  feMaskStatus.push_back(0);
127  }
128  else {
129  feMaskStatus.push_back(chipStatus);
130  }
131  }
132  }
133  }
134 
135  //====================================================================================
136  // This is an example how to read the Error informaiton.
137  //
138  // The Error word is defined in
139  // InDetConditions/PixelConditionsData/PixelConditionsData/PixelByteStreamErrors.h
140  //
141  // The IDCInDetBSErrContainer can be accessed through
142  // m_pixelCondSummaryTool->getBSErrorWord(i,ctx)
143  // where
144  // i= [ 0, 2047] : module error
145  // ( [0, 11] - DBMC, [12, 155] - ECC, [156, 435] - IBL,
146  // [436, 721] - B0, [722, 1215] - B1, [1216, 1891] - B2,
147  // [1892, 2035] - ECA, [2036, 2047] - DBMA )
148  //
149  // for PIXEL(FEI3):
150  // = [ 2048, 4095] : FE-0 error
151  // = [ 4096, 6143] : FE-1 error
152  // = [ 6144, 8191] : FE-2 error
153  // ... ... ...
154  // ... ... ...
155  // = [30720, 32767] : FE-14 error
156  // = [32768, 34815] : FE-15 error
157  //
158  // for IBL(FEI4):
159  // = [ 2048, 4095] : FE-0 error
160  // = [ 4096, 6143] : FE-1 error
161  // = [34816, 35375] : Error counter in bit#=0 from ServiceRecords (shift: modHash*nFE+iFE)
162  // = [35376, 35935] : Error counter in bit#=1 from ServiceRecords
163  // ... ... ...
164  // ... ... ...
165  // = [52176, 52735] : Error counter in bit#=31 from ServiceRecords
166  //
167  //====================================================================================
168  std::vector<uint64_t> bsErrIndex;
169  std::vector<uint64_t> bsErrWord;
170  if (!isMC) {
175  if (!idcErrCont.isValid()) {
176  ATH_MSG_FATAL("Faled to get BS error container" << m_idcErrContKey.key());
177  }
178  }
179 
180  if (maxHash==2048) { // only valid for RUN2/3
181  // First, access BS error for each FE chip
182  for (int ihash=0; ihash<maxHash; ihash++) {
183  for (int chFE=0; chFE<16; chFE++) {
184  int indexFE = (1+chFE)*maxHash+ihash; // (FE_channel+1)*2048 + moduleHash
186  ? InDet::getBSErrorWord(*pixel_active,*idcErrCont,ihash,indexFE,m_readoutTechnologyMask)
187  : m_pixelSummary->getBSErrorWord(ihash,indexFE,ctx));
189  InDet::getBSErrorWord(*pixel_active,*idcErrCont,ihash,indexFE,m_readoutTechnologyMask),
190  m_pixelSummary->getBSErrorWord(ihash,indexFE,ctx));
191 
192  if (word>0) {
193  bsErrIndex.push_back(indexFE);
194  bsErrWord.push_back(word);
195  }
196  }
197  }
198  // Next, access IBL service record
199  int indexOffset = 17*maxHash;
200  for (int ihash=156; ihash<436; ihash++) {
201  for (int chFE=0; chFE<2; chFE++) {
202  for (int serviceCode=0; serviceCode<32; serviceCode++) {
203  int indexSvcCounter = indexOffset+serviceCode*280*2+2*(ihash-156)+chFE;
205  ? InDet::getBSErrorWord(*pixel_active,*idcErrCont,ihash,indexSvcCounter,m_readoutTechnologyMask)
206  : m_pixelSummary->getBSErrorWord(ihash,indexSvcCounter,ctx));
208  InDet::getBSErrorWord(*pixel_active,*idcErrCont,ihash,indexSvcCounter,m_readoutTechnologyMask),
209  m_pixelSummary->getBSErrorWord(ihash,indexSvcCounter,ctx));
210 
211  if (word>0) {
212  bsErrIndex.push_back(indexSvcCounter);
213  bsErrWord.push_back(word);
214  }
215  }
216  }
217  }
218  }
219  }
220  std::vector<SG::WriteDecorHandle<xAOD::EventInfo,std::vector<float>>> decorModuleCondition(createDecorators<xAOD::EventInfo,std::vector<float>>(m_moduleConditionKeys,ctx));
221  assert(decorModuleCondition.size()==2);
222  decorModuleCondition[0](*eventInfo) = std::move(biasVoltage);
223  decorModuleCondition[1](*eventInfo) = std::move(temperature);
224 
225  std::vector<SG::WriteDecorHandle<xAOD::EventInfo,std::vector<int>>> decorModuleFEmask(createDecorators<xAOD::EventInfo,std::vector<int>>(m_moduleFEmaskKeys,ctx));
226  assert(decorModuleFEmask.size()==2);
227  decorModuleFEmask[0](*eventInfo) = std::move(feMaskIndex);
228  decorModuleFEmask[1](*eventInfo) = std::move(feMaskStatus);
229  decorModuleFEmask[2](*eventInfo) = std::move(activeState);
230  decorModuleFEmask[3](*eventInfo) = std::move(activeStatus);
231 
232  std::vector<SG::WriteDecorHandle<xAOD::EventInfo,std::vector<uint64_t>>> decorModuleBSErr(createDecorators<xAOD::EventInfo,std::vector<uint64_t>>(m_moduleBSErrKeys,ctx));
233  assert(decorModuleBSErr.size()==2);
234  decorModuleBSErr[0](*eventInfo) = std::move(bsErrIndex);
235  decorModuleBSErr[1](*eventInfo) = std::move(bsErrWord);
236 
237  return StatusCode::SUCCESS;
238  }
239 
240 }
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:44
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:833
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
DerivationFramework::EventInfoPixelModuleStatusMonitoring::addBranches
virtual StatusCode addBranches() const
Definition: EventInfoPixelModuleStatusMonitoring.cxx:70
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::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.