ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/CmsHi/JetAnalysis/src/FastJetAnalyzer.cc
Revision: 1.2
Committed: Wed Feb 13 18:53:32 2013 UTC (12 years, 2 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_73, HEAD
Changes since 1.1: +4 -1 lines
Log Message:
rho analyzer

File Contents

# User Rev Content
1 yilmaz 1.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 yilmaz 1.2 // $Id: FastJetAnalyzer.cc,v 1.1 2013/02/13 18:51:07 yilmaz Exp $
17 yilmaz 1.1 //
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 yilmaz 1.2 iEvent.getByLabel(edm::InputTag(labels_[ialgo].data(),"rhos"),rhos);
128     iEvent.getByLabel(edm::InputTag(labels_[ialgo].data(),"sigmas"),sigmas);
129    
130 yilmaz 1.1 bkgs_[ialgo].n = rhos->size();
131     for(unsigned int i = 0; i < rhos->size(); ++i){
132     bkgs_[ialgo].rho[i] = (*rhos)[i];
133     bkgs_[ialgo].sigma[i] = (*sigmas)[i];
134     }
135     }
136    
137    
138     for(unsigned int ialgo = 0; ialgo < labels_.size(); ++ialgo){
139     trees_[ialgo]->Fill();
140     }
141    
142    
143    
144     }
145    
146    
147     // ------------ method called once each job just before starting event loop ------------
148     void
149     FastJetAnalyzer::beginJob()
150     {
151    
152     for(unsigned int ialgo = 0; ialgo < labels_.size(); ++ialgo){
153     MyBkg b;
154     bkgs_.push_back(b);
155     trees_.push_back(fs->make<TTree>(Form("%s",labels_[ialgo].data()),""));
156     trees_[ialgo]->Branch("n",&bkgs_[ialgo].n,"n/I");
157     trees_[ialgo]->Branch("rho",bkgs_[ialgo].rho,"rho[n]/F");
158     trees_[ialgo]->Branch("sigma",bkgs_[ialgo].sigma,"sigma[n]/F");
159     }
160    
161     }
162    
163     // ------------ method called once each job just after ending the event loop ------------
164     void
165     FastJetAnalyzer::endJob()
166     {
167     }
168    
169     // ------------ method called when starting to processes a run ------------
170     void
171     FastJetAnalyzer::beginRun(edm::Run const&, edm::EventSetup const&)
172     {
173     }
174    
175     // ------------ method called when ending the processing of a run ------------
176     void
177     FastJetAnalyzer::endRun(edm::Run const&, edm::EventSetup const&)
178     {
179     }
180    
181     // ------------ method called when starting to processes a luminosity block ------------
182     void
183     FastJetAnalyzer::beginLuminosityBlock(edm::LuminosityBlock const&, edm::EventSetup const&)
184     {
185     }
186    
187     // ------------ method called when ending the processing of a luminosity block ------------
188     void
189     FastJetAnalyzer::endLuminosityBlock(edm::LuminosityBlock const&, edm::EventSetup const&)
190     {
191     }
192    
193     // ------------ method fills 'descriptions' with the allowed parameters for the module ------------
194     void
195     FastJetAnalyzer::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
196     //The following says we do not know what parameters are allowed so do no validation
197     // Please change this to state exactly what you do use, even if it is no parameters
198     edm::ParameterSetDescription desc;
199     desc.setUnknown();
200     descriptions.addDefault(desc);
201     }
202    
203     //define this as a plug-in
204     DEFINE_FWK_MODULE(FastJetAnalyzer);