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 
10 
50 namespace TopDiLeptonOffline {
51 
53  public:
55  enum Level {
59  };
64  enum DecayChannel {
69  };
70 
71  public:
74  MonitorEnsemble(const char* label, const edm::ParameterSet& cfg,
78 
80  void book(DQMStore::IBooker & ibooker);
82  void fill(const edm::Event& event, const edm::EventSetup& setup);
83 
84  private:
88  return label.substr(label.find(':') + 1);
89  };
93  return label.substr(0, label.find(':'));
94  };
96  DecayChannel decayChannel(const std::vector<const reco::PFCandidate*>& muons,
97  const std::vector<const reco::PFCandidate*>& elecs)
98  const;
99 
103  void triggerBinLabels(std::string channel,
104  const std::vector<std::string> labels);
106  void fill(const edm::Event& event, const edm::TriggerResults& triggerTable,
107  std::string channel, const std::vector<std::string> labels) const;
108 
110  bool booked(const std::string histName) const {
111  return hists_.find(histName) != hists_.end();
112  };
114  void fill(const std::string histName, double value) const {
115  if (booked(histName))
116  hists_.find(histName)->second->Fill(value);
117  };
119  void fill(const std::string histName, double xValue, double yValue) const {
120  if (booked(histName))
121  hists_.find(histName)->second->Fill(xValue, yValue);
122  };
124  void fill(const std::string histName, double xValue, double yValue,
125  double zValue) const {
126  if (booked(histName))
127  hists_.find(histName)->second->Fill(xValue, yValue, zValue);
128  };
129 
130  private:
139 
141  std::vector<edm::EDGetTokenT<edm::View<reco::MET> > > mets_;
142 
147  std::vector<std::string> elecMuPaths_;
149  std::vector<std::string> diMuonPaths_;
150 
164  // int eidPattern_;
165  // the cut for the MVA Id
166  double eidCutValue_;
168  std::unique_ptr<StringCutObjectSelector<reco::PFCandidate> > elecIso_;
170  std::unique_ptr<StringCutObjectSelector<reco::PFCandidate> > elecSelect_;
171 
173  std::unique_ptr<StringCutObjectSelector<reco::PFCandidate, true> > muonIso_;
174 
176  std::unique_ptr< StringCutObjectSelector<reco::PFCandidate, true> > muonSelect_;
177 
183  std::unique_ptr<StringCutObjectSelector<reco::JetID> > jetIDSelect_;
189 
194  std::map<std::string, MonitorElement*> hists_;
195 
197 };
198 
200  // set axes titles for selected events
201  hists_[hist]->getTH1()->SetOption("TEXT");
202  hists_[hist]->setBinLabel(1, "Run", 1);
203  hists_[hist]->setBinLabel(2, "Block", 1);
204  hists_[hist]->setBinLabel(3, "Event", 1);
205  hists_[hist]->setBinLabel(6, "pt_{L2L3}(jet1)", 1);
206  hists_[hist]->setBinLabel(7, "pt_{L2L3}(jet2)", 1);
207  hists_[hist]->setBinLabel(8, "MET_{Calo}", 1);
208  hists_[hist]->setAxisTitle("logged evts", 2);
209 
210  if (hist == "diMuonLogger_") {
211  hists_[hist]->setBinLabel(4, "pt(muon)", 1);
212  hists_[hist]->setBinLabel(5, "pt(muon)", 1);
213  }
214  if (hist == "diElecLogger_") {
215  hists_[hist]->setBinLabel(4, "pt(elec)", 1);
216  hists_[hist]->setBinLabel(5, "pt(elec)", 1);
217  }
218  if (hist == "elecMuLogger_") {
219  hists_[hist]->setBinLabel(4, "pt(elec)", 1);
220  hists_[hist]->setBinLabel(5, "pt(muon)", 1);
221  }
222 }
223 
225  std::string channel, const std::vector<std::string> labels) {
226  for (unsigned int idx = 0; idx < labels.size(); ++idx) {
227  hists_[channel + "Mon_"]
228  ->setBinLabel(idx + 1, "[" + monitorPath(labels[idx]) + "]", 1);
229  hists_[channel + "Eff_"]
230  ->setBinLabel(idx + 1, "[" + selectionPath(labels[idx]) + "]|[" +
231  monitorPath(labels[idx]) + "]",
232  1);
233  }
234 }
235 
237  const edm::TriggerResults& triggerTable,
238  std::string channel,
239  const std::vector<std::string> labels) const {
240  for (unsigned int idx = 0; idx < labels.size(); ++idx) {
241  if (accept(event, triggerTable, monitorPath(labels[idx]))) {
242  fill(channel + "Mon_", idx + 0.5);
243  // take care to fill triggerMon_ before evts is being called
244  int evts = hists_.find(channel + "Mon_")
245  ->second->getBinContent(idx + 1);
246  double value = hists_.find(channel + "Eff_")
247  ->second->getBinContent(idx + 1);
248  fill(
249  channel + "Eff_", idx + 0.5,
250  1. / evts * (accept(event, triggerTable, selectionPath(labels[idx])) -
251  value));
252  }
253  }
254 }
255 
257  const std::vector<const reco::PFCandidate*>& muons,
258  const std::vector<const reco::PFCandidate*>& elecs) const {
260  if (muons.size() > 1) {
261  type = DIMUON;
262  } else if (elecs.size() > 1) {
263  type = DIELEC;
264  } else if (!elecs.empty() && !muons.empty()) {
265  type = ELECMU;
266  }
267  return type;
268 }
269 }
270 
271 #include <utility>
272 
276 
282 
320 // using TopDiLeptonOffline::MonitorEnsemble;
322 
324  public:
329 
331  void analyze(const edm::Event& event, const edm::EventSetup& setup) override;
332 
333  protected:
334  //Book histograms
336  edm::Run const &, edm::EventSetup const &) override;
337 
338  private:
342  return label.substr(0, label.find(':'));
343  };
347  return label.substr(label.find(':') + 1);
348  };
349 
350  private:
354  std::vector<std::string> triggerPaths_;
358  std::unique_ptr<StringCutObjectSelector<reco::Vertex> > vertexSelect_;
362  std::unique_ptr<StringCutObjectSelector<reco::BeamSpot> > beamspotSelect_;
363 
366  std::vector<std::string> selectionOrder_;
373  std::pair<edm::ParameterSet, std::unique_ptr<TopDiLeptonOffline::MonitorEnsemble > > >
375  std::unique_ptr<SelectionStep<reco::PFCandidate> > MuonStep;
376  std::unique_ptr<SelectionStep<reco::PFCandidate> > ElectronStep;
377  std::unique_ptr<SelectionStep<reco::Vertex> > PvStep;
378  std::unique_ptr<SelectionStep<reco::MET> > METStep;
379  std::vector<std::unique_ptr<SelectionStep<reco::Jet> > > JetSteps;
380  std::vector<std::unique_ptr<SelectionStep<reco::CaloJet> > > CaloJetSteps;
381  std::vector<std::unique_ptr<SelectionStep<reco::PFJet> > > PFJetSteps;
382 
383  std::vector<edm::ParameterSet> sel_;
385 };
386 
387 #endif
type
Definition: HCALResponse.h:21
std::string selectionPath(const std::string &label) const
std::string selectionStep(const std::string &label)
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
virtual example_stream void analyze(const edm::Event &, const edm::EventSetup &) override
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)
def setup(process, global_tag, zero_tesla=False)
Definition: GeneralSetup.py:1
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
bool booked(const std::string histName) const
check if histogram was booked
edm::EDGetTokenT< edm::View< reco::Jet > > jets_
input sources for monitoring
std::vector< std::unique_ptr< SelectionStep< reco::Jet > > > JetSteps
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
double lowerEdge_
mass window upper and lower edge
virtual example_stream void bookHistograms(DQMStore::IBooker &,@example_stream edm::Run const &,@example_stream edm::EventSetup const &) override
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_
void book(DQMStore::IBooker &ibooker)
book histograms in subdirectory directory
std::map< std::string, std::pair< edm::ParameterSet, std::unique_ptr< TopDiLeptonOffline::MonitorEnsemble > > > selection_
~TopDiLeptonOfflineDQM() override
default destructor
edm::EDGetTokenT< edm::TriggerResults > triggerTable_
trigger table
std::unique_ptr< StringCutObjectSelector< reco::BeamSpot > > beamspotSelect_
string cut selector
std::unique_ptr< StringCutObjectSelector< reco::PFCandidate, true > > muonSelect_
extra selection on muons
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
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:43
edm::EDGetTokenT< edm::View< reco::PFCandidate > > elecs_
std::vector< std::unique_ptr< SelectionStep< reco::PFJet > > > PFJetSteps