CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Tau3MuMonitor.cc
Go to the documentation of this file.
11 
12 class Tau3MuMonitor : public DQMEDAnalyzer, public TriggerDQMBase {
13 public:
16 
19  static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
20 
21 protected:
22  void bookHistograms(DQMStore::IBooker&, edm::Run const&, edm::EventSetup const&) override;
23  void analyze(edm::Event const& iEvent, edm::EventSetup const& iSetup) override;
24 
25 private:
26  const std::string folderName_;
27 
30 
31  // internally store a flag to remember whether the needed tau3mu collection is present and valid
33 
34  edm::EDGetTokenT<reco::CompositeCandidateCollection> tauToken_; // tau 3 mu collection
35 
36  MonitorElement* tau1DPt_; // 1D tau pt histogram
37  MonitorElement* tau1DEta_; // 1D tau eta histogram
38  MonitorElement* tau1DPhi_; // 1D tau phi histogram
39  MonitorElement* tau1DMass_; // 1D tau mass histogram
40  MonitorElement* tau2DEtaPhi_; // 2D tau eta vs phi histogram
41 
42  MEbinning pt_binning_; // for the 1D tau pt histogram
43  MEbinning eta_binning_; // for the 1D tau eta histogram and 2D tau eta vs phi histogram
44  MEbinning phi_binning_; // for the 1D tau phi histogram and 2D tau eta vs phi histogram
45  MEbinning mass_binning_; // for the 1D tau mass histogram
46 
48 };
49 
51  : folderName_(iConfig.getParameter<std::string>("FolderName")),
52  requireValidHLTPaths_(iConfig.getParameter<bool>("requireValidHLTPaths")),
53  hltPathsAreValid_(false),
54  tauToken_(mayConsume<reco::CompositeCandidateCollection>(iConfig.getParameter<edm::InputTag>("taus"))),
55  pt_binning_(
56  getHistoPSet(iConfig.getParameter<edm::ParameterSet>("histoPSet").getParameter<edm::ParameterSet>("ptPSet"))),
57  eta_binning_(getHistoPSet(
58  iConfig.getParameter<edm::ParameterSet>("histoPSet").getParameter<edm::ParameterSet>("etaPSet"))),
59  phi_binning_(getHistoPSet(
60  iConfig.getParameter<edm::ParameterSet>("histoPSet").getParameter<edm::ParameterSet>("phiPSet"))),
61  mass_binning_(getHistoPSet(
62  iConfig.getParameter<edm::ParameterSet>("histoPSet").getParameter<edm::ParameterSet>("massPSet"))),
63  genTriggerEventFlag_(new GenericTriggerEventFlag(
64  iConfig.getParameter<edm::ParameterSet>("GenericTriggerEventPSet"), consumesCollector(), *this)) {}
65 
68  genTriggerEventFlag_.reset();
69  }
70 }
71 
72 void Tau3MuMonitor::bookHistograms(DQMStore::IBooker& ibooker, edm::Run const& iRun, edm::EventSetup const& iSetup) {
73  // Initialize the GenericTriggerEventFlag
75  genTriggerEventFlag_->initRun(iRun, iSetup);
76  }
77 
78  // check if every HLT path specified in numerator and denominator has a valid match in the HLT Menu
80  (genTriggerEventFlag_ && genTriggerEventFlag_->on() && genTriggerEventFlag_->allHLTPathsAreValid());
81 
82  // if valid HLT paths are required,
83  // create DQM outputs only if all paths are valid
85  return;
86  }
87 
88  std::string histname;
89 
90  std::string currentFolder = folderName_;
91  ibooker.setCurrentFolder(currentFolder);
92 
93  // tau 3 mu 1D pt
94  histname = "tau1DPt";
95  tau1DPt_ = ibooker.book1D(histname, "", pt_binning_.nbins, pt_binning_.xmin, pt_binning_.xmax);
96  tau1DPt_->setAxisTitle("3-#mu p_{T} [GeV]", 1);
97  tau1DPt_->setAxisTitle("counts", 2);
98 
99  // tau 3 mu 1D eta
100  histname = "tau1DEta";
102  tau1DEta_->setAxisTitle("3-#mu #eta", 1);
103  tau1DEta_->setAxisTitle("counts", 2);
104 
105  // tau 3 mu 1D phi
106  histname = "tau1DPhi";
108  tau1DPhi_->setAxisTitle("3-#mu #phi", 1);
109  tau1DPhi_->setAxisTitle("counts", 2);
110 
111  // tau 3 mu 1D mass
112  histname = "tau1DMass";
114  tau1DMass_->setAxisTitle("mass_{3#mu} [GeV]", 1);
115  tau1DMass_->setAxisTitle("counts", 2);
116 
117  // tau 3 mu 2D eta vs phi
118  histname = "tau2DEtaPhi";
119  tau2DEtaPhi_ = ibooker.book2D(histname,
120  "",
127  tau2DEtaPhi_->setAxisTitle("3-#mu #eta", 1);
128  tau2DEtaPhi_->setAxisTitle("3-#mu #phi", 2);
129 }
130 
132  // if valid HLT paths are required,
133  // analyze event only if all paths are valid
135  return;
136  }
137 
138  // require the trigger to be fired
139  if (genTriggerEventFlag_->on() && !genTriggerEventFlag_->accept(iEvent, iSetup))
140  return;
141 
142  // check if the previous event failed because of missing tau3mu collection.
143  // Return silently, a warning must have been issued already at this point
144  if (not validProduct_)
145  return;
146 
147  // get ahold of the tau(3mu) collection
149  iEvent.getByToken(tauToken_, tauHandle);
150 
151  // if the handle is not valid issue a warning (only for the forst occurrency)
152  if (not tauHandle.isValid()) {
153  edm::LogWarning("ProductNotValid") << "Tau3Mu trigger product not valid";
154  validProduct_ = false;
155  return;
156  }
157 
158  // loop and fill
159  for (auto const& itau : *tauHandle) {
160  tau1DPt_->Fill(itau.pt());
161  tau1DEta_->Fill(itau.eta());
162  tau1DPhi_->Fill(itau.phi());
163  tau1DMass_->Fill(itau.mass());
164  tau2DEtaPhi_->Fill(itau.eta(), itau.phi());
165  }
166 }
167 
170  desc.add<std::string>("FolderName", "HLT/BPH/");
171  desc.add<bool>("requireValidHLTPaths", true);
172 
173  desc.add<edm::InputTag>("taus", edm::InputTag("hltTauPt10MuPts511Mass1p2to2p3Iso", "Taus"));
174 
180  fillHistoPSetDescription(ptPSet);
181  fillHistoPSetDescription(etaPSet);
182  fillHistoPSetDescription(phiPSet);
183  fillHistoPSetDescription(massPSet);
184  histoPSet.add<edm::ParameterSetDescription>("ptPSet", ptPSet);
185  histoPSet.add<edm::ParameterSetDescription>("etaPSet", etaPSet);
186  histoPSet.add<edm::ParameterSetDescription>("phiPSet", phiPSet);
187  histoPSet.add<edm::ParameterSetDescription>("massPSet", massPSet);
188  desc.add<edm::ParameterSetDescription>("histoPSet", histoPSet);
189 
190  edm::ParameterSetDescription genericTriggerEventPSet;
191  GenericTriggerEventFlag::fillPSetDescription(genericTriggerEventPSet);
192  desc.add<edm::ParameterSetDescription>("GenericTriggerEventPSet", genericTriggerEventPSet);
193 
194  descriptions.add("tau3muMonitoring", desc);
195 }
196 
void analyze(edm::Event const &iEvent, edm::EventSetup const &iSetup) override
MonitorElement * tau1DEta_
void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override
std::vector< CompositeCandidate > CompositeCandidateCollection
collection of Candidate objects
MonitorElement * tau1DPt_
virtual void setCurrentFolder(std::string const &fullpath)
Definition: DQMStore.cc:32
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:539
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
MEbinning pt_binning_
dqm::reco::DQMStore DQMStore
Provides a code based selection for trigger and DCS information in order to have no failing filters i...
static void fillHistoPSetDescription(edm::ParameterSetDescription &pset)
const std::string folderName_
std::unique_ptr< T, impl::DeviceDeleter > unique_ptr
std::unique_ptr< GenericTriggerEventFlag > genTriggerEventFlag_
MonitorElement * tau1DMass_
void Fill(long long x)
bool hltPathsAreValid_
static MEbinning getHistoPSet(const edm::ParameterSet &pset)
int iEvent
Definition: GenABIO.cc:224
#define override(base_class)
MonitorElement * tau1DPhi_
~Tau3MuMonitor() override
MEbinning mass_binning_
ParameterDescriptionBase * add(U const &iLabel, T const &value)
bool isValid() const
Definition: HandleBase.h:70
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
MonitorElement * tau2DEtaPhi_
MonitorElement * book2D(TString const &name, TString const &title, int nchX, double lowX, double highX, int nchY, double lowY, double highY, FUNC onbooking=NOOP())
Definition: DQMStore.h:177
void add(std::string const &label, ParameterSetDescription const &psetDescription)
MEbinning phi_binning_
dqm::reco::MonitorElement MonitorElement
MEbinning eta_binning_
Log< level::Warning, false > LogWarning
MonitorElement * book1D(TString const &name, TString const &title, int const nchX, double const lowX, double const highX, FUNC onbooking=NOOP())
Definition: DQMStore.h:98
edm::EDGetTokenT< reco::CompositeCandidateCollection > tauToken_
static void fillPSetDescription(edm::ParameterSetDescription &desc)
const bool requireValidHLTPaths_
Tau3MuMonitor(const edm::ParameterSet &)
Definition: Run.h:45
virtual void setAxisTitle(const std::string &title, int axis=1)
set x-, y- or z-axis title (axis=1, 2, 3 respectively)