00001 #ifndef TOPDILEPTONOFFLINEDQM
00002 #define TOPDILEPTONOFFLINEDQM
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/Math/interface/deltaR.h"
00012 #include "DataFormats/JetReco/interface/Jet.h"
00013 #include "DQM/Physics/interface/TopDQMHelpers.h"
00014 #include "DataFormats/MuonReco/interface/Muon.h"
00015 #include "DataFormats/Common/interface/ValueMap.h"
00016 #include "DataFormats/METReco/interface/CaloMET.h"
00017 #include "JetMETCorrections/Objects/interface/JetCorrector.h"
00018 #include "DataFormats/EgammaCandidates/interface/GsfElectron.h"
00019
00037 namespace TopDiLeptonOffline {
00038
00039 class MonitorEnsemble {
00040 public:
00042 enum Level{ STANDARD, VERBOSE, DEBUG };
00045 typedef reco::LeafCandidate::LorentzVector LorentzVector;
00047 enum DecayChannel{ NONE, DIMUON, DIELEC, ELECMU };
00048
00049 public:
00051 MonitorEnsemble(const char* label, const edm::ParameterSet& cfg);
00053 ~MonitorEnsemble(){};
00054
00056 void book(std::string directory);
00058 void fill(const edm::Event& event, const edm::EventSetup& setup);
00059
00060 private:
00063 std::string monitorPath(const std::string& label) const { return label.substr(label.find(':')+1); };
00066 std::string selectionPath(const std::string& label) const { return label.substr(0, label.find(':')); };
00068 DecayChannel decayChannel(const std::vector<const reco::Muon*>& muons, const std::vector<const reco::GsfElectron*>& elecs) const;
00069
00071 void loggerBinLabels(std::string hist);
00073 void triggerBinLabels(std::string channel, const std::vector<std::string> labels);
00075 void fill(const edm::Event& event, const edm::TriggerResults& triggerTable, std::string channel, const std::vector<std::string> labels) const;
00076
00078 bool booked(const std::string histName) const { return hists_.find(histName.c_str())!=hists_.end(); };
00080 void fill(const std::string histName, double value) const { if(booked(histName.c_str())) hists_.find(histName.c_str())->second->Fill(value); };
00082 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); };
00084 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); };
00085
00086 private:
00088 Level verbosity_;
00090 std::string label_;
00092 edm::InputTag elecs_, muons_, jets_;
00094 std::vector<edm::InputTag> mets_;
00095
00097 edm::InputTag triggerTable_;
00100 std::vector<std::string> elecMuPaths_;
00102 std::vector<std::string> diMuonPaths_;
00103
00105 edm::InputTag electronId_;
00116 int eidPattern_;
00118 StringCutObjectSelector<reco::GsfElectron>* elecIso_;
00120 StringCutObjectSelector<reco::GsfElectron>* elecSelect_;
00121
00123 StringCutObjectSelector<reco::Muon>* muonIso_;
00125 StringCutObjectSelector<reco::Muon>* muonSelect_;
00126
00128 std::string jetCorrector_;
00130 edm::InputTag jetIDLabel_;
00132 StringCutObjectSelector<reco::JetID>* jetIDSelect_;
00135 std::string jetSelect_;
00137 double lowerEdge_, upperEdge_;
00138
00140 int elecMuLogged_, diMuonLogged_, diElecLogged_;
00142 DQMStore* store_;
00144 std::map<std::string,MonitorElement*> hists_;
00145 };
00146
00147 inline void
00148 MonitorEnsemble::loggerBinLabels(std::string hist)
00149 {
00150
00151 hists_[hist.c_str()]->getTH1()->SetOption("TEXT");
00152 hists_[hist.c_str()]->setBinLabel( 1 , "Run" , 1);
00153 hists_[hist.c_str()]->setBinLabel( 2 , "Block" , 1);
00154 hists_[hist.c_str()]->setBinLabel( 3 , "Event" , 1);
00155 hists_[hist.c_str()]->setBinLabel( 6 , "pt_{L2L3}(jet1)" , 1);
00156 hists_[hist.c_str()]->setBinLabel( 7 , "pt_{L2L3}(jet2)" , 1);
00157 hists_[hist.c_str()]->setBinLabel( 8 , "MET_{Calo}" , 1);
00158 hists_[hist.c_str()]->setAxisTitle("logged evts" , 2);
00159
00160 if(hist=="diMuonLogger_"){
00161 hists_[hist.c_str()]->setBinLabel( 4 , "pt(muon)" , 1);
00162 hists_[hist.c_str()]->setBinLabel( 5 , "pt(muon)" , 1);
00163 }
00164 if(hist=="diElecLogger_"){
00165 hists_[hist.c_str()]->setBinLabel( 4 , "pt(elec)" , 1);
00166 hists_[hist.c_str()]->setBinLabel( 5 , "pt(elec)" , 1);
00167 }
00168 if(hist=="elecMuLogger_"){
00169 hists_[hist.c_str()]->setBinLabel( 4 , "pt(elec)" , 1);
00170 hists_[hist.c_str()]->setBinLabel( 5 , "pt(muon)" , 1);
00171 }
00172 }
00173
00174 inline void
00175 MonitorEnsemble::triggerBinLabels(std::string channel, const std::vector<std::string> labels)
00176 {
00177 for(unsigned int idx=0; idx<labels.size(); ++idx){
00178 hists_[(channel+"Mon_").c_str()]->setBinLabel( idx+1, "["+monitorPath(labels[idx])+"]", 1);
00179 hists_[(channel+"Eff_").c_str()]->setBinLabel( idx+1, "["+selectionPath(labels[idx])+"]|["+monitorPath(labels[idx])+"]", 1);
00180 }
00181 }
00182
00183 inline void
00184 MonitorEnsemble::fill(const edm::Event& event, const edm::TriggerResults& triggerTable, std::string channel, const std::vector<std::string> labels) const
00185 {
00186 for(unsigned int idx=0; idx<labels.size(); ++idx){
00187 if( accept(event, triggerTable, monitorPath(labels[idx])) ){
00188 fill((channel+"Mon_").c_str(), idx+0.5 );
00189
00190 int evts = hists_.find((channel+"Mon_").c_str())->second->getBinContent(idx+1);
00191 double value = hists_.find((channel+"Eff_").c_str())->second->getBinContent(idx+1);
00192 fill((channel+"Eff_").c_str(), idx+0.5, 1./evts*(accept(event, triggerTable, selectionPath(labels[idx]))-value));
00193 }
00194 }
00195 }
00196
00197 inline MonitorEnsemble::DecayChannel
00198 MonitorEnsemble::decayChannel(const std::vector<const reco::Muon*>& muons, const std::vector<const reco::GsfElectron*>& elecs) const
00199 {
00200 DecayChannel type=NONE;
00201 if( muons.size()>1 ){ type=DIMUON; } else if( elecs.size()>1 ){ type=DIELEC; } else if( !elecs.empty() && !muons.empty() ){ type=ELECMU; }
00202 return type;
00203 }
00204
00205 }
00206
00207 #include <utility>
00208
00209 #include "FWCore/Framework/interface/EDAnalyzer.h"
00210 #include "FWCore/Framework/interface/Frameworkfwd.h"
00211 #include "FWCore/ServiceRegistry/interface/Service.h"
00212 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00213
00214 #include "FWCore/Common/interface/TriggerNames.h"
00215 #include "DataFormats/BeamSpot/interface/BeamSpot.h"
00216 #include "DataFormats/VertexReco/interface/Vertex.h"
00217 #include "DataFormats/Common/interface/TriggerResults.h"
00218
00244
00245
00246
00247 class TopDiLeptonOfflineDQM : public edm::EDAnalyzer {
00248 public:
00250 TopDiLeptonOfflineDQM(const edm::ParameterSet& cfg);
00252 ~TopDiLeptonOfflineDQM(){};
00253
00255 virtual void analyze(const edm::Event& event, const edm::EventSetup& setup);
00256
00257 private:
00260 std::string objectType(const std::string& label) { return label.substr(0, label.find(':')); };
00263 std::string selectionStep(const std::string& label) { return label.substr(label.find(':')+1); };
00264
00265 private:
00267 edm::InputTag triggerTable_;
00269 std::vector<std::string> triggerPaths_;
00271 edm::InputTag vertex_;
00273 StringCutObjectSelector<reco::Vertex>* vertexSelect_;
00275 edm::InputTag beamspot_;
00277 StringCutObjectSelector<reco::BeamSpot>* beamspotSelect_;
00278
00281 std::vector<std::string> selectionOrder_;
00287 std::map<std::string, std::pair<edm::ParameterSet, TopDiLeptonOffline::MonitorEnsemble*> > selection_;
00288 };
00289
00290 #endif