Main Page
Namespaces
Classes
Package Documentation
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Properties
Friends
Macros
Pages
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
std::auto_ptr<OutputType>
output
(
new
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->size();
80
evt.
put
(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
i
int i
Definition:
DBlmapReader.cc:9
edm::InputType
InputType
Definition:
InputType.h:5
edm::Ref::isNonnull
bool isNonnull() const
Checks for non-null.
Definition:
Ref.h:250
reco::PFTauCollection
std::vector< PFTau > PFTauCollection
collection of PFTau objects
Definition:
PFTauFwd.h:9
PFTauFwd.h
Association.h
PFTau.h
edm::Ref
Definition:
AssociativeIterator.h:51
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:47
reco::tau::AssociationMatchRefSelector::filter_
bool filter_
Definition:
RecoTauGenJetMatchSelector.cc:88
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
Handle.h
reco::tau::AssociationMatchRefSelector::AssociationMatchRefSelector
AssociationMatchRefSelector(const edm::ParameterSet &pset)
Definition:
RecoTauGenJetMatchSelector.cc:58
dt_dqm_sourceclient_common_cff.reco
tuple reco
Definition:
dt_dqm_sourceclient_common_cff.py:107
Frameworkfwd.h
edm::RefToBase
Definition:
AssociativeIterator.h:49
reco::tau::AssociationMatchRefSelector::src_
edm::InputTag src_
Definition:
RecoTauGenJetMatchSelector.cc:86
input
static std::string const input
Definition:
EdmProvDump.cc:44
ParameterSet.h
edm::Association
Definition:
Association.h:18
CandViewGenJetMatchRefSelector
reco::tau::AssociationMatchRefSelector< reco::Candidate, reco::GenJetCollection > CandViewGenJetMatchRefSelector
Definition:
RecoTauGenJetMatchSelector.cc:99
edm::Event::put
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition:
Event.h:113
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:27
metsig::tau
Definition:
SignAlgoResolutions.h:40
edm::EventSetup
Definition:
EventSetup.h:44
cond::ecalcond::value_type
Container::value_type value_type
Definition:
EcalChannelStatusPyWrapper.cc:33
edm::Event::getByLabel
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition:
Event.h:402
edm::EDFilter
Definition:
EDFilter.h:37
configurableAnalysis::Candidate
char Candidate[]
Definition:
modules.cc:22
convertSQLitetoXML_cfg.output
tuple output
Definition:
convertSQLitetoXML_cfg.py:32
convertXMLtoSQLite_cfg.toPut
tuple toPut
Definition:
convertXMLtoSQLite_cfg.py:21
CandViewPFTauMatchRefSelector
reco::tau::AssociationMatchRefSelector< reco::Candidate, reco::PFTauCollection, reco::PFTauRefVector, reco::tau::RefCaster > CandViewPFTauMatchRefSelector
Definition:
RecoTauGenJetMatchSelector.cc:103
reco::tau::AssociationMatchRefSelector::cloner_
ClonePolicy cloner_
Definition:
RecoTauGenJetMatchSelector.cc:85
edm::InputTag
Definition:
InputTag.h:17
InputTag.h
edm::ParameterSet
Definition:
ParameterSet.h:35
match
std::pair< typename Association::data_type::first_type, double > match(Reference key, Association association, bool bestMatchByMaxValue)
Generic matching function.
Definition:
Utils.h:6
edm::Event
Definition:
Event.h:59
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
reco::tau::AssociationMatchRefSelector::OutputValue
OutputType::value_type OutputValue
Definition:
RecoTauGenJetMatchSelector.cc:54
fileCollector.convert
def convert
Definition:
fileCollector.py:45
PFJet.h
reco::tau::AssociationMatchRefSelector::AssocType
edm::Association< MatchedType > AssocType
Definition:
RecoTauGenJetMatchSelector.cc:55
Generated for CMSSW Reference Manual by
1.8.5