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_;
00096 StringCutObjectSelector<reco::GsfElectron>* elecIso_;
00098 StringCutObjectSelector<reco::GsfElectron>* elecSelect_;
00099
00101 StringCutObjectSelector<reco::Muon>* muonIso_;
00103 StringCutObjectSelector<reco::Muon>* muonSelect_;
00104
00106 std::string jetCorrector_;
00108 edm::InputTag jetIDLabel_;
00110 StringCutObjectSelector<reco::JetID>* jetIDSelect_;
00113 std::string jetSelect_;
00116 bool includeBTag_;
00118 edm::InputTag btagEff_, btagPur_, btagVtx_;
00120 double btagEffWP_, btagPurWP_, btagVtxWP_;
00122 double lowerEdge_, upperEdge_;
00123
00125 int logged_;
00127 DQMStore* store_;
00129 std::map<std::string,MonitorElement*> hists_;
00130 };
00131
00132 inline void
00133 MonitorEnsemble::triggerBinLabels(std::string channel, const std::vector<std::string> labels)
00134 {
00135 for(unsigned int idx=0; idx<labels.size(); ++idx){
00136 hists_[(channel+"Mon_").c_str()]->setBinLabel( idx+1, "["+monitorPath(labels[idx])+"]", 1);
00137 hists_[(channel+"Eff_").c_str()]->setBinLabel( idx+1, "["+selectionPath(labels[idx])+"]|["+monitorPath(labels[idx])+"]", 1);
00138 }
00139 }
00140
00141 inline void
00142 MonitorEnsemble::fill(const edm::Event& event, const edm::TriggerResults& triggerTable, std::string channel, const std::vector<std::string> labels) const
00143 {
00144 for(unsigned int idx=0; idx<labels.size(); ++idx){
00145 if( accept(event, triggerTable, monitorPath(labels[idx])) ){
00146 fill((channel+"Mon_").c_str(), idx+0.5 );
00147
00148 int evts = hists_.find((channel+"Mon_").c_str())->second->getBinContent(idx+1);
00149 double value = hists_.find((channel+"Eff_").c_str())->second->getBinContent(idx+1);
00150 fill((channel+"Eff_").c_str(), idx+0.5, 1./evts*(accept(event, triggerTable, selectionPath(labels[idx]))-value));
00151 }
00152 }
00153 }
00154
00155 }
00156
00157 #include <utility>
00158
00159 #include "DQM/Physics/interface/TopDQMHelpers.h"
00160 #include "FWCore/Framework/interface/EDAnalyzer.h"
00161 #include "FWCore/Framework/interface/Frameworkfwd.h"
00162 #include "FWCore/ServiceRegistry/interface/Service.h"
00163 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00164
00165 #include "FWCore/Common/interface/TriggerNames.h"
00166 #include "DataFormats/BeamSpot/interface/BeamSpot.h"
00167 #include "DataFormats/VertexReco/interface/Vertex.h"
00168 #include "DataFormats/Common/interface/TriggerResults.h"
00169
00195
00196
00197
00198 class TopSingleLeptonDQM : public edm::EDAnalyzer {
00199 public:
00201 TopSingleLeptonDQM(const edm::ParameterSet& cfg);
00203 ~TopSingleLeptonDQM(){};
00204
00206 virtual void analyze(const edm::Event& event, const edm::EventSetup& setup);
00207
00208 private:
00211 std::string objectType(const std::string& label) { return label.substr(0, label.find(':')); };
00214 std::string selectionStep(const std::string& label) { return label.substr(label.find(':')+1); };
00215
00216 private:
00218 edm::InputTag triggerTable_;
00220 std::vector<std::string> triggerPaths_;
00222 edm::InputTag vertex_;
00224 StringCutObjectSelector<reco::Vertex>* vertexSelect_;
00226 edm::InputTag beamspot_;
00228 StringCutObjectSelector<reco::BeamSpot>* beamspotSelect_;
00229
00232 std::vector<std::string> selectionOrder_;
00238 std::map<std::string, std::pair<edm::ParameterSet, TopSingleLepton::MonitorEnsemble*> > selection_;
00239 };
00240
00241 #endif