17 m_nMaskedLinks[reg] = 0;
33 const unsigned int maxHash{
static_cast<unsigned int>(
m_pSCTHelper->wafer_hash_max())};
35 m_geo.resize(maxHash, moduleGeo);
37 const double deltaZ{0.};
38 for (
unsigned int i{0}; i<maxHash; i++) {
42 moduleGeo.first.first, moduleGeo.first.second,
43 moduleGeo.second.first, moduleGeo.second.second,
55 return StatusCode::SUCCESS;
67 fill(
"SCTErrMonitor", lumiBlockAcc, is1DAcc, sctFlagAcc);
70 std::array<int, N_REGIONS_INC_GENERAL> flaggedWafersIndices
72 std::array<int, N_REGIONS_INC_GENERAL> nFlaggedWafers{};
73 nFlaggedWafers.fill(0);
74 const unsigned int wafer_hash_max{
static_cast<unsigned int>(
m_pSCTHelper->wafer_hash_max())};
75 for (
unsigned int iHash{0}; iHash<wafer_hash_max; iHash++) {
80 nFlaggedWafers[barrel_ec]++;
86 fill(
"SCTErrMonitor", flaggedWwafersIndicesAcc, nFlaggedWafersAcc);
89 return StatusCode::SUCCESS;
94 std::lock_guard<std::mutex> glock{
m_mutex};
109 const std::string errMonName{
"SCTErrMonitor"};
110 for (; waferIterator not_eq waferEnd; ++waferIterator) {
129 fill(errMonName, mEtaAcc, mPhiAcc, mOutAcc);
135 fill(errMonName, moduleOutBinAcc, moduleOutAcc);
138 return StatusCode::SUCCESS;
147 fill(
"SCTErrMonitor", maskedLinksBinAcc, maskedLinksAcc);
149 return StatusCode::SUCCESS;
156 const std::map<IdentifierHash, std::pair<bool, bool>>* badLinks{
m_configurationTool->badLinks(ctx)};
157 unsigned int nBadLink0{0}, nBadLink1{0}, nBadLinkBoth{0};
158 for (
const std::pair<
const IdentifierHash, std::pair<bool, bool>>& link: *badLinks) {
159 std::pair<bool, bool> status{link.second};
160 if ((status.first ==
false) and (status.second ==
true)) {
163 if ((status.first ==
true) and (status.second ==
false)) {
166 if ((status.first ==
false) and (status.second ==
false)) {
172 unsigned int nBadChips{0};
173 for (
const std::pair<const Identifier, unsigned int>& chip : *badChips) {
174 unsigned int status{chip.second};
176 nBadChips += ((status & (1 << i)) == 0 ? 0 : 1);
180 std::set<Identifier> badStripsAll;
182 unsigned int nBadStrips{
static_cast<unsigned int>(badStripsAll.size())};
184 std::set<Identifier> badStripsExclusive;
186 int nBadStripsExclusive{
static_cast<int>(badStripsExclusive.size())};
187 int nBadStripsExclusiveBEC[
N_REGIONS] = {
192 nBadStripsExclusiveBEC[
bec2Index(bec)] += 1;
199 vDetailedConfBin[i] = i;
200 if (i==0) vNBad[i] = nBadMods;
201 else if (i==1) vNBad[i] = nBadLink0;
202 else if (i==2) vNBad[i] = nBadLink1;
203 else if (i==3) vNBad[i] = nBadChips;
204 else if (i==4) vNBad[i] =
static_cast<double>(nBadStripsExclusive) / 100.;
208 fill(
"SCTErrMonitor", detailedConfBinAcc, nBadAcc);
210 ATH_MSG_DEBUG(
"-----------------------------------------------------------------------");
217 ATH_MSG_DEBUG(
"Number of bad strips exclusive = " << nBadStripsExclusive);
218 ATH_MSG_DEBUG(
"Number of bad strips exclusive (ECC, B, ECA) = "
222 ATH_MSG_DEBUG(
"-----------------------------------------------------------------------");
224 return StatusCode::SUCCESS;
232 return StatusCode::SUCCESS;
236 for (
int errType{0}; errType < SCT_ByteStreamErrors::NUM_ERROR_TYPES; ++errType) {
243 fill(
"SCTErrMonitor", lumiBlockAcc, nBSErrorsAcc);
247 categoryErrorMap_t categoryErrorMap;
248 std::array<int, N_REGIONS_INC_GENERAL> nMaskedLinks{};
249 nMaskedLinks.fill(0);
250 for (
int errType{0}; errType < SCT_ByteStreamErrors::NUM_ERROR_TYPES; ++errType) {
254 m_nMaskedLinks[reg] = nMaskedLinks[reg];
257 std::vector<int> vEta;
258 std::vector<int> vPhi;
259 std::vector<bool> vHasError;
263 categoryErrorMap.count(errCate))};
264 fill(
"SCTErrMonitor", lumiBlockAcc, nCategoryErrorsAcc);
266 for (
int iReg{0}; iReg<
N_REGIONS; iReg++) {
272 const size_t size{
static_cast<size_t>((lastEta-firstEta+1)*(lastPhi-firstPhi+1))};
273 for (
int iLay{0}; iLay<maxLayer; iLay++) {
276 vHasError.resize(
size);
277 for (
int eta{firstEta};
eta<=lastEta;
eta++) {
278 const int iEta{
eta-firstEta};
279 for (
int phi{firstPhi};
phi<=lastPhi;
phi++) {
280 const int iPhi{
phi-firstPhi};
281 size_t index{
static_cast<size_t>(iEta*(lastPhi-firstPhi+1)+iPhi)};
284 vHasError[
index] = categoryErrorMap[errCate][iReg][iLay][iEta][iPhi];
291 fill(
"SCTErrMonitor", etaAcc, phiAcc, hasErrorAcc);
295 fill(
"SCTErrMonitor", etaAcc, phiAcc, hasErrorRecentAcc);
302 bool doCoverage =
false;
306 m_procLB.insert(pEvent->lumiBlock());
317 "SCT_MapOfDisabledLinks",
318 "SCT_MapOfLinksWithBadLinkLevelErrors",
319 "SCT_MapOfLinksWithBadRODLevelErrors",
320 "SCT_MapOfLinksWithBadErrors",
321 "SCT_MapOfLinksWithPSTrip",
322 "SCT_MapOfLinksWithAnyProbelm"
326 "Map of Disabled Links",
327 "Map of Links with bad LinkLevelErrors",
328 "Map of Links with Bad RODLevelErrors",
329 "Map of Links with Bad Errors",
330 "Map of Links Affected by PS Trip",
331 "Map of Links with Any Bad Problem"
335 CacheEntry* ent{m_cache.get(ctx)};
336 if (ent->m_evt!=ctx.evt()) {
337 if (ent->m_mapSCT.empty()) {
339 ent->m_mapSCT.emplace_back(names[iProblem].c_str(), titles[iProblem].c_str(),
341 ent->m_mapSCT[iProblem].GetXaxis()->SetTitle(
"#eta");
342 ent->m_mapSCT[iProblem].GetYaxis()->SetTitle(
"#phi");
346 ent->m_mapSCT[iProblem].Reset();
349 ent->m_evt = ctx.evt();
356 float psTripModules{0.};
375 fill(
"SCTErrMonitor", lumiBlockAcc, detectorCoverageAcc);
381 fill(
"SCTErrMonitor", lumiBlockAcc, detectorCoverageR4PAcc);
390 fill(
"SCTErrMonitor", lumiBlockAcc, psTripModulesAcc);
394 return StatusCode::SUCCESS;
400 categoryErrorMap_t& categoryErrorMap,
401 std::array<int, N_REGIONS_INC_GENERAL>& nMaskedLinks)
const {
403 std::array<bool, CategoryErrors::N_ERRCATEGORY> b_category{};
404 b_category.fill(
false);
408 (err_type == SCT_ByteStreamErrors::MaskedLink) or (err_type == SCT_ByteStreamErrors::MaskedROD);
414 if (err_type == tmpBadError) {
422 if (err_type == linkLevelError) {
430 if (err_type == rodLevelError) {
437 (err_type == SCT_ByteStreamErrors::TempMaskedChip0) or (err_type == SCT_ByteStreamErrors::TempMaskedChip1) or
438 (err_type == SCT_ByteStreamErrors::TempMaskedChip2) or (err_type == SCT_ByteStreamErrors::TempMaskedChip3) or
439 (err_type == SCT_ByteStreamErrors::TempMaskedChip4) or (err_type == SCT_ByteStreamErrors::TempMaskedChip5);
478 std::array<std::vector<int>,
N_REGIONS> numErrorsPerLumi;
482 numErrorsPerLumi[reg].resize(nLayers, 0);
488 for (
const auto& hash: errors) {
490 if (not hash.is_valid())
continue;
499 layer = layer * 2 + side;
514 nMaskedLinks[regionIndex]++;
522 categoryErrorMap[errCate][regionIndex][layer][ieta][iphi] =
true;
529 std::vector<int> vErrorType;
530 std::vector<int> vLayerSide;
531 std::vector<float> vErrorFraction;
532 std::vector<bool> vIsEC;
533 std::vector<bool> vIsB;
534 std::vector<bool> vIsEA;
535 vErrorType.reserve(
size);
536 vLayerSide.reserve(
size);
537 vErrorFraction.reserve(
size);
543 for (
int layerSide{0}; layerSide<nLayers; layerSide++) {
545 if (num_modules==0.)
continue;
546 vErrorType.push_back(err_type);
547 vLayerSide.push_back(layerSide);
548 vErrorFraction.push_back(
static_cast<float>(numErrorsPerLumi[reg][layerSide])/num_modules);
561 fill(
"SCTErrMonitor", errorTypeAcc, layerSideAcc, errorFractionAcc, isECAcc, isBAcc, isEAAcc);
570 for (
const auto& fit: errors) {
571 if (fit.is_valid()) {
579 sctHashDisabled.clear();
582 for (
const Identifier& badModule: *badModules) {
587 sctHashDisabled.insert(hashSide0);
588 sctHashDisabled.insert(hashSide1);
594 std::set<IdentifierHash>& sctHashBadRODError,
595 std::set<IdentifierHash>& sctHashBadError)
const {
596 sctHashBadLinkError.clear();
597 sctHashBadRODError.clear();
598 sctHashBadError.clear();
599 const EventContext& ctx{Gaudi::Hive::currentContext()};
602 const std::set<IdentifierHash> sctErrors{
m_byteStreamErrTool->getErrorSet( linkLevelBadErrors, ctx )};
604 sctHashBadLinkError.insert(waferHash);
610 const std::set<IdentifierHash> sctErrors{
m_byteStreamErrTool->getErrorSet( RodLevelBadErrors, ctx )};
612 sctHashBadRODError.insert(waferHash);
618 const std::set<IdentifierHash> sctErrors{
m_byteStreamErrTool->getErrorSet( tmpBadError, ctx )};
620 sctHashBadError.insert(waferHash);
630 sctHashSummary.clear();
632 const EventContext& ctx{Gaudi::Hive::currentContext()};
634 const unsigned int maxHash{
static_cast<unsigned int>(
m_pSCTHelper->wafer_hash_max())};
635 for (
unsigned int i{0}; i<maxHash; i++) {
637 sctHashAll.insert(hash);
639 sctHashSummary.insert(hash);
648 sctHashPSTripDCS.clear();
650 const unsigned int maxHash{
static_cast<unsigned int>(
m_pSCTHelper->wafer_hash_max())};
652 for (
unsigned int i{0}; i<maxHash; i++) {
657 sctHashPSTripDCS.insert(hash);
660 psTripModules = npsw/2.;
665 double etaMin{
module.first.first}, etaMax{module.first.second};
666 double phiMin{
module.second.first}, phiMax{module.second.second};
667 unsigned int nRep{1};
674 for (
unsigned int iRep{0}; iRep<nRep; iRep++) {
676 phiMin =
module.second.first;
681 const int iyMin{
static_cast<int>((phiMin/
M_PI+1.)*
s_nBinsPhi/2)+1};
685 const double yMin{(
static_cast<double>(iyMin)/
s_nBinsPhi*2-1.)*
M_PI};
686 const double yMax{(
static_cast<double>(iyMax)/
s_nBinsPhi*2-1.)*
M_PI};
693 for (
int ix{ixMin}; ix<=ixMax+1; ix++) {
695 if (ixMin==ixMax+1) weightx = wxOne;
696 else if (ix==ixMin) weightx = wxMin;
697 else if (ix==ixMax+1) weightx = wxMax;
698 for (
int iy{iyMin}; iy<=iyMax+1; iy++) {
699 double weight{weightx};
700 if (iyMin==iyMax+1) weight *= wyOne;
701 else if (iy==iyMin) weight *= wyMin;
702 else if (iy==iyMax+1) weight *= wyMax;
703 histo.SetBinContent(ix, iy, histo.GetBinContent(ix,iy)+weight);
711 double occupancy{0.};
713 for (
unsigned int i{0}; i <
s_nBinsEta; i++) {
714 for (
unsigned int j{0}; j <
s_nBinsPhi; j++) {
715 double waferCell{histoAll.GetBinContent(i+1, j+1) - histo.GetBinContent(i+1, j+1)};
727 double detector_coverage{100. * occupancy / (
static_cast<double>(
s_nBinsEta ) *
static_cast<double>(
s_nBinsPhi ) )};
728 return detector_coverage;
731const unsigned int SCTErrMonAlg::s_nBinsEta = 100;
732const double SCTErrMonAlg::s_rangeEta = 2.5;
733const unsigned int SCTErrMonAlg::s_nBinsPhi = 100;
734const double SCTErrMonAlg::s_wafersThreshold = 4.0;
Scalar eta() const
pseudorapidity method
Scalar phi() const
phi method
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_WARNING(x)
virtual void lock()=0
Interface to allow an object to lock itself when made const in SG.
This is an Identifier helper class for the SCT subdetector.
Handle class for reading from StoreGate.
size_t size() const
Number of registered mappings.
const ServiceHandle< StoreGateSvc > & detStore() const
virtual StatusCode initialize() override
initialize
AthMonitorAlgorithm(const std::string &name, ISvcLocator *pSvcLocator)
Constructor.
SG::ReadHandleKey< xAOD::EventInfo > m_EventInfoKey
Key for retrieving EventInfo from StoreGate.
This is a "hash" representation of an Identifier.
Dedicated detector manager extending the functionality of the SiDetectorManager with dedicated SCT in...
virtual const SiDetectorElement * getDetectorElement(const Identifier &id) const override
access to individual elements via Identifier
Class to hold geometrical description of a silicon detector element.
void getEtaPhiRegion(double deltaZ, double &etaMin, double &etaMax, double &phiMin, double &phiMax, double &rz) const
Method for building up region of interest table.
Declare a monitored scalar variable.
void fillWafer(moduleGeo_t module, TH2F &histo) const
std::atomic_bool m_isFirstConfigurationDetails
bool errorSCT(std::set< IdentifierHash > &sctHashBadLinkError, std::set< IdentifierHash > &sctHashBadRODError, std::set< IdentifierHash > &sctHashBadError) const
int fillByteStreamErrorsHelper(const std::set< IdentifierHash > &errors, int err_type, categoryErrorMap_t &categoryErrorMap, std::array< int, SCT_Monitoring::N_REGIONS_INC_GENERAL > &nMaskedLinks) const
Used in fillByteStreamErrors().
ToolHandle< ISCT_ByteStreamErrorsTool > m_byteStreamErrTool
StatusCode fillByteStreamErrors(const EventContext &ctx) const
StatusCode fillConfigurationDetails(const EventContext &ctx) const
Used in fillHistograms().
BooleanProperty m_coverageCheck
ToolHandle< IInDetConditionsTool > m_pSummaryTool
double calculateDetectorCoverage(const TH2F &histo, const TH2F &histoAll) const
ToolHandle< IDQFilterTool > m_atlasReadyFilter
virtual StatusCode initialize() override final
initialize
static const double s_wafersThreshold
bool summarySCT(std::set< IdentifierHash > &sctHashAll, std::set< IdentifierHash > &sctHashSummary) const
SCTErrMonAlg(const std::string &name, ISvcLocator *pSvcLocator)
ToolHandle< ISCT_DCSConditionsTool > m_dcsTool
bool disabledSCT(const EventContext &ctx, std::set< IdentifierHash > &sctHashDisabled) const
static const double s_rangeEta
static const unsigned int s_nBinsPhi
BooleanProperty m_doOnline
BooleanProperty m_makeConfHisto
bool psTripDCSSCT(const EventContext &ctx, std::set< IdentifierHash > &sctHashPSTripDCS, float &PSTripModules) const
ToolHandle< ISCT_ConfigurationConditionsTool > m_configurationTool
BooleanProperty m_doPerLumiErrors
virtual StatusCode stop() override final
std::pair< std::pair< double, double >, std::pair< double, double > > moduleGeo_t
std::vector< moduleGeo_t > m_geo
BooleanProperty m_coverageCheckOnlyFirtsEventOfLB
ToolHandle< ISCT_FlaggedConditionTool > m_flaggedTool
void numByteStreamErrors(const std::set< IdentifierHash > &errors, int &ntot) const
virtual StatusCode fillHistograms(const EventContext &ctx) const override final
adds event to the monitoring histograms
const SCT_ID * m_pSCTHelper
static const unsigned int s_nBinsEta
std::vector< Identifier >::const_iterator const_id_iterator
virtual bool isValid() override final
Can the handle be successfully dereferenced?
@ Error
The sub-detector issued an error.
ValuesCollection< T > Collection(std::string name, const T &collection)
Declare a monitored (double-convertible) collection.
ErrorType
SCT byte stream error type enums used in SCT_RodDecoder, SCT_ByteStreamErrorsTool,...
static const std::vector< ErrorType > RodLevelBadErrors
Bad error enums in ROD level used in SCTErrMonAlg.
static const std::vector< std::string > ErrorTypeDescription
SCT byte stream error type strings used in SCTErrMonAlg.
static const std::vector< ErrorType > BadErrors
Bad error enums used in SCT_ByteStreamErrorsTool and SCTErrMonAlg.
static const std::vector< ErrorType > LinkLevelErrors
Error enums in FE-link level used in SCTErrMonAlg (assigned by SCT_RodDecoder::addSingleError).
static const std::vector< ErrorType > RodLevelErrors
Error enums in ROD level used in SCTErrMonAlg (assigned by SCT_RodDecoder::addRODError).
static const std::vector< ErrorType > LinkLevelBadErrors
Bad error enums in FE-link level used in SCTErrMonAlg.
@ numberOfProblemForCoverage
static const std::vector< std::string > coverageVarNames
unsigned int bec2Index(const int becVal)
Conversion bec->index.
int getNumModules(const int reg, const int layer)
Bec index2Bec(const unsigned int i)
Conversion index->bec.
static const std::vector< TString > subDetNameShort
static const std::vector< std::string > CategoryErrorsNames
static const std::vector< int > n_layers
@ HEADERTRAILERLIMITERROR
void fill(H5::Group &out_file, size_t iterations)