CMS 3D CMS Logo

Public Member Functions | Private Attributes

ExpressionHisto< T > Class Template Reference

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

List of all members.

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.

                                                                 :
  min(iConfig.template getUntrackedParameter<double>("min")),
  max(iConfig.template getUntrackedParameter<double>("max")),
  nbins(iConfig.template getUntrackedParameter<int>("nbins")),
  name(iConfig.template getUntrackedParameter<std::string>("name")),
  description(iConfig.template getUntrackedParameter<std::string>("description")),
  function(iConfig.template getUntrackedParameter<std::string>("plotquantity"), 
           iConfig.template getUntrackedParameter<bool>("lazyParsing", false)) {
  int32_t itemsToPlot = iConfig.template getUntrackedParameter<int32_t>("itemsToPlot", -1);
  if (itemsToPlot <= 0) {
      nhistos = 1; separatePlots = false;
  } else {
      nhistos = itemsToPlot; separatePlots = true;
  }
}
template<typename T >
ExpressionHisto< T >::~ExpressionHisto ( )

Definition at line 75 of file ExpressionHisto.h.

                                     {
}

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 root::function(), estimatePileup::hist, and i.

{
  if (!separatePlots) hist[0]->Fill( function(element), weight );
  else if (i < nhistos)  hist[i]->Fill( function(element), weight );
  else return false;
  return true;
}
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(), min, mergeVDriftHistosByStation::name, and pileupCalc::nbins.

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

{
   hist = new TH1F*[nhistos];
   char buff[1024],baff[1024];
   if (separatePlots) {
       for (uint32_t i = 0; i < nhistos; i++) {
               if (strstr(name.c_str(), "%d") != 0) {
                       snprintf(buff, 1024, name.c_str(), i+1);
               } else {
                       snprintf(buff, 1024, "%s [#%d]", name.c_str(), i+1);
               }
               if (strstr(description.c_str(), "%d") != 0) {
                       snprintf(baff, 1024, description.c_str(), i+1);
               } else {
                       snprintf(baff, 1024, "%s [#%d]", description.c_str(), i+1);
               }
               hist[i] = fs.make<TH1F>(buff,baff,nbins,min,max);
       }
    } else {
       hist[0] = fs.make<TH1F>(name.c_str(),description.c_str(),nbins,min,max);
    }
}

Member Data Documentation

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

Definition at line 50 of file ExpressionHisto.h.

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]

Definition at line 50 of file ExpressionHisto.h.

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

Definition at line 49 of file ExpressionHisto.h.

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().