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