13 #include "Identifier/Identifier.h"
23 #include "GaudiKernel/ITHistSvc.h"
38 static const bool testOffline{
false};
41 numberOfInefficientSides(TH2* pHistogramArray[],
const int xbin,
const int ybin,
const float threshold) {
43 if (pHistogramArray[0]==
nullptr or pHistogramArray[1]==
nullptr)
return 0;
45 double histogramBinContent0{pHistogramArray[0]->GetBinContent(xbin, ybin)};
46 double histogramBinContent1{pHistogramArray[1]->GetBinContent(xbin, ybin)};
47 int side0Inefficient{histogramBinContent0 >
threshold};
48 int side1Inefficient{histogramBinContent1 >
threshold};
50 return side0Inefficient + side1Inefficient;
54 eitherSideIsOverThreshold(TH2* pHistogramArray[],
const int xbin,
const int ybin,
const float threshold) {
56 if (pHistogramArray[0]==
nullptr or pHistogramArray[1]==
nullptr)
return false;
58 double histogramBinContent0{pHistogramArray[0]->GetBinContent(xbin, ybin)};
59 double histogramBinContent1{pHistogramArray[1]->GetBinContent(xbin, ybin)};
65 thereAreEnoughEntries(TH2* pHistogramArray[],
const float threshold) {
67 if (pHistogramArray[0]==
nullptr or pHistogramArray[1]==
nullptr)
return false;
69 double histogramEntries0{pHistogramArray[0]->GetEntries()};
70 double histogramEntries1{pHistogramArray[1]->GetEntries()};
76 countNoisyModules(
const int regionIndex,
const int generalIndex, TH2* pHistogram[],
77 const float threshold,
int countArray[]) {
79 if (pHistogram[0]==
nullptr or pHistogram[1]==
nullptr)
return;
81 const int xbins{pHistogram[0]->GetNbinsX() + 1};
82 const int ybins{pHistogram[0]->GetNbinsY() + 1};
85 for (
int yb{1}; yb <
ybins; ++yb) {
86 if (eitherSideIsOverThreshold(pHistogram,
xb, yb,
threshold)) {
87 countArray[generalIndex]++;
88 countArray[regionIndex]++;
116 m_geo.resize(maxHash, moduleGeo);
124 for (
unsigned int i{0};
i<maxHash;
i++) {
125 IdentifierHash
hash{
i};
128 moduleGeo.first.first, moduleGeo.first.second,
129 moduleGeo.second.first, moduleGeo.second.second,
143 return "MaskedLinkALL";
152 return "LinkLevelErrors";
155 return "RODLevelErrors";
158 return "MaskedChipALL";
207 return StatusCode::SUCCESS;
216 "SCT_CoverageOfEnabledLinksVsLbs",
217 "SCT_CoverageWithNoBadLinkLevelErrorVsLbs",
218 "SCT_CoverageWithNoBadRODLevelErrorVsLbs",
219 "SCT_CoverageWithNoBadErrorVsLbs",
220 "SCT_CoverageWithNoPSTripVsLbs",
221 "SCT_CoverageOfLinksWithNoBadProblemVsLbs"
225 "Ave. Coverage of Enabled Links per LB",
226 "Ave. Coverage of Links with No Bad LinkLevelError per LB",
227 "Ave. Coverage of Links with No Bad RODLevelError per LB",
228 "Ave. Coverage of Links with No Bad Error per LB",
229 "Ave. Coverage of links Not Affected by PS Trip",
230 "Ave. Coverage of Links With No Bad Problem per LB"
235 return StatusCode::SUCCESS;
251 m_mapSCT[
badRODError] =
new TH2F(
"SCT_MapOfLinksWithBadRODLevelErrors",
"Map of Links with Bad RODLevelErrors",
260 m_mapSCT[
summary] =
new TH2F(
"SCT_MapOfLinksWithAnyProbelm",
"Map of Links with Any Bad Problem",
265 m_mapSCT[iProblem]->GetXaxis()->SetTitle(
"#eta");
266 m_mapSCT[iProblem]->GetYaxis()->SetTitle(
"#phi");
278 ATH_MSG_WARNING(
"Cannot book " << profNames[iProblem] <<
", " << profTitles[iProblem]);
284 "Ave. Num of Modules Affected by PS Trip per LB in All Region",
285 NBINS_LBs,0.5,NBINS_LBs+0.5);
293 return (
status ) ? StatusCode::SUCCESS : StatusCode::FAILURE;
304 if (not pEvent.isValid()) {
306 return StatusCode::SUCCESS;
322 std::array<int, N_REGIONS_INC_GENERAL> nFlaggedWafers{};
323 nFlaggedWafers.fill(0);
325 for (
unsigned int iHash{0}; iHash<wafer_hash_max; iHash++) {
326 const IdentifierHash
hash{iHash};
330 nFlaggedWafers[barrel_ec]++;
339 return StatusCode::SUCCESS;
365 return StatusCode::SUCCESS;
391 for (
unsigned int yb{1}; yb <
ybins; ++yb) {
395 if (num_modules > 0) {
404 if (isEndOfEventsBlock) {
421 return StatusCode::SUCCESS;
432 ATH_MSG_DEBUG(
"Calling checkHists(true); true := end of run");
438 return StatusCode::SUCCESS;
446 bool lumi2DHist,
int err_type) {
452 (err_type == SCT_ByteStreamErrors::MaskedLink) or (err_type == SCT_ByteStreamErrors::MaskedROD);
458 if (err_type == tmpBadError) {
467 if (err_type == linkLevelError) {
475 if (err_type == rodLevelError) {
482 (err_type == SCT_ByteStreamErrors::TempMaskedChip0) or (err_type == SCT_ByteStreamErrors::TempMaskedChip1) or
483 (err_type == SCT_ByteStreamErrors::TempMaskedChip2) or (err_type == SCT_ByteStreamErrors::TempMaskedChip3) or
484 (err_type == SCT_ByteStreamErrors::TempMaskedChip4) or (err_type == SCT_ByteStreamErrors::TempMaskedChip5);
490 if (not
hash.is_valid())
continue;
511 if (not lumi2DHist) {
530 if (
fit.is_valid()) {
545 if (not pEvent.isValid()) {
547 return StatusCode::RECOVERABLE;
555 const EventContext& ctx{Gaudi::Hive::currentContext()};
567 return StatusCode::SUCCESS;
575 tot_mod_bytestreamCate_errs[errType] = 0;
579 const int nLayers{n_layers[
reg]*2};
580 for (
int lyr{0}; lyr < nLayers; ++lyr) {
610 float PSTripModules{0.};
615 for (
const IdentifierHash&
hash: sctHash[iProblem]) {
635 const int nLayers{n_layers[
reg]*2};
636 for (
int lyr{0}; lyr < nLayers; ++lyr) {
639 for (
unsigned int xb{1};
xb < nBinsX; ++
xb) {
641 for (
unsigned int yb{1}; yb < nBinsY; ++yb) {
649 tot_mod_bytestreamCate_errs[errType]++;
681 return StatusCode::SUCCESS;
691 std::ostringstream streamhitmap;
693 streamhitmap <<
layer / 2 <<
"_" <<
layer % 2;
695 name += streamhitmap.str();
696 title += streamhitmap.str();
697 titlehitmap += streamhitmap.str();
716 if (sc0.isFailure() or sc1.isFailure()) {
717 return StatusCode::FAILURE;
719 return StatusCode::SUCCESS;
728 const bool barrel)
const {
729 std::ostringstream streamhitmap;
731 streamhitmap <<
layer / 2 <<
"_" <<
layer % 2;
733 name += streamhitmap.str();
734 title += streamhitmap.str();
744 if (
sc.isFailure()) {
745 return StatusCode::FAILURE;
747 return StatusCode::SUCCESS;
757 if (
reg==-1)
return StatusCode::FAILURE;
759 const int nLayers{n_layers[
reg]*2};
760 std::string regName{(
"SCT" + subDetNameShort[
reg]).
Data()};
761 std::string layerTitle{layerName[
reg].Data()};
762 layerTitle.at(0)=toupper(layerTitle.at(0));
769 TH2F_LW::create(
"NumErrsPerLumi", (
"Total Number of Error Types for "+layerTitle+
" per Lumi-Block").c_str(),
771 nLayers, -0.5, nLayers-0.5);
777 TProfile2D_LW::create(
"RateErrorsPerLumi", (
"Rate of Error Types for "+layerTitle+
" per Lumi-Block").c_str(),
779 nLayers, -0.5, nLayers-0.5);
796 bool somethingFailed{
false};
803 std::string name2{(
"SCT_T" +
errorsString(errType) + subDetNameShort[
reg].Data() +
"_").
Data()};
810 (
"summaryErrsRecent"+subDetNameShort[
reg]+
"_").
Data(),
811 "summary recent Layer ",
816 if (somethingFailed) {
817 ATH_MSG_DEBUG(
"Something went wrong in bookErrHistos "<< regName);
821 return StatusCode::SUCCESS;
845 return StatusCode::SUCCESS;
854 "Mod Out",
"Flagged Links",
"Masked Links",
"Errors",
"Inefficient",
"Noisy"
857 "Modules",
"Link 0",
"Link 1",
"Chips",
"Strips (10^{2})"
860 "Mod Out",
"Flagged Links",
"Masked Links",
"Errors"
863 "EndcapC",
"Barrel",
"EndcapA",
""
866 "EndcapC",
"Barrel",
"EndcapA",
"All Region"
909 "Ave. " + SCT_ByteStreamErrors::ErrorTypeDescription[errType] +
" per LB in " + regTitle[
GENERAL_INDEX],
910 NBINS_LBs, 0.5, NBINS_LBs + 0.5);
915 ATH_MSG_WARNING(
"Cannot book Histogram:" + SCT_ByteStreamErrors::ErrorTypeDescription[errType]);
923 NBINS_LBs, 0.5, NBINS_LBs+0.5);
986 return StatusCode::SUCCESS;
1022 bool failedbooking{
false};
1023 TH2* hitsHisto_tmp[2];
1027 std::string regName{(
"SCT" + subDetNameShort[
reg]).
Data()};
1028 const int nLayers{n_layers[
reg]*2};
1031 TH2F hitsHisto_tmp2{
TH2F(mapName.c_str(),
1032 (std::string{
"Module Out of Configuration : "}+subDetName[
reg].Data()+
", "+
1035 n_etabins[
reg], f_etabin[
reg] - 0.5, l_etabin[
reg] + 0.5,
1036 n_phibins[
reg], f_phibin[
reg] - 0.5, l_phibin[
reg] + 0.5)};
1037 hitsHisto_tmp2.GetXaxis()->SetTitle(
"Index in the direction of #eta");
1038 hitsHisto_tmp2.GetYaxis()->SetTitle(
"Index in the direction of #phi");
1039 p2DmapHistoVectorAll[
reg].push_back(hitsHisto_tmp2);
1046 for (; planeIterator not_eq planeEnd; ++planeIterator) {
1047 Identifier planeId{*planeIterator};
1065 p2DmapHistoVectorAll[
reg][element].SetBinContent(
x,
y, IN);
1070 const int nLayers{n_layers[
reg]};
1071 for (
int lyr{0}; lyr < nLayers; ++lyr) {
1077 for (
unsigned int yb{1}; yb <
ybins; ++yb) {
1087 failedbooking =
getHisto(lyr,
reg, 0, hitsHisto_tmp);
1088 if (failedbooking ==
false) {
1094 if (failedbooking ==
false) {
1100 failedbooking =
getHisto(lyr,
reg, 1, hitsHisto_tmp);
1101 if (failedbooking ==
false) {
1105 const int xbins{hitsHisto_tmp[0]->GetNbinsX() + 1};
1106 const int ybins{hitsHisto_tmp[0]->GetNbinsY() + 1};
1109 for (
int yb{1}; yb <
ybins; ++yb) {
1110 float outOfConfig{
static_cast<float>(p2DmapHistoVectorAll[
reg][2 * lyr].GetBinContent(
xb, yb))};
1111 if (outOfConfig < 1.) {
1112 int nSides{numberOfInefficientSides(hitsHisto_tmp,
xb, yb, 1 -
m_effThreshold)};
1114 InEffModules[
reg] += nSides;
1141 const float f{
static_cast<float>(
reg)};
1149 return StatusCode::SUCCESS;
1159 unsigned int nBadMods{
static_cast<unsigned int>(
m_ConfigurationTool->badModules()->size())};
1160 const std::map<IdentifierHash, std::pair<bool, bool>>* badLinks{
m_ConfigurationTool->badLinks()};
1161 unsigned int nBadLink0{0}, nBadLink1{0}, nBadLinkBoth{0};
1162 for (
const std::pair<
const IdentifierHash, std::pair<bool, bool>>& link: *badLinks) {
1163 std::pair<bool, bool>
status{link.second};
1164 if ((
status.first ==
false) and (
status.second ==
true)) {
1167 if ((
status.first ==
true) and (
status.second ==
false)) {
1170 if ((
status.first ==
false) and (
status.second ==
false)) {
1176 unsigned int nBadChips{0};
1177 for (
const std::pair<const Identifier, unsigned int>& chip : *badChips) {
1178 unsigned int status{chip.second};
1180 nBadChips += ((
status & (1 <<
i)) == 0 ? 0 : 1);
1184 std::set<Identifier> badStripsAll;
1186 unsigned int nBadStrips{
static_cast<unsigned int>(badStripsAll.size())};
1188 std::set<Identifier> badStripsExclusive;
1190 int nBadStripsExclusive{
static_cast<int>(badStripsExclusive.size())};
1191 int nBadStripsExclusiveBEC[
N_REGIONS] = {
1194 for (
const Identifier&
strip: badStripsExclusive) {
1205 ATH_MSG_DEBUG(
"-----------------------------------------------------------------------");
1209 ATH_MSG_DEBUG(
"Number of bad link both = " << nBadLinkBoth);
1212 ATH_MSG_DEBUG(
"Number of bad strips exclusive = " << nBadStripsExclusive);
1213 ATH_MSG_DEBUG(
"Number of bad strips exclusive (ECC, B, ECA) = "
1217 ATH_MSG_DEBUG(
"-----------------------------------------------------------------------");
1219 return StatusCode::SUCCESS;
1228 return StatusCode::SUCCESS;
1238 return StatusCode::SUCCESS;
1247 return StatusCode::SUCCESS;
1252 return StatusCode::SUCCESS;
1260 static const std::string trm[2][
N_REGIONS] = {
1261 {
"SCT/SCTEC/Noise/noiseoccupancymapECm_",
"SCT/SCTB/Noise/noiseoccupancymap_",
"SCT/SCTEA/Noise/noiseoccupancymapECp_"},
1262 {
"SCT/SCTEC/eff/ineffm_",
"SCT/SCTB/eff/ineff_",
"SCT/SCTEA/eff/ineffp_"}
1264 static const std::string trm_trig[2][
N_REGIONS] = {
1265 {
"SCT/SCTEC/Noise/noiseoccupancymaptriggerECm_",
"SCT/SCTB/Noise/noiseoccupancymaptrigger_",
"SCT/SCTEA/Noise/noiseoccupancymaptriggerECp_"},
1266 {
"SCT/SCTEC/eff/ineffm_",
"SCT/SCTB/eff/ineff_",
"SCT/SCTEA/eff/ineffp_"}
1283 bool failedBooking{
false};
1290 failedBooking =
true;
1294 failedBooking =
true;
1301 failedBooking =
true;
1305 failedBooking =
true;
1308 return failedBooking;
1316 static const std::string trm[1][
N_REGIONS] = {
1317 {
"SCT/SCTEC/Noise/noiseoccupancymaprecentECm_",
"SCT/SCTB/Noise/noiseoccupancymaprecent_",
"SCT/SCTEA/Noise/noiseoccupancymaprecentECp_"}
1322 bool failedBooking{
false};
1329 failedBooking =
true;
1333 failedBooking =
true;
1339 failedBooking =
true;
1343 failedBooking =
true;
1346 return failedBooking;
1354 double phiMin{
module.second.first}, phiMax{
module.second.second};
1355 unsigned int nRep{1};
1358 if (phiMin>phiMax) {
1362 for (
unsigned int iRep{0}; iRep<nRep; iRep++) {
1364 phiMin =
module.second.first;
1369 const int iyMin{
static_cast<int>((phiMin/
M_PI+1.)*
s_nBinsPhi/2)+1};
1370 const int iyMax{
static_cast<int>((phiMax/
M_PI+1.)*
s_nBinsPhi/2)};
1373 const double yMin{(
static_cast<double>(iyMin)/
s_nBinsPhi*2-1.)*
M_PI};
1374 const double yMax{(
static_cast<double>(iyMax)/
s_nBinsPhi*2-1.)*
M_PI};
1381 for (
int ix{ixMin}; ix<=ixMax+1; ix++) {
1383 if (ixMin==ixMax+1) weightx = wxOne;
1384 else if (ix==ixMin) weightx = wxMin;
1385 else if (ix==ixMax+1) weightx = wxMax;
1386 for (
int iy{iyMin}; iy<=iyMax+1; iy++) {
1388 if (iyMin==iyMax+1)
weight *= wyOne;
1389 else if (iy==iyMin)
weight *= wyMin;
1390 else if (iy==iyMax+1)
weight *= wyMax;
1402 std::set<IdentifierHash>& sctHashBadRODError,
1403 std::set<IdentifierHash>& sctHashBadError)
const {
1404 sctHashBadLinkError.clear();
1405 sctHashBadRODError.clear();
1406 sctHashBadError.clear();
1407 const EventContext& ctx{Gaudi::Hive::currentContext()};
1410 const std::set<IdentifierHash> sctErrors{
m_byteStreamErrTool->getErrorSet( linkLevelBadErrors, ctx )};
1411 for (
const IdentifierHash& waferHash : sctErrors) {
1412 sctHashBadLinkError.insert(waferHash);
1418 const std::set<IdentifierHash> sctErrors{
m_byteStreamErrTool->getErrorSet( RodLevelBadErrors, ctx )};
1419 for (
const IdentifierHash& waferHash: sctErrors) {
1420 sctHashBadRODError.insert(waferHash);
1426 const std::set<IdentifierHash> sctErrors{
m_byteStreamErrTool->getErrorSet( tmpBadError, ctx )};
1427 for (
const IdentifierHash& waferHash: sctErrors) {
1428 sctHashBadError.insert(waferHash);
1436 bool altered{
false};
1437 sctHashDisabled.clear();
1440 for (
const Identifier& badModule: *badModules) {
1443 IdentifierHash hashSide1;
1445 sctHashDisabled.insert(hashSide0);
1446 sctHashDisabled.insert(hashSide1);
1453 bool altered{
false};
1455 sctHashSummary.clear();
1456 const EventContext& ctx = Gaudi::Hive::currentContext();
1458 for (
unsigned int i{0};
i<maxHash;
i++) {
1459 IdentifierHash
hash{
i};
1460 sctHashAll.insert(
hash);
1462 sctHashSummary.insert(
hash);
1470 bool altered{
false};
1471 sctHashPSTripDCS.clear();
1475 for (
unsigned int i{0};
i<maxHash;
i++) {
1476 IdentifierHash
hash{
i};
1480 sctHashPSTripDCS.insert(
hash);
1483 PSTripModules = npsw/2.;
1491 double occupancy{0.};
1494 for (
unsigned int j{0}; j <
s_nBinsPhi; j++) {
1507 double detector_coverage{100. *
static_cast<double>( occupancy )/(
static_cast<double>(
s_nBinsEta ) *
static_cast<double>(
s_nBinsPhi ) )};
1508 return detector_coverage;