SimTracker
TrackAssociation
plugins
TrackMCQuality.cc
Go to the documentation of this file.
1
// -*- C++ -*-
2
//
3
// Package: TrackMCQuality
4
// Class: TrackMCQuality
5
//
14
//
15
// Original Author: Jean-Roch Vlimant
16
// Created: Fri Mar 27 15:19:03 CET 2009
17
//
18
//
19
20
// system include files
21
#include <memory>
22
23
// user include files
24
#include "
FWCore/Framework/interface/Frameworkfwd.h
"
25
#include "
FWCore/Framework/interface/global/EDProducer.h
"
26
27
#include "
FWCore/Framework/interface/Event.h
"
28
#include "
FWCore/Framework/interface/MakerMacros.h
"
29
30
#include "
FWCore/Framework/interface/ESHandle.h
"
31
#include "
FWCore/ParameterSet/interface/ParameterSet.h
"
32
33
#include "
SimDataFormats/Associations/interface/TrackToTrackingParticleAssociator.h
"
34
35
#include "
DataFormats/TrackReco/interface/Track.h
"
36
#include "
SimDataFormats/TrackingAnalysis/interface/TrackingParticle.h
"
37
38
//
39
// class decleration
40
//
41
42
class
TrackMCQuality
final :
public
edm::global::EDProducer
<> {
43
public
:
44
explicit
TrackMCQuality
(
const
edm::ParameterSet
&);
45
~TrackMCQuality
()
override
;
46
47
private
:
48
void
produce
(
edm::StreamID
,
edm::Event
&,
const
edm::EventSetup
&)
const override
;
49
50
// ----------member data ---------------------------
51
52
edm::EDGetTokenT<reco::TrackToTrackingParticleAssociator>
label_assoc
;
53
edm::EDGetTokenT<TrackingParticleCollection>
label_tp
;
54
edm::EDGetTokenT<edm::View<reco::Track>
>
label_tr
;
55
56
using
Product
= std::vector<float>;
57
};
58
59
//
60
// constants, enums and typedefs
61
//
62
63
//
64
// static data member definitions
65
//
66
67
//
68
// constructors and destructor
69
//
70
TrackMCQuality::TrackMCQuality
(
const
edm::ParameterSet
&
pset
)
71
: label_assoc(consumes<
reco
::
TrackToTrackingParticleAssociator
>(
pset
.getParameter<
edm
::
InputTag
>(
"associator"
))),
72
label_tp
(consumes<
TrackingParticleCollection
>(
pset
.getParameter<
edm
::
InputTag
>(
"trackingParticles"
))),
73
label_tr
(consumes<
edm
::
View
<
reco
::Track>>(
pset
.getParameter<
edm
::
InputTag
>(
"tracks"
))) {
74
produces<Product>();
75
}
76
77
TrackMCQuality::~TrackMCQuality
() {}
78
79
//
80
// member functions
81
//
82
83
// ------------ method called to produce the data ------------
84
void
TrackMCQuality::produce
(
edm::StreamID
,
edm::Event
&
iEvent
,
const
edm::EventSetup
&iSetup)
const
{
85
using namespace
edm
;
86
Handle<reco::TrackToTrackingParticleAssociator>
associator
;
87
iEvent
.getByToken(
label_assoc
,
associator
);
88
89
Handle<TrackingParticleCollection>
TPCollection;
90
iEvent
.getByToken(
label_tp
, TPCollection);
91
92
Handle<edm::View<reco::Track>
>
trackCollection
;
93
iEvent
.getByToken(
label_tr
,
trackCollection
);
94
95
reco::RecoToSimCollection
recSimColl =
associator
->associateRecoToSim(
trackCollection
, TPCollection);
96
97
// then loop the track collection
98
std::unique_ptr<Product> product(
new
Product
(
trackCollection
->size(), 0));
99
100
for
(
unsigned
int
iT = 0; iT !=
trackCollection
->size(); ++iT) {
101
auto
&
prod
= (*product)[iT];
102
103
edm::RefToBase<reco::Track>
track
(
trackCollection
, iT);
104
105
// find it in the map
106
if
(recSimColl.
find
(
track
) == recSimColl.
end
())
107
continue
;
108
109
auto
const
&
tp
= recSimColl[
track
];
110
111
if
(
tp
.empty())
112
continue
;
// can it be?
113
// nSimHits = tp[0].first->numberOfTrackerHits();
114
prod
=
tp
[0].second;
115
// if (tp[0].first->charge() != track->charge()) isChargeMatched = false;
116
if
((
tp
[0].
first
->eventId().event() != 0) || (
tp
[0].
first
->eventId().bunchCrossing() != 0))
117
prod
= -
prod
;
118
}
119
120
iEvent
.put(
std::move
(product));
121
}
122
123
// define this as a plug-in
124
DEFINE_FWK_MODULE
(
TrackMCQuality
);
LCToCPAssociation_cfi.associator
associator
Definition:
LCToCPAssociation_cfi.py:4
edm::StreamID
Definition:
StreamID.h:30
TrackMCQuality::label_tr
edm::EDGetTokenT< edm::View< reco::Track > > label_tr
Definition:
TrackMCQuality.cc:54
edm::AssociationMap::find
const_iterator find(const key_type &k) const
find element with specified reference key
Definition:
AssociationMap.h:173
HLT_FULL_cff.track
track
Definition:
HLT_FULL_cff.py:11713
TrackMCQuality::Product
std::vector< float > Product
Definition:
TrackMCQuality.cc:56
trackingParticleRecoTrackAsssociation_cfi.label_tp
label_tp
Definition:
trackingParticleRecoTrackAsssociation_cfi.py:5
ESHandle.h
sistrip::View
View
Definition:
ConstantsForView.h:26
edm::EDGetTokenT< reco::TrackToTrackingParticleAssociator >
edm
HLT enums.
Definition:
AlignableModifier.h:19
TrackMCQuality::label_assoc
edm::EDGetTokenT< reco::TrackToTrackingParticleAssociator > label_assoc
Definition:
TrackMCQuality.cc:52
HLT_FULL_cff.InputTag
InputTag
Definition:
HLT_FULL_cff.py:89281
reco
fixed size matrix
Definition:
AlignmentAlgorithmBase.h:45
edm::Handle< reco::TrackToTrackingParticleAssociator >
TrackToTrackingParticleAssociator
edm::AssociationMap::end
const_iterator end() const
last iterator over the map (read only)
Definition:
AssociationMap.h:171
MakerMacros.h
Track.h
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition:
MakerMacros.h:16
dumpMFGeometry_cfg.prod
prod
Definition:
dumpMFGeometry_cfg.py:24
TrackMCQuality::TrackMCQuality
TrackMCQuality(const edm::ParameterSet &)
Definition:
TrackMCQuality.cc:70
cmsswSequenceInfo.tp
tp
Definition:
cmsswSequenceInfo.py:17
first
auto first
Definition:
CAHitNtupletGeneratorKernelsImpl.h:112
edm::global::EDProducer
Definition:
EDProducer.h:32
TrackMCQuality::produce
void produce(edm::StreamID, edm::Event &, const edm::EventSetup &) const override
Definition:
TrackMCQuality.cc:84
TrackToTrackingParticleAssociator.h
edm::ParameterSet
Definition:
ParameterSet.h:47
duplicaterechits_cfi.trackCollection
trackCollection
Definition:
duplicaterechits_cfi.py:4
Event.h
edm::AssociationMap< edm::OneToManyWithQualityGeneric< edm::View< reco::Track >, TrackingParticleCollection, double > >
iEvent
int iEvent
Definition:
GenABIO.cc:224
edm::EventSetup
Definition:
EventSetup.h:58
TrackMCQuality::label_tp
edm::EDGetTokenT< TrackingParticleCollection > label_tp
Definition:
TrackMCQuality.cc:53
TrackingParticle.h
eostools.move
def move(src, dest)
Definition:
eostools.py:511
Frameworkfwd.h
TrackingParticleCollection
std::vector< TrackingParticle > TrackingParticleCollection
Definition:
TrackingParticleFwd.h:9
edm::RefToBase< reco::Track >
TrackMCQuality::~TrackMCQuality
~TrackMCQuality() override
Definition:
TrackMCQuality.cc:77
TrackMCQuality
Definition:
TrackMCQuality.cc:42
ParameterSet.h
EDProducer.h
edm::Event
Definition:
Event.h:73
trackingParticleRecoTrackAsssociation_cff.label_tr
label_tr
Definition:
trackingParticleRecoTrackAsssociation_cff.py:12
muonDTDigis_cfi.pset
pset
Definition:
muonDTDigis_cfi.py:27
Generated for CMSSW Reference Manual by
1.8.16