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

◆ ExpressionHisto()

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.

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;
69  separatePlots = false;
70  } else {
71  nhistos = itemsToPlot;
72  separatePlots = true;
73  }
74 }
std::string description
std::string name

◆ ~ExpressionHisto()

template<typename T >
ExpressionHisto< T >::~ExpressionHisto ( )

Definition at line 77 of file ExpressionHisto.h.

77 {}

Member Function Documentation

◆ fill()

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 compareTotals::hist, and mps_fire::i.

103  {
104  if (!separatePlots)
105  hist[0]->Fill(function(element), weight);
106  else if (i < nhistos)
107  hist[i]->Fill(function(element), weight);
108  else
109  return false;
110  return true;
111 }
Definition: weight.py:1

◆ initialize()

template<typename T >
void ExpressionHisto< T >::initialize ( TFileDirectory fs)

Definition at line 80 of file ExpressionHisto.h.

References makeListRunsInFiles::description, compareTotals::fs, compareTotals::hist, mps_fire::i, SiStripPI::max, SiStripPI::min, Skims_PA_cff::name, and LaserClient_cfi::nbins.

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 }
std::string description
std::string name

Member Data Documentation

◆ description

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

Definition at line 50 of file ExpressionHisto.h.

◆ function

template<typename T>
StringObjectFunction<T> ExpressionHisto< T >::function
private

◆ hist

template<typename T>
TH1F** ExpressionHisto< T >::hist
private

◆ max

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

Definition at line 48 of file ExpressionHisto.h.

◆ min

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

Definition at line 48 of file ExpressionHisto.h.

◆ name

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__(), 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__(), FWLite.WorkingPoints::_reformat_cut_definitions(), core.autovars.NTupleObjectType::addSubObjects(), core.autovars.NTupleObjectType::addVariables(), core.autovars.NTupleObjectType::allVars(), dataset.CMSDataset::buildListOfFiles(), dataset.LocalDataset::buildListOfFiles(), dataset.CMSDataset::buildListOfFilesDBS(), 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(), 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(), python.rootplot.utilities.Hist::TGraph(), python.rootplot.utilities.Hist::TH1F(), counter.Counter::write(), and average.Average::write().

◆ nbins

template<typename T>
int ExpressionHisto< T >::nbins
private

◆ nhistos

template<typename T>
uint32_t ExpressionHisto< T >::nhistos
private

Definition at line 51 of file ExpressionHisto.h.

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

◆ separatePlots

template<typename T>
bool ExpressionHisto< T >::separatePlots
private

Definition at line 52 of file ExpressionHisto.h.

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