Main Page
Namespaces
Classes
Package Documentation
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Properties
Friends
Macros
Pages
PhysicsTools
JetMCAlgos
plugins
CandOneToManyDeltaRMatcher.cc
Go to the documentation of this file.
1
/* \class CandOneToManyDeltaRMatcher
2
*
3
* Producer for simple match map:
4
* class to match two collections of candidate
5
* with one-to-Many matching
6
* All elements of class "matched" are matched to each element
7
* of class "source" orderd in DeltaR
8
*
9
*/
10
11
#include "
FWCore/Framework/interface/EDProducer.h
"
12
#include "
FWCore/ParameterSet/interface/ParameterSetfwd.h
"
13
#include "
FWCore/Utilities/interface/InputTag.h
"
14
15
#include<vector>
16
#include<iostream>
17
18
class
CandOneToManyDeltaRMatcher
:
public
edm::EDProducer
{
19
public
:
20
CandOneToManyDeltaRMatcher
(
const
edm::ParameterSet
& );
21
~CandOneToManyDeltaRMatcher
();
22
private
:
23
void
produce
(
edm::Event
&,
const
edm::EventSetup
& );
24
25
edm::InputTag
source_
;
26
edm::InputTag
matched_
;
27
bool
printdebug_
;
28
};
29
30
#include "
FWCore/Framework/interface/ESHandle.h
"
31
#include "
FWCore/Framework/interface/Event.h
"
32
#include "
FWCore/Framework/interface/EventSetup.h
"
33
#include "
FWCore/Utilities/interface/EDMException.h
"
34
#include "
FWCore/ParameterSet/interface/ParameterSet.h
"
35
#include "
FWCore/MessageLogger/interface/MessageLogger.h
"
36
37
#include "
DataFormats/Common/interface/Handle.h
"
38
#include "
DataFormats/Candidate/interface/Candidate.h
"
39
#include "
DataFormats/Candidate/interface/LeafCandidate.h
"
40
#include "
DataFormats/Candidate/interface/CandMatchMap.h
"
41
#include "
DataFormats/Candidate/interface/CandMatchMapMany.h
"
42
#include "
DataFormats/Candidate/interface/CandidateFwd.h
"
43
44
45
#include <Math/VectorUtil.h>
46
#include <TMath.h>
47
48
using namespace
edm;
49
using namespace
std;
50
using namespace
reco
;
51
using namespace
ROOT::Math::VectorUtil;
52
53
namespace
reco
{
54
namespace
helper {
55
typedef
pair<size_t, double>
MatchPair
;
56
57
struct
SortBySecond
{
58
bool
operator()
(
const
MatchPair
&
p1
,
const
MatchPair
&
p2
)
const
{
59
return
p1.second < p2.second;
60
}
61
};
62
}
63
}
64
65
CandOneToManyDeltaRMatcher::CandOneToManyDeltaRMatcher
(
const
ParameterSet
& cfg ) :
66
source_( cfg.getParameter<
InputTag
>(
"src"
) ),
67
matched_( cfg.getParameter<
InputTag
>(
"matched"
) ),
68
printdebug_( cfg.getUntrackedParameter<bool>(
"printDebug"
,
false
) ) {
69
produces<CandMatchMapMany>();
70
}
71
72
CandOneToManyDeltaRMatcher::~CandOneToManyDeltaRMatcher
() {
73
}
74
75
void
CandOneToManyDeltaRMatcher::produce
(
Event
& evt,
const
EventSetup
& es ) {
76
77
Handle<CandidateCollection>
source
;
78
Handle<CandidateCollection>
matched;
79
evt.
getByLabel
(
source_
, source ) ;
80
evt.
getByLabel
(
matched_
, matched ) ;
81
82
if
(
printdebug_
) {
83
for
(
CandidateCollection::const_iterator
c
= source->begin();
c
!= source->end(); ++
c
) {
84
cout
<<
"[CandOneToManyDeltaRMatcher] Et source "
<<
c
->et() << endl;
85
}
86
for
(
CandidateCollection::const_iterator
c
= matched->begin();
c
!= matched->end(); ++
c
) {
87
cout
<<
"[CandOneToManyDeltaRMatcher] Et matched "
<<
c
->et() << endl;
88
}
89
}
90
91
92
auto_ptr<CandMatchMapMany> matchMap(
new
CandMatchMapMany
(
CandMatchMapMany::ref_type
(
CandidateRefProd
( source ),
93
CandidateRefProd
( matched )
94
) ) );
95
for
(
size_t
c
= 0;
c
!= source->size(); ++
c
) {
96
const
Candidate
&
src
= (*source)[
c
];
97
if
(
printdebug_
)
cout
<<
"[CandOneToManyDeltaRMatcher] source (Et,Eta,Phi) =("
<< src.
et
() <<
","
<<
98
src.
eta
() <<
","
<<
99
src.
phi
() <<
")"
<< endl;
100
vector<reco::helper::MatchPair>
v
;
101
for
(
size_t
m
= 0;
m
!= matched->size(); ++
m
) {
102
const
Candidate
&
match
= ( * matched )[
m
];
103
double
dist =
DeltaR
( src.
p4
() , match.
p4
() );
104
v.push_back( make_pair(
m
, dist ) );
105
}
106
if
( v.size() > 0 ) {
107
sort
( v.begin(), v.end(),
reco::helper::SortBySecond
() );
108
for
(
size_t
m
= 0;
m
!= v.size(); ++
m
) {
109
if
(
printdebug_
)
cout
<<
"[CandOneToManyDeltaRMatcher] match (Et,Eta,Phi) =("
<< ( * matched )[ v[
m
].first ].et() <<
","
<<
110
( * matched )[ v[
m
].first ].eta() <<
","
<<
111
( * matched )[ v[
m
].first ].phi() <<
") DeltaR="
<<
112
v[
m
].second << endl;
113
matchMap->insert(
CandidateRef
( source,
c
), make_pair(
CandidateRef
( matched, v[
m
].
first
), v[
m
].
second
) );
114
}
115
}
116
}
117
118
evt.
put
( matchMap );
119
120
}
121
122
#include "
FWCore/PluginManager/interface/ModuleDef.h
"
123
#include "
FWCore/Framework/interface/MakerMacros.h
"
124
125
DEFINE_FWK_MODULE
(
CandOneToManyDeltaRMatcher
);
reco::helper::SortBySecond::operator()
bool operator()(const MatchPair &p1, const MatchPair &p2) const
Definition:
CandOneToManyDeltaRMatcher.cc:58
CandMatchMap.h
reco::CandMatchMapMany
edm::AssociationMap< edm::OneToManyWithQuality< reco::CandidateCollection, reco::CandidateCollection, double > > CandMatchMapMany
Definition:
CandMatchMapMany.h:19
MessageLogger.h
LeafCandidate.h
DeltaR
Definition:
deltaR.h:51
reco::Candidate::et
virtual double et() const =0
transverse energy
funct::false
false
Definition:
Factorize.h:34
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition:
MakerMacros.h:17
Event.h
MakerMacros.h
EventSetup.h
reco::Candidate
Definition:
Candidate.h:29
python.multivaluedict.sort
def sort
Definition:
multivaluedict.py:161
CandOneToManyDeltaRMatcher::source_
edm::InputTag source_
Definition:
CandOneToManyDeltaRMatcher.cc:25
CandOneToManyDeltaRMatcher::matched_
edm::InputTag matched_
Definition:
CandOneToManyDeltaRMatcher.cc:26
reco::helper::SortBySecond
Definition:
CandOneToManyDeltaRMatcher.cc:57
Handle.h
edm::Handle
Definition:
AssociativeIterator.h:48
dt_dqm_sourceclient_common_cff.reco
tuple reco
Definition:
dt_dqm_sourceclient_common_cff.py:105
ParameterSetfwd.h
edm::EDProducer
Definition:
EDProducer.h:21
ParameterSet.h
CandOneToManyDeltaRMatcher::printdebug_
bool printdebug_
Definition:
CandOneToManyDeltaRMatcher.cc:27
edm::second
U second(std::pair< T, U > const &p)
Definition:
ParameterSet.cc:234
Candidate.h
CandOneToManyDeltaRMatcher::CandOneToManyDeltaRMatcher
CandOneToManyDeltaRMatcher(const edm::ParameterSet &)
Definition:
CandOneToManyDeltaRMatcher.cc:65
EDMException.h
edm::Event::put
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition:
Event.h:85
reco::helper::MatchPair
pair< size_t, double > MatchPair
Definition:
CandOneToManyDeltaRMatcher.cc:55
ESHandle.h
edm::EventSetup
Definition:
EventSetup.h:44
alcazmumu_cfi.src
tuple src
Definition:
alcazmumu_cfi.py:30
CandMatchMapMany.h
first
bool first
Definition:
L1TdeRCT.cc:94
p2
double p2[4]
Definition:
TauolaWrapper.h:90
edm::Event::getByLabel
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition:
Event.h:356
EDProducer.h
CandOneToManyDeltaRMatcher
Definition:
CandOneToManyDeltaRMatcher.cc:18
m
int m
Definition:
DTDataIntegrityTask.cc:33
CandOneToManyDeltaRMatcher::~CandOneToManyDeltaRMatcher
~CandOneToManyDeltaRMatcher()
Definition:
CandOneToManyDeltaRMatcher.cc:72
reco::CandidateRef
edm::Ref< CandidateCollection > CandidateRef
persistent reference to an object in a collection of Candidate objects
Definition:
CandidateFwd.h:29
trackerHits.c
tuple c
Definition:
trackerHits.py:26
CandOneToManyDeltaRMatcher::produce
void produce(edm::Event &, const edm::EventSetup &)
Definition:
CandOneToManyDeltaRMatcher.cc:75
reco::modules::helper::MatchPair
std::pair< size_t, double > MatchPair
Definition:
Matcher.h:66
p1
double p1[4]
Definition:
TauolaWrapper.h:89
edm::InputTag
Definition:
InputTag.h:12
edm::OwnVector::const_iterator
Definition:
OwnVector.h:42
InputTag.h
edm::AssociationMap::ref_type
Tag::ref_type ref_type
reference set type
Definition:
AssociationMap.h:34
LaserTracksInput_cfi.source
tuple source
Definition:
LaserTracksInput_cfi.py:5
edm::ParameterSet
Definition:
ParameterSet.h:35
gather_cfg.cout
tuple cout
Definition:
gather_cfg.py:121
CandidateFwd.h
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:50
reco::CandidateRefProd
edm::RefProd< CandidateCollection > CandidateRefProd
reference to a collection of Candidate objects
Definition:
CandidateFwd.h:37
ModuleDef.h
v
mathSSE::Vec4< T > v
Definition:
newBasic3DVector.h:354
reco::Candidate::phi
virtual double phi() const =0
momentum azimuthal angle
reco::Candidate::eta
virtual double eta() const =0
momentum pseudorapidity
reco::Candidate::p4
virtual const LorentzVector & p4() const =0
four-momentum Lorentz vector
Generated for CMSSW Reference Manual by
1.8.5