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