#include <PhysicsTools/UtilAlgos/interface/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 &) |
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) |
Template parameters:
Definition at line 20 of file HistoAnalyzer.h.
HistoAnalyzer< C >::HistoAnalyzer | ( | const edm::ParameterSet & | par | ) | [inline] |
constructor from parameter set
Definition at line 43 of file HistoAnalyzer.h.
References end, bookConverter::histograms, ExpressionHisto< T >::initialize(), it, and HistoAnalyzer< C >::vhistograms.
00043 : 00044 src_(par.template getParameter<edm::InputTag>("src")), 00045 usingWeights_(par.exists("weights")), 00046 weights_(par.template getUntrackedParameter<edm::InputTag>("weights", edm::InputTag("fake"))) 00047 { 00048 edm::Service<TFileService> fs; 00049 std::vector<edm::ParameterSet> histograms = 00050 par.template getParameter<std::vector<edm::ParameterSet> >("histograms"); 00051 std::vector<edm::ParameterSet>::const_iterator it = histograms.begin(); 00052 std::vector<edm::ParameterSet>::const_iterator end = histograms.end(); 00053 00054 // create the histograms from the given parameter sets 00055 for (; it!=end; ++it) 00056 { 00057 ExpressionHisto<typename C::value_type>* hist = new ExpressionHisto<typename C::value_type>(*it); 00058 hist->initialize(fs); 00059 vhistograms.push_back(hist); 00060 } 00061 00062 }
HistoAnalyzer< C >::~HistoAnalyzer | ( | ) | [inline] |
destructor
Definition at line 65 of file HistoAnalyzer.h.
References end, it, and HistoAnalyzer< C >::vhistograms.
00066 { 00067 // delete all histograms and clear the vector of pointers 00068 typename std::vector<ExpressionHisto<typename C::value_type>* >::iterator it = vhistograms.begin(); 00069 typename std::vector<ExpressionHisto<typename C::value_type>* >::iterator end = vhistograms.end(); 00070 for (;it!=end; ++it){ 00071 (*it)->~ExpressionHisto<typename C::value_type>(); 00072 } 00073 vhistograms.clear(); 00074 }
void HistoAnalyzer< C >::analyze | ( | const edm::Event & | iEvent, | |
const edm::EventSetup & | ||||
) | [inline, protected, virtual] |
process an event
Implements edm::EDAnalyzer.
Reimplemented in ZToMuMuHistogrammer.
Definition at line 77 of file HistoAnalyzer.h.
References coll, end, edm::Event::getByLabel(), i, it, HistoAnalyzer< C >::src_, HistoAnalyzer< C >::usingWeights_, HistoAnalyzer< C >::vhistograms, weight, and HistoAnalyzer< C >::weights_.
Referenced by ZToMuMuHistogrammer::analyze().
00078 { 00079 edm::Handle<C> coll; 00080 iEvent.getByLabel( src_, coll); 00081 double weight = 1.0; 00082 if (usingWeights_) { 00083 edm::Handle<double> weightColl; 00084 iEvent.getByLabel( weights_, weightColl ); 00085 weight = *weightColl; 00086 } 00087 00088 typename std::vector<ExpressionHisto<typename C::value_type>* >::iterator it = vhistograms.begin(); 00089 typename std::vector<ExpressionHisto<typename C::value_type>* >::iterator end = vhistograms.end(); 00090 00091 for (;it!=end; ++it){ 00092 uint32_t i = 0; 00093 for( typename C::const_iterator elem=coll->begin(); elem!=coll->end(); ++elem, ++i ) { 00094 if (!(*it)->fill( *elem, weight, i )) { 00095 break; 00096 } 00097 } 00098 } 00099 }
edm::InputTag HistoAnalyzer< C >::src_ [private] |
label of the collection to be read in
Definition at line 33 of file HistoAnalyzer.h.
Referenced by HistoAnalyzer< C >::analyze().
bool HistoAnalyzer< C >::usingWeights_ [private] |
Do we weight events?
Definition at line 35 of file HistoAnalyzer.h.
Referenced by HistoAnalyzer< C >::analyze().
std::vector<ExpressionHisto<typename C::value_type>* > HistoAnalyzer< C >::vhistograms [private] |
vector of the histograms
Definition at line 39 of file HistoAnalyzer.h.
Referenced by HistoAnalyzer< C >::analyze(), HistoAnalyzer< C >::HistoAnalyzer(), and HistoAnalyzer< C >::~HistoAnalyzer().
edm::InputTag HistoAnalyzer< C >::weights_ [private] |
label of the weight collection (can be null for weights = 1)
Definition at line 37 of file HistoAnalyzer.h.
Referenced by HistoAnalyzer< C >::analyze().