CMS 3D CMS Logo

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::one::EDAnalyzer< edm::one::SharedResources > edm::one::EDAnalyzerBase edm::EDConsumerBase

Public Member Functions

 HistoAnalyzer (const edm::ParameterSet &)
 constructor from parameter set More...
 
 ~HistoAnalyzer () override
 destructor More...
 
- Public Member Functions inherited from edm::one::EDAnalyzer< edm::one::SharedResources >
 EDAnalyzer ()=default
 
 EDAnalyzer (const EDAnalyzer &)=delete
 
SerialTaskQueueglobalLuminosityBlocksQueue () final
 
SerialTaskQueueglobalRunsQueue () final
 
const EDAnalyzeroperator= (const EDAnalyzer &)=delete
 
bool wantsGlobalLuminosityBlocks () const final
 
bool wantsGlobalRuns () const final
 
bool wantsInputProcessBlocks () const final
 
bool wantsProcessBlocks () const final
 
- Public Member Functions inherited from edm::one::EDAnalyzerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 EDAnalyzerBase ()
 
ModuleDescription const & moduleDescription () const
 
bool wantsStreamLuminosityBlocks () const
 
bool wantsStreamRuns () const
 
 ~EDAnalyzerBase () override
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
void convertCurrentProcessAlias (std::string const &processName)
 Convert "@currentProcess" in InputTag process names to the actual current process name. More...
 
 EDConsumerBase ()
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
 EDConsumerBase (EDConsumerBase &&)=default
 
ESProxyIndex const * esGetTokenIndices (edm::Transition iTrans) const
 
std::vector< ESProxyIndex > const & esGetTokenIndicesVector (edm::Transition iTrans) const
 
std::vector< ESRecordIndex > const & esGetTokenRecordIndicesVector (edm::Transition iTrans) const
 
ProductResolverIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
std::vector< ProductResolverIndexAndSkipBit > const & itemsToGetFrom (BranchType iType) const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesWhoseProductsAreConsumed (std::array< std::vector< ModuleDescription const *> *, NumBranchTypes > &modulesAll, std::vector< ModuleProcessName > &modulesInPreviousProcesses, ProductRegistry const &preg, std::map< std::string, ModuleDescription const *> const &labelsToDesc, std::string const &processName) const
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
bool registeredToConsume (ProductResolverIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void selectInputProcessBlocks (ProductRegistry const &productRegistry, ProcessBlockHelperBase const &processBlockHelperBase)
 
ProductResolverIndexAndSkipBit uncheckedIndexFrom (EDGetToken) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
void updateLookup (eventsetup::ESRecordsToProxyIndices const &)
 
virtual ~EDConsumerBase () noexcept(false)
 

Protected Member Functions

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)
 
template<BranchType B = InEvent>
EDConsumerBaseAdaptor< Bconsumes (edm::InputTag tag) noexcept
 
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 ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes ()
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes (ESInputTag const &tag)
 
template<Transition Tr = Transition::Event>
constexpr auto esConsumes ()
 
template<Transition Tr = Transition::Event>
auto esConsumes (ESInputTag tag)
 
template<Transition Tr = Transition::Event>
ESGetTokenGeneric esConsumes (eventsetup::EventSetupRecordKey const &iRecord, eventsetup::DataKey const &iKey)
 Used with EventSetupRecord::doGet. More...
 
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)
 
void resetItemsToGetFrom (BranchType iType)
 

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::one::EDAnalyzerBase
typedef EDAnalyzerBase ModuleType
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- Static Public Member Functions inherited from edm::one::EDAnalyzerBase
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 

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

◆ HistoAnalyzer()

template<typename C >
HistoAnalyzer< C >::HistoAnalyzer ( const edm::ParameterSet par)

constructor from parameter set

Definition at line 45 of file HistoAnalyzer.h.

References mps_fire::end, compareTotals::fs, gpuVertexFinder::hist, TFileService::kSharedResource, and HistoAnalyzer< C >::vhistograms.

46  : srcToken_(consumes<C>(par.template getParameter<edm::InputTag>("src"))),
47  usingWeights_(par.exists("weights")),
49  mayConsume<double>(par.template getUntrackedParameter<edm::InputTag>("weights", edm::InputTag("fake")))) {
50  usesResource(TFileService::kSharedResource);
52  std::vector<edm::ParameterSet> histograms = 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) {
59  hist->initialize(fs->tFileDirectory());
60  vhistograms.push_back(hist);
61  }
62 }
static const std::string kSharedResource
Definition: TFileService.h:76
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
__shared__ Hist hist
edm::EDGetTokenT< double > weightsToken_
label of the weight collection (can be null for weights = 1)
Definition: HistoAnalyzer.h:39
bool usingWeights_
Do we weight events?
Definition: HistoAnalyzer.h:37

◆ ~HistoAnalyzer()

template<typename C >
HistoAnalyzer< C >::~HistoAnalyzer ( )
override

destructor

Definition at line 65 of file HistoAnalyzer.h.

References mps_fire::end.

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

Member Function Documentation

◆ analyze()

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

process an event

Implements edm::one::EDAnalyzerBase.

Definition at line 76 of file HistoAnalyzer.h.

References mps_fire::end, mps_fire::i, and iEvent.

76  {
77  edm::Handle<C> coll;
78  iEvent.getByToken(srcToken_, coll);
79  double weight = 1.0;
80  if (usingWeights_) {
81  edm::Handle<double> weightColl;
82  iEvent.getByToken(weightsToken_, weightColl);
83  weight = *weightColl;
84  }
85 
86  typename std::vector<ExpressionHisto<typename C::value_type>*>::iterator it = vhistograms.begin();
87  typename std::vector<ExpressionHisto<typename C::value_type>*>::iterator end = vhistograms.end();
88 
89  for (; it != end; ++it) {
90  uint32_t i = 0;
91  for (typename C::const_iterator elem = coll->begin(); elem != coll->end(); ++elem, ++i) {
92  if (!(*it)->fill(*elem, weight, i)) {
93  break;
94  }
95  }
96  }
97 }
edm::EDGetTokenT< C > srcToken_
label of the collection to be read in
Definition: HistoAnalyzer.h:35
Definition: weight.py:1
std::vector< ExpressionHisto< typename C::value_type > * > vhistograms
vector of the histograms
Definition: HistoAnalyzer.h:41
int iEvent
Definition: GenABIO.cc:224
edm::EDGetTokenT< double > weightsToken_
label of the weight collection (can be null for weights = 1)
Definition: HistoAnalyzer.h:39
bool usingWeights_
Do we weight events?
Definition: HistoAnalyzer.h:37

Member Data Documentation

◆ srcToken_

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.

◆ usingWeights_

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

Do we weight events?

Definition at line 37 of file HistoAnalyzer.h.

◆ vhistograms

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

◆ weightsToken_

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.