PhysicsTools
TagAndProbe
plugins
ObjectMultiplicityCounter.cc
Go to the documentation of this file.
1
//
2
10
#include "
FWCore/Framework/interface/EDProducer.h
"
11
#include "
FWCore/Framework/interface/Event.h
"
12
#include "
FWCore/ParameterSet/interface/ParameterSet.h
"
13
#include "
FWCore/Utilities/interface/InputTag.h
"
14
15
#include "
DataFormats/Math/interface/deltaR.h
"
16
#include "
DataFormats/Common/interface/ValueMap.h
"
17
#include "
DataFormats/Common/interface/View.h
"
18
19
#include "
DataFormats/Candidate/interface/CandidateFwd.h
"
20
#include "
DataFormats/Candidate/interface/Candidate.h
"
21
#include "
DataFormats/TrackReco/interface/Track.h
"
22
#include "
DataFormats/VertexReco/interface/Vertex.h
"
23
#include "
CommonTools/Utils/interface/StringCutObjectSelector.h
"
24
25
template
<
typename
T>
26
class
ObjectMultiplicityCounter
:
public
edm::EDProducer
{
27
public
:
28
explicit
ObjectMultiplicityCounter
(
const
edm::ParameterSet
& iConfig);
29
~ObjectMultiplicityCounter
()
override
;
30
31
void
produce
(
edm::Event
&
iEvent
,
const
edm::EventSetup
& iSetup)
override
;
32
33
private
:
34
edm::EDGetTokenT<edm::View<reco::Candidate>
>
probesToken_
;
35
edm::EDGetTokenT<edm::View<T>
>
objectsToken_
;
36
StringCutObjectSelector<T, true>
objCut_
;
// lazy parsing, to allow cutting on variables not in reco::Candidate class
37
};
38
39
template
<
typename
T>
40
ObjectMultiplicityCounter<T>::ObjectMultiplicityCounter
(
const
edm::ParameterSet
& iConfig)
41
: probesToken_(consumes<
edm
::
View
<
reco
::
Candidate
>>(iConfig.getParameter<
edm
::
InputTag
>(
"probes"
))),
42
objectsToken_(consumes<
edm
::
View
<
T
>>(iConfig.getParameter<
edm
::
InputTag
>(
"objects"
))),
43
objCut_(
44
iConfig.existsAs<
std
::
string
>(
"objectSelection"
) ? iConfig.getParameter<
std
::
string
>(
"objectSelection"
) :
""
,
45
true
) {
46
produces<edm::ValueMap<float>>();
47
}
48
49
template
<
typename
T>
50
ObjectMultiplicityCounter<T>::~ObjectMultiplicityCounter
() {}
51
52
template
<
typename
T>
53
void
ObjectMultiplicityCounter<T>::produce
(
edm::Event
&
iEvent
,
const
edm::EventSetup
& iSetup) {
54
using namespace
edm
;
55
56
// read input
57
Handle<View<reco::Candidate>
> probes;
58
Handle<View<T>
>
objects
;
59
iEvent
.getByToken(probesToken_, probes);
60
iEvent
.getByToken(objectsToken_,
objects
);
61
62
// fill
63
float
count
= 0.0;
64
typename
View<T>::const_iterator
object
, endobjects =
objects
->end();
65
for
(
object
=
objects
->begin();
object
!= endobjects; ++
object
) {
66
if
(!(objCut_(*
object
)))
67
continue
;
68
count
+= 1.0;
69
}
70
71
// prepare vector for output
72
std::vector<float>
values
(probes->size(),
count
);
73
74
// convert into ValueMap and store
75
auto
valMap = std::make_unique<ValueMap<float>>();
76
ValueMap<float>::Filler
filler
(*valMap);
77
filler
.insert(probes,
values
.begin(),
values
.end());
78
filler
.fill();
79
iEvent
.put(
std::move
(valMap));
80
}
81
82
typedef
ObjectMultiplicityCounter<reco::Candidate>
CandMultiplicityCounter
;
83
typedef
ObjectMultiplicityCounter<reco::Track>
TrackMultiplicityCounter
;
84
typedef
ObjectMultiplicityCounter<reco::Vertex>
VertexMultiplicityCounter
;
85
86
#include "
FWCore/Framework/interface/MakerMacros.h
"
87
DEFINE_FWK_MODULE
(
CandMultiplicityCounter
);
88
DEFINE_FWK_MODULE
(
TrackMultiplicityCounter
);
89
DEFINE_FWK_MODULE
(
VertexMultiplicityCounter
);
VertexMultiplicityCounter
ObjectMultiplicityCounter< reco::Vertex > VertexMultiplicityCounter
Definition:
ObjectMultiplicityCounter.cc:84
resolutioncreator_cfi.object
object
Definition:
resolutioncreator_cfi.py:4
configurableAnalysis::Candidate
char Candidate[]
Definition:
modules.cc:20
EDProducer.h
sistrip::View
View
Definition:
ConstantsForView.h:26
edm::EDGetTokenT
Definition:
EDGetToken.h:33
edm
HLT enums.
Definition:
AlignableModifier.h:19
ObjectMultiplicityCounter::probesToken_
edm::EDGetTokenT< edm::View< reco::Candidate > > probesToken_
Definition:
ObjectMultiplicityCounter.cc:34
objects
Definition:
__init__.py:1
HLT_FULL_cff.InputTag
InputTag
Definition:
HLT_FULL_cff.py:89285
ObjectMultiplicityCounter::ObjectMultiplicityCounter
ObjectMultiplicityCounter(const edm::ParameterSet &iConfig)
Definition:
ObjectMultiplicityCounter.cc:40
reco
fixed size matrix
Definition:
AlignmentAlgorithmBase.h:45
edm::Handle
Definition:
AssociativeIterator.h:50
CandidateFwd.h
CandMultiplicityCounter
ObjectMultiplicityCounter< reco::Candidate > CandMultiplicityCounter
Definition:
ObjectMultiplicityCounter.cc:82
MakerMacros.h
Track.h
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition:
MakerMacros.h:16
contentValuesCheck.values
values
Definition:
contentValuesCheck.py:38
ObjectMultiplicityCounter::produce
void produce(edm::Event &iEvent, const edm::EventSetup &iSetup) override
Definition:
ObjectMultiplicityCounter.cc:53
submitPVResolutionJobs.count
count
Definition:
submitPVResolutionJobs.py:352
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition:
AlCaHLTBitMon_QueryRunRegistry.py:256
Vertex.h
funct::true
true
Definition:
Factorize.h:173
edm::ParameterSet
Definition:
ParameterSet.h:47
Event.h
deltaR.h
trigObjTnPSource_cfi.filler
filler
Definition:
trigObjTnPSource_cfi.py:21
iEvent
int iEvent
Definition:
GenABIO.cc:224
edm::EventSetup
Definition:
EventSetup.h:58
TrackMultiplicityCounter
ObjectMultiplicityCounter< reco::Track > TrackMultiplicityCounter
Definition:
ObjectMultiplicityCounter.cc:83
hgcalPerformanceValidation.objects
objects
Definition:
hgcalPerformanceValidation.py:791
InputTag.h
ValueMap.h
eostools.move
def move(src, dest)
Definition:
eostools.py:511
std
Definition:
JetResolutionObject.h:76
StringCutObjectSelector.h
T
long double T
Definition:
Basic3DVectorLD.h:48
edm::ValueMap
Definition:
ValueMap.h:107
StringCutObjectSelector< T, true >
edm::EDProducer
Definition:
EDProducer.h:35
edm::View::const_iterator
boost::indirect_iterator< typename seq_t::const_iterator > const_iterator
Definition:
View.h:86
ObjectMultiplicityCounter
Matcher of number of reconstructed objects in the event to probe.
Definition:
ObjectMultiplicityCounter.cc:26
Candidate.h
View.h
ParameterSet.h
edm::Event
Definition:
Event.h:73
ObjectMultiplicityCounter::~ObjectMultiplicityCounter
~ObjectMultiplicityCounter() override
Definition:
ObjectMultiplicityCounter.cc:50
ObjectMultiplicityCounter::objectsToken_
edm::EDGetTokenT< edm::View< T > > objectsToken_
Definition:
ObjectMultiplicityCounter.cc:35
ObjectMultiplicityCounter::objCut_
StringCutObjectSelector< T, true > objCut_
Definition:
ObjectMultiplicityCounter.cc:36
Generated for CMSSW Reference Manual by
1.8.16