test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
SiStripBadAPVandHotStripAlgorithmFromClusterOccupancy.cc
Go to the documentation of this file.
2 
10 
11 
13  ratio_(1.5),
14  lowoccupancy_(0),
15  highoccupancy_(100),
16  absolutelow_(0),
17  numberiterations_(2),
18  Nevents_(0),
19  absolute_occupancy_(0),
20  OutFileName_("Occupancy.root"),
21  DQMOutfileName_("DQMOutput"),
22  UseInputDB_(iConfig.getUntrackedParameter<bool>("UseInputDB",false)),
23  tTopo(theTopo)
24  {
26  }
27 
29  LogTrace("SiStripBadAPVandHotStripAlgorithmFromClusterOccupancy")<<"[SiStripBadAPVandHotStripAlgorithmFromClusterOccupancy::~SiStripBadAPVandHotStripAlgorithmFromClusterOccupancy] "<<std::endl;
30 }
31 
33 
34  LogTrace("SiStripBadAPVandHotStripAlgorithmFromClusterOccupancy")<<"[SiStripBadAPVandHotStripAlgorithmFromClusterOccupancy::extractBadAPVs] "<<std::endl;
35 
36  if (WriteOutputFile_== true)
37  {
38  f = new TFile(OutFileName_.c_str(),"RECREATE");
39  f->cd();
40 
41  apvtree = new TTree("moduleOccupancy","tree");
42 
43  apvtree->Branch("DetRawId", &detrawid, "DetRawId/I");
44  apvtree->Branch("SubDetId", &subdetid, "SubDetId/I");
45  apvtree->Branch("Layer_Ring", &layer_ring, "Layer_Ring/I");
46  apvtree->Branch("Disc", &disc, "Disc/I");
47  apvtree->Branch("IsBack", &isback, "IsBack/I");
48  apvtree->Branch("IsExternalString", &isexternalstring, "IsExternalString/I");
49  apvtree->Branch("IsZMinusSide", &iszminusside, "IsZMinusSide/I");
50  apvtree->Branch("RodStringPetal", &rodstringpetal, "RodStringPetal/I");
51  apvtree->Branch("IsStereo", &isstereo, "IsStereo/I");
52  apvtree->Branch("ModuleNumber", &module_number, "ModuleNumber/I");
53  apvtree->Branch("NumberOfStrips", &number_strips, "NumberOfStrips/I");
54  apvtree->Branch("APVGlobalPositionX", &global_position_x, "APVGlobalPositionX/F");
55  apvtree->Branch("APVGlobalPositionY", &global_position_y, "APVGlobalPositionY/F");
56  apvtree->Branch("APVGlobalPositionZ", &global_position_z, "APVGlobalPositionZ/F");
57  apvtree->Branch("APVNumber", &apv_number, "APVNumber/I");
58  apvtree->Branch("APVAbsoluteOccupancy", &apvAbsoluteOccupancy, "apvAbsoluteOccupancy/I");
59  apvtree->Branch("APVMedianOccupancy", &apvMedianOccupancy, "apvMedianOccupancy/D");
60  apvtree->Branch("IsBad", &isBad, "IsBad/I");
61 
62  striptree = new TTree("stripOccupancy","tree");
63 
64  striptree->Branch("DetRawId", &detrawid, "DetRawId/I");
65  striptree->Branch("SubDetId", &subdetid, "SubDetId/I");
66  striptree->Branch("Layer_Ring", &layer_ring, "Layer_Ring/I");
67  striptree->Branch("Disc", &disc, "Disc/I");
68  striptree->Branch("IsBack", &isback, "IsBack/I");
69  striptree->Branch("IsExternalString", &isexternalstring, "IsExternalString/I");
70  striptree->Branch("IsZMinusSide", &iszminusside, "IsZMinusSide/I");
71  striptree->Branch("RodStringPetal", &rodstringpetal, "RodStringPetal/I");
72  striptree->Branch("IsStereo", &isstereo, "IsStereo/I");
73  striptree->Branch("ModulePosition", &module_number, "ModulePosition/I");
74  striptree->Branch("NumberOfStrips", &number_strips, "NumberOfStrips/I");
75  striptree->Branch("StripNumber", &strip_number, "StripNumber/I");
76  striptree->Branch("APVChannel", &apv_channel, "APVChannel/I");
77  striptree->Branch("StripGlobalPositionX", &strip_global_position_x, "StripGlobalPositionX/F");
78  striptree->Branch("StripGlobalPositionY", &strip_global_position_y, "StripGlobalPositionY/F");
79  striptree->Branch("StripGlobalPositionZ", &strip_global_position_z, "StripGlobalPositionZ/F");
80  striptree->Branch("IsHot", &isHot, "IsHot/I");
81  striptree->Branch("HotStripsPerAPV", &hotStripsPerAPV, "HotStripsPerAPV/I");
82  striptree->Branch("HotStripsPerModule", &hotStripsPerModule,"HotStripsPerModule/I");
83  striptree->Branch("StripOccupancy", &singleStripOccupancy, "StripOccupancy/D");
84  striptree->Branch("StripHits", &stripHits, "StripHits/I");
85  striptree->Branch("PoissonProb", &poissonProb, "PoissonProb/D");
86  striptree->Branch("MedianAPVHits", &medianAPVHits, "MedianAPVHits/D");
87  striptree->Branch("AvgAPVHits", &avgAPVHits, "AvgAPVHits/D");
88  }
89 
90  HistoMap::iterator it=DM.begin();
91  HistoMap::iterator itEnd=DM.end();
92  std::vector<unsigned int> badStripList;
93  uint32_t detid;
94  for (;it!=itEnd;++it){
95 
96  Apv APV;
97 
98  for (int apv=0; apv<6; apv++)
99  {
100  APV.apvMedian[apv] = 0;
101  APV.apvabsoluteOccupancy[apv] = 0;
102  APV.NEntries[apv] = 0;
103  APV.NEmptyBins[apv] = 0;
104 
105  for (int strip=0; strip<128; strip++)
106  {
107  stripOccupancy[apv][strip] = 0;
108  stripWeight[apv][strip] = 0;
109  }
110  }
111 
112  number_strips = (int)((it->second.get())->GetNbinsX());
114  APV.numberApvs = number_apvs;
115 
116  for (int apv=0; apv<number_apvs; apv++)
117  {
118  APV.th1f[apv] = new TH1F("tmp","tmp",128,0.5,128.5);
119  int NumberEntriesPerAPV=0;
120 
121  for (int strip=0; strip<128; strip++)
122  {
123  stripOccupancy[apv][strip] = (it->second.get())->GetBinContent((apv*128)+strip+1); // Remember: Bin=0 is underflow bin!
124  stripWeight[apv][strip] = 1;
125  APV.apvabsoluteOccupancy[apv] += (it->second.get())->GetBinContent((apv*128)+strip+1); // Remember: Bin=0 is underflow bin!
126  APV.th1f[apv]->SetBinContent(strip+1,(it->second.get())->GetBinContent((apv*128)+strip+1));
127  NumberEntriesPerAPV += (int)(it->second.get())->GetBinContent((apv*128)+strip+1);
128  }
129 
130  APV.th1f[apv]->SetEntries(NumberEntriesPerAPV);
131  APV.NEntries[apv]=(int)APV.th1f[apv]->GetEntries();
132  }
133 
134  for (int apv=0; apv<number_apvs; apv++)
135  {
136  APV.apvMedian[apv] = TMath::Median(128,stripOccupancy[apv],stripWeight[apv]);
137  }
138 
139  detid=it->first;
140  DetId detectorId=DetId(detid);
141 
142  if (edm::isDebugEnabled())
143  LogTrace("SiStripBadAPV") << "Analyzing detid " << detid<< std::endl;
144 
145  detrawid = detid;
146  APV.detrawId = detrawid;
147  subdetid = detectorId.subdetId();
148 
149  switch (detectorId.subdetId())
150  {
151  case StripSubdetector::TIB :
155 
156  if (layer_ring == 1) medianValues_TIB_Layer1.push_back(APV);
157  else if (layer_ring == 2) medianValues_TIB_Layer2.push_back(APV);
158  else if (layer_ring == 3) medianValues_TIB_Layer3.push_back(APV);
159  else if (layer_ring == 4) medianValues_TIB_Layer4.push_back(APV);
160  break;
161 
162  case StripSubdetector::TID :
166 
168  else iszminusside = 0;
169 
170  if (iszminusside==0)
171  {
172  if (disc==1) medianValues_TIDPlus_Disc1.push_back(APV);
173  else if (disc==2) medianValues_TIDPlus_Disc2.push_back(APV);
174  else if (disc==3) medianValues_TIDPlus_Disc3.push_back(APV);
175  }
176  else if (iszminusside==1)
177  {
178  if (disc==1) medianValues_TIDMinus_Disc1.push_back(APV);
179  else if (disc==2) medianValues_TIDMinus_Disc2.push_back(APV);
180  else if (disc==3) medianValues_TIDMinus_Disc3.push_back(APV);
181  }
182  break;
183 
184  case StripSubdetector::TOB :
188 
189  if (layer_ring == 1) medianValues_TOB_Layer1.push_back(APV);
190  else if (layer_ring == 2) medianValues_TOB_Layer2.push_back(APV);
191  else if (layer_ring == 3) medianValues_TOB_Layer3.push_back(APV);
192  else if (layer_ring == 4) medianValues_TOB_Layer4.push_back(APV);
193  else if (layer_ring == 5) medianValues_TOB_Layer5.push_back(APV);
194  else if (layer_ring == 6) medianValues_TOB_Layer6.push_back(APV);
195  break;
196 
197  case StripSubdetector::TEC :
201 
203  else iszminusside = 0;
204 
205  if (iszminusside==0)
206  {
207  if (disc==1) medianValues_TECPlus_Disc1.push_back(APV);
208  else if (disc==2) medianValues_TECPlus_Disc2.push_back(APV);
209  else if (disc==3) medianValues_TECPlus_Disc3.push_back(APV);
210  else if (disc==4) medianValues_TECPlus_Disc4.push_back(APV);
211  else if (disc==5) medianValues_TECPlus_Disc5.push_back(APV);
212  else if (disc==6) medianValues_TECPlus_Disc6.push_back(APV);
213  else if (disc==7) medianValues_TECPlus_Disc7.push_back(APV);
214  else if (disc==8) medianValues_TECPlus_Disc8.push_back(APV);
215  else if (disc==9) medianValues_TECPlus_Disc9.push_back(APV);
216  }
217  else if (iszminusside==1)
218  {
219  if (disc==1) medianValues_TECMinus_Disc1.push_back(APV);
220  else if (disc==2) medianValues_TECMinus_Disc2.push_back(APV);
221  else if (disc==3) medianValues_TECMinus_Disc3.push_back(APV);
222  else if (disc==4) medianValues_TECMinus_Disc4.push_back(APV);
223  else if (disc==5) medianValues_TECMinus_Disc5.push_back(APV);
224  else if (disc==6) medianValues_TECMinus_Disc6.push_back(APV);
225  else if (disc==7) medianValues_TECMinus_Disc7.push_back(APV);
226  else if (disc==8) medianValues_TECMinus_Disc8.push_back(APV);
227  else if (disc==9) medianValues_TECMinus_Disc9.push_back(APV);
228  }
229  break;
230 
231  default :
232  std::cout << "### Detector does not belong to TIB, TID, TOB or TEC !? ###" << std::endl;
233  std::cout << "### DetRawId: " << detrawid << " ###" << std::endl;
234  }
235 
236  } // end loop on modules
237 
238  // Calculate Mean and RMS for each Layer
243 
250 
257 
267 
277 
278  pQuality=siStripQuality;
279  badStripList.clear();
280 
281  // Initialize the DQM output histograms
283 
284  // Analyze the Occupancy for both APVs and Strips
285  AnalyzeOccupancy(siStripQuality,medianValues_TIB_Layer1,MeanAndRms_TIB_Layer1,badStripList,inSiStripQuality);
286  AnalyzeOccupancy(siStripQuality,medianValues_TIB_Layer2,MeanAndRms_TIB_Layer2,badStripList,inSiStripQuality);
287  AnalyzeOccupancy(siStripQuality,medianValues_TIB_Layer3,MeanAndRms_TIB_Layer3,badStripList,inSiStripQuality);
288  AnalyzeOccupancy(siStripQuality,medianValues_TIB_Layer4,MeanAndRms_TIB_Layer4,badStripList,inSiStripQuality);
289 
290  AnalyzeOccupancy(siStripQuality,medianValues_TOB_Layer1,MeanAndRms_TOB_Layer1,badStripList,inSiStripQuality);
291  AnalyzeOccupancy(siStripQuality,medianValues_TOB_Layer2,MeanAndRms_TOB_Layer2,badStripList,inSiStripQuality);
292  AnalyzeOccupancy(siStripQuality,medianValues_TOB_Layer3,MeanAndRms_TOB_Layer3,badStripList,inSiStripQuality);
293  AnalyzeOccupancy(siStripQuality,medianValues_TOB_Layer4,MeanAndRms_TOB_Layer4,badStripList,inSiStripQuality);
294  AnalyzeOccupancy(siStripQuality,medianValues_TOB_Layer5,MeanAndRms_TOB_Layer5,badStripList,inSiStripQuality);
295  AnalyzeOccupancy(siStripQuality,medianValues_TOB_Layer6,MeanAndRms_TOB_Layer6,badStripList,inSiStripQuality);
296 
297  AnalyzeOccupancy(siStripQuality,medianValues_TIDPlus_Disc1,MeanAndRms_TIDPlus_Disc1,badStripList,inSiStripQuality);
298  AnalyzeOccupancy(siStripQuality,medianValues_TIDPlus_Disc2,MeanAndRms_TIDPlus_Disc2,badStripList,inSiStripQuality);
299  AnalyzeOccupancy(siStripQuality,medianValues_TIDPlus_Disc3,MeanAndRms_TIDPlus_Disc3,badStripList,inSiStripQuality);
300  AnalyzeOccupancy(siStripQuality,medianValues_TIDMinus_Disc1,MeanAndRms_TIDMinus_Disc1,badStripList,inSiStripQuality);
301  AnalyzeOccupancy(siStripQuality,medianValues_TIDMinus_Disc2,MeanAndRms_TIDMinus_Disc2,badStripList,inSiStripQuality);
302  AnalyzeOccupancy(siStripQuality,medianValues_TIDMinus_Disc3,MeanAndRms_TIDMinus_Disc3,badStripList,inSiStripQuality);
303 
304  AnalyzeOccupancy(siStripQuality,medianValues_TECPlus_Disc1,MeanAndRms_TECPlus_Disc1,badStripList,inSiStripQuality);
305  AnalyzeOccupancy(siStripQuality,medianValues_TECPlus_Disc2,MeanAndRms_TECPlus_Disc2,badStripList,inSiStripQuality);
306  AnalyzeOccupancy(siStripQuality,medianValues_TECPlus_Disc3,MeanAndRms_TECPlus_Disc3,badStripList,inSiStripQuality);
307  AnalyzeOccupancy(siStripQuality,medianValues_TECPlus_Disc4,MeanAndRms_TECPlus_Disc4,badStripList,inSiStripQuality);
308  AnalyzeOccupancy(siStripQuality,medianValues_TECPlus_Disc5,MeanAndRms_TECPlus_Disc5,badStripList,inSiStripQuality);
309  AnalyzeOccupancy(siStripQuality,medianValues_TECPlus_Disc6,MeanAndRms_TECPlus_Disc6,badStripList,inSiStripQuality);
310  AnalyzeOccupancy(siStripQuality,medianValues_TECPlus_Disc7,MeanAndRms_TECPlus_Disc7,badStripList,inSiStripQuality);
311  AnalyzeOccupancy(siStripQuality,medianValues_TECPlus_Disc8,MeanAndRms_TECPlus_Disc8,badStripList,inSiStripQuality);
312  AnalyzeOccupancy(siStripQuality,medianValues_TECPlus_Disc9,MeanAndRms_TECPlus_Disc9,badStripList,inSiStripQuality);
313 
314  AnalyzeOccupancy(siStripQuality,medianValues_TECMinus_Disc1,MeanAndRms_TECMinus_Disc1,badStripList,inSiStripQuality);
315  AnalyzeOccupancy(siStripQuality,medianValues_TECMinus_Disc2,MeanAndRms_TECMinus_Disc2,badStripList,inSiStripQuality);
316  AnalyzeOccupancy(siStripQuality,medianValues_TECMinus_Disc3,MeanAndRms_TECMinus_Disc3,badStripList,inSiStripQuality);
317  AnalyzeOccupancy(siStripQuality,medianValues_TECMinus_Disc4,MeanAndRms_TECMinus_Disc4,badStripList,inSiStripQuality);
318  AnalyzeOccupancy(siStripQuality,medianValues_TECMinus_Disc5,MeanAndRms_TECMinus_Disc5,badStripList,inSiStripQuality);
319  AnalyzeOccupancy(siStripQuality,medianValues_TECMinus_Disc6,MeanAndRms_TECMinus_Disc6,badStripList,inSiStripQuality);
320  AnalyzeOccupancy(siStripQuality,medianValues_TECMinus_Disc7,MeanAndRms_TECMinus_Disc7,badStripList,inSiStripQuality);
321  AnalyzeOccupancy(siStripQuality,medianValues_TECMinus_Disc8,MeanAndRms_TECMinus_Disc8,badStripList,inSiStripQuality);
322  AnalyzeOccupancy(siStripQuality,medianValues_TECMinus_Disc9,MeanAndRms_TECMinus_Disc9,badStripList,inSiStripQuality);
323 
324  siStripQuality->fillBadComponents();
325 
326  // Fill DQM histograms
327  for(unsigned int i = 0; i < subDetName.size(); i++)
328  {
329  projYDistanceVsStripNumber[i]->Add((TH1F*)distanceVsStripNumber[i]->ProjectionY());
330  pfxDistanceVsStripNumber[i]->Add(distanceVsStripNumber[i]->ProfileX(pfxDistanceVsStripNumber[i]->GetName(),1,998));
331  projYNHitsVsStripNumber[i]->Add(nHitsVsStripNumber[i]->ProjectionY());
334  projYOccupancyVsStripNumber[i]->Add(occupancyVsStripNumber[i]->ProjectionY());
337  pfxOccupancyVsStripNumber[i]->Add(occupancyVsStripNumber[i]->ProfileX(pfxOccupancyVsStripNumber[i]->GetName(),-8.,0.));
346  projXDistanceVsStripNumber[i]->Add(distanceVsStripNumber[i]->ProjectionX(projXDistanceVsStripNumber[i]->GetName(),1,998));
347 
348  }
349 
350  // Save output files
351 
352  if (WriteOutputFile_==true){
353  f->cd();
354  apvtree->Write();
355  striptree->Write();
356  f->Close();
357  }
358 
359  if (WriteDQMHistograms_==true){
360  dqmStore->cd();
361  dqmStore->save(DQMOutfileName_.c_str());
362  }
363 
364  LogTrace("SiStripBadAPV") << ss.str() << std::endl;
365 }
366 
367 
368 void SiStripBadAPVandHotStripAlgorithmFromClusterOccupancy::CalculateMeanAndRMS(const std::vector<Apv>& a, std::pair<double,double>* MeanRMS, int number_iterations)
369 {
370  Double_t tot[7], tot2[7];
371  Double_t n[7];
372 
373  Double_t Mean[7] = {0};
374  Double_t Rms[7] = {1000,1000,1000,1000,1000,1000,1000};
375 
376  int Moduleposition;
377 
378  for (int i=0; i<number_iterations; i++)
379  {
380  for (int j=0; j<7; j++)
381  {
382  n[j] = 0;
383  tot[j] = 0;
384  tot2[j] = 0;
385  }
386 
387  for (uint32_t it=0; it<a.size(); it++)
388  {
389  Moduleposition = (a[it].modulePosition)-1;
390 
391  for (int apv=0; apv<a[it].numberApvs; apv++)
392  {
393  if (i>0)
394  {
395  if (a[it].apvMedian[apv]<(Mean[Moduleposition]-3*Rms[Moduleposition]) || (a[it].apvMedian[apv]>(Mean[Moduleposition]+5*Rms[Moduleposition])))
396  {
397  continue;
398  }
399  }
400  tot[Moduleposition] += a[it].apvMedian[apv];
401  tot2[Moduleposition] += (a[it].apvMedian[apv])*(a[it].apvMedian[apv]);
402  n[Moduleposition]++;
403  }
404  }
405 
406  for (int j=0; j<7; j++)
407  {
408  if (n[j]!=0)
409  {
410  Mean[j] = tot[j]/n[j];
411  Rms[j] = TMath::Sqrt(TMath::Abs(tot2[j]/n[j] -Mean[j]*Mean[j]));
412  }
413  }
414  }
415 
416  for (int j=0; j<7; j++)
417  {
418  MeanRMS[j] = std::make_pair(Mean[j],Rms[j]);
419  }
420 
421 }
422 
423 void SiStripBadAPVandHotStripAlgorithmFromClusterOccupancy::AnalyzeOccupancy(SiStripQuality* quality, std::vector<Apv>& medianValues, std::pair<double,double>* MeanAndRms, std::vector<unsigned int>& BadStripList, edm::ESHandle<SiStripQuality>& InSiStripQuality)
424 {
425  int Moduleposition;
426  uint32_t Detid;
427 
428  for (uint32_t it=0; it<medianValues.size(); it++)
429  {
430  Moduleposition = (medianValues[it].modulePosition)-1;
431  Detid = medianValues[it].detrawId;
432 
433  setBasicTreeParameters(Detid);
434 
435  DetId DetectorId=DetId(Detid);
436  const StripGeomDetUnit* TheStripDet = dynamic_cast<const StripGeomDetUnit*>( (TkGeom->idToDet(DetectorId)) );
437  const StripTopology* TheStripTopol = dynamic_cast<const StripTopology*>( &(TheStripDet->specificTopology()) );
438 
439  //Analyze the occupancies
440  hotstripspermodule = 0;
441  vHotStripsInModule.clear();
442 
443  for (int apv=0; apv<medianValues[it].numberApvs; apv++)
444  {
445  double logMedianOccupancy = -1;
446  double logAbsoluteOccupancy = -1;
447 
448  for (int i=0; i<128; i++)
449  {
450  ishot[i] = 0;
451  stripoccupancy[i] = 0;
452  striphits[i] = 0;
453  poissonprob[i] = 0;
454  }
455 
456  number_strips = (medianValues[it].numberApvs)*128;
457  apv_number = apv+1;
458  apvMedianOccupancy = medianValues[it].apvMedian[apv];
459  apvAbsoluteOccupancy = medianValues[it].apvabsoluteOccupancy[apv];
460  isBad = 0;
461  hotstripsperapv[apv] = 0;
462 
463  LocalPoint pos_apv_local = TheStripTopol->localPosition((apv*128));
464  GlobalPoint pos_apv_global = (TkGeom->idToDet(DetectorId))->surface().toGlobal(pos_apv_local);
465 
466  global_position_x = pos_apv_global.x();
467  global_position_y = pos_apv_global.y();
468  global_position_z = pos_apv_global.z();
469 
470  if (apvMedianOccupancy>0) logMedianOccupancy = log10(apvMedianOccupancy);
471  if (apvAbsoluteOccupancy>0) logAbsoluteOccupancy = log10(apvAbsoluteOccupancy);
472 
473  //Fill the DQM histograms
474  unsigned int layer = 0;
475  if(subdetid==3 || subdetid==5)
476  layer=layer_ring;
477  else
478  layer=disc;
479 
480  // Fill histograms for all the tracker
481  medianVsAbsoluteOccupancy[0][0]->Fill(logAbsoluteOccupancy,logMedianOccupancy);
482  medianOccupancy[0][0]->Fill(logMedianOccupancy);
483  absoluteOccupancy[0][0]->Fill(logAbsoluteOccupancy);
484  // Fill summary histograms for each subdetector
485  medianVsAbsoluteOccupancy[subdetid-2][0]->Fill(logAbsoluteOccupancy,logMedianOccupancy);
486  medianOccupancy[subdetid-2][0]->Fill(logMedianOccupancy);
487  absoluteOccupancy[subdetid-2][0]->Fill(logAbsoluteOccupancy);
488  // Fill histograms for each layer/disk
489  medianVsAbsoluteOccupancy[subdetid-2][layer]->Fill(logAbsoluteOccupancy,logMedianOccupancy);
490  medianOccupancy[subdetid-2][layer]->Fill(logMedianOccupancy);
491  absoluteOccupancy[subdetid-2][layer]->Fill(logAbsoluteOccupancy);
492 
493  if(UseInputDB_)
494  {
495  if(InSiStripQuality->IsApvBad(Detid,apv) )
496  {
497  if (WriteOutputFile_==true)
498  {
499  apvtree->Fill();
500  for (int strip=0; strip<128; strip++)
501  {
502  strip_number = (apv*128)+strip+1;
503  apv_channel = apv+1;
504  isHot = ishot[strip];
506  stripHits = striphits[strip];
507  poissonProb = poissonprob[strip];
508 
511 
512  LocalPoint pos_strip_local = TheStripTopol->localPosition(strip);
513  GlobalPoint pos_strip_global = (TkGeom->idToDet(DetectorId))->surface().toGlobal(pos_strip_local);
514 
515  strip_global_position_x = pos_strip_global.x();
516  strip_global_position_y = pos_strip_global.y();
517  strip_global_position_z = pos_strip_global.z();
518  striptree->Fill();
519 
520  // Fill the strip DQM Plots
522  }
523 
524  if(vHotStripsInModule.size()==1)
525  {
526  distance = 999;
529  }
530  else if(vHotStripsInModule.size()>1)
531  {
532  for(unsigned int iVec = 0; iVec != vHotStripsInModule.size(); iVec++)
533  {
534  if(iVec==0)
536  else if(iVec==vHotStripsInModule.size()-1)
537  {
538  distance = vHotStripsInModule[vHotStripsInModule.size()-1] - vHotStripsInModule[vHotStripsInModule.size() -2];
539  }
540  else if(vHotStripsInModule.size()>2)
541  {
542  distanceR = vHotStripsInModule[iVec + 1] - vHotStripsInModule[iVec];
543  distanceL = vHotStripsInModule[iVec] - vHotStripsInModule[iVec - 1];
545  }
546  else
547  {
548  std::cout << "ERROR! distance is never computed!!!\n";
549  }
550  distanceVsStripNumber[0]->Fill(vHotStripsInModule[iVec], distance);
551  distanceVsStripNumber[subdetid-2]->Fill(vHotStripsInModule[iVec], distance);
552  }
553  }
554 
555  }
556  continue;//if the apv is already flagged as bad, continue.
557  }
558  }
559 
560  if (medianValues[it].apvMedian[apv] > minNevents_)
561  {
562  if ((medianValues[it].apvMedian[apv]>(MeanAndRms[Moduleposition].first+highoccupancy_*MeanAndRms[Moduleposition].second)) && (medianValues[it].apvMedian[apv]>absolutelow_))
563  {
564  BadStripList.push_back(pQuality->encode((apv*128),128,0));
565  isBad = 1;
566  }
567  }
568  else if (medianValues[it].apvMedian[apv]<(MeanAndRms[Moduleposition].first-lowoccupancy_*MeanAndRms[Moduleposition].second) && (MeanAndRms[Moduleposition].first>2 || medianValues[it].apvabsoluteOccupancy[apv]==0))
569  {
570  BadStripList.push_back(pQuality->encode((apv*128),128,0));
571  isBad = 1;
572  }
573 
574  if (isBad!=1)
575  {
576  iterativeSearch(medianValues[it],BadStripList,apv);
577  }
578 
579  if (WriteOutputFile_==true)
580  {
581  apvtree->Fill();
582  for (int strip=0; strip<128; strip++)
583  {
584  strip_number = (apv*128)+strip+1;
585  apv_channel = apv+1;
586  isHot = ishot[strip];
588  stripHits = striphits[strip];
589  poissonProb = poissonprob[strip];
590 
593 
594  LocalPoint pos_strip_local = TheStripTopol->localPosition(strip);
595  GlobalPoint pos_strip_global = (TkGeom->idToDet(DetectorId))->surface().toGlobal(pos_strip_local);
596 
597  strip_global_position_x = pos_strip_global.x();
598  strip_global_position_y = pos_strip_global.y();
599  strip_global_position_z = pos_strip_global.z();
600  striptree->Fill();
601 
602  // Fill the strip DQM Plots
604  }
605  if(vHotStripsInModule.size()==1)
606  {
607  distance = 999;
610  }
611  else if(vHotStripsInModule.size()>1)
612  {
613  for(unsigned int iVec = 0; iVec != vHotStripsInModule.size(); iVec++)
614  {
615  if(iVec==0)
617  else if(iVec==vHotStripsInModule.size()-1)
618  {
619  distance = vHotStripsInModule[vHotStripsInModule.size()-1] - vHotStripsInModule[vHotStripsInModule.size() -2];
620  }
621  else if(vHotStripsInModule.size()>2)
622  {
623  distanceR = vHotStripsInModule[iVec + 1] - vHotStripsInModule[iVec];
624  distanceL = vHotStripsInModule[iVec] - vHotStripsInModule[iVec - 1];
626  }
627  else
628  {
629  std::cout << "ERROR! distance is never computed!!!\n";
630  }
631  distanceVsStripNumber[0]->Fill(vHotStripsInModule[iVec], distance);
632  distanceVsStripNumber[subdetid-2]->Fill(vHotStripsInModule[iVec], distance);
633  }
634  }
635  }
636  }
637 
638  if (BadStripList.begin()!=BadStripList.end())
639  {
640  quality->compact(Detid,BadStripList);
641  SiStripQuality::Range range(BadStripList.begin(),BadStripList.end());
642  quality->put(Detid,range);
643  }
644  BadStripList.clear();
645  }
646 }
647 
649  if (!histo.NEntries[apv] || histo.NEntries[apv] <=MinNumEntries_ || histo.NEntries[apv] <= minNevents_)
650  return;
651 
652  size_t startingSize=vect.size();
653  long double diff=1.-prob_;
654 
655  size_t Nbins = histo.th1f[apv]->GetNbinsX();
656  size_t ibinStart = 1;
657  size_t ibinStop = Nbins+1;
658  int MaxEntry = (int)histo.th1f[apv]->GetMaximum();
659 
660  std::vector<long double> vPoissonProbs(MaxEntry+1,0);
661  long double meanVal=1.*histo.NEntries[apv]/(1.*Nbins-histo.NEmptyBins[apv]);
662  evaluatePoissonian(vPoissonProbs,meanVal);
663 
664  // Find median occupancy, taking into account only good strips
665  unsigned int goodstripentries[128];
666  int nGoodStrips = 0;
667  for (size_t i=ibinStart; i<ibinStop; ++i){
668  if (ishot[(apv*128)+i-1]==0){
669  goodstripentries[nGoodStrips] = (unsigned int)histo.th1f[apv]->GetBinContent(i);
670  nGoodStrips++;
671  }
672  }
673  double median = TMath::Median(nGoodStrips,goodstripentries);
674 
675  for (size_t i=ibinStart; i<ibinStop; ++i){
676  unsigned int entries= (unsigned int)histo.th1f[apv]->GetBinContent(i);
677 
678  if (ishot[i-1]==0){
679  stripoccupancy[i-1] = entries/(double) Nevents_;
680  striphits[i-1] = entries;
681  poissonprob[i-1] = 1-vPoissonProbs[entries];
682  medianapvhits[apv] = median;
683  avgapvhits[apv] = meanVal;
684  }
685 
686  if (entries<=MinNumEntriesPerStrip_ || entries <= minNevents_ || entries / median < ratio_) continue;
687 
688  if(diff<vPoissonProbs[entries]){
689  ishot[i-1] = 1;
691  hotstripsperapv[apv]++;
692  histo.th1f[apv]->SetBinContent(i,0.);
693  histo.NEntries[apv]-=entries;
694  histo.NEmptyBins[apv]++;
695  if (edm::isDebugEnabled())
696  LogTrace("SiStripHotStrip")<< " rejecting strip " << (apv*128)+i-1 << " value " << entries << " diff " << diff << " prob " << vPoissonProbs[entries]<< std::endl;
697  vect.push_back(pQuality->encode((apv*128)+i-1,1,0));
698  }
699 
700  }
701  if (edm::isDebugEnabled())
702  LogTrace("SiStripHotStrip") << " [SiStripHotStripAlgorithmFromClusterOccupancy::iterativeSearch] Nbins="<< Nbins << " MaxEntry="<<MaxEntry << " meanVal=" << meanVal << " NEmptyBins="<<histo.NEmptyBins[apv]<< " NEntries=" << histo.NEntries[apv] << " thEntries " << histo.th1f[apv]->GetEntries()<< " startingSize " << startingSize << " vector.size " << vect.size() << std::endl;
703 
704  if (vect.size()!=startingSize)
705  iterativeSearch(histo,vect,apv);
706 }
707 
708 void SiStripBadAPVandHotStripAlgorithmFromClusterOccupancy::evaluatePoissonian(std::vector<long double>& vPoissonProbs, long double& meanVal){
709  for(size_t i=0;i<vPoissonProbs.size();++i){
710  vPoissonProbs[i]= (i==0)?TMath::Poisson(i,meanVal):vPoissonProbs[i-1]+TMath::Poisson(i,meanVal);
711  }
712 }
713 
715  DetId DetectorID=DetId(detid);
716 
717  detrawid = detid;
718  subdetid = DetectorID.subdetId();
719 
720  switch (DetectorID.subdetId())
721  {
722  case StripSubdetector::TIB :
723  layer_ring = tTopo->tibLayer(detid);
724  disc = -1;
725  isstereo = tTopo->tibIsStereo(detid);
726  isback = -1;
727  if (tTopo->tibIsExternalString(detid)) isexternalstring = 1;
728  else isexternalstring = 0;
729  if (tTopo->tibIsZMinusSide(detid)) iszminusside = 1;
730  else iszminusside = 0;
731  rodstringpetal = tTopo->tibString(detid);
732  module_number = tTopo->tibModule(detid);
733 
734  break;
735 
736  case StripSubdetector::TID :
737  layer_ring = tTopo->tidRing(detid);
738  disc = tTopo->tidWheel(detid);
739  isstereo = tTopo->tidIsStereo(detid);
740  if (tTopo->tidIsBackRing(detid)) isback = 1;
741  else isback = 0;
742  if (tTopo->tidIsZMinusSide(detid)) iszminusside = 1;
743  else iszminusside = 0;
744  isexternalstring = -1;
745  rodstringpetal = -1;
746  module_number = tTopo->tidModule(detid);
747 
748  break;
749 
750  case StripSubdetector::TOB :
751  layer_ring = tTopo->tobLayer(detid);
752  disc = -1;
753  isstereo = tTopo->tobIsStereo(detid);
754  isback = -1;
755  if (tTopo->tobIsZMinusSide(detid)) iszminusside = 1;
756  else iszminusside = 0;
757  isexternalstring = -1;
758  rodstringpetal = tTopo->tobRod(detid);
759  module_number = tTopo->tobModule(detid);
760 
761  break;
762 
763  case StripSubdetector::TEC :
764  layer_ring = tTopo->tecRing(detid);
765  disc = tTopo->tecWheel(detid);
766  isstereo = tTopo->tecIsStereo(detid);
767  if (tTopo->tecIsBackPetal(detid)) isback = 1;
768  else isback = 0;
769  if (tTopo->tecIsZMinusSide(detid)) iszminusside = 1;
770  else iszminusside = 0;
771  isexternalstring = -1;
773  module_number = tTopo->tecModule(detid);
774 
775  break;
776 
777  default :
778  std::cout << "### Detector does not belong to TIB, TID, TOB or TEC !? ###" << std::endl;
779  std::cout << "### DetRawId: " << detid << " ###" << std::endl;
780  }
781 }
782 
784 {
786 }
787 
789 {
790  oss.str("");
791  oss << 1; //runNumber
792 
794  dqmStore->setCurrentFolder("ChannelStatusPlots");
795 
796  // Initialize histograms
797  subDetName.push_back(""); subDetName.push_back("TIB"); subDetName.push_back("TID"); subDetName.push_back("TOB"); subDetName.push_back("TEC");
798  nLayers.push_back(0); nLayers.push_back(4); nLayers.push_back(3); nLayers.push_back(6); nLayers.push_back(9);
799  layerName.push_back(""); layerName.push_back("Layer"); layerName.push_back("Disk"); layerName.push_back("Layer"); layerName.push_back("Disk");
800 
801  std::string histoName;
802  std::string histoTitle;
803 
804  for(unsigned int i = 0; i < subDetName.size(); i++)
805  {
806  histoName = "distanceVsStripNumber" + subDetName[i];
807  histoTitle = "Distance between hot strips vs. strip number";
808  if(i!=0)
809  histoTitle += " in " + subDetName[i];
810  tmp = dqmStore->book2D(histoName.c_str(), histoTitle.c_str(), 768, 0.5, 768.5, 999, 0.5, 999.5);
811  distanceVsStripNumber.push_back(tmp->getTH2F());
812 
813  histoName = "pfxDistanceVsStripNumber" + subDetName[i];
814  tmp_prof = new TProfile(histoName.c_str(), histoTitle.c_str(), 768, 0.5, 768.5);
815  tmp = dqmStore->bookProfile(histoName.c_str(), tmp_prof);
817  pfxDistanceVsStripNumber[i]->GetXaxis()->SetTitle("Strip");
818  pfxDistanceVsStripNumber[i]->GetYaxis()->SetTitle("Distance");
819 
820  histoName = "projXDistanceVsStripNumber" + subDetName[i];
821  histoTitle = "Number of hot strips vs. strip number";
822  if(i!=0)
823  histoTitle += " in " + subDetName[i];
824  tmp = dqmStore->book1D(histoName.c_str(), histoTitle.c_str(), 768, 0.5, 768.5);
825  projXDistanceVsStripNumber.push_back(tmp->getTH1F());
826  projXDistanceVsStripNumber[i]->GetXaxis()->SetTitle("Strip");
827  projXDistanceVsStripNumber[i]->GetYaxis()->SetTitle("N_{hot}");
828 
829  histoName = "projYDistanceVsStripNumber" + subDetName[i];
830  histoTitle = "Distribution of distance between hot strips";
831  if(i!=0)
832  histoTitle += " in " + subDetName[i];
833  tmp = dqmStore->book1D(histoName.c_str(), histoTitle.c_str(), 999, 0.5, 999.5);
834  projYDistanceVsStripNumber.push_back(tmp->getTH1F());
835  projYDistanceVsStripNumber[i]->GetXaxis()->SetTitle("Distance");
836  projYDistanceVsStripNumber[i]->GetYaxis()->SetTitle("N_{strips}");
837 
838  //
839  histoName = "occupancyVsStripNumber" + subDetName[i];
840  histoTitle = "Occupancy of strips vs. strip number";
841  if(i!=0)
842  histoTitle += " in " + subDetName[i];
843  tmp = dqmStore->book2D(histoName.c_str(), histoTitle.c_str(), 768, 0.5, 768.5, 1000, -8.,0.);
844  occupancyVsStripNumber.push_back(tmp->getTH2F());
845 
846  histoName = "pfxOccupancyVsStripNumber" + subDetName[i];
847  tmp_prof = new TProfile(histoName.c_str(), histoTitle.c_str(), 768, 0.5, 768.5);
848  tmp = dqmStore->bookProfile(histoName.c_str(), tmp_prof);
850  pfxOccupancyVsStripNumber[i]->GetXaxis()->SetTitle("Strip");
851  pfxOccupancyVsStripNumber[i]->GetYaxis()->SetTitle("log_{10}(Occupancy)");
852 
853  histoName = "projYOccupancyVsStripNumber" + subDetName[i];
854  histoTitle = "Distribution of strip occupancy";
855  if(i!=0)
856  histoTitle += " in " + subDetName[i];
857  tmp = dqmStore->book1D(histoName.c_str(), histoTitle.c_str(), 1000, -8., 0.);
859  projYOccupancyVsStripNumber[i]->GetXaxis()->SetTitle("log_{10}(Occupancy)");
860  projYOccupancyVsStripNumber[i]->GetYaxis()->SetTitle("N_{strips}");
861 
862  //
863  histoName = "occupancyHotStripsVsStripNumber" + subDetName[i];
864  histoTitle = "Occupancy of hot strips vs. strip number";
865  if(i!=0)
866  histoTitle += " in " + subDetName[i];
867  tmp = dqmStore->book2D(histoName.c_str(), histoTitle.c_str(), 768, 0.5, 768.5, 1000, -8., 0.);
869 
870  histoName = "pfxOccupancyHotStripsVsStripNumber" + subDetName[i];
871  tmp_prof = new TProfile(histoName.c_str(), histoTitle.c_str(), 768, 0.5, 768.5);
872  tmp = dqmStore->bookProfile(histoName.c_str(), tmp_prof);
874  pfxOccupancyHotStripsVsStripNumber[i]->GetXaxis()->SetTitle("Strip");
875  pfxOccupancyHotStripsVsStripNumber[i]->GetYaxis()->SetTitle("log_{10}(Occupancy)");
876 
877  histoName = "projYOccupancyHotStripsVsStripNumber" + subDetName[i];
878  histoTitle = "Distribution of hot strip occupancy";
879  if(i!=0)
880  histoTitle += " in " + subDetName[i];
881  tmp = dqmStore->book1D(histoName.c_str(), histoTitle.c_str(), 1000, -8., 0.);
883  projYOccupancyHotStripsVsStripNumber[i]->GetXaxis()->SetTitle("log_{10}(Occupancy)");
884  projYOccupancyHotStripsVsStripNumber[i]->GetYaxis()->SetTitle("N_{strips}");
885 
886  //
887  histoName = "occupancyGoodStripsVsStripNumber" + subDetName[i];
888  histoTitle = "Occupancy of good strips vs. strip number";
889  if(i!=0)
890  histoTitle += " in " + subDetName[i];
891  tmp = dqmStore->book2D(histoName.c_str(), histoTitle.c_str(), 768, 0.5, 768.5, 1000, -8., 0.);
893 
894  histoName = "pfxOccupancyGoodStripsVsStripNumber" + subDetName[i];
895  tmp_prof = new TProfile(histoName.c_str(), histoTitle.c_str(), 768, 0.5, 768.5);
896  tmp = dqmStore->bookProfile(histoName.c_str(), tmp_prof);
898  pfxOccupancyGoodStripsVsStripNumber[i]->GetXaxis()->SetTitle("Strip");
899  pfxOccupancyGoodStripsVsStripNumber[i]->GetYaxis()->SetTitle("log_{10}(Occupancy)");
900 
901  histoName = "projYOccupancyGoodStripsVsStripNumber" + subDetName[i];
902  histoTitle = "Distribution of good strip occupancy";
903  if(i!=0)
904  histoTitle += " in " + subDetName[i];
905  tmp = dqmStore->book1D(histoName.c_str(), histoTitle.c_str(), 1000, -8., 0.);
907  projYOccupancyGoodStripsVsStripNumber[i]->GetXaxis()->SetTitle("log_{10}(Occupancy)");
908  projYOccupancyGoodStripsVsStripNumber[i]->GetYaxis()->SetTitle("N_{strips}");
909 
910  //
911  histoName = "poissonProbVsStripNumber" + subDetName[i];
912  histoTitle = "Poisson probability of strips vs. strip number";
913  if(i!=0)
914  histoTitle += " in " + subDetName[i];
915  tmp = dqmStore->book2D(histoName.c_str(), histoTitle.c_str(), 768, 0.5, 768.5, 1000, -18., 0.);
916  poissonProbVsStripNumber.push_back(tmp->getTH2F());
917 
918  histoName = "pfxPoissonProbVsStripNumber" + subDetName[i];
919  tmp_prof = new TProfile(histoName.c_str(), histoTitle.c_str(), 768, 0.5, 768.5);
920  tmp = dqmStore->bookProfile(histoName.c_str(), tmp_prof);
922  pfxPoissonProbVsStripNumber[i]->GetXaxis()->SetTitle("Strip");
923  pfxPoissonProbVsStripNumber[i]->GetYaxis()->SetTitle("log_{10}(Probability)");
924 
925  histoName = "projYPoissonProbVsStripNumber" + subDetName[i];
926  histoTitle = "Distribution of strip Poisson probability";
927  if(i!=0)
928  histoTitle += " in " + subDetName[i];
929  tmp = dqmStore->book1D(histoName.c_str(), histoTitle.c_str(), 1000, -18., 0.);
931  projYPoissonProbVsStripNumber[i]->GetXaxis()->SetTitle("log_{10}(Probability)");
932  projYPoissonProbVsStripNumber[i]->GetYaxis()->SetTitle("N_{strips}");
933 
934  //
935  histoName = "poissonProbHotStripsVsStripNumber" + subDetName[i];
936  histoTitle = "Poisson probability of hot strips vs. strip number";
937  if(i!=0)
938  histoTitle += " in " + subDetName[i];
939  tmp = dqmStore->book2D(histoName.c_str(), histoTitle.c_str(), 768, 0.5, 768.5, 1000, -18., 0.);
941 
942  histoName = "pfxPoissonProbHotStripsVsStripNumber" + subDetName[i];
943  tmp_prof = new TProfile(histoName.c_str(), histoTitle.c_str(), 768, 0.5, 768.5);
944  tmp = dqmStore->bookProfile(histoName.c_str(), tmp_prof);
946  pfxPoissonProbHotStripsVsStripNumber[i]->GetXaxis()->SetTitle("Strip");
947  pfxPoissonProbHotStripsVsStripNumber[i]->GetYaxis()->SetTitle("log_{10}(Probability)");
948 
949  histoName = "projYPoissonProbHotStripsVsStripNumber" + subDetName[i];
950  histoTitle = "Distribution of hot strip Poisson probability";
951  if(i!=0)
952  histoTitle += " in " + subDetName[i];
953  tmp = dqmStore->book1D(histoName.c_str(), histoTitle.c_str(), 1000, -18., 0.);
955  projYPoissonProbHotStripsVsStripNumber[i]->GetXaxis()->SetTitle("log_{10}(Probability)");
956  projYPoissonProbHotStripsVsStripNumber[i]->GetYaxis()->SetTitle("N_{strips}");
957 
958  //
959  histoName = "poissonProbGoodStripsVsStripNumber" + subDetName[i];
960  histoTitle = "Poisson probability of good strips vs. strip number";
961  if(i!=0)
962  histoTitle += " in " + subDetName[i];
963  tmp = dqmStore->book2D(histoName.c_str(), histoTitle.c_str(), 768, 0.5, 768.5, 1000, -18., 0.);
965 
966  histoName = "pfxPoissonProbGoodStripsVsStripNumber" + subDetName[i];
967  tmp_prof = new TProfile(histoName.c_str(), histoTitle.c_str(), 768, 0.5, 768.5);
968  tmp = dqmStore->bookProfile(histoName.c_str(), tmp_prof);
970  pfxPoissonProbGoodStripsVsStripNumber[i]->GetXaxis()->SetTitle("Strip");
971  pfxPoissonProbGoodStripsVsStripNumber[i]->GetYaxis()->SetTitle("log_{10}(Probability)");
972 
973  histoName = "projYPoissonProbGoodStripsVsStripNumber" + subDetName[i];
974  histoTitle = "Distribution of good strip Poisson probability";
975  if(i!=0)
976  histoTitle += " in " + subDetName[i];
977  tmp = dqmStore->book1D(histoName.c_str(), histoTitle.c_str(), 1000, -18., 0.);
979  projYPoissonProbGoodStripsVsStripNumber[i]->GetXaxis()->SetTitle("log_{10}(Probability)");
980  projYPoissonProbGoodStripsVsStripNumber[i]->GetYaxis()->SetTitle("N_{strips}");
981 
982  //
983  histoName = "nHitsVsStripNumber" + subDetName[i];
984  histoTitle = "NHits in strips vs. strip number";
985  if(i!=0)
986  histoTitle += " in " + subDetName[i];
987  tmp = dqmStore->book2D(histoName.c_str(), histoTitle.c_str(), 768, 0.5, 768.5, 10000, -0.5, 9999.5);
988  nHitsVsStripNumber.push_back(tmp->getTH2F());
989 
990  histoName = "pfxNHitsVsStripNumber" + subDetName[i];
991  tmp_prof = new TProfile(histoName.c_str(), histoTitle.c_str(), 768, 0.5, 768.5);
992  tmp = dqmStore->bookProfile(histoName.c_str(), tmp_prof);
993  pfxNHitsVsStripNumber.push_back(tmp->getTProfile());
994 
995  histoName = "projXNHitsVsStripNumber" + subDetName[i];
996  histoTitle = "Cumulative nHits in strips vs. strip number";
997  if(i!=0)
998  histoTitle += " in " + subDetName[i];
999  tmp = dqmStore->book1D(histoName.c_str(), histoTitle.c_str(), 768, 0.5, 768.5);
1000  projXNHitsVsStripNumber.push_back(tmp->getTH1F());
1001 
1002  histoName = "projYNHitsVsStripNumber" + subDetName[i];
1003  histoTitle = "Distribution of nHits for all strips";
1004  if(i!=0)
1005  histoTitle += " in " + subDetName[i];
1006  tmp = dqmStore->book1D(histoName.c_str(), histoTitle.c_str(), 10000, -0.5, 9999.5);
1007  projYNHitsVsStripNumber.push_back(tmp->getTH1F());
1008  projYNHitsVsStripNumber[i]->GetXaxis()->SetTitle("N_{hits}");
1009  projYNHitsVsStripNumber[i]->GetYaxis()->SetTitle("N_{strips}");
1010 
1011  //
1012  histoName = "nHitsHotStripsVsStripNumber" + subDetName[i];
1013  histoTitle = "NHits in hot strips vs. strip number";
1014  if(i!=0)
1015  histoTitle += " in " + subDetName[i];
1016  tmp = dqmStore->book2D(histoName.c_str(), histoTitle.c_str(), 768, 0.5, 768.5, 10000, -0.5, 9999.5);
1017  nHitsHotStripsVsStripNumber.push_back(tmp->getTH2F());
1018 
1019  histoName = "pfxNHitsHotStripsVsStripNumber" + subDetName[i];
1020  tmp_prof = new TProfile(histoName.c_str(), histoTitle.c_str(), 768, 0.5, 768.5);
1021  tmp = dqmStore->bookProfile(histoName.c_str(), tmp_prof);
1023 
1024  histoName = "projXNHitsHotStripsVsStripNumber" + subDetName[i];
1025  histoTitle = "Cumulative nHits in hot strips vs. strip number";
1026  if(i!=0)
1027  histoTitle += " in " + subDetName[i];
1028  tmp = dqmStore->book1D(histoName.c_str(), histoTitle.c_str(), 768, 0.5, 768.5);
1030 
1031  histoName = "projYNHitsHotStripsVsStripNumber" + subDetName[i];
1032  histoTitle = "Distribution of nHits for hot strips";
1033  if(i!=0)
1034  histoTitle += " in " + subDetName[i];
1035  tmp = dqmStore->book1D(histoName.c_str(), histoTitle.c_str(), 10000, -0.5, 9999.5);
1037  projYNHitsHotStripsVsStripNumber[i]->GetXaxis()->SetTitle("N_{hits}");
1038  projYNHitsHotStripsVsStripNumber[i]->GetYaxis()->SetTitle("N_{strips}");
1039 
1040  //
1041  histoName = "nHitsGoodStripsVsStripNumber" + subDetName[i];
1042  histoTitle = "NHits in good strips vs. strip number";
1043  if(i!=0)
1044  histoTitle += " in " + subDetName[i];
1045  tmp = dqmStore->book2D(histoName.c_str(), histoTitle.c_str(), 768, 0.5, 768.5, 10000, -0.5, 9999.5);
1047 
1048  histoName = "pfxNHitsGoodStripsVsStripNumber" + subDetName[i];
1049  tmp_prof = new TProfile(histoName.c_str(), histoTitle.c_str(), 768, 0.5, 768.5);
1050  tmp = dqmStore->bookProfile(histoName.c_str(), tmp_prof);
1052 
1053  histoName = "projXNHitsGoodStripsVsStripNumber" + subDetName[i];
1054  histoTitle = "Cumulative nHits in good strips vs. strip number";
1055  if(i!=0)
1056  histoTitle += " in " + subDetName[i];
1057  tmp = dqmStore->book1D(histoName.c_str(), histoTitle.c_str(), 768, 0.5, 768.5);
1059 
1060  histoName = "projYNHitsGoodStripsVsStripNumber" + subDetName[i];
1061  histoTitle = "Distribution of nHits for good strips";
1062  if(i!=0)
1063  histoTitle += " in " + subDetName[i];
1064  tmp = dqmStore->book1D(histoName.c_str(), histoTitle.c_str(), 10000, -0.5, 9999.5);
1066  projYNHitsGoodStripsVsStripNumber[i]->GetXaxis()->SetTitle("N_{hits}");
1067  projYNHitsGoodStripsVsStripNumber[i]->GetYaxis()->SetTitle("N_{strips}");
1068 
1069  for(unsigned int j = 0; j <= nLayers[i]; j++)
1070  {
1071  histoName = "medianVsAbsoluteOccupancy" + subDetName[i];
1072  if(j!=0)
1073  {
1074  oss.str("");
1075  oss << j;
1076  histoName += layerName[i] + oss.str();
1077  }
1078  histoTitle = "Median APV occupancy vs. absolute APV occupancy";
1079  if(i!=0)
1080  histoTitle += " in " + subDetName[i];
1081  if(j!=0)
1082  {
1083  histoTitle += " " + layerName[i] + " " + oss.str();
1084  }
1085  tmp = dqmStore->book2D(histoName.c_str(), histoTitle.c_str(), 1000, 0., 6., 1000, -1., 3.);
1087  medianVsAbsoluteOccupancy[i][j]->Rebin2D(10,10);
1088  medianVsAbsoluteOccupancy[i][j]->GetXaxis()->SetTitle("log_{10}(Abs. Occupancy)");
1089  medianVsAbsoluteOccupancy[i][j]->GetYaxis()->SetTitle("log_{10}(Median Occupancy)");
1090  //
1091  histoName = "medianOccupancy" + subDetName[i];
1092  if(j!=0)
1093  {
1094  oss.str("");
1095  oss << j;
1096  histoName += layerName[i] + oss.str();
1097  }
1098  histoTitle = "Median APV occupancy";
1099  if(i!=0)
1100  histoTitle += " in " + subDetName[i];
1101  if(j!=0)
1102  {
1103  histoTitle += " " + layerName[i] + " " + oss.str();
1104  }
1105  tmp = dqmStore->book1D(histoName.c_str(), histoTitle.c_str(), 1000, -1., 3.);
1106  medianOccupancy[i][j] = tmp->getTH1F();
1107  medianOccupancy[i][j]->GetXaxis()->SetTitle("log_{10}(Occupancy)");
1108  medianOccupancy[i][j]->GetYaxis()->SetTitle("APVs");
1109  //
1110  histoName = "absoluteOccupancy" + subDetName[i];
1111  if(j!=0)
1112  {
1113  oss.str("");
1114  oss << j;
1115  histoName += layerName[i] + oss.str();
1116  }
1117  histoTitle = "Absolute APV occupancy";
1118  if(i!=0)
1119  histoTitle += " in " + subDetName[i];
1120  if(j!=0)
1121  {
1122  histoTitle += " " + layerName[i] + " " + oss.str();
1123  }
1124  tmp = dqmStore->book1D(histoName.c_str(), histoTitle.c_str(), 1000, 0., 6.);
1125  absoluteOccupancy[i][j] = tmp->getTH1F();
1126  absoluteOccupancy[i][j]->GetXaxis()->SetTitle("log_{10}(Occupancy)");
1127  absoluteOccupancy[i][j]->GetYaxis()->SetTitle("APVs");
1128  }
1129  }
1130 }
1131 
1133 {
1134  double logStripOccupancy = -1;
1135  double logPoissonProb = -1;
1136 
1137  if (singleStripOccupancy>0) logStripOccupancy = log10(singleStripOccupancy);
1138  if (poissonProb>0) logPoissonProb = log10(fabs(poissonProb));
1139 
1140  occupancyVsStripNumber[0]->Fill(strip_number,logStripOccupancy);
1141  occupancyVsStripNumber[subdetid-2]->Fill(strip_number,logStripOccupancy);
1142  poissonProbVsStripNumber[0]->Fill(strip_number,logPoissonProb);
1143  poissonProbVsStripNumber[subdetid-2]->Fill(strip_number,logPoissonProb);
1146 
1147  if(isHot)
1148  {
1149  vHotStripsInModule.push_back(strip_number);
1150  occupancyHotStripsVsStripNumber[0]->Fill(strip_number,logStripOccupancy);
1151  occupancyHotStripsVsStripNumber[subdetid-2]->Fill(strip_number,logStripOccupancy);
1152  poissonProbHotStripsVsStripNumber[0]->Fill(strip_number,logPoissonProb);
1153  poissonProbHotStripsVsStripNumber[subdetid-2]->Fill(strip_number,logPoissonProb);
1156  }
1157  else
1158  {
1159  occupancyGoodStripsVsStripNumber[0]->Fill(strip_number,logStripOccupancy);
1160  occupancyGoodStripsVsStripNumber[subdetid-2]->Fill(strip_number,logStripOccupancy);
1161  poissonProbGoodStripsVsStripNumber[0]->Fill(strip_number,logPoissonProb);
1162  poissonProbGoodStripsVsStripNumber[subdetid-2]->Fill(strip_number,logPoissonProb);
1165  }
1166 }
bool isDebugEnabled()
int i
Definition: DBlmapReader.cc:9
unsigned int tibLayer(const DetId &id) const
unsigned int tibString(const DetId &id) const
unsigned int tidRing(const DetId &id) const
MonitorElement * book1D(const char *name, const char *title, int nchX, double lowX, double highX)
Book 1D histogram.
Definition: DQMStore.cc:1021
bool tobIsStereo(const DetId &id) const
void cd(void)
go to top directory (ie. root)
Definition: DQMStore.cc:704
unsigned int tecRing(const DetId &id) const
ring id
T y() const
Definition: PV3DBase.h:63
unsigned int tidWheel(const DetId &id) const
void CalculateMeanAndRMS(const std::vector< Apv > &, std::pair< double, double > *, int)
virtual const StripTopology & specificTopology() const
Returns a reference to the strip proxy topology.
list diff
Definition: mps_update.py:85
bool tecIsZMinusSide(const DetId &id) const
bool tidIsStereo(const DetId &id) const
bool tidIsZMinusSide(const DetId &id) const
U second(std::pair< T, U > const &p)
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
T z() const
Definition: PV3DBase.h:64
void compact(unsigned int &, std::vector< unsigned int > &)
T Abs(T a)
Definition: MathUtil.h:49
bool tobIsZMinusSide(const DetId &id) const
int j
Definition: DBlmapReader.cc:9
MonitorElement * bookProfile(const char *name, const char *title, int nchX, double lowX, double highX, int nchY, double lowY, double highY, const char *option="s")
Definition: DQMStore.cc:1335
SiStripBadAPVandHotStripAlgorithmFromClusterOccupancy(const edm::ParameterSet &, const TrackerTopology *)
void fillBadComponents()
int subdetId() const
get the contents of the subdetector field (not cast into any detector&#39;s numbering enum) ...
Definition: DetId.h:37
#define LogTrace(id)
unsigned int tibModule(const DetId &id) const
unsigned int tecModule(const DetId &id) const
bool tecIsBackPetal(const DetId &id) const
Definition: DetId.h:18
bool tibIsStereo(const DetId &id) const
TH1F * getTH1F(void) const
void AnalyzeOccupancy(SiStripQuality *, std::vector< Apv > &, std::pair< double, double > *, std::vector< unsigned int > &, edm::ESHandle< SiStripQuality > &)
unsigned int tobModule(const DetId &id) const
void save(const std::string &filename, const std::string &path="", const std::string &pattern="", const std::string &rewrite="", const uint32_t run=0, const uint32_t lumi=0, SaveReferenceTag ref=SaveWithReference, int minStatus=dqm::qstatus::STATUS_OK, const std::string &fileupdate="RECREATE", const bool resetMEsAfterWriting=false)
Definition: DQMStore.cc:2636
double a
Definition: hdecay.h:121
TProfile * getTProfile(void) const
std::pair< ContainerIterator, ContainerIterator > Range
virtual LocalPoint localPosition(float strip) const =0
unsigned int tecPetalNumber(const DetId &id) const
tuple cout
Definition: gather_cfg.py:145
void extractBadAPVSandStrips(SiStripQuality *, HistoMap &, edm::ESHandle< SiStripQuality > &)
volatile std::atomic< bool > shutdown_flag false
unsigned int tobRod(const DetId &id) const
TH2F * getTH2F(void) const
bool put(const uint32_t &detID, const InputVector &vect)
MonitorElement * book2D(const char *name, const char *title, int nchX, double lowX, double highX, int nchY, double lowY, double highY)
Book 2D histogram.
Definition: DQMStore.cc:1149
T x() const
Definition: PV3DBase.h:62
unsigned int tecWheel(const DetId &id) const
unsigned int encode(const unsigned short &first, const unsigned short &NconsecutiveBadStrips, const unsigned short &flag=0)
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:727
unsigned int tobLayer(const DetId &id) const
const TrackerGeomDet * idToDet(DetId) const