StripHist Class Reference

#include <StripHist.h>

List of all members.

Public Member Functions

 StripHist (const char *name, const char *title)
 Create a StripHist.
 StripHist (const char *name, const char *title, int nbin, double minbin, double maxbin)
TGraph & GetStrip ()
 Access the strip TGraph.
TH1D & GetHist ()
 Access the TH1D histogram.
void Fill (double x, double y, double histweight=1.0)
void SetLineColor (int color=0)
 Sets the Line Color of the TGraph.
void SetStripRange (double range)
void SetMaxStripEntries (int max)
void SetGraphYTitle (const char *title="")
 Set Y axis on Graph.
void Draw (Option_t *option="")
void DrawStrip (Option_t *option="")
 Draw ONLY the strip graph. The option is for the strip.
void DrawHist (Option_t *option="")
 Draw ONLY the strip hist. The option is for the strip.
void Reset ()
 Reset histogram and graph.
double GetMin ()
 Get Minimum Y value of Graph.
double GetMax ()
 Get Maximum Y value of Graph.

Private Attributes

TGraph * fStrip
TH1D * fHist
double fStripRange
int fMaxStripEntries
std::string fYtitle


Detailed Description

Definition at line 19 of file StripHist.h.


Constructor & Destructor Documentation

StripHist::StripHist ( const char *  name,
const char *  title 
)

Create a StripHist.

Definition at line 8 of file StripHist.cxx.

References fHist, Form(), and fStrip.

00009     : fStrip(new TGraph)
00010     , fHist(new TH1D)
00011     , fStripRange(0)
00012     , fMaxStripEntries(0)
00013     , fYtitle("")
00014 {
00015     fStrip->SetName(Form("%s Strip Chart",name));
00016     fStrip->SetTitle(title);
00017     fHist->SetName(Form("%s Histogram",name));
00018     fHist->SetTitle(title);
00019 }

StripHist::StripHist ( const char *  name,
const char *  title,
int  nbin,
double  minbin,
double  maxbin 
)

Definition at line 21 of file StripHist.cxx.

References Form(), and fStrip.

00023     : fStrip(new TGraph)
00024     , fHist(new TH1D(Form("%s Histogram",name),title,nbin,minbin,maxbin))
00025     , fStripRange(0)
00026     , fMaxStripEntries(0)
00027 {
00028     fStrip->SetName(Form("%s Strip Chart",name));
00029     fStrip->SetTitle(title);
00030 }


Member Function Documentation

void StripHist::Draw ( Option_t *  option = ""  ) 

Draw the strip hist onto the current pad. The option is for the strip.

Definition at line 37 of file StripHist.cxx.

References fHist, and fStrip.

Referenced by TempModule::BeginJob(), NpotModule::BeginJob(), and LossModule::BeginJob().

00038 {
00039     TVirtualPad* pad = gPad, *oldpad = gPad;
00040 
00041     pad->Divide(1,2);
00042     pad->cd(1);
00043     fHist->Draw();
00044     pad->cd(2);
00045     fStrip->Draw(option);
00046     oldpad->cd();
00047 }

void StripHist::DrawHist ( Option_t *  option = ""  ) 

Draw ONLY the strip hist. The option is for the strip.

Definition at line 58 of file StripHist.cxx.

References fHist.

00059 {
00060     TVirtualPad* pad = gPad, *oldpad = gPad;
00061   
00062     pad->cd();
00063     fHist->Draw(option);
00064     oldpad->cd();
00065 }

void StripHist::DrawStrip ( Option_t *  option = ""  ) 

Draw ONLY the strip graph. The option is for the strip.

Definition at line 49 of file StripHist.cxx.

References fStrip.

Referenced by TargetModule::BeginJob(), and HadMuMonModule::BeginJob().

00050 {
00051     TVirtualPad* pad = gPad, *oldpad = gPad;
00052 
00053     pad->cd();
00054     fStrip->Draw(option);
00055     oldpad->cd();
00056 }

void StripHist::Fill ( double  x,
double  y,
double  histweight = 1.0 
)

Add point x,y to the strip chart and fill histogram with y and optional histweight

Definition at line 67 of file StripHist.cxx.

References fHist, fMaxStripEntries, fStrip, fStripRange, and fYtitle.

Referenced by TempModule::Fill(), TargetModule::Fill(), NpotModule::Fill(), LossModule::Fill(), and HornModule::Fill().

00068 {
00069     fHist->Fill(y,histweight);
00070 
00071     if (fStripRange>0) {
00072         for (int n = fStrip->GetN(); 
00073              n > 2 && fStrip->GetX()[n-1]-fStrip->GetX()[0] > fStripRange;
00074              n = fStrip->GetN()) {
00075             fStrip->RemovePoint(0);
00076         }
00077     }
00078 
00079     if (fMaxStripEntries) {
00080         
00081         for (int n = fStrip->GetN(); n > fMaxStripEntries; n = fStrip->GetN()) {
00082             fStrip->RemovePoint(0);
00083         }
00084     }
00085 
00086     fStrip->SetPoint(fStrip->GetN(),x,y);
00087     
00088     // Evidently this crap needs to be done each update.  Sigh.
00089 
00090     TH1F* frame = fStrip->GetHistogram();
00091     TAxis* axis = frame->GetXaxis();
00092     axis->SetTimeDisplay(1);
00093     axis->SetTimeFormat("%b %d %H:%M:%S %Z");
00094     axis->SetNdivisions(202,false);
00095     axis->SetAxisColor(2);
00096     TH1F* frame2 = fStrip->GetHistogram();
00097     TAxis* axis2 = frame2->GetYaxis();
00098     axis2->SetTitle(fYtitle.c_str());
00099     axis2->CenterTitle();
00100 
00101 }

TH1D& StripHist::GetHist (  )  [inline]

Access the TH1D histogram.

Definition at line 38 of file StripHist.h.

References fHist.

Referenced by TempModule::BeginJob(), TargetModule::BeginJob(), NpotModule::BeginJob(), and LossModule::BeginJob().

00038 { return *fHist; }

double StripHist::GetMax (  ) 

Get Maximum Y value of Graph.

Definition at line 125 of file StripHist.cxx.

References fStrip, and max.

Referenced by GetMin(), TargetModule::RangeFinder(), and HadMuMonModule::RangeFinder().

00126 {
00127     if(fStrip->GetN() == 0) return 0.0;
00128     double max = 0.0, x = 0.0, y = 0.0;
00129     for(int i=0; i<fStrip->GetN(); i++) {
00130         fStrip->GetPoint(i, x, y);
00131         if(y > max) max = y;
00132     }
00133     return max;
00134 }

double StripHist::GetMin (  ) 

Get Minimum Y value of Graph.

Definition at line 136 of file StripHist.cxx.

References fStrip, GetMax(), max, and min.

Referenced by TargetModule::RangeFinder(), and HadMuMonModule::RangeFinder().

00137 {
00138     if(fStrip->GetN() == 0) return 0.0;
00139     double max = this->GetMax();
00140     double min = max, x = 0.0, y = 0.0;
00141     for(int i=0; i<fStrip->GetN(); i++) {
00142         fStrip->GetPoint(i, x, y);
00143         if(y < min) min = y;
00144     }
00145     return min;
00146 }

TGraph& StripHist::GetStrip (  )  [inline]

Access the strip TGraph.

Definition at line 35 of file StripHist.h.

References fStrip.

Referenced by TargetModule::Fill(), and HadMuMonModule::Fill().

00035 { return *fStrip; }

void StripHist::Reset (  ) 

Reset histogram and graph.

Definition at line 117 of file StripHist.cxx.

References fHist, and fStrip.

00118 {
00119     fHist->Reset();
00120     for(int i=0; i<fStrip->GetN(); i++) {
00121         fStrip->RemovePoint(i);
00122     }
00123 }

void StripHist::SetGraphYTitle ( const char *  title = ""  ) 

Set Y axis on Graph.

Definition at line 103 of file StripHist.cxx.

References fYtitle.

Referenced by HadMuMonModule::HadMuMonModule(), and TargetModule::TargetModule().

00104 {
00105     fYtitle = title;
00106 }

void StripHist::SetLineColor ( int  color = 0  ) 

Sets the Line Color of the TGraph.

Definition at line 32 of file StripHist.cxx.

References fStrip.

Referenced by TargetModule::TargetModule().

00033 {
00034     if(color >=0 && color <= 50) fStrip->SetLineColor(color);
00035 }

void StripHist::SetMaxStripEntries ( int  max  ) 

Limit the number of entries in the strip chart. Upon a Fill() this will remove later entries until the limit is satisfied. Set to 0 (default) the range will be unlimited.

Definition at line 112 of file StripHist.cxx.

References fMaxStripEntries.

00113 {
00114     fMaxStripEntries = max;
00115 }

void StripHist::SetStripRange ( double  range  ) 

Limit the range of the displayed strip chart. Upon a Fill() this will remove later entries until the range is satisfied. Set to 0 (default) the range will be unlimited.

Definition at line 108 of file StripHist.cxx.

References fStripRange.

Referenced by NpotModule::NpotModule(), and TargetModule::TargetModule().

00109 {
00110     fStripRange = range;
00111 }


Member Data Documentation

TH1D* StripHist::fHist [private]

Definition at line 21 of file StripHist.h.

Referenced by Draw(), DrawHist(), Fill(), GetHist(), Reset(), and StripHist().

int StripHist::fMaxStripEntries [private]

Definition at line 24 of file StripHist.h.

Referenced by Fill(), and SetMaxStripEntries().

TGraph* StripHist::fStrip [private]

Definition at line 20 of file StripHist.h.

Referenced by Draw(), DrawStrip(), Fill(), GetMax(), GetMin(), GetStrip(), Reset(), SetLineColor(), and StripHist().

double StripHist::fStripRange [private]

Definition at line 23 of file StripHist.h.

Referenced by Fill(), and SetStripRange().

std::string StripHist::fYtitle [private]

Definition at line 25 of file StripHist.h.

Referenced by Fill(), and SetGraphYTitle().


The documentation for this class was generated from the following files:
Generated on Fri Oct 10 22:46:33 2014 for loon by  doxygen 1.4.7