HWwatchlist.C
Go to the documentation of this file.
1 #include <TChain.h>
2 #include <TColor.h>
3 #include <TCanvas.h>
4 #include <TFile.h>
5 #include <TGraph.h>
6 #include <TH1.h>
7 #include <TH2.h>
8 #include <TH1F.h>
9 #include <TH1D.h>
10 #include <TH2F.h>
11 #include <TLegend.h>
12 #include <TLine.h>
13 #include <TMarker.h>
14 #include <TMultiGraph.h>
15 #include <TNtuple.h>
16 #include <TProfile.h>
17 #include <TStyle.h>
18 #include <TTree.h>
19 
20 #include <iostream>
21 #include <fstream>
22 #include <algorithm>
23 #include <iomanip>
24 #include <sstream>
25 #include <stdio.h>
26 #include <stdlib.h>
27 #include <time.h>
28 #include <string>
29 #include <vector>
30 
31 
34 
35 /*
36  This Scrip makes the Hawrdare Watch List and set of plots.
37  It uses onmon_ana output and computes a score
38  The list is sorted by score and misbehaving pixels.
39 
40 */
41 
42 // Class to save FEB scores and details
43 class FEBscore{
44 public:
47  void set_values(int, int, int, int, int, int, int, int, int, int, double, double, double, double, double, double, double, double);
48 };
49 
50 void FEBscore::set_values (int db_,int dcm_,int feb_,int blk_,int pinb_,int mod_,
51  int view_,int hwx_,int hwy_,int Nbadpix_,
52  double score_, double scoreN_, double scoreQ_, double scoreZ_, double scoreL_, double scoreH_, double scoreD_, double drops_) {
53  db=db_;
54  dcm=dcm_;
55  feb=feb_;
56  blk=blk_;
57  pinb=pinb_;
58  mod=mod_;
59  view=view_;
60  hwx=hwx_;
61  hwy=hwy_;
62  Nbadpix=Nbadpix_;
63  score=score_;
64  scoreN=scoreN_;
65  scoreQ=scoreQ_;
66  scoreZ=scoreZ_;
67  scoreL=scoreL_;
68  scoreH=scoreH_;
69  scoreD=scoreD_;
70  drops=drops_;
71 }
72 
73 //Sorting for score list
74 bool byScore (FEBscore i,FEBscore j) { return (i.score>j.score);}
75 bool byCount (FEBscore i,FEBscore j) { return (i.Nbadpix>j.Nbadpix);}
76 bool bychan (FEBscore i,FEBscore j) { return ((i.db-1)*13*64+(i.dcm-1)*64+(i.feb-1)<(j.db-1)*13*64+(j.dcm-1)*64+(j.feb-1));}
77 
78 void makeHWwatchlist(int idet, int lothresh, int hithresh, int DBlo, int DBhi, int timeopt, const std::string& infile)
79 {
80 
81  std::cout<<"--------------------------------------------------"<<std::endl;
82  std::cout<<"--------------------------------------------------"<<std::endl;
83  std::cout<<" Making plots with these parameters: "<<std::endl;
84  std::cout<<" Low Threshold "<<lothresh<<std::endl;
85  std::cout<<" High Threshold "<<hithresh<<std::endl;
86  std::cout<<" From diblocks "<<DBlo<<" to "<<DBhi<<std::endl;
87  std::cout<<"--------------------------------------------------"<<std::endl;
88  std::cout<<"--------------------------------------------------"<<std::endl;
89 
90 
91  std::cout<<" Reading file: "<<infile<<std::endl;
92 
93  std::ifstream in;
94  in.open(infile);
95 
96  std::cout<<" New files: "<<infile<<std::endl;
97 
98  std::vector<std::string> newfiles;
99  string line;
100  while(in.good()) {
101  in >> line;
102  newfiles.push_back(line);
103  }
104 
105  std::cout<<" Start Chain: "<<std::endl;
106 
107  TChain ch("OnMonSummary");
108  for(unsigned int i=0; i<newfiles.size()-1; i++){ //MakeHWwatchlist.sh leaves an extra space in file
109  ch.Add(&newfiles[i][0]);
110  std::cout<<"Chaining file: "<<&newfiles[i][0]<<std::endl;
111  }
112 
113  //...... Initialize histos and lists .........
115  ch.SetBranchAddress("fRateSummaryNt", &Nt);
116 
117  int DB_size;
118  int DCM_size;
119  int MapXbin;
120  int MapXmin;
121  int MapXmax;
122  int MapXsize;
123  int MapYbin;
124  int MapYmin;
125  int MapYmax;
126  int MapYdiv;
127  string detname;
128  if(idet==1){
129  cout << " far det " << endl;
130  detname="FarDet";
131  DB_size = 16;
132  DCM_size = 13;
133  MapXbin = 224;
134  MapXmin = 0;
135  MapXmax = 896;
136  MapXsize = 500;
137  MapYbin = 48;
138  MapYmin = 0;
139  MapYmax = 384;
140  MapYdiv = 20;
141  }
142  else if(idet==2){
143  cout << " near det " << endl;
144  detname="NearDet";
145  DB_size = 5;
146  DCM_size = 5;
147  MapXbin = 64;
148  MapXmin = 0;
149  MapXmax = 256;
150  MapXsize = 300;
151  MapYbin = 16;
152  MapYmin = 0;
153  MapYmax = 128;
154  MapYdiv = 4;
155  }
156  else cout << "Invalid Detector in HWwatchlist " << endl;
157 
158  int FEB_size = 64;
159  int PIX_size = 33;
160 
161  TH2D* FEBstatus[DB_size];
162  TH2D* FEBnoisyPIX[DB_size];
163  TH2D* FEBquietPIX[DB_size];
164  TH2D* FEBzeroPIX[DB_size];
165 
166  // // NEW
167  TH2D* FEBshutoffs[DB_size];
168  TH2D* FEBhiADCPIX[DB_size];
169  TH2D* FEBloADCPIX[DB_size];
170 
171  double Score[DB_size][DCM_size][FEB_size];
172  double NquietPIX[DB_size][DCM_size][FEB_size];
173  double NzeroPIX[DB_size][DCM_size][FEB_size];
174  double NnoisyPIX[DB_size][DCM_size][FEB_size];
175  int BadPIXcount[DB_size][DCM_size][FEB_size];
176  int QuietPIXcount[DB_size][DCM_size][FEB_size];
177  int NoisyPIXcount[DB_size][DCM_size][FEB_size];
178  int ZeroPIXcount[DB_size][DCM_size][FEB_size];
179 
180  // //NEW
181  double NhiADCPIX[DB_size][DCM_size][FEB_size];
182  double NloADCPIX[DB_size][DCM_size][FEB_size];
183  double NdropoutPIX[DB_size][DCM_size][FEB_size];
184  int HiADCPIXcount[DB_size][DCM_size][FEB_size];
185  int LoADCPIXcount[DB_size][DCM_size][FEB_size];
186 
187  int FEBsubruncount[DB_size][DCM_size][FEB_size];
188  bool noisy[DB_size][DCM_size][FEB_size][PIX_size];
189  bool quiet[DB_size][DCM_size][FEB_size][PIX_size];
190  bool zero[DB_size][DCM_size][FEB_size][PIX_size];
191 
192  // //NEW
193  double FEBshutoffcount[DB_size][DCM_size][FEB_size];
194  bool hiADC[DB_size][DCM_size][FEB_size][PIX_size];
195  bool loADC[DB_size][DCM_size][FEB_size][PIX_size];
196 
197  int hwBLK[DB_size][DCM_size][FEB_size];
198  int hwPINB[DB_size][DCM_size][FEB_size];
199  int hwMOD[DB_size][DCM_size][FEB_size];
200  int hwVIEW[DB_size][DCM_size][FEB_size];
201  int hwX[DB_size][DCM_size][FEB_size];
202  int hwY[DB_size][DCM_size][FEB_size];
203 
204 
205  std::cout << "Initializing arrays... " << std::endl;
206  for(int i = 0; i < DB_size; ++i) {
207  FEBstatus[i] = 0;
208  FEBnoisyPIX[i] = 0;
209  FEBquietPIX[i] = 0;
210  FEBzeroPIX[i] = 0;
211  FEBshutoffs[i] = 0;
212  FEBhiADCPIX[i] = 0;
213  FEBloADCPIX[i] = 0;
214  for(int j = 0; j < DCM_size; ++j) {
215  for(int k = 0; k < FEB_size; ++k) {
216  Score[i][j][k] = 0;
217  NquietPIX[i][j][k] = 0;
218  NzeroPIX[i][j][k] = 0;
219  NnoisyPIX[i][j][k] = 0;
220  BadPIXcount[i][j][k] = 0;
221  QuietPIXcount[i][j][k] = 0;
222  NoisyPIXcount[i][j][k] = 0;
223  ZeroPIXcount[i][j][k] = 0;
224  FEBsubruncount[i][j][k] = 0;
225  hwBLK[i][j][k] = -1;
226  hwPINB[i][j][k] = -1;
227  hwMOD[i][j][k] = -1;
228  hwVIEW[i][j][k] = -1;
229  hwX[i][j][k] = 0;
230  hwY[i][j][k] = 0;
231  NdropoutPIX[i][j][k];
232  NhiADCPIX[i][j][k] = 0;
233  NloADCPIX[i][j][k] = 0;
234  HiADCPIXcount[i][j][k] = 0;
235  LoADCPIXcount[i][j][k] = 0;
236  FEBshutoffcount[i][j][k] = 0;
237  for(int l = 0; l < PIX_size; ++l) {
238  noisy[i][j][k][l] = 0;
239  zero[i][j][k][l] = 0;
240  quiet[i][j][k][l] = 0;
241  hiADC[i][j][k][l] = 0;
242  loADC[i][j][k][l] = 0;
243  }
244  }
245  }
246  }
247 
248 
249  int n_entries = ch.GetEntries();
250  std::cout << "Looping over " << n_entries << " events..." << std::endl;
251 
252  // Get run range
253  ch.GetEntry(0);
254  int runlo=Nt->run;
255  ch.GetEntry(n_entries-1);
256  int runhi=Nt->run+1;
257 
258  char title0[50], title1[50], title2[50], title3[50], title4[50], titleL[50], titleH[50], titleD[50];
259  sprintf(title0, "%s Hardware status map Runs %.2u - %.2u", detname.c_str(),runlo,runhi-1);
260  sprintf(title1, "%s Noisy hardware map Runs %.2u - %.2u", detname.c_str(),runlo,runhi-1);
261  sprintf(title2, "%s Quiet hardware map Runs %.2u - %.2u", detname.c_str(), runlo,runhi-1);
262  sprintf(title3, "%s Non-reporting hardware map Runs %.2u - %.2u", detname.c_str(), runlo,runhi-1);
263  TH2D* DetStatusMap = new TH2D("DetStatus",title0,MapXbin,MapXmin,MapXmax,MapYbin,MapYmin,MapYmax);
264  TH2D* DetNoisyMap = new TH2D("DetNoisy",title1,MapXbin,MapXmin,MapXmax,MapYbin,MapYmin,MapYmax);
265  TH2D* DetQuietMap = new TH2D("DetQuiet",title2,MapXbin,MapXmin,MapXmax,MapYbin,MapYmin,MapYmax);
266  TH2D* DetZeroMap = new TH2D( "DetZero",title3,MapXbin,MapXmin,MapXmax,MapYbin,MapYmin,MapYmax);
267  // Initialize datacheck histos... not for display, just stored for checks
268  TH1D* AllRates = new TH1D("AllPixelHitRates",
269  "Rate in all Pixels;rate (Hz);pixels*subrun", 3000, 0, 6000);
270  TH1D* HWstatus = new TH1D("AllFEBscores",
271  "Number of issue pixels in FEBs;issue pixels;FEBs", 33, 0, 33);
272  TH1D* AllRatesNON0 = new TH1D("AllPixelHitRatesNON0",
273  "Rate in all Pixels >0;log10(rate (Hz));pixels*subrun", 70, -1, 6);
274  TH1D* HighADC = new TH1D("AllHighADC",
275  "High ADC (all pixels in run);log10(high ADC rate (Hz));pixels*subrun", 70, -1, 6);
276  TH1D* HighToMipADC = new TH1D("HighToMipADC",
277  "HightoMip ADC (all pixels in run);log10(hightomip ADC rate (Hz));pixels*subrun", 100, 0, 100);
278  // NEW
279  // Fill once per FEB per subrun with the number of shutoffs in that subrun
280  TH1D* AllShutOffs = new TH1D("AllFEBshutOffs",
281  "FEB ShutOff counts;number of shutoff counts per subrun (in 100 event intervals);FEBs*subrun",
282  80, 0, 400);
283  TH1D* AllShutOffs13 = new TH1D("AllFEBshutOffs13",
284  "FEB ShutOff counts;number of shutoff counts per subrun in DB01-03 (in 100 event intervals);FEBs*subrun",
285  80, 0, 400);
286  // Check this as well as HighADC to decide cutoff values
287  TH1D* LowADC = new TH1D("AllLowADC",
288  "Low ADC (all pixels in run);log10(low ADC rate (Hz));pixels*subrun", 70, -1, 6);
289 
290  sprintf(titleL, "%s LowADC hardware map Runs %.2u - %.2u", detname.c_str(), runlo,runhi-1);
291  sprintf(titleH, "%s HighADC hardware map Runs %.2u - %.2u", detname.c_str(), runlo,runhi-1);
292  sprintf(titleD, "%s Dropout hardware map Runs %.2u - %.2u", detname.c_str(), runlo,runhi-1);
293 
294  TH2D* DetLowMap = new TH2D( "DetLow",titleL,MapXbin,MapXmin,MapXmax,MapYbin,MapYmin,MapYmax);
295  TH2D* DetHighMap = new TH2D( "DetHigh",titleH,MapXbin,MapXmin,MapXmax,MapYbin,MapYmin,MapYmax);
296  TH2D* DetDropMap = new TH2D( "DetDrop",titleD,MapXbin,MapXmin,MapXmax,MapYbin,MapYmin,MapYmax);
297 
298 
299  //// make the OnMon hardware label drawer
300  om::HwDetLabel *hwdetlbl = new om::HwDetLabel();
301 
302  //Check for at leat 1 active feb in each diblock (for multi partition running)
303  std::cout<<"Checking for activity in each diblock."<<std::endl;
304  std::vector<bool> activityinDiblock;
305  int counter=0, activeFEB=0, pastdb=14, pastrun=0, pastsubrun=-1;
306  for(int i = 0; i < n_entries; ++i) {
307  ch.GetEntry(i);
308  activityinDiblock.push_back(1);
309  if(Nt->db != pastdb){
310  if(activeFEB==0){
311  std::cout<<"Inactive diblock identified in: Run "<<pastrun<<"/"<<pastsubrun<<" Diblock "<<pastdb<<std::endl;
312  for(int j=i-1;j>i-1-counter;--j){
313  activityinDiblock[j]=0;
314  }
315  }
316  pastdb=Nt->db;
317  activeFEB=0;
318  counter=0;
319  }
320  if(Nt->run!= pastrun){
321  std::cout << "RUN: " << Nt->run << std::endl;
322  pastrun=Nt->run;
323  }
324  if(Nt->subrun!= pastsubrun){
325  pastsubrun=Nt->subrun;
326  }
327  if(Nt->rate>0){
328  activeFEB=1;
329  }
330  else{
331  counter++;
332  }
333  }
334  if(activeFEB==0){
335  std::cout<<"Inactive diblock identified in: Run "<<pastrun<<"/"<<pastsubrun<<" Diblock "<<pastdb<<std::endl;
336  for(int j=n_entries-1;j>n_entries-1-counter;--j){
337  activityinDiblock[j]=0;
338  }
339 
340 
341  }
342 
343  //Count channel issues per subrun & initialize histos
344  std::cout<<"Counting channel issues."<<std::endl;
345  pastrun=0;
346  pastsubrun=-1;
347  int Nsubruns=0;
348  for (int i = 0; i < n_entries; ++i)
349  {
350  ch.GetEntry(i);
351  if(Nt->run!= pastrun){
352  std::cout << "RUN: " << Nt->run << std::endl;
353  pastrun=Nt->run;
354  }
355  if(Nt->subrun!= pastsubrun){
356  pastsubrun=Nt->subrun;
357  Nsubruns++;
358  }
359  if(Nt->db < DBlo-1 || Nt->db > DBhi || activityinDiblock[i]==0) continue;
360  // Save hw address for each FEB
361  if(hwBLK[Nt->db][Nt->dcm][Nt->feb] == -1){
362  hwBLK[Nt->db][Nt->dcm][Nt->feb] = Nt->blk;
363  hwPINB[Nt->db][Nt->dcm][Nt->feb] = Nt->pinb;
364  hwMOD[Nt->db][Nt->dcm][Nt->feb] = Nt->mod;
365  hwVIEW[Nt->db][Nt->dcm][Nt->feb] = Nt->view;
366  hwX[Nt->db][Nt->dcm][Nt->feb] = Nt->hwx;
367  hwY[Nt->db][Nt->dcm][Nt->feb] = Nt->hwy;
368  }
369 
370  // NEW
371  AllShutOffs->Fill(Nt->dropoutCount);
372  if (Nt->db < 4) AllShutOffs13->Fill(Nt->dropoutCount);
373  if (Nt->rateLow > 0){
374  double lograteLo = log10(Nt->rateLow);
375  LowADC->Fill(lograteLo);
376  }
377  if (Nt->rateHigh > 0){
378  double lograteHi = log10(Nt->rateHigh);
379  HighADC->Fill(lograteHi);
380  }
381 
382  FEBsubruncount[Nt->db][Nt->dcm][Nt->feb] ++;
383  AllRates->Fill(Nt->rate);
384  HighToMipADC->Fill(Nt->rateHigh/Nt->rateMip);
385 
386  if(Nt->rate > 0){
387  double lograte = log10(Nt->rate);
388  AllRatesNON0->Fill(lograte);
389  }
390  //Initialize only the histos that will be used
391  if(FEBstatus[Nt->db] == 0){
392  char histoname[50];
393  sprintf(histoname, "%s FEBstatus_%.2u",detname.c_str(), Nt->db);
394  char histotitle[50];
395  sprintf(histotitle, "%s HW status - DB %.2u ;FEB;DCM",detname.c_str(), Nt->db);
396  FEBstatus[Nt->db] = new TH2D(histoname, histotitle, FEB_size, 0, FEB_size, DCM_size-1, 1, DCM_size);
397  char histoname1[50];
398  sprintf(histoname1, "%s zeroFEB_%.2u",detname.c_str(), Nt->db);
399  char histotitle1[50];
400  sprintf(histotitle1, "%s Non reporting HW - DB %.2u ;FEB;DCM", detname.c_str(), Nt->db);
401  FEBzeroPIX[Nt->db] = new TH2D(histoname1, histotitle1, FEB_size, 0, FEB_size, DCM_size-1, 1, DCM_size);
402  char histoname2[50];
403  sprintf(histoname2, "%s noisyFEB_%.2u",detname.c_str(), Nt->db);
404  char histotitle2[50];
405  sprintf(histotitle2, "%s Noisy HW - DB %.2u ;FEB;DCM",detname.c_str(), Nt->db);
406  FEBnoisyPIX[Nt->db] = new TH2D(histoname2, histotitle2, FEB_size, 0, FEB_size, DCM_size-1, 1, DCM_size);
407  char histoname3[50];
408  sprintf(histoname3, "%s quietFEB_%.2u",detname.c_str(), Nt->db);
409  char histotitle3[50];
410  sprintf(histotitle3, "%s Quiet HW - DB %.2u ;FEB;DCM",detname.c_str(), Nt->db);
411  FEBquietPIX[Nt->db] = new TH2D(histoname3, histotitle3, FEB_size, 0, FEB_size, DCM_size-1, 1, DCM_size);
412 
413 
414  // NEW
415  char histoname0[50];
416  sprintf(histoname0, "%s FEBshutoffs_%.2u",detname.c_str(), Nt->db);
417  char histotitle0[50];
418  sprintf(histotitle0, "%s dropouts - DB %.2u ;FEB;DCM",detname.c_str(), Nt->db);
419  FEBshutoffs[Nt->db] = new TH2D(histoname0, histotitle0, FEB_size, 0, FEB_size, DCM_size-1, 1, DCM_size);
420 
421  char histonameH[50];
422  sprintf(histonameH, "%s HighADCrateFEB_%.2u",detname.c_str(), Nt->db);
423  char histotitleH[50];
424  sprintf(histotitleH, "%s HW with High ADC rates - DB %.2u ;FEB;DCM",detname.c_str(), Nt->db);
425  FEBhiADCPIX[Nt->db] = new TH2D(histonameH, histotitleH, FEB_size, 0, FEB_size, DCM_size-1, 1, DCM_size);
426 
427  char histonameL[50];
428  sprintf(histonameL, "%s LowADCrateFEB_%.2u",detname.c_str(), Nt->db);
429  char histotitleL[50];
430  sprintf(histotitleL, "%s HW with Low ADC rates - DB %.2u ;FEB;DCM",detname.c_str(), Nt->db);
431  FEBloADCPIX[Nt->db] = new TH2D(histonameL, histotitleL, FEB_size, 0, FEB_size, DCM_size-1, 1, DCM_size);
432 
433  }
434 
435  bool PixShowsFailure = 0;
436 
437  if(Nt->rate > hithresh){
438  noisy[Nt->db][Nt->dcm][Nt->feb][Nt->pix] = 1;
439  Score[Nt->db][Nt->dcm][Nt->feb] ++;
440  NnoisyPIX[Nt->db][Nt->dcm][Nt->feb] ++;
441  PixShowsFailure = 1;
442  }
443  if(Nt->rate > 0 && Nt->rate < lothresh ){
444  Score[Nt->db][Nt->dcm][Nt->feb] ++;
445  quiet[Nt->db][Nt->dcm][Nt->feb][Nt->pix] = 1;
446  NquietPIX[Nt->db][Nt->dcm][Nt->feb] ++;
447  PixShowsFailure = 1;
448  }
449  if(Nt->rate == 0 ){
450  Score[Nt->db][Nt->dcm][Nt->feb] ++;
451  zero[Nt->db][Nt->dcm][Nt->feb][Nt->pix] = 1;
452  NzeroPIX[Nt->db][Nt->dcm][Nt->feb] ++;
453  PixShowsFailure = 1;
454  }
455 
456  // NEW
457  if ( Nt->rateHigh > 10 ){
458  if ( PixShowsFailure == 0 ) Score[Nt->db][Nt->dcm][Nt->feb] ++;
459  hiADC[Nt->db][Nt->dcm][Nt->feb][Nt->pix] = 1;
460  NhiADCPIX[Nt->db][Nt->dcm][Nt->feb] ++;
461  PixShowsFailure = 1;
462  }
463 
464  if ( Nt->rateLow > 700 ){
465  if ( PixShowsFailure == 0 ) Score[Nt->db][Nt->dcm][Nt->feb] ++;
466  loADC[Nt->db][Nt->dcm][Nt->feb][Nt->pix] = 1;
467  NloADCPIX[Nt->db][Nt->dcm][Nt->feb] ++;
468  PixShowsFailure = 1;
469  }
470 
471  if ( Nt->dropoutCount > 0){
472  if ( PixShowsFailure == 0 ) Score[Nt->db][Nt->dcm][Nt->feb] ++;
473  if ( Nt-> pix == 1) FEBshutoffcount[Nt->db][Nt->dcm][Nt->feb] += Nt->dropoutCount;
474  NdropoutPIX[Nt->db][Nt->dcm][Nt->feb] ++;
475  PixShowsFailure = 1;
476  }
477 
478 
479 
480  }
481  std::cout<<"All entries done. "<<Nsubruns<<" subruns total."<<std::endl;
482  std::cout<<"--------------------------------------------------"<<std::endl;
483 
484 
485  //... Fill histograms with scores ...
486  vector <FEBscore> BadFEBlist;
487  for(int i = 0; i < DB_size; ++i) {
488  for(int j = 0; j < DCM_size; ++j) {
489  for(int k = 0; k < FEB_size; ++k) {
490  //normalize by number of active subruns
491  FEBsubruncount[i][j][k]=FEBsubruncount[i][j][k]/32;
492  if(FEBsubruncount[i][j][k] != Nsubruns) {
493  if(FEBsubruncount[i][j][k]!=0){
494  Score[i][j][k] = Score[i][j][k]/FEBsubruncount[i][j][k];
495  NnoisyPIX[i][j][k] = NnoisyPIX[i][j][k]/FEBsubruncount[i][j][k];
496  NquietPIX[i][j][k] = NquietPIX[i][j][k]/FEBsubruncount[i][j][k];
497  NzeroPIX[i][j][k] = NzeroPIX[i][j][k]/FEBsubruncount[i][j][k];
498  NhiADCPIX[i][j][k] = NhiADCPIX[i][j][k]/FEBsubruncount[i][j][k];
499  NloADCPIX[i][j][k] = NloADCPIX[i][j][k]/FEBsubruncount[i][j][k];
500  NdropoutPIX[i][j][k] = NdropoutPIX[i][j][k]/FEBsubruncount[i][j][k];
501  FEBshutoffcount[i][j][k] = FEBshutoffcount[i][j][k]/FEBsubruncount[i][j][k];
502  }
503  }
504  else{
505  if(Nsubruns!=0){
506  Score[i][j][k] = Score[i][j][k]/Nsubruns;
507  NnoisyPIX[i][j][k] = NnoisyPIX[i][j][k]/Nsubruns;
508  NquietPIX[i][j][k] = NquietPIX[i][j][k]/Nsubruns;
509  NzeroPIX[i][j][k] = NzeroPIX[i][j][k]/Nsubruns;
510  NhiADCPIX[i][j][k] = NhiADCPIX[i][j][k]/Nsubruns;
511  NloADCPIX[i][j][k] = NloADCPIX[i][j][k]/Nsubruns;
512  NdropoutPIX[i][j][k] = NdropoutPIX[i][j][k]/Nsubruns;
513  FEBshutoffcount[i][j][k] = FEBshutoffcount[i][j][k]/Nsubruns; // Now this is number of dropout counts per subrun
514  }
515  }
516  for(int l = 0; l < PIX_size; ++l){
517  if(noisy[i][j][k][l]==1 || quiet[i][j][k][l]==1|| zero[i][j][k][l]==1|| hiADC[i][j][k][l]==1|| loADC[i][j][k][l]==1){
518  BadPIXcount[i][j][k] ++;
519  if(quiet[i][j][k][l]==1) QuietPIXcount[i][j][k] ++;
520  if(noisy[i][j][k][l]==1) NoisyPIXcount[i][j][k] ++;
521  if( zero[i][j][k][l]==1) ZeroPIXcount[i][j][k] ++;
522  if (hiADC[i][j][k][l]==1) HiADCPIXcount[i][j][k] ++;
523  if (loADC[i][j][k][l]==1) LoADCPIXcount[i][j][k] ++;
524  }
525  }
526 
527  // List only connected FEBs for the NearDet (Permanent List from DAQChannelMap)
528  if( (idet==2 && i<4 && (j==1 || j==4) && k > 31)
529  ||( idet==2 && i==4 && j==1 && k>32)
530  ||( idet==2 && i==4 && j==2 && k>21)
531  ||( idet==2 && i==4 && j>2) ){
532  Score[i][j][k]=0;
533  }
534  // List only connected FEBs for the FarDet (Permanent List from Ash River crew)
535  if( (idet==1 && i==4 && j==7 && k==15) || // This is the sawed off module with no electronics
536  (idet==1 && i==5 && j==7 && k==59) || // This module has a cracked snout and no electronics
537  (idet==1 && i==14 && j==6 && k==42) ){ // This module failed the pressure test and did not receive electronics
538  Score[i][j][k]=0;
539  }
540 
541  // List only FEBs with issues
542  double MyScore = Score[i][j][k]/0.32;
543  double MyScoreN = NnoisyPIX[i][j][k]/0.32;
544  double MyScoreQ = NquietPIX[i][j][k]/0.32;
545  double MyScoreZ = NzeroPIX[i][j][k]/0.32;
546  double MyScoreH = NhiADCPIX[i][j][k]/0.32;
547  double MyScoreL = NloADCPIX[i][j][k]/0.32;
548  double MyScoreD = NdropoutPIX[i][j][k]/0.32; // <-Only counted once per FEB
549  double MyDrops = FEBshutoffcount[i][j][k]; // <-NUmber of dropouts per subrun, not a score
550  if(Score[i][j][k]>1 || FEBshutoffcount[i][j][k] > 1){
551  FEBscore StoreThisScore;
552  StoreThisScore.set_values(i,j,k,hwBLK[i][j][k],hwPINB[i][j][k],hwMOD[i][j][k],hwVIEW[i][j][k],
553  hwX[i][j][k],hwY[i][j][k],BadPIXcount[i][j][k],
554  MyScore,MyScoreN,MyScoreQ,MyScoreZ,MyScoreL,MyScoreH, MyScoreD, MyDrops);
555 
556  BadFEBlist.push_back(StoreThisScore);
557  }
558 
559  // Set min above zero for displaying purposes
560  HWstatus->Fill(MyScore);
561  if(MyScore==0) MyScore=MyScore+0.00001;
562  if(MyScoreN==0) MyScoreN=MyScoreN+0.00001;
563  if(MyScoreQ==0) MyScoreQ=MyScoreQ+0.00001;
564  if(MyScoreZ==0) MyScoreZ=MyScoreZ+0.00001;
565  if(MyScoreH==0) MyScoreH=MyScoreH+0.00001;
566  if(MyScoreL==0) MyScoreL=MyScoreL+0.00001;
567  if(MyScoreD==0) MyScoreD=MyScoreD+0.00001;
568  if(FEBstatus[i] != 0) FEBstatus[i]->SetBinContent(k+1,j,MyScore);
569  if(FEBnoisyPIX[i] != 0) FEBnoisyPIX[i]->SetBinContent(k+1,j,MyScoreN);
570  if(FEBquietPIX[i] != 0) FEBquietPIX[i]->SetBinContent(k+1,j,MyScoreQ);
571  if(FEBzeroPIX[i] != 0) FEBzeroPIX[i]->SetBinContent(k+1,j,MyScoreZ);
572  if(FEBhiADCPIX[i] != 0) FEBhiADCPIX[i]->SetBinContent(k+1,j,MyScoreH);
573  if(FEBloADCPIX[i] != 0) FEBloADCPIX[i]->SetBinContent(k+1,j,MyScoreL);
574  if(FEBshutoffs[i] != 0) FEBshutoffs[i]->SetBinContent(k+1,j,MyScoreD);
575 
576 
577  DetStatusMap->SetBinContent(DetStatusMap->FindFixBin(hwX[i][j][k],hwY[i][j][k]),MyScore);
578  DetNoisyMap->SetBinContent(DetNoisyMap->FindFixBin(hwX[i][j][k],hwY[i][j][k]),MyScoreN);
579  DetQuietMap->SetBinContent(DetQuietMap->FindFixBin(hwX[i][j][k],hwY[i][j][k]),MyScoreQ);
580  DetZeroMap->SetBinContent(DetZeroMap->FindFixBin(hwX[i][j][k],hwY[i][j][k]),MyScoreZ);
581  DetLowMap->SetBinContent(DetLowMap->FindFixBin(hwX[i][j][k],hwY[i][j][k]),MyScoreL);
582  DetHighMap->SetBinContent(DetHighMap->FindFixBin(hwX[i][j][k],hwY[i][j][k]),MyScoreH);
583  DetDropMap->SetBinContent(DetDropMap->FindFixBin(hwX[i][j][k],hwY[i][j][k]),MyScoreD);
584  }//k
585  }//j
586  }//i
587 
588 
589  // ... Display partial list, just checking...
590  for(int i=0; i<20; i++){
591  std::cout<<BadFEBlist[i].db<<"\t "<<BadFEBlist[i].dcm<<"\t "<<BadFEBlist[i].feb<<"\t "
592  <<BadFEBlist[i].Nbadpix<<"\t "<<BadFEBlist[i].score<<"\t "
593  <<BadFEBlist[i].scoreN<<"\t "<<BadFEBlist[i].scoreQ<<"\t "<<BadFEBlist[i].scoreZ<<"\t "
594  <<BadFEBlist[i].scoreL<<"\t "<<BadFEBlist[i].scoreH<<"\t "<<BadFEBlist[i].scoreD<<"\t "<<BadFEBlist[i].drops<<std::endl;
595  }
596 
597  // Sort list by score and "bad" pixels
598  std::stable_sort (BadFEBlist.begin(), BadFEBlist.end(), byCount);
599  std::stable_sort (BadFEBlist.begin(), BadFEBlist.end(), byScore);
600  std::cout<<" "<<std::endl;
601 
602  // ... Display partial sorted list, just checking...
603  for(int i=0; i<20; i++){
604  std::cout<<BadFEBlist[i].db<<"\t "<<BadFEBlist[i].dcm<<"\t "<<BadFEBlist[i].feb<<"\t "
605  <<BadFEBlist[i].Nbadpix<<"\t "<<BadFEBlist[i].score<<std::endl;
606  }
607 
608  std::cout<<"Writing out file: HardwareWatchlist.csv ..."<<std::endl;
609  std::ofstream out_file;
610  out_file << std::setprecision(2) << std::fixed;
611  if(idet==1){
612  out_file.open ("FarDetHardwareWatchlist.csv");
613  }
614  if(idet==2){
615  out_file.open ("NearDetHardwareWatchlist.csv");
616  }
617  out_file << runlo <<", "<< runhi-1 <<std::endl;
618  out_file <<"DB,DCM,FEB,BLK,PL,MOD,V,issue rate (score),noisy rate,quiet rate,non-rep rate,lowADC rate,highADC rate,dropout rate,drops per subrun,issue pixels,noisy,quiet,non-reporting"<<std::endl;
619 
620  for(unsigned int i=0; i<BadFEBlist.size(); i++){
621  out_file <<BadFEBlist[i].db<<","<<BadFEBlist[i].dcm<<","<<BadFEBlist[i].feb<<","
622  <<BadFEBlist[i].blk<<","<<BadFEBlist[i].pinb<<","<<BadFEBlist[i].mod<<","<<BadFEBlist[i].view<<","
623  <<BadFEBlist[i].score<<","<<BadFEBlist[i].scoreN<<","<<BadFEBlist[i].scoreQ<<","
624  <<BadFEBlist[i].scoreZ<<","<<BadFEBlist[i].scoreL<<","<<BadFEBlist[i].scoreH<<","
625  <<BadFEBlist[i].scoreD<<","<<BadFEBlist[i].drops<<","<<BadFEBlist[i].Nbadpix<<",";
626  if( NoisyPIXcount[BadFEBlist[i].db][BadFEBlist[i].dcm][BadFEBlist[i].feb] == 32 ) out_file<<"ALL,";
627  else{
628  for(int l=0; l<33;l++){
629  if(noisy[BadFEBlist[i].db][BadFEBlist[i].dcm][BadFEBlist[i].feb][l]==1)
630  out_file << l <<" ";
631  }
632  out_file <<",";
633  }
634  if( QuietPIXcount[BadFEBlist[i].db][BadFEBlist[i].dcm][BadFEBlist[i].feb] == 32 ) out_file<<"ALL,";
635  else{
636  for(int l=0; l<33;l++){
637  if(quiet[BadFEBlist[i].db][BadFEBlist[i].dcm][BadFEBlist[i].feb][l]==1)
638  out_file << l <<" ";
639  }
640  out_file <<",";
641  }
642  if( ZeroPIXcount[BadFEBlist[i].db][BadFEBlist[i].dcm][BadFEBlist[i].feb] == 32 ) out_file<<"ALL";
643  else{
644  for(int l=0; l<33;l++){
645  if(zero[BadFEBlist[i].db][BadFEBlist[i].dcm][BadFEBlist[i].feb][l]==1)
646  out_file << l <<" ";
647  }
648  }
649  out_file <<std::endl;
650  }
651  out_file.close();
652 
653 
654  std::cout<<"Saving Plots... "<<std::endl;
655 
656  char plottitle[50];
657  TLine *lineV[8];
658  TLine *linev[7];
659  TLine *lineh[3];
660  lineV[0] = new TLine( 0, 1, 0, DCM_size);
661  lineV[1] = new TLine(11, 1, 11, DCM_size);
662  lineV[2] = new TLine(21, 1, 21, DCM_size);
663  lineV[3] = new TLine(31, 1, 31, DCM_size);
664  lineV[4] = new TLine(41, 1, 41, DCM_size);
665  lineV[5] = new TLine(51, 1, 51, DCM_size);
666  lineV[6] = new TLine(61, 1, 61, DCM_size);
667  lineV[7] = new TLine(64, 1, 64, DCM_size);
668  linev[0] = new TLine( 6, 1, 6, DCM_size);
669  linev[1] = new TLine(16, 1, 16, DCM_size);
670  linev[2] = new TLine(26, 1, 26, DCM_size);
671  linev[3] = new TLine(36, 1, 36, DCM_size);
672  linev[4] = new TLine(46, 1, 46, DCM_size);
673  linev[5] = new TLine(56, 1, 56, DCM_size);
674  lineh[0] = new TLine( 0, 1, 64, 1);
675  lineh[1] = new TLine( 0, 7, 64, 7);
676  lineh[2] = new TLine( 0,DCM_size, 64, DCM_size);
677  for(int s=0; s<8; s++){
678  lineV[s]->SetLineWidth(2);
679  if(s<6) linev[s]->SetLineWidth(1);
680  if(s<3) lineh[s]->SetLineWidth(2);
681  }
682 
683  //pink for noisy
684  const Int_t NRGBs3 = 3;
685  const Int_t NCont3 = 255;
686  Double_t stops3[NRGBs3] = { 0.00, 0.1, 1.00};
687  Double_t red3[NRGBs3] = { 1.00, 1.00, 0.60};
688  Double_t green3[NRGBs3] = { 0.94, 0.40, 0.00};
689  Double_t blue3[NRGBs3] = { 0.95, 0.70, 0.00};
690 
691  TColor::CreateGradientColorTable(NRGBs3, stops3, red3, green3, blue3, NCont3);
692  gStyle->SetNumberContours(NCont3);
693 
694  for(int i = 0; i < DB_size; ++i) {
695  if(FEBnoisyPIX[i] != 0){
696  TCanvas* cStatusbyDCM = new TCanvas("StatusbyDCM","StatusbyDCM",1000,MapXsize);
697  FEBnoisyPIX[i]->Draw("colz");
698  FEBnoisyPIX[i]->SetStats(0);
699  FEBnoisyPIX[i]->GetXaxis()->SetNdivisions(65, kTRUE);
700  FEBnoisyPIX[i]->GetXaxis()->SetLabelSize(0.03);
701  FEBnoisyPIX[i]->GetXaxis()->CenterLabels();
702  FEBnoisyPIX[i]->GetYaxis()->CenterLabels();
703  FEBnoisyPIX[i]->GetYaxis()->SetNdivisions(MapYdiv, kTRUE);
704  FEBnoisyPIX[i]->GetYaxis()->SetLabelSize(0.06);
705  FEBnoisyPIX[i]->SetMaximum(100);
706  cStatusbyDCM->SetGridy();
707  cStatusbyDCM->SetGridx();
708  for(int s=0; s<8; s++){
709  lineV[s]->Draw();
710  if(s<6) linev[s]->Draw();
711  if(s<3) lineh[s]->Draw();
712  }
713  sprintf(plottitle, "%sHWnoisyDB%.2u.png",detname.c_str(), i);
714 
715  cStatusbyDCM->Print(plottitle, "png");
716  }
717  }
718 
719  TCanvas* cDetNoisy = new TCanvas("cDetNoisy","cDetNoisy",1200,800);
720  DetNoisyMap->SetAxisRange(0,100,"Z");
721  DetNoisyMap->GetXaxis()->SetTickLength(0);
722  DetNoisyMap->GetXaxis()->SetLabelColor(0);
723  DetNoisyMap->GetYaxis()->SetTickLength(0);
724  DetNoisyMap->GetYaxis()->SetLabelColor(0);
725  DetNoisyMap->SetStats(kFALSE);
726  hwdetlbl->Config(DetNoisyMap);
727  DetNoisyMap->Draw("colz");
728  hwdetlbl->Draw();
729  sprintf(plottitle, "%sHWnoisyDet.png",detname.c_str());
730  cDetNoisy->Print(plottitle, "png");
731 
732 
733  //blue for quiet
734  const Int_t NRGBs2 = 3;
735  const Int_t NCont2 = 255;
736  Double_t stops2[NRGBs2] = { 0.00, 0.3, 1.00};
737  Double_t red2[NRGBs2] = { 0.85, 0.25, 0.00};
738  Double_t green2[NRGBs2] = { 0.96, 0.61, 0.00};
739  Double_t blue2[NRGBs2] = { 1.00, 0.98, 0.59};
740  TColor::CreateGradientColorTable(NRGBs2, stops2, red2, green2, blue2, NCont2);
741  gStyle->SetNumberContours(NCont2);
742 
743  for(int i = 0; i < DB_size; ++i) {
744  if(FEBquietPIX[i] != 0){
745  TCanvas* cStatusbyDCM = new TCanvas("StatusbyDCM","StatusbyDCM",1000,MapXsize);
746  FEBquietPIX[i]->Draw("colz");
747  FEBquietPIX[i]->SetStats(0);
748  FEBquietPIX[i]->GetXaxis()->SetNdivisions(65, kTRUE);
749  FEBquietPIX[i]->GetXaxis()->SetLabelSize(0.03);
750  FEBquietPIX[i]->GetXaxis()->CenterLabels();
751  FEBquietPIX[i]->GetYaxis()->CenterLabels();
752  FEBquietPIX[i]->GetYaxis()->SetNdivisions(MapYdiv, kTRUE);
753  FEBquietPIX[i]->GetYaxis()->SetLabelSize(0.06);
754  FEBquietPIX[i]->SetMaximum(100);
755  cStatusbyDCM->SetGridy();
756  cStatusbyDCM->SetGridx();
757  for(int s=0; s<8; s++){
758  lineV[s]->Draw();
759  if(s<6) linev[s]->Draw();
760  if(s<3) lineh[s]->Draw();
761  }
762  sprintf(plottitle, "%sHWquietDB%.2u.png",detname.c_str(), i);
763  cStatusbyDCM->Print(plottitle, "png");
764  }
765  }
766 
767  TCanvas* cDetQuiet = new TCanvas("cDetQuiet","cDetQuiet",1200,800);
768  DetQuietMap->SetAxisRange(0,100,"Z");
769  DetQuietMap->GetXaxis()->SetTickLength(0);
770  DetQuietMap->GetXaxis()->SetLabelColor(0);
771  DetQuietMap->GetYaxis()->SetTickLength(0);
772  DetQuietMap->GetYaxis()->SetLabelColor(0);
773  DetQuietMap->SetStats(kFALSE);
774  hwdetlbl->Config(DetQuietMap);
775  DetQuietMap->Draw("colz");
776  hwdetlbl->Draw();
777 
778  sprintf(plottitle, "%sHWquietDet.png",detname.c_str());
779  cDetQuiet->Print(plottitle, "png");
780 
781 
782  //grey for zero
783  const Int_t NRGBs0 = 3;
784  const Int_t NCont0 = 255;
785  Double_t stops0[NRGBs0] = { 0.00, 0.15, 1.00};
786  Double_t red0[NRGBs0] = { 0.92, 0.45, 0.20};
787  Double_t green0[NRGBs0] = { 0.92, 0.45, 0.20};
788  Double_t blue0[NRGBs0] = { 0.92, 0.45, 0.20};
789  TColor::CreateGradientColorTable(NRGBs0, stops0, red0, green0, blue0, NCont0);
790  gStyle->SetNumberContours(NCont0);
791 
792  for(int i = 0; i < DB_size; ++i) {
793  if(FEBzeroPIX[i] != 0){
794  TCanvas* cStatusbyDCM = new TCanvas("StatusbyDCM","StatusbyDCM",1000,MapXsize);
795  FEBzeroPIX[i]->Draw("colz");
796  FEBzeroPIX[i]->SetStats(0);
797  FEBzeroPIX[i]->GetXaxis()->SetNdivisions(65, kTRUE);
798  FEBzeroPIX[i]->GetXaxis()->SetLabelSize(0.03);
799  FEBzeroPIX[i]->GetXaxis()->CenterLabels();
800  FEBzeroPIX[i]->GetYaxis()->CenterLabels();
801  FEBzeroPIX[i]->GetYaxis()->SetNdivisions(MapYdiv, kTRUE);
802  FEBzeroPIX[i]->GetYaxis()->SetLabelSize(0.06);
803  FEBzeroPIX[i]->SetMaximum(100);
804  cStatusbyDCM->SetGridy();
805  cStatusbyDCM->SetGridx();
806  for(int s=0; s<8; s++){
807  lineV[s]->Draw();
808  if(s<6) linev[s]->Draw();
809  if(s<3) lineh[s]->Draw();
810  }
811 
812  sprintf(plottitle, "%sHWzeroDB%.2u.png",detname.c_str(), i);
813  cStatusbyDCM->Print(plottitle, "png");
814  }
815  }
816 
817  TCanvas* cDetZero = new TCanvas("cDetZero","cDetZero",1200,800);
818  DetZeroMap->SetAxisRange(0,100,"Z");
819  DetZeroMap->GetXaxis()->SetTickLength(0);
820  DetZeroMap->GetXaxis()->SetLabelColor(0);
821  DetZeroMap->GetYaxis()->SetTickLength(0);
822  DetZeroMap->GetYaxis()->SetLabelColor(0);
823  DetZeroMap->SetStats(kFALSE);
824  hwdetlbl->Config(DetZeroMap);
825  DetZeroMap->Draw("colz");
826  hwdetlbl->Draw();
827  sprintf(plottitle, "%sHWzeroDet.png",detname.c_str());
828  cDetZero->Print(plottitle, "png");
829 
830 
831  //colors for score
832  const Int_t NRGBs = 4;
833  const Int_t NCont = 255;
834  Double_t stops[NRGBs] = { 0.00, 0.25, 0.50, 1.00};
835  Double_t red[NRGBs] = { 0.38, 0.97, 1.00, 0.80};
836  Double_t green[NRGBs] = { 0.80, 0.80, 0.50, 0.00};
837  Double_t blue[NRGBs] = { 0.00, 0.20, 0.00, 0.00};
838  TColor::CreateGradientColorTable(NRGBs, stops, red, green, blue, NCont);
839  gStyle->SetNumberContours(NCont);
840 
841 
842 for(int i = 0; i < DB_size; ++i) {
843  if(FEBstatus[i] != 0){
844  TCanvas* cStatusbyDCM = new TCanvas("StatusbyDCM","StatusbyDCM",1000,MapXsize);
845  FEBstatus[i]->Draw("colz");
846  FEBstatus[i]->SetStats(0);
847  FEBstatus[i]->GetXaxis()->SetNdivisions(65, kTRUE);
848  FEBstatus[i]->GetXaxis()->SetLabelSize(0.03);
849  FEBstatus[i]->GetXaxis()->CenterLabels();
850  FEBstatus[i]->GetYaxis()->CenterLabels();
851  FEBstatus[i]->GetYaxis()->SetNdivisions(MapYdiv, kTRUE);
852  FEBstatus[i]->GetYaxis()->SetLabelSize(0.06);
853  FEBstatus[i]->SetMaximum(100);
854  cStatusbyDCM->SetGridy();
855  cStatusbyDCM->SetGridx();
856  for(int s=0; s<8; s++){
857  lineV[s]->Draw();
858  if(s<6) linev[s]->Draw();
859  if(s<3) lineh[s]->Draw();
860  }
861 
862  sprintf(plottitle, "%sHWstatusDB%.2u.png",detname.c_str(), i);
863  cStatusbyDCM->Print(plottitle, "png");
864  }
865  }
866 
867  TCanvas* cDetStatus = new TCanvas("cDetStatus","cDetStatus",1200,800);
868  DetStatusMap->SetAxisRange(0,100,"Z");
869  DetStatusMap->GetXaxis()->SetTickLength(0);
870  DetStatusMap->GetXaxis()->SetLabelColor(0);
871  DetStatusMap->GetYaxis()->SetTickLength(0);
872  DetStatusMap->GetYaxis()->SetLabelColor(0);
873  DetStatusMap->SetStats(kFALSE);
874  hwdetlbl->Config(DetStatusMap);
875  DetStatusMap->Draw("colz");
876  hwdetlbl->Draw();
877  sprintf(plottitle, "%sHWstatusDet.png",detname.c_str());
878  cDetStatus->Print(plottitle, "png");
879 
880  TCanvas* cHWstatus = new TCanvas("cHWstatus","cHWstatus",800,400);
881  int top=HWstatus->GetEntries();
882  TLine *lineTop = new TLine( top, 0, top, 33);
883  lineTop->SetLineStyle(7);
884  HWstatus->SetLineWidth(2);
885  HWstatus->Draw();
886  HWstatus->SetStats(0);
887  cHWstatus->SetLogy();
888  lineTop->Draw();
889  sprintf(plottitle, "%sHWstatusALLDet.png",detname.c_str());
890  cHWstatus->Print(plottitle, "png");
891 
892  TCanvas* cAllRates = new TCanvas("cAllRates","cAllRates",800,400);
893  // int top=HWstatus->GetEntries();
894  // TLine *lineTop = new TLine( top, 0, top, 33);
895  // lineTop->SetLineStyle(7);
896  AllRates->SetLineWidth(2);
897  AllRates->Draw();
898  AllRates->SetStats(0);
899  cAllRates->SetLogy();
900  // lineTop->Draw();
901  sprintf(plottitle, "%sHWAllRates.png",detname.c_str());
902  cAllRates->Print(plottitle, "png");
903 
904 
905  TCanvas* cAllRatesNON0 = new TCanvas("cAllRatesNON0","cAllRatesNON0",800,400);
906  // int top=HWstatus->GetEntries();
907  // TLine *lineTop = new TLine( top, 0, top, 33);
908  // lineTop->SetLineStyle(7);
909  AllRatesNON0->SetLineWidth(2);
910  AllRatesNON0->Draw();
911  AllRatesNON0->SetStats(0);
912 
913  cAllRatesNON0->SetLogy();
914  // lineTop->Draw();
915  sprintf(plottitle, "%sHWAllRatesNON0.png",detname.c_str());
916  cAllRatesNON0->Print(plottitle, "png");
917 
918  TCanvas* cAllRatesNON0All = new TCanvas("cAllRatesNON0All","cAllRatesNON0All",800,400);
919  // int top=HWstatus->GetEntries();
920  // TLine *lineTop = new TLine( top, 0, top, 33);
921  // lineTop->SetLineStyle(7);
922  AllRatesNON0->SetLineWidth(2);
923  AllRatesNON0->Draw();
924  AllRatesNON0->SetStats(0);
925 
926  LowADC->SetLineWidth(2);
927  LowADC->SetLineColor(kViolet-6);
928  LowADC->Draw("same");
929  LowADC->SetStats(0);
930 
931  HighADC->SetLineWidth(2);
932  HighADC->SetLineColor(kOrange+7);
933  HighADC->Draw("same");
934  HighADC->SetStats(0);
935 
936  cAllRatesNON0All->SetLogy();
937  // lineTop->Draw();
938  sprintf(plottitle, "%sHWAllRatesNON0All.png",detname.c_str());
939  cAllRatesNON0All->Print(plottitle, "png");
940 
941  std::cout<<"--------------------------------------------------"<<std::endl;
942  std::cout<<"HWwatchlist.C DONE "<<std::endl;
943  std::cout<<"--------------------------------------------------"<<std::endl;
944 
945  //NEW
946  TCanvas* cAllRatesHi = new TCanvas("cAllRatesHi","cAllRatesHi",800,400);
947  HighADC->SetLineWidth(2);
948  HighADC->Draw();
949  HighADC->SetStats(0);
950  cAllRatesHi->SetLogy();
951  sprintf(plottitle, "%sHWAllRatesHighADC.png",detname.c_str());
952  cAllRatesHi->Print(plottitle, "png");
953 
954  TCanvas* cAllRatesLo = new TCanvas("cAllRatesLo","cAllRatesLo",800,400);
955  LowADC->SetLineWidth(2);
956  LowADC->Draw();
957  LowADC->SetStats(0);
958  cAllRatesLo->SetLogy();
959  sprintf(plottitle, "%sHWAllRatesLowADC.png",detname.c_str());
960  cAllRatesLo->Print(plottitle, "png");
961 
962  TCanvas* cAllShutOffs = new TCanvas("cAllShutOffs","cAllShutOffs",800,400);
963  AllShutOffs->SetLineWidth(2);
964  AllShutOffs->Draw();
965  AllShutOffs->SetStats(0);
966  cAllShutOffs->SetLogy();
967  sprintf(plottitle, "%sHWAllShutoffs.png",detname.c_str());
968  cAllShutOffs->Print(plottitle, "png");
969 
970  TCanvas* cAllShutOffs13 = new TCanvas("cAllShutOffs13","cAllShutOffs13",800,400);
971  AllShutOffs13->SetLineWidth(2);
972  AllShutOffs13->Draw();
973  AllShutOffs13->SetStats(0);
974  cAllShutOffs13->SetLogy();
975  sprintf(plottitle, "%sHWAllShutoffs13.png",detname.c_str());
976  cAllShutOffs13->Print(plottitle, "png");
977 
978 
979  //purple for low
980  const Int_t NRGBs5 = 3;
981  const Int_t NCont5 = 255;
982  Double_t stops5[NRGBs5] = { 0.00, 0.3, 1.00};
983  Double_t red5[NRGBs5] = { 0.96, 0.56, 0.19};
984  Double_t green5[NRGBs5] = { 0.94, 0.40, 0.10};
985  Double_t blue5[NRGBs5] = { 1.00, 1.00, 0.45};
986  TColor::CreateGradientColorTable(NRGBs5, stops5, red5, green5, blue5, NCont5);
987  gStyle->SetNumberContours(NCont5);
988 
989 
990  for(int i = 0; i < DB_size; ++i) {
991  if(FEBloADCPIX[i] != 0){
992  TCanvas* cStatusbyDCM = new TCanvas("StatusbyDCM","StatusbyDCM",1000,MapXsize);
993  FEBloADCPIX[i]->Draw("colz");
994  FEBloADCPIX[i]->SetStats(0);
995  FEBloADCPIX[i]->GetXaxis()->SetNdivisions(65, kTRUE);
996  FEBloADCPIX[i]->GetXaxis()->SetLabelSize(0.03);
997  FEBloADCPIX[i]->GetXaxis()->CenterLabels();
998  FEBloADCPIX[i]->GetYaxis()->CenterLabels();
999  FEBloADCPIX[i]->GetYaxis()->SetNdivisions(MapYdiv, kTRUE);
1000  FEBloADCPIX[i]->GetYaxis()->SetLabelSize(0.06);
1001  FEBloADCPIX[i]->SetMaximum(100);
1002  cStatusbyDCM->SetGridy();
1003  cStatusbyDCM->SetGridx();
1004  for(int s=0; s<8; s++){
1005  lineV[s]->Draw();
1006  if(s<6) linev[s]->Draw();
1007  if(s<3) lineh[s]->Draw();
1008  }
1009  sprintf(plottitle, "%sHWloADCDB%.2u.png",detname.c_str(), i);
1010 
1011  cStatusbyDCM->Print(plottitle, "png");
1012  }
1013  }
1014 
1015 
1016  TCanvas* cDetLow = new TCanvas("cDetLow","cDetLow",1200,800);
1017  DetLowMap->SetAxisRange(0,100,"Z");
1018  DetLowMap->GetXaxis()->SetTickLength(0);
1019  DetLowMap->GetXaxis()->SetLabelColor(0);
1020  DetLowMap->GetYaxis()->SetTickLength(0);
1021  DetLowMap->GetYaxis()->SetLabelColor(0);
1022  DetLowMap->SetStats(kFALSE);
1023  hwdetlbl->Config(DetLowMap);
1024  DetLowMap->Draw("colz");
1025  hwdetlbl->Draw();
1026  sprintf(plottitle, "%sHWlowDet.png",detname.c_str());
1027  cDetLow->Print(plottitle, "png");
1028 
1029 
1030  //orange for hi
1031  const Int_t NRGBs4 = 3;
1032  const Int_t NCont4 = 255;
1033  Double_t stops4[NRGBs4] = { 0.00, 0.3, 1.00};
1034  Double_t red4[NRGBs4] = { 1.00, 1.00, 0.67};
1035  Double_t green4[NRGBs4] = { 0.91, 0.43, 0.18};
1036  Double_t blue4[NRGBs4] = { 0.88, 0.23, 0.00};
1037  TColor::CreateGradientColorTable(NRGBs4, stops4, red4, green4, blue4, NCont4);
1038  gStyle->SetNumberContours(NCont4);
1039 
1040 
1041  for(int i = 0; i < DB_size; ++i) {
1042  if(FEBhiADCPIX[i] != 0){
1043  TCanvas* cStatusbyDCM = new TCanvas("StatusbyDCM","StatusbyDCM",1000,MapXsize);
1044  FEBhiADCPIX[i]->Draw("colz");
1045  FEBhiADCPIX[i]->SetStats(0);
1046  FEBhiADCPIX[i]->GetXaxis()->SetNdivisions(65, kTRUE);
1047  FEBhiADCPIX[i]->GetXaxis()->SetLabelSize(0.03);
1048  FEBhiADCPIX[i]->GetXaxis()->CenterLabels();
1049  FEBhiADCPIX[i]->GetYaxis()->CenterLabels();
1050  FEBhiADCPIX[i]->GetYaxis()->SetNdivisions(MapYdiv, kTRUE);
1051  FEBhiADCPIX[i]->GetYaxis()->SetLabelSize(0.06);
1052  FEBhiADCPIX[i]->SetMaximum(100);
1053  cStatusbyDCM->SetGridy();
1054  cStatusbyDCM->SetGridx();
1055  for(int s=0; s<8; s++){
1056  lineV[s]->Draw();
1057  if(s<6) linev[s]->Draw();
1058  if(s<3) lineh[s]->Draw();
1059  }
1060  sprintf(plottitle, "%sHWhiADCDB%.2u.png",detname.c_str(), i);
1061 
1062  cStatusbyDCM->Print(plottitle, "png");
1063  }
1064  }
1065 
1066 
1067  TCanvas* cDetHigh = new TCanvas("cDetHigh","cDetHigh",1200,800);
1068  DetHighMap->SetAxisRange(0,100,"Z");
1069  DetHighMap->GetXaxis()->SetTickLength(0);
1070  DetHighMap->GetXaxis()->SetLabelColor(0);
1071  DetHighMap->GetYaxis()->SetTickLength(0);
1072  DetHighMap->GetYaxis()->SetLabelColor(0);
1073  DetHighMap->SetStats(kFALSE);
1074  hwdetlbl->Config(DetHighMap);
1075  DetHighMap->Draw("colz");
1076  hwdetlbl->Draw();
1077  sprintf(plottitle, "%sHWhighDet.png",detname.c_str());
1078  cDetHigh->Print(plottitle, "png");
1079 
1080 
1081  // for FEBshutoffs
1082  const Int_t NRGBs6 = 3;
1083  const Int_t NCont6 = 255;
1084  Double_t stops6[NRGBs6] = { 0.00, 0.3, 1.00};
1085  Double_t red6[NRGBs6] = { 1.00, 1.00, 0.67};
1086  Double_t green6[NRGBs6] = { 0.91, 0.43, 0.18};
1087  Double_t blue6[NRGBs6] = { 0.88, 0.23, 0.00};
1088  TColor::CreateGradientColorTable(NRGBs6, stops6, red6, green6, blue6, NCont6);
1089  gStyle->SetNumberContours(NCont6);
1090 
1091 
1092 
1093  for(int i = 0; i < DB_size; ++i) {
1094  if(FEBshutoffs[i] != 0){
1095  TCanvas* cShutoffsbyDCM = new TCanvas("ShutoffsbyDCM","ShutoffsbyDCM",1000,MapXsize);
1096  FEBshutoffs[i]->Draw("colz");
1097  FEBshutoffs[i]->SetStats(0);
1098  FEBshutoffs[i]->GetXaxis()->SetNdivisions(65, kTRUE);
1099  FEBshutoffs[i]->GetXaxis()->SetLabelSize(0.03);
1100  FEBshutoffs[i]->GetXaxis()->CenterLabels();
1101  FEBshutoffs[i]->GetYaxis()->CenterLabels();
1102  FEBshutoffs[i]->GetYaxis()->SetNdivisions(MapYdiv, kTRUE);
1103  FEBshutoffs[i]->GetYaxis()->SetLabelSize(0.06);
1104  FEBshutoffs[i]->SetMaximum(100);
1105  cShutoffsbyDCM->SetGridy();
1106  cShutoffsbyDCM->SetGridx();
1107  for(int s=0; s<8; s++){
1108  lineV[s]->Draw();
1109  if(s<6) linev[s]->Draw();
1110  if(s<3) lineh[s]->Draw();
1111  }
1112  sprintf(plottitle, "%sHWdropDB%.2u.png",detname.c_str(), i);
1113 
1114  cShutoffsbyDCM->Print(plottitle, "png");
1115  }
1116  }
1117 
1118 
1119 
1120  TCanvas* cDetDrop = new TCanvas("cDetDrop","cDetDrop",1200,800);
1121  DetDropMap->SetAxisRange(0,100,"Z");
1122  DetDropMap->GetXaxis()->SetTickLength(0);
1123  DetDropMap->GetXaxis()->SetLabelColor(0);
1124  DetDropMap->GetYaxis()->SetTickLength(0);
1125  DetDropMap->GetYaxis()->SetLabelColor(0);
1126  DetDropMap->SetStats(kFALSE);
1127  hwdetlbl->Config(DetDropMap);
1128  DetDropMap->Draw("colz");
1129  hwdetlbl->Draw();
1130  sprintf(plottitle, "%sHWdropDet.png",detname.c_str());
1131  cDetDrop->Print(plottitle, "png");
1132 
1133 
1134 }
1135 
enum BeamMode kOrange
bool byCount(FEBscore i, FEBscore j)
Definition: HWwatchlist.C:75
double scoreL
Definition: HWwatchlist.C:46
bool bychan(FEBscore i, FEBscore j)
Definition: HWwatchlist.C:76
int view
Definition: HWwatchlist.C:45
double scoreQ
Definition: HWwatchlist.C:46
double scoreZ
Definition: HWwatchlist.C:46
int pinb
Definition: HWwatchlist.C:45
bool byScore(FEBscore i, FEBscore j)
Definition: HWwatchlist.C:74
void set_values(int, int, int, int, int, int, int, int, int, int, double, double, double, double, double, double, double, double)
Definition: HWwatchlist.C:50
const XML_Char * s
Definition: expat.h:262
out_file
Append EOF lines.
Definition: modifyFHiCL.py:113
string infile
tuple blue
Definition: rootlogon.py:65
int NRGBs
Definition: rootlogon.py:77
double score
Definition: HWwatchlist.C:46
int NCont
Definition: rootlogon.py:78
const double j
Definition: BetheBloch.cxx:29
double scoreN
Definition: HWwatchlist.C:46
int Nbadpix
Definition: HWwatchlist.C:45
OStream cout
Definition: OStream.cxx:6
double scoreD
Definition: HWwatchlist.C:46
void makeHWwatchlist(int idet, int lothresh, int hithresh, int DBlo, int DBhi, int timeopt, const std::string &infile)
Definition: HWwatchlist.C:78
ifstream in
Definition: comparison.C:7
double scoreH
Definition: HWwatchlist.C:46
T log10(T number)
Definition: d0nt_math.hpp:120
enum BeamMode kViolet
double drops
Definition: HWwatchlist.C:46
void Config(const TH1 *h)
Definition: HwDetLabel.cxx:21
auto zero()
Definition: PMNS.cxx:47
TGeoVolume * top
Definition: make_fe_box.C:9
enum BeamMode string