DCSPlotMaker.C
Go to the documentation of this file.
1 #include <TFile.h>
2 #include <TCanvas.h>
3 #include <TTree.h>
4 #include <TGraph.h>
5 #include <TDatime.h>
6 #include <TPaveText.h>
7 #include <TAxis.h>
8 #include <TGaxis.h>
9 #include <TStyle.h>
10 #include <TObject.h>
11 #include <TROOT.h>
12 
13 #include <algorithm>
14 #include <string>
15 #include <iostream>
16 
17 //TCanvas *c0 = new TCanvas("c0");
18 TPaveText *UpdateText = new TPaveText(0.1, 0.0, 0.5, 0.05, "NDC");
19 TPaveText *WarningText = new TPaveText(0.15, 0.15, 0.9, 0.3, "NDC");
20 int nwarnings = 0;
21 //Plots a single channel onto the canvas
22 void plot_with_zoom(TTree *t, char *branchname, int color, int marker, TCanvas *c1, char *title, float *ylimit,
23  float *zoom, UInt_t timeago, UInt_t XNow, int mode, char *saveme, int timeperiod)
24 {
25  //cout << "mode = " << mode << endl;
26  // Find timezone offset
27  TDatime now,nowlocal,tstart,tend;
28  now.Set(now.Convert(kTRUE));
29  nowlocal.Set(nowlocal.Convert(kFALSE));
30  int houroffset = now.GetHour()-nowlocal.GetHour();
31  if (houroffset < -12 ) houroffset+=24;
32  cout << "using houroffset " << houroffset << endl ;
33 
34  // Some lazy idiot got tired of scope problems amd moved the axes here. It all needs a rewrite anyway.
35  TGaxis *axis,*zoomaxis;
36 
37  //cout << " UTC offset is " << houroffset << endl ;
38  // The following constructor tries to open a file named "g", that's a problem. LMM
39  //TGraph *g = new TGraph("g");
40  // Try with empty arguments or wait until we have something to plot. LMM
41  TGraph *g = new TGraph();
42  //char canvasname[20];
43  //sprintf(canvasname,"c0_%s",branchname) ;
44  //if (gROOT->FindObject("c0"))
45  // TCanvas *c0 = (TCanvas*)gROOT->FindObject("c0");
46  // else
47  // TCanvas *c0 = new TCanvas("c0");
48  TCanvas *c0 = new TCanvas("c0","c0",1200,800);
49  //TCanvas *c0 = new TCanvas(canvasname);
50  cout << "Plotting with_zoom branchname = " << branchname << endl;
51  char drawme[50];
52  sprintf(drawme,"%s:Time_%s.Convert(kFALSE)-2*60*60*%d", branchname, branchname,houroffset);
53  //for wierd Time based root axis reasons the offset is subracted twice, because the axis is also converted.
54  //cout << "t->Draw(" << drawme << ");" << endl;
55  t->Draw(drawme);
56  if ( t->GetBranch(branchname) == 0 )
57  {
58  cout << "Branch " << branchname << " does not exist " << endl;
59  return;
60  }
61  int nentries = t->GetBranch(branchname)->GetEntries();
62  //cout << "Plotting " << nentries << " Entries " << endl;
63  double *v = t->GetV1();
64  //cout << "min,max = " << zoom[0] << ", " << zoom[1] << endl;
65  if(*(std::min_element(v, v+nentries)) < zoom[0]) zoom[0] = *(std::min_element(v, v+nentries));
66  if(*(std::max_element(v, v+nentries)) > zoom[1]) zoom[1] = *(std::max_element(v, v+nentries));
67  //cout << "min,max = " << zoom[0] << ", " << zoom[1] << endl;
68  double *times = t->GetV2();
69  g = new TGraph(nentries,times,v);
70  c1->cd();
71  if(color==10)color=95; //10 is white. Useless. Make it orange.
72  if(color==12)color=50; //12 is dark grey, too similar to black. Make it an ugly pink.
73  g->SetMarkerColor(color);
74  g->SetLineColor(color);
75  g->SetMarkerStyle(marker);
76 
77  if(mode==0 || mode==3) //If it's the first channel plotted on this canvas (mode 0) or the only channel (mode 3), we need axes and titles
78  {
79  //cout << "Drawing axes" << endl;
80  g->SetMinimum(ylimit[0]);
81  g->SetMaximum(ylimit[1]);
82  g->Draw("ALP");
83  g->SetTitle(title);
84  g->GetXaxis()->SetTimeDisplay(1);
85  g->GetXaxis()->SetTimeOffset(0,"gmt"); // make X axis think it is GMT
86  g->GetXaxis()->SetLabelSize(0.03);
87  // Adding information of hour and minute helped sort some confusing root date plotting issues.
88  //if(timeperiod == 0) g->GetXaxis()->SetTimeFormat("%m/%d %H:%M");//for day plots, use hour:minute
89  //else g->GetXaxis()->SetTimeFormat("%m/%d %H");//for week and month plots, use month/day
90  if(timeperiod == 0) g->GetXaxis()->SetTimeFormat("%H:%M");//for day plots, use hour:minute
91  else g->GetXaxis()->SetTimeFormat("%m/%d");//for week and month plots, use month/day
92  g->GetXaxis()->SetLimits(timeago-houroffset*60*60,XNow-houroffset*60*60); //Convert limits to a UTC time
93  g->GetYaxis()->SetTitleOffset(1.5);
94  //tstart.Set(timeago,kFALSE);
95  //tend.Set(XNow,kFALSE);
96  //cout << " creating axes from " << tstart.AsString() << endl;
97  //cout << " to " << tend.AsString() << endl ;
98  //cout << " From timeago=" << timeago << " to XNow=" << XNow << endl;
99 
100  }
101  else//Not first
102  {
103  g->Draw("same LP");
104  }
105  //There should be 1 entry per hour (i.e. 24 entries) but sometimes a reading is minutes (or even seconds) too early/too late so there are
106  //only 23 entries. Anyway, if there are fewer than that, we need a warning due to missing entries
107  //LMM Only worry about empty plots, goodNentries >0.
108  int goodNEntries = 0;
109  // Standard warning trigger
110  if(timeperiod == 0) goodNEntries = 23;
111  else if(timeperiod == 1) goodNEntries = 23*7;
112  else if(timeperiod == 2) goodNEntries = 23*7*30;
113  // LMM 20180813 warning trigger at least 2/day
114  if(timeperiod == 0) goodNEntries = 1;
115  else if(timeperiod == 1) goodNEntries = 1;
116  else if(timeperiod == 2) goodNEntries = 1;
117  if(nentries < goodNEntries && mode != 3)
118  {
119  WarningText->SetLineColor(0);
120  WarningText->SetFillColor(0);
121  WarningText->SetBorderSize(0);
122  WarningText->SetMargin(0.0);
123  WarningText->SetTextAlign(11);
124  WarningText->SetTextColor(color);
125  char buff1[256];
126  char buff2[10];
127  if(nwarnings==0){
128  sprintf(buff1, "Warning: check for missing entries in:");// %s", branchname);
129  WarningText->AddText(buff1);
130  }
131  nwarnings+=1;
132  sprintf(buff2, "%s", branchname);
133  WarningText->AddText(buff2);
134  //WarningText->Draw();
135  }
136 
137  if(mode==2 || mode==3)//If it's the last or only plot - save and clear
138  {
139  char savename[100];
140  UpdateText->Draw();
141  if(nwarnings>0) WarningText->Draw();
142  c1->Modified();
143  c1->Update();
144  if(timeperiod == 0) sprintf(savename,"%sDay.png", saveme);
145  if(timeperiod == 1) sprintf(savename,"%sWeek.png", saveme);
146  if(timeperiod == 2) sprintf(savename,"%sMonth.png", saveme);
147 
148  //TGraph *g1 = new TGraph("g1");
149  TGraph *g1 = new TGraph();
150  g1 = (TGraph*)gPad->GetPrimitive("Graph");
151  gPad->SetGridx(1);
152  char* newtitle = strrchr(title,';');
153  //If it's a temperature plot, we need an extra axis so that it can be plotted in terms of Farenheit and Celsius
154  if(title[strlen(title)-2] == 'C' || title[strlen(title)-2] == 'F')
155  //if(temperature)
156  {
157  //cout << "Temperature plot" << endl;
158  //char* newtitle = strrchr(title,';');
159  newtitle = newtitle+1;
160  //cout << newtitle << ", length = " << strlen(newtitle) << "--->";
161  //TGaxis *axis;
162  if(title[strlen(title)-2] == 'F')//Farenheit
163  {
164  axis = new TGaxis(gPad->GetUxmax(),gPad->GetUymin(),gPad->GetUxmax(),gPad->GetUymax(),(gPad->GetUymin()-32)/1.8,(gPad->GetUymax()-32)/1.8,510,"+L");
165  //cout << "making 2nd axis with " << gPad->GetUxmax() << " " << gPad->GetUymin() << " " << gPad->GetUxmax() << " "
166  //<< gPad->GetUymax() << " " << (gPad->GetUymin()-32)/1.8 << " " << (gPad->GetUymax()-32)/1.8 << endl ;
167  newtitle[strlen(newtitle)-2] = 'C';
168  }
169  else if(title[strlen(title)-2] == 'C')//Celcius
170  {
171  axis = new TGaxis(gPad->GetUxmax(),gPad->GetUymin(),gPad->GetUxmax(),gPad->GetUymax(),(gPad->GetUymin()*1.8)+32,(gPad->GetUymax()*1.8)+32,510,"+L");
172  //cout << "making 2nd axis with " << gPad->GetUxmax() << " " <<
173  //gPad->GetUymin() << " " << gPad->GetUxmax() << " " << gPad->GetUymax() << " "
174  //<< (gPad->GetUymin()*1.8)+32 << " " << (gPad->GetUymax()*1.8)+32 << endl;
175  newtitle[strlen(newtitle)-2] = 'F';
176  }
177  cout << newtitle << endl;
178  axis->SetTitle(newtitle);
179  axis->SetTitleSize(g->GetYaxis()->GetTitleSize());
180  axis->SetLabelSize(g->GetYaxis()->GetLabelSize());
181  axis->SetTitleFont(g->GetYaxis()->GetTitleFont());
182  axis->SetLabelFont(g->GetYaxis()->GetTitleFont());
183  axis->SetTitleOffset(1.5);
184  axis->Draw();
185  }
186 
187  c1->SaveAs(savename);
188  //cout << "nonzoom file: " << saveme << endl;
189 
190  //For zoomed plot
191  g1->SetMinimum(zoom[0] - (zoom[1]-zoom[0])*0.10);
192  g1->SetMaximum(zoom[1] + (zoom[1]-zoom[0])*0.10);
193 
194  //cout << "Min: " << g1->GetMinimum() << " Max: " << g1->GetMaximum() << endl;
195  //cout << "C Min: " << (g1->GetMinimum()-32)/1.8 << " C Max: " << (g1->GetMaximum()-32)/1.8 << endl;
196  //cout << "title " << title << endl;
197 
198  if(title[strlen(title)-2] == 'C' || title[strlen(title)-2] == 'F')
199  {
200  //cout << "Temperature plot" << endl;
201  axis->Delete(); // removes TGaxis from the unzoomed plot Why not just draw with new parameters? LMM
202  if(newtitle[strlen(newtitle)-2] == 'C')
203  zoomaxis = new TGaxis( gPad->GetUxmax(),g1->GetMinimum(),gPad->GetUxmax(),g1->GetMaximum(),(g1->GetMinimum()-32)/1.8,(g1->GetMaximum()-32)/1.8,510,"+L");
204  else if(newtitle[strlen(newtitle)-2] == 'F')
205  zoomaxis = new TGaxis( gPad->GetUxmax(),g1->GetMinimum(),gPad->GetUxmax(), g1->GetMaximum(),(g1->GetMinimum()*1.8)+32,(g1->GetMaximum()*1.8)+32,510,"+L");
206  zoomaxis->SetTitle(newtitle);
207  zoomaxis->SetTitleSize(g->GetYaxis()->GetTitleSize());
208  zoomaxis->SetLabelSize(g->GetYaxis()->GetLabelSize());
209  zoomaxis->SetTitleFont(g->GetYaxis()->GetTitleFont());
210  zoomaxis->SetLabelFont(g->GetYaxis()->GetLabelFont());
211  zoomaxis->Draw();
212  zoomaxis->SetTitleOffset(1.5);
213  }
214 
215  //cout << "modifying and updating canvas" << endl;
216  c1->Modified();
217  c1->Update();
218 
219  //cout << saveme << ":" << strlen(saveme);
220  // int pos = saveme.length();
221  //cout <<"changing name..." << endl;
222  if(timeperiod == 0) sprintf(savename,"%szoomDay.png", saveme);
223  else if(timeperiod == 1) sprintf(savename,"%szoomWeek.png", saveme);
224  else if(timeperiod == 2) sprintf(savename,"%szoomMonth.png", saveme);
225  //cout << "saving zoom..." << endl;
226  c1->SaveAs(savename);
227  //cout << "zoom file: " << saveme << endl;
228  c1->Clear();
229  zoom[0] = 99999;
230  zoom[1] =-99999;
231  nwarnings=0;
232  WarningText->Clear();
233  //cout << "all clear, start again" << endl;
234  //if(title[strlen(title)-2] == 'C' || title[strlen(title)-2] == 'F') zoomaxis->Delete();
235  }
236 }
237 
238 //Like plot_with_zoom, but calculates the strain from the 3 strain gauges
239 void plot_strain_with_zoom(TTree *t, char *branchname, int x, int y, int marker, TCanvas *c1, char *title, float *ylimit, float *zoom, int timeago, int XNow, int mode, char *saveme, int timeperiod)
240 {
241  //TGraph *g = new TGraph("g");
242  TDatime now,nowlocal;
243  now.Set(now.Convert(kTRUE));
244  nowlocal.Set(nowlocal.Convert(kFALSE));
245  int houroffset = now.GetHour()-nowlocal.GetHour();
246  if (houroffset < -12 ) houroffset+=24;
247  //cout << " UTC offset is " << houroffset << endl ;
248 
249  //char canvasname[20];
250  //sprintf(canvasname,"c0_%s",branchname) ;
251  //if (gROOT->FindObject("c0"))
252  // TCanvas *c0 = (TCanvas*)gROOT->FindObject("c0");
253  //else
254  // TCanvas *c0 = new TCanvas("c0");
255  TCanvas *c0 = new TCanvas("c0");
256  //TCanvas *c0 = new TCanvas(canvasname);
257  cout << "Plotting strain branchname = " << branchname << endl;
258  char drawme[50];
259 
260  sprintf(drawme,"%s1:Time_%s1.Convert(kFALSE)-60*60*%d", branchname, branchname,houroffset);
261  //cout << "t->Draw(" << drawme << ");" << endl;
262  t->Draw(drawme);
263  char realbranchname[20];
264  sprintf(realbranchname,"%s1",branchname);
265  int nentries = t->GetBranch(realbranchname)->GetEntries();
266  double *v1 = t->GetV1();
267  double *times = t->GetV2();
268 
269  sprintf(drawme,"%s2:Time_%s2.Convert(kFALSE)-60*60*%d", branchname, branchname,houroffset);
270  //cout << "t->Draw(" << drawme << ");" << endl;
271  t->Draw(drawme);
272  double *v2 = t->GetV1();
273 
274  sprintf(drawme,"%s3:Time_%s3.Convert(kFALSE)-60*60*%d", branchname, branchname,houroffset);
275  //cout << "t->Draw(" << drawme << ");" << endl;
276  t->Draw(drawme);
277  double *v3 = t->GetV1();
278 
279  for(int entry=0;entry<nentries;entry++)
280  {
281  v1[entry] = 0.5*(v1[entry]+v3[entry]) + (1/sqrt(2))*sqrt(pow(v1[entry]-v2[entry],2)+(pow(v2[entry]-v3[entry],2)));
282  //cout << "Strain in " << branchname << " = " << v1[entry];
283  if(v1[entry] < zoom[0]) zoom[0] = v1[entry];
284  if(v1[entry] > zoom[1]) zoom[1] = v1[entry];
285  //cout << "min, max: " << zoom[0] << ", " << zoom[1] << endl;
286  }
287 
288  TGraph *g = new TGraph(nentries, times, v1);
289 
290  c1->cd();
291  if(branchname[2] == 'N')
292  {
293  if(x==1)g->SetMarkerColor(kGreen+y-1);
294  if(x==2)g->SetMarkerColor(kRed+y-1);
295  if(x==3)g->SetMarkerColor(kGray+y-1);
296  if(x==4)g->SetMarkerColor(kCyan+y-1);
297  if(x==5)g->SetMarkerColor(kBlue+y-1);
298  if(x==6)g->SetMarkerColor(kMagenta+y-1);
299  }
300  else
301  {
302  if(y==1)g->SetMarkerColor(kRed+3*(x-1));
303  if(y==2)g->SetMarkerColor(kGreen+3*(x-1));
304  if(y==3)g->SetMarkerColor(kBlue+3*(x-1));
305  }
306  g->SetLineColor(g->GetMarkerColor());
307  g->SetMarkerStyle(marker);
308  //cout << "x,y,marker, marker size: " << x << "," << y << "," << marker << "," << g->GetMarkerSize() << endl;
309  if(mode==0)//x==1 && y==1 && marker == 20 && g->GetMarkerSize()==1)
310  {
311  //cout << "Drawing axes" << endl;
312  g->SetMinimum(ylimit[0]);
313  g->SetMaximum(ylimit[1]);
314  g->Draw("ALP");
315  g->SetTitle(title);
316  g->GetXaxis()->SetTimeDisplay(1);
317  g->GetXaxis()->SetLabelSize(0.03);
318  if(timeperiod == 0) g->GetXaxis()->SetTimeFormat("%H:%M");
319  else g->GetXaxis()->SetTimeFormat("%m/%d");
320  g->GetXaxis()->SetLimits(timeago,XNow);
321  g->GetYaxis()->SetTitleOffset(1.5);
322  }
323  else
324  {
325  g->Draw("same LP");
326  }
327 
328  if(mode==2)
329  {
330  char savename[100];
331  UpdateText->Draw();
332  c1->Modified();
333  c1->Update();
334  if(timeperiod == 0) sprintf(savename,"%sDay.png", saveme);
335  else if(timeperiod == 1) sprintf(savename,"%sWeek.png", saveme);
336  else if(timeperiod == 2) sprintf(savename,"%sMonth.png", saveme);
337 
338 
339  //TGraph *g1 = new TGraph("g1");
340  TGraph *g1 = new TGraph();
341  g1 = (TGraph*)gPad->GetPrimitive("Graph");
342 
343  c1->SaveAs(savename);
344  //cout << "nonzoom file: " << saveme << endl;
345 
346  //For zoomed plot
347  g1->SetMinimum(zoom[0] - (zoom[1]-zoom[0])*0.1);
348  g1->SetMaximum(zoom[1] + (zoom[1]-zoom[0])*0.1);
349 
350  //cout << "Min: " << g1->GetMinimum() << " Max: " << g1->GetMaximum() << endl;
351  c1->Modified();
352  c1->Update();
353 
354  //cout << saveme << ":" << strlen(saveme);
355  // int pos = saveme.length();
356  if(timeperiod == 0) sprintf(savename,"%szoomDay.png", saveme);
357  else if(timeperiod == 1) sprintf(savename,"%szoomWeek.png", saveme);
358  else if(timeperiod == 2) sprintf(savename,"%szoomMonth.png", saveme);
359  c1->SaveAs(savename);
360  //cout << "zoom file: " << saveme << endl;
361  c1->Clear();
362  zoom[0] = 99999;
363  zoom[1] =-99999;
364 
365  }
366 
367 }
368 
369 //Main function
370 // void DCSPlotMaker(int timeperiod, int detector)
371 void DCSPlotMaker(string timeperiodname, string detectorname)
372 {
373  int timeperiod = 0;
374  int detector = 0;
375 
376  if(timeperiodname.compare("day") == 0) {
377  timeperiod = 0;
378  std::cout << "Making day plots\n";
379  } else if(timeperiodname.compare("week") == 0) {
380  timeperiod = 1;
381  std::cout << "Making week plots\n";
382  } else if(timeperiodname.compare("month") == 0) {
383  timeperiod = 2;
384  std::cout << "Making month plots\n";
385  } else {
386  std::cout << "Macro should take input of 'day', 'week', or 'month'. \n"
387  << "You have input '" << timeperiodname
388  << "'\nSomething's wrong. Abort.";
389  return;
390  }
391 
392  if(detectorname.compare("ND") == 0) {
393  detector = 1;
394  std::cout << "Making plots for ND\n";
395  } else if(detectorname.compare("FD") == 0) {
396  detector = 2;
397  std::cout << "Making plots for FD\n";
398  } else {
399  std::cout << "Macro should take input of 1 for ND, 2 for FD"
400  << "You have input " << detector
401  << "... Something's wrong. Abort.";
402  return;
403  }
404 
405  gStyle->SetPalette(55);
406  gStyle->SetMarkerStyle(7);
407  gStyle->SetFillStyle(0);
408 
409  //TFile *f = new TFile("/nova/app/users/mcampbel/dcs_db/automated/temp_dcs_db_readout_multichan_day.root");
410  TFile *f;
411  if(detector == 1){
412  // if(timeperiod == 0) f = new TFile("dcs_db_readout_multichan_nd_day.root", "read");
413  if(timeperiod == 0) f = new TFile("trees/dcs_db_readout_multichan_day_ND.root", "read");
414  else if(timeperiod == 1) f = new TFile("trees/dcs_db_readout_multichan_week_ND.root", "read");
415  else if(timeperiod == 2) f = new TFile("trees/dcs_db_readout_multichan_month_ND.root", "read");
416  } else if(detector == 2) {
417  if(timeperiod == 0) f = new TFile("trees/dcs_db_readout_multichan_day_FD.root", "read");
418  else if(timeperiod == 1) f = new TFile("trees/dcs_db_readout_multichan_week_FD.root", "read");
419  else if(timeperiod == 2) f = new TFile("trees/dcs_db_readout_multichan_month_FD.root", "read");
420  }
421 
422  TTree *t = (TTree*)f->Get("dcs_db_tree");
423  TCanvas *c1 = new TCanvas("c1","c1",1200,800);
424  TCanvas *c2 = new TCanvas("c2","c2",1200,800);
425 
426  //TLegend *leg = new TLegend(0.9,0.1,1.0,0.9);
427 
428  char name[10];
429  char saveme[50];
430  char saveme2[50];
431  char title[100];
432  char title2[100];
433  char branchname[10];
434  char* filepath;
435  //If ND, call the plots NearDet-something
436  if(detector == 1) {
437  if(timeperiod == 0) filepath = "dayplots/NearDet-";
438  else if(timeperiod == 1) filepath = "weekplots/NearDet-";
439  else if(timeperiod == 2) filepath = "monthplots/NearDet-";
440  } else if(detector == 2){
441  //If FD, call them FarDet-something
442  if(timeperiod == 0) filepath = "dayplots/FarDet-";
443  else if(timeperiod == 1) filepath = "weekplots/FarDet-";
444  else if(timeperiod == 2) filepath = "monthplots/FarDet-";
445  }
446  //I don't know why, but there's a segmentation violation after the first plot any time I try to define a full filepath
447  //To get around this, the shell script directs the user to the correct directory and works from there
448  //then copies the contents of dayplots to /nusoft/app/web/htdoc/nova/datacheck/nearline/plots/
449  //Sorry for the hackiness...
450 
451  float ylimit[2];//For setting axis limits
452  float zoom[2] = {99999, -99999};//For setting axis limits for zoomed plots
453  float zoom2[2] = {99999, -99999};
454  int mode = 0;
455  int mode2 = 0;
456  t->UseCurrentStyle();
457 
458  //FOR X AXIS
459  //TDatime * TNowGMT = new TDatime;
460  //TNowGMT->Set();
461  //cout << TNowGMT->AsString() << endl;
462  TDatime *TNow = new TDatime;
463  TDatime tstart,tend;
464  TNow->Set(); // sets time o now
465  //cout << " Running at " << TNow->AsString() << endl;
466  TNow->Set(TNow->GetYear(),TNow->GetMonth(),TNow->GetDay(),TNow->GetHour()+1,0,0); //LMM added one hour
467  //cout << " Dropped Min/Sec? " << TNow->AsString() << endl; cout << " Running at " << TNow->AsString() << endl;
468  // unused ? TDatime *SRtime = new TDatime;
469  //int XNowGMT = TNowGMT->Convert(kTRUE);
470  UInt_t XNow = TNow->Convert(kFALSE); // Gets current time
471  //cout << XNowGMT << " " << XNow << endl;
472  //int GMToffset = XNowGMT - XNow;
473  //XNow = XNow - 30*60;//To make up for the time the python code takes to read the database
474 
475  //gStyle->SetTimeOffset(GMToffset);
476 
477  UInt_t timeago = 0;
478  if(timeperiod == 0) timeago = XNow - 60*60*24;
479  else if(timeperiod == 1) timeago = XNow - 60*60*24*7;
480  else if(timeperiod == 2) timeago = XNow - 60*60*24*30;
481 
482  //tstart.Set(timeago,kFALSE);
483  //cout << " Tstart " << tstart.AsString() << endl;
484  //tend.Set(XNow,kFALSE);
485  //cout << " Tend " << tend.AsString() << endl;
486  //cout << " will create axes from " << tstart.AsString() << endl ;
487  //cout << " to " << tend.AsString() << endl ;
488  //cout << " From timeago=" << timeago << " to XNow=" << XNow << endl;
489 
490  //FOR TIMESTAMP
491  TDatime *Tfinish = new TDatime;
492  Tfinish->Set();
493  UpdateText->SetLineColor(0);
494  UpdateText->SetFillColor(0);
495  UpdateText->SetBorderSize(1);
496  UpdateText->SetMargin(0.0);
497  UpdateText->SetTextAlign(11);
498  char buff1[256];
499  sprintf(buff1, "Last updated on: %s (central time)", Tfinish->AsString());
500  UpdateText->AddText(buff1);
501 
502  //POWER SUPPLY ---------------------------------------------------------------------------------------------------
503  int ndiblocks = 0; //Number of diblocks
504  if(detector == 1) ndiblocks = 4;
505  else if(detector == 2) ndiblocks = 14;
506 
507  char lmh[4] = "LMH"; //Measure low, medium, and high voltage
508  char measstr[3];
509  int ndevices = 0; //Number of devices per diblock
510  if(detector == 1) ndevices = 4;
511  else if(detector == 2) ndevices = 12;
512  int nps = 3; //Number of power supplies (i.e. low, med, high)
513  int nmeas = 4; //Number of measurements per device
514  int col = 800; //Colour of graph (I like 800-910 and 920 onwards)
515  int col2 = 800;
516  int mark = 20; //Marker style
517 
518  for(int meas = 0;meas<nmeas;meas++)
519  {
520  if(meas == 0)strcpy(measstr,"");//Voltage at device
521  if(meas == 1)strcpy(measstr,"MC");//Current
522  if(meas == 2)strcpy(measstr,"MV");//Voltage at source
523  if(meas == 3)strcpy(measstr,"TP");//Temperature
524 
525  for(int ps = 0;ps<nps;ps++)
526  {
527  for(int diblock = 1;diblock<ndiblocks+1;diblock++)
528  {
529  //cout << "diblock = " << diblock << ", detector = " << detector;
530  if(detector == 1 && diblock == 4)
531  {
532  sprintf(name,"%c0M", lmh[ps], diblock);//muon catcher
533  //cout << endl << "CHANGE NAME TO ACCOUNT FOR MUON CATCHER" << endl;
534  ndevices = 2;
535  }
536  else if(diblock<10) sprintf(name,"%c0%i", lmh[ps], diblock);
537  else sprintf(name,"%c%i", lmh[ps], diblock);
538  //cout << name << endl;
539 
540  //Setting titles and y axis range Probably need adjustment/rethink. LMM
541  if(meas == 0)
542  {
543  if(ps ==0){
544  sprintf(title, "Low V power supply, diblock %i: Voltage at device;;Voltage (V)", diblock);
545  sprintf(title2, "Low V power supply: Voltage at device;;Voltage (V)", diblock);
546  ylimit[0] = 2.5;
547  ylimit[1] = 4.5;//These limits are set by me looking at the plots and guessing a useful range, they are not set in stone
548  }
549  if(ps ==1){
550  sprintf(title, "Medium V power supply, diblock %i: Voltage at device;;Voltage (V)", diblock);
551  sprintf(title2, "Medium V power supply: Voltage at device;;Voltage (V)", diblock);
552  ylimit[0] = 20;
553  ylimit[1] = 26;
554  }
555  if(ps ==2){
556  sprintf(title, "High V power supply, diblock %i: Voltage at device;;Voltage (V)", diblock);
557  sprintf(title2, "High V power supply: Voltage at device;;Voltage (V)", diblock);
558  ylimit[0] = 422;
559  ylimit[1] = 428;
560  }
561  }
562 
563  if(meas == 1)
564  {
565  if(ps ==0){
566  sprintf(title, "Low V power supply, diblock %i: Current;;Current (mA)", diblock);
567  sprintf(title2, "Low V power supply: Current;;Current (mA)", diblock);
568  ylimit[0] = 30000;
569  ylimit[1] = 31000;
570  }
571  if(ps ==1){
572  sprintf(title, "Medium V power supply, diblock %i: Current;;Current (mA)", diblock);
573  sprintf(title2, "Medium V power supply: Current;;Current (mA)", diblock);
574  ylimit[0] = 8000;
575  ylimit[1] = 9900;
576  }
577  if(ps ==2){
578  sprintf(title, "High V power supply, diblock %i: Current;;Current (A)", diblock);
579  sprintf(title2, "High V power supply: Current;;Current (A)", diblock);
580  ylimit[0] = 3.;
581  ylimit[1] = 4.5;
582  }
583  }
584 
585  if(meas == 2)
586  {
587  if(ps ==0){
588  sprintf(title, "Low V power supply, diblock %i: Voltage at source;;Voltage (V)", diblock);
589  sprintf(title2, "Low V power supply: Voltage at source;;Voltage (V)", diblock);
590  ylimit[0] = 3.5;
591  ylimit[1] = 5.;
592  }
593  if(ps ==1){
594  sprintf(title, "Medium V power supply, diblock %i: Voltage at source;;Voltage (V)", diblock);
595  sprintf(title2, "Medium V power supply: Voltage at source;;Voltage (V)", diblock);
596  ylimit[0] = 22.;
597  ylimit[1] = 28.;
598  }
599  if(ps ==2){
600  sprintf(title, "High V power supply, diblock %i: Voltage at source;;Voltage (V)", diblock);
601  sprintf(title2, "High V power supply: Voltage at source;;Voltage (V)", diblock);
602  ylimit[0] = 422.;
603  ylimit[1] = 428.;
604  }
605  }
606 
607  if(meas == 3)
608  {
609  if(ps ==0){
610  sprintf(title, "Low V power supply, diblock %i: Temperature;;Temperature (C)", diblock);
611  sprintf(title2, "Low V power supply: Temperature;;Temperature (C)", diblock);
612  ylimit[0] = 20.;
613  ylimit[1] = 35.;
614  }
615  if(ps ==1){
616  sprintf(title, "Medium V power supply, diblock %i: Temperature;;Temperature (C)", diblock);
617  sprintf(title2, "Medium V power supply: Temperature;;Temperature (C)", diblock);
618  ylimit[0] = 20;
619  ylimit[1] = 30;
620  }
621  if(ps ==2){
622  sprintf(title, "High V power supply, diblock %i: Temperature;;Temperature (C)", diblock);
623  sprintf(title2, "High V power supply: Temperature;;Temperature (C)", diblock);
624  ylimit[0] = 25;
625  ylimit[1] = 35;
626  }
627  }
628 
629  sprintf(saveme,"%s%s%s", filepath, name, measstr);
630  sprintf(saveme2,"%s%c%s", filepath, lmh[ps], measstr);
631 
632  for(int device=1;device<ndevices+1;device++)
633  {
634  if(device==ndevices)
635  {
636  mode=2;//If it's the last device, save
637  if(diblock==ndiblocks)mode2=2;
638  }
639  if(device<10) sprintf(branchname,"%s0%i%s", name, device, measstr);
640  else sprintf(branchname, "%s%i%s", name, device, measstr);
641  // plot once for diblock
642  plot_with_zoom(t, branchname, device, 20, c1, title, ylimit, zoom, timeago, XNow, mode, saveme, timeperiod);
643  // plot again for detector -- maybe combine to access the data once?
644  plot_with_zoom(t, branchname, device, 19+diblock, c2, title2, ylimit, zoom2, timeago, XNow, mode2, saveme2, timeperiod);
645  mode = 1;
646  mode2 = 1;
647  }
648  //saveplot(c1, leg, UpdateText, saveme, zoom, ylimit);
649  mode = 0;
650  }//end diblock<ndiblocks
651  mode2 = 0;
652  // Reset number of devices/diblock
653  if(detector == 1) ndevices = 4;
654  else if(detector == 2) ndevices = 12;
655  }//end ps<nps
656  }//end meas<nmeas
657  mode = 0;
658  mode2 = 0;
659  //*/
660 
661  //UTLOPC-------------------------------------------------------------------------------------------------------------------------------
662  ///*
663 
664  //----------BUILDING FLOW----------
665  /*
666  ylimit[0] = 0.;
667  ylimit[1] = 5.;
668  sprintf(name,"EBF");
669  //cout << name << endl;
670 
671  sprintf(title,"Building flow;;");
672  sprintf(branchname,"%s1",name);
673  sprintf(legendentry,"BF1");
674  plot_with_zoom(t, branchname, 1, c1, title, g1, legendentry, ylimit, zoom, timeago, XNow);
675  sprintf(branchname,"%s2",name);
676  sprintf(legendentry,"BF2");
677  plot_with_zoom(t, branchname, 2, c1, title, g2, legendentry, ylimit, zoom, timeago, XNow);
678  sprintf(branchname,"%s3",name);
679  sprintf(legendentry,"BF3");
680  plot_with_zoom(t, branchname, 3, c1, title, g3, legendentry, ylimit, zoom, timeago, XNow);
681 
682  c1->cd();
683  leg->Draw();
684  c1->Modified();
685  c1->Update();
686  sprintf(saveme,"%sEBFDay.png", filepath);
687 
688  //For zoomed plot
689  g1 = (TGraph*)gPad->GetPrimitive("Graph");
690  g1->SetMinimum(zoom[0] - (zoom[1]-zoom[0])*0.1);
691  g1->SetMaximum(zoom[1] + (zoom[1]-zoom[0])*0.1);
692  c1->Modified();
693  c1->Update();
694  sprintf(saveme,"%sEBFzoomDay.png", filepath, name);
695  c1->SaveAs(saveme);
696 
697  c1->Clear();
698  leg->Clear();
699  zoom[0] = 99999;
700  zoom[1] =-99999;
701  */
702 
703  //AIR FLOW-----------------------------------------------------
704  if(detector == 1)
705  {
706  //cout << "starting airflow" << endl;
707  sprintf(title, "Rack Air Flow");
708  ylimit[0] = 0;
709  ylimit[1] = 300;
710  sprintf(saveme,"%sAirFlow", filepath);
711 
712  sprintf(branchname,"ENNALV1");
713  //sprintf(legendentry,"LV1");
714  plot_with_zoom(t, branchname, 1, 20, c1, title, ylimit, zoom, timeago, XNow, 0, saveme, timeperiod);
715  sprintf(branchname,"ENNALV2");
716  //sprintf(legendentry,"LV2");
717  plot_with_zoom(t, branchname, 2, 20, c1, title, ylimit, zoom, timeago, XNow, 1, saveme, timeperiod);
718  sprintf(branchname,"ENNAHV1");
719  //sprintf(legendentry,"HV");
720  plot_with_zoom(t, branchname, 3, 20, c1, title, ylimit, zoom, timeago, XNow, 2, saveme, timeperiod);
721  }
722 
723  //----------DEWPOINT & TEMPERATURE----------
724 
725  if(detector == 1){
726  nmeas = 2;
727  char dh[3] = "DH";
728 
729  zoom[0]=99999.;
730  zoom[1]=-99999.;
731 
732  for(int iter=0;iter<nmeas;iter++)
733  {
734  if(iter==0)
735  {
736  sprintf(title, "Dewpoint;;Dewpoint (C)");
737  ylimit[0] = -60;
738  ylimit[1] = 30;
739  sprintf(saveme,"%sDewPoint", filepath);
740  }
741  if(iter==1)
742  {
743  sprintf(title, "Humidity;;Humidity (%)");
744  ylimit[0] = 0;
745  ylimit[1] = 90;
746  sprintf(saveme,"%sHumidity", filepath);
747  }
748 
749  sprintf(branchname,"ENN%cDB1", dh[iter]);
750  //cout << " zoom params " << zoom[0] << " and " << zoom[1] << endl;
751  plot_with_zoom(t, branchname, 1, 20, c1, title, ylimit, zoom, timeago, XNow, 0, saveme, timeperiod);
752  sprintf(branchname,"ENN%cDB2", dh[iter]);
753  //cout << " zoom params " << zoom[0] << " and " << zoom[1] << endl;
754  plot_with_zoom(t, branchname, 2, 20, c1, title, ylimit, zoom, timeago, XNow, 1, saveme, timeperiod);
755  sprintf(branchname,"ENN%cDB3", dh[iter]);
756  //cout << " zoom params " << zoom[0] << " and " << zoom[1] << endl;
757  plot_with_zoom(t, branchname, 3, 20, c1, title, ylimit, zoom, timeago, XNow, 1, saveme, timeperiod);
758  sprintf(branchname,"ENN%cDME", dh[iter]);
759  //cout << " zoom params " << zoom[0] << " and " << zoom[1] << endl;
760  plot_with_zoom(t, branchname, 4, 20, c1, title, ylimit, zoom, timeago, XNow, 1, saveme, timeperiod);
761  sprintf(branchname,"ENN%cDMN", dh[iter]);
762  //cout << " zoom params " << zoom[0] << " and " << zoom[1] << endl;
763  plot_with_zoom(t, branchname, 5, 20, c1, title, ylimit, zoom, timeago, XNow, 2, saveme, timeperiod);
764  //cout << " zoom params " << zoom[0] << " and " << zoom[1] << endl;
765 
766  }
767  }//end if (ND)
768 
769  else if(detector == 2){
770  sprintf(measstr,"HT");
771  nmeas = 2;
772 
773  for(int iter = 0;iter<nmeas;iter++)
774  {
775  if(iter == 0)
776  {
777  ylimit[0] = 0.;
778  ylimit[1] = 70.;
779  sprintf(title,"Dewpoint;;Dewpoint (F)");
780  }
781  if(iter == 1)
782  {
783  ylimit[0] = 60;
784  ylimit[1] = 90;
785  sprintf(title,"Temperature;;Temperature (F)");
786  }
787  sprintf(name,"E%cL", measstr[iter]);
788  //cout << name << endl;
789  if(iter==0)sprintf(saveme,"%sDewPoint", filepath);
790  else sprintf(saveme,"%sTemperature", filepath);
791 
792  sprintf(branchname,"%s101", name);//Weirdly ordered colors to match a previous code, where this order made sense!
793  plot_with_zoom(t, branchname, 1, 20, c1, title, ylimit, zoom, timeago, XNow, mode, saveme, timeperiod);
794  mode = 1;
795  sprintf(branchname,"%s102", name);
796  plot_with_zoom(t, branchname, 2, 20, c1, title, ylimit, zoom, timeago, XNow, mode, saveme, timeperiod);
797  sprintf(branchname,"%s103", name);
798  plot_with_zoom(t, branchname, 3, 20, c1, title, ylimit, zoom, timeago, XNow, mode, saveme, timeperiod);
799 
800  if(iter == 1)
801  {
802  sprintf(branchname,"%sL0ME", name);
803  plot_with_zoom(t, branchname, 95, 20, c1, title, ylimit, zoom, timeago, XNow, mode, saveme, timeperiod);
804  sprintf(branchname,"%sL0NE", name);
805  plot_with_zoom(t, branchname, 11, 20, c1, title, ylimit, zoom, timeago, XNow, mode, saveme, timeperiod);
806  sprintf(branchname,"%sL0SE", name);
807  plot_with_zoom(t, branchname, 14, 20, c1, title, ylimit, zoom, timeago, XNow, mode, saveme, timeperiod);
808  }
809 
810  sprintf(branchname,"%sL0MW", name);
811  plot_with_zoom(t, branchname, 4, 20, c1, title, ylimit, zoom, timeago, XNow, mode, saveme, timeperiod);
812  sprintf(branchname,"%sL0NW", name);
813  plot_with_zoom(t, branchname, 5, 20, c1, title, ylimit, zoom, timeago, XNow, mode, saveme, timeperiod);
814  sprintf(branchname,"%sL0SW", name);
815  plot_with_zoom(t, branchname, 6, 20, c1, title, ylimit, zoom, timeago, XNow, mode, saveme, timeperiod);
816  /*
817  sprintf(branchname,"%sL1MW", name);
818  sprintf(legendentry,"L1MW");
819  plot_with_zoom(t, branchname, 1, 20, c1, title, leg, legendentry, ylimit, zoom, timeago, XNow);
820  sprintf(branchname,"%sL1NW", name);
821  sprintf(legendentry,"L1 NW");
822  plot_with_zoom(t, branchname, 1, 20, c1, title, leg, legendentry, ylimit, zoom, timeago, XNow);
823  sprintf(branchname,"%sL1SW", name);
824  sprintf(legendentry,"L1SW");
825  plot_with_zoom(t, branchname, 1, 20, c1, title, leg, legendentry, ylimit, zoom, timeago, XNow);
826  sprintf(branchname,"%sL2MW", name);
827  sprintf(legendentry,"L2 MW");
828  plot_with_zoom(t, branchname, 1, 20, c1, title, leg, legendentry, ylimit, zoom, timeago, XNow);
829  sprintf(branchname,"%sL2NW", name);
830  sprintf(legendentry,"L2 NW");
831  plot_with_zoom(t, branchname, 1, 20, c1, title, leg, legendentry, ylimit, zoom, timeago, XNow);
832  sprintf(branchname,"%sL2SW", name);
833  sprintf(legendentry,"L2 SW");
834  plot_with_zoom(t, branchname, 1, 20, c1, title, leg, legendentry, ylimit, zoom, timeago, XNow);
835  sprintf(branchname,"%sL3MW", name);
836  sprintf(legendentry,"L3MW");
837  plot_with_zoom(t, branchname, 1, 20, c1, title, leg, legendentry, ylimit, zoom, timeago, XNow);
838  sprintf(branchname,"%sL3NW", name);
839  sprintf(legendentry,"L3 NW");
840  plot_with_zoom(t, branchname, 1, 20, c1, title, leg, legendentry, ylimit, zoom, timeago, XNow);
841  sprintf(branchname,"%sL3SW", name);
842  sprintf(legendentry,"L3 SW");
843  plot_with_zoom(t, branchname, 1, 20, c1, title, leg, legendentry, ylimit, zoom, timeago, XNow);
844  */
845  sprintf(branchname,"%sL4MW", name);
846  plot_with_zoom(t, branchname, 7, 20, c1, title, ylimit, zoom, timeago, XNow, mode, saveme, timeperiod);
847  sprintf(branchname,"%sL4NW", name);
848  plot_with_zoom(t, branchname, 8, 20, c1, title, ylimit, zoom, timeago, XNow, mode, saveme, timeperiod);
849  sprintf(branchname,"%sL4SW", name);
850  mode = 2;
851  plot_with_zoom(t, branchname, 9, 20, c1, title, ylimit, zoom, timeago, XNow, mode, saveme, timeperiod);
852  mode = 0;
853  }//end iter over h vs t
854  }//end if (FD)
855 
856  //----------------STATUSES-------------------
857  if(detector == 1){
858  int ndastatuses = 7;//7 dry air statuses
859  sprintf(title,"Status of systems");
860  ylimit[0] = -1;
861  ylimit[1] = 11;
862  sprintf(saveme,"%sStatuses", filepath);
863  mode = 0;
864 
865  for(int dastatus=1;dastatus<ndastatuses+1;dastatus++)
866  {
867  //sprintf(legendentry,"Dry air status %i",dastatus);
868  sprintf(branchname,"ENNDAS%i",dastatus);
869  if(dastatus==ndastatuses)mode = 2;
870  plot_with_zoom(t, branchname, dastatus, 20, c1, title, ylimit, zoom, timeago, XNow, mode, saveme, timeperiod);
871  mode = 1;
872  }
873  /* sprintf(legendentry,"EPICS Reset status");
874  sprintf(branchname,"ENNEPIC"); plot_with_zoom(t, branchname, ndastatuses+1, c1, title, ylimit, zoom, timeago, XNow);*/
875  }
876 
877  //PHIDGT VARIABLES--------------------------------------------------------------------------------------------------------------
878 
879  if(detector == 2){
880  char side[4] = "WNS";
881  int nblocks = 29;//28 plus south bookend
882  int nsides = 2;//North and south, or north and west
883  int xmax;
884  int ymax;
885  col=800;
886  int marker=20;
887 
888  for(int iter=0;iter<nsides;iter++)
889  {
890 
891  //----------STRAIN----------------
892  nblocks = 8;
893  for(int block=0;block < nblocks;block++)
894  {
895  col = 800;
896  ylimit[0] = -500;
897  ylimit[1] = 1000;
898 
899  char realblock[3];
900  if(block == 0)sprintf(realblock, "00");
901  if(block == 1)sprintf(realblock, "01");
902  if(block == 2)sprintf(realblock, "08");
903  if(block == 3)sprintf(realblock, "09");
904  if(block == 4)sprintf(realblock, "18");
905  if(block == 5)sprintf(realblock, "19");
906  if(block == 6)sprintf(realblock, "26");
907  if(block == 7)sprintf(realblock, "27");
908 
909  if(iter==0)sprintf(title,"Strain measured on West side of blocks;;Micro strain");
910  if(iter==1)sprintf(title,"Strain measured on North side of blocks;;Micro strain");
911 
912  //sprintf(name,"ES%i%c", block, side[iter]);
913  sprintf(name,"ES");
914  //cout << name << endl;
915 
916  if(iter==1)
917  {
918  xmax = 6;
919  ymax = 4;
920  }
921  else if(iter==0)
922  {
923  xmax = 2;
924  ymax = 3;
925  }
926  //cout << "xmax = " << xmax << endl;
927 
928  for(int x=1;x<xmax+1;x++)
929  {
930  //cout << "x = " << x << endl;
931  for(int y=1;y<ymax+1;y++)
932  {
933  if(x==xmax && y==ymax) mode = 2;
934  //cout << "x,y,block: " << x << "," << y << "," << block << endl;
935  //print_strings("strain", block, x, y, name, branchname, legendentry);
936  sprintf(branchname,"%s%i%c%i%i",name,block,side[iter],x,y);
937  sprintf(saveme,"%s%s%c",filepath, name,side[iter]);
938  //cout << "col = " << col << endl;
939  plot_strain_with_zoom(t, branchname, x, y, marker, c1, title, ylimit, zoom, timeago, XNow, mode, saveme, timeperiod);
940  col += 1;
941  mode = 1;
942  if(col==910)col=920;//910-920 is white
943  }
944  }
945  marker += 1;
946  if(marker > 34)
947  {
948  marker = 20;
949  gStyle->SetMarkerSize(2);
950  }
951  }//end iteration over blocks
952 
953  //sprintf(saveme,"%sFarDet-Strain%c",filepath,side[iter]);
954  //saveplot(c1, leg, UpdateText, saveme, zoom, ylimit);
955 
956  gStyle->SetMarkerSize(1);
957  marker = 20;
958  mode = 0;
959 
960  //*//*
961  //----------DISTANCE----------
962  nblocks = 29;
963  for(int block=0;block < nblocks;block++)
964  {
965  sprintf(saveme,"%sDist%c", filepath, side[iter+1]);
966 
967  col2 = 1;
968  ylimit[0] = -0.2;
969  ylimit[1] = 1.;
970  if((block==0 && iter==1) || (block==27 && iter==0) || (block==28 && iter==1)) continue;
971 
972  if(iter==0) sprintf(title,"Distance from original position (North side of blocks);;Distance (inches)");
973  if(iter==1) sprintf(title,"Distance from original position (South side of blocks);;Distance (inches)");
974 
975  if(block < 10) sprintf(name,"ED0%i",block);
976  else if (block < 28) sprintf(name,"ED%i",block);
977  else sprintf(name,"EDSB");
978 
979  //cout << name << endl;
980 
981  xmax = 2;
982 
983  for(int x=1; x<xmax+1; x++)
984  {
985  if(iter == 1 && x == 2)
986  {
987  x=6;
988  if(block==nblocks-2)mode = 2;
989  }
990  //int nwchar = iter +1;
991  sprintf(branchname,"%s%c%i1", name, side[iter+1], x);
992  plot_with_zoom(t, branchname, col2, marker, c2, title, ylimit, zoom2, timeago, XNow, mode, saveme, timeperiod);
993  mode = 1;
994  col2 += 1;
995  if(col2==910)col2=920;//910-920 is white
996 
997  if(iter==0)
998  {
999  if(block!=28)sprintf(branchname,"%s%c%i9",name, side[iter+1],x);
1000  else
1001  {
1002  sprintf(branchname,"%s%c%i6",name, side[iter+1],x);
1003  if(x==xmax && block==nblocks-1)mode = 2;
1004  }
1005  plot_with_zoom(t, branchname, col2, marker, c2, title, ylimit, zoom2, timeago, XNow, mode, saveme, timeperiod);
1006  col2 += 1;
1007  if(col2==910)col2=920;//910-920 is white
1008  }
1009  }
1010  marker += 1;
1011  if(marker > 34)
1012  {
1013  marker = 20;
1014  gStyle->SetMarkerSize(2);
1015  }
1016 
1017  } //end iteration over blocks
1018 
1019  marker = 20;
1020  gStyle->SetMarkerSize(1);
1021 
1022  mode = 0;
1023  } //end iteration over sides
1024  gStyle->SetMarkerSize(1);
1025 
1026  //----------TEMPERATURE-----------
1027 
1028  nsides = 2;
1029  nblocks = 8;
1030  ylimit[0] = 10;
1031  ylimit[1] = 25;
1032  xmax = 2;
1033  sprintf(title,"Internal temperature;;Temperature (C)");
1034  sprintf(saveme,"%sIntTemp", filepath);
1035 
1036  for(int s=0;s<nsides;s++)
1037  {
1038  if(s==0) sprintf(name,"ETN");
1039  else if(s==1) sprintf(name, "ETW");
1040 
1041  for(int block=0;block<nblocks;block++)
1042  {
1043  for(int x=1;x<xmax+1;x++)
1044  {
1045  if(s==nsides-1 && block==nblocks-1 && x==xmax) mode = 2;
1046  col = x + xmax*s;
1047  sprintf(branchname,"ET%i%c%i1",block, side[s],x);
1048  plot_with_zoom(t, branchname, col, 20+block, c1, title, ylimit, zoom, timeago, XNow, mode, saveme, timeperiod);
1049  mode = 1;
1050  }
1051  }
1052  }
1053  //*/
1054 
1055  //---------OAT, GLYCOT, HTWARN-------
1056 
1057  sprintf(title,"Outside air temperature;;Temperature (F)");
1058  sprintf(saveme, "%sOAT", filepath);
1059  sprintf(branchname,"EOAT");
1060  ylimit[0] = -40.;
1061  ylimit[1] = 90.;
1062  plot_with_zoom(t, branchname, 1, 7, c1, title, ylimit, zoom, timeago, XNow, 3, saveme, timeperiod);
1063 
1064  sprintf(title,"Cooling liquid temperature;;Temperature (F)");
1065  sprintf(saveme, "%sGLYCOT", filepath);
1066  sprintf(branchname,"EGLYCOT");
1067  ylimit[0] = 20.;
1068  ylimit[1] = 120.;
1069  plot_with_zoom(t, branchname, 1, 7, c1, title, ylimit, zoom, timeago, XNow, 3, saveme, timeperiod);
1070 
1071  sprintf(title,"High Temperature warning status");
1072  sprintf(saveme, "%sHTWarn", filepath);
1073  sprintf(branchname,"EHTWARN");
1074  ylimit[0] = -1;
1075  ylimit[1] = 2;
1076  plot_with_zoom(t, branchname, 1, 7, c1, title, ylimit, zoom, timeago, XNow, 3, saveme, timeperiod);
1077 
1078  }//End FD only plots
1079 }//End EVERYTHING. We're done here.
const XML_Char * name
Definition: expat.h:151
diblock
print "ROW IS " print row
Definition: geo2elec.py:31
enum BeamMode kRed
std::map< std::string, double > xmax
void DCSPlotMaker(string timeperiodname, string detectorname)
Definition: DCSPlotMaker.C:371
TPaveText * UpdateText
Definition: DCSPlotMaker.C:18
TDatime * TNow
Definition: AnaPlotMaker.h:41
T sqrt(T number)
Definition: d0nt_math.hpp:156
constexpr T pow(T x)
Definition: pow.h:75
void plot_strain_with_zoom(TTree *t, char *branchname, int x, int y, int marker, TCanvas *c1, char *title, float *ylimit, float *zoom, int timeago, int XNow, int mode, char *saveme, int timeperiod)
Definition: DCSPlotMaker.C:239
newtitle
Definition: plotROC.py:122
Double_t ymax
Definition: plot.C:25
int nwarnings
Definition: DCSPlotMaker.C:20
c2
Definition: demo5.py:33
const XML_Char * s
Definition: expat.h:262
block
print "ROW IS " print row
Definition: elec2geo.py:31
TPaveText * WarningText
Definition: DCSPlotMaker.C:19
Long64_t nentries
Int_t col[ntarg]
Definition: Style.C:29
OStream cout
Definition: OStream.cxx:6
c1
Definition: demo5.py:24
enum BeamMode kGreen
enum BeamMode kBlue
def entry(str)
Definition: HTMLTools.py:26
void plot_with_zoom(TTree *t, char *branchname, int color, int marker, TCanvas *c1, char *title, float *ylimit, float *zoom, UInt_t timeago, UInt_t XNow, int mode, char *saveme, int timeperiod)
Definition: DCSPlotMaker.C:22