CMS 3D CMS Logo

TrackTimingImporter.cc
Go to the documentation of this file.
12 
13 // this doesn't actually import anything,
14 // but rather applies time stamps to tracks after they are all inserted
15 
17 public:
19  edm::ConsumesCollector& sumes) :
20  BlockElementImporterBase(conf,sumes),
21  srcTime_( sumes.consumes<edm::ValueMap<float> >(conf.getParameter<edm::InputTag>("timeValueMap")) ),
22  srcTimeError_( sumes.consumes<edm::ValueMap<float> >(conf.getParameter<edm::InputTag>("timeErrorMap")) ),
23  srcTimeGsf_( sumes.consumes<edm::ValueMap<float> >(conf.getParameter<edm::InputTag>("timeValueMapGsf")) ),
24  srcTimeErrorGsf_( sumes.consumes<edm::ValueMap<float> >(conf.getParameter<edm::InputTag>("timeErrorMapGsf")) ),
25  debug_(conf.getUntrackedParameter<bool>("debug",false)) {
26  }
27 
28  void importToBlock( const edm::Event& ,
29  ElementList& ) const override;
30 
31 private:
32 
34  const bool debug_;
35 
36 };
37 
40  "TrackTimingImporter");
41 
46 
47  auto const& time = e.get(srcTime_);
48  auto const& timeErr = e.get(srcTimeError_);
49  auto const& timeGsf = e.get(srcTimeGsf_);
50  auto const& timeErrGsf = e.get(srcTimeErrorGsf_);
51 
52  for( auto& elem : elems ) {
53  if( reco::PFBlockElement::TRACK == elem->type() ) {
54  const auto& ref = elem->trackRef();
55  if (time.contains(ref.id())) {
56  elem->setTime( time[ref], timeErr[ref] );
57  }
58  if( debug_ ) {
59  edm::LogInfo("TrackTimingImporter")
60  << "Track with pT / eta " << ref->pt() << " / " << ref->eta()
61  << " has time: " << elem->time() << " +/- " << elem->timeError() << std::endl;
62  }
63  } else if ( reco::PFBlockElement::GSF == elem->type() ) {
64  const auto& ref = static_cast<const reco::PFBlockElementGsfTrack*>(elem.get())->GsftrackRef();
65  if (timeGsf.contains(ref.id())) {
66  elem->setTime( timeGsf[ref], timeErrGsf[ref] );
67  }
68  if( debug_ ) {
69  edm::LogInfo("TrackTimingImporter")
70  << "Track with pT / eta " << ref->pt() << " / " << ref->eta()
71  << " has time: " << elem->time() << " +/- " << elem->timeError() << std::endl;
72  }
73  }
74  }
75 }
edm::EDGetTokenT< edm::ValueMap< float > > srcTimeErrorGsf_
edm::EDGetTokenT< edm::ValueMap< float > > srcTimeError_
edm::EDGetTokenT< edm::ValueMap< float > > srcTime_
bool get(ProductID const &oid, Handle< PROD > &result) const
Definition: Event.h:326
def elem(elemtype, innerHTML='', html_class='', kwargs)
Definition: HTMLExport.py:19
HLT enums.
#define DEFINE_EDM_PLUGIN(factory, type, name)
std::vector< std::unique_ptr< reco::PFBlockElement > > ElementList
TrackTimingImporter(const edm::ParameterSet &conf, edm::ConsumesCollector &sumes)
void importToBlock(const edm::Event &, ElementList &) const override
edm::EDGetTokenT< edm::ValueMap< float > > srcTimeGsf_