CMS 3D CMS Logo

BPHMonitor.cc
Go to the documentation of this file.
2 
4 
6 
7 
8 // -----------------------------
9 // constructors and destructor
10 // -----------------------------
11 
13  folderName_ ( iConfig.getParameter<std::string>("FolderName") )
14  , muoToken_ ( mayConsume<reco::MuonCollection> (iConfig.getParameter<edm::InputTag>("muons") ) )
15  , bsToken_ ( mayConsume<reco::BeamSpot> (iConfig.getParameter<edm::InputTag>("beamSpot")))
16  , phi_binning_ ( getHistoPSet (iConfig.getParameter<edm::ParameterSet>("histoPSet").getParameter<edm::ParameterSet> ("phiPSet") ) )
17  , pt_binning_ ( getHistoPSet (iConfig.getParameter<edm::ParameterSet>("histoPSet").getParameter<edm::ParameterSet> ("ptPSet") ) )
18  , eta_binning_ ( getHistoPSet (iConfig.getParameter<edm::ParameterSet>("histoPSet").getParameter<edm::ParameterSet> ("etaPSet") ) )
19  , d0_binning_ ( getHistoLSPSet (iConfig.getParameter<edm::ParameterSet>("histoPSet").getParameter<edm::ParameterSet> ("d0PSet") ) )
20  , z0_binning_ ( getHistoLSPSet (iConfig.getParameter<edm::ParameterSet>("histoPSet").getParameter<edm::ParameterSet> ("z0PSet") ) )
21  , num_genTriggerEventFlag_(new GenericTriggerEventFlag(iConfig.getParameter<edm::ParameterSet>("numGenericTriggerEventPSet"),consumesCollector(), *this))
22  , den_genTriggerEventFlag_(new GenericTriggerEventFlag(iConfig.getParameter<edm::ParameterSet>("denGenericTriggerEventPSet"),consumesCollector(), *this))
23  , muoSelection_ ( iConfig.getParameter<std::string>("muoSelection") )
24  , muoSelection_ref ( iConfig.getParameter<std::string>("muoSelection_ref") )
25  , nmuons_ ( iConfig.getParameter<int>("nmuons" ) )
26 {
27 
28  muPhi_.numerator = nullptr;
29  muPhi_.denominator = nullptr;
30  muEta_.numerator = nullptr;
31  muEta_.denominator = nullptr;
32  muPt_.numerator = nullptr;
33  muPt_.denominator = nullptr;
34  mud0_.numerator = nullptr;
35  mud0_.denominator = nullptr;
36  muz0_.numerator = nullptr;
37  muz0_.denominator = nullptr;
38 }
39 
41 {
44 }
45 
47 {
48  return MEbinning{
49  pset.getParameter<int32_t>("nbins"),
50  pset.getParameter<double>("xmin"),
51  pset.getParameter<double>("xmax"),
52  };
53 }
54 
56 {
57  return MEbinning{
58  pset.getParameter<int32_t>("nbins"),
59  0.,
60  double(pset.getParameter<int32_t>("nbins"))
61  };
62 }
63 
64 void BPHMonitor::setMETitle(METME& me, const std::string& titleX, const std::string& titleY)
65 {
66  me.numerator->setAxisTitle(titleX,1);
67  me.numerator->setAxisTitle(titleY,2);
68  me.denominator->setAxisTitle(titleX,1);
69  me.denominator->setAxisTitle(titleY,2);
70 
71 }
72 
73 void BPHMonitor::bookME(DQMStore::IBooker &ibooker, METME& me, std::string& histname, std::string& histtitle, int& nbins, double& min, double& max)
74 {
75  me.numerator = ibooker.book1D(histname+"_numerator", histtitle+" (numerator)", nbins, min, max);
76  me.denominator = ibooker.book1D(histname+"_denominator", histtitle+" (denominator)", nbins, min, max);
77 }
78 void BPHMonitor::bookME(DQMStore::IBooker &ibooker, METME& me, std::string& histname, std::string& histtitle, std::vector<double> binning)
79 {
80  int nbins = binning.size()-1;
81  std::vector<float> fbinning(binning.begin(),binning.end());
82  float* arr = &fbinning[0];
83  me.numerator = ibooker.book1D(histname+"_numerator", histtitle+" (numerator)", nbins, arr);
84  me.denominator = ibooker.book1D(histname+"_denominator", histtitle+" (denominator)", nbins, arr);
85 }
86 void BPHMonitor::bookME(DQMStore::IBooker &ibooker, METME& me, std::string& histname, std::string& histtitle, int& nbinsX, double& xmin, double& xmax, double& ymin, double& ymax)
87 {
88  me.numerator = ibooker.bookProfile(histname+"_numerator", histtitle+" (numerator)", nbinsX, xmin, xmax, ymin, ymax);
89  me.denominator = ibooker.bookProfile(histname+"_denominator", histtitle+" (denominator)", nbinsX, xmin, xmax, ymin, ymax);
90 }
91 void BPHMonitor::bookME(DQMStore::IBooker &ibooker, METME& me, std::string& histname, std::string& histtitle, int& nbinsX, double& xmin, double& xmax, int& nbinsY, double& ymin, double& ymax)
92 {
93  me.numerator = ibooker.book2D(histname+"_numerator", histtitle+" (numerator)", nbinsX, xmin, xmax, nbinsY, ymin, ymax);
94  me.denominator = ibooker.book2D(histname+"_denominator", histtitle+" (denominator)", nbinsX, xmin, xmax, nbinsY, ymin, ymax);
95 }
96 void BPHMonitor::bookME(DQMStore::IBooker &ibooker, METME& me, std::string& histname, std::string& histtitle, std::vector<double> binningX, std::vector<double> binningY)
97 {
98  int nbinsX = binningX.size()-1;
99  std::vector<float> fbinningX(binningX.begin(),binningX.end());
100  float* arrX = &fbinningX[0];
101  int nbinsY = binningY.size()-1;
102  std::vector<float> fbinningY(binningY.begin(),binningY.end());
103  float* arrY = &fbinningY[0];
104 
105  me.numerator = ibooker.book2D(histname+"_numerator", histtitle+" (numerator)", nbinsX, arrX, nbinsY, arrY);
106  me.denominator = ibooker.book2D(histname+"_denominator", histtitle+" (denominator)", nbinsX, arrX, nbinsY, arrY);
107 }
108 
110  edm::Run const & iRun,
111  edm::EventSetup const & iSetup)
112 {
113 
114  std::string histname, histtitle;
115 
116  std::string currentFolder = folderName_ ;
117  ibooker.setCurrentFolder(currentFolder.c_str());
118 
119  histname = "muPt"; histtitle = "mu_P_{t}";
120  bookME(ibooker,muPt_,histname,histtitle, pt_binning_.nbins, pt_binning_.xmin, pt_binning_.xmax);
121  setMETitle(muPt_,"Mu_Pt[GeV]","events/1GeV");
122 
123  histname = "muPhi"; histtitle = "muPhi";
124  bookME(ibooker,muPhi_,histname,histtitle, phi_binning_.nbins, phi_binning_.xmin, phi_binning_.xmax);
125  setMETitle(muPhi_," mu_#phi","events / 0.1 rad");
126 
127  histname = "muEta"; histtitle = "mu_Eta";
128  bookME(ibooker,muEta_,histname,histtitle, eta_binning_.nbins,eta_binning_.xmin, eta_binning_.xmax);
129  setMETitle(muEta_," mu_#eta","events/ ");
130 
131  histname = "mu_d0"; histtitle = "mu_d0";
132  bookME(ibooker,mud0_,histname,histtitle, d0_binning_.nbins,d0_binning_.xmin, d0_binning_.xmax);
133  setMETitle(mud0_," mu_d0","events/bin ");
134 
135  histname = "mu_z0"; histtitle = "mu_z0";
136  bookME(ibooker,muz0_,histname,histtitle, z0_binning_.nbins,z0_binning_.xmin, z0_binning_.xmax);
137  setMETitle(muz0_," mu_z0","events/bin ");
138 
139  // Initialize the GenericTriggerEventFlag
142 
143 }
144 
150 
151 // edm::Handle<reco::BeamSpot> const& beamSpot;
152  // Filter out events if Trigger Filtering is requested
153  if (den_genTriggerEventFlag_->on() && ! den_genTriggerEventFlag_->accept( iEvent, iSetup) ) return;
154 
155 
157  iEvent.getByToken( bsToken_, beamSpot);
159  iEvent.getByToken( muoToken_, muoHandle );
160 
161  for (auto const & m : *muoHandle) {
162  if(!muoSelection_ref(m))continue;
163  muPhi_.denominator->Fill(m.phi());
164  muEta_.denominator->Fill(m.eta());
165  muPt_.denominator ->Fill(m.pt());
166  const reco::Track * track = nullptr;
167  if (m.isTrackerMuon()) track = & * m.innerTrack();
168  else if (m.isStandAloneMuon()) track = & * m.outerTrack();
169  if (track) {
170  double d0 = track->dxy(beamSpot->position());
171  double z0 = track->dz(beamSpot->position());
172  mud0_.denominator ->Fill(d0);
173  muz0_.denominator ->Fill(z0);
174  }
175  }
176  // applying selection for numerator
177  if (num_genTriggerEventFlag_->on() && ! num_genTriggerEventFlag_->accept( iEvent, iSetup) ) return;
178  for (auto const & m : *muoHandle) {
179  if(!muoSelection_(m))continue;
180  muPhi_.numerator->Fill(m.phi());
181  muEta_.numerator->Fill(m.eta());
182  muPt_.numerator ->Fill(m.pt());
183  const reco::Track * track = nullptr;
184  if (m.isTrackerMuon()) track = & * m.innerTrack();
185  else if (m.isStandAloneMuon()) track = & * m.outerTrack();
186  if (track) {
187  double d0 = track->dxy(beamSpot->position());
188  double z0 = track->dz(beamSpot->position());
189  mud0_.numerator ->Fill(d0);
190  muz0_.numerator ->Fill(z0);
191  }
192  }
193 
194  // filling histograms (num_genTriggerEventFlag_)
195 
196 }
197 
199 {
200  pset.add<int> ( "nbins");
201  pset.add<double>( "xmin" );
202  pset.add<double>( "xmax" );
203 }
204 
206 {
207  pset.add<int> ( "nbins", 2500);
208 }
209 
211 {
213  desc.add<std::string> ( "FolderName", "HLT/BPH/" );
214 
215  desc.add<edm::InputTag>( "tracks", edm::InputTag("generalTracks") );
216  desc.add<edm::InputTag>( "offlinePVs", edm::InputTag("offlinePrimaryVertices") );
217  desc.add<edm::InputTag>( "beamSpot",edm::InputTag("offlineBeamSpot") );
218  desc.add<edm::InputTag>( "muons", edm::InputTag("muons") );
219  desc.add<std::string>("muoSelection", "abs(eta)<1.4 & isPFMuon & isGlobalMuon & innerTrack.hitPattern.trackerLayersWithMeasurement>5 & innerTrack.hitPattern.numberOfValidPixelHits>0");
220  desc.add<std::string>("muoSelection_ref", "isPFMuon & isGlobalMuon & innerTrack.hitPattern.trackerLayersWithMeasurement>5 & innerTrack.hitPattern.numberOfValidPixelHits>0");
221  desc.add<int>("nmuons", 1);
222 
223  edm::ParameterSetDescription genericTriggerEventPSet;
224  genericTriggerEventPSet.add<bool>("andOr");
225  genericTriggerEventPSet.add<edm::InputTag>("dcsInputTag", edm::InputTag("scalersRawToDigi") );
226  genericTriggerEventPSet.add<std::vector<int> >("dcsPartitions",{});
227  genericTriggerEventPSet.add<bool>("andOrDcs", false);
228  genericTriggerEventPSet.add<bool>("errorReplyDcs", true);
229  genericTriggerEventPSet.add<std::string>("dbLabel","");
230  genericTriggerEventPSet.add<bool>("andOrHlt", true);
231  genericTriggerEventPSet.add<edm::InputTag>("hltInputTag", edm::InputTag("TriggerResults::HLT") );
232  genericTriggerEventPSet.add<std::vector<std::string> >("hltPaths",{});
233  genericTriggerEventPSet.add<std::string>("hltDBKey","");
234  genericTriggerEventPSet.add<bool>("errorReplyHlt",false);
235  genericTriggerEventPSet.add<unsigned int>("verbosityLevel",0);
236 
237  desc.add<edm::ParameterSetDescription>("numGenericTriggerEventPSet", genericTriggerEventPSet);
238  desc.add<edm::ParameterSetDescription>("denGenericTriggerEventPSet", genericTriggerEventPSet);
239 
246  fillHistoPSetDescription(phiPSet);
247  fillHistoPSetDescription(ptPSet);
248  fillHistoPSetDescription(etaPSet);
249  fillHistoPSetDescription(z0PSet);
250  fillHistoPSetDescription(d0PSet);
251  histoPSet.add<edm::ParameterSetDescription>("d0PSet", d0PSet);
252  histoPSet.add<edm::ParameterSetDescription>("etaPSet", etaPSet);
253  histoPSet.add<edm::ParameterSetDescription>("phiPSet", phiPSet);
254  histoPSet.add<edm::ParameterSetDescription>("ptPSet", ptPSet);
255  histoPSet.add<edm::ParameterSetDescription>("z0PSet", z0PSet);
256  desc.add<edm::ParameterSetDescription>("histoPSet",histoPSet);
257 
258  descriptions.add("bphMonitoring", desc);
259 }
260 
261 // Define this as a plug-in
MEbinning z0_binning_
Definition: BPHMonitor.h:88
MonitorElement * numerator
Definition: BPHMonitor.h:45
T getParameter(std::string const &) const
METME muPt_
Definition: BPHMonitor.h:93
MonitorElement * bookProfile(Args &&...args)
Definition: DQMStore.h:157
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:460
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
edm::EDGetTokenT< reco::MuonCollection > muoToken_
Definition: BPHMonitor.h:81
void bookME(DQMStore::IBooker &, METME &me, std::string &histname, std::string &histtitle, int &nbins, double &xmin, double &xmax)
Definition: BPHMonitor.cc:73
std::string folderName_
Definition: BPHMonitor.h:78
static void fillHistoLSPSetDescription(edm::ParameterSetDescription &pset)
Definition: BPHMonitor.cc:205
Provides a code based selection for trigger and DCS information in order to have no failing filters i...
MEbinning eta_binning_
Definition: BPHMonitor.h:86
std::vector< Muon > MuonCollection
collection of Muon objects
Definition: MuonFwd.h:9
void Fill(long long x)
int iEvent
Definition: GenABIO.cc:230
MEbinning pt_binning_
Definition: BPHMonitor.h:85
static MEbinning getHistoLSPSet(const edm::ParameterSet &pset)
Definition: BPHMonitor.cc:55
bool accept(const edm::Event &event, const edm::EventSetup &setup)
To be called from analyze/filter() methods.
double xmin
Definition: LumiMonitor.h:30
GenericTriggerEventFlag * den_genTriggerEventFlag_
Definition: BPHMonitor.h:99
BPHMonitor(const edm::ParameterSet &)
Definition: BPHMonitor.cc:12
MonitorElement * book1D(Args &&...args)
Definition: DQMStore.h:115
MonitorElement * denominator
Definition: BPHMonitor.h:46
void setMETitle(METME &me, const std::string &titleX, const std::string &titleY)
Definition: BPHMonitor.cc:64
MEbinning phi_binning_
Definition: BPHMonitor.h:84
static void fillHistoPSetDescription(edm::ParameterSetDescription &pset)
Definition: BPHMonitor.cc:198
T min(T a, T b)
Definition: MathUtil.h:58
ParameterDescriptionBase * add(U const &iLabel, T const &value)
void analyze(edm::Event const &iEvent, edm::EventSetup const &iSetup) override
Definition: BPHMonitor.cc:149
StringCutObjectSelector< reco::Muon, true > muoSelection_
Definition: BPHMonitor.h:100
METME muz0_
Definition: BPHMonitor.h:95
MEbinning d0_binning_
Definition: BPHMonitor.h:87
double dz() const
dz parameter (= dsz/cos(lambda)). This is the track z0 w.r.t (0,0,0) only if the refPoint is close to...
Definition: TrackBase.h:609
void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override
Definition: BPHMonitor.cc:109
edm::EDGetTokenT< reco::BeamSpot > bsToken_
Definition: BPHMonitor.h:82
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
Definition: BPHMonitor.cc:210
~BPHMonitor() override
Definition: BPHMonitor.cc:40
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:277
StringCutObjectSelector< reco::Muon, true > muoSelection_ref
Definition: BPHMonitor.h:101
MonitorElement * book2D(Args &&...args)
Definition: DQMStore.h:133
void add(std::string const &label, ParameterSetDescription const &psetDescription)
fixed size matrix
METME muEta_
Definition: BPHMonitor.h:92
HLT enums.
METME mud0_
Definition: BPHMonitor.h:94
const Point & position() const
position
Definition: BeamSpot.h:62
void initRun(const edm::Run &run, const edm::EventSetup &setup)
To be called from beginRun() methods.
double dxy() const
dxy parameter. (This is the transverse impact parameter w.r.t. to (0,0,0) ONLY if refPoint is close t...
Definition: TrackBase.h:591
GenericTriggerEventFlag * num_genTriggerEventFlag_
Definition: BPHMonitor.h:98
void setAxisTitle(const std::string &title, int axis=1)
set x-, y- or z-axis title (axis=1, 2, 3 respectively)
METME muPhi_
Definition: BPHMonitor.h:91
static MEbinning getHistoPSet(const edm::ParameterSet &pset)
Definition: BPHMonitor.cc:46
Definition: Run.h:42
double xmax
Definition: LumiMonitor.h:31