20 absolute_occupancy_(0),
21 OutFileName_(
"Occupancy.root"),
22 DQMOutfileName_(
"DQMOutput"),
23 UseInputDB_(iConfig.getUntrackedParameter<
bool>(
"UseInputDB",
false)),
29 LogTrace(
"SiStripBadAPVandHotStripAlgorithmFromClusterOccupancy")
30 <<
"[SiStripBadAPVandHotStripAlgorithmFromClusterOccupancy::~"
31 "SiStripBadAPVandHotStripAlgorithmFromClusterOccupancy] "
37 LogTrace(
"SiStripBadAPVandHotStripAlgorithmFromClusterOccupancy")
38 <<
"[SiStripBadAPVandHotStripAlgorithmFromClusterOccupancy::extractBadAPVs] " << std::endl;
44 apvtree =
new TTree(
"moduleOccupancy",
"tree");
65 striptree =
new TTree(
"stripOccupancy",
"tree");
93 HistoMap::iterator it = DM.begin();
94 HistoMap::iterator itEnd = DM.end();
95 std::vector<unsigned int> badStripList;
97 for (; it != itEnd; ++it) {
100 for (
int apv = 0; apv < 6; apv++) {
101 APV.apvMedian[apv] = 0;
102 APV.apvabsoluteOccupancy[apv] = 0;
103 APV.NEntries[apv] = 0;
104 APV.NEmptyBins[apv] = 0;
117 APV.th1f[apv] =
new TH1F(
"tmp",
"tmp", 128, 0.5, 128.5);
118 int NumberEntriesPerAPV = 0;
122 (it->second.get())->GetBinContent((apv * 128) +
strip + 1);
124 APV.apvabsoluteOccupancy[apv] +=
125 (it->second.get())->GetBinContent((apv * 128) +
strip + 1);
126 APV.th1f[apv]->SetBinContent(
strip + 1, (it->second.get())->GetBinContent((apv * 128) +
strip + 1));
127 NumberEntriesPerAPV += (
int)(it->second.get())->GetBinContent((apv * 128) +
strip + 1);
130 APV.th1f[apv]->SetEntries(NumberEntriesPerAPV);
131 APV.NEntries[apv] = (
int)
APV.th1f[apv]->GetEntries();
142 LogTrace(
"SiStripBadAPV") <<
"Analyzing detid " << detid << std::endl;
262 std::cout <<
"### Detector does not belong to TIB, TID, TOB or TEC !? ###" << std::endl;
309 badStripList.
clear();
424 LogTrace(
"SiStripBadAPV") <<
ss.str() << std::endl;
428 std::pair<double, double>* MeanRMS,
429 int number_iterations) {
430 Double_t tot[7], tot2[7];
433 Double_t
Mean[7] = {0};
434 Double_t Rms[7] = {1000, 1000, 1000, 1000, 1000, 1000, 1000};
438 for (
int i = 0;
i < number_iterations;
i++) {
439 for (
int j = 0;
j < 7;
j++) {
445 for (uint32_t it = 0; it <
a.size(); it++) {
446 Moduleposition = (
a[it].modulePosition) - 1;
448 for (
int apv = 0; apv <
a[it].numberApvs; apv++) {
450 if (
a[it].apvMedian[apv] < (
Mean[Moduleposition] - 3 * Rms[Moduleposition]) ||
451 (
a[it].apvMedian[apv] > (
Mean[Moduleposition] + 5 * Rms[Moduleposition]))) {
455 tot[Moduleposition] +=
a[it].apvMedian[apv];
456 tot2[Moduleposition] += (
a[it].apvMedian[apv]) * (
a[it].apvMedian[apv]);
461 for (
int j = 0;
j < 7;
j++) {
469 for (
int j = 0;
j < 7;
j++) {
470 MeanRMS[
j] = std::make_pair(
Mean[
j], Rms[
j]);
476 std::vector<Apv>& medianValues,
477 std::pair<double, double>* MeanAndRms,
478 std::vector<unsigned int>& BadStripList,
483 for (uint32_t it = 0; it < medianValues.size(); it++) {
484 Moduleposition = (medianValues[it].modulePosition) - 1;
485 Detid = medianValues[it].detrawId;
497 for (
int apv = 0; apv < medianValues[it].numberApvs; apv++) {
498 double logMedianOccupancy = -1;
499 double logAbsoluteOccupancy = -1;
501 for (
int i = 0;
i < 128;
i++) {
528 unsigned int layer = 0;
548 if (InSiStripQuality->
IsApvBad(Detid, apv)) {
590 std::cout <<
"ERROR! distance is never computed!!!\n";
601 if (medianValues[it].apvMedian[apv] >
minNevents_) {
602 if ((medianValues[it].apvMedian[apv] >
608 }
else if (medianValues[it].apvMedian[apv] <
610 (MeanAndRms[Moduleposition].first > 2 || medianValues[it].apvabsoluteOccupancy[apv] == 0)) {
659 std::cout <<
"ERROR! distance is never computed!!!\n";
668 if (BadStripList.begin() != BadStripList.end()) {
669 quality->compact(Detid, BadStripList);
673 BadStripList.clear();
678 std::vector<unsigned int>& vect,
683 size_t startingSize = vect.size();
687 size_t ibinStart = 1;
688 size_t ibinStop =
Nbins + 1;
689 int MaxEntry = (
int)
histo.th1f[apv]->GetMaximum();
691 std::vector<long double> vPoissonProbs(MaxEntry + 1, 0);
692 long double meanVal = 1. *
histo.NEntries[apv] / (1. *
Nbins -
histo.NEmptyBins[apv]);
696 unsigned int goodstripentries[128];
698 for (
size_t i = ibinStart;
i < ibinStop; ++
i) {
699 if (
ishot[(apv * 128) +
i - 1] == 0) {
700 goodstripentries[nGoodStrips] = (
unsigned int)
histo.th1f[apv]->GetBinContent(
i);
704 double median = TMath::Median(nGoodStrips, goodstripentries);
706 for (
size_t i = ibinStart;
i < ibinStop; ++
i) {
707 unsigned int entries = (
unsigned int)
histo.th1f[apv]->GetBinContent(
i);
720 if (
diff < vPoissonProbs[entries]) {
724 histo.th1f[apv]->SetBinContent(
i, 0.);
725 histo.NEntries[apv] -= entries;
726 histo.NEmptyBins[apv]++;
728 LogTrace(
"SiStripHotStrip") <<
" rejecting strip " << (apv * 128) +
i - 1 <<
" value " << entries <<
" diff "
729 <<
diff <<
" prob " << vPoissonProbs[entries] << std::endl;
734 LogTrace(
"SiStripHotStrip") <<
" [SiStripHotStripAlgorithmFromClusterOccupancy::iterativeSearch] Nbins=" <<
Nbins
735 <<
" MaxEntry=" << MaxEntry <<
" meanVal=" << meanVal
736 <<
" NEmptyBins=" <<
histo.NEmptyBins[apv] <<
" NEntries=" <<
histo.NEntries[apv]
737 <<
" thEntries " <<
histo.th1f[apv]->GetEntries() <<
" startingSize " << startingSize
738 <<
" vector.size " << vect.size() << std::endl;
740 if (vect.size() != startingSize)
745 long double& meanVal) {
746 for (
size_t i = 0;
i < vPoissonProbs.size(); ++
i) {
747 vPoissonProbs[
i] = (
i == 0) ? TMath::Poisson(
i, meanVal) : vPoissonProbs[
i - 1] + TMath::Poisson(
i, meanVal);
828 std::cout <<
"### Detector does not belong to TIB, TID, TOB or TEC !? ###" << std::endl;
829 std::cout <<
"### DetRawId: " << detid <<
" ###" << std::endl;
866 histoTitle =
"Distance between hot strips vs. strip number";
880 histoTitle =
"Number of hot strips vs. strip number";
889 histoTitle =
"Distribution of distance between hot strips";
899 histoTitle =
"Occupancy of strips vs. strip number";
913 histoTitle =
"Distribution of strip occupancy";
923 histoTitle =
"Occupancy of hot strips vs. strip number";
937 histoTitle =
"Distribution of hot strip occupancy";
947 histoTitle =
"Occupancy of good strips vs. strip number";
961 histoTitle =
"Distribution of good strip occupancy";
971 histoTitle =
"Poisson probability of strips vs. strip number";
985 histoTitle =
"Distribution of strip Poisson probability";
995 histoTitle =
"Poisson probability of hot strips vs. strip number";
1002 tmp_prof =
new TProfile(
histoName.c_str(), histoTitle.c_str(), 768, 0.5, 768.5);
1009 histoTitle =
"Distribution of hot strip Poisson probability";
1019 histoTitle =
"Poisson probability of good strips vs. strip number";
1026 tmp_prof =
new TProfile(
histoName.c_str(), histoTitle.c_str(), 768, 0.5, 768.5);
1033 histoTitle =
"Distribution of good strip Poisson probability";
1043 histoTitle =
"NHits in strips vs. strip number";
1050 tmp_prof =
new TProfile(
histoName.c_str(), histoTitle.c_str(), 768, 0.5, 768.5);
1055 histoTitle =
"Cumulative nHits in strips vs. strip number";
1062 histoTitle =
"Distribution of nHits for all strips";
1072 histoTitle =
"NHits in hot strips vs. strip number";
1079 tmp_prof =
new TProfile(
histoName.c_str(), histoTitle.c_str(), 768, 0.5, 768.5);
1084 histoTitle =
"Cumulative nHits in hot strips vs. strip number";
1091 histoTitle =
"Distribution of nHits for hot strips";
1101 histoTitle =
"NHits in good strips vs. strip number";
1108 tmp_prof =
new TProfile(
histoName.c_str(), histoTitle.c_str(), 768, 0.5, 768.5);
1113 histoTitle =
"Cumulative nHits in good strips vs. strip number";
1120 histoTitle =
"Distribution of nHits for good strips";
1135 histoTitle =
"Median APV occupancy vs. absolute APV occupancy";
1153 histoTitle =
"Median APV occupancy";
1170 histoTitle =
"Absolute APV occupancy";
1185 double logStripOccupancy = -1;
1186 double logPoissonProb = -1;