Main Page
Namespaces
Classes
Package Documentation
CommonTools
UtilAlgos
interface
ObjectCounter.h
Go to the documentation of this file.
1
#ifndef UtilAlgos_ObjectCounter_h
2
#define UtilAlgos_ObjectCounter_h
3
18
#include "
FWCore/Framework/interface/EDAnalyzer.h
"
19
#include "
FWCore/Framework/interface/Event.h
"
20
#include "
FWCore/ParameterSet/interface/ParameterSet.h
"
21
#include "FWCore/Framework/interface/TypeID.h"
22
#include <iostream>
23
#include <cmath>
24
25
template
<
typename
C>
26
class
ObjectCounter
:
public
edm::EDAnalyzer
{
27
public
:
29
explicit
ObjectCounter
(
const
edm::ParameterSet
& );
31
void
endJob
();
32
33
private
:
35
virtual
void
analyze
(
const
edm::Event
&,
const
edm::EventSetup
&)
override
;
37
edm::EDGetTokenT<C>
srcToken_
;
39
bool
verbose_
;
41
unsigned
long
n_
,
nSum_
,
n2Sum_
;
42
};
43
44
template
<
typename
C>
45
ObjectCounter<C>::ObjectCounter
(
const
edm::ParameterSet
& par ) :
46
srcToken_
(
consumes
<
C
>(
edm
::InputTag( par.
template
getParameter<
std
::
string
>(
"src"
) ) ) ),
47
verbose_
( par.
template
getUntrackedParameter<
bool
>(
"verbose"
,
true
) ),
48
n_
( 0 ),
nSum_
( 0 ),
n2Sum_
( 0 ) {
49
}
50
51
template
<
typename
C>
52
void
ObjectCounter<C>::endJob
() {
53
double
n
= 0, n2 = 0,
s
;
54
if
(
n_
!= 0 ) {
55
n = double(
nSum_
) /
n_
;
56
n2 = double (
n2Sum_
) /
n_
;
57
}
58
s
=
sqrt
( n2 - n * n );
59
if
(
verbose_
) {
60
edm::TypeID
id
(
typeid
(
typename
C::value_type
) );
61
std::cout
<<
">>> collection \""
<<
srcToken_
<<
"\" contains ("
62
<< n <<
" +/- "
<<
s
<<
") "
63
<<
id
.friendlyClassName() <<
" objects"
<< std::endl;
64
}
65
}
66
67
template
<
typename
C>
68
void
ObjectCounter<C>::analyze
(
const
edm::Event
& evt,
const
edm::EventSetup
& ) {
69
edm::Handle<C>
h
;
70
evt.
getByToken
(
srcToken_
, h );
71
if
(!h.
isValid
()) {
72
std::cerr
<<
">>> product: "
<<
srcToken_
<<
" not found"
<< std::endl;
73
}
else
{
74
int
n
= h->size();
75
nSum_
+=
n
;
76
n2Sum_
+= ( n *
n
);
77
}
78
++
n_
;
79
}
80
81
#endif
82
h
FWCore Framework interface EventSetupRecordImplementation h
Helper function to determine trigger accepts.
Definition:
L1TUtmAlgorithmRcd.h:4
ObjectCounter::ObjectCounter
ObjectCounter(const edm::ParameterSet &)
constructor from parameter set
Definition:
ObjectCounter.h:45
edm::Event::getByToken
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition:
Event.h:517
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition:
AlCaHLTBitMon_QueryRunRegistry.py:256
ObjectCounter
Definition:
ObjectCounter.h:26
ObjectCounter::n_
unsigned long n_
partial statistics
Definition:
ObjectCounter.h:41
Event.h
ObjectCounter::verbose_
bool verbose_
verbosity flag
Definition:
ObjectCounter.h:39
alignCSCRings.s
s
Definition:
alignCSCRings.py:92
edm::Handle
Definition:
AssociativeIterator.h:47
MessageLogger_cfi.cerr
cerr
Definition:
MessageLogger_cfi.py:547
std
Definition:
JetResolutionObject.h:80
edm::TypeID
Definition:
TypeID.h:22
edm::EDGetTokenT< C >
edm::EDConsumerBase::consumes
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
Definition:
EDConsumerBase.h:126
ParameterSet.h
funct::true
true
Definition:
Factorize.h:185
reco::JetExtendedAssociation::value_type
Container::value_type value_type
Definition:
JetExtendedAssociation.h:30
ObjectCounter::srcToken_
edm::EDGetTokenT< C > srcToken_
label of source collection
Definition:
ObjectCounter.h:37
ObjectCounter::analyze
virtual void analyze(const edm::Event &, const edm::EventSetup &) override
event processing
Definition:
ObjectCounter.h:68
ObjectCounter::nSum_
unsigned long nSum_
Definition:
ObjectCounter.h:41
triggerObjects_cff.id
id
Definition:
triggerObjects_cff.py:31
patCaloMETCorrections_cff.C
C
Definition:
patCaloMETCorrections_cff.py:45
mathSSE::sqrt
T sqrt(T t)
Definition:
SSEVec.h:18
ObjectCounter::endJob
void endJob()
end-of-job processing
Definition:
ObjectCounter.h:52
svgfig.template
def template(fileName, svg, replaceme="REPLACEME")
Definition:
svgfig.py:521
edm::EventSetup
Definition:
EventSetup.h:57
edm::HandleBase::isValid
bool isValid() const
Definition:
HandleBase.h:74
edm::EDAnalyzer
Definition:
EDAnalyzer.h:29
EDAnalyzer.h
electrons_cff.bool
bool
Definition:
electrons_cff.py:389
gen::n
int n
Definition:
Cascade2Hadronizer.cc:79
edm
HLT enums.
Definition:
AlignableModifier.h:17
edm::ParameterSet
Definition:
ParameterSet.h:36
gather_cfg.cout
cout
Definition:
gather_cfg.py:144
ObjectCounter::n2Sum_
unsigned long n2Sum_
Definition:
ObjectCounter.h:41
edm::Event
Definition:
Event.h:71
Generated for CMSSW Reference Manual by
1.8.11