CMS 3D CMS Logo

TopDiLeptonOfflineDQM.h
Go to the documentation of this file.
1 #ifndef TOPDILEPTONOFFLINEDQM
2 #define TOPDILEPTONOFFLINEDQM
3 
4 #include <string>
5 #include <vector>
6 
9 
49 namespace TopDiLeptonOffline {
52 
54  public:
62 
63  public:
69 
71  void book(DQMStore::IBooker& ibooker);
73  void fill(const edm::Event& event, const edm::EventSetup& setup);
74 
75  private:
78  std::string monitorPath(const std::string& label) const { return label.substr(label.find(':') + 1); };
81  std::string selectionPath(const std::string& label) const { return label.substr(0, label.find(':')); };
83  DecayChannel decayChannel(const std::vector<const reco::PFCandidate*>& muons,
84  const std::vector<const reco::PFCandidate*>& elecs) const;
85 
89  void triggerBinLabels(std::string channel, const std::vector<std::string> labels);
91  void fill(const edm::Event& event,
92  const edm::TriggerResults& triggerTable,
93  std::string channel,
94  const std::vector<std::string> labels) const;
95 
97  bool booked(const std::string histName) const { return hists_.find(histName) != hists_.end(); };
99  void fill(const std::string histName, double value) const {
100  if (booked(histName))
101  hists_.find(histName)->second->Fill(value);
102  };
104  void fill(const std::string histName, double xValue, double yValue) const {
105  if (booked(histName))
106  hists_.find(histName)->second->Fill(xValue, yValue);
107  };
109  void fill(const std::string histName, double xValue, double yValue, double zValue) const {
110  if (booked(histName))
111  hists_.find(histName)->second->Fill(xValue, yValue, zValue);
112  };
113 
114  private:
123 
125  std::vector<edm::EDGetTokenT<edm::View<reco::MET> > > mets_;
126 
131  std::vector<std::string> elecMuPaths_;
133  std::vector<std::string> diMuonPaths_;
134 
148  // int eidPattern_;
149  // the cut for the MVA Id
150  double eidCutValue_;
152  std::unique_ptr<StringCutObjectSelector<reco::PFCandidate> > elecIso_;
154  std::unique_ptr<StringCutObjectSelector<reco::PFCandidate> > elecSelect_;
155 
157  std::unique_ptr<StringCutObjectSelector<reco::PFCandidate, true> > muonIso_;
158 
160  std::unique_ptr<StringCutObjectSelector<reco::PFCandidate, true> > muonSelect_;
161 
167  std::unique_ptr<StringCutObjectSelector<reco::JetID> > jetIDSelect_;
173 
178  std::map<std::string, MonitorElement*> hists_;
179 
181  };
182 
184  // set axes titles for selected events
185  hists_[hist]->getTH1()->SetOption("TEXT");
186  hists_[hist]->setBinLabel(1, "Run", 1);
187  hists_[hist]->setBinLabel(2, "Block", 1);
188  hists_[hist]->setBinLabel(3, "Event", 1);
189  hists_[hist]->setBinLabel(6, "pt_{L2L3}(jet1)", 1);
190  hists_[hist]->setBinLabel(7, "pt_{L2L3}(jet2)", 1);
191  hists_[hist]->setBinLabel(8, "MET_{Calo}", 1);
192  hists_[hist]->setAxisTitle("logged evts", 2);
193 
194  if (hist == "diMuonLogger_") {
195  hists_[hist]->setBinLabel(4, "pt(muon)", 1);
196  hists_[hist]->setBinLabel(5, "pt(muon)", 1);
197  }
198  if (hist == "diElecLogger_") {
199  hists_[hist]->setBinLabel(4, "pt(elec)", 1);
200  hists_[hist]->setBinLabel(5, "pt(elec)", 1);
201  }
202  if (hist == "elecMuLogger_") {
203  hists_[hist]->setBinLabel(4, "pt(elec)", 1);
204  hists_[hist]->setBinLabel(5, "pt(muon)", 1);
205  }
206  }
207 
208  inline void MonitorEnsemble::triggerBinLabels(std::string channel, const std::vector<std::string> labels) {
209  for (unsigned int idx = 0; idx < labels.size(); ++idx) {
210  hists_[channel + "Mon_"]->setBinLabel(idx + 1, "[" + monitorPath(labels[idx]) + "]", 1);
211  hists_[channel + "Eff_"]->setBinLabel(
212  idx + 1, "[" + selectionPath(labels[idx]) + "]|[" + monitorPath(labels[idx]) + "]", 1);
213  }
214  }
215 
217  const edm::TriggerResults& triggerTable,
218  std::string channel,
219  const std::vector<std::string> labels) const {
220  for (unsigned int idx = 0; idx < labels.size(); ++idx) {
221  if (accept(event, triggerTable, monitorPath(labels[idx]))) {
222  fill(channel + "Mon_", idx + 0.5);
223  // take care to fill triggerMon_ before evts is being called
224  int evts = hists_.find(channel + "Mon_")->second->getBinContent(idx + 1);
225  double value = hists_.find(channel + "Eff_")->second->getBinContent(idx + 1);
226  fill(
227  channel + "Eff_", idx + 0.5, 1. / evts * (accept(event, triggerTable, selectionPath(labels[idx])) - value));
228  }
229  }
230  }
231 
233  const std::vector<const reco::PFCandidate*>& muons, const std::vector<const reco::PFCandidate*>& elecs) const {
235  if (muons.size() > 1) {
236  type = DIMUON;
237  } else if (elecs.size() > 1) {
238  type = DIELEC;
239  } else if (!elecs.empty() && !muons.empty()) {
240  type = ELECMU;
241  }
242  return type;
243  }
244 } // namespace TopDiLeptonOffline
245 
246 #include <utility>
247 
251 
257 
295 // using TopDiLeptonOffline::MonitorEnsemble;
297 
299 public:
304 
306  void analyze(const edm::Event& event, const edm::EventSetup& setup) override;
307 
308 protected:
309  //Book histograms
310  void bookHistograms(DQMStore::IBooker&, edm::Run const&, edm::EventSetup const&) override;
311 
312 private:
315  std::string objectType(const std::string& label) { return label.substr(0, label.find(':')); };
318  std::string selectionStep(const std::string& label) { return label.substr(label.find(':') + 1); };
319 
320 private:
324  std::vector<std::string> triggerPaths_;
328  std::unique_ptr<StringCutObjectSelector<reco::Vertex> > vertexSelect_;
332  std::unique_ptr<StringCutObjectSelector<reco::BeamSpot> > beamspotSelect_;
333 
336  std::vector<std::string> selectionOrder_;
342  std::map<std::string, std::pair<edm::ParameterSet, std::unique_ptr<TopDiLeptonOffline::MonitorEnsemble> > > selection_;
343  std::unique_ptr<SelectionStep<reco::PFCandidate> > MuonStep;
344  std::unique_ptr<SelectionStep<reco::PFCandidate> > ElectronStep;
345  std::unique_ptr<SelectionStep<reco::Vertex> > PvStep;
346  std::unique_ptr<SelectionStep<reco::MET> > METStep;
347  std::vector<std::unique_ptr<SelectionStep<reco::Jet> > > JetSteps;
348  std::vector<std::unique_ptr<SelectionStep<reco::CaloJet> > > CaloJetSteps;
349  std::vector<std::unique_ptr<SelectionStep<reco::PFJet> > > PFJetSteps;
350 
351  std::vector<edm::ParameterSet> sel_;
353 };
354 
355 #endif
type
Definition: HCALResponse.h:21
std::string selectionPath(const std::string &label) const
std::vector< std::string > selectionOrder_
void fill(const std::string histName, double value) const
fill histogram if it had been booked before
std::unique_ptr< SelectionStep< reco::Vertex > > PvStep
Level verbosity_
verbosity level for booking
edm::EDGetTokenT< reco::JetIDValueMap > jetIDLabel_
jetID as an extra selection type
define MonitorEnsembple to be used
std::vector< std::unique_ptr< SelectionStep< reco::CaloJet > > > CaloJetSteps
edm::EDGetTokenT< std::vector< reco::Vertex > > vertex_
primary vertex
MonitorEnsemble(const char *label, const edm::ParameterSet &cfg, edm::ConsumesCollector &&iC)
void loggerBinLabels(std::string hist)
set labels for event logging histograms
std::unique_ptr< StringCutObjectSelector< reco::PFCandidate > > elecIso_
extra isolation criterion on electron
std::string monitorPath(const std::string &label) const
std::unique_ptr< StringCutObjectSelector< reco::Vertex > > vertexSelect_
string cut selector
std::vector< edm::ParameterSet > sel_
bool accept(const edm::Event &event, const edm::TriggerResults &triggerTable, const std::string &triggerPath)
Definition: TopDQMHelpers.h:30
void fill(const std::string histName, double xValue, double yValue) const
fill histogram if it had been booked before (2-dim version)
void fill(const edm::Event &event, const edm::EventSetup &setup)
fill monitor histograms with electronId and jetCorrections
example_stream void analyze(const edm::Event &, const edm::EventSetup &) override
bool booked(const std::string histName) const
check if histogram was booked
dqm::dqmstoreimpl::DQMStore DQMStore
Definition: DQMStore.h:706
edm::EDGetTokenT< edm::View< reco::Jet > > jets_
input sources for monitoring
std::vector< std::unique_ptr< SelectionStep< reco::Jet > > > JetSteps
char const * label
std::unique_ptr< StringCutObjectSelector< reco::JetID > > jetIDSelect_
extra jetID selection on calo jets
edm::EDGetTokenT< edm::View< reco::PFCandidate > > muons_
std::unique_ptr< SelectionStep< reco::PFCandidate > > MuonStep
std::unique_ptr< StringCutObjectSelector< reco::PFCandidate, true > > muonSelect_
extra selection on muons
double lowerEdge_
mass window upper and lower edge
std::vector< edm::EDGetTokenT< edm::View< reco::MET > > > mets_
considers a vector of METs
std::vector< std::string > elecMuPaths_
Definition: value.py:1
std::unique_ptr< StringCutObjectSelector< reco::PFCandidate > > elecSelect_
extra selection on electrons
std::unique_ptr< SelectionStep< reco::MET > > METStep
std::unique_ptr< SelectionStep< reco::PFCandidate > > ElectronStep
int elecMuLogged_
number of logged interesting events
std::vector< std::string > diMuonPaths_
trigger paths for di muon channel
reco::LeafCandidate::LorentzVector LorentzVector
std::map< std::string, MonitorElement * > hists_
dqm::legacy::MonitorElement MonitorElement
example_stream void bookHistograms(DQMStore::IBooker &,@example_stream edm::Run const &,@example_stream edm::EventSetup const &) override
void book(DQMStore::IBooker &ibooker)
book histograms in subdirectory directory
~TopDiLeptonOfflineDQM() override
default destructor
edm::EDGetTokenT< edm::TriggerResults > triggerTable_
trigger table
std::unique_ptr< StringCutObjectSelector< reco::BeamSpot > > beamspotSelect_
string cut selector
edm::EDGetTokenT< edm::TriggerResults > triggerTable_
trigger table
std::vector< std::string > triggerPaths_
trigger paths
std::string objectType(const std::string &label)
DecayChannel decayChannel(const std::vector< const reco::PFCandidate * > &muons, const std::vector< const reco::PFCandidate * > &elecs) const
determine dileptonic decay channel
std::unique_ptr< StringCutObjectSelector< reco::PFCandidate, true > > muonIso_
extra isolation criterion on muon
void fill(const std::string histName, double xValue, double yValue, double zValue) const
fill histogram if it had been booked before (2-dim version)
edm::EDGetTokenT< reco::BeamSpot > beamspot_
beamspot
edm::EDGetTokenT< edm::ValueMap< float > > electronId_
electronId label
math::XYZTLorentzVector LorentzVector
Lorentz vector.
Definition: LeafCandidate.h:23
std::map< std::string, std::pair< edm::ParameterSet, std::unique_ptr< TopDiLeptonOffline::MonitorEnsemble > > > selection_
void triggerBinLabels(std::string channel, const std::vector< std::string > labels)
set configurable labels for trigger monitoring histograms
Definition: event.py:1
Definition: Run.h:45
edm::EDGetTokenT< edm::View< reco::PFCandidate > > elecs_
std::vector< std::unique_ptr< SelectionStep< reco::PFJet > > > PFJetSteps