Imperial Analysis
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
ICTrackProducer.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 ICTrackProducer::ICTrackProducer(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::Track>();
24  PrintHeaderWithProduces(config, input_, branch_);
25 }
26 
27 ICTrackProducer::~ICTrackProducer() { delete tracks_; }
28 
29 void ICTrackProducer::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::Track());
36 
37  for (unsigned i = 0; i < track_handle->size(); ++i) {
38  reco::Track const& src = track_handle->at(i);
39  ic::Track& dest = tracks_->at(i);
40  dest.set_id(track_hasher_(&src));
41  dest.set_pt(src.pt());
42  dest.set_eta(src.eta());
43  dest.set_phi(src.phi());
44  dest.set_charge(src.charge());
45  dest.set_vx(src.vx());
46  dest.set_vy(src.vy());
47  dest.set_vz(src.vz());
48  dest.set_normalized_chi2(src.normalizedChi2());
49  dest.set_hits(src.hitPattern().numberOfValidHits());
50  dest.set_pixel_hits(src.hitPattern().numberOfValidPixelHits());
51  dest.set_algorithm(src.algo());
52  dest.set_pt_err(src.ptError());
53  dest.set_quality(src.qualityMask());
54 #if CMSSW_MAJOR_VERSION > 7 || (CMSSW_MAJOR_VERSION == 7 && CMSSW_MINOR_VERSION >= 2)
56  src.hitPattern().numberOfHits(reco::HitPattern::MISSING_INNER_HITS));
57 #else
58  dest.set_hits_miss_inner(src.trackerExpectedHitsInner().numberOfHits());
59 #endif
60  }
61 }
62 
63 void ICTrackProducer::beginJob() {
64  ic::StaticTree::tree_->Branch(branch_.c_str(), &tracks_);
65 }
66 
67 void ICTrackProducer::endJob() {}
68 
void set_hits_miss_inner(int const &hits_miss_inner)
hitPattern().numberOfHits(reco::HitPattern::MISSING_INNER_HITS)
Definition: Track.hh:171
void set_quality(int const &quality)
The track quality flags.
Definition: Track.hh:168
void set_phi(double const &phi)
Track azimuthal angle.
Definition: Track.hh:130
void set_hits(int const &hits)
Number of tracker hits.
Definition: Track.hh:147
DEFINE_FWK_MODULE(ICTrackProducer)
void set_vy(double const &y)
The y-coordinate of the PCA.
Definition: Track.hh:136
static TTree * tree_
Definition: StaticTree.hh:13
void set_algorithm(int16_t const &algorithm)
The tracking algorithm used to produce this track See: DataFormats/TrackReco/interface/TrackBase.h.
Definition: Track.hh:160
void set_eta(double const &eta)
Track pseudorapidity.
Definition: Track.hh:127
void set_pt_err(double const &pt_err)
The track error.
Definition: Track.hh:165
void set_charge(int const &charge)
The track charge.
Definition: Track.hh:157
See documentation here.
Stores limited information about the track kinematics and trajectory.
Definition: Track.hh:18
Definition: Consumes.h:19
ICTrackProducer(const edm::ParameterSet &)
void set_vx(double const &x)
The z-coordinate of the PCA.
Definition: Track.hh:133
void set_vz(double const &z)
The z-coordinate of the PCA.
Definition: Track.hh:139
void set_id(std::size_t const &id)
The unique identifier.
Definition: Track.hh:121
void set_pt(double const &pt)
The track transverse momentum.
Definition: Track.hh:124
void set_normalized_chi2(double const &normalized_chi2)
The normalised chi2 of the track fit.
Definition: Track.hh:142
void PrintHeaderWithProduces(edm::ParameterSet const &config, edm::InputTag const &in, std::string branch)
void set_pixel_hits(int const &pixel_hits)
Number of pixel hits.
Definition: Track.hh:152