ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/CmsHi/JetAnalysis/src/CaloDisplay.cc
Revision: 1.1
Committed: Mon Apr 27 21:24:37 2009 UTC (16 years ago) by yilmaz
Content type: text/plain
Branch: MAIN
CVS Tags: cmshi_32X, cmshi_22X_v2, cmshi_22X
Branch point for: BRANCH22X
Log Message:
Heavy Ion Jet Analysis tools

File Contents

# User Rev Content
1 yilmaz 1.1 // -*- C++ -*-
2     //
3     // Package: CaloDisplay
4     // Class: CaloDisplay
5     //
6     /**\class CaloDisplay CaloDisplay.cc yetkin/CaloDisplay/src/CaloDisplay.cc
7    
8     Description: <one line class summary>
9    
10     Implementation:
11     <Notes on implementation>
12     */
13     //
14     // Original Author: Yetkin Yilmaz
15     // Created: Wed Oct 3 08:07:18 EDT 2007
16     // $Id: CaloDisplay.cc,v 1.1 2008/04/07 14:29:18 yilmaz Exp $
17     //
18     //
19    
20    
21     // system include files
22     #include <memory>
23     #include <iostream>
24    
25     // user include files
26     #include "FWCore/Framework/interface/Frameworkfwd.h"
27     #include "FWCore/Framework/interface/EDAnalyzer.h"
28     #include "FWCore/Framework/interface/EventSetup.h"
29     #include "FWCore/Framework/interface/ESHandle.h"
30    
31     #include "FWCore/Framework/interface/Event.h"
32     #include "FWCore/Framework/interface/MakerMacros.h"
33    
34     #include "FWCore/ParameterSet/interface/ParameterSet.h"
35     #include "FWCore/ParameterSet/interface/InputTag.h"
36    
37     #include "FWCore/ServiceRegistry/interface/Service.h"
38     #include "PhysicsTools/UtilAlgos/interface/TFileService.h"
39    
40     #include "DataFormats/EcalRecHit/interface/EcalRecHitCollections.h"
41    
42     #include "DataFormats/HcalRecHit/interface/HcalRecHitCollections.h"
43     #include "DataFormats/HcalDetId/interface/HcalDetId.h"
44     #include "DataFormats/DetId/interface/DetId.h"
45     #include "Geometry/CaloGeometry/interface/CaloGeometry.h"
46     #include "Geometry/Records/interface/IdealGeometryRecord.h"
47     #include "Geometry/Records/interface/CaloGeometryRecord.h"
48    
49     #include "DataFormats/GeometryVector/interface/GlobalPoint.h"
50    
51     #include "DataFormats/JetReco/interface/JetCollection.h"
52     #include "DataFormats/JetReco/interface/Jet.h"
53    
54     #include "SimDataFormats/GeneratorProducts/interface/HepMCProduct.h"
55    
56     #include "HepMC/GenEvent.h"
57     #include "HepMC/HeavyIon.h"
58    
59     #include <TH1D.h>
60     #include <TH2D.h>
61     #include <TNtuple.h>
62     #include <TMath.h>
63     #include <TString.h>
64    
65     using namespace std;
66    
67     //
68     // class decleration
69     //
70    
71     class CaloDisplay : public edm::EDAnalyzer {
72     public:
73     explicit CaloDisplay(const edm::ParameterSet&);
74     ~CaloDisplay();
75    
76    
77     private:
78     virtual void beginJob(const edm::EventSetup&) ;
79     virtual void analyze(const edm::Event&, const edm::EventSetup&);
80     virtual void endJob() ;
81     double computeEt(const DetId &id, double energy);
82    
83     // ----------member data ---------------------------
84    
85     const CaloGeometry *geo;
86    
87     edm::Service<TFileService> fs;
88    
89     TNtuple* ntjet;
90     TNtuple* ntcalo;
91     TNtuple* ntmc;
92    
93     TH2D* hHad;
94     TH2D* hEM;
95     TH2D* hMC;
96    
97     int NoE;
98     };
99    
100     //
101     // constants, enums and typedefs
102     //
103    
104     //
105     // static data member definitions
106     //
107    
108     //
109     // constructors and destructor
110     //
111     CaloDisplay::CaloDisplay(const edm::ParameterSet& iConfig)
112     {
113     //now do what ever initialization is needed
114    
115     }
116    
117    
118     CaloDisplay::~CaloDisplay()
119     {
120    
121     // do anything here that needs to be done at desctruction time
122     // (e.g. close files, deallocate resources etc.)
123    
124     }
125    
126    
127     //
128     // member functions
129     //
130    
131     // ------------ method called to for each event ------------
132     void
133     CaloDisplay::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup)
134     {
135     using namespace edm;
136    
137     NoE += 1;
138    
139     Handle<EcalRecHitCollection> ebhits;
140     iEvent.getByLabel(InputTag("ecalRecHit","EcalRecHitsEB"),ebhits);
141     for( size_t ihit = 0; ihit<ebhits->size(); ++ihit){
142     const EcalRecHit & rechit = (*ebhits)[ihit];
143     const DetId& detId = rechit.id();
144     const GlobalPoint& hitpoint = geo->getPosition(detId);
145     double phi = hitpoint.phi();
146     double eta = hitpoint.eta();
147     double et = computeEt(detId, rechit.energy());
148     hEM->Fill(eta,phi,et);
149     ntcalo->Fill(eta,phi,et,2);
150     }
151    
152     Handle<EcalRecHitCollection> eehits;
153     iEvent.getByLabel(InputTag("ecalRecHit","EcalRecHitsEE"),eehits);
154     for( size_t eit = 0; eit<eehits->size(); ++eit){
155     const EcalRecHit & rechit = (*eehits)[eit];
156     const DetId& detId = rechit.id();
157     const GlobalPoint& hitpoint = geo->getPosition(detId);
158     double phi = hitpoint.phi();
159     double eta = hitpoint.eta();
160     double et = computeEt(detId, rechit.energy());
161     hEM->Fill(eta,phi,et);
162     ntcalo->Fill(eta,phi,et,2);
163    
164     }
165    
166     Handle<HBHERecHitCollection> hhits;
167     iEvent.getByLabel(InputTag("hbhereco"),hhits);
168     for( size_t hhit = 0; hhit<hhits->size(); ++hhit){
169     const HBHERecHit & rechit = (*hhits)[hhit];
170     const DetId& detId = rechit.id();
171     const GlobalPoint& hitpoint = geo->getPosition(detId);
172     double phi = hitpoint.phi();
173     double eta = hitpoint.eta();
174     double et = computeEt(detId, rechit.energy());
175     hHad->Fill(eta,phi,et);
176     ntcalo->Fill(eta,phi,et,1);
177    
178     }
179    
180     Handle<HFRecHitCollection> hfhits;
181     iEvent.getByLabel(InputTag("hfreco"),hfhits);
182     for( size_t ihf = 0; ihf<hfhits->size(); ++ihf){
183     const HFRecHit & rechit = (*hfhits)[ihf];
184     const DetId& detId = rechit.id();
185     const GlobalPoint& hitpoint = geo->getPosition(detId);
186     double phi = hitpoint.phi();
187     double eta = hitpoint.eta();
188     double et = computeEt(detId, rechit.energy());
189     hHad->Fill(eta,phi,et);
190     ntcalo->Fill(eta,phi,et,1);
191     }
192    
193     Handle<HORecHitCollection> hohits;
194     iEvent.getByLabel(InputTag("horeco"),hohits);
195     for( size_t iho = 0; iho<hohits->size(); ++iho){
196     const HORecHit & rechit = (*hohits)[iho];
197     const DetId& detId = rechit.id();
198     const GlobalPoint& hitpoint = geo->getPosition(detId);
199     double phi = hitpoint.phi();
200     double eta = hitpoint.eta();
201     double et = computeEt(detId, rechit.energy());
202     hHad->Fill(eta,phi,et);
203     ntcalo->Fill(eta,phi,et,1);
204     }
205    
206     edm::Handle<reco::JetView> jets;
207     iEvent.getByLabel("iterativeConePu5CaloJets",jets);
208     for(int ijet = 0; ijet < jets->size(); ++ijet){
209     const reco::Jet* jet = &((*jets)[ijet]);
210     double pt = jet->pt();
211     double eta = jet->eta();
212     double phi = jet->phi();
213     ntjet->Fill(eta,phi,pt);
214     }
215    
216     Handle<HepMCProduct> mc;
217     iEvent.getByLabel("signal",mc);
218     const HepMC::GenEvent* evt = mc->GetEvent();
219    
220     int all = evt->particles_size();
221     HepMC::GenEvent::particle_const_iterator begin = evt->particles_begin();
222     HepMC::GenEvent::particle_const_iterator end = evt->particles_end();
223     for(HepMC::GenEvent::particle_const_iterator it = begin; it != end; ++it){
224    
225     int pdg = (*it)->pdg_id();
226     float eta = (*it)->momentum().eta();
227     float phi = (*it)->momentum().phi();
228     float pt = (*it)->momentum().perp();
229     int st = (*it)->status();
230    
231     if(st == 1) hMC->Fill(eta,phi,pt);
232     ntmc->Fill(eta,phi,pt,pdg);
233     }
234     }
235    
236    
237     // ------------ method called once each job just before starting event loop ------------
238     void
239     CaloDisplay::beginJob(const edm::EventSetup& iSetup)
240     {
241    
242    
243     hHad = fs->make<TH2D>("hHad","E_{T} in Hcal;#eta;#phi",60,-2.5,2.5,75,-3.15,3.15);
244     hEM = fs->make<TH2D>("hEM","E_{T} in Ecal;#eta;#phi",150,-2.5,2.5,180,-3.15,3.15);
245     hMC = fs->make<TH2D>("hMC","E_{T} from MC;#eta;#phi",150,-2.5,2.5,180,-3.15,3.15);
246    
247     ntcalo = fs->make<TNtuple>("ntcalo","","eta:phi:et:type");
248     ntjet = fs->make<TNtuple>("ntjet","","eta:phi:et");
249     ntmc = fs->make<TNtuple>("ntmc","","eta:phi:pt:pdg:st");
250    
251     NoE = 0;
252     edm::ESHandle<CaloGeometry> pGeo;
253     iSetup.get<CaloGeometryRecord>().get(pGeo);
254     geo = pGeo.product();
255    
256    
257     }
258    
259     // ------------ method called once each job just after ending the event loop ------------
260     void
261     CaloDisplay::endJob() {
262    
263     double n = 1/NoE;
264    
265     }
266    
267     double CaloDisplay::computeEt(const DetId &id, double energy){
268     const GlobalPoint& pos=geo->getPosition(id);
269     double et = energy*sin(pos.theta());
270     return et;
271     }
272    
273     //define this as a plug-in
274     DEFINE_FWK_MODULE(CaloDisplay);