00001 #ifndef TOPSINGLELEPTONDQM
00002 #define TOPSINGLELEPTONDQM
00003
00004 #include <string>
00005 #include <vector>
00006
00007 #include "FWCore/Framework/interface/Event.h"
00008 #include "DQMServices/Core/interface/DQMStore.h"
00009 #include "DQMServices/Core/interface/MonitorElement.h"
00010
00011 #include "DataFormats/JetReco/interface/Jet.h"
00012 #include "DQM/Physics/interface/TopDQMHelpers.h"
00013 #include "DataFormats/MuonReco/interface/Muon.h"
00014 #include "DataFormats/Common/interface/ValueMap.h"
00015 #include "DataFormats/METReco/interface/CaloMET.h"
00016 #include "JetMETCorrections/Objects/interface/JetCorrector.h"
00017 #include "DataFormats/EgammaCandidates/interface/GsfElectron.h"
00018
00019
00037 namespace TopSingleLepton {
00038
00039 class MonitorEnsemble {
00040 public:
00042 enum Level{ STANDARD, VERBOSE, DEBUG };
00043
00044 public:
00046 MonitorEnsemble(const char* label, const edm::ParameterSet& cfg);
00048 ~MonitorEnsemble(){};
00049
00051 void book(std::string directory);
00053 void fill(const edm::Event& event, const edm::EventSetup& setup);
00054
00055 private:
00058 std::string monitorPath(const std::string& label) const { return label.substr(label.find(':')+1); };
00061 std::string selectionPath(const std::string& label) const { return label.substr(0, label.find(':')); };
00062
00064 void triggerBinLabels(std::string channel, const std::vector<std::string> labels);
00066 void fill(const edm::Event& event, const edm::TriggerResults& triggerTable, std::string channel, const std::vector<std::string> labels) const;
00067
00069 bool booked(const std::string histName) const { return hists_.find(histName.c_str())!=hists_.end(); };
00071 void fill(const std::string histName, double value) const { if(booked(histName.c_str())) hists_.find(histName.c_str())->second->Fill(value); };
00073 void fill(const std::string histName, double xValue, double yValue) const { if(booked(histName.c_str())) hists_.find(histName.c_str())->second->Fill(xValue, yValue); };
00075 void fill(const std::string histName, double xValue, double yValue, double zValue) const { if(booked(histName.c_str())) hists_.find(histName.c_str())->second->Fill(xValue, yValue, zValue); };
00076
00077 private:
00079 Level verbosity_;
00081 std::string label_;
00083 std::vector<edm::InputTag> mets_;
00085 edm::InputTag elecs_, muons_, jets_;
00086
00088 edm::InputTag triggerTable_;
00091 std::vector<std::string> triggerPaths_;
00092
00094 edm::InputTag electronId_;
00105 int eidPattern_;
00107 StringCutObjectSelector<reco::GsfElectron>* elecIso_;
00109 StringCutObjectSelector<reco::GsfElectron>* elecSelect_;
00110
00112 StringCutObjectSelector<reco::Muon>* muonIso_;
00114 StringCutObjectSelector<reco::Muon>* muonSelect_;
00115
00117 std::string jetCorrector_;
00119 edm::InputTag jetIDLabel_;
00121 StringCutObjectSelector<reco::JetID>* jetIDSelect_;
00124 std::string jetSelect_;
00127 bool includeBTag_;
00129 edm::InputTag btagEff_, btagPur_, btagVtx_;
00131 double btagEffWP_, btagPurWP_, btagVtxWP_;
00133 double lowerEdge_, upperEdge_;
00134
00136 int logged_;
00138 DQMStore* store_;
00140 std::map<std::string,MonitorElement*> hists_;
00141 };
00142
00143 inline void
00144 MonitorEnsemble::triggerBinLabels(std::string channel, const std::vector<std::string> labels)
00145 {
00146 for(unsigned int idx=0; idx<labels.size(); ++idx){
00147 hists_[(channel+"Mon_").c_str()]->setBinLabel( idx+1, "["+monitorPath(labels[idx])+"]", 1);
00148 hists_[(channel+"Eff_").c_str()]->setBinLabel( idx+1, "["+selectionPath(labels[idx])+"]|["+monitorPath(labels[idx])+"]", 1);
00149 }
00150 }
00151
00152 inline void
00153 MonitorEnsemble::fill(const edm::Event& event, const edm::TriggerResults& triggerTable, std::string channel, const std::vector<std::string> labels) const
00154 {
00155 for(unsigned int idx=0; idx<labels.size(); ++idx){
00156 if( accept(event, triggerTable, monitorPath(labels[idx])) ){
00157 fill((channel+"Mon_").c_str(), idx+0.5 );
00158
00159 int evts = hists_.find((channel+"Mon_").c_str())->second->getBinContent(idx+1);
00160 double value = hists_.find((channel+"Eff_").c_str())->second->getBinContent(idx+1);
00161 fill((channel+"Eff_").c_str(), idx+0.5, 1./evts*(accept(event, triggerTable, selectionPath(labels[idx]))-value));
00162 }
00163 }
00164 }
00165
00166 }
00167
00168 #include <utility>
00169
00170 #include "DQM/Physics/interface/TopDQMHelpers.h"
00171 #include "FWCore/Framework/interface/EDAnalyzer.h"
00172 #include "FWCore/Framework/interface/Frameworkfwd.h"
00173 #include "FWCore/ServiceRegistry/interface/Service.h"
00174 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00175
00176 #include "FWCore/Common/interface/TriggerNames.h"
00177 #include "DataFormats/BeamSpot/interface/BeamSpot.h"
00178 #include "DataFormats/VertexReco/interface/Vertex.h"
00179 #include "DataFormats/Common/interface/TriggerResults.h"
00180
00206
00207
00208
00209 class TopSingleLeptonDQM : public edm::EDAnalyzer {
00210 public:
00212 TopSingleLeptonDQM(const edm::ParameterSet& cfg);
00214 ~TopSingleLeptonDQM(){};
00215
00217 virtual void analyze(const edm::Event& event, const edm::EventSetup& setup);
00218
00219 private:
00222 std::string objectType(const std::string& label) { return label.substr(0, label.find(':')); };
00225 std::string selectionStep(const std::string& label) { return label.substr(label.find(':')+1); };
00226
00227 private:
00229 edm::InputTag triggerTable_;
00231 std::vector<std::string> triggerPaths_;
00233 edm::InputTag vertex_;
00235 StringCutObjectSelector<reco::Vertex>* vertexSelect_;
00237 edm::InputTag beamspot_;
00239 StringCutObjectSelector<reco::BeamSpot>* beamspotSelect_;
00240
00243 std::vector<std::string> selectionOrder_;
00249 std::map<std::string, std::pair<edm::ParameterSet, TopSingleLepton::MonitorEnsemble*> > selection_;
00250 };
00251
00252 #endif