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):
15  m_pixelID(nullptr) {
16  declareInterface<DerivationFramework::IAugmentationTool>(this);
17  }
18 
20 
21  if (m_prefix.empty()) {
22  ATH_MSG_WARNING("No decoration prefix name provided for the output of EventInfoPixelModuleStatusMonitoring!");
23  }
24 
26  ATH_CHECK(detStore()->retrieve(m_pixelID,"PixelID"));
27 
33  ATH_CHECK(m_pixelSummary.retrieve());
34 
39 
40 
41  {
42  std::vector<std::string> moduleConditionList;
43  moduleConditionList.emplace_back("PixelBiasVoltagePerLB");
44  moduleConditionList.emplace_back("PixelTemperaturePerLB");
45  createDecoratorKeys(*this,m_eventInfoKey,m_prefix.value(),moduleConditionList,m_moduleConditionKeys);
46  }
47 
48  {
49  std::vector<std::string> moduleFEmaskList;
50  moduleFEmaskList.emplace_back("PixelFEmaskIndex");
51  moduleFEmaskList.emplace_back("PixelFEmaskPerLB");
52  moduleFEmaskList.emplace_back("PixelDCSStatePerLB");
53  moduleFEmaskList.emplace_back("PixelDCSStatusPerLB");
54  createDecoratorKeys(*this,m_eventInfoKey,m_prefix.value(),moduleFEmaskList,m_moduleFEmaskKeys);
55  }
56 
57  {
58  std::vector<std::string> moduleBSErrList;
59  moduleBSErrList.emplace_back("PixelBSErrIndex");
60  moduleBSErrList.emplace_back("PixelBSErrWord");
61  createDecoratorKeys(*this,m_eventInfoKey,m_prefix.value(),moduleBSErrList,m_moduleBSErrKeys);
62  }
63 
64  return StatusCode::SUCCESS;
65  }
66 
68  return StatusCode::SUCCESS;
69  }
70 
72 
73  ATH_MSG_DEBUG("Adding Pixel module status in EventInfo");
74 
75  const EventContext& ctx = Gaudi::Hive::currentContext();
77  ATH_CHECK(eventInfo.isValid() ? StatusCode::SUCCESS : StatusCode::FAILURE);
78 
79  const xAOD::EventInfo *eventInfoLB = nullptr;
80  ATH_CHECK(evtStore()->retrieve(eventInfoLB, "EventInfo"));
81  int LB = eventInfoLB->lumiBlock();
82  int chkLB = m_lbCounter;
83  if (chkLB==0) { chkLB=-1; }
84 
85  bool isMC = false;
86  if (eventInfo->eventType(xAOD::EventInfo::IS_SIMULATION)) { isMC=true; }
87 
93 
94  int maxHash = m_pixelID->wafer_hash_max();
95  std::vector<float> biasVoltage;
96  std::vector<float> temperature;
97  std::vector<int> activeState;
98  std::vector<int> activeStatus;
99  std::vector<int> feMaskIndex;
100  std::vector<int> feMaskStatus;
101  bool storeLB = false;
102  if (!isMC) {
103  if (chkLB!=LB) {
104  storeLB = true;
105  m_lbCounter = LB;
106  }
107  }
108  else {
109  if (chkLB==-1) {
110  storeLB = true;
111  m_lbCounter = 1;
112  }
113  }
114 
115  if (storeLB) {
116  for (int ihash=0; ihash<maxHash; ihash++) {
117  biasVoltage.push_back(dcsHV->getBiasVoltage(ihash));
118  temperature.push_back(dcsTemp->getTemperature(ihash));
119  activeState.push_back(dcsState->getModuleStatus(ihash));
120  activeStatus.push_back(dcsStatus->getModuleStatus(ihash));
121 
122  int moduleStatus = deadMap->getModuleStatus(ihash);
123  int chipStatus = deadMap->getChipStatus(ihash);
124  if (moduleStatus || chipStatus) {
125  feMaskIndex.push_back(ihash);
126  if (moduleStatus) {
127  feMaskStatus.push_back(0);
128  }
129  else {
130  feMaskStatus.push_back(chipStatus);
131  }
132  }
133  }
134  }
135 
136  //====================================================================================
137  // This is an example how to read the Error informaiton.
138  //
139  // The Error word is defined in
140  // InDetConditions/PixelConditionsData/PixelConditionsData/PixelByteStreamErrors.h
141  //
142  // The IDCInDetBSErrContainer can be accessed through
143  // m_pixelCondSummaryTool->getBSErrorWord(i,ctx)
144  // where
145  // i= [ 0, 2047] : module error
146  // ( [0, 11] - DBMC, [12, 155] - ECC, [156, 435] - IBL,
147  // [436, 721] - B0, [722, 1215] - B1, [1216, 1891] - B2,
148  // [1892, 2035] - ECA, [2036, 2047] - DBMA )
149  //
150  // for PIXEL(FEI3):
151  // = [ 2048, 4095] : FE-0 error
152  // = [ 4096, 6143] : FE-1 error
153  // = [ 6144, 8191] : FE-2 error
154  // ... ... ...
155  // ... ... ...
156  // = [30720, 32767] : FE-14 error
157  // = [32768, 34815] : FE-15 error
158  //
159  // for IBL(FEI4):
160  // = [ 2048, 4095] : FE-0 error
161  // = [ 4096, 6143] : FE-1 error
162  // = [34816, 35375] : Error counter in bit#=0 from ServiceRecords (shift: modHash*nFE+iFE)
163  // = [35376, 35935] : Error counter in bit#=1 from ServiceRecords
164  // ... ... ...
165  // ... ... ...
166  // = [52176, 52735] : Error counter in bit#=31 from ServiceRecords
167  //
168  //====================================================================================
169  std::vector<uint64_t> bsErrIndex;
170  std::vector<uint64_t> bsErrWord;
171  if (!isMC) {
176  if (!idcErrCont.isValid()) {
177  ATH_MSG_FATAL("Faled to get BS error container" << m_idcErrContKey.key());
178  }
179  }
180 
181  if (maxHash==2048) { // only valid for RUN2/3
182  // First, access BS error for each FE chip
183  for (int ihash=0; ihash<maxHash; ihash++) {
184  for (int chFE=0; chFE<16; chFE++) {
185  int indexFE = (1+chFE)*maxHash+ihash; // (FE_channel+1)*2048 + moduleHash
187  ? InDet::getBSErrorWord(*pixel_active,*idcErrCont,ihash,indexFE,m_readoutTechnologyMask)
188  : m_pixelSummary->getBSErrorWord(ihash,indexFE,ctx));
190  InDet::getBSErrorWord(*pixel_active,*idcErrCont,ihash,indexFE,m_readoutTechnologyMask),
191  m_pixelSummary->getBSErrorWord(ihash,indexFE,ctx));
192 
193  if (word>0) {
194  bsErrIndex.push_back(indexFE);
195  bsErrWord.push_back(word);
196  }
197  }
198  }
199  // Next, access IBL service record
200  int indexOffset = 17*maxHash;
201  for (int ihash=156; ihash<436; ihash++) {
202  for (int chFE=0; chFE<2; chFE++) {
203  for (int serviceCode=0; serviceCode<32; serviceCode++) {
204  int indexSvcCounter = indexOffset+serviceCode*280*2+2*(ihash-156)+chFE;
206  ? InDet::getBSErrorWord(*pixel_active,*idcErrCont,ihash,indexSvcCounter,m_readoutTechnologyMask)
207  : m_pixelSummary->getBSErrorWord(ihash,indexSvcCounter,ctx));
209  InDet::getBSErrorWord(*pixel_active,*idcErrCont,ihash,indexSvcCounter,m_readoutTechnologyMask),
210  m_pixelSummary->getBSErrorWord(ihash,indexSvcCounter,ctx));
211 
212  if (word>0) {
213  bsErrIndex.push_back(indexSvcCounter);
214  bsErrWord.push_back(word);
215  }
216  }
217  }
218  }
219  }
220  }
221  std::vector<SG::WriteDecorHandle<xAOD::EventInfo,std::vector<float>>> decorModuleCondition(createDecorators<xAOD::EventInfo,std::vector<float>>(m_moduleConditionKeys,ctx));
222  assert(decorModuleCondition.size()==2);
223  decorModuleCondition[0](*eventInfo) = std::move(biasVoltage);
224  decorModuleCondition[1](*eventInfo) = std::move(temperature);
225 
226  std::vector<SG::WriteDecorHandle<xAOD::EventInfo,std::vector<int>>> decorModuleFEmask(createDecorators<xAOD::EventInfo,std::vector<int>>(m_moduleFEmaskKeys,ctx));
227  assert(decorModuleFEmask.size()==2);
228  decorModuleFEmask[0](*eventInfo) = std::move(feMaskIndex);
229  decorModuleFEmask[1](*eventInfo) = std::move(feMaskStatus);
230  decorModuleFEmask[2](*eventInfo) = std::move(activeState);
231  decorModuleFEmask[3](*eventInfo) = std::move(activeStatus);
232 
233  std::vector<SG::WriteDecorHandle<xAOD::EventInfo,std::vector<uint64_t>>> decorModuleBSErr(createDecorators<xAOD::EventInfo,std::vector<uint64_t>>(m_moduleBSErrKeys,ctx));
234  assert(decorModuleBSErr.size()==2);
235  decorModuleBSErr[0](*eventInfo) = std::move(bsErrIndex);
236  decorModuleBSErr[1](*eventInfo) = std::move(bsErrWord);
237 
238  return StatusCode::SUCCESS;
239  }
240 
241 }
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:70
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:19
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
DerivationFramework::EventInfoPixelModuleStatusMonitoring::m_moduleConditionKeys
std::vector< SG::WriteDecorHandleKey< xAOD::EventInfo > > m_moduleConditionKeys
Definition: EventInfoPixelModuleStatusMonitoring.h:86
AthCommonDataStore< AthCommonMsg< AlgTool > >::detStore
const ServiceHandle< StoreGateSvc > & detStore() const
The standard StoreGateSvc/DetectorStore Returns (kind of) a pointer to the StoreGateSvc.
Definition: AthCommonDataStore.h:95
InDetDD::PixelReadoutTechnology::RD53
@ RD53
AthCommonDataStore< AthCommonMsg< AlgTool > >::evtStore
ServiceHandle< StoreGateSvc > & evtStore()
The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc.
Definition: AthCommonDataStore.h:85
DerivationFramework::EventInfoPixelModuleStatusMonitoring::finalize
StatusCode finalize()
Definition: EventInfoPixelModuleStatusMonitoring.cxx:67
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?
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
PixelDCSStateData::getModuleStatus
int getModuleStatus(const int chanNum) const
Definition: PixelDCSStateData.cxx:11
DerivationFramework::EventInfoPixelModuleStatusMonitoring::addBranches
virtual StatusCode addBranches() const
Pass the thinning service
Definition: EventInfoPixelModuleStatusMonitoring.cxx:71
SG::CondHandleKey::initialize
StatusCode initialize(bool used=true)
PixelID::wafer_hash_max
size_type wafer_hash_max(void) const
Definition: PixelID.cxx:831
InDetDD::PixelReadoutTechnology::FEI4
@ FEI4
DerivationFramework::EventInfoPixelModuleStatusMonitoring::m_readoutTechnologyMask
unsigned int m_readoutTechnologyMask
Definition: EventInfoPixelModuleStatusMonitoring.h:84
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
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
PixelDCSHVData::getBiasVoltage
float getBiasVoltage(const int chanNum) const
Definition: PixelDCSHVData.cxx:11
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
AthAlgTool
Definition: AthAlgTool.h:26
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.
PixelDCSTempData::getTemperature
float getTemperature(const int chanNum) const
Definition: PixelDCSTemp.cxx:11