12 MinNumEntriesPerStrip_(0),
15 OutFileName_(
"Occupancy.root"),
17 UseInputDB_(iConfig.getUntrackedParameter<bool>(
"UseInputDB",
false))
24 LogTrace(
"SiStripHotStripAlgorithmFromClusterOccupancy")<<
"[SiStripHotStripAlgorithmFromClusterOccupancy::~SiStripHotStripAlgorithmFromClusterOccupancy] "<<std::endl;
29 LogTrace(
"SiStripHotStripAlgorithmFromClusterOccupancy")<<
"[SiStripHotStripAlgorithmFromClusterOccupancy::extractBadStrips] "<<std::endl;
37 striptree =
new TTree(
"stripOccupancy",
"tree");
66 HistoMap::iterator it=DM.begin();
67 HistoMap::iterator itEnd=DM.end();
68 std::vector<unsigned int> badStripList;
70 for (;it!=itEnd;++it){
78 LogTrace(
"SiStripHotStrip") <<
"Analyzing detid " << detid<< std::endl;
80 int numberAPVs = (int)(it->second.get())->GetNbinsX()/128;
141 std::cout <<
"### Detector does not belong to TIB, TID, TOB or TEC !? ###" << std::endl;
149 badStripList.
clear();
151 for (
int i=0;
i<768;
i++){
161 for (
int apv=0; apv<numberAPVs; apv++){
163 if(InSiStripQuality->IsApvBad(detid,apv) ){
165 LogTrace(
"SiStripHotStrip")<<
"(Module and Apv number) "<<detid<<
" , "<<apv<<
" excluded by input ESetup."<<std::endl;
170 LogTrace(
"SiStripHotStrip")<<
"(Module and Apv number) "<<detid<<
" , "<<apv<<
" good by input ESetup."<<std::endl;
174 phisto.
_th1f =
new TH1F(
"tmp",
"tmp",128,0.5,128.5);
175 int NumberEntriesPerAPV=0;
177 for (
int strip=0; strip<128; strip++){
178 phisto.
_th1f->SetBinContent(strip+1,(it->second.get())->GetBinContent((apv*128)+strip+1));
179 NumberEntriesPerAPV += (int)(it->second.get())->GetBinContent((apv*128)+strip+1);
182 phisto.
_th1f->SetEntries(NumberEntriesPerAPV);
186 LogTrace(
"SiStripHotStrip") <<
"Number of clusters in APV " << apv <<
": " << NumberEntriesPerAPV << std::endl;
220 if (badStripList.begin()==badStripList.end())
223 OutSiStripQuality->
compact(detid,badStripList);
226 if ( ! OutSiStripQuality->
put(detid,range) )
227 edm::LogError(
"SiStripHotStrip")<<
"[SiStripHotStripAlgorithmFromClusterOccupancy::extractBadStrips] detid already exists"<<std::endl;
237 LogTrace(
"SiStripHotStrip") <<
ss.str() << std::endl;
245 size_t startingSize=vect.size();
249 size_t ibinStart = 1;
250 size_t ibinStop = Nbins+1;
251 int MaxEntry = (int)histo.
_th1f->GetMaximum();
253 std::vector<long double> vPoissonProbs(MaxEntry+1,0);
258 unsigned int goodstripentries[128];
260 for (
size_t i=ibinStart;
i<ibinStop; ++
i){
261 if (
ishot[(apv*128)+
i-1]==0){
262 goodstripentries[nGoodStrips] = (
unsigned int)histo.
_th1f->GetBinContent(
i);
266 double median = TMath::Median(nGoodStrips,goodstripentries);
268 for (
size_t i=ibinStart;
i<ibinStop; ++
i){
269 unsigned int entries= (
unsigned int)histo.
_th1f->GetBinContent(
i);
271 if (
ishot[(apv*128)+
i-1]==0){
280 if(diff<vPoissonProbs[entries]){
284 histo.
_th1f->SetBinContent(
i,0.);
288 LogTrace(
"SiStripHotStrip")<<
" rejecting strip " << (apv*128)+
i-1 <<
" value " << entries <<
" diff " << diff <<
" prob " << vPoissonProbs[entries]<< std::endl;
294 LogTrace(
"SiStripHotStrip") <<
" [SiStripHotStripAlgorithmFromClusterOccupancy::iterativeSearch] Nbins="<< Nbins <<
" MaxEntry="<<MaxEntry <<
" meanVal=" << meanVal <<
" NEmptyBins="<<histo.
_NEmptyBins<<
" NEntries=" << histo.
_NEntries <<
" thEntries " << histo.
_th1f->GetEntries()<<
" startingSize " << startingSize <<
" vector.size " << vect.size() << std::endl;
296 if (vect.size()!=startingSize)
301 for(
size_t i=0;
i<vPoissonProbs.size();++
i){
302 vPoissonProbs[
i]= (
i==0)?TMath::Poisson(
i,meanVal):vPoissonProbs[
i-1]+TMath::Poisson(
i,meanVal);
310 LogTrace(
"SiStripHotStrip")<<
" [SiStripHotStripAlgorithmFromClusterOccupancy::setNumberOfEvents] minNumber of Events per strip used to consider a strip bad" <<
minNevents_ <<
" for occupancy " <<
occupancy_ << std::endl;
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
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
unsigned short MinNumEntriesPerStrip_
int subdetId() const
get the contents of the subdetector field (not cast into any detector's numbering enum) ...
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
virtual ~SiStripHotStripAlgorithmFromClusterOccupancy()
virtual LocalPoint localPosition(float strip) const =0
unsigned int tecPetalNumber(const DetId &id) const
volatile std::atomic< bool > shutdown_flag false
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_
virtual const TrackerGeomDet * idToDet(DetId) const