ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/CmsHi/JetAnalysis/src/HiJetResponseAnalyzer.cc
Revision: 1.2
Committed: Fri Sep 10 12:54:47 2010 UTC (14 years, 7 months ago) by yilmaz
Content type: text/plain
Branch: MAIN
Changes since 1.1: +64 -28 lines
Log Message:
fixes

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.2 // $Id: HiJetResponseAnalyzer.cc,v 1.1 2010/09/09 15:05:01 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     cout<<"a"<<endl;
159 yilmaz 1.1
160 yilmaz 1.2 jra_.nref = 0;
161 yilmaz 1.1 for(unsigned int j = 0 ; j < jets->size(); ++j){
162 yilmaz 1.2 cout<<"b"<<endl;
163    
164     // const pat::Jet& jet = (*jets)[j];
165     const reco::Jet jet = (*jets)[j];
166     jra_.jtpt[jra_.nref] = jet.pt();
167     jra_.jteta[jra_.nref] = jet.eta();
168     jra_.jtphi[jra_.nref] = jet.phi();
169     cout<<"c"<<endl;
170 yilmaz 1.1
171 yilmaz 1.2 if(usePat_){
172     const pat::Jet& patjet = (*jets)[j];
173    
174     if(doMC_ && patjet.genJet() != 0){
175     // if(jet.genJet()->pt() < genJetPtMin_) continue;
176     jra_.refpt[jra_.nref] = patjet.genJet()->pt();
177     jra_.refeta[jra_.nref] = patjet.genJet()->eta();
178     jra_.refphi[jra_.nref] = patjet.genJet()->phi();
179    
180     }else{
181     jra_.refpt[jra_.nref] = -99;
182     jra_.refeta[jra_.nref] = -99;
183     jra_.refphi[jra_.nref] = -99;
184     }
185 yilmaz 1.1 }
186 yilmaz 1.2
187     jra_.nref++;
188    
189 yilmaz 1.1 }
190    
191     t->Fill();
192    
193     }
194    
195    
196     // ------------ method called once each job just before starting event loop ------------
197     void
198     HiJetResponseAnalyzer::beginJob()
199     {
200 yilmaz 1.2
201     t= fs->make<TTree>("t","Jet Response Analyzer");
202     t->Branch("b",&jra_.b,"b/F");
203     t->Branch("hf",&jra_.hf,"hf/F");
204     t->Branch("nref",&jra_.nref,"nref/I");
205     t->Branch("jtpt",jra_.jtpt,"jtpt[nref]/F");
206     t->Branch("refpt",jra_.refpt,"refpt[nref]/F");
207     t->Branch("jteta",jra_.jteta,"jteta[nref]/F");
208     t->Branch("refeta",jra_.refeta,"refeta[nref]/F");
209     t->Branch("jtphi",jra_.jtphi,"jtphi[nref]/F");
210     t->Branch("refphi",jra_.refphi,"refphi[nref]/F");
211     t->Branch("weight",&jra_.weight,"weight/F");
212     t->Branch("bin",&jra_.bin,"bin/I");
213    
214    
215    
216 yilmaz 1.1 }
217    
218     // ------------ method called once each job just after ending the event loop ------------
219     void
220     HiJetResponseAnalyzer::endJob() {
221     }
222    
223     //define this as a plug-in
224     DEFINE_FWK_MODULE(HiJetResponseAnalyzer);