CMS 3D CMS Logo

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

#include <TH1Keys.h>

Inheritance diagram for TH1Keys:

Public Member Functions

virtual void Add (const TH1 *h1, Double_t c1=1)
 
virtual void Add (const TH1 *h, const TH1 *h2, Double_t c1=1, Double_t c2=1)
 
virtual void AddBinContent (Int_t bin)
 
virtual void AddBinContent (Int_t bin, Double_t w)
 
virtual void Copy (TObject &hnew) const
 
void dont (const char *) const
 
virtual TH1 * DrawCopy (Option_t *option="") const
 
virtual Int_t Fill (Double_t x)
 
virtual Int_t Fill (Double_t x, Double_t w)
 
void FillH1 () const
 
virtual void FillN (Int_t ntimes, const Double_t *x, const Double_t *w, Int_t stride=1)
 
virtual Double_t GetBinContent (Int_t bin) const
 
virtual Double_t GetBinContent (Int_t bin, Int_t) const
 
virtual Double_t GetBinContent (Int_t bin, Int_t, Int_t) const
 
virtual Double_t GetEntries () const
 
TH1 * GetHisto ()
 
const TH1 * GetHisto () const
 
virtual void Reset (Option_t *option="")
 
virtual void Scale (Double_t c1=1, Option_t *option="")
 
virtual void SetBinContent (Int_t bin, Double_t content)
 
virtual void SetBinContent (Int_t bin, Int_t, Double_t content)
 
virtual void SetBinContent (Int_t bin, Int_t, Int_t, Double_t content)
 
virtual void SetBinsLength (Int_t n=-1)
 
 TH1Keys ()
 
 TH1Keys (const char *name, const char *title, Int_t nbinsx, Double_t xlow, Double_t xup, TString options="a", Double_t rho=1.5)
 
 TH1Keys (const char *name, const char *title, Int_t nbinsx, const Float_t *xbins, TString options="a", Double_t rho=1.5)
 
 TH1Keys (const char *name, const char *title, Int_t nbinsx, const Double_t *xbins, TString options="a", Double_t rho=1.5)
 
 TH1Keys (const TH1Keys &other)
 
virtual ~TH1Keys ()
 

Public Attributes

TH1 * cache_
 
RooDataSet * dataset_
 
Double_t globalScale_
 
bool isCacheGood_
 
TString options_
 
Double_t overflow_
 
RooArgSet point_
 
Double_t rho_
 
Double_t underflow_
 
ClassDef(TH1Keys, 1) private
RooRealVar * 
w_
 
ClassDef(TH1Keys, 1) private
RooRealVar * 
x_
 

Detailed Description

Definition at line 10 of file TH1Keys.h.

Constructor & Destructor Documentation

TH1Keys::TH1Keys ( )

Definition at line 8 of file TH1Keys.cc.

8  :
9  x_(0),
10  dataset_(0),
11  underflow_(0.0), overflow_(0.0),
12  globalScale_(1.0),
13  cache_(0),
14  isCacheGood_(false)
15 {
16 }
TH1 * cache_
Definition: TH1Keys.h:61
RooDataSet * dataset_
Definition: TH1Keys.h:54
bool isCacheGood_
Definition: TH1Keys.h:62
Double_t underflow_
Definition: TH1Keys.h:55
Double_t overflow_
Definition: TH1Keys.h:55
ClassDef(TH1Keys, 1) private RooRealVar * x_
Definition: TH1Keys.h:48
Double_t globalScale_
Definition: TH1Keys.h:56
TH1Keys::TH1Keys ( const char *  name,
const char *  title,
Int_t  nbinsx,
Double_t  xlow,
Double_t  xup,
TString  options = "a",
Double_t  rho = 1.5 
)

Definition at line 18 of file TH1Keys.cc.

References cache_, and x_.

18  :
19  TH1(name,title,nbinsx,xlow,xup),
20  min_(xlow), max_(xup),
21  x_(new RooRealVar("x", "x", min_, max_)),
22  w_(new RooRealVar("w", "w", 1.0)),
23  point_(*x_),
24  dataset_(new RooDataSet(name, title, RooArgSet(*x_, *w_), "w")),
25  underflow_(0.0), overflow_(0.0),
26  globalScale_(1.0),
28  rho_(rho),
29  cache_(new TH1F("",title,nbinsx,xlow,xup)),
30  isCacheGood_(true)
31 {
32  cache_->SetDirectory(0);
33  fDimension = 1;
34  x_->setBins(nbinsx);
35 }
TH1 * cache_
Definition: TH1Keys.h:61
ClassDef(TH1Keys, 1) private RooRealVar * w_
Definition: TH1Keys.h:48
RooDataSet * dataset_
Definition: TH1Keys.h:54
Definition: DDAxes.h:10
RooArgSet point_
Definition: TH1Keys.h:53
bool isCacheGood_
Definition: TH1Keys.h:62
Double_t underflow_
Definition: TH1Keys.h:55
Double_t rho_
Definition: TH1Keys.h:59
Double_t overflow_
Definition: TH1Keys.h:55
ClassDef(TH1Keys, 1) private RooRealVar * x_
Definition: TH1Keys.h:48
TString options_
Definition: TH1Keys.h:58
Double_t globalScale_
Definition: TH1Keys.h:56
TH1Keys::TH1Keys ( const char *  name,
const char *  title,
Int_t  nbinsx,
const Float_t *  xbins,
TString  options = "a",
Double_t  rho = 1.5 
)

Definition at line 37 of file TH1Keys.cc.

References cache_, i, and x_.

37  :
38  TH1(name,title,nbinsx,xbins),
39  min_(xbins[0]), max_(xbins[nbinsx]),
40  x_(new RooRealVar("x", "x", min_, max_)),
41  w_(new RooRealVar("w", "w", 1.0)),
42  point_(*x_),
43  dataset_(new RooDataSet(name, title, RooArgSet(*x_, *w_), "w")),
44  underflow_(0.0), overflow_(0.0),
45  globalScale_(1.0),
47  rho_(rho),
48  cache_(new TH1F("",title,nbinsx,xbins)),
49  isCacheGood_(true)
50 {
51  cache_->SetDirectory(0);
52  fDimension = 1;
53  std::vector<Double_t> boundaries(nbinsx+1);
54  for (Int_t i = 0; i <= nbinsx; ++i) boundaries[i] = xbins[i];
55  x_->setBinning(RooBinning(nbinsx, &boundaries[0]));
56 }
int i
Definition: DBlmapReader.cc:9
TH1 * cache_
Definition: TH1Keys.h:61
ClassDef(TH1Keys, 1) private RooRealVar * w_
Definition: TH1Keys.h:48
const double xbins[]
RooDataSet * dataset_
Definition: TH1Keys.h:54
Definition: DDAxes.h:10
RooArgSet point_
Definition: TH1Keys.h:53
bool isCacheGood_
Definition: TH1Keys.h:62
Double_t underflow_
Definition: TH1Keys.h:55
Double_t rho_
Definition: TH1Keys.h:59
Double_t overflow_
Definition: TH1Keys.h:55
ClassDef(TH1Keys, 1) private RooRealVar * x_
Definition: TH1Keys.h:48
TString options_
Definition: TH1Keys.h:58
Double_t globalScale_
Definition: TH1Keys.h:56
TH1Keys::TH1Keys ( const char *  name,
const char *  title,
Int_t  nbinsx,
const Double_t *  xbins,
TString  options = "a",
Double_t  rho = 1.5 
)

Definition at line 58 of file TH1Keys.cc.

References cache_, and x_.

58  :
59  TH1(name,title,nbinsx,xbins),
60  min_(xbins[0]), max_(xbins[nbinsx]),
61  x_(new RooRealVar("x", "x", min_, max_)),
62  w_(new RooRealVar("w", "w", 1.0)),
63  point_(*x_),
64  dataset_(new RooDataSet(name, title, RooArgSet(*x_, *w_), "w")),
65  underflow_(0.0), overflow_(0.0),
66  globalScale_(1.0),
68  rho_(rho),
69  cache_(new TH1F("",title,nbinsx,xbins)),
70  isCacheGood_(true)
71 {
72  cache_->SetDirectory(0);
73  fDimension = 1;
74  x_->setBinning(RooBinning(nbinsx, xbins));
75 }
TH1 * cache_
Definition: TH1Keys.h:61
ClassDef(TH1Keys, 1) private RooRealVar * w_
Definition: TH1Keys.h:48
const double xbins[]
RooDataSet * dataset_
Definition: TH1Keys.h:54
Definition: DDAxes.h:10
RooArgSet point_
Definition: TH1Keys.h:53
bool isCacheGood_
Definition: TH1Keys.h:62
Double_t underflow_
Definition: TH1Keys.h:55
Double_t rho_
Definition: TH1Keys.h:59
Double_t overflow_
Definition: TH1Keys.h:55
ClassDef(TH1Keys, 1) private RooRealVar * x_
Definition: TH1Keys.h:48
TString options_
Definition: TH1Keys.h:58
Double_t globalScale_
Definition: TH1Keys.h:56
TH1Keys::TH1Keys ( const TH1Keys other)

Definition at line 78 of file TH1Keys.cc.

References x_.

78  :
79  TH1(other),
80  min_(other.min_), max_(other.max_),
81  x_(new RooRealVar("x", "x", min_, max_)),
82  w_(new RooRealVar("w", "w", 1.0)),
83  point_(*x_),
84  dataset_(new RooDataSet(other.GetName(), other.GetTitle(), RooArgSet(*x_, *w_), "w")),
87  options_(other.options_),
88  rho_(other.rho_),
89  cache_((TH1*)other.cache_->Clone()),
91 {
92  fDimension = 1;
93  x_->setBinning(other.x_->getBinning());
94 }
TH1 * cache_
Definition: TH1Keys.h:61
ClassDef(TH1Keys, 1) private RooRealVar * w_
Definition: TH1Keys.h:48
RooDataSet * dataset_
Definition: TH1Keys.h:54
RooArgSet point_
Definition: TH1Keys.h:53
bool isCacheGood_
Definition: TH1Keys.h:62
Double_t underflow_
Definition: TH1Keys.h:55
Double_t rho_
Definition: TH1Keys.h:59
Double_t overflow_
Definition: TH1Keys.h:55
ClassDef(TH1Keys, 1) private RooRealVar * x_
Definition: TH1Keys.h:48
TString options_
Definition: TH1Keys.h:58
Double_t globalScale_
Definition: TH1Keys.h:56
TH1Keys::~TH1Keys ( )
virtual

Definition at line 97 of file TH1Keys.cc.

References cache_, dataset_, and x_.

98 {
99  delete cache_;
100  delete dataset_;
101  delete x_;
102 }
TH1 * cache_
Definition: TH1Keys.h:61
RooDataSet * dataset_
Definition: TH1Keys.h:54
ClassDef(TH1Keys, 1) private RooRealVar * x_
Definition: TH1Keys.h:48

Member Function Documentation

void TH1Keys::Add ( const TH1 *  h1,
Double_t  c1 = 1 
)
virtual

Definition at line 125 of file TH1Keys.cc.

References dataset_, dont(), and isCacheGood_.

126 {
127  if (c1 != 1.0) dont("Add with constant != 1");
128  const TH1Keys *other = dynamic_cast<const TH1Keys *>(h1);
129  if (other == 0) dont("Add with a non TH1Keys");
130  dataset_->append(const_cast<RooDataSet&>(*other->dataset_));
131  isCacheGood_ = false;
132 }
RooDataSet * dataset_
Definition: TH1Keys.h:54
bool isCacheGood_
Definition: TH1Keys.h:62
void dont(const char *) const
Definition: TH1Keys.cc:169
virtual void TH1Keys::Add ( const TH1 *  h,
const TH1 *  h2,
Double_t  c1 = 1,
Double_t  c2 = 1 
)
inlinevirtual

Definition at line 27 of file TH1Keys.h.

References dont().

27 { dont("Add with two arguments"); }
void dont(const char *) const
Definition: TH1Keys.cc:169
virtual void TH1Keys::AddBinContent ( Int_t  bin)
inlinevirtual

Definition at line 29 of file TH1Keys.h.

References AddBinContent().

Referenced by AddBinContent().

29 { AddBinContent(bin, 1.0); }
virtual void AddBinContent(Int_t bin)
Definition: TH1Keys.h:29
virtual void TH1Keys::AddBinContent ( Int_t  bin,
Double_t  w 
)
inlinevirtual

Definition at line 30 of file TH1Keys.h.

References dont().

30 { dont("AddBinContent"); }
void dont(const char *) const
Definition: TH1Keys.cc:169
virtual void TH1Keys::Copy ( TObject &  hnew) const
inlinevirtual

Definition at line 31 of file TH1Keys.h.

References dont().

31 { dont("Copy"); }
void dont(const char *) const
Definition: TH1Keys.cc:169
void TH1Keys::dont ( const char *  msg) const

Definition at line 169 of file TH1Keys.cc.

Referenced by Add(), AddBinContent(), Copy(), DrawCopy(), SetBinContent(), and SetBinsLength().

169  {
170  TObject::Error("TH1Keys",msg);
171  throw std::runtime_error(std::string("Error in TH1Keys: ")+msg);
172 }
virtual TH1* TH1Keys::DrawCopy ( Option_t *  option = "") const
inlinevirtual

Definition at line 33 of file TH1Keys.h.

References dont().

33 { dont("DrawCopy"); return 0; }
void dont(const char *) const
Definition: TH1Keys.cc:169
virtual Int_t TH1Keys::Fill ( Double_t  x)
inlinevirtual

Definition at line 22 of file TH1Keys.h.

References Fill().

Referenced by Fill(), and FillN().

22 { return Fill(x,1.0); }
virtual Int_t Fill(Double_t x)
Definition: TH1Keys.h:22
Definition: DDAxes.h:10
Int_t TH1Keys::Fill ( Double_t  x,
Double_t  w 
)
virtual

Definition at line 104 of file TH1Keys.cc.

References dataset_, isCacheGood_, overflow_, point_, underflow_, w(), and x_.

105 {
106  isCacheGood_ = false;
107  if (x >= max_) overflow_ += w;
108  else if (x < min_) underflow_ += w;
109  else {
110  x_->setVal(x);
111  dataset_->add(point_, w);
112  return 1;
113  }
114  return -1;
115 }
RooDataSet * dataset_
Definition: TH1Keys.h:54
RooArgSet point_
Definition: TH1Keys.h:53
bool isCacheGood_
Definition: TH1Keys.h:62
Double_t underflow_
Definition: TH1Keys.h:55
Double_t overflow_
Definition: TH1Keys.h:55
Definition: DDAxes.h:10
ClassDef(TH1Keys, 1) private RooRealVar * x_
Definition: TH1Keys.h:48
T w() const
void TH1Keys::FillH1 ( ) const

Definition at line 150 of file TH1Keys.cc.

References cache_, dataset_, globalScale_, instance, isCacheGood_, options_, overflow_, rho_, underflow_, and x_.

Referenced by GetHisto().

151 {
152  if (dataset_->numEntries() == 0) {
153  cache_->Reset(); // make sure it's empty
154  } else {
155  RooFit::MsgLevel gKill = RooMsgService::instance().globalKillBelow();
156  RooMsgService::instance().setGlobalKillBelow(RooFit::FATAL);
157  delete cache_;
158  RooNDKeysPdf pdf("","",*x_,*dataset_,options_,rho_);
159  cache_ = pdf.createHistogram(GetName(), *x_);
160  if (cache_->Integral()) cache_->Scale(1.0/cache_->Integral());
161  cache_->SetBinContent(0, underflow_);
162  cache_->SetBinContent(cache_->GetNbinsX()+1, overflow_);
163  cache_->Scale(dataset_->sumEntries() * globalScale_);
164  RooMsgService::instance().setGlobalKillBelow(gKill);
165  }
166  isCacheGood_ = true;
167 }
TH1 * cache_
Definition: TH1Keys.h:61
RooDataSet * dataset_
Definition: TH1Keys.h:54
static PFTauRenderPlugin instance
bool isCacheGood_
Definition: TH1Keys.h:62
Double_t underflow_
Definition: TH1Keys.h:55
Double_t rho_
Definition: TH1Keys.h:59
Double_t overflow_
Definition: TH1Keys.h:55
ClassDef(TH1Keys, 1) private RooRealVar * x_
Definition: TH1Keys.h:48
TString options_
Definition: TH1Keys.h:58
Double_t globalScale_
Definition: TH1Keys.h:56
void TH1Keys::FillN ( Int_t  ntimes,
const Double_t *  x,
const Double_t *  w,
Int_t  stride = 1 
)
virtual

Definition at line 117 of file TH1Keys.cc.

References Fill(), i, and isCacheGood_.

118 {
119  isCacheGood_ = false;
120  for (Int_t i = 0; i < ntimes; i += stride) {
121  Fill(x[i], w[i]);
122  }
123 }
int i
Definition: DBlmapReader.cc:9
virtual Int_t Fill(Double_t x)
Definition: TH1Keys.h:22
bool isCacheGood_
Definition: TH1Keys.h:62
Definition: DDAxes.h:10
T w() const
virtual Double_t TH1Keys::GetBinContent ( Int_t  bin) const
inlinevirtual

Definition at line 35 of file TH1Keys.h.

References GetHisto().

35 { return GetHisto()->GetBinContent(bin); }
TH1 * GetHisto()
Definition: TH1Keys.h:19
virtual Double_t TH1Keys::GetBinContent ( Int_t  bin,
Int_t   
) const
inlinevirtual

Definition at line 36 of file TH1Keys.h.

References GetHisto().

36 { return GetHisto()->GetBinContent(bin); }
TH1 * GetHisto()
Definition: TH1Keys.h:19
virtual Double_t TH1Keys::GetBinContent ( Int_t  bin,
Int_t  ,
Int_t   
) const
inlinevirtual

Definition at line 37 of file TH1Keys.h.

References GetHisto().

37 {return GetHisto()->GetBinContent(bin); }
TH1 * GetHisto()
Definition: TH1Keys.h:19
virtual Double_t TH1Keys::GetEntries ( ) const
inlinevirtual

Definition at line 39 of file TH1Keys.h.

References dataset_.

39 { return dataset_->numEntries(); }
RooDataSet * dataset_
Definition: TH1Keys.h:54
TH1* TH1Keys::GetHisto ( )
inline

Definition at line 19 of file TH1Keys.h.

References cache_, FillH1(), and isCacheGood_.

Referenced by GetBinContent().

19 { if (!isCacheGood_) FillH1(); return cache_; }
TH1 * cache_
Definition: TH1Keys.h:61
bool isCacheGood_
Definition: TH1Keys.h:62
void FillH1() const
Definition: TH1Keys.cc:150
const TH1* TH1Keys::GetHisto ( ) const
inline

Definition at line 20 of file TH1Keys.h.

References cache_, FillH1(), and isCacheGood_.

20 { if (!isCacheGood_) FillH1(); return cache_; }
TH1 * cache_
Definition: TH1Keys.h:61
bool isCacheGood_
Definition: TH1Keys.h:62
void FillH1() const
Definition: TH1Keys.cc:150
void TH1Keys::Reset ( Option_t *  option = "")
virtual

Definition at line 140 of file TH1Keys.cc.

References cache_, dataset_, globalScale_, isCacheGood_, overflow_, and underflow_.

140  {
141  dataset_->reset();
142  overflow_ = underflow_ = 0.0;
143  globalScale_ = 1.0;
144  cache_->Reset();
145  isCacheGood_ = true;
146 }
TH1 * cache_
Definition: TH1Keys.h:61
RooDataSet * dataset_
Definition: TH1Keys.h:54
bool isCacheGood_
Definition: TH1Keys.h:62
Double_t underflow_
Definition: TH1Keys.h:55
Double_t overflow_
Definition: TH1Keys.h:55
Double_t globalScale_
Definition: TH1Keys.h:56
void TH1Keys::Scale ( Double_t  c1 = 1,
Option_t *  option = "" 
)
virtual

Definition at line 134 of file TH1Keys.cc.

References alignmentValidation::c1, cache_, and globalScale_.

135 {
136  globalScale_ *= c1;
137  if (cache_) cache_->Scale(c1);
138 }
TH1 * cache_
Definition: TH1Keys.h:61
Double_t globalScale_
Definition: TH1Keys.h:56
virtual void TH1Keys::SetBinContent ( Int_t  bin,
Double_t  content 
)
inlinevirtual

Definition at line 42 of file TH1Keys.h.

References dont().

42 { dont("SetBinContent"); }
void dont(const char *) const
Definition: TH1Keys.cc:169
virtual void TH1Keys::SetBinContent ( Int_t  bin,
Int_t  ,
Double_t  content 
)
inlinevirtual

Definition at line 43 of file TH1Keys.h.

References SetBinContent().

Referenced by SetBinContent().

virtual void SetBinContent(Int_t bin, Double_t content)
Definition: TH1Keys.h:42
virtual void TH1Keys::SetBinContent ( Int_t  bin,
Int_t  ,
Int_t  ,
Double_t  content 
)
inlinevirtual

Definition at line 44 of file TH1Keys.h.

References SetBinContent().

Referenced by SetBinContent().

virtual void SetBinContent(Int_t bin, Double_t content)
Definition: TH1Keys.h:42
virtual void TH1Keys::SetBinsLength ( Int_t  n = -1)
inlinevirtual

Definition at line 45 of file TH1Keys.h.

References dont().

45 { dont("SetBinLength"); }
void dont(const char *) const
Definition: TH1Keys.cc:169

Member Data Documentation

TH1* TH1Keys::cache_
mutable

Definition at line 61 of file TH1Keys.h.

Referenced by FillH1(), GetHisto(), Reset(), Scale(), TH1Keys(), and ~TH1Keys().

RooDataSet* TH1Keys::dataset_

Definition at line 54 of file TH1Keys.h.

Referenced by Add(), Fill(), FillH1(), GetEntries(), Reset(), and ~TH1Keys().

Double_t TH1Keys::globalScale_

Definition at line 56 of file TH1Keys.h.

Referenced by FillH1(), Reset(), and Scale().

bool TH1Keys::isCacheGood_
mutable

Definition at line 62 of file TH1Keys.h.

Referenced by Add(), Fill(), FillH1(), FillN(), GetHisto(), and Reset().

TString TH1Keys::options_

Definition at line 58 of file TH1Keys.h.

Referenced by FillH1(), and valtools.webpage::parseArgs().

Double_t TH1Keys::overflow_

Definition at line 55 of file TH1Keys.h.

Referenced by Fill(), FillH1(), and Reset().

RooArgSet TH1Keys::point_

Definition at line 53 of file TH1Keys.h.

Referenced by Fill().

Double_t TH1Keys::rho_

Definition at line 59 of file TH1Keys.h.

Referenced by FillH1().

Double_t TH1Keys::underflow_

Definition at line 55 of file TH1Keys.h.

Referenced by Fill(), FillH1(), and Reset().

ClassDef (TH1Keys,1) private RooRealVar * TH1Keys::w_

Definition at line 48 of file TH1Keys.h.

ClassDef (TH1Keys,1) private RooRealVar* TH1Keys::x_

Definition at line 48 of file TH1Keys.h.

Referenced by Fill(), FillH1(), TH1Keys(), and ~TH1Keys().