RecoParticleFlow
PFProducer
plugins
importers
TrackTimingImporter.cc
Go to the documentation of this file.
1
#include "
RecoParticleFlow/PFProducer/interface/BlockElementImporterBase.h
"
2
#include "
DataFormats/ParticleFlowReco/interface/PFBlockElementTrack.h
"
3
#include "
DataFormats/ParticleFlowReco/interface/PFBlockElementGsfTrack.h
"
4
#include "
DataFormats/ParticleFlowReco/interface/PFRecTrack.h
"
5
#include "
DataFormats/TrackReco/interface/Track.h
"
6
#include "
DataFormats/MuonReco/interface/Muon.h
"
7
#include "
DataFormats/Common/interface/ValueMap.h
"
8
#include "
RecoParticleFlow/PFProducer/interface/PFMuonAlgo.h
"
9
#include "
RecoParticleFlow/PFTracking/interface/PFTrackAlgoTools.h
"
10
#include "
FWCore/MessageLogger/interface/MessageLogger.h
"
11
12
// this doesn't actually import anything,
13
// but rather applies time stamps to tracks after they are all inserted
14
15
class
TrackTimingImporter
:
public
BlockElementImporterBase
{
16
public
:
17
TrackTimingImporter
(
const
edm::ParameterSet
& conf,
edm::ConsumesCollector
&
cc
)
18
:
BlockElementImporterBase
(conf,
cc
),
19
useTimeQuality_
(conf.existsAs<
edm
::
InputTag
>(
"timeQualityMap"
)),
20
timeQualityThreshold_
(
useTimeQuality_
? conf.getParameter<double>(
"timeQualityThreshold"
) : -99.),
21
srcTime_
(
cc
.consumes<
edm
::ValueMap<
float
>>(conf.getParameter<
edm
::
InputTag
>(
"timeValueMap"
))),
22
srcTimeError_
(
cc
.consumes<
edm
::ValueMap<
float
>>(conf.getParameter<
edm
::
InputTag
>(
"timeErrorMap"
))),
23
srcTimeQuality_
(
useTimeQuality_
24
?
cc
.consumes<
edm
::ValueMap<
float
>>(conf.getParameter<
edm
::
InputTag
>(
"timeQualityMap"
))
25
:
edm
::EDGetTokenT<
edm
::ValueMap<
float
>>()),
26
srcTimeGsf_
(
cc
.consumes<
edm
::ValueMap<
float
>>(conf.getParameter<
edm
::
InputTag
>(
"timeValueMapGsf"
))),
27
srcTimeErrorGsf_
(
cc
.consumes<
edm
::ValueMap<
float
>>(conf.getParameter<
edm
::
InputTag
>(
"timeErrorMapGsf"
))),
28
srcTimeQualityGsf_
(
29
useTimeQuality_
?
cc
.consumes<
edm
::ValueMap<
float
>>(conf.getParameter<
edm
::
InputTag
>(
"timeQualityMapGsf"
))
30
:
edm
::EDGetTokenT<
edm
::ValueMap<
float
>>()),
31
debug_
(conf.getUntrackedParameter<
bool
>(
"debug"
,
false
)) {}
32
33
void
importToBlock
(
const
edm::Event
&,
ElementList
&)
const override
;
34
35
private
:
36
const
bool
useTimeQuality_
;
37
const
double
timeQualityThreshold_
;
38
edm::EDGetTokenT<edm::ValueMap<float>
>
srcTime_
,
srcTimeError_
,
srcTimeQuality_
,
srcTimeGsf_
,
srcTimeErrorGsf_
,
39
srcTimeQualityGsf_
;
40
const
bool
debug_
;
41
};
42
43
DEFINE_EDM_PLUGIN
(
BlockElementImporterFactory
,
TrackTimingImporter
,
"TrackTimingImporter"
);
44
45
void
TrackTimingImporter::importToBlock
(
const
edm::Event
&
e
,
BlockElementImporterBase::ElementList
& elems)
const
{
46
typedef
BlockElementImporterBase::ElementList::value_type
ElementType;
47
48
auto
const
&
time
=
e
.get(
srcTime_
);
49
auto
const
& timeErr =
e
.get(
srcTimeError_
);
50
auto
const
& timeGsf =
e
.get(
srcTimeGsf_
);
51
auto
const
& timeErrGsf =
e
.get(
srcTimeErrorGsf_
);
52
53
edm::Handle<edm::ValueMap<float>
> timeQualH, timeQualGsfH;
54
if
(
useTimeQuality_
) {
55
e
.getByToken(
srcTimeQuality_
, timeQualH);
56
e
.getByToken(
srcTimeQualityGsf_
, timeQualGsfH);
57
}
58
59
for
(
auto
& elem : elems) {
60
if
(
reco::PFBlockElement::TRACK
== elem->type()) {
61
const
auto
& ref = elem->trackRef();
62
if
(
time
.contains(ref.id())) {
63
const
bool
assocQuality =
useTimeQuality_
? (*timeQualH)[ref] >
timeQualityThreshold_
:
true
;
64
if
(assocQuality) {
65
elem->setTime(
time
[ref], timeErr[ref]);
66
}
else
{
67
elem->setTime(0., -1.);
68
}
69
}
70
if
(
debug_
) {
71
edm::LogInfo
(
"TrackTimingImporter"
)
72
<<
"Track with pT / eta "
<< ref->pt() <<
" / "
<< ref->eta() <<
" has time: "
<< elem->time() <<
" +/- "
73
<< elem->timeError() << std::endl;
74
}
75
}
else
if
(
reco::PFBlockElement::GSF
== elem->type()) {
76
const
auto
& ref = static_cast<const reco::PFBlockElementGsfTrack*>(elem.get())->GsftrackRef();
77
if
(timeGsf.contains(ref.id())) {
78
const
bool
assocQuality =
useTimeQuality_
? (*timeQualGsfH)[ref] >
timeQualityThreshold_
:
true
;
79
if
(assocQuality) {
80
elem->setTime(timeGsf[ref], timeErrGsf[ref]);
81
}
else
{
82
elem->setTime(0., -1.);
83
}
84
}
85
if
(
debug_
) {
86
edm::LogInfo
(
"TrackTimingImporter"
)
87
<<
"Track with pT / eta "
<< ref->pt() <<
" / "
<< ref->eta() <<
" has time: "
<< elem->time() <<
" +/- "
88
<< elem->timeError() << std::endl;
89
}
90
}
91
}
92
}
electrons_cff.bool
bool
Definition:
electrons_cff.py:366
Muon.h
MessageLogger.h
dqmMemoryStats.float
float
Definition:
dqmMemoryStats.py:127
PFMuonAlgo.h
funct::false
false
Definition:
Factorize.h:29
edm::EDGetTokenT
Definition:
EDGetToken.h:33
edm
HLT enums.
Definition:
AlignableModifier.h:19
TrackTimingImporter::srcTimeError_
edm::EDGetTokenT< edm::ValueMap< float > > srcTimeError_
Definition:
TrackTimingImporter.cc:38
HLT_FULL_cff.InputTag
InputTag
Definition:
HLT_FULL_cff.py:89301
protons_cff.time
time
Definition:
protons_cff.py:35
TrackTimingImporter::srcTimeGsf_
edm::EDGetTokenT< edm::ValueMap< float > > srcTimeGsf_
Definition:
TrackTimingImporter.cc:38
TrackTimingImporter::importToBlock
void importToBlock(const edm::Event &, ElementList &) const override
Definition:
TrackTimingImporter.cc:45
edm::LogInfo
Log< level::Info, false > LogInfo
Definition:
MessageLogger.h:125
edm::Handle
Definition:
AssociativeIterator.h:50
TrackTimingImporter::debug_
const bool debug_
Definition:
TrackTimingImporter.cc:40
Track.h
TrackTimingImporter::TrackTimingImporter
TrackTimingImporter(const edm::ParameterSet &conf, edm::ConsumesCollector &cc)
Definition:
TrackTimingImporter.cc:17
BlockElementImporterBase.h
reco::PFBlockElement::TRACK
Definition:
PFBlockElement.h:32
TrackTimingImporter
Definition:
TrackTimingImporter.cc:15
TrackTimingImporter::srcTimeErrorGsf_
edm::EDGetTokenT< edm::ValueMap< float > > srcTimeErrorGsf_
Definition:
TrackTimingImporter.cc:38
DEFINE_EDM_PLUGIN
#define DEFINE_EDM_PLUGIN(factory, type, name)
Definition:
PluginFactory.h:124
BlockElementImporterBase::ElementList
std::vector< std::unique_ptr< reco::PFBlockElement > > ElementList
Definition:
BlockElementImporterBase.h:16
PFTrackAlgoTools.h
edm::ParameterSet
Definition:
ParameterSet.h:47
reco::PFBlockElement::GSF
Definition:
PFBlockElement.h:37
edmplugin::PluginFactory
Definition:
PluginFactory.h:34
TrackTimingImporter::srcTimeQuality_
edm::EDGetTokenT< edm::ValueMap< float > > srcTimeQuality_
Definition:
TrackTimingImporter.cc:38
TrackTimingImporter::srcTime_
edm::EDGetTokenT< edm::ValueMap< float > > srcTime_
Definition:
TrackTimingImporter.cc:38
TrackTimingImporter::timeQualityThreshold_
const double timeQualityThreshold_
Definition:
TrackTimingImporter.cc:37
reco::JetExtendedAssociation::value_type
Container::value_type value_type
Definition:
JetExtendedAssociation.h:30
cc
PFRecTrack.h
ValueMap.h
edm::Event
Definition:
Event.h:73
PFBlockElementGsfTrack.h
TrackTimingImporter::srcTimeQualityGsf_
edm::EDGetTokenT< edm::ValueMap< float > > srcTimeQualityGsf_
Definition:
TrackTimingImporter.cc:38
edm::ConsumesCollector
Definition:
ConsumesCollector.h:45
PFBlockElementTrack.h
MillePedeFileConverter_cfg.e
e
Definition:
MillePedeFileConverter_cfg.py:37
BlockElementImporterBase
Definition:
BlockElementImporterBase.h:14
TrackTimingImporter::useTimeQuality_
const bool useTimeQuality_
Definition:
TrackTimingImporter.cc:36
Generated for CMSSW Reference Manual by
1.8.16