Public Member Functions | Public Attributes | List of all members
NearlinePlot Struct Reference

#include <NearlinePlotMaker.h>

Public Member Functions

 NearlinePlot (std::string this_hist_name, NearlinePlotInfo this_plot_info, NearlinePlotEnables this_plot_enable=NearlinePlotEnables(), NearlinePlotLogScale this_plot_log_scale=NearlinePlotLogScale())
 
bool AddHistogram (TFile const &file, TTree *header, int Xsrtime, int XNow, int GMToffset, int time_ago)
 
bool AddHistogram1D (TFile const &file, TTree *header, int Xsrtime, int XNow, int GMToffset, int time_ago)
 
bool AddHistogram2D (TFile const &file, TTree *header, int Xsrtime, int XNow, int GMToffset, int time_ago)
 
void normaliseHisto1D ()
 
TCanvas * makeHistoCanvas (TPaveText *updateText, int width=1200, int height=800)
 
TCanvas * makeHisto2DCanvas (TPaveText *updateText, int time_ago, int XNow, int width=1200, int height=800, std::string taxis_labels="")
 
TCanvas * makeGraphMetricTimeCanvas (TPaveText *updateText, int time_ago, int XNow, bool rms=false, bool zoom=false, int width=1200, int height=800, std::string taxis_labels="")
 
TCanvas * makeBinByBinGraphTime (unsigned int bin, TPaveText *updateText, int time_ago, int XNow, int width=1200, int height=800, std::string taxis_labels="")
 
void printPlots (std::string plot_dir, TPaveText *updateText, int time_ago, int XNow, int width=1200, int height=800, std::string taxis_labels="")
 
void printHistogram1D (std::string plot_dir, TPaveText *updateText, int time_ago, int XNow, int width=1200, int height=800, std::string taxis_labels="")
 
void printHistogram2D (std::string plot_dir, TPaveText *updateText, int time_ago, int XNow, int width=1200, int height=800, std::string taxis_labels="")
 
void printGraphs (std::string plot_dir, TPaveText *updateText, int time_ago, int XNow, int width=1200, int height=800, std::string taxis_labels="")
 
void printBinByBinGraphs (std::string plot_dir, TPaveText *updateText, int time_ago, int XNow, int width=1200, int height=800, std::string taxis_labels="")
 
void setMetricDetails (std::string metric_details)
 
void setHistTitle (std::string hist_title)
 
void setPlotInfo (NearlinePlotInfo this_plot_info)
 
 NearlinePlot (std::string this_hist_name, NearlinePlotInfo this_plot_info, NearlinePlotEnables this_plot_enable=NearlinePlotEnables(), NearlinePlotLogScale this_plot_log_scale=NearlinePlotLogScale())
 
bool AddHistogram (TFile const &file, TTree *header, int Xsrtime, int XNow, int GMToffset, int time_ago)
 
bool AddHistogram1D (TFile const &file, TTree *header, int Xsrtime, int XNow, int GMToffset, int time_ago)
 
bool AddHistogram2D (TFile const &file, TTree *header, int Xsrtime, int XNow, int GMToffset, int time_ago)
 
void normaliseHisto1D ()
 
TCanvas * makeHistoCanvas (TPaveText *updateText, int width=1200, int height=800)
 
TCanvas * makeHisto2DCanvas (TPaveText *updateText, int time_ago, int XNow, int width=1200, int height=800, std::string taxis_labels="")
 
TCanvas * makeGraphMetricTimeCanvas (TPaveText *updateText, int time_ago, int XNow, bool rms=false, bool zoom=false, int width=1200, int height=800, std::string taxis_labels="")
 
TCanvas * makeBinByBinGraphTime (unsigned int bin, TPaveText *updateText, int time_ago, int XNow, int width=1200, int height=800, std::string taxis_labels="")
 
void printPlots (std::string plot_dir, TPaveText *updateText, int time_ago, int XNow, int width=1200, int height=800, std::string taxis_labels="")
 
void printHistogram1D (std::string plot_dir, TPaveText *updateText, int time_ago, int XNow, int width=1200, int height=800, std::string taxis_labels="")
 
void printHistogram2D (std::string plot_dir, TPaveText *updateText, int time_ago, int XNow, int width=1200, int height=800, std::string taxis_labels="")
 
void printGraphs (std::string plot_dir, TPaveText *updateText, int time_ago, int XNow, int width=1200, int height=800, std::string taxis_labels="")
 
void printBinByBinGraphs (std::string plot_dir, TPaveText *updateText, int time_ago, int XNow, int width=1200, int height=800, std::string taxis_labels="")
 
void setMetricDetails (std::string metric_details)
 
void setHistTitle (std::string hist_title)
 
void setPlotInfo (NearlinePlotInfo this_plot_info)
 
 NearlinePlot (int Npoint, std::string this_hist_name, std::string this_output_name, std::string hist_title, int num_bins, int min_x, int max_x, bool RMS=false)
 
bool AddHistogram (TFile const &file, TTree *header, int Xstrtime, int Xsrtime, int XNow, int GMToffset)
 
TCanvas * makeHistoCanvas (std::string can_name, std::string can_title, int width, int height, TPaveText *updateText)
 
TCanvas * makeGraphTimeCanvas (std::string can_name, std::string can_title, int width, int height)
 

Public Attributes

NearlinePlotEnables fPlotEnables
 
NearlinePlotLogScale fPlotLogScale
 
TH1F * fHistogram
 
std::string fHistName
 
NearlinePlotInfo fPlotInfo
 
std::string fHistTitle
 
TH2F * fHistogram2D
 
TH1F * fHistogram2DNormalisation
 
bool fNormalised
 
TGraph * fGraphMetricTime
 
TGraph * fGraphMetricRmsTime
 
std::vector< float > fMetricVec
 
std::vector< float > fMetricRmsVec
 
std::vector< float > fTimeVec
 
int fPlotCount
 
std::vector< TGraphErrors * > fBinByBinGraphMetricTime
 
std::vector< std::vector< float > > fBinByBinMetricVec
 
std::vector< std::vector< float > > fBinByBinMetricErrorVec
 
std::vector< std::stringfBinByBinLabels
 
std::string fBinByBinYAxisTitle
 
TGraph * fGraphTime
 
std::string fOutputName
 
int fNumPoints
 
bool fRMSPlot
 
bool fMakeHistogram
 

Detailed Description

Definition at line 166 of file NearlinePlotMaker.h.

Constructor & Destructor Documentation

NearlinePlot::NearlinePlot ( std::string  this_hist_name,
NearlinePlotInfo  this_plot_info,
NearlinePlotEnables  this_plot_enable = NearlinePlotEnables(),
NearlinePlotLogScale  this_plot_log_scale = NearlinePlotLogScale() 
)

Definition at line 219 of file NearlinePlotMaker.h.

220 {
221 
222  fPlotEnables=this_plot_enable;
223  fPlotLogScale=this_plot_log_scale;
224 
225  fHistogram=0;
226  fHistName = this_hist_name;
227  fPlotInfo = this_plot_info;
228  fHistTitle = "";
229 
230  fHistogram2D=0;
232  fNormalised = false;
233 
234  fMetricVec.resize(0);
235  fMetricRmsVec.resize(0);
236  fTimeVec.resize(0);
237  fPlotCount = 0;
238  fGraphMetricTime = 0;
240 
241  fBinByBinGraphMetricTime.resize(0);
242  fBinByBinMetricVec.resize(0);
243  fBinByBinMetricErrorVec.resize(0);
244  fBinByBinLabels.resize(0);
245  fBinByBinYAxisTitle = "";
246 }
TGraph * fGraphMetricTime
std::vector< std::vector< float > > fBinByBinMetricVec
std::string fHistTitle
std::vector< float > fMetricRmsVec
TGraph * fGraphMetricRmsTime
std::string fBinByBinYAxisTitle
std::vector< float > fTimeVec
NearlinePlotLogScale fPlotLogScale
TH1F * fHistogram2DNormalisation
std::string fHistName
std::vector< std::string > fBinByBinLabels
std::vector< std::vector< float > > fBinByBinMetricErrorVec
std::vector< TGraphErrors * > fBinByBinGraphMetricTime
NearlinePlotEnables fPlotEnables
std::vector< float > fMetricVec
NearlinePlotInfo fPlotInfo
NearlinePlot::NearlinePlot ( std::string  this_hist_name,
NearlinePlotInfo  this_plot_info,
NearlinePlotEnables  this_plot_enable = NearlinePlotEnables(),
NearlinePlotLogScale  this_plot_log_scale = NearlinePlotLogScale() 
)
NearlinePlot::NearlinePlot ( int  Npoint,
std::string  this_hist_name,
std::string  this_output_name,
std::string  hist_title,
int  num_bins,
int  min_x,
int  max_x,
bool  RMS = false 
)

Definition at line 78 of file NearlinePlotMakerJPD.h.

79 {
80  fNumPoints = Npoint;
81  fHistName = this_hist_name;
82  fOutputName = this_output_name;
83  fMetricVec = std::vector<float>(Npoint, 0);
84  fTimeVec = std::vector<float>(Npoint, 0);
85  fPlotCount = 0;
86  fRMSPlot=RMS;
87  fHistogram = new TH1F(fHistName.c_str(), hist_title.c_str(), num_bins, min_x, max_x);
88  fGraphTime = 0;
89 }
std::vector< float > fTimeVec
std::string fHistName
std::string fOutputName
std::vector< float > fMetricVec

Member Function Documentation

bool NearlinePlot::AddHistogram ( TFile const &  file,
TTree *  header,
int  Xstrtime,
int  Xsrtime,
int  XNow,
int  GMToffset 
)
bool NearlinePlot::AddHistogram ( TFile const &  file,
TTree *  header,
int  Xsrtime,
int  XNow,
int  GMToffset,
int  time_ago 
)

Definition at line 261 of file NearlinePlotMaker.h.

261  {
262 
263  bool result;
264  result = AddHistogram1D(file, header, Xsrtime, XNow, GMToffset, time_ago);
265  if(fPlotEnables.fMake2DHisto) result = result & AddHistogram2D(file, header, Xsrtime, XNow, GMToffset, time_ago);
266  return result;
267 
268 }
bool AddHistogram2D(TFile const &file, TTree *header, int Xsrtime, int XNow, int GMToffset, int time_ago)
static QCString result
bool AddHistogram1D(TFile const &file, TTree *header, int Xsrtime, int XNow, int GMToffset, int time_ago)
NearlinePlotEnables fPlotEnables
Int_t GMToffset
bool NearlinePlot::AddHistogram ( TFile const &  file,
TTree *  header,
int  Xsrtime,
int  XNow,
int  GMToffset,
int  time_ago 
)
bool NearlinePlot::AddHistogram1D ( TFile const &  file,
TTree *  header,
int  Xsrtime,
int  XNow,
int  GMToffset,
int  time_ago 
)

Definition at line 270 of file NearlinePlotMaker.h.

270  {
271 
272  TH1F *hist_temp = (TH1F*)file.FindObjectAny(fHistName.c_str());
273  if(hist_temp != 0){
274  if(fHistogram == 0){
275  fHistogram = (TH1F*) hist_temp->Clone((fHistName + "_temp").c_str());
276  if(fHistTitle!="") fHistogram->SetTitle(fHistTitle.c_str());
277  else fHistTitle = fHistogram->GetTitle();
278  fHistogram->SetDirectory(0);
279  }
280  else{
281  if(fHistogram->GetNbinsX() != hist_temp->GetNbinsX()){
282  // std::cerr << "ERROR: " << file.GetName() << " " << fHistogram->GetName() << " " << fHistogram->GetNbinsX() << " bins vs " << hist_temp->GetNbinsX() << std::endl;
283  return false;
284  }
285  if(hist_temp->GetEntries() == 0){
286  // std::cerr << "ERROR: " << file.GetName() << " " << fHistogram->GetName() << " Has no entries" << std::endl;
287  return false;
288  }
289  fHistogram->Add(hist_temp,1.0);
290  }
291  }
292  else{
293  // std::cerr << "NearlinePlot::AddHistogram - Failed to find histogram - " << fHistName << std::endl;
294  return false;
295  }
296  if(hist_temp != 0 && header != 0 && Xsrtime != XNow - GMToffset) {
297  fTimeVec.push_back(Xsrtime);
298  fMetricVec.push_back(hist_temp->GetMean(1));
299  fMetricRmsVec.push_back(hist_temp->GetRMS(1));
300 
302  //Initiliase the binbybin vector of vectors
303  if(fBinByBinMetricVec.size()==0){
304  fBinByBinMetricVec.resize(hist_temp->GetNbinsX());
305  fBinByBinMetricErrorVec.resize(hist_temp->GetNbinsX());
306  fBinByBinLabels.resize(hist_temp->GetNbinsX());
307  fBinByBinYAxisTitle = std::string(hist_temp->GetYaxis()->GetTitle());
308  for(int bin=1; bin<=hist_temp->GetNbinsX();bin++){
309  std::string label = hist_temp->GetXaxis()->GetBinLabel(bin);
310  fBinByBinLabels.at(bin-1) = (label);
311  // std::cerr << "ERROR: " << hist_temp->GetName() << " bin " << bin << " " << label << std::endl;
312  }
313  }
314  if(fHistogram->GetNbinsX() != hist_temp->GetNbinsX()){
315  // std::cerr << "ERROR: " << file.GetName() << " " << fHistogram->GetName() << " " << fHistogram->GetNbinsX() << " bins vs " << hist_temp->GetNbinsX() << std::endl;
316  return false;;
317  }
318  if(hist_temp->GetEntries() == 0){
319  // std::cerr << "ERROR: " << file.GetName() << " " << fHistogram->GetName() << " Has no entries" << std::endl;
320  return false;
321  }
322  for(int bin=1; bin<=hist_temp->GetNbinsX();bin++){
323  fBinByBinMetricVec.at(bin-1).push_back(hist_temp->GetBinContent(bin));
324  fBinByBinMetricErrorVec.at(bin-1).push_back(hist_temp->GetBinError(bin));
325  }
326  }//fMakeBinByBinPlots
327 
328  fPlotCount++;
329  // std::cerr << "NearlinePlot::AddHistogram - Success" << std::endl;
330  return true;
331  }
332 
333  std::cerr << "NearlinePlot::AddHistogram - Failed - Shouldn't get here" << std::endl;
334  return false;
335 
336 }
std::vector< std::vector< float > > fBinByBinMetricVec
std::string string
Definition: nybbler.cc:12
std::string fHistTitle
std::vector< float > fMetricRmsVec
std::string fBinByBinYAxisTitle
std::vector< float > fTimeVec
std::string fHistName
std::vector< std::string > fBinByBinLabels
QTextStream & bin(QTextStream &s)
std::vector< std::vector< float > > fBinByBinMetricErrorVec
QTextStream & endl(QTextStream &s)
NearlinePlotEnables fPlotEnables
Int_t GMToffset
std::vector< float > fMetricVec
bool NearlinePlot::AddHistogram1D ( TFile const &  file,
TTree *  header,
int  Xsrtime,
int  XNow,
int  GMToffset,
int  time_ago 
)
bool NearlinePlot::AddHistogram2D ( TFile const &  file,
TTree *  header,
int  Xsrtime,
int  XNow,
int  GMToffset,
int  time_ago 
)
bool NearlinePlot::AddHistogram2D ( TFile const &  file,
TTree *  header,
int  Xsrtime,
int  XNow,
int  GMToffset,
int  time_ago 
)

Definition at line 338 of file NearlinePlotMaker.h.

338  {
339 
340  TH1F *hist_temp = (TH1F*)file.FindObjectAny(fHistName.c_str());
341  if(hist_temp != 0){
342  if(fHistogram2D == 0){
343  int nbinsx = hist_temp->GetNbinsX();
344  double xmin = hist_temp->GetBinLowEdge(1);
345  double xmax = hist_temp->GetBinLowEdge(1+nbinsx);
346  int nbinst = 72;//FIXME
347  double tmin = time_ago;
348  double tmax = XNow;
349  fHistogram2D = new TH2F((fHistName + "_vs_time").c_str(), (std::string(hist_temp->GetTitle()) + " - vs Time").c_str(), nbinst, tmin, tmax, nbinsx, xmin, xmax);
350  // fHistogram2D->GetXaxis()->SetTitle("x axis");
351  fHistogram2D->GetYaxis()->SetTitle(hist_temp->GetXaxis()->GetTitle());
352  fHistogram2D->GetZaxis()->SetTitle(hist_temp->GetYaxis()->GetTitle());
353 
354  //Also make the normalisation histogram
355  fHistogram2DNormalisation = new TH1F((fHistName + "_normalisation").c_str(), (std::string(hist_temp->GetName()) + " Normalisation").c_str(), nbinst, tmin, tmax);
356 
357  //Make sure we keep the histograms in memory
358  fHistogram2D->SetDirectory(0);
359  fHistogram2DNormalisation->SetDirectory(0);
360 
361  //Get bin labels
362  int nbins = hist_temp->GetNbinsX();
363  for(int i=0;i<=nbins+1;i++){
364  std::string label = hist_temp->GetXaxis()->GetBinLabel(i);
365  if(label != "") {
366  fHistogram2D->GetYaxis()->SetBinLabel(i, label.c_str());
367  fHistogram2D->GetYaxis()->SetLabelSize(hist_temp->GetXaxis()->GetLabelSize());
368  }
369  }//bins
370  }//make TH2
371  }//Got TH1
372  else{
373  // std::cerr << "NearlinePlot::AddHistogram2D - Failed to find histogram - " << fHistName << std::endl;
374  return false;
375  }
376  if(hist_temp != 0 && header != 0 && Xsrtime != XNow - GMToffset) {
377  //Now add this th1 to the th2
378  int nbins = hist_temp->GetNbinsX();
379  if(fHistogram->GetNbinsX() != hist_temp->GetNbinsX()){
380  // std::cerr << "ERROR: " << file.GetName() << " " << fHistogram->GetName() << " " << fHistogram->GetNbinsX() << " bins vs " << hist_temp->GetNbinsX() << std::endl;
381  return false;
382  }
383  if(hist_temp->GetEntries() == 0){
384  // std::cerr << "ERROR: " << file.GetName() << " " << fHistogram->GetName() << " Has no entries" << std::endl;
385  return false;
386  }
387 
388  for(int i=0;i<=nbins+1;i++){
389  double content = hist_temp->GetBinContent(i);
390  double center = hist_temp->GetBinCenter(i);
391  fHistogram2D->Fill(Xsrtime, center, content);
392  }//loops over the histogram bins
393 
394  //Add Entry to our normalisation
395  fHistogram2DNormalisation->Fill(Xsrtime);
396  return true;
397  }
398  // std::cerr << "NearlinePlot::AddHistogram2D - Failed - Shouldn't get here" << std::endl;
399  return false;
400 }
std::string string
Definition: nybbler.cc:12
TH1F * fHistogram2DNormalisation
std::string fHistName
def center(depos, point)
Definition: depos.py:117
Int_t GMToffset
TCanvas * NearlinePlot::makeBinByBinGraphTime ( unsigned int  bin,
TPaveText *  updateText,
int  time_ago,
int  XNow,
int  width = 1200,
int  height = 800,
std::string  taxis_labels = "" 
)

Definition at line 473 of file NearlinePlotMaker.h.

473  {
474 
475 
476  if(bin >= fBinByBinMetricVec.size()) return NULL;
477 
478  std::string can_name = fHistName + "_time_bin_";
479  std::string can_title = fHistTitle;
480  if(fBinByBinLabels.at(bin) == "" ){
481  can_name += std::to_string(bin);
482  can_title += + " Bin " + std::to_string(bin);
483  }
484  else{
485  can_title += " " + fBinByBinLabels.at(bin);
486  }
487 
488  TCanvas* can = new TCanvas(can_name.c_str(), can_title.c_str(), width, height);
489  can->cd();
490  gPad->SetGridx();
491 
492  TGraphErrors* gr = new TGraphErrors(fPlotCount);
493  for(int i=0;i<fPlotCount;i++) gr->SetPoint(i, fTimeVec.at(i), fBinByBinMetricVec.at(bin).at(i));
494  for(int i=0;i<fPlotCount;i++) gr->SetPointError(i, 0, fBinByBinMetricErrorVec.at(bin).at(i));
495 
496  gr->SetTitle(can_title.c_str());
497  gr->SetMarkerColor(kBlue);
498  gr->GetYaxis()->SetTitle(fBinByBinYAxisTitle.c_str());
499  gr->GetXaxis()->SetTimeDisplay(1);
500  gr->GetXaxis()->SetLabelSize(0.03);
501 
502  if(taxis_labels==""){
503  if(fPlotInfo.fNumDays <= 2) taxis_labels = "%H:%M";
504  else taxis_labels = "%m/%d";
505  }
506 
507  gr->GetXaxis()->SetTimeFormat(taxis_labels.c_str());
508  gr->GetXaxis()->SetLimits(time_ago,XNow);
509  gr->GetXaxis()->SetTitle("(central time)");
510  gr->Draw("A*");
511 
512  updateText->Draw();
513 
514  int maxtime = 0;
515  double max = 0.0, ave = 0.0;
516  TPaveText *LastPoint = new TPaveText(0.3,0.88,0.93,0.93,"NDC");
517  LastPoint->SetLineColor(1);
518  LastPoint->SetFillColor(0);
519  LastPoint->SetBorderSize(1);
520  char lptext[128];
521  maxtime = 0;
522  max = 0.0;
523  ave = 0.0;
524  for(int i = 0; i < fPlotCount; ++i) {
525  ave += (double)fMetricVec.at(i);
526  if(fTimeVec.at(i) > maxtime) {
527  maxtime = fTimeVec.at(i);
528  max = fMetricVec.at(i);
529  }
530  }
531  if(fPlotCount > 0) ave = ave/(double)fPlotCount;
532  sprintf(lptext,"Last Point = %f / Average = %f",max,ave);
533  LastPoint->Clear();
534  LastPoint->AddText(lptext);
535 
536 
537  LastPoint->Draw();
538 
539  return can;
540 
541 
542 }
std::vector< std::vector< float > > fBinByBinMetricVec
std::string string
Definition: nybbler.cc:12
std::string fHistTitle
std::string fBinByBinYAxisTitle
std::vector< float > fTimeVec
std::string fHistName
static int max(int a, int b)
std::vector< std::string > fBinByBinLabels
QTextStream & bin(QTextStream &s)
std::vector< std::vector< float > > fBinByBinMetricErrorVec
std::string to_string(ModuleType const mt)
Definition: ModuleType.h:34
std::vector< float > fMetricVec
NearlinePlotInfo fPlotInfo
TCanvas* NearlinePlot::makeBinByBinGraphTime ( unsigned int  bin,
TPaveText *  updateText,
int  time_ago,
int  XNow,
int  width = 1200,
int  height = 800,
std::string  taxis_labels = "" 
)
TCanvas* NearlinePlot::makeGraphMetricTimeCanvas ( TPaveText *  updateText,
int  time_ago,
int  XNow,
bool  rms = false,
bool  zoom = false,
int  width = 1200,
int  height = 800,
std::string  taxis_labels = "" 
)
TCanvas * NearlinePlot::makeGraphMetricTimeCanvas ( TPaveText *  updateText,
int  time_ago,
int  XNow,
bool  rms = false,
bool  zoom = false,
int  width = 1200,
int  height = 800,
std::string  taxis_labels = "" 
)

Definition at line 544 of file NearlinePlotMaker.h.

544  {
545 
546  std::string can_name;
547  if(rms) can_name= fHistName + "_rms_time_can";
548  else can_name= fHistName + "_metric_time_can";
549 
550  std::string can_title;
551  if(rms) can_title = "RMS of " + fHistTitle;
552  else can_title = "Mean of " + fHistTitle;
553 
554 
555  if(zoom) can_name += "_zoom";
556 
557 
558  TCanvas* can = new TCanvas(can_name.c_str(), can_title.c_str(), width, height);
559  can->cd();
560  gPad->SetGridx();
561 
562  TGraph* gr;
563  std::vector<float> yValuesVec;
564  if(rms){
565  fGraphMetricRmsTime = new TGraph(fPlotCount);
566  gr = fGraphMetricRmsTime;
567  yValuesVec = fMetricRmsVec;
568  }
569  else{
570  fGraphMetricTime = new TGraph(fPlotCount);
571  gr = fGraphMetricTime;
572  yValuesVec = fMetricVec;
573  }
574 
575 
576  for(int i=0;i<fPlotCount;i++) gr->SetPoint(i, fTimeVec.at(i), yValuesVec.at(i));
577 
578  gr->SetMarkerColor(kBlue);
579  gr->GetXaxis()->SetTimeDisplay(1);
580  gr->GetXaxis()->SetLabelSize(0.03);
581 
582  if(taxis_labels==""){
583  if(fPlotInfo.fNumDays <= 2) taxis_labels = "%H:%M";
584  else taxis_labels = "%m/%d";
585  }
586 
587  gr->GetXaxis()->SetTimeFormat(taxis_labels.c_str());
588  gr->GetXaxis()->SetLimits(time_ago,XNow);
589  gr->GetXaxis()->SetTitle("(central time)");
590  gr->Draw("A*");
591 
592  if(zoom){
593  graphZoom(gr, 2.0);
594  gr->SetTitle(std::string(can_title + " - Zoom").c_str());
595  }
596  else gr->SetTitle(can_title.c_str());
597 
598  updateText->Draw();
599 
600  int maxtime = 0;
601  double max = 0.0, ave = 0.0;
602  TPaveText *LastPoint = new TPaveText(0.3,0.88,0.93,0.93,"NDC");
603  LastPoint->SetLineColor(1);
604  LastPoint->SetFillColor(0);
605  LastPoint->SetBorderSize(1);
606  char lptext[128];
607  maxtime = 0;
608  max = 0.0;
609  ave = 0.0;
610  for(int i = 0; i < fPlotCount; ++i) {
611  ave += (double)fMetricVec.at(i);
612  if(fTimeVec.at(i) > maxtime) {
613  maxtime = fTimeVec.at(i);
614  max = fMetricVec.at(i);
615  }
616  }
617  if(fPlotCount > 0) ave = ave/(double)fPlotCount;
618  sprintf(lptext,"Last Point = %f / Average = %f",max,ave);
619  LastPoint->Clear();
620  LastPoint->AddText(lptext);
621 
622 
623  LastPoint->Draw();
624 
625  return can;
626 
627 }
TGraph * fGraphMetricTime
double rms(sqlite3 *db, std::string const &table_name, std::string const &column_name)
Definition: statistics.cc:39
void graphZoom(TGraph *gr, double n_sigma)
std::string string
Definition: nybbler.cc:12
std::string fHistTitle
std::vector< float > fMetricRmsVec
TGraph * fGraphMetricRmsTime
std::vector< float > fTimeVec
std::string fHistName
static int max(int a, int b)
std::vector< float > fMetricVec
NearlinePlotInfo fPlotInfo
TCanvas * NearlinePlot::makeGraphTimeCanvas ( std::string  can_name,
std::string  can_title,
int  width,
int  height 
)

Definition at line 122 of file NearlinePlotMakerJPD.h.

122  {
123  TCanvas* can = new TCanvas(can_name.c_str(), can_title.c_str(), width, height);
124  can->cd();
125  gPad->SetGridx();
126  fGraphTime = new TGraph(fPlotCount);
127  for(int i=0;i<fPlotCount;i++) fGraphTime->SetPoint(i, fTimeVec.at(i), fMetricVec.at(i));
128 
129  fGraphTime->SetTitle(can_title.c_str());
130  fGraphTime->SetMarkerColor(kBlue);
131  fGraphTime->GetXaxis()->SetTimeDisplay(1);
132  fGraphTime->GetXaxis()->SetLabelSize(0.03);
133  fGraphTime->GetXaxis()->SetTimeFormat(taxis_labels.c_str());
134  fGraphTime->GetXaxis()->SetLimits(time_ago,XNow);
135  fGraphTime->GetXaxis()->SetTitle("(central time)");
136  fGraphTime->Draw("A*");
137 
138  updateText->Draw();
139 
140  int maxtime = 0;
141  double max = 0.0, ave = 0.0;
142  TPaveText *LastPoint = new TPaveText(0.3,0.88,0.93,0.93,"NDC");
143  LastPoint->SetLineColor(1);
144  LastPoint->SetFillColor(0);
145  LastPoint->SetBorderSize(1);
146  char lptext[128];
147  maxtime = 0;
148  max = 0.0;
149  ave = 0.0;
150  for(int i = 0; i < fPlotCount; ++i) {
151  ave += (double)fMetricVec.at(i);
152  if(fTimeVec.at(i) > maxtime) {
153  maxtime = fTimeVec.at(i);
154  max = fMetricVec.at(i);
155  }
156  }
157  if(fPlotCount > 0) ave = ave/(double)fPlotCount;
158  sprintf(lptext,"Last Point = %f / Average = %f",max,ave);
159  LastPoint->Clear();
160  LastPoint->AddText(lptext);
161 
162 
163  LastPoint->Draw();
164 
165  return can;
166 
167 }
std::vector< float > fTimeVec
static int max(int a, int b)
std::vector< float > fMetricVec
TCanvas* NearlinePlot::makeHisto2DCanvas ( TPaveText *  updateText,
int  time_ago,
int  XNow,
int  width = 1200,
int  height = 800,
std::string  taxis_labels = "" 
)
TCanvas * NearlinePlot::makeHisto2DCanvas ( TPaveText *  updateText,
int  time_ago,
int  XNow,
int  width = 1200,
int  height = 800,
std::string  taxis_labels = "" 
)

Definition at line 429 of file NearlinePlotMaker.h.

429  {
430 
431  std::string can_name = fHistName + "_vs_time_can";
432  std::string can_title = fHistName + "_vs_time_can";
433 
434  TCanvas *can = new TCanvas(can_name.c_str(), can_title.c_str(), width, height);
435  can->cd();
436  if(fPlotLogScale.fHisto2DLog) can->SetLogz();
437  can->SetRightMargin(0.15);
438  gStyle->SetOptStat(0);
439  gPad->SetGridx();
440  gPad->SetGridy();
441  if(taxis_labels==""){
442  if(fPlotInfo.fNumDays <= 2) taxis_labels = "%H:%M";
443  else taxis_labels = "%m/%d";
444  }
445 
446  if(fNormalised!=true){
447  for(int xbin=1;xbin<=fHistogram2D->GetNbinsX();xbin++){
448  double norm = fHistogram2DNormalisation->GetBinContent(xbin);
449  if(norm <= 0.0) continue;
450  for(int ybin=1;ybin<=fHistogram2D->GetNbinsY();ybin++){
451  int global_bin = fHistogram2D->GetBin(xbin, ybin);
452  double content = fHistogram2D->GetBinContent(global_bin);
453  if(content <= 0.0) continue;
454  fHistogram2D->SetBinContent(global_bin, content/norm);
455  }//ybin
456  }//xbin
457  fNormalised=true;
458  }//Normalise
459 
460 
461  fHistogram2D->GetXaxis()->SetTimeFormat(taxis_labels.c_str());
462  fHistogram2D->GetXaxis()->SetLimits(time_ago,XNow);
463  fHistogram2D->GetXaxis()->SetTitle("(central time)");
464  fHistogram2D->GetXaxis()->SetTimeDisplay(1);
465  fHistogram2D->GetXaxis()->SetLabelSize(0.03);
466  fHistogram2D->Draw("COLZ");
467  updateText->Draw();
468 
469 
470  return can;
471 }
std::string string
Definition: nybbler.cc:12
NearlinePlotLogScale fPlotLogScale
TH1F * fHistogram2DNormalisation
std::string fHistName
auto norm(Vector const &v)
Return norm of the specified vector.
NearlinePlotInfo fPlotInfo
TCanvas * NearlinePlot::makeHistoCanvas ( std::string  can_name,
std::string  can_title,
int  width,
int  height,
TPaveText *  updateText 
)

Definition at line 110 of file NearlinePlotMakerJPD.h.

110  {
111  TCanvas *can = new TCanvas(can_name.c_str(), can_title.c_str(), width, height);
112  can->cd();
113  can->SetLogy();
114  gStyle->SetOptStat(111111);
115  fHistogram->SetLineWidth(2);
116  fHistogram->SetLineColor(kRed);
117  updateText->Draw();
118 
119  return can;
120 }
TCanvas* NearlinePlot::makeHistoCanvas ( TPaveText *  updateText,
int  width = 1200,
int  height = 800 
)
TCanvas * NearlinePlot::makeHistoCanvas ( TPaveText *  updateText,
int  width = 1200,
int  height = 800 
)

Definition at line 406 of file NearlinePlotMaker.h.

406  {
407 
409 
410  std::string can_name = fHistName + "_can";
411  std::string can_title = fHistName + "_can";
412 
413  TCanvas *can = new TCanvas(can_name.c_str(), can_title.c_str(), width, height);
414  can->cd();
415  gPad->SetGridx();
416  gPad->SetGridy();
417  if(fPlotLogScale.fHisto1DLog) can->SetLogy();
418  if(!(fPlotEnables.fNormaliseHisto1D)) gStyle->SetOptStat(111111);
419  fHistogram->SetLineWidth(2);
420  fHistogram->SetLineColor(kRed);
421  fHistogram->SetName(fHistName.c_str());
422  fHistogram->Draw();
423  updateText->Draw();
424 
425 
426  return can;
427 }
std::string string
Definition: nybbler.cc:12
NearlinePlotLogScale fPlotLogScale
std::string fHistName
NearlinePlotEnables fPlotEnables
void NearlinePlot::normaliseHisto1D ( )

Definition at line 402 of file NearlinePlotMaker.h.

402  {
403  if(fPlotCount>0) fHistogram->Scale(1./fPlotCount);
404 }
void NearlinePlot::normaliseHisto1D ( )
void NearlinePlot::printBinByBinGraphs ( std::string  plot_dir,
TPaveText *  updateText,
int  time_ago,
int  XNow,
int  width = 1200,
int  height = 800,
std::string  taxis_labels = "" 
)

Definition at line 655 of file NearlinePlotMaker.h.

655  {
656 
657  TCanvas *can;
658  std::string can_name;
659 
660  for(unsigned int bin=0;bin<fBinByBinMetricVec.size();bin++){
661  can = makeBinByBinGraphTime(bin, updateText, time_ago, XNow);
662  can_name = plot_dir + "/" + fPlotInfo.GetBinByBinTimeGraphName(bin);
663  can->Print(can_name.c_str());
664  delete can;
665  }//bin
666 
667 }
std::vector< std::vector< float > > fBinByBinMetricVec
std::string string
Definition: nybbler.cc:12
TCanvas * makeBinByBinGraphTime(unsigned int bin, TPaveText *updateText, int time_ago, int XNow, int width=1200, int height=800, std::string taxis_labels="")
std::string GetBinByBinTimeGraphName(unsigned int bin)
QTextStream & bin(QTextStream &s)
NearlinePlotInfo fPlotInfo
void NearlinePlot::printBinByBinGraphs ( std::string  plot_dir,
TPaveText *  updateText,
int  time_ago,
int  XNow,
int  width = 1200,
int  height = 800,
std::string  taxis_labels = "" 
)
void NearlinePlot::printGraphs ( std::string  plot_dir,
TPaveText *  updateText,
int  time_ago,
int  XNow,
int  width = 1200,
int  height = 800,
std::string  taxis_labels = "" 
)
void NearlinePlot::printGraphs ( std::string  plot_dir,
TPaveText *  updateText,
int  time_ago,
int  XNow,
int  width = 1200,
int  height = 800,
std::string  taxis_labels = "" 
)

Definition at line 669 of file NearlinePlotMaker.h.

669  {
670 
671  bool zoom;
672  bool rms;
673  TCanvas *can;
674  std::string can_name;
675 
676  rms=false;
677 
678  zoom=false;
679  can = makeGraphMetricTimeCanvas(updateText, time_ago, XNow, rms, zoom);
680  can_name = plot_dir + "/" + fPlotInfo.GetMetricMeanTimeGraphName(zoom);
681  can->Print(can_name.c_str());
682 
683  delete can;
684 
685  zoom=true;
686  can = makeGraphMetricTimeCanvas(updateText, time_ago, XNow, rms, zoom);
687  can_name = plot_dir + "/" + fPlotInfo.GetMetricMeanTimeGraphName(zoom);
688  can->Print(can_name.c_str());
689 
690  delete can;
691 
692  rms=true;
693 
694  zoom=false;
695  can = makeGraphMetricTimeCanvas(updateText, time_ago, XNow, rms, zoom);
696  can_name = plot_dir + "/" + fPlotInfo.GetMetricRmsTimeGraphName(zoom);
697  can->Print(can_name.c_str());
698 
699  delete can;
700 
701  zoom=true;
702  can = makeGraphMetricTimeCanvas(updateText, time_ago, XNow, rms, zoom);
703  can_name = plot_dir + "/" + fPlotInfo.GetMetricRmsTimeGraphName(zoom);
704  can->Print(can_name.c_str());
705 
706  delete can;
707 
708 }
std::string GetMetricMeanTimeGraphName(bool zoom=false)
double rms(sqlite3 *db, std::string const &table_name, std::string const &column_name)
Definition: statistics.cc:39
std::string string
Definition: nybbler.cc:12
TCanvas * makeGraphMetricTimeCanvas(TPaveText *updateText, int time_ago, int XNow, bool rms=false, bool zoom=false, int width=1200, int height=800, std::string taxis_labels="")
std::string GetMetricRmsTimeGraphName(bool zoom=false)
NearlinePlotInfo fPlotInfo
void NearlinePlot::printHistogram1D ( std::string  plot_dir,
TPaveText *  updateText,
int  time_ago,
int  XNow,
int  width = 1200,
int  height = 800,
std::string  taxis_labels = "" 
)

Definition at line 641 of file NearlinePlotMaker.h.

641  {
642  TCanvas* can = makeHistoCanvas(updateText, width, height);
643  std::string can_name = plot_dir + "/" + fPlotInfo.GetHistOutputName();
644  can->Print(can_name.c_str());
645  delete can;
646 }
TCanvas * makeHistoCanvas(TPaveText *updateText, int width=1200, int height=800)
std::string string
Definition: nybbler.cc:12
std::string GetHistOutputName()
NearlinePlotInfo fPlotInfo
void NearlinePlot::printHistogram1D ( std::string  plot_dir,
TPaveText *  updateText,
int  time_ago,
int  XNow,
int  width = 1200,
int  height = 800,
std::string  taxis_labels = "" 
)
void NearlinePlot::printHistogram2D ( std::string  plot_dir,
TPaveText *  updateText,
int  time_ago,
int  XNow,
int  width = 1200,
int  height = 800,
std::string  taxis_labels = "" 
)
void NearlinePlot::printHistogram2D ( std::string  plot_dir,
TPaveText *  updateText,
int  time_ago,
int  XNow,
int  width = 1200,
int  height = 800,
std::string  taxis_labels = "" 
)

Definition at line 648 of file NearlinePlotMaker.h.

648  {
649  TCanvas* can = makeHisto2DCanvas(updateText, time_ago, XNow, width, height, taxis_labels);
650  std::string can_name = plot_dir + "/" + fPlotInfo.GetHist2DOutputName();
651  can->Print(can_name.c_str());
652  delete can;
653 }
std::string string
Definition: nybbler.cc:12
std::string GetHist2DOutputName()
TCanvas * makeHisto2DCanvas(TPaveText *updateText, int time_ago, int XNow, int width=1200, int height=800, std::string taxis_labels="")
NearlinePlotInfo fPlotInfo
void NearlinePlot::printPlots ( std::string  plot_dir,
TPaveText *  updateText,
int  time_ago,
int  XNow,
int  width = 1200,
int  height = 800,
std::string  taxis_labels = "" 
)
void NearlinePlot::printPlots ( std::string  plot_dir,
TPaveText *  updateText,
int  time_ago,
int  XNow,
int  width = 1200,
int  height = 800,
std::string  taxis_labels = "" 
)

Definition at line 629 of file NearlinePlotMaker.h.

629  {
630 
631  printHistogram1D(plot_dir, updateText, time_ago, XNow, width, height, taxis_labels);
632 
633  if(fPlotEnables.fMake2DHisto) printHistogram2D(plot_dir, updateText, time_ago, XNow, width, height, taxis_labels);
634 
635  if(fPlotEnables.fMakeMetricTimeGraph) printGraphs(plot_dir, updateText, time_ago, XNow, width, height, taxis_labels);
636 
637  if(fPlotEnables.fMakeBinByBinPlots) printBinByBinGraphs(plot_dir, updateText, time_ago, XNow, width, height, taxis_labels);
638 
639 }
void printBinByBinGraphs(std::string plot_dir, TPaveText *updateText, int time_ago, int XNow, int width=1200, int height=800, std::string taxis_labels="")
void printHistogram1D(std::string plot_dir, TPaveText *updateText, int time_ago, int XNow, int width=1200, int height=800, std::string taxis_labels="")
void printHistogram2D(std::string plot_dir, TPaveText *updateText, int time_ago, int XNow, int width=1200, int height=800, std::string taxis_labels="")
void printGraphs(std::string plot_dir, TPaveText *updateText, int time_ago, int XNow, int width=1200, int height=800, std::string taxis_labels="")
NearlinePlotEnables fPlotEnables
void NearlinePlot::setHistTitle ( std::string  hist_title)

Definition at line 248 of file NearlinePlotMaker.h.

248  {
249  fHistTitle = hist_title;
250 }
std::string fHistTitle
void NearlinePlot::setHistTitle ( std::string  hist_title)
void NearlinePlot::setMetricDetails ( std::string  metric_details)
void NearlinePlot::setMetricDetails ( std::string  metric_details)

Definition at line 256 of file NearlinePlotMaker.h.

256  {
257  fPlotInfo.AddMetricDetails(metric_details);
258 }
void AddMetricDetails(std::string metric_details)
NearlinePlotInfo fPlotInfo
void NearlinePlot::setPlotInfo ( NearlinePlotInfo  this_plot_info)

Definition at line 252 of file NearlinePlotMaker.h.

252  {
253  fPlotInfo = this_plot_info;
254 }
NearlinePlotInfo fPlotInfo
void NearlinePlot::setPlotInfo ( NearlinePlotInfo  this_plot_info)

Member Data Documentation

std::vector< TGraphErrors * > NearlinePlot::fBinByBinGraphMetricTime

Definition at line 187 of file NearlinePlotMaker.h.

std::vector< std::string > NearlinePlot::fBinByBinLabels

Definition at line 190 of file NearlinePlotMaker.h.

std::vector< std::vector< float > > NearlinePlot::fBinByBinMetricErrorVec

Definition at line 189 of file NearlinePlotMaker.h.

std::vector< std::vector< float > > NearlinePlot::fBinByBinMetricVec

Definition at line 188 of file NearlinePlotMaker.h.

std::string NearlinePlot::fBinByBinYAxisTitle

Definition at line 191 of file NearlinePlotMaker.h.

TGraph * NearlinePlot::fGraphMetricRmsTime

Definition at line 181 of file NearlinePlotMaker.h.

TGraph * NearlinePlot::fGraphMetricTime

Definition at line 180 of file NearlinePlotMaker.h.

TGraph* NearlinePlot::fGraphTime

Definition at line 58 of file NearlinePlotMakerJPD.h.

std::string NearlinePlot::fHistName

Definition at line 172 of file NearlinePlotMaker.h.

TH1F * NearlinePlot::fHistogram

Definition at line 171 of file NearlinePlotMaker.h.

TH2F * NearlinePlot::fHistogram2D

Definition at line 176 of file NearlinePlotMaker.h.

TH1F * NearlinePlot::fHistogram2DNormalisation

Definition at line 177 of file NearlinePlotMaker.h.

std::string NearlinePlot::fHistTitle

Definition at line 174 of file NearlinePlotMaker.h.

bool NearlinePlot::fMakeHistogram

Definition at line 67 of file NearlinePlotMakerJPD.h.

std::vector< float > NearlinePlot::fMetricRmsVec

Definition at line 183 of file NearlinePlotMaker.h.

std::vector< float > NearlinePlot::fMetricVec

Definition at line 182 of file NearlinePlotMaker.h.

bool NearlinePlot::fNormalised

Definition at line 178 of file NearlinePlotMaker.h.

int NearlinePlot::fNumPoints

Definition at line 61 of file NearlinePlotMakerJPD.h.

std::string NearlinePlot::fOutputName

Definition at line 60 of file NearlinePlotMakerJPD.h.

int NearlinePlot::fPlotCount

Definition at line 185 of file NearlinePlotMaker.h.

NearlinePlotEnables NearlinePlot::fPlotEnables

Definition at line 168 of file NearlinePlotMaker.h.

NearlinePlotInfo NearlinePlot::fPlotInfo

Definition at line 173 of file NearlinePlotMaker.h.

NearlinePlotLogScale NearlinePlot::fPlotLogScale

Definition at line 169 of file NearlinePlotMaker.h.

bool NearlinePlot::fRMSPlot

Definition at line 66 of file NearlinePlotMakerJPD.h.

std::vector< float > NearlinePlot::fTimeVec

Definition at line 184 of file NearlinePlotMaker.h.


The documentation for this struct was generated from the following files: