CMS 3D CMS Logo

SiStripBadAPVandHotStripAlgorithmFromClusterOccupancy.h
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: SiStripQuality
4 // Class: SiStripBadAPVandHotStripAlgorithmFromClusterOccupancy
5 //
13 //
14 // Original Author: Gordon KAUSSEN
15 // Created: Wed Jan 28 09:11:10 CEST 2009
16 //
17 //
18 
19 #ifndef CalibTracker_SiStripQuality_SiStripBadAPVandHotStripAlgorithmFromClusterOccupancy_H
20 #define CalibTracker_SiStripQuality_SiStripBadAPVandHotStripAlgorithmFromClusterOccupancy_H
21 
22 // system include files
23 #include <memory>
24 #include <vector>
25 #include <map>
26 #include <sstream>
27 #include <iostream>
28 
29 #include "TMath.h"
30 #include "TTree.h"
31 #include "TFile.h"
32 
36 
38 
39 class SiStripQuality;
40 class TrackerTopology;
41 
43 public:
47 
49 
51 
52  void setProbabilityThreshold(long double prob) { prob_ = prob; }
53  void setMinNumEntries(unsigned short m) { MinNumEntries_ = m; }
54  void setMinNumEntriesPerStrip(unsigned short m) { MinNumEntriesPerStrip_ = m; }
55  void setLowOccupancyThreshold(long double low_occupancy) { lowoccupancy_ = low_occupancy; }
56  void setHighOccupancyThreshold(long double high_occupancy) { highoccupancy_ = high_occupancy; }
57  void setAbsoluteLowThreshold(long double absolute_low) { absolutelow_ = absolute_low; }
58  void setNumberIterations(int number_iterations) { numberiterations_ = number_iterations; }
59  void setAbsoluteOccupancyThreshold(long double absolute_occupancy) { absolute_occupancy_ = absolute_occupancy; }
60  void setNumberOfEvents(double Nevents) { Nevents_ = Nevents; }
61  void setMinNumOfEvents();
63  bool WriteOutputFile,
64  std::string DQMOutfileName,
65  bool WriteDQMHistograms) {
68  DQMOutfileName_ = DQMOutfileName;
69  WriteDQMHistograms_ = WriteDQMHistograms;
70  }
71  void setTrackerGeometry(const TrackerGeometry* tkgeom) { TkGeom = tkgeom; }
73 
74 private:
75  struct Apv {
76  uint32_t detrawId;
79  double apvMedian[6];
81  TH1F* th1f[6];
82  int NEntries[6];
83  int NEmptyBins[6];
84  };
85 
86  void CalculateMeanAndRMS(const std::vector<Apv>&, std::pair<double, double>*, int);
87 
89  std::vector<Apv>&,
90  std::pair<double, double>*,
91  std::vector<unsigned int>&,
92  const SiStripQuality*);
93 
94  void iterativeSearch(Apv&, std::vector<unsigned int>&, int);
95 
96  void evaluatePoissonian(std::vector<long double>&, long double& meanVal);
97 
98  void setBasicTreeParameters(int detid);
99 
101 
102  void fillStripDQMHistograms();
103 
104  long double prob_;
105  long double ratio_;
106  unsigned short MinNumEntries_;
107  unsigned short MinNumEntriesPerStrip_;
108  long double lowoccupancy_;
109  long double highoccupancy_;
110  long double absolutelow_;
112  double Nevents_;
113  long double absolute_occupancy_;
114  double minNevents_;
122 
124 
125  double stripOccupancy[6][128];
126  double stripWeight[6][128];
127 
128  std::vector<Apv> medianValues_TIB_Layer1;
129  std::pair<double, double> MeanAndRms_TIB_Layer1[7];
130  std::vector<Apv> medianValues_TIB_Layer2;
131  std::pair<double, double> MeanAndRms_TIB_Layer2[7];
132  std::vector<Apv> medianValues_TIB_Layer3;
133  std::pair<double, double> MeanAndRms_TIB_Layer3[7];
134  std::vector<Apv> medianValues_TIB_Layer4;
135  std::pair<double, double> MeanAndRms_TIB_Layer4[7];
136 
137  std::vector<Apv> medianValues_TOB_Layer1;
138  std::pair<double, double> MeanAndRms_TOB_Layer1[7];
139  std::vector<Apv> medianValues_TOB_Layer2;
140  std::pair<double, double> MeanAndRms_TOB_Layer2[7];
141  std::vector<Apv> medianValues_TOB_Layer3;
142  std::pair<double, double> MeanAndRms_TOB_Layer3[7];
143  std::vector<Apv> medianValues_TOB_Layer4;
144  std::pair<double, double> MeanAndRms_TOB_Layer4[7];
145  std::vector<Apv> medianValues_TOB_Layer5;
146  std::pair<double, double> MeanAndRms_TOB_Layer5[7];
147  std::vector<Apv> medianValues_TOB_Layer6;
148  std::pair<double, double> MeanAndRms_TOB_Layer6[7];
149 
150  std::vector<Apv> medianValues_TIDPlus_Disc1;
151  std::pair<double, double> MeanAndRms_TIDPlus_Disc1[7];
152  std::vector<Apv> medianValues_TIDPlus_Disc2;
153  std::pair<double, double> MeanAndRms_TIDPlus_Disc2[7];
154  std::vector<Apv> medianValues_TIDPlus_Disc3;
155  std::pair<double, double> MeanAndRms_TIDPlus_Disc3[7];
156 
157  std::vector<Apv> medianValues_TIDMinus_Disc1;
158  std::pair<double, double> MeanAndRms_TIDMinus_Disc1[7];
159  std::vector<Apv> medianValues_TIDMinus_Disc2;
160  std::pair<double, double> MeanAndRms_TIDMinus_Disc2[7];
161  std::vector<Apv> medianValues_TIDMinus_Disc3;
162  std::pair<double, double> MeanAndRms_TIDMinus_Disc3[7];
163 
164  std::vector<Apv> medianValues_TECPlus_Disc1;
165  std::pair<double, double> MeanAndRms_TECPlus_Disc1[7];
166  std::vector<Apv> medianValues_TECPlus_Disc2;
167  std::pair<double, double> MeanAndRms_TECPlus_Disc2[7];
168  std::vector<Apv> medianValues_TECPlus_Disc3;
169  std::pair<double, double> MeanAndRms_TECPlus_Disc3[7];
170  std::vector<Apv> medianValues_TECPlus_Disc4;
171  std::pair<double, double> MeanAndRms_TECPlus_Disc4[7];
172  std::vector<Apv> medianValues_TECPlus_Disc5;
173  std::pair<double, double> MeanAndRms_TECPlus_Disc5[7];
174  std::vector<Apv> medianValues_TECPlus_Disc6;
175  std::pair<double, double> MeanAndRms_TECPlus_Disc6[7];
176  std::vector<Apv> medianValues_TECPlus_Disc7;
177  std::pair<double, double> MeanAndRms_TECPlus_Disc7[7];
178  std::vector<Apv> medianValues_TECPlus_Disc8;
179  std::pair<double, double> MeanAndRms_TECPlus_Disc8[7];
180  std::vector<Apv> medianValues_TECPlus_Disc9;
181  std::pair<double, double> MeanAndRms_TECPlus_Disc9[7];
182 
183  std::vector<Apv> medianValues_TECMinus_Disc1;
184  std::pair<double, double> MeanAndRms_TECMinus_Disc1[7];
185  std::vector<Apv> medianValues_TECMinus_Disc2;
186  std::pair<double, double> MeanAndRms_TECMinus_Disc2[7];
187  std::vector<Apv> medianValues_TECMinus_Disc3;
188  std::pair<double, double> MeanAndRms_TECMinus_Disc3[7];
189  std::vector<Apv> medianValues_TECMinus_Disc4;
190  std::pair<double, double> MeanAndRms_TECMinus_Disc4[7];
191  std::vector<Apv> medianValues_TECMinus_Disc5;
192  std::pair<double, double> MeanAndRms_TECMinus_Disc5[7];
193  std::vector<Apv> medianValues_TECMinus_Disc6;
194  std::pair<double, double> MeanAndRms_TECMinus_Disc6[7];
195  std::vector<Apv> medianValues_TECMinus_Disc7;
196  std::pair<double, double> MeanAndRms_TECMinus_Disc7[7];
197  std::vector<Apv> medianValues_TECMinus_Disc8;
198  std::pair<double, double> MeanAndRms_TECMinus_Disc8[7];
199  std::vector<Apv> medianValues_TECMinus_Disc9;
200  std::pair<double, double> MeanAndRms_TECMinus_Disc9[7];
201 
202  TFile* f;
203  TTree* apvtree;
204 
205  uint32_t detrawid;
206  int subdetid;
208  int disc;
209  int isback;
213  int isstereo;
218 
225 
228  int isBad;
229 
230  TTree* striptree;
233 
234  int isHot;
240  double avgAPVHits;
241  double poissonProb;
242 
243  int ishot[128];
246  double stripoccupancy[128];
247  int striphits[128];
248  double poissonprob[128];
249  double medianapvhits[6];
250  double avgapvhits[6];
251 
252  std::stringstream ss;
253 
254  std::ostringstream oss;
255 
257 
259  TProfile* tmp_prof;
260 
261  // Histograms
262  // indexes in these arrays are [SubDetId-2][LayerN]
263  // histograms for [SubDetId-2][0] are global for the subdetector
264  // histogram for [0][0] is global for the tracker
265 
267  TH1F* medianOccupancy[5][10];
268  TH1F* absoluteOccupancy[5][10];
269 
270  std::vector<TH2F*> distanceVsStripNumber;
271  std::vector<TProfile*> pfxDistanceVsStripNumber;
272  std::vector<TH1F*> projXDistanceVsStripNumber;
273  std::vector<TH1F*> projYDistanceVsStripNumber;
274 
275  std::vector<TH2F*> occupancyVsStripNumber;
276  std::vector<TProfile*> pfxOccupancyVsStripNumber;
277  std::vector<TH1F*> projYOccupancyVsStripNumber;
279  std::vector<TProfile*> pfxOccupancyHotStripsVsStripNumber;
282  std::vector<TProfile*> pfxOccupancyGoodStripsVsStripNumber;
284 
285  std::vector<TH2F*> poissonProbVsStripNumber;
286  std::vector<TProfile*> pfxPoissonProbVsStripNumber;
287  std::vector<TH1F*> projYPoissonProbVsStripNumber;
289  std::vector<TProfile*> pfxPoissonProbHotStripsVsStripNumber;
294 
295  std::vector<TH2F*> nHitsVsStripNumber;
296  std::vector<TProfile*> pfxNHitsVsStripNumber;
297  std::vector<TH1F*> projXNHitsVsStripNumber;
298  std::vector<TH1F*> projYNHitsVsStripNumber;
299  std::vector<TH2F*> nHitsHotStripsVsStripNumber;
300  std::vector<TProfile*> pfxNHitsHotStripsVsStripNumber;
303  std::vector<TH2F*> nHitsGoodStripsVsStripNumber;
304  std::vector<TProfile*> pfxNHitsGoodStripsVsStripNumber;
307 
308  std::vector<std::string> subDetName;
309  std::vector<unsigned int> nLayers;
310  std::vector<std::string> layerName;
311 
312  std::vector<unsigned int> vHotStripsInModule;
313  unsigned int distance;
314  unsigned int distanceR, distanceL;
315 
317 };
318 #endif
string OutputFileName
WriteOutputFile
Name of root file for histograms.
void setOutputFileName(std::string OutputFileName, bool WriteOutputFile, std::string DQMOutfileName, bool WriteDQMHistograms)
void extractBadAPVSandStrips(SiStripQuality *, HistoMap &, const SiStripQuality *)
void CalculateMeanAndRMS(const std::vector< Apv > &, std::pair< double, double > *, int)
std::map< uint32_t, TH1F * > HistoMap
std::unordered_map< unsigned int, std::shared_ptr< TH1F > > QualityHistosMap
void AnalyzeOccupancy(SiStripQuality *, std::vector< Apv > &, std::pair< double, double > *, std::vector< unsigned int > &, const SiStripQuality *)
SiStripBadAPVandHotStripAlgorithmFromClusterOccupancy(const edm::ParameterSet &, const TrackerTopology *)