CMS 3D CMS Logo

PackedCandidateTrackValidator.cc
Go to the documentation of this file.
9 
12 
21 
24 
25 #include "boost/math/special_functions/sign.hpp"
26 
27 #include <iomanip>
28 
29 namespace {
30  using dqm::reco::DQMStore;
32 
33  template <typename T>
34  void fillNoFlow(MonitorElement* me, T val) {
35  auto h = me->getTH1();
36  const auto xaxis = h->GetXaxis();
37  if (val <= xaxis->GetXmin())
38  h->AddBinContent(xaxis->GetFirst());
39  else if (val >= xaxis->GetXmax())
40  h->AddBinContent(xaxis->GetLast());
41  else
42  h->Fill(val);
43  }
44 
45  class HitPatternPrinter {
46  public:
47  explicit HitPatternPrinter(const reco::Track& trk) : track(trk) {}
48 
49  void print(std::ostream& os) const {
50  const reco::HitPattern& p = track.hitPattern();
51 
52  for (int i = 0; i < p.numberOfAllHits(reco::HitPattern::TRACK_HITS); ++i) {
54 
55  detLayer(os, p, hit);
56  if (p.missingHitFilter(hit)) {
57  os << "(miss)";
58  } else if (p.inactiveHitFilter(hit)) {
59  os << "(inact)";
60  } else if (p.badHitFilter(hit)) {
61  os << "(bad)";
62  }
63  os << " ";
64  }
65 
67  os << "lost inner ";
68 
71  detLayer(os, p, hit);
72  if (p.missingHitFilter(hit)) {
73  os << "(miss)";
74  } else if (p.inactiveHitFilter(hit)) {
75  os << "(inact)";
76  }
77  }
78  }
80  os << "lost outer ";
81 
84  detLayer(os, p, hit);
85  if (p.missingHitFilter(hit)) {
86  os << "(miss)";
87  } else if (p.inactiveHitFilter(hit)) {
88  os << "(inact)";
89  }
90  }
91  }
92  }
93 
94  private:
95  static void detLayer(std::ostream& os, const reco::HitPattern& p, uint32_t hit) {
96  if (p.pixelBarrelHitFilter(hit)) {
97  os << "BPIX";
98  } else if (p.pixelEndcapHitFilter(hit)) {
99  os << "FPIX";
100  } else if (p.stripTIBHitFilter(hit)) {
101  os << "TIB";
102  } else if (p.stripTIDHitFilter(hit)) {
103  os << "TID";
104  } else if (p.stripTOBHitFilter(hit)) {
105  os << "TOB";
106  } else if (p.stripTECHitFilter(hit)) {
107  os << "TEC";
108  }
109  os << p.getLayer(hit);
110  }
111 
112  const reco::Track& track;
113  };
114 
115  std::ostream& operator<<(std::ostream& os, const HitPatternPrinter& hpp) {
116  hpp.print(os);
117  return os;
118  }
119 
120  class TrackAlgoPrinter {
121  public:
122  explicit TrackAlgoPrinter(const reco::Track& trk) : track(trk) {}
123 
124  void print(std::ostream& os) const {
126  for (int ialgo = 0; ialgo < reco::TrackBase::algoSize; ++ialgo) {
127  auto algo = static_cast<reco::TrackBase::TrackAlgorithm>(ialgo);
128  if (track.isAlgoInMask(algo)) {
129  algos.push_back(algo);
130  }
131  }
132 
133  os << "algo " << reco::TrackBase::algoName(track.algo());
134  if (track.originalAlgo() != track.algo())
135  os << " originalAlgo " << reco::TrackBase::algoName(track.originalAlgo());
136  if (algos.size() > 1) {
137  os << " algoMask";
138  for (auto algo : algos) {
139  os << " " << reco::TrackBase::algoName(algo);
140  }
141  }
142  }
143 
144  private:
145  const reco::Track& track;
146  };
147  std::ostream& operator<<(std::ostream& os, const TrackAlgoPrinter& tap) {
148  tap.print(os);
149  return os;
150  }
151 
152  double diffRelative(double a, double b) { return (a - b) / b; }
153 
154  class LogIntHelper {
155  public:
156  LogIntHelper(double lmin, double lmax) : lmin_(lmin), lmax_(lmax) {}
157 
158  class UnderOverflow {
159  public:
160  UnderOverflow(double largestValue, double smallestValue, std::function<double(double)> modifyUnpack)
161  : unpackedLargestValue_(modifyUnpack ? modifyUnpack(largestValue) : largestValue),
162  unpackedSmallestValue_(modifyUnpack ? modifyUnpack(smallestValue) : smallestValue) {}
163 
164  bool compatibleWithUnderflow(double value) const { return value == unpackedSmallestValue_; }
165  void printNonOkUnderflow(std::ostream& os) const { os << " (not min " << unpackedSmallestValue_ << ")"; }
166 
167  bool compatibleWithOverflow(double value) const { return value == unpackedLargestValue_; }
168  void printNonOkOverflow(std::ostream& os) const { os << " (not max " << unpackedLargestValue_ << ")"; }
169 
170  private:
171  // narrow to float to compare apples to apples with values from
172  // PackedCandidate (even though the final comparison is done in
173  // double)
174  const float unpackedLargestValue_;
175  const float unpackedSmallestValue_;
176  };
177 
178  static std::string maxName() { return "max"; }
179  static std::string minName() { return "min"; }
180 
181  UnderOverflow underOverflowHelper(double value, std::function<double(double)> modifyUnpack) const {
182  return UnderOverflow(
183  largestValue(), value >= 0 ? smallestPositiveValue() : std::abs(smallestNegativeValue()), modifyUnpack);
184  }
185 
186  double largestValue() const { return logintpack::unpack8log(127, lmin_, lmax_); }
187 
188  static bool wouldBeDenorm(double value) { return false; }
189 
190  // lessThan means closer to zero
191  bool lessThanSmallestValue(double value) const {
192  if (value >= 0)
193  return value < smallestPositiveValue();
194  else
195  return value > smallestNegativeValue();
196  }
197 
198  double smallestPositiveValue() const { return logintpack::unpack8log(logintpack::smallestPositive, lmin_, lmax_); }
199 
200  double smallestNegativeValue() const { return logintpack::unpack8log(logintpack::smallestNegative, lmin_, lmax_); }
201 
202  private:
203  const double lmin_;
204  const double lmax_;
205  };
206  class Float16Helper {
207  public:
208  class UnderOverflow {
209  public:
210  static void printNonOkUnderflow(std::ostream& os) { os << " (not 0)"; }
211  static bool compatibleWithUnderflow(double value) { return value == 0.0; }
212  static void printNonOkOverflow(std::ostream& os) { os << " (not inf)"; }
213  static bool compatibleWithOverflow(double value) { return edm::isNotFinite(value); }
214  };
215 
216  static std::string maxName() { return "inf"; }
217  static std::string minName() { return "0"; }
218 
219  static UnderOverflow underOverflowHelper(double value, std::function<double(double)>) { return UnderOverflow(); }
220 
221  static double largestValue() { return MiniFloatConverter::max32RoundedToMax16(); }
222 
223  static bool wouldBeDenorm(double value) {
224  const float valuef = static_cast<float>(value);
225  return valuef >= MiniFloatConverter::denorm_min() && valuef < MiniFloatConverter::min();
226  }
227 
228  static bool lessThanSmallestValue(double value) { return std::abs(value) < smallestValue(); }
229 
230  static double smallestValue() { return MiniFloatConverter::denorm_min(); }
231  };
232 
233  enum class RangeStatus {
234  inrange = 0,
235  inrange_signflip = 1,
236  denormal = 2,
237  underflow_OK = 3,
238  underflow_notOK = 4,
239  overflow_OK = 5,
240  overflow_notOK = 6
241  };
242  bool isInRange(RangeStatus status) { return status == RangeStatus::inrange || status == RangeStatus::denormal; }
243 
244  template <typename T>
245  class PackedValueCheckResult {
246  public:
247  PackedValueCheckResult(RangeStatus status,
248  double diff,
249  double pcvalue,
250  double trackvalue,
251  double rangeMin,
252  double rangeMax,
253  const typename T::UnderOverflow& underOverflow)
254  : diff_(diff),
255  pcvalue_(pcvalue),
256  trackvalue_(trackvalue),
257  rangeMin_(rangeMin),
258  rangeMax_(rangeMax),
259  status_(status),
260  underOverflow_(underOverflow) {}
261 
262  RangeStatus status() const { return status_; }
263  double diff() const { return diff_; }
264 
265  bool outsideExpectedRange() const {
266  if (status_ == RangeStatus::inrange)
267  return diff_ < rangeMin_ || diff_ > rangeMax_;
268  // denormal is considered as "in range" regardless of the expected range
269  return status_ == RangeStatus::underflow_notOK || status_ == RangeStatus::overflow_notOK ||
270  status_ == RangeStatus::inrange_signflip;
271  }
272 
273  void print(std::ostream& os) const {
274  if (outsideExpectedRange())
275  os << "!! ";
276  os << "(" << rangeMin_ << "," << rangeMax_ << ") ";
277 
278  os << diff_ << " " << pcvalue_;
279  if (status_ == RangeStatus::underflow_OK || status_ == RangeStatus::underflow_notOK) {
280  os << " (underflow) ";
281  if (status_ == RangeStatus::underflow_notOK)
282  underOverflow_.printNonOkUnderflow(os);
283  } else if (status_ == RangeStatus::overflow_OK || status_ == RangeStatus::overflow_notOK) {
284  os << " (overflow) ";
285  if (status_ == RangeStatus::overflow_notOK)
286  underOverflow_.printNonOkOverflow(os);
287  } else if (status_ == RangeStatus::denormal)
288  os << " (denormal)";
289  os << " " << trackvalue_;
290  }
291 
292  private:
293  const double diff_;
294  const double pcvalue_;
295  const double trackvalue_;
296  const double rangeMin_;
297  const double rangeMax_;
298  const RangeStatus status_;
299  const typename T::UnderOverflow underOverflow_;
300  };
301 
302  struct Range {
303  Range(double mi, double ma) : min(mi), max(ma) {}
304  const double min, max;
305  };
306  struct RangeAbs {
307  RangeAbs(double val) : min(-val), max(val) {}
308  const double min, max;
309  };
310 
311  template <typename T>
312  class PackedValueCheck {
313  public:
314  template <typename R, typename... Args>
315  PackedValueCheck(const R& range, Args&&... args)
316  : helper_(std::forward<Args>(args)...), rangeMin_(range.min), rangeMax_(range.max) {}
317 
318  void book(DQMStore::IBooker& iBooker,
319  const std::string& name,
320  const std::string& title,
321  int nbins,
322  double min,
323  double max,
324  int flow_nbins,
325  double flow_min,
326  double flow_max) {
327  hInrange = iBooker.book1D(name, title, nbins, min, max);
328  hUnderOverflowSign = iBooker.book1D(name + "UnderOverFlowSign",
329  title + " with over- and underflow, and sign flip",
330  flow_nbins,
331  flow_min,
332  flow_max);
333  hStatus = iBooker.book1D(name + "Status", title + " status", 7, -0.5, 6.5);
334  hStatus->setBinLabel(1, "In range");
335  hStatus->setBinLabel(2, "In range, sign flip");
336  hStatus->setBinLabel(3, "Denormal");
337  hStatus->setBinLabel(4, "Underflow, PC is " + T::minName());
338  hStatus->setBinLabel(5, "Underflow, PC is not " + T::minName());
339  hStatus->setBinLabel(6, "Overflow, PC is " + T::maxName());
340  hStatus->setBinLabel(7, "Overflow, PC is not " + T::maxName());
341  }
342 
343  PackedValueCheckResult<T> fill(double pcvalue,
344  double trackvalue,
345  std::function<double(double)> modifyPack = std::function<double(double)>(),
346  std::function<double(double)> modifyUnpack = std::function<double(double)>()) {
347  const auto diff = diffRelative(pcvalue, trackvalue);
348 
349  const auto tmpSigned = modifyPack ? modifyPack(trackvalue) : trackvalue;
350  const auto tmp = std::abs(tmpSigned);
351  const auto underOverflow = helper_.underOverflowHelper(tmpSigned, modifyUnpack);
353  if (tmp > helper_.largestValue()) {
354  fillNoFlow(hUnderOverflowSign, diff);
355  if (underOverflow.compatibleWithOverflow(std::abs(pcvalue))) {
356  status = RangeStatus::overflow_OK;
357  } else {
358  status = RangeStatus::overflow_notOK;
359  }
360  } else if (helper_.lessThanSmallestValue(tmpSigned)) {
361  fillNoFlow(hUnderOverflowSign, diff);
362  if (underOverflow.compatibleWithUnderflow(std::abs(pcvalue))) {
363  status = RangeStatus::underflow_OK;
364  } else {
365  status = RangeStatus::underflow_notOK;
366  }
367  } else {
368  if (boost::math::sign(pcvalue) == boost::math::sign(trackvalue)) {
369  if (T::wouldBeDenorm(tmp)) {
370  status = RangeStatus::denormal;
371  } else {
372  status = RangeStatus::inrange;
373  }
374  fillNoFlow(hInrange, diff);
375  } else {
376  fillNoFlow(hUnderOverflowSign, diff);
377  status = RangeStatus::inrange_signflip;
378  }
379  }
380  hStatus->Fill(static_cast<int>(status));
381 
382  return PackedValueCheckResult<T>(status, diff, pcvalue, trackvalue, rangeMin_, rangeMax_, underOverflow);
383  }
384 
385  private:
386  const T helper_;
387  const double rangeMin_;
388  const double rangeMax_;
389 
390  MonitorElement* hInrange;
391  MonitorElement* hUnderOverflowSign;
392  MonitorElement* hStatus;
393  };
394  template <typename T>
395  std::ostream& operator<<(std::ostream& os, const PackedValueCheckResult<T>& res) {
396  res.print(os);
397  return os;
398  }
399 } // namespace
400 
402 public:
404  ~PackedCandidateTrackValidator() override;
405 
406  void bookHistograms(DQMStore::IBooker&, edm::Run const&, edm::EventSetup const&) override;
407  void analyze(const edm::Event&, const edm::EventSetup&) override;
408 
409  static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
410 
411 private:
415 
417  bool debug_;
418 
419  enum {
420  sf_AllTracks = 0,
421  sf_AssociatedToPC = 1,
422  sf_PCIsCharged = 2,
423  sf_PCHasTrack = 3,
424  sf_PCIsNotElectron = 4,
425  sf_PCHasHits = 5,
426  sf_PCNdofNot0 = 6,
427  sf_NoMissingInnerHits = 7
428  };
430 
434 
437 
440 
444  PackedValueCheck<Float16Helper> h_diffDxyAssocPV;
445  PackedValueCheck<Float16Helper> h_diffDzAssocPV;
448 
451 
452  PackedValueCheck<LogIntHelper> h_diffCovQoverpQoverp;
453  PackedValueCheck<LogIntHelper> h_diffCovLambdaLambda;
454  PackedValueCheck<LogIntHelper> h_diffCovLambdaDsz;
455  PackedValueCheck<LogIntHelper> h_diffCovPhiPhi;
456  PackedValueCheck<LogIntHelper> h_diffCovPhiDxy;
457  PackedValueCheck<Float16Helper> h_diffCovDxyDxy;
458  PackedValueCheck<Float16Helper> h_diffCovDxyDsz;
459  PackedValueCheck<Float16Helper> h_diffCovDszDsz;
460 
464 
467 
470 
476 
484 
491 };
492 
494  : tracksToken_(consumes<edm::View<reco::Track>>(iConfig.getUntrackedParameter<edm::InputTag>("tracks"))),
495  verticesToken_(consumes<reco::VertexCollection>(iConfig.getUntrackedParameter<edm::InputTag>("vertices"))),
496  trackToPackedCandidateToken_(consumes<edm::Association<pat::PackedCandidateCollection>>(
497  iConfig.getUntrackedParameter<edm::InputTag>("trackToPackedCandidateAssociation"))),
498  rootFolder_(iConfig.getUntrackedParameter<std::string>("rootFolder")),
499  debug_(iConfig.getUntrackedParameter<bool>("debug")),
500  h_diffDxyAssocPV(RangeAbs(0.001)),
501  h_diffDzAssocPV(RangeAbs(0.001)),
502  h_diffCovQoverpQoverp(Range(-1e-6, 0.13), -15, 0), // despite of ceil in pack, there is rounding in double->float
503  h_diffCovLambdaLambda(
504  Range(-1e-6, 0.13), -20, -5), // despite of ceil in pack, there is rounding in double->float
505  h_diffCovLambdaDsz(RangeAbs(0.13), -17, -4),
506  h_diffCovPhiPhi(RangeAbs(0.13), -15, 0),
507  h_diffCovPhiDxy(RangeAbs(0.13), -17, -4),
508  h_diffCovDxyDxy(RangeAbs(0.001)),
509  h_diffCovDxyDsz(RangeAbs(0.001)),
510  h_diffCovDszDsz(RangeAbs(0.001)) {}
511 
513 
516 
517  desc.addUntracked<edm::InputTag>("tracks", edm::InputTag("generalTracks"));
518  desc.addUntracked<edm::InputTag>("vertices", edm::InputTag("offlinePrimaryVertices"));
519  desc.addUntracked<edm::InputTag>("trackToPackedCandidateAssociation", edm::InputTag("packedPFCandidates"));
520  desc.addUntracked<std::string>("rootFolder", "Tracking/PackedCandidate");
521  desc.addUntracked<bool>("debug", false);
522 
523  descriptions.add("packedCandidateTrackValidator", desc);
524 }
525 
527  edm::Run const&,
528  edm::EventSetup const&) {
529  iBooker.setCurrentFolder(rootFolder_);
530 
531  h_selectionFlow = iBooker.book1D("selectionFlow", "Track selection flow", 8, -0.5, 7.5);
532  h_selectionFlow->setBinLabel(1, "All tracks");
533  h_selectionFlow->setBinLabel(2, "Associated to PackedCandidate");
534  h_selectionFlow->setBinLabel(3, "PC is charged"), h_selectionFlow->setBinLabel(4, "PC has track");
535  h_selectionFlow->setBinLabel(5, "PC is not electron");
536  h_selectionFlow->setBinLabel(6, "PC has hits");
537  h_selectionFlow->setBinLabel(7, "PC ndof != 0");
538  h_selectionFlow->setBinLabel(8, "Track: no missing inner hits");
539 
540  constexpr int diffBins = 50;
541 
542  h_diffVx =
543  iBooker.book1D("diffVx", "PackedCandidate::bestTrack() - reco::Track in vx()", diffBins, -0.2, 0.2); // not equal
544  h_diffVy =
545  iBooker.book1D("diffVy", "PackedCandidate::bestTrack() - reco::Track in vy()", diffBins, -0.2, 0.2); // not equal
546  h_diffVz =
547  iBooker.book1D("diffVz", "PackedCandidate::bestTrack() - reco::Track in vz()", diffBins, -0.4, 0.4); // not equal
548 
549  h_diffNormalizedChi2 = iBooker.book1D("diffNormalizedChi2",
550  "PackedCandidate::bestTrack() - reco::Track in normalizedChi2()",
551  30,
552  -1.5,
553  1.5); // expected difference in -1...0
554  h_diffNdof = iBooker.book1D(
555  "diffNdof", "PackedCandidate::bestTrack() - reco::Track in ndof()", 33, -30.5, 2.5); // to monitor the difference
556 
557  h_diffCharge = iBooker.book1D(
558  "diffCharge", "PackedCandidate::bestTrack() - reco::Track in charge()", 5, -2.5, 2.5); // expect equality
559  h_diffIsHighPurity = iBooker.book1D("diffIsHighPurity",
560  "PackedCandidate::bestTrack() - reco::Track in quality(highPurity)",
561  3,
562  -1.5,
563  1.5); // expect equality
564 
565  h_diffPt = iBooker.book1D("diffPt",
566  "(PackedCandidate::bestTrack() - reco::Track)/reco::Track in pt()",
567  diffBins,
568  -1.1,
569  1.1); // not equal, keep
570  h_diffEta = iBooker.book1D(
571  "diffEta", "PackedCandidate::bestTrack() - reco::Track in eta()", diffBins, -0.001, 0.001); // not equal, keep
572  h_diffPhi = iBooker.book1D("diffPhi",
573  "PackedCandidate::bestTrack() - reco::Track in phi()",
574  diffBins,
575  -0.0005,
576  0.0005); // expect equality within precision
577 
578  h_diffDxyAssocPV.book(iBooker,
579  "diffDxyAssocPV",
580  "(PackedCandidate::dxy() - reco::Track::dxy(assocPV))/reco::Track",
581  40,
582  -0.001,
583  0.001, // expect equality within precision
584  50,
585  -0.5,
586  0.5);
587  h_diffDzAssocPV.book(iBooker,
588  "diffDzAssocPV",
589  "(PackedCandidate::dzAssociatedPV() - reco::Track::dz(assocPV))/reco::Track",
590  40,
591  -0.001,
592  0.001, // expect equality within precision
593  50,
594  -0.5,
595  0.5);
596  h_diffDxyPV = iBooker.book1D("diffDxyPV",
597  "(PackedCandidate::dxy(PV) - reco::Track::dxy(PV))/reco::Track",
598  diffBins,
599  -0.01,
600  0.01); // expect equality within precision (worse than assocPV)
601  h_diffDzPV = iBooker.book1D("diffDzPV",
602  "(PackedCandidate::dz(PV) - reco::Track::dz(PV))/reco::Track",
603  diffBins,
604  -0.01,
605  0.01); // expect equality wihtin precision (worse than assocPV)
607  iBooker.book1D("diffTrackDxyAssocPV",
608  "(PackedCandidate::bestTrack()::dxy(assocPV)) - reco::Track::dxy(assocPV))/reco::Track",
609  diffBins,
610  -0.01,
611  0.01); // not equal
613  iBooker.book1D("diffTrackDzAssocPV",
614  "(PackedCandidate::bestTrack()::dz(assocPV)) - reco::Track::dz(assocPV))/reco::Track",
615  diffBins,
616  -0.01,
617  0.01); // not equal
618 
619  h_diffCovQoverpQoverp.book(iBooker,
620  "diffCovQoverpQoverp",
621  "(PackedCandidate::bestTrack() - reco::Track)/reco::track in cov(qoverp, qoverp)",
622  40,
623  -0.05,
624  0.15, // expect equality within precision (worst precision is exp(1/128*15) =~ 12 %
625  50,
626  -0.5,
627  0.5);
629  iBooker,
630  "diffCovLambdaLambda",
631  "(PackedCandidate::bestTrack() - reco::Track)/reco::Track in cov(lambda, lambda)",
632  40,
633  -0.05,
634  0.15, // expect equality within precision worst precision is exp(1/128*(20-5)) =~ 12 % (multiplied by pt^2 in packing & unpacking)
635  50,
636  -0.5,
637  0.5);
638  h_diffCovLambdaDsz.book(iBooker,
639  "diffCovLambdaDsz",
640  "(PackedCandidate::bestTrack() - reco::Track)/reco::Track in cov(lambda, dsz)",
641  60,
642  -0.15,
643  0.15, // expect equality within precision, worst precision is exp(1/128*(17-4) =~ 11 %
644  50,
645  -1,
646  1);
647  h_diffCovPhiPhi.book(
648  iBooker,
649  "diffCovPhiPhi",
650  "(PackedCandidate::bestTrack() - reco::Track)/reco::Track in cov(phi, phi)",
651  40,
652  -0.05,
653  0.15, // expect equality within precision worst precision is exp(1/128*(20-5)) =~ 12 % (multiplied by pt^2 in packing & unpacking)
654  50,
655  -0.5,
656  0.5);
657  h_diffCovPhiDxy.book(iBooker,
658  "diffCovPhiDxy",
659  "(PackedCandidate::bestTrack() - reco::Track)/reco::Track in cov(phi, dxy)",
660  60,
661  -0.15,
662  0.15, // expect equality within precision, wors precision is exp(1/128)*(17-4) =~ 11 %
663  50,
664  -1,
665  1);
666  h_diffCovDxyDxy.book(iBooker,
667  "diffCovDxyDxy",
668  "(PackedCandidate::bestTrack() - reco::Track)/reco::Track in cov(dxy, dxy)",
669  40,
670  -0.001,
671  0.001,
672  50,
673  -0.1,
674  0.1);
675  h_diffCovDxyDsz.book(iBooker,
676  "diffCovDxyDsz",
677  "(PackedCandidate::bestTrack() - reco::Track)/reco::Track in cov(dxy, dsz)",
678  40,
679  -0.001,
680  0.001, // expect equality within precision
681  50,
682  -0.5,
683  0.5);
684  h_diffCovDszDsz.book(iBooker,
685  "diffCovDszDsz",
686  "(PackedCandidate::bestTrack() - reco::Track)/reco::Track in cov(dsz, dsz)",
687  40,
688  -0.001,
689  0.001, // expect equality within precision
690  50,
691  -0.1,
692  0.1);
693 
694  h_diffDxyError = iBooker.book1D("diffDxyError",
695  "(PackedCandidate::dxyError() - reco::Track::dxyError())/reco::Track",
696  40,
697  -0.001,
698  0.001); // expect equality within precision
699  h_diffDszError = iBooker.book1D("diffDszError",
700  "(PackedCandidate::dzError() - reco::Track::dszError())/reco::Track",
701  40,
702  -0.001,
703  0.001); // ideally, not equal, but for now they are
704  h_diffDzError = iBooker.book1D("diffDzError",
705  "(PackedCandidate::dzError() - reco::Track::dzError())/reco::Track",
706  40,
707  -0.001,
708  0.001); // expect equality within precision (not currently the case)
709 
710  h_diffTrackDxyError = iBooker.book1D("diffTrackDxyError",
711  "(PackedCandidate::bestTrack() - reco::Track)/reco::Track in dxyError()",
712  40,
713  -0.001,
714  0.001); // expect equality within precision
715  h_diffTrackDzError = iBooker.book1D("diffTrackDzError",
716  "(PackedCandidate::bestTrack() - reco::Track)/reco::Track in dzError()",
717  40,
718  -0.05,
719  0.05); // not equal
720 
721  h_diffPtError = iBooker.book1D("diffPtError",
722  "(PackedCandidate::bestTrack() - reco::Track)/reco::Track in ptError()",
723  diffBins,
724  -1.1,
725  1.1); // not equal
726  h_diffEtaError = iBooker.book1D("diffEtaError",
727  "(PackedCandidate::bestTrack() - reco::Track)/reco::Track in etaError()",
728  60,
729  -0.15,
730  0.15); // not equal
731 
733  "diffNumberOfPixelLayers",
734  "PackedCandidate::pixelLayersWithMeasurement() - reco::Track::hitPattern::pixelLayersWithMeasurement()",
735  5,
736  -2.5,
737  2.5); // expect equality
739  "diffNumberOfStripLayers",
740  "PackedCandidate::stripLayersWithMeasurement() - reco::Track::hitPattern::stripLayersWithMeasurement()",
741  5,
742  -2.5,
743  2.5); // expect equality
745  iBooker.book1D("diffNumberOfPixelHits",
746  "PackedCandidate::numberOfPixelHits() - reco::Track::hitPattern::numberOfValidPixelHits()",
747  5,
748  -2.5,
749  2.5); // expect equality
750  h_diffNumberOfHits = iBooker.book1D("diffNumberOfHits",
751  "PackedCandidate::numberHits() - reco::Track::hitPattern::numberOfValidHits()",
752  5,
753  -2.5,
754  2.5); // expect equality
756  iBooker.book1D("diffLostInnerHits",
757  "PackedCandidate::lostInnerHits() - reco::Track::hitPattern::numberOfLostHits(MISSING_INNER_HITS)",
758  5,
759  -2.5,
760  2.5); // expect equality
761 
763  iBooker.book1D("diffHitPatternPixelLayersWithMeasurement",
764  "PackedCandidate::bestTrack() - reco::Track in hitPattern::pixelLayersWithMeasurement()",
765  13,
766  -10.5,
767  2.5); // not equal
769  iBooker.book1D("diffHitPatternStripLayersWithMeasurement",
770  "PackedCandidate::bestTrack() - reco::Track in hitPattern::stripLayersWithMeasurement()",
771  13,
772  -10.5,
773  2.5); // not equal
775  iBooker.book1D("diffHitPatternTrackerLayersWithMeasurement",
776  "PackedCandidate::bestTrack() - reco::Track in hitPattern::trackerLayersWithMeasurement()",
777  13,
778  -10.5,
779  2.5); // not equal
781  iBooker.book1D("diffHitPatternNumberOfValidPixelHits",
782  "PackedCandidate::bestTrack() - reco::Track in hitPattern::numberOfValidPixelHits()",
783  13,
784  -10.5,
785  2.5); // not equal
787  iBooker.book1D("diffHitPatternNumberOfValidHits",
788  "PackedCandidate::bestTrack() - reco::Track in hitPattern::numberOfValidHits()",
789  13,
790  -10.5,
791  2.5); // not equal
793  iBooker.book1D("diffHitPatternNumberOfLostPixelHits",
794  "PackedCandidate::bestTrack() - reco::Track in hitPattern::numberOfLostHits(MISSING_INNER_HITS)",
795  13,
796  -10.5,
797  2.5); // not equal
799  iBooker.book1D("diffHitPatternHasValidHitInFirstPixelBarrel",
800  "PackedCandidate::bestTrack() - reco::Track in hitPattern::hasValidHitInFirstPixelBarrel",
801  3,
802  -1.5,
803  1.5); // expect equality
804 
806  "numberPixelLayersOverMax", "Number of pixel layers over the maximum of PackedCandidate", 10, 0, 10);
808  "numberStripLayersOverMax", "Number of strip layers over the maximum of PackedCandidate", 10, 0, 10);
810  iBooker.book1D("numberLayersOverMax", "Number of layers over the maximum of PackedCandidate", 20, 0, 20);
812  iBooker.book1D("numberPixelHitsOverMax", "Number of pixel hits over the maximum of PackedCandidate", 10, 0, 10);
814  iBooker.book1D("numberStripHitsOverMax", "Number of strip hits over the maximum of PackedCandidate", 10, 0, 10);
816  iBooker.book1D("numberHitsOverMax", "Number of hits over the maximum of PackedCandidate", 20, 0, 20);
817 }
818 
821  iEvent.getByToken(tracksToken_, htracks);
822  const auto& tracks = *htracks;
823 
825  iEvent.getByToken(verticesToken_, hvertices);
826  const auto& vertices = *hvertices;
827 
828  if (vertices.empty())
829  return;
830  const reco::Vertex& pv = vertices[0];
831 
834  const auto& trackToPackedCandidate = *hassoc;
835 
836  for (size_t i = 0; i < tracks.size(); ++i) {
837  auto trackPtr = tracks.ptrAt(i);
838  const reco::Track& track = *trackPtr;
840 
841  pat::PackedCandidateRef pcRef = trackToPackedCandidate[trackPtr];
842  if (pcRef.isNull()) {
843  continue;
844  }
846 
847  // Filter out neutral PackedCandidates, some of them may have track associated, and for those the charge comparison fails
848  if (pcRef->charge() == 0) {
849  continue;
850  }
852 
853  const reco::Track* trackPcPtr = pcRef->bestTrack();
854  if (!trackPcPtr) {
855  continue;
856  }
858 
859  // Filter out electrons to avoid comparisons to PackedCandidates with GsfTrack
860  if (std::abs(pcRef->pdgId()) == 11) {
861  continue;
862  }
864 
865  // Filter out PackedCandidate-tracks with no hits, as they won't have their details filled
866  const reco::Track& trackPc = *trackPcPtr;
867  if (trackPc.hitPattern().numberOfValidHits() == 0) {
868  continue;
869  }
871 
872  auto slimmedVertexRef = pcRef->vertexRef();
873  const reco::Vertex& pcVertex = vertices[slimmedVertexRef.key()];
874 
875  fillNoFlow(h_diffVx, trackPc.vx() - track.vx());
876  fillNoFlow(h_diffVy, trackPc.vy() - track.vy());
877  fillNoFlow(h_diffVz, trackPc.vz() - track.vz());
878 
879  // PackedCandidate recalculates the ndof in unpacking as
880  // (nhits+npixelhits-5), but some strip hits may have dimension 2.
881  // If PackedCandidate has ndof=0, the resulting normalizedChi2
882  // will be 0 too. Hence, the comparison makes sense only for those
883  // PackedCandidates that have ndof != 0.
884  double diffNormalizedChi2 = 0;
885  if (trackPc.ndof() != 0) {
887  diffNormalizedChi2 = trackPc.normalizedChi2() - track.normalizedChi2();
888  fillNoFlow(h_diffNormalizedChi2, diffNormalizedChi2);
889  }
890  fillNoFlow(h_diffNdof, trackPc.ndof() - track.ndof());
891 
892  auto diffCharge = trackPc.charge() - track.charge();
893  fillNoFlow(h_diffCharge, diffCharge);
894  int diffHP = static_cast<int>(trackPc.quality(reco::TrackBase::highPurity)) -
895  static_cast<int>(track.quality(reco::TrackBase::highPurity));
896  fillNoFlow(h_diffIsHighPurity, diffHP);
897 
898  const auto diffPt = diffRelative(trackPc.pt(), track.pt());
899  const auto diffPhi = reco::deltaPhi(trackPc.phi(), track.phi());
900  fillNoFlow(h_diffPt, diffPt);
901  fillNoFlow(h_diffEta, trackPc.eta() - track.eta());
902  fillNoFlow(h_diffPhi, diffPhi);
903 
904  const auto diffDxyAssocPV =
905  h_diffDxyAssocPV.fill(pcRef->dxy(), track.dxy(pcVertex.position()), [](double value) { return value * 100.; });
906  const auto diffDzAssocPV = h_diffDzAssocPV.fill(
907  pcRef->dzAssociatedPV(), track.dz(pcVertex.position()), [](double value) { return value * 100.; });
908  const auto diffDxyPV = diffRelative(pcRef->dxy(pv.position()), track.dxy(pv.position()));
909  const auto diffDzPV = diffRelative(pcRef->dz(pv.position()), track.dz(pv.position()));
910  fillNoFlow(h_diffDxyPV, diffDxyPV);
911  fillNoFlow(h_diffDzPV, diffDzPV);
912  fillNoFlow(h_diffTrackDxyAssocPV, diffRelative(trackPc.dxy(pcVertex.position()), track.dxy(pcVertex.position())));
913  fillNoFlow(h_diffTrackDzAssocPV, diffRelative(trackPc.dz(pcVertex.position()), track.dz(pcVertex.position())));
914 
915  auto fillCov1 = [&](auto& hlp, const int i, const int j) {
916  return hlp.fill(trackPc.covariance(i, j), track.covariance(i, j));
917  };
918  auto fillCov2 = [&](auto& hlp, const int i, const int j, std::function<double(double)> modifyPack) {
919  return hlp.fill(trackPc.covariance(i, j), track.covariance(i, j), modifyPack);
920  };
921  auto fillCov3 = [&](auto& hlp,
922  const int i,
923  const int j,
924  std::function<double(double)> modifyPack,
925  std::function<double(double)> modifyUnpack) {
926  return hlp.fill(trackPc.covariance(i, j), track.covariance(i, j), modifyPack, modifyUnpack);
927  };
928 
929  const auto pcPt = pcRef->pt();
930  const auto diffCovQoverpQoverp = fillCov3(h_diffCovQoverpQoverp,
933  [=](double val) { return val * pcPt * pcPt; },
934  [=](double val) { return val / pcPt / pcPt; });
935  const auto diffCovLambdaLambda =
937  const auto diffCovLambdaDsz = fillCov1(h_diffCovLambdaDsz, reco::TrackBase::i_lambda, reco::TrackBase::i_dsz);
938  const auto diffCovPhiPhi = fillCov3(h_diffCovPhiPhi,
941  [=](double val) { return val * pcPt * pcPt; },
942  [=](double val) { return val / pcPt / pcPt; });
943  const auto diffCovPhiDxy = fillCov1(h_diffCovPhiDxy, reco::TrackBase::i_phi, reco::TrackBase::i_dxy);
944  const auto diffCovDxyDxy = fillCov2(
945  h_diffCovDxyDxy, reco::TrackBase::i_dxy, reco::TrackBase::i_dxy, [](double value) { return value * 10000.; });
946  const auto diffCovDxyDsz = fillCov2(
947  h_diffCovDxyDsz, reco::TrackBase::i_dxy, reco::TrackBase::i_dsz, [](double value) { return value * 10000.; });
948  const auto diffCovDszDsz = fillCov2(
949  h_diffCovDszDsz, reco::TrackBase::i_dsz, reco::TrackBase::i_dsz, [](double value) { return value * 10000.; });
950 
951  if (isInRange(diffCovDszDsz.status())) {
952  fillNoFlow(h_diffDszError, diffRelative(pcRef->dzError(), track.dszError()));
953  fillNoFlow(h_diffDzError, diffRelative(pcRef->dzError(), track.dzError()));
954  fillNoFlow(h_diffTrackDzError, diffRelative(trackPc.dzError(), track.dzError()));
955  }
956  if (isInRange(diffCovDxyDxy.status())) {
957  fillNoFlow(h_diffDxyError, diffRelative(pcRef->dxyError(), track.dxyError()));
958  fillNoFlow(h_diffTrackDxyError, diffRelative(trackPc.dxyError(), track.dxyError()));
959  }
960  fillNoFlow(h_diffPtError, diffRelative(trackPc.ptError(), track.ptError()));
961  fillNoFlow(h_diffEtaError, diffRelative(trackPc.etaError(), track.etaError()));
962 
963  // For the non-HitPattern ones, take into account the PackedCandidate packing precision
964  const auto trackNumberOfHits = track.hitPattern().numberOfValidHits();
965  const auto trackNumberOfPixelHits = track.hitPattern().numberOfValidPixelHits();
966  const auto trackNumberOfStripHits = track.hitPattern().numberOfValidStripHits();
967  const auto pcNumberOfHits = pcRef->numberOfHits();
968  const auto pcNumberOfPixelHits = pcRef->numberOfPixelHits();
969  const auto pcNumberOfStripHits = pcNumberOfHits - pcNumberOfPixelHits;
970  const auto trackNumberOfLayers = track.hitPattern().trackerLayersWithMeasurement();
971  const auto trackNumberOfPixelLayers = track.hitPattern().pixelLayersWithMeasurement();
972  const auto trackNumberOfStripLayers = track.hitPattern().stripLayersWithMeasurement();
973  const auto pcNumberOfLayers = pcRef->trackerLayersWithMeasurement();
974  const auto pcNumberOfPixelLayers = pcRef->pixelLayersWithMeasurement();
975  const auto pcNumberOfStripLayers = pcRef->stripLayersWithMeasurement();
976 
977  // layer number overflow (should be zero)
978  const int pixelLayerOverflow = trackNumberOfPixelLayers > pat::PackedCandidate::trackPixelHitsMask
979  ? trackNumberOfPixelLayers - pat::PackedCandidate::trackPixelHitsMask
980  : 0;
981  const int stripLayerOverflow = trackNumberOfStripLayers > pat::PackedCandidate::trackStripHitsMask
982  ? trackNumberOfStripLayers - pat::PackedCandidate::trackStripHitsMask
983  : 0;
984  const int layerOverflow =
986  ? trackNumberOfLayers -
988  : 0;
989 
990  // hit overflow (should also be zero)
991  const int pixelOverflow =
992  trackNumberOfPixelHits - pcNumberOfPixelLayers > pat::PackedCandidate::trackPixelHitsMask
993  ? trackNumberOfPixelHits - pcNumberOfPixelLayers - pat::PackedCandidate::trackPixelHitsMask
994  : 0;
995  const int stripOverflow =
996  trackNumberOfStripHits - pcNumberOfStripLayers > pat::PackedCandidate::trackStripHitsMask
997  ? trackNumberOfStripHits - pcNumberOfStripLayers - pat::PackedCandidate::trackStripHitsMask
998  : 0;
999  const int hitsOverflow =
1000  trackNumberOfHits - pcNumberOfLayers >
1002  ? trackNumberOfHits - pcNumberOfLayers -
1004  : 0;
1005  // PackedCandidate counts overflow pixel hits as strip
1006  const int pixelInducedStripOverflow =
1007  (trackNumberOfStripHits + pixelOverflow - pcNumberOfStripLayers) > pat::PackedCandidate::trackStripHitsMask
1008  ? (trackNumberOfStripHits + pixelOverflow - stripOverflow - pcNumberOfStripLayers) -
1010  : 0;
1011  h_numberPixelLayersOverMax->Fill(pixelLayerOverflow);
1012  h_numberStripLayersOverMax->Fill(stripLayerOverflow);
1013  h_numberLayersOverMax->Fill(layerOverflow);
1014  h_numberPixelHitsOverMax->Fill(pixelOverflow);
1015  h_numberStripHitsOverMax->Fill(stripOverflow);
1016  h_numberHitsOverMax->Fill(hitsOverflow);
1017 
1018  int diffNumberOfPixelHits = 0;
1019  int diffNumberOfHits = 0;
1020  int diffNumberOfPixelLayers = 0;
1021  int diffNumberOfStripLayers = 0;
1022  if (pixelLayerOverflow) {
1023  diffNumberOfPixelLayers = pcNumberOfPixelLayers - pat::PackedCandidate::trackPixelHitsMask;
1024  } else {
1025  diffNumberOfPixelLayers = pcNumberOfPixelLayers - trackNumberOfPixelLayers;
1026  }
1027  if (pixelOverflow) {
1028  diffNumberOfPixelHits = pcNumberOfPixelHits - pcNumberOfPixelLayers - pat::PackedCandidate::trackPixelHitsMask;
1029  } else {
1030  diffNumberOfPixelHits = pcNumberOfPixelHits - trackNumberOfPixelHits;
1031  }
1032  if (stripLayerOverflow) {
1033  diffNumberOfStripLayers = pcNumberOfStripLayers - pat::PackedCandidate::trackStripHitsMask;
1034  } else {
1035  diffNumberOfStripLayers = pcNumberOfStripLayers - trackNumberOfStripLayers;
1036  }
1037  if (stripOverflow || pixelInducedStripOverflow || pixelOverflow) {
1038  int diffNumberOfStripHits = 0;
1039  if (stripOverflow || pixelInducedStripOverflow) {
1040  diffNumberOfStripHits = pcNumberOfStripHits - pat::PackedCandidate::trackStripHitsMask;
1041  } else if (pixelOverflow) {
1042  diffNumberOfStripHits = (pcNumberOfStripHits - pixelOverflow) - trackNumberOfStripHits;
1043  }
1044 
1045  diffNumberOfHits = diffNumberOfPixelHits + diffNumberOfStripHits;
1046  } else {
1047  diffNumberOfHits = pcNumberOfHits - trackNumberOfHits;
1048  }
1049 
1050  fillNoFlow(h_diffNumberOfPixelHits, diffNumberOfPixelHits);
1051  fillNoFlow(h_diffNumberOfHits, diffNumberOfHits);
1052  fillNoFlow(h_diffNumberOfPixelLayers, diffNumberOfPixelLayers);
1053  fillNoFlow(h_diffNumberOfStripLayers, diffNumberOfStripLayers);
1054 
1055  int diffLostInnerHits = 0;
1056  const auto trackLostInnerHits = track.hitPattern().numberOfLostHits(reco::HitPattern::MISSING_INNER_HITS);
1057  switch (pcRef->lostInnerHits()) {
1060  diffLostInnerHits = -trackLostInnerHits;
1061  break;
1063  diffLostInnerHits = 1 - trackLostInnerHits;
1064  break;
1066  diffLostInnerHits = trackLostInnerHits >= 2 ? 0 : 2 - trackLostInnerHits;
1067  break;
1068  }
1069  fillNoFlow(h_diffLostInnerHits, diffLostInnerHits);
1070 
1071  // For HitPattern ones, calculate the full diff (i.e. some differences are expected)
1072  auto diffHitPatternPixelLayersWithMeasurement =
1073  trackPc.hitPattern().pixelLayersWithMeasurement() - trackNumberOfPixelLayers;
1074  fillNoFlow(h_diffHitPatternPixelLayersWithMeasurement, diffHitPatternPixelLayersWithMeasurement);
1075  auto diffHitPatternStripLayersWithMeasurement =
1076  trackPc.hitPattern().stripLayersWithMeasurement() - trackNumberOfStripLayers;
1077  fillNoFlow(h_diffHitPatternStripLayersWithMeasurement, diffHitPatternStripLayersWithMeasurement);
1078  auto diffHitPatternTrackerLayersWithMeasurement =
1079  trackPc.hitPattern().trackerLayersWithMeasurement() - trackNumberOfLayers;
1080  fillNoFlow(h_diffHitPatternTrackerLayersWithMeasurement, diffHitPatternTrackerLayersWithMeasurement);
1081  auto diffHitPatternNumberOfValidPixelHits = trackPc.hitPattern().numberOfValidPixelHits() - trackNumberOfPixelHits;
1082  fillNoFlow(h_diffHitPatternNumberOfValidPixelHits, diffHitPatternNumberOfValidPixelHits);
1083  auto diffHitPatternNumberOfValidHits = trackPc.hitPattern().numberOfValidHits() - trackNumberOfHits;
1084  fillNoFlow(h_diffHitPatternNumberOfValidHits, diffHitPatternNumberOfValidHits);
1088 
1089  // hasValidHitInFirstPixelBarrel is set only if numberOfLostHits(MISSING_INNER_HITS) == 0
1090  int diffHitPatternHasValidHitInFirstPixelBarrel = 0;
1093  diffHitPatternHasValidHitInFirstPixelBarrel =
1094  static_cast<int>(
1097  fillNoFlow(h_diffHitPatternHasValidHitInFirstPixelBarrel, diffHitPatternHasValidHitInFirstPixelBarrel);
1098  }
1099 
1100  // Print warning if there are differences outside the expected range
1101  if (debug_ &&
1102  (diffNormalizedChi2 < -1 || diffNormalizedChi2 > 0 || diffCharge != 0 || diffHP != 0 ||
1103  std::abs(diffPhi) > 5e-4 || diffDxyAssocPV.outsideExpectedRange() || diffDzAssocPV.outsideExpectedRange() ||
1104  std::abs(diffDxyPV) > 0.05 || std::abs(diffDzPV) > 0.05 || diffCovQoverpQoverp.outsideExpectedRange() ||
1105  diffCovLambdaLambda.outsideExpectedRange() || diffCovLambdaDsz.outsideExpectedRange() ||
1106  diffCovPhiPhi.outsideExpectedRange() || diffCovPhiDxy.outsideExpectedRange() ||
1107  diffCovDxyDxy.outsideExpectedRange() || diffCovDxyDsz.outsideExpectedRange() ||
1108  diffCovDszDsz.outsideExpectedRange() || diffNumberOfPixelHits != 0 || diffNumberOfHits != 0 ||
1109  diffLostInnerHits != 0 || diffHitPatternHasValidHitInFirstPixelBarrel != 0)) {
1110  edm::LogInfo("PackedCandidateTrackValidator")
1111  << "Track " << i << " pt " << track.pt() << " eta " << track.eta() << " phi " << track.phi() << " chi2 "
1112  << track.chi2() << " ndof " << track.ndof() << "\n"
1113  << " ptError " << track.ptError() << " etaError " << track.etaError() << " phiError " << track.phiError()
1114  << " dxyError " << track.dxyError() << " dzError " << track.dzError() << "\n"
1115  << " refpoint " << track.referencePoint() << " momentum " << track.momentum() << "\n"
1116  << " dxy " << track.dxy() << " dz " << track.dz() << "\n"
1117  << " " << TrackAlgoPrinter(track) << " lost inner hits " << trackLostInnerHits << " lost outer hits "
1119  << HitPatternPrinter(track) << " \n"
1120  << " PC " << pcRef.id() << ":" << pcRef.key() << " track pt " << trackPc.pt() << " eta " << trackPc.eta()
1121  << " phi " << trackPc.phi() << " (PC " << pcRef->phi() << ") chi2 " << trackPc.chi2() << " ndof "
1122  << trackPc.ndof() << " pdgId " << pcRef->pdgId() << " mass " << pcRef->mass() << "\n"
1123  << " ptError " << trackPc.ptError() << " etaError " << trackPc.etaError() << " phiError "
1124  << trackPc.phiError() << "\n"
1125  << " pc.vertex " << pcRef->vertex() << " momentum " << pcRef->momentum() << " track " << trackPc.momentum()
1126  << "\n"
1127  << " dxy " << trackPc.dxy() << " dz " << trackPc.dz() << " pc.dz " << pcRef->dz() << " dxyError "
1128  << trackPc.dxyError() << " dzError " << trackPc.dzError() << "\n"
1129  << " dxy(PV) " << trackPc.dxy(pv.position()) << " dz(PV) " << trackPc.dz(pv.position()) << " dxy(assocPV) "
1130  << trackPc.dxy(pcVertex.position()) << " dz(assocPV) " << trackPc.dz(pcVertex.position()) << "\n"
1131  << " (diff PackedCandidate track)"
1132  << " highPurity " << diffHP << " " << trackPc.quality(reco::TrackBase::highPurity) << " "
1133  << track.quality(reco::TrackBase::highPurity) << " charge " << diffCharge << " " << trackPc.charge() << " "
1134  << track.charge() << " normalizedChi2 " << diffNormalizedChi2 << " " << trackPc.normalizedChi2() << " "
1135  << track.normalizedChi2() << "\n "
1136  << " numberOfAllHits " << diffNumberOfHits << " " << pcNumberOfHits << " " << trackNumberOfHits
1137  << " numberOfPixelHits " << diffNumberOfPixelHits << " " << pcNumberOfPixelHits << " "
1138  << trackNumberOfPixelHits << " numberOfStripHits # " << pcNumberOfStripHits << " " << trackNumberOfStripHits
1139  << "\n "
1140  << " hitPattern.numberOfValidPixelHits " << diffHitPatternNumberOfValidPixelHits << " "
1141  << trackPc.hitPattern().numberOfValidPixelHits() << " " << track.hitPattern().numberOfValidPixelHits()
1142  << " hitPattern.numberOfValidHits " << diffHitPatternNumberOfValidHits << " "
1143  << trackPc.hitPattern().numberOfValidHits() << " " << track.hitPattern().numberOfValidHits()
1144  << " hitPattern.hasValidHitInFirstPixelBarrel " << diffHitPatternHasValidHitInFirstPixelBarrel << " "
1147  << " lostInnerHits " << diffLostInnerHits << " " << pcRef->lostInnerHits() << " #"
1148  << " phi (5e-4) " << diffPhi << " " << trackPc.phi() << " " << track.phi() << "\n "
1149  << " dxy(assocPV) " << diffDxyAssocPV << "\n "
1150  << " dz(assocPV) " << diffDzAssocPV << "\n "
1151  << " dxy(PV) (0.05) " << diffDxyPV << " " << pcRef->dxy(pv.position()) << " " << track.dxy(pv.position())
1152  << "\n "
1153  << " dz(PV) (0.05) " << diffDzPV << " " << pcRef->dz(pv.position()) << " " << track.dz(pv.position()) << "\n "
1154  << " cov(qoverp, qoverp) " << diffCovQoverpQoverp << "\n "
1155  << " cov(lambda, lambda) " << diffCovLambdaLambda << "\n "
1156  << " cov(lambda, dsz) " << diffCovLambdaDsz << "\n "
1157  << " cov(phi, phi) " << diffCovPhiPhi << "\n "
1158  << " cov(phi, dxy) " << diffCovPhiDxy << "\n "
1159  << " cov(dxy, dxy) " << diffCovDxyDxy << "\n "
1160  << " cov(dxy, dsz) " << diffCovDxyDsz << "\n "
1161  << " cov(dsz, dsz) " << diffCovDszDsz;
1162  }
1163  }
1164 }
1165 
constexpr double deltaPhi(double phi1, double phi2)
Definition: deltaPhi.h:26
MonitorElement * book1D(TString const &name, TString const &title, int const nchX, double const lowX, double const highX)
Definition: DQMStore.cc:239
FWCore Framework interface EventSetupRecordImplementation h
Helper function to determine trigger accepts.
const Point & referencePoint() const
Reference point on the track.
Definition: TrackBase.h:632
static bool stripTECHitFilter(uint16_t pattern)
Definition: HitPattern.h:621
static uint32_t getLayer(uint16_t pattern)
Definition: HitPattern.h:703
PackedValueCheck< LogIntHelper > h_diffCovLambdaDsz
PackedValueCheck< Float16Helper > h_diffDzAssocPV
PackedValueCheck< Float16Helper > h_diffDxyAssocPV
ParameterDescriptionBase * addUntracked(U const &iLabel, T const &value)
bool hasValidHitInPixelLayer(enum PixelSubdetector::SubDetector, uint16_t layer) const
Definition: HitPattern.cc:337
static bool badHitFilter(uint16_t pattern)
Definition: HitPattern.h:772
double normalizedChi2() const
chi-squared divided by n.d.o.f. (or chi-squared * 1e6 if n.d.o.f. is zero)
Definition: TrackBase.h:572
edm::EDGetTokenT< edm::View< reco::Track > > tracksToken_
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:525
constexpr bool isNotFinite(T x)
Definition: isFinite.h:9
PixelRecoRange< float > Range
double dxyError() const
error on dxy
Definition: TrackBase.h:716
void setCurrentFolder(std::string const &fullpath)
Definition: DQMStore.cc:418
double unpack8log(int8_t i, double lmin, double lmax, uint8_t base=128)
int numberOfValidHits() const
Definition: HitPattern.h:787
PackedCandidateTrackValidator(const edm::ParameterSet &pset)
std::vector< pat::PackedCandidate > PackedCandidateCollection
edm::EDGetTokenT< edm::Association< pat::PackedCandidateCollection > > trackToPackedCandidateToken_
double etaError() const
error on eta
Definition: TrackBase.h:710
int numberOfValidStripHits() const
Definition: HitPattern.h:813
double phi() const
azimuthal angle of momentum vector
Definition: TrackBase.h:614
std::vector< Vertex > VertexCollection
collection of Vertex objects
Definition: VertexFwd.h:9
constexpr int8_t smallestNegative
Definition: liblogintpack.h:11
key_type key() const
Accessor for product key.
Definition: Ref.h:250
int pixelLayersWithMeasurement() const
Definition: HitPattern.cc:492
const Vector & momentum() const
track momentum vector
Definition: TrackBase.h:629
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
std::ostream & operator<<(std::ostream &out, const ALILine &li)
Definition: ALILine.cc:167
S & print(S &os, JobReport::InputFile const &f)
Definition: JobReport.cc:66
static bool missingHitFilter(uint16_t pattern)
Definition: HitPattern.h:768
int trackerLayersWithMeasurement() const
Definition: HitPattern.cc:513
const Point & position() const
position
Definition: Vertex.h:113
static bool pixelBarrelHitFilter(uint16_t pattern)
Definition: HitPattern.h:582
example_stream void analyze(const edm::Event &, const edm::EventSetup &) override
Definition: Electron.h:6
ProductID id() const
Accessor for product ID.
Definition: Ref.h:244
void push_back(const T &value)
Definition: VecArray.h:76
TrackAlgorithm
track algorithm
Definition: TrackBase.h:89
static float denorm_min()
Definition: libminifloat.h:158
static bool pixelEndcapHitFilter(uint16_t pattern)
Definition: HitPattern.h:590
Definition: HeavyIon.h:7
PackedValueCheck< LogIntHelper > h_diffCovLambdaLambda
void Fill(long long x)
double dszError() const
error on dsz
Definition: TrackBase.h:722
int iEvent
Definition: GenABIO.cc:224
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
double eta() const
pseudorapidity of momentum vector
Definition: TrackBase.h:617
PackedValueCheck< LogIntHelper > h_diffCovPhiDxy
double chi2() const
chi-squared of the fit
Definition: TrackBase.h:566
PackedValueCheck< Float16Helper > h_diffCovDxyDxy
PackedValueCheck< LogIntHelper > h_diffCovPhiPhi
double ndof() const
number of degrees of freedom of the fit
Definition: TrackBase.h:569
CovarianceMatrix covariance() const
return track covariance matrix
Definition: TrackBase.h:677
dqm::dqmstoreimpl::DQMStore DQMStore
Definition: DQMStore.h:709
double pt() const
track transverse momentum
Definition: TrackBase.h:602
double ptError() const
error on Pt (set to 1000 TeV if charge==0 for safety)
Definition: TrackBase.h:696
double phiError() const
error on phi
Definition: TrackBase.h:713
int numberOfAllHits(HitCategory category) const
Definition: HitPattern.h:774
def pv(vc)
Definition: MetAnalyzer.py:7
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override
Definition: value.py:1
T min(T a, T b)
Definition: MathUtil.h:58
constexpr size_type size() const noexcept
Definition: VecArray.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)
static float min()
Definition: libminifloat.h:137
bool isNull() const
Checks for null.
Definition: Ref.h:235
static bool inactiveHitFilter(uint16_t pattern)
Definition: HitPattern.h:770
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:596
double dzError() const
error on dz
Definition: TrackBase.h:725
double vz() const
z coordinate of the reference point on track
Definition: TrackBase.h:626
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
edm::EDGetTokenT< reco::VertexCollection > verticesToken_
const HitPattern & hitPattern() const
Access the hit pattern, indicating in which Tracker layers the track has hits.
Definition: TrackBase.h:483
std::string algoName() const
Definition: TrackBase.h:529
constexpr int8_t smallestPositive
Definition: liblogintpack.h:8
int stripLayersWithMeasurement() const
Definition: HitPattern.h:975
example_stream void bookHistograms(DQMStore::IBooker &,@example_stream edm::Run const &,@example_stream edm::EventSetup const &) override
double b
Definition: hdecay.h:118
void add(std::string const &label, ParameterSetDescription const &psetDescription)
static bool stripTOBHitFilter(uint16_t pattern)
Definition: HitPattern.h:617
bool quality(const TrackQuality) const
Track quality.
Definition: TrackBase.h:531
int numberOfLostHits(HitCategory category) const
Definition: HitPattern.h:861
double vy() const
y coordinate of the reference point on track
Definition: TrackBase.h:623
static bool stripTIBHitFilter(uint16_t pattern)
Definition: HitPattern.h:609
fixed size matrix
HLT enums.
double a
Definition: hdecay.h:119
void analyze(const edm::Event &, const edm::EventSetup &) override
static float max32RoundedToMax16()
Definition: libminifloat.h:126
dqm::impl::MonitorElement MonitorElement
PackedValueCheck< LogIntHelper > h_diffCovQoverpQoverp
PackedValueCheck< Float16Helper > h_diffCovDxyDsz
int numberOfValidPixelHits() const
Definition: HitPattern.h:801
PackedValueCheck< Float16Helper > h_diffCovDszDsz
int charge() const
track electric charge
Definition: TrackBase.h:575
uint16_t getHitPattern(HitCategory category, int position) const
Definition: HitPattern.h:531
static bool stripTIDHitFilter(uint16_t pattern)
Definition: HitPattern.h:613
tmp
align.sh
Definition: createJobs.py:716
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:587
long double T
virtual TH1 * getTH1() const
#define constexpr
Definition: Run.h:45
double vx() const
x coordinate of the reference point on track
Definition: TrackBase.h:620