ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/ShallowTools/plugins/ShallowTracksProducer.cc
Revision: 1.4
Committed: Tue Sep 29 10:16:31 2009 UTC (15 years, 7 months ago) by bbetchar
Content type: text/plain
Branch: MAIN
CVS Tags: HEAD
Changes since 1.3: +1 -0 lines
Log Message:
updates for CMSSW_3_3_X

File Contents

# Content
1 #include "UserCode/ShallowTools/interface/ShallowTracksProducer.h"
2
3 #include "FWCore/Framework/interface/Event.h"
4 #include "DataFormats/TrackReco/interface/Track.h"
5 #include "DataFormats/TrackReco/interface/TrackFwd.h"
6 #include "TrackingTools/PatternTools/interface/Trajectory.h"
7 #include "boost/foreach.hpp"
8
9 ShallowTracksProducer::ShallowTracksProducer(const edm::ParameterSet& iConfig)
10 : theTracksLabel( iConfig.getParameter<edm::InputTag>("Tracks") ),
11 Prefix ( iConfig.getParameter<std::string>("Prefix") ),
12 Suffix ( iConfig.getParameter<std::string>("Suffix") )
13 {
14 produces <unsigned int> ( Prefix + "number" + Suffix );
15 produces <std::vector<double> > ( Prefix + "chi2" + Suffix );
16 produces <std::vector<double> > ( Prefix + "ndof" + Suffix );
17 produces <std::vector<double> > ( Prefix + "chi2ndof" + Suffix );
18 produces <std::vector<float> > ( Prefix + "charge" + Suffix );
19 produces <std::vector<float> > ( Prefix + "momentum" + Suffix );
20 produces <std::vector<float> > ( Prefix + "pt" + Suffix );
21 produces <std::vector<float> > ( Prefix + "pterr" + Suffix );
22 produces <std::vector<unsigned int> > ( Prefix + "hitsvalid" + Suffix );
23 produces <std::vector<unsigned int> > ( Prefix + "hitslost" + Suffix );
24 produces <std::vector<double> > ( Prefix + "theta" + Suffix );
25 produces <std::vector<double> > ( Prefix + "thetaerr" + Suffix );
26 produces <std::vector<double> > ( Prefix + "phi" + Suffix );
27 produces <std::vector<double> > ( Prefix + "phierr" + Suffix );
28 produces <std::vector<double> > ( Prefix + "eta" + Suffix );
29 produces <std::vector<double> > ( Prefix + "etaerr" + Suffix );
30 produces <std::vector<double> > ( Prefix + "dxy" + Suffix );
31 produces <std::vector<double> > ( Prefix + "dxyerr" + Suffix );
32 produces <std::vector<double> > ( Prefix + "dsz" + Suffix );
33 produces <std::vector<double> > ( Prefix + "dszerr" + Suffix );
34 produces <std::vector<double> > ( Prefix + "qoverp" + Suffix );
35 produces <std::vector<double> > ( Prefix + "qoverperr" + Suffix );
36 produces <std::vector<double> > ( Prefix + "vx" + Suffix );
37 produces <std::vector<double> > ( Prefix + "vy" + Suffix );
38 produces <std::vector<double> > ( Prefix + "vz" + Suffix );
39 }
40
41 void ShallowTracksProducer::
42 produce(edm::Event& iEvent, const edm::EventSetup& iSetup) {
43 std::auto_ptr<unsigned int> number ( new unsigned int(0) );
44 std::auto_ptr<std::vector<double> > chi2 ( new std::vector<double>() );
45 std::auto_ptr<std::vector<double> > ndof ( new std::vector<double>() );
46 std::auto_ptr<std::vector<double> > chi2ndof ( new std::vector<double>() );
47 std::auto_ptr<std::vector<float> > charge ( new std::vector<float>() );
48 std::auto_ptr<std::vector<float> > momentum ( new std::vector<float>() );
49 std::auto_ptr<std::vector<float> > pt ( new std::vector<float>() );
50 std::auto_ptr<std::vector<float> > pterr ( new std::vector<float>() );
51 std::auto_ptr<std::vector<unsigned int> > hitsvalid ( new std::vector<unsigned int>() );
52 std::auto_ptr<std::vector<unsigned int> > hitslost ( new std::vector<unsigned int>() );
53 std::auto_ptr<std::vector<double> > theta ( new std::vector<double>() );
54 std::auto_ptr<std::vector<double> > thetaerr ( new std::vector<double>() );
55 std::auto_ptr<std::vector<double> > phi ( new std::vector<double>() );
56 std::auto_ptr<std::vector<double> > phierr ( new std::vector<double>() );
57 std::auto_ptr<std::vector<double> > eta ( new std::vector<double>() );
58 std::auto_ptr<std::vector<double> > etaerr ( new std::vector<double>() );
59 std::auto_ptr<std::vector<double> > dxy ( new std::vector<double>() );
60 std::auto_ptr<std::vector<double> > dxyerr ( new std::vector<double>() );
61 std::auto_ptr<std::vector<double> > dsz ( new std::vector<double>() );
62 std::auto_ptr<std::vector<double> > dszerr ( new std::vector<double>() );
63 std::auto_ptr<std::vector<double> > qoverp ( new std::vector<double>() );
64 std::auto_ptr<std::vector<double> > qoverperr ( new std::vector<double>() );
65 std::auto_ptr<std::vector<double> > vx ( new std::vector<double>() );
66 std::auto_ptr<std::vector<double> > vy ( new std::vector<double>() );
67 std::auto_ptr<std::vector<double> > vz ( new std::vector<double>() );
68
69 edm::Handle<edm::View<reco::Track> > tracks; iEvent.getByLabel(theTracksLabel, tracks);
70
71 *number = tracks->size();
72 BOOST_FOREACH( const reco::Track track, *tracks) {
73 chi2->push_back( track.chi2() );
74 ndof->push_back( track.ndof() );
75 chi2ndof->push_back( track.chi2()/track.ndof() );
76 charge->push_back( track.charge() );
77 momentum->push_back( track.p() );
78 pt->push_back( track.pt() );
79 pterr->push_back( track.ptError() );
80 hitsvalid->push_back( track.numberOfValidHits() );
81 hitslost->push_back( track.numberOfLostHits() );
82 theta->push_back( track.theta() );
83 thetaerr->push_back( track.thetaError() );
84 phi->push_back( track.phi() );
85 phierr->push_back( track.phiError() );
86 eta->push_back( track.eta() );
87 etaerr->push_back( track.etaError() );
88 dxy->push_back( track.dxy() );
89 dxyerr->push_back( track.dxyError() );
90 dsz->push_back( track.dsz() );
91 dszerr->push_back( track.dszError() );
92 qoverp->push_back( track.qoverp() );
93 qoverperr->push_back( track.qoverpError() );
94 vx->push_back( track.vx() );
95 vy->push_back( track.vy() );
96 vz->push_back( track.vz() );
97 }
98
99 iEvent.put(number, Prefix + "number" + Suffix );
100 iEvent.put(chi2, Prefix + "chi2" + Suffix );
101 iEvent.put(ndof, Prefix + "ndof" + Suffix );
102 iEvent.put(chi2ndof, Prefix + "chi2ndof" + Suffix );
103 iEvent.put(charge, Prefix + "charge" + Suffix );
104 iEvent.put(momentum, Prefix + "momentum" + Suffix );
105 iEvent.put(pt, Prefix + "pt" + Suffix );
106 iEvent.put(pterr, Prefix + "pterr" + Suffix );
107 iEvent.put(hitsvalid, Prefix + "hitsvalid" + Suffix );
108 iEvent.put(hitslost, Prefix + "hitslost" + Suffix );
109 iEvent.put(theta, Prefix + "theta" + Suffix );
110 iEvent.put(thetaerr, Prefix + "thetaerr" + Suffix );
111 iEvent.put(phi, Prefix + "phi" + Suffix );
112 iEvent.put(phierr, Prefix + "phierr" + Suffix );
113 iEvent.put(eta, Prefix + "eta" + Suffix );
114 iEvent.put(etaerr, Prefix + "etaerr" + Suffix );
115 iEvent.put(dxy, Prefix + "dxy" + Suffix );
116 iEvent.put(dxyerr, Prefix + "dxyerr" + Suffix );
117 iEvent.put(dsz, Prefix + "dsz" + Suffix );
118 iEvent.put(dszerr, Prefix + "dszerr" + Suffix );
119 iEvent.put(qoverp, Prefix + "qoverp" + Suffix );
120 iEvent.put(qoverperr, Prefix + "qoverperr" + Suffix );
121 iEvent.put(vx, Prefix + "vx" + Suffix );
122 iEvent.put(vy, Prefix + "vy" + Suffix );
123 iEvent.put(vz, Prefix + "vz" + Suffix );
124
125 }
126