CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Protected Member Functions | Private Attributes
HistoAnalyzer< C > Class Template Reference

#include <HistoAnalyzer.h>

Inheritance diagram for HistoAnalyzer< C >:
edm::EDAnalyzer edm::EDConsumerBase

Public Member Functions

 HistoAnalyzer (const edm::ParameterSet &)
 constructor from parameter set More...
 
 ~HistoAnalyzer ()
 destructor More...
 
- Public Member Functions inherited from edm::EDAnalyzer
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 EDAnalyzer ()
 
ModuleDescription const & moduleDescription () const
 
std::string workerType () const
 
virtual ~EDAnalyzer ()
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
 EDConsumerBase ()
 
ProductHolderIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
std::vector
< ProductHolderIndexAndSkipBit >
const & 
itemsToGetFromEvent () const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesDependentUpon (const std::string &iProcessName, std::vector< const char * > &oModuleLabels) const
 
void modulesWhoseProductsAreConsumed (std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
bool registeredToConsume (ProductHolderIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductHolderIndexHelper const &)
 
virtual ~EDConsumerBase ()
 

Protected Member Functions

virtual void analyze (const edm::Event &, const edm::EventSetup &) override
 process an event More...
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken consumes (TypeToGet const &id, edm::InputTag const &tag)
 
ConsumesCollector consumesCollector ()
 Use a ConsumesCollector to gather consumes information from helper functions. More...
 
template<typename ProductType , BranchType B = InEvent>
void consumesMany ()
 
void consumesMany (const TypeToGet &id)
 
template<BranchType B>
void consumesMany (const TypeToGet &id)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 

Private Attributes

edm::EDGetTokenT< C > srcToken_
 label of the collection to be read in More...
 
bool usingWeights_
 Do we weight events? More...
 
std::vector< ExpressionHisto
< typename C::value_type > * > 
vhistograms
 vector of the histograms More...
 
edm::EDGetTokenT< double > weightsToken_
 label of the weight collection (can be null for weights = 1) More...
 

Additional Inherited Members

- Public Types inherited from edm::EDAnalyzer
typedef EDAnalyzer ModuleType
 
- Static Public Member Functions inherited from edm::EDAnalyzer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &)
 

Detailed Description

template<typename C>
class HistoAnalyzer< C >

Creates histograms defined in config file

Author
: Benedikt Hegner, DESY

Template parameters:

Definition at line 22 of file HistoAnalyzer.h.

Constructor & Destructor Documentation

template<typename C >
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(), TFileService::tFileDirectory(), and HistoAnalyzer< C >::vhistograms.

45  :
46  srcToken_(consumes<C>(par.template getParameter<edm::InputTag>("src"))),
47  usingWeights_(par.exists("weights")),
48  weightsToken_(mayConsume<double>(par.template getUntrackedParameter<edm::InputTag>("weights", edm::InputTag("fake"))))
49 {
51  std::vector<edm::ParameterSet> histograms =
52  par.template getParameter<std::vector<edm::ParameterSet> >("histograms");
53  std::vector<edm::ParameterSet>::const_iterator it = histograms.begin();
54  std::vector<edm::ParameterSet>::const_iterator end = histograms.end();
55 
56  // create the histograms from the given parameter sets
57  for (; it!=end; ++it)
58  {
60  hist->initialize(fs->tFileDirectory());
61  vhistograms.push_back(hist);
62  }
63 
64 }
edm::EDGetTokenT< C > srcToken_
label of the collection to be read in
Definition: HistoAnalyzer.h:35
bool exists(std::string const &parameterName) const
checks if a parameter exists
std::vector< ExpressionHisto< typename C::value_type > * > vhistograms
vector of the histograms
Definition: HistoAnalyzer.h:41
TFileDirectory & tFileDirectory()
Definition: TFileService.h:42
#define end
Definition: vmac.h:37
edm::EDGetTokenT< double > weightsToken_
label of the weight collection (can be null for weights = 1)
Definition: HistoAnalyzer.h:39
void initialize(TFileDirectory &fs)
bool usingWeights_
Do we weight events?
Definition: HistoAnalyzer.h:37
template<typename C >
HistoAnalyzer< C >::~HistoAnalyzer ( )

destructor

Definition at line 67 of file HistoAnalyzer.h.

References end.

68 {
69  // delete all histograms and clear the vector of pointers
70  typename std::vector<ExpressionHisto<typename C::value_type>* >::iterator it = vhistograms.begin();
71  typename std::vector<ExpressionHisto<typename C::value_type>* >::iterator end = vhistograms.end();
72  for (;it!=end; ++it){
73  (*it)->~ExpressionHisto<typename C::value_type>();
74  }
75  vhistograms.clear();
76 }
std::vector< ExpressionHisto< typename C::value_type > * > vhistograms
vector of the histograms
Definition: HistoAnalyzer.h:41
#define end
Definition: vmac.h:37
Container::value_type value_type

Member Function Documentation

template<typename C >
void HistoAnalyzer< C >::analyze ( const edm::Event iEvent,
const edm::EventSetup  
)
overrideprotectedvirtual

process an event

Implements edm::EDAnalyzer.

Definition at line 79 of file HistoAnalyzer.h.

References coll, HTMLExport::elem(), end, edm::Event::getByToken(), i, and histoStyle::weight.

80 {
82  iEvent.getByToken( srcToken_, coll);
83  double weight = 1.0;
84  if (usingWeights_) {
85  edm::Handle<double> weightColl;
86  iEvent.getByToken( weightsToken_, weightColl );
87  weight = *weightColl;
88  }
89 
90  typename std::vector<ExpressionHisto<typename C::value_type>* >::iterator it = vhistograms.begin();
91  typename std::vector<ExpressionHisto<typename C::value_type>* >::iterator end = vhistograms.end();
92 
93  for (;it!=end; ++it){
94  uint32_t i = 0;
95  for( typename C::const_iterator elem=coll->begin(); elem!=coll->end(); ++elem, ++i ) {
96  if (!(*it)->fill( *elem, weight, i )) {
97  break;
98  }
99  }
100  }
101 }
int i
Definition: DBlmapReader.cc:9
edm::EDGetTokenT< C > srcToken_
label of the collection to be read in
Definition: HistoAnalyzer.h:35
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:449
std::vector< ExpressionHisto< typename C::value_type > * > vhistograms
vector of the histograms
Definition: HistoAnalyzer.h:41
#define end
Definition: vmac.h:37
JetCorrectorParametersCollection coll
Definition: classes.h:10
edm::EDGetTokenT< double > weightsToken_
label of the weight collection (can be null for weights = 1)
Definition: HistoAnalyzer.h:39
int weight
Definition: histoStyle.py:50
bool usingWeights_
Do we weight events?
Definition: HistoAnalyzer.h:37

Member Data Documentation

template<typename C >
edm::EDGetTokenT<C> HistoAnalyzer< C >::srcToken_
private

label of the collection to be read in

Definition at line 35 of file HistoAnalyzer.h.

template<typename C >
bool HistoAnalyzer< C >::usingWeights_
private

Do we weight events?

Definition at line 37 of file HistoAnalyzer.h.

template<typename C >
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().

template<typename C >
edm::EDGetTokenT<double> HistoAnalyzer< C >::weightsToken_
private

label of the weight collection (can be null for weights = 1)

Definition at line 39 of file HistoAnalyzer.h.