CMS 3D CMS Logo

TopDiLeptonOfflineDQM.h
Go to the documentation of this file.
1 #ifndef TOPDILEPTONOFFLINEDQM
2 #define TOPDILEPTONOFFLINEDQM
3 
5 
6 #include <string>
7 #include <vector>
8 
48 namespace TopDiLeptonOffline {
51 
53  public:
61 
62  public:
68 
70  void book(DQMStore::IBooker& ibooker);
72  void fill(const edm::Event& event, const edm::EventSetup& setup);
73 
74  private:
77  std::string monitorPath(const std::string& label) const { return label.substr(label.find(':') + 1); };
80  std::string selectionPath(const std::string& label) const { return label.substr(0, label.find(':')); };
82  DecayChannel decayChannel(const std::vector<const reco::PFCandidate*>& muons,
83  const std::vector<const reco::PFCandidate*>& elecs) const;
84 
88  void triggerBinLabels(std::string channel, const std::vector<std::string> labels);
90  void fill(const edm::Event& event,
91  const edm::TriggerResults& triggerTable,
92  std::string channel,
93  const std::vector<std::string> labels) const;
94 
96  bool booked(const std::string histName) const { return hists_.find(histName) != hists_.end(); };
98  void fill(const std::string histName, double value) const {
99  if (booked(histName))
100  hists_.find(histName)->second->Fill(value);
101  };
103  void fill(const std::string histName, double xValue, double yValue) const {
104  if (booked(histName))
105  hists_.find(histName)->second->Fill(xValue, yValue);
106  };
108  void fill(const std::string histName, double xValue, double yValue, double zValue) const {
109  if (booked(histName))
110  hists_.find(histName)->second->Fill(xValue, yValue, zValue);
111  };
112 
113  private:
122 
124  std::vector<edm::EDGetTokenT<edm::View<reco::MET> > > mets_;
125 
130  std::vector<std::string> elecMuPaths_;
132  std::vector<std::string> diMuonPaths_;
133 
147  // int eidPattern_;
148  // the cut for the MVA Id
149  double eidCutValue_;
151  std::unique_ptr<StringCutObjectSelector<reco::PFCandidate> > elecIso_;
153  std::unique_ptr<StringCutObjectSelector<reco::PFCandidate> > elecSelect_;
154 
156  std::unique_ptr<StringCutObjectSelector<reco::PFCandidate, true> > muonIso_;
157 
159  std::unique_ptr<StringCutObjectSelector<reco::PFCandidate, true> > muonSelect_;
160 
166  std::unique_ptr<StringCutObjectSelector<reco::JetID> > jetIDSelect_;
172 
177  std::map<std::string, MonitorElement*> hists_;
178 
180  };
181 
183  // set axes titles for selected events
184  hists_[hist]->getTH1()->SetOption("TEXT");
185  hists_[hist]->setBinLabel(1, "Run", 1);
186  hists_[hist]->setBinLabel(2, "Block", 1);
187  hists_[hist]->setBinLabel(3, "Event", 1);
188  hists_[hist]->setBinLabel(6, "pt_{L2L3}(jet1)", 1);
189  hists_[hist]->setBinLabel(7, "pt_{L2L3}(jet2)", 1);
190  hists_[hist]->setBinLabel(8, "MET_{Calo}", 1);
191  hists_[hist]->setAxisTitle("logged evts", 2);
192 
193  if (hist == "diMuonLogger_") {
194  hists_[hist]->setBinLabel(4, "pt(muon)", 1);
195  hists_[hist]->setBinLabel(5, "pt(muon)", 1);
196  }
197  if (hist == "diElecLogger_") {
198  hists_[hist]->setBinLabel(4, "pt(elec)", 1);
199  hists_[hist]->setBinLabel(5, "pt(elec)", 1);
200  }
201  if (hist == "elecMuLogger_") {
202  hists_[hist]->setBinLabel(4, "pt(elec)", 1);
203  hists_[hist]->setBinLabel(5, "pt(muon)", 1);
204  }
205  }
206 
207  inline void MonitorEnsemble::triggerBinLabels(std::string channel, const std::vector<std::string> labels) {
208  for (unsigned int idx = 0; idx < labels.size(); ++idx) {
209  hists_[channel + "Mon_"]->setBinLabel(idx + 1, "[" + monitorPath(labels[idx]) + "]", 1);
210  hists_[channel + "Eff_"]->setBinLabel(
211  idx + 1, "[" + selectionPath(labels[idx]) + "]|[" + monitorPath(labels[idx]) + "]", 1);
212  }
213  }
214 
216  const edm::TriggerResults& triggerTable,
217  std::string channel,
218  const std::vector<std::string> labels) const {
219  for (unsigned int idx = 0; idx < labels.size(); ++idx) {
220  if (accept(event, triggerTable, monitorPath(labels[idx]))) {
221  fill(channel + "Mon_", idx + 0.5);
222  // take care to fill triggerMon_ before evts is being called
223  int evts = hists_.find(channel + "Mon_")->second->getBinContent(idx + 1);
224  double value = hists_.find(channel + "Eff_")->second->getBinContent(idx + 1);
225  fill(
226  channel + "Eff_", idx + 0.5, 1. / evts * (accept(event, triggerTable, selectionPath(labels[idx])) - value));
227  }
228  }
229  }
230 
232  const std::vector<const reco::PFCandidate*>& muons, const std::vector<const reco::PFCandidate*>& elecs) const {
234  if (muons.size() > 1) {
235  type = DIMUON;
236  } else if (elecs.size() > 1) {
237  type = DIELEC;
238  } else if (!elecs.empty() && !muons.empty()) {
239  type = ELECMU;
240  }
241  return type;
242  }
243 } // namespace TopDiLeptonOffline
244 
245 #include <utility>
246 
250 
255 
293 // using TopDiLeptonOffline::MonitorEnsemble;
295 
297 public:
302 
304  void analyze(const edm::Event& event, const edm::EventSetup& setup) override;
305 
306 protected:
307  //Book histograms
308  void bookHistograms(DQMStore::IBooker&, edm::Run const&, edm::EventSetup const&) override;
309 
310 private:
313  std::string objectType(const std::string& label) { return label.substr(0, label.find(':')); };
316  std::string selectionStep(const std::string& label) { return label.substr(label.find(':') + 1); };
317 
318 private:
322  std::vector<std::string> triggerPaths_;
326  std::unique_ptr<StringCutObjectSelector<reco::Vertex> > vertexSelect_;
330  std::unique_ptr<StringCutObjectSelector<reco::BeamSpot> > beamspotSelect_;
331 
334  std::vector<std::string> selectionOrder_;
340  std::map<std::string, std::pair<edm::ParameterSet, std::unique_ptr<TopDiLeptonOffline::MonitorEnsemble> > > selection_;
341  std::unique_ptr<SelectionStep<reco::PFCandidate> > MuonStep;
342  std::unique_ptr<SelectionStep<reco::PFCandidate> > ElectronStep;
343  std::unique_ptr<SelectionStep<reco::Vertex> > PvStep;
344  std::unique_ptr<SelectionStep<reco::MET> > METStep;
345  std::vector<std::unique_ptr<SelectionStep<reco::Jet> > > JetSteps;
346  std::vector<std::unique_ptr<SelectionStep<reco::CaloJet> > > CaloJetSteps;
347  std::vector<std::unique_ptr<SelectionStep<reco::PFJet> > > PFJetSteps;
348 
349  std::vector<edm::ParameterSet> sel_;
351 };
352 
353 #endif
std::string selectionStep(const std::string &label)
std::vector< std::string > selectionOrder_
bool booked(const std::string histName) const
check if histogram was booked
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::unique_ptr< StringCutObjectSelector< reco::Vertex > > vertexSelect_
string cut selector
std::vector< edm::ParameterSet > sel_
muons
the two sets of parameters below are mutually exclusive, depending if RECO or ALCARECO is used the us...
Definition: DiMuonV_cfg.py:214
bool accept(const edm::Event &event, const edm::TriggerResults &triggerTable, const std::string &triggerPath)
Definition: TopDQMHelpers.h:31
void fill(const edm::Event &event, const edm::EventSetup &setup)
fill monitor histograms with electronId and jetCorrections
void fill(const std::string histName, double xValue, double yValue) const
fill histogram if it had been booked before (2-dim version)
edm::EDGetTokenT< edm::View< reco::Jet > > jets_
input sources for monitoring
edm::EDGetTokenT< reco::JetCorrector > jetCorrector_
jetCorrector
dqm::reco::DQMStore DQMStore
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
DecayChannel decayChannel(const std::vector< const reco::PFCandidate *> &muons, const std::vector< const reco::PFCandidate *> &elecs) const
determine dileptonic decay channel
void analyze(const edm::Event &event, const edm::EventSetup &setup) override
do this during the event loop
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
void fill(const std::string histName, double value) const
fill histogram if it had been booked before
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
TopDiLeptonOfflineDQM(const edm::ParameterSet &cfg)
default constructor
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
void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override
std::map< std::string, MonitorElement * > hists_
dqm::legacy::MonitorElement MonitorElement
void book(DQMStore::IBooker &ibooker)
book histograms in subdirectory directory
std::string monitorPath(const std::string &label) const
~TopDiLeptonOfflineDQM() override
default destructor
edm::EDGetTokenT< edm::TriggerResults > triggerTable_
trigger table
std::unique_ptr< StringCutObjectSelector< reco::BeamSpot > > beamspotSelect_
string cut selector
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< edm::TriggerResults > triggerTable_
trigger table
std::vector< std::string > triggerPaths_
trigger paths
std::string objectType(const std::string &label)
std::unique_ptr< StringCutObjectSelector< reco::PFCandidate, true > > muonIso_
extra isolation criterion on muon
std::string selectionPath(const std::string &label) const
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