CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_4_1_8_patch13/src/DQMOffline/PFTau/plugins/PFJetDQMAnalyzer.cc

Go to the documentation of this file.
00001 #include "DQMOffline/PFTau/plugins/PFJetDQMAnalyzer.h"
00002 
00003 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00004 
00005 #include "FWCore/Framework/interface/Event.h"
00006 #include "DataFormats/Common/interface/Handle.h"
00007 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00008 #include "FWCore/Utilities/interface/InputTag.h"
00009 
00010 #include "DataFormats/ParticleFlowCandidate/interface/PFCandidateFwd.h"
00011 #include "DataFormats/ParticleFlowCandidate/interface/PFCandidate.h"
00012 #include "DataFormats/JetReco/interface/CaloJetCollection.h"
00013 #include "DataFormats/JetReco/interface/JetCollection.h"
00014 #include "DataFormats/JetReco/interface/PFJet.h"
00015 
00016 #include "DQMServices/Core/interface/DQMStore.h"
00017 #include "DQMServices/Core/interface/MonitorElement.h"
00018 #include "FWCore/ServiceRegistry/interface/Service.h"
00019 //
00020 // -- Constructor
00021 //
00022 PFJetDQMAnalyzer::PFJetDQMAnalyzer(const edm::ParameterSet& parameterSet)  
00023   
00024 {
00025   pSet_                = parameterSet;
00026   inputLabel_          = pSet_.getParameter<edm::InputTag>("InputCollection");
00027   matchLabel_          = pSet_.getParameter<edm::InputTag>("MatchCollection");
00028   benchmarkLabel_      = pSet_.getParameter<std::string>("BenchmarkLabel"); 
00029 
00030   pfJetMonitor_.setParameters(parameterSet);  
00031   
00032 }
00033 //
00034 // -- BeginJob
00035 //
00036 void PFJetDQMAnalyzer::beginJob() {
00037 
00038   Benchmark::DQM_ = edm::Service<DQMStore>().operator->();
00039   // part of the following could be put in the base class
00040   std::string path = "ParticleFlow/" + benchmarkLabel_;
00041   Benchmark::DQM_->setCurrentFolder(path.c_str());
00042   edm::LogInfo("PFJetDQMAnalyzer") << " PFJetDQMAnalyzer::beginJob " << "Histogram Folder path set to "<< path;
00043   pfJetMonitor_.setup(pSet_);  
00044 
00045 }
00046 //
00047 // -- Analyze
00048 //
00049 void PFJetDQMAnalyzer::analyze(edm::Event const& iEvent, 
00050                                       edm::EventSetup const& iSetup) {
00051   edm::Handle< edm::View<reco::Jet> > jetCollection;
00052   iEvent.getByLabel(inputLabel_, jetCollection);   
00053   
00054   edm::Handle< edm::View<reco::Jet> > matchedJetCollection; 
00055   iEvent.getByLabel( matchLabel_, matchedJetCollection);
00056 
00057   float maxRes = 0.0;
00058   float minRes = 99.99;
00059   if (jetCollection.isValid() && matchedJetCollection.isValid()) {
00060     pfJetMonitor_.fill( *jetCollection, *matchedJetCollection, minRes, maxRes);
00061     
00062     edm::ParameterSet skimPS = pSet_.getParameter<edm::ParameterSet>("SkimParameter");
00063     if (skimPS.getParameter<bool>("switchOn")) {
00064       if ( minRes < skimPS.getParameter<double>("lowerCutOffOnResolution")) storeBadEvents(iEvent,minRes);
00065       else if (maxRes > skimPS.getParameter<double>("upperCutOffOnResolution")) storeBadEvents(iEvent,maxRes);
00066     }
00067   }
00068 }
00069 void PFJetDQMAnalyzer::storeBadEvents(edm::Event const& iEvent, float& val) {
00070   unsigned int runNb  = iEvent.id().run();
00071   unsigned int evtNb  = iEvent.id().event();
00072   unsigned int lumiNb = iEvent.id().luminosityBlock();
00073   
00074   std::string path = "ParticleFlow/" + benchmarkLabel_ + "/BadEvents";
00075   Benchmark::DQM_->setCurrentFolder(path.c_str());
00076   std::ostringstream eventid_str;
00077   eventid_str << runNb << "_"<< evtNb << "_" << lumiNb;
00078   MonitorElement* me = Benchmark::DQM_->get(path + "/" + eventid_str.str());
00079   if (me) me->Reset();
00080   else me = Benchmark::DQM_->bookFloat(eventid_str.str());
00081   me->Fill(val);  
00082 }
00083 //
00084 // -- EndJob
00085 // 
00086 void PFJetDQMAnalyzer::endJob() {
00087 }
00088 #include "FWCore/Framework/interface/MakerMacros.h"
00089 DEFINE_FWK_MODULE (PFJetDQMAnalyzer) ;