00001 #include "Validation/RecoParticleFlow/interface/GenericBenchmarkAnalyzer.h"
00002
00003
00004
00005
00006
00007
00008 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00009 #include "FWCore/ServiceRegistry/interface/Service.h"
00010
00011 #include "FWCore/Framework/interface/Event.h"
00012 #include "DataFormats/Common/interface/Handle.h"
00013 #include "FWCore/Framework/interface/ESHandle.h"
00014 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00015 #include "FWCore/ParameterSet/interface/InputTag.h"
00016
00017
00018 #include "DataFormats/Candidate/interface/CandidateFwd.h"
00019 #include "DataFormats/Candidate/interface/Candidate.h"
00020
00021 #include "DQMServices/Core/interface/DQMStore.h"
00022
00023 #include "DataFormats/ParticleFlowCandidate/interface/PFCandidateFwd.h"
00024 #include "DataFormats/ParticleFlowCandidate/interface/PFCandidate.h"
00025
00026 #include <vector>
00027 #include <ostream>
00028 #include <fstream>
00029 #include <iostream>
00030 #include <algorithm>
00031 #include <cmath>
00032 #include <memory>
00033
00034 using namespace reco;
00035 using namespace edm;
00036 using namespace std;
00037
00038 GenericBenchmarkAnalyzer::GenericBenchmarkAnalyzer(const edm::ParameterSet& iConfig)
00039 {
00040
00041 inputTruthLabel_ = iConfig.getParameter<edm::InputTag>("InputTruthLabel");
00042 inputRecoLabel_ = iConfig.getParameter<edm::InputTag>("InputRecoLabel");
00043 outputFile_ = iConfig.getUntrackedParameter<std::string>("OutputFile");
00044 benchmarkLabel_ = iConfig.getParameter<std::string>("BenchmarkLabel");
00045 plotAgainstRecoQuantities_ = iConfig.getParameter<bool>("PlotAgainstRecoQuantities");
00046 onlyTwoJets_ = iConfig.getParameter<bool>("OnlyTwoJets");
00047 recPt_cut = iConfig.getParameter<double>("recPt");
00048 maxEta_cut = iConfig.getParameter<double>("maxEta");
00049 deltaR_cut = iConfig.getParameter<double>("deltaRMax");
00050
00051 if (outputFile_.size() > 0)
00052 edm::LogInfo("OutputInfo") << " ParticleFLow Task histograms will be saved to '" << outputFile_.c_str()<< "'";
00053 else edm::LogInfo("OutputInfo") << " ParticleFlow Task histograms will NOT be saved";
00054
00055 }
00056
00057 GenericBenchmarkAnalyzer::~GenericBenchmarkAnalyzer() { }
00058
00059 void GenericBenchmarkAnalyzer::beginJob(const edm::EventSetup& iSetup)
00060 {
00061
00062
00063 dbe_ = edm::Service<DQMStore>().operator->();
00064
00065 if (dbe_) {
00066
00067 string path = "PFTask/Benchmarks/" + benchmarkLabel_ + "/";
00068 if (plotAgainstRecoQuantities_) path += "Reco"; else path += "Gen";
00069 dbe_->setCurrentFolder(path.c_str());
00070 setup(dbe_, plotAgainstRecoQuantities_);
00071
00072 }
00073
00074 }
00075
00076 void GenericBenchmarkAnalyzer::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup)
00077 {
00078
00079
00080 typedef edm::View<reco::Candidate> candidateCollection ;
00081 typedef edm::View<reco::Candidate> candidateCollection ;
00082
00083 const candidateCollection *truth_candidates;
00084 const candidateCollection *reco_candidates;
00085
00086
00087
00088
00089
00090 {
00091
00092 Handle<candidateCollection> truth_hnd;
00093 bool isGen = iEvent.getByLabel(inputTruthLabel_, truth_hnd);
00094 if ( !isGen ) {
00095 std::cout << "Warning : no Gen jets in input !" << std::endl;
00096 return;
00097 }
00098
00099 truth_candidates = truth_hnd.product();
00100
00101
00102 Handle<candidateCollection> reco_hnd;
00103 bool isReco = iEvent.getByLabel(inputRecoLabel_, reco_hnd);
00104 if ( !isReco ) {
00105 std::cout << "Warning : no Reco jets in input !" << std::endl;
00106 return;
00107 }
00108 reco_candidates = reco_hnd.product();
00109
00110
00111
00112
00113
00114
00115 }
00116 if (!truth_candidates || !reco_candidates) {
00117
00118 edm::LogInfo("OutputInfo") << " failed to retrieve data required by ParticleFlow Task";
00119 edm::LogInfo("OutputInfo") << " ParticleFlow Task cannot continue...!";
00120 return;
00121
00122 }
00123
00124
00125
00126
00127
00128 fill(reco_candidates,truth_candidates,plotAgainstRecoQuantities_, onlyTwoJets_, recPt_cut, maxEta_cut, deltaR_cut);
00129
00130 }
00131
00132 void GenericBenchmarkAnalyzer::endJob()
00133 {
00134
00135
00136 if (outputFile_.size() != 0)
00137 dbe_->save(outputFile_);
00138 }