Back to home page

Project CMSSW displayed by LXR

 
 

    


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

0001 #include "DQMOffline/PFTau/plugins/PFJetDQMAnalyzer.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/JetReco/interface/CaloJetCollection.h"
0011 #include "DataFormats/JetReco/interface/JetCollection.h"
0012 #include "DataFormats/JetReco/interface/PFJet.h"
0013 #include "DataFormats/ParticleFlowCandidate/interface/PFCandidate.h"
0014 #include "DataFormats/ParticleFlowCandidate/interface/PFCandidateFwd.h"
0015 
0016 #include "DQMServices/Core/interface/DQMStore.h"
0017 
0018 //
0019 // -- Constructor
0020 //
0021 PFJetDQMAnalyzer::PFJetDQMAnalyzer(const edm::ParameterSet &parameterSet)
0022 
0023 {
0024   pSet_ = parameterSet;
0025   inputLabel_ = pSet_.getParameter<edm::InputTag>("InputCollection");
0026   matchLabel_ = pSet_.getParameter<edm::InputTag>("MatchCollection");
0027   benchmarkLabel_ = pSet_.getParameter<std::string>("BenchmarkLabel");
0028 
0029   pfJetMonitor_.setParameters(parameterSet);  // set parameters for booking histograms and validating jet
0030 
0031   myJet_ = consumes<edm::View<reco::Jet>>(inputLabel_);
0032   myMatchedJet_ = consumes<edm::View<reco::Jet>>(matchLabel_);
0033 
0034   std::string folder = benchmarkLabel_;
0035 
0036   subsystemname_ = "ParticleFlow";
0037   eventInfoFolder_ = subsystemname_ + "/" + folder;
0038 
0039   nBadEvents_ = 0;
0040 }
0041 
0042 //
0043 // -- BookHistograms
0044 //
0045 void PFJetDQMAnalyzer::bookHistograms(DQMStore::IBooker &ibooker,
0046                                       edm::Run const & /* iRun */,
0047                                       edm::EventSetup const & /* iSetup */) {
0048   ibooker.setCurrentFolder(eventInfoFolder_);
0049 
0050   edm::LogInfo("PFJetDQMAnalyzer") << " PFJetDQMAnalyzer::bookHistograms "
0051                                    << "Histogram Folder path set to " << eventInfoFolder_;
0052 
0053   pfJetMonitor_.setup(ibooker, pSet_);
0054 }
0055 
0056 //
0057 // -- Analyze
0058 //
0059 void PFJetDQMAnalyzer::analyze(edm::Event const &iEvent, edm::EventSetup const &iSetup) {
0060   edm::Handle<edm::View<reco::Jet>> jetCollection;
0061   iEvent.getByToken(myJet_, jetCollection);
0062 
0063   edm::Handle<edm::View<reco::Jet>> matchedJetCollection;
0064   iEvent.getByToken(myMatchedJet_, matchedJetCollection);
0065 
0066   float maxRes = 0.0;
0067   float minRes = 99.99;
0068   float jetpT = 0.0;
0069   if (jetCollection.isValid() && matchedJetCollection.isValid()) {
0070     pfJetMonitor_.fill(*jetCollection,
0071                        *matchedJetCollection,
0072                        minRes,
0073                        maxRes,
0074                        jetpT,
0075                        pSet_);  // match collections and fill pt eta phi and charge histos for
0076                                 // candidate jet, fill delta_x_VS_y histos for matched couples,
0077                                 // book and fill delta_frac_VS_frac histos for matched couples
0078   }
0079 }
0080 
0081 #include "FWCore/Framework/interface/MakerMacros.h"
0082 DEFINE_FWK_MODULE(PFJetDQMAnalyzer);