35 ATH_MSG_FATAL(
"The event data (PixelDetElStatusEventDataBaseKey) and cond data (PixelDetElStatusCondDataBaseKey) keys cannot be set at the same time.");
53 return StatusCode::FAILURE;
56 ATH_MSG_FATAL(
"Logic error: status id too large. Cannot be represented by a bit");
57 return StatusCode::FAILURE;
70 ATH_MSG_ERROR(
"No matching DCS status " << isActiveStatus <<
" in DCSModuleStatus");
71 return StatusCode::FAILURE;
74 ATH_MSG_FATAL(
"Logic error: status id too large. Cannot be represented by a bit");
75 return StatusCode::FAILURE;
80 return StatusCode::SUCCESS;
89 if (not idcErrCont.
isValid()) {
return nullptr; }
91 return idcErrCont.
cptr();
98 if (idcErrContPtr==
nullptr) {
99 cacheEntry->
reset(ctx.evt(),
nullptr);
102 cacheEntry->
reset(ctx.evt(), idcErrContPtr->cache());
104 ATH_MSG_VERBOSE(
"PixelConditionsSummaryTool Cache for the event reset " << cacheEntry->
eventId <<
" with IDC container" << idcErrContPtr);
110 std::scoped_lock<std::mutex> lock{*m_cacheMutex.get(ctx)};
120 if (moduleHash>=
m_pixelID->wafer_hash_max()) {
121 ATH_MSG_ERROR(
"invalid moduleHash : " << moduleHash <<
" exceed maximum hash id: " <<
m_pixelID->wafer_hash_max());
127 if (not pixelDetEleHandle.
isValid() or elements==
nullptr) {
136 const EventContext& ctx,
145 const EventContext& ctx,
152 if (cacheEntry ==
nullptr){
153 std::scoped_lock<std::mutex> lock{*m_cacheMutex.get(ctx)};
156 const auto *idcCachePtr = cacheEntry->
IDCCache;
157 if (idcCachePtr==
nullptr) {
161 uint64_t word = (uint64_t)idcCachePtr->retrieve(
index);
168 return hasBSError(p_design,moduleHash, ctx,cacheEntry);
173 const EventContext& ctx,
175 uint64_t word =
getBSErrorWord(p_design,moduleHash, ctx,cacheEntry);
195 if (
hasBSError(p_design, moduleHash, ctx, cacheEntry)) {
return true; }
197 int maxHash =
m_pixelID->wafer_hash_max();
199 std::array<InDetDD::PixelDiodeTree::CellIndexType,2> diode_idx
203 std::uint32_t chFE = p_design->
getFE(si_param);
205 int indexFE = (1+chFE)*maxHash+
static_cast<int>(moduleHash);
229 if (useByteStream &&
getBSErrorWord(moduleHash,moduleHash+52736,ctx)!=1) {
return false; }
232 bool isDCSActive =
false;
234 if (istate==dcsstate_data->getModuleStatus(moduleHash)) { isDCSActive=
true; }
236 if (!isDCSActive) {
return false; }
250 if (useByteStream &&
getBSErrorWord(moduleHash,moduleHash+52736,ctx)!=1) {
return false; }
253 bool isDCSActive =
false;
255 if (istate==dcsstate_data->getModuleStatus(moduleHash)) { isDCSActive=
true; }
257 if (!isDCSActive) {
return false; }
274 if (
hasBSError(moduleHash, ctx)) {
return false; }
277 bool isDCSActive =
false;
279 if (istate==dcsstate_data->getModuleStatus(moduleHash)) { isDCSActive=
true; }
281 if (!isDCSActive) {
return false; }
284 bool isDCSGood =
false;
286 if (activeStatus==dcsstatus_data->getModuleStatus(moduleHash)) { isDCSGood=
true; }
288 if (!isDCSGood) {
return false; }
296 if (
hasBSError(moduleHash, elementId, ctx)) {
return false; }
303 inline void andStatus(
const std::unordered_map<int, int> &status_map,
unsigned int status_mask, std::vector<bool> &module_status) {
304 for (
const std::pair<const int, int> &elm : status_map ) {
306 module_status.at(elm.first) = module_status.at(elm.first) && (status_mask & (1<<elm.second));
309 inline void andNotStatus(
const std::unordered_map<int, int> &status_map, std::vector<bool> &module_status) {
310 for (
const std::pair<const int, int> &elm : status_map ) {
312 module_status.at(elm.first) = module_status.at(elm.first) && (elm.second==0);
315 bool isBSError(uint64_t
error, uint64_t max_error, uint64_t mask) {
324 throw std::runtime_error(
"Object is not of expected type InDet::PixelDetectorElementStatus");
329std::unique_ptr<InDet::SiDetectorElementStatus>
337 return std::make_unique<InDet::PixelDetectorElementStatus>(*castToDerived(input_element_status.
cptr()));
341 return std::make_unique<InDet::PixelDetectorElementStatus>(*castToDerived(input_element_status.
cptr()));
345 if (not pixelDetEleHandle.
isValid() ) {
346 std::stringstream
msg;
348 throw std::runtime_error(
msg.str());
354 return std::make_unique<InDet::PixelDetectorElementStatus>(*elements);
358std::unique_ptr<InDet::SiDetectorElementStatus>
362 std::vector<bool> &status=element_status->getElementStatus();
363 status.resize(
m_pixelID->wafer_hash_max(),
366 std::vector<InDet::ChipFlags_t> &chip_status=element_status->getElementChipStatus();
367 chip_status.resize(status.size(),0);
387 andNotStatus(tdaq_handle->moduleStatusMap(), status);
394 andNotStatus(dead_map_handle->moduleStatusMap(), status);
400 unsigned int element_i=0;
402 if (status[element_i]) {
406 InDet::ChipFlags_t chip_mask = (1ul<<number_of_chips)-1ul;
407 assert( chip_mask != 0 );
408 std::bitset<16> dead_chip_mask(dead_map->
getChipStatus(element_i));
409 chip_status[element_i] = chip_mask & (~static_cast<InDet::ChipFlags_t>(dead_chip_mask.to_ulong()));
422 if (readout_technology_mask) {
424 ATH_MSG_ERROR(
"PixelConditionsSummaryTool not configured for use with conditions objects");
427 std::scoped_lock<std::mutex> lock{*m_cacheMutex.get(ctx)};
430 if (idcCachePtr==
nullptr) {
461 unsigned int element_offset_i = (active_only ? 52736 : 0);
463 unsigned int element_i=0;
464 unsigned int maxHash =
m_pixelID->wafer_hash_max();
471 status.at(element_i) = status.at(element_i) && not ( readout_technology_flags
474 : idcCachePtr->
retrieve(element_i+element_offset_i)!=1 ));
477 if (status[element_i]) {
479 InDet::ChipFlags_t chip_mask = status[element_i] ? (1ul<<number_of_chips)-1ul : 0;
480 assert( chip_mask != 0 );
481 InDet::ChipFlags_t bs_status_flags = active_only ? chip_mask : 0;
483 for (
unsigned int chip_i =0; chip_i < number_of_chips; ++chip_i) {
485 unsigned int indexFE = (1+chip_i)*maxHash + element_i;
486 InDet::ChipFlags_t chip_flag =not ( readout_technology_flags
488 bs_status_flags |= (chip_flag << chip_i);
491 chip_status[element_i] &= (bs_status_flags & chip_mask);
494 chip_status[element_i] = 0;
500 return element_status;
505 if (
hasBSError(moduleHash, ctx)) {
return false; }
508 bool isDCSActive =
false;
510 if (istate==dcsstate_data->getModuleStatus(moduleHash)) { isDCSActive=
true; }
512 if (!isDCSActive) {
return false; }
515 bool isDCSGood =
false;
517 if (activeStatus==dcsstatus_data->getModuleStatus(moduleHash)) { isDCSGood=
true; }
519 if (!isDCSGood) {
return false; }
530 if (
hasBSError(moduleHash, ctx, cacheEntry)) {
return false; }
533 bool isDCSActive =
false;
535 if (istate==dcsstate_data->getModuleStatus(moduleHash)) { isDCSActive=
true; }
537 if (!isDCSActive) {
return false; }
540 bool isDCSGood =
false;
542 if (activeStatus==dcsstatus_data->getModuleStatus(moduleHash)) { isDCSGood=
true; }
544 if (!isDCSGood) {
return false; }
552 if (
hasBSError(moduleHash, elementId, ctx, cacheEntry)) {
return false; }
559 if (!
isGood(moduleHash, ctx)) {
return 0.0; }
563 int phiStart =
m_pixelID->phi_index(idStart);
564 int etaStart =
m_pixelID->eta_index(idStart);
566 int phiEnd =
m_pixelID->phi_index(idEnd);
567 int etaEnd =
m_pixelID->eta_index(idEnd);
569 double nTotal = (std::abs(phiStart-phiEnd)+1.0)*(std::abs(etaStart-etaEnd)+1.0);
573 for (
int i=std::min(phiStart,phiEnd); i<=std::max(phiStart,phiEnd); i++) {
574 for (
int j=std::min(etaStart,etaEnd); j<=std::max(etaStart,etaEnd); j++) {
576 if (!
hasBSError(moduleHash,
m_pixelID->pixel_id(moduleID,i,j), ctx, cacheEntry)) { nGood++; }
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_VERBOSE(x)
IdentifiableValueCache< IDCInDetBSErrContainer::ErrorCode > IDCInDetBSErrContainer_Cache
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
const ServiceHandle< StoreGateSvc > & detStore() const
Header file for AthHistogramAlgorithm.
IDC like storage for BS errors, TODO, customise implementation further so that we store int rather th...
T retrieve(size_t i)
Retrieve the Value stored in that hash.
This is a "hash" representation of an Identifier.
static constexpr std::array< PixelDiodeTree::CellIndexType, 2 > makeCellIndex(T local_x_idx, T local_y_idx)
Create a 2D cell index from the indices in local-x (phi, row) and local-y (eta, column) direction.
Class used to describe the design of a module (diode segmentation and readout scheme)
PixelReadoutTechnology getReadoutTechnology() const
PixelDiodeTree::DiodeProxy diodeProxyFromIdx(const std::array< PixelDiodeTree::IndexType, 2 > &idx) const
int numberOfCircuits() const
Total number of circuits:
static unsigned int getFE(const PixelDiodeTree::DiodeProxy &diode_proxy)
Class to hold the SiDetectorElement objects to be put in the detector store.
const SiDetectorElement * getDetectorElement(const IdentifierHash &hash) const
Class to hold geometrical description of a silicon detector element.
virtual const SiDetectorDesign & design() const override final
access to the local description (inline):
Event data to hold the status information for Pixel modules.
int getChipStatus(const int chanNum) const
const_pointer_type cptr()
virtual bool isValid() override final
Can the handle be successfully dereferenced?
const_pointer_type cptr()
Dereference the pointer.
void addDependency(const EventIDRange &range)
constexpr IDCInDetBSErrContainer::ErrorCode makeError(PixelErrorsEnum errType)
helper to be used in clients to fetch error information
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.
bool needsUpdate(const EventContext &ctx) const
void reset(EventContext::ContextEvt_t evtId, const IDCInDetBSErrContainer_Cache *cache)
const IDCInDetBSErrContainer_Cache * IDCCache
EventContext::ContextEvt_t eventId
Helper class to access parameters of a diode.