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  template<typename T> void fillNoFlow(MonitorElement* me, T val){
31  auto h = me->getTH1();
32  const auto xaxis = h->GetXaxis();
33  if(val <= xaxis->GetXmin())
34  h->AddBinContent(xaxis->GetFirst());
35  else if(val >= xaxis->GetXmax())
36  h->AddBinContent(xaxis->GetLast());
37  else
38  h->Fill(val);
39  }
40 
41  class HitPatternPrinter {
42  public:
43  explicit HitPatternPrinter(const reco::Track& trk): track(trk) {}
44 
45  void print(std::ostream& os) const {
46  const reco::HitPattern &p = track.hitPattern();
47 
48  for (int i = 0; i < p.numberOfHits(reco::HitPattern::TRACK_HITS); ++i) {
50 
51  detLayer(os, p, hit);
52  if(p.missingHitFilter(hit)) {
53  os << "(miss)";
54  }
55  else if(p.inactiveHitFilter(hit)) {
56  os << "(inact)";
57  }
58  else if(p.badHitFilter(hit)) {
59  os << "(bad)";
60  }
61  os << " ";
62  }
63 
65  os << "lost inner ";
66 
67  for (int i = 0; i < p.numberOfHits(reco::HitPattern::MISSING_INNER_HITS); ++i) {
69 
70  if(p.missingHitFilter(hit)) {
71  detLayer(os, p, hit);
72  os << " ";
73  }
74  }
75  }
77  os << "lost outer ";
78 
79  for (int i = 0; i < p.numberOfHits(reco::HitPattern::MISSING_OUTER_HITS); ++i) {
81 
82  if(p.missingHitFilter(hit)) {
83  detLayer(os, p, hit);
84  os << " ";
85  }
86  }
87  }
88  }
89 
90  private:
91  static void detLayer(std::ostream& os, const reco::HitPattern& p, uint32_t hit) {
92  if(p.pixelBarrelHitFilter(hit)) {
93  os << "BPIX";
94  }
95  else if(p.pixelEndcapHitFilter(hit)) {
96  os << "FPIX";
97  }
98  else if(p.stripTIBHitFilter(hit)) {
99  os << "TIB";
100  }
101  else if(p.stripTIDHitFilter(hit)) {
102  os << "TID";
103  }
104  else if(p.stripTOBHitFilter(hit)) {
105  os << "TOB";
106  }
107  else if(p.stripTECHitFilter(hit)) {
108  os << "TEC";
109  }
110  os << p.getLayer(hit);
111  }
112 
113  const reco::Track& track;
114  };
115 
116  std::ostream& operator<<(std::ostream& os, const HitPatternPrinter& hpp) {
117  hpp.print(os);
118  return os;
119  }
120 
121  class TrackAlgoPrinter {
122  public:
123  explicit TrackAlgoPrinter(const reco::Track& trk): track(trk) {}
124 
125  void print(std::ostream& os) const {
127  for(int ialgo=0; ialgo < reco::TrackBase::algoSize; ++ialgo) {
128  auto algo = static_cast<reco::TrackBase::TrackAlgorithm>(ialgo);
129  if(track.isAlgoInMask(algo)) {
130  algos.push_back(algo);
131  }
132  }
133 
134  os << "algo " << reco::TrackBase::algoName(track.algo());
135  if(track.originalAlgo() != track.algo())
136  os << " originalAlgo " << reco::TrackBase::algoName(track.originalAlgo());
137  if(algos.size() > 1) {
138  os << " algoMask";
139  for(auto algo: algos) {
140  os << " " << reco::TrackBase::algoName(algo);
141  }
142  }
143  }
144 
145  private:
146  const reco::Track& track;
147  };
148  std::ostream& operator<<(std::ostream& os, const TrackAlgoPrinter& tap) {
149  tap.print(os);
150  return os;
151  }
152 
153  double diffRelative(double a, double b) {
154  return (a-b)/b;
155  }
156 
157  class LogIntHelper {
158  public:
159  LogIntHelper(double lmin, double lmax): lmin_(lmin), lmax_(lmax) {}
160 
161  class UnderOverflow {
162  public:
163  UnderOverflow(double largestValue, double smallestValue, std::function<double(double)> modifyUnpack):
164  unpackedLargestValue_(modifyUnpack ? modifyUnpack(largestValue) : largestValue),
165  unpackedSmallestValue_(modifyUnpack ? modifyUnpack(smallestValue) : smallestValue)
166  {}
167 
168  bool compatibleWithUnderflow(double value) const {
169  return value == unpackedSmallestValue_;
170  }
171  void printNonOkUnderflow(std::ostream& os) const {
172  os << " (not min " << unpackedSmallestValue_ << ")";
173  }
174 
175  bool compatibleWithOverflow(double value) const {
176  return value == unpackedLargestValue_;
177  }
178  void printNonOkOverflow(std::ostream& os) const {
179  os << " (not max " << unpackedLargestValue_ << ")";
180  }
181 
182  private:
183  // narrow to float to compare apples to apples with values from
184  // PackedCandidate (even though the final comparison is done in
185  // double)
186  const float unpackedLargestValue_;
187  const float unpackedSmallestValue_;
188  };
189 
190  static std::string maxName() { return "max"; }
191  static std::string minName() { return "min"; }
192 
193  UnderOverflow underOverflowHelper(double value, std::function<double(double)> modifyUnpack) const {
194  return UnderOverflow(largestValue(), value >= 0 ? smallestPositiveValue() : std::abs(smallestNegativeValue()), modifyUnpack);
195  }
196 
197  double largestValue() const {
198  return logintpack::unpack8log(127, lmin_, lmax_);
199  }
200 
201  static bool wouldBeDenorm(double value) {
202  return false;
203  }
204 
205  // lessThan means closer to zero
206  bool lessThanSmallestValue(double value) const {
207  if(value >= 0)
208  return value < smallestPositiveValue();
209  else
210  return value > smallestNegativeValue();
211  }
212 
213  double smallestPositiveValue() const {
215  }
216 
217  double smallestNegativeValue() const {
219  }
220 
221  private:
222  const double lmin_;
223  const double lmax_;
224  };
225  class Float16Helper {
226  public:
227  class UnderOverflow {
228  public:
229  static void printNonOkUnderflow(std::ostream& os) {
230  os << " (not 0)";
231  }
232  static bool compatibleWithUnderflow(double value) {
233  return value == 0.0;
234  }
235  static void printNonOkOverflow(std::ostream& os) {
236  os << " (not inf)";
237  }
238  static bool compatibleWithOverflow(double value) {
239  return edm::isNotFinite(value);
240  }
241  };
242 
243  static std::string maxName() { return "inf"; }
244  static std::string minName() { return "0"; }
245 
246  static UnderOverflow underOverflowHelper(double value, std::function<double(double)>) {
247  return UnderOverflow();
248  }
249 
250  static double largestValue() {
252  }
253 
254  static bool wouldBeDenorm(double value) {
255  const float valuef = static_cast<float>(value);
256  return valuef >= MiniFloatConverter::denorm_min() && valuef < MiniFloatConverter::min();
257  }
258 
259  static bool lessThanSmallestValue(double value) {
260  return std::abs(value) < smallestValue();
261  }
262 
263  static double smallestValue() {
265  }
266  };
267 
268  enum class RangeStatus {
269  inrange = 0,
270  inrange_signflip = 1,
271  denormal = 2,
272  underflow_OK = 3,
273  underflow_notOK = 4,
274  overflow_OK = 5,
275  overflow_notOK = 6
276  };
277  bool isInRange(RangeStatus status) {
278  return status == RangeStatus::inrange || status == RangeStatus::denormal;
279  }
280 
281  template <typename T>
282  class PackedValueCheckResult {
283  public:
284  PackedValueCheckResult(RangeStatus status, double diff,
285  double pcvalue, double trackvalue,
286  double rangeMin, double rangeMax,
287  const typename T::UnderOverflow& underOverflow):
288  diff_(diff), pcvalue_(pcvalue), trackvalue_(trackvalue), rangeMin_(rangeMin), rangeMax_(rangeMax),
289  status_(status), underOverflow_(underOverflow)
290  {}
291 
292  RangeStatus status() const { return status_; }
293  double diff() const { return diff_; }
294 
295  bool outsideExpectedRange() const {
296  if(status_ == RangeStatus::inrange)
297  return diff_ < rangeMin_ || diff_ > rangeMax_;
298  // denormal is considered as "in range" regardless of the expected range
299  return status_ == RangeStatus::underflow_notOK || status_ == RangeStatus::overflow_notOK || status_ == RangeStatus::inrange_signflip;
300  }
301 
302  void print(std::ostream& os) const {
303  if(outsideExpectedRange())
304  os << "!! ";
305  os << "(" << rangeMin_ << "," << rangeMax_ << ") ";
306 
307  os << diff_ << " " << pcvalue_;
308  if(status_ == RangeStatus::underflow_OK || status_ == RangeStatus::underflow_notOK) {
309  os << " (underflow) ";
310  if(status_ == RangeStatus::underflow_notOK)
311  underOverflow_.printNonOkUnderflow(os);
312  }
313  else if(status_ == RangeStatus::overflow_OK || status_ == RangeStatus::overflow_notOK) {
314  os << " (overflow) ";
315  if(status_ == RangeStatus::overflow_notOK)
316  underOverflow_.printNonOkOverflow(os);
317  }
318  else if(status_ == RangeStatus::denormal)
319  os << " (denormal)";
320  os << " " << trackvalue_;
321  }
322 
323  private:
324  const double diff_;
325  const double pcvalue_;
326  const double trackvalue_;
327  const double rangeMin_;
328  const double rangeMax_;
329  const RangeStatus status_;
330  const typename T::UnderOverflow underOverflow_;
331  };
332 
333  struct Range {
334  Range(double mi, double ma): min(mi), max(ma) {}
335  const double min, max;
336  };
337  struct RangeAbs {
338  RangeAbs(double val): min(-val), max(val) {}
339  const double min, max;
340  };
341 
342  template <typename T>
343  class PackedValueCheck {
344  public:
345  template <typename R, typename ...Args>
346  PackedValueCheck(const R& range, Args&&... args):
347  helper_(std::forward<Args>(args)...),
348  rangeMin_(range.min), rangeMax_(range.max)
349  {}
350 
351  void book(DQMStore::IBooker& iBooker,
352  const std::string& name, const std::string& title,
353  int nbins,double min,double max,
354  int flow_nbins,double flow_min,double flow_max) {
355  hInrange = iBooker.book1D(name, title, nbins, min, max);
356  hUnderOverflowSign = iBooker.book1D(name+"UnderOverFlowSign", title+" with over- and underflow, and sign flip", flow_nbins, flow_min, flow_max);
357  hStatus = iBooker.book1D(name+"Status", title+" status", 7, -0.5, 6.5);
358  hStatus->setBinLabel(1, "In range");
359  hStatus->setBinLabel(2, "In range, sign flip");
360  hStatus->setBinLabel(3, "Denormal");
361  hStatus->setBinLabel(4, "Underflow, PC is "+T::minName());
362  hStatus->setBinLabel(5, "Underflow, PC is not "+T::minName());
363  hStatus->setBinLabel(6, "Overflow, PC is "+T::maxName());
364  hStatus->setBinLabel(7, "Overflow, PC is not "+T::maxName());
365  }
366 
367  PackedValueCheckResult<T> fill(double pcvalue, double trackvalue,
368  std::function<double(double)> modifyPack=std::function<double(double)>(),
369  std::function<double(double)> modifyUnpack=std::function<double(double)>()) {
370  const auto diff = diffRelative(pcvalue, trackvalue);
371 
372  const auto tmpSigned = modifyPack ? modifyPack(trackvalue) : trackvalue;
373  const auto tmp = std::abs(tmpSigned);
374  const auto underOverflow = helper_.underOverflowHelper(tmpSigned, modifyUnpack);
376  if(tmp > helper_.largestValue()) {
377  fillNoFlow(hUnderOverflowSign, diff);
378  if(underOverflow.compatibleWithOverflow(std::abs(pcvalue))) {
379  status = RangeStatus::overflow_OK;
380  }
381  else {
382  status = RangeStatus::overflow_notOK;
383  }
384  }
385  else if(helper_.lessThanSmallestValue(tmpSigned)) {
386  fillNoFlow(hUnderOverflowSign, diff);
387  if(underOverflow.compatibleWithUnderflow(std::abs(pcvalue))) {
388  status = RangeStatus::underflow_OK;
389  }
390  else {
391  status = RangeStatus::underflow_notOK;
392  }
393  }
394  else {
395  if(boost::math::sign(pcvalue) == boost::math::sign(trackvalue)) {
396  if(T::wouldBeDenorm(tmp)) {
397  status = RangeStatus::denormal;
398  }
399  else {
400  status = RangeStatus::inrange;
401  }
402  fillNoFlow(hInrange, diff);
403  }
404  else {
405  fillNoFlow(hUnderOverflowSign, diff);
406  status = RangeStatus::inrange_signflip;
407  }
408  }
409  hStatus->Fill(static_cast<int>(status));
410 
411  return PackedValueCheckResult<T>(status, diff, pcvalue, trackvalue, rangeMin_, rangeMax_, underOverflow);
412  }
413 
414  private:
415  const T helper_;
416  const double rangeMin_;
417  const double rangeMax_;
418 
419  MonitorElement *hInrange;
420  MonitorElement *hUnderOverflowSign;
421  MonitorElement *hStatus;
422  };
423  template <typename T>
424  std::ostream& operator<<(std::ostream& os, const PackedValueCheckResult<T>& res) {
425  res.print(os);
426  return os;
427  }
428 }
429 
431  public:
434 
435  void bookHistograms(DQMStore::IBooker&, edm::Run const&, edm::EventSetup const&) override;
436  void analyze(const edm::Event&, const edm::EventSetup& ) override;
437 
438  static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
439 
440  private:
441 
445 
447 
448  enum {
449  sf_AllTracks = 0,
450  sf_AssociatedToPC = 1,
451  sf_PCIsCharged = 2,
452  sf_PCHasTrack = 3,
453  sf_PCIsNotElectron = 4,
454  sf_PCHasHits = 5,
455  sf_PCNdofNot0 = 6,
456  sf_NoMissingInnerHits = 7
457  };
459 
463 
466 
469 
473  PackedValueCheck<Float16Helper> h_diffDxyAssocPV;
474  PackedValueCheck<Float16Helper> h_diffDzAssocPV;
477 
480 
481  PackedValueCheck<LogIntHelper> h_diffCovQoverpQoverp;
482  PackedValueCheck<LogIntHelper> h_diffCovLambdaLambda;
483  PackedValueCheck<LogIntHelper> h_diffCovLambdaDsz;
484  PackedValueCheck<LogIntHelper> h_diffCovPhiPhi;
485  PackedValueCheck<LogIntHelper> h_diffCovPhiDxy;
486  PackedValueCheck<Float16Helper> h_diffCovDxyDxy;
487  PackedValueCheck<Float16Helper> h_diffCovDxyDsz;
488  PackedValueCheck<Float16Helper> h_diffCovDszDsz;
489 
493 
496 
499 
500 
506 
514 
521 };
522 
524  tracksToken_(consumes<edm::View<reco::Track>>(iConfig.getUntrackedParameter<edm::InputTag>("tracks"))),
525  verticesToken_(consumes<reco::VertexCollection>(iConfig.getUntrackedParameter<edm::InputTag>("vertices"))),
526  trackToPackedCandidateToken_(consumes<edm::Association<pat::PackedCandidateCollection>>(iConfig.getUntrackedParameter<edm::InputTag>("trackToPackedCandidateAssociation"))),
527  rootFolder_(iConfig.getUntrackedParameter<std::string>("rootFolder")),
528  h_diffDxyAssocPV(RangeAbs(0.001)),
529  h_diffDzAssocPV(RangeAbs(0.001)),
530  h_diffCovQoverpQoverp(Range(-1e-6, 0.13), -15, 0), // despite of ceil in pack, there is rounding in double->float
531  h_diffCovLambdaLambda(Range(-1e-6, 0.13), -20, -5), // despite of ceil in pack, there is rounding in double->float
532  h_diffCovLambdaDsz(RangeAbs(0.13), -17, -4),
533  h_diffCovPhiPhi(RangeAbs(0.13), -15, 0),
534  h_diffCovPhiDxy(RangeAbs(0.13), -17, -4),
535  h_diffCovDxyDxy(RangeAbs(0.001)),
536  h_diffCovDxyDsz(RangeAbs(0.001)),
537  h_diffCovDszDsz(RangeAbs(0.001))
538 {}
539 
541 
544 
545  desc.addUntracked<edm::InputTag>("tracks", edm::InputTag("generalTracks"));
546  desc.addUntracked<edm::InputTag>("vertices", edm::InputTag("offlinePrimaryVertices"));
547  desc.addUntracked<edm::InputTag>("trackToPackedCandidateAssociation", edm::InputTag("packedPFCandidates"));
548  desc.addUntracked<std::string>("rootFolder", "Tracking/PackedCandidate");
549 
550  descriptions.add("packedCandidateTrackValidator", desc);
551 }
552 
554  iBooker.setCurrentFolder(rootFolder_);
555 
556  h_selectionFlow = iBooker.book1D("selectionFlow", "Track selection flow", 8, -0.5, 7.5);
557  h_selectionFlow->setBinLabel(1, "All tracks");
558  h_selectionFlow->setBinLabel(2, "Associated to PackedCandidate");
559  h_selectionFlow->setBinLabel(3, "PC is charged"),
560  h_selectionFlow->setBinLabel(4, "PC has track");
561  h_selectionFlow->setBinLabel(5, "PC is not electron");
562  h_selectionFlow->setBinLabel(6, "PC has hits");
563  h_selectionFlow->setBinLabel(7, "PC ndof != 0");
564  h_selectionFlow->setBinLabel(8, "Track: no missing inner hits");
565 
566  constexpr int diffBins = 50;
567 
568  h_diffVx = iBooker.book1D("diffVx", "PackedCandidate::bestTrack() - reco::Track in vx()", diffBins, -0.2, 0.2); // not equal
569  h_diffVy = iBooker.book1D("diffVy", "PackedCandidate::bestTrack() - reco::Track in vy()", diffBins, -0.2, 0.2); // not equal
570  h_diffVz = iBooker.book1D("diffVz", "PackedCandidate::bestTrack() - reco::Track in vz()", diffBins, -0.4, 0.4); // not equal
571 
572  h_diffNormalizedChi2 = iBooker.book1D("diffNormalizedChi2", "PackedCandidate::bestTrack() - reco::Track in normalizedChi2()", 30, -1.5, 1.5); // expected difference in -1...0
573  h_diffNdof = iBooker.book1D("diffNdof", "PackedCandidate::bestTrack() - reco::Track in ndof()", 33, -30.5, 2.5); // to monitor the difference
574 
575  h_diffCharge = iBooker.book1D("diffCharge", "PackedCandidate::bestTrack() - reco::Track in charge()", 5, -2.5, 2.5); // expect equality
576  h_diffIsHighPurity = iBooker.book1D("diffIsHighPurity", "PackedCandidate::bestTrack() - reco::Track in quality(highPurity)", 3, -1.5, 1.5); // expect equality
577 
578  h_diffPt = iBooker.book1D("diffPt", "(PackedCandidate::bestTrack() - reco::Track)/reco::Track in pt()", diffBins, -1.1, 1.1); // not equal, keep
579  h_diffEta = iBooker.book1D("diffEta", "PackedCandidate::bestTrack() - reco::Track in eta()", diffBins, -0.001, 0.001); // not equal, keep
580  h_diffPhi = iBooker.book1D("diffPhi", "PackedCandidate::bestTrack() - reco::Track in phi()", diffBins, -0.0005, 0.0005); // expect equality within precision
581 
582  h_diffDxyAssocPV.book(iBooker, "diffDxyAssocPV", "(PackedCandidate::dxy() - reco::Track::dxy(assocPV))/reco::Track",
583  40, -0.001, 0.001, // expect equality within precision
584  50, -0.5, 0.5);
585  h_diffDzAssocPV.book(iBooker, "diffDzAssocPV","(PackedCandidate::dzAssociatedPV() - reco::Track::dz(assocPV))/reco::Track",
586  40, -0.001, 0.001, // expect equality within precision
587  50, -0.5, 0.5);
588  h_diffDxyPV = iBooker.book1D("diffDxyPV", "(PackedCandidate::dxy(PV) - reco::Track::dxy(PV))/reco::Track", diffBins, -0.01, 0.01); // expect equality within precision (worse than assocPV)
589  h_diffDzPV = iBooker.book1D("diffDzPV", "(PackedCandidate::dz(PV) - reco::Track::dz(PV))/reco::Track", diffBins, -0.01, 0.01); // expect equality wihtin precision (worse than assocPV)
590  h_diffTrackDxyAssocPV = iBooker.book1D("diffTrackDxyAssocPV", "(PackedCandidate::bestTrack()::dxy(assocPV)) - reco::Track::dxy(assocPV))/reco::Track", diffBins, -0.01, 0.01); // not equal
591  h_diffTrackDzAssocPV = iBooker.book1D("diffTrackDzAssocPV", "(PackedCandidate::bestTrack()::dz(assocPV)) - reco::Track::dz(assocPV))/reco::Track", diffBins, -0.01, 0.01); // not equal
592 
593  h_diffCovQoverpQoverp.book(iBooker, "diffCovQoverpQoverp", "(PackedCandidate::bestTrack() - reco::Track)/reco::track in cov(qoverp, qoverp)",
594  40, -0.05, 0.15, // expect equality within precision (worst precision is exp(1/128*15) =~ 12 %
595  50, -0.5, 0.5);
596  h_diffCovLambdaLambda.book(iBooker, "diffCovLambdaLambda", "(PackedCandidate::bestTrack() - reco::Track)/reco::Track in cov(lambda, lambda)",
597  40, -0.05, 0.15, // expect equality within precision worst precision is exp(1/128*(20-5)) =~ 12 % (multiplied by pt^2 in packing & unpacking)
598  50, -0.5, 0.5);
599  h_diffCovLambdaDsz.book(iBooker, "diffCovLambdaDsz", "(PackedCandidate::bestTrack() - reco::Track)/reco::Track in cov(lambda, dsz)",
600  60, -0.15, 0.15, // expect equality within precision, worst precision is exp(1/128*(17-4) =~ 11 %
601  50, -1, 1);
602  h_diffCovPhiPhi.book(iBooker, "diffCovPhiPhi", "(PackedCandidate::bestTrack() - reco::Track)/reco::Track in cov(phi, phi)",
603  40, -0.05, 0.15, // expect equality within precision worst precision is exp(1/128*(20-5)) =~ 12 % (multiplied by pt^2 in packing & unpacking)
604  50, -0.5, 0.5);
605  h_diffCovPhiDxy.book(iBooker, "diffCovPhiDxy", "(PackedCandidate::bestTrack() - reco::Track)/reco::Track in cov(phi, dxy)",
606  60, -0.15, 0.15, // expect equality within precision, wors precision is exp(1/128)*(17-4) =~ 11 %
607  50, -1, 1);
608  h_diffCovDxyDxy.book(iBooker, "diffCovDxyDxy", "(PackedCandidate::bestTrack() - reco::Track)/reco::Track in cov(dxy, dxy)",
609  40, -0.001, 0.001,
610  50, -0.1, 0.1);
611  h_diffCovDxyDsz.book(iBooker, "diffCovDxyDsz", "(PackedCandidate::bestTrack() - reco::Track)/reco::Track in cov(dxy, dsz)",
612  40, -0.001, 0.001, // expect equality within precision
613  50, -0.5, 0.5);
614  h_diffCovDszDsz.book(iBooker, "diffCovDszDsz", "(PackedCandidate::bestTrack() - reco::Track)/reco::Track in cov(dsz, dsz)",
615  40, -0.001, 0.001, // expect equality within precision
616  50, -0.1, 0.1);
617 
618  h_diffDxyError = iBooker.book1D("diffDxyError", "(PackedCandidate::dxyError() - reco::Track::dxyError())/reco::Track", 40, -0.001, 0.001); // expect equality within precision
619  h_diffDszError = iBooker.book1D("diffDszError", "(PackedCandidate::dzError() - reco::Track::dszError())/reco::Track", 40, -0.001, 0.001); // ideally, not equal, but for now they are
620  h_diffDzError = iBooker.book1D("diffDzError", "(PackedCandidate::dzError() - reco::Track::dzError())/reco::Track", 40, -0.001, 0.001); // expect equality within precision (not currently the case)
621 
622  h_diffTrackDxyError = iBooker.book1D("diffTrackDxyError", "(PackedCandidate::bestTrack() - reco::Track)/reco::Track in dxyError()", 40, -0.001, 0.001); // expect equality within precision
623  h_diffTrackDzError = iBooker.book1D("diffTrackDzError", "(PackedCandidate::bestTrack() - reco::Track)/reco::Track in dzError()", 40, -0.05, 0.05); // not equal
624 
625  h_diffPtError = iBooker.book1D("diffPtError", "(PackedCandidate::bestTrack() - reco::Track)/reco::Track in ptError()", diffBins, -1.1, 1.1); // not equal
626  h_diffEtaError = iBooker.book1D("diffEtaError", "(PackedCandidate::bestTrack() - reco::Track)/reco::Track in etaError()", 60, -0.15, 0.15); // not equal
627 
628 
629  h_diffNumberOfPixelLayers = iBooker.book1D("diffNumberOfPixelLayers", "PackedCandidate::pixelLayersWithMeasurement() - reco::Track::hitPattern::pixelLayersWithMeasurement()", 5, -2.5, 2.5); // expect equality
630  h_diffNumberOfStripLayers = iBooker.book1D("diffNumberOfStripLayers", "PackedCandidate::stripLayersWithMeasurement() - reco::Track::hitPattern::stripLayersWithMeasurement()", 5, -2.5, 2.5); // expect equality
631  h_diffNumberOfPixelHits = iBooker.book1D("diffNumberOfPixelHits", "PackedCandidate::numberOfPixelHits() - reco::Track::hitPattern::numberOfValidPixelHits()", 5, -2.5, 2.5); // expect equality
632  h_diffNumberOfHits = iBooker.book1D("diffNumberOfHits", "PackedCandidate::numberHits() - reco::Track::hitPattern::numberOfValidHits()", 5, -2.5, 2.5); // expect equality
633  h_diffLostInnerHits = iBooker.book1D("diffLostInnerHits", "PackedCandidate::lostInnerHits() - reco::Track::hitPattern::numberOfLostHits(MISSING_INNER_HITS)", 5, -2.5, 2.5); // expect equality
634 
635  h_diffHitPatternPixelLayersWithMeasurement = iBooker.book1D("diffHitPatternPixelLayersWithMeasurement", "PackedCandidate::bestTrack() - reco::Track in hitPattern::pixelLayersWithMeasurement()", 13, -10.5, 2.5); // not equal
636  h_diffHitPatternStripLayersWithMeasurement = iBooker.book1D("diffHitPatternStripLayersWithMeasurement", "PackedCandidate::bestTrack() - reco::Track in hitPattern::stripLayersWithMeasurement()", 13, -10.5, 2.5); // not equal
637  h_diffHitPatternTrackerLayersWithMeasurement = iBooker.book1D("diffHitPatternTrackerLayersWithMeasurement", "PackedCandidate::bestTrack() - reco::Track in hitPattern::trackerLayersWithMeasurement()", 13, -10.5, 2.5); // not equal
638  h_diffHitPatternNumberOfValidPixelHits = iBooker.book1D("diffHitPatternNumberOfValidPixelHits", "PackedCandidate::bestTrack() - reco::Track in hitPattern::numberOfValidPixelHits()", 13, -10.5, 2.5); // not equal
639  h_diffHitPatternNumberOfValidHits = iBooker.book1D("diffHitPatternNumberOfValidHits", "PackedCandidate::bestTrack() - reco::Track in hitPattern::numberOfValidHits()", 13, -10.5, 2.5); // not equal
640  h_diffHitPatternNumberOfLostInnerHits = iBooker.book1D("diffHitPatternNumberOfLostPixelHits", "PackedCandidate::bestTrack() - reco::Track in hitPattern::numberOfLostHits(MISSING_INNER_HITS)", 13, -10.5, 2.5); // not equal
641  h_diffHitPatternHasValidHitInFirstPixelBarrel = iBooker.book1D("diffHitPatternHasValidHitInFirstPixelBarrel", "PackedCandidate::bestTrack() - reco::Track in hitPattern::hasValidHitInFirstPixelBarrel", 3, -1.5, 1.5); // expect equality
642 
643  h_numberPixelLayersOverMax = iBooker.book1D("numberPixelLayersOverMax", "Number of pixel layers over the maximum of PackedCandidate", 10, 0, 10);
644  h_numberStripLayersOverMax = iBooker.book1D("numberStripLayersOverMax", "Number of strip layers over the maximum of PackedCandidate", 10, 0, 10);
645  h_numberLayersOverMax = iBooker.book1D("numberLayersOverMax", "Number of layers over the maximum of PackedCandidate", 20, 0, 20);
646  h_numberPixelHitsOverMax = iBooker.book1D("numberPixelHitsOverMax", "Number of pixel hits over the maximum of PackedCandidate", 10, 0, 10);
647  h_numberStripHitsOverMax = iBooker.book1D("numberStripHitsOverMax", "Number of strip hits over the maximum of PackedCandidate", 10, 0, 10);
648  h_numberHitsOverMax = iBooker.book1D("numberHitsOverMax", "Number of hits over the maximum of PackedCandidate", 20, 0, 20);
649 }
650 
653  iEvent.getByToken(tracksToken_, htracks);
654  const auto& tracks = *htracks;
655 
657  iEvent.getByToken(verticesToken_, hvertices);
658  const auto& vertices = *hvertices;
659 
660  if(vertices.empty())
661  return;
662  const reco::Vertex& pv = vertices[0];
663 
666  const auto& trackToPackedCandidate = *hassoc;
667 
668  for(size_t i=0; i<tracks.size(); ++i) {
669  auto trackPtr = tracks.ptrAt(i);
670  const reco::Track& track = *trackPtr;
672 
673  pat::PackedCandidateRef pcRef = trackToPackedCandidate[trackPtr];
674  if(pcRef.isNull()) {
675  continue;
676  }
678 
679  // Filter out neutral PackedCandidates, some of them may have track associated, and for those the charge comparison fails
680  if(pcRef->charge() == 0) {
681  continue;
682  }
684 
685  const reco::Track *trackPcPtr = pcRef->bestTrack();
686  if(!trackPcPtr) {
687  continue;
688  }
690 
691  // Filter out electrons to avoid comparisons to PackedCandidates with GsfTrack
692  if(std::abs(pcRef->pdgId()) == 11) {
693  continue;
694  }
696 
697  // Filter out PackedCandidate-tracks with no hits, as they won't have their details filled
698  const reco::Track& trackPc = *trackPcPtr;
699  if(trackPc.hitPattern().numberOfValidHits() == 0) {
700  continue;
701  }
703 
704  auto slimmedVertexRef = pcRef->vertexRef();
705  const reco::Vertex& pcVertex = vertices[slimmedVertexRef.key()];
706 
707  fillNoFlow(h_diffVx, trackPc.vx() - track.vx());
708  fillNoFlow(h_diffVy, trackPc.vy() - track.vy());
709  fillNoFlow(h_diffVz, trackPc.vz() - track.vz());
710 
711  // PackedCandidate recalculates the ndof in unpacking as
712  // (nhits+npixelhits-5), but some strip hits may have dimension 2.
713  // If PackedCandidate has ndof=0, the resulting normalizedChi2
714  // will be 0 too. Hence, the comparison makes sense only for those
715  // PackedCandidates that have ndof != 0.
716  double diffNormalizedChi2 = 0;
717  if(trackPc.ndof() != 0) {
719  diffNormalizedChi2 = trackPc.normalizedChi2() - track.normalizedChi2();
720  fillNoFlow(h_diffNormalizedChi2, diffNormalizedChi2);
721  }
722  fillNoFlow(h_diffNdof, trackPc.ndof() - track.ndof());
723 
724  auto diffCharge = trackPc.charge() - track.charge();
725  fillNoFlow(h_diffCharge, diffCharge);
726  int diffHP = static_cast<int>(trackPc.quality(reco::TrackBase::highPurity)) - static_cast<int>(track.quality(reco::TrackBase::highPurity));
727  fillNoFlow(h_diffIsHighPurity, diffHP);
728 
729  const auto diffPt = diffRelative(trackPc.pt(), track.pt());
730  const auto diffPhi = reco::deltaPhi(trackPc.phi(), track.phi());
731  fillNoFlow(h_diffPt , diffPt);
732  fillNoFlow(h_diffEta, trackPc.eta() - track.eta());
733  fillNoFlow(h_diffPhi, diffPhi);
734 
735  const auto diffDxyAssocPV = h_diffDxyAssocPV.fill(pcRef->dxy( ) , track.dxy(pcVertex.position()), [](double value){return value*100.;});
736  const auto diffDzAssocPV = h_diffDzAssocPV.fill( pcRef->dzAssociatedPV(), track.dz(pcVertex.position()) , [](double value){return value*100.;});
737  const auto diffDxyPV = diffRelative(pcRef->dxy(pv.position()), track.dxy(pv.position()));
738  const auto diffDzPV = diffRelative(pcRef->dz(pv.position()) , track.dz(pv.position()));
739  fillNoFlow(h_diffDxyPV , diffDxyPV);
740  fillNoFlow(h_diffDzPV , diffDzPV);
741  fillNoFlow(h_diffTrackDxyAssocPV, diffRelative(trackPc.dxy(pcVertex.position()), track.dxy(pcVertex.position())));
742  fillNoFlow(h_diffTrackDzAssocPV , diffRelative(trackPc.dz(pcVertex.position()) , track.dz(pcVertex.position())));
743 
744  auto fillCov1 = [&](auto& hlp, const int i, const int j) {
745  return hlp.fill(trackPc.covariance(i, j), track.covariance(i, j));
746  };
747  auto fillCov2 = [&](auto& hlp, const int i, const int j, std::function<double(double)> modifyPack) {
748  return hlp.fill(trackPc.covariance(i, j), track.covariance(i, j), modifyPack);
749  };
750  auto fillCov3 = [&](auto& hlp, const int i, const int j, std::function<double(double)> modifyPack, std::function<double(double)> modifyUnpack) {
751  return hlp.fill(trackPc.covariance(i, j), track.covariance(i, j), modifyPack, modifyUnpack);
752  };
753 
754  const auto pcPt = pcRef->pt();
755  const auto diffCovQoverpQoverp = fillCov3(h_diffCovQoverpQoverp, reco::TrackBase::i_qoverp, reco::TrackBase::i_qoverp, [=](double val){return val*pcPt*pcPt;}, [=](double val){return val/pcPt/pcPt;});
756  const auto diffCovLambdaLambda = fillCov1(h_diffCovLambdaLambda, reco::TrackBase::i_lambda, reco::TrackBase::i_lambda);
757  const auto diffCovLambdaDsz = fillCov1(h_diffCovLambdaDsz, reco::TrackBase::i_lambda, reco::TrackBase::i_dsz);
758  const auto diffCovPhiPhi = fillCov3(h_diffCovPhiPhi, reco::TrackBase::i_phi, reco::TrackBase::i_phi, [=](double val){return val*pcPt*pcPt;}, [=](double val){return val/pcPt/pcPt;});
759  const auto diffCovPhiDxy = fillCov1(h_diffCovPhiDxy, reco::TrackBase::i_phi, reco::TrackBase::i_dxy);
760  const auto diffCovDxyDxy = fillCov2(h_diffCovDxyDxy, reco::TrackBase::i_dxy, reco::TrackBase::i_dxy, [](double value){return value*10000.;});
761  const auto diffCovDxyDsz = fillCov2(h_diffCovDxyDsz, reco::TrackBase::i_dxy, reco::TrackBase::i_dsz, [](double value){return value*10000.;});
762  const auto diffCovDszDsz = fillCov2(h_diffCovDszDsz, reco::TrackBase::i_dsz, reco::TrackBase::i_dsz, [](double value){return value*10000.;});
763 
764  if(isInRange(diffCovDszDsz.status())) {
765  fillNoFlow(h_diffDszError, diffRelative(pcRef->dzError(), track.dszError()));
766  fillNoFlow(h_diffDzError, diffRelative(pcRef->dzError(), track.dzError()));
767  fillNoFlow(h_diffTrackDzError, diffRelative(trackPc.dzError(), track.dzError()));
768  }
769  if(isInRange(diffCovDxyDxy.status())) {
770  fillNoFlow(h_diffDxyError, diffRelative(pcRef->dxyError(), track.dxyError()));
771  fillNoFlow(h_diffTrackDxyError, diffRelative(trackPc.dxyError(), track.dxyError()));
772  }
773  fillNoFlow(h_diffPtError , diffRelative(trackPc.ptError() , track.ptError() ));
774  fillNoFlow(h_diffEtaError , diffRelative(trackPc.etaError() , track.etaError() ));
775 
776 
777 
778  // For the non-HitPattern ones, take into account the PackedCandidate packing precision
779  const auto trackNumberOfHits = track.hitPattern().numberOfValidHits();
780  const auto trackNumberOfPixelHits = track.hitPattern().numberOfValidPixelHits();
781  const auto trackNumberOfStripHits = track.hitPattern().numberOfValidStripHits();
782  const auto pcNumberOfHits = pcRef->numberOfHits();
783  const auto pcNumberOfPixelHits = pcRef->numberOfPixelHits();
784  const auto pcNumberOfStripHits = pcNumberOfHits - pcNumberOfPixelHits;
785  const auto trackNumberOfLayers = track.hitPattern().trackerLayersWithMeasurement();
786  const auto trackNumberOfPixelLayers = track.hitPattern().pixelLayersWithMeasurement();
787  const auto trackNumberOfStripLayers = track.hitPattern().stripLayersWithMeasurement();
788  const auto pcNumberOfLayers = pcRef->trackerLayersWithMeasurement();
789  const auto pcNumberOfPixelLayers = pcRef->pixelLayersWithMeasurement();
790  const auto pcNumberOfStripLayers = pcRef->stripLayersWithMeasurement();
791 
792  // layer number overflow (should be zero)
793  const int pixelLayerOverflow = trackNumberOfPixelLayers > pat::PackedCandidate::trackPixelHitsMask ? trackNumberOfPixelLayers - pat::PackedCandidate::trackPixelHitsMask : 0;
794  const int stripLayerOverflow = trackNumberOfStripLayers > pat::PackedCandidate::trackStripHitsMask ? trackNumberOfStripLayers - pat::PackedCandidate::trackStripHitsMask : 0;
796 
797  // hit overflow (should also be zero)
798  const int pixelOverflow = trackNumberOfPixelHits - pcNumberOfPixelLayers > pat::PackedCandidate::trackPixelHitsMask ? trackNumberOfPixelHits - pcNumberOfPixelLayers - pat::PackedCandidate::trackPixelHitsMask : 0;
799  const int stripOverflow = trackNumberOfStripHits - pcNumberOfStripLayers > pat::PackedCandidate::trackStripHitsMask ? trackNumberOfStripHits - pcNumberOfStripLayers - pat::PackedCandidate::trackStripHitsMask : 0;
800  const int hitsOverflow = trackNumberOfHits - pcNumberOfLayers > (pat::PackedCandidate::trackPixelHitsMask+pat::PackedCandidate::trackStripHitsMask) ? trackNumberOfHits - pcNumberOfLayers - (pat::PackedCandidate::trackPixelHitsMask+pat::PackedCandidate::trackStripHitsMask) : 0;
801  // PackedCandidate counts overflow pixel hits as strip
802  const int pixelInducedStripOverflow = (trackNumberOfStripHits+pixelOverflow-pcNumberOfStripLayers) > pat::PackedCandidate::trackStripHitsMask ? (trackNumberOfStripHits+pixelOverflow-stripOverflow-pcNumberOfStripLayers) - pat::PackedCandidate::trackStripHitsMask : 0;
803  h_numberPixelLayersOverMax->Fill(pixelLayerOverflow);
804  h_numberStripLayersOverMax->Fill(stripLayerOverflow);
805  h_numberLayersOverMax->Fill(layerOverflow);
806  h_numberPixelHitsOverMax->Fill(pixelOverflow);
807  h_numberStripHitsOverMax->Fill(stripOverflow);
808  h_numberHitsOverMax->Fill(hitsOverflow);
809 
810  int diffNumberOfPixelHits = 0;
811  int diffNumberOfHits = 0;
812  int diffNumberOfPixelLayers = 0;
813  int diffNumberOfStripLayers = 0;
814  if(pixelLayerOverflow) {
815  diffNumberOfPixelLayers = pcNumberOfPixelLayers - pat::PackedCandidate::trackPixelHitsMask;
816  }
817  else {
818  diffNumberOfPixelLayers = pcNumberOfPixelLayers - trackNumberOfPixelLayers;
819  }
820  if(pixelOverflow) {
821  diffNumberOfPixelHits = pcNumberOfPixelHits - pcNumberOfPixelLayers - pat::PackedCandidate::trackPixelHitsMask;
822  }
823  else {
824  diffNumberOfPixelHits = pcNumberOfPixelHits - trackNumberOfPixelHits;
825  }
826  if(stripLayerOverflow) {
827  diffNumberOfStripLayers = pcNumberOfStripLayers - pat::PackedCandidate::trackStripHitsMask;
828  }
829  else {
830  diffNumberOfStripLayers = pcNumberOfStripLayers - trackNumberOfStripLayers;
831  }
832  if(stripOverflow || pixelInducedStripOverflow || pixelOverflow) {
833  int diffNumberOfStripHits = 0;
834  if(stripOverflow || pixelInducedStripOverflow) {
835  diffNumberOfStripHits = pcNumberOfStripHits - pat::PackedCandidate::trackStripHitsMask;
836  }
837  else if(pixelOverflow) {
838  diffNumberOfStripHits = (pcNumberOfStripHits - pixelOverflow) - trackNumberOfStripHits;
839  }
840 
841  diffNumberOfHits = diffNumberOfPixelHits + diffNumberOfStripHits;
842  }
843  else {
844  diffNumberOfHits = pcNumberOfHits - trackNumberOfHits;
845  }
846 
847 
848 
849  fillNoFlow(h_diffNumberOfPixelHits, diffNumberOfPixelHits);
850  fillNoFlow(h_diffNumberOfHits, diffNumberOfHits);
851  fillNoFlow(h_diffNumberOfPixelLayers, diffNumberOfPixelLayers);
852  fillNoFlow(h_diffNumberOfStripLayers, diffNumberOfStripLayers);
853 
854  int diffLostInnerHits = 0;
855  const auto trackLostInnerHits = track.hitPattern().numberOfLostHits(reco::HitPattern::MISSING_INNER_HITS);
856  switch(pcRef->lostInnerHits()) {
859  diffLostInnerHits = -trackLostInnerHits;
860  break;
862  diffLostInnerHits = 1-trackLostInnerHits;
863  break;
865  diffLostInnerHits = trackLostInnerHits>=2 ? 0 : 2-trackLostInnerHits;
866  break;
867  }
868  fillNoFlow(h_diffLostInnerHits, diffLostInnerHits);
869 
870  // For HitPattern ones, calculate the full diff (i.e. some differences are expected)
871  auto diffHitPatternPixelLayersWithMeasurement = trackPc.hitPattern().pixelLayersWithMeasurement() - trackNumberOfPixelLayers;
872  fillNoFlow(h_diffHitPatternPixelLayersWithMeasurement, diffHitPatternPixelLayersWithMeasurement);
873  auto diffHitPatternStripLayersWithMeasurement = trackPc.hitPattern().stripLayersWithMeasurement() - trackNumberOfStripLayers;
874  fillNoFlow(h_diffHitPatternStripLayersWithMeasurement, diffHitPatternStripLayersWithMeasurement);
875  auto diffHitPatternTrackerLayersWithMeasurement = trackPc.hitPattern().trackerLayersWithMeasurement() - trackNumberOfLayers;
876  fillNoFlow(h_diffHitPatternTrackerLayersWithMeasurement, diffHitPatternTrackerLayersWithMeasurement);
877  auto diffHitPatternNumberOfValidPixelHits = trackPc.hitPattern().numberOfValidPixelHits() - trackNumberOfPixelHits;
878  fillNoFlow(h_diffHitPatternNumberOfValidPixelHits, diffHitPatternNumberOfValidPixelHits);
879  auto diffHitPatternNumberOfValidHits = trackPc.hitPattern().numberOfValidHits() - trackNumberOfHits;
880  fillNoFlow(h_diffHitPatternNumberOfValidHits, diffHitPatternNumberOfValidHits);
882 
883  // hasValidHitInFirstPixelBarrel is set only if numberOfLostHits(MISSING_INNER_HITS) == 0
884  int diffHitPatternHasValidHitInFirstPixelBarrel = 0;
887  diffHitPatternHasValidHitInFirstPixelBarrel = static_cast<int>(trackPc.hitPattern().hasValidHitInPixelLayer(PixelSubdetector::SubDetector::PixelBarrel, 1)) - static_cast<int>(track.hitPattern().hasValidHitInPixelLayer(PixelSubdetector::SubDetector::PixelBarrel, 1));
888  fillNoFlow(h_diffHitPatternHasValidHitInFirstPixelBarrel, diffHitPatternHasValidHitInFirstPixelBarrel);
889  }
890 
891  // Print warning if there are differences outside the expected range
892  if(diffNormalizedChi2 < -1 || diffNormalizedChi2 > 0 || diffCharge != 0 || diffHP != 0
893  || std::abs(diffPhi) > 5e-4
894  || diffDxyAssocPV.outsideExpectedRange()
895  || diffDzAssocPV.outsideExpectedRange()
896  || std::abs(diffDxyPV) > 0.05 || std::abs(diffDzPV) > 0.05
897  || diffCovQoverpQoverp.outsideExpectedRange() || diffCovLambdaLambda.outsideExpectedRange()
898  || diffCovLambdaDsz.outsideExpectedRange() || diffCovPhiPhi.outsideExpectedRange()
899  || diffCovPhiDxy.outsideExpectedRange() || diffCovDxyDxy.outsideExpectedRange()
900  || diffCovDxyDsz.outsideExpectedRange() || diffCovDszDsz.outsideExpectedRange()
901  || diffNumberOfPixelHits != 0 || diffNumberOfHits != 0 || diffLostInnerHits != 0
902  || diffHitPatternHasValidHitInFirstPixelBarrel != 0
903  ) {
904 
905  edm::LogInfo("PackedCandidateTrackValidator") << "Track " << i << " pt " << track.pt() << " eta " << track.eta() << " phi " << track.phi() << " chi2 " << track.chi2() << " ndof " << track.ndof()
906  << "\n"
907  << " ptError " << track.ptError() << " etaError " << track.etaError() << " phiError " << track.phiError() << " dxyError " << track.dxyError() << " dzError " << track.dzError()
908  << "\n"
909  << " refpoint " << track.referencePoint() << " momentum " << track.momentum()
910  << "\n"
911  << " dxy " << track.dxy() << " dz " << track.dz()
912  << "\n"
913  << " " << TrackAlgoPrinter(track)
914  << " lost inner hits " << trackLostInnerHits
915  << " lost outer hits " << track.hitPattern().numberOfLostHits(reco::HitPattern::MISSING_OUTER_HITS)
916  << " hitpattern " << HitPatternPrinter(track)
917  << " \n"
918  << " PC " << pcRef.id() << ":" << pcRef.key() << " track pt " << trackPc.pt() << " eta " << trackPc.eta() << " phi " << trackPc.phi() << " (PC " << pcRef->phi() << ") chi2 " << trackPc.chi2() << " ndof " << trackPc.ndof() << " pdgId " << pcRef->pdgId() << " mass " << pcRef->mass()
919  << "\n"
920  << " ptError " << trackPc.ptError() << " etaError " << trackPc.etaError() << " phiError " << trackPc.phiError()
921  << "\n"
922  << " pc.vertex " << pcRef->vertex() << " momentum " << pcRef->momentum() << " track " << trackPc.momentum()
923  << "\n"
924  << " dxy " << trackPc.dxy() << " dz " << trackPc.dz() << " pc.dz " << pcRef->dz()
925  << " dxyError " << trackPc.dxyError() << " dzError " << trackPc.dzError()
926  << "\n"
927  << " dxy(PV) " << trackPc.dxy(pv.position()) << " dz(PV) " << trackPc.dz(pv.position())
928  << " dxy(assocPV) " << trackPc.dxy(pcVertex.position()) << " dz(assocPV) " << trackPc.dz(pcVertex.position())
929  << "\n"
930  << " (diff PackedCandidate track)"
931  << " highPurity " << diffHP << " " << trackPc.quality(reco::TrackBase::highPurity) << " " << track.quality(reco::TrackBase::highPurity)
932  << " charge " << diffCharge << " " << trackPc.charge() << " " << track.charge()
933  << " normalizedChi2 " << diffNormalizedChi2 << " " << trackPc.normalizedChi2() << " " << track.normalizedChi2()
934  << "\n "
935  << " numberOfHits " << diffNumberOfHits << " " << pcNumberOfHits << " " << trackNumberOfHits
936  << " numberOfPixelHits " << diffNumberOfPixelHits << " " << pcNumberOfPixelHits << " " << trackNumberOfPixelHits
937  << " numberOfStripHits # " << pcNumberOfStripHits << " " << trackNumberOfStripHits
938  << "\n "
939  << " hitPattern.numberOfValidPixelHits " << diffHitPatternNumberOfValidPixelHits << " " << trackPc.hitPattern().numberOfValidPixelHits() << " " << track.hitPattern().numberOfValidPixelHits()
940  << " hitPattern.numberOfValidHits " << diffHitPatternNumberOfValidHits << " " << trackPc.hitPattern().numberOfValidHits() << " " << track.hitPattern().numberOfValidHits()
941  << " hitPattern.hasValidHitInFirstPixelBarrel " << diffHitPatternHasValidHitInFirstPixelBarrel << " " << trackPc.hitPattern().hasValidHitInPixelLayer(PixelSubdetector::SubDetector::PixelBarrel, 1) << " " << track.hitPattern().hasValidHitInPixelLayer(PixelSubdetector::SubDetector::PixelBarrel, 1)
942  << "\n "
943  << " lostInnerHits " << diffLostInnerHits << " " << pcRef->lostInnerHits() << " #"
944  << " phi (5e-4) " << diffPhi << " " << trackPc.phi() << " " << track.phi()
945  << "\n "
946  << " dxy(assocPV) " << diffDxyAssocPV
947  << "\n "
948  << " dz(assocPV) " << diffDzAssocPV
949  << "\n "
950  << " dxy(PV) (0.05) " << diffDxyPV << " " << pcRef->dxy(pv.position()) << " " << track.dxy(pv.position())
951  << "\n "
952  << " dz(PV) (0.05) " << diffDzPV << " " << pcRef->dz(pv.position()) << " " << track.dz(pv.position())
953  << "\n "
954  << " cov(qoverp, qoverp) " << diffCovQoverpQoverp
955  << "\n "
956  << " cov(lambda, lambda) " << diffCovLambdaLambda
957  << "\n "
958  << " cov(lambda, dsz) " << diffCovLambdaDsz
959  << "\n "
960  << " cov(phi, phi) " << diffCovPhiPhi
961  << "\n "
962  << " cov(phi, dxy) " << diffCovPhiDxy
963  << "\n "
964  << " cov(dxy, dxy) " << diffCovDxyDxy
965  << "\n "
966  << " cov(dxy, dsz) " << diffCovDxyDsz
967  << "\n "
968  << " cov(dsz, dsz) " << diffCovDszDsz;
969  }
970  }
971 }
972 
const Point & referencePoint() const
Reference point on the track.
Definition: TrackBase.h:676
static bool stripTECHitFilter(uint16_t pattern)
Definition: HitPattern.h:625
static uint32_t getLayer(uint16_t pattern)
Definition: HitPattern.h:700
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:327
static bool badHitFilter(uint16_t pattern)
Definition: HitPattern.h:802
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:556
edm::EDGetTokenT< edm::View< reco::Track > > tracksToken_
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:457
def analyze(function, filename, filter=None)
Definition: Profiling.py:11
double dxyError() const
error on dxy
Definition: TrackBase.h:791
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
double unpack8log(int8_t i, double lmin, double lmax, uint8_t base=128)
int numberOfValidHits() const
Definition: HitPattern.h:823
PackedCandidateTrackValidator(const edm::ParameterSet &pset)
std::string print(const Track &, edm::Verbosity=edm::Concise)
Track print utility.
Definition: print.cc:10
std::vector< pat::PackedCandidate > PackedCandidateCollection
edm::EDGetTokenT< edm::Association< pat::PackedCandidateCollection > > trackToPackedCandidateToken_
double etaError() const
error on eta
Definition: TrackBase.h:779
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)
int numberOfValidStripHits() const
Definition: HitPattern.h:853
double phi() const
azimuthal angle of momentum vector
Definition: TrackBase.h:640
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:264
int pixelLayersWithMeasurement() const
Definition: HitPattern.cc:499
const Vector & momentum() const
track momentum vector
Definition: TrackBase.h:670
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
std::ostream & operator<<(std::ostream &out, const ALILine &li)
Definition: ALILine.cc:188
static bool missingHitFilter(uint16_t pattern)
Definition: HitPattern.h:792
int trackerLayersWithMeasurement() const
Definition: HitPattern.cc:518
const Point & position() const
position
Definition: Vertex.h:109
static bool pixelBarrelHitFilter(uint16_t pattern)
Definition: HitPattern.h:575
#define constexpr
void bookHistograms(fwlite::EventContainer &eventCont)
Definition: Electron.h:4
ProductID id() const
Accessor for product ID.
Definition: Ref.h:258
void push_back(const T &value)
Definition: VecArray.h:78
TrackAlgorithm
track algorithm
Definition: TrackBase.h:99
static float denorm_min()
Definition: libminifloat.h:87
static bool pixelEndcapHitFilter(uint16_t pattern)
Definition: HitPattern.h:585
void Fill(long long x)
Definition: HeavyIon.h:7
PackedValueCheck< LogIntHelper > h_diffCovLambdaLambda
double dszError() const
error on dsz
Definition: TrackBase.h:803
int iEvent
Definition: GenABIO.cc:230
double eta() const
pseudorapidity of momentum vector
Definition: TrackBase.h:646
bool isNotFinite(T x)
Definition: isFinite.h:10
PixelRecoRange< float > Range
PackedValueCheck< LogIntHelper > h_diffCovPhiDxy
double chi2() const
chi-squared of the fit
Definition: TrackBase.h:544
PackedValueCheck< Float16Helper > h_diffCovDxyDxy
PackedValueCheck< LogIntHelper > h_diffCovPhiPhi
double ndof() const
number of degrees of freedom of the fit
Definition: TrackBase.h:550
CovarianceMatrix covariance() const
return track covariance matrix
Definition: TrackBase.h:726
double pt() const
track transverse momentum
Definition: TrackBase.h:616
double ptError() const
error on Pt (set to 1000 TeV if charge==0 for safety)
Definition: TrackBase.h:758
double phiError() const
error on phi
Definition: TrackBase.h:785
MonitorElement * book1D(Args &&...args)
Definition: DQMStore.h:115
def pv(vc)
Definition: MetAnalyzer.py:6
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
TH1 * getTH1(void) const
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
static float min()
Definition: libminifloat.h:72
bool isNull() const
Checks for null.
Definition: Ref.h:249
static bool inactiveHitFilter(uint16_t pattern)
Definition: HitPattern.h:797
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:604
double dzError() const
error on dz
Definition: TrackBase.h:809
double deltaPhi(double phi1, double phi2)
Definition: deltaPhi.h:22
double vz() const
z coordinate of the reference point on track
Definition: TrackBase.h:664
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:277
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:445
std::string algoName() const
Definition: TrackBase.h:503
constexpr int8_t smallestPositive
Definition: liblogintpack.h:8
int stripLayersWithMeasurement() const
Definition: HitPattern.h:1035
double b
Definition: hdecay.h:120
void add(std::string const &label, ParameterSetDescription const &psetDescription)
static bool stripTOBHitFilter(uint16_t pattern)
Definition: HitPattern.h:620
bool quality(const TrackQuality) const
Track quality.
Definition: TrackBase.h:505
int numberOfLostHits(HitCategory category) const
Definition: HitPattern.h:902
std::vector< std::vector< double > > tmp
Definition: MVATrainer.cc:100
double vy() const
y coordinate of the reference point on track
Definition: TrackBase.h:658
static bool stripTIBHitFilter(uint16_t pattern)
Definition: HitPattern.h:610
fixed size matrix
HLT enums.
double a
Definition: hdecay.h:121
void analyze(const edm::Event &, const edm::EventSetup &) override
static float max32RoundedToMax16()
Definition: libminifloat.h:64
PackedValueCheck< LogIntHelper > h_diffCovQoverpQoverp
PackedValueCheck< Float16Helper > h_diffCovDxyDsz
int numberOfValidPixelHits() const
Definition: HitPattern.h:838
PackedValueCheck< Float16Helper > h_diffCovDszDsz
int charge() const
track electric charge
Definition: TrackBase.h:562
uint16_t getHitPattern(HitCategory category, int position) const
Definition: HitPattern.h:515
static bool stripTIDHitFilter(uint16_t pattern)
Definition: HitPattern.h:615
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:586
long double T
Definition: Run.h:42
double vx() const
x coordinate of the reference point on track
Definition: TrackBase.h:652
int numberOfHits(HitCategory category) const
Definition: HitPattern.h:807