CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Private Member Functions | Private Attributes
Overlayer Class Reference

#include <Overlayer.h>

Public Member Functions

Overlayerclear ()
 
Overlayerfind (std::string)
 
OverlayerlegendLeft (bool state=true)
 
Overlayerlogy (bool state=true)
 
 Overlayer (std::string filename, std::string datadir, std::string simdir, Color_t color)
 
void print (std::string)
 
OverlayerwithLegend (bool state=true)
 
Overlayerxlabel (std::string s)
 
Overlayerylabel (std::string s)
 

Private Member Functions

std::string getStats (const TH1 *const) const
 

Private Attributes

const Color_t color_
 
TH1 * data_
 
const std::string dataLocation_
 
TFile *const file_
 
std::string histName_
 
bool left_
 
TLegend * legend_
 
bool logy_
 
TH1 * sim_
 
const std::string simLocation_
 
std::string title_
 
std::string xlabel_
 
std::string ylabel_
 

Detailed Description

Definition at line 12 of file Overlayer.h.

Constructor & Destructor Documentation

Overlayer::Overlayer ( std::string  filename,
std::string  datadir,
std::string  simdir,
Color_t  color 
)
inline

Definition at line 14 of file Overlayer.h.

References clear().

15  : file_(new TFile(filename.c_str(),"READ")),
17  simLocation_(simdir),
18  color_(color)
19 { clear(); }
const std::string simLocation_
Definition: Overlayer.h:33
const Color_t color_
Definition: Overlayer.h:34
const TString datadir("/src/Fireworks/Core/")
const std::string dataLocation_
Definition: Overlayer.h:33
TFile *const file_
Definition: Overlayer.h:32
Overlayer & clear()
Definition: Overlayer.h:43
tuple filename
Definition: lut2db_cfg.py:20

Member Function Documentation

Overlayer & Overlayer::clear ( void  )
Overlayer & Overlayer::find ( std::string  name)

Definition at line 54 of file Overlayer.h.

References gather_cfg::cout, data_, dataLocation_, file_, histName_, mergeVDriftHistosByStation::name, sim_, and simLocation_.

54  {
55  std::cout << "find " << name << "\t" << std::flush;
56  histName_=name;
57  data_ = (TH1*) file_->GetDirectory(dataLocation_.c_str())->FindObjectAny(name.c_str());
58  sim_ = (TH1*) file_->GetDirectory(simLocation_.c_str())->FindObjectAny(name.c_str());
59  return *this;
60 }
TH1 * sim_
Definition: Overlayer.h:37
const std::string simLocation_
Definition: Overlayer.h:33
TH1 * data_
Definition: Overlayer.h:36
const std::string dataLocation_
Definition: Overlayer.h:33
TFile *const file_
Definition: Overlayer.h:32
std::string histName_
Definition: Overlayer.h:35
tuple cout
Definition: gather_cfg.py:121
std::string Overlayer::getStats ( const TH1 * const  hist) const
private

Definition at line 81 of file Overlayer.h.

References contentValuesCheck::ss.

Referenced by withLegend().

81  {
82  stringstream ss;
83  ss << "N: " << hist->GetEntries() << ", "
84  << "#mu: " << round_string()(std::make_pair(hist->GetMean(),hist->GetMeanError())) << ", "
85  << "#sigma: " << round_string()(std::make_pair(hist->GetRMS(),hist->GetRMSError()));
86  return ss.str().c_str();
87 }
Overlayer& Overlayer::legendLeft ( bool  state = true)
inline

Definition at line 27 of file Overlayer.h.

References left_.

27 { left_=state; return *this;}
bool left_
Definition: Overlayer.h:38
Overlayer& Overlayer::logy ( bool  state = true)
inline

Definition at line 25 of file Overlayer.h.

References logy_.

25 { logy_=state; return *this;}
bool logy_
Definition: Overlayer.h:38
void Overlayer::print ( std::string  suffix)

Definition at line 90 of file Overlayer.h.

References trackerHits::c, color_, gather_cfg::cout, data_, histName_, legend_, logy_, max(), sim_, title_, xlabel_, and ylabel_.

90  {
91  std::cout << "print\t" << std::flush;
92 
93  sim_->GetXaxis()->SetLabelSize(0.05); sim_->GetXaxis()->SetTitleSize(0.05);
94  sim_->GetYaxis()->SetLabelSize(0.05); sim_->GetYaxis()->SetTitleSize(0.05);
95  sim_->SetTitle((title_+";"+xlabel_+";"+ylabel_).c_str());
96  sim_->Scale(data_->Integral()/sim_->Integral());
97  sim_->SetMinimum( (logy_?0.1:0) );
98  sim_->SetMaximum( (logy_?2:1.1) * std::max( sim_->GetBinContent(sim_->GetMaximumBin()) + sim_->GetBinError(sim_->GetMaximumBin()) ,
99  data_->GetBinContent(data_->GetMaximumBin()) + data_->GetBinError(data_->GetMaximumBin()) ) );
100 
101  sim_->SetFillColor(color_);
102  TH1* sim_errors = (TH1*) sim_->Clone((histName_+"_clone").c_str());
103  sim_->SetLineColor(kRed);
104  sim_errors->SetFillColor(kRed);
105  sim_errors->SetFillStyle(3244);
106  data_->SetMarkerStyle(20);
107 
108  TCanvas c("c","",800,600);
109  if(logy_) c.SetLogy();
110 
111  sim_->Draw("hist");
112  sim_errors->Draw("e2same");
113  data_->Draw("same");
114  if(legend_) legend_->Draw();
115 
116  c.Print((histName_+suffix).c_str());
117 }
TH1 * sim_
Definition: Overlayer.h:37
const Color_t color_
Definition: Overlayer.h:34
bool logy_
Definition: Overlayer.h:38
TH1 * data_
Definition: Overlayer.h:36
std::string ylabel_
Definition: Overlayer.h:35
TLegend * legend_
Definition: Overlayer.h:39
const T & max(const T &a, const T &b)
std::string title_
Definition: Overlayer.h:35
std::string histName_
Definition: Overlayer.h:35
std::string xlabel_
Definition: Overlayer.h:35
tuple cout
Definition: gather_cfg.py:121
Overlayer & Overlayer::withLegend ( bool  state = true)

Definition at line 62 of file Overlayer.h.

References gather_cfg::cout, data_, dataLocation_, getStats(), left_, legend_, max(), sim_, simLocation_, and AlCaHLTBitMon_QueryRunRegistry::string.

62  {
63  std::cout << "legend: " << (state?"true\t":"false\t") << std::flush;
64  if(!state) {legend_=0; return *this;}
65 
66  std::string data_stats = getStats(data_);
67  std::string sim_stats = getStats(sim_);
68  unsigned maxlength = std::max( std::max( dataLocation_.size(), simLocation_.size()),
69  std::max( data_stats.size(), sim_stats.size()) );
70 
71  if(left_) legend_ = new TLegend(0,0.75,maxlength*0.015,1.0);
72  else legend_ = new TLegend(1.0-maxlength*0.015,0.75,1.0,1.0);
73 
74  legend_->SetFillColor(kWhite);
75  legend_->AddEntry(data_,("#splitline{"+dataLocation_+"}{"+ data_stats + "}").c_str() );
76  legend_->AddEntry(sim_,("#splitline{"+simLocation_+"}{"+ sim_stats + "}").c_str() );
77  return *this;
78 }
TH1 * sim_
Definition: Overlayer.h:37
const std::string simLocation_
Definition: Overlayer.h:33
TH1 * data_
Definition: Overlayer.h:36
TLegend * legend_
Definition: Overlayer.h:39
const T & max(const T &a, const T &b)
const std::string dataLocation_
Definition: Overlayer.h:33
bool left_
Definition: Overlayer.h:38
std::string getStats(const TH1 *const) const
Definition: Overlayer.h:81
tuple cout
Definition: gather_cfg.py:121
Overlayer& Overlayer::xlabel ( std::string  s)
inline

Definition at line 23 of file Overlayer.h.

References alignCSCRings::s, and xlabel_.

23 { xlabel_=s; return *this;}
std::string xlabel_
Definition: Overlayer.h:35
Overlayer& Overlayer::ylabel ( std::string  s)
inline

Definition at line 24 of file Overlayer.h.

References alignCSCRings::s, and ylabel_.

24 { ylabel_=s; return *this;}
std::string ylabel_
Definition: Overlayer.h:35

Member Data Documentation

const Color_t Overlayer::color_
private

Definition at line 34 of file Overlayer.h.

Referenced by print().

TH1* Overlayer::data_
private

Definition at line 36 of file Overlayer.h.

Referenced by clear(), find(), print(), and withLegend().

const std::string Overlayer::dataLocation_
private

Definition at line 33 of file Overlayer.h.

Referenced by find(), and withLegend().

TFile* const Overlayer::file_
private

Definition at line 32 of file Overlayer.h.

Referenced by find().

std::string Overlayer::histName_
private

Definition at line 35 of file Overlayer.h.

Referenced by clear(), find(), and print().

bool Overlayer::left_
private

Definition at line 38 of file Overlayer.h.

Referenced by clear(), legendLeft(), and withLegend().

TLegend* Overlayer::legend_
private

Definition at line 39 of file Overlayer.h.

Referenced by clear(), print(), and withLegend().

bool Overlayer::logy_
private

Definition at line 38 of file Overlayer.h.

Referenced by clear(), logy(), and print().

TH1* Overlayer::sim_
private

Definition at line 37 of file Overlayer.h.

Referenced by clear(), find(), print(), and withLegend().

const std::string Overlayer::simLocation_
private

Definition at line 33 of file Overlayer.h.

Referenced by find(), and withLegend().

std::string Overlayer::title_
private

Definition at line 35 of file Overlayer.h.

Referenced by clear(), and print().

std::string Overlayer::xlabel_
private

Definition at line 35 of file Overlayer.h.

Referenced by clear(), print(), and xlabel().

std::string Overlayer::ylabel_
private

Definition at line 35 of file Overlayer.h.

Referenced by clear(), print(), and ylabel().