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 for (; waferIterator not_eq waferEnd; ++waferIterator) {
128 fill(
"SCTErrMonitor", mEtaAcc, mPhiAcc, mOutAcc);
134 fill(
"SCTErrMonitor", moduleOutBinAcc, moduleOutAcc);
137 return StatusCode::SUCCESS;
146 fill(
"SCTErrMonitor", maskedLinksBinAcc, maskedLinksAcc);
148 return StatusCode::SUCCESS;
154 unsigned int nBadMods{
static_cast<unsigned int>(
m_configurationTool->badModules()->size())};
155 const std::map<IdentifierHash, std::pair<bool, bool>>* badLinks{
m_configurationTool->badLinks(ctx)};
156 unsigned int nBadLink0{0}, nBadLink1{0}, nBadLinkBoth{0};
157 for (
const std::pair<
const IdentifierHash, std::pair<bool, bool>>& link: *badLinks) {
158 std::pair<bool, bool> status{link.second};
159 if ((status.first ==
false) and (status.second ==
true)) {
162 if ((status.first ==
true) and (status.second ==
false)) {
165 if ((status.first ==
false) and (status.second ==
false)) {
171 unsigned int nBadChips{0};
172 for (
const std::pair<const Identifier, unsigned int>& chip : *badChips) {
173 unsigned int status{chip.second};
175 nBadChips += ((status & (1 << i)) == 0 ? 0 : 1);
179 std::set<Identifier> badStripsAll;
181 unsigned int nBadStrips{
static_cast<unsigned int>(badStripsAll.size())};
183 std::set<Identifier> badStripsExclusive;
185 int nBadStripsExclusive{
static_cast<int>(badStripsExclusive.size())};
186 int nBadStripsExclusiveBEC[
N_REGIONS] = {
191 nBadStripsExclusiveBEC[
bec2Index(bec)] += 1;
198 vDetailedConfBin[i] = i;
199 if (i==0) vNBad[i] = nBadMods;
200 else if (i==1) vNBad[i] = nBadLink0;
201 else if (i==2) vNBad[i] = nBadLink1;
202 else if (i==3) vNBad[i] = nBadChips;
203 else if (i==4) vNBad[i] =
static_cast<double>(nBadStripsExclusive) / 100.;
207 fill(
"SCTErrMonitor", detailedConfBinAcc, nBadAcc);
209 ATH_MSG_DEBUG(
"-----------------------------------------------------------------------");
216 ATH_MSG_DEBUG(
"Number of bad strips exclusive = " << nBadStripsExclusive);
217 ATH_MSG_DEBUG(
"Number of bad strips exclusive (ECC, B, ECA) = "
221 ATH_MSG_DEBUG(
"-----------------------------------------------------------------------");
223 return StatusCode::SUCCESS;
231 return StatusCode::SUCCESS;
235 for (
int errType{0}; errType < SCT_ByteStreamErrors::NUM_ERROR_TYPES; ++errType) {
242 fill(
"SCTErrMonitor", lumiBlockAcc, nBSErrorsAcc);
245 categoryErrorMap_t categoryErrorMap;
246 std::array<int, N_REGIONS_INC_GENERAL> nMaskedLinks{};
247 nMaskedLinks.fill(0);
248 for (
int errType{0}; errType < SCT_ByteStreamErrors::NUM_ERROR_TYPES; ++errType) {
252 m_nMaskedLinks[reg] = nMaskedLinks[reg];
255 std::vector<int> vEta;
256 std::vector<int> vPhi;
257 std::vector<bool> vHasError;
261 categoryErrorMap.count(errCate))};
262 fill(
"SCTErrMonitor", lumiBlockAcc, nCategoryErrorsAcc);
264 for (
int iReg{0}; iReg<
N_REGIONS; iReg++) {
270 const size_t size{
static_cast<size_t>((lastEta-firstEta+1)*(lastPhi-firstPhi+1))};
271 for (
int iLay{0}; iLay<maxLayer; iLay++) {
274 vHasError.resize(size);
275 for (
int eta{firstEta};
eta<=lastEta;
eta++) {
276 const int iEta{
eta-firstEta};
277 for (
int phi{firstPhi};
phi<=lastPhi;
phi++) {
278 const int iPhi{
phi-firstPhi};
279 size_t index{
static_cast<size_t>(iEta*(lastPhi-firstPhi+1)+iPhi)};
282 vHasError[
index] = categoryErrorMap[errCate][iReg][iLay][iEta][iPhi];
289 fill(
"SCTErrMonitor", etaAcc, phiAcc, hasErrorAcc);
293 fill(
"SCTErrMonitor", etaAcc, phiAcc, hasErrorRecentAcc);
300 bool doCoverage =
false;
302 std::lock_guard<std::mutex> lock(
m_mutex);
304 m_procLB.insert(pEvent->lumiBlock());
315 "SCT_MapOfDisabledLinks",
316 "SCT_MapOfLinksWithBadLinkLevelErrors",
317 "SCT_MapOfLinksWithBadRODLevelErrors",
318 "SCT_MapOfLinksWithBadErrors",
319 "SCT_MapOfLinksWithPSTrip",
320 "SCT_MapOfLinksWithAnyProbelm"
324 "Map of Disabled Links",
325 "Map of Links with bad LinkLevelErrors",
326 "Map of Links with Bad RODLevelErrors",
327 "Map of Links with Bad Errors",
328 "Map of Links Affected by PS Trip",
329 "Map of Links with Any Bad Problem"
332 std::lock_guard<std::mutex> lock{
m_mutex};
333 CacheEntry* ent{m_cache.get(ctx)};
334 if (ent->m_evt!=ctx.evt()) {
335 if (ent->m_mapSCT.empty()) {
337 ent->m_mapSCT.emplace_back(names[iProblem].c_str(), titles[iProblem].c_str(),
339 ent->m_mapSCT[iProblem].GetXaxis()->SetTitle(
"#eta");
340 ent->m_mapSCT[iProblem].GetYaxis()->SetTitle(
"#phi");
344 ent->m_mapSCT[iProblem].Reset();
347 ent->m_evt = ctx.evt();
354 float psTripModules{0.};
373 fill(
"SCTErrMonitor", lumiBlockAcc, detectorCoverageAcc);
379 fill(
"SCTErrMonitor", lumiBlockAcc, detectorCoverageR4PAcc);
388 fill(
"SCTErrMonitor", lumiBlockAcc, psTripModulesAcc);
392 return StatusCode::SUCCESS;
398 categoryErrorMap_t& categoryErrorMap,
399 std::array<int, N_REGIONS_INC_GENERAL>& nMaskedLinks)
const {
401 std::array<bool, CategoryErrors::N_ERRCATEGORY> b_category{};
402 b_category.fill(
false);
406 (err_type == SCT_ByteStreamErrors::MaskedLink) or (err_type == SCT_ByteStreamErrors::MaskedROD);
412 if (err_type == tmpBadError) {
420 if (err_type == linkLevelError) {
428 if (err_type == rodLevelError) {
435 (err_type == SCT_ByteStreamErrors::TempMaskedChip0) or (err_type == SCT_ByteStreamErrors::TempMaskedChip1) or
436 (err_type == SCT_ByteStreamErrors::TempMaskedChip2) or (err_type == SCT_ByteStreamErrors::TempMaskedChip3) or
437 (err_type == SCT_ByteStreamErrors::TempMaskedChip4) or (err_type == SCT_ByteStreamErrors::TempMaskedChip5);
476 std::vector<int> numErrorsPerLumi[
N_REGIONS];
480 numErrorsPerLumi[reg].resize(nLayers, 0);
486 for (
const auto& hash: errors) {
488 if (not hash.is_valid())
continue;
497 layer = layer * 2 + side;
512 nMaskedLinks[regionIndex]++;
520 categoryErrorMap[errCate][regionIndex][layer][ieta][iphi] =
true;
527 std::vector<int> vErrorType;
528 std::vector<int> vLayerSide;
529 std::vector<float> vErrorFraction;
530 std::vector<bool> vIsEC;
531 std::vector<bool> vIsB;
532 std::vector<bool> vIsEA;
533 vErrorType.reserve(size);
534 vLayerSide.reserve(size);
535 vErrorFraction.reserve(size);
541 for (
int layerSide{0}; layerSide<nLayers; layerSide++) {
543 if (num_modules==0.)
continue;
544 vErrorType.push_back(err_type);
545 vLayerSide.push_back(layerSide);
546 vErrorFraction.push_back(
static_cast<float>(numErrorsPerLumi[reg][layerSide])/num_modules);
559 fill(
"SCTErrMonitor", errorTypeAcc, layerSideAcc, errorFractionAcc, isECAcc, isBAcc, isEAAcc);
568 for (
const auto& fit: errors) {
569 if (fit.is_valid()) {
577 sctHashDisabled.clear();
580 for (
const Identifier& badModule: *badModules) {
585 sctHashDisabled.insert(hashSide0);
586 sctHashDisabled.insert(hashSide1);
592 std::set<IdentifierHash>& sctHashBadRODError,
593 std::set<IdentifierHash>& sctHashBadError)
const {
594 sctHashBadLinkError.clear();
595 sctHashBadRODError.clear();
596 sctHashBadError.clear();
597 const EventContext& ctx{Gaudi::Hive::currentContext()};
600 const std::set<IdentifierHash> sctErrors{
m_byteStreamErrTool->getErrorSet( linkLevelBadErrors, ctx )};
602 sctHashBadLinkError.insert(waferHash);
608 const std::set<IdentifierHash> sctErrors{
m_byteStreamErrTool->getErrorSet( RodLevelBadErrors, ctx )};
610 sctHashBadRODError.insert(waferHash);
616 const std::set<IdentifierHash> sctErrors{
m_byteStreamErrTool->getErrorSet( tmpBadError, ctx )};
618 sctHashBadError.insert(waferHash);
628 sctHashSummary.clear();
630 const EventContext& ctx{Gaudi::Hive::currentContext()};
632 const unsigned int maxHash{
static_cast<unsigned int>(
m_pSCTHelper->wafer_hash_max())};
633 for (
unsigned int i{0}; i<maxHash; i++) {
635 sctHashAll.insert(hash);
637 sctHashSummary.insert(hash);
646 sctHashPSTripDCS.clear();
648 const unsigned int maxHash{
static_cast<unsigned int>(
m_pSCTHelper->wafer_hash_max())};
650 for (
unsigned int i{0}; i<maxHash; i++) {
655 sctHashPSTripDCS.insert(hash);
658 psTripModules = npsw/2.;
663 double etaMin{
module.first.first}, etaMax{module.first.second};
664 double phiMin{
module.second.first}, phiMax{module.second.second};
665 unsigned int nRep{1};
672 for (
unsigned int iRep{0}; iRep<nRep; iRep++) {
674 phiMin =
module.second.first;
679 const int iyMin{
static_cast<int>((phiMin/
M_PI+1.)*
s_nBinsPhi/2)+1};
683 const double yMin{(
static_cast<double>(iyMin)/
s_nBinsPhi*2-1.)*
M_PI};
684 const double yMax{(
static_cast<double>(iyMax)/
s_nBinsPhi*2-1.)*
M_PI};
691 for (
int ix{ixMin}; ix<=ixMax+1; ix++) {
693 if (ixMin==ixMax+1) weightx = wxOne;
694 else if (ix==ixMin) weightx = wxMin;
695 else if (ix==ixMax+1) weightx = wxMax;
696 for (
int iy{iyMin}; iy<=iyMax+1; iy++) {
697 double weight{weightx};
698 if (iyMin==iyMax+1) weight *= wyOne;
699 else if (iy==iyMin) weight *= wyMin;
700 else if (iy==iyMax+1) weight *= wyMax;
701 histo.SetBinContent(ix, iy, histo.GetBinContent(ix,iy)+weight);
709 double occupancy{0.};
711 for (
unsigned int i{0}; i <
s_nBinsEta; i++) {
712 for (
unsigned int j{0}; j <
s_nBinsPhi; j++) {
713 double waferCell{histoAll.GetBinContent(i+1, j+1) - histo.GetBinContent(i+1, j+1)};
725 double detector_coverage{100. * occupancy / (
static_cast<double>(
s_nBinsEta ) *
static_cast<double>(
s_nBinsPhi ) )};
726 return detector_coverage;
729const unsigned int SCTErrMonAlg::s_nBinsEta = 100;
730const double SCTErrMonAlg::s_rangeEta = 2.5;
731const unsigned int SCTErrMonAlg::s_nBinsPhi = 100;
732const 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)
This is an Identifier helper class for the SCT subdetector.
Handle class for reading from StoreGate.
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
bool psTripDCSSCT(std::set< IdentifierHash > &sctHashPSTripDCS, float &PSTripModules) const
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
static const double s_rangeEta
static const unsigned int s_nBinsPhi
BooleanProperty m_doOnline
bool disabledSCT(std::set< IdentifierHash > &sctHashDisabled) const
BooleanProperty m_makeConfHisto
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)