10 MinNumEntriesPerStrip_(0),
13 OutFileName_(
"Occupancy.root"),
15 UseInputDB_(iConfig.getUntrackedParameter<bool>(
"UseInputDB",
false)) {
20 LogTrace(
"SiStripHotStripAlgorithmFromClusterOccupancy")
21 <<
"[SiStripHotStripAlgorithmFromClusterOccupancy::~SiStripHotStripAlgorithmFromClusterOccupancy] " << std::endl;
27 LogTrace(
"SiStripHotStripAlgorithmFromClusterOccupancy")
28 <<
"[SiStripHotStripAlgorithmFromClusterOccupancy::extractBadStrips] " << std::endl;
34 striptree =
new TTree(
"stripOccupancy",
"tree");
62 HistoMap::iterator it = DM.begin();
63 HistoMap::iterator itEnd = DM.end();
64 std::vector<unsigned int> badStripList;
66 for (; it != itEnd; ++it) {
74 LogTrace(
"SiStripHotStrip") <<
"Analyzing detid " << detid << std::endl;
76 int numberAPVs = (int)(it->second.get())->GetNbinsX() / 128;
150 std::cout <<
"### Detector does not belong to TIB, TID, TOB or TEC !? ###" << std::endl;
157 badStripList.
clear();
159 for (
int i = 0;
i < 768;
i++) {
169 for (
int apv = 0; apv < numberAPVs; apv++) {
171 if (InSiStripQuality->
IsApvBad(detid, apv)) {
173 LogTrace(
"SiStripHotStrip") <<
"(Module and Apv number) " << detid <<
" , " << apv
174 <<
" excluded by input ESetup." << std::endl;
178 LogTrace(
"SiStripHotStrip") <<
"(Module and Apv number) " << detid <<
" , " << apv
179 <<
" good by input ESetup." << std::endl;
183 phisto.
_th1f =
new TH1F(
"tmp",
"tmp", 128, 0.5, 128.5);
184 int NumberEntriesPerAPV = 0;
187 phisto.
_th1f->SetBinContent(
strip + 1, (it->second.get())->GetBinContent((apv * 128) +
strip + 1));
188 NumberEntriesPerAPV += (int)(it->second.get())->GetBinContent((apv * 128) +
strip + 1);
191 phisto.
_th1f->SetEntries(NumberEntriesPerAPV);
195 LogTrace(
"SiStripHotStrip") <<
"Number of clusters in APV " << apv <<
": " << NumberEntriesPerAPV << std::endl;
229 if (badStripList.begin() == badStripList.end())
232 OutSiStripQuality->
compact(detid, badStripList);
235 if (!OutSiStripQuality->
put(detid,
range))
237 <<
"[SiStripHotStripAlgorithmFromClusterOccupancy::extractBadStrips] detid already exists" << std::endl;
247 LogTrace(
"SiStripHotStrip") <<
ss.str() << std::endl;
251 std::vector<unsigned int>& vect,
256 size_t startingSize = vect.size();
259 size_t Nbins = histo.
_th1f->GetNbinsX();
260 size_t ibinStart = 1;
261 size_t ibinStop = Nbins + 1;
262 int MaxEntry = (int)histo.
_th1f->GetMaximum();
264 std::vector<long double> vPoissonProbs(MaxEntry + 1, 0);
269 unsigned int goodstripentries[128];
271 for (
size_t i = ibinStart;
i < ibinStop; ++
i) {
272 if (
ishot[(apv * 128) +
i - 1] == 0) {
273 goodstripentries[nGoodStrips] = (
unsigned int)histo.
_th1f->GetBinContent(
i);
277 double median = TMath::Median(nGoodStrips, goodstripentries);
279 for (
size_t i = ibinStart;
i < ibinStop; ++
i) {
280 unsigned int entries = (
unsigned int)histo.
_th1f->GetBinContent(
i);
282 if (
ishot[(apv * 128) +
i - 1] == 0) {
285 poissonprob[(apv * 128) +
i - 1] = 1 - vPoissonProbs[entries];
292 if (diff < vPoissonProbs[entries]) {
293 ishot[(apv * 128) +
i - 1] = 1;
296 histo.
_th1f->SetBinContent(
i, 0.);
300 LogTrace(
"SiStripHotStrip") <<
" rejecting strip " << (apv * 128) +
i - 1 <<
" value " << entries <<
" diff "
301 << diff <<
" prob " << vPoissonProbs[entries] << std::endl;
306 LogTrace(
"SiStripHotStrip") <<
" [SiStripHotStripAlgorithmFromClusterOccupancy::iterativeSearch] Nbins=" << Nbins
307 <<
" MaxEntry=" << MaxEntry <<
" meanVal=" << meanVal
309 <<
" thEntries " << histo.
_th1f->GetEntries() <<
" startingSize " << startingSize
310 <<
" vector.size " << vect.size() << std::endl;
312 if (vect.size() != startingSize)
317 long double& meanVal) {
318 for (
size_t i = 0;
i < vPoissonProbs.size(); ++
i) {
319 vPoissonProbs[
i] = (
i == 0) ? TMath::Poisson(
i, meanVal) : vPoissonProbs[
i - 1] + TMath::Poisson(
i, meanVal);
327 LogTrace(
"SiStripHotStrip") <<
" [SiStripHotStripAlgorithmFromClusterOccupancy::setNumberOfEvents] minNumber of "
328 "Events per strip used to consider a strip bad"
bool IsApvBad(const uint32_t &detid, const short &apvNb) const
static constexpr auto TEC
SiStripHotStripAlgorithmFromClusterOccupancy(const edm::ParameterSet &, const TrackerTopology *)
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
const uint16_t range(const Frame &aFrame)
bool tidIsZMinusSide(const DetId &id) const
bool tecIsStereo(const DetId &id) const
bool tibIsExternalString(const DetId &id) const
bool tibIsZMinusSide(const DetId &id) const
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) ...
void extractBadStrips(SiStripQuality *, HistoMap &, const SiStripQuality *)
unsigned short MinNumEntriesPerStrip_
static constexpr auto TOB
const TrackerGeomDet * idToDet(DetId) const override
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)
static constexpr auto TIB
bool tibIsStereo(const DetId &id) const
SiStripQuality * pQuality
unsigned int tobModule(const DetId &id) const
std::pair< ContainerIterator, ContainerIterator > Range
SiStrip::QualityHistosMap HistoMap
virtual ~SiStripHotStripAlgorithmFromClusterOccupancy()
virtual LocalPoint localPosition(float strip) const =0
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
static constexpr auto TID
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_