CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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 estimatePileup::hist, and i.

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 }
int i
Definition: DBlmapReader.cc:9
int weight
Definition: histoStyle.py:50
template<typename T >
void ExpressionHisto< T >::initialize ( TFileDirectory fs)

Definition at line 79 of file ExpressionHisto.h.

References idDealer::description, estimatePileup::hist, i, TFileDirectory::make(), max(), bookConverter::min, mergeVDriftHistosByStation::name, and pileupCalc::nbins.

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") != 0) {
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") != 0) {
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 }
int i
Definition: DBlmapReader.cc:9
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
template<typename T>
StringObjectFunction<T> ExpressionHisto< T >::function
private

Definition at line 54 of file ExpressionHisto.h.

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

Definition at line 53 of file ExpressionHisto.h.

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

Definition at line 48 of file ExpressionHisto.h.

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

Definition at line 48 of file ExpressionHisto.h.

template<typename T>
std::string ExpressionHisto< T >::name
private
template<typename T>
int ExpressionHisto< T >::nbins
private
template<typename T>
uint32_t ExpressionHisto< T >::nhistos
private

Definition at line 51 of file ExpressionHisto.h.

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

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

Definition at line 52 of file ExpressionHisto.h.

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