CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_0/src/DQM/Physics/src/TopSingleLeptonDQM.h

Go to the documentation of this file.
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 #include "DataFormats/VertexReco/interface/Vertex.h"
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_, pvs_; 
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::Vertex>* pvSelect_;
00113     
00115     StringCutObjectSelector<reco::Muon>* muonIso_;
00117     StringCutObjectSelector<reco::Muon>* muonSelect_;
00118 
00120     std::string jetCorrector_;
00122     edm::InputTag jetIDLabel_;
00124     StringCutObjectSelector<reco::JetID>* jetIDSelect_;
00127     std::string jetSelect_;
00130     bool includeBTag_;
00132     edm::InputTag btagEff_, btagPur_, btagVtx_;
00134     double btagEffWP_, btagPurWP_, btagVtxWP_;
00136     double lowerEdge_, upperEdge_;
00137 
00139     int logged_;
00141     DQMStore* store_;
00143     std::map<std::string,MonitorElement*> hists_;
00144   };
00145 
00146   inline void 
00147   MonitorEnsemble::triggerBinLabels(std::string channel, const std::vector<std::string> labels)
00148   {
00149     for(unsigned int idx=0; idx<labels.size(); ++idx){
00150       hists_[(channel+"Mon_").c_str()]->setBinLabel( idx+1, "["+monitorPath(labels[idx])+"]", 1);
00151       hists_[(channel+"Eff_").c_str()]->setBinLabel( idx+1, "["+selectionPath(labels[idx])+"]|["+monitorPath(labels[idx])+"]", 1);
00152     }
00153   }
00154 
00155   inline void 
00156   MonitorEnsemble::fill(const edm::Event& event, const edm::TriggerResults& triggerTable, std::string channel, const std::vector<std::string> labels) const
00157   {
00158     for(unsigned int idx=0; idx<labels.size(); ++idx){
00159       if( accept(event, triggerTable, monitorPath(labels[idx])) ){
00160         fill((channel+"Mon_").c_str(), idx+0.5 );
00161         // take care to fill triggerMon_ before evts is being called
00162         int evts = hists_.find((channel+"Mon_").c_str())->second->getBinContent(idx+1);
00163         double value = hists_.find((channel+"Eff_").c_str())->second->getBinContent(idx+1);
00164         fill((channel+"Eff_").c_str(), idx+0.5, 1./evts*(accept(event, triggerTable, selectionPath(labels[idx]))-value));
00165       }
00166     }
00167   }
00168 
00169 }
00170 
00171 #include <utility>
00172 
00173 #include "DQM/Physics/interface/TopDQMHelpers.h"
00174 #include "FWCore/Framework/interface/EDAnalyzer.h"
00175 #include "FWCore/Framework/interface/Frameworkfwd.h"
00176 #include "FWCore/ServiceRegistry/interface/Service.h"
00177 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00178 
00179 #include "FWCore/Common/interface/TriggerNames.h"
00180 #include "DataFormats/BeamSpot/interface/BeamSpot.h"
00181 #include "DataFormats/VertexReco/interface/Vertex.h"
00182 #include "DataFormats/Common/interface/TriggerResults.h"
00183   
00209 
00210 //using TopSingleLepton::MonitorEnsemble;
00211 
00212 class TopSingleLeptonDQM : public edm::EDAnalyzer  {
00213  public: 
00215   TopSingleLeptonDQM(const edm::ParameterSet& cfg);
00217   ~TopSingleLeptonDQM(){
00218     if( vertexSelect_ ) delete vertexSelect_;
00219     if( beamspotSelect_ ) delete beamspotSelect_;
00220   };
00221   
00223   virtual void analyze(const edm::Event& event, const edm::EventSetup& setup);
00224     
00225  private:
00228   std::string objectType(const std::string& label) { return label.substr(0, label.find(':')); };  
00231   std::string selectionStep(const std::string& label) { return label.substr(label.find(':')+1); };  
00232 
00233  private:
00235   edm::InputTag triggerTable_;
00237   std::vector<std::string> triggerPaths_;
00239   edm::InputTag vertex_;
00241   StringCutObjectSelector<reco::Vertex>* vertexSelect_;
00242 
00244   edm::InputTag beamspot_;
00246   StringCutObjectSelector<reco::BeamSpot>* beamspotSelect_;
00247 
00250   std::vector<std::string> selectionOrder_;
00256   std::map<std::string, std::pair<edm::ParameterSet, TopSingleLepton::MonitorEnsemble*> > selection_;
00257 };
00258 
00259 #endif