CMS 3D CMS Logo

TrackTimingImporter.cc
Go to the documentation of this file.
11 
12 // this doesn't actually import anything,
13 // but rather applies time stamps to tracks after they are all inserted
14 
16 public:
18  : BlockElementImporterBase(conf, sumes),
19  useTimeQuality_(conf.existsAs<edm::InputTag>("timeQualityMap")),
20  timeQualityThreshold_(useTimeQuality_ ? conf.getParameter<double>("timeQualityThreshold") : -99.),
21  srcTime_(sumes.consumes<edm::ValueMap<float>>(conf.getParameter<edm::InputTag>("timeValueMap"))),
22  srcTimeError_(sumes.consumes<edm::ValueMap<float>>(conf.getParameter<edm::InputTag>("timeErrorMap"))),
24  ? sumes.consumes<edm::ValueMap<float>>(conf.getParameter<edm::InputTag>("timeQualityMap"))
25  : edm::EDGetTokenT<edm::ValueMap<float>>()),
26  srcTimeGsf_(sumes.consumes<edm::ValueMap<float>>(conf.getParameter<edm::InputTag>("timeValueMapGsf"))),
27  srcTimeErrorGsf_(sumes.consumes<edm::ValueMap<float>>(conf.getParameter<edm::InputTag>("timeErrorMapGsf"))),
28  srcTimeQualityGsf_(useTimeQuality_ ? sumes.consumes<edm::ValueMap<float>>(
29  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_;
40  const bool debug_;
41 };
42 
44 
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:89285
protons_cff.time
time
Definition: protons_cff.py:39
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
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
PFRecTrack.h
ValueMap.h
edm::Event
Definition: Event.h:73
TrackTimingImporter::TrackTimingImporter
TrackTimingImporter(const edm::ParameterSet &conf, edm::ConsumesCollector &sumes)
Definition: TrackTimingImporter.cc:17
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