9 MinNumEntriesPerStrip_(0),
12 OutFileName_(
"Occupancy.root"),
14 UseInputDB_(iConfig.getUntrackedParameter<
bool>(
"UseInputDB",
false)) {
19 LogTrace(
"SiStripHotStripAlgorithmFromClusterOccupancy")
20 <<
"[SiStripHotStripAlgorithmFromClusterOccupancy::~SiStripHotStripAlgorithmFromClusterOccupancy] " << std::endl;
26 LogTrace(
"SiStripHotStripAlgorithmFromClusterOccupancy")
27 <<
"[SiStripHotStripAlgorithmFromClusterOccupancy::extractBadStrips] " << std::endl;
33 striptree =
new TTree(
"stripOccupancy",
"tree");
61 HistoMap::iterator it = DM.begin();
62 HistoMap::iterator itEnd = DM.end();
63 std::vector<unsigned int> badStripList;
65 for (; it != itEnd; ++it) {
73 LogTrace(
"SiStripHotStrip") <<
"Analyzing detid " << detid << std::endl;
75 int numberAPVs = (
int)(it->second.get())->GetNbinsX() / 128;
149 std::cout <<
"### Detector does not belong to TIB, TID, TOB or TEC !? ###" << std::endl;
156 badStripList.
clear();
158 for (
int i = 0;
i < 768;
i++) {
168 for (
int apv = 0; apv < numberAPVs; apv++) {
170 if (InSiStripQuality->
IsApvBad(detid, apv)) {
172 LogTrace(
"SiStripHotStrip") <<
"(Module and Apv number) " << detid <<
" , " << apv
173 <<
" excluded by input ESetup." << std::endl;
177 LogTrace(
"SiStripHotStrip") <<
"(Module and Apv number) " << detid <<
" , " << apv
178 <<
" good by input ESetup." << std::endl;
182 phisto.
_th1f =
new TH1F(
"tmp",
"tmp", 128, 0.5, 128.5);
183 int NumberEntriesPerAPV = 0;
186 phisto.
_th1f->SetBinContent(
strip + 1, (it->second.get())->GetBinContent((apv * 128) +
strip + 1));
187 NumberEntriesPerAPV += (
int)(it->second.get())->GetBinContent((apv * 128) +
strip + 1);
190 phisto.
_th1f->SetEntries(NumberEntriesPerAPV);
194 LogTrace(
"SiStripHotStrip") <<
"Number of clusters in APV " << apv <<
": " << NumberEntriesPerAPV << std::endl;
228 if (badStripList.begin() == badStripList.end())
231 OutSiStripQuality->
compact(detid, badStripList);
234 if (!OutSiStripQuality->
put(detid, range))
236 <<
"[SiStripHotStripAlgorithmFromClusterOccupancy::extractBadStrips] detid already exists" << std::endl;
246 LogTrace(
"SiStripHotStrip") <<
ss.str() << std::endl;
250 std::vector<unsigned int>& vect,
255 size_t startingSize = vect.size();
259 size_t ibinStart = 1;
260 size_t ibinStop = Nbins + 1;
261 int MaxEntry = (
int)histo.
_th1f->GetMaximum();
263 std::vector<long double> vPoissonProbs(MaxEntry + 1, 0);
268 unsigned int goodstripentries[128];
270 for (
size_t i = ibinStart;
i < ibinStop; ++
i) {
271 if (
ishot[(apv * 128) +
i - 1] == 0) {
272 goodstripentries[nGoodStrips] = (
unsigned int)histo.
_th1f->GetBinContent(
i);
276 double median = TMath::Median(nGoodStrips, goodstripentries);
278 for (
size_t i = ibinStart;
i < ibinStop; ++
i) {
279 unsigned int entries = (
unsigned int)histo.
_th1f->GetBinContent(
i);
281 if (
ishot[(apv * 128) +
i - 1] == 0) {
284 poissonprob[(apv * 128) +
i - 1] = 1 - vPoissonProbs[entries];
291 if (diff < vPoissonProbs[entries]) {
292 ishot[(apv * 128) +
i - 1] = 1;
295 histo.
_th1f->SetBinContent(
i, 0.);
299 LogTrace(
"SiStripHotStrip") <<
" rejecting strip " << (apv * 128) +
i - 1 <<
" value " << entries <<
" diff " 300 << diff <<
" prob " << vPoissonProbs[entries] << std::endl;
305 LogTrace(
"SiStripHotStrip") <<
" [SiStripHotStripAlgorithmFromClusterOccupancy::iterativeSearch] Nbins=" << Nbins
306 <<
" MaxEntry=" << MaxEntry <<
" meanVal=" << meanVal
308 <<
" thEntries " << histo.
_th1f->GetEntries() <<
" startingSize " << startingSize
309 <<
" vector.size " << vect.size() << std::endl;
311 if (vect.size() != startingSize)
316 long double& meanVal) {
317 for (
size_t i = 0;
i < vPoissonProbs.size(); ++
i) {
318 vPoissonProbs[
i] = (
i == 0) ? TMath::Poisson(
i, meanVal) : vPoissonProbs[
i - 1] + TMath::Poisson(
i, meanVal);
326 LogTrace(
"SiStripHotStrip") <<
" [SiStripHotStripAlgorithmFromClusterOccupancy::setNumberOfEvents] minNumber of " 327 "Events per strip used to consider a strip bad" bool IsApvBad(const uint32_t &detid, const short &apvNb) const
SiStripHotStripAlgorithmFromClusterOccupancy(const edm::ParameterSet &, const TrackerTopology *)
void extractBadStrips(SiStripQuality *, HistoMap &, edm::ESHandle< SiStripQuality > &)
unsigned int tibLayer(const DetId &id) const
unsigned int tibString(const DetId &id) const
unsigned int tidRing(const DetId &id) const
bool tobIsStereo(const DetId &id) const
unsigned int tecRing(const DetId &id) const
ring id
void evaluatePoissonian(std::vector< long double > &, long double &meanVal)
unsigned int tidWheel(const DetId &id) const
const TrackerGeometry * TkGeom
virtual const StripTopology & specificTopology() const
Returns a reference to the strip proxy topology.
double stripoccupancy[768]
bool tecIsZMinusSide(const DetId &id) const
bool tidIsStereo(const DetId &id) const
bool tidIsZMinusSide(const DetId &id) const
bool tecIsStereo(const DetId &id) const
bool tibIsExternalString(const DetId &id) const
bool tibIsZMinusSide(const DetId &id) const
virtual LocalPoint localPosition(float strip) const =0
unsigned int tidModule(const DetId &id) const
bool tidIsBackRing(const DetId &id) const
void compact(unsigned int &, std::vector< unsigned int > &)
bool tobIsZMinusSide(const DetId &id) const
constexpr int subdetId() const
get the contents of the subdetector field (not cast into any detector's numbering enum) ...
unsigned short MinNumEntriesPerStrip_
unsigned int tibModule(const DetId &id) const
unsigned int tecModule(const DetId &id) const
void setNumberOfEvents(double Nevents)
bool tecIsBackPetal(const DetId &id) const
void iterativeSearch(pHisto &, std::vector< unsigned int > &, int)
bool tibIsStereo(const DetId &id) const
SiStripQuality * pQuality
unsigned int tobModule(const DetId &id) const
std::pair< ContainerIterator, ContainerIterator > Range
SiStrip::QualityHistosMap HistoMap
const TrackerGeomDet * idToDet(DetId) const override
virtual ~SiStripHotStripAlgorithmFromClusterOccupancy()
unsigned int tecPetalNumber(const DetId &id) const
const TrackerTopology * tTopo
unsigned int tobRod(const DetId &id) const
bool put(const uint32_t &detID, const InputVector &vect)
unsigned int tecWheel(const DetId &id) const
unsigned int encode(const unsigned short &first, const unsigned short &NconsecutiveBadStrips, const unsigned short &flag=0)
unsigned int tobLayer(const DetId &id) const
unsigned short MinNumEntries_