ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/auterman/RA2/FinalPlots/src/FinalPlots.cc
Revision: 1.1.1.1 (vendor branch)
Committed: Mon Oct 19 08:25:35 2009 UTC (15 years, 6 months ago) by auterman
Content type: text/plain
Branch: FinalPlots
CVS Tags: start
Changes since 1.1: +0 -0 lines
Log Message:
new project

File Contents

# User Rev Content
1 auterman 1.1 // -*- C++ -*-
2     //
3     // Package: FinalPlots
4     // Class: FinalPlots
5     //
6     /**\class FinalPlots FinalPlots.cc RA2/FinalPlots/src/FinalPlots.cc
7    
8     Description: <one line class summary>
9    
10     Implementation:
11     <Notes on implementation>
12     */
13     //
14     // Original Author: Christian Autermann,68/112,2115,
15     // Created: Sun Oct 18 20:00:45 CEST 2009
16     // $Id$
17     //
18     //
19    
20    
21     // system include files
22     #include <memory>
23     #include <string>
24     #include <cmath>
25    
26     // user include files
27     #include "FWCore/Framework/interface/Frameworkfwd.h"
28     #include "FWCore/Framework/interface/EDAnalyzer.h"
29     #include "FWCore/Framework/interface/Event.h"
30     #include "FWCore/Framework/interface/MakerMacros.h"
31     #include "FWCore/ParameterSet/interface/ParameterSet.h"
32     #include "DataFormats/Math/interface/LorentzVector.h"
33     #include "DataFormats/METReco/interface/CaloMET.h"
34     #include "DataFormats/METReco/interface/MET.h"
35     #include "DataFormats/JetReco/interface/CaloJet.h"
36     #include "DataFormats/Candidate/interface/Candidate.h"
37     #include "FWCore/ServiceRegistry/interface/Service.h"
38     #include "PhysicsTools/UtilAlgos/interface/TFileService.h"
39    
40     #include "TH1F.h"
41     //
42     // class decleration
43     //
44    
45     class FinalPlots : public edm::EDAnalyzer {
46     public:
47     explicit FinalPlots(const edm::ParameterSet&);
48     ~FinalPlots();
49    
50    
51     private:
52     virtual void beginJob(const edm::EventSetup&);
53     virtual void analyze(const edm::Event&, const edm::EventSetup&);
54     virtual void endJob() ;
55    
56     // ----------member data ---------------------------
57    
58     edm::InputTag Jet_;
59     edm::InputTag Met_;
60     std::string name_;
61    
62     TH1F * HT_;
63     TH1F * MHT_;
64     TH1F * MET_;
65     };
66    
67     FinalPlots::FinalPlots(const edm::ParameterSet& iConfig):
68     Jet_( iConfig.getParameter<edm::InputTag>("Jet") ),
69     Met_( iConfig.getParameter<edm::InputTag>("MET") ),
70     name_( iConfig.getParameter<std::string>("uncertainty_name") )
71     {
72     }
73    
74     // ------------ method called once each job just before starting event loop ------------
75     void
76     FinalPlots::beginJob(const edm::EventSetup&)
77     {
78     edm::Service<TFileService> fs;
79     if( !fs ){
80     throw edm::Exception( edm::errors::Configuration,
81     "TFile Service is not registered in cfg file" );
82     }
83    
84     std::string histname = "HT_"+name_;
85     HT_ = fs->make<TH1F>(histname.c_str(),";HT [GeV];events", 100, 0.0, 500.0);
86    
87     histname = "MHT_"+name_;
88     MHT_ = fs->make<TH1F>(histname.c_str(),";MHT [GeV];events", 100, 0.0, 500.0);
89    
90     histname = "MET_"+name_;
91     MET_ = fs->make<TH1F>(histname.c_str(),";MET [GeV];events", 100, 0.0, 500.0);
92     }
93    
94    
95     FinalPlots::~FinalPlots()
96     {
97    
98     // do anything here that needs to be done at desctruction time
99     // (e.g. close files, deallocate resources etc.)
100    
101     }
102    
103    
104     //
105     // member functions
106     //
107    
108     // ------------ method called to for each event ------------
109     void
110     FinalPlots::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup)
111     {
112     using namespace edm;
113     using namespace std;
114    
115     edm::Handle<edm::View<reco::Candidate> > jet_hnd;
116     iEvent.getByLabel(Jet_, jet_hnd);
117    
118     edm::Handle<edm::View<reco::MET> > met_hnd;
119     iEvent.getByLabel(Met_, met_hnd);
120    
121     MET_->Fill( met_hnd->begin()->pt() );
122    
123     double ht=0.0;
124     math::PtEtaPhiMLorentzVector htvec(0.0, 0.0, 0.0, 0.0);
125     for (edm::View<reco::Candidate>::const_iterator jet=jet_hnd->begin();
126     jet!=jet_hnd->end(); ++jet){
127     if ( fabs(jet->eta())>3.0 ) continue;
128     if ( jet->pt()<30. ) continue;
129     htvec += jet->p4();
130     ht+=jet->pt();
131     }
132     HT_ ->Fill( ht );
133     MHT_->Fill( htvec.pt() );
134    
135     //other variables
136     //MPT...
137    
138    
139     }
140    
141    
142     // ------------ method called once each job just after ending the event loop ------------
143     void
144     FinalPlots::endJob() {
145     }
146    
147     //define this as a plug-in
148     DEFINE_FWK_MODULE(FinalPlots);