11 MinNumEntriesPerStrip_(0),
14 OutFileName_(
"Occupancy.root"),
16 UseInputDB_(iConfig.getUntrackedParameter<bool>(
"UseInputDB",
false))
23 LogTrace(
"SiStripHotStripAlgorithmFromClusterOccupancy")<<
"[SiStripHotStripAlgorithmFromClusterOccupancy::~SiStripHotStripAlgorithmFromClusterOccupancy] "<<std::endl;
28 LogTrace(
"SiStripHotStripAlgorithmFromClusterOccupancy")<<
"[SiStripHotStripAlgorithmFromClusterOccupancy::extractBadStrips] "<<std::endl;
36 striptree =
new TTree(
"stripOccupancy",
"tree");
65 HistoMap::iterator it=DM.begin();
66 HistoMap::iterator itEnd=DM.end();
67 std::vector<unsigned int> badStripList;
69 for (;it!=itEnd;++it){
77 LogTrace(
"SiStripHotStrip") <<
"Analyzing detid " << detid<< std::endl;
79 int numberAPVs = (
int)(it->second.get())->GetNbinsX()/128;
140 std::cout <<
"### Detector does not belong to TIB, TID, TOB or TEC !? ###" << std::endl;
148 badStripList.
clear();
150 for (
int i=0;
i<768;
i++){
160 for (
int apv=0; apv<numberAPVs; apv++){
162 if(InSiStripQuality->
IsApvBad(detid,apv) ){
164 LogTrace(
"SiStripHotStrip")<<
"(Module and Apv number) "<<detid<<
" , "<<apv<<
" excluded by input ESetup."<<std::endl;
169 LogTrace(
"SiStripHotStrip")<<
"(Module and Apv number) "<<detid<<
" , "<<apv<<
" good by input ESetup."<<std::endl;
173 phisto.
_th1f =
new TH1F(
"tmp",
"tmp",128,0.5,128.5);
174 int NumberEntriesPerAPV=0;
177 phisto.
_th1f->SetBinContent(
strip+1,(it->second.get())->GetBinContent((apv*128)+
strip+1));
178 NumberEntriesPerAPV += (
int)(it->second.get())->GetBinContent((apv*128)+
strip+1);
181 phisto.
_th1f->SetEntries(NumberEntriesPerAPV);
185 LogTrace(
"SiStripHotStrip") <<
"Number of clusters in APV " << apv <<
": " << NumberEntriesPerAPV << std::endl;
219 if (badStripList.begin()==badStripList.end())
222 OutSiStripQuality->
compact(detid,badStripList);
225 if ( ! OutSiStripQuality->
put(detid,range) )
226 edm::LogError(
"SiStripHotStrip")<<
"[SiStripHotStripAlgorithmFromClusterOccupancy::extractBadStrips] detid already exists"<<std::endl;
236 LogTrace(
"SiStripHotStrip") <<
ss.str() << std::endl;
244 size_t startingSize=vect.size();
248 size_t ibinStart = 1;
249 size_t ibinStop = Nbins+1;
250 int MaxEntry = (
int)histo.
_th1f->GetMaximum();
252 std::vector<long double> vPoissonProbs(MaxEntry+1,0);
257 unsigned int goodstripentries[128];
259 for (
size_t i=ibinStart;
i<ibinStop; ++
i){
260 if (
ishot[(apv*128)+
i-1]==0){
261 goodstripentries[nGoodStrips] = (
unsigned int)histo.
_th1f->GetBinContent(
i);
265 double median = TMath::Median(nGoodStrips,goodstripentries);
267 for (
size_t i=ibinStart;
i<ibinStop; ++
i){
268 unsigned int entries= (
unsigned int)histo.
_th1f->GetBinContent(
i);
270 if (
ishot[(apv*128)+
i-1]==0){
279 if(diff<vPoissonProbs[entries]){
283 histo.
_th1f->SetBinContent(
i,0.);
287 LogTrace(
"SiStripHotStrip")<<
" rejecting strip " << (apv*128)+
i-1 <<
" value " << entries <<
" diff " << diff <<
" prob " << vPoissonProbs[entries]<< std::endl;
293 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;
295 if (vect.size()!=startingSize)
300 for(
size_t i=0;
i<vPoissonProbs.size();++
i){
301 vPoissonProbs[
i]= (
i==0)?TMath::Poisson(
i,meanVal):vPoissonProbs[
i-1]+TMath::Poisson(
i,meanVal);
309 LogTrace(
"SiStripHotStrip")<<
" [SiStripHotStripAlgorithmFromClusterOccupancy::setNumberOfEvents] minNumber of Events per strip used to consider a strip bad" <<
minNevents_ <<
" for occupancy " <<
occupancy_ << std::endl;
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
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()
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_
const TrackerGeomDet * idToDet(DetId) const