13 MinNumEntriesPerStrip_(0),
16 OutFileName_(
"Occupancy.root"),
18 UseInputDB_(iConfig.getUntrackedParameter<bool>(
"UseInputDB",
false))
25 LogTrace(
"SiStripHotStripAlgorithmFromClusterOccupancy")<<
"[SiStripHotStripAlgorithmFromClusterOccupancy::~SiStripHotStripAlgorithmFromClusterOccupancy] "<<std::endl;
30 LogTrace(
"SiStripHotStripAlgorithmFromClusterOccupancy")<<
"[SiStripHotStripAlgorithmFromClusterOccupancy::extractBadStrips] "<<std::endl;
38 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;
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);
182 LogTrace(
"SiStripHotStrip") <<
"Number of clusters in APV " << apv <<
": " << NumberEntriesPerAPV << std::endl;
214 if (badStripList.begin()==badStripList.end())
217 OutSiStripQuality->compact(detid,badStripList);
220 if ( ! OutSiStripQuality->put(detid,range) )
221 edm::LogError(
"SiStripHotStrip")<<
"[SiStripHotStripAlgorithmFromClusterOccupancy::extractBadStrips] detid already exists"<<std::endl;
223 OutSiStripQuality->fillBadComponents();
231 LogTrace(
"SiStripHotStrip") <<
ss.str() << std::endl;
239 size_t startingSize=vect.size();
243 size_t ibinStart = 1;
244 size_t ibinStop = Nbins+1;
245 int MaxEntry = (int)histo.
_th1f->GetMaximum();
247 std::vector<long double> vPoissonProbs(MaxEntry+1,0);
251 for (
size_t i=ibinStart;
i<ibinStop; ++
i){
252 unsigned int entries= (
unsigned int)histo.
_th1f->GetBinContent(
i);
254 if (
ishot[(apv*128)+
i-1]==0){
263 if(diff<vPoissonProbs[entries]){
267 histo.
_th1f->SetBinContent(
i,0.);
271 LogTrace(
"SiStripHotStrip")<<
" rejecting strip " << (apv*128)+
i-1 <<
" value " << entries <<
" diff " << diff <<
" prob " << vPoissonProbs[entries]<< std::endl;
272 vect.push_back(
pQuality->encode((apv*128)+
i-1,1,0));
277 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;
279 if (vect.size()!=startingSize)
284 for(
size_t i=0;
i<vPoissonProbs.size();++
i){
285 vPoissonProbs[
i]= (
i==0)?TMath::Poisson(
i,meanVal):vPoissonProbs[
i-1]+TMath::Poisson(
i,meanVal);
293 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
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 tidIsZMinusSide(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
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) ...
virtual const GeomDet * idToDet(DetId) const
unsigned int tibModule(const DetId &id) const
unsigned int tecModule(const DetId &id) const
void setNumberOfEvents(double Nevents)
Detector identifier class for the strip tracker.
bool tecIsBackPetal(const DetId &id) const
void iterativeSearch(pHisto &, std::vector< unsigned int > &, int)
PixelRecoRange< float > Range
SiStripQuality * pQuality
unsigned int tobModule(const DetId &id) const
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
unsigned int tecWheel(const DetId &id) const
unsigned int tobLayer(const DetId &id) const
unsigned short MinNumEntries_