CMS 3D CMS Logo

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

#include <ConfigurableHisto.h>

Inheritance diagram for ConfigurableHisto:
SplittingConfigurableHisto

Public Types

enum  HType { h1, h2, prof }
 

Public Member Functions

virtual void book (TFileDirectory *dir)
 
virtual ConfigurableHistoclone () const
 
void complete ()
 
 ConfigurableHisto (HType t, std::string name, edm::ParameterSet &iConfig)
 
virtual void fill (const edm::Event &iEvent)
 
TH1 * h ()
 
const HTypetype ()
 
virtual ~ConfigurableHisto ()
 

Protected Member Functions

 ConfigurableHisto (const ConfigurableHisto &master)
 

Protected Attributes

edm::ParameterSet conf_
 
TH1 * h_
 
std::string name_
 
HType type_
 
const CachingVariablew_
 
const CachingVariablex_
 
const CachingVariabley_
 
const CachingVariablez_
 

Detailed Description

Definition at line 53 of file ConfigurableHisto.h.

Member Enumeration Documentation

Enumerator
h1 
h2 
prof 

Definition at line 55 of file ConfigurableHisto.h.

Constructor & Destructor Documentation

ConfigurableHisto::ConfigurableHisto ( HType  t,
std::string  name,
edm::ParameterSet iConfig 
)
inline

Definition at line 56 of file ConfigurableHisto.h.

Referenced by clone(), and SplittingConfigurableHisto::SplittingConfigurableHisto().

56  :
57  type_(t),h_(0),name_(name), conf_(iConfig),x_(0),y_(0),z_(0),w_(0){}
const CachingVariable * y_
const CachingVariable * x_
const CachingVariable * w_
edm::ParameterSet conf_
const CachingVariable * z_
virtual ConfigurableHisto::~ConfigurableHisto ( )
inlinevirtual

Definition at line 59 of file ConfigurableHisto.h.

59 {}
ConfigurableHisto::ConfigurableHisto ( const ConfigurableHisto master)
inlineprotected

Definition at line 204 of file ConfigurableHisto.h.

References conf_, h_, name_, type_, w_, x_, y_, and z_.

204  {
205  type_=master.type_;
206  h_=0; //no histogram attached in copy constructor
207  name_=master.name_;
208  conf_=master.conf_;
209  x_=master.x_;
210  y_=master.y_;
211  z_=master.z_;
212  w_=master.w_;
213  }
const CachingVariable * y_
const CachingVariable * x_
const CachingVariable * w_
edm::ParameterSet conf_
const CachingVariable * z_

Member Function Documentation

virtual void ConfigurableHisto::book ( TFileDirectory dir)
inlinevirtual

Reimplemented in SplittingConfigurableHisto.

Definition at line 63 of file ConfigurableHisto.h.

References conf_, edm::ParameterSet::dump(), edm::ParameterSet::exists(), edm::ParameterSet::getParameter(), h1, h2, h_, TFileDirectory::make(), ConfigurableAxis::Max(), ConfigurableAxis::Min(), name_, ConfigurableAxis::nBin(), prof, AlCaHLTBitMon_QueryRunRegistry::string, indexGen::title, type(), w_, x_, ConfigurableAxis::xBins(), and y_.

Referenced by SplittingConfigurableHisto::book().

63  {
66  ConfigurableAxis xAxis(xAxisPSet);
67  x_=edm::Service<VariableHelperService>()->get().variable(xAxisPSet.getParameter<std::string>("var"));
68 
69  std::string yLabel="";
70  bool yVBin=false;
71  ConfigurableAxis yAxis;
72  if (conf_.exists("yAxis")){
74  yAxis=ConfigurableAxis(yAxisPSet);
75  yLabel=yAxis.Label();
76  //at least TH2 or TProfile
77  if (yAxisPSet.exists("var"))
78  y_=edm::Service<VariableHelperService>()->get().variable(yAxisPSet.getParameter<std::string>("var"));
79  yVBin=yAxis.variableSize();
80  }
81 
82  if (conf_.exists("zAxis")){
83  throw;
84  }
85 
86  bool xVBin=xAxis.variableSize();
87 
88 
89  if (type()==h1){
90  //make TH1F
91  if (xVBin)
92  h_=dir->make<TH1F>(name_.c_str(),title.c_str(),
93  xAxis.nBin(), xAxis.xBins());
94  else
95  h_=dir->make<TH1F>(name_.c_str(),title.c_str(),
96  xAxis.nBin(),xAxis.Min(),xAxis.Max());
97  }
98  else if (type()==h2){
99  //make TH2F
100  if (xVBin){
101  if (yVBin)
102  h_=dir->make<TH2F>(name_.c_str(),title.c_str(),
103  xAxis.nBin(),xAxis.xBins(),
104  yAxis.nBin(),yAxis.xBins());
105  else
106  h_=dir->make<TH2F>(name_.c_str(),title.c_str(),
107  xAxis.nBin(),xAxis.xBins(),
108  yAxis.nBin(),yAxis.Min(),yAxis.Max());
109  }else{
110  if (yVBin)
111  h_=dir->make<TH2F>(name_.c_str(),title.c_str(),
112  xAxis.nBin(),xAxis.Min(),xAxis.Max(),
113  yAxis.nBin(),yAxis.xBins());
114  else
115  h_=dir->make<TH2F>(name_.c_str(),title.c_str(),
116  xAxis.nBin(),xAxis.Min(),xAxis.Max(),
117  yAxis.nBin(),yAxis.Min(),yAxis.Max());
118  }
119  }
120  else if (type()==prof){
121  //make TProfile
122  std::string pFopt="";
123  if (conf_.exists("Option"))
124  pFopt=conf_.getParameter<std::string>("Option");
125 
126  if (xVBin)
127  h_=dir->make<TProfile>(name_.c_str(),title.c_str(),
128  xAxis.nBin(), xAxis.xBins(),
129  yAxis.Min(),yAxis.Max(),
130  pFopt.c_str());
131  else
132  h_=dir->make<TProfile>(name_.c_str(),title.c_str(),
133  xAxis.nBin(),xAxis.Min(),xAxis.Max(),
134  yAxis.Min(),yAxis.Max(),
135  pFopt.c_str());
136 
137  }
138  else {
139  edm::LogError("ConfigurableHisto")<<"cannot book: "<<name_<<"\n"<<conf_.dump();
140  throw;
141  }
142 
143  //cosmetics
144  h_->GetXaxis()->SetTitle(xAxis.Label().c_str());
145  h_->SetYTitle(yLabel.c_str());
146 
147  if (conf_.exists("weight"))
148  {
150  }
151  }
T getParameter(std::string const &) const
const HType & type()
std::string dump(unsigned int indent=0) const
bool exists(std::string const &parameterName) const
checks if a parameter exists
const CachingVariable * y_
T * make(const Args &...args) const
make new ROOT object
const CachingVariable * x_
const CachingVariable * w_
edm::ParameterSet conf_
virtual ConfigurableHisto* ConfigurableHisto::clone ( void  ) const
inlinevirtual

Reimplemented in SplittingConfigurableHisto.

Definition at line 61 of file ConfigurableHisto.h.

References ConfigurableHisto().

61 { return new ConfigurableHisto(*this);}
ConfigurableHisto(HType t, std::string name, edm::ParameterSet &iConfig)
void ConfigurableHisto::complete ( )
inline

Definition at line 200 of file ConfigurableHisto.h.

200 {}
virtual void ConfigurableHisto::fill ( const edm::Event iEvent)
inlinevirtual

Reimplemented in SplittingConfigurableHisto.

Definition at line 153 of file ConfigurableHisto.h.

References CachingVariable::compute(), conf_, edm::ParameterSet::dump(), h1, h2, h_, iEvent, name_, prof, type_, w_, histoStyle::weight, x_, and y_.

Referenced by SplittingConfigurableHisto::fill().

153  {
154  if (!h_) return;
155 
156  double weight=1.0;
157  if (w_){
158  if (w_->compute(iEvent))
159  weight=(*w_)(iEvent);
160  else{
161  edm::LogInfo("ConfigurableHisto")<<"could not compute the weight for: "<<name_
162  <<" with config:\n"<<conf_.dump()
163  <<" default to 1.0";
164  }
165  }
166 
167  TProfile * pcast(0);
168  TH2 * h2cast(0);
169  switch(type_){
170  case h1:
171  if (!h_) throw;
172  if (x_->compute(iEvent)) h_->Fill((*x_)(iEvent),weight);
173  else{
174  edm::LogInfo("ConfigurableHisto")<<"could not fill: "<<name_
175  <<" with config:\n"<<conf_.dump();
176  }
177  break;
178  case prof:
179  pcast=dynamic_cast<TProfile*>(h_);
180  if (!pcast) throw;
181  if (x_->compute(iEvent) && y_->compute(iEvent)) pcast->Fill((*x_)(iEvent),(*y_)(iEvent),weight);
182  else{
183  edm::LogInfo("ConfigurableHisto")<<"could not fill: "<<name_
184  <<" with config:\n"<<conf_.dump();
185  }
186  break;
187  case h2:
188  h2cast=dynamic_cast<TH2*>(h_);
189  if (!h2cast) throw;
190  if (x_->compute(iEvent) && y_->compute(iEvent)) h2cast->Fill((*x_)(iEvent),(*y_)(iEvent),weight);
191  else{
192  edm::LogInfo("ConfigurableHisto")<<"could not fill: "<<name_
193  <<" with config:\n"<<conf_.dump();
194  }
195  break;
196  }
197  }
std::string dump(unsigned int indent=0) const
const CachingVariable * y_
int iEvent
Definition: GenABIO.cc:243
const CachingVariable * x_
const CachingVariable * w_
bool compute(const edm::Event &iEvent) const
edm::ParameterSet conf_
int weight
Definition: histoStyle.py:50
TH1* ConfigurableHisto::h ( )
inline

Definition at line 201 of file ConfigurableHisto.h.

References h_.

Referenced by SplittingConfigurableHisto::book(), and SplittingConfigurableHisto::complete().

201 {return h_;}
const HType& ConfigurableHisto::type ( )
inline

Definition at line 198 of file ConfigurableHisto.h.

References type_.

Referenced by cuy.ValElement::__init__(), and book().

198 { return type_;}

Member Data Documentation

edm::ParameterSet ConfigurableHisto::conf_
protected

Definition at line 217 of file ConfigurableHisto.h.

Referenced by book(), ConfigurableHisto(), and fill().

TH1* ConfigurableHisto::h_
protected

Definition at line 215 of file ConfigurableHisto.h.

Referenced by book(), ConfigurableHisto(), fill(), and h().

std::string ConfigurableHisto::name_
protected
HType ConfigurableHisto::type_
protected
const CachingVariable* ConfigurableHisto::w_
protected

Definition at line 222 of file ConfigurableHisto.h.

Referenced by book(), ConfigurableHisto(), and fill().

const CachingVariable* ConfigurableHisto::x_
protected

Definition at line 219 of file ConfigurableHisto.h.

Referenced by book(), ConfigurableHisto(), and fill().

const CachingVariable* ConfigurableHisto::y_
protected

Definition at line 220 of file ConfigurableHisto.h.

Referenced by book(), ConfigurableHisto(), and fill().

const CachingVariable* ConfigurableHisto::z_
protected

Definition at line 221 of file ConfigurableHisto.h.

Referenced by ConfigurableHisto().