Functions | Variables
AnaPlotMaker.C File Reference
#include "AnaPlotMaker.h"

Go to the source code of this file.

Functions

Long64_t AnaPlotMaker (TString det_type, TString t_prd, TString trigger)
 
void eff_plots (unsigned int par_eff, string det, string period, string trig, string trigname)
 

Variables

const std::string PLOT_DIR = "/nusoft/app/web/htdoc/nova/datacheck/nearline/plots"
 

Function Documentation

Long64_t AnaPlotMaker ( TString  det_type,
TString  t_prd,
TString  trigger 
)

< TEST

< Threshold cut value for flaggin low rate DCM

< number of dcms in FarDet

< add the number of 2D-tracks by column (per diblock)

< add the number of 3D-tracks by column (per diblock)

< TO 15 SINCE ENTRY 0 IS EMPTY ALL TIMES IN HISTO

TEST

Definition at line 11 of file AnaPlotMaker.C.

References confusionMatrixTree::count, om::cout, febshutoff_auto::day, febshutoff_auto::dcm, fillBadChanDBTables::det, hit::E, eff_plots(), allTimeWatchdog::endl, shutoffs::filename, check_time_usage::float, GMToffset, hCellsVwcellDay, submit_syst::header, hHitsVwcellDay, febshutoff_auto::hour, MECModelEnuComparisons::i, inFile, calib::j, kBlue, kRed, submit_hadd::l, Last_Run, Last_SR, LastRun, LastSR, MECModelEnuComparisons::leg, make_mec_shifts_plots::legend, livetime, cet::sqlite::max(), min(), nevents, Npar, pad1, pad2, par, DCS_db_parser::period, PLOT_DIR, updateRunHistoryTables::run, SRtime, getGoodRuns4SAM::subrun, confusionMatrixTree::t, plotROC::title, TNow, TNowGMT, UpdateText, and Munits::year.

11  {
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,400,-5,2);
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  // New lines for period 11
1768  TLine* lYPosition=new TLine(0,0,0,lmax);
1769  TLine* l2YPosition=new TLine(-4.5,0,-4.5,lmax);
1770  lYPosition->SetLineColor(kRed);
1771  lYPosition->SetLineWidth(3);
1772  lYPosition->SetLineStyle(9);
1773  lYPosition->Draw();
1774  l2YPosition->SetLineColor(kRed);
1775  l2YPosition->SetLineWidth(3);
1776  l2YPosition->SetLineStyle(9);
1777  l2YPosition->Draw();
1778  hYPositionDay[p]->Draw("same");
1779  sprintf(filename,"%s/%s-%s-P%.1uYPosition%s.png",PLOT_DIR.c_str(),det.c_str(),trig.c_str(),p,period.c_str());
1780  cYPositionday->Print(filename);
1781  delete cYPositionday;
1782  cYPositionday = 0;
1783 
1784  TCanvas *cXWidthday = new TCanvas("cXWidthday","X Width Day",1200,800);
1785  cXWidthday->cd();
1786  gStyle->SetOptStat(111111);
1787  hXWidthDay[p]->SetLineWidth(2);
1788  hXWidthDay[p]->Draw();
1789  UpdateText->Draw();
1790  cXWidthday->Update();
1791  lmax=gPad->GetUymax();
1792  TLine* lXWidth=new TLine(0.57,0,0.57,lmax);
1793  TLine* l2XWidth=new TLine(1.88,0,1.88,lmax);
1794  lXWidth->SetLineColor(kRed);
1795  lXWidth->SetLineWidth(3);
1796  lXWidth->SetLineStyle(9);
1797  lXWidth->Draw();
1798  l2XWidth->SetLineColor(kRed);
1799  l2XWidth->SetLineWidth(3);
1800  l2XWidth->SetLineStyle(9);
1801  l2XWidth->Draw();
1802  hXWidthDay[p]->Draw("same");
1803  sprintf(filename,"%s/%s-%s-P%.1uXWidth%s.png",PLOT_DIR.c_str(),det.c_str(),trig.c_str(),p,period.c_str());
1804  cXWidthday->Print(filename);
1805  delete cXWidthday;
1806  cXWidthday = 0;
1807 
1808  TCanvas *cYWidthday = new TCanvas("cYWidthday","Y Width Day",1200,800);
1809  cYWidthday->cd();
1810  gStyle->SetOptStat(111111);
1811  hYWidthDay[p]->SetLineWidth(2);
1812  hYWidthDay[p]->Draw();
1813  UpdateText->Draw();
1814  cYWidthday->Update();
1815  lmax=gPad->GetUymax();
1816  TLine* lYWidth=new TLine(0.57,0,0.57,lmax);
1817  TLine* l2YWidth=new TLine(1.58,0,1.58,lmax);
1818  lYWidth->SetLineColor(kRed);
1819  lYWidth->SetLineWidth(3);
1820  lYWidth->SetLineStyle(9);
1821  lYWidth->Draw();
1822  l2YWidth->SetLineColor(kRed);
1823  l2YWidth->SetLineWidth(3);
1824  l2YWidth->SetLineStyle(9);
1825  l2YWidth->Draw();
1826  hYWidthDay[p]->Draw("same");
1827  sprintf(filename,"%s/%s-%s-P%.1uYWidth%s.png",PLOT_DIR.c_str(),det.c_str(),trig.c_str(),p,period.c_str());
1828  cYWidthday->Print(filename);
1829  delete cYWidthday;
1830  cYWidthday = 0;
1831 
1832  TCanvas *cGoodBeamday = new TCanvas("cGoodBeamday","Y Good Beam Day",1200,800);
1833  cGoodBeamday->cd();
1834  gStyle->SetOptStat(111111);
1835  hGoodBeamDay[p]->SetLineWidth(2);
1836  hGoodBeamDay[p]->Draw();
1837  TAxis *GoodBeamaxis = hGoodBeamDay[p]->GetXaxis();
1838  GoodBeamaxis->SetBinLabel(1,"bad beam");
1839  GoodBeamaxis->SetBinLabel(2,"good beam");
1840  UpdateText->Draw();
1841  sprintf(filename,"%s/%s-%s-P%.1uGoodBeam%s.png",PLOT_DIR.c_str(),det.c_str(),trig.c_str(),p,period.c_str());
1842  cGoodBeamday->Print(filename);
1843  delete cGoodBeamday;
1844  cGoodBeamday = 0;
1845 
1846  TCanvas *cBadSpillsday = new TCanvas("cBadSpillsday","Y Bad Spills Day",1200,800);
1847  cBadSpillsday->cd();
1848  cBadSpillsday->SetLogy();
1849  hBadSpillsDay[p]->SetLineWidth(2);
1850  gStyle->SetOptStat(0);
1851  hBadSpillsDay[p]->Draw();
1852  UpdateText->Draw();
1853  sprintf(filename,"%s/%s-%s-P%.1uBadSpills%s.png",PLOT_DIR.c_str(),det.c_str(),trig.c_str(),p,period.c_str());
1854  cBadSpillsday->Print(filename);
1855  delete cBadSpillsday;
1856  cBadSpillsday = 0;
1857  //end new
1858 
1859  TCanvas *cnSliceday = new TCanvas("cnSliceday","# Slice Day",1200,800);
1860  cnSliceday->cd();
1861  cnSliceday->SetLogy();
1862  gStyle->SetOptStat(111111);
1863  if(det_type=="NearDet") hNSliceDay[p]->SetAxisRange(0.0,50.0,"X");
1864  else if(det_type=="TestBeam") hNSliceDay[p]->SetAxisRange(0.0,200.0,"X");
1865  else hNSliceDay[p]->SetAxisRange(0.0,200.0,"X");
1866  hNSliceDay[p]->SetLineWidth(2);
1867  hNSliceDay[p]->SetLineColor(kRed);
1868  hNSliceDay[p]->Draw();
1869  UpdateText->Draw();
1870 
1871  sprintf(filename,"%s/%s-%s-P%.1uNSlice%s.png",PLOT_DIR.c_str(),det.c_str(),trig.c_str(),p,period.c_str());
1872  cnSliceday->Print(filename);
1873  delete cnSliceday;
1874  cnSliceday = 0;
1875 
1876  TCanvas *cnSliceHitday = new TCanvas("cnSliceHitday","# Non-Noise Slice Hits Day",1200,800);
1877  cnSliceHitday->cd();
1878  cnSliceHitday->SetLogy();
1879  gStyle->SetOptStat(111111);
1880  gPad->SetLogy();
1881  gPad->SetLogx();
1882  hNNonNoiseSliceHitDay[p]->SetAxisRange(0.0,3000.0,"X");
1883  hNNonNoiseSliceHitDay[p]->SetLineWidth(2);
1884  hNNonNoiseSliceHitDay[p]->SetLineColor(kRed);
1885  hNNonNoiseSliceHitDay[p]->Draw();
1886  UpdateText->Draw();
1887  sprintf(filename,"%s/%s-%s-P%.1uNSliceHit%s.png",PLOT_DIR.c_str(),det.c_str(),trig.c_str(),p,period.c_str());
1888  cnSliceHitday->Print(filename);
1889  delete cnSliceHitday;
1890  cnSliceHitday = 0;
1891 
1892  TCanvas *cNNoiseSliceHitday = new TCanvas("cNNoiseSliceHitday","# Noise Slice Hits Day",1200,800);
1893  cNNoiseSliceHitday->cd();
1894  cNNoiseSliceHitday->SetLogy();
1895  gStyle->SetOptStat(111111);
1896  if(det_type=="NearDet") hNNoiseSliceHitDay[p]->SetAxisRange(0.0,2000.0,"X");
1897  else if(det_type=="TestBeam") hNNoiseSliceHitDay[p]->SetAxisRange(0.0,1500.0,"X");
1898  // hNNoiseSliceHitDay[p]->SetAxisRange(0.0,10000.0,"X");
1899  hNNoiseSliceHitDay[p]->SetLineWidth(2);
1900  hNNoiseSliceHitDay[p]->SetLineColor(kRed);
1901  hNNoiseSliceHitDay[p]->Draw();
1902  UpdateText->Draw();
1903  sprintf(filename,"%s/%s-%s-P%.1uNNoiseSliceHit%s.png",PLOT_DIR.c_str(),det.c_str(),trig.c_str(),p,period.c_str());
1904  cNNoiseSliceHitday->Print(filename);
1905  delete cNNoiseSliceHitday;
1906  cNNoiseSliceHitday = 0;
1907 
1908  TCanvas *cPEday = new TCanvas("cPEday","PE distributions by Day",1200,800);
1909  cPEday->cd();
1910  gStyle->SetOptStat(0);
1911  gPad->SetLogy();
1912  gPad->SetLogx();
1913  hNoiseSlicePEDay[p]->GetXaxis()->SetRange(2,5000);
1914  sprintf(filename,"%s PE Distribution (%s) - partition %.1u",trigname.c_str(),time.c_str(),p);
1915  hNoiseSlicePEDay[p]->SetTitle(filename);
1916  hNonNoiseSlicePEDay[p]->SetTitle(filename);
1917  hTrackPEDay[p]->SetTitle(filename);
1918  hNoiseSlicePEDay[p]->SetLineWidth(2);
1919  hNoiseSlicePEDay[p]->SetLineColor(kBlack);
1920  hNoiseSlicePEDay[p]->Draw();
1921  hNonNoiseSlicePEDay[p]->SetLineWidth(2);
1922  hNonNoiseSlicePEDay[p]->SetLineColor(kRed);
1923  hNonNoiseSlicePEDay[p]->Draw("sames");
1924  hTrackPEDay[p]->SetLineWidth(2);
1925  hTrackPEDay[p]->SetLineColor(kBlue);
1926  hTrackPEDay[p]->Draw("sames");
1927  UpdateText->Draw();
1928  TLegend *legend = new TLegend(0.6,0.6,0.85,0.85);
1929  legend->AddEntry(hNoiseSlicePEDay[p],"Hits in Noise Slice","l");
1930  legend->AddEntry(hNonNoiseSlicePEDay[p],"Hits in Non-Noise Slices","l");
1931  legend->AddEntry(hTrackPEDay[p],"Hits on Tracks","l");
1932  legend->SetFillStyle(4000);
1933  legend->SetLineColor(0);
1934  legend->SetFillColor(0);
1935  legend->Draw();
1936  sprintf(filename,"%s/%s-%s-P%.1uPE%s.png",PLOT_DIR.c_str(),det.c_str(),trig.c_str(),p,period.c_str());
1937  cPEday->Print(filename);
1938  delete cPEday;
1939  cPEday = 0;
1940  delete legend;
1941  legend = 0;
1942 
1943  TCanvas *cTsdday = new TCanvas("cTsdday","Slice Time Standard Dev.",1200,800);
1944  cTsdday->cd();
1945  cTsdday->SetLogy();
1946  gStyle->SetOptStat(111111);
1947  if(det_type=="NearDet") hTsdDay[p]->SetAxisRange(0.0,600.0,"X");
1948  else if(det_type=="TestBeam") hTsdDay[p]->SetAxisRange(0.0,500.0,"X");
1949  else hTsdDay[p]->SetAxisRange(0.0,1000.0,"X");
1950  hTsdDay[p]->SetLineWidth(2);
1951  hTsdDay[p]->SetLineColor(kRed);
1952  hTsdDay[p]->Draw();
1953  UpdateText->Draw();
1954  sprintf(filename,"%s/%s-%s-P%.1uTsd%s.png",PLOT_DIR.c_str(),det.c_str(),trig.c_str(),p,period.c_str());
1955  cTsdday->Print(filename);
1956  delete cTsdday;
1957  cTsdday = 0;
1958 
1959  TCanvas *cnTrackday = new TCanvas("cnTrackday"," # Cosmic Tracks",1200,800);
1960  cnTrackday->cd();
1961  cnTrackday->SetLogy();
1962  gStyle->SetOptStat(111111);
1963  hnTrackDay[p]->SetAxisRange(0.0,300.0,"X");
1964  hnTrackDay[p]->SetLineWidth(2);
1965  hnTrackDay[p]->SetLineColor(kRed);
1966  hnTrackDay[p]->Draw();
1967  UpdateText->Draw();
1968  sprintf(filename,"%s/%s-%s-P%.1unTrackAll3D%s.png",PLOT_DIR.c_str(),det.c_str(),trig.c_str(),p,period.c_str());
1969  cnTrackday->Print(filename);
1970  delete cnTrackday;
1971  cnTrackday = 0;
1972 
1973  TCanvas *cTrackLenday = new TCanvas("cTrackLenday","Cosmic Track Length",1200,800);
1974  cTrackLenday->cd();
1975  cTrackLenday->SetLogy();
1976  gStyle->SetOptStat(111111);
1977  hTrackLenDay[p]->SetAxisRange(0.0,6000.0,"X");
1978  hTrackLenDay[p]->SetLineWidth(2);
1979  hTrackLenDay[p]->SetLineColor(kRed);
1980  hTrackLenDay[p]->Draw();
1981  UpdateText->Draw();
1982  sprintf(filename,"%s/%s-%s-P%.1uTrackLenAll3D%s.png",PLOT_DIR.c_str(),det.c_str(),trig.c_str(),p,period.c_str());
1983  cTrackLenday->Print(filename);
1984  delete cTrackLenday;
1985  cTrackLenday = 0;
1986 
1987  TCanvas *cCosNumiday = new TCanvas("cCosNumiday","Cos Theta(numi)",1200,800);
1988  cCosNumiday->cd();
1989  gStyle->SetOptStat(111111);
1990  hCosNumiDay[p]->SetAxisRange(-1.0,1.0,"X");
1991  hCosNumiDay[p]->SetLineWidth(2);
1992  hCosNumiDay[p]->SetLineColor(kRed);
1993  hCosNumiDay[p]->Draw();
1994  UpdateText->Draw();
1995  sprintf(filename,"%s/%s-%s-P%.1uCosNumiAll3D%s.png",PLOT_DIR.c_str(),det.c_str(),trig.c_str(),p,period.c_str());
1996  cCosNumiday->Print(filename);
1997  delete cCosNumiday;
1998  cCosNumiday = 0;
1999 
2000  TCanvas *cPCaveday = new TCanvas("cPCaveday","PCave day",1200,1200);
2001  cPCaveday->Divide(1,2);
2002  cPCaveday->cd(1);
2003  gStyle->SetOptStat(0);
2004  gStyle->SetPalette(1); //kRainbow
2005  gPad->SetLogz();
2006  if(det_type=="NearDet"){
2007  hPCXaveDay[p]->SetAxisRange(-225.0,20.0,"X");
2008  hPCXaveDay[p]->SetAxisRange(-110.0,10.0,"Y");
2009  }
2010  else if(det_type=="TestBeam"){
2011  hPCXaveDay[p]->SetAxisRange(-68.0,5.0,"X");
2012  hPCXaveDay[p]->SetAxisRange(-70.0,5.0,"Y");
2013  }
2014  else{
2015  hPCXaveDay[p]->SetAxisRange(-920.0,20.0,"X");
2016  hPCXaveDay[p]->SetAxisRange(-400.0,10.0,"Y");
2017  }
2018  hPCXaveDay[p]->Draw("colz");
2019  L1x->Draw();
2020  L2x->Draw();
2021  L3x->Draw();
2022  L4x->Draw();
2023  cPCaveday->cd(2);
2024  gStyle->SetOptStat(0);
2025  gPad->SetLogz();
2026  if(det_type=="NearDet"){
2027  hPCYaveDay[p]->SetAxisRange(-225.0,20.0,"X");
2028  hPCYaveDay[p]->SetAxisRange(-10.0,110.0,"Y");
2029  }
2030  else if(det_type=="TestBeam"){
2031  hPCYaveDay[p]->SetAxisRange(-68.0,5.0,"X");
2032  hPCYaveDay[p]->SetAxisRange(-5.0,70.0,"Y");
2033  }
2034  else{
2035  hPCYaveDay[p]->SetAxisRange(-920.0,20.0,"X");
2036  hPCYaveDay[p]->SetAxisRange(-10.0,400.0,"Y");
2037  }
2038  hPCYaveDay[p]->Draw("colz");
2039  L1y->Draw();
2040  L2y->Draw();
2041  L3y->Draw();
2042  L4y->Draw();
2043  UpdateText->Draw();
2044  sprintf(filename,"%s/%s-%s-P%.1uPCave%s.png",PLOT_DIR.c_str(),det.c_str(),trig.c_str(),p,period.c_str());
2045  cPCaveday->Print(filename);
2046  delete cPCaveday;
2047  cPCaveday = 0;
2048 
2049  TCanvas *cnTrackAll3Dday = new TCanvas("cnTrackday"," # 3D Cosmic Tracks",1200,800);
2050  cnTrackAll3Dday->cd();
2051  cnTrackAll3Dday->SetLogy();
2052  gStyle->SetOptStat(111111);
2053  if(det_type=="NearDet") hnTrackAll3DDay[p]->SetAxisRange(0.0,50.0,"X");
2054  else if(det_type=="TestBeam" && trigger=="Spill") hnTrackAll3DDay[p]->SetAxisRange(0.0,300.0,"X");
2055  else hnTrackAll3DDay[p]->SetAxisRange(0.0,300.0,"X");
2056  hnTrackAll3DDay[p]->SetLineWidth(2);
2057  hnTrackAll3DDay[p]->SetLineColor(kRed);
2058  hnTrackAll3DDay[p]->Draw();
2059  UpdateText->Draw();
2060  sprintf(filename,"%s/%s-%s-P%.1unTrackAll3D%s.png",PLOT_DIR.c_str(),det.c_str(),trig.c_str(),p,period.c_str());
2061  cnTrackAll3Dday->Print(filename);
2062  delete cnTrackAll3Dday;
2063  cnTrackAll3Dday = 0;
2064 
2065  TCanvas *cTrackStartAll3Dday = new TCanvas("cTrackStartAll3Dday","All 3D Track Start day",1200,1200);
2066  cTrackStartAll3Dday->Divide(1,2);
2067  cTrackStartAll3Dday->cd(1);
2068  gStyle->SetOptStat(0);
2069  gPad->SetLogz();
2070  if(det_type=="NearDet"){
2071  hTrackStartXZAll3DDay[p]->SetAxisRange(-1750.0,0.0,"X");
2072  hTrackStartXZAll3DDay[p]->SetAxisRange(-250.0,250.0,"Y");
2073  }
2074  else if(det_type=="TestBeam"){
2075  hTrackStartXZAll3DDay[p]->SetAxisRange(-440.0,0.0,"X");
2076  hTrackStartXZAll3DDay[p]->SetAxisRange(-140.0,140.0,"Y");
2077  }
2078  hTrackStartXZAll3DDay[p]->Draw("colz");
2079  cTrackStartAll3Dday->cd(2);
2080  gStyle->SetOptStat(0);
2081  gPad->SetLogz();
2082  if(det_type=="NearDet"){
2083  hTrackStartYZAll3DDay[p]->SetAxisRange(-1750.0,0.0,"X");
2084  hTrackStartYZAll3DDay[p]->SetAxisRange(-250.0,250.0,"Y");
2085  }
2086  else if(det_type=="TestBeam"){
2087  hTrackStartYZAll3DDay[p]->SetAxisRange(-440.0,0.0,"X");
2088  hTrackStartYZAll3DDay[p]->SetAxisRange(-140.0,140.0,"Y");
2089  }
2090  hTrackStartYZAll3DDay[p]->Draw("colz");
2091  UpdateText->Draw();
2092  sprintf(filename,"%s/%s-%s-P%.1uTrackStartAll3D%s.png",PLOT_DIR.c_str(),det.c_str(),trig.c_str(),p,period.c_str());
2093  cTrackStartAll3Dday->Print(filename);
2094  delete cTrackStartAll3Dday;
2095  cTrackStartAll3Dday = 0;
2096 
2097  TCanvas *cTrackStopAll3Dday = new TCanvas("cTrackStopAll3Dday","All 3D Track Stop day",1200,1200);
2098  cTrackStopAll3Dday->Divide(1,2);
2099  cTrackStopAll3Dday->cd(1);
2100  gStyle->SetOptStat(0);
2101  gPad->SetLogz();
2102  if(det_type=="NearDet"){
2103  hTrackStopXZAll3DDay[p]->SetAxisRange(-1750.0,0.0,"X");
2104  hTrackStopXZAll3DDay[p]->SetAxisRange(-250.0,250.0,"Y");
2105  }
2106  else if(det_type=="TestBeam"){
2107  hTrackStopXZAll3DDay[p]->SetAxisRange(-440.0,0.0,"X");
2108  hTrackStopXZAll3DDay[p]->SetAxisRange(-140.0,140.0,"Y");
2109  }
2110  hTrackStopXZAll3DDay[p]->Draw("colz");
2111  cTrackStopAll3Dday->cd(2);
2112  gStyle->SetOptStat(0);
2113  gPad->SetLogz();
2114  if(det_type=="NearDet"){
2115  hTrackStopYZAll3DDay[p]->SetAxisRange(-1750.0,0.0,"X");
2116  hTrackStopYZAll3DDay[p]->SetAxisRange(-250.0,250.0,"Y");
2117  }
2118  else if(det_type=="TestBeam"){
2119  hTrackStopYZAll3DDay[p]->SetAxisRange(-440.0,0.0,"X");
2120  hTrackStopYZAll3DDay[p]->SetAxisRange(-140.0,140.0,"Y");
2121  }
2122  hTrackStopYZAll3DDay[p]->Draw("colz");
2123  UpdateText->Draw();
2124  sprintf(filename,"%s/%s-%s-P%.1uTrackStopAll3D%s.png",PLOT_DIR.c_str(),det.c_str(),trig.c_str(),p,period.c_str());
2125  cTrackStopAll3Dday->Print(filename);
2126  delete cTrackStopAll3Dday;
2127  cTrackStopAll3Dday = 0;
2128 
2129  TCanvas *cTrackLenAll3Dday = new TCanvas("cTrackLenAll3Dday"," 3D Cosmic Track Length",1200,800);
2130  cTrackLenAll3Dday->cd();
2131  cTrackLenAll3Dday->SetLogy();
2132  gStyle->SetOptStat(111111);
2133  if(det_type=="NearDet") hTrackLenAll3DDay[p]->SetAxisRange(0.0,2000.0,"X");
2134  else if(det_type=="TestBeam") hTrackLenAll3DDay[p]->SetAxisRange(0.0,450.0,"X");
2135  else hTrackLenAll3DDay[p]->SetAxisRange(0.0,6000.0,"X");
2136  //hTrackLenAll3DDay[p]->GetXaxis()->SetRangeUser(0.,6000.);
2137  hTrackLenAll3DDay[p]->SetLineWidth(2);
2138  hTrackLenAll3DDay[p]->SetLineColor(kRed);
2139  hTrackLenAll3DDay[p]->Draw();
2140  UpdateText->Draw();
2141  sprintf(filename,"%s/%s-%s-P%.1uTrackLenAll3D%s.png",PLOT_DIR.c_str(),det.c_str(),trig.c_str(),p,period.c_str());
2142  cTrackLenAll3Dday->Print(filename);
2143  delete cTrackLenAll3Dday;
2144  cTrackLenAll3Dday = 0;
2145 
2146  TCanvas *cnTrackCont3Dday = new TCanvas("cnTrackCont3Dday"," # Contained 3D Cosmic Tracks",1200,800);
2147  cnTrackCont3Dday->cd();
2148  cnTrackCont3Dday->SetLogy();
2149  gStyle->SetOptStat(111111);
2150  hnTrackCont3DDay[p]->SetAxisRange(0.0,300.0,"X");
2151  hnTrackCont3DDay[p]->SetLineWidth(2);
2152  hnTrackCont3DDay[p]->SetLineColor(kRed);
2153  hnTrackCont3DDay[p]->Draw();
2154  UpdateText->Draw();
2155  sprintf(filename,"%s/%s-%s-P%.1unTrackCont3D%s.png",PLOT_DIR.c_str(),det.c_str(),trig.c_str(),p,period.c_str());
2156  cnTrackCont3Dday->Print(filename);
2157  delete cnTrackCont3Dday;
2158  cnTrackCont3Dday = 0;
2159 
2160  TCanvas *cTrackStartCont3Dday = new TCanvas("cTrackStartCont3Dday","Cont 3D Track Start day",1200,1200);
2161  cTrackStartCont3Dday->Divide(1,2);
2162  cTrackStartCont3Dday->cd(1);
2163  gStyle->SetOptStat(0);
2164  gPad->SetLogz();
2165  if(det_type=="NearDet"){
2166  hTrackStartXZCont3DDay[p]->SetAxisRange(-1750.0,0.0,"X");
2167  hTrackStartXZCont3DDay[p]->SetAxisRange(-250.0,250.0,"Y");
2168  }
2169  else if(det_type=="TestBeam"){
2170  hTrackStartXZCont3DDay[p]->SetAxisRange(-440.0,0.0,"X");
2171  hTrackStartXZCont3DDay[p]->SetAxisRange(-140.0,140.0,"Y");
2172  }
2173  hTrackStartXZCont3DDay[p]->Draw("colz");
2174  cTrackStartCont3Dday->cd(2);
2175  gStyle->SetOptStat(0);
2176  gPad->SetLogz();
2177  if(det_type=="NearDet"){
2178  hTrackStartYZCont3DDay[p]->SetAxisRange(-1750.0,0.0,"X");
2179  hTrackStartYZCont3DDay[p]->SetAxisRange(-250.0,250.0,"Y");
2180  }
2181  else if(det_type=="TestBeam"){
2182  hTrackStartYZCont3DDay[p]->SetAxisRange(-440.0,0.0,"X");
2183  hTrackStartYZCont3DDay[p]->SetAxisRange(-140.0,140.0,"Y");
2184  }
2185  hTrackStartYZCont3DDay[p]->Draw("colz");
2186  UpdateText->Draw();
2187  sprintf(filename,"%s/%s-%s-P%.1uTrackStartCont3D%s.png",PLOT_DIR.c_str(),det.c_str(),trig.c_str(),p,period.c_str());
2188  cTrackStartCont3Dday->Print(filename);
2189  delete cTrackStartCont3Dday;
2190  cTrackStartCont3Dday = 0;
2191 
2192  TCanvas *cTrackStopCont3Dday = new TCanvas("cTrackStopCont3Dday","Cont 3D Track Stop day",1200,1200);
2193  cTrackStopCont3Dday->Divide(1,2);
2194  cTrackStopCont3Dday->cd(1);
2195  gStyle->SetOptStat(0);
2196  gPad->SetLogz();
2197  if(det_type=="NearDet"){
2198  hTrackStopXZCont3DDay[p]->SetAxisRange(-1750.0,0.0,"X");
2199  hTrackStopXZCont3DDay[p]->SetAxisRange(-250.0,250.0,"Y");
2200  }
2201  else if(det_type=="TestBeam"){
2202  hTrackStopXZCont3DDay[p]->SetAxisRange(-440.0,0.0,"X");
2203  hTrackStopXZCont3DDay[p]->SetAxisRange(-140.0,140.0,"Y");
2204  }
2205  hTrackStopXZCont3DDay[p]->Draw("colz");
2206  cTrackStopCont3Dday->cd(2);
2207  gStyle->SetOptStat(0);
2208  gPad->SetLogz();
2209  if(det_type=="NearDet"){
2210  hTrackStopYZCont3DDay[p]->SetAxisRange(-1750.0,0.0,"X");
2211  hTrackStopYZCont3DDay[p]->SetAxisRange(-250.0,250.0,"Y");
2212  }
2213  else if(det_type=="TestBeam"){
2214  hTrackStopYZCont3DDay[p]->SetAxisRange(-440.0,0.0,"X");
2215  hTrackStopYZCont3DDay[p]->SetAxisRange(-140.0,140.0,"Y");
2216  }
2217  hTrackStopYZCont3DDay[p]->Draw("colz");
2218  UpdateText->Draw();
2219  sprintf(filename,"%s/%s-%s-P%.1uTrackStopCont3D%s.png",PLOT_DIR.c_str(),det.c_str(),trig.c_str(),p,period.c_str());
2220  cTrackStopCont3Dday->Print(filename);
2221  delete cTrackStopCont3Dday;
2222  cTrackStopCont3Dday = 0;
2223 
2224  TCanvas *cTrackLenCont3Dday = new TCanvas("cTrackLenCont3Dday"," 3D Cosmic Track Length",1200,800);
2225  cTrackLenCont3Dday->cd();
2226  cTrackLenCont3Dday->SetLogy();
2227  gStyle->SetOptStat(111111);
2228  hTrackLenCont3DDay[p]->SetAxisRange(0.0,6000.0,"X");
2229  //hTrackLenCont3DDay[p]->GetXaxis()->SetRangeUser(0.,6000.);
2230  hTrackLenCont3DDay[p]->SetLineWidth(2);
2231  hTrackLenCont3DDay[p]->SetLineColor(kRed);
2232  hTrackLenCont3DDay[p]->Draw();
2233  UpdateText->Draw();
2234  sprintf(filename,"%s/%s-%s-P%.1uTrackLenCont3D%s.png",PLOT_DIR.c_str(),det.c_str(),trig.c_str(),p,period.c_str());
2235  cTrackLenCont3Dday->Print(filename);
2236  delete cTrackLenCont3Dday;
2237  cTrackLenCont3Dday = 0;
2238 
2239  // NEW PLOTS
2240  TCanvas *cDeltaSliceTrackday = new TCanvas("cDeltaSliceTrackday","Delta Slice/Track",1200,800);
2241  cDeltaSliceTrackday->cd();
2242  cDeltaSliceTrackday->SetLogy();
2243  gStyle->SetOptStat(111111);
2244  hDeltaSliceTrackDay[p]->SetAxisRange(-15.0,15.0,"X");
2245  hDeltaSliceTrackDay[p]->SetLineWidth(2);
2246  hDeltaSliceTrackDay[p]->SetLineColor(kRed);
2247  hDeltaSliceTrackDay[p]->Draw();
2248  UpdateText->Draw();
2249  sprintf(filename,"%s/%s-%s-P%.1uDeltaSliceTrack%s.png",PLOT_DIR.c_str(),det.c_str(),trig.c_str(),p,period.c_str());
2250  cDeltaSliceTrackday->Print(filename);
2251  delete cDeltaSliceTrackday;
2252  cDeltaSliceTrackday = 0;
2253 
2254  TCanvas *cSliceTrackRatioday = new TCanvas("cSliceTrackRatioday","Slice/Track Ratio",1200,800);
2255  cSliceTrackRatioday->cd();
2256  cSliceTrackRatioday->SetLogy();
2257  gStyle->SetOptStat(111111);
2258  hSliceTrackRatioDay[p]->SetAxisRange(0.0,1.0,"X"); // NOTE: This range will be different for the NearDet.C_Str()
2259  hSliceTrackRatioDay[p]->SetLineWidth(2);
2260  hSliceTrackRatioDay[p]->SetLineColor(kRed);
2261  hSliceTrackRatioDay[p]->Draw();
2262  UpdateText->Draw();
2263  sprintf(filename,"%s/%s-%s-P%.1uSliceTrackRatio%s.png",PLOT_DIR.c_str(),det.c_str(),trig.c_str(),p,period.c_str());
2264  cSliceTrackRatioday->Print(filename);
2265  delete cSliceTrackRatioday;
2266  cSliceTrackRatioday = 0;
2267 
2268  TCanvas *cSliceTrackNHitRatioday = new TCanvas("cSliceTrackNHitRatioday","Slice/Track NHit Ratio",1200,800);
2269  cSliceTrackNHitRatioday->cd();
2270  cSliceTrackNHitRatioday->SetLogy();
2271  gStyle->SetOptStat(111111);
2272  hSliceTrackNHitRatioDay[p]->SetLineWidth(2);
2273  hSliceTrackNHitRatioDay[p]->SetLineColor(kRed);
2274  hSliceTrackNHitRatioDay[p]->Draw();
2275  UpdateText->Draw();
2276  sprintf(filename,"%s/%s-%s-P%.1uSliceTrackNHitRatio%s.png",PLOT_DIR.c_str(),det.c_str(),trig.c_str(),p,period.c_str());
2277  cSliceTrackNHitRatioday->Print(filename);
2278  delete cSliceTrackNHitRatioday;
2279  cSliceTrackNHitRatioday = 0;
2280 
2281 
2282  //new beam plots
2283  maxtime = 0;
2284  max = 0.0;
2285  ave = 0.0;
2286  for(int i = 0; i < NTimeDiffDayCount[p]; ++i) {
2287  ave += (double)NTimeDiffNanoSecDay[p][i];
2288  if(NTimeDiffNanoSectimeDay[p][i] > maxtime) {
2289  maxtime = NTimeDiffNanoSectimeDay[p][i];
2290  max = NTimeDiffNanoSecDay[p][i];
2291  }
2292  }
2293  if(NTimeDiffDayCount[p] > 0) ave = ave/(double)NTimeDiffDayCount[p];
2294  sprintf(lptext,"Last Point = %f / Average = %f",max,ave);
2295  LastPoint->Clear();
2296  LastPoint->AddText(lptext);
2297  TCanvas *ctnTimeDiffday = new TCanvas("cnTimeDiffday","Time Difference (spill and IFDB) day",1200,800);
2298  ctnTimeDiffday->cd();
2299  gPad->SetGridx();
2300  TGraph *gnTimeDiffday = new TGraph(NTimeDiffDayCount[p],NTimeDiffNanoSectimeDay[p],NTimeDiffNanoSecDay[p]);
2301  sprintf(title,"%s Time Difference (spill and IFDB) - partition %.1u",trigname.c_str(),p);
2302  gnTimeDiffday->SetTitle(title);
2303  gnTimeDiffday->SetMarkerColor(kBlue);
2304  gnTimeDiffday->GetXaxis()->SetTimeDisplay(1);
2305  gnTimeDiffday->GetXaxis()->SetLabelSize(0.03);
2306  gnTimeDiffday->GetXaxis()->SetTimeFormat(taxis_labels.c_str());
2307  gnTimeDiffday->GetXaxis()->SetLimits(time_ago,XNow);
2308  gnTimeDiffday->GetXaxis()->SetTitle("(central time)");
2309  gnTimeDiffday->GetYaxis()->SetTitle("(sec)");
2310  gnTimeDiffday->GetYaxis()->SetRangeUser(-0.1,0.6);
2311  gnTimeDiffday->Draw("A*");
2312  TLine* l2TimeDiff=new TLine(time_ago,0.5,XNow,0.5);
2313  l2TimeDiff->SetLineColor(kRed);
2314  l2TimeDiff->SetLineWidth(3);
2315  l2TimeDiff->SetLineStyle(9);
2316  l2TimeDiff->Draw();
2317  UpdateText->Draw();
2318  LastPoint->Draw();
2319  sprintf(filename,"%s/%s-%s-P%.1unTimeDiff%s.png",PLOT_DIR.c_str(),det.c_str(),trig.c_str(),p,period.c_str());
2320  ctnTimeDiffday->Print(filename);
2321  delete ctnTimeDiffday;
2322  ctnTimeDiffday = 0;
2323 
2324  // Adding "zoomed in" version of above plot
2325  TCanvas *ctnTimeDiff_zoom = new TCanvas("cnTimeDiff_zoom","Time Difference (sill and IFDB) day",1200,800);
2326  ctnTimeDiff_zoom->cd();
2327  gPad->SetGridx();
2328  TGraph *gnTimeDiff_zoom = new TGraph(NTimeDiffDayCount[p],NTimeDiffNanoSectimeDay[p],NTimeDiffNanoSecDay[p]);
2329  sprintf(title,"%s Time Difference (spill and IFDB) - partition %.1u",trigname.c_str(),p);
2330  gnTimeDiff_zoom->SetTitle(title);
2331  gnTimeDiff_zoom->SetMarkerColor(kBlue);
2332  gnTimeDiff_zoom->GetXaxis()->SetTimeDisplay(1);
2333  gnTimeDiff_zoom->GetXaxis()->SetLabelSize(0.03);
2334  gnTimeDiff_zoom->GetXaxis()->SetTimeFormat(taxis_labels.c_str());
2335  gnTimeDiff_zoom->GetXaxis()->SetLimits(time_ago,XNow);
2336  gnTimeDiff_zoom->GetXaxis()->SetTitle("(central time)");
2337  gnTimeDiff_zoom->GetYaxis()->SetTitle("(sec)");
2338  gnTimeDiff_zoom->GetYaxis()->SetRangeUser((gnTimeDiff_zoom->GetMean(2)-3.*gnTimeDiff_zoom->GetRMS(2)),(gnTimeDiff_zoom->GetMean(2)+3.*gnTimeDiff_zoom->GetRMS(2)));
2339  gnTimeDiff_zoom->Draw("A*");
2340  UpdateText->Draw();
2341  LastPoint->Draw();
2342  sprintf(filename,"%s/%s-%s-P%.1unTimeDiffzoom%s.png",PLOT_DIR.c_str(),det.c_str(),trig.c_str(),p,period.c_str());
2343  ctnTimeDiff_zoom->Print(filename);
2344  delete ctnTimeDiff_zoom;
2345  ctnTimeDiff_zoom = 0;
2346 
2347  maxtime = 0;
2348  max = 0.0;
2349  ave = 0.0;
2350  for(int i = 0; i < NPOTSumDayCount[p]; ++i) {
2351  ave += (double)NPOTSumDay[p][i];
2352  if(NPOTSumtimeDay[p][i] > maxtime) {
2353  maxtime = NPOTSumtimeDay[p][i];
2354  max = NPOTSumDay[p][i];
2355  }
2356  }
2357  if(NPOTSumDayCount[p] > 0) ave = ave/(double)NPOTSumDayCount[p];
2358  sprintf(lptext,"Last Point = %f / Average = %f",max,ave);
2359  LastPoint->Clear();
2360  LastPoint->AddText(lptext);
2361  TCanvas *ctnPOTSumday = new TCanvas("cnPOTSumday","POT Sum day",1200,800);
2362  ctnPOTSumday->cd();
2363  gPad->SetGridx();
2364  TGraph *gnPOTSumday = new TGraph(NPOTSumDayCount[p],NPOTSumtimeDay[p],NPOTSumDay[p]);
2365  sprintf(title,"%s POT per Subrun - partition %.1u",trigname.c_str(),p);
2366  gnPOTSumday->SetTitle(title);
2367  gnPOTSumday->SetMarkerColor(kBlue);
2368  gnPOTSumday->GetXaxis()->SetTimeDisplay(1);
2369  gnPOTSumday->GetXaxis()->SetLabelSize(0.03);
2370  gnPOTSumday->GetXaxis()->SetTimeFormat(taxis_labels.c_str());
2371  gnPOTSumday->GetXaxis()->SetLimits(time_ago,XNow);
2372  gnPOTSumday->GetYaxis()->SetLabelSize(0.03);
2373  gnPOTSumday->GetYaxis()->SetTitle("(POT)");
2374  gnPOTSumday->GetXaxis()->SetTitle("(central time)");
2375  gnPOTSumday->GetYaxis()->SetRangeUser(25E15,150E15);
2376  gnPOTSumday->Draw("A*");
2377  UpdateText->Draw();
2378  LastPoint->Draw();
2379  sprintf(filename,"%s/%s-%s-P%.1unPOTSumperSR%s.png",PLOT_DIR.c_str(),det.c_str(),trig.c_str(),p,period.c_str());
2380  ctnPOTSumday->Print(filename);
2381  delete ctnPOTSumday;
2382  ctnPOTSumday = 0;
2383 
2384  // Adding "zoomed in" version of above plot
2385  TCanvas *ctnPOTSumday_zoom = new TCanvas("cnPOTSumday_zoom","POT Sum day",1200,800);
2386  ctnPOTSumday_zoom->cd();
2387  gPad->SetGridx();
2388  TGraph *gnPOTSumday_zoom = new TGraph(NPOTSumDayCount[p],NPOTSumtimeDay[p],NPOTSumDay[p]);
2389  sprintf(title,"%s POT per subrun - partition %.1u",trigname.c_str(),p);
2390  gnPOTSumday_zoom->SetTitle(title);
2391  gnPOTSumday_zoom->SetMarkerColor(kBlue);
2392  gnPOTSumday_zoom->GetXaxis()->SetTimeDisplay(1);
2393  gnPOTSumday_zoom->GetXaxis()->SetLabelSize(0.03);
2394  gnPOTSumday_zoom->GetXaxis()->SetTimeFormat(taxis_labels.c_str());
2395  gnPOTSumday_zoom->GetXaxis()->SetLimits(time_ago,XNow);
2396  gnPOTSumday_zoom->GetYaxis()->SetLabelSize(0.03);
2397  gnPOTSumday_zoom->GetYaxis()->SetTitle("(POT)");
2398  gnPOTSumday_zoom->GetXaxis()->SetTitle("(central time)");
2399  gnPOTSumday_zoom->GetYaxis()->SetRangeUser((gnPOTSumday_zoom->GetMean(2)-3.*gnPOTSumday_zoom->GetRMS(2)),(gnPOTSumday_zoom->GetMean(2)+3.*gnPOTSumday_zoom->GetRMS(2)));
2400  gnPOTSumday_zoom->Draw("A*");
2401  UpdateText->Draw();
2402  LastPoint->Draw();
2403  sprintf(filename,"%s/%s-%s-P%.1unPOTSumperSRzoom%s.png",PLOT_DIR.c_str(),det.c_str(),trig.c_str(),p,period.c_str());
2404  ctnPOTSumday_zoom->Print(filename);
2405  delete ctnPOTSumday_zoom;
2406  ctnPOTSumday_zoom = 0;
2407 
2408  maxtime = 0;
2409  max = 0.0;
2410  ave = 0.0;
2411  for(int i = 0; i < NspillPOTDayCount[p]; ++i) {
2412  ave += (double)NspillPOTDay[p][i];
2413  if(NspillPOTtimeDay[p][i] > maxtime) {
2414  maxtime = NspillPOTtimeDay[p][i];
2415  max = NspillPOTDay[p][i];
2416  }
2417  }
2418  if(NspillPOTDayCount[p] > 0) ave = ave/(double)NspillPOTDayCount[p];
2419  sprintf(lptext,"Last Point = %f / Average = %f",max,ave);
2420  LastPoint->Clear();
2421  LastPoint->AddText(lptext);
2422  TCanvas *ctnspillPOTday = new TCanvas("cnspillPOTday","POT Sum day",1200,800);
2423  ctnspillPOTday->cd();
2424  gPad->SetGridx();
2425  TGraph *gnspillPOTday = new TGraph(NspillPOTDayCount[p],NspillPOTtimeDay[p],NspillPOTDay[p]);
2426  sprintf(title,"%s Spill POT per Subrun - partition %.1u",trigname.c_str(),p);
2427  gnspillPOTday->SetTitle(title);
2428  gnspillPOTday->SetMarkerColor(kBlue);
2429  gnspillPOTday->GetXaxis()->SetTimeDisplay(1);
2430  gnspillPOTday->GetXaxis()->SetLabelSize(0.03);
2431  gnspillPOTday->GetXaxis()->SetTimeFormat(taxis_labels.c_str());
2432  gnspillPOTday->GetXaxis()->SetLimits(time_ago,XNow);
2433  gnspillPOTday->GetYaxis()->SetLabelSize(0.03);
2434  gnspillPOTday->GetXaxis()->SetTitle("(central time)");
2435  gnspillPOTday->GetYaxis()->SetRangeUser(0,60e12);
2436  gnspillPOTday->Draw("A*");
2437  TLine* l2SpillPOT=new TLine(time_ago,2e12,XNow,2e12);
2438  l2SpillPOT->SetLineColor(kRed);
2439  l2SpillPOT->SetLineWidth(3);
2440  l2SpillPOT->SetLineStyle(9);
2441  l2SpillPOT->Draw();
2442  UpdateText->Draw();
2443  LastPoint->Draw();
2444  sprintf(filename,"%s/%s-%s-P%.1unspillPOTperSR%s.png",PLOT_DIR.c_str(),det.c_str(),trig.c_str(),p,period.c_str());
2445  ctnspillPOTday->Print(filename);
2446  delete ctnspillPOTday;
2447  ctnspillPOTday = 0;
2448 
2449  // Adding "zoomed in" version of above plot
2450  TCanvas *ctnspillPOTday_zoom = new TCanvas("cnspillPOTday_zoom","POT Sum day",1200,800);
2451  ctnspillPOTday_zoom->cd();
2452  gPad->SetGridx();
2453  TGraph *gnspillPOTday_zoom = new TGraph(NspillPOTDayCount[p],NspillPOTtimeDay[p],NspillPOTDay[p]);
2454  sprintf(title,"%s Spill POT per subrun - partition %.1u",trigname.c_str(),p);
2455  gnspillPOTday_zoom->SetTitle(title);
2456  gnspillPOTday_zoom->SetMarkerColor(kBlue);
2457  gnspillPOTday_zoom->GetXaxis()->SetTimeDisplay(1);
2458  gnspillPOTday_zoom->GetXaxis()->SetLabelSize(0.03);
2459  gnspillPOTday_zoom->GetXaxis()->SetTimeFormat(taxis_labels.c_str());
2460  gnspillPOTday_zoom->GetXaxis()->SetLimits(time_ago,XNow);
2461  gnspillPOTday_zoom->GetYaxis()->SetLabelSize(0.03);
2462  gnspillPOTday_zoom->GetXaxis()->SetTitle("(central time)");
2463  gnspillPOTday_zoom->GetYaxis()->SetRangeUser((gnspillPOTday_zoom->GetMean(2)-3.*gnspillPOTday_zoom->GetRMS(2)),(gnspillPOTday_zoom->GetMean(2)+3.*gnspillPOTday_zoom->GetRMS(2)));
2464  gnspillPOTday_zoom->Draw("A*");
2465  UpdateText->Draw();
2466  LastPoint->Draw();
2467  sprintf(filename,"%s/%s-%s-P%.1unspillPOTperSRzoom%s.png",PLOT_DIR.c_str(),det.c_str(),trig.c_str(),p,period.c_str());
2468  ctnspillPOTday_zoom->Print(filename);
2469  delete ctnspillPOTday_zoom;
2470  ctnspillPOTday_zoom = 0;
2471 
2472  maxtime = 0;
2473  max = 0;
2474  ave = 0;
2475 
2476  for(int i = 0; i < NHornCurrentDayCount[p]; ++i) {
2477  ave += (double)NHornCurrentDay[p][i];
2478  if(NHornCurrenttimeDay[p][i] > maxtime) {
2479  maxtime = NHornCurrenttimeDay[p][i];
2480  max = NHornCurrentDay[p][i];
2481  }
2482  }
2483  if(NHornCurrentDayCount[p] > 0) ave = ave/(double)NHornCurrentDayCount[p];
2484  sprintf(lptext,"Last Point = %f / Average = %f",max,ave);
2485  LastPoint->Clear();
2486  LastPoint->AddText(lptext);
2487  TCanvas *ctnHornCurrentday = new TCanvas("cnHornCurrentday","Horn Current day",1200,800);
2488  ctnHornCurrentday->cd();
2489  gPad->SetGridx();
2490  TGraph *gnHornCurrentday = new TGraph(NHornCurrentDayCount[p],NHornCurrenttimeDay[p],NHornCurrentDay[p]);
2491  sprintf(title,"%s Horn Current per Subrun - partition %.1u",trigname.c_str(),p);
2492  gnHornCurrentday->SetTitle(title);
2493  gnHornCurrentday->SetMarkerColor(kBlue);
2494  gnHornCurrentday->GetXaxis()->SetTimeDisplay(1);
2495  gnHornCurrentday->GetXaxis()->SetLabelSize(0.03);
2496  gnHornCurrentday->GetXaxis()->SetTimeFormat(taxis_labels.c_str());
2497  gnHornCurrentday->GetXaxis()->SetLimits(time_ago,XNow);
2498  gnHornCurrentday->GetXaxis()->SetTitle("(central time)");
2499  gnHornCurrentday->GetYaxis()->SetTitle("(kA)");
2500  gnHornCurrentday->GetYaxis()->SetRangeUser(-203,-197);
2501  gnHornCurrentday->Draw("A*");
2502  TLine* l2cHornCurrent=new TLine(time_ago,-202,XNow,-202);
2503  l2cHornCurrent->SetLineColor(kRed);
2504  l2cHornCurrent->SetLineWidth(3);
2505  l2cHornCurrent->SetLineStyle(9);
2506  l2cHornCurrent->Draw();
2507  TLine* l2bHornCurrent=new TLine(time_ago,-198,XNow,-198);
2508  l2bHornCurrent->SetLineColor(kRed);
2509  l2bHornCurrent->SetLineWidth(3);
2510  l2bHornCurrent->SetLineStyle(9);
2511  l2bHornCurrent->Draw();
2512  UpdateText->Draw();
2513  LastPoint->Draw();
2514  UpdateText->Draw();
2515  LastPoint->Draw();
2516  sprintf(filename,"%s/%s-%s-P%.1unHornCurrentperSR%s.png",PLOT_DIR.c_str(),det.c_str(),trig.c_str(),p,period.c_str());
2517  ctnHornCurrentday->Print(filename);
2518  delete ctnHornCurrentday;
2519  ctnHornCurrentday = 0;
2520 
2521  // Adding "zoomed in" version of above plot
2522  TCanvas *ctnHornCurrentday_zoom = new TCanvas("cnHornCurrentday_zoom","Horn Current day",1200,800);
2523  ctnHornCurrentday_zoom->cd();
2524  gPad->SetGridx();
2525  TGraph *gnHornCurrentday_zoom = new TGraph(NHornCurrentDayCount[p],NHornCurrenttimeDay[p],NHornCurrentDay[p]);
2526  sprintf(title,"%s Horn Current per subrun - partition %.1u",trigname.c_str(),p);
2527  gnHornCurrentday_zoom->SetTitle(title);
2528  gnHornCurrentday_zoom->SetMarkerColor(kBlue);
2529  gnHornCurrentday_zoom->GetXaxis()->SetTimeDisplay(1);
2530  gnHornCurrentday_zoom->GetXaxis()->SetLabelSize(0.03);
2531  gnHornCurrentday_zoom->GetXaxis()->SetTimeFormat(taxis_labels.c_str());
2532  gnHornCurrentday_zoom->GetXaxis()->SetLimits(time_ago,XNow);
2533  gnHornCurrentday_zoom->GetXaxis()->SetTitle("(central time)");
2534  gnHornCurrentday_zoom->GetYaxis()->SetTitle("(kA)");
2535  gnHornCurrentday_zoom->GetYaxis()->SetRangeUser((gnHornCurrentday_zoom->GetMean(2)-3.*gnHornCurrentday_zoom->GetRMS(2)),(gnHornCurrentday_zoom->GetMean(2)+3.*gnHornCurrentday_zoom->GetRMS(2)));
2536  gnHornCurrentday_zoom->Draw("A*");
2537  UpdateText->Draw();
2538  LastPoint->Draw();
2539  sprintf(filename,"%s/%s-%s-P%.1unHornCurrentperSRzoom%s.png",PLOT_DIR.c_str(),det.c_str(),trig.c_str(),p,period.c_str());
2540  ctnHornCurrentday_zoom->Print(filename);
2541  delete ctnHornCurrentday_zoom;
2542  ctnHornCurrentday_zoom = 0;
2543 
2544  maxtime = 0;
2545  max = 0.0;
2546  ave = 0.0;
2547  for(int i = 0; i < NXPositionDayCount[p]; ++i) {
2548  ave += (double)NXPositionDay[p][i];
2549  if(NXPositiontimeDay[p][i] > maxtime) {
2550  maxtime = NXPositiontimeDay[p][i];
2551  max = NXPositionDay[p][i];
2552  }
2553  }
2554  if(NXPositionDayCount[p] > 0) ave = ave/(double)NXPositionDayCount[p];
2555  sprintf(lptext,"Last Point = %f / Average = %f",max,ave);
2556  LastPoint->Clear();
2557  LastPoint->AddText(lptext);
2558  TCanvas *ctnXPositionday = new TCanvas("cnXPositionday","X Position day",1200,800);
2559  ctnXPositionday->cd();
2560  gPad->SetGridx();
2561  TGraph *gnXPositionday = new TGraph(NXPositionDayCount[p],NXPositiontimeDay[p],NXPositionDay[p]);
2562  sprintf(title,"%s X Position per Subrun - partition %.1u",trigname.c_str(),p);
2563  gnXPositionday->SetTitle(title);
2564  gnXPositionday->SetMarkerColor(kBlue);
2565  gnXPositionday->GetXaxis()->SetTimeDisplay(1);
2566  gnXPositionday->GetXaxis()->SetLabelSize(0.03);
2567  gnXPositionday->GetXaxis()->SetTimeFormat(taxis_labels.c_str());
2568  gnXPositionday->GetXaxis()->SetLimits(time_ago,XNow);
2569  gnXPositionday->GetXaxis()->SetTitle("(central time)");
2570  gnXPositionday->GetYaxis()->SetTitle("(mm)");
2571  gnXPositionday->GetYaxis()->SetRangeUser(-2.1,2.1);
2572  gnXPositionday->Draw("A*");
2573  TLine* l2cXPosition=new TLine(time_ago,-2.0,XNow,-2.0);
2574  l2cXPosition->SetLineColor(kRed);
2575  l2cXPosition->SetLineWidth(3);
2576  l2cXPosition->SetLineStyle(9);
2577  l2cXPosition->Draw();
2578  TLine* l2bXPosition=new TLine(time_ago,2.0,XNow,2.0);
2579  l2bXPosition->SetLineColor(kRed);
2580  l2bXPosition->SetLineWidth(3);
2581  l2bXPosition->SetLineStyle(9);
2582  l2bXPosition->Draw();
2583  UpdateText->Draw();
2584  LastPoint->Draw();
2585  sprintf(filename,"%s/%s-%s-P%.1unXPositionperSR%s.png",PLOT_DIR.c_str(),det.c_str(),trig.c_str(),p,period.c_str());
2586  ctnXPositionday->Print(filename);
2587  delete ctnXPositionday;
2588  ctnXPositionday = 0;
2589 
2590  // Adding "zoomed in" version of above plot
2591  TCanvas *ctnXPositionday_zoom = new TCanvas("cnXPositionday_zoom","X Position day",1200,800);
2592  ctnXPositionday_zoom->cd();
2593  gPad->SetGridx();
2594  TGraph *gnXPositionday_zoom = new TGraph(NXPositionDayCount[p],NXPositiontimeDay[p],NXPositionDay[p]);
2595  sprintf(title,"%s X Position per subrun - partition %.1u",trigname.c_str(),p);
2596  gnXPositionday_zoom->SetTitle(title);
2597  gnXPositionday_zoom->SetMarkerColor(kBlue);
2598  gnXPositionday_zoom->GetXaxis()->SetTimeDisplay(1);
2599  gnXPositionday_zoom->GetXaxis()->SetLabelSize(0.03);
2600  gnXPositionday_zoom->GetXaxis()->SetTimeFormat(taxis_labels.c_str());
2601  gnXPositionday_zoom->GetXaxis()->SetLimits(time_ago,XNow);
2602  gnXPositionday_zoom->GetXaxis()->SetTitle("(central time)");
2603  gnXPositionday_zoom->GetYaxis()->SetTitle("(mm)");
2604  gnXPositionday_zoom->GetYaxis()->SetRangeUser((gnXPositionday_zoom->GetMean(2)-3.*gnXPositionday_zoom->GetRMS(2)),(gnXPositionday_zoom->GetMean(2)+3.*gnXPositionday_zoom->GetRMS(2)));
2605  gnXPositionday_zoom->Draw("A*");
2606  UpdateText->Draw();
2607  LastPoint->Draw();
2608  sprintf(filename,"%s/%s-%s-P%.1unXPositionperSRzoom%s.png",PLOT_DIR.c_str(),det.c_str(),trig.c_str(),p,period.c_str());
2609  ctnXPositionday_zoom->Print(filename);
2610  delete ctnXPositionday_zoom;
2611  ctnXPositionday_zoom = 0;
2612 
2613  maxtime = 0;
2614  max = 0.0;
2615  ave = 0.0;
2616  for(int i = 0; i < NYPositionDayCount[p]; ++i) {
2617  ave += (double)NYPositionDay[p][i];
2618  if(NYPositionDay[p][i] > maxtime) {
2619  maxtime = NYPositiontimeDay[p][i];
2620  max = NYPositionDay[p][i];
2621  }
2622  }
2623  if(NYPositionDayCount[p] > 0) ave = ave/(double)NYPositionDayCount[p];
2624  sprintf(lptext,"Last Point = %f / Average = %f",max,ave);
2625  LastPoint->Clear();
2626  LastPoint->AddText(lptext);
2627  TCanvas *ctnYPositionday = new TCanvas("cnYPositionday","Y Position day",1200,800);
2628  ctnYPositionday->cd();
2629  gPad->SetGridx();
2630  TGraph *gnYPositionday = new TGraph(NYPositionDayCount[p],NYPositiontimeDay[p],NYPositionDay[p]);
2631  sprintf(title,"%s Y Position per Subrun - partition %.1u",trigname.c_str(),p);
2632  gnYPositionday->SetTitle(title);
2633  gnYPositionday->SetMarkerColor(kBlue);
2634  gnYPositionday->GetXaxis()->SetTimeDisplay(1);
2635  gnYPositionday->GetXaxis()->SetLabelSize(0.03);
2636  gnYPositionday->GetXaxis()->SetTimeFormat(taxis_labels.c_str());
2637  gnYPositionday->GetXaxis()->SetLimits(time_ago,XNow);
2638  gnYPositionday->GetXaxis()->SetTitle("(central time)");
2639  gnYPositionday->GetYaxis()->SetTitle("(mm)");
2640  //gnYPositionday->GetYaxis()->SetRangeUser(-2.1, 2.1);
2641  gnYPositionday->GetYaxis()->SetRangeUser(-5, 2);
2642  gnYPositionday->Draw("A*");
2643  TLine* l2cYPosition=new TLine(time_ago,-4.5,XNow,-4.5);
2644  l2cYPosition->SetLineColor(kRed);
2645  l2cYPosition->SetLineWidth(3);
2646  l2cYPosition->SetLineStyle(9);
2647  l2cYPosition->Draw();
2648  TLine* l2bYPosition=new TLine(time_ago,0,XNow,0);
2649  l2bYPosition->SetLineColor(kRed);
2650  l2bYPosition->SetLineWidth(3);
2651  l2bYPosition->SetLineStyle(9);
2652  l2bYPosition->Draw();
2653  UpdateText->Draw();
2654  LastPoint->Draw();
2655  sprintf(filename,"%s/%s-%s-P%.1unYPositionperSR%s.png",PLOT_DIR.c_str(),det.c_str(),trig.c_str(),p,period.c_str());
2656  ctnYPositionday->Print(filename);
2657  delete ctnYPositionday;
2658  ctnYPositionday = 0;
2659 
2660  // Adding "zoomed in" version of above plot
2661  TCanvas *ctnYPositionday_zoom = new TCanvas("cnYPositionday_zoom","Y Position day",1200,800);
2662  ctnYPositionday_zoom->cd();
2663  gPad->SetGridx();
2664  TGraph *gnYPositionday_zoom = new TGraph(NYPositionDayCount[p],NYPositiontimeDay[p],NYPositionDay[p]);
2665  sprintf(title,"%s Y Position per subrun - partition %.1u",trigname.c_str(),p);
2666  gnYPositionday_zoom->SetTitle(title);
2667  gnYPositionday_zoom->SetMarkerColor(kBlue);
2668  gnYPositionday_zoom->GetXaxis()->SetTimeDisplay(1);
2669  gnYPositionday_zoom->GetXaxis()->SetLabelSize(0.03);
2670  gnYPositionday_zoom->GetXaxis()->SetTimeFormat(taxis_labels.c_str());
2671  gnYPositionday_zoom->GetXaxis()->SetLimits(time_ago,XNow);
2672  gnYPositionday_zoom->GetXaxis()->SetTitle("(central time)");
2673  gnYPositionday_zoom->GetYaxis()->SetTitle("(mm)");
2674  gnYPositionday_zoom->GetYaxis()->SetRangeUser((gnYPositionday_zoom->GetMean(2)-3.*gnYPositionday_zoom->GetRMS(2)),(gnYPositionday_zoom->GetMean(2)+3.*gnYPositionday_zoom->GetRMS(2)));
2675  gnYPositionday_zoom->Draw("A*");
2676  UpdateText->Draw();
2677  LastPoint->Draw();
2678  sprintf(filename,"%s/%s-%s-P%.1unYPositionperSRzoom%s.png",PLOT_DIR.c_str(),det.c_str(),trig.c_str(),p,period.c_str());
2679  ctnYPositionday_zoom->Print(filename);
2680  delete ctnYPositionday_zoom;
2681  ctnYPositionday_zoom = 0;
2682 
2683  maxtime = 0;
2684  max = 0.0;
2685  ave = 0.0;
2686  for(int i = 0; i < NXWidthDayCount[p]; ++i) {
2687  ave += (double)NXWidthDay[p][i];
2688  if(NXWidthtimeDay[p][i] > maxtime) {
2689  maxtime = NXWidthtimeDay[p][i];
2690  max = NXWidthDay[p][i];
2691  }
2692  }
2693  if(NXWidthDayCount[p] > 0) ave = ave/(double)NXWidthDayCount[p];
2694  sprintf(lptext,"Last Point = %f / Average = %f",max,ave);
2695  LastPoint->Clear();
2696  LastPoint->AddText(lptext);
2697  TCanvas *ctnXWidthday = new TCanvas("cnXWidthday","X Width day",1200,800);
2698  ctnXWidthday->cd();
2699  gPad->SetGridx();
2700  TGraph *gnXWidthday = new TGraph(NXWidthDayCount[p],NXWidthtimeDay[p],NXWidthDay[p]);
2701  sprintf(title,"%s X Width per Subrun - partition %.1u",trigname.c_str(),p);
2702  gnXWidthday->SetTitle(title);
2703  gnXWidthday->SetMarkerColor(kBlue);
2704  gnXWidthday->GetXaxis()->SetTimeDisplay(1);
2705  gnXWidthday->GetXaxis()->SetLabelSize(0.03);
2706  gnXWidthday->GetXaxis()->SetTimeFormat(taxis_labels.c_str());
2707  gnXWidthday->GetXaxis()->SetLimits(time_ago,XNow);
2708  gnXWidthday->GetXaxis()->SetTitle("(central time)");
2709  gnXWidthday->GetYaxis()->SetTitle("(mm)");
2710  gnXWidthday->GetYaxis()->SetRangeUser(0.5,2.0);
2711  gnXWidthday->Draw("A*");
2712  TLine* l2cXWidth=new TLine(time_ago,0.57,XNow,0.57);
2713  l2cXWidth->SetLineColor(kRed);
2714  l2cXWidth->SetLineWidth(3);
2715  l2cXWidth->SetLineStyle(9);
2716  l2cXWidth->Draw();
2717  TLine* l2bXWidth=new TLine(time_ago,1.88,XNow,1.88);
2718  l2bXWidth->SetLineColor(kRed);
2719  l2bXWidth->SetLineWidth(3);
2720  l2bXWidth->SetLineStyle(9);
2721  l2bXWidth->Draw();
2722  UpdateText->Draw();
2723  LastPoint->Draw();
2724  sprintf(filename,"%s/%s-%s-P%.1unXWidthperSR%s.png",PLOT_DIR.c_str(),det.c_str(),trig.c_str(),p,period.c_str());
2725  ctnXWidthday->Print(filename);
2726  delete ctnXWidthday;
2727  ctnXWidthday = 0;
2728 
2729  // Adding "zoomed in" version of above plot
2730  TCanvas *ctnXWidthday_zoom = new TCanvas("cnXWidthday_zoom","X Width day",1200,800);
2731  ctnXWidthday_zoom->cd();
2732  gPad->SetGridx();
2733  TGraph *gnXWidthday_zoom = new TGraph(NXWidthDayCount[p],NXWidthtimeDay[p],NXWidthDay[p]);
2734  sprintf(title,"%s X Width per subrun - partition %.1u",trigname.c_str(),p);
2735  gnXWidthday_zoom->SetTitle(title);
2736  gnXWidthday_zoom->SetMarkerColor(kBlue);
2737  gnXWidthday_zoom->GetXaxis()->SetTimeDisplay(1);
2738  gnXWidthday_zoom->GetXaxis()->SetLabelSize(0.03);
2739  gnXWidthday_zoom->GetXaxis()->SetTimeFormat(taxis_labels.c_str());
2740  gnXWidthday_zoom->GetXaxis()->SetLimits(time_ago,XNow);
2741  gnXWidthday_zoom->GetXaxis()->SetTitle("(central time)");
2742  gnXWidthday_zoom->GetYaxis()->SetTitle("(mm)");
2743  gnXWidthday_zoom->GetYaxis()->SetRangeUser((gnXWidthday_zoom->GetMean(2)-3.*gnXWidthday_zoom->GetRMS(2)),(gnXWidthday_zoom->GetMean(2)+3.*gnXWidthday_zoom->GetRMS(2)));
2744  gnXWidthday_zoom->Draw("A*");
2745  UpdateText->Draw();
2746  LastPoint->Draw();
2747  sprintf(filename,"%s/%s-%s-P%.1unXWidthperSRzoom%s.png",PLOT_DIR.c_str(),det.c_str(),trig.c_str(),p,period.c_str());
2748  ctnXWidthday_zoom->Print(filename);
2749  delete ctnXWidthday_zoom;
2750  ctnXWidthday_zoom = 0;
2751 
2752  maxtime = 0;
2753  max = 0.0;
2754  ave = 0.0;
2755  for(int i = 0; i < NYWidthDayCount[p]; ++i) {
2756  ave += (double)NYWidthDay[p][i];
2757  if(NYWidthtimeDay[p][i] > maxtime) {
2758  maxtime = NYWidthtimeDay[p][i];
2759  max = NYWidthDay[p][i];
2760  }
2761  }
2762  if(NYWidthDayCount[p] > 0) ave = ave/(double)NYWidthDayCount[p];
2763  sprintf(lptext,"Last Point = %f / Average = %f",max,ave);
2764  LastPoint->Clear();
2765  LastPoint->AddText(lptext);
2766  TCanvas *ctnYWidthday = new TCanvas("cnYWidthday","Y Width day",1200,800);
2767  ctnYWidthday->cd();
2768  gPad->SetGridx();
2769  TGraph *gnYWidthday = new TGraph(NYWidthDayCount[p],NYWidthtimeDay[p],NYWidthDay[p]);
2770  sprintf(title,"%s Y Width per Subrun - partition %.1u",trigname.c_str(),p);
2771  gnYWidthday->SetTitle(title);
2772  gnYWidthday->SetMarkerColor(kBlue);
2773  gnYWidthday->GetXaxis()->SetTimeDisplay(1);
2774  gnYWidthday->GetXaxis()->SetLabelSize(0.03);
2775  gnYWidthday->GetXaxis()->SetTimeFormat(taxis_labels.c_str());
2776  gnYWidthday->GetXaxis()->SetLimits(time_ago,XNow);
2777  gnYWidthday->GetXaxis()->SetTitle("(central time)");
2778  gnYWidthday->GetYaxis()->SetTitle("(mm)");
2779  gnYWidthday->GetYaxis()->SetRangeUser(0.5,2.0);
2780  gnYWidthday->Draw("A*");
2781  TLine* l2cYWidth=new TLine(time_ago,0.57,XNow,0.57);
2782  l2cYWidth->SetLineColor(kRed);
2783  l2cYWidth->SetLineWidth(3);
2784  l2cYWidth->SetLineStyle(9);
2785  l2cYWidth->Draw();
2786  TLine* l2bYWidth=new TLine(time_ago,1.58,XNow,1.58);
2787  l2bYWidth->SetLineColor(kRed);
2788  l2bYWidth->SetLineWidth(3);
2789  l2bYWidth->SetLineStyle(9);
2790  l2bYWidth->Draw();
2791  UpdateText->Draw();
2792  LastPoint->Draw();
2793  sprintf(filename,"%s/%s-%s-P%.1unYWidthperSR%s.png",PLOT_DIR.c_str(),det.c_str(),trig.c_str(),p,period.c_str());
2794  ctnYWidthday->Print(filename);
2795  delete ctnYWidthday;
2796  ctnYWidthday = 0;
2797 
2798  // Adding "zoomed in" version of above plot
2799  TCanvas *ctnYWidthday_zoom = new TCanvas("cnYWidthday_zoom","Y Width day",1200,800);
2800  ctnYWidthday_zoom->cd();
2801  gPad->SetGridx();
2802  TGraph *gnYWidthday_zoom = new TGraph(NYWidthDayCount[p],NYWidthtimeDay[p],NYWidthDay[p]);
2803  sprintf(title,"%s Y Width per subrun - partition %.1u",trigname.c_str(),p);
2804  gnYWidthday_zoom->SetTitle(title);
2805  gnYWidthday_zoom->SetMarkerColor(kBlue);
2806  gnYWidthday_zoom->GetXaxis()->SetTimeDisplay(1);
2807  gnYWidthday_zoom->GetXaxis()->SetLabelSize(0.03);
2808  gnYWidthday_zoom->GetXaxis()->SetTimeFormat(taxis_labels.c_str());
2809  gnYWidthday_zoom->GetXaxis()->SetLimits(time_ago,XNow);
2810  gnYWidthday_zoom->GetXaxis()->SetTitle("(central time)");
2811  gnYWidthday_zoom->GetYaxis()->SetTitle("(mm)");
2812  gnYWidthday_zoom->GetYaxis()->SetRangeUser((gnYWidthday_zoom->GetMean(2)-3.*gnYWidthday_zoom->GetRMS(2)),(gnYWidthday_zoom->GetMean(2)+3.*gnYWidthday_zoom->GetRMS(2)));
2813  gnYWidthday_zoom->Draw("A*");
2814  UpdateText->Draw();
2815  LastPoint->Draw();
2816  sprintf(filename,"%s/%s-%s-P%.1unYWidthperSRzoom%s.png",PLOT_DIR.c_str(),det.c_str(),trig.c_str(),p,period.c_str());
2817  ctnYWidthday_zoom->Print(filename);
2818  delete ctnYWidthday_zoom;
2819  ctnYWidthday_zoom = 0;
2820 
2821  maxtime = 0;
2822  max = 0.0;
2823  ave = 0.0;
2824  for(int i = 0; i < NGoodBeamDayCount[p]; ++i) {
2825  ave += (double)NGoodBeamDay[p][i];
2826  if(NGoodBeamtimeDay[p][i] > maxtime) {
2827  maxtime = NGoodBeamtimeDay[p][i];
2828  max = NGoodBeamDay[p][i];
2829  }
2830  }
2831  if(NGoodBeamDayCount[p] > 0) ave = ave/(double)NGoodBeamDayCount[p];
2832  sprintf(lptext,"Last Point = %f / Average = %f",max,ave);
2833  LastPoint->Clear();
2834  LastPoint->AddText(lptext);
2835  TCanvas *ctnGoodBeamday = new TCanvas("cnGoodBeamday","Good Beam day",1200,800);
2836  ctnGoodBeamday->cd();
2837  gPad->SetGridx();
2838  TGraph *gnGoodBeamday = new TGraph(NGoodBeamDayCount[p],NGoodBeamtimeDay[p],NGoodBeamDay[p]);
2839  sprintf(title,"%s Good Beam per Subrun - partition %.1u",trigname.c_str(),p);
2840  gnGoodBeamday->SetTitle(title);
2841  gnGoodBeamday->SetMarkerColor(kBlue);
2842  gnGoodBeamday->GetXaxis()->SetTimeDisplay(1);
2843  gnGoodBeamday->GetXaxis()->SetLabelSize(0.03);
2844  gnGoodBeamday->GetXaxis()->SetTimeFormat(taxis_labels.c_str());
2845  gnGoodBeamday->GetXaxis()->SetLimits(time_ago,XNow);
2846  gnGoodBeamday->GetXaxis()->SetTitle("(central time)");
2847  gnGoodBeamday->GetYaxis()->SetRangeUser(-0.1,1.2);
2848  gnGoodBeamday->Draw("A*");
2849  UpdateText->Draw();
2850  LastPoint->Draw();
2851  sprintf(filename,"%s/%s-%s-P%.1unGoodBeamperSR%s.png",PLOT_DIR.c_str(),det.c_str(),trig.c_str(),p,period.c_str());
2852  ctnGoodBeamday->Print(filename);
2853  delete ctnGoodBeamday;
2854  ctnGoodBeamday = 0;
2855 
2856  // Adding "zoomed in" version of above plot
2857  TCanvas *ctnGoodBeamday_zoom = new TCanvas("cnGoodBeamday_zoom","Good Beam day",1200,800);
2858  ctnGoodBeamday_zoom->cd();
2859  gPad->SetGridx();
2860  TGraph *gnGoodBeamday_zoom = new TGraph(NGoodBeamDayCount[p],NGoodBeamtimeDay[p],NGoodBeamDay[p]);
2861  sprintf(title,"%s Good Beam per subrun - partition %.1u",trigname.c_str(),p);
2862  gnGoodBeamday_zoom->SetTitle(title);
2863  gnGoodBeamday_zoom->SetMarkerColor(kBlue);
2864  gnGoodBeamday_zoom->GetXaxis()->SetTimeDisplay(1);
2865  gnGoodBeamday_zoom->GetXaxis()->SetLabelSize(0.03);
2866  gnGoodBeamday_zoom->GetXaxis()->SetTimeFormat(taxis_labels.c_str());
2867  gnGoodBeamday_zoom->GetXaxis()->SetLimits(time_ago,XNow);
2868  gnGoodBeamday_zoom->GetXaxis()->SetTitle("(central time)");
2869  gnGoodBeamday_zoom->GetYaxis()->SetRangeUser((gnGoodBeamday_zoom->GetMean(2)-3.*gnGoodBeamday_zoom->GetRMS(2)),(gnGoodBeamday_zoom->GetMean(2)+3.*gnGoodBeamday_zoom->GetRMS(2)));
2870  gnGoodBeamday_zoom->Draw("A*");
2871  UpdateText->Draw();
2872  LastPoint->Draw();
2873  sprintf(filename,"%s/%s-%s-P%.1unGoodBeamperSRzoom%s.png",PLOT_DIR.c_str(),det.c_str(),trig.c_str(),p,period.c_str());
2874  ctnGoodBeamday_zoom->Print(filename);
2875  delete ctnGoodBeamday_zoom;
2876  ctnGoodBeamday_zoom = 0;
2877  //end new beam plots
2878 
2879  maxtime = 0;
2880  max = 0.0;
2881  ave = 0.0;
2882  for(int i = 0; i < NSliceDayCount[p]; ++i) {
2883  ave += (double)NSliceDay[p][i];
2884  if(NSlicetimeDay[p][i] > maxtime) {
2885  maxtime = NSlicetimeDay[p][i];
2886  max = NSliceDay[p][i];
2887  }
2888  }
2889  if(NSliceDayCount[p] > 0) ave = ave/(double)NSliceDayCount[p];
2890  sprintf(lptext,"Last Point = %f / Average = %f",max,ave);
2891  LastPoint->Clear();
2892  LastPoint->AddText(lptext);
2893  TCanvas *ctnSliceday = new TCanvas("cnSliceday","# Non-Noise Slices day",1200,800);
2894  ctnSliceday->cd();
2895  gPad->SetGridx();
2896  TGraph *gnSliceday = new TGraph(NSliceDayCount[p],NSlicetimeDay[p],NSliceDay[p]);
2897  sprintf(title,"%s Number of Slices per Subrun - partition %.1u",trigname.c_str(),p);
2898  gnSliceday->SetTitle(title);
2899  gnSliceday->SetMarkerColor(kBlue);
2900  gnSliceday->GetXaxis()->SetTimeDisplay(1);
2901  gnSliceday->GetXaxis()->SetLabelSize(0.03);
2902  gnSliceday->GetXaxis()->SetTimeFormat(taxis_labels.c_str());
2903  gnSliceday->GetXaxis()->SetLimits(time_ago,XNow);
2904  gnSliceday->GetXaxis()->SetTitle("(central time)");
2905  gnSliceday->Draw("A*");
2906  UpdateText->Draw();
2907  LastPoint->Draw();
2908  sprintf(filename,"%s/%s-%s-P%.1unSliceperSR%s.png",PLOT_DIR.c_str(),det.c_str(),trig.c_str(),p,period.c_str());
2909  ctnSliceday->Print(filename);
2910  delete ctnSliceday;
2911  ctnSliceday = 0;
2912 
2913  // Adding "zoomed in" version of above plot
2914  TCanvas *ctnSliceday_zoom = new TCanvas("cnSliceday_zoom","# Non-Noise Slices day",1200,800);
2915  ctnSliceday_zoom->cd();
2916  gPad->SetGridx();
2917  TGraph *gnSliceday_zoom = new TGraph(NSliceDayCount[p],NSlicetimeDay[p],NSliceDay[p]);
2918  sprintf(title,"%s Number of Slices per Subrun - partition %.1u",trigname.c_str(),p);
2919  gnSliceday_zoom->SetTitle(title);
2920  gnSliceday_zoom->SetMarkerColor(kBlue);
2921  gnSliceday_zoom->GetXaxis()->SetTimeDisplay(1);
2922  gnSliceday_zoom->GetXaxis()->SetLabelSize(0.03);
2923  gnSliceday_zoom->GetXaxis()->SetTimeFormat(taxis_labels.c_str());
2924  gnSliceday_zoom->GetXaxis()->SetLimits(time_ago,XNow);
2925  gnSliceday_zoom->GetXaxis()->SetTitle("(central time)");
2926  gnSliceday_zoom->GetYaxis()->SetRangeUser((gnSliceday_zoom->GetMean(2)-3.*gnSliceday_zoom->GetRMS(2)),(gnSliceday_zoom->GetMean(2)+3.*gnSliceday_zoom->GetRMS(2)));
2927  gnSliceday_zoom->Draw("A*");
2928  UpdateText->Draw();
2929  LastPoint->Draw();
2930  sprintf(filename,"%s/%s-%s-P%.1unSliceperSRzoom%s.png",PLOT_DIR.c_str(),det.c_str(),trig.c_str(),p,period.c_str());
2931  ctnSliceday_zoom->Print(filename);
2932  delete ctnSliceday_zoom;
2933  ctnSliceday_zoom = 0;
2934 
2935  maxtime = 0;
2936  max = 0.0;
2937  ave = 0.0;
2938  for(int i = 0; i < NNonNoiseSliceHitDayCount[p]; ++i) {
2939  ave += (double)NNonNoiseSliceHitDay[p][i];
2940  if(NNonNoiseSliceHittimeDay[p][i] > maxtime) {
2941  maxtime = NNonNoiseSliceHittimeDay[p][i];
2942  max = NNonNoiseSliceHitDay[p][i];
2943  }
2944  }
2945  if(NNonNoiseSliceHitDayCount[p] > 0) ave = ave/(double)NNonNoiseSliceHitDayCount[p];
2946  sprintf(lptext,"Last Point = %f / Average = %f",max,ave);
2947  LastPoint->Clear();
2948  LastPoint->AddText(lptext);
2949  TCanvas *ctnSliceHitday = new TCanvas("cnSliceHitday","# Non-Noise Slice Hits day",1200,800);
2950  ctnSliceHitday->cd();
2951  //ctnSliceHitday->SetLogy();
2952  gPad->SetGridx();
2953  TGraph *gnSliceHitday = new TGraph(NNonNoiseSliceHitDayCount[p],NNonNoiseSliceHittimeDay[p],NNonNoiseSliceHitDay[p]);
2954  sprintf(title,"%s Number of Slice Hits per Subrun - partition %.1u",trigname.c_str(),p);
2955  gnSliceHitday->SetTitle(title);
2956  gnSliceHitday->SetMarkerColor(kBlue);
2957  gnSliceHitday->GetXaxis()->SetTimeDisplay(1);
2958  gnSliceHitday->GetXaxis()->SetLabelSize(0.03);
2959  gnSliceHitday->GetXaxis()->SetTimeFormat(taxis_labels.c_str());
2960  gnSliceHitday->GetXaxis()->SetLimits(time_ago,XNow);
2961  gnSliceHitday->GetXaxis()->SetTitle("(central time)");
2962  gnSliceHitday->Draw("A*");
2963  UpdateText->Draw();
2964  LastPoint->Draw();
2965  sprintf(filename,"%s/%s-%s-P%.1unSliceHitperSR%s.png",PLOT_DIR.c_str(),det.c_str(),trig.c_str(),p,period.c_str());
2966  ctnSliceHitday->Print(filename);
2967  delete ctnSliceHitday;
2968  ctnSliceHitday = 0;
2969 
2970  //Adding "zoomed in" version of the above plot
2971  TCanvas *ctnSliceHitday_zoom = new TCanvas("cnSliceHitday_zoom","# Non-Noise Slice Hits day",1200,800);
2972  ctnSliceHitday_zoom->cd();
2973  //ctnSliceHitday_zoom->SetLogy();
2974  gPad->SetGridx();
2975  TGraph *gnSliceHitday_zoom = new TGraph(NNonNoiseSliceHitDayCount[p],NNonNoiseSliceHittimeDay[p],NNonNoiseSliceHitDay[p]);
2976  sprintf(title,"%s Number of Slice Hits per Subrun - partition %.1u",trigname.c_str(),p);
2977  gnSliceHitday_zoom->SetTitle(title);
2978  gnSliceHitday_zoom->SetMarkerColor(kBlue);
2979  gnSliceHitday_zoom->GetXaxis()->SetTimeDisplay(1);
2980  gnSliceHitday_zoom->GetXaxis()->SetLabelSize(0.03);
2981  gnSliceHitday_zoom->GetXaxis()->SetTimeFormat(taxis_labels.c_str());
2982  gnSliceHitday_zoom->GetXaxis()->SetLimits(time_ago,XNow);
2983  gnSliceHitday_zoom->GetXaxis()->SetTitle("(central time)");
2984  gnSliceHitday_zoom->GetYaxis()->SetRangeUser((gnSliceHitday_zoom->GetMean(2)-3.*gnSliceHitday_zoom->GetRMS(2)),(gnSliceHitday_zoom->GetMean(2)+3.*gnSliceHitday_zoom->GetRMS(2)));
2985  gnSliceHitday_zoom->Draw("A*");
2986  UpdateText->Draw();
2987  LastPoint->Draw();
2988  sprintf(filename,"%s/%s-%s-P%.1unSliceHitperSRzoom%s.png",PLOT_DIR.c_str(),det.c_str(),trig.c_str(),p,period.c_str());
2989  ctnSliceHitday_zoom->Print(filename);
2990  delete ctnSliceHitday_zoom;
2991  ctnSliceHitday_zoom = 0;
2992 
2993  maxtime = 0;
2994  max = 0.0;
2995  ave = 0.0;
2996  for(int i = 0; i < NNoiseSliceHitDayCount[p]; ++i) {
2997  ave += (double)NNoiseSliceHitDay[p][i];
2998  if(NNoiseSliceHittimeDay[p][i] > maxtime) {
2999  maxtime = NNoiseSliceHittimeDay[p][i];
3000  max = NNoiseSliceHitDay[p][i];
3001  }
3002  }
3003  if(NNoiseSliceHitDayCount[p] > 0) ave = ave/(double)NNoiseSliceHitDayCount[p];
3004  sprintf(lptext,"Last Point = %f / Average = %f",max,ave);
3005  LastPoint->Clear();
3006  LastPoint->AddText(lptext);
3007  TCanvas *ctNNoiseSliceHitday = new TCanvas("cNNoiseSliceHitday","# Noise Slice Hits day",1200,800);
3008  ctNNoiseSliceHitday->cd();
3009  gPad->SetGridx();
3010  TGraph *gNNoiseSliceHitday = new TGraph(NNoiseSliceHitDayCount[p],NNoiseSliceHittimeDay[p],NNoiseSliceHitDay[p]);
3011  sprintf(title,"%s Number of Noise Slice Hits per Subrun - partition %.1u",trigname.c_str(),p);
3012  gNNoiseSliceHitday->SetTitle(title);
3013  gNNoiseSliceHitday->SetMarkerColor(kBlue);
3014  gNNoiseSliceHitday->GetXaxis()->SetTimeDisplay(1);
3015  gNNoiseSliceHitday->GetXaxis()->SetLabelSize(0.03);
3016  gNNoiseSliceHitday->GetXaxis()->SetTimeFormat(taxis_labels.c_str());
3017  gNNoiseSliceHitday->GetXaxis()->SetLimits(time_ago,XNow);
3018  gNNoiseSliceHitday->GetXaxis()->SetTitle("(central time)");
3019  gNNoiseSliceHitday->Draw("A*");
3020  UpdateText->Draw();
3021  LastPoint->Draw();
3022  sprintf(filename,"%s/%s-%s-P%.1uNNoiseSliceHitperSR%s.png",PLOT_DIR.c_str(),det.c_str(),trig.c_str(),p,period.c_str());
3023  ctNNoiseSliceHitday->Print(filename);
3024  delete ctNNoiseSliceHitday;
3025  ctNNoiseSliceHitday = 0;
3026 
3027  // Adding "zoomed in" version of the above plot
3028  TCanvas *ctNNoiseSliceHitday_zoom = new TCanvas("cNNoiseSliceHitday_zoom","# Noise Slice Hits day",1200,800);
3029  ctNNoiseSliceHitday_zoom->cd();
3030  gPad->SetGridx();
3031  TGraph *gNNoiseSliceHitday_zoom = new TGraph(NNoiseSliceHitDayCount[p],NNoiseSliceHittimeDay[p],NNoiseSliceHitDay[p]);
3032  sprintf(title,"%s Number of Noise Slice Hits per Subrun - partition %.1u",trigname.c_str(),p);
3033  gNNoiseSliceHitday_zoom->SetTitle(title);
3034  gNNoiseSliceHitday_zoom->SetMarkerColor(kBlue);
3035  gNNoiseSliceHitday_zoom->GetXaxis()->SetTimeDisplay(1);
3036  gNNoiseSliceHitday_zoom->GetXaxis()->SetLabelSize(0.03);
3037  gNNoiseSliceHitday_zoom->GetXaxis()->SetTimeFormat(taxis_labels.c_str());
3038  gNNoiseSliceHitday_zoom->GetXaxis()->SetLimits(time_ago,XNow);
3039  gNNoiseSliceHitday_zoom->GetXaxis()->SetTitle("(central time)");
3040  gNNoiseSliceHitday_zoom->GetYaxis()->SetRangeUser((gNNoiseSliceHitday_zoom->GetMean(2)-3.*gNNoiseSliceHitday_zoom->GetRMS(2)),(gNNoiseSliceHitday_zoom->GetMean(2)+3.*gNNoiseSliceHitday_zoom->GetRMS(2)));
3041  gNNoiseSliceHitday_zoom->Draw("A*");
3042  UpdateText->Draw();
3043  LastPoint->Draw();
3044  sprintf(filename,"%s/%s-%s-P%.1uNNoiseSliceHitperSRzoom%s.png",PLOT_DIR.c_str(),det.c_str(),trig.c_str(),p,period.c_str());
3045  ctNNoiseSliceHitday_zoom->Print(filename);
3046  delete ctNNoiseSliceHitday_zoom;
3047  ctNNoiseSliceHitday_zoom = 0;
3048 
3049  maxtime = 0;
3050  max = 0.0;
3051  ave = 0.0;
3052  for(int i = 0; i < NTsdDayCount[p]; ++i) {
3053  ave += (double)NTsdDay[p][i];
3054  if(NTsdtimeDay[p][i] > maxtime) {
3055  maxtime = NTsdtimeDay[p][i];
3056  max = NTsdDay[p][i];
3057  }
3058  }
3059  if(NTsdDayCount[p] > 0) ave = ave/(double)NTsdDayCount[p];
3060  sprintf(lptext,"Last Point = %f / Average = %f",max,ave);
3061  LastPoint->Clear();
3062  LastPoint->AddText(lptext);
3063  TCanvas *ctTsdday = new TCanvas("cTsdday","Slice Time Duration Standard Dev. day",1200,800);
3064  ctTsdday->cd();
3065  gPad->SetGridx();
3066  TGraph *gTsdday = new TGraph(NTsdDayCount[p],NTsdtimeDay[p],NTsdDay[p]);
3067  sprintf(title,"%s Slice Time Duration Standard Dev. by Subrun - partition %.1u",trigname.c_str(),p);
3068  gTsdday->SetTitle(title);
3069  gTsdday->SetMarkerColor(kBlue);
3070  gTsdday->GetXaxis()->SetTimeDisplay(1);
3071  gTsdday->GetXaxis()->SetLabelSize(0.03);
3072  gTsdday->GetXaxis()->SetTimeFormat(taxis_labels.c_str());
3073  gTsdday->GetXaxis()->SetLimits(time_ago,XNow);
3074  gTsdday->GetXaxis()->SetTitle("(central time)");
3075  gTsdday->Draw("A*");
3076  UpdateText->Draw();
3077  LastPoint->Draw();
3078  sprintf(filename,"%s/%s-%s-P%.1uTsdperSR%s.png",PLOT_DIR.c_str(),det.c_str(),trig.c_str(),p,period.c_str());
3079  ctTsdday->Print(filename);
3080  delete ctTsdday;
3081  ctTsdday = 0;
3082 
3083  // Adding "zoomed in" version of the above plot
3084  TCanvas *ctTsdday_zoom = new TCanvas("cTsdday_zoom","Slice Time Duration Standard Dev. day",1200,800);
3085  ctTsdday_zoom->cd();
3086  gPad->SetGridx();
3087  TGraph *gTsdday_zoom = new TGraph(NTsdDayCount[p],NTsdtimeDay[p],NTsdDay[p]);
3088  sprintf(title,"%s Slice Time Duration Standard Dev. by Subrun - partition %.1u",trigname.c_str(),p);
3089  gTsdday_zoom->SetTitle(title);
3090  gTsdday_zoom->SetMarkerColor(kBlue);
3091  gTsdday_zoom->GetXaxis()->SetTimeDisplay(1);
3092  gTsdday_zoom->GetXaxis()->SetLabelSize(0.03);
3093  gTsdday_zoom->GetXaxis()->SetTimeFormat(taxis_labels.c_str());
3094  gTsdday_zoom->GetXaxis()->SetLimits(time_ago,XNow);
3095  gTsdday_zoom->GetXaxis()->SetTitle("(central time)");
3096  gTsdday_zoom->GetYaxis()->SetRangeUser((gTsdday_zoom->GetMean(2)-3.*gTsdday_zoom->GetRMS(2)),(gTsdday_zoom->GetMean(2)+3.*gTsdday_zoom->GetRMS(2)));
3097  gTsdday_zoom->Draw("A*");
3098  UpdateText->Draw();
3099  LastPoint->Draw();
3100  sprintf(filename,"%s/%s-%s-P%.1uTsdperSRzoom%s.png",PLOT_DIR.c_str(),det.c_str(),trig.c_str(),p,period.c_str());
3101  ctTsdday_zoom->Print(filename);
3102  delete ctTsdday_zoom;
3103  ctTsdday_zoom = 0;
3104 
3105 
3106  maxtime = 0;
3107  max = 0.0;
3108  ave = 0.0;
3109  for(int i = 0; i < NTrackDayCount[p]; ++i) {
3110  ave += (double)NTrackDay[p][i];
3111  if(NTracktimeDay[p][i] > maxtime) {
3112  maxtime = NTracktimeDay[p][i];
3113  max = NTrackDay[p][i];
3114  }
3115  }
3116  if(NTrackDayCount[p] > 0) ave = ave/(double)NTrackDayCount[p];
3117  sprintf(lptext,"Last Point = %f / Average = %f",max,ave);
3118  LastPoint->Clear();
3119  LastPoint->AddText(lptext);
3120  TCanvas *ctnTrackday = new TCanvas("cnTrackday","# 3D Tracks day",1200,800);
3121  ctnTrackday->cd();
3122  gPad->SetGridx();
3123  TGraph *gnTrackday = new TGraph(NTrackDayCount[p],NTracktimeDay[p],NTrackDay[p]);
3124  sprintf(title,"%s # Tracks by Subrun - partition %.1u",trigname.c_str(),p);
3125  gnTrackday->SetTitle(title);
3126  gnTrackday->SetMarkerColor(kBlue);
3127  gnTrackday->GetXaxis()->SetTimeDisplay(1);
3128  gnTrackday->GetXaxis()->SetLabelSize(0.03);
3129  gnTrackday->GetXaxis()->SetTimeFormat(taxis_labels.c_str());
3130  gnTrackday->GetXaxis()->SetLimits(time_ago,XNow);
3131  gnTrackday->GetXaxis()->SetTitle("(central time)");
3132  gnTrackday->Draw("A*");
3133  UpdateText->Draw();
3134  LastPoint->Draw();
3135  sprintf(filename,"%s/%s-%s-P%.1unTrackAll3DperSR%s.png",PLOT_DIR.c_str(),det.c_str(),trig.c_str(),p,period.c_str());
3136  ctnTrackday->Print(filename);
3137  delete ctnTrackday;
3138  ctnTrackday = 0;
3139 
3140  // Adding "zoomed in" version of the above plot
3141  TCanvas *ctnTrackday_zoom = new TCanvas("cnTrackday_zoom","# 3D Tracks day",1200,800);
3142  ctnTrackday_zoom->cd();
3143  gPad->SetGridx();
3144  TGraph *gnTrackday_zoom = new TGraph(NTrackDayCount[p],NTracktimeDay[p],NTrackDay[p]);
3145  sprintf(title,"%s # Tracks by Subrun - partition %.1u",trigname.c_str(),p);
3146  gnTrackday_zoom->SetTitle(title);
3147  gnTrackday_zoom->SetMarkerColor(kBlue);
3148  gnTrackday_zoom->GetXaxis()->SetTimeDisplay(1);
3149  gnTrackday_zoom->GetXaxis()->SetLabelSize(0.03);
3150  gnTrackday_zoom->GetXaxis()->SetTimeFormat(taxis_labels.c_str());
3151  gnTrackday_zoom->GetXaxis()->SetLimits(time_ago,XNow);
3152  gnTrackday_zoom->GetXaxis()->SetTitle("(central time)");
3153  gnTrackday_zoom->GetYaxis()->SetRangeUser((gnTrackday_zoom->GetMean(2)-3.*gnTrackday_zoom->GetRMS(2)),(gnTrackday_zoom->GetMean(2)+3.*gnTrackday_zoom->GetRMS(2)));
3154  gnTrackday_zoom->Draw("A*");
3155  UpdateText->Draw();
3156  LastPoint->Draw();
3157  sprintf(filename,"%s/%s-%s-P%.1unTrackAll3DperSRzoom%s.png",PLOT_DIR.c_str(),det.c_str(),trig.c_str(),p,period.c_str());
3158  ctnTrackday_zoom->Print(filename);
3159  delete ctnTrackday_zoom;
3160  ctnTrackday_zoom = 0;
3161 
3162  maxtime = 0;
3163  max = 0.0;
3164  ave = 0.0;
3165  for(int i = 0; i < NTrackLenDayCount[p]; ++i) {
3166  ave += (double)NTrackLenDay[p][i];
3167  if(NTrackLentimeDay[p][i] > maxtime) {
3168  maxtime = NTrackLentimeDay[p][i];
3169  max = NTrackLenDay[p][i];
3170  }
3171  }
3172  if(NTrackLenDayCount[p] > 0) ave = ave/(double)NTrackLenDayCount[p];
3173  sprintf(lptext,"Last Point = %f / Average = %f",max,ave);
3174  LastPoint->Clear();
3175  LastPoint->AddText(lptext);
3176  TCanvas *ctTrackLenday = new TCanvas("cTrackLenday","3D Track Len day",1200,800);
3177  ctTrackLenday->cd();
3178  gPad->SetGridx();
3179  TGraph *gTrackLenday = new TGraph(NTrackLenDayCount[p],NTrackLentimeDay[p],NTrackLenDay[p]);
3180  sprintf(title,"%s Ave. Track Length by Subrun - partition %.1u",trigname.c_str(),p);
3181  gTrackLenday->SetTitle(title);
3182  gTrackLenday->SetMarkerColor(kBlue);
3183  gTrackLenday->GetXaxis()->SetTimeDisplay(1);
3184  gTrackLenday->GetXaxis()->SetLabelSize(0.03);
3185  gTrackLenday->GetXaxis()->SetTimeFormat(taxis_labels.c_str());
3186  gTrackLenday->GetXaxis()->SetLimits(time_ago,XNow);
3187  gTrackLenday->GetXaxis()->SetTitle("(central time)");
3188  gTrackLenday->Draw("A*");
3189  UpdateText->Draw();
3190  LastPoint->Draw();
3191  sprintf(filename,"%s/%s-%s-P%.1uTrackLenAll3DperSR%s.png",PLOT_DIR.c_str(),det.c_str(),trig.c_str(),p,period.c_str());
3192  ctTrackLenday->Print(filename);
3193  delete ctTrackLenday;
3194  ctTrackLenday = 0;
3195 
3196  // New "zoomed-in" version of TrackLenday above...
3197  TCanvas *ctTrackLenday_zoom = new TCanvas("cTrackLenday_zoom","3D Track Len day",1200,800);
3198  ctTrackLenday_zoom->cd();
3199  gPad->SetGridx();
3200  TGraph *gTrackLenday_zoom = new TGraph(NTrackLenDayCount[p],NTrackLentimeDay[p],NTrackLenDay[p]);
3201  sprintf(title,"%s Ave. Track Length by Subrun - partition %.1u",trigname.c_str(),p);
3202  gTrackLenday_zoom->SetTitle(title);
3203  gTrackLenday_zoom->SetMarkerColor(kBlue);
3204  gTrackLenday_zoom->GetXaxis()->SetTimeDisplay(1);
3205  gTrackLenday_zoom->GetXaxis()->SetLabelSize(0.03);
3206  gTrackLenday_zoom->GetXaxis()->SetTimeFormat(taxis_labels.c_str());
3207  gTrackLenday_zoom->GetXaxis()->SetLimits(time_ago,XNow);
3208  gTrackLenday_zoom->GetXaxis()->SetTitle("(central time)");
3209  gTrackLenday_zoom->GetYaxis()->SetRangeUser((gTrackLenday_zoom->GetMean(2)-3.*gTrackLenday_zoom->GetRMS(2)),(gTrackLenday_zoom->GetMean(2)+3.*gTrackLenday_zoom->GetRMS(2)));
3210  gTrackLenday_zoom->Draw("A*");
3211  UpdateText->Draw();
3212  LastPoint->Draw();
3213  sprintf(filename,"%s/%s-%s-P%.1uTrackLenAll3DperSRzoom%s.png",PLOT_DIR.c_str(),det.c_str(),trig.c_str(),p,period.c_str());
3214  ctTrackLenday_zoom->Print(filename);
3215  delete ctTrackLenday_zoom;
3216  ctTrackLenday_zoom = 0;
3217 
3218  // NEW PLOTS
3219  // Comment by Hayes: Am now able to draw the three graphs on the same pad and canvas (via a TMultiGraph), but cannot convert
3220  // the time on the xaxis to the readable Hour Minute format. Tried using the same commands on the multigraph as are used
3221  // for each graph and it seg faults every time...
3222  TCanvas *cTrackFracday = new TCanvas("cTrackFracday","Track Fractions day",1200,800);
3223  TPad *pad1 = new TPad("pad1","",0,0,1,1);
3224  TPad *pad2 = new TPad("pad2","",0,0,1,1);
3225  pad2->SetFillStyle(4000); // pad2 will be transparent
3226  pad2->SetFillColor(0);
3227  pad2->SetFrameFillStyle(4000);
3228  pad1->Draw();
3229  pad1->cd();
3230  pad1->SetGridx();
3231  TMultiGraph *gTF = new TMultiGraph;
3232  TGraph *gTFAll3Dday = new TGraph(TrackFracDayCount[p],TrackFracAll3DtimeDay[p],TrackFracAll3DDay[p]);
3233  TGraph *gTFAll2Dday = new TGraph(TrackFracDayCount[p],TrackFracAll2DtimeDay[p],TrackFracAll2DDay[p]);
3234  TGraph *gTFCont3Dday = new TGraph(TrackFracDayCount[p],TrackFracCont3DtimeDay[p],TrackFracCont3DDay[p]);
3235  sprintf(title,"%s Track Fractions - partition %.1u",trigname.c_str(),p);
3236 
3237  pad1->SetLogy();
3238 
3239 
3240  gTFAll2Dday->SetTitle(title);
3241  gTFAll2Dday->SetMarkerColor(kBlue-7);
3242  gTFAll2Dday->SetFillColor(kBlue-7);
3243  if(det == "NearDet" || det == "TestBeam")
3244  gTFAll2Dday->SetMarkerStyle(21);
3245  else
3246  gTFAll2Dday->SetMarkerStyle(7);
3247 
3248  gTFCont3Dday->SetTitle(title);
3249  gTFCont3Dday->SetMarkerColor(kGray+3);
3250  gTFCont3Dday->SetFillColor(kGray+3);
3251  if(det == "NearDet" || det == "TestBeam")
3252  gTFCont3Dday->SetMarkerStyle(21);
3253  else
3254  gTFCont3Dday->SetMarkerStyle(7);
3255 
3256  //gTF->Add(gTFAll3Dday);
3257  gTF->Add(gTFAll2Dday);
3258  gTF->Add(gTFCont3Dday);
3259  gTF->Draw("ap");
3260 
3261  gTF->SetTitle(title);
3262  //cTrackFracday->Modified();
3263  //cTrackFracday->Update();
3264  pad1->Modified();
3265  pad1->Update();
3266 
3267  UpdateText->Draw();
3268 
3269  //gTF->SetTitle(title);
3270  gTF->GetXaxis()->SetRangeUser(0.0,1.1);
3271  gTF->GetXaxis()->SetTimeDisplay(1);
3272  gTF->GetXaxis()->SetLabelSize(0.03);
3273  gTF->GetXaxis()->SetTimeFormat(taxis_labels.c_str());
3274  gTF->GetXaxis()->SetLimits(time_ago,XNow);
3275  gTF->GetXaxis()->SetTitle("(central time)");
3276  gTF->GetYaxis()->SetRangeUser(0.001,1.0);
3277 
3278  //cTrackFracday->cd();
3279 
3280  pad2->Draw();
3281  pad2->cd();
3282  pad2->SetGridx();
3283  gTFAll3Dday->SetTitle("");
3284  gTFAll3Dday->SetMarkerColor(kMagenta-7);
3285  gTFAll3Dday->SetFillColor(kMagenta-7);
3286  if(det == "NearDet" || det == "TestBeam")
3287  gTFAll3Dday->SetMarkerStyle(21);
3288  else
3289  gTFAll3Dday->SetMarkerStyle(7);
3290  gTFAll3Dday->GetXaxis()->SetRangeUser(0.0,1.1);
3291  gTFAll3Dday->GetXaxis()->SetTimeDisplay(1);
3292  gTFAll3Dday->GetXaxis()->SetLabelSize(0.03);
3293  gTFAll3Dday->GetXaxis()->SetTimeFormat(taxis_labels.c_str());
3294  gTFAll3Dday->GetXaxis()->SetLimits(time_ago,XNow);
3295  gTFAll3Dday->GetXaxis()->SetTitle("(central time)");
3296  gTFAll3Dday->GetYaxis()->SetLabelColor(kMagenta-7);
3297  gTFAll3Dday->GetYaxis()->SetLabelSize(0.026);
3298  //gTFAll3Dday->GetYaxis()->SetRangeUser(0.97,1.00);
3299  gTFAll3Dday->Draw("apY+");
3300  pad2->Modified();
3301  pad2->Update();
3302 
3303  // Define legend
3304  TLegend *leg = new TLegend(0.60,0.66,0.85,0.78);
3305  leg->SetFillColor(0);
3306  leg->AddEntry(gTFAll2Dday,"#bf{All 2D Tracks}","f");
3307  leg->AddEntry(gTFCont3Dday,"#bf{Contained 3D Tracks}","f");
3308  leg->AddEntry(gTFAll3Dday,"#bf{All 3D Tracks}","f");
3309  leg->SetFillStyle(4000);
3310  leg->SetLineColor(0);
3311 
3312  leg->Draw();
3313 
3314  sprintf(filename,"%s/%s-%s-P%.1uTrackFractionsperSR%s.png",PLOT_DIR.c_str(),det.c_str(),trig.c_str(),p,period.c_str());
3315  cTrackFracday->Print(filename);
3316  delete cTrackFracday;
3317  cTrackFracday = 0;
3318 
3319 
3320  // Now start making efficiency plots using hitsVwcell and cellsVwcell
3321  eff_plots(p, det, period, trig, trigname);
3322 
3323  UpdateText->Clear();
3324 
3325  } // end loop over partitions
3326 
3327  return 0;
3328 
3329 } // End script.
UInt_t LastSR
Definition: AnaPlotMaker.h:50
enum BeamMode kRed
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
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
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:21
static float min(const float a, const float b, const float c)
Definition: absgeo.cxx:45
Int_t GMToffset
Definition: AnaPlotMaker.h:43
double livetime
Definition: saveFDMCHists.C:21
Definition: structs.h:12
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
enum BeamMode kBlue
float E
Definition: structs.h:18
TPad * pad1
Definition: analysis.C:13
TH2F * hCellsVwcellDay[Npar]
Definition: AnaPlotMaker.h:71
static constexpr Double_t year
Definition: Munits.h:185
void eff_plots ( unsigned int  par_eff,
string  det,
string  period,
string  trig,
string  trigname 
)

Definition at line 3332 of file AnaPlotMaker.C.

References demo5::c1, demo5::c2, chisquared::c3, chisquared::c4, getBrightness::cell, nd_projection_maker::eff, allTimeWatchdog::endl, copy_new_pkl_files::f_name, GMToffset, hCellsVwcellDay, hHitsVwcellDay, Last_Run, Last_SR, new_module::module, getGoodRuns4SAM::n, NDAPDHVSetting::plane, PLOT_DIR, std::sqrt(), UpdateText, PandAna.Demos.tute_pid_validation::var, POTSpillRate::view, and w.

Referenced by AnaPlotMaker().

3332  {
3333 
3334 
3335  // Output file list of low efficiency modules.
3336  ofstream modules;
3337 
3338  int ncellbins_local = 344065;
3339  double cellmin_local = -0.5;
3340  double cellmax_local = 344064.5;
3341  int nwbins_local = 32;
3342  double wmin_local = -800;
3343  double wmax_local = 800;
3344 
3345  double wavglength = 200.0; // low w length to average cell/module efficiencies over
3346  int wbinlow = 1;
3347  int wbinhigh = 5;
3348 
3349  char f_name[56];
3350  char hmod_name[56];
3351 
3352  // Defing binning for histograms that will be made here
3353  int neffbins = 101;
3354  double effmin = -0.05;
3355  double effmax = 1.05;
3356  int nplbins = 897;
3357  double plmin = -0.5;
3358  double plmax = nplbins-0.5;
3359  int nmodbins = 12;
3360  double modmin = 0;
3361  double modmax = 12;
3362 
3363 // TH1F* mod_Eff[12];
3364 // for(int imod=0;imod<12;imod++){
3365 // sprintf(hmod_name,"mod%ieffperplane",imod);
3366 // mod_Eff[imod] = new TH1F(hmod_name,hmod_name,nplbins,0,nplbins);
3367 // }
3368 
3369  TH2F* moduleEfficiencyAverage = new TH2F("moduleEfficiencyAverage",";Plane;Module",
3370  nplbins,plmin,plmax,nmodbins,modmin,modmax);
3371  TH2F* moduleEfficiencyRMS = new TH2F("moduleEfficiencyRMS",";Plane;Module",
3372  nplbins,plmin,plmax,nmodbins,modmin,modmax);
3373  TH2F* moduleEfficiencyAverageXView = new TH2F("moduleEfficiencyAverageXView",";Plane;Module",
3374  nplbins,plmin,plmax,nmodbins,modmin,modmax);
3375  TH2F* moduleEfficiencyRMSXView = new TH2F("moduleEfficiencyRMSXView",";Plane;Module",
3376  nplbins,plmin,plmax,nmodbins,modmin,modmax);
3377 
3378  TH2F* moduleEfficiencyAverageYView = new TH2F("moduleEfficiencyAverageYView",";Plane;Module",
3379  nplbins,plmin,plmax,nmodbins,modmin,modmax);
3380  TH2F* moduleEfficiencyRMSYView = new TH2F("moduleEfficiencyRMSYView",";Plane;Module",
3381  nplbins,plmin,plmax,nmodbins,modmin,modmax);
3382 
3383  // Histogram of efficiency for a module
3384  TH1F* modeff = new TH1F("modeff",";Efficiency;NCells",neffbins,effmin,effmax);
3385 
3386  // Histogram of efficiency vs w for one cell
3387  TH1F* eff = new TH1F("eff","",nwbins_local,wmin_local,wmax_local);
3388 
3389  int currmodule = 0;
3390  int currplane = 0;
3391  int currview = 0; // View convention y = 0, x = 1
3392 
3393  // loop over every cell in each partition
3394  if(par_eff==1 && period=="Month"){
3395  char lowEffFile[150];
3396  sprintf(lowEffFile, "%s/low_eff_modules.txt", PLOT_DIR.c_str());
3397  modules.open(lowEffFile);
3398  modules<<"Partition "<<par_eff<<std::endl;
3399  modules<<std::endl;
3400  }
3401  for(int icell = 1; icell <= ncellbins_local; ++icell){
3402 
3403  // convert this to a plane and cell number
3404  int cell = (icell-1)%384;
3405  int plane = (icell-1-cell)/384;
3406  int modcell = cell%32;
3407  int module = (cell-modcell)/32;
3408  int view = plane%2; // view = 0 y, view = 1 x
3409 
3410  if(plane != currplane || module != currmodule){
3411  // fill in the histogram of average efficiency and rms of average for the last module
3412  double effavg = modeff->GetMean();
3413  double effrms = modeff->GetRMS();
3414  //double effavg_far = modeff_far->GetMean();
3415  int planebin = moduleEfficiencyAverage->GetXaxis()->FindFixBin(currplane);
3416  int modulebin = moduleEfficiencyAverage->GetYaxis()->FindFixBin((double)currmodule + 0.5);
3417 
3418  if(par_eff==1 && period=="Month"){
3419  if(effavg<0.3){
3420  modules<<"module: "<<modulebin<<" plane: "<<planebin<<" efficiency: "<<effavg<<std::endl;
3421  }
3422  }
3423  //mod_Eff[modulebin-1]->Fill(planebin,effavg);
3424  moduleEfficiencyAverage->SetBinContent(planebin,modulebin,effavg);
3425  moduleEfficiencyRMS->SetBinContent(planebin,modulebin,effrms);
3426  if(currview){
3427  // x view
3428  moduleEfficiencyAverageXView->SetBinContent(planebin,modulebin,effavg);
3429  moduleEfficiencyRMSXView->SetBinContent(planebin,modulebin,effrms);
3430  }
3431  else{
3432  // y view
3433  moduleEfficiencyAverageYView->SetBinContent(planebin,modulebin,effavg);
3434  moduleEfficiencyRMSYView->SetBinContent(planebin,modulebin,effrms);
3435  }
3436  // reset things for the new module
3437  modeff->Reset("ICES");
3438  currmodule = module;
3439  currplane = plane;
3440  currview = view;
3441  }
3442 
3443 
3444  // need to switch the module in cell for x view
3445 
3446  if(view){ modcell = 31-modcell; }
3447 
3448  // loop over every w bin
3449  double totcell = 0.0;
3450  double tothit = 0.0;
3451 
3452  // Calculate the cell efficiency vs w
3453  for(int iw = 1; iw <= nwbins_local; ++iw){
3454  // get the efficiency at this cell/w, eff = k/n
3455  double k = hHitsVwcellDay[par_eff]->GetBinContent(icell,iw);
3456  double n = hCellsVwcellDay[par_eff]->GetBinContent(icell,iw);
3457 
3458  totcell+=n;
3459  tothit+=k;
3460  double ef = k/n;
3461  if(n == 0){ ef = 0; }
3462 
3463  // calculate the variance of this
3464  double var = (k+1)*(k+2)/((n+2)*(n+3)) - (k+1)*(k+1)/((n+2)*(n+2));
3465 
3466  double w = hHitsVwcellDay[par_eff]->GetYaxis()->GetBinCenter(iw);
3467 
3468  eff->SetBinContent(iw,ef);
3469  eff->SetBinError(iw,sqrt(var));
3470 
3471  }
3472 
3473 
3474  // Average over the last 200 cm of the cell
3475  double efftot = eff->Integral(wbinlow,wbinhigh);
3476  double navgbins = wbinhigh-wbinlow+1.0;
3477 
3478  modeff->Fill(efftot/navgbins);
3479 
3480  }
3481  if(par_eff==1 && period=="Month") modules.close();
3482 
3483  char title_buff[128];
3484 
3485  gStyle->SetTimeOffset(0);
3486  string t_title;
3487  if(period == "Day") t_title = "(past 24 hrs.)";
3488  if(period == "Week") t_title = "(past week)";
3489  if(period == "Month") t_title = "(past month)";
3490  if(period == "6Months") t_title = "(past 26 weeks)";
3491  if(period == "Month") t_title = "(past 52 weeks)";
3492 
3493  TDatime *Ttemp = new TDatime; // finish time
3494  int Xfin = Ttemp->Convert() - GMToffset;
3495  TDatime *Tfinish = new TDatime(Xfin); // finish time
3496  TPaveText *UpdateText = new TPaveText(0.1, 0.0, 0.5, 0.05, "NDC");
3497  UpdateText->SetLineColor(0);
3498  UpdateText->SetFillColor(0);
3499  UpdateText->SetBorderSize(1);
3500  UpdateText->SetMargin(0.0);
3501  UpdateText->SetTextAlign(11);
3502  char buff1[256];
3503  sprintf(buff1, "Last updated on: %s (central time)", Tfinish->AsString());
3504  UpdateText->AddText(buff1);
3505  char buff2[256];
3506  sprintf(buff2, "Last run / subrun: %d / %d", Last_Run[par_eff], Last_SR[par_eff]);
3507  UpdateText->AddText(buff2);
3508 
3509  TPaveText *StatusText = new TPaveText(0.1, 0.1, 0.9, 0.9, "NDC");
3510  StatusText->SetLineColor(1);
3511  StatusText->SetFillColor(0);
3512  StatusText->SetBorderSize(1);
3513  // StatusText->SetMargin(0.0);
3514  StatusText->AddText(buff1);
3515  StatusText->AddText(buff2);
3516 
3517  TCanvas* c1 = new TCanvas("c1","c1",1200,800);
3518  gStyle->SetOptStat(0);
3519  sprintf(title_buff,"Average Module Efficiency %s - partition %.1u",t_title.c_str(),par_eff);
3520  moduleEfficiencyAverage->SetTitle(title_buff);
3521  moduleEfficiencyAverage->Draw("colz");
3522  //moduleEfficiencyAverage->GetXaxis()->SetRangeUser(0.,300.);
3523  gPad->Update();
3524 // TPaveStats *stats1 = (TPaveStats*)moduleEfficiencyAverage->FindObject("stats");
3525 // stats1->SetX1NDC(0.65);
3526 // stats1->SetY1NDC(0.65);
3527 // stats1->SetX2NDC(0.90);
3528 // stats1->SetY2NDC(0.90);
3529  c1->Modified();
3530  c1->Update();
3531  UpdateText->Draw();
3532  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());
3533  c1->Print(f_name);
3534  delete c1;
3535  c1 = 0;
3536 
3537  //////////////////////////////////////////////////////////////////////
3538  // Creating list of low efficiency modules and corresponding planes.//
3539  //////////////////////////////////////////////////////////////////////
3540  /* TFile *test_out = new TFile("testout.root","RECREATE");
3541  modules.open("low_eff_modules.txt");
3542  //int Nbinsy = moduleEfficiencyAverage->GetNbinsY();
3543  //int Nbinsx = moduleEfficiencyAverage->GetNbinsX();
3544  if(det=="FarDet" && period=="Day"){
3545  for(int i=1;i<257;i++){
3546  for(int j=1;j<13;j++){
3547  //Int_t bin_num = moduleEfficiencyAverage->FindFixBin(double(i)+0.5,j);
3548  //Int_t bin_num = moduleEfficiencyAverage->GetBin(i+1,j+1);
3549  Double_t eff_mod = moduleEfficiencyAverage->GetBinContent(i,j);
3550  //std::cout<<bin_num<<" "<<eff_mod<<std::endl;
3551  //if(eff_mod<0.6){
3552  //modules<<" plane: "<<i<<" module: "<<j<<" efficiency: "<<eff_mod<<std::endl;
3553  modules << moduleEfficiencyAverage->GetBinContent(i,j)<<std::endl;
3554  //}
3555  }
3556  }
3557  }
3558  modules.close();
3559  test_out->cd();
3560  for(int ii=0;ii<12;ii++){
3561  mod_Eff[ii]->Write();
3562  }
3563  //moduleEfficiencyAverage->Write();
3564  //test_out->Close();
3565  */
3566 
3567  TCanvas* c2 = new TCanvas("c2","c2",1200,800);
3568  gStyle->SetOptStat(0);
3569  sprintf(title_buff,"%s Average Module Efficiency RMS %s - partition %.1u",trigname.c_str(),t_title.c_str(),par_eff);
3570  moduleEfficiencyRMS->SetTitle(title_buff);
3571  moduleEfficiencyRMS->Draw("colz");
3572  //moduleEfficiencyRMS->GetXaxis()->SetRangeUser(0.,300.);
3573  gPad->Update();
3574 // TPaveStats *stats2 = (TPaveStats*)moduleEfficiencyRMS->FindObject("stats");
3575 // stats2->SetX1NDC(0.65);
3576 // stats2->SetY1NDC(0.65);
3577 // stats2->SetX2NDC(0.90);
3578 // stats2->SetY2NDC(0.90);
3579  c2->Modified();
3580  c2->Update();
3581  UpdateText->Draw();
3582  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());
3583  c2->Print(f_name);
3584  delete c2;
3585  c2 = 0;
3586 
3587  TCanvas* c3 = new TCanvas("c3","c3",1200,800);
3588  gStyle->SetOptStat(0);
3589  sprintf(title_buff,"%s Average Module Efficiency In X-view %s - partition %.1u",trigname.c_str(),t_title.c_str(),par_eff);
3590  moduleEfficiencyAverageXView->SetTitle(title_buff);
3591  moduleEfficiencyAverageXView->Draw("colz");
3592  moduleEfficiencyAverageXView->RebinX(2);
3593  //moduleEfficiencyAverageXView->GetXaxis()->SetRangeUser(0.,300.);
3594  gPad->Update();
3595 // TPaveStats *stats3 = (TPaveStats*)moduleEfficiencyAverageXView->FindObject("stats");
3596 // stats3->SetX1NDC(0.65);
3597 // stats3->SetY1NDC(0.65);
3598 // stats3->SetX2NDC(0.90);
3599 // stats3->SetY2NDC(0.90);
3600  c3->Modified();
3601  c3->Update();
3602  UpdateText->Draw();
3603  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());
3604  c3->Print(f_name);
3605  delete c3;
3606  c3 = 0;
3607 
3608  TCanvas* c4 = new TCanvas("c4","c4",1200,800);
3609  gStyle->SetOptStat(0);
3610  sprintf(title_buff,"%s Average Module Efficiency In X-view RMS %s - partition %.1u",trigname.c_str(),t_title.c_str(),par_eff);
3611  moduleEfficiencyRMSXView->SetTitle(title_buff);
3612  moduleEfficiencyRMSXView->Draw("colz");
3613  moduleEfficiencyRMSXView->RebinX(2);
3614  //moduleEfficiencyRMSXView->GetXaxis()->SetRangeUser(0.,300.);
3615  gPad->Update();
3616 // TPaveStats *stats4 = (TPaveStats*)moduleEfficiencyRMSXView->FindObject("stats");
3617 // stats4->SetX1NDC(0.65);
3618 // stats4->SetY1NDC(0.65);
3619 // stats4->SetX2NDC(0.90);
3620 // stats4->SetY2NDC(0.90);
3621  c4->Modified();
3622  c4->Update();
3623  UpdateText->Draw();
3624  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());
3625  c4->Print(f_name);
3626  delete c4;
3627  c4 = 0;
3628 
3629  TCanvas* c5 = new TCanvas("c5","c5",1200,800);
3630  gStyle->SetOptStat(0);
3631  sprintf(title_buff,"%s Average Module Efficiency In Y-view %s - partition %.1u",trigname.c_str(),t_title.c_str(),par_eff);
3632  moduleEfficiencyAverageYView->SetTitle(title_buff);
3633  moduleEfficiencyAverageYView->Draw("colz");
3634  moduleEfficiencyAverageYView->RebinX(2);
3635  //moduleEfficiencyAverageYView->GetXaxis()->SetRangeUser(0.,300.);
3636  gPad->Update();
3637 // TPaveStats *stats5 = (TPaveStats*)moduleEfficiencyAverageYView->FindObject("stats");
3638 // stats5->SetX1NDC(0.65);
3639 // stats5->SetY1NDC(0.65);
3640 // stats5->SetX2NDC(0.90);
3641 // stats5->SetY2NDC(0.90);
3642  c5->Modified();
3643  c5->Update();
3644  UpdateText->Draw();
3645  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());
3646  c5->Print(f_name);
3647  delete c5;
3648  c5 = 0;
3649 
3650  TCanvas* c6 = new TCanvas("c6","c6",1200,800);
3651  gStyle->SetOptStat(0);
3652  sprintf(title_buff,"%s Average Module Efficiency In Y-view RMS %s - partition %.1u",trigname.c_str(),t_title.c_str(),par_eff);
3653  moduleEfficiencyRMSYView->SetTitle(title_buff);
3654  moduleEfficiencyRMSYView->Draw("colz");
3655  moduleEfficiencyRMSYView->RebinX(2);
3656  //moduleEfficiencyRMSYView->GetXaxis()->SetRangeUser(0.,300.);
3657  gPad->Update();
3658 // TPaveStats *stats6 = (TPaveStats*)moduleEfficiencyRMSYView->FindObject("stats");
3659 // stats6->SetX1NDC(0.65);
3660 // stats6->SetY1NDC(0.65);
3661 // stats6->SetX2NDC(0.90);
3662 // stats6->SetY2NDC(0.90);
3663  c6->Modified();
3664  c6->Update();
3665  UpdateText->Draw();
3666  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());
3667  c6->Print(f_name);
3668  delete c6;
3669  c6 = 0;
3670 
3671 }
TH2F * hHitsVwcellDay[Npar]
Definition: AnaPlotMaker.h:70
TPaveText * UpdateText
Definition: DCSPlotMaker.C:18
T sqrt(T number)
Definition: d0nt_math.hpp:156
UInt_t Last_SR[Npar]
Definition: AnaPlotMaker.h:54
c2
Definition: demo5.py:33
const std::string PLOT_DIR
Definition: AnaPlotMaker.C:8
UInt_t Last_Run[Npar]
Definition: AnaPlotMaker.h:53
Int_t GMToffset
Definition: AnaPlotMaker.h:43
c1
Definition: demo5.py:24
Float_t w
Definition: plot.C:20
TH2F * hCellsVwcellDay[Npar]
Definition: AnaPlotMaker.h:71

Variable Documentation

const std::string PLOT_DIR = "/nusoft/app/web/htdoc/nova/datacheck/nearline/plots"

Brief: Make DCM Sync Plots for ND Work Status:

  1. Add logic when dealing with empty instrumented histrogram
  2. Add booleans and other global variables (keyword: NUEVO)

Definition at line 8 of file AnaPlotMaker.C.

Referenced by AnaPlotMaker(), eff_plots(), and OnMonPlotMaker().