Main Page
Namespaces
Classes
Package Documentation
CVS Directory
WorkBook
Offline Guide
Release schedule
•
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Properties
Friends
Macros
Pages
src
PhysicsTools
HepMCCandAlgos
plugins
MCTruthCompositeMatcherNew.cc
Go to the documentation of this file.
1
/* \class MCTruthCompositeMatcher
2
*
3
* \author Luca Lista, INFN
4
*
5
*/
6
7
#include "
FWCore/Framework/interface/EDProducer.h
"
8
#include "
FWCore/Utilities/interface/InputTag.h
"
9
#include "
PhysicsTools/CandUtils/interface/CandMatcherNew.h
"
10
#include "
DataFormats/HepMCCandidate/interface/GenParticle.h
"
11
#include "
DataFormats/Common/interface/Association.h
"
12
#include "
FWCore/ParameterSet/interface/ParameterSet.h
"
13
#include "
FWCore/Framework/interface/Event.h
"
14
#include "
DataFormats/Common/interface/Handle.h
"
15
16
namespace
reco
{
17
namespace
modulesNew {
18
19
class
MCTruthCompositeMatcher
:
public
edm::EDProducer
{
20
public
:
21
explicit
MCTruthCompositeMatcher
(
const
edm::ParameterSet
& );
22
~MCTruthCompositeMatcher
();
23
private
:
24
edm::InputTag
src_
;
25
std::vector<edm::InputTag>
matchMaps_
;
26
std::vector<int>
pdgId_
;
27
void
produce
(
edm::Event
& ,
const
edm::EventSetup
&)
override
;
28
};
29
30
MCTruthCompositeMatcher::MCTruthCompositeMatcher
(
const
edm::ParameterSet
& cfg ) :
31
src_(cfg.getParameter<edm::InputTag>(
"src"
)),
32
matchMaps_(cfg.getParameter<std::vector<edm::InputTag> >(
"matchMaps"
)),
33
pdgId_(cfg.getParameter<std::vector<int> >(
"matchPDGId"
)) {
34
produces<reco::GenParticleMatch>();
35
}
36
37
MCTruthCompositeMatcher::~MCTruthCompositeMatcher
() {
38
}
39
40
void
MCTruthCompositeMatcher::produce
(
edm::Event
& evt ,
const
edm::EventSetup
& ) {
41
using namespace
edm;
42
using namespace
std;
43
Handle<CandidateView>
cands;
44
evt.
getByLabel
(
src_
, cands);
45
size_t
nMaps =
matchMaps_
.size();
46
std::vector<const GenParticleMatch *> maps;
47
maps.reserve( nMaps );
48
for
(
size_t
i
= 0;
i
!= nMaps; ++
i
) {
49
Handle<reco::GenParticleMatch>
matchMap;
50
evt.
getByLabel
(
matchMaps_
[
i
], matchMap);
51
maps.push_back(& * matchMap);
52
}
53
utilsNew::CandMatcher<GenParticleCollection>
match
(maps);
54
auto_ptr<GenParticleMatch> matchMap(
new
GenParticleMatch
(match.
ref
()));
55
int
size
= cands->size();
56
vector<int>::const_iterator
begin
=
pdgId_
.begin(),
end
=
pdgId_
.end();
57
if
(
size
!= 0) {
58
GenParticleMatch::Filler
filler(*matchMap);
59
vector<int> indices(
size
);
60
for
(
int
i
= 0;
i
!=
size
; ++
i
) {
61
const
Candidate
& cand = (* cands)[
i
];
62
GenParticleRef
mc = match[cand];
63
if
(mc.
isNull
()) {
64
indices[
i
] = -1;
65
}
else
{
66
bool
found
=
true
;
67
if
(
begin
!=
end
) found =
find
(
begin
,
end
,
std::abs
(mc->pdgId())) !=
end
;
68
indices[
i
] = found ? int(mc.
key
()) : -1;
69
}
70
}
71
CandidateBaseRefProd
ref(cands->refAt(0));
72
filler.
insert
(ref, indices.begin(), indices.end());
73
filler.
fill
();
74
}
75
evt.
put
(matchMap);
76
}
77
78
}
79
}
80
81
#include "
DataFormats/Candidate/interface/Candidate.h
"
82
#include "
FWCore/Framework/interface/MakerMacros.h
"
83
84
namespace
reco
{
85
namespace
modulesNew {
86
87
typedef
MCTruthCompositeMatcher
MCTruthCompositeMatcherNew
;
88
89
DEFINE_FWK_MODULE
(
MCTruthCompositeMatcherNew
);
90
91
}
92
}
93
edm::helper::Filler::fill
void fill()
Definition:
ValueMap.h:62
i
int i
Definition:
DBlmapReader.cc:9
reco::modulesNew::MCTruthCompositeMatcher::~MCTruthCompositeMatcher
~MCTruthCompositeMatcher()
Definition:
MCTruthCompositeMatcherNew.cc:37
Association.h
reco::modulesNew::DEFINE_FWK_MODULE
DEFINE_FWK_MODULE(MCTruthCompositeMatcherNew)
GenParticle.h
Event.h
MakerMacros.h
reco::Candidate
Definition:
Candidate.h:32
edm::helper::Filler::insert
void insert(const H &h, I begin, I end)
Definition:
ValueMap.h:53
abs
#define abs(x)
Definition:
mlp_lapack.h:159
reco::utilsNew::CandMatcher::ref
map_type::refprod_type ref() const
reference to matched collection
Definition:
CandMatcherNew.h:35
Handle.h
edm::Handle
Definition:
AssociativeIterator.h:48
spr::find
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition:
FindCaloHit.cc:7
edm::EDProducer
Definition:
EDProducer.h:22
edm::Association::Filler
Definition:
Association.h:78
ParameterSet.h
Candidate.h
edm::Ref::isNull
bool isNull() const
Checks for null.
Definition:
Ref.h:247
edm::RefToBaseProd
Definition:
RefToBase.h:62
edm::Event::put
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition:
Event.h:94
reco::utilsNew::CandMatcher
Definition:
CandMatcherNew.h:19
L1Trigger_dataformats.reco
dictionary reco
Definition:
L1Trigger_dataformats.py:9
reco::modulesNew::MCTruthCompositeMatcher::MCTruthCompositeMatcher
MCTruthCompositeMatcher(const edm::ParameterSet &)
Definition:
MCTruthCompositeMatcherNew.cc:30
edm::EventSetup
Definition:
EventSetup.h:44
end
#define end
Definition:
vmac.h:38
edm::Event::getByLabel
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition:
Event.h:361
CandMatcherNew.h
reco::modulesNew::MCTruthCompositeMatcher::pdgId_
std::vector< int > pdgId_
Definition:
MCTruthCompositeMatcherNew.cc:26
EDProducer.h
reco::modulesNew::MCTruthCompositeMatcher::src_
edm::InputTag src_
Definition:
MCTruthCompositeMatcherNew.cc:24
edm::Ref::key
key_type key() const
Accessor for product key.
Definition:
Ref.h:266
reco::modulesNew::MCTruthCompositeMatcher::produce
void produce(edm::Event &, const edm::EventSetup &) override
Definition:
MCTruthCompositeMatcherNew.cc:40
reco::modulesNew::MCTruthCompositeMatcherNew
MCTruthCompositeMatcher MCTruthCompositeMatcherNew
Definition:
MCTruthCompositeMatcherNew.cc:87
begin
#define begin
Definition:
vmac.h:31
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
reco::modulesNew::MCTruthCompositeMatcher::matchMaps_
std::vector< edm::InputTag > matchMaps_
Definition:
MCTruthCompositeMatcherNew.cc:25
edm::Event
Definition:
Event.h:56
newFWLiteAna.found
found
Definition:
newFWLiteAna.py:118
findQualityFiles.size
tuple size
Write out results.
Definition:
findQualityFiles.py:442
edm::Ref< GenParticleCollection >
reco::modulesNew::MCTruthCompositeMatcher
Definition:
MCTruthCompositeMatcherNew.cc:19
reco::GenParticleMatch
edm::Association< GenParticleCollection > GenParticleMatch
vector of reference to GenParticle in the same collection
Definition:
GenParticleFwd.h:20
Generated for CMSSW Reference Manual by
1.8.5