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");
63 HistoMap::iterator it=DM.begin();
64 HistoMap::iterator itEnd=DM.end();
65 std::vector<unsigned int> badStripList;
67 for (;it!=itEnd;++it){
75 LogTrace(
"SiStripHotStrip") <<
"Analyzing detid " << detid<< std::endl;
77 int numberAPVs = (int)(it->second.get())->GetNbinsX()/128;
138 std::cout <<
"### Detector does not belong to TIB, TID, TOB or TEC !? ###" << std::endl;
146 badStripList.
clear();
148 for (
int i=0;
i<768;
i++){
158 for (
int apv=0; apv<numberAPVs; apv++){
160 if(InSiStripQuality->IsApvBad(detid,apv) ){
162 LogTrace(
"SiStripHotStrip")<<
"(Module and Apv number) "<<detid<<
" , "<<apv<<
" excluded by input ESetup."<<std::endl;
167 LogTrace(
"SiStripHotStrip")<<
"(Module and Apv number) "<<detid<<
" , "<<apv<<
" good by input ESetup."<<std::endl;
171 phisto.
_th1f =
new TH1F(
"tmp",
"tmp",128,0.5,128.5);
172 int NumberEntriesPerAPV=0;
174 for (
int strip=0; strip<128; strip++){
175 phisto.
_th1f->SetBinContent(strip+1,(it->second.get())->GetBinContent((apv*128)+strip+1));
176 NumberEntriesPerAPV += (int)(it->second.get())->GetBinContent((apv*128)+strip+1);
179 phisto.
_th1f->SetEntries(NumberEntriesPerAPV);
183 LogTrace(
"SiStripHotStrip") <<
"Number of clusters in APV " << apv <<
": " << NumberEntriesPerAPV << std::endl;
215 if (badStripList.begin()==badStripList.end())
218 OutSiStripQuality->
compact(detid,badStripList);
221 if ( ! OutSiStripQuality->
put(detid,range) )
222 edm::LogError(
"SiStripHotStrip")<<
"[SiStripHotStripAlgorithmFromClusterOccupancy::extractBadStrips] detid already exists"<<std::endl;
232 LogTrace(
"SiStripHotStrip") <<
ss.str() << std::endl;
240 size_t startingSize=vect.size();
244 size_t ibinStart = 1;
245 size_t ibinStop = Nbins+1;
246 int MaxEntry = (int)histo.
_th1f->GetMaximum();
248 std::vector<long double> vPoissonProbs(MaxEntry+1,0);
252 for (
size_t i=ibinStart;
i<ibinStop; ++
i){
253 unsigned int entries= (
unsigned int)histo.
_th1f->GetBinContent(
i);
255 if (
ishot[(apv*128)+
i-1]==0){
264 if(diff<vPoissonProbs[entries]){
268 histo.
_th1f->SetBinContent(
i,0.);
272 LogTrace(
"SiStripHotStrip")<<
" rejecting strip " << (apv*128)+
i-1 <<
" value " << entries <<
" diff " << diff <<
" prob " << vPoissonProbs[entries]<< std::endl;
278 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;
280 if (vect.size()!=startingSize)
285 for(
size_t i=0;
i<vPoissonProbs.size();++
i){
286 vPoissonProbs[
i]= (
i==0)?TMath::Poisson(
i,meanVal):vPoissonProbs[
i-1]+TMath::Poisson(
i,meanVal);
294 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