ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/CmsHi/JetAnalysis/src/HiJetResponseAnalyzer.cc
Revision: 1.3
Committed: Fri Sep 10 14:47:48 2010 UTC (14 years, 8 months ago) by yilmaz
Content type: text/plain
Branch: MAIN
Changes since 1.2: +1 -4 lines
Log Message:
Filter added

File Contents

# User Rev Content
1 yilmaz 1.1 // -*- C++ -*-
2     //
3     // Package: HiJetResponseAnalyzer
4     // Class: HiJetResponseAnalyzer
5     //
6     /**\class HiJetResponseAnalyzer HiJetResponseAnalyzer.cc CmsHi/HiJetResponseAnalyzer/src/HiJetResponseAnalyzer.cc
7    
8     Description: [one line class summary]
9    
10     Implementation:
11     [Notes on implementation]
12     */
13     //
14     // Original Author: Yetkin Yilmaz
15     // Created: Thu Sep 9 10:38:59 EDT 2010
16 yilmaz 1.3 // $Id: HiJetResponseAnalyzer.cc,v 1.2 2010/09/10 12:54:47 yilmaz Exp $
17 yilmaz 1.1 //
18     //
19    
20    
21     // system include files
22     #include <memory>
23 yilmaz 1.2 #include <iostream>
24 yilmaz 1.1
25     // user include files
26     #include "FWCore/Framework/interface/Frameworkfwd.h"
27     #include "FWCore/Framework/interface/EDAnalyzer.h"
28    
29     #include "FWCore/Framework/interface/Event.h"
30     #include "FWCore/Framework/interface/MakerMacros.h"
31    
32     #include "FWCore/ParameterSet/interface/ParameterSet.h"
33    
34     #include "FWCore/Utilities/interface/InputTag.h"
35     #include "DataFormats/HeavyIonEvent/interface/CentralityBins.h"
36     #include "DataFormats/CaloTowers/interface/CaloTowerCollection.h"
37     #include "DataFormats/HeavyIonEvent/interface/Centrality.h"
38     #include "DataFormats/PatCandidates/interface/Jet.h"
39     #include "SimDataFormats/HiGenData/interface/GenHIEvent.h"
40     #include "DataFormats/JetReco/interface/CaloJetCollection.h"
41     #include "DataFormats/JetReco/interface/GenJetCollection.h"
42    
43 yilmaz 1.2 #include "CommonTools/UtilAlgos/interface/TFileService.h"
44     #include "FWCore/ServiceRegistry/interface/Service.h"
45    
46    
47 yilmaz 1.1 #include "TTree.h"
48    
49     using namespace std;
50    
51     static const int MAXJETS = 500;
52    
53     struct etdr{
54     double et;
55     double dr;
56     };
57    
58     struct JRA{
59    
60     int nref;
61     int bin;
62     float b;
63     float hf;
64     float jtpt[MAXJETS];
65     float refpt[MAXJETS];
66     float jteta[MAXJETS];
67     float refeta[MAXJETS];
68     float jtphi[MAXJETS];
69     float refphi[MAXJETS];
70    
71     float weight;
72     };
73    
74     //
75     // class declaration
76     //
77    
78     class HiJetResponseAnalyzer : public edm::EDAnalyzer {
79     public:
80     explicit HiJetResponseAnalyzer(const edm::ParameterSet&);
81     ~HiJetResponseAnalyzer();
82    
83    
84     private:
85     virtual void beginJob() ;
86     virtual void analyze(const edm::Event&, const edm::EventSetup&);
87     virtual void endJob() ;
88    
89     // ----------member data ---------------------------
90    
91 yilmaz 1.2 bool usePat_;
92     bool doMC_;
93    
94 yilmaz 1.1 double genJetPtMin_;
95    
96 yilmaz 1.2
97     edm::InputTag jetTag_;
98    
99 yilmaz 1.1 JRA jra_;
100     TTree* t;
101    
102     edm::Handle<edm::GenHIEvent> mc;
103     edm::Handle<reco::Centrality> cent;
104    
105     edm::Handle<reco::JetView> jets;
106 yilmaz 1.2 // edm::Handle<pat::JetCollection> jets;
107 yilmaz 1.1
108    
109 yilmaz 1.2 edm::Service<TFileService> fs;
110 yilmaz 1.1
111     };
112    
113     //
114     // constants, enums and typedefs
115     //
116    
117     //
118     // static data member definitions
119     //
120    
121     //
122     // constructors and destructor
123     //
124     HiJetResponseAnalyzer::HiJetResponseAnalyzer(const edm::ParameterSet& iConfig)
125    
126     {
127     //now do what ever initialization is needed
128     genJetPtMin_ = 0;
129 yilmaz 1.2
130     usePat_ = false;
131     doMC_ = false;
132    
133     jetTag_ = edm::InputTag("selectedPatJets");
134    
135 yilmaz 1.1 }
136    
137    
138     HiJetResponseAnalyzer::~HiJetResponseAnalyzer()
139     {
140    
141     // do anything here that needs to be done at desctruction time
142     // (e.g. close files, deallocate resources etc.)
143    
144     }
145    
146    
147     //
148     // member functions
149     //
150    
151     // ------------ method called to for each event ------------
152     void
153     HiJetResponseAnalyzer::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup)
154     {
155     using namespace edm;
156    
157 yilmaz 1.2 iEvent.getByLabel(jetTag_,jets);
158 yilmaz 1.1
159 yilmaz 1.2 jra_.nref = 0;
160 yilmaz 1.1 for(unsigned int j = 0 ; j < jets->size(); ++j){
161 yilmaz 1.2
162     // const pat::Jet& jet = (*jets)[j];
163     const reco::Jet jet = (*jets)[j];
164     jra_.jtpt[jra_.nref] = jet.pt();
165     jra_.jteta[jra_.nref] = jet.eta();
166     jra_.jtphi[jra_.nref] = jet.phi();
167 yilmaz 1.1
168 yilmaz 1.2 if(usePat_){
169     const pat::Jet& patjet = (*jets)[j];
170    
171     if(doMC_ && patjet.genJet() != 0){
172     // if(jet.genJet()->pt() < genJetPtMin_) continue;
173     jra_.refpt[jra_.nref] = patjet.genJet()->pt();
174     jra_.refeta[jra_.nref] = patjet.genJet()->eta();
175     jra_.refphi[jra_.nref] = patjet.genJet()->phi();
176    
177     }else{
178     jra_.refpt[jra_.nref] = -99;
179     jra_.refeta[jra_.nref] = -99;
180     jra_.refphi[jra_.nref] = -99;
181     }
182 yilmaz 1.1 }
183 yilmaz 1.2
184     jra_.nref++;
185    
186 yilmaz 1.1 }
187    
188     t->Fill();
189    
190     }
191    
192    
193     // ------------ method called once each job just before starting event loop ------------
194     void
195     HiJetResponseAnalyzer::beginJob()
196     {
197 yilmaz 1.2
198     t= fs->make<TTree>("t","Jet Response Analyzer");
199     t->Branch("b",&jra_.b,"b/F");
200     t->Branch("hf",&jra_.hf,"hf/F");
201     t->Branch("nref",&jra_.nref,"nref/I");
202     t->Branch("jtpt",jra_.jtpt,"jtpt[nref]/F");
203     t->Branch("refpt",jra_.refpt,"refpt[nref]/F");
204     t->Branch("jteta",jra_.jteta,"jteta[nref]/F");
205     t->Branch("refeta",jra_.refeta,"refeta[nref]/F");
206     t->Branch("jtphi",jra_.jtphi,"jtphi[nref]/F");
207     t->Branch("refphi",jra_.refphi,"refphi[nref]/F");
208     t->Branch("weight",&jra_.weight,"weight/F");
209     t->Branch("bin",&jra_.bin,"bin/I");
210    
211    
212    
213 yilmaz 1.1 }
214    
215     // ------------ method called once each job just after ending the event loop ------------
216     void
217     HiJetResponseAnalyzer::endJob() {
218     }
219    
220     //define this as a plug-in
221     DEFINE_FWK_MODULE(HiJetResponseAnalyzer);