ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/Martin/src/Weber.cc
Revision: 1.1
Committed: Tue May 20 07:20:46 2008 UTC (16 years, 11 months ago) by mweber
Content type: text/plain
Branch: MAIN
Log Message:
- initial commit of SimpleTrackAnalyzer

File Contents

# User Rev Content
1 mweber 1.1 // -*- C++ -*-
2     //
3     // Package: Weber
4     // Class: Weber
5     //
6     /**\class Weber Weber.cc Martin/Weber/src/Weber.cc
7    
8     Description: <one line class summary>
9    
10     Implementation:
11     <Notes on implementation>
12     */
13     //
14     // Original Author: Martin Weber
15     // Created: Thu Mar 20 21:07:21 CET 2008
16     // $Id$
17     //
18     //
19    
20    
21     #include "TH1F.h"
22     #include "TH2F.h"
23     #include "TFile.h"
24     // system include files
25     #include <memory>
26     #include <iostream>
27     using namespace std;
28    
29     // user include files
30     #include "FWCore/Framework/interface/Frameworkfwd.h"
31     #include "FWCore/Framework/interface/EDAnalyzer.h"
32    
33     #include "FWCore/Framework/interface/Event.h"
34     #include "FWCore/Framework/interface/MakerMacros.h"
35    
36     #include "FWCore/ParameterSet/interface/ParameterSet.h"
37    
38    
39     #include "DataFormats/TrackReco/interface/Track.h"
40     #include "DataFormats/TrackReco/interface/TrackFwd.h"
41     //
42     // class decleration
43     //
44    
45     class Weber : public edm::EDAnalyzer {
46     public:
47     explicit Weber(const edm::ParameterSet&);
48     ~Weber();
49    
50    
51     private:
52     virtual void beginJob(const edm::EventSetup&) ;
53     virtual void analyze(const edm::Event&, const edm::EventSetup&);
54     virtual void endJob() ;
55    
56     // ----------member data ---------------------------
57     TH1F * hfx;
58     TH1F * hfy;
59     TH1F * hfz;
60     TH1F * hlx;
61     TH1F * hly;
62     TH1F * hlz;
63     TH1F * hp;
64     TH1F * hpt;
65     TH1F * hphi;
66     TH1F * heta;
67     TH1F * hrho;
68     TH1F * h1;
69     TH2F * hfxy;
70     TH2F * hlxy;
71     TH2F * hxy;
72     TH2F * hrz;
73     TH2F * hxz;
74     TH2F * hhits;
75     TFile * myFile;
76     };
77    
78     //
79     // constants, enums and typedefs
80     //
81    
82     //
83     // static data member definitions
84     //
85    
86     //
87     // constructors and destructor
88     //
89     Weber::Weber(const edm::ParameterSet& iConfig)
90    
91     {
92     //now do what ever initialization is needed
93     myFile = new TFile("histo.root", "RECREATE");
94     hfx = new TH1F("hfx", "x", 100, -120, 120);
95     hfy = new TH1F("hfy", "y", 100, -120, 120);
96     hfz = new TH1F("hfz", "z", 100, -300, 300);
97     hlx = new TH1F("hlx", "x", 100, -120, 120);
98     hly = new TH1F("hly", "y", 100, -120, 120);
99     hlz = new TH1F("hlz", "z", 100, -300, 300);
100     hp = new TH1F("hp", "p", 100, 0, 100);
101     hpt = new TH1F("hpt", "pt", 100, 0, 100);
102     hphi = new TH1F("hphi", "#phi", 100, -1.9, 0);
103     heta = new TH1F("heta", "#eta", 100, -3, 3);
104     hrho = new TH1F("hrho", "#rho", 100, 0, 1000);
105     h1 = new TH1F("h1", "r", 200, -120, 120);
106     hfxy = new TH2F("hfxy", "fxy", 100, -120, 120, 100, -120, 120);
107     hlxy = new TH2F("hlxy", "lxy", 100, -120, 120, 100, -120, 120);
108     hxy = new TH2F("hxy", "xy", 100, -120, 120, 100, -120, 120);
109     hrz = new TH2F("hrz", "rz", 100, -300, 300, 100, -120, 120);
110     hxz = new TH2F("hxz", "xz", 100, -300, 300, 100, -120, 120);
111     hhits = new TH2F("hhits", "hits x vs y", 100, -120, 120, 100, -120, 120);
112     }
113    
114    
115     Weber::~Weber()
116     {
117     // do anything here that needs to be done at desctruction time
118     // (e.g. close files, deallocate resources etc.)
119     myFile->cd();
120     hfx->Write();
121     hfy->Write();
122     hfz->Write();
123     hlx->Write();
124     hly->Write();
125     hlz->Write();
126     hp->Write();
127     hpt->Write();
128     hphi->Write();
129     heta->Write();
130     hrho->Write();
131     h1->Write();
132     hfxy->Write();
133     hlxy->Write();
134     hxy->Write();
135     hrz->Write();
136     hxz->Write();
137     myFile->Close();
138     delete myFile;
139     }
140    
141    
142     //
143     // member functions
144     //
145    
146     // ------------ method called to for each event ------------
147     void
148     Weber::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup)
149     {
150     using namespace edm;
151     using reco::TrackCollection;
152    
153     Handle<TrackCollection> tracks;
154     iEvent.getByLabel("ctfWithMaterialTracksBeamHaloMuon",tracks);
155     for(TrackCollection::const_iterator itTrack = tracks->begin();
156     itTrack != tracks->end();
157     ++itTrack) {
158     const reco::TrackBase::Point firstPoint(itTrack->innerPosition());
159     double fx = firstPoint.x();
160     double fy = firstPoint.y();
161     double fz = firstPoint.z();
162     double r = sqrt(fx*fx+fy*fy);
163     const reco::TrackBase::Point lastPoint(itTrack->outerPosition());
164     double lx = lastPoint.x();
165     double ly = lastPoint.y();
166     double lz = lastPoint.z();
167     double px = (*itTrack).momentum().x();
168     double py = (*itTrack).momentum().y();
169     double pz = (*itTrack).momentum().z();
170     double p = sqrt(px*px+py*py+pz*pz);
171     double pt = (*itTrack).pt();
172     double phi = (*itTrack).phi();
173     double eta = (*itTrack).eta();
174     double rho = firstPoint.Rho();
175     hfx->Fill(fx);
176     hfy->Fill(fy);
177     hfz->Fill(fz);
178     hlx->Fill(lx);
179     hly->Fill(ly);
180     hlz->Fill(lz);
181     hp->Fill(p);
182     hpt->Fill(pt);
183     hphi->Fill(phi);
184     heta->Fill(eta);
185     hrho->Fill(rho);
186     h1->Fill(r);
187     hfxy->Fill(fx, fy);
188     hlxy->Fill(lx, ly);
189     hxy->Fill(fx, fy);
190     hxy->Fill(lx, ly);
191     hrz->Fill(fz, r);
192     hxz->Fill(fz, fx);
193     for (trackingRecHit_iterator rit = (*itTrack).recHitsBegin();
194     rit != (*itTrack).recHitsEnd(); ++rit) {
195     TrackingRecHitRef hit = *rit;
196     }
197     }
198     }
199    
200    
201     // ------------ method called once each job just before starting event loop ------------
202     void
203     Weber::beginJob(const edm::EventSetup&)
204     {
205     }
206    
207     // ------------ method called once each job just after ending the event loop ------------
208     void
209     Weber::endJob() {
210     }
211    
212     //define this as a plug-in
213     DEFINE_FWK_MODULE(Weber);