Private Attributes

BCMTFComparisonTool Class Reference

A helper class for BCMTFAnalysisFacility storing information. More...

#include <BCMTFComparisonTool.h>

List of all members.

Public Member Functions

Constructors and destructors

 BCMTFComparisonTool (const char *name)
 ~BCMTFComparisonTool ()
Member functions (get)

std::string GetName ()
int GetNContributions ()
Member functions (miscellaneous methods)

void AddContribution (const char *name, TH1D hist)
void AddContribution (const char *name, double centralvalue, double uncertainty)
void DrawOverview ()
Member functions (output methods)

void PrintHistograms (const char *filename)
void PrintOverview (const char *filename)

Private Attributes

std::string fName
std::vector< std::string > fNameContainer
std::vector< TH1D * > fHistogramContainer
std::vector< double > fCentralValueContainer
std::vector< double > fUncertaintyContainer

Detailed Description

A helper class for BCMTFAnalysisFacility storing information.

Author:
Daniel Kollar
Kevin Kröninger
Version:
1.1
Date:
06.2012 This is a helper class for BCMTFAnalysisFacility storing information.

Definition at line 28 of file BCMTFComparisonTool.h.


Constructor & Destructor Documentation

BCMTFComparisonTool::BCMTFComparisonTool ( const char *  name  ) 

The default constructor.

Parameters:
name The name of the class.

Definition at line 21 of file BCMTFComparisonTool.cxx.

{
   fName = name;
}

BCMTFComparisonTool::~BCMTFComparisonTool (  ) 

The defaul destructor.

Definition at line 27 of file BCMTFComparisonTool.cxx.

{
   for (int i = 0; i < GetNContributions(); ++i) {
      if (fHistogramContainer.at(i))
         delete fHistogramContainer.at(i);
   }
}


Member Function Documentation

void BCMTFComparisonTool::AddContribution ( const char *  name,
TH1D  hist 
)

Add a constribution.

Parameters:
name The name of the contribution.
hist The histogram.

Definition at line 36 of file BCMTFComparisonTool.cxx.

{
   // add name to container
   fNameContainer.push_back(name);

   // add histogram to container
   fHistogramContainer.push_back(new TH1D(hist));

   // add central value to container
   fCentralValueContainer.push_back(hist.GetMean());

   // add uncertainty to container
   fUncertaintyContainer.push_back(hist.GetRMS());
}

void BCMTFComparisonTool::AddContribution ( const char *  name,
double  centralvalue,
double  uncertainty 
)

Add a constribution.

Parameters:
name The name of the contribution.
centralvalue The central value.
uncertainty The uncertainty.

Definition at line 52 of file BCMTFComparisonTool.cxx.

{
   // add name to container
   fNameContainer.push_back(name);

   // add 0 to container
   fHistogramContainer.push_back(0);

   // add central value to container
   fCentralValueContainer.push_back(centralvalue);

   // add uncertainty to container
   fUncertaintyContainer.push_back(uncertainty);
}

void BCMTFComparisonTool::DrawOverview (  ) 

Draw an overview.

Definition at line 104 of file BCMTFComparisonTool.cxx.

{
   // get number of contributions
   int ncontributions = GetNContributions();

   // create graph
   TGraphAsymmErrors * graph_contributions = new TGraphAsymmErrors(ncontributions);
   graph_contributions->SetMarkerStyle(20);
   graph_contributions->SetMarkerSize(1);

   // coordinate system
   double xmin = 0.0;
   double xmax = 0.0;
   double xwidth = 0.0;
   double ymin = -0.5;
   double ymax = double(ncontributions)-0.5;

   // ---- fill the graph ---- //

   // loop over all contributions
   for (int i = 0; i < ncontributions; ++i) {

      // get summary information
      double centralvalue = fCentralValueContainer.at(i);
      double uncertainty  = fUncertaintyContainer.at(i);

      // update coordinate system
      if ((centralvalue-uncertainty) < xmin || i == 0)
         xmin = centralvalue-uncertainty;
      if ((centralvalue+uncertainty) > xmax || i == 0)
         xmax = centralvalue+uncertainty;
      xwidth = xmax - xmin;

      // set point and error
      graph_contributions->SetPoint(i, centralvalue, double(ncontributions-i-1));
      graph_contributions->SetPointError(i, uncertainty, uncertainty, 0, 0);
   }

   // ---- do the plotting ---- //

   // create histogram for axes
   TH2D * hist_axes = new TH2D("", Form(";%s;", GetName().c_str()), 1, xmin - 0.25 *xwidth, xmax + 1.75 * xwidth, ncontributions, ymin, ymax);
   hist_axes->SetStats(kFALSE);
   hist_axes->GetYaxis()->SetNdivisions(0);
   hist_axes->GetYaxis()->SetTitleOffset(1.0);

   // create latex
   TLatex * latex = new TLatex();
   latex->SetTextSize(0.04);
   if (ncontributions>=10)
      latex->SetTextSize(0.02);
   latex->SetTextAlign(12);

   // draw
   hist_axes->Draw();
   graph_contributions->Draw("SAMEPZ");

   // loop over all contributions and draw labels
   for (int i = 0; i < ncontributions; ++i) {
      latex->DrawLatex(xmax + 0.25 *xwidth, double(ncontributions-i-1), fNameContainer.at(i).c_str());
   }
   hist_axes->Draw("SAMEAXIS");

   // debugKK
   // stuff doesn't get deleted
}

std::string BCMTFComparisonTool::GetName (  )  [inline]
Returns:
The name of the class.

Definition at line 51 of file BCMTFComparisonTool.h.

         { return fName; };

int BCMTFComparisonTool::GetNContributions (  )  [inline]
Returns:
The number of contributions.

Definition at line 56 of file BCMTFComparisonTool.h.

         { return (int) fHistogramContainer.size(); };

void BCMTFComparisonTool::PrintHistograms ( const char *  filename  ) 

Print all histograms to a file.

Parameters:
filename The name of the file.

Definition at line 68 of file BCMTFComparisonTool.cxx.

{
   // get number of histograms
   int nhistograms = (int) fHistogramContainer.size();

   // create canvas
   TCanvas * c1 = new TCanvas();
   c1->cd();

   // loop over all histograms
   for (int i = 0; i < nhistograms; ++i) {
      // get histogram
      TH1D * hist = fHistogramContainer.at(i);

      // set color
      hist->SetLineColor(2+i);

      // draw histogram
      if (i == 0) {
         hist->Draw("HIST");
         std::cout << " here as well." << std::endl;
      }
      else {
         hist->Draw("SAMEHIST");
         std::cout << " here as well 2." << std::endl;
      }
   }

   // print canvas
   c1->Print(filename);

   // free memory
   delete c1;
}

void BCMTFComparisonTool::PrintOverview ( const char *  filename  ) 

Print an overview to a file.

Parameters:
filename The name of the file.

Definition at line 172 of file BCMTFComparisonTool.cxx.

{
   // create canvas
   TCanvas * c1 = new TCanvas();
   c1->cd();

   // draw the overview
   DrawOverview();

   // print to file
   c1->Print(filename);
}


Member Data Documentation

std::vector<double> BCMTFComparisonTool::fCentralValueContainer [private]

A container of central values.

Definition at line 112 of file BCMTFComparisonTool.h.

std::vector<TH1D *> BCMTFComparisonTool::fHistogramContainer [private]

A container of TH1D histograms.

Definition at line 108 of file BCMTFComparisonTool.h.

std::string BCMTFComparisonTool::fName [private]

The name of the class.

Definition at line 100 of file BCMTFComparisonTool.h.

std::vector<std::string> BCMTFComparisonTool::fNameContainer [private]

The names of the contributions.

Definition at line 104 of file BCMTFComparisonTool.h.

std::vector<double> BCMTFComparisonTool::fUncertaintyContainer [private]

A container of uncertainties.

Definition at line 116 of file BCMTFComparisonTool.h.


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