test
CMS 3D CMS Logo

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