CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_1/src/Validation/RecoParticleFlow/plugins/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.3 2010/02/20 21:02:43 wmtan 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/Utilities/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() ;
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, 
00144                                 const edm::EventSetup& iSetup)
00145 {
00146  // get gen jet collection
00147   Handle<GenJetCollection> genjets;
00148   bool isGen = iEvent.getByLabel(sGenJetAlgo, genjets);
00149   if (!isGen) { 
00150     std::cout << "Warning : no Gen jets in input !" << std::endl;
00151     return;
00152   }
00153 
00154   // get rec PFJet collection
00155   Handle<PFJetCollection> pfjets;
00156   bool isReco = iEvent.getByLabel(sJetAlgo, pfjets);   
00157   if (!isReco) { 
00158     std::cout << "Warning : no PF jets in input !" << std::endl;
00159     return;
00160   }
00161   // Analyse (no "z" in "analyse" : we are in Europe, dammit!) 
00162   PFJetBenchmark_.process(*pfjets, *genjets);
00163 }
00164 
00165 
00166 // ------------ method called once each job just before starting event loop  ------------
00167 void 
00168 PFJetBenchmarkAnalyzer::beginJob()
00169 {
00170 
00171 }
00172 
00173 // ------------ method called once each job just after ending the event loop  ------------
00174 void 
00175 PFJetBenchmarkAnalyzer::endJob() {
00176 //  PFJetBenchmark_.save();
00177   PFJetBenchmark_.write();
00178 }
00179 
00180 //define this as a plug-in
00181 DEFINE_FWK_MODULE(PFJetBenchmarkAnalyzer);