Main Page
Namespaces
Classes
Package Documentation
PhysicsTools
HepMCCandAlgos
interface
MCTruthCompositeMatcher.h
Go to the documentation of this file.
1
#ifndef HepMCCandAlgos_MCTruthCompositeMatcher
2
#define HepMCCandAlgos_MCTruthCompositeMatcher
3
/* \class MCTruthCompositeMatcher
4
*
5
* \author Luca Lista, INFN
6
*
7
*/
8
#include "
FWCore/Framework/interface/EDProducer.h
"
9
#include "
FWCore/Utilities/interface/InputTag.h
"
10
#include "PhysicsTools/HepMCCandAlgos/interface/MCCandMatcher.h"
11
12
template
<
typename
C1,
typename
C2 = C1>
13
class
MCTruthCompositeMatcher
:
public
edm::EDProducer
{
14
public
:
15
explicit
MCTruthCompositeMatcher
(
const
edm::ParameterSet
& );
16
~MCTruthCompositeMatcher
();
17
private
:
18
typedef
typename
CandMatcher<C1, C2>::map_type
map_type
;
19
edm::EDGetTokenT<C1>
srcToken_
;
20
std::vector<edm::EDGetTokenT<map_type> >
matchMapTokens_
;
21
void
produce
(
edm::Event
& ,
const
edm::EventSetup
&)
override
;
22
};
23
24
#include "
FWCore/ParameterSet/interface/ParameterSet.h
"
25
#include "
FWCore/Utilities/interface/transform.h
"
26
#include "
FWCore/Framework/interface/Event.h
"
27
#include "
DataFormats/Common/interface/Handle.h
"
28
29
template
<
typename
C1,
typename
C2>
30
MCTruthCompositeMatcher<C1, C2>::MCTruthCompositeMatcher
(
const
edm::ParameterSet
&
cfg
) :
31
srcToken_
(
consumes
<C1>(cfg.
template
getParameter<
edm
::InputTag>(
"src"
) ) ),
32
matchMapTokens_
(
edm
::
vector_transform
(cfg.
template
getParameter<
std
::vector<
edm
::InputTag> >(
"matchMaps"
), [this](
edm
::InputTag const &
tag
){
return
consumes<map_type>(
tag
);} ) ) {
33
produces<map_type>();
34
}
35
36
template
<
typename
C1,
typename
C2>
37
MCTruthCompositeMatcher<C1, C2>::~MCTruthCompositeMatcher
() {
38
}
39
40
template
<
typename
C1,
typename
C2>
41
void
MCTruthCompositeMatcher<C1, C2>::produce
(
edm::Event
& evt ,
const
edm::EventSetup
& ) {
42
typedef
typename
CandMatcher<C1, C2>::reference_type
reference_type;
43
Handle<C1>
cands
;
44
evt.
getByToken
(
srcToken_
, cands);
45
46
size_t
nMaps = matchMaps_.size();
47
std::vector<const map_type *> maps;
48
maps.reserve( nMaps );
49
for
(
size_t
i
= 0;
i
!= nMaps; ++
i
) {
50
Handle<map_type>
matchMap;
51
evt.
getByToken
(
matchMapTokens_
[
i
], matchMap );
52
maps.push_back( & * matchMap );
53
}
54
MCCandMatcher<C1, C2>
match
( maps );
55
auto
matchMap = std::make_unique<map_type>();
56
for
(
size_t
i
= 0;
i
!= cands->size(); ++
i
) {
57
const
typename
C1::value_type
&
cand
= ( * cands )[
i
];
58
reference_type
mc
(
match
( cand ));
59
if
( mc.isNonnull() ) {
60
matchMap->insert( reference_type( cands,
i
), mc );
61
}
62
}
63
64
evt.
put
(
std::move
(matchMap) );
65
}
66
67
#endif
68
CaloTowersParam_cfi.mc
mc
Definition:
CaloTowersParam_cfi.py:8
edm::Event::put
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition:
Event.h:125
GlobalPosition_Frontier_DevDB_cff.tag
tag
Definition:
GlobalPosition_Frontier_DevDB_cff.py:11
mps_fire.i
i
Definition:
mps_fire.py:338
MCTruthCompositeMatcher
Definition:
MCTruthCompositeMatcher.h:13
edm::Event::getByToken
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition:
Event.h:517
MCTruthCompositeMatcher::matchMapTokens_
std::vector< edm::EDGetTokenT< map_type > > matchMapTokens_
Definition:
MCTruthCompositeMatcher.h:20
Event.h
Handle
std
Definition:
JetResolutionObject.h:80
MCTruthCompositeMatcher::MCTruthCompositeMatcher
MCTruthCompositeMatcher(const edm::ParameterSet &)
Definition:
MCTruthCompositeMatcher.h:30
edm::EDGetTokenT< C1 >
edm::EDProducer
Definition:
EDProducer.h:36
MCTruthCompositeMatcher::map_type
CandMatcher< C1, C2 >::map_type map_type
Definition:
MCTruthCompositeMatcher.h:18
MCTruthCompositeMatcher::~MCTruthCompositeMatcher
~MCTruthCompositeMatcher()
Definition:
MCTruthCompositeMatcher.h:37
edm::EDConsumerBase::consumes
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
Definition:
EDConsumerBase.h:126
ParameterSet.h
reco::JetExtendedAssociation::value_type
Container::value_type value_type
Definition:
JetExtendedAssociation.h:30
MCTruthCompositeMatcher::produce
void produce(edm::Event &, const edm::EventSetup &) override
Definition:
MCTruthCompositeMatcher.h:41
MCTruthCompositeMatcher::srcToken_
edm::EDGetTokenT< C1 > srcToken_
Definition:
MCTruthCompositeMatcher.h:19
edm::AssociationMap
Definition:
AssociationMap.h:48
svgfig.template
def template(fileName, svg, replaceme="REPLACEME")
Definition:
svgfig.py:521
edm::EventSetup
Definition:
EventSetup.h:57
looper.cfg
cfg
Definition:
looper.py:297
transform.h
EDProducer.h
edm::vector_transform
auto vector_transform(std::vector< InputType > const &input, Function predicate) -> std::vector< typename std::remove_cv< typename std::remove_reference< decltype(predicate(input.front()))>::type >::type >
Definition:
transform.h:11
edm
HLT enums.
Definition:
AlignableModifier.h:17
egammaForCoreTracking_cff.cands
cands
Definition:
egammaForCoreTracking_cff.py:39
InputTag.h
edm::ParameterSet
Definition:
ParameterSet.h:36
cand
Definition:
decayParser.h:34
match
std::pair< typename Association::data_type::first_type, double > match(Reference key, Association association, bool bestMatchByMaxValue)
Generic matching function.
Definition:
Utils.h:10
edm::Event
Definition:
Event.h:71
CandMatcherBase::reference_type
map_type::key_type reference_type
concrete candidate reference type
Definition:
CandMatcher.h:27
eostools.move
def move(src, dest)
Definition:
eostools.py:511
Handle.h
Generated for CMSSW Reference Manual by
1.8.11