ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/ShallowTools/plugins/ShallowTracksProducer.cc
Revision: 1.2
Committed: Thu Jun 11 16:09:16 2009 UTC (15 years, 10 months ago) by bbetchar
Content type: text/plain
Branch: MAIN
Changes since 1.1: +1 -1 lines
Log Message:
Added ShallowSimTracksProducer (sans cfi)

File Contents

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