CMS 3D CMS Logo

TopSingleLeptonDQM.h
Go to the documentation of this file.
1 #ifndef TOPSINGLELEPTONDQM
2 #define TOPSINGLELEPTONDQM
3 
4 #include <string>
5 #include <vector>
10 
50 namespace TopSingleLepton {
51 
53  public:
55  enum Level {
59  };
60 
61  public:
63  MonitorEnsemble(const char* label, const edm::ParameterSet& cfg,
67 
69  void book(DQMStore::IBooker & ibooker);
71  void fill(const edm::Event& event, const edm::EventSetup& setup);
72 
73  private:
77  return label.substr(label.find(':') + 1);
78  };
82  return label.substr(0, label.find(':'));
83  };
84 
86  void triggerBinLabels(std::string channel,
87  const std::vector<std::string> labels);
89  void fill(const edm::Event& event, const edm::TriggerResults& triggerTable,
90  std::string channel, const std::vector<std::string> labels) const;
91 
93  bool booked(const std::string histName) const {
94  return hists_.find(histName.c_str()) != hists_.end();
95  };
97  void fill(const std::string histName, double value) const {
98  if (booked(histName.c_str()))
99  hists_.find(histName.c_str())->second->Fill(value);
100  };
102  void fill(const std::string histName, double xValue, double yValue) const {
103  if (booked(histName.c_str()))
104  hists_.find(histName.c_str())->second->Fill(xValue, yValue);
105  };
107  void fill(const std::string histName, double xValue, double yValue,
108  double zValue) const {
109  if (booked(histName.c_str()))
110  hists_.find(histName.c_str())->second->Fill(xValue, yValue, zValue);
111  };
112 
113  private:
119  std::vector<edm::EDGetTokenT<edm::View<reco::MET> > > mets_;
129  std::vector<std::string> triggerPaths_;
130 
144  // int eidPattern_;
145  // the cut for the MVA Id
146  double eidCutValue_;
148  std::unique_ptr<StringCutObjectSelector<reco::PFCandidate> > elecIso_;
150  std::unique_ptr<StringCutObjectSelector<reco::PFCandidate> > elecSelect_;
151 
154  std::unique_ptr<StringCutObjectSelector<reco::Vertex> > pvSelect_;
155 
157  std::unique_ptr<StringCutObjectSelector<reco::PFCandidate> > muonIso_;
158 
160  std::unique_ptr<StringCutObjectSelector<reco::PFCandidate> > muonSelect_;
161 
167  std::unique_ptr<StringCutObjectSelector<reco::JetID> > jetIDSelect_;
176  btagCSV_;
181 
183  int logged_;
184 
186  std::map<std::string, MonitorElement*> hists_;
188 
190 };
191 
193  std::string channel, const std::vector<std::string> labels) {
194  for (unsigned int idx = 0; idx < labels.size(); ++idx) {
195  hists_[(channel + "Mon_").c_str()]
196  ->setBinLabel(idx + 1, "[" + monitorPath(labels[idx]) + "]", 1);
197  hists_[(channel + "Eff_").c_str()]
198  ->setBinLabel(idx + 1, "[" + selectionPath(labels[idx]) + "]|[" +
199  monitorPath(labels[idx]) + "]",
200  1);
201  }
202 }
203 
205  const edm::TriggerResults& triggerTable,
206  std::string channel,
207  const std::vector<std::string> labels) const {
208  for (unsigned int idx = 0; idx < labels.size(); ++idx) {
209  if (accept(event, triggerTable, monitorPath(labels[idx]))) {
210  fill((channel + "Mon_").c_str(), idx + 0.5);
211  // take care to fill triggerMon_ before evts is being called
212  int evts = hists_.find((channel + "Mon_").c_str())
213  ->second->getBinContent(idx + 1);
214  double value = hists_.find((channel + "Eff_").c_str())
215  ->second->getBinContent(idx + 1);
216  fill(
217  (channel + "Eff_").c_str(), idx + 0.5,
218  1. / evts * (accept(event, triggerTable, selectionPath(labels[idx])) -
219  value));
220  }
221  }
222 }
223 }
224 
225 #include <utility>
226 
231 
237 
276 // using TopSingleLepton::MonitorEnsemble;
278 
280  public:
285 
287  virtual void analyze(const edm::Event& event, const edm::EventSetup& setup) override;
288 
289  protected:
290  //Book histograms
292  edm::Run const &, edm::EventSetup const &) override;
293 
294  private:
298  return label.substr(0, label.find(':'));
299  };
303  return label.substr(label.find(':') + 1);
304  };
305 
306  private:
310  std::vector<std::string> triggerPaths_;
312  std::unique_ptr<StringCutObjectSelector<reco::Vertex> > vertexSelect_;
313 
318  std::unique_ptr<StringCutObjectSelector<reco::BeamSpot> > beamspotSelect_;
319 
322  std::vector<std::string> selectionOrder_;
329  std::pair<edm::ParameterSet, std::unique_ptr<TopSingleLepton::MonitorEnsemble> > >
331  std::unique_ptr<SelectionStep<reco::PFCandidate> > MuonStep;
332  std::unique_ptr<SelectionStep<reco::PFCandidate> > ElectronStep;
333  std::unique_ptr<SelectionStep<reco::Vertex> > PvStep;
334  std::unique_ptr<SelectionStep<reco::MET> > METStep;
335  std::vector<std::unique_ptr<SelectionStep<reco::Jet> > > JetSteps;
336  std::vector<std::unique_ptr<SelectionStep<reco::CaloJet> > > CaloJetSteps;
337  std::vector<std::unique_ptr<SelectionStep<reco::PFJet> > > PFJetSteps;
338 
339  std::vector<edm::ParameterSet> sel_;
341 };
342 
343 #endif
344 
345 /* Local Variables: */
346 /* show-trailing-whitespace: t */
347 /* truncate-lines: t */
348 /* End: */
std::map< std::string, MonitorElement * > hists_
histogram container
std::string selectionPath(const std::string &label) const
void fill(const std::string histName, double xValue, double yValue, double zValue) const
fill histogram if it had been booked before (2-dim version)
int logged_
number of logged interesting events
edm::EDGetTokenT< reco::JetIDValueMap > jetIDLabel_
jetID as an extra selection type
double btagEffWP_
btag working points
MonitorEnsemble(const char *label, const edm::ParameterSet &cfg, edm::ConsumesCollector &&iC)
default contructor
edm::EDGetTokenT< edm::View< reco::PFCandidate > > muons_
std::unique_ptr< SelectionStep< reco::PFCandidate > > ElectronStep
void fill(const std::string histName, double xValue, double yValue) const
fill histogram if it had been booked before (2-dim version)
std::unique_ptr< StringCutObjectSelector< reco::BeamSpot > > beamspotSelect_
string cut selector
def analyze(function, filename, filter=None)
Definition: Profiling.py:11
std::vector< std::string > triggerPaths_
edm::EDGetTokenT< edm::TriggerResults > triggerTable_
trigger table
std::unique_ptr< StringCutObjectSelector< reco::JetID > > jetIDSelect_
extra jetID selection on calo jets
std::unique_ptr< StringCutObjectSelector< reco::PFCandidate > > muonSelect_
extra selection on muons
std::unique_ptr< StringCutObjectSelector< reco::PFCandidate > > elecSelect_
extra selection on electrons
def setup(process, global_tag, zero_tesla=False)
Definition: GeneralSetup.py:1
define MonitorEnsembple to be used
edm::EDGetTokenT< reco::BeamSpot > beamspot__
std::map< std::string, std::pair< edm::ParameterSet, std::unique_ptr< TopSingleLepton::MonitorEnsemble > > > selection_
edm::EDGetTokenT< reco::JetTagCollection > btagCSV_
bool accept(const edm::Event &event, const edm::TriggerResults &triggerTable, const std::string &triggerPath)
Definition: TopDQMHelpers.h:30
std::vector< std::string > triggerPaths_
trigger paths
std::vector< std::string > selectionOrder_
void bookHistograms(fwlite::EventContainer &eventCont)
std::vector< edm::EDGetTokenT< edm::View< reco::MET > > > mets_
considers a vector of METs
std::unique_ptr< StringCutObjectSelector< reco::PFCandidate > > elecIso_
extra isolation criterion on electron
std::string selectionStep(const std::string &label)
edm::EDGetTokenT< edm::View< reco::Jet > > jets_
input sources for monitoring
Level verbosity_
verbosity level for booking
double lowerEdge_
mass window upper and lower edge
U second(std::pair< T, U > const &p)
std::vector< std::unique_ptr< SelectionStep< reco::Jet > > > JetSteps
std::unique_ptr< StringCutObjectSelector< reco::Vertex > > vertexSelect_
string cut selector
edm::InputTag beamspot_
beamspot
void fill(const std::string histName, double value) const
fill histogram if it had been booked before
~MonitorEnsemble()
default destructor
edm::EDGetTokenT< edm::View< reco::Vertex > > pvs_
Definition: value.py:1
edm::EDGetTokenT< edm::View< reco::PFCandidate > > elecs_
void book(DQMStore::IBooker &ibooker)
book histograms in subdirectory directory
edm::EDGetTokenT< edm::TriggerResults > triggerTable__
trigger table
std::unique_ptr< SelectionStep< reco::PFCandidate > > MuonStep
std::unique_ptr< SelectionStep< reco::MET > > METStep
std::string label_
instance label
edm::EDGetTokenT< reco::JetTagCollection > btagVtx_
Level
different verbosity levels
std::string objectType(const std::string &label)
std::unique_ptr< StringCutObjectSelector< reco::Vertex > > pvSelect_
void fill(const edm::Event &event, const edm::EventSetup &setup)
fill monitor histograms with electronId and jetCorrections
std::vector< edm::ParameterSet > sel_
edm::ParameterSet setup_
edm::EDGetTokenT< reco::JetTagCollection > btagEff_
btag discriminator labels
void triggerBinLabels(std::string channel, const std::vector< std::string > labels)
set configurable labels for trigger monitoring histograms
std::string jetCorrector_
jetCorrector
std::vector< std::unique_ptr< SelectionStep< reco::PFJet > > > PFJetSteps
edm::EDGetTokenT< edm::ValueMap< float > > electronId_
electronId label
~TopSingleLeptonDQM()
default destructor
std::string monitorPath(const std::string &label) const
std::unique_ptr< SelectionStep< reco::Vertex > > PvStep
edm::EDGetTokenT< reco::JetTagCollection > btagPur_
Definition: event.py:1
Definition: Run.h:42
bool booked(const std::string histName) const
check if histogram was booked
std::vector< std::unique_ptr< SelectionStep< reco::CaloJet > > > CaloJetSteps
std::unique_ptr< StringCutObjectSelector< reco::PFCandidate > > muonIso_
extra isolation criterion on muon