CMS 3D CMS Logo

List of all members | Public Member Functions | Private Attributes
ExpressionHisto< T > Class Template Reference

#include <CommonTools/Utils/interface/ExpressionHisto.h>

Public Member Functions

 ExpressionHisto (const edm::ParameterSet &iConfig)
 
bool fill (const T &element, double weight=1.0, uint32_t i=0)
 
void initialize (TFileDirectory &fs)
 
 ~ExpressionHisto ()
 

Private Attributes

std::string description
 
StringObjectFunction< Tfunction
 
TH1F ** hist
 
double max
 
double min
 
std::string name
 
int nbins
 
uint32_t nhistos
 
bool separatePlots
 

Detailed Description

template<typename T>
class ExpressionHisto< T >

Description: Histogram tool using expressions

Usage: <usage>

Definition at line 34 of file ExpressionHisto.h.

Constructor & Destructor Documentation

template<typename T >
ExpressionHisto< T >::ExpressionHisto ( const edm::ParameterSet iConfig)

Definition at line 58 of file ExpressionHisto.h.

References ExpressionHisto< T >::nhistos, and ExpressionHisto< T >::separatePlots.

58  :
59  min(iConfig.template getUntrackedParameter<double>("min")),
60  max(iConfig.template getUntrackedParameter<double>("max")),
61  nbins(iConfig.template getUntrackedParameter<int>("nbins")),
62  name(iConfig.template getUntrackedParameter<std::string>("name")),
63  description(iConfig.template getUntrackedParameter<std::string>("description")),
64  function(iConfig.template getUntrackedParameter<std::string>("plotquantity"),
65  iConfig.template getUntrackedParameter<bool>("lazyParsing", false)) {
66  int32_t itemsToPlot = iConfig.template getUntrackedParameter<int32_t>("itemsToPlot", -1);
67  if (itemsToPlot <= 0) {
68  nhistos = 1; separatePlots = false;
69  } else {
70  nhistos = itemsToPlot; separatePlots = true;
71  }
72 }
std::string description
std::string name
template<typename T >
ExpressionHisto< T >::~ExpressionHisto ( )

Definition at line 75 of file ExpressionHisto.h.

75  {
76 }

Member Function Documentation

template<typename T >
bool ExpressionHisto< T >::fill ( const T element,
double  weight = 1.0,
uint32_t  i = 0 
)

Plot the quantity for the specified element and index. Returns true if the quantity has been plotted, false otherwise. A return value of "false" means "please don't send any more elements". The default "i = 0" is to keep backwards compatibility with usages outside HistoAnalyzer

Definition at line 103 of file ExpressionHisto.h.

References ExpressionHisto< T >::hist, mps_fire::i, ExpressionHisto< T >::nhistos, and ExpressionHisto< T >::separatePlots.

104 {
105  if (!separatePlots) hist[0]->Fill( function(element), weight );
106  else if (i < nhistos) hist[i]->Fill( function(element), weight );
107  else return false;
108  return true;
109 }
Definition: weight.py:1
template<typename T >
void ExpressionHisto< T >::initialize ( TFileDirectory fs)

Definition at line 79 of file ExpressionHisto.h.

References ExpressionHisto< T >::description, ExpressionHisto< T >::hist, mps_fire::i, TFileDirectory::make(), ExpressionHisto< T >::max, ExpressionHisto< T >::min, ExpressionHisto< T >::name, ExpressionHisto< T >::nbins, ExpressionHisto< T >::nhistos, and ExpressionHisto< T >::separatePlots.

Referenced by HistoAnalyzer< C >::HistoAnalyzer().

80 {
81  hist = new TH1F*[nhistos];
82  char buff[1024],baff[1024];
83  if (separatePlots) {
84  for (uint32_t i = 0; i < nhistos; i++) {
85  if (strstr(name.c_str(), "%d") != nullptr) {
86  snprintf(buff, 1024, name.c_str(), i+1);
87  } else {
88  snprintf(buff, 1024, "%s [#%d]", name.c_str(), i+1);
89  }
90  if (strstr(description.c_str(), "%d") != nullptr) {
91  snprintf(baff, 1024, description.c_str(), i+1);
92  } else {
93  snprintf(baff, 1024, "%s [#%d]", description.c_str(), i+1);
94  }
95  hist[i] = fs.make<TH1F>(buff,baff,nbins,min,max);
96  }
97  } else {
98  hist[0] = fs.make<TH1F>(name.c_str(),description.c_str(),nbins,min,max);
99  }
100 }
T * make(const Args &...args) const
make new ROOT object
std::string description
std::string name

Member Data Documentation

template<typename T>
std::string ExpressionHisto< T >::description
private

Definition at line 50 of file ExpressionHisto.h.

Referenced by ExpressionHisto< T >::initialize().

template<typename T>
StringObjectFunction<T> ExpressionHisto< T >::function
private
template<typename T>
TH1F** ExpressionHisto< T >::hist
private
template<typename T>
double ExpressionHisto< T >::max
private

Definition at line 48 of file ExpressionHisto.h.

Referenced by ExpressionHisto< T >::initialize().

template<typename T>
double ExpressionHisto< T >::min
private

Definition at line 48 of file ExpressionHisto.h.

Referenced by ExpressionHisto< T >::initialize().

template<typename T>
std::string ExpressionHisto< T >::name
private

Definition at line 50 of file ExpressionHisto.h.

Referenced by ElectronMVAID.ElectronMVAID::__call__(), FWLite.ElectronMVAID::__call__(), dirstructure.Directory::__create_pie_image(), DisplayManager.DisplayManager::__del__(), dqm_interfaces.DirID::__eq__(), BeautifulSoup.Tag::__eq__(), dirstructure.Directory::__get_full_path(), dirstructure.Comparison::__get_img_name(), dataset.Dataset::__getDataType(), dataset.Dataset::__getFileInfoList(), dirstructure.Comparison::__make_image(), core.autovars.NTupleVariable::__repr__(), core.autovars.NTupleObjectType::__repr__(), core.autovars.NTupleObject::__repr__(), core.autovars.NTupleCollection::__repr__(), dirstructure.Directory::__repr__(), dqm_interfaces.DirID::__repr__(), dirstructure.Comparison::__repr__(), config.Service::__setattr__(), config.CFG::__str__(), counter.Counter::__str__(), average.Average::__str__(), BeautifulSoup.Tag::__str__(), BeautifulSoup.SoupStrainer::__str__(), FWLite.WorkingPoints::_reformat_cut_definitions(), core.autovars.NTupleObjectType::addSubObjects(), core.autovars.NTupleObjectType::addVariables(), core.autovars.NTupleObjectType::allVars(), dirstructure.Directory::calcStats(), validation.Sample::digest(), python.rootplot.utilities.Hist::divide(), python.rootplot.utilities.Hist::divide_wilson(), DisplayManager.DisplayManager::Draw(), TreeCrawler.Package::dump(), core.autovars.NTupleVariable::fillBranch(), core.autovars.NTupleObject::fillBranches(), core.autovars.NTupleCollection::fillBranchesScalar(), core.autovars.NTupleCollection::fillBranchesVector(), core.autovars.NTupleCollection::get_cpp_declaration(), core.autovars.NTupleCollection::get_cpp_wrapper_class(), core.autovars.NTupleCollection::get_py_wrapper_class(), utils.StatisticalTest::get_status(), production_tasks.Task::getname(), dataset.CMSDataset::getPrimaryDatasetEntries(), dataset.PrivateDataset::getPrimaryDatasetEntries(), ExpressionHisto< T >::initialize(), VIDSelectorBase.VIDSelectorBase::initialize(), personalPlayback.Applet::log(), core.autovars.NTupleVariable::makeBranch(), core.autovars.NTupleObject::makeBranches(), core.autovars.NTupleCollection::makeBranchesScalar(), core.autovars.NTupleCollection::makeBranchesVector(), dirstructure.Directory::print_report(), dataset.BaseDataset::printInfo(), dataset.Dataset::printInfo(), production_tasks.MonitorJobs::run(), BeautifulSoup.SoupStrainer::searchTag(), python.rootplot.utilities.Hist::TGraph(), python.rootplot.utilities.Hist::TH1F(), Vispa.Views.PropertyView.Property::valueChanged(), counter.Counter::write(), and average.Average::write().

template<typename T>
int ExpressionHisto< T >::nbins
private
template<typename T>
uint32_t ExpressionHisto< T >::nhistos
private
template<typename T>
bool ExpressionHisto< T >::separatePlots
private