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>
6 
9 
22 
51 namespace TopSingleLepton {
54 
56  public:
59 
60  public:
65 
67  void book(DQMStore::IBooker& ibooker);
69  void fill(const edm::Event& event, const edm::EventSetup& setup);
70 
71  private:
74  std::string monitorPath(const std::string& label) const { return label.substr(label.find(':') + 1); };
77  std::string selectionPath(const std::string& label) const { return label.substr(0, label.find(':')); };
78 
80  void triggerBinLabels(std::string channel, const std::vector<std::string> labels);
82  void fill(const edm::Event& event,
83  const edm::TriggerResults& triggerTable,
84  std::string channel,
85  const std::vector<std::string> labels) const;
86 
88  bool booked(const std::string histName) const { return hists_.find(histName) != hists_.end(); };
90  void fill(const std::string histName, double value) const {
91  if (booked(histName))
92  hists_.find(histName)->second->Fill(value);
93  };
95  void fill(const std::string histName, double xValue, double yValue) const {
96  if (booked(histName))
97  hists_.find(histName)->second->Fill(xValue, yValue);
98  };
100  void fill(const std::string histName, double xValue, double yValue, double zValue) const {
101  if (booked(histName))
102  hists_.find(histName)->second->Fill(xValue, yValue, zValue);
103  };
104 
105  private:
111  std::vector<edm::EDGetTokenT<edm::View<reco::MET> > > mets_;
121  std::vector<std::string> triggerPaths_;
122 
126 
138  // int eidPattern_;
139  // the cut for the MVA Id
140  double eidCutValue_;
141  // electron ISO things
142 
144 
146 
147  std::unique_ptr<StringCutObjectSelector<reco::PFCandidate> > elecSelect_;
148 
151  std::unique_ptr<StringCutObjectSelector<reco::Vertex> > pvSelect_;
152 
154  std::unique_ptr<StringCutObjectSelector<reco::PFCandidate> > muonIso_;
155 
157  std::unique_ptr<StringCutObjectSelector<reco::PFCandidate> > muonSelect_;
158 
161 
164 
165  std::unique_ptr<StringCutObjectSelector<reco::JetID> > jetIDSelect_;
168  std::unique_ptr<StringCutObjectSelector<reco::PFJet> > jetlooseSelection_;
169  std::unique_ptr<StringCutObjectSelector<reco::PFJet> > jetSelection_;
179 
181  int logged_;
182 
184  std::map<std::string, MonitorElement*> hists_;
186 
188  };
189 
190  inline void MonitorEnsemble::triggerBinLabels(std::string channel, const std::vector<std::string> labels) {
191  for (unsigned int idx = 0; idx < labels.size(); ++idx) {
192  hists_[channel + "Mon_"]->setBinLabel(idx + 1, "[" + monitorPath(labels[idx]) + "]", 1);
193  hists_[channel + "Eff_"]->setBinLabel(
194  idx + 1, "[" + selectionPath(labels[idx]) + "]|[" + monitorPath(labels[idx]) + "]", 1);
195  }
196  }
197 
199  const edm::TriggerResults& triggerTable,
200  std::string channel,
201  const std::vector<std::string> labels) const {
202  for (unsigned int idx = 0; idx < labels.size(); ++idx) {
203  if (accept(event, triggerTable, monitorPath(labels[idx]))) {
204  fill(channel + "Mon_", idx + 0.5);
205  // take care to fill triggerMon_ before evts is being called
206  int evts = hists_.find(channel + "Mon_")->second->getBinContent(idx + 1);
207  double value = hists_.find(channel + "Eff_")->second->getBinContent(idx + 1);
208  fill(
209  channel + "Eff_", idx + 0.5, 1. / evts * (accept(event, triggerTable, selectionPath(labels[idx])) - value));
210  }
211  }
212  }
213 } // namespace TopSingleLepton
214 
215 #include <utility>
216 
221 
227 
266 // using TopSingleLepton::MonitorEnsemble;
268 
270 public:
274  ~TopSingleLeptonDQM() override{};
275 
277  void analyze(const edm::Event& event, const edm::EventSetup& setup) override;
278 
279 protected:
280  //Book histograms
281  void bookHistograms(DQMStore::IBooker&, edm::Run const&, edm::EventSetup const&) override;
282 
283 private:
286  std::string objectType(const std::string& label) { return label.substr(0, label.find(':')); };
289  std::string selectionStep(const std::string& label) { return label.substr(label.find(':') + 1); };
290 
291 private:
295  std::vector<std::string> triggerPaths_;
297  std::unique_ptr<StringCutObjectSelector<reco::Vertex> > vertexSelect_;
298 
303  std::unique_ptr<StringCutObjectSelector<reco::BeamSpot> > beamspotSelect_;
304 
307  std::vector<std::string> selectionOrder_;
313  std::map<std::string, std::pair<edm::ParameterSet, std::unique_ptr<TopSingleLepton::MonitorEnsemble> > > selection_;
314  std::unique_ptr<SelectionStep<reco::PFCandidate> > MuonStep;
315  std::unique_ptr<SelectionStep<reco::PFCandidate> > ElectronStep;
316  std::unique_ptr<SelectionStep<reco::Vertex> > PvStep;
317  std::unique_ptr<SelectionStep<reco::MET> > METStep;
318  std::vector<std::unique_ptr<SelectionStep<reco::Jet> > > JetSteps;
319  std::vector<std::unique_ptr<SelectionStep<reco::CaloJet> > > CaloJetSteps;
320  std::vector<std::unique_ptr<SelectionStep<reco::PFJet> > > PFJetSteps;
321 
322  std::vector<edm::ParameterSet> sel_;
324 };
325 
326 #endif
327 
328 /* Local Variables: */
329 /* show-trailing-whitespace: t */
330 /* truncate-lines: t */
331 /* 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
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
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_
edm::EDGetTokenT< reco::JetCorrector > mJetCorrector
example_stream void analyze(const edm::Event &, const edm::EventSetup &) override
std::vector< edm::EDGetTokenT< edm::View< reco::MET > > > mets_
considers a vector of METs
dqm::dqmstoreimpl::DQMStore DQMStore
Definition: DQMStore.h:706
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
std::vector< std::unique_ptr< SelectionStep< reco::Jet > > > JetSteps
char const * label
std::unique_ptr< StringCutObjectSelector< reco::PFJet > > jetSelection_
std::unique_ptr< StringCutObjectSelector< reco::Vertex > > vertexSelect_
string cut selector
std::string jetSelect_
extra selection on jets
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
dqm::legacy::MonitorElement MonitorElement
std::string label_
instance label
edm::EDGetTokenT< reco::JetTagCollection > btagVtx_
example_stream void bookHistograms(DQMStore::IBooker &,@example_stream edm::Run const &,@example_stream edm::EventSetup const &) override
~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_
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
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:45
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