Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:09:44

0001 #include "DQMOffline/PFTau/plugins/PFMETDQMAnalyzer.h"
0002 
0003 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0004 
0005 #include "DataFormats/Common/interface/Handle.h"
0006 #include "FWCore/Framework/interface/Event.h"
0007 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0008 #include "FWCore/Utilities/interface/InputTag.h"
0009 
0010 #include "DataFormats/METReco/interface/MET.h"
0011 #include "DataFormats/ParticleFlowCandidate/interface/PFCandidate.h"
0012 #include "DataFormats/ParticleFlowCandidate/interface/PFCandidateFwd.h"
0013 
0014 #include "DQMServices/Core/interface/DQMStore.h"
0015 
0016 //
0017 // -- Constructor
0018 //
0019 PFMETDQMAnalyzer::PFMETDQMAnalyzer(const edm::ParameterSet &parameterSet)
0020 
0021 {
0022   pSet_ = parameterSet;
0023   inputLabel_ = pSet_.getParameter<edm::InputTag>("InputCollection");
0024   matchLabel_ = pSet_.getParameter<edm::InputTag>("MatchCollection");
0025   benchmarkLabel_ = pSet_.getParameter<std::string>("BenchmarkLabel");
0026 
0027   pfMETMonitor_.setParameters(parameterSet);
0028 
0029   myMET_ = consumes<edm::View<reco::MET>>(inputLabel_);
0030   myMatchedMET_ = consumes<edm::View<reco::MET>>(matchLabel_);
0031 
0032   std::string folder = benchmarkLabel_;
0033 
0034   subsystemname_ = "ParticleFlow";
0035   eventInfoFolder_ = subsystemname_ + "/" + folder;
0036 
0037   nBadEvents_ = 0;
0038 }
0039 
0040 //
0041 // -- BookHistograms
0042 //
0043 void PFMETDQMAnalyzer::bookHistograms(DQMStore::IBooker &ibooker,
0044                                       edm::Run const & /* iRun */,
0045                                       edm::EventSetup const & /* iSetup */) {
0046   ibooker.setCurrentFolder(eventInfoFolder_);
0047 
0048   edm::LogInfo("PFMETDQMAnalyzer") << " PFMETDQMAnalyzer::bookHistograms "
0049                                    << "Histogram Folder path set to " << eventInfoFolder_;
0050 
0051   pfMETMonitor_.setup(ibooker, pSet_);
0052 }
0053 
0054 //
0055 // -- Analyze
0056 //
0057 void PFMETDQMAnalyzer::analyze(edm::Event const &iEvent, edm::EventSetup const &iSetup) {
0058   edm::Handle<edm::View<reco::MET>> metCollection;
0059   iEvent.getByToken(myMET_, metCollection);
0060 
0061   edm::Handle<edm::View<reco::MET>> matchedMetCollection;
0062   iEvent.getByToken(myMatchedMET_, matchedMetCollection);
0063 
0064   if (metCollection.isValid() && matchedMetCollection.isValid()) {
0065     float maxRes = 0.0;
0066     float minRes = 99.99;
0067     pfMETMonitor_.fillOne((*metCollection)[0], (*matchedMetCollection)[0], minRes, maxRes);
0068   }
0069 }
0070 
0071 #include "FWCore/Framework/interface/MakerMacros.h"
0072 DEFINE_FWK_MODULE(PFMETDQMAnalyzer);