test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
SiPixelDQMRocLevelAnalyzer.cc
Go to the documentation of this file.
2 
4 {
5 
6 
7 }
8 
9 
11 {
12 
13 
14 }
15 
16 // ------------ method called to for each event ------------
17 void
19 {
20  using namespace edm;
21 
22 
23 #ifdef THIS_IS_AN_EVENT_EXAMPLE
25  iEvent.getByLabel("example",pIn);
26 #endif
27 
28 #ifdef THIS_IS_AN_EVENTSETUP_EXAMPLE
29  ESHandle<SetupData> pSetup;
30  iSetup.get<SetupRecord>().get(pSetup);
31 #endif
32 }
33 
34 
35 // ------------ method called once each job just before starting event loop ------------
36 void
38 {
40  bRS = conf_.getUntrackedParameter<bool>("barrelRocStud");
41  fRS = conf_.getUntrackedParameter<bool>("endcapRocStud");
42  bPixelAlive = conf_.getUntrackedParameter<bool>("pixelAliveStudy");
43  double pixelAliveThresh = conf_.getUntrackedParameter<double>("pixelAliveThreshold");
44  bool bThreshold = conf_.getUntrackedParameter<bool>("thresholdStudy");
45  bool bNoise = conf_.getUntrackedParameter<bool>("noiseStudy");
46  bool bGain = conf_.getUntrackedParameter<bool>("gainStudy");
47  bool bPedestal = conf_.getUntrackedParameter<bool>("pedestalStudy");
48 
49  if(!bRS && !fRS) return;
50 
51  //Open file and get MEs
53  dbe->open(filename);
54  mes = dbe->getAllContents("");
55  std::cout << "found " << mes.size() << " monitoring elements!" << std::endl;
56 
57 
58  //BARREL
59  if(bRS){
60  //PIXELALIVE
61  if(bPixelAlive){
62  bhPixelAlive = fs_->make<TH1F>("bpixAlive","PixelAliveSummary_mean_Barrel",11520, 0., 11520.);
63  bhPixelAlive_dist = fs_->make<TH1F>("bpixAliveDist","Mean PixelAliveSummary_mean_Barrel Disbribution", 110, 0., 1.1);
64  }
65  //THRESHOLD
66  if(bThreshold){
67  bhThresholdMean = fs_->make<TH1F>("bthreshMean","ScurveThresholdSummary_mean_Barrel",11520,0.,11520.);
68  bhThresholdMean_dist = fs_->make<TH1F>("bthreshMeanDist","Mean ScurveThresholdSummary_mean_Barrel Distribution",600,0.,150.);
69  bhThresholdRMS = fs_->make<TH1F>("bthreshRMS","ScurveThresholdSummary_RMS_Barrel",11520,0.,11520.);
70  bhThresholdRMS_dist = fs_->make<TH1F>("bthreshRMSDist","Mean ScurveThresholdSummary_RMS_Barrel Distribution",800,0.,80.);
71  }
72  //NOISE
73  if(bNoise){
74  bhNoiseMean = fs_->make<TH1F>("bnoiseMean","ScurveSigmasSummary_mean_Barrel",11520,0.,11520.);
75  bhNoiseMean_dist = fs_->make<TH1F>("bnoiseMeanDist","Mean ScurveSigmasSummary_mean_Barrel Distribution",256,-2.,6.);
76  bhNoiseRMS = fs_->make<TH1F>("bnoiseRMS","ScurveSigmasSummary_RMS_Barrel",11520,0.,11520.);
77  bhNoiseRMS_dist = fs_->make<TH1F>("bnoiseRMSDist","Mean ScurveSigmasSummary_RMS_Barrel Distribution",768,0.,8.);
78  }
79  //GAIN
80  if(bGain){
81  bhGainMean = fs_->make<TH1F>("bgainMean","ScurveGainSummary_mean_Barrel",11520,0.,11520.);
82  bhGainMean_dist = fs_->make<TH1F>("bgainMeanDist","Mean ScurveGainSummary_mean_Barrel Distribution",80,0.,8.);
83  bhGainRMS = fs_->make<TH1F>("bgainRMS","ScurveGainSummary_RMS_Barrel",11520,0.,11520.);
84  bhGainRMS_dist = fs_->make<TH1F>("bgainRMSDist","Mean ScurveGainSummary_RMS_Barrel Distribution",100,0.,10.);
85  }
86  //PEDESTAL
87  if(bPedestal){
88  bhPedestalMean = fs_->make<TH1F>("bpedestalMean","ScurvePedestalSummary_mean_Barrel",11520,0.,11520.);
89  bhPedestalMean_dist = fs_->make<TH1F>("bpedestalMeanDist","Mean ScurvePedestalSummary_mean_Barrel Distribution",600,0.,300.);
90  bhPedestalRMS = fs_->make<TH1F>("bpedestalRMS","ScurvePedestalSummary_RMS_Barrel",11520,0.,11520.);
91  bhPedestalRMS_dist = fs_->make<TH1F>("bpedestalRMSDist","Mean ScurvePedestalSummary_RMS_Barrel Distribution",1000,0.,100.);
92  }
93  }
94 
95  //ENDCAP
96  if(fRS){
97  //PIXELALIVE
98  if(bPixelAlive){
99  ehPixelAlive = fs_->make<TH1F>("fpixAlive","PixelAliveSummary_mean_Endcap",4320, 0., 4320.);
100  ehPixelAlive_dist = fs_->make<TH1F>("fpixAliveDist","Mean PixelAliveSummary_mean_Endcap Disbribution", 110, 0., 1.1);
101  }
102  //THRESHOLD
103  if(bThreshold){
104  ehThresholdMean = fs_->make<TH1F>("fthreshMean","ScurveThresholdSummary_mean_Endcap",4320,0.,4320.);
105  ehThresholdMean_dist = fs_->make<TH1F>("fthreshMeanDist","Mean ScurveThresholdSummary_mean_Endcap Distribution",600,0.,150.);
106  ehThresholdRMS = fs_->make<TH1F>("fthreshRMS","ScurveThresholdSummary_RMS_Endcap",4320,0.,4320.);
107  ehThresholdRMS_dist = fs_->make<TH1F>("fthreshRMSDist","Mean ScurveThresholdSummary_RMS_Endcap Distribution",800,0.,80.);
108  }
109  //NOISE
110  if(bNoise){
111  ehNoiseMean = fs_->make<TH1F>("fnoiseMean","ScurveSigmasSummary_mean_Endcap",4320,0.,4320.);
112  ehNoiseMean_dist = fs_->make<TH1F>("fnoiseMeanDist","Mean ScurveSigmasSummary_mean_Endcap Distribution",256,-2.,6.);
113  ehNoiseRMS = fs_->make<TH1F>("fnoiseRMS","ScurveSigmasSummary_RMS_Endcap",4320,0.,4320.);
114  ehNoiseRMS_dist = fs_->make<TH1F>("fnoiseRMSDist","Mean ScurveSigmasSummary_RMS_Endcap Distribution",384,0.,4.);
115  }
116  //GAIN
117  if(bGain){
118  ehGainMean = fs_->make<TH1F>("fgainMean","ScurveGainSummary_mean_Endcap",4320,0.,4320.);
119  ehGainMean_dist = fs_->make<TH1F>("fgainMeanDist","Mean ScurveGainSummary_mean_Endcap Distribution",600,0.,150.);
120  ehGainRMS = fs_->make<TH1F>("fgainRMS","ScurveGainSummary_RMS_Endcap",4320,0.,4320.);
121  ehGainRMS_dist = fs_->make<TH1F>("fgainRMSDist","Mean ScurveGainSummary_RMS_Endcap Distribution",800,0.,80.);
122  }
123  //PEDESTAL
124  if(bPedestal){
125  ehPedestalMean = fs_->make<TH1F>("fpedestalMean","ScurvePedestalSummary_mean_Endcap",4320,0.,4320.);
126  ehPedestalMean_dist = fs_->make<TH1F>("fpedestalMeanDist","Mean ScurvePedestalSummary_mean_Endcap Distribution",600,0.,150.);
127  ehPedestalRMS = fs_->make<TH1F>("fpedestalRMS","ScurvePedestalSummary_RMS_Endcap",4320,0.,4320.);
128  ehPedestalRMS_dist = fs_->make<TH1F>("fpedestalRMSDist","Mean ScurvePedestalSummary_RMS_Endcap Distribution",800,0.,80.);
129  }
130  }
131  //PIXELALIVE
132  if(bPixelAlive){
133  RocSummary("pixelAlive_siPixelCalibDigis_");
134  if(bRS){
136 
137  //print a list of pixels with pixelAlive quantity below pixelAliveThresh
138  for(unsigned int i=0; i<vbpixCN.size(); i++){
139 
140  if(vbpixM[i]<pixelAliveThresh){
141  double temp = vbpixCN[i];
142  int shell = (int)((temp-1)/2880); //0 mi, 1 mo, 2 pi, 3 po
143  temp -= shell *2880;
144  int lay = 1;
145  if(temp>576){
146  temp -= 576; lay++;
147  }
148  if(temp>960){
149  temp -= 960; lay++;
150  }
151  int lad = 1;
152  if(temp > 32){
153  temp -=32; lad++;
154  }
155  while(temp>64){
156  temp -=64; lad++;
157  }
158  int mod =1; int modsize = 16;
159  if(lad ==1 || (lay == 1 && lad == 10) || (lay == 2 && lad == 16) || (lay == 3 && lad == 22) ) modsize = 8;
160  while(temp>modsize){
161  temp -= modsize; mod ++;
162  }
163  std::cout << vbpixCN[i] << " " << vbpixM[i] << ":\n";
164  std::cout << "Shell ";
165  switch(shell){
166  case 0: std::cout << "mI"; break;
167  case 1: std::cout << "mO"; break;
168  case 2: std::cout << "pI"; break;
169  case 3: std::cout << "pO"; break;
170  }
171  std::cout << " Lay" << lay << " Lad" << lad << " Mod" << mod << " Chip" << temp << "\n\n";
172 
173  }
174 
175  }
176  }
177  if(fRS){
179  //print a list of pixels with pixelAlive quantity below pixelAliveThresh
180  for(unsigned int i=0; i<vfpixCN.size(); i++){
181  if(vfpixM[i]<pixelAliveThresh){
182  double temp = vfpixCN[i];
183  int hcyl = (int)((temp-1)/1080); //0 mi, 1 mo, 2 pi, 3 po
184  temp -= hcyl *1080;
185  int disk = 1;
186  if(temp > 540){
187  temp -= 540; disk++;
188  }
189  int blade = 1;
190  while(temp>45){
191  temp-=45; blade++;
192  }
193  int panel = 1, mod = 1;
194  if(temp<22){
195  //panel 1
196  if(temp>16){
197  temp-=16; mod = 4;
198  }
199  else if(temp>8){
200  temp-=8; mod = 3;
201  }
202  else if(temp>2){
203  temp-=2; mod = 2;
204  }
205  }
206  else{
207  //panel 2
208  temp-=21; panel++;
209  if(temp>14){
210  temp-=14; mod = 3;
211  }
212  else if(temp>6){
213  temp-=6; mod = 2;
214  }
215  }
216 
217  std::cout << vfpixCN[i] << " " << vfpixM[i] << ":\n";
218  std::cout << "HalfCylinder ";
219  switch(hcyl){
220  case 0: std::cout << "mI"; break;
221  case 1: std::cout << "mO"; break;
222  case 2: std::cout << "pI"; break;
223  case 3: std::cout << "pO"; break;
224  }
225  std::cout << " Disk" << disk << " Blade" << blade << " Panel" << panel << " Mod" << mod << " Chip" << temp << "\n\n";
226 
227  }
228  }
229  }
230 
231  }
232  //THRESHOLD
233  if(bThreshold) {
234  vbpixCN.clear();
235  vbpixM.clear();
236  vbpixSD.clear();
237  vfpixCN.clear();
238  vfpixM.clear();
239  vfpixSD.clear();
240 
241  RocSummary("ScurveThresholds_siPixelCalibDigis_");
242  if(bRS){
245  }
246  if(fRS){
249  }
250  }
251  //NOISE
252  if(bNoise){
253  vbpixCN.clear();
254  vbpixM.clear();
255  vbpixSD.clear();
256  vfpixCN.clear();
257  vfpixM.clear();
258  vfpixSD.clear();
259 
260  RocSummary("ScurveSigmas_siPixelCalibDigis_");
261  if(bRS){
264  }
265  if(fRS){
268  }
269  }
270  //GAIN
271  if(bGain){
272  vbpixCN.clear();
273  vbpixM.clear();
274  vbpixSD.clear();
275  vfpixCN.clear();
276  vfpixM.clear();
277  vfpixSD.clear();
278 
279  RocSummary("Gain2d_siPixelCalibDigis_");
280  if(bRS){
283  }
284  if(fRS){
287  }
288  }
289  //PEDESTAL
290  if(bPedestal){
291  vbpixCN.clear();
292  vbpixM.clear();
293  vbpixSD.clear();
294  vfpixCN.clear();
295  vfpixM.clear();
296  vfpixSD.clear();
297 
298  RocSummary("Pedestal2d_siPixelCalibDigis_");
299  if(bRS){
302  }
303  if(fRS){
306  }
307  }
308 }
309 
310 // ------------ method called once each job just after ending the event loop ------------
311 void
313 }
314 
315 void
317 
318  int maxcrow, maxccol;
319  std::string name, path = "first";
320  std::string oldPath = "";
321  int moduleNumber = 0;
322  int bchipNumber = 0;
323  int fchipNumber = 0;
324  bool bbarrel = false, bforward = false, bhalfMod = false, bwasHM = false;
325  bool bPFFM = false;
326  bool bMNCS = false;
327  int panelNumber = -1;
328 
329  for(std::vector<MonitorElement*>::const_iterator ime = mes.begin(); ime!=mes.end(); ++ime){
330  bwasHM = bhalfMod;
331  //set default values
332  bMNCS = false;
333  bbarrel = false; bforward = false; bhalfMod = false;
334  //set name, (old) path
335  name = (*ime)->getName();
336  oldPath = path;
337  path = (*ime)->getPathname();
338 
339  //determine module number if any
340  if(path.find("Module_")<path.size()){
341  if(path!=oldPath) {
342  moduleNumber++;
343  if(moduleNumber!=1) bMNCS = true;
344 
345  }
346  }
347  else {
348  if(moduleNumber>0) bMNCS = true;
349  moduleNumber =0;
350  }
351 
352 
353  //find out location (barrel (hm), endcap)
354  if(path.find("Barrel/") < path.size()) {
355  bbarrel = true;
356  if(path.find("H/") < path.size()) bhalfMod = true;
357  }
358  if(path.find("Endcap/") < path.size()) {
359  bforward = true;
360  panelNumber = -1;
361  if(path.find("Panel_1") < path.size()) panelNumber = 1;
362  if(path.find("Panel_2") < path.size()) panelNumber = 2;
363 
364  }
365 
366 
367  //find tagname in histoname
368  if(name.find(tagname)<name.size()) bPFFM = true;
369  else{
370  //adjust chip number if necessary, skip ME
371  if(bMNCS){
372  if(!bPFFM){
373  if(bbarrel && bRS){
374  if(bPixelAlive){
375  int a = 16;
376  if(bwasHM) a = 8;
377  for(int i=0; i<a; i++){
378  bchipNumber++;
379  vbpixCN.push_back(bchipNumber);
380  vbpixM.push_back(0);
381  }
382  }
383  else{
384  if(bwasHM) bchipNumber += 8;
385  else bchipNumber += 16;
386  }
387  }
388  if(bforward && fRS){
389 
390  int maxcol = 2;
391  int mod = moduleNumber;
392  if(mod>1) mod--;
393  else{
394  if(panelNumber == 1) mod = 4;
395  else mod = 3;
396  }
397  if(panelNumber==1 && (mod==1 || mod==4)) maxcol = 1;
398  if(bPixelAlive){
399  for(int i=0; i<maxcol*(mod + panelNumber); i++){
400  fchipNumber++;
401  vfpixCN.push_back(fchipNumber);
402  vfpixM.push_back(0);
403  }
404  }
405  else{
406  fchipNumber += maxcol * (mod + panelNumber);
407  }
408  }
409  }
410  else bPFFM = false;
411  }
412  continue;
413  }
414 
415  //BARREL ROC LEVEL PLOTS
416 
417  if(bbarrel && bRS){
418  maxccol=8, maxcrow=2;
419  if(bhalfMod) {
420  maxcrow=1;
421  }
422 
423  RocSumOneModule(maxcrow, maxccol, (*ime), vbpixCN, vbpixM, vbpixSD, bchipNumber);
424 
425  }
426 
427 
428  //ENDCAP ROC LEVEL PLOTS
429  if(bforward && fRS){
430  maxccol = moduleNumber + panelNumber;
431  maxcrow = 2;
432  if(panelNumber==1 && (moduleNumber==1 || moduleNumber==4)) maxcrow = 1;
433 
434  RocSumOneModule(maxcrow, maxccol, (*ime), vfpixCN, vfpixM, vfpixSD, fchipNumber);
435  }
436  }
437 
438  std::cout << "Number of Chips: b" << bchipNumber << " f" << fchipNumber << " " << tagname << std::endl;
439 
440 }
441 
442 void
443 SiPixelDQMRocLevelAnalyzer::RocSumOneModule(int maxr, int maxc, MonitorElement* const &me, std::vector<double> &vecCN, std::vector<double> &vecMean, std::vector<double> &vecSD, int &chipNumber){
444 
445  float temp, sum, nentries;
446  for(int cr=0; cr<maxr; cr++){
447  for(int cc=0; cc<maxc; cc++){
448  //compute mean of 1 ROC
449  chipNumber++;
450  sum = 0;
451  nentries = 0;
452  //sum for 1 ROC
453  for(int c=1; c<53; c++){
454  for(int r=1; r<81; r++){
455 
456  temp = me->getBinContent(52*cc+c, 80*cr+r);
457 
458  if(temp!=0.){
459  sum += temp;
460  nentries++;
461  }
462  }
463  }
464  if(nentries==0 && bPixelAlive){
465  vecCN.push_back(chipNumber);
466  vecMean.push_back(0);
467  }
468  if(nentries!=0){
469  double mean = sum/nentries;
470  double avsd = 0.;
471  int ne = 0;
472  vecCN.push_back(chipNumber);
473  vecMean.push_back(mean);
474 
475  //computing std dev.
476  for(int c=1; c<53; c++){
477  for(int r=1; r<81; r++){
478  temp = me->getBinContent(52*cc+c, 80*cr+r);
479  if(temp!=0){
480  avsd += (temp-mean)*(temp-mean);
481  ne++;
482 
483  }
484  }
485  }
486  avsd = avsd/ne;
487  avsd = sqrt(avsd);
488  vecSD.push_back(avsd);
489  }
490 
491  }
492  }
493 }
494 
495 void
496 SiPixelDQMRocLevelAnalyzer::FillRocLevelHistos(TH1F *hrocdep, TH1F *hdist, std::vector<double> &vecx, std::vector<double> &vecy){
497  if(vecx.size() == vecy.size()){
498  for(unsigned int i=0; i<vecx.size(); i++){
499  hrocdep->Fill(vecx[i],vecy[i]);
500  hdist->Fill(vecy[i]);
501  }
502  }
503 }
504 
505 // -- define this as a plug-in
void FillRocLevelHistos(TH1F *hrocdep, TH1F *hdist, std::vector< double > &vecx, std::vector< double > &vecy)
std::vector< MonitorElement * > mes
T getUntrackedParameter(std::string const &, T const &) const
int i
Definition: DBlmapReader.cc:9
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
void RocSumOneModule(int maxr, int maxc, MonitorElement *const &me, std::vector< double > &vecCN, std::vector< double > &vecMean, std::vector< double > &vecSD, int &chipNumber)
SiPixelDQMRocLevelAnalyzer(const edm::ParameterSet &)
T * make(const Args &...args) const
make new ROOT object
Definition: TFileService.h:64
unsigned int moduleNumber(align::ID, const TrackerTopology *)
Module number increases (decreases) with phi for +z (-z) endcap.
Definition: TECNameSpace.h:43
int iEvent
Definition: GenABIO.cc:230
T sqrt(T t)
Definition: SSEVec.h:18
void RocSummary(std::string tagname)
virtual void analyze(const edm::Event &, const edm::EventSetup &)
unsigned int panelNumber(align::ID, const TrackerTopology *)
Panel number is 1 for 4 modules, 2 for 3 modules.
Definition: TPENameSpace.h:51
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:418
const T & get() const
Definition: EventSetup.h:56
double getBinContent(int binx) const
get content of bin (1-D)
double a
Definition: hdecay.h:121
tuple filename
Definition: lut2db_cfg.py:20
tuple cout
Definition: gather_cfg.py:145
edm::Service< TFileService > fs_
T mod(const T &a, const T &b)
Definition: ecalDccMap.h:4