Main Page
Namespaces
Classes
Package Documentation
SimTracker
TrackAssociation
plugins
TrackMCQuality.cc
Go to the documentation of this file.
1
// -*- C++ -*-
2
//
3
// Package: TrackMCQuality
4
// Class: TrackMCQuality
5
//
13
//
14
// Original Author: Jean-Roch Vlimant
15
// Created: Fri Mar 27 15:19:03 CET 2009
16
//
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
#include "
FWCore/Framework/interface/ESHandle.h
"
32
33
#include "
SimDataFormats/Associations/interface/TrackToTrackingParticleAssociator.h
"
34
35
#include "
SimDataFormats/TrackingAnalysis/interface/TrackingParticle.h
"
36
#include "
DataFormats/TrackReco/interface/Track.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
//
61
// constants, enums and typedefs
62
//
63
64
65
//
66
// static data member definitions
67
//
68
69
//
70
// constructors and destructor
71
//
72
TrackMCQuality::TrackMCQuality
(
const
edm::ParameterSet
&
pset
):
73
label_assoc
(
consumes
<
reco
::
TrackToTrackingParticleAssociator
>(pset.getParameter<
edm
::InputTag >(
"associator"
))),
74
label_tp
(
consumes
<
TrackingParticleCollection
>(pset.getParameter<
edm
::InputTag >(
"trackingParticles"
))),
75
label_tr
(
consumes
<
edm
::
View
<
reco
::Track> >(pset.getParameter<
edm
::InputTag >(
"tracks"
)))
76
{
77
produces<Product>();
78
}
79
80
81
TrackMCQuality::~TrackMCQuality
()
82
{
83
}
84
85
86
//
87
// member functions
88
//
89
90
// ------------ method called to produce the data ------------
91
void
92
TrackMCQuality::produce
(
edm::StreamID
,
edm::Event
&
iEvent
,
const
edm::EventSetup
& iSetup)
const
93
{
94
95
using namespace
edm
;
96
Handle<reco::TrackToTrackingParticleAssociator>
associator
;
97
iEvent.
getByToken
(
label_assoc
,associator);
98
99
Handle<TrackingParticleCollection>
TPCollection ;
100
iEvent.
getByToken
(
label_tp
, TPCollection);
101
102
Handle<edm::View<reco::Track>
>
trackCollection
;
103
iEvent.
getByToken
(
label_tr
, trackCollection );
104
105
reco::RecoToSimCollection
recSimColl=associator->
associateRecoToSim
(trackCollection,
106
TPCollection);
107
108
//then loop the track collection
109
std::unique_ptr<Product> product(
new
Product
(trackCollection->size(),0));
110
111
112
for
(
unsigned
int
iT=0;iT!=trackCollection->size();++iT){
113
auto
&
prod
= (*product)[iT];
114
115
edm::RefToBase<reco::Track>
track
(trackCollection, iT);
116
117
//find it in the map
118
if
(recSimColl.
find
(track)==recSimColl.
end
())
continue
;
119
120
auto
const
& tp = recSimColl[
track
];
121
122
if
(tp.empty())
continue
;
// can it be?
123
// nSimHits = tp[0].first->numberOfTrackerHits();
124
prod
= tp[0].second;
125
// if (tp[0].first->charge() != track->charge()) isChargeMatched = false;
126
if
( (tp[0].
first
->eventId().event() != 0) || (tp[0].
first
->eventId().bunchCrossing() != 0) )
prod
=-
prod
;
127
128
129
}
130
131
iEvent.
put
(
std::move
(product));
132
}
133
134
//define this as a plug-in
135
DEFINE_FWK_MODULE
(
TrackMCQuality
);
parseEventContent.prod
prod
Definition:
parseEventContent.py:153
EDProducer.h
edm::Event::put
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition:
Event.h:136
TrackMCQuality::label_tr
edm::EDGetTokenT< edm::View< reco::Track > > label_tr
Definition:
TrackMCQuality.cc:54
TrackToTrackingParticleAssociator.h
TrackingParticleCollection
std::vector< TrackingParticle > TrackingParticleCollection
Definition:
HiEvtPlaneFlatProducer.cc:111
edm::AssociationMap::end
const_iterator end() const
last iterator over the map (read only)
Definition:
AssociationMap.h:160
edm::Event::getByToken
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition:
Event.h:519
TrackToTrackingParticleAssociator
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition:
MakerMacros.h:17
edm::StreamID
Definition:
StreamID.h:30
Event.h
MakerMacros.h
edm::Handle< reco::TrackToTrackingParticleAssociator >
edm::AssociationMap::find
const_iterator find(const key_type &k) const
find element with specified reference key
Definition:
AssociationMap.h:162
muonDTDigis_cfi.pset
pset
Definition:
muonDTDigis_cfi.py:27
TrackingParticle.h
edm::EDGetTokenT< reco::TrackToTrackingParticleAssociator >
Frameworkfwd.h
edm::RefToBase< reco::Track >
TrackMCQuality
Definition:
TrackMCQuality.cc:42
edm::EDConsumerBase::consumes
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
Definition:
EDConsumerBase.h:105
ParameterSet.h
TrackMCQuality::TrackMCQuality
TrackMCQuality(const edm::ParameterSet &)
Definition:
TrackMCQuality.cc:72
iEvent
int iEvent
Definition:
GenABIO.cc:230
TrackMCQuality::Product
std::vector< float > Product
Definition:
TrackMCQuality.cc:56
TrackMCQuality::produce
void produce(edm::StreamID, edm::Event &, const edm::EventSetup &) const override
Definition:
TrackMCQuality.cc:92
ctfWithMaterialTrackMCMatch_cfi.associator
associator
Definition:
ctfWithMaterialTrackMCMatch_cfi.py:7
ESHandle.h
edm::AssociationMap< edm::OneToManyWithQualityGeneric< edm::View< reco::Track >, TrackingParticleCollection, double > >
edm::EventSetup
Definition:
EventSetup.h:47
edm::global::EDProducer
Definition:
EDProducer.h:32
TrackMCQuality::label_assoc
edm::EDGetTokenT< reco::TrackToTrackingParticleAssociator > label_assoc
Definition:
TrackMCQuality.cc:52
reco::TrackToTrackingParticleAssociator::associateRecoToSim
reco::RecoToSimCollection associateRecoToSim(const edm::Handle< edm::View< reco::Track > > &tCH, const edm::Handle< TrackingParticleCollection > &tPCH) const
compare reco to sim the handle of reco::Track and TrackingParticle collections
Definition:
TrackToTrackingParticleAssociator.h:63
HiIsolationCommonParameters_cff.track
track
Definition:
HiIsolationCommonParameters_cff.py:9
plotBeamSpotDB.first
first
Definition:
plotBeamSpotDB.py:379
findElectronsInSiStrips_cfi.trackCollection
trackCollection
Definition:
findElectronsInSiStrips_cfi.py:57
TrackMCQuality::~TrackMCQuality
~TrackMCQuality() override
Definition:
TrackMCQuality.cc:81
reco
fixed size matrix
Definition:
AlignmentAlgorithmBase.h:43
edm
HLT enums.
Definition:
AlignableModifier.h:17
edm::ParameterSet
Definition:
ParameterSet.h:36
TrackMCQuality::label_tp
edm::EDGetTokenT< TrackingParticleCollection > label_tp
Definition:
TrackMCQuality.cc:53
edm::Event
Definition:
Event.h:69
Track.h
sistrip::View
View
Definition:
ConstantsForView.h:26
eostools.move
def move(src, dest)
Definition:
eostools.py:510
Generated for CMSSW Reference Manual by
1.8.11