CMS 3D CMS Logo

TopSingleLeptonDQM_miniAOD.h
Go to the documentation of this file.
1 #ifndef TOPSINGLELEPTONDQM_MINIAOD
2 #define TOPSINGLELEPTONDQM_MINIAOD
3 
4 #include <string>
5 #include <vector>
10 
22 
23 
28 
29 
30 namespace TopSingleLepton_miniAOD {
31 
33  public:
35  enum Level {
39  };
40 
41  public:
43  MonitorEnsemble(const char* label, const edm::ParameterSet& cfg,
47 
49  void book(DQMStore::IBooker & ibooker);
51  void fill(const edm::Event& event, const edm::EventSetup& setup);
52 
53  private:
57  return label.substr(label.find(':') + 1);
58  };
62  return label.substr(0, label.find(':'));
63  };
64 
66  void triggerBinLabels(std::string channel,
67  const std::vector<std::string> labels);
69  void fill(const edm::Event& event, const edm::TriggerResults& triggerTable,
70  std::string channel, const std::vector<std::string> labels) const;
71 
73  bool booked(const std::string histName) const {
74  return hists_.find(histName.c_str()) != hists_.end();
75  };
77  void fill(const std::string histName, double value) const {
78  if (booked(histName.c_str()))
79  hists_.find(histName.c_str())->second->Fill(value);
80  };
82  void fill(const std::string histName, double xValue, double yValue) const {
83  if (booked(histName.c_str()))
84  hists_.find(histName.c_str())->second->Fill(xValue, yValue);
85  };
87  void fill(const std::string histName, double xValue, double yValue,
88  double zValue) const {
89  if (booked(histName.c_str()))
90  hists_.find(histName.c_str())->second->Fill(xValue, yValue, zValue);
91  };
92 
93  private:
99  std::vector<edm::EDGetTokenT<edm::View<pat::MET> > > mets_;
109  std::vector<std::string> triggerPaths_;
110 
113 
114  double eidCutValue_;
116  std::unique_ptr<StringCutObjectSelector<pat::Electron> > elecIso_;
118  std::unique_ptr<StringCutObjectSelector<pat::Electron> > elecSelect_;
119 
122  std::unique_ptr<StringCutObjectSelector<reco::Vertex> > pvSelect_;
123 
125  std::unique_ptr<StringCutObjectSelector<pat::Muon> > muonIso_;
126 
128  std::unique_ptr<StringCutObjectSelector<pat::Muon> > muonSelect_;
129 
135  std::unique_ptr<StringCutObjectSelector<reco::JetID> > jetIDSelect_;
139  std::unique_ptr<StringCutObjectSelector<pat::Jet> > jetSelect;
145  btagCSV_;
150 
152  int logged_;
153 
155  std::map<std::string, MonitorElement*> hists_;
158 };
159 
161  std::string channel, const std::vector<std::string> labels) {
162  for (unsigned int idx = 0; idx < labels.size(); ++idx) {
163  hists_[(channel + "Mon_").c_str()]
164  ->setBinLabel(idx + 1, "[" + monitorPath(labels[idx]) + "]", 1);
165  hists_[(channel + "Eff_").c_str()]
166  ->setBinLabel(idx + 1, "[" + selectionPath(labels[idx]) + "]|[" +
167  monitorPath(labels[idx]) + "]",
168  1);
169  }
170 }
171 
173  const edm::TriggerResults& triggerTable,
174  std::string channel,
175  const std::vector<std::string> labels) const {
176  for (unsigned int idx = 0; idx < labels.size(); ++idx) {
177  if (accept(event, triggerTable, monitorPath(labels[idx]))) {
178  fill((channel + "Mon_").c_str(), idx + 0.5);
179  // take care to fill triggerMon_ before evts is being called
180  int evts = hists_.find((channel + "Mon_").c_str())
181  ->second->getBinContent(idx + 1);
182  double value = hists_.find((channel + "Eff_").c_str())
183  ->second->getBinContent(idx + 1);
184  fill(
185  (channel + "Eff_").c_str(), idx + 0.5,
186  1. / evts * (accept(event, triggerTable, selectionPath(labels[idx])) -
187  value));
188  }
189  }
190 }
191 }
192 
193 #include <utility>
194 
199 
205 
206 
208  public:
213 
215  virtual void analyze(const edm::Event& event, const edm::EventSetup& setup) override;
216 
217  protected:
218  //Book histograms
220  edm::Run const &, edm::EventSetup const &) override;
221 
222  private:
226  return label.substr(0, label.find(':'));
227  };
231  return label.substr(label.find(':') + 1);
232  };
233 
234  private:
238  std::vector<std::string> triggerPaths_;
240  std::unique_ptr<StringCutObjectSelector<reco::Vertex> > vertexSelect_;
241 
246  std::unique_ptr<StringCutObjectSelector<reco::BeamSpot> > beamspotSelect_;
247 
250  std::vector<std::string> selectionOrder_;
257  std::pair<edm::ParameterSet, std::unique_ptr<TopSingleLepton_miniAOD::MonitorEnsemble> > >
259  std::unique_ptr<SelectionStep<pat::Muon> > MuonStep;
260  std::unique_ptr<SelectionStep<pat::Electron> > ElectronStep;
261  std::unique_ptr<SelectionStep<reco::Vertex> > PvStep;
262  std::unique_ptr<SelectionStep<pat::MET> > METStep;
263  std::vector<std::unique_ptr<SelectionStep<pat::Jet> > > JetSteps;
264 
265 
266  std::vector<edm::ParameterSet> sel_;
268 };
269 
270 #endif
271 
272 /* Local Variables: */
273 /* show-trailing-whitespace: t */
274 /* truncate-lines: t */
275 /* End: */
std::unique_ptr< StringCutObjectSelector< pat::Muon > > muonIso_
extra isolation criterion on muon
std::unique_ptr< StringCutObjectSelector< reco::JetID > > jetIDSelect_
extra jetID selection on calo jets
std::vector< edm::EDGetTokenT< edm::View< pat::MET > > > mets_
considers a vector of METs
std::unique_ptr< StringCutObjectSelector< reco::Vertex > > vertexSelect_
string cut selector
std::unique_ptr< StringCutObjectSelector< pat::Muon > > muonSelect_
extra selection on muons
std::unique_ptr< SelectionStep< reco::Vertex > > PvStep
std::string objectType(const std::string &label)
bool booked(const std::string histName) const
check if histogram was booked
std::unique_ptr< StringCutObjectSelector< pat::Electron > > elecIso_
extra isolation criterion on electron
edm::EDGetTokenT< edm::View< pat::Jet > > jets_
input sources for monitoring
def analyze(function, filename, filter=None)
Definition: Profiling.py:11
edm::EDGetTokenT< edm::ValueMap< float > > electronId_
electronId label
void triggerBinLabels(std::string channel, const std::vector< std::string > labels)
set configurable labels for trigger monitoring histograms
MonitorEnsemble(const char *label, const edm::ParameterSet &cfg, edm::ConsumesCollector &&iC)
default contructor
edm::EDGetTokenT< edm::View< pat::Electron > > elecs_
def setup(process, global_tag, zero_tesla=False)
Definition: GeneralSetup.py:1
std::unique_ptr< StringCutObjectSelector< reco::BeamSpot > > beamspotSelect_
string cut selector
std::map< std::string, std::pair< edm::ParameterSet, std::unique_ptr< TopSingleLepton_miniAOD::MonitorEnsemble > > > selection_
bool accept(const edm::Event &event, const edm::TriggerResults &triggerTable, const std::string &triggerPath)
Definition: TopDQMHelpers.h:30
~TopSingleLeptonDQM_miniAOD()
default destructor
std::vector< edm::ParameterSet > sel_
void bookHistograms(fwlite::EventContainer &eventCont)
std::vector< std::string > selectionOrder_
U second(std::pair< T, U > const &p)
edm::EDGetTokenT< reco::BeamSpot > beamspot__
std::string selectionStep(const std::string &label)
std::unique_ptr< StringCutObjectSelector< pat::Jet > > jetSelect
std::unique_ptr< StringCutObjectSelector< reco::Vertex > > pvSelect_
std::string monitorPath(const std::string &label) const
edm::EDGetTokenT< edm::TriggerResults > triggerTable_
trigger table
void fill(const std::string histName, double value) const
fill histogram if it had been booked before
std::map< std::string, MonitorElement * > hists_
histogram container
std::vector< std::string > triggerPaths_
trigger paths
Definition: value.py:1
std::unique_ptr< SelectionStep< pat::MET > > METStep
edm::EDGetTokenT< reco::JetTagCollection > btagVtx_
void fill(const std::string histName, double xValue, double yValue) const
fill histogram if it had been booked before (2-dim version)
std::vector< std::unique_ptr< SelectionStep< pat::Jet > > > JetSteps
std::unique_ptr< SelectionStep< pat::Muon > > MuonStep
edm::EDGetTokenT< edm::View< pat::Muon > > muons_
edm::EDGetTokenT< reco::JetTagCollection > btagPur_
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, double zValue) const
fill histogram if it had been booked before (2-dim version)
edm::EDGetTokenT< edm::View< reco::Vertex > > pvs_
edm::EDGetTokenT< reco::JetTagCollection > btagCSV_
double lowerEdge_
mass window upper and lower edge
void book(DQMStore::IBooker &ibooker)
book histograms in subdirectory directory
int logged_
number of logged interesting events
std::string selectionPath(const std::string &label) const
std::unique_ptr< StringCutObjectSelector< pat::Electron > > elecSelect_
extra selection on electrons
edm::EDGetTokenT< reco::JetTagCollection > btagEff_
btag discriminator labels
Level verbosity_
verbosity level for booking
std::unique_ptr< SelectionStep< pat::Electron > > ElectronStep
edm::EDGetTokenT< edm::TriggerResults > triggerTable__
trigger table
Definition: event.py:1
Definition: Run.h:42
edm::EDGetTokenT< reco::JetIDValueMap > jetIDLabel_
jetID as an extra selection type