File indexing completed on 2023-03-17 11:28:41
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021 #include <memory>
0022
0023
0024 #include "FWCore/Framework/interface/one/EDAnalyzer.h"
0025 #include "FWCore/Framework/interface/Frameworkfwd.h"
0026
0027 #include "FWCore/Framework/interface/Event.h"
0028 #include "FWCore/Framework/interface/MakerMacros.h"
0029
0030 #include "DQMServices/Core/interface/DQMStore.h"
0031 #include "DataFormats/Candidate/interface/Candidate.h"
0032 #include "DataFormats/Candidate/interface/CandidateFwd.h"
0033 #include "DataFormats/HepMCCandidate/interface/GenParticle.h"
0034 #include "DataFormats/HepMCCandidate/interface/GenParticleFwd.h"
0035 #include "DataFormats/METReco/interface/CaloMET.h"
0036 #include "DataFormats/METReco/interface/CaloMETCollection.h"
0037 #include "DataFormats/METReco/interface/GenMET.h"
0038 #include "DataFormats/METReco/interface/MET.h"
0039 #include "DataFormats/METReco/interface/PFMET.h"
0040 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0041 #include "FWCore/ServiceRegistry/interface/Service.h"
0042 #include "FWCore/Utilities/interface/InputTag.h"
0043 #include "RecoParticleFlow/Benchmark/interface/PFMETBenchmark.h"
0044 using namespace edm;
0045 using namespace reco;
0046 using namespace std;
0047
0048
0049
0050
0051 class PFMETBenchmarkAnalyzer : public edm::one::EDAnalyzer<> {
0052 public:
0053 typedef dqm::legacy::DQMStore DQMStore;
0054 typedef dqm::legacy::MonitorElement MonitorElement;
0055
0056 explicit PFMETBenchmarkAnalyzer(const edm::ParameterSet &);
0057 ~PFMETBenchmarkAnalyzer() override;
0058
0059 private:
0060 void beginJob() override;
0061 void analyze(const edm::Event &, const edm::EventSetup &) override;
0062 void endJob() override;
0063
0064 edm::EDGetTokenT<reco::GenParticleCollection> sInputTruthLabel_tok_;
0065 edm::EDGetTokenT<reco::PFMETCollection> sInputRecoLabel_tok_;
0066 edm::EDGetTokenT<reco::CaloMETCollection> sInputCaloLabel_tok_;
0067 edm::EDGetTokenT<reco::METCollection> sInputTCLabel_tok_;
0068
0069
0070 PFMETBenchmark PFMETBenchmark_;
0071 string OutputFileName;
0072 bool pfmBenchmarkDebug;
0073 bool xplotAgainstReco;
0074 string xbenchmarkLabel_;
0075 dqm::legacy::DQMStore *xdbe_;
0076 };
0077
0078
0079
0080
0081
0082
0083
0084
0085
0086
0087
0088
0089
0090 PFMETBenchmarkAnalyzer::PFMETBenchmarkAnalyzer(const edm::ParameterSet &iConfig)
0091
0092 {
0093
0094 sInputTruthLabel_tok_ = consumes<reco::GenParticleCollection>(iConfig.getParameter<InputTag>("InputTruthLabel"));
0095 sInputRecoLabel_tok_ = consumes<reco::PFMETCollection>(iConfig.getParameter<InputTag>("InputRecoLabel"));
0096 sInputCaloLabel_tok_ = consumes<reco::CaloMETCollection>(iConfig.getParameter<InputTag>("InputCaloLabel"));
0097 sInputTCLabel_tok_ = consumes<reco::METCollection>(iConfig.getParameter<InputTag>("InputTCLabel"));
0098 OutputFileName = iConfig.getUntrackedParameter<string>("OutputFile");
0099 pfmBenchmarkDebug = iConfig.getParameter<bool>("pfjBenchmarkDebug");
0100 xplotAgainstReco = iConfig.getParameter<bool>("PlotAgainstRecoQuantities");
0101 xbenchmarkLabel_ = iConfig.getParameter<string>("BenchmarkLabel");
0102 xdbe_ = edm::Service<DQMStore>().operator->();
0103
0104 PFMETBenchmark_.setup(OutputFileName, pfmBenchmarkDebug, xplotAgainstReco, xbenchmarkLabel_, xdbe_);
0105 }
0106
0107 PFMETBenchmarkAnalyzer::~PFMETBenchmarkAnalyzer() {
0108
0109
0110 }
0111
0112
0113
0114
0115
0116
0117 void PFMETBenchmarkAnalyzer::analyze(const edm::Event &iEvent, const edm::EventSetup &iSetup) {
0118
0119 Handle<GenParticleCollection> genparticles;
0120 bool isGen = iEvent.getByToken(sInputTruthLabel_tok_, genparticles);
0121 if (!isGen) {
0122 std::cout << "Warning : no Gen Particles in input !" << std::endl;
0123 return;
0124 }
0125
0126
0127 Handle<PFMETCollection> pfmets;
0128 bool isReco = iEvent.getByToken(sInputRecoLabel_tok_, pfmets);
0129 if (!isReco) {
0130 std::cout << "Warning : no PF MET in input !" << std::endl;
0131 return;
0132 }
0133
0134
0135 Handle<METCollection> tcmets;
0136 bool isTC = iEvent.getByToken(sInputTCLabel_tok_, tcmets);
0137 if (!isTC) {
0138 std::cout << "Warning : no TC MET in input !" << std::endl;
0139 return;
0140 }
0141
0142 Handle<CaloMETCollection> calomets;
0143 bool isCalo = iEvent.getByToken(sInputCaloLabel_tok_, calomets);
0144 if (!isCalo) {
0145 std::cout << "Warning : no Calo MET in input !" << std::endl;
0146 return;
0147 }
0148
0149
0150 PFMETBenchmark_.process(*pfmets, *genparticles, *calomets, *tcmets);
0151 }
0152
0153
0154
0155 void PFMETBenchmarkAnalyzer::beginJob() {}
0156
0157
0158
0159 void PFMETBenchmarkAnalyzer::endJob() {
0160
0161 PFMETBenchmark_.analyse();
0162 PFMETBenchmark_.write();
0163 }
0164
0165
0166 DEFINE_FWK_MODULE(PFMETBenchmarkAnalyzer);