Main Page
Namespaces
Classes
Package Documentation
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Properties
Friends
Macros
Pages
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_ptr<map_type> matchMap(
new
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
( matchMap );
65
}
66
67
#endif
68
i
int i
Definition:
DBlmapReader.cc:9
looper.cfg
tuple cfg
Definition:
looper.py:293
MCTruthCompositeMatcher
Definition:
MCTruthCompositeMatcher.h:13
edm::Event::getByToken
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition:
Event.h:462
MCTruthCompositeMatcher::matchMapTokens_
std::vector< edm::EDGetTokenT< map_type > > matchMapTokens_
Definition:
MCTruthCompositeMatcher.h:20
Event.h
Handle
Handle.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
MCTruthCompositeMatcher::MCTruthCompositeMatcher
MCTruthCompositeMatcher(const edm::ParameterSet &)
Definition:
MCTruthCompositeMatcher.h:30
edm::EDGetTokenT< C1 >
edm::EDProducer
Definition:
EDProducer.h:35
MCTruthCompositeMatcher::map_type
CandMatcher< C1, C2 >::map_type map_type
Definition:
MCTruthCompositeMatcher.h:18
MCTruthCompositeMatcher::~MCTruthCompositeMatcher
~MCTruthCompositeMatcher()
Definition:
MCTruthCompositeMatcher.h:37
ParameterSet.h
reco::JetExtendedAssociation::value_type
Container::value_type value_type
Definition:
JetExtendedAssociation.h:30
GlobalPosition_Frontier_DevDB_cff.tag
tuple tag
Definition:
GlobalPosition_Frontier_DevDB_cff.py:11
edm::Event::put
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition:
Event.h:121
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
edm::EventSetup
Definition:
EventSetup.h:45
transform.h
EDProducer.h
compareJSON.const
string const
Definition:
compareJSON.py:14
HLT_FULL_cff.InputTag
tuple InputTag
Definition:
HLT_FULL_cff.py:72666
InputTag.h
edm::ParameterSet
Definition:
ParameterSet.h:36
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:65
CandMatcherBase::reference_type
map_type::key_type reference_type
concrete candidate reference type
Definition:
CandMatcher.h:27
svgfig.template
def template
Definition:
svgfig.py:520
Generated for CMSSW Reference Manual by
1.8.5