Main Page
Namespaces
Classes
Package Documentation
RecoTauTag
TauTagTools
plugins
RecoTauGenJetMatchSelector.cc
Go to the documentation of this file.
1
/*
2
* AssociationMatchRefSelector
3
*
4
* EDFilter template to select objects from a View<InputType> that have valid
5
* matches in the given Association<MatchedType> matching, and produce a
6
* RefToBaseVector pointing to the matched objects.
7
*
8
* Author: Evan K. Friis (UC Davis)
9
*
10
*/
11
12
#include "
FWCore/Framework/interface/Frameworkfwd.h
"
13
#include "
FWCore/Framework/interface/EDFilter.h
"
14
#include "
FWCore/Framework/interface/Event.h
"
15
#include "
FWCore/Utilities/interface/InputTag.h
"
16
#include "
FWCore/ParameterSet/interface/ParameterSet.h
"
17
#include "
DataFormats/Common/interface/Handle.h
"
18
#include "
DataFormats/Common/interface/Association.h
"
19
#include "
DataFormats/Common/interface/RefToBaseVector.h
"
20
21
namespace
reco
{
namespace
tau
{
22
23
namespace
{
24
25
// When the output is a RefToBaseVector<Candidate>, we need to copy the input
26
// RefToBases. (otherwise we get a complaint since Ref<Candidate> is not the
27
// concrete type. When storing RefVectors to PFTaus we need to cast the refs
28
// correctly.
29
30
class
RefCaster {
31
public
:
32
template
<
typename
InBaseRef,
typename
REF>
33
REF
convert
(
const
InBaseRef&
in
)
const
{
34
return
in.template castTo<REF>();
35
}
36
};
37
38
class
RefCopier {
39
public
:
40
template
<
typename
InBaseRef,
typename
REF>
41
REF
convert
(
const
InBaseRef&
in
)
const
{
42
return
REF(in);
43
}
44
};
45
46
}
47
48
template
<
typename
InputType
,
typename
MatchedType,
49
typename
OutputType=
typename
edm::RefToBaseVector<InputType>
,
50
typename
ClonePolicy=RefCopier>
51
class
AssociationMatchRefSelector
:
public
edm::EDFilter
{
52
public
:
53
//typedef typename edm::RefToBaseVector<InputType> OutputType;
54
typedef
typename
OutputType::value_type
OutputValue
;
55
typedef
typename
edm::Association<MatchedType>
AssocType
;
56
typedef
typename
edm::RefToBase<InputType>
InputRef
;
57
58
explicit
AssociationMatchRefSelector
(
const
edm::ParameterSet
&
pset
) {
59
src_ = pset.
getParameter
<
edm::InputTag
>(
"src"
);
60
matching_ = pset.
getParameter
<
edm::InputTag
>(
"matching"
);
61
filter_ = pset.
getParameter
<
bool
>(
"filter"
);
62
produces<OutputType>();
63
}
64
bool
filter
(
edm::Event
& evt,
const
edm::EventSetup
&es)
override
{
65
edm::Handle<edm::View<InputType>
>
input
;
66
evt.
getByLabel
(src_, input);
67
edm::Handle<AssocType>
match
;
68
evt.
getByLabel
(matching_, match);
69
auto
output
= std::make_unique<OutputType>();
70
for
(
size_t
i
= 0;
i
< input->size(); ++
i
) {
71
typename
AssocType::reference_type
matched
= (*match)[input->refAt(
i
)];
72
// Check if matched
73
if
(matched.
isNonnull
()) {
74
OutputValue
toPut
=
75
cloner_.template convert<InputRef, OutputValue>(input->refAt(
i
));
76
output
->push_back(toPut);
77
}
78
}
79
bool
notEmpty = !
output
->empty();
80
evt.
put
(
std::move
(
output
));
81
// Filter if no events passed
82
return
( !filter_ || notEmpty );
83
}
84
private
:
85
ClonePolicy
cloner_
;
86
edm::InputTag
src_
;
87
edm::InputTag
matching_
;
88
bool
filter_
;
89
};
90
}}
// end reco::tau
91
92
#include "
FWCore/Framework/interface/MakerMacros.h
"
93
#include "
DataFormats/JetReco/interface/GenJetCollection.h
"
94
#include "
DataFormats/JetReco/interface/PFJet.h
"
95
#include "
DataFormats/TauReco/interface/PFTau.h
"
96
#include "
DataFormats/TauReco/interface/PFTauFwd.h
"
97
98
typedef
reco::tau::AssociationMatchRefSelector
<
reco::Candidate
,
99
reco::GenJetCollection
>
CandViewGenJetMatchRefSelector
;
100
101
typedef
reco::tau::AssociationMatchRefSelector
<
reco::Candidate
,
102
reco::PFTauCollection
,
reco::PFTauRefVector
,
103
reco::tau::RefCaster>
CandViewPFTauMatchRefSelector
;
104
105
DEFINE_FWK_MODULE
(
CandViewGenJetMatchRefSelector
);
106
DEFINE_FWK_MODULE
(
CandViewPFTauMatchRefSelector
);
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
edm::InputType
InputType
Definition:
InputType.h:5
edm::Event::put
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition:
Event.h:137
edm::Ref::isNonnull
bool isNonnull() const
Checks for non-null.
Definition:
Ref.h:251
reco::PFTauCollection
std::vector< PFTau > PFTauCollection
collection of PFTau objects
Definition:
PFTauFwd.h:9
mps_fire.i
i
Definition:
mps_fire.py:329
PFTauFwd.h
Association.h
PFTau.h
edm::Ref
Definition:
AssociativeIterator.h:52
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition:
MakerMacros.h:17
Event.h
reco::GenJetCollection
std::vector< GenJet > GenJetCollection
collection of GenJet objects
Definition:
GenJetCollection.h:14
MakerMacros.h
edm::Handle
Definition:
AssociativeIterator.h:48
reco::tau::AssociationMatchRefSelector::filter_
bool filter_
Definition:
RecoTauGenJetMatchSelector.cc:88
muonDTDigis_cfi.pset
pset
Definition:
muonDTDigis_cfi.py:27
convertSQLitetoXML_cfg.output
output
Definition:
convertSQLitetoXML_cfg.py:32
reco::PFTauRefVector
edm::RefVector< PFTauCollection > PFTauRefVector
vector of references to PFTau objects all in the same collection
Definition:
PFTauFwd.h:17
recoMuon::in
Definition:
RecoMuonEnumerators.h:6
reco::tau::AssociationMatchRefSelector::AssociationMatchRefSelector
AssociationMatchRefSelector(const edm::ParameterSet &pset)
Definition:
RecoTauGenJetMatchSelector.cc:58
Frameworkfwd.h
edm::RefToBase
Definition:
AssociativeIterator.h:50
reco::tau::AssociationMatchRefSelector::src_
edm::InputTag src_
Definition:
RecoTauGenJetMatchSelector.cc:86
input
static std::string const input
Definition:
EdmProvDump.cc:45
ParameterSet.h
edm::Association
Definition:
Association.h:18
reco::JetExtendedAssociation::value_type
Container::value_type value_type
Definition:
JetExtendedAssociation.h:30
CandViewGenJetMatchRefSelector
reco::tau::AssociationMatchRefSelector< reco::Candidate, reco::GenJetCollection > CandViewGenJetMatchRefSelector
Definition:
RecoTauGenJetMatchSelector.cc:99
EDFilter.h
reco::tau::AssociationMatchRefSelector
Definition:
RecoTauGenJetMatchSelector.cc:51
RefToBaseVector.h
GenJetCollection.h
reco::tau::AssociationMatchRefSelector::InputRef
edm::RefToBase< InputType > InputRef
Definition:
RecoTauGenJetMatchSelector.cc:56
edm::RefToBaseVector
Definition:
EDProductfwd.h:24
metsig::tau
Definition:
SignAlgoResolutions.h:40
edm::EventSetup
Definition:
EventSetup.h:54
electrons_cff.matched
matched
Definition:
electrons_cff.py:419
fileCollector.convert
def convert(infile, ofile)
Definition:
fileCollector.py:46
edm::Event::getByLabel
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition:
Event.h:535
edm::EDFilter
Definition:
EDFilter.h:38
configurableAnalysis::Candidate
char Candidate[]
Definition:
modules.cc:22
CandViewPFTauMatchRefSelector
reco::tau::AssociationMatchRefSelector< reco::Candidate, reco::PFTauCollection, reco::PFTauRefVector, reco::tau::RefCaster > CandViewPFTauMatchRefSelector
Definition:
RecoTauGenJetMatchSelector.cc:103
reco
fixed size matrix
Definition:
AlignmentAlgorithmBase.h:43
reco::tau::AssociationMatchRefSelector::cloner_
ClonePolicy cloner_
Definition:
RecoTauGenJetMatchSelector.cc:85
edm::InputTag
Definition:
InputTag.h:15
InputTag.h
DBConfiguration_cff.toPut
toPut
Definition:
DBConfiguration_cff.py:25
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:70
reco::tau::AssociationMatchRefSelector::matching_
edm::InputTag matching_
Definition:
RecoTauGenJetMatchSelector.cc:87
reco::tau::AssociationMatchRefSelector::filter
bool filter(edm::Event &evt, const edm::EventSetup &es) override
Definition:
RecoTauGenJetMatchSelector.cc:64
eostools.move
def move(src, dest)
Definition:
eostools.py:511
reco::tau::AssociationMatchRefSelector::OutputValue
OutputType::value_type OutputValue
Definition:
RecoTauGenJetMatchSelector.cc:54
PFJet.h
Handle.h
reco::tau::AssociationMatchRefSelector::AssocType
edm::Association< MatchedType > AssocType
Definition:
RecoTauGenJetMatchSelector.cc:55
Generated for CMSSW Reference Manual by
1.8.11