ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/CmsHi/JetAnalysis/src/HiJetResponseAnalyzer.cc
Revision: 1.1
Committed: Thu Sep 9 15:05:01 2010 UTC (14 years, 7 months ago) by yilmaz
Content type: text/plain
Branch: MAIN
Log Message:
module to create a quick jet tree

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     // $Id$
17     //
18     //
19    
20    
21     // system include files
22     #include <memory>
23    
24     // user include files
25     #include "FWCore/Framework/interface/Frameworkfwd.h"
26     #include "FWCore/Framework/interface/EDAnalyzer.h"
27    
28     #include "FWCore/Framework/interface/Event.h"
29     #include "FWCore/Framework/interface/MakerMacros.h"
30    
31     #include "FWCore/ParameterSet/interface/ParameterSet.h"
32    
33     #include "FWCore/Utilities/interface/InputTag.h"
34     #include "DataFormats/HeavyIonEvent/interface/CentralityBins.h"
35     #include "DataFormats/CaloTowers/interface/CaloTowerCollection.h"
36     #include "DataFormats/HeavyIonEvent/interface/Centrality.h"
37     #include "DataFormats/PatCandidates/interface/Jet.h"
38     #include "SimDataFormats/HiGenData/interface/GenHIEvent.h"
39     #include "DataFormats/JetReco/interface/CaloJetCollection.h"
40     #include "DataFormats/JetReco/interface/GenJetCollection.h"
41    
42     #include "TTree.h"
43    
44     using namespace std;
45    
46     static const int MAXJETS = 500;
47    
48     struct etdr{
49     double et;
50     double dr;
51     };
52    
53     struct JRA{
54    
55     int nref;
56     int bin;
57     float b;
58     float hf;
59     float jtpt[MAXJETS];
60     float refpt[MAXJETS];
61     float jteta[MAXJETS];
62     float refeta[MAXJETS];
63     float jtphi[MAXJETS];
64     float refphi[MAXJETS];
65    
66     float weight;
67     };
68    
69     //
70     // class declaration
71     //
72    
73     class HiJetResponseAnalyzer : public edm::EDAnalyzer {
74     public:
75     explicit HiJetResponseAnalyzer(const edm::ParameterSet&);
76     ~HiJetResponseAnalyzer();
77    
78    
79     private:
80     virtual void beginJob() ;
81     virtual void analyze(const edm::Event&, const edm::EventSetup&);
82     virtual void endJob() ;
83    
84     // ----------member data ---------------------------
85    
86     double genJetPtMin_;
87    
88     JRA jra_;
89     TTree* t;
90    
91     edm::Handle<edm::GenHIEvent> mc;
92     edm::Handle<reco::Centrality> cent;
93    
94     edm::Handle<reco::JetView> jets;
95    
96    
97    
98    
99     };
100    
101     //
102     // constants, enums and typedefs
103     //
104    
105     //
106     // static data member definitions
107     //
108    
109     //
110     // constructors and destructor
111     //
112     HiJetResponseAnalyzer::HiJetResponseAnalyzer(const edm::ParameterSet& iConfig)
113    
114     {
115     //now do what ever initialization is needed
116     genJetPtMin_ = 0;
117     }
118    
119    
120     HiJetResponseAnalyzer::~HiJetResponseAnalyzer()
121     {
122    
123     // do anything here that needs to be done at desctruction time
124     // (e.g. close files, deallocate resources etc.)
125    
126     }
127    
128    
129     //
130     // member functions
131     //
132    
133     // ------------ method called to for each event ------------
134     void
135     HiJetResponseAnalyzer::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup)
136     {
137     using namespace edm;
138    
139    
140     for(unsigned int j = 0 ; j < jets->size(); ++j){
141    
142     const pat::Jet jet = (pat::Jet)((*jets)[j]);
143    
144     if(jet.genJet() != 0){
145    
146     if(jet.genJet()->pt() < genJetPtMin_) continue;
147     jra_.refpt[jra_.nref] = jet.genJet()->pt();
148     jra_.refeta[jra_.nref] = jet.genJet()->eta();
149     jra_.refphi[jra_.nref] = jet.genJet()->phi();
150    
151     jra_.jtpt[jra_.nref] = jet.pt();
152     jra_.jteta[jra_.nref] = jet.eta();
153     jra_.jtphi[jra_.nref] = jet.phi();
154    
155     jra_.nref++;
156    
157     }
158     }
159    
160     t->Fill();
161    
162    
163    
164     #ifdef THIS_IS_AN_EVENT_EXAMPLE
165     Handle<ExampleData> pIn;
166     iEvent.getByLabel("example",pIn);
167     #endif
168    
169     #ifdef THIS_IS_AN_EVENTSETUP_EXAMPLE
170     ESHandle<SetupData> pSetup;
171     iSetup.get<SetupRecord>().get(pSetup);
172     #endif
173     }
174    
175    
176     // ------------ method called once each job just before starting event loop ------------
177     void
178     HiJetResponseAnalyzer::beginJob()
179     {
180     }
181    
182     // ------------ method called once each job just after ending the event loop ------------
183     void
184     HiJetResponseAnalyzer::endJob() {
185     }
186    
187     //define this as a plug-in
188     DEFINE_FWK_MODULE(HiJetResponseAnalyzer);