CMS 3D CMS Logo

PrimaryVertexMonitor.cc
Go to the documentation of this file.
5 
7 
9 
10 #include "TMath.h"
11 
12 using namespace reco;
13 using namespace edm;
14 
16  : conf_(pSet),
17  TopFolderName_(pSet.getParameter<std::string>("TopFolderName")),
18  AlignmentLabel_(pSet.getParameter<std::string>("AlignmentLabel")),
19  ndof_(pSet.getParameter<int>("ndof")),
20  useHPfoAlignmentPlots_(pSet.getParameter<bool>("useHPforAlignmentPlots")),
21  errorPrinted_(false),
22  nbvtx(nullptr),
23  bsX(nullptr),
24  bsY(nullptr),
25  bsZ(nullptr),
26  bsSigmaZ(nullptr),
27  bsDxdz(nullptr),
28  bsDydz(nullptr),
29  bsBeamWidthX(nullptr),
30  bsBeamWidthY(nullptr),
31  bsType(nullptr),
32  sumpt(nullptr),
33  ntracks(nullptr),
34  weight(nullptr),
35  chi2ndf(nullptr),
36  chi2prob(nullptr),
37  dxy(nullptr),
38  dxy2(nullptr),
39  dz(nullptr),
40  dxyErr(nullptr),
41  dzErr(nullptr),
42  phi_pt1(nullptr),
43  eta_pt1(nullptr),
44  phi_pt10(nullptr),
45  eta_pt10(nullptr),
46  dxyVsPhi_pt1(nullptr),
47  dzVsPhi_pt1(nullptr),
48  dxyVsEta_pt1(nullptr),
49  dzVsEta_pt1(nullptr),
50  dxyVsEtaVsPhi_pt1(nullptr),
51  dzVsEtaVsPhi_pt1(nullptr),
52  dxyVsPhi_pt10(nullptr),
53  dzVsPhi_pt10(nullptr),
54  dxyVsEta_pt10(nullptr),
55  dzVsEta_pt10(nullptr),
56  dxyVsEtaVsPhi_pt10(nullptr),
57  dzVsEtaVsPhi_pt10(nullptr) {
58  vertexInputTag_ = pSet.getParameter<InputTag>("vertexLabel");
59  beamSpotInputTag_ = pSet.getParameter<InputTag>("beamSpotLabel");
60  vertexToken_ = consumes<reco::VertexCollection>(vertexInputTag_);
61  scoreToken_ = consumes<VertexScore>(vertexInputTag_);
62  beamspotToken_ = consumes<reco::BeamSpot>(beamSpotInputTag_);
63 }
64 
65 // -- BeginRun
66 //---------------------------------------------------------------------------------//
68  std::string dqmLabel = "";
69 
70  //
71  // Book all histograms.
72  //
73 
74  // get the store
76  iBooker.setCurrentFolder(dqmLabel);
77 
78  // xPos = iBooker.book1D ("xPos","x Coordinate" ,100, -0.1, 0.1);
79 
80  nbvtx = iBooker.book1D("vtxNbr", "Reconstructed Vertices in Event", 80, -0.5, 79.5);
81  nbgvtx = iBooker.book1D("goodvtxNbr", "Reconstructed Good Vertices in Event", 80, -0.5, 79.5);
82 
83  // to be configured each year...
84  auto vposx = conf_.getParameter<double>("Xpos");
85  auto vposy = conf_.getParameter<double>("Ypos");
86 
87  nbtksinvtx[0] = iBooker.book1D("otherVtxTrksNbr", "Reconstructed Tracks in Vertex (other Vtx)", 40, -0.5, 99.5);
88  ntracksVsZ[0] = iBooker.bookProfile(
89  "otherVtxTrksVsZ", "Reconstructed Tracks in Vertex (other Vtx) vs Z", 80, -20., 20., 50, 0, 100, "");
90  ntracksVsZ[0]->setAxisTitle("z-bs", 1);
91  ntracksVsZ[0]->setAxisTitle("#tracks", 2);
92 
93  score[0] = iBooker.book1D("otherVtxScore", "sqrt(score) (other Vtx)", 100, 0., 400.);
94  trksWeight[0] = iBooker.book1D("otherVtxTrksWeight", "Total weight of Tracks in Vertex (other Vtx)", 40, 0, 100.);
95  vtxchi2[0] = iBooker.book1D("otherVtxChi2", "#chi^{2} (other Vtx)", 100, 0., 200.);
96  vtxndf[0] = iBooker.book1D("otherVtxNdf", "ndof (other Vtx)", 100, 0., 200.);
97  vtxprob[0] = iBooker.book1D("otherVtxProb", "#chi^{2} probability (other Vtx)", 100, 0., 1.);
98  nans[0] = iBooker.book1D("otherVtxNans", "Illegal values for x,y,z,xx,xy,xz,yy,yz,zz (other Vtx)", 9, 0.5, 9.5);
99 
100  nbtksinvtx[1] = iBooker.book1D("tagVtxTrksNbr", "Reconstructed Tracks in Vertex (tagged Vtx)", 100, -0.5, 99.5);
101  ntracksVsZ[1] = iBooker.bookProfile(
102  "tagVtxTrksVsZ", "Reconstructed Tracks in Vertex (tagged Vtx) vs Z", 80, -20., 20., 50, 0, 100, "");
103  ntracksVsZ[1]->setAxisTitle("z-bs", 1);
104  ntracksVsZ[1]->setAxisTitle("#tracks", 2);
105 
106  score[1] = iBooker.book1D("tagVtxScore", "sqrt(score) (tagged Vtx)", 100, 0., 400.);
107  trksWeight[1] = iBooker.book1D("tagVtxTrksWeight", "Total weight of Tracks in Vertex (tagged Vtx)", 100, 0, 100.);
108  vtxchi2[1] = iBooker.book1D("tagVtxChi2", "#chi^{2} (tagged Vtx)", 100, 0., 200.);
109  vtxndf[1] = iBooker.book1D("tagVtxNdf", "ndof (tagged Vtx)", 100, 0., 200.);
110  vtxprob[1] = iBooker.book1D("tagVtxProb", "#chi^{2} probability (tagged Vtx)", 100, 0., 1.);
111  nans[1] = iBooker.book1D("tagVtxNans", "Illegal values for x,y,z,xx,xy,xz,yy,yz,zz (tagged Vtx)", 9, 0.5, 9.5);
112 
113  xrec[0] = iBooker.book1D("otherPosX", "Position x Coordinate (other Vtx)", 100, vposx - 0.1, vposx + 0.1);
114  yrec[0] = iBooker.book1D("otherPosY", "Position y Coordinate (other Vtx)", 100, vposy - 0.1, vposy + 0.1);
115  zrec[0] = iBooker.book1D("otherPosZ", "Position z Coordinate (other Vtx)", 100, -20., 20.);
116  xDiff[0] = iBooker.book1D("otherDiffX", "X distance from BeamSpot (other Vtx)", 100, -500, 500);
117  yDiff[0] = iBooker.book1D("otherDiffY", "Y distance from BeamSpot (other Vtx)", 100, -500, 500);
118  xerr[0] = iBooker.book1D("otherErrX", "Uncertainty x Coordinate (other Vtx)", 100, 0., 100);
119  yerr[0] = iBooker.book1D("otherErrY", "Uncertainty y Coordinate (other Vtx)", 100, 0., 100);
120  zerr[0] = iBooker.book1D("otherErrZ", "Uncertainty z Coordinate (other Vtx)", 100, 0., 100);
121  xerrVsTrks[0] = iBooker.book2D(
122  "otherErrVsWeightX", "Uncertainty x Coordinate vs. track weight (other Vtx)", 100, 0, 100., 100, 0., 100);
123  yerrVsTrks[0] = iBooker.book2D(
124  "otherErrVsWeightY", "Uncertainty y Coordinate vs. track weight (other Vtx)", 100, 0, 100., 100, 0., 100);
125  zerrVsTrks[0] = iBooker.book2D(
126  "otherErrVsWeightZ", "Uncertainty z Coordinate vs. track weight (other Vtx)", 100, 0, 100., 100, 0., 100);
127 
128  xrec[1] = iBooker.book1D("tagPosX", "Position x Coordinate (tagged Vtx)", 100, vposx - 0.1, vposx + 0.1);
129  yrec[1] = iBooker.book1D("tagPosY", "Position y Coordinate (tagged Vtx)", 100, vposy - 0.1, vposy + 0.1);
130  zrec[1] = iBooker.book1D("tagPosZ", "Position z Coordinate (tagged Vtx)", 100, -20., 20.);
131  xDiff[1] = iBooker.book1D("tagDiffX", "X distance from BeamSpot (tagged Vtx)", 100, -500, 500);
132  yDiff[1] = iBooker.book1D("tagDiffY", "Y distance from BeamSpot (tagged Vtx)", 100, -500, 500);
133  xerr[1] = iBooker.book1D("tagErrX", "Uncertainty x Coordinate (tagged Vtx)", 100, 0., 100);
134  yerr[1] = iBooker.book1D("tagErrY", "Uncertainty y Coordinate (tagged Vtx)", 100, 0., 100);
135  zerr[1] = iBooker.book1D("tagErrZ", "Uncertainty z Coordinate (tagged Vtx)", 100, 0., 100);
136  xerrVsTrks[1] = iBooker.book2D(
137  "tagErrVsWeightX", "Uncertainty x Coordinate vs. track weight (tagged Vtx)", 100, 0, 100., 100, 0., 100);
138  yerrVsTrks[1] = iBooker.book2D(
139  "tagErrVsWeightY", "Uncertainty y Coordinate vs. track weight (tagged Vtx)", 100, 0, 100., 100, 0., 100);
140  zerrVsTrks[1] = iBooker.book2D(
141  "tagErrVsWeightZ", "Uncertainty z Coordinate vs. track weight (tagged Vtx)", 100, 0, 100., 100, 0., 100);
142 
143  type[0] = iBooker.book1D("otherType", "Vertex type (other Vtx)", 3, -0.5, 2.5);
144  type[1] = iBooker.book1D("tagType", "Vertex type (tagged Vtx)", 3, -0.5, 2.5);
145  for (int i = 0; i < 2; ++i) {
146  type[i]->setBinLabel(1, "Valid, real");
147  type[i]->setBinLabel(2, "Valid, fake");
148  type[i]->setBinLabel(3, "Invalid");
149  }
150 
151  // get the store
153  iBooker.setCurrentFolder(dqmLabel);
154 
155  bsX = iBooker.book1D("bsX", "BeamSpot x0", 100, -0.1, 0.1);
156  bsY = iBooker.book1D("bsY", "BeamSpot y0", 100, -0.1, 0.1);
157  bsZ = iBooker.book1D("bsZ", "BeamSpot z0", 100, -2., 2.);
158  bsSigmaZ = iBooker.book1D("bsSigmaZ", "BeamSpot sigmaZ", 100, 0., 10.);
159  bsDxdz = iBooker.book1D("bsDxdz", "BeamSpot dxdz", 100, -0.0003, 0.0003);
160  bsDydz = iBooker.book1D("bsDydz", "BeamSpot dydz", 100, -0.0003, 0.0003);
161  bsBeamWidthX = iBooker.book1D("bsBeamWidthX", "BeamSpot BeamWidthX", 100, 0., 100.);
162  bsBeamWidthY = iBooker.book1D("bsBeamWidthY", "BeamSpot BeamWidthY", 100, 0., 100.);
163  bsType = iBooker.book1D("bsType", "BeamSpot type", 4, -1.5, 2.5);
164  bsType->setBinLabel(1, "Unknown");
165  bsType->setBinLabel(2, "Fake");
166  bsType->setBinLabel(3, "LHC");
167  bsType->setBinLabel(4, "Tracker");
168 
169  // get the store
171  iBooker.setCurrentFolder(dqmLabel);
172 
173  int TKNoBin = conf_.getParameter<int>("TkSizeBin");
174  double TKNoMin = conf_.getParameter<double>("TkSizeMin");
175  double TKNoMax = conf_.getParameter<double>("TkSizeMax");
176 
177  int DxyBin = conf_.getParameter<int>("DxyBin");
178  double DxyMin = conf_.getParameter<double>("DxyMin");
179  double DxyMax = conf_.getParameter<double>("DxyMax");
180 
181  int DzBin = conf_.getParameter<int>("DzBin");
182  double DzMin = conf_.getParameter<double>("DzMin");
183  double DzMax = conf_.getParameter<double>("DzMax");
184 
185  int PhiBin = conf_.getParameter<int>("PhiBin");
186  int PhiBin2D = conf_.getParameter<int>("PhiBin2D");
187  double PhiMin = conf_.getParameter<double>("PhiMin");
188  double PhiMax = conf_.getParameter<double>("PhiMax");
189 
190  int EtaBin = conf_.getParameter<int>("EtaBin");
191  int EtaBin2D = conf_.getParameter<int>("EtaBin2D");
192  double EtaMin = conf_.getParameter<double>("EtaMin");
193  double EtaMax = conf_.getParameter<double>("EtaMax");
194 
195  ntracks = iBooker.book1D("ntracks", "number of PV tracks (p_{T} > 1 GeV)", TKNoBin, TKNoMin, TKNoMax);
196  ntracks->setAxisTitle("Number of PV Tracks (p_{T} > 1 GeV) per Event", 1);
197  ntracks->setAxisTitle("Number of Event", 2);
198 
199  weight = iBooker.book1D("weight", "weight of PV tracks (p_{T} > 1 GeV)", 100, 0., 1.);
200  weight->setAxisTitle("weight of PV Tracks (p_{T} > 1 GeV) per Event", 1);
201  weight->setAxisTitle("Number of Event", 2);
202 
203  sumpt = iBooker.book1D("sumpt", "#Sum p_{T} of PV tracks (p_{T} > 1 GeV)", 100, -0.5, 249.5);
204  chi2ndf = iBooker.book1D("chi2ndf", "PV tracks (p_{T} > 1 GeV) #chi^{2}/ndof", 100, 0., 20.);
205  chi2prob = iBooker.book1D("chi2prob", "PV tracks (p_{T} > 1 GeV) #chi^{2} probability", 100, 0., 1.);
206 
207  dxy = iBooker.book1D("dxy", "PV tracks (p_{T} > 1 GeV) d_{xy} (#mum)", DxyBin, DxyMin, DxyMax);
208  dxy2 = iBooker.book1D("dxyzoom", "PV tracks (p_{T} > 1 GeV) d_{xy} (#mum)", DxyBin, DxyMin / 5., DxyMax / 5.);
209  dxyErr = iBooker.book1D("dxyErr", "PV tracks (p_{T} > 1 GeV) d_{xy} error (#mum)", 100, 0., 2000.);
210  dz = iBooker.book1D("dz", "PV tracks (p_{T} > 1 GeV) d_{z} (#mum)", DzBin, DzMin, DzMax);
211  dzErr = iBooker.book1D("dzErr", "PV tracks (p_{T} > 1 GeV) d_{z} error(#mum)", 100, 0., 10000.);
212 
213  phi_pt1 = iBooker.book1D("phi_pt1", "PV tracks (p_{T} > 1 GeV) #phi; PV tracks #phi;#tracks", PhiBin, PhiMin, PhiMax);
214  eta_pt1 = iBooker.book1D("eta_pt1", "PV tracks (p_{T} > 1 GeV) #eta; PV tracks #eta;#tracks", EtaBin, EtaMin, EtaMax);
215  phi_pt10 =
216  iBooker.book1D("phi_pt10", "PV tracks (p_{T} > 10 GeV) #phi; PV tracks #phi;#tracks", PhiBin, PhiMin, PhiMax);
217  eta_pt10 =
218  iBooker.book1D("eta_pt10", "PV tracks (p_{T} > 10 GeV) #phi; PV tracks #eta;#tracks", EtaBin, EtaMin, EtaMax);
219 
220  dxyVsPhi_pt1 = iBooker.bookProfile("dxyVsPhi_pt1",
221  "PV tracks (p_{T} > 1 GeV) d_{xy} (#mum) VS track #phi",
222  PhiBin,
223  PhiMin,
224  PhiMax,
225  DxyBin,
226  DxyMin,
227  DxyMax,
228  "");
229  dxyVsPhi_pt1->setAxisTitle("PV track (p_{T} > 1 GeV) #phi", 1);
230  dxyVsPhi_pt1->setAxisTitle("PV track (p_{T} > 1 GeV) d_{xy} (#mum)", 2);
231 
232  dzVsPhi_pt1 = iBooker.bookProfile("dzVsPhi_pt1",
233  "PV tracks (p_{T} > 1 GeV) d_{z} (#mum) VS track #phi",
234  PhiBin,
235  PhiMin,
236  PhiMax,
237  DzBin,
238  DzMin,
239  DzMax,
240  "");
241  dzVsPhi_pt1->setAxisTitle("PV track (p_{T} > 1 GeV) #phi", 1);
242  dzVsPhi_pt1->setAxisTitle("PV track (p_{T} > 1 GeV) d_{z} (#mum)", 2);
243 
244  dxyVsEta_pt1 = iBooker.bookProfile("dxyVsEta_pt1",
245  "PV tracks (p_{T} > 1 GeV) d_{xy} (#mum) VS track #eta",
246  EtaBin,
247  EtaMin,
248  EtaMax,
249  DxyBin,
250  DxyMin,
251  DxyMax,
252  "");
253  dxyVsEta_pt1->setAxisTitle("PV track (p_{T} > 1 GeV) #eta", 1);
254  dxyVsEta_pt1->setAxisTitle("PV track (p_{T} > 1 GeV) d_{xy} (#mum)", 2);
255 
256  dzVsEta_pt1 = iBooker.bookProfile("dzVsEta_pt1",
257  "PV tracks (p_{T} > 1 GeV) d_{z} (#mum) VS track #eta",
258  EtaBin,
259  EtaMin,
260  EtaMax,
261  DzBin,
262  DzMin,
263  DzMax,
264  "");
265  dzVsEta_pt1->setAxisTitle("PV track (p_{T} > 1 GeV) #eta", 1);
266  dzVsEta_pt1->setAxisTitle("PV track (p_{T} > 1 GeV) d_{z} (#mum)", 2);
267 
268  dxyVsEtaVsPhi_pt1 = iBooker.bookProfile2D("dxyVsEtaVsPhi_pt1",
269  "PV tracks (p_{T} > 1 GeV) d_{xy} (#mum) VS track #eta VS track #phi",
270  EtaBin2D,
271  EtaMin,
272  EtaMax,
273  PhiBin2D,
274  PhiMin,
275  PhiMax,
276  DxyBin,
277  DxyMin,
278  DxyMax,
279  "");
280  dxyVsEtaVsPhi_pt1->setAxisTitle("PV track (p_{T} > 1 GeV) #eta", 1);
281  dxyVsEtaVsPhi_pt1->setAxisTitle("PV track (p_{T} > 1 GeV) #phi", 2);
282  dxyVsEtaVsPhi_pt1->setAxisTitle("PV track (p_{T} > 1 GeV) d_{xy} (#mum)", 3);
283 
284  dzVsEtaVsPhi_pt1 = iBooker.bookProfile2D("dzVsEtaVsPhi_pt1",
285  "PV tracks (p_{T} > 1 GeV) d_{z} (#mum) VS track #eta VS track #phi",
286  EtaBin2D,
287  EtaMin,
288  EtaMax,
289  PhiBin2D,
290  PhiMin,
291  PhiMax,
292  DzBin,
293  DzMin,
294  DzMax,
295  "");
296  dzVsEtaVsPhi_pt1->setAxisTitle("PV track (p_{T} > 1 GeV) #eta", 1);
297  dzVsEtaVsPhi_pt1->setAxisTitle("PV track (p_{T} > 1 GeV) #phi", 2);
298  dzVsEtaVsPhi_pt1->setAxisTitle("PV track (p_{T} > 1 GeV) d_{z} (#mum)", 3);
299 
300  dxyVsPhi_pt10 = iBooker.bookProfile("dxyVsPhi_pt10",
301  "PV tracks (p_{T} > 10 GeV) d_{xy} (#mum) VS track #phi",
302  PhiBin,
303  PhiMin,
304  PhiMax,
305  DxyBin,
306  DxyMin,
307  DxyMax,
308  "");
309  dxyVsPhi_pt10->setAxisTitle("PV track (p_{T} > 10 GeV) #phi", 1);
310  dxyVsPhi_pt10->setAxisTitle("PV track (p_{T} > 10 GeV) d_{xy} (#mum)", 2);
311 
312  dzVsPhi_pt10 = iBooker.bookProfile("dzVsPhi_pt10",
313  "PV tracks (p_{T} > 10 GeV) d_{z} (#mum) VS track #phi",
314  PhiBin,
315  PhiMin,
316  PhiMax,
317  DzBin,
318  DzMin,
319  DzMax,
320  "");
321  dzVsPhi_pt10->setAxisTitle("PV track (p_{T} > 10 GeV) #phi", 1);
322  dzVsPhi_pt10->setAxisTitle("PV track (p_{T} > 10 GeV) d_{z} (#mum)", 2);
323 
324  dxyVsEta_pt10 = iBooker.bookProfile("dxyVsEta_pt10",
325  "PV tracks (p_{T} > 10 GeV) d_{xy} (#mum) VS track #eta",
326  EtaBin,
327  EtaMin,
328  EtaMax,
329  DxyBin,
330  DxyMin,
331  DxyMax,
332  "");
333  dxyVsEta_pt10->setAxisTitle("PV track (p_{T} > 10 GeV) #eta", 1);
334  dxyVsEta_pt10->setAxisTitle("PV track (p_{T} > 10 GeV) d_{xy} (#mum)", 2);
335 
336  dzVsEta_pt10 = iBooker.bookProfile("dzVsEta_pt10",
337  "PV tracks (p_{T} > 10 GeV) d_{z} (#mum) VS track #eta",
338  EtaBin,
339  EtaMin,
340  EtaMax,
341  DzBin,
342  DzMin,
343  DzMax,
344  "");
345  dzVsEta_pt10->setAxisTitle("PV track (p_{T} > 10 GeV) #eta", 1);
346  dzVsEta_pt10->setAxisTitle("PV track (p_{T} > 10 GeV) d_{z} (#mum)", 2);
347 
348  dxyVsEtaVsPhi_pt10 = iBooker.bookProfile2D("dxyVsEtaVsPhi_pt10",
349  "PV tracks (p_{T} > 10 GeV) d_{xy} (#mum) VS track #eta VS track #phi",
350  EtaBin2D,
351  EtaMin,
352  EtaMax,
353  PhiBin2D,
354  PhiMin,
355  PhiMax,
356  DxyBin,
357  DxyMin,
358  DxyMax,
359  "");
360  dxyVsEtaVsPhi_pt10->setAxisTitle("PV track (p_{T} > 10 GeV) #eta", 1);
361  dxyVsEtaVsPhi_pt10->setAxisTitle("PV track (p_{T} > 10 GeV) #phi", 2);
362  dxyVsEtaVsPhi_pt10->setAxisTitle("PV track (p_{T} > 10 GeV) d_{xy} (#mum)", 3);
363 
364  dzVsEtaVsPhi_pt10 = iBooker.bookProfile2D("dzVsEtaVsPhi_pt10",
365  "PV tracks (p_{T} > 10 GeV) d_{z} (#mum) VS track #eta VS track #phi",
366  EtaBin2D,
367  EtaMin,
368  EtaMax,
369  PhiBin2D,
370  PhiMin,
371  PhiMax,
372  DzBin,
373  DzMin,
374  DzMax,
375  "");
376  dzVsEtaVsPhi_pt10->setAxisTitle("PV track (p_{T} > 10 GeV) #eta", 1);
377  dzVsEtaVsPhi_pt10->setAxisTitle("PV track (p_{T} > 10 GeV) #phi", 2);
378  dzVsEtaVsPhi_pt10->setAxisTitle("PV track (p_{T} > 10 GeV) d_{z} (#mum)", 3);
379 }
380 
383  iEvent.getByToken(vertexToken_, recVtxs);
384 
385  Handle<VertexScore> scores;
386  iEvent.getByToken(scoreToken_, scores);
387 
388  edm::Handle<reco::BeamSpot> beamSpotHandle;
389  iEvent.getByToken(beamspotToken_, beamSpotHandle);
390 
391  //
392  // check for absent products and simply "return" in that case
393  //
394  if (recVtxs.isValid() == false || beamSpotHandle.isValid() == false) {
395  edm::LogWarning("PrimaryVertexMonitor")
396  << " Some products not available in the event: VertexCollection " << vertexInputTag_ << " " << recVtxs.isValid()
397  << " BeamSpot " << beamSpotInputTag_ << " " << beamSpotHandle.isValid() << ". Skipping plots for this event";
398  return;
399  }
400 
401  // check upfront that refs to track are (likely) to be valid
402  {
403  bool ok = true;
404  for (const auto& v : *recVtxs) {
405  if (v.tracksSize() > 0) {
406  const auto& ref = v.trackRefAt(0);
407  if (ref.isNull() || !ref.isAvailable()) {
408  if (!errorPrinted_)
409  edm::LogWarning("PrimaryVertexMonitor")
410  << "Skipping vertex collection: " << vertexInputTag_
411  << " since likely the track collection the vertex has refs pointing to is missing (at least the first "
412  "TrackBaseRef is null or not available)";
413  else
414  errorPrinted_ = true;
415  ok = false;
416  }
417  }
418  }
419  if (!ok)
420  return;
421  }
422 
423  BeamSpot beamSpot = *beamSpotHandle;
424 
425  nbvtx->Fill(recVtxs->size() * 1.);
426  int ng = 0;
427  for (auto const& vx : (*recVtxs))
428  if (vx.isValid() && !vx.isFake() && vx.ndof() >= ndof_)
429  ++ng;
430  nbgvtx->Fill(ng * 1.);
431 
432  if (scores.isValid() && !(*scores).empty()) {
433  auto pvScore = (*scores).get(0);
434  score[1]->Fill(std::sqrt(pvScore));
435  for (unsigned int i = 1; i < (*scores).size(); ++i)
436  score[0]->Fill(std::sqrt((*scores).get(i)));
437  }
438 
439  // fill PV tracks MEs (as now, for alignment)
440  if (!recVtxs->empty()) {
441  vertexPlots(recVtxs->front(), beamSpot, 1);
442  pvTracksPlots(recVtxs->front());
443 
444  for (reco::VertexCollection::const_iterator v = recVtxs->begin() + 1; v != recVtxs->end(); ++v)
445  vertexPlots(*v, beamSpot, 0);
446  }
447 
448  // Beamline plots:
449  bsX->Fill(beamSpot.x0());
450  bsY->Fill(beamSpot.y0());
451  bsZ->Fill(beamSpot.z0());
452  bsSigmaZ->Fill(beamSpot.sigmaZ());
453  bsDxdz->Fill(beamSpot.dxdz());
454  bsDydz->Fill(beamSpot.dydz());
455  bsBeamWidthX->Fill(beamSpot.BeamWidthX() * cmToUm);
456  bsBeamWidthY->Fill(beamSpot.BeamWidthY() * cmToUm);
457  // bsType->Fill(beamSpot.type());
458 }
459 
461  if (!v.isValid())
462  return;
463  if (v.isFake())
464  return;
465 
466  if (v.tracksSize() == 0) {
467  ntracks->Fill(0);
468  return;
469  }
470 
471  const math::XYZPoint myVertex(v.position().x(), v.position().y(), v.position().z());
472 
473  size_t nTracks = 0;
474  float sumPT = 0.;
475 
476  for (reco::Vertex::trackRef_iterator t = v.tracks_begin(); t != v.tracks_end(); t++) {
477  bool isHighPurity = (**t).quality(reco::TrackBase::highPurity);
478  if (!isHighPurity && useHPfoAlignmentPlots_)
479  continue;
480 
481  float pt = (**t).pt();
482  if (pt < 1.)
483  continue;
484 
485  nTracks++;
486 
487  float eta = (**t).eta();
488  float phi = (**t).phi();
489 
490  float w = v.trackWeight(*t);
491  float chi2NDF = (**t).normalizedChi2();
492  float chi2Prob = TMath::Prob((**t).chi2(), (int)(**t).ndof());
493  float Dxy = (**t).dxy(myVertex) * cmToUm;
494  float Dz = (**t).dz(myVertex) * cmToUm;
495  float DxyErr = (**t).dxyError() * cmToUm;
496  float DzErr = (**t).dzError() * cmToUm;
497 
498  sumPT += pt * pt;
499 
500  // fill MEs
501  weight->Fill(w);
502  chi2ndf->Fill(chi2NDF);
503  chi2prob->Fill(chi2Prob);
504  dxy->Fill(Dxy);
505  dxy2->Fill(Dxy);
506  dz->Fill(Dz);
507  dxyErr->Fill(DxyErr);
508  dzErr->Fill(DzErr);
509  phi_pt1->Fill(phi);
510  eta_pt1->Fill(eta);
511 
512  dxyVsPhi_pt1->Fill(phi, Dxy);
513  dzVsPhi_pt1->Fill(phi, Dz);
514  dxyVsEta_pt1->Fill(eta, Dxy);
515  dzVsEta_pt1->Fill(eta, Dz);
516  dxyVsEtaVsPhi_pt1->Fill(eta, phi, Dxy);
517  dzVsEtaVsPhi_pt1->Fill(eta, phi, Dz);
518 
519  if (pt < 10.)
520  continue;
521 
522  phi_pt10->Fill(phi);
523  eta_pt10->Fill(eta);
524  dxyVsPhi_pt10->Fill(phi, Dxy);
525  dzVsPhi_pt10->Fill(phi, Dz);
526  dxyVsEta_pt10->Fill(eta, Dxy);
527  dzVsEta_pt10->Fill(eta, Dz);
528  dxyVsEtaVsPhi_pt10->Fill(eta, phi, Dxy);
529  dzVsEtaVsPhi_pt10->Fill(eta, phi, Dz);
530  }
531  ntracks->Fill(float(nTracks));
532  sumpt->Fill(sumPT);
533 }
534 
536  if (i < 0 || i > 1)
537  return;
538  if (!v.isValid())
539  type[i]->Fill(2.);
540  else if (v.isFake())
541  type[i]->Fill(1.);
542  else
543  type[i]->Fill(0.);
544 
545  if (v.isValid() && !v.isFake()) {
546  float weight = 0;
547  for (reco::Vertex::trackRef_iterator t = v.tracks_begin(); t != v.tracks_end(); t++)
548  weight += v.trackWeight(*t);
549  trksWeight[i]->Fill(weight);
550  nbtksinvtx[i]->Fill(v.tracksSize());
551  ntracksVsZ[i]->Fill(v.position().z() - beamSpot.z0(), v.tracksSize());
552 
553  vtxchi2[i]->Fill(v.chi2());
554  vtxndf[i]->Fill(v.ndof());
555  vtxprob[i]->Fill(ChiSquaredProbability(v.chi2(), v.ndof()));
556 
557  xrec[i]->Fill(v.position().x());
558  yrec[i]->Fill(v.position().y());
559  zrec[i]->Fill(v.position().z());
560 
561  float xb = beamSpot.x0() + beamSpot.dxdz() * (v.position().z() - beamSpot.z0());
562  float yb = beamSpot.y0() + beamSpot.dydz() * (v.position().z() - beamSpot.z0());
563  xDiff[i]->Fill((v.position().x() - xb) * cmToUm);
564  yDiff[i]->Fill((v.position().y() - yb) * cmToUm);
565 
566  xerr[i]->Fill(v.xError() * cmToUm);
567  yerr[i]->Fill(v.yError() * cmToUm);
568  zerr[i]->Fill(v.zError() * cmToUm);
569  xerrVsTrks[i]->Fill(weight, v.xError() * cmToUm);
570  yerrVsTrks[i]->Fill(weight, v.yError() * cmToUm);
571  zerrVsTrks[i]->Fill(weight, v.zError() * cmToUm);
572 
573  nans[i]->Fill(1., edm::isNotFinite(v.position().x()) * 1.);
574  nans[i]->Fill(2., edm::isNotFinite(v.position().y()) * 1.);
575  nans[i]->Fill(3., edm::isNotFinite(v.position().z()) * 1.);
576 
577  int index = 3;
578  for (int k = 0; k != 3; k++) {
579  for (int j = k; j != 3; j++) {
580  index++;
581  nans[i]->Fill(index * 1., edm::isNotFinite(v.covariance(k, j)) * 1.);
582  // in addition, diagonal element must be positive
583  if (j == k && v.covariance(k, j) < 0) {
584  nans[i]->Fill(index * 1., 1.);
585  }
586  }
587  }
588  }
589 }
590 
591 //define this as a plug-in
MonitorElement * xerrVsTrks[2]
MonitorElement * xerr[2]
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
MonitorElement * vtxndf[2]
MonitorElement * dxyVsEta_pt1
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:476
MonitorElement * dzVsPhi_pt10
MonitorElement * dzVsPhi_pt1
void pvTracksPlots(const reco::Vertex &v)
virtual void setCurrentFolder(std::string const &fullpath)
Definition: DQMStore.cc:32
void vertexPlots(const reco::Vertex &v, const reco::BeamSpot &beamSpot, int i)
T w() const
constexpr bool isNotFinite(T x)
Definition: isFinite.h:9
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
MonitorElement * bsSigmaZ
edm::InputTag beamSpotInputTag_
MonitorElement * eta_pt1
edm::EDGetTokenT< VertexScore > scoreToken_
Definition: weight.py:1
MonitorElement * dxyVsEtaVsPhi_pt10
MonitorElement * dzVsEtaVsPhi_pt1
MonitorElement * chi2ndf
MonitorElement * dxyVsPhi_pt10
std::string const & label() const
Definition: InputTag.h:36
MonitorElement * xDiff[2]
MonitorElement * dzVsEta_pt1
MonitorElement * ntracksVsZ[2]
edm::ParameterSet conf_
MonitorElement * zerrVsTrks[2]
MonitorElement * nans[2]
void Fill(long long x)
MonitorElement * phi_pt10
int iEvent
Definition: GenABIO.cc:224
MonitorElement * yerrVsTrks[2]
void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override
MonitorElement * dxyVsEta_pt10
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:399
void Fill(HcalDetId &id, double val, std::vector< TH2F > &depth)
MonitorElement * zerr[2]
T sqrt(T t)
Definition: SSEVec.h:19
MonitorElement * yrec[2]
float ChiSquaredProbability(double chiSquared, double nrDOF)
MonitorElement * zrec[2]
MonitorElement * vtxchi2[2]
edm::EDGetTokenT< reco::BeamSpot > beamspotToken_
edm::EDGetTokenT< reco::VertexCollection > vertexToken_
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)
MonitorElement * eta_pt10
MonitorElement * dzVsEta_pt10
MonitorElement * dxyVsEtaVsPhi_pt1
MonitorElement * chi2prob
XYZPointD XYZPoint
point in space with cartesian internal representation
Definition: Point3D.h:12
MonitorElement * nbtksinvtx[2]
MonitorElement * phi_pt1
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:212
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]
MonitorElement * ntracks
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 * dzVsEtaVsPhi_pt10
MonitorElement * yDiff[2]
std::vector< TrackBaseRef >::const_iterator trackRef_iterator
The iteratator for the vector<TrackRef>
Definition: Vertex.h:38
MonitorElement * trksWeight[2]
PrimaryVertexMonitor(const edm::ParameterSet &pSet)
Definition: Run.h:45
MonitorElement * bsBeamWidthX
MonitorElement * dxyVsPhi_pt1
virtual void setAxisTitle(const std::string &title, int axis=1)
set x-, y- or z-axis title (axis=1, 2, 3 respectively)