CMS 3D CMS Logo

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::Overlayer ( std::string  filename,
std::string  datadir,
std::string  simdir,
Color_t  color 
)
inline

Definition at line 14 of file Overlayer.h.

15  : file_(new TFile(filename.c_str(),"READ")),
17  simLocation_(simdir),
18  color_(color)
19 { clear(); }

References clear().

Member Function Documentation

◆ clear()

Overlayer & Overlayer::clear ( void  )

Definition at line 43 of file Overlayer.h.

43  {
44  std::cout << "clear" << std::endl;
45  data_=sim_=0;
47  logy_=false;
48  legend_=0;
49  left_=false;
50  return *this;
51 }

References gather_cfg::cout, data_, histName_, left_, legend_, logy_, sim_, title_, xlabel_, and ylabel_.

Referenced by Overlayer().

◆ find()

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

Definition at line 54 of file Overlayer.h.

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 }

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

◆ getStats()

std::string Overlayer::getStats ( const TH1 * const  hist) const
private

Definition at line 81 of file Overlayer.h.

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 }

References compare::hist, and contentValuesCheck::ss.

Referenced by withLegend().

◆ legendLeft()

Overlayer& Overlayer::legendLeft ( bool  state = true)
inline

Definition at line 27 of file Overlayer.h.

27 { left_=state; return *this;}

References left_.

◆ logy()

Overlayer& Overlayer::logy ( bool  state = true)
inline

Definition at line 25 of file Overlayer.h.

25 { logy_=state; return *this;}

References logy_.

◆ print()

void Overlayer::print ( std::string  suffix)

Definition at line 90 of file Overlayer.h.

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 }

References HltBtagPostValidation_cff::c, color_, gather_cfg::cout, data_, histName_, legend_, logy_, SiStripPI::max, sim_, createPayload::suffix, title_, xlabel_, and ylabel_.

◆ withLegend()

Overlayer & Overlayer::withLegend ( bool  state = true)

Definition at line 62 of file Overlayer.h.

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 }

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

◆ xlabel()

Overlayer& Overlayer::xlabel ( std::string  s)
inline

Definition at line 23 of file Overlayer.h.

23 { xlabel_=s; return *this;}

References alignCSCRings::s, and xlabel_.

◆ ylabel()

Overlayer& Overlayer::ylabel ( std::string  s)
inline

Definition at line 24 of file Overlayer.h.

24 { ylabel_=s; return *this;}

References alignCSCRings::s, and ylabel_.

Member Data Documentation

◆ color_

const Color_t Overlayer::color_
private

Definition at line 34 of file Overlayer.h.

Referenced by print().

◆ data_

TH1* Overlayer::data_
private

Definition at line 36 of file Overlayer.h.

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

◆ dataLocation_

const std::string Overlayer::dataLocation_
private

Definition at line 33 of file Overlayer.h.

Referenced by find(), and withLegend().

◆ file_

TFile* const Overlayer::file_
private

Definition at line 32 of file Overlayer.h.

Referenced by find().

◆ histName_

std::string Overlayer::histName_
private

Definition at line 35 of file Overlayer.h.

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

◆ left_

bool Overlayer::left_
private

Definition at line 38 of file Overlayer.h.

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

◆ legend_

TLegend* Overlayer::legend_
private

Definition at line 39 of file Overlayer.h.

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

◆ logy_

bool Overlayer::logy_
private

Definition at line 38 of file Overlayer.h.

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

◆ sim_

TH1* Overlayer::sim_
private

Definition at line 37 of file Overlayer.h.

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

◆ simLocation_

const std::string Overlayer::simLocation_
private

Definition at line 33 of file Overlayer.h.

Referenced by find(), and withLegend().

◆ title_

std::string Overlayer::title_
private

Definition at line 35 of file Overlayer.h.

Referenced by clear(), and print().

◆ xlabel_

std::string Overlayer::xlabel_
private

Definition at line 35 of file Overlayer.h.

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

◆ ylabel_

std::string Overlayer::ylabel_
private

Definition at line 35 of file Overlayer.h.

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

Overlayer::simLocation_
const std::string simLocation_
Definition: Overlayer.h:33
Overlayer::color_
const Color_t color_
Definition: Overlayer.h:34
gather_cfg.cout
cout
Definition: gather_cfg.py:144
Overlayer::data_
TH1 * data_
Definition: Overlayer.h:36
createPayload.suffix
suffix
Definition: createPayload.py:281
contentValuesCheck.ss
ss
Definition: contentValuesCheck.py:33
alignCSCRings.s
s
Definition: alignCSCRings.py:92
Overlayer::xlabel_
std::string xlabel_
Definition: Overlayer.h:35
Overlayer::clear
Overlayer & clear()
Definition: Overlayer.h:43
compare.hist
hist
Definition: compare.py:376
fireworks::datadir
const TString datadir("/src/Fireworks/Core/")
corrVsCorr.filename
filename
Definition: corrVsCorr.py:123
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
Overlayer::getStats
std::string getStats(const TH1 *const) const
Definition: Overlayer.h:81
Overlayer::histName_
std::string histName_
Definition: Overlayer.h:35
SiStripPI::max
Definition: SiStripPayloadInspectorHelper.h:169
Overlayer::dataLocation_
const std::string dataLocation_
Definition: Overlayer.h:33
Overlayer::left_
bool left_
Definition: Overlayer.h:38
HltBtagPostValidation_cff.c
c
Definition: HltBtagPostValidation_cff.py:31
Overlayer::file_
TFile *const file_
Definition: Overlayer.h:32
round_string
Definition: round_string.h:10
Overlayer::ylabel_
std::string ylabel_
Definition: Overlayer.h:35
Skims_PA_cff.name
name
Definition: Skims_PA_cff.py:17
Overlayer::sim_
TH1 * sim_
Definition: Overlayer.h:37
Overlayer::logy_
bool logy_
Definition: Overlayer.h:38
Overlayer::legend_
TLegend * legend_
Definition: Overlayer.h:39
Overlayer::title_
std::string title_
Definition: Overlayer.h:35