ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/CmsHi/JetAnalysis/src/CaloDisplay.cc
Revision: 1.3
Committed: Thu Jun 3 09:11:03 2010 UTC (14 years, 11 months ago) by yilmaz
Content type: text/plain
Branch: MAIN
CVS Tags: HiForest_V02_85, HiForest_V02_84, HiForest_V02_83, HiForest_V02_82, HiForest_V02_81, HiForest_V02_80, HiForest_V02_79, HiForest_V02_78, HiForest_V02_77, HiForest_V02_76, HiForest_V02_75, HiForest_V02_74, HiForest_V02_73, HiForest_V02_72, HiForest_V02_71, HiForest_V02_70, HiForest_V02_69, HiForest_V02_68, HiForest_V02_67, HiForest_V02_66, HiForest_V02_65, HiForest_V02_64, HiForest_V02_63, HiForest_V02_62, HiForest_V02_61, HiForest_V02_60, HiForest_V02_59, HiForest_V02_58, HiForest_V02_57, HiForest_V02_56, HiForest_V02_55, HiForest_V02_54, HiForest_V02_53, HiForest_V02_52, HiForest_V02_51, HiForest_V02_50, HiForest_V02_49, HiForest_V02_48, HiForest_V02_47, HiForest_V02_46, HiForest_V02_45, HiForest_V02_44, HiForest_V02_43, HiForest_V02_42, HiForest_V02_41, HiForest_V02_40, HiForest_V02_39, HiForest_V02_38, HiForest_V02_37, HiForest_V02_36, HiForest_V02_35, HiForest_V02_34, HiForest_V02_33, HiForest_V02_32, HiForest_V02_31, HiForest_V02_30, HiForest_V02_27, HiForest_V02_26, QM_2012, HiForest_V02_25, HiForest_V02_24, HiForest_V02_23, HiForest_V02_22, HiForest_V02_21, HiForest_V02_20, HiForest_V02_19, HiForest_V02_18, HiForest_V02_17, HiForest_V02_16, HiForest_V02_15, HiForest_V02_14, HiForest_V02_13, HiForest_V02_12, HiForest_V02_11, HiForest_V02_10, HiForest_V02_09, HiForest_V02_08, HiForest_V02_07, HiForest_V02_06, HiForest_V02_05, HiForest_V02_04, HiForest_V02_03, HiForest_V02_02, HiForest_V02_01, HiForest_V02_00, hi44X_02, hi413_03, hi441_1, hi441_0, hi413_11, hi413_10, hi413_09, hi413_08, hi413_07, hi413_06, hi413_05, hi413_04, hi413_02, hi39X_01, tag_d20110915, cmssw39x_base, cmssw39X_base, HEAD
Branch point for: branch_44x, cmssw39x_branch
Changes since 1.2: +2 -2 lines
Log Message:
fix

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 yilmaz 1.3 // $Id: CaloDisplay.cc,v 1.2 2010/05/19 14:14:49 yilmaz Exp $
17 yilmaz 1.1 //
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 yilmaz 1.3 #include "FWCore/Utilities/interface/InputTag.h"
36 yilmaz 1.1
37     #include "FWCore/ServiceRegistry/interface/Service.h"
38 yilmaz 1.2 #include "CommonTools/UtilAlgos/interface/TFileService.h"
39 yilmaz 1.1
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 yilmaz 1.2 for(unsigned int ijet = 0; ijet < jets->size(); ++ijet){
209 yilmaz 1.1 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);