AnaPlotMaker.C
Go to the documentation of this file.
1 #include "AnaPlotMaker.h"
2 
3 /// Brief: Make DCM Sync Plots for ND Work
4 /// Status:
5 /// 1. Add logic when dealing with empty instrumented histrogram
6 /// 2. Add booleans and other global variables (keyword: NUEVO)
7 
8 const std::string PLOT_DIR = "/nusoft/app/web/htdoc/nova/datacheck/nearline/plots";
9 //const std::string PLOT_DIR = "/nusoft/app/web/htdoc/nova/datacheck/nearline/test_plots";
10 
11 Long64_t AnaPlotMaker(TString det_type, TString t_prd, TString trigger){
12 
13  if(t_prd == "Day") std::cout << "\n\nMaking FD Ana/Nearline Day plots...\n\n";
14  if(t_prd == "Week") std::cout << "\n\nMaking FD Ana/Nearline Week plots...\n\n";
15  if(t_prd == "Month") std::cout << "\n\nMaking FD Ana/Nearline Month plots...\n\n";
16  if(t_prd == "6Months") std::cout << "\n\nMaking FD Ana/Nearline 6-Months plots...\n\n";
17  if(t_prd == "Year") std::cout << "\n\nMaking FD Ana/Nearline Year plots...\n\n";
18 
19 
20 
21  TNowGMT = new TDatime; // current GMT time
22  TNow = new TDatime; // current local time
23  SRtime = new TDatime;
24  int XNowGMT = TNowGMT->Convert(kTRUE);
25  int XNow = TNow ->Convert(kFALSE);
26 
27  GMToffset = XNowGMT - XNow;
28 
29  XNow = XNow - GMToffset;
30 
31  // Define times used for all time periods of plots.
32  int XDayAgo = XNow - 60*60*24;
33  int XWeekAgo = XNow - 60*60*24*7;
34  int XMonthAgo = XNow - 60*60*24*30;
35  int XSixMonthsAgo = XNow - 60*60*24*26*7;
36  int XYearAgo = XNow - 60*60*24*52*7;
37 
38  // Generic amount of time ago.
39  int time_ago = 0;
40  string det;
41  string period;
42  string trig;
43  string trigname;
44 
45  // NUEVO
46  unsigned int N_diblock = 0;
47  unsigned int N_dcms = 0;
48  bool isND = false;
49  bool isFD = false;
50  // end NUEVO
51 
52  if(det_type == "FarDet"){
53  det = "FarDet";
54  trig = "t02";
55  trigname = " ";
56 
57  //NUEVO
58  N_diblock = 14;
59  N_dcms =12;
60  isFD = true;
61  // end NUEVO
62 
63  if(t_prd == "Day"){
64  period = "Day";
65  time_ago = XDayAgo;
66  }
67  else if(t_prd == "Week"){
68  period = "Week";
69  time_ago = XWeekAgo;
70  }
71  else if(t_prd == "Month"){
72  period = "Month";
73  time_ago = XMonthAgo;
74  }
75  else if(t_prd == "6Months"){
76  period = "6Months";
77  time_ago = XSixMonthsAgo;
78  }
79  else if(t_prd == "Year"){
80  period = "Year";
81  time_ago = XYearAgo;
82  }
83  }
84 
85  if(det_type == "NearDet"){
86  det = "NearDet";
87 
88  //NUEVO
89  N_diblock = 4;
90  N_dcms =4;
91  isND = true;
92  // end NUEVO
93 
94  if (trigger == "t00"){
95  trig = "t00";
96  trigname = "NuMI";
97  }
98  else if(trigger == "DDActivity1"){
99  trig = "DDActivity1";
100  trigname = "DDActivity";
101  }
102  else if(trigger == "t02"){
103  trig = "t02";
104  trigname = "Cosmic";
105  }
106  if(t_prd == "Day"){
107  period = "Day";
108  time_ago = XDayAgo;
109  }
110  else if(t_prd == "Week"){
111  period = "Week";
112  time_ago = XWeekAgo;
113  }
114  else if(t_prd == "Month"){
115  period = "Month";
116  time_ago = XMonthAgo;
117  }
118  else if(t_prd == "6Months"){
119  period = "6Months";
120  time_ago = XSixMonthsAgo;
121  }
122  else if(t_prd == "Year"){
123  period = "Year";
124  time_ago = XYearAgo;
125  }
126  }
127 
128  if(det_type == "TestBeam"){
129  det = "TestBeam";
130 
131  N_diblock = 1;
132  N_dcms =3;
133  isND = false;
134 
135  if (trigger == "Beamline"){
136  trig = "Beamline";
137  trigname = "Beamline";
138  }
139  else if(trigger == "DDActivity1"){
140  trig = "DDActivity1";
141  trigname = "DDActivity";
142  }
143  else if(trigger == "t02"){
144  trig = "t02";
145  trigname = "Cosmic";
146  }
147  else if(trigger == "Spill"){
148  trig = "Spill";
149  trigname = "Full Spill";
150  }
151  if(t_prd == "Day"){
152  period = "Day";
153  time_ago = XDayAgo;
154  }
155  else if(t_prd == "Week"){
156  period = "Week";
157  time_ago = XWeekAgo;
158  }
159  else if(t_prd == "Month"){
160  period = "Month";
161  time_ago = XMonthAgo;
162  }
163  else if(t_prd == "6Months"){
164  period = "6Months";
165  time_ago = XSixMonthsAgo;
166  }
167  else if(t_prd == "Year"){
168  period = "Year";
169  time_ago = XYearAgo;
170  }
171  }
172 
173  int Xsrtime = 0;
174 
175  unsigned int year = 0;
176  unsigned int month = 0;
177  unsigned int day = 0;
178  double Hour = 0.0;
179  double Min = 0.0;
180  int hour = 0;
181  int min = 0;
182  int sec = 0;
183 
184  run = 0;
185  subrun = 0;
186  par = 0;
187 
188  LastRun = 0;
189  LastSR = 0;
190 
191  // Initializing Last_Run and Last_SR
192  for(int i=0;i<5;i++){
193  Last_Run[i]=0;
194  Last_SR[i]=0;
195  }
196 
197  unsigned int yearEnd = 0;
198  unsigned int monthEnd = 0;
199  unsigned int dayEnd = 0;
200  double HourEnd = 0.0;
201 
202  // Root is stupid and you have to make it think that it is in a different time zone so that it will draw any
203  // plots with time on the X-axis correctly.
204  gSystem->Setenv("TZ","UTC");
205  gStyle->SetTimeOffset(0);
206 
207 
208  // Define the number of partitions in the data. Make this number one more
209  // than the actual number so that there can be a default unassigned value.
210  // Define the maximum number of points to go into a TGraph (assuming a max
211  // of one subrun every minute.)
212  int t_n = 1;
213  if(t_prd == "Day") t_n = 1;
214  if(t_prd == "Week") t_n = 7;
215  if(t_prd == "Month") t_n = 30;
216  if(t_prd == "6Months") t_n = 7*26;
217  if(t_prd == "Year") t_n = 7*52;
218  //const unsigned int Npar = 5;
219  const unsigned int Npoint = 1440 * t_n;
220 
221  //Make plots.
222 
223  // std::ifstream inDay;
224  // std::ifstream inFile;
225 
226  // make titles for lists [testing for automatic trigger file name]
227  // char filelist_title[128];
228  if(det_type == "FarDet"){
229  if(t_prd == "Day"){
230  // sprintf(filelist_title,"FDAnaDayFileList_%s.txt",trig.c_str());
231  inFile.open("FDAnaDayFileList_t02.txt");
232  }
233  else if(t_prd == "Week"){
234  // sprintf(filelist_title,"FDAnaWeekFileList_%s.txt",trig.c_str());
235  // inFile.open(filelist_title);
236  inFile.open("FDAnaWeekFileList_t02.txt");
237  }
238  else if(t_prd == "Month"){
239  // sprintf(filelist_title,"FDAnaMonthFileList_%s.txt",trig.c_str());
240  // inFile.open(filelist_title);
241  inFile.open("FDAnaMonthFileList_t02.txt");
242  }
243  else if(t_prd == "6Months"){
244  inFile.open("FDAna6MonthsFileList_t02.txt");
245  }
246  else if(t_prd == "Year"){
247  inFile.open("FDAnaYearFileList_t02.txt");
248  }
249  }
250 
251  if(det_type == "NearDet"){
252  if(t_prd == "Day"){
253  // sprintf(filelist_title,"NDAnaDayFileList_%s.txt",trig.c_str());
254  if(trig== "t00")
255  inFile.open("NDAnaDayFileList_t00.txt");
256  if(trig== "t02")
257  inFile.open("NDAnaDayFileList_t02.txt");
258  else if(trig == "DDActivity1")
259  inFile.open("NDAnaDayFileList_DDActivity1.txt");
260  }
261  else if(t_prd == "Week"){
262  //sprintf(filelist_title,"NDAnaWeekFileList_%s.txt",trig.c_str());
263  if(trig== "t00")
264  inFile.open("NDAnaWeekFileList_t00.txt");
265  if(trig== "t02")
266  inFile.open("NDAnaWeekFileList_t02.txt");
267  else if(trig == "DDActivity1")
268  inFile.open("NDAnaWeekFileList_DDActivity1.txt");
269  }
270  else if(t_prd == "Month"){
271  //sprintf(filelist_title,"NDAnaMonthFileList_%s.txt",trig.c_str());
272  if(trig== "t00")
273  inFile.open("NDAnaMonthFileList_t00.txt");
274  if(trig== "t02")
275  inFile.open("NDAnaMonthFileList_t02.txt");
276  else if(trig == "DDActivity1")
277  inFile.open("NDAnaMonthFileList_DDActivity1.txt");
278  }
279  else if(t_prd == "6Months"){
280  if(trig== "t00")
281  inFile.open("NDAna6MonthsFileList_t00.txt");
282  if(trig== "t02")
283  inFile.open("NDAna6MonthsFileList_t02.txt");
284  else if(trig == "DDActivity1")
285  inFile.open("NDAna6MonthsFileList_DDActivity1.txt");
286  }
287  else if(t_prd == "Year"){
288  if(trig== "t00")
289  inFile.open("NDAnaYearFileList_t00.txt");
290  if(trig== "t02")
291  inFile.open("NDAnaYearFileList_t02.txt");
292  else if(trig == "DDActivity1")
293  inFile.open("NDAnaYearFileList_DDActivity1.txt");
294  }
295  }
296 
297  if(det_type == "TestBeam"){
298  if(t_prd == "Day"){
299  if(trig== "Beamline")
300  inFile.open("TBAnaDayFileList_Beamline.txt");
301  else if(trig== "t02")
302  inFile.open("TBAnaDayFileList_t02.txt");
303  else if(trig == "DDActivity1")
304  inFile.open("TBAnaDayFileList_DDActivity1.txt");
305  else if(trig == "Spill")
306  inFile.open("TBAnaDayFileList_Spill.txt");
307  }
308  else if(t_prd == "Week"){
309  if(trig== "Beamline")
310  inFile.open("TBAnaWeekFileList_Beamline.txt");
311  else if(trig== "t02")
312  inFile.open("TBAnaWeekFileList_t02.txt");
313  else if(trig == "DDActivity1")
314  inFile.open("TBAnaWeekFileList_DDActivity1.txt");
315  else if(trig == "Spill")
316  inFile.open("TBAnaWeekFileList_Spill.txt");
317  }
318  else if(t_prd == "Month"){
319  if(trig== "Beamline")
320  inFile.open("TBAnaMonthFileList_Beamline.txt");
321  else if(trig== "t02")
322  inFile.open("TBAnaMonthFileList_t02.txt");
323  else if(trig == "DDActivity1")
324  inFile.open("TBAnaMonthFileList_DDActivity1.txt");
325  else if(trig == "Spill")
326  inFile.open("TBAnaMonthFileList_Spill.txt");
327  }
328  else if(t_prd == "6Months"){
329  if(trig== "Beamline")
330  inFile.open("TBAna6MonthsFileList_Beamline.txt");
331  else if(trig== "t02")
332  inFile.open("TBAna6MonthsFileList_t02.txt");
333  else if(trig == "DDActivity1")
334  inFile.open("TBAna6MonthsFileList_DDActivity1.txt");
335  else if(trig == "Spill")
336  inFile.open("TBAna6MonthsFileList_Spill.txt");
337  }
338  else if(t_prd == "Year"){
339  if(trig== "Beamline")
340  inFile.open("TBAnaYearFileList_Beamline.txt");
341  else if(trig== "t02")
342  inFile.open("TBAnaYearFileList_t02.txt");
343  else if(trig == "DDActivity1")
344  inFile.open("TBAnaYearFileList_DDActivity1.txt");
345  else if(trig == "Spill")
346  inFile.open("TBAnaYearFileList_Spill.txt");
347  }
348  }
349 
350  //fix trig string
351  if(trigger == "DDActivity1")
352  trig = "Act";
353 
354  // fix this
355  //string filelist("/home/nearline/Nearline-test-releases/FDAnaDayFileList.txt");
356  //inDay.open(filelist);
357  // inDay.open("/home/nearline/Nearline-test-releases/FDAnaDayFileList.txt");
358  //inDay.open("FDAnaDayFileList.txt");
359 
360  // book histos, arrays for TGraphs, etc.
361  TH1F* hNSliceDay[Npar];
362  TH1F* hNNonNoiseSliceHitDay[Npar];
363  TH1F* hNNoiseSliceHitDay[Npar];
364  TH1F* hNonNoiseSlicePEDay[Npar];
365  TH1F* hNoiseSlicePEDay[Npar];
366  TH1F* hTrackPEDay[Npar];
367  TH1F* hTsdDay[Npar];
368  TH1F* hTrackLenDay[Npar];
369  TH1F* hnTrackDay[Npar];
370  TH1F* hCosNumiDay[Npar];
371 
372  TH2F* hPCXaveDay[Npar];
373  TH2F* hPCYaveDay[Npar];
374 
375  TH1F* hnTrackAll3DDay[Npar];
376  TH2F* hTrackStartXZAll3DDay[Npar];
377  TH2F* hTrackStartYZAll3DDay[Npar];
378  TH2F* hTrackStopXZAll3DDay[Npar];
379  TH2F* hTrackStopYZAll3DDay[Npar];
380  TH1F* hTrackLenAll3DDay[Npar];
381 
382  TH1F* hnTrackCont3DDay[Npar];
383  TH2F* hTrackStartXZCont3DDay[Npar];
384  TH2F* hTrackStartYZCont3DDay[Npar];
385  TH2F* hTrackStopXZCont3DDay[Npar];
386  TH2F* hTrackStopYZCont3DDay[Npar];
387  TH1F* hTrackLenCont3DDay[Npar];
388 
389  // NEW PLOTS
390  TH1F* hDeltaSliceTrackDay[Npar];
391  TH1F* hSliceTrackRatioDay[Npar];
392  TH1F* hSliceTrackNHitRatioDay[Npar];
393 
394  // Jose's DCM sync plots
395  TH2F* g3DRateEvo[Npar];
396  TH1F* hNormalization[Npar];
397 
398  //New IFDB beam plots
399  TH1F* hTimeDiffNanoSecDay[Npar];
400  TH1F* hPOTSumDay[Npar];
401  TH1F* hspillPOTDay[Npar];
402  TH1F* hHornCurrentDay[Npar];
403  TH1F* hXPositionDay[Npar];
404  TH1F* hYPositionDay[Npar];
405  TH1F* hXWidthDay[Npar];
406  TH1F* hYWidthDay[Npar];
407  TH1F* hGoodBeamDay[Npar];
408  TH1F* hBadSpillsDay[Npar];
409  //end new plots
410 
411  // Declaration of these floats as pointers gets around the program terminating memory problem that we encountered
412  // when casting them as arrays allocated to "stack" memory.
413  //new beam code
414  float *NTimeDiffNanoSecDay[Npar];
415  float *NTimeDiffNanoSectimeDay[Npar];
416  float *NPOTSumDay[Npar];
417  float *NPOTSumtimeDay[Npar];
418  float *NspillPOTDay[Npar];
419  float *NspillPOTtimeDay[Npar];
420  float *NHornCurrentDay[Npar];
421  float *NHornCurrenttimeDay[Npar];
422  float *NXPositionDay[Npar];
423  float *NXPositiontimeDay[Npar];
424  float *NYPositionDay[Npar];
425  float *NYPositiontimeDay[Npar];
426  float *NXWidthDay[Npar];
427  float *NXWidthtimeDay[Npar];
428  float *NYWidthDay[Npar];
429  float *NYWidthtimeDay[Npar];
430  float *NGoodBeamDay[Npar];
431  float *NGoodBeamtimeDay[Npar];
432  //end new
433  float *NSliceDay[Npar];
434  float *NSlicetimeDay[Npar];
435  int NSliceDayCount[Npar];
436 
437  //new beam plots
438  int NTimeDiffDayCount[Npar];
439  int NHornCurrentDayCount[Npar];
440  int NPOTSumDayCount[Npar];
441  int NspillPOTDayCount[Npar];
442  int NXPositionDayCount[Npar];
443  int NYPositionDayCount[Npar];
444  int NXWidthDayCount[Npar];
445  int NYWidthDayCount[Npar];
446  int NGoodBeamDayCount[Npar];
447 
448  float *NNonNoiseSliceHitDay[Npar];
449  float *NNonNoiseSliceHittimeDay[Npar];
450  float *NNoiseSliceHitDay[Npar];
451  float *NNoiseSliceHittimeDay[Npar];
452  float *NTrackDay[Npar];
453  float *NTracktimeDay[Npar];
454  float *NTrackLenDay[Npar];
455  float *NTrackLentimeDay[Npar];
456  float *NTsdDay[Npar];
457  float *NTsdtimeDay[Npar];
458  int NNonNoiseSliceHitDayCount[Npar];
459  int NNoiseSliceHitDayCount[Npar];
460  int NTrackDayCount[Npar];
461  int NTrackLenDayCount[Npar];
462  //float NTrackLenAll3DDay[Npar][Npoint], NTrackLenAll3DtimeDay[Npar][Npoint]; currently not used but might be in the future
463  int NTrackLenAll3DDayCount[Npar];
464  int NTsdDayCount[Npar];
465 
466  // NEW PLOTS
467  float *TrackFracAll3DDay[Npar];
468  float *TrackFracAll2DDay[Npar];
469  float *TrackFracCont3DDay[Npar];
470  float *TrackFracAll3DtimeDay[Npar];
471  float *TrackFracAll2DtimeDay[Npar];
472  float *TrackFracCont3DtimeDay[Npar];
473  int TrackFracDayCount[Npar];
474 
475  // DCM sync variables
476  double MinDCM;
477  double livetime = 0.;
478  int nevents = 0;
479  int lastevt;
480 
481  // Bin size of 10 min for Evolution plot
482  // i.e 4320 = 30*24*(60/10)
483  int t_nn = 1;
484  if(t_prd == "Day") t_nn = 1;
485  if(t_prd == "Week") t_nn = 7;
486  if(t_prd == "Month") t_nn = 30;
487  if(t_prd == "6Months") t_nn = 7*26;
488  if(t_prd == "Year") t_nn = 7*52;
489 
490  const unsigned int tbins = 144 * t_nn;
491 
492 
493  //NEW LABELS STRIP PLOT
494  TText* t;
495  char buff[16];
496  TLine* l;
497  float Lastevt[Npar];
498  int count[Npar];
499  int fullyinstrdib[Npar];
500  int diblocklast[Npar]; ///< TEST
501  float evoindex, tr3devo, ptime;
502  float lowratemin = 35000.0; ///< Threshold cut value for flaggin low rate DCM
503  int dcm; ///< number of dcms in FarDet
504 
505  float *xtime[Npar];
506  float *minDCM[Npar];
507  //float *minDCMError[Npar];
508  float *sum2dtrk_col[Npar]; ///< add the number of 2D-tracks by column (per diblock)
509  float *sum3dtrk_col[Npar]; ///< add the number of 3D-tracks by column (per diblock)
510  //float *tr3Ddib[Npar][14];
511  //float *tr2Ddib[Npar][14]; ///< Track rate (value/lifetime) for each subrun //N=files or subruns, 14 = diblocks
512  //float *tr3D[Npar][14][12];
513  //float *tr2D[Npar][14][12]; ///< Track rate (value/lifetime) for each subrun //14 = diblocks, 12 = dcms
514  //float *tr3Dfull[Npar];
515  //float *tr2Dfull[Npar]; ///< Track rate (value/lifetime) for each subrun entire detector
516  float sum_hits_col[15]; ///< TO 15 SINCE ENTRY 0 IS EMPTY ALL TIMES IN HISTO
517 
518  // NUEVO: comment this
519  //const unsigned int N_diblock = 14;
520  //const unsigned int N_dcms = 12;
521  // end NUEVO
522 
523  // assigning for every partition an array of dimension Npoint.
524  for(unsigned int i =0; i < Npar; i++){
525  xtime[i] = new float[Npoint];
526  minDCM[i] = new float[Npoint];
527  //minDCMError[i] = new float[Npoint];
528  sum2dtrk_col[i] = new float[Npoint];
529  sum3dtrk_col[i] = new float[Npoint];
530  //tr3Dfull[i] = new float[Npoint];
531  //tr2Dfull[i] = new float[Npoint];
532  //if(t_prd!="Month"){
533  /*
534  for(unsigned int jj=0;jj<14;jj++){
535  tr3Ddib[i][jj] = new float[Npoint];
536  tr2Ddib[i][jj] = new float[Npoint];
537  for(unsigned int kk=0;kk<12;kk++){
538  tr3D[i][jj][kk] = new float[Npoint];
539  tr2D[i][jj][kk] = new float[Npoint];
540  }
541  }
542  */
543  //}
544  //New beam plots
545  NTimeDiffNanoSecDay[i] =new float[Npoint];
546  NTimeDiffNanoSectimeDay[i] =new float[Npoint];
547  NPOTSumDay[i] =new float[Npoint];
548  NPOTSumtimeDay[i] =new float[Npoint];
549  NspillPOTDay[i] =new float[Npoint];
550  NspillPOTtimeDay[i] =new float[Npoint];
551  NHornCurrentDay[i] =new float[Npoint];
552  NHornCurrenttimeDay[i] =new float[Npoint];
553  NXPositionDay[i] =new float[Npoint];
554  NXPositiontimeDay[i] =new float[Npoint];
555  NYPositionDay[i] =new float[Npoint];
556  NYPositiontimeDay[i] =new float[Npoint];
557  NXWidthDay[i] =new float[Npoint];
558  NXWidthtimeDay[i] =new float[Npoint];
559  NYWidthDay[i] =new float[Npoint];
560  NYWidthtimeDay[i] =new float[Npoint];
561  NGoodBeamDay[i] =new float[Npoint];
562  NGoodBeamtimeDay[i] =new float[Npoint];
563  //end new
564  NSliceDay[i] = new float[Npoint];
565  NSlicetimeDay[i] = new float[Npoint];
566  NNonNoiseSliceHitDay[i] = new float[Npoint];
567  NNonNoiseSliceHittimeDay[i] = new float[Npoint];
568  NNoiseSliceHitDay[i] = new float[Npoint];
569  NNoiseSliceHittimeDay[i] = new float[Npoint];
570  NTrackDay[i] = new float[Npoint];
571  NTracktimeDay[i] = new float[Npoint];
572  NTrackLenDay[i] = new float[Npoint];
573  NTrackLentimeDay[i] = new float[Npoint];
574  NTsdDay[i] = new float[Npoint];
575  NTsdtimeDay[i] = new float[Npoint];
576 
577  TrackFracAll3DDay[i] = new float[Npoint];
578  TrackFracAll2DDay[i] = new float[Npoint];
579  TrackFracCont3DDay[i] = new float[Npoint];
580  TrackFracAll3DtimeDay[i] = new float[Npoint];
581  TrackFracAll2DtimeDay[i] = new float[Npoint];
582  TrackFracCont3DtimeDay[i] = new float[Npoint];
583  }
584 
585 
586  string time;
587  if(period == "Day") time = "past 24 hrs.";
588  if(period == "Week") time = "past 7 days";
589  if(period == "Month") time = "past 30 days";
590  if(period == "6Months") time = "past 26 week";
591  if(period == "Year") time = "past 52 weeks";
592 
593  // initalize histos
594  for(unsigned int p = 0; p < Npar; ++p) {
595  count[p]=0;
596  char histoname[56];
597  char histotitle[128];
598 
599  // Adding in histogram names and title for Jose's DCM sync plots
600  sprintf(histoname,"3DRateEvolution%.1u",p);
601  sprintf(histotitle,"%s Rate of Hits from 3D Tracks per DCM vs Time (%s) - partition %.1u; (central time);",trigname.c_str(),time.c_str(),p);
602  g3DRateEvo[p] = new TH2F(histoname,histotitle,tbins,time_ago,XNow,168,0,167); // FIX BINNING HERE LATER
603 
604  sprintf(histoname,"hNormalizationVsTime2Hours%.1u",p);
605  sprintf(histotitle,"%s Temporal Normalization (%s) - partition %.1u",trigname.c_str(),time.c_str(),p);
606  hNormalization[p] = new TH1F(histoname,histotitle,tbins,time_ago,XNow); // FIX BINNING HERE LATER
607 
608  // End of new DCM sync stuff
609  //new beam plots stuff
610  sprintf(histoname,"TimeDiffNanoSecc%.1u",p);
611  sprintf(histotitle,"%s Time Difference(%s) - partition %.1u;Time difference (sec)",trigname.c_str(),time.c_str(), p);
612  hTimeDiffNanoSecDay[p] = new TH1F(histoname,histotitle,500,-0.1,0.6);
613 
614  sprintf(histoname,"POTSum%.1u",p);
615  sprintf(histotitle,"%s Sum POT(%s) - partition %.1u;Sum POT",trigname.c_str(),time.c_str(), p);
616  hPOTSumDay[p] = new TH1F(histoname,histotitle,2,0,1);
617 
618  sprintf(histoname,"SpillPOT%.1u",p);
619  sprintf(histotitle,"%s Spill POT(%s) - partition %.1u;Spill POT",trigname.c_str(),time.c_str(), p);
620  hspillPOTDay[p] = new TH1F(histoname,histotitle,200,0,90e12);
621 
622  sprintf(histoname,"HornCurrent%.1u",p);
623  sprintf(histotitle,"%sHorn Current (%s) - partition %.1u; Horn Current (kA);",trigname.c_str(),time.c_str(), p);
624  hHornCurrentDay[p] = new TH1F(histoname,histotitle,100,-203,-197);
625 
626  sprintf(histoname,"XPosition%.1u",p);
627  sprintf(histotitle,"%s Horizontal Beam Position (mm)(%s) - partition %.1u;Position(mm)",trigname.c_str(),time.c_str(), p);
628  hXPositionDay[p] = new TH1F(histoname,histotitle,240,-2.1,2.1);
629 
630  sprintf(histoname,"YPosition%.1u",p);
631  sprintf(histotitle,"%s Vertical Beam Position (mm)(%s) - partition %.1u;Position(mm)",trigname.c_str(),time.c_str(), p);
632  hYPositionDay[p] = new TH1F(histoname,histotitle,240,-2.1,2.1);
633 
634  sprintf(histoname,"XWidth%.1u",p);
635  sprintf(histotitle,"%s Horizontal Beam Width (mm)(%s) - partition %.1u;Width(mm)",trigname.c_str(),time.c_str(), p);
636  hXWidthDay[p] = new TH1F(histoname,histotitle,150,0.5,2.0);
637 
638  sprintf(histoname,"YWidth%.1u",p);
639  sprintf(histotitle,"%s Vertical Beam Width (mm)(%s) - partition %.1u;Width(mm)",trigname.c_str(),time.c_str(), p);
640  hYWidthDay[p] = new TH1F(histoname,histotitle,150,0.5,2.0);
641 
642  sprintf(histoname,"GoodBeam%.1u",p);
643  sprintf(histotitle,"%s Good Beam(%s) - partition %.1u;",trigname.c_str(),time.c_str(), p);
644  hGoodBeamDay[p] = new TH1F(histoname,histotitle,2,0,2);
645 
646  sprintf(histoname,"BadSpills%.1u",p);
647  sprintf(histotitle,"%s Failure Mode for Bad Spills(%s) - partition %.1u;count",trigname.c_str(),time.c_str(), p);
648  hBadSpillsDay[p] = new TH1F(histoname,histotitle,8,1,9);
649  TAxis *badspillsxaxis = hBadSpillsDay[p]->GetXaxis();
650  badspillsxaxis->SetBinLabel(1,"delta t");
651  badspillsxaxis->SetBinLabel(2,"POT");
652  badspillsxaxis->SetBinLabel(3,"horn I");
653  badspillsxaxis->SetBinLabel(4,"x position");
654  badspillsxaxis->SetBinLabel(5,"y position");
655  badspillsxaxis->SetBinLabel(6,"x width");
656  badspillsxaxis->SetBinLabel(7,"y width");
657  badspillsxaxis->SetBinLabel(8,"Total Bad Spills");
658  //end new beam plots stuff
659 
660  sprintf(histoname,"hNNonNoiseSlice%sP%.1u",period.c_str(),p);
661  sprintf(histotitle,"%s # Non-Noise Slices (%s) - partition %.1u;N Slices;",trigname.c_str(),time.c_str(), p);
662  hNSliceDay[p] = new TH1F(histoname,histotitle,501,-0.5,500.5);
663 
664  sprintf(histoname,"hNNonNoiseSliceHit%sP%.1u",period.c_str(),p);
665  sprintf(histotitle,"%s # Non-Noise Slice Hits (%s) - partition %.1u;N Hits;",trigname.c_str(),time.c_str(),p);
666  hNNonNoiseSliceHitDay[p] = new TH1F(histoname,histotitle,1000,0,5000);
667 
668  sprintf(histoname,"hNNoiseSliceHit%sP%.1u",period.c_str(),p);
669  sprintf(histotitle,"%s # Noise Slice Hits (%s) - partition %.1u;N Hits;",trigname.c_str(),time.c_str(),p);
670  hNNoiseSliceHitDay[p] = new TH1F(histoname,histotitle,8000,0,40000);
671 
672  sprintf(histoname,"hNonNoisePE%sP%.1u",period.c_str(),p);
673  sprintf(histotitle,"%s Non-Noise Slice PE (%s) - partition %.1u;PE;",trigname.c_str(),time.c_str(),p);
674  hNonNoiseSlicePEDay[p] = new TH1F(histoname,histotitle,1862,0,4096);
675 
676  sprintf(histoname,"hNoiseSlicePE%sP%.1u",period.c_str(),p);
677  sprintf(histotitle,"%s Noise Slice PE (%s) - partition %.1u;PE;",trigname.c_str(),time.c_str(),p);
678  hNoiseSlicePEDay[p] = new TH1F(histoname,histotitle,1862,0,4096);
679 
680  sprintf(histoname,"hTrackPE%sP%.1u",period.c_str(),p);
681  sprintf(histotitle,"%s Track PE (%s) - partition %.1u;PE;",trigname.c_str(),time.c_str(),p);
682  hTrackPEDay[p] = new TH1F(histoname,histotitle,1862,0,4096);
683 
684  sprintf(histoname,"hTsd%sP%.1u",period.c_str(),p);
685  sprintf(histotitle,"%s Slice Time Standard Dev. (%s) - partition %.1u;time [ns];",trigname.c_str(),time.c_str(),p);
686  hTsdDay[p] = new TH1F(histoname,histotitle,500000,0,500000);
687 
688  sprintf(histoname,"hTrackLen%sP%.1u",period.c_str(),p);
689  sprintf(histotitle,"%s Track Length (%s) - partition %.1u;length [cm]",trigname.c_str(),time.c_str(),p);
690  hTrackLenDay[p] = new TH1F(histoname,histotitle,650,0,6500);
691 
692  sprintf(histoname,"hnTrack%sP%.1u",period.c_str(),p);
693  sprintf(histotitle,"%s # Tracks (%s) - partition %.1u;N Tracks;",trigname.c_str(),time.c_str(),p);
694  hnTrackDay[p] = new TH1F(histoname,histotitle,301,-0.5,300.5);
695 
696  sprintf(histoname,"hCosNumi%sP%.1u",period.c_str(),p);
697  sprintf(histotitle,"%s Cos(#theta_{NuMI}) (%s) - partition %.1u",trigname.c_str(),time.c_str(),p);
698  hCosNumiDay[p] = new TH1F(histoname,histotitle,202,-1.01,1.01);
699 
700  sprintf(histoname,"hPCXave%sP%.1u",period.c_str(),p);
701  sprintf(histotitle,"%s Average Plane/Cell Hit per Non-Noise Slice XZ-view (%s) - partition %.1u;Plane;Cell",trigname.c_str(),time.c_str(),p);
702  hPCXaveDay[p] = new TH2F(histoname,histotitle,660,-1300.0,20.0,255,-500.0,10.0);
703 
704  sprintf(histoname,"hPCYave%sP%.1u",period.c_str(),p);
705  sprintf(histotitle,"%s Average Plane/Cell Hit per Non-Noise Slice YZ-view (%s) - partition %.1u;Plane;Cell",trigname.c_str(),time.c_str(),p);
706  hPCYaveDay[p] = new TH2F(histoname,histotitle,660,-1300.0,20.0,255,-10.0,500.0);
707 
708  sprintf(histoname,"hnTrackAll3D%sP%.1u",period.c_str(),p);
709  sprintf(histotitle,"%s # 3D Tracks (%s) - partition %.1u;N Tracks;",trigname.c_str(),time.c_str(),p);
710  hnTrackAll3DDay[p] = new TH1F(histoname,histotitle,301,-0.5,300.5);
711 
712  sprintf(histoname,"hTrackStartXZAll3D%sP%.1u",period.c_str(),p);
713  sprintf(histotitle,"%s 3D Track Start Position XZ-view (%s) - partition %.1u;Z [cm];X [cm]",trigname.c_str(),time.c_str(),p);
714  hTrackStartXZAll3DDay[p] = new TH2F(histoname,histotitle,630,-6300.,0.0,160,-800.0,800.0);
715 
716  sprintf(histoname,"hTrackStartYZAll3D%sP%.1u",period.c_str(),p);
717  sprintf(histotitle,"%s 3D Track Start Position YZ-view (%s) - partition %.1u;Z [cm];Y [cm]",trigname.c_str(),time.c_str(),p);
718  hTrackStartYZAll3DDay[p] = new TH2F(histoname,histotitle,630,-6300.0,0.0,160,-800.0,800.0);
719 
720  sprintf(histoname,"hTrackStopXZAll3D%sP%.1u",period.c_str(),p);
721  sprintf(histotitle,"%s 3D Track Stop Position XZ-view (%s) - partition %.1u;Z [cm];X [cm]",trigname.c_str(),time.c_str(),p);
722  hTrackStopXZAll3DDay[p] = new TH2F(histoname,histotitle,630,-6300.0,0.0,160,-800.0,800.0);
723 
724  sprintf(histoname,"hTrackStopYZAll3D%sP%.1u",period.c_str(),p);
725  sprintf(histotitle,"%s 3D Track Stop Position YZ-view (%s) - partition %.1u;Z [cm];Y [cm]",trigname.c_str(),time.c_str(),p);
726  hTrackStopYZAll3DDay[p] = new TH2F(histoname,histotitle,630,-6300.0,0.0,160,-800.0,800.0);
727 
728  sprintf(histoname,"hTrackLenAll3D%sP%.1u",period.c_str(),p);
729  sprintf(histotitle,"%s 3D Track Length (%s) - partition %.1u;length [cm]",trigname.c_str(),time.c_str(),p);
730  hTrackLenAll3DDay[p] = new TH1F(histoname,histotitle,650,0,6500);
731 
732  sprintf(histoname,"hnTrackCont3D%sP%.1u",period.c_str(),p);
733  sprintf(histotitle,"%s # Contained 3D Tracks (%s) - partition %.1u;N Tracks;",trigname.c_str(),time.c_str(),p);
734  hnTrackCont3DDay[p] = new TH1F(histoname,histotitle,301,-0.5,300.5);
735 
736  sprintf(histoname,"hTrackStartXZCont3D%sP%.1u",period.c_str(),p);
737  sprintf(histotitle,"%s Contained 3D Track Start Position XZ-view (%s) - partition %.1u;Z [cm];X [cm]",trigname.c_str(),time.c_str(),p);
738  hTrackStartXZCont3DDay[p] = new TH2F(histoname,histotitle,630,-6300.0,0.0,160,-800.0,800.0);
739 
740  sprintf(histoname,"hTrackStartYZCont3D%sP%.1u",period.c_str(),p);
741  sprintf(histotitle,"%s Contained 3D Track Start Position YZ-view (%s) - partition %.1u;Z [cm];Y [cm]",trigname.c_str(),time.c_str(),p);
742  hTrackStartYZCont3DDay[p] = new TH2F(histoname,histotitle,630,-6300.0,0.0,160,-800.0,800.0);
743 
744  sprintf(histoname,"hTrackStopXZCont3D%sP%.1u",period.c_str(),p);
745  sprintf(histotitle,"%s Contained 3D Track Stop Position XZ-view (%s) - partition %.1u;Z [cm];X [cm]",trigname.c_str(),time.c_str(),p);
746  hTrackStopXZCont3DDay[p] = new TH2F(histoname,histotitle,630,-6300.0,0.0,160,-800.0,800.0);
747 
748  sprintf(histoname,"hTrackStopYZCont3D%sP%.1u",period.c_str(),p);
749  sprintf(histotitle,"%s Contained 3D Track Stop Position YZ-view (%s) - partition %.1u;Z [cm];Y [cm]",trigname.c_str(),time.c_str(),p);
750  hTrackStopYZCont3DDay[p] = new TH2F(histoname,histotitle,630,-6300.0,0.0,160,-800.0,800.0);
751 
752  sprintf(histoname,"hTrackLenCont3D%sP%.1u",period.c_str(),p);
753  sprintf(histotitle,"%s Contained 3D Track Length (%s) - partition %.1u;length [cm]",trigname.c_str(),time.c_str(),p);
754  hTrackLenCont3DDay[p] = new TH1F(histoname,histotitle,650,0,6500);
755 
756  // NEW PLOTS
757  sprintf(histoname,"hDeltaSliceTrack%sP%.1u",period.c_str(),p);
758  sprintf(histotitle,"%s N-slices minus N-3D-tracks per Trigger (%s) - partition %.1u;(N-Sl) - (N-3D-Trk)",trigname.c_str(),time.c_str(),p);
759  hDeltaSliceTrackDay[p] = new TH1F(histoname,histotitle,201,-100.5,100.5);
760 
761  sprintf(histoname,"hSliceTrackRatio%sP%.1u",period.c_str(),p);
762  sprintf(histotitle,"%s Ratio of N-3D-tracks to N-slices per Trigger (%s) - partition %.1u;(N-3D-Tracks)/(N-Slices)",trigname.c_str(),time.c_str(),p);
763  hSliceTrackRatioDay[p] = new TH1F(histoname,histotitle,2000,0.0,20.0);
764 
765  sprintf(histoname,"hSliceTrackNHitRatio%sP%.1u",period.c_str(),p);
766  sprintf(histotitle,"%s NHit Ratio from 3D-tracks to Nhits from Slice per Slice (%s) - partition %.1u;(NHit 3D-Tracks)/(NHit slice)",trigname.c_str(),time.c_str(),p);
767  hSliceTrackNHitRatioDay[p] = new TH1F(histoname,histotitle,101,0.0,1.01);
768 
769  // Efficiency plots
770  sprintf(histoname,"hHitsVwcell%sP%.1u",period.c_str(),p);
771  sprintf(histotitle,"%s Number of Hits vs W (%s) - partition %.1u;",trigname.c_str(),time.c_str(),p);
772  hHitsVwcellDay[p] = new TH2F(histoname,histotitle,344065,-0.5,344064.5,32,-800,800);
773 
774  sprintf(histoname,"hCellsVwcell%sP%.1u",period.c_str(),p);
775  sprintf(histotitle,"%s Number of Cells vs W (%s) - partition %.1u;",trigname.c_str(),time.c_str(),p);
776  hCellsVwcellDay[p] = new TH2F(histoname,histotitle,344065,-0.5,344064.5,32,-800,800);
777 
778  NSliceDayCount[p] = 0;
779  //new beam plots
780  NTimeDiffDayCount[p] = 0;
781  NHornCurrentDayCount[p] = 0;
782  NPOTSumDayCount[p] = 0;
783  NspillPOTDayCount[p] = 0;
784  NXPositionDayCount[p] = 0;
785  NYPositionDayCount[p] = 0;
786  NXWidthDayCount[p] = 0;
787  NYWidthDayCount[p] = 0;
788  NGoodBeamDayCount[p] = 0;
789  //end new
790  NNonNoiseSliceHitDayCount[p] = 0;
791  NNoiseSliceHitDayCount[p] = 0;
792  NTrackDayCount[p] = 0;
793  NTrackLenDayCount[p] = 0;
794  NTrackLenAll3DDayCount[p] = 0;
795  NTsdDayCount[p] = 0;
796 
797  // NEW PLOTS
798  TrackFracDayCount[p] = 0;
799 
800 
801  }
802 
803  std::cout<<" FILE OPEN "<<std::endl;
804  while(inFile.good()) {
805  char filenameD[512];
806  inFile >> filenameD;
807  //added to prevent code from running over the last file twice
808  if(!inFile.good()) continue;
809  std::cout << filenameD << std::endl;
810  TFile fileD(filenameD);
811  fileD.cd("nearlineana");
812  TTree *header = (TTree *)fileD.FindObjectAny("Header");
813  //////////////////////////////////////////////////////////////
814  // BREAK - SEGMENTATION VIOLATION ERROR MESSAGE SOLVED HERE // TEMPORAL?
815  /*
816  if(!header) {
817  std::cerr<<" File with no header! Skipping... "<<std::endl;
818  continue;
819  }
820  else{
821  */
822  //////////////////////////////////////////////////////////////
823  if(header != 0) {
824  header->SetBranchAddress("StartYear", &year);
825  header->SetBranchAddress("StartMonth", &month);
826  header->SetBranchAddress("StartDay", &day);
827  header->SetBranchAddress("StartHour", &Hour);
828  header->SetBranchAddress("EndYear", &yearEnd);
829  header->SetBranchAddress("EndMonth", &monthEnd);
830  header->SetBranchAddress("EndDay", &dayEnd);
831  header->SetBranchAddress("EndHour", &HourEnd);
832  header->SetBranchAddress("Run", &run);
833  header->SetBranchAddress("Subrun", &subrun);
834  header->SetBranchAddress("Partition", &par);
835  header->SetBranchAddress("LiveTime", &livetime); // Added for DCM sync plots 08-20-2014
836  header->SetBranchAddress("Nevents", &nevents); // Added for DCM sync plots 08-20-2014
837  header->GetEntry(0);
838 
839  hour = Hour;
840  Min = (Hour-hour)*60.0;
841  min = (Hour-hour)*60.0;
842  sec = (Min-min)*60.0;
843 
844  // Ana/DAQ keeps track of GMT time, so convert to local time
845  SRtime->Set(year,month,day,hour,min,sec);
846  Xsrtime = SRtime->Convert() - GMToffset;
847  std::cout << "Datetime: " << year << "-" << month << "-" << day << " " << Hour << std::endl;
848  hour = HourEnd;
849  Min = (HourEnd-hour)*60.0;
850  min = (HourEnd-hour)*60.0;
851  sec = (Min-min)*60.0;
852 
853  // Get the end time and compute subrun duration.
854  SRtime->Set(yearEnd,monthEnd,dayEnd,hour,min,sec);
855 
856  if(Xsrtime < time_ago) continue;
857 
858  if(run >= Last_Run[par]) {
859  if(run > Last_Run[par]) {
860  Last_Run[par] = run;
861  Last_SR[par] = subrun;
862  }
863  else if(subrun > Last_SR[par]) {
864  Last_Run[par] = run;
865  Last_SR[par] = subrun;
866  }
867  }
868 
869  // Storing last run and sub run for each partition...tis a test.
870  /*if(par==0){
871  Last_Run[0] = LastRun;
872  Last_SR[0] = LastSR;
873  }
874  if(par==1){
875  Last_Run[1] = LastRun;
876  Last_SR[1] = LastSR;
877  }
878  if(par==2){
879  Last_Run[2] = LastRun;
880  Last_SR[2] = LastSR;
881  }
882  if(par==3){
883  Last_Run[3] = LastRun;
884  Last_SR[3] = LastSR;
885  }
886  if(par==4){
887  Last_Run[4] = LastRun;
888  Last_SR[4] = LastSR;
889  }*/
890 
891  }
892 
893  std::cout << t_prd << " loop: adding run " << run << ", subrun " << subrun << std::endl;
894 
895  // Find DCM sync histograms from reco_hist root files
896  TH2F *hit = (TH2F*)fileD.FindObjectAny("H3DHitOnTrack");
897  TH2F *instr = (TH2F*)fileD.FindObjectAny("instrumented"); //MAP OF INSTRUMENTED DETECTOR (i.e. DCM WITH > 50 APDS)
898 
899  TH2F *trk3 = (TH2F*)fileD.FindObjectAny("H3DTrackNum");
900  TH2F *trk2 = (TH2F*)fileD.FindObjectAny("H2DTrackNum");
901 
902  evoindex=0.;
903  fullyinstrdib[par] = 0;
904  diblocklast[par] = 0;
905 
906 
907  if((hit !=0)){
908  /*
909  if(!hit){ // TEMPORAL??
910  std::cerr<<" There is no Hits from 3D Track Histogram!! Skipping... "<<std::endl;
911  continue;
912  }
913  else{
914  */
915 
916  //NUEVO: xdiblock<=N_diblock
917  for(unsigned int xdiblock =1; xdiblock <=14; xdiblock++){
918  sum_hits_col[xdiblock]=0.;
919 
920  for(unsigned int yldc =1; yldc <=N_dcms; yldc++){
921  sum_hits_col[xdiblock] += hit->GetBinContent(xdiblock,yldc);
922  }
923  if(sum_hits_col[xdiblock] > 0){
924  ++fullyinstrdib[par];
925  diblocklast[par] = xdiblock; /// TEST
926  }
927  } //for xdiblock
928 
929  } //else
930 
931 
932  //tr3Dfull[par][count[par]]=0.;
933  //tr2Dfull[par][count[par]]=0.;
934 
935  // IMPORTANT: MUST GUARATNEE LIVETIME IS NEVER ZERO
936  if(livetime == 0) livetime = 550000*1.0E-9*nevents;
937 
938  int init_dib = diblocklast[par] - fullyinstrdib[par] +1; // counts 1st db of partition
939 
940  MinDCM = 99999.99;
941 
942  // NUEVO
943 
944  // The negative instead...
945 
946  bool noInstr = false;
947 
948  if((!instr) || instr->GetEntries() == 0){
949  //std::cout<<"==============================================================================================="<<std::endl;
950  //std::cout<<"==============================================================================================="<<std::endl;
951  //std::cout<<" "<<std::endl;
952  //std::cout<<" "<<std::endl;
953  //std::cout<<" NearlineAna files have empty OR missing Instrumented Histograms!! processing will continue... "<<std::endl;
954  //std::cout<<" "<<std::endl;
955  //std::cout<<" "<<std::endl;
956  //std::cout<<"==============================================================================================="<<std::endl;
957  //std::cout<<"==============================================================================================="<<std::endl;
958 
959  noInstr = true;
960  }
961 
962  // Dealing with funky instr histos
963  if(isND && (instr->GetEntries() > 14)) noInstr = true;
964  //end NUEVO
965 
966 
967  for(int xbin= init_dib; xbin <= diblocklast[par]; xbin++){
968 
969  sum3dtrk_col[par][xbin]=0.;
970  sum2dtrk_col[par][xbin]=0.;
971 
972  //NUEVO
973 
974  //NUEVO: ybin<=N_dcms
975  for(unsigned int ybin=1; ybin<=N_dcms; ++ybin){ //counts for each dcm
976 
977  if(noInstr){
978 
979  if(isND){
980 
981  // Last two dcms on db 4 are not instrumented in ND
982  if((xbin==4 && ybin==3) ||(xbin ==4 && ybin ==4)) continue;
983 
984  evoindex=float(N_dcms)*(xbin-1.)+ybin-1.;
985 
986  //GETTING: PER DIBLOCK SUM OF TRACKS
987  sum3dtrk_col[par][xbin] += trk3->GetBinContent(xbin,ybin); //get the sum of 3D tracks for each diblock
988  sum2dtrk_col[par][xbin] += trk2->GetBinContent(xbin,ybin); //get the sum of 2D tracks for each diblock
989 
990  if((hit->GetBinContent(xbin, ybin))/(livetime) < MinDCM){
991  MinDCM = (hit->GetBinContent(xbin, ybin))/(livetime); // rate = value/livetime
992  }
993 
994  else{
995  continue;
996  }
997 
998  //TIME EVOLUTION-STRIP PLOT
999  hNormalization[par]->Fill(Xsrtime); //NORMALIZATION FOR STRIP PLOT
1000  tr3devo = hit->GetBinContent(hit->FindBin(xbin,ybin))/(livetime); //Hits from 3D Tracks
1001  //if(tr3devo > 2.5*MinDCM ){ // IS RELATED TO Min3DRate PLOT OR WHERE GAP BEGINS
1002  if(tr3devo < lowratemin ){
1003  g3DRateEvo[par]->Fill(Xsrtime,evoindex,tr3devo);
1004  }
1005 
1006  }//isND
1007  else if(isFD){
1008 
1009  evoindex=float(N_dcms)*(xbin-1.)+ybin-1.;
1010  //GETTING: PER DIBLOCK SUM OF TRACKS
1011  sum3dtrk_col[par][xbin] += trk3->GetBinContent(xbin,ybin); //get the sum of 3D tracks for each diblock
1012  sum2dtrk_col[par][xbin] += trk2->GetBinContent(xbin,ybin); //get the sum of 2D tracks for each diblock
1013 
1014  if((hit->GetBinContent(xbin, ybin))/(livetime) < MinDCM){
1015 
1016  MinDCM = (hit->GetBinContent(xbin, ybin))/(livetime); // rate = value/livetime
1017 
1018  }
1019  else{
1020  continue;
1021  }
1022 
1023  //TIME EVOLUTION-STRIP PLOT
1024  hNormalization[par]->Fill(Xsrtime); //NORMALIZATION FOR STRIP PLOT
1025  tr3devo = hit->GetBinContent(hit->FindBin(xbin,ybin))/(livetime); //Hits from 3D Tracks
1026  //if(tr3devo > 2.5*MinDCM ){ // IS RELATED TO Min3DRate PLOT OR WHERE GAP BEGINS
1027 
1028  if(tr3devo < lowratemin ){
1029  g3DRateEvo[par]->Fill(Xsrtime,evoindex,tr3devo);
1030  }
1031 
1032  }//end isFD
1033  else{
1034  continue;
1035  }
1036  }//end noInstr //end NUEVO
1037  else if(instr-> GetBinContent(xbin,ybin) > 0){ //Get those DCMs with +50 APDs only and neglect the rest
1038  //NUEVO: float(N_dcms)
1039  evoindex=float(N_dcms)*(xbin-1.)+ybin-1.;
1040 
1041  sum3dtrk_col[par][xbin] += trk3->GetBinContent(xbin,ybin); //get the sum of 3D tracks for each diblock
1042  sum2dtrk_col[par][xbin] += trk2->GetBinContent(xbin,ybin); //get the sum of 2D tracks for each diblock
1043 
1044  //PER DCM RATE OF TRACKS
1045  //if(t_prd!="Month"){
1046  //tr3D[par][xbin][ybin][count[par]] = trk3->GetBinContent(xbin,ybin)/(livetime);
1047  //tr2D[par][xbin][ybin][count[par]] = trk2->GetBinContent(xbin,ybin)/(livetime);
1048  //}
1049  ////////////////////////////////////////////////////////////////////////////
1050 
1051  //TIME EVOLUTION-STRIP PLOT
1052  hNormalization[par]->Fill(Xsrtime); //NORMALIZATION FOR STRIP PLOT
1053  tr3devo = hit->GetBinContent(hit->FindBin(xbin,ybin))/(livetime); //Hits from 3D Tracks
1054 
1055  //PLOTTING THE NEGATIVE: IF LOW RATE THEN PRINT IT
1056  if(tr3devo < lowratemin ){ // IS RELATED TO Min3DRate PLOT OR WHERE GAP BEGINS
1057  g3DRateEvo[par]->Fill(Xsrtime,evoindex,tr3devo);
1058  }
1059  //===========================================================================================
1060 
1061  //MINIMUM HISTOGRAM
1062  if((hit->GetBinContent(xbin, ybin))/(livetime) < MinDCM){
1063 
1064  MinDCM = (hit->GetBinContent(xbin, ybin))/(livetime); // rate = value/livetime
1065 
1066  }
1067  else{
1068  continue;
1069  }
1070 
1071  //===========================================================================================
1072  }//end if/else
1073  }//end for //counter here gives 168 = total no. dcms in FarDet
1074  }//end for //gives 14 = no. of diblocks
1075  //}
1076 
1077  minDCM[par][count[par]] = MinDCM;
1078  xtime[par][count[par]] = Xsrtime;
1079  count[par]++;
1080 
1081 
1082 
1083  TH1F *hnSlicetemp = (TH1F*)fileD.FindObjectAny("fNumSlices");
1084  if(hnSlicetemp != 0){
1085  hNSliceDay[par]->Add(hnSlicetemp,1.0);
1086  }
1087  if(hnSlicetemp != 0 && header !=0) {
1088  NSlicetimeDay[par][NSliceDayCount[par]] = Xsrtime;
1089  NSliceDay [par][NSliceDayCount[par]] = hnSlicetemp->GetMean(1);
1090  NSliceDayCount[par]++;
1091  }
1092  //new beam stuff stuff
1093  TH1F *hTimeDifftemp = (TH1F*)fileD.FindObjectAny("fTimeDiffNanoSec");
1094  if(hTimeDifftemp != 0){
1095  hTimeDiffNanoSecDay[par]->Add(hTimeDifftemp,1.0);
1096  }
1097  if(hTimeDifftemp != 0 && header !=0) {
1098  NTimeDiffNanoSectimeDay[par][NTimeDiffDayCount[par]] = Xsrtime;
1099  NTimeDiffNanoSecDay [par][NTimeDiffDayCount[par]] = hTimeDifftemp->GetMean(1);
1100  NTimeDiffDayCount[par]++;
1101  }
1102 
1103  TH1F *hPOTSumtemp = (TH1F*)fileD.FindObjectAny("fPOTSum");
1104  if(hPOTSumtemp != 0){
1105  hPOTSumDay[par]->Add(hPOTSumtemp,1.0);
1106  }
1107  if(hPOTSumtemp != 0 && header !=0) {
1108  NPOTSumtimeDay[par][NPOTSumDayCount[par]] = Xsrtime;
1109  NPOTSumDay [par][NPOTSumDayCount[par]] = hPOTSumtemp->GetBinContent(1);//we want the value in the first bin (this is the POT)
1110  NPOTSumDayCount[par]++;
1111  }
1112 
1113  TH1F *hspillPOTtemp = (TH1F*)fileD.FindObjectAny("fspillPOT");
1114  if(hspillPOTtemp != 0){
1115  hspillPOTDay[par]->Add(hspillPOTtemp,1.0);
1116  }
1117  if(hspillPOTtemp != 0 && header !=0) {
1118  NspillPOTtimeDay[par][NspillPOTDayCount[par]] = Xsrtime;
1119  NspillPOTDay [par][NspillPOTDayCount[par]] = hspillPOTtemp->GetMean(1);
1120  NspillPOTDayCount[par]++;
1121  }
1122 
1123  TH1F *hXPositiontemp = (TH1F*)fileD.FindObjectAny("fXPosition");
1124  if(hXPositiontemp != 0){
1125  hXPositionDay[par]->Add(hXPositiontemp,1.0);
1126  }
1127  if(hXPositiontemp != 0 && header !=0) {
1128  NXPositiontimeDay[par][NXPositionDayCount[par]] = Xsrtime;
1129  NXPositionDay [par][NXPositionDayCount[par]] = hXPositiontemp->GetMean(1);
1130  NXPositionDayCount[par]++;
1131  }
1132 
1133  TH1F *hYPositiontemp = (TH1F*)fileD.FindObjectAny("fYPosition");
1134  if(hYPositiontemp != 0){
1135  hYPositionDay[par]->Add(hYPositiontemp,1.0);
1136  }
1137  if(hYPositiontemp != 0 && header !=0) {
1138  NYPositiontimeDay[par][NYPositionDayCount[par]] = Xsrtime;
1139  NYPositionDay [par][NYPositionDayCount[par]] = hYPositiontemp->GetMean(1);
1140  NYPositionDayCount[par]++;
1141  }
1142 
1143  TH1F *hXWidthtemp = (TH1F*)fileD.FindObjectAny("fXWidth");
1144  if(hXWidthtemp != 0){
1145  hXWidthDay[par]->Add(hXWidthtemp,1.0);
1146  }
1147  if(hXWidthtemp != 0 && header !=0) {
1148  NXWidthtimeDay[par][NXWidthDayCount[par]] = Xsrtime;
1149  NXWidthDay [par][NXWidthDayCount[par]] = hXWidthtemp->GetMean(1);
1150  NXWidthDayCount[par]++;
1151  }
1152 
1153  TH1F *hYWidthtemp = (TH1F*)fileD.FindObjectAny("fYWidth");
1154  if(hYWidthtemp != 0){
1155  hYWidthDay[par]->Add(hYWidthtemp,1.0);
1156  }
1157  if(hYWidthtemp != 0 && header !=0) {
1158  NYWidthtimeDay[par][NYWidthDayCount[par]] = Xsrtime;
1159  NYWidthDay [par][NYWidthDayCount[par]] = hYWidthtemp->GetMean(1);
1160  NYWidthDayCount[par]++;
1161  }
1162 
1163 
1164  TH1F *hGoodBeamtemp = (TH1F*)fileD.FindObjectAny("fGoodBeam");
1165  if(hGoodBeamtemp != 0){
1166  hGoodBeamDay[par]->Add(hGoodBeamtemp,1.0);
1167  }
1168  if(hGoodBeamtemp != 0 && header !=0) {
1169  NGoodBeamtimeDay[par][NGoodBeamDayCount[par]] = Xsrtime;
1170  NGoodBeamDay [par][NGoodBeamDayCount[par]] = hGoodBeamtemp->GetMean(1);
1171  NGoodBeamDayCount[par]++;
1172  }
1173 
1174  TH1F *hBadSpillstemp = (TH1F*)fileD.FindObjectAny("fBadSpills");
1175  if(hBadSpillstemp != 0){
1176  hBadSpillsDay[par]->Add(hBadSpillstemp,1.0);
1177  }
1178 
1179  TH1F *hHornCurrenttemp = (TH1F*)fileD.FindObjectAny("fHornCurrent");
1180  if(hHornCurrenttemp != 0){
1181  hHornCurrentDay[par]->Add(hHornCurrenttemp,1.0);
1182  }
1183  if(hHornCurrenttemp != 0 && header !=0) {
1184  NHornCurrenttimeDay[par][NHornCurrentDayCount[par]] = Xsrtime;
1185  NHornCurrentDay [par][NHornCurrentDayCount[par]] = hHornCurrenttemp->GetMean(1);
1186  NHornCurrentDayCount[par]++;
1187  }
1188 
1189  //end new beam plots
1190  TH1F *hnSliceHittemp = (TH1F*)fileD.FindObjectAny("fNumHits");
1191  if(hnSliceHittemp != 0){
1192  hNNonNoiseSliceHitDay[par]->Add(hnSliceHittemp,1.0);
1193  }
1194  if(hnSliceHittemp != 0 && header !=0) {
1195  NNonNoiseSliceHittimeDay[par][NNonNoiseSliceHitDayCount[par]] = Xsrtime;
1196  NNonNoiseSliceHitDay [par][NNonNoiseSliceHitDayCount[par]] = hnSliceHittemp->GetMean(1);
1197  NNonNoiseSliceHitDayCount[par]++;
1198  }
1199 
1200  TH1F *hnNoiseSliceHittemp = (TH1F*)fileD.FindObjectAny("fNumHitsNoise");
1201  if(hnNoiseSliceHittemp != 0){
1202  hNNoiseSliceHitDay[par]->Add(hnNoiseSliceHittemp,1.0);
1203  }
1204  if(hnNoiseSliceHittemp != 0 && header !=0) {
1205  NNoiseSliceHittimeDay[par][NNoiseSliceHitDayCount[par]] = Xsrtime;
1206  NNoiseSliceHitDay [par][NNoiseSliceHitDayCount[par]] = hnNoiseSliceHittemp->GetMean(1);
1207  NNoiseSliceHitDayCount[par]++;
1208  }
1209 
1210 
1211  TH1F *hNonNoiseSlicePEtemp = (TH1F*)fileD.FindObjectAny("fPENonNoiseHits");
1212  if(hNonNoiseSlicePEtemp != 0){
1213  hNonNoiseSlicePEDay[par]->Add(hNonNoiseSlicePEtemp,1.0);
1214  }
1215 
1216 
1217  TH1F *hNoiseSlicePEtemp = (TH1F*)fileD.FindObjectAny("fPENoiseHits");
1218  if(hNoiseSlicePEtemp != 0){
1219  hNoiseSlicePEDay[par]->Add(hNoiseSlicePEtemp,1.0);
1220  }
1221 
1222  TH1F *hTrackPEtemp = (TH1F*)fileD.FindObjectAny("fPETrackHitsAll3D");
1223  if(hTrackPEtemp != 0){
1224  hTrackPEDay[par]->Add(hTrackPEtemp,1.0);
1225  }
1226 
1227  TH1F *hTsdtemp = (TH1F*)fileD.FindObjectAny("fTsd");
1228  if(hTsdtemp != 0){
1229  hTsdDay[par]->Add(hTsdtemp,1.0);
1230  }
1231  if(hTsdtemp != 0 && header !=0) {
1232  NTsdtimeDay[par][NTsdDayCount[par]] = Xsrtime;
1233  NTsdDay [par][NTsdDayCount[par]] = hTsdtemp->GetMean(1);
1234  NTsdDayCount[par]++;
1235  }
1236 
1237  TH1F *hnTracktemp = (TH1F*)fileD.FindObjectAny("fNumTracksAll3D");
1238  if(hnTracktemp != 0){
1239  hnTrackDay[par]->Add(hnTracktemp,1.0);
1240  }
1241  if(hnTracktemp != 0 && header !=0) {
1242  NTracktimeDay[par][NTrackDayCount[par]] = Xsrtime;
1243  NTrackDay [par][NTrackDayCount[par]] = hnTracktemp->GetMean(1);
1244  NTrackDayCount[par]++;
1245  }
1246 
1247  TH1F *hTrackLentemp = (TH1F*)fileD.FindObjectAny("fTrackLengthAll3D");
1248  if(hTrackLentemp != 0){
1249  hTrackLenDay[par]->Add(hTrackLentemp,1.0);
1250  }
1251  if(hTrackLentemp != 0 && header !=0) {
1252  NTrackLentimeDay[par][NTrackLenDayCount[par]] = Xsrtime;
1253  NTrackLenDay [par][NTrackLenDayCount[par]] = hTrackLentemp->GetMean(1);
1254  NTrackLenDayCount[par]++;
1255  }
1256 
1257  TH1F *hCosNumitemp = (TH1F*)fileD.FindObjectAny("fTrackCosNumiAll3D");
1258  if(hCosNumitemp != 0){
1259  hCosNumiDay[par]->Add(hCosNumitemp,1.0);
1260  }
1261 
1262  TH2F *hPCXavetemp = (TH2F*)fileD.FindObjectAny("fPCXaveCR");
1263  if(hPCXavetemp != 0) {
1264  hPCXaveDay[par]->Add(hPCXavetemp,1.0);
1265  }
1266 
1267  TH2F *hPCYavetemp = (TH2F*)fileD.FindObjectAny("fPCYaveCR");
1268  if(hPCYavetemp != 0) {
1269  hPCYaveDay[par]->Add(hPCYavetemp,1.0);
1270  }
1271 
1272  TH1F *hnTrackAll3Dtemp = (TH1F*)fileD.FindObjectAny("fNumTracksAll3D");
1273  if(hnTrackAll3Dtemp != 0){
1274  hnTrackAll3DDay[par]->Add(hnTrackAll3Dtemp,1.0);
1275  }
1276 
1277  TH2F *hTrackStartXZAll3Dtemp = (TH2F*)fileD.FindObjectAny("fStartPointTrackXZCRAll3D");
1278  if(hTrackStartXZAll3Dtemp != 0) {
1279  hTrackStartXZAll3DDay[par]->Add(hTrackStartXZAll3Dtemp,1.0);
1280  }
1281 
1282  TH2F *hTrackStartYZAll3Dtemp = (TH2F*)fileD.FindObjectAny("fStartPointTrackYZCRAll3D");
1283  if(hTrackStartYZAll3Dtemp != 0) {
1284  hTrackStartYZAll3DDay[par]->Add(hTrackStartYZAll3Dtemp,1.0);
1285  }
1286 
1287  TH2F *hTrackStopXZAll3Dtemp = (TH2F*)fileD.FindObjectAny("fStopPointTrackXZCRAll3D");
1288  if(hTrackStopXZAll3Dtemp != 0) {
1289  hTrackStopXZAll3DDay[par]->Add(hTrackStopXZAll3Dtemp,1.0);
1290  }
1291 
1292  TH2F *hTrackStopYZAll3Dtemp = (TH2F*)fileD.FindObjectAny("fStopPointTrackYZCRAll3D");
1293  if(hTrackStopYZAll3Dtemp != 0) {
1294  hTrackStopYZAll3DDay[par]->Add(hTrackStopYZAll3Dtemp,1.0);
1295  }
1296 
1297  TH1F *hTrackLengthAll3Dtemp = (TH1F*)fileD.FindObjectAny("fTrackLengthAll3D");
1298  if(hTrackLengthAll3Dtemp != 0){
1299  hTrackLenAll3DDay[par]->Add(hTrackLengthAll3Dtemp,1.0);
1300  }
1301 
1302  TH1F *hnTrackCont3Dtemp = (TH1F*)fileD.FindObjectAny("fNumTracksCont3D");
1303  if(hnTrackCont3Dtemp != 0){
1304  hnTrackCont3DDay[par]->Add(hnTrackCont3Dtemp,1.0);
1305  }
1306 
1307  TH2F *hTrackStartXZCont3Dtemp = (TH2F*)fileD.FindObjectAny("fStartPointTrackXZCRCont3D");
1308  if(hTrackStartXZCont3Dtemp != 0) {
1309  hTrackStartXZCont3DDay[par]->Add(hTrackStartXZCont3Dtemp,1.0);
1310  }
1311 
1312  TH2F *hTrackStartYZCont3Dtemp = (TH2F*)fileD.FindObjectAny("fStartPointTrackYZCRCont3D");
1313  if(hTrackStartYZCont3Dtemp != 0) {
1314  hTrackStartYZCont3DDay[par]->Add(hTrackStartYZCont3Dtemp,1.0);
1315  }
1316 
1317  TH2F *hTrackStopXZCont3Dtemp = (TH2F*)fileD.FindObjectAny("fStopPointTrackXZCRCont3D");
1318  if(hTrackStopXZCont3Dtemp != 0) {
1319  hTrackStopXZCont3DDay[par]->Add(hTrackStopXZCont3Dtemp,1.0);
1320  }
1321 
1322  TH2F *hTrackStopYZCont3Dtemp = (TH2F*)fileD.FindObjectAny("fStopPointTrackYZCRCont3D");
1323  if(hTrackStopYZCont3Dtemp != 0) {
1324  hTrackStopYZCont3DDay[par]->Add(hTrackStopYZCont3Dtemp,1.0);
1325  }
1326 
1327  TH1F *hTrackLengthCont3Dtemp = (TH1F*)fileD.FindObjectAny("fTrackLengthCont3D");
1328  if(hTrackLengthCont3Dtemp != 0){
1329  hTrackLenCont3DDay[par]->Add(hTrackLengthCont3Dtemp,1.0);
1330  }
1331 
1332  /*if(hTrackLenAll3Dtemp != 0 && header !=0) {
1333  NTrackLenAll3DtimeDay[par][NTrackLenAll3DDayCount[par]] = Xsrtime;
1334  NTrackLenAll3DDay [par][NTrackLenAll3DDayCount[par]] = hTrackLenAll3Dtemp->GetMean(1);
1335  NTrackLenAll3DDayCount[par]++;
1336  }*/
1337 
1338  // NEW PLOTS
1339  TH1F *hDSlTrktemp = (TH1F*)fileD.FindObjectAny("fDeltaSliceTrack");
1340  if(hDSlTrktemp != 0) {
1341  hDeltaSliceTrackDay[par]->Add(hDSlTrktemp,1.0);
1342  }
1343 
1344  TH1F *hSlTrkRtemp = (TH1F*)fileD.FindObjectAny("fSliceTrackRatio");
1345  if(hSlTrkRtemp != 0) {
1346  hSliceTrackRatioDay[par]->Add(hSlTrkRtemp,1.0);
1347  }
1348 
1349  TH1F *hSlTrkNHRtemp = (TH1F*)fileD.FindObjectAny("fSliceTrackNHitRatio");
1350  if(hSlTrkNHRtemp != 0) {
1351  hSliceTrackNHitRatioDay[par]->Add(hSlTrkNHRtemp,1.0);
1352  }
1353 
1354  TH1F *hTrackFracAll3Dtemp = (TH1F*)fileD.FindObjectAny("fTrackFractionAll3D");
1355  TH1F *hTrackFracAll2Dtemp = (TH1F*)fileD.FindObjectAny("fTrackFractionAll2D");
1356  TH1F *hTrackFracCont3Dtemp = (TH1F*)fileD.FindObjectAny("fTrackFractionCont3D");
1357  if(hTrackFracAll3Dtemp != 0 && hTrackFracAll2Dtemp != 0 &&
1358  hTrackFracCont3Dtemp != 0 && header !=0) {
1359  TrackFracAll3DtimeDay[par][TrackFracDayCount[par]] = Xsrtime;
1360  TrackFracAll3DDay [par][TrackFracDayCount[par]] = hTrackFracAll3Dtemp->GetMean(1);
1361  //TrackFracAll3DDay[par][TrackFracDayCount[par]] = hTrackFracAll3Dtemp->GetMean(1);
1362 
1363 
1364  TrackFracAll2DtimeDay[par][TrackFracDayCount[par]] = Xsrtime;
1365  TrackFracAll2DDay [par][TrackFracDayCount[par]] = hTrackFracAll2Dtemp->GetMean(1);
1366 
1367  TrackFracCont3DtimeDay[par][TrackFracDayCount[par]] = Xsrtime;
1368  TrackFracCont3DDay [par][TrackFracDayCount[par]] = hTrackFracCont3Dtemp->GetMean(1);
1369 
1370  TrackFracDayCount[par]++;
1371  }
1372 
1373  fileD.cd("hitefficiencyana");
1374  TH2F *hHitsVwcelltemp = (TH2F*)fileD.FindObjectAny("hitsVwcell");
1375  if(hHitsVwcelltemp != 0){
1376  hHitsVwcellDay[par]->Add(hHitsVwcelltemp,1.0);
1377  }
1378 
1379  TH2F *hCellsVwcelltemp = (TH2F*)fileD.FindObjectAny("cellsVwcell");
1380  if(hCellsVwcelltemp != 0){
1381  hCellsVwcellDay[par]->Add(hCellsVwcelltemp,1.0);
1382  }
1383 
1384 
1385  fileD.Close();
1386  } // end while loop
1387 
1388  /////////////////////////////////////////////////////////////////////////////////////////////////////
1389  //NORMALIZATION STRIP PLOT FOR DCM SYNC STUFF
1390  for(unsigned int p=0; p < Npar; ++p){
1391  for(int i = 0; i < g3DRateEvo[p]->GetNbinsX(); ++i){
1392  double norma = hNormalization[p]->GetBinContent(hNormalization[p]->GetBin(i));
1393  for(int j =0; j< g3DRateEvo[p]->GetNbinsY(); ++j){
1394  double content = 0.0;
1395  if(norma > 0.0) content = (g3DRateEvo[p]->GetBinContent(g3DRateEvo[p]->GetBin(i,j)))/(norma);
1396  g3DRateEvo[p]->SetBinContent(g3DRateEvo[p]->GetBin(i,j),content);
1397  }
1398  }
1399  }
1400 
1401  // Define last run and subrun unique to each partition. Define here as to avoid overwriting same value many times.
1402  // Last_Run[par] = LastRun;
1403  // Last_SR[par] = LastSR;
1404 
1405  //
1406  // Make time/date stamp for each plot
1407  //
1408  TDatime *Ttemp = new TDatime; // finish time
1409  int Xfin = Ttemp->Convert() - GMToffset;
1410  TDatime *Tfinish = new TDatime(Xfin); // finish time
1411  // std::cout<<Tfinish->AsString()<<std::endl;
1412  /* TPaveText *UpdateText = new TPaveText(0.1, 0.0, 0.5, 0.05, "NDC");
1413  UpdateText->SetLineColor(0);
1414  UpdateText->SetFillColor(0);
1415  UpdateText->SetBorderSize(1);
1416  UpdateText->SetMargin(0.0);
1417  UpdateText->SetTextAlign(11);*/
1418  char buff1[256];
1419  //sprintf(buff1, "Last updated on: %s (central time)", Tfinish->AsString());
1420  //UpdateText->AddText(buff1);
1421  char buff2[256];
1422  //sprintf(buff2, "Last run / subrun: %d / %d", LastRun, LastSR);
1423  //UpdateText->AddText(buff2);*/
1424 
1425  TPaveText *StatusText = new TPaveText(0.1, 0.1, 0.9, 0.9, "NDC");
1426  StatusText->SetLineColor(1);
1427  StatusText->SetFillColor(0);
1428  StatusText->SetBorderSize(1);
1429  // StatusText->SetMargin(0.0);
1430  StatusText->AddText(buff1);
1431  StatusText->AddText(buff2);
1432 
1433  TCanvas *cStatus = new TCanvas("cStatus","FD Status",800,200);
1434  cStatus->cd();
1435  StatusText->Draw();
1436  //cStatus->Print("/nusoft/app/web/htdoc/nova/datacheck/nearline/plots/DCMsyncTEST/FarDetAnaStatus.png");
1437  cStatus->Print("/nusoft/app/web/htdoc/nova/datacheck/nearline/plots/FarDetAnaStatus.png");
1438 
1439  //
1440  // Draw pretty canvases...
1441  //
1442  int maxtime = 0;
1443  double max = 0.0, ave = 0.0;
1444  TPaveText *LastPoint = new TPaveText(0.3,0.88,0.93,0.93,"NDC");
1445  LastPoint->SetLineColor(1);
1446  LastPoint->SetFillColor(0);
1447  LastPoint->SetBorderSize(1);
1448  char lptext[128];
1449 
1450  /*
1451  TLine *L1x = new TLine(0,0,0,384);
1452  TLine *L2x = new TLine(0,384,896,384);
1453  TLine *L3x = new TLine(0,0,896,0);
1454  TLine *L4x = new TLine(896,0,896,384);
1455  TLine *L1y = new TLine(0,0,0,384);
1456  TLine *L2y = new TLine(0,384,896,384);
1457  TLine *L3y = new TLine(0,0,896,0);
1458  TLine *L4y = new TLine(896,0,896,384);
1459  L1x->SetLineWidth(2);
1460  L2x->SetLineWidth(2);
1461  L3x->SetLineWidth(2);
1462  L4x->SetLineWidth(2);
1463  L1y->SetLineWidth(2);
1464  L2y->SetLineWidth(2);
1465  L3y->SetLineWidth(2);
1466  L4y->SetLineWidth(2);
1467  */
1468 
1469  // Make conditional standard time axis labels depending on period (Day, Week, Month)
1470  string taxis_labels;
1471  if(period == "Day"){
1472  taxis_labels = "%H:%M";
1473  }
1474  else{
1475  taxis_labels = "%m/%d";
1476  }
1477 
1478  TLine *L1x;
1479  TLine *L2x;
1480  TLine *L3x;
1481  TLine *L4x;
1482  TLine *L1y;
1483  TLine *L2y;
1484  TLine *L3y;
1485  TLine *L4y;
1486 
1487 
1488  // New lines defined in Control Room view...
1489  if(det_type=="NearDet"){
1490  L1x = new TLine(0,0,0,-96);
1491  L2x = new TLine(0,-96,-214,-96);
1492  L3x = new TLine(0,0,-214,0);
1493  L4x = new TLine(-214,0,-214,-96);
1494  L1y = new TLine(0,0,0,96);
1495  L2y = new TLine(0,96,-214,96);
1496  L3y = new TLine(0,0,-214,0);
1497  L4y = new TLine(-214,0,-214,96);
1498  }
1499  else if(det_type=="TestBeam"){
1500  L1x = new TLine(0,0,0,-64);
1501  L2x = new TLine(0,-64,-63,-64);
1502  L3x = new TLine(0,0,-63,0);
1503  L4x = new TLine(-63,0,-63,-64);
1504  L1y = new TLine(0,0,0,64);
1505  L2y = new TLine(0,64,-63,64);
1506  L3y = new TLine(0,0,-63,0);
1507  L4y = new TLine(-63,0,-63,64);
1508  }
1509  else{
1510  L1x = new TLine(0,0,0,-384);
1511  L2x = new TLine(0,-384,-896,-384);
1512  L3x = new TLine(0,0,-896,0);
1513  L4x = new TLine(-896,0,-896,-384);
1514  L1y = new TLine(0,0,0,384);
1515  L2y = new TLine(0,384,-896,384);
1516  L3y = new TLine(0,0,-896,0);
1517  L4y = new TLine(-896,0,-896,384);
1518  }
1519  L1x->SetLineWidth(2);
1520  L2x->SetLineWidth(2);
1521  L3x->SetLineWidth(2);
1522  L4x->SetLineWidth(2);
1523  L1y->SetLineWidth(2);
1524  L2y->SetLineWidth(2);
1525  L3y->SetLineWidth(2);
1526  L4y->SetLineWidth(2);
1527 
1528  // loop over all partitions to make 24 hour plots
1529  for(unsigned int p = 0; p < Npar; ++p) {
1530  char filename[128];
1531  char title[128];
1532 
1533  TPaveText *UpdateText = new TPaveText(0.1, 0.0, 0.5, 0.05, "NDC");
1534  UpdateText->SetLineColor(0);
1535  UpdateText->SetFillColor(0);
1536  UpdateText->SetBorderSize(1);
1537  UpdateText->SetMargin(0.0);
1538  UpdateText->SetTextAlign(11);
1539  char buff3[256];
1540  char buff4[256];
1541  sprintf(buff3, "Last updated on: %s (central time)", Tfinish->AsString());
1542  UpdateText->AddText(buff3);
1543 
1544  //UInt_t lcl_lastrun = Last_Run[p];
1545  //UInt_t lcl_lastsr = Last_SR[p];
1546  // Adding last run and subrun per partition inside of par loop.
1547  sprintf(buff4, "Last run / subrun: %i / %i", Last_Run[p], Last_SR[p]);
1548  UpdateText->AddText(buff4);
1549  //delete buff3;
1550 
1551  // Draw DCM sync plots
1552  //////////////////////////////////////////////////////
1553 
1554  maxtime = 0;
1555  max = 0.0;
1556  ave = 0.0;
1557  for(int s = 0; s < count[p]; ++s) {
1558  ave += (double)minDCM[p][s];
1559  if(minDCM[p][s] > maxtime) {
1560  maxtime = xtime[p][s];
1561  max = minDCM[p][s];
1562  }
1563  }
1564  if(count[p] > 0) ave = ave/(double)count[p];
1565  sprintf(lptext,"Last Point = %.f / Average = %f",max,ave);
1566  LastPoint->Clear();
1567  LastPoint->AddText(lptext);
1568 
1569  //MINIMUM OF THE RATE OF HITS ON 3D TRACKS (DMC-SYNC)
1570  //if(t_prd!="Month"){
1571  TCanvas *cMin3D = new TCanvas("cMin3D","Minimum of the Rate of Hits on 3D Tracks",1000,700);
1572  cMin3D->cd();
1573  cMin3D->SetGridy();
1574 
1575  TGraph *gmin = new TGraph(count[p],xtime[p],minDCM[p]); //minDCMError was used but set to 0 for now //dim
1576  sprintf(title,"%s Minimum of the Rate of Hits on 3D Tracks vs Time (DCM Sync) %s - partition %2.2d",trigname.c_str(),time.c_str(), p);
1577  gmin->SetTitle(title);
1578  gmin->GetXaxis()->SetTimeDisplay(1);
1579  gmin->GetXaxis()->SetLabelSize(0.03);
1580  gmin->GetXaxis()->SetTimeFormat(taxis_labels.c_str());
1581  gmin->GetXaxis()->SetLimits(time_ago,XNow);
1582  gmin->SetMarkerStyle(7); //prev 21
1583 
1584  gmin->GetYaxis()->SetTitle("MinHit3D [Hz]");
1585  gmin->GetYaxis()->SetTitleOffset(1.45);
1586 
1587  gmin->GetXaxis()->SetTitle("(central time)");
1588  gmin->GetXaxis()->SetLabelOffset(0.015);
1589  gmin->GetXaxis()->SetTitleOffset(1.25);
1590  gmin->SetMarkerColor(4);
1591 
1592  gmin->Draw("AP"); //"A*"
1593  UpdateText->Draw();
1594  LastPoint->Draw();
1595 
1596  sprintf(filename,"%s/%s-%s-P%.1uMin_rate_3DTrks_%s.png",PLOT_DIR.c_str(),det.c_str(),trig.c_str(),p,period.c_str());
1597  cMin3D->Print(filename);
1598  delete cMin3D;
1599  cMin3D = 0;
1600 
1601  ///////////////////////////////////////////////////////////
1602  //STRIP PLOT i.e. EVOLUTION PLOT
1603 
1604  TCanvas *cRate3Devo = new TCanvas("cRate3Devo","Rate of Hits from 3D Tracks per DCM vs Time",1100,700);
1605  cRate3Devo->cd();
1606  cRate3Devo->SetLogz();
1607 
1608  gPad->SetGridx();
1609 
1610  g3DRateEvo[p]->GetXaxis()->SetTimeDisplay(1);
1611  g3DRateEvo[p]->GetXaxis()->SetLabelSize(0.03);
1612  g3DRateEvo[p]->GetXaxis()->SetTimeFormat(taxis_labels.c_str());
1613  g3DRateEvo[p]->GetXaxis()->SetLimits(time_ago,XNow);
1614  g3DRateEvo[p]->GetXaxis()->SetLabelOffset(0.015);
1615 
1616  g3DRateEvo[p]->GetXaxis()->SetTitleOffset(1.25);
1617  g3DRateEvo[p]->GetYaxis()->SetTitleOffset(1.05);
1618 
1619  g3DRateEvo[p]->GetYaxis()->SetTickLength(0);
1620  g3DRateEvo[p]->GetYaxis()->SetLabelColor(0);
1621 
1622  g3DRateEvo[p]->SetStats(kFALSE);
1623 
1624  g3DRateEvo[p]->Draw("colz");
1625  UpdateText->Draw();
1626 
1627  //DIBLOCK LABELS FOR STRIP PLOT
1628  for(int i=1; i<14; ++i){
1629  //l = new TLine(XMonthAgo,i*12.,XNow,i*12.);
1630  l = new TLine(time_ago,i*12.,XNow,i*12.);
1631  l->SetLineColor(kBlack);
1632  l->SetLineWidth(2);
1633  l->SetBit(kCannotPick);
1634  l->Draw("same");
1635  }
1636 
1637  for (int i=0; i<14; ++i) {
1638  sprintf(buff,"DB%.2d",i+1);
1639  buff[15]=0;
1640  //t = new TText(XMonthAgo-10000.,12*(i+0.5),buff);
1641  t = new TText(time_ago-10000.,12*(i+0.5),buff);
1642  t->SetTextAlign(32);
1643  t->SetTextSize(0.03);
1644  t->SetBit(kCannotPick);
1645  //fText.push_back(t);
1646  t->Draw("same");
1647  }
1648 
1649  sprintf(filename,"%s/%s-%s-P%.1u3DHitTrackRateEvolution%s.png",PLOT_DIR.c_str(),det.c_str(),trig.c_str(),p,period.c_str());
1650  cRate3Devo->Print(filename);
1651  delete cRate3Devo;
1652  cRate3Devo = 0;
1653 
1654  //new beam plots
1655  TCanvas *cTimeDiffday = new TCanvas("cTimeDiffday","Time Difference Day",1200,800);
1656  cTimeDiffday->cd();
1657  gStyle->SetOptStat(111111);
1658  hTimeDiffNanoSecDay[p]->SetLineWidth(2);
1659  hTimeDiffNanoSecDay[p]->Draw();
1660  cTimeDiffday->Update();
1661  double lmax=gPad->GetUymax();
1662  TLine* lTimeDiff=new TLine(0.5,0,0.5,lmax);
1663  lTimeDiff->SetLineColor(kRed);
1664  lTimeDiff->SetLineWidth(3);
1665  lTimeDiff->SetLineStyle(9);
1666  lTimeDiff->Draw();
1667  hTimeDiffNanoSecDay[p]->Draw("same");
1668  UpdateText->Draw();
1669  sprintf(filename,"%s/%s-%s-P%.1uTimeDiffDBBeamSpill%s.png",PLOT_DIR.c_str(),det.c_str(),trig.c_str(),p,period.c_str());
1670  cTimeDiffday->Print(filename);
1671  delete cTimeDiffday;
1672  cTimeDiffday = 0;
1673 
1674  TCanvas *cPOTSumday = new TCanvas("cPOTSumday","POT Sum Day",1200,800);
1675  cPOTSumday->cd();
1676  gStyle->SetOptStat(111111);
1677  hPOTSumDay[p]->SetAxisRange(0.0,0.25,"X");
1678  hPOTSumDay[p]->SetLineWidth(2);
1679  hPOTSumDay[p]->GetYaxis()->SetTitle("(POT)");
1680  hPOTSumDay[p]->GetXaxis()->SetTitle("");
1681  hPOTSumDay[p]->Draw();
1682  UpdateText->Draw();
1683  sprintf(filename,"%s/%s-%s-P%.1uPOTSum%s.png",PLOT_DIR.c_str(),det.c_str(),trig.c_str(),p,period.c_str());
1684  cPOTSumday->Print(filename);
1685  delete cPOTSumday;
1686  cPOTSumday = 0;
1687 
1688  TCanvas *cspillPOTday = new TCanvas("cspillPOTday","spill POT Day",1200,800);
1689  cspillPOTday->cd();
1690  gStyle->SetOptStat(111111);
1691  hspillPOTDay[p]->SetLineWidth(2);
1692  hspillPOTDay[p]->Draw();
1693  UpdateText->Draw();
1694  cspillPOTday->Update();
1695  lmax=gPad->GetUymax();
1696  TLine* lspillPOT=new TLine(2e12,0,2e12,lmax);
1697  lspillPOT->SetLineColor(kRed);
1698  lspillPOT->SetLineWidth(3);
1699  lspillPOT->SetLineStyle(9);
1700  lspillPOT->Draw();
1701  hspillPOTDay[p]->Draw("same");
1702  sprintf(filename,"%s/%s-%s-P%.1uspillPOT%s.png",PLOT_DIR.c_str(),det.c_str(),trig.c_str(),p,period.c_str());
1703  cspillPOTday->Print(filename);
1704  delete cspillPOTday;
1705  cspillPOTday = 0;
1706 
1707  TCanvas *cHornCurrentday = new TCanvas("cHornCurrentday","Time Difference Day",1200,800);
1708  cHornCurrentday->cd();
1709  gStyle->SetOptStat(111111);
1710  hHornCurrentDay[p]->SetAxisRange(-202.5,-197.5,"X");
1711  hHornCurrentDay[p]->SetLineWidth(2);
1712  hHornCurrentDay[p]->Draw();
1713  cHornCurrentday->Update();
1714  lmax=gPad->GetUymax();
1715  TLine* lHornCurrent=new TLine(-202,0,-202,lmax);
1716  TLine* l2HornCurrent=new TLine(-198,0,-198,lmax);
1717  lHornCurrent->SetLineColor(kRed);
1718  lHornCurrent->SetLineWidth(3);
1719  lHornCurrent->SetLineStyle(9);
1720  lHornCurrent->Draw();
1721  l2HornCurrent->SetLineColor(kRed);
1722  l2HornCurrent->SetLineWidth(3);
1723  l2HornCurrent->SetLineStyle(9);
1724  lHornCurrent->Draw();
1725  l2HornCurrent->Draw();
1726  hHornCurrentDay[p]->Draw("same");
1727  UpdateText->Draw();
1728  sprintf(filename,"%s/%s-%s-P%.1uHornCurrent%s.png",PLOT_DIR.c_str(),det.c_str(),trig.c_str(),p,period.c_str());
1729  cHornCurrentday->Print(filename);
1730  delete cHornCurrentday;
1731  cHornCurrentday = 0;
1732 
1733  TCanvas *cXPositionday = new TCanvas("cXPositionday","X Position Day",1200,800);
1734  cXPositionday->cd();
1735  gStyle->SetOptStat(111111);
1736  hXPositionDay[p]->SetLineWidth(2);
1737  hXPositionDay[p]->Draw();
1738  UpdateText->Draw();
1739  cXPositionday->Update();
1740  lmax=gPad->GetUymax();
1741  TLine* lXPosition=new TLine(2,0,2,lmax);
1742  TLine* l2XPosition=new TLine(-2,0,-2,lmax);
1743  lXPosition->SetLineColor(kRed);
1744  lXPosition->SetLineWidth(3);
1745  lXPosition->SetLineStyle(9);
1746  lXPosition->Draw();
1747  l2XPosition->SetLineColor(kRed);
1748  l2XPosition->SetLineWidth(3);
1749  l2XPosition->SetLineStyle(9);
1750  l2XPosition->Draw();
1751  hXPositionDay[p]->Draw("same");
1752  sprintf(filename,"%s/%s-%s-P%.1uXPosition%s.png",PLOT_DIR.c_str(),det.c_str(),trig.c_str(),p,period.c_str());
1753  cXPositionday->Print(filename);
1754  delete cXPositionday;
1755  cXPositionday = 0;
1756 
1757  TCanvas *cYPositionday = new TCanvas("cYPositionday","Y Position Day",1200,800);
1758  cYPositionday->cd();
1759  gStyle->SetOptStat(111111);
1760  hYPositionDay[p]->SetLineWidth(2);
1761  hYPositionDay[p]->Draw();
1762  UpdateText->Draw();
1763  cYPositionday->Update();
1764  lmax=gPad->GetUymax();
1765  TLine* lYPosition=new TLine(2,0,2,lmax);
1766  TLine* l2YPosition=new TLine(-2,0,-2,lmax);
1767  lYPosition->SetLineColor(kRed);
1768  lYPosition->SetLineWidth(3);
1769  lYPosition->SetLineStyle(9);
1770  lYPosition->Draw();
1771  l2YPosition->SetLineColor(kRed);
1772  l2YPosition->SetLineWidth(3);
1773  l2YPosition->SetLineStyle(9);
1774  l2YPosition->Draw();
1775  hYPositionDay[p]->Draw("same");
1776  sprintf(filename,"%s/%s-%s-P%.1uYPosition%s.png",PLOT_DIR.c_str(),det.c_str(),trig.c_str(),p,period.c_str());
1777  cYPositionday->Print(filename);
1778  delete cYPositionday;
1779  cYPositionday = 0;
1780 
1781  TCanvas *cXWidthday = new TCanvas("cXWidthday","X Width Day",1200,800);
1782  cXWidthday->cd();
1783  gStyle->SetOptStat(111111);
1784  hXWidthDay[p]->SetLineWidth(2);
1785  hXWidthDay[p]->Draw();
1786  UpdateText->Draw();
1787  cXWidthday->Update();
1788  lmax=gPad->GetUymax();
1789  TLine* lXWidth=new TLine(0.57,0,0.57,lmax);
1790  TLine* l2XWidth=new TLine(1.88,0,1.88,lmax);
1791  lXWidth->SetLineColor(kRed);
1792  lXWidth->SetLineWidth(3);
1793  lXWidth->SetLineStyle(9);
1794  lXWidth->Draw();
1795  l2XWidth->SetLineColor(kRed);
1796  l2XWidth->SetLineWidth(3);
1797  l2XWidth->SetLineStyle(9);
1798  l2XWidth->Draw();
1799  hXWidthDay[p]->Draw("same");
1800  sprintf(filename,"%s/%s-%s-P%.1uXWidth%s.png",PLOT_DIR.c_str(),det.c_str(),trig.c_str(),p,period.c_str());
1801  cXWidthday->Print(filename);
1802  delete cXWidthday;
1803  cXWidthday = 0;
1804 
1805  TCanvas *cYWidthday = new TCanvas("cYWidthday","Y Width Day",1200,800);
1806  cYWidthday->cd();
1807  gStyle->SetOptStat(111111);
1808  hYWidthDay[p]->SetLineWidth(2);
1809  hYWidthDay[p]->Draw();
1810  UpdateText->Draw();
1811  cYWidthday->Update();
1812  lmax=gPad->GetUymax();
1813  TLine* lYWidth=new TLine(0.57,0,0.57,lmax);
1814  TLine* l2YWidth=new TLine(1.58,0,1.58,lmax);
1815  lYWidth->SetLineColor(kRed);
1816  lYWidth->SetLineWidth(3);
1817  lYWidth->SetLineStyle(9);
1818  lYWidth->Draw();
1819  l2YWidth->SetLineColor(kRed);
1820  l2YWidth->SetLineWidth(3);
1821  l2YWidth->SetLineStyle(9);
1822  l2YWidth->Draw();
1823  hYWidthDay[p]->Draw("same");
1824  sprintf(filename,"%s/%s-%s-P%.1uYWidth%s.png",PLOT_DIR.c_str(),det.c_str(),trig.c_str(),p,period.c_str());
1825  cYWidthday->Print(filename);
1826  delete cYWidthday;
1827  cYWidthday = 0;
1828 
1829  TCanvas *cGoodBeamday = new TCanvas("cGoodBeamday","Y Good Beam Day",1200,800);
1830  cGoodBeamday->cd();
1831  gStyle->SetOptStat(111111);
1832  hGoodBeamDay[p]->SetLineWidth(2);
1833  hGoodBeamDay[p]->Draw();
1834  TAxis *GoodBeamaxis = hGoodBeamDay[p]->GetXaxis();
1835  GoodBeamaxis->SetBinLabel(1,"bad beam");
1836  GoodBeamaxis->SetBinLabel(2,"good beam");
1837  UpdateText->Draw();
1838  sprintf(filename,"%s/%s-%s-P%.1uGoodBeam%s.png",PLOT_DIR.c_str(),det.c_str(),trig.c_str(),p,period.c_str());
1839  cGoodBeamday->Print(filename);
1840  delete cGoodBeamday;
1841  cGoodBeamday = 0;
1842 
1843  TCanvas *cBadSpillsday = new TCanvas("cBadSpillsday","Y Bad Spills Day",1200,800);
1844  cBadSpillsday->cd();
1845  cBadSpillsday->SetLogy();
1846  hBadSpillsDay[p]->SetLineWidth(2);
1847  gStyle->SetOptStat(0);
1848  hBadSpillsDay[p]->Draw();
1849  UpdateText->Draw();
1850  sprintf(filename,"%s/%s-%s-P%.1uBadSpills%s.png",PLOT_DIR.c_str(),det.c_str(),trig.c_str(),p,period.c_str());
1851  cBadSpillsday->Print(filename);
1852  delete cBadSpillsday;
1853  cBadSpillsday = 0;
1854  //end new
1855 
1856  TCanvas *cnSliceday = new TCanvas("cnSliceday","# Slice Day",1200,800);
1857  cnSliceday->cd();
1858  cnSliceday->SetLogy();
1859  gStyle->SetOptStat(111111);
1860  if(det_type=="NearDet") hNSliceDay[p]->SetAxisRange(0.0,50.0,"X");
1861  else if(det_type=="TestBeam") hNSliceDay[p]->SetAxisRange(0.0,200.0,"X");
1862  else hNSliceDay[p]->SetAxisRange(0.0,200.0,"X");
1863  hNSliceDay[p]->SetLineWidth(2);
1864  hNSliceDay[p]->SetLineColor(kRed);
1865  hNSliceDay[p]->Draw();
1866  UpdateText->Draw();
1867 
1868  sprintf(filename,"%s/%s-%s-P%.1uNSlice%s.png",PLOT_DIR.c_str(),det.c_str(),trig.c_str(),p,period.c_str());
1869  cnSliceday->Print(filename);
1870  delete cnSliceday;
1871  cnSliceday = 0;
1872 
1873  TCanvas *cnSliceHitday = new TCanvas("cnSliceHitday","# Non-Noise Slice Hits Day",1200,800);
1874  cnSliceHitday->cd();
1875  cnSliceHitday->SetLogy();
1876  gStyle->SetOptStat(111111);
1877  gPad->SetLogy();
1878  gPad->SetLogx();
1879  hNNonNoiseSliceHitDay[p]->SetAxisRange(0.0,3000.0,"X");
1880  hNNonNoiseSliceHitDay[p]->SetLineWidth(2);
1881  hNNonNoiseSliceHitDay[p]->SetLineColor(kRed);
1882  hNNonNoiseSliceHitDay[p]->Draw();
1883  UpdateText->Draw();
1884  sprintf(filename,"%s/%s-%s-P%.1uNSliceHit%s.png",PLOT_DIR.c_str(),det.c_str(),trig.c_str(),p,period.c_str());
1885  cnSliceHitday->Print(filename);
1886  delete cnSliceHitday;
1887  cnSliceHitday = 0;
1888 
1889  TCanvas *cNNoiseSliceHitday = new TCanvas("cNNoiseSliceHitday","# Noise Slice Hits Day",1200,800);
1890  cNNoiseSliceHitday->cd();
1891  cNNoiseSliceHitday->SetLogy();
1892  gStyle->SetOptStat(111111);
1893  if(det_type=="NearDet") hNNoiseSliceHitDay[p]->SetAxisRange(0.0,2000.0,"X");
1894  else if(det_type=="TestBeam") hNNoiseSliceHitDay[p]->SetAxisRange(0.0,1500.0,"X");
1895  // hNNoiseSliceHitDay[p]->SetAxisRange(0.0,10000.0,"X");
1896  hNNoiseSliceHitDay[p]->SetLineWidth(2);
1897  hNNoiseSliceHitDay[p]->SetLineColor(kRed);
1898  hNNoiseSliceHitDay[p]->Draw();
1899  UpdateText->Draw();
1900  sprintf(filename,"%s/%s-%s-P%.1uNNoiseSliceHit%s.png",PLOT_DIR.c_str(),det.c_str(),trig.c_str(),p,period.c_str());
1901  cNNoiseSliceHitday->Print(filename);
1902  delete cNNoiseSliceHitday;
1903  cNNoiseSliceHitday = 0;
1904 
1905  TCanvas *cPEday = new TCanvas("cPEday","PE distributions by Day",1200,800);
1906  cPEday->cd();
1907  gStyle->SetOptStat(0);
1908  gPad->SetLogy();
1909  gPad->SetLogx();
1910  hNoiseSlicePEDay[p]->GetXaxis()->SetRange(2,5000);
1911  sprintf(filename,"%s PE Distribution (%s) - partition %.1u",trigname.c_str(),time.c_str(),p);
1912  hNoiseSlicePEDay[p]->SetTitle(filename);
1913  hNonNoiseSlicePEDay[p]->SetTitle(filename);
1914  hTrackPEDay[p]->SetTitle(filename);
1915  hNoiseSlicePEDay[p]->SetLineWidth(2);
1916  hNoiseSlicePEDay[p]->SetLineColor(kBlack);
1917  hNoiseSlicePEDay[p]->Draw();
1918  hNonNoiseSlicePEDay[p]->SetLineWidth(2);
1919  hNonNoiseSlicePEDay[p]->SetLineColor(kRed);
1920  hNonNoiseSlicePEDay[p]->Draw("sames");
1921  hTrackPEDay[p]->SetLineWidth(2);
1922  hTrackPEDay[p]->SetLineColor(kBlue);
1923  hTrackPEDay[p]->Draw("sames");
1924  UpdateText->Draw();
1925  TLegend *legend = new TLegend(0.6,0.6,0.85,0.85);
1926  legend->AddEntry(hNoiseSlicePEDay[p],"Hits in Noise Slice","l");
1927  legend->AddEntry(hNonNoiseSlicePEDay[p],"Hits in Non-Noise Slices","l");
1928  legend->AddEntry(hTrackPEDay[p],"Hits on Tracks","l");
1929  legend->SetFillStyle(4000);
1930  legend->SetLineColor(0);
1931  legend->SetFillColor(0);
1932  legend->Draw();
1933  sprintf(filename,"%s/%s-%s-P%.1uPE%s.png",PLOT_DIR.c_str(),det.c_str(),trig.c_str(),p,period.c_str());
1934  cPEday->Print(filename);
1935  delete cPEday;
1936  cPEday = 0;
1937  delete legend;
1938  legend = 0;
1939 
1940  TCanvas *cTsdday = new TCanvas("cTsdday","Slice Time Standard Dev.",1200,800);
1941  cTsdday->cd();
1942  cTsdday->SetLogy();
1943  gStyle->SetOptStat(111111);
1944  if(det_type=="NearDet") hTsdDay[p]->SetAxisRange(0.0,600.0,"X");
1945  else if(det_type=="TestBeam") hTsdDay[p]->SetAxisRange(0.0,500.0,"X");
1946  else hTsdDay[p]->SetAxisRange(0.0,1000.0,"X");
1947  hTsdDay[p]->SetLineWidth(2);
1948  hTsdDay[p]->SetLineColor(kRed);
1949  hTsdDay[p]->Draw();
1950  UpdateText->Draw();
1951  sprintf(filename,"%s/%s-%s-P%.1uTsd%s.png",PLOT_DIR.c_str(),det.c_str(),trig.c_str(),p,period.c_str());
1952  cTsdday->Print(filename);
1953  delete cTsdday;
1954  cTsdday = 0;
1955 
1956  TCanvas *cnTrackday = new TCanvas("cnTrackday"," # Cosmic Tracks",1200,800);
1957  cnTrackday->cd();
1958  cnTrackday->SetLogy();
1959  gStyle->SetOptStat(111111);
1960  hnTrackDay[p]->SetAxisRange(0.0,300.0,"X");
1961  hnTrackDay[p]->SetLineWidth(2);
1962  hnTrackDay[p]->SetLineColor(kRed);
1963  hnTrackDay[p]->Draw();
1964  UpdateText->Draw();
1965  sprintf(filename,"%s/%s-%s-P%.1unTrackAll3D%s.png",PLOT_DIR.c_str(),det.c_str(),trig.c_str(),p,period.c_str());
1966  cnTrackday->Print(filename);
1967  delete cnTrackday;
1968  cnTrackday = 0;
1969 
1970  TCanvas *cTrackLenday = new TCanvas("cTrackLenday","Cosmic Track Length",1200,800);
1971  cTrackLenday->cd();
1972  cTrackLenday->SetLogy();
1973  gStyle->SetOptStat(111111);
1974  hTrackLenDay[p]->SetAxisRange(0.0,6000.0,"X");
1975  hTrackLenDay[p]->SetLineWidth(2);
1976  hTrackLenDay[p]->SetLineColor(kRed);
1977  hTrackLenDay[p]->Draw();
1978  UpdateText->Draw();
1979  sprintf(filename,"%s/%s-%s-P%.1uTrackLenAll3D%s.png",PLOT_DIR.c_str(),det.c_str(),trig.c_str(),p,period.c_str());
1980  cTrackLenday->Print(filename);
1981  delete cTrackLenday;
1982  cTrackLenday = 0;
1983 
1984  TCanvas *cCosNumiday = new TCanvas("cCosNumiday","Cos Theta(numi)",1200,800);
1985  cCosNumiday->cd();
1986  gStyle->SetOptStat(111111);
1987  hCosNumiDay[p]->SetAxisRange(-1.0,1.0,"X");
1988  hCosNumiDay[p]->SetLineWidth(2);
1989  hCosNumiDay[p]->SetLineColor(kRed);
1990  hCosNumiDay[p]->Draw();
1991  UpdateText->Draw();
1992  sprintf(filename,"%s/%s-%s-P%.1uCosNumiAll3D%s.png",PLOT_DIR.c_str(),det.c_str(),trig.c_str(),p,period.c_str());
1993  cCosNumiday->Print(filename);
1994  delete cCosNumiday;
1995  cCosNumiday = 0;
1996 
1997  TCanvas *cPCaveday = new TCanvas("cPCaveday","PCave day",1200,1200);
1998  cPCaveday->Divide(1,2);
1999  cPCaveday->cd(1);
2000  gStyle->SetOptStat(0);
2001  gStyle->SetPalette(1); //kRainbow
2002  gPad->SetLogz();
2003  if(det_type=="NearDet"){
2004  hPCXaveDay[p]->SetAxisRange(-225.0,20.0,"X");
2005  hPCXaveDay[p]->SetAxisRange(-110.0,10.0,"Y");
2006  }
2007  else if(det_type=="TestBeam"){
2008  hPCXaveDay[p]->SetAxisRange(-68.0,5.0,"X");
2009  hPCXaveDay[p]->SetAxisRange(-70.0,5.0,"Y");
2010  }
2011  else{
2012  hPCXaveDay[p]->SetAxisRange(-920.0,20.0,"X");
2013  hPCXaveDay[p]->SetAxisRange(-400.0,10.0,"Y");
2014  }
2015  hPCXaveDay[p]->Draw("colz");
2016  L1x->Draw();
2017  L2x->Draw();
2018  L3x->Draw();
2019  L4x->Draw();
2020  cPCaveday->cd(2);
2021  gStyle->SetOptStat(0);
2022  gPad->SetLogz();
2023  if(det_type=="NearDet"){
2024  hPCYaveDay[p]->SetAxisRange(-225.0,20.0,"X");
2025  hPCYaveDay[p]->SetAxisRange(-10.0,110.0,"Y");
2026  }
2027  else if(det_type=="TestBeam"){
2028  hPCYaveDay[p]->SetAxisRange(-68.0,5.0,"X");
2029  hPCYaveDay[p]->SetAxisRange(-5.0,70.0,"Y");
2030  }
2031  else{
2032  hPCYaveDay[p]->SetAxisRange(-920.0,20.0,"X");
2033  hPCYaveDay[p]->SetAxisRange(-10.0,400.0,"Y");
2034  }
2035  hPCYaveDay[p]->Draw("colz");
2036  L1y->Draw();
2037  L2y->Draw();
2038  L3y->Draw();
2039  L4y->Draw();
2040  UpdateText->Draw();
2041  sprintf(filename,"%s/%s-%s-P%.1uPCave%s.png",PLOT_DIR.c_str(),det.c_str(),trig.c_str(),p,period.c_str());
2042  cPCaveday->Print(filename);
2043  delete cPCaveday;
2044  cPCaveday = 0;
2045 
2046  TCanvas *cnTrackAll3Dday = new TCanvas("cnTrackday"," # 3D Cosmic Tracks",1200,800);
2047  cnTrackAll3Dday->cd();
2048  cnTrackAll3Dday->SetLogy();
2049  gStyle->SetOptStat(111111);
2050  if(det_type=="NearDet") hnTrackAll3DDay[p]->SetAxisRange(0.0,50.0,"X");
2051  else if(det_type=="TestBeam" && trigger=="Spill") hnTrackAll3DDay[p]->SetAxisRange(0.0,300.0,"X");
2052  else hnTrackAll3DDay[p]->SetAxisRange(0.0,300.0,"X");
2053  hnTrackAll3DDay[p]->SetLineWidth(2);
2054  hnTrackAll3DDay[p]->SetLineColor(kRed);
2055  hnTrackAll3DDay[p]->Draw();
2056  UpdateText->Draw();
2057  sprintf(filename,"%s/%s-%s-P%.1unTrackAll3D%s.png",PLOT_DIR.c_str(),det.c_str(),trig.c_str(),p,period.c_str());
2058  cnTrackAll3Dday->Print(filename);
2059  delete cnTrackAll3Dday;
2060  cnTrackAll3Dday = 0;
2061 
2062  TCanvas *cTrackStartAll3Dday = new TCanvas("cTrackStartAll3Dday","All 3D Track Start day",1200,1200);
2063  cTrackStartAll3Dday->Divide(1,2);
2064  cTrackStartAll3Dday->cd(1);
2065  gStyle->SetOptStat(0);
2066  gPad->SetLogz();
2067  if(det_type=="NearDet"){
2068  hTrackStartXZAll3DDay[p]->SetAxisRange(-1750.0,0.0,"X");
2069  hTrackStartXZAll3DDay[p]->SetAxisRange(-250.0,250.0,"Y");
2070  }
2071  else if(det_type=="TestBeam"){
2072  hTrackStartXZAll3DDay[p]->SetAxisRange(-440.0,0.0,"X");
2073  hTrackStartXZAll3DDay[p]->SetAxisRange(-140.0,140.0,"Y");
2074  }
2075  hTrackStartXZAll3DDay[p]->Draw("colz");
2076  cTrackStartAll3Dday->cd(2);
2077  gStyle->SetOptStat(0);
2078  gPad->SetLogz();
2079  if(det_type=="NearDet"){
2080  hTrackStartYZAll3DDay[p]->SetAxisRange(-1750.0,0.0,"X");
2081  hTrackStartYZAll3DDay[p]->SetAxisRange(-250.0,250.0,"Y");
2082  }
2083  else if(det_type=="TestBeam"){
2084  hTrackStartYZAll3DDay[p]->SetAxisRange(-440.0,0.0,"X");
2085  hTrackStartYZAll3DDay[p]->SetAxisRange(-140.0,140.0,"Y");
2086  }
2087  hTrackStartYZAll3DDay[p]->Draw("colz");
2088  UpdateText->Draw();
2089  sprintf(filename,"%s/%s-%s-P%.1uTrackStartAll3D%s.png",PLOT_DIR.c_str(),det.c_str(),trig.c_str(),p,period.c_str());
2090  cTrackStartAll3Dday->Print(filename);
2091  delete cTrackStartAll3Dday;
2092  cTrackStartAll3Dday = 0;
2093 
2094  TCanvas *cTrackStopAll3Dday = new TCanvas("cTrackStopAll3Dday","All 3D Track Stop day",1200,1200);
2095  cTrackStopAll3Dday->Divide(1,2);
2096  cTrackStopAll3Dday->cd(1);
2097  gStyle->SetOptStat(0);
2098  gPad->SetLogz();
2099  if(det_type=="NearDet"){
2100  hTrackStopXZAll3DDay[p]->SetAxisRange(-1750.0,0.0,"X");
2101  hTrackStopXZAll3DDay[p]->SetAxisRange(-250.0,250.0,"Y");
2102  }
2103  else if(det_type=="TestBeam"){
2104  hTrackStopXZAll3DDay[p]->SetAxisRange(-440.0,0.0,"X");
2105  hTrackStopXZAll3DDay[p]->SetAxisRange(-140.0,140.0,"Y");
2106  }
2107  hTrackStopXZAll3DDay[p]->Draw("colz");
2108  cTrackStopAll3Dday->cd(2);
2109  gStyle->SetOptStat(0);
2110  gPad->SetLogz();
2111  if(det_type=="NearDet"){
2112  hTrackStopYZAll3DDay[p]->SetAxisRange(-1750.0,0.0,"X");
2113  hTrackStopYZAll3DDay[p]->SetAxisRange(-250.0,250.0,"Y");
2114  }
2115  else if(det_type=="TestBeam"){
2116  hTrackStopYZAll3DDay[p]->SetAxisRange(-440.0,0.0,"X");
2117  hTrackStopYZAll3DDay[p]->SetAxisRange(-140.0,140.0,"Y");
2118  }
2119  hTrackStopYZAll3DDay[p]->Draw("colz");
2120  UpdateText->Draw();
2121  sprintf(filename,"%s/%s-%s-P%.1uTrackStopAll3D%s.png",PLOT_DIR.c_str(),det.c_str(),trig.c_str(),p,period.c_str());
2122  cTrackStopAll3Dday->Print(filename);
2123  delete cTrackStopAll3Dday;
2124  cTrackStopAll3Dday = 0;
2125 
2126  TCanvas *cTrackLenAll3Dday = new TCanvas("cTrackLenAll3Dday"," 3D Cosmic Track Length",1200,800);
2127  cTrackLenAll3Dday->cd();
2128  cTrackLenAll3Dday->SetLogy();
2129  gStyle->SetOptStat(111111);
2130  if(det_type=="NearDet") hTrackLenAll3DDay[p]->SetAxisRange(0.0,2000.0,"X");
2131  else if(det_type=="TestBeam") hTrackLenAll3DDay[p]->SetAxisRange(0.0,450.0,"X");
2132  else hTrackLenAll3DDay[p]->SetAxisRange(0.0,6000.0,"X");
2133  //hTrackLenAll3DDay[p]->GetXaxis()->SetRangeUser(0.,6000.);
2134  hTrackLenAll3DDay[p]->SetLineWidth(2);
2135  hTrackLenAll3DDay[p]->SetLineColor(kRed);
2136  hTrackLenAll3DDay[p]->Draw();
2137  UpdateText->Draw();
2138  sprintf(filename,"%s/%s-%s-P%.1uTrackLenAll3D%s.png",PLOT_DIR.c_str(),det.c_str(),trig.c_str(),p,period.c_str());
2139  cTrackLenAll3Dday->Print(filename);
2140  delete cTrackLenAll3Dday;
2141  cTrackLenAll3Dday = 0;
2142 
2143  TCanvas *cnTrackCont3Dday = new TCanvas("cnTrackCont3Dday"," # Contained 3D Cosmic Tracks",1200,800);
2144  cnTrackCont3Dday->cd();
2145  cnTrackCont3Dday->SetLogy();
2146  gStyle->SetOptStat(111111);
2147  hnTrackCont3DDay[p]->SetAxisRange(0.0,300.0,"X");
2148  hnTrackCont3DDay[p]->SetLineWidth(2);
2149  hnTrackCont3DDay[p]->SetLineColor(kRed);
2150  hnTrackCont3DDay[p]->Draw();
2151  UpdateText->Draw();
2152  sprintf(filename,"%s/%s-%s-P%.1unTrackCont3D%s.png",PLOT_DIR.c_str(),det.c_str(),trig.c_str(),p,period.c_str());
2153  cnTrackCont3Dday->Print(filename);
2154  delete cnTrackCont3Dday;
2155  cnTrackCont3Dday = 0;
2156 
2157  TCanvas *cTrackStartCont3Dday = new TCanvas("cTrackStartCont3Dday","Cont 3D Track Start day",1200,1200);
2158  cTrackStartCont3Dday->Divide(1,2);
2159  cTrackStartCont3Dday->cd(1);
2160  gStyle->SetOptStat(0);
2161  gPad->SetLogz();
2162  if(det_type=="NearDet"){
2163  hTrackStartXZCont3DDay[p]->SetAxisRange(-1750.0,0.0,"X");
2164  hTrackStartXZCont3DDay[p]->SetAxisRange(-250.0,250.0,"Y");
2165  }
2166  else if(det_type=="TestBeam"){
2167  hTrackStartXZCont3DDay[p]->SetAxisRange(-440.0,0.0,"X");
2168  hTrackStartXZCont3DDay[p]->SetAxisRange(-140.0,140.0,"Y");
2169  }
2170  hTrackStartXZCont3DDay[p]->Draw("colz");
2171  cTrackStartCont3Dday->cd(2);
2172  gStyle->SetOptStat(0);
2173  gPad->SetLogz();
2174  if(det_type=="NearDet"){
2175  hTrackStartYZCont3DDay[p]->SetAxisRange(-1750.0,0.0,"X");
2176  hTrackStartYZCont3DDay[p]->SetAxisRange(-250.0,250.0,"Y");
2177  }
2178  else if(det_type=="TestBeam"){
2179  hTrackStartYZCont3DDay[p]->SetAxisRange(-440.0,0.0,"X");
2180  hTrackStartYZCont3DDay[p]->SetAxisRange(-140.0,140.0,"Y");
2181  }
2182  hTrackStartYZCont3DDay[p]->Draw("colz");
2183  UpdateText->Draw();
2184  sprintf(filename,"%s/%s-%s-P%.1uTrackStartCont3D%s.png",PLOT_DIR.c_str(),det.c_str(),trig.c_str(),p,period.c_str());
2185  cTrackStartCont3Dday->Print(filename);
2186  delete cTrackStartCont3Dday;
2187  cTrackStartCont3Dday = 0;
2188 
2189  TCanvas *cTrackStopCont3Dday = new TCanvas("cTrackStopCont3Dday","Cont 3D Track Stop day",1200,1200);
2190  cTrackStopCont3Dday->Divide(1,2);
2191  cTrackStopCont3Dday->cd(1);
2192  gStyle->SetOptStat(0);
2193  gPad->SetLogz();
2194  if(det_type=="NearDet"){
2195  hTrackStopXZCont3DDay[p]->SetAxisRange(-1750.0,0.0,"X");
2196  hTrackStopXZCont3DDay[p]->SetAxisRange(-250.0,250.0,"Y");
2197  }
2198  else if(det_type=="TestBeam"){
2199  hTrackStopXZCont3DDay[p]->SetAxisRange(-440.0,0.0,"X");
2200  hTrackStopXZCont3DDay[p]->SetAxisRange(-140.0,140.0,"Y");
2201  }
2202  hTrackStopXZCont3DDay[p]->Draw("colz");
2203  cTrackStopCont3Dday->cd(2);
2204  gStyle->SetOptStat(0);
2205  gPad->SetLogz();
2206  if(det_type=="NearDet"){
2207  hTrackStopYZCont3DDay[p]->SetAxisRange(-1750.0,0.0,"X");
2208  hTrackStopYZCont3DDay[p]->SetAxisRange(-250.0,250.0,"Y");
2209  }
2210  else if(det_type=="TestBeam"){
2211  hTrackStopYZCont3DDay[p]->SetAxisRange(-440.0,0.0,"X");
2212  hTrackStopYZCont3DDay[p]->SetAxisRange(-140.0,140.0,"Y");
2213  }
2214  hTrackStopYZCont3DDay[p]->Draw("colz");
2215  UpdateText->Draw();
2216  sprintf(filename,"%s/%s-%s-P%.1uTrackStopCont3D%s.png",PLOT_DIR.c_str(),det.c_str(),trig.c_str(),p,period.c_str());
2217  cTrackStopCont3Dday->Print(filename);
2218  delete cTrackStopCont3Dday;
2219  cTrackStopCont3Dday = 0;
2220 
2221  TCanvas *cTrackLenCont3Dday = new TCanvas("cTrackLenCont3Dday"," 3D Cosmic Track Length",1200,800);
2222  cTrackLenCont3Dday->cd();
2223  cTrackLenCont3Dday->SetLogy();
2224  gStyle->SetOptStat(111111);
2225  hTrackLenCont3DDay[p]->SetAxisRange(0.0,6000.0,"X");
2226  //hTrackLenCont3DDay[p]->GetXaxis()->SetRangeUser(0.,6000.);
2227  hTrackLenCont3DDay[p]->SetLineWidth(2);
2228  hTrackLenCont3DDay[p]->SetLineColor(kRed);
2229  hTrackLenCont3DDay[p]->Draw();
2230  UpdateText->Draw();
2231  sprintf(filename,"%s/%s-%s-P%.1uTrackLenCont3D%s.png",PLOT_DIR.c_str(),det.c_str(),trig.c_str(),p,period.c_str());
2232  cTrackLenCont3Dday->Print(filename);
2233  delete cTrackLenCont3Dday;
2234  cTrackLenCont3Dday = 0;
2235 
2236  // NEW PLOTS
2237  TCanvas *cDeltaSliceTrackday = new TCanvas("cDeltaSliceTrackday","Delta Slice/Track",1200,800);
2238  cDeltaSliceTrackday->cd();
2239  cDeltaSliceTrackday->SetLogy();
2240  gStyle->SetOptStat(111111);
2241  hDeltaSliceTrackDay[p]->SetAxisRange(-15.0,15.0,"X");
2242  hDeltaSliceTrackDay[p]->SetLineWidth(2);
2243  hDeltaSliceTrackDay[p]->SetLineColor(kRed);
2244  hDeltaSliceTrackDay[p]->Draw();
2245  UpdateText->Draw();
2246  sprintf(filename,"%s/%s-%s-P%.1uDeltaSliceTrack%s.png",PLOT_DIR.c_str(),det.c_str(),trig.c_str(),p,period.c_str());
2247  cDeltaSliceTrackday->Print(filename);
2248  delete cDeltaSliceTrackday;
2249  cDeltaSliceTrackday = 0;
2250 
2251  TCanvas *cSliceTrackRatioday = new TCanvas("cSliceTrackRatioday","Slice/Track Ratio",1200,800);
2252  cSliceTrackRatioday->cd();
2253  cSliceTrackRatioday->SetLogy();
2254  gStyle->SetOptStat(111111);
2255  hSliceTrackRatioDay[p]->SetAxisRange(0.0,1.0,"X"); // NOTE: This range will be different for the NearDet.C_Str()
2256  hSliceTrackRatioDay[p]->SetLineWidth(2);
2257  hSliceTrackRatioDay[p]->SetLineColor(kRed);
2258  hSliceTrackRatioDay[p]->Draw();
2259  UpdateText->Draw();
2260  sprintf(filename,"%s/%s-%s-P%.1uSliceTrackRatio%s.png",PLOT_DIR.c_str(),det.c_str(),trig.c_str(),p,period.c_str());
2261  cSliceTrackRatioday->Print(filename);
2262  delete cSliceTrackRatioday;
2263  cSliceTrackRatioday = 0;
2264 
2265  TCanvas *cSliceTrackNHitRatioday = new TCanvas("cSliceTrackNHitRatioday","Slice/Track NHit Ratio",1200,800);
2266  cSliceTrackNHitRatioday->cd();
2267  cSliceTrackNHitRatioday->SetLogy();
2268  gStyle->SetOptStat(111111);
2269  hSliceTrackNHitRatioDay[p]->SetLineWidth(2);
2270  hSliceTrackNHitRatioDay[p]->SetLineColor(kRed);
2271  hSliceTrackNHitRatioDay[p]->Draw();
2272  UpdateText->Draw();
2273  sprintf(filename,"%s/%s-%s-P%.1uSliceTrackNHitRatio%s.png",PLOT_DIR.c_str(),det.c_str(),trig.c_str(),p,period.c_str());
2274  cSliceTrackNHitRatioday->Print(filename);
2275  delete cSliceTrackNHitRatioday;
2276  cSliceTrackNHitRatioday = 0;
2277 
2278 
2279  //new beam plots
2280  maxtime = 0;
2281  max = 0.0;
2282  ave = 0.0;
2283  for(int i = 0; i < NTimeDiffDayCount[p]; ++i) {
2284  ave += (double)NTimeDiffNanoSecDay[p][i];
2285  if(NTimeDiffNanoSectimeDay[p][i] > maxtime) {
2286  maxtime = NTimeDiffNanoSectimeDay[p][i];
2287  max = NTimeDiffNanoSecDay[p][i];
2288  }
2289  }
2290  if(NTimeDiffDayCount[p] > 0) ave = ave/(double)NTimeDiffDayCount[p];
2291  sprintf(lptext,"Last Point = %f / Average = %f",max,ave);
2292  LastPoint->Clear();
2293  LastPoint->AddText(lptext);
2294  TCanvas *ctnTimeDiffday = new TCanvas("cnTimeDiffday","Time Difference (spill and IFDB) day",1200,800);
2295  ctnTimeDiffday->cd();
2296  gPad->SetGridx();
2297  TGraph *gnTimeDiffday = new TGraph(NTimeDiffDayCount[p],NTimeDiffNanoSectimeDay[p],NTimeDiffNanoSecDay[p]);
2298  sprintf(title,"%s Time Difference (spill and IFDB) - partition %.1u",trigname.c_str(),p);
2299  gnTimeDiffday->SetTitle(title);
2300  gnTimeDiffday->SetMarkerColor(kBlue);
2301  gnTimeDiffday->GetXaxis()->SetTimeDisplay(1);
2302  gnTimeDiffday->GetXaxis()->SetLabelSize(0.03);
2303  gnTimeDiffday->GetXaxis()->SetTimeFormat(taxis_labels.c_str());
2304  gnTimeDiffday->GetXaxis()->SetLimits(time_ago,XNow);
2305  gnTimeDiffday->GetXaxis()->SetTitle("(central time)");
2306  gnTimeDiffday->GetYaxis()->SetTitle("(sec)");
2307  gnTimeDiffday->GetYaxis()->SetRangeUser(-0.1,0.6);
2308  gnTimeDiffday->Draw("A*");
2309  TLine* l2TimeDiff=new TLine(time_ago,0.5,XNow,0.5);
2310  l2TimeDiff->SetLineColor(kRed);
2311  l2TimeDiff->SetLineWidth(3);
2312  l2TimeDiff->SetLineStyle(9);
2313  l2TimeDiff->Draw();
2314  UpdateText->Draw();
2315  LastPoint->Draw();
2316  sprintf(filename,"%s/%s-%s-P%.1unTimeDiff%s.png",PLOT_DIR.c_str(),det.c_str(),trig.c_str(),p,period.c_str());
2317  ctnTimeDiffday->Print(filename);
2318  delete ctnTimeDiffday;
2319  ctnTimeDiffday = 0;
2320 
2321  // Adding "zoomed in" version of above plot
2322  TCanvas *ctnTimeDiff_zoom = new TCanvas("cnTimeDiff_zoom","Time Difference (sill and IFDB) day",1200,800);
2323  ctnTimeDiff_zoom->cd();
2324  gPad->SetGridx();
2325  TGraph *gnTimeDiff_zoom = new TGraph(NTimeDiffDayCount[p],NTimeDiffNanoSectimeDay[p],NTimeDiffNanoSecDay[p]);
2326  sprintf(title,"%s Time Difference (spill and IFDB) - partition %.1u",trigname.c_str(),p);
2327  gnTimeDiff_zoom->SetTitle(title);
2328  gnTimeDiff_zoom->SetMarkerColor(kBlue);
2329  gnTimeDiff_zoom->GetXaxis()->SetTimeDisplay(1);
2330  gnTimeDiff_zoom->GetXaxis()->SetLabelSize(0.03);
2331  gnTimeDiff_zoom->GetXaxis()->SetTimeFormat(taxis_labels.c_str());
2332  gnTimeDiff_zoom->GetXaxis()->SetLimits(time_ago,XNow);
2333  gnTimeDiff_zoom->GetXaxis()->SetTitle("(central time)");
2334  gnTimeDiff_zoom->GetYaxis()->SetTitle("(sec)");
2335  gnTimeDiff_zoom->GetYaxis()->SetRangeUser((gnTimeDiff_zoom->GetMean(2)-3.*gnTimeDiff_zoom->GetRMS(2)),(gnTimeDiff_zoom->GetMean(2)+3.*gnTimeDiff_zoom->GetRMS(2)));
2336  gnTimeDiff_zoom->Draw("A*");
2337  UpdateText->Draw();
2338  LastPoint->Draw();
2339  sprintf(filename,"%s/%s-%s-P%.1unTimeDiffzoom%s.png",PLOT_DIR.c_str(),det.c_str(),trig.c_str(),p,period.c_str());
2340  ctnTimeDiff_zoom->Print(filename);
2341  delete ctnTimeDiff_zoom;
2342  ctnTimeDiff_zoom = 0;
2343 
2344  maxtime = 0;
2345  max = 0.0;
2346  ave = 0.0;
2347  for(int i = 0; i < NPOTSumDayCount[p]; ++i) {
2348  ave += (double)NPOTSumDay[p][i];
2349  if(NPOTSumtimeDay[p][i] > maxtime) {
2350  maxtime = NPOTSumtimeDay[p][i];
2351  max = NPOTSumDay[p][i];
2352  }
2353  }
2354  if(NPOTSumDayCount[p] > 0) ave = ave/(double)NPOTSumDayCount[p];
2355  sprintf(lptext,"Last Point = %f / Average = %f",max,ave);
2356  LastPoint->Clear();
2357  LastPoint->AddText(lptext);
2358  TCanvas *ctnPOTSumday = new TCanvas("cnPOTSumday","POT Sum day",1200,800);
2359  ctnPOTSumday->cd();
2360  gPad->SetGridx();
2361  TGraph *gnPOTSumday = new TGraph(NPOTSumDayCount[p],NPOTSumtimeDay[p],NPOTSumDay[p]);
2362  sprintf(title,"%s POT per Subrun - partition %.1u",trigname.c_str(),p);
2363  gnPOTSumday->SetTitle(title);
2364  gnPOTSumday->SetMarkerColor(kBlue);
2365  gnPOTSumday->GetXaxis()->SetTimeDisplay(1);
2366  gnPOTSumday->GetXaxis()->SetLabelSize(0.03);
2367  gnPOTSumday->GetXaxis()->SetTimeFormat(taxis_labels.c_str());
2368  gnPOTSumday->GetXaxis()->SetLimits(time_ago,XNow);
2369  gnPOTSumday->GetYaxis()->SetLabelSize(0.03);
2370  gnPOTSumday->GetYaxis()->SetTitle("(POT)");
2371  gnPOTSumday->GetXaxis()->SetTitle("(central time)");
2372  gnPOTSumday->GetYaxis()->SetRangeUser(25E15,150E15);
2373  gnPOTSumday->Draw("A*");
2374  UpdateText->Draw();
2375  LastPoint->Draw();
2376  sprintf(filename,"%s/%s-%s-P%.1unPOTSumperSR%s.png",PLOT_DIR.c_str(),det.c_str(),trig.c_str(),p,period.c_str());
2377  ctnPOTSumday->Print(filename);
2378  delete ctnPOTSumday;
2379  ctnPOTSumday = 0;
2380 
2381  // Adding "zoomed in" version of above plot
2382  TCanvas *ctnPOTSumday_zoom = new TCanvas("cnPOTSumday_zoom","POT Sum day",1200,800);
2383  ctnPOTSumday_zoom->cd();
2384  gPad->SetGridx();
2385  TGraph *gnPOTSumday_zoom = new TGraph(NPOTSumDayCount[p],NPOTSumtimeDay[p],NPOTSumDay[p]);
2386  sprintf(title,"%s POT per subrun - partition %.1u",trigname.c_str(),p);
2387  gnPOTSumday_zoom->SetTitle(title);
2388  gnPOTSumday_zoom->SetMarkerColor(kBlue);
2389  gnPOTSumday_zoom->GetXaxis()->SetTimeDisplay(1);
2390  gnPOTSumday_zoom->GetXaxis()->SetLabelSize(0.03);
2391  gnPOTSumday_zoom->GetXaxis()->SetTimeFormat(taxis_labels.c_str());
2392  gnPOTSumday_zoom->GetXaxis()->SetLimits(time_ago,XNow);
2393  gnPOTSumday_zoom->GetYaxis()->SetLabelSize(0.03);
2394  gnPOTSumday_zoom->GetYaxis()->SetTitle("(POT)");
2395  gnPOTSumday_zoom->GetXaxis()->SetTitle("(central time)");
2396  gnPOTSumday_zoom->GetYaxis()->SetRangeUser((gnPOTSumday_zoom->GetMean(2)-3.*gnPOTSumday_zoom->GetRMS(2)),(gnPOTSumday_zoom->GetMean(2)+3.*gnPOTSumday_zoom->GetRMS(2)));
2397  gnPOTSumday_zoom->Draw("A*");
2398  UpdateText->Draw();
2399  LastPoint->Draw();
2400  sprintf(filename,"%s/%s-%s-P%.1unPOTSumperSRzoom%s.png",PLOT_DIR.c_str(),det.c_str(),trig.c_str(),p,period.c_str());
2401  ctnPOTSumday_zoom->Print(filename);
2402  delete ctnPOTSumday_zoom;
2403  ctnPOTSumday_zoom = 0;
2404 
2405  maxtime = 0;
2406  max = 0.0;
2407  ave = 0.0;
2408  for(int i = 0; i < NspillPOTDayCount[p]; ++i) {
2409  ave += (double)NspillPOTDay[p][i];
2410  if(NspillPOTtimeDay[p][i] > maxtime) {
2411  maxtime = NspillPOTtimeDay[p][i];
2412  max = NspillPOTDay[p][i];
2413  }
2414  }
2415  if(NspillPOTDayCount[p] > 0) ave = ave/(double)NspillPOTDayCount[p];
2416  sprintf(lptext,"Last Point = %f / Average = %f",max,ave);
2417  LastPoint->Clear();
2418  LastPoint->AddText(lptext);
2419  TCanvas *ctnspillPOTday = new TCanvas("cnspillPOTday","POT Sum day",1200,800);
2420  ctnspillPOTday->cd();
2421  gPad->SetGridx();
2422  TGraph *gnspillPOTday = new TGraph(NspillPOTDayCount[p],NspillPOTtimeDay[p],NspillPOTDay[p]);
2423  sprintf(title,"%s Spill POT per Subrun - partition %.1u",trigname.c_str(),p);
2424  gnspillPOTday->SetTitle(title);
2425  gnspillPOTday->SetMarkerColor(kBlue);
2426  gnspillPOTday->GetXaxis()->SetTimeDisplay(1);
2427  gnspillPOTday->GetXaxis()->SetLabelSize(0.03);
2428  gnspillPOTday->GetXaxis()->SetTimeFormat(taxis_labels.c_str());
2429  gnspillPOTday->GetXaxis()->SetLimits(time_ago,XNow);
2430  gnspillPOTday->GetYaxis()->SetLabelSize(0.03);
2431  gnspillPOTday->GetXaxis()->SetTitle("(central time)");
2432  gnspillPOTday->GetYaxis()->SetRangeUser(0,60e12);
2433  gnspillPOTday->Draw("A*");
2434  TLine* l2SpillPOT=new TLine(time_ago,2e12,XNow,2e12);
2435  l2SpillPOT->SetLineColor(kRed);
2436  l2SpillPOT->SetLineWidth(3);
2437  l2SpillPOT->SetLineStyle(9);
2438  l2SpillPOT->Draw();
2439  UpdateText->Draw();
2440  LastPoint->Draw();
2441  sprintf(filename,"%s/%s-%s-P%.1unspillPOTperSR%s.png",PLOT_DIR.c_str(),det.c_str(),trig.c_str(),p,period.c_str());
2442  ctnspillPOTday->Print(filename);
2443  delete ctnspillPOTday;
2444  ctnspillPOTday = 0;
2445 
2446  // Adding "zoomed in" version of above plot
2447  TCanvas *ctnspillPOTday_zoom = new TCanvas("cnspillPOTday_zoom","POT Sum day",1200,800);
2448  ctnspillPOTday_zoom->cd();
2449  gPad->SetGridx();
2450  TGraph *gnspillPOTday_zoom = new TGraph(NspillPOTDayCount[p],NspillPOTtimeDay[p],NspillPOTDay[p]);
2451  sprintf(title,"%s Spill POT per subrun - partition %.1u",trigname.c_str(),p);
2452  gnspillPOTday_zoom->SetTitle(title);
2453  gnspillPOTday_zoom->SetMarkerColor(kBlue);
2454  gnspillPOTday_zoom->GetXaxis()->SetTimeDisplay(1);
2455  gnspillPOTday_zoom->GetXaxis()->SetLabelSize(0.03);
2456  gnspillPOTday_zoom->GetXaxis()->SetTimeFormat(taxis_labels.c_str());
2457  gnspillPOTday_zoom->GetXaxis()->SetLimits(time_ago,XNow);
2458  gnspillPOTday_zoom->GetYaxis()->SetLabelSize(0.03);
2459  gnspillPOTday_zoom->GetXaxis()->SetTitle("(central time)");
2460  gnspillPOTday_zoom->GetYaxis()->SetRangeUser((gnspillPOTday_zoom->GetMean(2)-3.*gnspillPOTday_zoom->GetRMS(2)),(gnspillPOTday_zoom->GetMean(2)+3.*gnspillPOTday_zoom->GetRMS(2)));
2461  gnspillPOTday_zoom->Draw("A*");
2462  UpdateText->Draw();
2463  LastPoint->Draw();
2464  sprintf(filename,"%s/%s-%s-P%.1unspillPOTperSRzoom%s.png",PLOT_DIR.c_str(),det.c_str(),trig.c_str(),p,period.c_str());
2465  ctnspillPOTday_zoom->Print(filename);
2466  delete ctnspillPOTday_zoom;
2467  ctnspillPOTday_zoom = 0;
2468 
2469  maxtime = 0;
2470  max = 0;
2471  ave = 0;
2472 
2473  for(int i = 0; i < NHornCurrentDayCount[p]; ++i) {
2474  ave += (double)NHornCurrentDay[p][i];
2475  if(NHornCurrenttimeDay[p][i] > maxtime) {
2476  maxtime = NHornCurrenttimeDay[p][i];
2477  max = NHornCurrentDay[p][i];
2478  }
2479  }
2480  if(NHornCurrentDayCount[p] > 0) ave = ave/(double)NHornCurrentDayCount[p];
2481  sprintf(lptext,"Last Point = %f / Average = %f",max,ave);
2482  LastPoint->Clear();
2483  LastPoint->AddText(lptext);
2484  TCanvas *ctnHornCurrentday = new TCanvas("cnHornCurrentday","Horn Current day",1200,800);
2485  ctnHornCurrentday->cd();
2486  gPad->SetGridx();
2487  TGraph *gnHornCurrentday = new TGraph(NHornCurrentDayCount[p],NHornCurrenttimeDay[p],NHornCurrentDay[p]);
2488  sprintf(title,"%s Horn Current per Subrun - partition %.1u",trigname.c_str(),p);
2489  gnHornCurrentday->SetTitle(title);
2490  gnHornCurrentday->SetMarkerColor(kBlue);
2491  gnHornCurrentday->GetXaxis()->SetTimeDisplay(1);
2492  gnHornCurrentday->GetXaxis()->SetLabelSize(0.03);
2493  gnHornCurrentday->GetXaxis()->SetTimeFormat(taxis_labels.c_str());
2494  gnHornCurrentday->GetXaxis()->SetLimits(time_ago,XNow);
2495  gnHornCurrentday->GetXaxis()->SetTitle("(central time)");
2496  gnHornCurrentday->GetYaxis()->SetTitle("(kA)");
2497  gnHornCurrentday->GetYaxis()->SetRangeUser(-203,-197);
2498  gnHornCurrentday->Draw("A*");
2499  TLine* l2cHornCurrent=new TLine(time_ago,-202,XNow,-202);
2500  l2cHornCurrent->SetLineColor(kRed);
2501  l2cHornCurrent->SetLineWidth(3);
2502  l2cHornCurrent->SetLineStyle(9);
2503  l2cHornCurrent->Draw();
2504  TLine* l2bHornCurrent=new TLine(time_ago,-198,XNow,-198);
2505  l2bHornCurrent->SetLineColor(kRed);
2506  l2bHornCurrent->SetLineWidth(3);
2507  l2bHornCurrent->SetLineStyle(9);
2508  l2bHornCurrent->Draw();
2509  UpdateText->Draw();
2510  LastPoint->Draw();
2511  UpdateText->Draw();
2512  LastPoint->Draw();
2513  sprintf(filename,"%s/%s-%s-P%.1unHornCurrentperSR%s.png",PLOT_DIR.c_str(),det.c_str(),trig.c_str(),p,period.c_str());
2514  ctnHornCurrentday->Print(filename);
2515  delete ctnHornCurrentday;
2516  ctnHornCurrentday = 0;
2517 
2518  // Adding "zoomed in" version of above plot
2519  TCanvas *ctnHornCurrentday_zoom = new TCanvas("cnHornCurrentday_zoom","Horn Current day",1200,800);
2520  ctnHornCurrentday_zoom->cd();
2521  gPad->SetGridx();
2522  TGraph *gnHornCurrentday_zoom = new TGraph(NHornCurrentDayCount[p],NHornCurrenttimeDay[p],NHornCurrentDay[p]);
2523  sprintf(title,"%s Horn Current per subrun - partition %.1u",trigname.c_str(),p);
2524  gnHornCurrentday_zoom->SetTitle(title);
2525  gnHornCurrentday_zoom->SetMarkerColor(kBlue);
2526  gnHornCurrentday_zoom->GetXaxis()->SetTimeDisplay(1);
2527  gnHornCurrentday_zoom->GetXaxis()->SetLabelSize(0.03);
2528  gnHornCurrentday_zoom->GetXaxis()->SetTimeFormat(taxis_labels.c_str());
2529  gnHornCurrentday_zoom->GetXaxis()->SetLimits(time_ago,XNow);
2530  gnHornCurrentday_zoom->GetXaxis()->SetTitle("(central time)");
2531  gnHornCurrentday_zoom->GetYaxis()->SetTitle("(kA)");
2532  gnHornCurrentday_zoom->GetYaxis()->SetRangeUser((gnHornCurrentday_zoom->GetMean(2)-3.*gnHornCurrentday_zoom->GetRMS(2)),(gnHornCurrentday_zoom->GetMean(2)+3.*gnHornCurrentday_zoom->GetRMS(2)));
2533  gnHornCurrentday_zoom->Draw("A*");
2534  UpdateText->Draw();
2535  LastPoint->Draw();
2536  sprintf(filename,"%s/%s-%s-P%.1unHornCurrentperSRzoom%s.png",PLOT_DIR.c_str(),det.c_str(),trig.c_str(),p,period.c_str());
2537  ctnHornCurrentday_zoom->Print(filename);
2538  delete ctnHornCurrentday_zoom;
2539  ctnHornCurrentday_zoom = 0;
2540 
2541  maxtime = 0;
2542  max = 0.0;
2543  ave = 0.0;
2544  for(int i = 0; i < NXPositionDayCount[p]; ++i) {
2545  ave += (double)NXPositionDay[p][i];
2546  if(NXPositiontimeDay[p][i] > maxtime) {
2547  maxtime = NXPositiontimeDay[p][i];
2548  max = NXPositionDay[p][i];
2549  }
2550  }
2551  if(NXPositionDayCount[p] > 0) ave = ave/(double)NXPositionDayCount[p];
2552  sprintf(lptext,"Last Point = %f / Average = %f",max,ave);
2553  LastPoint->Clear();
2554  LastPoint->AddText(lptext);
2555  TCanvas *ctnXPositionday = new TCanvas("cnXPositionday","X Position day",1200,800);
2556  ctnXPositionday->cd();
2557  gPad->SetGridx();
2558  TGraph *gnXPositionday = new TGraph(NXPositionDayCount[p],NXPositiontimeDay[p],NXPositionDay[p]);
2559  sprintf(title,"%s X Position per Subrun - partition %.1u",trigname.c_str(),p);
2560  gnXPositionday->SetTitle(title);
2561  gnXPositionday->SetMarkerColor(kBlue);
2562  gnXPositionday->GetXaxis()->SetTimeDisplay(1);
2563  gnXPositionday->GetXaxis()->SetLabelSize(0.03);
2564  gnXPositionday->GetXaxis()->SetTimeFormat(taxis_labels.c_str());
2565  gnXPositionday->GetXaxis()->SetLimits(time_ago,XNow);
2566  gnXPositionday->GetXaxis()->SetTitle("(central time)");
2567  gnXPositionday->GetYaxis()->SetTitle("(mm)");
2568  gnXPositionday->GetYaxis()->SetRangeUser(-2.1,2.1);
2569  gnXPositionday->Draw("A*");
2570  TLine* l2cXPosition=new TLine(time_ago,-2.0,XNow,-2.0);
2571  l2cXPosition->SetLineColor(kRed);
2572  l2cXPosition->SetLineWidth(3);
2573  l2cXPosition->SetLineStyle(9);
2574  l2cXPosition->Draw();
2575  TLine* l2bXPosition=new TLine(time_ago,2.0,XNow,2.0);
2576  l2bXPosition->SetLineColor(kRed);
2577  l2bXPosition->SetLineWidth(3);
2578  l2bXPosition->SetLineStyle(9);
2579  l2bXPosition->Draw();
2580  UpdateText->Draw();
2581  LastPoint->Draw();
2582  sprintf(filename,"%s/%s-%s-P%.1unXPositionperSR%s.png",PLOT_DIR.c_str(),det.c_str(),trig.c_str(),p,period.c_str());
2583  ctnXPositionday->Print(filename);
2584  delete ctnXPositionday;
2585  ctnXPositionday = 0;
2586 
2587  // Adding "zoomed in" version of above plot
2588  TCanvas *ctnXPositionday_zoom = new TCanvas("cnXPositionday_zoom","X Position day",1200,800);
2589  ctnXPositionday_zoom->cd();
2590  gPad->SetGridx();
2591  TGraph *gnXPositionday_zoom = new TGraph(NXPositionDayCount[p],NXPositiontimeDay[p],NXPositionDay[p]);
2592  sprintf(title,"%s X Position per subrun - partition %.1u",trigname.c_str(),p);
2593  gnXPositionday_zoom->SetTitle(title);
2594  gnXPositionday_zoom->SetMarkerColor(kBlue);
2595  gnXPositionday_zoom->GetXaxis()->SetTimeDisplay(1);
2596  gnXPositionday_zoom->GetXaxis()->SetLabelSize(0.03);
2597  gnXPositionday_zoom->GetXaxis()->SetTimeFormat(taxis_labels.c_str());
2598  gnXPositionday_zoom->GetXaxis()->SetLimits(time_ago,XNow);
2599  gnXPositionday_zoom->GetXaxis()->SetTitle("(central time)");
2600  gnXPositionday_zoom->GetYaxis()->SetTitle("(mm)");
2601  gnXPositionday_zoom->GetYaxis()->SetRangeUser((gnXPositionday_zoom->GetMean(2)-3.*gnXPositionday_zoom->GetRMS(2)),(gnXPositionday_zoom->GetMean(2)+3.*gnXPositionday_zoom->GetRMS(2)));
2602  gnXPositionday_zoom->Draw("A*");
2603  UpdateText->Draw();
2604  LastPoint->Draw();
2605  sprintf(filename,"%s/%s-%s-P%.1unXPositionperSRzoom%s.png",PLOT_DIR.c_str(),det.c_str(),trig.c_str(),p,period.c_str());
2606  ctnXPositionday_zoom->Print(filename);
2607  delete ctnXPositionday_zoom;
2608  ctnXPositionday_zoom = 0;
2609 
2610  maxtime = 0;
2611  max = 0.0;
2612  ave = 0.0;
2613  for(int i = 0; i < NYPositionDayCount[p]; ++i) {
2614  ave += (double)NYPositionDay[p][i];
2615  if(NYPositionDay[p][i] > maxtime) {
2616  maxtime = NYPositiontimeDay[p][i];
2617  max = NYPositionDay[p][i];
2618  }
2619  }
2620  if(NYPositionDayCount[p] > 0) ave = ave/(double)NYPositionDayCount[p];
2621  sprintf(lptext,"Last Point = %f / Average = %f",max,ave);
2622  LastPoint->Clear();
2623  LastPoint->AddText(lptext);
2624  TCanvas *ctnYPositionday = new TCanvas("cnYPositionday","Y Position day",1200,800);
2625  ctnYPositionday->cd();
2626  gPad->SetGridx();
2627  TGraph *gnYPositionday = new TGraph(NYPositionDayCount[p],NYPositiontimeDay[p],NYPositionDay[p]);
2628  sprintf(title,"%s Y Position per Subrun - partition %.1u",trigname.c_str(),p);
2629  gnYPositionday->SetTitle(title);
2630  gnYPositionday->SetMarkerColor(kBlue);
2631  gnYPositionday->GetXaxis()->SetTimeDisplay(1);
2632  gnYPositionday->GetXaxis()->SetLabelSize(0.03);
2633  gnYPositionday->GetXaxis()->SetTimeFormat(taxis_labels.c_str());
2634  gnYPositionday->GetXaxis()->SetLimits(time_ago,XNow);
2635  gnYPositionday->GetXaxis()->SetTitle("(central time)");
2636  gnYPositionday->GetYaxis()->SetTitle("(mm)");
2637  gnYPositionday->GetYaxis()->SetRangeUser(-2.1, 2.1);
2638  gnYPositionday->Draw("A*");
2639  TLine* l2cYPosition=new TLine(time_ago,-2,XNow,-2);
2640  l2cYPosition->SetLineColor(kRed);
2641  l2cYPosition->SetLineWidth(3);
2642  l2cYPosition->SetLineStyle(9);
2643  l2cYPosition->Draw();
2644  TLine* l2bYPosition=new TLine(time_ago,2.0,XNow,2.0);
2645  l2bYPosition->SetLineColor(kRed);
2646  l2bYPosition->SetLineWidth(3);
2647  l2bYPosition->SetLineStyle(9);
2648  l2bYPosition->Draw();
2649  UpdateText->Draw();
2650  LastPoint->Draw();
2651  sprintf(filename,"%s/%s-%s-P%.1unYPositionperSR%s.png",PLOT_DIR.c_str(),det.c_str(),trig.c_str(),p,period.c_str());
2652  ctnYPositionday->Print(filename);
2653  delete ctnYPositionday;
2654  ctnYPositionday = 0;
2655 
2656  // Adding "zoomed in" version of above plot
2657  TCanvas *ctnYPositionday_zoom = new TCanvas("cnYPositionday_zoom","Y Position day",1200,800);
2658  ctnYPositionday_zoom->cd();
2659  gPad->SetGridx();
2660  TGraph *gnYPositionday_zoom = new TGraph(NYPositionDayCount[p],NYPositiontimeDay[p],NYPositionDay[p]);
2661  sprintf(title,"%s Y Position per subrun - partition %.1u",trigname.c_str(),p);
2662  gnYPositionday_zoom->SetTitle(title);
2663  gnYPositionday_zoom->SetMarkerColor(kBlue);
2664  gnYPositionday_zoom->GetXaxis()->SetTimeDisplay(1);
2665  gnYPositionday_zoom->GetXaxis()->SetLabelSize(0.03);
2666  gnYPositionday_zoom->GetXaxis()->SetTimeFormat(taxis_labels.c_str());
2667  gnYPositionday_zoom->GetXaxis()->SetLimits(time_ago,XNow);
2668  gnYPositionday_zoom->GetXaxis()->SetTitle("(central time)");
2669  gnYPositionday_zoom->GetYaxis()->SetTitle("(mm)");
2670  gnYPositionday_zoom->GetYaxis()->SetRangeUser((gnYPositionday_zoom->GetMean(2)-3.*gnYPositionday_zoom->GetRMS(2)),(gnYPositionday_zoom->GetMean(2)+3.*gnYPositionday_zoom->GetRMS(2)));
2671  gnYPositionday_zoom->Draw("A*");
2672  UpdateText->Draw();
2673  LastPoint->Draw();
2674  sprintf(filename,"%s/%s-%s-P%.1unYPositionperSRzoom%s.png",PLOT_DIR.c_str(),det.c_str(),trig.c_str(),p,period.c_str());
2675  ctnYPositionday_zoom->Print(filename);
2676  delete ctnYPositionday_zoom;
2677  ctnYPositionday_zoom = 0;
2678 
2679  maxtime = 0;
2680  max = 0.0;
2681  ave = 0.0;
2682  for(int i = 0; i < NXWidthDayCount[p]; ++i) {
2683  ave += (double)NXWidthDay[p][i];
2684  if(NXWidthtimeDay[p][i] > maxtime) {
2685  maxtime = NXWidthtimeDay[p][i];
2686  max = NXWidthDay[p][i];
2687  }
2688  }
2689  if(NXWidthDayCount[p] > 0) ave = ave/(double)NXWidthDayCount[p];
2690  sprintf(lptext,"Last Point = %f / Average = %f",max,ave);
2691  LastPoint->Clear();
2692  LastPoint->AddText(lptext);
2693  TCanvas *ctnXWidthday = new TCanvas("cnXWidthday","X Width day",1200,800);
2694  ctnXWidthday->cd();
2695  gPad->SetGridx();
2696  TGraph *gnXWidthday = new TGraph(NXWidthDayCount[p],NXWidthtimeDay[p],NXWidthDay[p]);
2697  sprintf(title,"%s X Width per Subrun - partition %.1u",trigname.c_str(),p);
2698  gnXWidthday->SetTitle(title);
2699  gnXWidthday->SetMarkerColor(kBlue);
2700  gnXWidthday->GetXaxis()->SetTimeDisplay(1);
2701  gnXWidthday->GetXaxis()->SetLabelSize(0.03);
2702  gnXWidthday->GetXaxis()->SetTimeFormat(taxis_labels.c_str());
2703  gnXWidthday->GetXaxis()->SetLimits(time_ago,XNow);
2704  gnXWidthday->GetXaxis()->SetTitle("(central time)");
2705  gnXWidthday->GetYaxis()->SetTitle("(mm)");
2706  gnXWidthday->GetYaxis()->SetRangeUser(0.5,2.0);
2707  gnXWidthday->Draw("A*");
2708  TLine* l2cXWidth=new TLine(time_ago,0.57,XNow,0.57);
2709  l2cXWidth->SetLineColor(kRed);
2710  l2cXWidth->SetLineWidth(3);
2711  l2cXWidth->SetLineStyle(9);
2712  l2cXWidth->Draw();
2713  TLine* l2bXWidth=new TLine(time_ago,1.88,XNow,1.88);
2714  l2bXWidth->SetLineColor(kRed);
2715  l2bXWidth->SetLineWidth(3);
2716  l2bXWidth->SetLineStyle(9);
2717  l2bXWidth->Draw();
2718  UpdateText->Draw();
2719  LastPoint->Draw();
2720  sprintf(filename,"%s/%s-%s-P%.1unXWidthperSR%s.png",PLOT_DIR.c_str(),det.c_str(),trig.c_str(),p,period.c_str());
2721  ctnXWidthday->Print(filename);
2722  delete ctnXWidthday;
2723  ctnXWidthday = 0;
2724 
2725  // Adding "zoomed in" version of above plot
2726  TCanvas *ctnXWidthday_zoom = new TCanvas("cnXWidthday_zoom","X Width day",1200,800);
2727  ctnXWidthday_zoom->cd();
2728  gPad->SetGridx();
2729  TGraph *gnXWidthday_zoom = new TGraph(NXWidthDayCount[p],NXWidthtimeDay[p],NXWidthDay[p]);
2730  sprintf(title,"%s X Width per subrun - partition %.1u",trigname.c_str(),p);
2731  gnXWidthday_zoom->SetTitle(title);
2732  gnXWidthday_zoom->SetMarkerColor(kBlue);
2733  gnXWidthday_zoom->GetXaxis()->SetTimeDisplay(1);
2734  gnXWidthday_zoom->GetXaxis()->SetLabelSize(0.03);
2735  gnXWidthday_zoom->GetXaxis()->SetTimeFormat(taxis_labels.c_str());
2736  gnXWidthday_zoom->GetXaxis()->SetLimits(time_ago,XNow);
2737  gnXWidthday_zoom->GetXaxis()->SetTitle("(central time)");
2738  gnXWidthday_zoom->GetYaxis()->SetTitle("(mm)");
2739  gnXWidthday_zoom->GetYaxis()->SetRangeUser((gnXWidthday_zoom->GetMean(2)-3.*gnXWidthday_zoom->GetRMS(2)),(gnXWidthday_zoom->GetMean(2)+3.*gnXWidthday_zoom->GetRMS(2)));
2740  gnXWidthday_zoom->Draw("A*");
2741  UpdateText->Draw();
2742  LastPoint->Draw();
2743  sprintf(filename,"%s/%s-%s-P%.1unXWidthperSRzoom%s.png",PLOT_DIR.c_str(),det.c_str(),trig.c_str(),p,period.c_str());
2744  ctnXWidthday_zoom->Print(filename);
2745  delete ctnXWidthday_zoom;
2746  ctnXWidthday_zoom = 0;
2747 
2748  maxtime = 0;
2749  max = 0.0;
2750  ave = 0.0;
2751  for(int i = 0; i < NYWidthDayCount[p]; ++i) {
2752  ave += (double)NYWidthDay[p][i];
2753  if(NYWidthtimeDay[p][i] > maxtime) {
2754  maxtime = NYWidthtimeDay[p][i];
2755  max = NYWidthDay[p][i];
2756  }
2757  }
2758  if(NYWidthDayCount[p] > 0) ave = ave/(double)NYWidthDayCount[p];
2759  sprintf(lptext,"Last Point = %f / Average = %f",max,ave);
2760  LastPoint->Clear();
2761  LastPoint->AddText(lptext);
2762  TCanvas *ctnYWidthday = new TCanvas("cnYWidthday","Y Width day",1200,800);
2763  ctnYWidthday->cd();
2764  gPad->SetGridx();
2765  TGraph *gnYWidthday = new TGraph(NYWidthDayCount[p],NYWidthtimeDay[p],NYWidthDay[p]);
2766  sprintf(title,"%s Y Width per Subrun - partition %.1u",trigname.c_str(),p);
2767  gnYWidthday->SetTitle(title);
2768  gnYWidthday->SetMarkerColor(kBlue);
2769  gnYWidthday->GetXaxis()->SetTimeDisplay(1);
2770  gnYWidthday->GetXaxis()->SetLabelSize(0.03);
2771  gnYWidthday->GetXaxis()->SetTimeFormat(taxis_labels.c_str());
2772  gnYWidthday->GetXaxis()->SetLimits(time_ago,XNow);
2773  gnYWidthday->GetXaxis()->SetTitle("(central time)");
2774  gnYWidthday->GetYaxis()->SetTitle("(mm)");
2775  gnYWidthday->GetYaxis()->SetRangeUser(0.5,2.0);
2776  gnYWidthday->Draw("A*");
2777  TLine* l2cYWidth=new TLine(time_ago,0.57,XNow,0.57);
2778  l2cYWidth->SetLineColor(kRed);
2779  l2cYWidth->SetLineWidth(3);
2780  l2cYWidth->SetLineStyle(9);
2781  l2cYWidth->Draw();
2782  TLine* l2bYWidth=new TLine(time_ago,1.58,XNow,1.58);
2783  l2bYWidth->SetLineColor(kRed);
2784  l2bYWidth->SetLineWidth(3);
2785  l2bYWidth->SetLineStyle(9);
2786  l2bYWidth->Draw();
2787  UpdateText->Draw();
2788  LastPoint->Draw();
2789  sprintf(filename,"%s/%s-%s-P%.1unYWidthperSR%s.png",PLOT_DIR.c_str(),det.c_str(),trig.c_str(),p,period.c_str());
2790  ctnYWidthday->Print(filename);
2791  delete ctnYWidthday;
2792  ctnYWidthday = 0;
2793 
2794  // Adding "zoomed in" version of above plot
2795  TCanvas *ctnYWidthday_zoom = new TCanvas("cnYWidthday_zoom","Y Width day",1200,800);
2796  ctnYWidthday_zoom->cd();
2797  gPad->SetGridx();
2798  TGraph *gnYWidthday_zoom = new TGraph(NYWidthDayCount[p],NYWidthtimeDay[p],NYWidthDay[p]);
2799  sprintf(title,"%s Y Width per subrun - partition %.1u",trigname.c_str(),p);
2800  gnYWidthday_zoom->SetTitle(title);
2801  gnYWidthday_zoom->SetMarkerColor(kBlue);
2802  gnYWidthday_zoom->GetXaxis()->SetTimeDisplay(1);
2803  gnYWidthday_zoom->GetXaxis()->SetLabelSize(0.03);
2804  gnYWidthday_zoom->GetXaxis()->SetTimeFormat(taxis_labels.c_str());
2805  gnYWidthday_zoom->GetXaxis()->SetLimits(time_ago,XNow);
2806  gnYWidthday_zoom->GetXaxis()->SetTitle("(central time)");
2807  gnYWidthday_zoom->GetYaxis()->SetTitle("(mm)");
2808  gnYWidthday_zoom->GetYaxis()->SetRangeUser((gnYWidthday_zoom->GetMean(2)-3.*gnYWidthday_zoom->GetRMS(2)),(gnYWidthday_zoom->GetMean(2)+3.*gnYWidthday_zoom->GetRMS(2)));
2809  gnYWidthday_zoom->Draw("A*");
2810  UpdateText->Draw();
2811  LastPoint->Draw();
2812  sprintf(filename,"%s/%s-%s-P%.1unYWidthperSRzoom%s.png",PLOT_DIR.c_str(),det.c_str(),trig.c_str(),p,period.c_str());
2813  ctnYWidthday_zoom->Print(filename);
2814  delete ctnYWidthday_zoom;
2815  ctnYWidthday_zoom = 0;
2816 
2817  maxtime = 0;
2818  max = 0.0;
2819  ave = 0.0;
2820  for(int i = 0; i < NGoodBeamDayCount[p]; ++i) {
2821  ave += (double)NGoodBeamDay[p][i];
2822  if(NGoodBeamtimeDay[p][i] > maxtime) {
2823  maxtime = NGoodBeamtimeDay[p][i];
2824  max = NGoodBeamDay[p][i];
2825  }
2826  }
2827  if(NGoodBeamDayCount[p] > 0) ave = ave/(double)NGoodBeamDayCount[p];
2828  sprintf(lptext,"Last Point = %f / Average = %f",max,ave);
2829  LastPoint->Clear();
2830  LastPoint->AddText(lptext);
2831  TCanvas *ctnGoodBeamday = new TCanvas("cnGoodBeamday","Good Beam day",1200,800);
2832  ctnGoodBeamday->cd();
2833  gPad->SetGridx();
2834  TGraph *gnGoodBeamday = new TGraph(NGoodBeamDayCount[p],NGoodBeamtimeDay[p],NGoodBeamDay[p]);
2835  sprintf(title,"%s Good Beam per Subrun - partition %.1u",trigname.c_str(),p);
2836  gnGoodBeamday->SetTitle(title);
2837  gnGoodBeamday->SetMarkerColor(kBlue);
2838  gnGoodBeamday->GetXaxis()->SetTimeDisplay(1);
2839  gnGoodBeamday->GetXaxis()->SetLabelSize(0.03);
2840  gnGoodBeamday->GetXaxis()->SetTimeFormat(taxis_labels.c_str());
2841  gnGoodBeamday->GetXaxis()->SetLimits(time_ago,XNow);
2842  gnGoodBeamday->GetXaxis()->SetTitle("(central time)");
2843  gnGoodBeamday->GetYaxis()->SetRangeUser(-0.1,1.2);
2844  gnGoodBeamday->Draw("A*");
2845  UpdateText->Draw();
2846  LastPoint->Draw();
2847  sprintf(filename,"%s/%s-%s-P%.1unGoodBeamperSR%s.png",PLOT_DIR.c_str(),det.c_str(),trig.c_str(),p,period.c_str());
2848  ctnGoodBeamday->Print(filename);
2849  delete ctnGoodBeamday;
2850  ctnGoodBeamday = 0;
2851 
2852  // Adding "zoomed in" version of above plot
2853  TCanvas *ctnGoodBeamday_zoom = new TCanvas("cnGoodBeamday_zoom","Good Beam day",1200,800);
2854  ctnGoodBeamday_zoom->cd();
2855  gPad->SetGridx();
2856  TGraph *gnGoodBeamday_zoom = new TGraph(NGoodBeamDayCount[p],NGoodBeamtimeDay[p],NGoodBeamDay[p]);
2857  sprintf(title,"%s Good Beam per subrun - partition %.1u",trigname.c_str(),p);
2858  gnGoodBeamday_zoom->SetTitle(title);
2859  gnGoodBeamday_zoom->SetMarkerColor(kBlue);
2860  gnGoodBeamday_zoom->GetXaxis()->SetTimeDisplay(1);
2861  gnGoodBeamday_zoom->GetXaxis()->SetLabelSize(0.03);
2862  gnGoodBeamday_zoom->GetXaxis()->SetTimeFormat(taxis_labels.c_str());
2863  gnGoodBeamday_zoom->GetXaxis()->SetLimits(time_ago,XNow);
2864  gnGoodBeamday_zoom->GetXaxis()->SetTitle("(central time)");
2865  gnGoodBeamday_zoom->GetYaxis()->SetRangeUser((gnGoodBeamday_zoom->GetMean(2)-3.*gnGoodBeamday_zoom->GetRMS(2)),(gnGoodBeamday_zoom->GetMean(2)+3.*gnGoodBeamday_zoom->GetRMS(2)));
2866  gnGoodBeamday_zoom->Draw("A*");
2867  UpdateText->Draw();
2868  LastPoint->Draw();
2869  sprintf(filename,"%s/%s-%s-P%.1unGoodBeamperSRzoom%s.png",PLOT_DIR.c_str(),det.c_str(),trig.c_str(),p,period.c_str());
2870  ctnGoodBeamday_zoom->Print(filename);
2871  delete ctnGoodBeamday_zoom;
2872  ctnGoodBeamday_zoom = 0;
2873  //end new beam plots
2874 
2875  maxtime = 0;
2876  max = 0.0;
2877  ave = 0.0;
2878  for(int i = 0; i < NSliceDayCount[p]; ++i) {
2879  ave += (double)NSliceDay[p][i];
2880  if(NSlicetimeDay[p][i] > maxtime) {
2881  maxtime = NSlicetimeDay[p][i];
2882  max = NSliceDay[p][i];
2883  }
2884  }
2885  if(NSliceDayCount[p] > 0) ave = ave/(double)NSliceDayCount[p];
2886  sprintf(lptext,"Last Point = %f / Average = %f",max,ave);
2887  LastPoint->Clear();
2888  LastPoint->AddText(lptext);
2889  TCanvas *ctnSliceday = new TCanvas("cnSliceday","# Non-Noise Slices day",1200,800);
2890  ctnSliceday->cd();
2891  gPad->SetGridx();
2892  TGraph *gnSliceday = new TGraph(NSliceDayCount[p],NSlicetimeDay[p],NSliceDay[p]);
2893  sprintf(title,"%s Number of Slices per Subrun - partition %.1u",trigname.c_str(),p);
2894  gnSliceday->SetTitle(title);
2895  gnSliceday->SetMarkerColor(kBlue);
2896  gnSliceday->GetXaxis()->SetTimeDisplay(1);
2897  gnSliceday->GetXaxis()->SetLabelSize(0.03);
2898  gnSliceday->GetXaxis()->SetTimeFormat(taxis_labels.c_str());
2899  gnSliceday->GetXaxis()->SetLimits(time_ago,XNow);
2900  gnSliceday->GetXaxis()->SetTitle("(central time)");
2901  gnSliceday->Draw("A*");
2902  UpdateText->Draw();
2903  LastPoint->Draw();
2904  sprintf(filename,"%s/%s-%s-P%.1unSliceperSR%s.png",PLOT_DIR.c_str(),det.c_str(),trig.c_str(),p,period.c_str());
2905  ctnSliceday->Print(filename);
2906  delete ctnSliceday;
2907  ctnSliceday = 0;
2908 
2909  // Adding "zoomed in" version of above plot
2910  TCanvas *ctnSliceday_zoom = new TCanvas("cnSliceday_zoom","# Non-Noise Slices day",1200,800);
2911  ctnSliceday_zoom->cd();
2912  gPad->SetGridx();
2913  TGraph *gnSliceday_zoom = new TGraph(NSliceDayCount[p],NSlicetimeDay[p],NSliceDay[p]);
2914  sprintf(title,"%s Number of Slices per Subrun - partition %.1u",trigname.c_str(),p);
2915  gnSliceday_zoom->SetTitle(title);
2916  gnSliceday_zoom->SetMarkerColor(kBlue);
2917  gnSliceday_zoom->GetXaxis()->SetTimeDisplay(1);
2918  gnSliceday_zoom->GetXaxis()->SetLabelSize(0.03);
2919  gnSliceday_zoom->GetXaxis()->SetTimeFormat(taxis_labels.c_str());
2920  gnSliceday_zoom->GetXaxis()->SetLimits(time_ago,XNow);
2921  gnSliceday_zoom->GetXaxis()->SetTitle("(central time)");
2922  gnSliceday_zoom->GetYaxis()->SetRangeUser((gnSliceday_zoom->GetMean(2)-3.*gnSliceday_zoom->GetRMS(2)),(gnSliceday_zoom->GetMean(2)+3.*gnSliceday_zoom->GetRMS(2)));
2923  gnSliceday_zoom->Draw("A*");
2924  UpdateText->Draw();
2925  LastPoint->Draw();
2926  sprintf(filename,"%s/%s-%s-P%.1unSliceperSRzoom%s.png",PLOT_DIR.c_str(),det.c_str(),trig.c_str(),p,period.c_str());
2927  ctnSliceday_zoom->Print(filename);
2928  delete ctnSliceday_zoom;
2929  ctnSliceday_zoom = 0;
2930 
2931  maxtime = 0;
2932  max = 0.0;
2933  ave = 0.0;
2934  for(int i = 0; i < NNonNoiseSliceHitDayCount[p]; ++i) {
2935  ave += (double)NNonNoiseSliceHitDay[p][i];
2936  if(NNonNoiseSliceHittimeDay[p][i] > maxtime) {
2937  maxtime = NNonNoiseSliceHittimeDay[p][i];
2938  max = NNonNoiseSliceHitDay[p][i];
2939  }
2940  }
2941  if(NNonNoiseSliceHitDayCount[p] > 0) ave = ave/(double)NNonNoiseSliceHitDayCount[p];
2942  sprintf(lptext,"Last Point = %f / Average = %f",max,ave);
2943  LastPoint->Clear();
2944  LastPoint->AddText(lptext);
2945  TCanvas *ctnSliceHitday = new TCanvas("cnSliceHitday","# Non-Noise Slice Hits day",1200,800);
2946  ctnSliceHitday->cd();
2947  //ctnSliceHitday->SetLogy();
2948  gPad->SetGridx();
2949  TGraph *gnSliceHitday = new TGraph(NNonNoiseSliceHitDayCount[p],NNonNoiseSliceHittimeDay[p],NNonNoiseSliceHitDay[p]);
2950  sprintf(title,"%s Number of Slice Hits per Subrun - partition %.1u",trigname.c_str(),p);
2951  gnSliceHitday->SetTitle(title);
2952  gnSliceHitday->SetMarkerColor(kBlue);
2953  gnSliceHitday->GetXaxis()->SetTimeDisplay(1);
2954  gnSliceHitday->GetXaxis()->SetLabelSize(0.03);
2955  gnSliceHitday->GetXaxis()->SetTimeFormat(taxis_labels.c_str());
2956  gnSliceHitday->GetXaxis()->SetLimits(time_ago,XNow);
2957  gnSliceHitday->GetXaxis()->SetTitle("(central time)");
2958  gnSliceHitday->Draw("A*");
2959  UpdateText->Draw();
2960  LastPoint->Draw();
2961  sprintf(filename,"%s/%s-%s-P%.1unSliceHitperSR%s.png",PLOT_DIR.c_str(),det.c_str(),trig.c_str(),p,period.c_str());
2962  ctnSliceHitday->Print(filename);
2963  delete ctnSliceHitday;
2964  ctnSliceHitday = 0;
2965 
2966  //Adding "zoomed in" version of the above plot
2967  TCanvas *ctnSliceHitday_zoom = new TCanvas("cnSliceHitday_zoom","# Non-Noise Slice Hits day",1200,800);
2968  ctnSliceHitday_zoom->cd();
2969  //ctnSliceHitday_zoom->SetLogy();
2970  gPad->SetGridx();
2971  TGraph *gnSliceHitday_zoom = new TGraph(NNonNoiseSliceHitDayCount[p],NNonNoiseSliceHittimeDay[p],NNonNoiseSliceHitDay[p]);
2972  sprintf(title,"%s Number of Slice Hits per Subrun - partition %.1u",trigname.c_str(),p);
2973  gnSliceHitday_zoom->SetTitle(title);
2974  gnSliceHitday_zoom->SetMarkerColor(kBlue);
2975  gnSliceHitday_zoom->GetXaxis()->SetTimeDisplay(1);
2976  gnSliceHitday_zoom->GetXaxis()->SetLabelSize(0.03);
2977  gnSliceHitday_zoom->GetXaxis()->SetTimeFormat(taxis_labels.c_str());
2978  gnSliceHitday_zoom->GetXaxis()->SetLimits(time_ago,XNow);
2979  gnSliceHitday_zoom->GetXaxis()->SetTitle("(central time)");
2980  gnSliceHitday_zoom->GetYaxis()->SetRangeUser((gnSliceHitday_zoom->GetMean(2)-3.*gnSliceHitday_zoom->GetRMS(2)),(gnSliceHitday_zoom->GetMean(2)+3.*gnSliceHitday_zoom->GetRMS(2)));
2981  gnSliceHitday_zoom->Draw("A*");
2982  UpdateText->Draw();
2983  LastPoint->Draw();
2984  sprintf(filename,"%s/%s-%s-P%.1unSliceHitperSRzoom%s.png",PLOT_DIR.c_str(),det.c_str(),trig.c_str(),p,period.c_str());
2985  ctnSliceHitday_zoom->Print(filename);
2986  delete ctnSliceHitday_zoom;
2987  ctnSliceHitday_zoom = 0;
2988 
2989  maxtime = 0;
2990  max = 0.0;
2991  ave = 0.0;
2992  for(int i = 0; i < NNoiseSliceHitDayCount[p]; ++i) {
2993  ave += (double)NNoiseSliceHitDay[p][i];
2994  if(NNoiseSliceHittimeDay[p][i] > maxtime) {
2995  maxtime = NNoiseSliceHittimeDay[p][i];
2996  max = NNoiseSliceHitDay[p][i];
2997  }
2998  }
2999  if(NNoiseSliceHitDayCount[p] > 0) ave = ave/(double)NNoiseSliceHitDayCount[p];
3000  sprintf(lptext,"Last Point = %f / Average = %f",max,ave);
3001  LastPoint->Clear();
3002  LastPoint->AddText(lptext);
3003  TCanvas *ctNNoiseSliceHitday = new TCanvas("cNNoiseSliceHitday","# Noise Slice Hits day",1200,800);
3004  ctNNoiseSliceHitday->cd();
3005  gPad->SetGridx();
3006  TGraph *gNNoiseSliceHitday = new TGraph(NNoiseSliceHitDayCount[p],NNoiseSliceHittimeDay[p],NNoiseSliceHitDay[p]);
3007  sprintf(title,"%s Number of Noise Slice Hits per Subrun - partition %.1u",trigname.c_str(),p);
3008  gNNoiseSliceHitday->SetTitle(title);
3009  gNNoiseSliceHitday->SetMarkerColor(kBlue);
3010  gNNoiseSliceHitday->GetXaxis()->SetTimeDisplay(1);
3011  gNNoiseSliceHitday->GetXaxis()->SetLabelSize(0.03);
3012  gNNoiseSliceHitday->GetXaxis()->SetTimeFormat(taxis_labels.c_str());
3013  gNNoiseSliceHitday->GetXaxis()->SetLimits(time_ago,XNow);
3014  gNNoiseSliceHitday->GetXaxis()->SetTitle("(central time)");
3015  gNNoiseSliceHitday->Draw("A*");
3016  UpdateText->Draw();
3017  LastPoint->Draw();
3018  sprintf(filename,"%s/%s-%s-P%.1uNNoiseSliceHitperSR%s.png",PLOT_DIR.c_str(),det.c_str(),trig.c_str(),p,period.c_str());
3019  ctNNoiseSliceHitday->Print(filename);
3020  delete ctNNoiseSliceHitday;
3021  ctNNoiseSliceHitday = 0;
3022 
3023  // Adding "zoomed in" version of the above plot
3024  TCanvas *ctNNoiseSliceHitday_zoom = new TCanvas("cNNoiseSliceHitday_zoom","# Noise Slice Hits day",1200,800);
3025  ctNNoiseSliceHitday_zoom->cd();
3026  gPad->SetGridx();
3027  TGraph *gNNoiseSliceHitday_zoom = new TGraph(NNoiseSliceHitDayCount[p],NNoiseSliceHittimeDay[p],NNoiseSliceHitDay[p]);
3028  sprintf(title,"%s Number of Noise Slice Hits per Subrun - partition %.1u",trigname.c_str(),p);
3029  gNNoiseSliceHitday_zoom->SetTitle(title);
3030  gNNoiseSliceHitday_zoom->SetMarkerColor(kBlue);
3031  gNNoiseSliceHitday_zoom->GetXaxis()->SetTimeDisplay(1);
3032  gNNoiseSliceHitday_zoom->GetXaxis()->SetLabelSize(0.03);
3033  gNNoiseSliceHitday_zoom->GetXaxis()->SetTimeFormat(taxis_labels.c_str());
3034  gNNoiseSliceHitday_zoom->GetXaxis()->SetLimits(time_ago,XNow);
3035  gNNoiseSliceHitday_zoom->GetXaxis()->SetTitle("(central time)");
3036  gNNoiseSliceHitday_zoom->GetYaxis()->SetRangeUser((gNNoiseSliceHitday_zoom->GetMean(2)-3.*gNNoiseSliceHitday_zoom->GetRMS(2)),(gNNoiseSliceHitday_zoom->GetMean(2)+3.*gNNoiseSliceHitday_zoom->GetRMS(2)));
3037  gNNoiseSliceHitday_zoom->Draw("A*");
3038  UpdateText->Draw();
3039  LastPoint->Draw();
3040  sprintf(filename,"%s/%s-%s-P%.1uNNoiseSliceHitperSRzoom%s.png",PLOT_DIR.c_str(),det.c_str(),trig.c_str(),p,period.c_str());
3041  ctNNoiseSliceHitday_zoom->Print(filename);
3042  delete ctNNoiseSliceHitday_zoom;
3043  ctNNoiseSliceHitday_zoom = 0;
3044 
3045  maxtime = 0;
3046  max = 0.0;
3047  ave = 0.0;
3048  for(int i = 0; i < NTsdDayCount[p]; ++i) {
3049  ave += (double)NTsdDay[p][i];
3050  if(NTsdtimeDay[p][i] > maxtime) {
3051  maxtime = NTsdtimeDay[p][i];
3052  max = NTsdDay[p][i];
3053  }
3054  }
3055  if(NTsdDayCount[p] > 0) ave = ave/(double)NTsdDayCount[p];
3056  sprintf(lptext,"Last Point = %f / Average = %f",max,ave);
3057  LastPoint->Clear();
3058  LastPoint->AddText(lptext);
3059  TCanvas *ctTsdday = new TCanvas("cTsdday","Slice Time Duration Standard Dev. day",1200,800);
3060  ctTsdday->cd();
3061  gPad->SetGridx();
3062  TGraph *gTsdday = new TGraph(NTsdDayCount[p],NTsdtimeDay[p],NTsdDay[p]);
3063  sprintf(title,"%s Slice Time Duration Standard Dev. by Subrun - partition %.1u",trigname.c_str(),p);
3064  gTsdday->SetTitle(title);
3065  gTsdday->SetMarkerColor(kBlue);
3066  gTsdday->GetXaxis()->SetTimeDisplay(1);
3067  gTsdday->GetXaxis()->SetLabelSize(0.03);
3068  gTsdday->GetXaxis()->SetTimeFormat(taxis_labels.c_str());
3069  gTsdday->GetXaxis()->SetLimits(time_ago,XNow);
3070  gTsdday->GetXaxis()->SetTitle("(central time)");
3071  gTsdday->Draw("A*");
3072  UpdateText->Draw();
3073  LastPoint->Draw();
3074  sprintf(filename,"%s/%s-%s-P%.1uTsdperSR%s.png",PLOT_DIR.c_str(),det.c_str(),trig.c_str(),p,period.c_str());
3075  ctTsdday->Print(filename);
3076  delete ctTsdday;
3077  ctTsdday = 0;
3078 
3079  // Adding "zoomed in" version of the above plot
3080  TCanvas *ctTsdday_zoom = new TCanvas("cTsdday_zoom","Slice Time Duration Standard Dev. day",1200,800);
3081  ctTsdday_zoom->cd();
3082  gPad->SetGridx();
3083  TGraph *gTsdday_zoom = new TGraph(NTsdDayCount[p],NTsdtimeDay[p],NTsdDay[p]);
3084  sprintf(title,"%s Slice Time Duration Standard Dev. by Subrun - partition %.1u",trigname.c_str(),p);
3085  gTsdday_zoom->SetTitle(title);
3086  gTsdday_zoom->SetMarkerColor(kBlue);
3087  gTsdday_zoom->GetXaxis()->SetTimeDisplay(1);
3088  gTsdday_zoom->GetXaxis()->SetLabelSize(0.03);
3089  gTsdday_zoom->GetXaxis()->SetTimeFormat(taxis_labels.c_str());
3090  gTsdday_zoom->GetXaxis()->SetLimits(time_ago,XNow);
3091  gTsdday_zoom->GetXaxis()->SetTitle("(central time)");
3092  gTsdday_zoom->GetYaxis()->SetRangeUser((gTsdday_zoom->GetMean(2)-3.*gTsdday_zoom->GetRMS(2)),(gTsdday_zoom->GetMean(2)+3.*gTsdday_zoom->GetRMS(2)));
3093  gTsdday_zoom->Draw("A*");
3094  UpdateText->Draw();
3095  LastPoint->Draw();
3096  sprintf(filename,"%s/%s-%s-P%.1uTsdperSRzoom%s.png",PLOT_DIR.c_str(),det.c_str(),trig.c_str(),p,period.c_str());
3097  ctTsdday_zoom->Print(filename);
3098  delete ctTsdday_zoom;
3099  ctTsdday_zoom = 0;
3100 
3101 
3102  maxtime = 0;
3103  max = 0.0;
3104  ave = 0.0;
3105  for(int i = 0; i < NTrackDayCount[p]; ++i) {
3106  ave += (double)NTrackDay[p][i];
3107  if(NTracktimeDay[p][i] > maxtime) {
3108  maxtime = NTracktimeDay[p][i];
3109  max = NTrackDay[p][i];
3110  }
3111  }
3112  if(NTrackDayCount[p] > 0) ave = ave/(double)NTrackDayCount[p];
3113  sprintf(lptext,"Last Point = %f / Average = %f",max,ave);
3114  LastPoint->Clear();
3115  LastPoint->AddText(lptext);
3116  TCanvas *ctnTrackday = new TCanvas("cnTrackday","# 3D Tracks day",1200,800);
3117  ctnTrackday->cd();
3118  gPad->SetGridx();
3119  TGraph *gnTrackday = new TGraph(NTrackDayCount[p],NTracktimeDay[p],NTrackDay[p]);
3120  sprintf(title,"%s # Tracks by Subrun - partition %.1u",trigname.c_str(),p);
3121  gnTrackday->SetTitle(title);
3122  gnTrackday->SetMarkerColor(kBlue);
3123  gnTrackday->GetXaxis()->SetTimeDisplay(1);
3124  gnTrackday->GetXaxis()->SetLabelSize(0.03);
3125  gnTrackday->GetXaxis()->SetTimeFormat(taxis_labels.c_str());
3126  gnTrackday->GetXaxis()->SetLimits(time_ago,XNow);
3127  gnTrackday->GetXaxis()->SetTitle("(central time)");
3128  gnTrackday->Draw("A*");
3129  UpdateText->Draw();
3130  LastPoint->Draw();
3131  sprintf(filename,"%s/%s-%s-P%.1unTrackAll3DperSR%s.png",PLOT_DIR.c_str(),det.c_str(),trig.c_str(),p,period.c_str());
3132  ctnTrackday->Print(filename);
3133  delete ctnTrackday;
3134  ctnTrackday = 0;
3135 
3136  // Adding "zoomed in" version of the above plot
3137  TCanvas *ctnTrackday_zoom = new TCanvas("cnTrackday_zoom","# 3D Tracks day",1200,800);
3138  ctnTrackday_zoom->cd();
3139  gPad->SetGridx();
3140  TGraph *gnTrackday_zoom = new TGraph(NTrackDayCount[p],NTracktimeDay[p],NTrackDay[p]);
3141  sprintf(title,"%s # Tracks by Subrun - partition %.1u",trigname.c_str(),p);
3142  gnTrackday_zoom->SetTitle(title);
3143  gnTrackday_zoom->SetMarkerColor(kBlue);
3144  gnTrackday_zoom->GetXaxis()->SetTimeDisplay(1);
3145  gnTrackday_zoom->GetXaxis()->SetLabelSize(0.03);
3146  gnTrackday_zoom->GetXaxis()->SetTimeFormat(taxis_labels.c_str());
3147  gnTrackday_zoom->GetXaxis()->SetLimits(time_ago,XNow);
3148  gnTrackday_zoom->GetXaxis()->SetTitle("(central time)");
3149  gnTrackday_zoom->GetYaxis()->SetRangeUser((gnTrackday_zoom->GetMean(2)-3.*gnTrackday_zoom->GetRMS(2)),(gnTrackday_zoom->GetMean(2)+3.*gnTrackday_zoom->GetRMS(2)));
3150  gnTrackday_zoom->Draw("A*");
3151  UpdateText->Draw();
3152  LastPoint->Draw();
3153  sprintf(filename,"%s/%s-%s-P%.1unTrackAll3DperSRzoom%s.png",PLOT_DIR.c_str(),det.c_str(),trig.c_str(),p,period.c_str());
3154  ctnTrackday_zoom->Print(filename);
3155  delete ctnTrackday_zoom;
3156  ctnTrackday_zoom = 0;
3157 
3158  maxtime = 0;
3159  max = 0.0;
3160  ave = 0.0;
3161  for(int i = 0; i < NTrackLenDayCount[p]; ++i) {
3162  ave += (double)NTrackLenDay[p][i];
3163  if(NTrackLentimeDay[p][i] > maxtime) {
3164  maxtime = NTrackLentimeDay[p][i];
3165  max = NTrackLenDay[p][i];
3166  }
3167  }
3168  if(NTrackLenDayCount[p] > 0) ave = ave/(double)NTrackLenDayCount[p];
3169  sprintf(lptext,"Last Point = %f / Average = %f",max,ave);
3170  LastPoint->Clear();
3171  LastPoint->AddText(lptext);
3172  TCanvas *ctTrackLenday = new TCanvas("cTrackLenday","3D Track Len day",1200,800);
3173  ctTrackLenday->cd();
3174  gPad->SetGridx();
3175  TGraph *gTrackLenday = new TGraph(NTrackLenDayCount[p],NTrackLentimeDay[p],NTrackLenDay[p]);
3176  sprintf(title,"%s Ave. Track Length by Subrun - partition %.1u",trigname.c_str(),p);
3177  gTrackLenday->SetTitle(title);
3178  gTrackLenday->SetMarkerColor(kBlue);
3179  gTrackLenday->GetXaxis()->SetTimeDisplay(1);
3180  gTrackLenday->GetXaxis()->SetLabelSize(0.03);
3181  gTrackLenday->GetXaxis()->SetTimeFormat(taxis_labels.c_str());
3182  gTrackLenday->GetXaxis()->SetLimits(time_ago,XNow);
3183  gTrackLenday->GetXaxis()->SetTitle("(central time)");
3184  gTrackLenday->Draw("A*");
3185  UpdateText->Draw();
3186  LastPoint->Draw();
3187  sprintf(filename,"%s/%s-%s-P%.1uTrackLenAll3DperSR%s.png",PLOT_DIR.c_str(),det.c_str(),trig.c_str(),p,period.c_str());
3188  ctTrackLenday->Print(filename);
3189  delete ctTrackLenday;
3190  ctTrackLenday = 0;
3191 
3192  // New "zoomed-in" version of TrackLenday above...
3193  TCanvas *ctTrackLenday_zoom = new TCanvas("cTrackLenday_zoom","3D Track Len day",1200,800);
3194  ctTrackLenday_zoom->cd();
3195  gPad->SetGridx();
3196  TGraph *gTrackLenday_zoom = new TGraph(NTrackLenDayCount[p],NTrackLentimeDay[p],NTrackLenDay[p]);
3197  sprintf(title,"%s Ave. Track Length by Subrun - partition %.1u",trigname.c_str(),p);
3198  gTrackLenday_zoom->SetTitle(title);
3199  gTrackLenday_zoom->SetMarkerColor(kBlue);
3200  gTrackLenday_zoom->GetXaxis()->SetTimeDisplay(1);
3201  gTrackLenday_zoom->GetXaxis()->SetLabelSize(0.03);
3202  gTrackLenday_zoom->GetXaxis()->SetTimeFormat(taxis_labels.c_str());
3203  gTrackLenday_zoom->GetXaxis()->SetLimits(time_ago,XNow);
3204  gTrackLenday_zoom->GetXaxis()->SetTitle("(central time)");
3205  gTrackLenday_zoom->GetYaxis()->SetRangeUser((gTrackLenday_zoom->GetMean(2)-3.*gTrackLenday_zoom->GetRMS(2)),(gTrackLenday_zoom->GetMean(2)+3.*gTrackLenday_zoom->GetRMS(2)));
3206  gTrackLenday_zoom->Draw("A*");
3207  UpdateText->Draw();
3208  LastPoint->Draw();
3209  sprintf(filename,"%s/%s-%s-P%.1uTrackLenAll3DperSRzoom%s.png",PLOT_DIR.c_str(),det.c_str(),trig.c_str(),p,period.c_str());
3210  ctTrackLenday_zoom->Print(filename);
3211  delete ctTrackLenday_zoom;
3212  ctTrackLenday_zoom = 0;
3213 
3214  // NEW PLOTS
3215  // Comment by Hayes: Am now able to draw the three graphs on the same pad and canvas (via a TMultiGraph), but cannot convert
3216  // the time on the xaxis to the readable Hour Minute format. Tried using the same commands on the multigraph as are used
3217  // for each graph and it seg faults every time...
3218  TCanvas *cTrackFracday = new TCanvas("cTrackFracday","Track Fractions day",1200,800);
3219  TPad *pad1 = new TPad("pad1","",0,0,1,1);
3220  TPad *pad2 = new TPad("pad2","",0,0,1,1);
3221  pad2->SetFillStyle(4000); // pad2 will be transparent
3222  pad2->SetFillColor(0);
3223  pad2->SetFrameFillStyle(4000);
3224  pad1->Draw();
3225  pad1->cd();
3226  pad1->SetGridx();
3227  TMultiGraph *gTF = new TMultiGraph;
3228  TGraph *gTFAll3Dday = new TGraph(TrackFracDayCount[p],TrackFracAll3DtimeDay[p],TrackFracAll3DDay[p]);
3229  TGraph *gTFAll2Dday = new TGraph(TrackFracDayCount[p],TrackFracAll2DtimeDay[p],TrackFracAll2DDay[p]);
3230  TGraph *gTFCont3Dday = new TGraph(TrackFracDayCount[p],TrackFracCont3DtimeDay[p],TrackFracCont3DDay[p]);
3231  sprintf(title,"%s Track Fractions - partition %.1u",trigname.c_str(),p);
3232 
3233  pad1->SetLogy();
3234 
3235 
3236  gTFAll2Dday->SetTitle(title);
3237  gTFAll2Dday->SetMarkerColor(kBlue-7);
3238  gTFAll2Dday->SetFillColor(kBlue-7);
3239  if(det == "NearDet" || det == "TestBeam")
3240  gTFAll2Dday->SetMarkerStyle(21);
3241  else
3242  gTFAll2Dday->SetMarkerStyle(7);
3243 
3244  gTFCont3Dday->SetTitle(title);
3245  gTFCont3Dday->SetMarkerColor(kGray+3);
3246  gTFCont3Dday->SetFillColor(kGray+3);
3247  if(det == "NearDet" || det == "TestBeam")
3248  gTFCont3Dday->SetMarkerStyle(21);
3249  else
3250  gTFCont3Dday->SetMarkerStyle(7);
3251 
3252  //gTF->Add(gTFAll3Dday);
3253  gTF->Add(gTFAll2Dday);
3254  gTF->Add(gTFCont3Dday);
3255  gTF->Draw("ap");
3256 
3257  gTF->SetTitle(title);
3258  //cTrackFracday->Modified();
3259  //cTrackFracday->Update();
3260  pad1->Modified();
3261  pad1->Update();
3262 
3263  UpdateText->Draw();
3264 
3265  //gTF->SetTitle(title);
3266  gTF->GetXaxis()->SetRangeUser(0.0,1.1);
3267  gTF->GetXaxis()->SetTimeDisplay(1);
3268  gTF->GetXaxis()->SetLabelSize(0.03);
3269  gTF->GetXaxis()->SetTimeFormat(taxis_labels.c_str());
3270  gTF->GetXaxis()->SetLimits(time_ago,XNow);
3271  gTF->GetXaxis()->SetTitle("(central time)");
3272  gTF->GetYaxis()->SetRangeUser(0.001,1.0);
3273 
3274  //cTrackFracday->cd();
3275 
3276  pad2->Draw();
3277  pad2->cd();
3278  pad2->SetGridx();
3279  gTFAll3Dday->SetTitle("");
3280  gTFAll3Dday->SetMarkerColor(kMagenta-7);
3281  gTFAll3Dday->SetFillColor(kMagenta-7);
3282  if(det == "NearDet" || det == "TestBeam")
3283  gTFAll3Dday->SetMarkerStyle(21);
3284  else
3285  gTFAll3Dday->SetMarkerStyle(7);
3286  gTFAll3Dday->GetXaxis()->SetRangeUser(0.0,1.1);
3287  gTFAll3Dday->GetXaxis()->SetTimeDisplay(1);
3288  gTFAll3Dday->GetXaxis()->SetLabelSize(0.03);
3289  gTFAll3Dday->GetXaxis()->SetTimeFormat(taxis_labels.c_str());
3290  gTFAll3Dday->GetXaxis()->SetLimits(time_ago,XNow);
3291  gTFAll3Dday->GetXaxis()->SetTitle("(central time)");
3292  gTFAll3Dday->GetYaxis()->SetLabelColor(kMagenta-7);
3293  gTFAll3Dday->GetYaxis()->SetLabelSize(0.026);
3294  //gTFAll3Dday->GetYaxis()->SetRangeUser(0.97,1.00);
3295  gTFAll3Dday->Draw("apY+");
3296  pad2->Modified();
3297  pad2->Update();
3298 
3299  // Define legend
3300  TLegend *leg = new TLegend(0.60,0.66,0.85,0.78);
3301  leg->SetFillColor(0);
3302  leg->AddEntry(gTFAll2Dday,"#bf{All 2D Tracks}","f");
3303  leg->AddEntry(gTFCont3Dday,"#bf{Contained 3D Tracks}","f");
3304  leg->AddEntry(gTFAll3Dday,"#bf{All 3D Tracks}","f");
3305  leg->SetFillStyle(4000);
3306  leg->SetLineColor(0);
3307 
3308  leg->Draw();
3309 
3310  sprintf(filename,"%s/%s-%s-P%.1uTrackFractionsperSR%s.png",PLOT_DIR.c_str(),det.c_str(),trig.c_str(),p,period.c_str());
3311  cTrackFracday->Print(filename);
3312  delete cTrackFracday;
3313  cTrackFracday = 0;
3314 
3315 
3316  // Now start making efficiency plots using hitsVwcell and cellsVwcell
3317  eff_plots(p, det, period, trig, trigname);
3318 
3319  UpdateText->Clear();
3320 
3321  } // end loop over partitions
3322 
3323  return 0;
3324 
3325 } // End script.
3326 
3327 
3328 void eff_plots(unsigned int par_eff, string det, string period, string trig, string trigname){
3329 
3330 
3331  // Output file list of low efficiency modules.
3332  ofstream modules;
3333 
3334  int ncellbins_local = 344065;
3335  double cellmin_local = -0.5;
3336  double cellmax_local = 344064.5;
3337  int nwbins_local = 32;
3338  double wmin_local = -800;
3339  double wmax_local = 800;
3340 
3341  double wavglength = 200.0; // low w length to average cell/module efficiencies over
3342  int wbinlow = 1;
3343  int wbinhigh = 5;
3344 
3345  char f_name[56];
3346  char hmod_name[56];
3347 
3348  // Defing binning for histograms that will be made here
3349  int neffbins = 101;
3350  double effmin = -0.05;
3351  double effmax = 1.05;
3352  int nplbins = 897;
3353  double plmin = -0.5;
3354  double plmax = nplbins-0.5;
3355  int nmodbins = 12;
3356  double modmin = 0;
3357  double modmax = 12;
3358 
3359 // TH1F* mod_Eff[12];
3360 // for(int imod=0;imod<12;imod++){
3361 // sprintf(hmod_name,"mod%ieffperplane",imod);
3362 // mod_Eff[imod] = new TH1F(hmod_name,hmod_name,nplbins,0,nplbins);
3363 // }
3364 
3365  TH2F* moduleEfficiencyAverage = new TH2F("moduleEfficiencyAverage",";Plane;Module",
3366  nplbins,plmin,plmax,nmodbins,modmin,modmax);
3367  TH2F* moduleEfficiencyRMS = new TH2F("moduleEfficiencyRMS",";Plane;Module",
3368  nplbins,plmin,plmax,nmodbins,modmin,modmax);
3369  TH2F* moduleEfficiencyAverageXView = new TH2F("moduleEfficiencyAverageXView",";Plane;Module",
3370  nplbins,plmin,plmax,nmodbins,modmin,modmax);
3371  TH2F* moduleEfficiencyRMSXView = new TH2F("moduleEfficiencyRMSXView",";Plane;Module",
3372  nplbins,plmin,plmax,nmodbins,modmin,modmax);
3373 
3374  TH2F* moduleEfficiencyAverageYView = new TH2F("moduleEfficiencyAverageYView",";Plane;Module",
3375  nplbins,plmin,plmax,nmodbins,modmin,modmax);
3376  TH2F* moduleEfficiencyRMSYView = new TH2F("moduleEfficiencyRMSYView",";Plane;Module",
3377  nplbins,plmin,plmax,nmodbins,modmin,modmax);
3378 
3379  // Histogram of efficiency for a module
3380  TH1F* modeff = new TH1F("modeff",";Efficiency;NCells",neffbins,effmin,effmax);
3381 
3382  // Histogram of efficiency vs w for one cell
3383  TH1F* eff = new TH1F("eff","",nwbins_local,wmin_local,wmax_local);
3384 
3385  int currmodule = 0;
3386  int currplane = 0;
3387  int currview = 0; // View convention y = 0, x = 1
3388 
3389  // loop over every cell in each partition
3390  if(par_eff==1 && period=="Month"){
3391  char lowEffFile[150];
3392  sprintf(lowEffFile, "%s/low_eff_modules.txt", PLOT_DIR.c_str());
3393  modules.open(lowEffFile);
3394  modules<<"Partition "<<par_eff<<std::endl;
3395  modules<<std::endl;
3396  }
3397  for(int icell = 1; icell <= ncellbins_local; ++icell){
3398 
3399  // convert this to a plane and cell number
3400  int cell = (icell-1)%384;
3401  int plane = (icell-1-cell)/384;
3402  int modcell = cell%32;
3403  int module = (cell-modcell)/32;
3404  int view = plane%2; // view = 0 y, view = 1 x
3405 
3406  if(plane != currplane || module != currmodule){
3407  // fill in the histogram of average efficiency and rms of average for the last module
3408  double effavg = modeff->GetMean();
3409  double effrms = modeff->GetRMS();
3410  //double effavg_far = modeff_far->GetMean();
3411  int planebin = moduleEfficiencyAverage->GetXaxis()->FindFixBin(currplane);
3412  int modulebin = moduleEfficiencyAverage->GetYaxis()->FindFixBin((double)currmodule + 0.5);
3413 
3414  if(par_eff==1 && period=="Month"){
3415  if(effavg<0.3){
3416  modules<<"module: "<<modulebin<<" plane: "<<planebin<<" efficiency: "<<effavg<<std::endl;
3417  }
3418  }
3419  //mod_Eff[modulebin-1]->Fill(planebin,effavg);
3420  moduleEfficiencyAverage->SetBinContent(planebin,modulebin,effavg);
3421  moduleEfficiencyRMS->SetBinContent(planebin,modulebin,effrms);
3422  if(currview){
3423  // x view
3424  moduleEfficiencyAverageXView->SetBinContent(planebin,modulebin,effavg);
3425  moduleEfficiencyRMSXView->SetBinContent(planebin,modulebin,effrms);
3426  }
3427  else{
3428  // y view
3429  moduleEfficiencyAverageYView->SetBinContent(planebin,modulebin,effavg);
3430  moduleEfficiencyRMSYView->SetBinContent(planebin,modulebin,effrms);
3431  }
3432  // reset things for the new module
3433  modeff->Reset("ICES");
3434  currmodule = module;
3435  currplane = plane;
3436  currview = view;
3437  }
3438 
3439 
3440  // need to switch the module in cell for x view
3441 
3442  if(view){ modcell = 31-modcell; }
3443 
3444  // loop over every w bin
3445  double totcell = 0.0;
3446  double tothit = 0.0;
3447 
3448  // Calculate the cell efficiency vs w
3449  for(int iw = 1; iw <= nwbins_local; ++iw){
3450  // get the efficiency at this cell/w, eff = k/n
3451  double k = hHitsVwcellDay[par_eff]->GetBinContent(icell,iw);
3452  double n = hCellsVwcellDay[par_eff]->GetBinContent(icell,iw);
3453 
3454  totcell+=n;
3455  tothit+=k;
3456  double ef = k/n;
3457  if(n == 0){ ef = 0; }
3458 
3459  // calculate the variance of this
3460  double var = (k+1)*(k+2)/((n+2)*(n+3)) - (k+1)*(k+1)/((n+2)*(n+2));
3461 
3462  double w = hHitsVwcellDay[par_eff]->GetYaxis()->GetBinCenter(iw);
3463 
3464  eff->SetBinContent(iw,ef);
3465  eff->SetBinError(iw,sqrt(var));
3466 
3467  }
3468 
3469 
3470  // Average over the last 200 cm of the cell
3471  double efftot = eff->Integral(wbinlow,wbinhigh);
3472  double navgbins = wbinhigh-wbinlow+1.0;
3473 
3474  modeff->Fill(efftot/navgbins);
3475 
3476  }
3477  if(par_eff==1 && period=="Month") modules.close();
3478 
3479  char title_buff[128];
3480 
3481  gStyle->SetTimeOffset(0);
3482  string t_title;
3483  if(period == "Day") t_title = "(past 24 hrs.)";
3484  if(period == "Week") t_title = "(past week)";
3485  if(period == "Month") t_title = "(past month)";
3486  if(period == "6Months") t_title = "(past 26 weeks)";
3487  if(period == "Month") t_title = "(past 52 weeks)";
3488 
3489  TDatime *Ttemp = new TDatime; // finish time
3490  int Xfin = Ttemp->Convert() - GMToffset;
3491  TDatime *Tfinish = new TDatime(Xfin); // finish time
3492  TPaveText *UpdateText = new TPaveText(0.1, 0.0, 0.5, 0.05, "NDC");
3493  UpdateText->SetLineColor(0);
3494  UpdateText->SetFillColor(0);
3495  UpdateText->SetBorderSize(1);
3496  UpdateText->SetMargin(0.0);
3497  UpdateText->SetTextAlign(11);
3498  char buff1[256];
3499  sprintf(buff1, "Last updated on: %s (central time)", Tfinish->AsString());
3500  UpdateText->AddText(buff1);
3501  char buff2[256];
3502  sprintf(buff2, "Last run / subrun: %d / %d", Last_Run[par_eff], Last_SR[par_eff]);
3503  UpdateText->AddText(buff2);
3504 
3505  TPaveText *StatusText = new TPaveText(0.1, 0.1, 0.9, 0.9, "NDC");
3506  StatusText->SetLineColor(1);
3507  StatusText->SetFillColor(0);
3508  StatusText->SetBorderSize(1);
3509  // StatusText->SetMargin(0.0);
3510  StatusText->AddText(buff1);
3511  StatusText->AddText(buff2);
3512 
3513  TCanvas* c1 = new TCanvas("c1","c1",1200,800);
3514  gStyle->SetOptStat(0);
3515  sprintf(title_buff,"Average Module Efficiency %s - partition %.1u",t_title.c_str(),par_eff);
3516  moduleEfficiencyAverage->SetTitle(title_buff);
3517  moduleEfficiencyAverage->Draw("colz");
3518  //moduleEfficiencyAverage->GetXaxis()->SetRangeUser(0.,300.);
3519  gPad->Update();
3520 // TPaveStats *stats1 = (TPaveStats*)moduleEfficiencyAverage->FindObject("stats");
3521 // stats1->SetX1NDC(0.65);
3522 // stats1->SetY1NDC(0.65);
3523 // stats1->SetX2NDC(0.90);
3524 // stats1->SetY2NDC(0.90);
3525  c1->Modified();
3526  c1->Update();
3527  UpdateText->Draw();
3528  sprintf(f_name,"%s/%s-%s-P%.1uAvgModuleEff%s.png",PLOT_DIR.c_str(),det.c_str(),trig.c_str(),par_eff,period.c_str());
3529  c1->Print(f_name);
3530  delete c1;
3531  c1 = 0;
3532 
3533  //////////////////////////////////////////////////////////////////////
3534  // Creating list of low efficiency modules and corresponding planes.//
3535  //////////////////////////////////////////////////////////////////////
3536  /* TFile *test_out = new TFile("testout.root","RECREATE");
3537  modules.open("low_eff_modules.txt");
3538  //int Nbinsy = moduleEfficiencyAverage->GetNbinsY();
3539  //int Nbinsx = moduleEfficiencyAverage->GetNbinsX();
3540  if(det=="FarDet" && period=="Day"){
3541  for(int i=1;i<257;i++){
3542  for(int j=1;j<13;j++){
3543  //Int_t bin_num = moduleEfficiencyAverage->FindFixBin(double(i)+0.5,j);
3544  //Int_t bin_num = moduleEfficiencyAverage->GetBin(i+1,j+1);
3545  Double_t eff_mod = moduleEfficiencyAverage->GetBinContent(i,j);
3546  //std::cout<<bin_num<<" "<<eff_mod<<std::endl;
3547  //if(eff_mod<0.6){
3548  //modules<<" plane: "<<i<<" module: "<<j<<" efficiency: "<<eff_mod<<std::endl;
3549  modules << moduleEfficiencyAverage->GetBinContent(i,j)<<std::endl;
3550  //}
3551  }
3552  }
3553  }
3554  modules.close();
3555  test_out->cd();
3556  for(int ii=0;ii<12;ii++){
3557  mod_Eff[ii]->Write();
3558  }
3559  //moduleEfficiencyAverage->Write();
3560  //test_out->Close();
3561  */
3562 
3563  TCanvas* c2 = new TCanvas("c2","c2",1200,800);
3564  gStyle->SetOptStat(0);
3565  sprintf(title_buff,"%s Average Module Efficiency RMS %s - partition %.1u",trigname.c_str(),t_title.c_str(),par_eff);
3566  moduleEfficiencyRMS->SetTitle(title_buff);
3567  moduleEfficiencyRMS->Draw("colz");
3568  //moduleEfficiencyRMS->GetXaxis()->SetRangeUser(0.,300.);
3569  gPad->Update();
3570 // TPaveStats *stats2 = (TPaveStats*)moduleEfficiencyRMS->FindObject("stats");
3571 // stats2->SetX1NDC(0.65);
3572 // stats2->SetY1NDC(0.65);
3573 // stats2->SetX2NDC(0.90);
3574 // stats2->SetY2NDC(0.90);
3575  c2->Modified();
3576  c2->Update();
3577  UpdateText->Draw();
3578  sprintf(f_name,"%s/%s-%s-P%.1uModuleEffRMS%s.png",PLOT_DIR.c_str(),det.c_str(),trig.c_str(),par_eff,period.c_str());
3579  c2->Print(f_name);
3580  delete c2;
3581  c2 = 0;
3582 
3583  TCanvas* c3 = new TCanvas("c3","c3",1200,800);
3584  gStyle->SetOptStat(0);
3585  sprintf(title_buff,"%s Average Module Efficiency In X-view %s - partition %.1u",trigname.c_str(),t_title.c_str(),par_eff);
3586  moduleEfficiencyAverageXView->SetTitle(title_buff);
3587  moduleEfficiencyAverageXView->Draw("colz");
3588  moduleEfficiencyAverageXView->RebinX(2);
3589  //moduleEfficiencyAverageXView->GetXaxis()->SetRangeUser(0.,300.);
3590  gPad->Update();
3591 // TPaveStats *stats3 = (TPaveStats*)moduleEfficiencyAverageXView->FindObject("stats");
3592 // stats3->SetX1NDC(0.65);
3593 // stats3->SetY1NDC(0.65);
3594 // stats3->SetX2NDC(0.90);
3595 // stats3->SetY2NDC(0.90);
3596  c3->Modified();
3597  c3->Update();
3598  UpdateText->Draw();
3599  sprintf(f_name,"%s/%s-%s-P%.1uAvgModuleXEff%s.png",PLOT_DIR.c_str(),det.c_str(),trig.c_str(),par_eff,period.c_str());
3600  c3->Print(f_name);
3601  delete c3;
3602  c3 = 0;
3603 
3604  TCanvas* c4 = new TCanvas("c4","c4",1200,800);
3605  gStyle->SetOptStat(0);
3606  sprintf(title_buff,"%s Average Module Efficiency In X-view RMS %s - partition %.1u",trigname.c_str(),t_title.c_str(),par_eff);
3607  moduleEfficiencyRMSXView->SetTitle(title_buff);
3608  moduleEfficiencyRMSXView->Draw("colz");
3609  moduleEfficiencyRMSXView->RebinX(2);
3610  //moduleEfficiencyRMSXView->GetXaxis()->SetRangeUser(0.,300.);
3611  gPad->Update();
3612 // TPaveStats *stats4 = (TPaveStats*)moduleEfficiencyRMSXView->FindObject("stats");
3613 // stats4->SetX1NDC(0.65);
3614 // stats4->SetY1NDC(0.65);
3615 // stats4->SetX2NDC(0.90);
3616 // stats4->SetY2NDC(0.90);
3617  c4->Modified();
3618  c4->Update();
3619  UpdateText->Draw();
3620  sprintf(f_name,"%s/%s-%s-P%.1uModuleXEffRMS%s.png",PLOT_DIR.c_str(),det.c_str(),trig.c_str(),par_eff,period.c_str());
3621  c4->Print(f_name);
3622  delete c4;
3623  c4 = 0;
3624 
3625  TCanvas* c5 = new TCanvas("c5","c5",1200,800);
3626  gStyle->SetOptStat(0);
3627  sprintf(title_buff,"%s Average Module Efficiency In Y-view %s - partition %.1u",trigname.c_str(),t_title.c_str(),par_eff);
3628  moduleEfficiencyAverageYView->SetTitle(title_buff);
3629  moduleEfficiencyAverageYView->Draw("colz");
3630  moduleEfficiencyAverageYView->RebinX(2);
3631  //moduleEfficiencyAverageYView->GetXaxis()->SetRangeUser(0.,300.);
3632  gPad->Update();
3633 // TPaveStats *stats5 = (TPaveStats*)moduleEfficiencyAverageYView->FindObject("stats");
3634 // stats5->SetX1NDC(0.65);
3635 // stats5->SetY1NDC(0.65);
3636 // stats5->SetX2NDC(0.90);
3637 // stats5->SetY2NDC(0.90);
3638  c5->Modified();
3639  c5->Update();
3640  UpdateText->Draw();
3641  sprintf(f_name,"%s/%s-%s-P%.1uAvgModuleYEff%s.png",PLOT_DIR.c_str(),det.c_str(),trig.c_str(),par_eff,period.c_str());
3642  c5->Print(f_name);
3643  delete c5;
3644  c5 = 0;
3645 
3646  TCanvas* c6 = new TCanvas("c6","c6",1200,800);
3647  gStyle->SetOptStat(0);
3648  sprintf(title_buff,"%s Average Module Efficiency In Y-view RMS %s - partition %.1u",trigname.c_str(),t_title.c_str(),par_eff);
3649  moduleEfficiencyRMSYView->SetTitle(title_buff);
3650  moduleEfficiencyRMSYView->Draw("colz");
3651  moduleEfficiencyRMSYView->RebinX(2);
3652  //moduleEfficiencyRMSYView->GetXaxis()->SetRangeUser(0.,300.);
3653  gPad->Update();
3654 // TPaveStats *stats6 = (TPaveStats*)moduleEfficiencyRMSYView->FindObject("stats");
3655 // stats6->SetX1NDC(0.65);
3656 // stats6->SetY1NDC(0.65);
3657 // stats6->SetX2NDC(0.90);
3658 // stats6->SetY2NDC(0.90);
3659  c6->Modified();
3660  c6->Update();
3661  UpdateText->Draw();
3662  sprintf(f_name,"%s/%s-%s-P%.1uModuleYEffRMS%s.png",PLOT_DIR.c_str(),det.c_str(),trig.c_str(),par_eff,period.c_str());
3663  c6->Print(f_name);
3664  delete c6;
3665  c6 = 0;
3666 
3667 }
UInt_t LastSR
Definition: AnaPlotMaker.h:50
TH2F * hHitsVwcellDay[Npar]
Definition: AnaPlotMaker.h:70
TPaveText * UpdateText
Definition: DCSPlotMaker.C:18
TDatime * TNow
Definition: AnaPlotMaker.h:41
const char * p
Definition: xmltok.h:285
T sqrt(T number)
Definition: d0nt_math.hpp:156
UInt_t Last_SR[Npar]
Definition: AnaPlotMaker.h:54
Int_t par
Definition: SimpleIterate.C:24
string filename
Definition: shutoffs.py:106
void eff_plots(unsigned int par_eff, string det, string period, string trig, string trigname)
TDatime * SRtime
Definition: AnaPlotMaker.h:42
::xsd::cxx::tree::time< char, simple_type > time
Definition: Database.h:194
Int_t nevents
Definition: SimpleIterate.C:25
c2
Definition: demo5.py:33
ifstream inFile
Definition: AnaPlotMaker.h:34
const XML_Char * s
Definition: expat.h:262
const unsigned int Npar
Definition: AnaPlotMaker.h:38
UInt_t LastRun
Definition: AnaPlotMaker.h:49
const double j
Definition: BetheBloch.cxx:29
const std::string PLOT_DIR
Definition: AnaPlotMaker.C:8
Definition: run.py:1
TDatime * TNowGMT
Definition: AnaPlotMaker.h:40
OStream cout
Definition: OStream.cxx:6
UInt_t Last_Run[Npar]
Definition: AnaPlotMaker.h:53
det_type
Definition: Constants.h:501
static float min(const float a, const float b, const float c)
Definition: absgeo.cxx:45
::xsd::cxx::tree::string< char, simple_type > string
Definition: Database.h:154
Int_t GMToffset
Definition: AnaPlotMaker.h:43
double livetime
Definition: saveFDMCHists.C:21
Definition: event.h:1
c1
Definition: demo5.py:24
TPad * pad2
Definition: analysis.C:13
T max(sqlite3 *const db, std::string const &table_name, std::string const &column_name)
Definition: statistics.h:68
Float_t w
Definition: plot.C:20
Long64_t AnaPlotMaker(TString det_type, TString t_prd, TString trigger)
Definition: AnaPlotMaker.C:11
TPad * pad1
Definition: analysis.C:13
TH2F * hCellsVwcellDay[Npar]
Definition: AnaPlotMaker.h:71
static constexpr Double_t year
Definition: Munits.h:185