CMS 3D CMS Logo

TopSingleLeptonDQM.h
Go to the documentation of this file.
1 #ifndef TOPSINGLELEPTONDQM
2 #define TOPSINGLELEPTONDQM
3 
5 #include <string>
6 #include <vector>
7 
19 
48 namespace TopSingleLepton {
51 
53  public:
56 
57  public:
62 
64  void book(DQMStore::IBooker& ibooker);
66  void fill(const edm::Event& event, const edm::EventSetup& setup);
67 
68  private:
71  std::string monitorPath(const std::string& label) const { return label.substr(label.find(':') + 1); };
74  std::string selectionPath(const std::string& label) const { return label.substr(0, label.find(':')); };
75 
77  void triggerBinLabels(std::string channel, const std::vector<std::string> labels);
79  void fill(const edm::Event& event,
80  const edm::TriggerResults& triggerTable,
81  std::string channel,
82  const std::vector<std::string> labels) const;
83 
85  bool booked(const std::string histName) const { return hists_.find(histName) != hists_.end(); };
87  void fill(const std::string histName, double value) const {
88  if (booked(histName))
89  hists_.find(histName)->second->Fill(value);
90  };
92  void fill(const std::string histName, double xValue, double yValue) const {
93  if (booked(histName))
94  hists_.find(histName)->second->Fill(xValue, yValue);
95  };
97  void fill(const std::string histName, double xValue, double yValue, double zValue) const {
98  if (booked(histName))
99  hists_.find(histName)->second->Fill(xValue, yValue, zValue);
100  };
101 
102  private:
108  std::vector<edm::EDGetTokenT<edm::View<reco::MET> > > mets_;
118  std::vector<std::string> triggerPaths_;
119 
122 
134  // int eidPattern_;
135  // the cut for the MVA Id
136  double eidCutValue_;
137  // electron ISO things
138 
140 
142 
143  std::unique_ptr<StringCutObjectSelector<reco::PFCandidate> > elecSelect_;
144 
147  std::unique_ptr<StringCutObjectSelector<reco::Vertex> > pvSelect_;
148 
150  std::unique_ptr<StringCutObjectSelector<reco::PFCandidate> > muonIso_;
151 
153  std::unique_ptr<StringCutObjectSelector<reco::PFCandidate> > muonSelect_;
154 
157 
160 
161  std::unique_ptr<StringCutObjectSelector<reco::JetID> > jetIDSelect_;
164  std::unique_ptr<StringCutObjectSelector<reco::PFJet> > jetlooseSelection_;
165  std::unique_ptr<StringCutObjectSelector<reco::PFJet> > jetSelection_;
175 
177  int logged_;
178 
180  std::map<std::string, MonitorElement*> hists_;
182 
184  };
185 
186  inline void MonitorEnsemble::triggerBinLabels(std::string channel, const std::vector<std::string> labels) {
187  for (unsigned int idx = 0; idx < labels.size(); ++idx) {
188  hists_[channel + "Mon_"]->setBinLabel(idx + 1, "[" + monitorPath(labels[idx]) + "]", 1);
189  hists_[channel + "Eff_"]->setBinLabel(
190  idx + 1, "[" + selectionPath(labels[idx]) + "]|[" + monitorPath(labels[idx]) + "]", 1);
191  }
192  }
193 
195  const edm::TriggerResults& triggerTable,
196  std::string channel,
197  const std::vector<std::string> labels) const {
198  for (unsigned int idx = 0; idx < labels.size(); ++idx) {
199  if (accept(event, triggerTable, monitorPath(labels[idx]))) {
200  fill(channel + "Mon_", idx + 0.5);
201  // take care to fill triggerMon_ before evts is being called
202  int evts = hists_.find(channel + "Mon_")->second->getBinContent(idx + 1);
203  double value = hists_.find(channel + "Eff_")->second->getBinContent(idx + 1);
204  fill(
205  channel + "Eff_", idx + 0.5, 1. / evts * (accept(event, triggerTable, selectionPath(labels[idx])) - value));
206  }
207  }
208  }
209 } // namespace TopSingleLepton
210 
211 #include <utility>
212 
217 
222 
261 // using TopSingleLepton::MonitorEnsemble;
263 
265 public:
269  ~TopSingleLeptonDQM() override {}
270 
272  void analyze(const edm::Event& event, const edm::EventSetup& setup) override;
273 
274 protected:
275  //Book histograms
276  void bookHistograms(DQMStore::IBooker&, edm::Run const&, edm::EventSetup const&) override;
277 
278 private:
281  std::string objectType(const std::string& label) { return label.substr(0, label.find(':')); };
284  std::string selectionStep(const std::string& label) { return label.substr(label.find(':') + 1); };
285 
286 private:
290  std::vector<std::string> triggerPaths_;
292  std::unique_ptr<StringCutObjectSelector<reco::Vertex> > vertexSelect_;
293 
298  std::unique_ptr<StringCutObjectSelector<reco::BeamSpot> > beamspotSelect_;
299 
302  std::vector<std::string> selectionOrder_;
308  std::map<std::string, std::pair<edm::ParameterSet, std::unique_ptr<TopSingleLepton::MonitorEnsemble> > > selection_;
309  std::unique_ptr<SelectionStep<reco::PFCandidate> > MuonStep;
310  std::unique_ptr<SelectionStep<reco::PFCandidate> > ElectronStep;
311  std::unique_ptr<SelectionStep<reco::Vertex> > PvStep;
312  std::unique_ptr<SelectionStep<reco::MET> > METStep;
313  std::vector<std::unique_ptr<SelectionStep<reco::Jet> > > JetSteps;
314  std::vector<std::unique_ptr<SelectionStep<reco::CaloJet> > > CaloJetSteps;
315  std::vector<std::unique_ptr<SelectionStep<reco::PFJet> > > PFJetSteps;
316 
317  std::vector<edm::ParameterSet> sel_;
319 };
320 
321 #endif
322 
323 /* Local Variables: */
324 /* show-trailing-whitespace: t */
325 /* truncate-lines: t */
326 /* End: */
std::map< std::string, MonitorElement * > hists_
histogram container
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 analyze(const edm::Event &event, const edm::EventSetup &setup) override
do this during the event loop
std::unique_ptr< StringCutObjectSelector< reco::BeamSpot > > beamspotSelect_
string cut selector
std::vector< std::string > triggerPaths_
edm::EDGetTokenT< edm::TriggerResults > triggerTable_
trigger table
std::unique_ptr< StringCutObjectSelector< reco::JetID > > jetIDSelect_
std::unique_ptr< StringCutObjectSelector< reco::PFCandidate > > muonSelect_
extra selection on muons
std::unique_ptr< StringCutObjectSelector< reco::PFCandidate > > elecSelect_
extra selection on electrons
define MonitorEnsembple to be used
TopSingleLeptonDQM(const edm::ParameterSet &cfg)
default constructor
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:31
std::vector< std::string > triggerPaths_
trigger paths
std::vector< std::string > selectionOrder_
std::vector< edm::EDGetTokenT< edm::View< reco::MET > > > mets_
considers a vector of METs
std::string selectionStep(const std::string &label)
edm::EDGetTokenT< edm::View< reco::Jet > > jets_
input sources for monitoring
std::string monitorPath(const std::string &label) const
Level verbosity_
verbosity level for booking
dqm::reco::DQMStore DQMStore
double lowerEdge_
mass window upper and lower edge
std::vector< std::unique_ptr< SelectionStep< reco::Jet > > > JetSteps
char const * label
std::unique_ptr< StringCutObjectSelector< reco::PFJet > > jetSelection_
std::string selectionPath(const std::string &label) const
std::unique_ptr< StringCutObjectSelector< reco::Vertex > > vertexSelect_
string cut selector
std::string jetSelect_
extra selection on jets
void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override
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
bool booked(const std::string histName) const
check if histogram was booked
edm::EDGetTokenT< edm::TriggerResults > triggerTable__
trigger table
std::unique_ptr< SelectionStep< reco::PFCandidate > > MuonStep
std::unique_ptr< SelectionStep< reco::MET > > METStep
dqm::legacy::MonitorElement MonitorElement
std::string label_
instance label
edm::EDGetTokenT< reco::JetTagCollection > btagVtx_
edm::EDGetTokenT< reco::JetCorrector > jetCorrector_
jetCorrector
~TopSingleLeptonDQM() override
default destructor
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::unique_ptr< StringCutObjectSelector< reco::PFJet > > jetlooseSelection_
std::vector< edm::ParameterSet > sel_
void fill(const std::string histName, double xValue, double yValue) const
fill histogram if it had been booked before (2-dim version)
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::vector< std::unique_ptr< SelectionStep< reco::PFJet > > > PFJetSteps
edm::EDGetTokenT< edm::ValueMap< float > > electronId_
electronId label
std::unique_ptr< SelectionStep< reco::Vertex > > PvStep
edm::EDGetTokenT< reco::JetTagCollection > btagPur_
Definition: event.py:1
Definition: Run.h:45
std::vector< std::unique_ptr< SelectionStep< reco::CaloJet > > > CaloJetSteps
std::unique_ptr< StringCutObjectSelector< reco::PFCandidate > > muonIso_
extra isolation criterion on muon