CMS 3D CMS Logo

PFJetBenchmarkAnalyzer.cc

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 //
00003 // Package:    
00004 // Class:   PFJetBenchmarkAnalyzer.cc    
00005 // 
00014 //
00015 // Original Author:  Michel Della Negra
00016 //         Created:  Wed Jan 23 10:11:13 CET 2008
00017 // $Id: PFJetBenchmarkAnalyzer.cc,v 1.4 2008/10/28 15:02:50 pjanot Exp $
00018 // Extensions by Joanna Weng
00019 //
00020 
00021 
00022 // system include files
00023 #include <memory>
00024 
00025 // user include files
00026 #include "FWCore/Framework/interface/Frameworkfwd.h"
00027 #include "FWCore/Framework/interface/EDAnalyzer.h"
00028 
00029 #include "FWCore/Framework/interface/Event.h"
00030 #include "FWCore/Framework/interface/MakerMacros.h"
00031 
00032 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00033 #include "DataFormats/JetReco/interface/Jet.h"
00034 #include "DataFormats/JetReco/interface/CaloJetCollection.h"
00035 #include "DataFormats/JetReco/interface/BasicJetCollection.h"
00036 #include "DataFormats/JetReco/interface/PFJet.h"
00037 #include "DataFormats/JetReco/interface/GenJet.h"
00038 #include "DataFormats/Candidate/interface/Candidate.h"
00039 #include "DataFormats/Candidate/interface/CandidateFwd.h"
00040 #include "RecoParticleFlow/Benchmark/interface/PFJetBenchmark.h"
00041 #include "FWCore/ServiceRegistry/interface/Service.h" 
00042 #include "FWCore/ParameterSet/interface/InputTag.h"
00043 using namespace edm;
00044 using namespace reco;
00045 using namespace std;
00046 
00047 //
00048 // class decleration
00049 
00050  
00051 class PFJetBenchmarkAnalyzer : public edm::EDAnalyzer {
00052 public:
00053   explicit PFJetBenchmarkAnalyzer(const edm::ParameterSet&);
00054   ~PFJetBenchmarkAnalyzer();
00055 
00056 
00057 private:
00058   virtual void beginJob(const edm::EventSetup&) ;
00059   virtual void analyze(const edm::Event&, const edm::EventSetup&);
00060   virtual void endJob() ;
00061   // ----------member data ---------------------------
00062 
00063 };
00065 
00066 //neuhaus - comment
00067 PFJetBenchmark PFJetBenchmark_;
00068 InputTag sGenJetAlgo;
00069 InputTag sJetAlgo;
00070 string outjetfilename;
00071 bool pfjBenchmarkDebug;
00072 bool plotAgainstReco;
00073 bool onlyTwoJets;
00074 double deltaRMax=0.1;
00075 string benchmarkLabel_;
00076 double recPt;
00077 double maxEta;
00078 DQMStore * dbe_;
00079 //
00080 // constants, enums and typedefs
00081 //
00082 
00083 //
00084 // static data member definitions
00085 //
00086 
00087 //
00088 // constructors and destructor
00089 //
00090 PFJetBenchmarkAnalyzer::PFJetBenchmarkAnalyzer(const edm::ParameterSet& iConfig)
00091 
00092 {
00093   //now do what ever initialization is needed
00094   sGenJetAlgo = 
00095     iConfig.getParameter<InputTag>("InputTruthLabel");
00096   sJetAlgo = 
00097     iConfig.getParameter<InputTag>("InputRecoLabel");
00098   outjetfilename = 
00099     iConfig.getUntrackedParameter<string>("OutputFile");
00100   pfjBenchmarkDebug = 
00101     iConfig.getParameter<bool>("pfjBenchmarkDebug");
00102   plotAgainstReco = 
00103     iConfig.getParameter<bool>("PlotAgainstRecoQuantities");
00104   onlyTwoJets = 
00105     iConfig.getParameter<bool>("OnlyTwoJets");
00106   deltaRMax = 
00107     iConfig.getParameter<double>("deltaRMax");    
00108   benchmarkLabel_  = 
00109     iConfig.getParameter<string>("BenchmarkLabel"); 
00110   recPt  = 
00111     iConfig.getParameter<double>("recPt"); 
00112   maxEta = 
00113     iConfig.getParameter<double>("maxEta"); 
00114   
00115   dbe_ = edm::Service<DQMStore>().operator->();
00116 
00117   PFJetBenchmark_.setup(
00118                         outjetfilename, 
00119                         pfjBenchmarkDebug,
00120                         plotAgainstReco,
00121                         onlyTwoJets,
00122                         deltaRMax,
00123                         benchmarkLabel_, 
00124                         recPt, 
00125                         maxEta, 
00126                         dbe_);
00127 }
00128 
00129 
00130 PFJetBenchmarkAnalyzer::~PFJetBenchmarkAnalyzer()
00131 {
00132   // do anything here that needs to be done at desctruction time
00133   // (e.g. close files, deallocate resources etc.)
00134 }
00135 
00136 
00137 //
00138 // member functions
00139 //
00140 
00141 // ------------ method called to for each event  ------------
00142 void
00143 PFJetBenchmarkAnalyzer::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup)
00144 {
00145  // get gen jet collection
00146   Handle<GenJetCollection> genjets;
00147   bool isGen = iEvent.getByLabel(sGenJetAlgo, genjets);
00148   if (!isGen) { 
00149     std::cout << "Warning : no Gen jets in input !" << std::endl;
00150     return;
00151   }
00152 
00153   // get rec PFJet collection
00154   Handle<PFJetCollection> pfjets;
00155   bool isReco = iEvent.getByLabel(sJetAlgo, pfjets);   
00156   if (!isReco) { 
00157     std::cout << "Warning : no PF jets in input !" << std::endl;
00158     return;
00159   }
00160   // Analyse (no "z" in "analyse" : we are in Europe, dammit!) 
00161   PFJetBenchmark_.process(*pfjets, *genjets);
00162 }
00163 
00164 
00165 // ------------ method called once each job just before starting event loop  ------------
00166 void 
00167 PFJetBenchmarkAnalyzer::beginJob(const edm::EventSetup&)
00168 {
00169 
00170 }
00171 
00172 // ------------ method called once each job just after ending the event loop  ------------
00173 void 
00174 PFJetBenchmarkAnalyzer::endJob() {
00175 //  PFJetBenchmark_.save();
00176   PFJetBenchmark_.write();
00177 }
00178 
00179 //define this as a plug-in
00180 DEFINE_FWK_MODULE(PFJetBenchmarkAnalyzer);

Generated on Tue Jun 9 17:49:36 2009 for CMSSW by  doxygen 1.5.4