ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/CmsHi/JetAnalysis/src/FastJetAnalyzer.cc
Revision: 1.1
Committed: Wed Feb 13 18:51:07 2013 UTC (12 years, 2 months ago) by yilmaz
Content type: text/plain
Branch: MAIN
Log Message:
rho analyzer

File Contents

# Content
1 // -*- C++ -*-
2 //
3 // Package: FastJetAnalyzer
4 // Class: FastJetAnalyzer
5 //
6 /**\class FastJetAnalyzer FastJetAnalyzer.cc CmsHi/FastJetAnalyzer/src/FastJetAnalyzer.cc
7
8 Description: [one line class summary]
9
10 Implementation:
11 [Notes on implementation]
12 */
13 //
14 // Original Author: Yetkin Yilmaz,32 4-A08,+41227673039,
15 // Created: Wed Feb 13 14:57:10 CET 2013
16 // $Id$
17 //
18 //
19
20
21 // system include files
22 #include <memory>
23 #include <vector>
24 #include <string>
25
26 // user include files
27 #include "FWCore/Framework/interface/Frameworkfwd.h"
28 #include "FWCore/Framework/interface/EDAnalyzer.h"
29
30 #include "FWCore/Framework/interface/Event.h"
31 #include "FWCore/Framework/interface/MakerMacros.h"
32
33 #include "FWCore/ParameterSet/interface/ParameterSet.h"
34 #include "CommonTools/UtilAlgos/interface/TFileService.h"
35 #include "FWCore/ServiceRegistry/interface/Service.h"
36 #include "FWCore/Utilities/interface/InputTag.h"
37
38 #include "TTree.h"
39
40 //
41 // class declaration
42 //
43
44 using namespace std;
45
46
47 struct MyBkg{
48 int n;
49 float rho[50];
50 float sigma[50];
51 };
52
53
54 class FastJetAnalyzer : public edm::EDAnalyzer {
55 public:
56 explicit FastJetAnalyzer(const edm::ParameterSet&);
57 ~FastJetAnalyzer();
58
59 static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
60
61
62 private:
63 virtual void beginJob() ;
64 virtual void analyze(const edm::Event&, const edm::EventSetup&);
65 virtual void endJob() ;
66
67 virtual void beginRun(edm::Run const&, edm::EventSetup const&);
68 virtual void endRun(edm::Run const&, edm::EventSetup const&);
69 virtual void beginLuminosityBlock(edm::LuminosityBlock const&, edm::EventSetup const&);
70 virtual void endLuminosityBlock(edm::LuminosityBlock const&, edm::EventSetup const&);
71
72 // ----------member data ---------------------------
73
74
75 vector<string> labels_;
76 vector<MyBkg> bkgs_;
77 vector<TTree*> trees_;
78
79 edm::Service<TFileService> fs;
80
81 };
82
83 //
84 // constants, enums and typedefs
85 //
86
87 //
88 // static data member definitions
89 //
90
91 //
92 // constructors and destructor
93 //
94 FastJetAnalyzer::FastJetAnalyzer(const edm::ParameterSet& iConfig)
95 {
96 //now do what ever initialization is needed
97
98 labels_ = iConfig.getParameter<vector<string> >("algos");
99 bkgs_.reserve(labels_.size());
100
101 }
102
103
104 FastJetAnalyzer::~FastJetAnalyzer()
105 {
106
107 // do anything here that needs to be done at desctruction time
108 // (e.g. close files, deallocate resources etc.)
109
110 }
111
112
113 //
114 // member functions
115 //
116
117 // ------------ method called for each event ------------
118 void
119 FastJetAnalyzer::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup)
120 {
121 using namespace edm;
122
123 for(unsigned int ialgo = 0; ialgo < labels_.size(); ++ialgo){
124
125 edm::Handle<vector<double> > rhos;
126 edm::Handle<vector<double> > sigmas;
127 bkgs_[ialgo].n = rhos->size();
128 for(unsigned int i = 0; i < rhos->size(); ++i){
129 bkgs_[ialgo].rho[i] = (*rhos)[i];
130 bkgs_[ialgo].sigma[i] = (*sigmas)[i];
131 }
132 }
133
134
135 for(unsigned int ialgo = 0; ialgo < labels_.size(); ++ialgo){
136 trees_[ialgo]->Fill();
137 }
138
139
140
141 }
142
143
144 // ------------ method called once each job just before starting event loop ------------
145 void
146 FastJetAnalyzer::beginJob()
147 {
148
149 for(unsigned int ialgo = 0; ialgo < labels_.size(); ++ialgo){
150 MyBkg b;
151 bkgs_.push_back(b);
152 trees_.push_back(fs->make<TTree>(Form("%s",labels_[ialgo].data()),""));
153 trees_[ialgo]->Branch("n",&bkgs_[ialgo].n,"n/I");
154 trees_[ialgo]->Branch("rho",bkgs_[ialgo].rho,"rho[n]/F");
155 trees_[ialgo]->Branch("sigma",bkgs_[ialgo].sigma,"sigma[n]/F");
156 }
157
158 }
159
160 // ------------ method called once each job just after ending the event loop ------------
161 void
162 FastJetAnalyzer::endJob()
163 {
164 }
165
166 // ------------ method called when starting to processes a run ------------
167 void
168 FastJetAnalyzer::beginRun(edm::Run const&, edm::EventSetup const&)
169 {
170 }
171
172 // ------------ method called when ending the processing of a run ------------
173 void
174 FastJetAnalyzer::endRun(edm::Run const&, edm::EventSetup const&)
175 {
176 }
177
178 // ------------ method called when starting to processes a luminosity block ------------
179 void
180 FastJetAnalyzer::beginLuminosityBlock(edm::LuminosityBlock const&, edm::EventSetup const&)
181 {
182 }
183
184 // ------------ method called when ending the processing of a luminosity block ------------
185 void
186 FastJetAnalyzer::endLuminosityBlock(edm::LuminosityBlock const&, edm::EventSetup const&)
187 {
188 }
189
190 // ------------ method fills 'descriptions' with the allowed parameters for the module ------------
191 void
192 FastJetAnalyzer::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
193 //The following says we do not know what parameters are allowed so do no validation
194 // Please change this to state exactly what you do use, even if it is no parameters
195 edm::ParameterSetDescription desc;
196 desc.setUnknown();
197 descriptions.addDefault(desc);
198 }
199
200 //define this as a plug-in
201 DEFINE_FWK_MODULE(FastJetAnalyzer);