CMS 3D CMS Logo

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