CMS 3D CMS Logo

PrimaryVertexMonitor.cc
Go to the documentation of this file.
1 // user includes
8 
9 // ROOT includes
10 #include "TMath.h"
11 
12 // system includes
13 #include <fmt/format.h>
14 
15 using namespace reco;
16 using namespace edm;
17 
19  : vertexInputTag_(pSet.getParameter<InputTag>("vertexLabel")),
20  beamSpotInputTag_(pSet.getParameter<InputTag>("beamSpotLabel")),
21  vertexToken_(consumes<reco::VertexCollection>(vertexInputTag_)),
22  scoreToken_(consumes<VertexScore>(vertexInputTag_)),
23  beamspotToken_(consumes<reco::BeamSpot>(beamSpotInputTag_)),
24  conf_(pSet),
25  TopFolderName_(pSet.getParameter<std::string>("TopFolderName")),
26  AlignmentLabel_(pSet.getParameter<std::string>("AlignmentLabel")),
27  ndof_(pSet.getParameter<int>("ndof")),
28  useHPfoAlignmentPlots_(pSet.getParameter<bool>("useHPforAlignmentPlots")),
29  errorPrinted_(false),
30  nbvtx(nullptr),
31  bsX(nullptr),
32  bsY(nullptr),
33  bsZ(nullptr),
34  bsSigmaZ(nullptr),
35  bsDxdz(nullptr),
36  bsDydz(nullptr),
37  bsBeamWidthX(nullptr),
38  bsBeamWidthY(nullptr),
39  bsType(nullptr),
40  sumpt(nullptr),
41  ntracks(nullptr),
42  weight(nullptr),
43  chi2ndf(nullptr),
44  chi2prob(nullptr),
45  trackpt(nullptr),
46  phi_pt1(nullptr),
47  eta_pt1(nullptr),
48  phi_pt10(nullptr),
49  eta_pt10(nullptr),
50  dxy2(nullptr) {}
51 
52 // -- BeginRun
53 //---------------------------------------------------------------------------------//
55  std::string dqmLabel = "";
56 
57  //
58  // Book all histograms.
59  //
60 
61  // get the store
63  iBooker.setCurrentFolder(dqmLabel);
64 
65  // xPos = iBooker.book1D ("xPos","x Coordinate" ,100, -0.1, 0.1);
66  auto maxPU = conf_.getParameter<double>("PUMax");
67  nbvtx = iBooker.book1D("vtxNbr", "Reconstructed Vertices in Event", maxPU, -0.5, maxPU - 0.5);
68  nbgvtx = iBooker.book1D("goodvtxNbr", "Reconstructed Good Vertices in Event", maxPU, -0.5, maxPU - 0.5);
69 
70  // to be configured each year...
71  auto vposx = conf_.getParameter<double>("Xpos");
72  auto vposy = conf_.getParameter<double>("Ypos");
73 
74  nbtksinvtx[0] = iBooker.book1D("otherVtxTrksNbr", "Reconstructed Tracks in Vertex (other Vtx)", 40, -0.5, 99.5);
75  ntracksVsZ[0] = iBooker.bookProfile(
76  "otherVtxTrksVsZ", "Reconstructed Tracks in Vertex (other Vtx) vs Z", 80, -20., 20., 50, 0, 100, "");
77  ntracksVsZ[0]->setAxisTitle("z-bs", 1);
78  ntracksVsZ[0]->setAxisTitle("#tracks", 2);
79 
80  score[0] = iBooker.book1D("otherVtxScore", "sqrt(score) (other Vtx)", 100, 0., 400.);
81  trksWeight[0] = iBooker.book1D("otherVtxTrksWeight", "Total weight of Tracks in Vertex (other Vtx)", 40, 0, 100.);
82  vtxchi2[0] = iBooker.book1D("otherVtxChi2", "#chi^{2} (other Vtx)", 100, 0., 200.);
83  vtxndf[0] = iBooker.book1D("otherVtxNdf", "ndof (other Vtx)", 100, 0., 200.);
84  vtxprob[0] = iBooker.book1D("otherVtxProb", "#chi^{2} probability (other Vtx)", 100, 0., 1.);
85  nans[0] = iBooker.book1D("otherVtxNans", "Illegal values for x,y,z,xx,xy,xz,yy,yz,zz (other Vtx)", 9, 0.5, 9.5);
86 
87  nbtksinvtx[1] = iBooker.book1D("tagVtxTrksNbr", "Reconstructed Tracks in Vertex (tagged Vtx)", 100, -0.5, 99.5);
88  ntracksVsZ[1] = iBooker.bookProfile(
89  "tagVtxTrksVsZ", "Reconstructed Tracks in Vertex (tagged Vtx) vs Z", 80, -20., 20., 50, 0, 100, "");
90  ntracksVsZ[1]->setAxisTitle("z-bs", 1);
91  ntracksVsZ[1]->setAxisTitle("#tracks", 2);
92 
93  score[1] = iBooker.book1D("tagVtxScore", "sqrt(score) (tagged Vtx)", 100, 0., 400.);
94  trksWeight[1] = iBooker.book1D("tagVtxTrksWeight", "Total weight of Tracks in Vertex (tagged Vtx)", 100, 0, 100.);
95  vtxchi2[1] = iBooker.book1D("tagVtxChi2", "#chi^{2} (tagged Vtx)", 100, 0., 200.);
96  vtxndf[1] = iBooker.book1D("tagVtxNdf", "ndof (tagged Vtx)", 100, 0., 200.);
97  vtxprob[1] = iBooker.book1D("tagVtxProb", "#chi^{2} probability (tagged Vtx)", 100, 0., 1.);
98  nans[1] = iBooker.book1D("tagVtxNans", "Illegal values for x,y,z,xx,xy,xz,yy,yz,zz (tagged Vtx)", 9, 0.5, 9.5);
99 
100  xrec[0] = iBooker.book1D("otherPosX", "Position x Coordinate (other Vtx)", 100, vposx - 0.1, vposx + 0.1);
101  yrec[0] = iBooker.book1D("otherPosY", "Position y Coordinate (other Vtx)", 100, vposy - 0.1, vposy + 0.1);
102  zrec[0] = iBooker.book1D("otherPosZ", "Position z Coordinate (other Vtx)", 100, -20., 20.);
103  xDiff[0] = iBooker.book1D("otherDiffX", "X distance from BeamSpot (other Vtx)", 100, -500, 500);
104  yDiff[0] = iBooker.book1D("otherDiffY", "Y distance from BeamSpot (other Vtx)", 100, -500, 500);
105  xerr[0] = iBooker.book1D("otherErrX", "Uncertainty x Coordinate (other Vtx)", 100, 0., 100);
106  yerr[0] = iBooker.book1D("otherErrY", "Uncertainty y Coordinate (other Vtx)", 100, 0., 100);
107  zerr[0] = iBooker.book1D("otherErrZ", "Uncertainty z Coordinate (other Vtx)", 100, 0., 100);
108  xerrVsTrks[0] = iBooker.book2D(
109  "otherErrVsWeightX", "Uncertainty x Coordinate vs. track weight (other Vtx)", 100, 0, 100., 100, 0., 100);
110  yerrVsTrks[0] = iBooker.book2D(
111  "otherErrVsWeightY", "Uncertainty y Coordinate vs. track weight (other Vtx)", 100, 0, 100., 100, 0., 100);
112  zerrVsTrks[0] = iBooker.book2D(
113  "otherErrVsWeightZ", "Uncertainty z Coordinate vs. track weight (other Vtx)", 100, 0, 100., 100, 0., 100);
114 
115  xrec[1] = iBooker.book1D("tagPosX", "Position x Coordinate (tagged Vtx)", 100, vposx - 0.1, vposx + 0.1);
116  yrec[1] = iBooker.book1D("tagPosY", "Position y Coordinate (tagged Vtx)", 100, vposy - 0.1, vposy + 0.1);
117  zrec[1] = iBooker.book1D("tagPosZ", "Position z Coordinate (tagged Vtx)", 100, -20., 20.);
118  xDiff[1] = iBooker.book1D("tagDiffX", "X distance from BeamSpot (tagged Vtx)", 100, -500, 500);
119  yDiff[1] = iBooker.book1D("tagDiffY", "Y distance from BeamSpot (tagged Vtx)", 100, -500, 500);
120  xerr[1] = iBooker.book1D("tagErrX", "Uncertainty x Coordinate (tagged Vtx)", 100, 0., 100);
121  yerr[1] = iBooker.book1D("tagErrY", "Uncertainty y Coordinate (tagged Vtx)", 100, 0., 100);
122  zerr[1] = iBooker.book1D("tagErrZ", "Uncertainty z Coordinate (tagged Vtx)", 100, 0., 100);
123  xerrVsTrks[1] = iBooker.book2D(
124  "tagErrVsWeightX", "Uncertainty x Coordinate vs. track weight (tagged Vtx)", 100, 0, 100., 100, 0., 100);
125  yerrVsTrks[1] = iBooker.book2D(
126  "tagErrVsWeightY", "Uncertainty y Coordinate vs. track weight (tagged Vtx)", 100, 0, 100., 100, 0., 100);
127  zerrVsTrks[1] = iBooker.book2D(
128  "tagErrVsWeightZ", "Uncertainty z Coordinate vs. track weight (tagged Vtx)", 100, 0, 100., 100, 0., 100);
129 
130  type[0] = iBooker.book1D("otherType", "Vertex type (other Vtx)", 3, -0.5, 2.5);
131  type[1] = iBooker.book1D("tagType", "Vertex type (tagged Vtx)", 3, -0.5, 2.5);
132  for (int i = 0; i < 2; ++i) {
133  type[i]->setBinLabel(1, "Valid, real");
134  type[i]->setBinLabel(2, "Valid, fake");
135  type[i]->setBinLabel(3, "Invalid");
136  }
137 
138  // get the store
140  iBooker.setCurrentFolder(dqmLabel);
141 
142  bsX = iBooker.book1D("bsX", "BeamSpot x0", 100, vposx - 0.1, vposx + 0.1);
143  bsY = iBooker.book1D("bsY", "BeamSpot y0", 100, vposy - 0.1, vposy + 0.1);
144  bsZ = iBooker.book1D("bsZ", "BeamSpot z0", 100, -2., 2.);
145  bsSigmaZ = iBooker.book1D("bsSigmaZ", "BeamSpot sigmaZ", 100, 0., 10.);
146  bsDxdz = iBooker.book1D("bsDxdz", "BeamSpot dxdz", 100, -0.0003, 0.0003);
147  bsDydz = iBooker.book1D("bsDydz", "BeamSpot dydz", 100, -0.0003, 0.0003);
148  bsBeamWidthX = iBooker.book1D("bsBeamWidthX", "BeamSpot BeamWidthX", 500, 0., 15.);
149  bsBeamWidthY = iBooker.book1D("bsBeamWidthY", "BeamSpot BeamWidthY", 500, 0., 15.);
150  bsType = iBooker.book1D("bsType", "BeamSpot type", 4, -1.5, 2.5);
151  bsType->setBinLabel(1, "Unknown");
152  bsType->setBinLabel(2, "Fake");
153  bsType->setBinLabel(3, "LHC");
154  bsType->setBinLabel(4, "Tracker");
155 
156  // get the store
158  iBooker.setCurrentFolder(dqmLabel);
159 
160  int TKNoBin = conf_.getParameter<int>("TkSizeBin");
161  double TKNoMin = conf_.getParameter<double>("TkSizeMin");
162  double TKNoMax = conf_.getParameter<double>("TkSizeMax");
163 
164  int DxyBin = conf_.getParameter<int>("DxyBin");
165  double DxyMin = conf_.getParameter<double>("DxyMin");
166  double DxyMax = conf_.getParameter<double>("DxyMax");
167 
168  int PhiBin = conf_.getParameter<int>("PhiBin");
169  double PhiMin = conf_.getParameter<double>("PhiMin");
170  double PhiMax = conf_.getParameter<double>("PhiMax");
171 
172  int EtaBin = conf_.getParameter<int>("EtaBin");
173  double EtaMin = conf_.getParameter<double>("EtaMin");
174  double EtaMax = conf_.getParameter<double>("EtaMax");
175 
176  int PtBin = conf_.getParameter<int>("PtBin");
177  double PtMin = conf_.getParameter<double>("PtMin");
178  double PtMax = conf_.getParameter<double>("PtMax");
179 
180  ntracks = iBooker.book1D("ntracks", "number of PV tracks (p_{T} > 1 GeV)", TKNoBin, TKNoMin, TKNoMax);
181  ntracks->setAxisTitle("Number of PV Tracks (p_{T} > 1 GeV) per Event", 1);
182  ntracks->setAxisTitle("Number of Event", 2);
183 
184  weight = iBooker.book1D("weight", "weight of PV tracks (p_{T} > 1 GeV)", 100, 0., 1.);
185  weight->setAxisTitle("weight of PV Tracks (p_{T} > 1 GeV) per Event", 1);
186  weight->setAxisTitle("Number of Event", 2);
187 
188  sumpt = iBooker.book1D("sumpt", "#Sum p_{T} of PV tracks (p_{T} > 1 GeV)", 100, -0.5, 249.5);
189  chi2ndf = iBooker.book1D("chi2ndf", "PV tracks (p_{T} > 1 GeV) #chi^{2}/ndof", 100, 0., 20.);
190  chi2prob = iBooker.book1D("chi2prob", "PV tracks (p_{T} > 1 GeV) #chi^{2} probability", 100, 0., 1.);
191 
192  dxy2 = iBooker.book1D("dxyzoom", "PV tracks (p_{T} > 1 GeV) d_{xy} (#mum)", DxyBin, DxyMin / 5., DxyMax / 5.);
193 
195  true,
196  false,
197  "pt_track",
198  "PV tracks p_{T};PV tracks p_{T} [GeV];#tracks",
199  PtBin,
200  log10(PtMin),
201  log10(PtMax));
202 
203  phi_pt1 = iBooker.book1D("phi_pt1", "PV tracks (p_{T} > 1 GeV) #phi; PV tracks #phi;#tracks", PhiBin, PhiMin, PhiMax);
204  eta_pt1 = iBooker.book1D("eta_pt1", "PV tracks (p_{T} > 1 GeV) #eta; PV tracks #eta;#tracks", EtaBin, EtaMin, EtaMax);
205  phi_pt10 =
206  iBooker.book1D("phi_pt10", "PV tracks (p_{T} > 10 GeV) #phi; PV tracks #phi;#tracks", PhiBin, PhiMin, PhiMax);
207  eta_pt10 =
208  iBooker.book1D("eta_pt10", "PV tracks (p_{T} > 10 GeV) #phi; PV tracks #eta;#tracks", EtaBin, EtaMin, EtaMax);
209 
210  // initialize and book the monitors;
211  dxy_pt1.varname_ = "xy";
212  dxy_pt1.pTcut_ = 1.f;
213  dxy_pt1.bookIPMonitor(iBooker, conf_);
214 
215  dxy_pt10.varname_ = "xy";
216  dxy_pt10.pTcut_ = 10.f;
217  dxy_pt10.bookIPMonitor(iBooker, conf_);
218 
219  dz_pt1.varname_ = "z";
220  dz_pt1.pTcut_ = 1.f;
221  dz_pt1.bookIPMonitor(iBooker, conf_);
222 
223  dz_pt10.varname_ = "z";
224  dz_pt10.pTcut_ = 10.f;
225  dz_pt10.bookIPMonitor(iBooker, conf_);
226 }
227 
229  int VarBin = config.getParameter<int>(fmt::format("D{}Bin", varname_));
230  double VarMin = config.getParameter<double>(fmt::format("D{}Min", varname_));
231  double VarMax = config.getParameter<double>(fmt::format("D{}Max", varname_));
232 
233  PhiBin_ = config.getParameter<int>("PhiBin");
234  PhiMin_ = config.getParameter<double>("PhiMin");
235  PhiMax_ = config.getParameter<double>("PhiMax");
236  int PhiBin2D = config.getParameter<int>("PhiBin2D");
237 
238  EtaBin_ = config.getParameter<int>("EtaBin");
239  EtaMin_ = config.getParameter<double>("EtaMin");
240  EtaMax_ = config.getParameter<double>("EtaMax");
241  int EtaBin2D = config.getParameter<int>("EtaBin2D");
242 
243  PtBin_ = config.getParameter<int>("PtBin");
244  PtMin_ = config.getParameter<double>("PtMin") * pTcut_;
245  PtMax_ = config.getParameter<double>("PtMax") * pTcut_;
246 
247  // 1D variables
248 
249  IP_ = iBooker.book1D(fmt::format("d{}_pt{}", varname_, pTcut_),
250  fmt::format("PV tracks (p_{{T}} > {} GeV) d_{{{}}} (#mum)", pTcut_, varname_),
251  VarBin,
252  VarMin,
253  VarMax);
254 
255  IPErr_ = iBooker.book1D(fmt::format("d{}Err_pt{}", varname_, pTcut_),
256  fmt::format("PV tracks (p_{{T}} > {} GeV) d_{{{}}} error (#mum)", pTcut_, varname_),
257  100,
258  0.,
259  (varname_.find("xy") != std::string::npos) ? 2000. : 10000.);
260 
261  IPPull_ = iBooker.book1D(
262  fmt::format("d{}Pull_pt{}", varname_, pTcut_),
263  fmt::format("PV tracks (p_{{T}} > {} GeV) d_{{{}}}/#sigma_{{d_{{{}}}}}", pTcut_, varname_, varname_),
264  100,
265  -5.,
266  5.);
267 
268  // IP profiles
269 
270  IPVsPhi_ = iBooker.bookProfile(fmt::format("d{}VsPhi_pt{}", varname_, pTcut_),
271  fmt::format("PV tracks (p_{{T}} > {}) d_{{{}}} VS track #phi", pTcut_, varname_),
272  PhiBin_,
273  PhiMin_,
274  PhiMax_,
275  VarBin,
276  VarMin,
277  VarMax,
278  "");
279  IPVsPhi_->setAxisTitle("PV track (p_{T} > 1 GeV) #phi", 1);
280  IPVsPhi_->setAxisTitle(fmt::format("PV tracks (p_{{T}} > {} GeV) d_{{{}}} (#mum)", pTcut_, varname_), 2);
281 
282  IPVsEta_ = iBooker.bookProfile(fmt::format("d{}VsEta_pt{}", varname_, pTcut_),
283  fmt::format("PV tracks (p_{{T}} > {}) d_{{{}}} VS track #eta", pTcut_, varname_),
284  EtaBin_,
285  EtaMin_,
286  EtaMax_,
287  VarBin,
288  VarMin,
289  VarMax,
290  "");
291  IPVsEta_->setAxisTitle("PV track (p_{T} > 1 GeV) #eta", 1);
292  IPVsEta_->setAxisTitle(fmt::format("PV tracks (p_{{T}} > {} GeV) d_{{{}}} (#mum)", pTcut_, varname_), 2);
293 
295  iBooker,
296  true, /* x-axis */
297  false, /* y-axis */
298  fmt::format("d{}VsPt_pt{}", varname_, pTcut_).c_str(),
299  fmt::format("PV tracks (p_{{T}} > {}) d_{{{}}} VS track p_{{T}}", pTcut_, varname_).c_str(),
300  PtBin_,
301  log10(PtMin_),
302  log10(PtMax_),
303  VarMin,
304  VarMax,
305  "");
306  IPVsPt_->setAxisTitle("PV track (p_{T} > 1 GeV) p_{T} [GeV]", 1);
307  IPVsPt_->setAxisTitle(fmt::format("PV tracks (p_{{T}} > {} GeV) d_{{{}}} (#mum)", pTcut_, varname_), 2);
308 
309  // IP error profiles
310 
311  IPErrVsPhi_ =
312  iBooker.bookProfile(fmt::format("d{}ErrVsPhi_pt{}", varname_, pTcut_),
313  fmt::format("PV tracks (p_{{T}} > {}) d_{{{}}} error VS track #phi", pTcut_, varname_),
314  PhiBin_,
315  PhiMin_,
316  PhiMax_,
317  VarBin,
318  0.,
319  (varname_.find("xy") != std::string::npos) ? 100. : 200.,
320  "");
321  IPErrVsPhi_->setAxisTitle("PV track (p_{T} > 1 GeV) #phi", 1);
322  IPErrVsPhi_->setAxisTitle(fmt::format("PV tracks (p_{{T}} > {} GeV) d_{{{}}} error (#mum)", pTcut_, varname_), 2);
323 
324  IPErrVsEta_ =
325  iBooker.bookProfile(fmt::format("d{}ErrVsEta_pt{}", varname_, pTcut_),
326  fmt::format("PV tracks (p_{{T}} > {}) d_{{{}}} error VS track #eta", pTcut_, varname_),
327  EtaBin_,
328  EtaMin_,
329  EtaMax_,
330  VarBin,
331  0.,
332  (varname_.find("xy") != std::string::npos) ? 100. : 200.,
333  "");
334  IPErrVsEta_->setAxisTitle("PV track (p_{T} > 1 GeV) #eta", 1);
335  IPErrVsEta_->setAxisTitle(fmt::format("PV tracks (p_{{T}} > {} GeV) d_{{{}}} error (#mum)", pTcut_, varname_), 2);
336 
338  iBooker,
339  true, /* x-axis */
340  false, /* y-axis */
341  fmt::format("d{}ErrVsPt_pt{}", varname_, pTcut_).c_str(),
342  fmt::format("PV tracks (p_{{T}} > {}) d_{{{}}} error VS track p_{{T}}", pTcut_, varname_).c_str(),
343  PtBin_,
344  log10(PtMin_),
345  log10(PtMax_),
346  VarMin,
347  VarMax,
348  "");
349  IPErrVsPt_->setAxisTitle("PV track (p_{T} > 1 GeV) p_{T} [GeV]", 1);
350  IPErrVsPt_->setAxisTitle(fmt::format("PV tracks (p_{{T}} > {} GeV) d_{{{}}} error (#mum)", pTcut_, varname_), 2);
351 
352  // 2D profiles
353 
354  IPVsEtaVsPhi_ = iBooker.bookProfile2D(
355  fmt::format("d{}VsEtaVsPhi_pt{}", varname_, pTcut_),
356  fmt::format("PV tracks (p_{{T}} > {}) d_{{{}}} VS track #eta VS track #phi", pTcut_, varname_),
357  EtaBin2D,
358  EtaMin_,
359  EtaMax_,
360  PhiBin2D,
361  PhiMin_,
362  PhiMax_,
363  VarBin,
364  VarMin,
365  VarMax,
366  "");
367  IPVsEtaVsPhi_->setAxisTitle("PV track (p_{T} > 1 GeV) #eta", 1);
368  IPVsEtaVsPhi_->setAxisTitle("PV track (p_{T} > 1 GeV) #phi", 2);
369  IPVsEtaVsPhi_->setAxisTitle(fmt::format("PV tracks (p_{{T}} > {} GeV) d_{{{}}} (#mum)", pTcut_, varname_), 3);
370 
372  fmt::format("d{}ErrVsEtaVsPhi_pt{}", varname_, pTcut_),
373  fmt::format("PV tracks (p_{{T}} > {}) d_{{{}}} error VS track #eta VS track #phi", pTcut_, varname_),
374  EtaBin2D,
375  EtaMin_,
376  EtaMax_,
377  PhiBin2D,
378  PhiMin_,
379  PhiMax_,
380  VarBin,
381  0.,
382  (varname_.find("xy") != std::string::npos) ? 100. : 200.,
383  "");
384  IPErrVsEtaVsPhi_->setAxisTitle("PV track (p_{T} > 1 GeV) #eta", 1);
385  IPErrVsEtaVsPhi_->setAxisTitle("PV track (p_{T} > 1 GeV) #phi", 2);
386  IPErrVsEtaVsPhi_->setAxisTitle(fmt::format("PV tracks (p_{{T}} > {} GeV) d_{{{}}} error (#mum)", pTcut_, varname_),
387  3);
388 }
389 
392  iEvent.getByToken(vertexToken_, recVtxs);
393 
394  Handle<VertexScore> scores;
395  iEvent.getByToken(scoreToken_, scores);
396 
397  edm::Handle<reco::BeamSpot> beamSpotHandle;
398  iEvent.getByToken(beamspotToken_, beamSpotHandle);
399 
400  //
401  // check for absent products and simply "return" in that case
402  //
403  if (recVtxs.isValid() == false || beamSpotHandle.isValid() == false) {
404  edm::LogWarning("PrimaryVertexMonitor")
405  << " Some products not available in the event: VertexCollection " << vertexInputTag_ << " " << recVtxs.isValid()
406  << " BeamSpot " << beamSpotInputTag_ << " " << beamSpotHandle.isValid() << ". Skipping plots for this event";
407  return;
408  }
409 
410  // check upfront that refs to track are (likely) to be valid
411  {
412  bool ok = true;
413  for (const auto& v : *recVtxs) {
414  if (v.tracksSize() > 0) {
415  const auto& ref = v.trackRefAt(0);
416  if (ref.isNull() || !ref.isAvailable()) {
417  if (!errorPrinted_)
418  edm::LogWarning("PrimaryVertexMonitor")
419  << "Skipping vertex collection: " << vertexInputTag_
420  << " since likely the track collection the vertex has refs pointing to is missing (at least the first "
421  "TrackBaseRef is null or not available)";
422  else
423  errorPrinted_ = true;
424  ok = false;
425  }
426  }
427  }
428  if (!ok)
429  return;
430  }
431 
432  BeamSpot beamSpot = *beamSpotHandle;
433 
434  nbvtx->Fill(recVtxs->size() * 1.);
435  int ng = 0;
436  for (auto const& vx : (*recVtxs))
437  if (vx.isValid() && !vx.isFake() && vx.ndof() >= ndof_)
438  ++ng;
439  nbgvtx->Fill(ng * 1.);
440 
441  if (scores.isValid() && !(*scores).empty()) {
442  auto pvScore = (*scores).get(0);
443  score[1]->Fill(std::sqrt(pvScore));
444  for (unsigned int i = 1; i < (*scores).size(); ++i)
445  score[0]->Fill(std::sqrt((*scores).get(i)));
446  }
447 
448  // fill PV tracks MEs (as now, for alignment)
449  if (!recVtxs->empty()) {
450  vertexPlots(recVtxs->front(), beamSpot, 1);
451  pvTracksPlots(recVtxs->front());
452 
453  for (reco::VertexCollection::const_iterator v = recVtxs->begin() + 1; v != recVtxs->end(); ++v)
454  vertexPlots(*v, beamSpot, 0);
455  }
456 
457  // Beamline plots:
458  bsX->Fill(beamSpot.x0());
459  bsY->Fill(beamSpot.y0());
460  bsZ->Fill(beamSpot.z0());
461  bsSigmaZ->Fill(beamSpot.sigmaZ());
462  bsDxdz->Fill(beamSpot.dxdz());
463  bsDydz->Fill(beamSpot.dydz());
464  bsBeamWidthX->Fill(beamSpot.BeamWidthX() * cmToUm);
465  bsBeamWidthY->Fill(beamSpot.BeamWidthY() * cmToUm);
466  bsType->Fill(beamSpot.type());
467 }
468 
470  if (!v.isValid())
471  return;
472  if (v.isFake())
473  return;
474 
475  if (v.tracksSize() == 0) {
476  ntracks->Fill(0);
477  return;
478  }
479 
480  const math::XYZPoint myVertex(v.position().x(), v.position().y(), v.position().z());
481 
482  size_t nTracks = 0;
483  float sumPT = 0.;
484 
485  for (reco::Vertex::trackRef_iterator t = v.tracks_begin(); t != v.tracks_end(); t++) {
486  bool isHighPurity = (**t).quality(reco::TrackBase::highPurity);
487  if (!isHighPurity && useHPfoAlignmentPlots_)
488  continue;
489 
490  float pt = (**t).pt();
491  trackpt->Fill(pt);
492 
493  if (pt < 1.)
494  continue;
495 
496  nTracks++;
497 
498  float eta = (**t).eta();
499  float phi = (**t).phi();
500 
501  float w = v.trackWeight(*t);
502  float chi2NDF = (**t).normalizedChi2();
503  float chi2Prob = TMath::Prob((**t).chi2(), (int)(**t).ndof());
504  float Dxy = (**t).dxy(myVertex) * cmToUm;
505  float Dz = (**t).dz(myVertex) * cmToUm;
506  float DxyErr = (**t).dxyError() * cmToUm;
507  float DzErr = (**t).dzError() * cmToUm;
508 
509  sumPT += pt * pt;
510 
511  // fill MEs
512  phi_pt1->Fill(phi);
513  eta_pt1->Fill(eta);
514 
515  weight->Fill(w);
516  chi2ndf->Fill(chi2NDF);
517  chi2prob->Fill(chi2Prob);
518  dxy2->Fill(Dxy);
519 
520  // dxy pT>1
521 
522  dxy_pt1.IP_->Fill(Dxy);
523  dxy_pt1.IPVsPhi_->Fill(phi, Dxy);
524  dxy_pt1.IPVsEta_->Fill(eta, Dxy);
525  dxy_pt1.IPVsPt_->Fill(pt, Dxy);
526  dxy_pt1.IPVsEtaVsPhi_->Fill(eta, phi, Dxy);
527 
528  dxy_pt1.IPErr_->Fill(DxyErr);
529  dxy_pt1.IPPull_->Fill(Dxy / DxyErr);
530  dxy_pt1.IPErrVsPhi_->Fill(phi, DxyErr);
531  dxy_pt1.IPErrVsEta_->Fill(eta, DxyErr);
532  dxy_pt1.IPErrVsPt_->Fill(pt, DxyErr);
533  dxy_pt1.IPErrVsEtaVsPhi_->Fill(eta, phi, DxyErr);
534 
535  // dz pT>1
536 
537  dz_pt1.IP_->Fill(Dz);
538  dz_pt1.IPVsPhi_->Fill(phi, Dz);
539  dz_pt1.IPVsEta_->Fill(eta, Dz);
540  dz_pt1.IPVsPt_->Fill(pt, Dz);
542 
543  dz_pt1.IPErr_->Fill(DzErr);
544  dz_pt1.IPPull_->Fill(Dz / DzErr);
545  dz_pt1.IPErrVsPhi_->Fill(phi, DzErr);
546  dz_pt1.IPErrVsEta_->Fill(eta, DzErr);
547  dz_pt1.IPErrVsPt_->Fill(pt, DxyErr);
548  dz_pt1.IPErrVsEtaVsPhi_->Fill(eta, phi, DzErr);
549 
550  if (pt < 10.)
551  continue;
552 
553  phi_pt10->Fill(phi);
554  eta_pt10->Fill(eta);
555 
556  // dxy pT>10
557 
558  dxy_pt10.IP_->Fill(Dxy);
559  dxy_pt10.IPVsPhi_->Fill(phi, Dxy);
560  dxy_pt10.IPVsEta_->Fill(eta, Dxy);
561  dxy_pt10.IPVsPt_->Fill(pt, Dxy);
563 
564  dxy_pt10.IPErr_->Fill(DxyErr);
565  dxy_pt10.IPPull_->Fill(Dxy / DxyErr);
566  dxy_pt10.IPErrVsPhi_->Fill(phi, DxyErr);
567  dxy_pt10.IPErrVsEta_->Fill(eta, DxyErr);
568  dxy_pt10.IPErrVsPt_->Fill(pt, DxyErr);
569  dxy_pt10.IPErrVsEtaVsPhi_->Fill(eta, phi, DxyErr);
570 
571  // dxz pT>10
572 
573  dz_pt10.IP_->Fill(Dz);
574  dz_pt10.IPVsPhi_->Fill(phi, Dz);
575  dz_pt10.IPVsEta_->Fill(eta, Dz);
576  dz_pt10.IPVsPt_->Fill(pt, Dz);
578 
579  dz_pt10.IPErr_->Fill(DzErr);
580  dz_pt10.IPPull_->Fill(Dz / DzErr);
581  dz_pt10.IPErrVsPhi_->Fill(phi, DzErr);
582  dz_pt10.IPErrVsEta_->Fill(eta, DzErr);
583  dz_pt10.IPErrVsPt_->Fill(pt, DxyErr);
584  dz_pt10.IPErrVsEtaVsPhi_->Fill(eta, phi, DzErr);
585  }
586  ntracks->Fill(float(nTracks));
587  sumpt->Fill(sumPT);
588 }
589 
591  if (i < 0 || i > 1)
592  return;
593  if (!v.isValid())
594  type[i]->Fill(2.);
595  else if (v.isFake())
596  type[i]->Fill(1.);
597  else
598  type[i]->Fill(0.);
599 
600  if (v.isValid() && !v.isFake()) {
601  float weight = 0;
602  for (reco::Vertex::trackRef_iterator t = v.tracks_begin(); t != v.tracks_end(); t++)
603  weight += v.trackWeight(*t);
604  trksWeight[i]->Fill(weight);
605  nbtksinvtx[i]->Fill(v.tracksSize());
606  ntracksVsZ[i]->Fill(v.position().z() - beamSpot.z0(), v.tracksSize());
607 
608  vtxchi2[i]->Fill(v.chi2());
609  vtxndf[i]->Fill(v.ndof());
610  vtxprob[i]->Fill(ChiSquaredProbability(v.chi2(), v.ndof()));
611 
612  xrec[i]->Fill(v.position().x());
613  yrec[i]->Fill(v.position().y());
614  zrec[i]->Fill(v.position().z());
615 
616  float xb = beamSpot.x0() + beamSpot.dxdz() * (v.position().z() - beamSpot.z0());
617  float yb = beamSpot.y0() + beamSpot.dydz() * (v.position().z() - beamSpot.z0());
618  xDiff[i]->Fill((v.position().x() - xb) * cmToUm);
619  yDiff[i]->Fill((v.position().y() - yb) * cmToUm);
620 
621  xerr[i]->Fill(v.xError() * cmToUm);
622  yerr[i]->Fill(v.yError() * cmToUm);
623  zerr[i]->Fill(v.zError() * cmToUm);
624  xerrVsTrks[i]->Fill(weight, v.xError() * cmToUm);
625  yerrVsTrks[i]->Fill(weight, v.yError() * cmToUm);
626  zerrVsTrks[i]->Fill(weight, v.zError() * cmToUm);
627 
628  nans[i]->Fill(1., edm::isNotFinite(v.position().x()) * 1.);
629  nans[i]->Fill(2., edm::isNotFinite(v.position().y()) * 1.);
630  nans[i]->Fill(3., edm::isNotFinite(v.position().z()) * 1.);
631 
632  int index = 3;
633  for (int k = 0; k != 3; k++) {
634  for (int j = k; j != 3; j++) {
635  index++;
636  nans[i]->Fill(index * 1., edm::isNotFinite(v.covariance(k, j)) * 1.);
637  // in addition, diagonal element must be positive
638  if (j == k && v.covariance(k, j) < 0) {
639  nans[i]->Fill(index * 1., 1.);
640  }
641  }
642  }
643  }
644 }
645 
648  desc.add<std::string>("TopFolderName", "OfflinePV");
649  desc.add<std::string>("AlignmentLabel", "Alignment");
650  desc.add<int>("ndof", 4);
651  desc.add<bool>("useHPforAlignmentPlots", true);
652  desc.add<InputTag>("vertexLabel", edm::InputTag("offlinePrimaryVertices"));
653  desc.add<InputTag>("beamSpotLabel", edm::InputTag("offlineBeamSpot"));
654  desc.add<double>("PUMax", 80.0);
655  desc.add<double>("Xpos", 0.1);
656  desc.add<double>("Ypos", 0.0);
657  desc.add<int>("TkSizeBin", 100);
658  desc.add<double>("TkSizeMin", -0.5);
659  desc.add<double>("TkSizeMax", 499.5);
660  desc.add<int>("DxyBin", 100);
661  desc.add<double>("DxyMin", -5000.0);
662  desc.add<double>("DxyMax", 5000.0);
663  desc.add<int>("DzBin", 100);
664  desc.add<double>("DzMin", -2000.0);
665  desc.add<double>("DzMax", 2000.0);
666  desc.add<int>("PhiBin", 32);
667  desc.add<double>("PhiMin", -M_PI);
668  desc.add<double>("PhiMax", M_PI);
669  desc.add<int>("EtaBin", 26);
670  desc.add<double>("EtaMin", 2.5);
671  desc.add<double>("EtaMax", -2.5);
672  desc.add<int>("PtBin", 49);
673  desc.add<double>("PtMin", 1.);
674  desc.add<double>("PtMax", 50.);
675  desc.add<int>("PhiBin2D", 12);
676  desc.add<int>("EtaBin2D", 8);
677  descriptions.addWithDefaultLabel(desc);
678 }
679 
680 //define this as a plug-in
MonitorElement * xerrVsTrks[2]
const std::string AlignmentLabel_
MonitorElement * xerr[2]
void addWithDefaultLabel(ParameterSetDescription const &psetDescription)
T getParameter(std::string const &) const
Definition: ParameterSet.h:307
MonitorElement * vtxndf[2]
MonitorElement * bookProfile2D(TString const &name, TString const &title, int nchX, double lowX, double highX, int nchY, double lowY, double highY, double lowZ, double highZ, char const *option="s", FUNC onbooking=NOOP())
Definition: DQMStore.h:485
void pvTracksPlots(const reco::Vertex &v)
virtual void setCurrentFolder(std::string const &fullpath)
Definition: DQMStore.cc:36
dqm::reco::MonitorElement * IPErrVsEta_
void vertexPlots(const reco::Vertex &v, const reco::BeamSpot &beamSpot, int i)
T w() const
constexpr bool isNotFinite(T x)
Definition: isFinite.h:9
dqm::reco::MonitorElement * IPErrVsPt_
const edm::EDGetTokenT< reco::BeamSpot > beamspotToken_
const std::string dqmLabel
dqm::reco::MonitorElement * IPPull_
std::vector< Vertex > VertexCollection
collection of Vertex objects
Definition: VertexFwd.h:9
Definition: weight.py:1
Definition: config.py:1
dqm::reco::MonitorElement * IPVsEtaVsPhi_
std::string const & label() const
Definition: InputTag.h:36
void bookIPMonitor(DQMStore::IBooker &, const edm::ParameterSet &)
MonitorElement * xDiff[2]
const edm::InputTag vertexInputTag_
dqm::reco::MonitorElement * IP_
MonitorElement * ntracksVsZ[2]
const edm::EDGetTokenT< VertexScore > scoreToken_
MonitorElement * zerrVsTrks[2]
MonitorElement * nans[2]
void Fill(long long x)
int iEvent
Definition: GenABIO.cc:224
dqm::reco::MonitorElement * IPVsEta_
dqm::reco::MonitorElement * IPErrVsPhi_
MonitorElement * yerrVsTrks[2]
void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override
MonitorElement * bookProfile(TString const &name, TString const &title, int nchX, double lowX, double highX, int, double lowY, double highY, char const *option="s", FUNC onbooking=NOOP())
Definition: DQMStore.h:408
void Fill(HcalDetId &id, double val, std::vector< TH2F > &depth)
MonitorElement * zerr[2]
T sqrt(T t)
Definition: SSEVec.h:23
MonitorElement * yrec[2]
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
dqm::reco::MonitorElement * IPErr_
float ChiSquaredProbability(double chiSquared, double nrDOF)
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
MonitorElement * zrec[2]
MonitorElement * vtxchi2[2]
virtual void setBinLabel(int bin, const std::string &label, int axis=1)
set bin label for x, y or z axis (axis=1, 2, 3 respectively)
dqm::reco::MonitorElement * IPErrVsEtaVsPhi_
#define M_PI
const edm::ParameterSet conf_
const std::string TopFolderName_
XYZPointD XYZPoint
point in space with cartesian internal representation
Definition: Point3D.h:12
MonitorElement * nbtksinvtx[2]
dqm::reco::MonitorElement * IPVsPhi_
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:221
dqm::reco::MonitorElement * IPVsPt_
static constexpr int cmToUm
bool isValid() const
Definition: HandleBase.h:70
MonitorElement * yerr[2]
fixed size matrix
HLT enums.
void analyze(const edm::Event &, const edm::EventSetup &) override
MonitorElement * xrec[2]
MonitorElement * vtxprob[2]
dqm::reco::MonitorElement * makeTH1IfLog(DQMStore::IBooker &ibook, bool logx, bool logy, Args &&...args)
const edm::EDGetTokenT< reco::VertexCollection > vertexToken_
Log< level::Warning, false > LogWarning
MonitorElement * bsBeamWidthY
MonitorElement * book1D(TString const &name, TString const &title, int const nchX, double const lowX, double const highX, FUNC onbooking=NOOP())
Definition: DQMStore.h:98
MonitorElement * score[2]
MonitorElement * yDiff[2]
std::vector< TrackBaseRef >::const_iterator trackRef_iterator
The iteratator for the vector<TrackRef>
Definition: Vertex.h:38
MonitorElement * trksWeight[2]
dqm::reco::MonitorElement * makeProfileIfLog(DQMStore::IBooker &ibook, bool logx, bool logy, Args &&...args)
PrimaryVertexMonitor(const edm::ParameterSet &pSet)
Definition: Run.h:45
MonitorElement * bsBeamWidthX
virtual void setAxisTitle(const std::string &title, int axis=1)
set x-, y- or z-axis title (axis=1, 2, 3 respectively)
const edm::InputTag beamSpotInputTag_