Imperial Analysis
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
ICLightTrackProducer.cc
Go to the documentation of this file.
2 #include <string>
3 #include <vector>
4 #include "FWCore/Framework/interface/Event.h"
5 #include "FWCore/Framework/interface/EventSetup.h"
6 #include "FWCore/Framework/interface/MakerMacros.h"
7 #include "FWCore/ParameterSet/interface/ParameterSet.h"
8 #include "FWCore/Utilities/interface/InputTag.h"
9 #include "DataFormats/Common/interface/Handle.h"
10 #include "DataFormats/Common/interface/View.h"
11 #include "DataFormats/TrackReco/interface/Track.h"
12 #include "DataFormats/TrackReco/interface/TrackFwd.h"
18 
19 ICLightTrackProducer::ICLightTrackProducer(const edm::ParameterSet& config)
20  : input_(config.getParameter<edm::InputTag>("input")),
21  branch_(config.getParameter<std::string>("branch")) {
22  consumes<edm::View<reco::Track>>(input_);
23  tracks_ = new std::vector<ic::LightTrack>();
24  PrintHeaderWithProduces(config, input_, branch_);
25 }
26 
28 
29 void ICLightTrackProducer::produce(edm::Event& event, const edm::EventSetup& setup) {
30  edm::Handle<edm::View<reco::Track> > track_handle;
31  event.getByLabel(input_, track_handle);
32 
33  // Prepare output collection
34  tracks_->clear();
35  tracks_->resize(track_handle->size(), ic::LightTrack());
36 
37  for (unsigned i = 0; i < track_handle->size(); ++i) {
38  reco::Track const& src = track_handle->at(i);
39  ic::LightTrack& dest = tracks_->at(i);
40  dest.set_id(track_hasher_(&src));
41  dest.set_pt(src.pt());
42  dest.set_vz(src.vz());
43  }
44 }
45 
46 void ICLightTrackProducer::beginJob() {
47  ic::StaticTree::tree_->Branch(branch_.c_str(), &tracks_);
48 }
49 
50 void ICLightTrackProducer::endJob() {}
51 
53 
void set_pt(double const &pt)
The track transverse momentum.
Definition: LightTrack.hh:40
ICLightTrackProducer(const edm::ParameterSet &)
DEFINE_FWK_MODULE(ICLightTrackProducer)
static TTree * tree_
Definition: StaticTree.hh:13
void set_vz(double const &vz)
The z-coordinate of the point-of-closest-approach to the beamspot.
Definition: LightTrack.hh:43
See documentation here.
Stores a minimal amount of track information.
Definition: LightTrack.hh:16
void set_id(std::size_t const &id)
The unique identifier.
Definition: LightTrack.hh:37
Definition: Consumes.h:19
void PrintHeaderWithProduces(edm::ParameterSet const &config, edm::InputTag const &in, std::string branch)