#include <HistoAnalyzer.h>
Public Member Functions | |
HistoAnalyzer (const edm::ParameterSet &) | |
constructor from parameter set | |
~HistoAnalyzer () | |
destructor | |
Protected Member Functions | |
virtual void | analyze (const edm::Event &, const edm::EventSetup &) override |
process an event | |
Private Attributes | |
edm::InputTag | src_ |
label of the collection to be read in | |
bool | usingWeights_ |
Do we weight events? | |
std::vector< ExpressionHisto < typename C::value_type > * > | vhistograms |
vector of the histograms | |
edm::InputTag | weights_ |
label of the weight collection (can be null for weights = 1) |
Creates histograms defined in config file
Template parameters:
Definition at line 22 of file HistoAnalyzer.h.
HistoAnalyzer< C >::HistoAnalyzer | ( | const edm::ParameterSet & | par | ) |
constructor from parameter set
Definition at line 45 of file HistoAnalyzer.h.
References end, estimatePileup::hist, bookConverter::histograms, ExpressionHisto< T >::initialize(), and HistoAnalyzer< C >::vhistograms.
: src_(par.template getParameter<edm::InputTag>("src")), usingWeights_(par.exists("weights")), weights_(par.template getUntrackedParameter<edm::InputTag>("weights", edm::InputTag("fake"))) { edm::Service<TFileService> fs; std::vector<edm::ParameterSet> histograms = par.template getParameter<std::vector<edm::ParameterSet> >("histograms"); std::vector<edm::ParameterSet>::const_iterator it = histograms.begin(); std::vector<edm::ParameterSet>::const_iterator end = histograms.end(); // create the histograms from the given parameter sets for (; it!=end; ++it) { ExpressionHisto<typename C::value_type>* hist = new ExpressionHisto<typename C::value_type>(*it); hist->initialize(*fs); vhistograms.push_back(hist); } }
HistoAnalyzer< C >::~HistoAnalyzer | ( | ) |
destructor
Definition at line 67 of file HistoAnalyzer.h.
References end.
{ // delete all histograms and clear the vector of pointers typename std::vector<ExpressionHisto<typename C::value_type>* >::iterator it = vhistograms.begin(); typename std::vector<ExpressionHisto<typename C::value_type>* >::iterator end = vhistograms.end(); for (;it!=end; ++it){ (*it)->~ExpressionHisto<typename C::value_type>(); } vhistograms.clear(); }
void HistoAnalyzer< C >::analyze | ( | const edm::Event & | iEvent, |
const edm::EventSetup & | |||
) | [override, protected, virtual] |
process an event
Implements edm::EDAnalyzer.
Definition at line 79 of file HistoAnalyzer.h.
References coll, HTMLExport::elem(), end, edm::Event::getByLabel(), i, and histoStyle::weight.
{ edm::Handle<C> coll; iEvent.getByLabel( src_, coll); double weight = 1.0; if (usingWeights_) { edm::Handle<double> weightColl; iEvent.getByLabel( weights_, weightColl ); weight = *weightColl; } typename std::vector<ExpressionHisto<typename C::value_type>* >::iterator it = vhistograms.begin(); typename std::vector<ExpressionHisto<typename C::value_type>* >::iterator end = vhistograms.end(); for (;it!=end; ++it){ uint32_t i = 0; for( typename C::const_iterator elem=coll->begin(); elem!=coll->end(); ++elem, ++i ) { if (!(*it)->fill( *elem, weight, i )) { break; } } } }
edm::InputTag HistoAnalyzer< C >::src_ [private] |
label of the collection to be read in
Definition at line 35 of file HistoAnalyzer.h.
bool HistoAnalyzer< C >::usingWeights_ [private] |
Do we weight events?
Definition at line 37 of file HistoAnalyzer.h.
std::vector<ExpressionHisto<typename C::value_type>* > HistoAnalyzer< C >::vhistograms [private] |
vector of the histograms
Definition at line 41 of file HistoAnalyzer.h.
Referenced by HistoAnalyzer< C >::HistoAnalyzer().
edm::InputTag HistoAnalyzer< C >::weights_ [private] |
label of the weight collection (can be null for weights = 1)
Definition at line 39 of file HistoAnalyzer.h.