Back to home page

Project CMSSW displayed by LXR

 
 

    


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

0001 #include "DQMOffline/PFTau/plugins/PFMuonDQMAnalyzer.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/Candidate/interface/Candidate.h"
0011 #include "DataFormats/Candidate/interface/CandidateFwd.h"
0012 #include "DataFormats/MuonReco/interface/Muon.h"
0013 
0014 #include "DQMServices/Core/interface/DQMStore.h"
0015 //
0016 // -- Constructor
0017 //
0018 PFMuonDQMAnalyzer::PFMuonDQMAnalyzer(const edm::ParameterSet &parameterSet)
0019 
0020 {
0021   pSet_ = parameterSet;
0022   inputLabel_ = pSet_.getParameter<edm::InputTag>("InputCollection");
0023   matchLabel_ = pSet_.getParameter<edm::InputTag>("MatchCollection");
0024   benchmarkLabel_ = pSet_.getParameter<std::string>("BenchmarkLabel");
0025   createEfficiencyHistos_ = pSet_.getParameter<bool>("CreateEfficiencyHistos");
0026 
0027   pfCandidateMonitor_.setParameters(parameterSet);
0028 
0029   myCand_ = consumes<edm::View<reco::Muon>>(inputLabel_);
0030   myMatchedCand_ = consumes<edm::View<reco::Muon>>(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 PFMuonDQMAnalyzer::bookHistograms(DQMStore::IBooker &ibooker,
0044                                        edm::Run const & /* iRun */,
0045                                        edm::EventSetup const & /* iSetup */) {
0046   ibooker.setCurrentFolder(eventInfoFolder_);
0047 
0048   edm::LogInfo("PFMuonDQMAnalyzer") << " PFMuonDQMAnalyzer::bookHistograms "
0049                                     << "Histogram Folder path set to " << eventInfoFolder_;
0050 
0051   pfCandidateMonitor_.setup(ibooker, pSet_);
0052 }
0053 
0054 //
0055 // -- Analyze
0056 //
0057 void PFMuonDQMAnalyzer::analyze(edm::Event const &iEvent, edm::EventSetup const &iSetup) {
0058   edm::Handle<edm::View<reco::Muon>> candCollection;
0059   edm::Handle<edm::View<reco::Muon>> matchedCandCollection;
0060   if (!createEfficiencyHistos_) {
0061     iEvent.getByToken(myCand_, candCollection);
0062     iEvent.getByToken(myMatchedCand_, matchedCandCollection);
0063   } else {
0064     iEvent.getByToken(myMatchedCand_, candCollection);
0065     iEvent.getByToken(myCand_, matchedCandCollection);
0066   }
0067 
0068   float maxRes = 0.0;
0069   float minRes = 99.99;
0070   if (candCollection.isValid() && matchedCandCollection.isValid()) {
0071     pfCandidateMonitor_.fill(*candCollection, *matchedCandCollection, minRes, maxRes, pSet_, *matchedCandCollection);
0072   }
0073 }
0074 
0075 #include "FWCore/Framework/interface/MakerMacros.h"
0076 DEFINE_FWK_MODULE(PFMuonDQMAnalyzer);