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