CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_6_1_2_SLHC4_patch1/src/HLTriggerOffline/Top/src/TopHLTSingleLeptonDQM.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 "HLTriggerOffline/Top/interface/TopHLTDQMHelper.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 /*Originally from DQM/Physics by R. Wolf and J. Andrea*/
00020 
00038 namespace TopHLTSingleLepton {
00039 
00040   class MonitorEnsemble {
00041   public:
00043     enum Level{ STANDARD, VERBOSE, DEBUG };
00044     
00045   public:
00047     MonitorEnsemble(const char* label, const edm::ParameterSet& cfg);
00049     ~MonitorEnsemble(){};
00050     
00052     void book(std::string directory);
00054     void fill(const edm::Event& event, const edm::EventSetup& setup);
00055 
00056   private:
00059     std::string monitorPath(const std::string& label) const { return label.substr(label.find(':')+1); };  
00062     std::string selectionPath(const std::string& label) const { return label.substr(0, label.find(':')); };  
00063 
00065     void triggerBinLabels(std::string channel, const std::vector<std::string> labels);
00067     void fill(const edm::Event& event, const edm::TriggerResults& triggerTable, std::string channel, const std::vector<std::string> labels) const;
00068 
00070     bool booked(const std::string histName) const { return hists_.find(histName.c_str())!=hists_.end(); };
00072     void fill(const std::string histName, double value) const { if(booked(histName.c_str())) hists_.find(histName.c_str())->second->Fill(value); };
00074     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); };
00076     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); };
00077 
00078   private:
00080     Level verbosity_;
00082     std::string label_;
00084     std::vector<edm::InputTag> mets_;
00086     edm::InputTag elecs_, muons_, jets_, pvs_; 
00087 
00089     edm::InputTag triggerTable_;
00092     std::vector<std::string> triggerPaths_;
00093 
00095     edm::InputTag electronId_;
00106     int eidPattern_;
00108     StringCutObjectSelector<reco::GsfElectron>* elecIso_;
00110     StringCutObjectSelector<reco::GsfElectron>* elecSelect_;
00111     
00113     StringCutObjectSelector<reco::Vertex>* pvSelect_;
00114     
00116     StringCutObjectSelector<reco::Muon>* muonIso_;
00118     StringCutObjectSelector<reco::Muon>* muonSelect_;
00119 
00121     std::string jetCorrector_;
00123     edm::InputTag jetIDLabel_;
00125     StringCutObjectSelector<reco::JetID>* jetIDSelect_;
00128     std::string jetSelect_;
00131     bool includeBTag_;
00133     edm::InputTag btagEff_, btagPur_, btagVtx_;
00135     double btagEffWP_, btagPurWP_, btagVtxWP_;
00137     double lowerEdge_, upperEdge_;
00138 
00140     int logged_;
00142     DQMStore* store_;
00144     std::map<std::string,MonitorElement*> hists_;
00145   };
00146 
00147   inline void 
00148   MonitorEnsemble::triggerBinLabels(std::string channel, const std::vector<std::string> labels)
00149   {
00150     for(unsigned int idx=0; idx<labels.size(); ++idx){
00151       hists_[(channel+"Mon_").c_str()]->setBinLabel( idx+1, "["+monitorPath(labels[idx])+"]", 1);
00152       hists_[(channel+"Eff_").c_str()]->setBinLabel( idx+1, "["+selectionPath(labels[idx])+"]|["+monitorPath(labels[idx])+"]", 1);
00153     }
00154   }
00155 
00156   inline void 
00157   MonitorEnsemble::fill(const edm::Event& event, const edm::TriggerResults& triggerTable, std::string channel, const std::vector<std::string> labels) const
00158   {
00159     for(unsigned int idx=0; idx<labels.size(); ++idx){
00160       if( acceptHLT(event, triggerTable, monitorPath(labels[idx])) ){
00161         fill((channel+"Mon_").c_str(), idx+0.5 );
00162         // take care to fill triggerMon_ before evts is being called
00163         int evts = hists_.find((channel+"Mon_").c_str())->second->getBinContent(idx+1);
00164         double value = hists_.find((channel+"Eff_").c_str())->second->getBinContent(idx+1);
00165         fill((channel+"Eff_").c_str(), idx+0.5, 1./evts*(acceptHLT(event, triggerTable, selectionPath(labels[idx]))-value));
00166       }
00167     }
00168   }
00169 
00170 }
00171 
00172 #include <utility>
00173 
00174 #include "DQM/Physics/interface/TopDQMHelpers.h"
00175 #include "FWCore/Framework/interface/EDAnalyzer.h"
00176 #include "FWCore/Framework/interface/Frameworkfwd.h"
00177 #include "FWCore/ServiceRegistry/interface/Service.h"
00178 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00179 
00180 #include "FWCore/Common/interface/TriggerNames.h"
00181 #include "DataFormats/BeamSpot/interface/BeamSpot.h"
00182 #include "DataFormats/VertexReco/interface/Vertex.h"
00183 #include "DataFormats/Common/interface/TriggerResults.h"
00184   
00210 
00211 //using TopHLTSingleLepton::MonitorEnsemble;
00212 
00213 class TopHLTSingleLeptonDQM : public edm::EDAnalyzer  {
00214  public: 
00216   TopHLTSingleLeptonDQM(const edm::ParameterSet& cfg);
00218   ~TopHLTSingleLeptonDQM(){
00219     if( vertexSelect_ ) delete vertexSelect_;
00220     if( beamspotSelect_ ) delete beamspotSelect_;
00221   };
00222   
00224   virtual void analyze(const edm::Event& event, const edm::EventSetup& setup);
00225     
00226  private:
00229   std::string objectType(const std::string& label) { return label.substr(0, label.find(':')); };  
00232   std::string selectionStep(const std::string& label) { return label.substr(label.find(':')+1); };  
00233 
00234  private:
00236   edm::InputTag triggerTable_;
00238   std::vector<std::string> triggerPaths_;
00240   edm::InputTag vertex_;
00242   StringCutObjectSelector<reco::Vertex>* vertexSelect_;
00243 
00245   edm::InputTag beamspot_;
00247   StringCutObjectSelector<reco::BeamSpot>* beamspotSelect_;
00248 
00251   std::vector<std::string> selectionOrder_;
00257   std::map<std::string, std::pair<edm::ParameterSet, TopHLTSingleLepton::MonitorEnsemble*> > selection_;
00258 };
00259 
00260 #endif