CMS 3D CMS Logo

PackedCandidate.h
Go to the documentation of this file.
1 #ifndef __DataFormats_PatCandidates_PackedCandidate_h__
2 #define __DataFormats_PatCandidates_PackedCandidate_h__
3 
4 #include <atomic>
5 #include <mutex>
15 
16 /* #include "DataFormats/Math/interface/PtEtaPhiMass.h" */
17 
18 //forward declare testing structure
19 class testPackedCandidate;
20 
21 namespace pat {
23  public:
34 
35  typedef unsigned int index;
36 
39  packedPt_(0), packedEta_(0),
40  packedPhi_(0), packedM_(0),
45  hcalFraction_(0),
46  p4_(new PolarLorentzVector(0,0,0,0)), p4c_( new LorentzVector(0,0,0,0)),
47  vertex_(new Point(0,0,0)), dphi_(0), deta_(0), dtrkpt_(0),track_(nullptr), pdgId_(0),
48  qualityFlags_(0), pvRefKey_(reco::VertexRef::invalidKey()),
50 
51  explicit PackedCandidate( const reco::Candidate & c,
52  const reco::VertexRefProd &pvRefProd,
53  reco::VertexRef::key_type pvRefKey) :
55  p4_( new PolarLorentzVector(c.pt(), c.eta(), c.phi(), c.mass())),
56  p4c_( new LorentzVector(*p4_)), vertex_( new Point(c.vertex())),
57  dphi_(0), deta_(0), dtrkpt_(0),
58  track_(nullptr), pdgId_(c.pdgId()), qualityFlags_(0), pvRefProd_(pvRefProd),
59  pvRefKey_(pvRefKey),m_(nullptr), packedHits_(0), packedLayers_(0),
61  packBoth();
62  }
63 
64  explicit PackedCandidate( const PolarLorentzVector &p4, const Point &vtx,
65  float trkPt,float etaAtVtx,float phiAtVtx,int pdgId,
66  const reco::VertexRefProd &pvRefProd,
67  reco::VertexRef::key_type pvRefKey) :
69  p4_( new PolarLorentzVector(p4) ), p4c_( new LorentzVector(*p4_)),
70  vertex_( new Point(vtx) ),
71  dphi_(reco::deltaPhi(phiAtVtx,p4_.load()->phi())),
72  deta_(std::abs(etaAtVtx-p4_.load()->eta())>=kMinDEtaToStore_ ? etaAtVtx-p4_.load()->eta() : 0.),
73  dtrkpt_(std::abs(trkPt-p4_.load()->pt())>=kMinDTrkPtToStore_ ? trkPt-p4_.load()->pt() : 0.),
74  track_(nullptr), pdgId_(pdgId),
75  qualityFlags_(0), pvRefProd_(pvRefProd), pvRefKey_(pvRefKey),
77  packBoth();
78  }
79 
80  explicit PackedCandidate( const LorentzVector &p4, const Point &vtx,
81  float trkPt, float etaAtVtx, float phiAtVtx, int pdgId,
82  const reco::VertexRefProd &pvRefProd,
83  reco::VertexRef::key_type pvRefKey) :
85  p4_(new PolarLorentzVector(p4.Pt(), p4.Eta(), p4.Phi(), p4.M())),
86  p4c_( new LorentzVector(p4)), vertex_( new Point(vtx) ) ,
87  dphi_(reco::deltaPhi(phiAtVtx,p4_.load()->phi())),
88  deta_(std::abs(etaAtVtx-p4_.load()->eta())>=kMinDEtaToStore_ ? etaAtVtx-p4_.load()->eta() : 0.),
89  dtrkpt_(std::abs(trkPt-p4_.load()->pt())>=kMinDTrkPtToStore_ ? trkPt-p4_.load()->pt() : 0.),
90  track_(nullptr), pdgId_(pdgId), qualityFlags_(0),
91  pvRefProd_(pvRefProd), pvRefKey_(pvRefKey),
93  packBoth();
94  }
95 
96  PackedCandidate( const PackedCandidate& iOther) :
97  packedPt_(iOther.packedPt_), packedEta_(iOther.packedEta_),
98  packedPhi_(iOther.packedPhi_), packedM_(iOther.packedM_),
99  packedDxy_(iOther.packedDxy_), packedDz_(iOther.packedDz_),
105  //Need to trigger unpacking in iOther
106  p4_( new PolarLorentzVector(iOther.polarP4() ) ),
107  p4c_( new LorentzVector(iOther.p4())), vertex_( new Point(iOther.vertex())),
108  dxy_(iOther.dxy_), dz_(iOther.dz_),
109  dphi_(iOther.dphi_), deta_(iOther.deta_), dtrkpt_(iOther.dtrkpt_),
110  track_( iOther.track_ ? new reco::Track(*iOther.track_) : nullptr),
111  pdgId_(iOther.pdgId_), qualityFlags_(iOther.qualityFlags_),
112  pvRefProd_(iOther.pvRefProd_),pvRefKey_(iOther.pvRefKey_),
113  m_(iOther.m_? new reco::TrackBase::CovarianceMatrix(*iOther.m_) : nullptr),
116  }
117 
119  packedPt_(iOther.packedPt_), packedEta_(iOther.packedEta_),
120  packedPhi_(iOther.packedPhi_), packedM_(iOther.packedM_),
121  packedDxy_(iOther.packedDxy_), packedDz_(iOther.packedDz_),
127  p4_( iOther.p4_.exchange(nullptr) ) ,
128  p4c_( iOther.p4c_.exchange(nullptr)), vertex_(iOther.vertex_.exchange(nullptr)),
129  dxy_(iOther.dxy_), dz_(iOther.dz_),
130  dphi_(iOther.dphi_), deta_(iOther.deta_), dtrkpt_(iOther.dtrkpt_),
131  track_( iOther.track_.exchange(nullptr) ),
132  pdgId_(iOther.pdgId_), qualityFlags_(iOther.qualityFlags_),
133  pvRefProd_(std::move(iOther.pvRefProd_)),pvRefKey_(iOther.pvRefKey_),
134  m_( iOther.m_.exchange(nullptr)),
137  }
138 
139 
141  if(this == &iOther) {
142  return *this;
143  }
144  packedPt_ =iOther.packedPt_;
145  packedEta_=iOther.packedEta_;
146  packedPhi_=iOther.packedPhi_;
147  packedM_=iOther.packedM_;
148  packedDxy_=iOther.packedDxy_;
149  packedDz_=iOther.packedDz_;
150  packedDPhi_=iOther.packedDPhi_;
151  packedDEta_=iOther.packedDEta_;
157  //Need to trigger unpacking in iOther
158  if(p4_) {
159  *p4_ = iOther.polarP4();
160  } else {
161  p4_.store( new PolarLorentzVector(iOther.polarP4() ) ) ;
162  }
163  if(p4c_) {
164  *p4c_ = iOther.p4();
165  } else {
166  p4c_.store( new LorentzVector(iOther.p4()));
167  }
168  if(vertex_) {
169  *vertex_ = iOther.vertex();
170  } else {
171  vertex_.store( new Point(iOther.vertex()));
172  }
173  dxy_=iOther.dxy_;
174  dz_ = iOther.dz_;
175  dphi_=iOther.dphi_;
176  deta_=iOther.deta_;
177  dtrkpt_=iOther.dtrkpt_;
178 
179  if(!iOther.track_) {
180  delete track_.exchange(nullptr);
181  } else {
182  if(!track_) {
183  track_.store( new reco::Track(*iOther.track_));
184  } else {
185  *track_ = *(iOther.track_);
186  }
187  }
188 
189  pdgId_=iOther.pdgId_;
191  pvRefProd_=iOther.pvRefProd_;
192  pvRefKey_=iOther.pvRefKey_;
193  if(!iOther.m_) {
194  delete m_.exchange(nullptr);
195  } else {
196  if(!m_) {
197  m_.store( new reco::Track::CovarianceMatrix(*iOther.m_));
198  } else {
199  *m_ = *(iOther.m_);
200  }
201  }
202 
203 
204  packedHits_=iOther.packedHits_;
209  return *this;
210  }
211 
213  if(this == &iOther) {
214  return *this;
215  }
216  packedPt_ =iOther.packedPt_;
217  packedEta_=iOther.packedEta_;
218  packedPhi_=iOther.packedPhi_;
219  packedM_=iOther.packedM_;
220  packedDxy_=iOther.packedDxy_;
221  packedDz_=iOther.packedDz_;
222  packedDPhi_=iOther.packedDPhi_;
223  packedDEta_=iOther.packedDEta_;
224  packedDTrkPt_=iOther.packedDTrkPt_;
225  packedCovariance_=iOther.packedCovariance_;
226  packedPuppiweight_=iOther.packedPuppiweight_;
227  packedPuppiweightNoLepDiff_=iOther.packedPuppiweightNoLepDiff_;
228  hcalFraction_=iOther.hcalFraction_;
229  delete p4_.exchange(iOther.p4_.exchange(nullptr));
230  delete p4c_.exchange(iOther.p4c_.exchange(nullptr));
231  delete vertex_.exchange(iOther.vertex_.exchange(nullptr));
232  dxy_=iOther.dxy_;
233  dz_ = iOther.dz_;
234  dphi_=iOther.dphi_;
235  deta_=iOther.deta_;
236  dtrkpt_=iOther.dtrkpt_;
237  delete track_.exchange(iOther.track_.exchange( nullptr));
238  pdgId_=iOther.pdgId_;
239  qualityFlags_=iOther.qualityFlags_;
240  pvRefProd_=iOther.pvRefProd_;
241  pvRefKey_=iOther.pvRefKey_;
242  delete m_.exchange(iOther.m_.exchange(nullptr));
243  packedHits_=iOther.packedHits_;
244  packedLayers_=iOther.packedLayers_;
245  normalizedChi2_=iOther.normalizedChi2_;
246  covarianceVersion_=iOther.covarianceVersion_;
247  covarianceSchema_=iOther.covarianceSchema_;
248  return *this;
249  }
250 
252  virtual ~PackedCandidate();
254  virtual size_t numberOfDaughters() const;
256  virtual const reco::Candidate * daughter( size_type ) const;
258  virtual size_t numberOfMothers() const;
260  virtual const reco::Candidate * mother( size_type ) const;
262  virtual reco::Candidate * daughter( size_type );
264  virtual reco::Candidate * daughter(const std::string& s );
266  virtual const reco::Candidate * daughter(const std::string& s ) const;
269  virtual size_t numberOfSourceCandidatePtrs() const {return 0;}
273  return reco::CandidatePtr();
274  }
275 
277  virtual int charge() const {
278  switch (abs(pdgId_)) {
279  case 211: return (pdgId_>0)-(pdgId_<0);
280  case 11: return (-1)*(pdgId_>0)+(pdgId_<0); //e
281  case 13: return (-1)*(pdgId_>0)+(pdgId_<0); //mu
282  case 15: return (-1)*(pdgId_>0)+(pdgId_<0); //tau
283  case 24: return (pdgId_>0)-(pdgId_<0); //W
284  default: return 0; //FIXME: charge is not defined
285  }
286  }
288  virtual void setCharge( int charge) {}
290  virtual int threeCharge() const {return charge()*3;}
292  virtual void setThreeCharge( int threecharge) {}
294  virtual const LorentzVector & p4() const { if (!p4c_) unpack(); return *p4c_; }
296  virtual const PolarLorentzVector & polarP4() const { if (!p4c_) unpack(); return *p4_; }
298  virtual Vector momentum() const { if (!p4c_) unpack(); return p4c_.load()->Vect(); }
301  virtual Vector boostToCM() const { if (!p4c_) unpack(); return p4c_.load()->BoostToCM(); }
303  virtual double p() const { if (!p4c_) unpack(); return p4c_.load()->P(); }
305  virtual double energy() const { if (!p4c_) unpack(); return p4c_.load()->E(); }
307  double et() const { return (pt()<=0) ? 0 : p4c_.load()->Et(); }
309  double et2() const { return (pt()<=0) ? 0 : p4c_.load()->Et2(); }
311  virtual double mass() const { if (!p4c_) unpack(); return p4_.load()->M(); }
313  virtual double massSqr() const { if (!p4c_) unpack(); auto m = p4_.load()->M(); return m*m;}
314 
316  virtual double mt() const { if (!p4c_) unpack(); return p4_.load()->Mt(); }
318  virtual double mtSqr() const { if (!p4c_) unpack(); return p4_.load()->Mt2(); }
320  virtual double px() const { if (!p4c_) unpack(); return p4c_.load()->Px(); }
322  virtual double py() const { if (!p4c_) unpack(); return p4c_.load()->Py(); }
324  virtual double pz() const { if (!p4c_) unpack(); return p4c_.load()->Pz(); }
326  virtual double pt() const { if (!p4c_) unpack(); return p4_.load()->Pt();}
328  virtual double phi() const { if (!p4c_) unpack(); return p4_.load()->Phi(); }
329 
331  virtual double ptTrk() const {
332  maybeUnpackBoth();
333  return p4_.load()->pt() + dtrkpt_;
334  }
336  virtual float phiAtVtx() const {
337  maybeUnpackBoth();
338  float ret = p4_.load()->Phi() + dphi_;
339  while (ret > float(M_PI)) ret -= 2*float(M_PI);
340  while (ret < -float(M_PI)) ret += 2*float(M_PI);
341  return ret;
342  }
344  virtual float etaAtVtx() const {
345  maybeUnpackBoth();
346  return p4_.load()->eta() + deta_;
347  }
348 
350  virtual double theta() const { if (!p4c_) unpack(); return p4_.load()->Theta(); }
352  virtual double eta() const { if (!p4c_) unpack(); return p4_.load()->Eta(); }
354  virtual double rapidity() const { if (!p4c_) unpack(); return p4_.load()->Rapidity(); }
356  virtual double y() const { if (!p4c_) unpack(); return p4_.load()->Rapidity(); }
358  virtual void setP4( const LorentzVector & p4 ) {
359  maybeUnpackBoth(); // changing px,py,pz changes also mapping between dxy,dz and x,y,z
360  *p4_ = PolarLorentzVector(p4.Pt(), p4.Eta(), p4.Phi(), p4.M());
361  packBoth();
362  }
364  virtual void setP4( const PolarLorentzVector & p4 ) {
365  maybeUnpackBoth(); // changing px,py,pz changes also mapping between dxy,dz and x,y,z
366  *p4_ = p4;
367  packBoth();
368  }
370  virtual void setMass( double m ) {
371  if (!p4c_) unpack();
372  *p4_ = PolarLorentzVector(p4_.load()->Pt(), p4_.load()->Eta(), p4_.load()->Phi(), m);
373  pack();
374  }
375  virtual void setPz( double pz ) {
376  maybeUnpackBoth(); // changing px,py,pz changes also mapping between dxy,dz and x,y,z
377  *p4c_ = LorentzVector(p4c_.load()->Px(), p4c_.load()->Py(), pz, p4c_.load()->E());
378  *p4_ = PolarLorentzVector(p4c_.load()->Pt(), p4c_.load()->Eta(), p4c_.load()->Phi(), p4c_.load()->M());
379  packBoth();
380  }
382 
383  // Note: mask is also the maximum value
387  };
388 
389  // set number of tracker hits and layers
390  virtual void setHits( const reco::Track & tk) {
391  // first we count the number of layers with hits
392  int numberOfPixelLayers_ = tk.hitPattern().pixelLayersWithMeasurement();
393  if (numberOfPixelLayers_ > trackPixelHitsMask) numberOfPixelLayers_ = trackPixelHitsMask;
394  int numberOfStripLayers_ = tk.hitPattern().stripLayersWithMeasurement();
395  if (numberOfStripLayers_ > trackStripHitsMask) numberOfStripLayers_ = trackStripHitsMask;
396  packedLayers_ = (numberOfPixelLayers_&trackPixelHitsMask) | (numberOfStripLayers_ << trackStripHitsShift);
397  // now we count number of additional hits, beyond the one-per-layer implied by packedLayers_
398  int numberOfPixelHits_ = tk.hitPattern().numberOfValidPixelHits() - numberOfPixelLayers_;
399  if (numberOfPixelHits_ > trackPixelHitsMask) numberOfPixelHits_ = trackPixelHitsMask;
400  int numberOfStripHits_ = tk.hitPattern().numberOfValidHits() - numberOfPixelHits_ - numberOfPixelLayers_ - numberOfStripLayers_;
401  if (numberOfStripHits_ > trackStripHitsMask) numberOfStripHits_ = trackStripHitsMask;
402 
403  packedHits_ = (numberOfPixelHits_&trackPixelHitsMask) | (numberOfStripHits_ << trackStripHitsShift);
404  }
405 
406  virtual void setTrackProperties( const reco::Track & tk, const reco::Track::CovarianceMatrix & covariance,int quality,int covarianceVersion) {
410  setHits(tk);
411  packBoth();
412  packCovariance(covariance,false);
413  }
414 
415  // set track properties using quality and covarianceVersion to define the level of details in the cov. matrix
416  virtual void setTrackProperties( const reco::Track & tk,int quality,int covarianceVersion ) {
418  }
419 
426  int covarianceVersion() const { return covarianceVersion_;}
427  int covarianceSchema() const { return covarianceSchema_;}
428 
429 
431  virtual const Point & vertex() const { maybeUnpackBoth(); return *vertex_; }//{ if (fromPV_) return Point(0,0,0); else return Point(0,0,100); }
433  virtual double vx() const { maybeUnpackBoth(); return vertex_.load()->X(); }//{ return 0; }
435  virtual double vy() const { maybeUnpackBoth(); return vertex_.load()->Y(); }//{ return 0; }
437  virtual double vz() const { maybeUnpackBoth(); return vertex_.load()->Z(); }//{ if (fromPV_) return 0; else return 100; }
439  virtual void setVertex( const Point & vertex ) { maybeUnpackBoth(); *vertex_ = vertex; packVtx(); }
440 
442  enum PVAssoc { NoPV=0, PVLoose=1, PVTight=2, PVUsedInFit=3 } ;
443  const PVAssoc fromPV(size_t ipv=0) const {
444  reco::VertexRef pvRef = vertexRef();
445  if(pvAssociationQuality()==UsedInFitTight and pvRef.key()==ipv) return PVUsedInFit;
446  if(pvRef.key()==ipv or abs(pdgId())==13 or abs(pdgId())==11 ) return PVTight;
447  if(pvAssociationQuality() == CompatibilityBTag and std::abs(dzAssociatedPV()) > std::abs(dz(ipv))) return PVTight; // it is not closest, but at least prevents the B assignment stealing
448  if(pvAssociationQuality() < UsedInFitLoose or pvRef->ndof() < 4.0 ) return PVLoose;
449  return NoPV;
450  }
451 
457 
459 
461  virtual float dxy() const { maybeUnpackBoth(); return dxy_; }
463  virtual float dz(size_t ipv=0) const { maybeUnpackBoth(); return dz_ + (*pvRefProd_)[pvRefKey_].position().z()-(*pvRefProd_)[ipv].position().z(); }
465  virtual float dzAssociatedPV() const { maybeUnpackBoth(); return dz_; }
467  virtual float dxy(const Point &p) const ;
469  virtual float dz(const Point &p) const ;
470 
472  virtual float dzError() const { maybeUnpackCovariance(); return sqrt((*m_.load())(4,4)); }
474  virtual float dxyError() const { maybeUnpackCovariance(); return sqrt((*m_.load())(3,3)); }
475 
476 
478  virtual const reco::Track & pseudoTrack() const { if (!track_) unpackTrk(); return *track_; }
479 
481  virtual const reco::Track * bestTrack() const {
482  if (packedHits_!=0 || packedLayers_ !=0) {
484  return track_.load();
485  }
486  else
487  return nullptr;
488  }
490  bool hasTrackDetails() {return (packedHits_!=0 || packedLayers_ !=0); }
491 
492 
497 
501  noLostInnerHits=0, // it could still not have a hit in the first layer, e.g. if it crosses an inactive sensor
504  };
507  }
509  int lost = hits; if (lost > 2) lost = 2; // protection against misuse
510  lost++; // shift so it's 0 .. 3 instead of (-1) .. 2
512  }
513 
514  void setMuonID(bool isStandAlone, bool isGlobal) {
515  int16_t muonFlags = isStandAlone | (2*isGlobal);
517  }
518 
520  virtual int pdgId() const { return pdgId_; }
521  // set PDG identifier
522  virtual void setPdgId( int pdgId ) { pdgId_ = pdgId; }
524  virtual int status() const { return qualityFlags_; } /*FIXME*/
526  virtual void setStatus( int status ) {} /*FIXME*/
528  static const unsigned int longLivedTag = 0; /*FIXME*/
530  virtual void setLongLived() {} /*FIXME*/
532  virtual bool longLived() const;
534  static const unsigned int massConstraintTag = 0; /*FIXME*/
536  virtual void setMassConstraint() {} /*FIXME*/
538  virtual bool massConstraint() const;
539 
541  virtual PackedCandidate * clone() const {
542  return new PackedCandidate( *this );
543  }
544 
546  virtual double vertexChi2() const;
553  virtual double vertexNdof() const;
555  virtual double vertexNormalizedChi2() const;
557  virtual double vertexCovariance(int i, int j) const;
561  virtual void fillVertexCovariance(CovarianceMatrix & v) const;
564  virtual bool hasMasterClone() const;
567  virtual const reco::CandidateBaseRef & masterClone() const;
570  virtual bool hasMasterClonePtr() const;
573 
574  virtual const reco::CandidatePtr & masterClonePtr() const;
575 
577  template<typename Ref>
578  Ref masterRef() const { return masterClone().template castTo<Ref>(); }
579 
580  virtual bool isElectron() const { return false; }
581  virtual bool isMuon() const { return false; }
582  virtual bool isStandAloneMuon() const { return ((qualityFlags_ & muonFlagsMask) >> muonFlagsShift) & 1; }
583  virtual bool isGlobalMuon() const { return ((qualityFlags_ & muonFlagsMask) >> muonFlagsShift) & 2; }
584  virtual bool isTrackerMuon() const { return false; }
585  virtual bool isCaloMuon() const { return false; }
586  virtual bool isPhoton() const { return false; }
587  virtual bool isConvertedPhoton() const { return false; }
588  virtual bool isJet() const { return false; }
589 
590  // puppiweights
591  void setPuppiWeight(float p, float p_nolep = 0.0);
592  float puppiWeight() const;
593  float puppiWeightNoLep() const;
594 
595  // for teh neutral fraction
596  void setHcalFraction(float p);
597  float hcalFraction() const { return (hcalFraction_/100.); }
598 
601  //3D IP covariance
602  uint16_t dxydxy;
603  uint16_t dxydz;
604  uint16_t dzdz;
605  //other IP relevant elements
606  uint16_t dlambdadz;
607  uint16_t dphidxy;
608  //other diag elements
609  uint16_t dptdpt;
610  uint16_t detadeta;
611  uint16_t dphidphi;
612  };
613 
614  private:
615  void unpackCovarianceElement(reco::TrackBase::CovarianceMatrix & m, uint16_t packed, int i,int j) const {
617  }
618  uint16_t packCovarianceElement(const reco::TrackBase::CovarianceMatrix &m,int i,int j) const {
620  }
621 
622  protected:
623  friend class ::testPackedCandidate;
624  static constexpr float kMinDEtaToStore_=0.001;
625  static constexpr float kMinDTrkPtToStore_=0.001;
626 
627 
631 
632  void pack(bool unpackAfterwards=true) ;
633  void unpack() const ;
634  void packVtx(bool unpackAfterwards=true) ;
635  void unpackVtx() const ;
636  void packCovariance(const reco::TrackBase::CovarianceMatrix & m,bool unpackAfterwards=true) ;
637  void unpackCovariance() const;
638  void maybeUnpackBoth() const { if (!p4c_) unpack(); if (!vertex_) unpackVtx(); }
639  void maybeUnpackTrack() const { if (!track_) unpackTrk(); }
640  void maybeUnpackCovariance() const { if (!m_) unpackCovariance(); }
641  void packBoth() { pack(false); packVtx(false); delete p4_.exchange(nullptr); delete p4c_.exchange(nullptr); delete vertex_.exchange(nullptr); unpack(); unpackVtx(); } // do it this way, so that we don't loose precision on the angles before computing dxy,dz
642  void unpackTrk() const ;
643 
645  int8_t packedPuppiweightNoLepDiff_; // storing the DIFFERENCE of (all - "no lep") for compression optimization
647 
649  mutable std::atomic<PolarLorentzVector*> p4_;
650  mutable std::atomic<LorentzVector*> p4c_;
652  mutable std::atomic<Point*> vertex_;
653  CMS_THREAD_GUARD(vertex_) mutable float dxy_, dz_, dphi_, deta_, dtrkpt_;
655  mutable std::atomic<reco::Track*> track_;
657  int pdgId_;
658  uint16_t qualityFlags_;
662 
664  mutable std::atomic<reco::TrackBase::CovarianceMatrix *> m_;
665  uint8_t packedHits_, packedLayers_; // packedLayers_ -> layers with valid hits; packedHits_ -> extra hits beyond the one-per-layer implied by packedLayers_
666 
668  uint8_t normalizedChi2_;
672  //static std::atomic<CovarianceParameterization*> covarianceParameterization_;
673  static std::once_flag covariance_load_flag;
675  std::call_once(covariance_load_flag,[](int v) { covarianceParameterization_.load(v); } ,covarianceVersion_ );
676  if(covarianceParameterization_.loadedVersion() != covarianceVersion_ )
677  {
679  << "Attempting to load multiple covariance version in same process. This is not supported.";
680  }
682  }
683 
685  virtual bool overlap( const reco::Candidate & ) const;
686  template<typename, typename, typename> friend struct component;
687  friend class ::OverlapChecker;
688  friend class ShallowCloneCandidate;
690 
696  };
697  };
698 
699  typedef std::vector<pat::PackedCandidate> PackedCandidateCollection;
702 }
703 
704 #endif
float puppiWeight() const
Set both weights at once (with option for only full PUPPI)
virtual float dz(size_t ipv=0) const
dz with respect to the PV[ipv]
virtual void setP4(const LorentzVector &p4)
set 4-momentum
void setMuonID(bool isStandAlone, bool isGlobal)
virtual void setVertex(const Point &vertex)
set vertex
virtual size_t numberOfMothers() const
number of mothers
virtual bool hasMasterClonePtr() const
virtual void setPdgId(int pdgId)
virtual float etaAtVtx() const
eta from the track (normally identical to eta())
int covarianceSchema() const
float puppiWeightNoLep() const
Weight from full PUPPI.
void setPuppiWeight(float p, float p_nolep=0.0)
virtual float dzError() const
uncertainty on dz
std::atomic< Point * > vertex_
vertex position
int numberOfHits() const
size_t size_type
Definition: Candidate.h:30
float unpack(uint16_t packed, int schema, int i, int j, float pt, float eta, int nHits, int pixelHits, float cii=1., float cjj=1.) const
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
uint16_t packCovarianceElement(const reco::TrackBase::CovarianceMatrix &m, int i, int j) const
float hcalFraction() const
Set the fraction of Ecal and Hcal needed for HF and neutral hadrons.
virtual const reco::Track * bestTrack() const
return a pointer to the track if present. otherwise, return a null pointer
reco::VertexRef::key_type pvRefKey_
virtual bool isCaloMuon() const
int pixelLayersWithMeasurement() const
void maybeUnpackBoth() const
static const unsigned int longLivedTag
long lived flag
int numberOfValidHits() const
Definition: HitPattern.h:823
PackedCandidate & operator=(const PackedCandidate &iOther)
virtual double y() const
rapidity
virtual void fillVertexCovariance(CovarianceMatrix &v) const
fill SMatrix
static const unsigned int massConstraintTag
do mass constraint flag
virtual double mtSqr() const
transverse mass squared
std::vector< pat::PackedCandidate > PackedCandidateCollection
math::XYZPoint Point
point in the space
virtual void setCovarianceVersion(int v)
virtual double vertexNdof() const
PackedCandidate(const PackedCandidate &iOther)
void unpackCovarianceElement(reco::TrackBase::CovarianceMatrix &m, uint16_t packed, int i, int j) const
PackedCovariance packedCovariance_
virtual double pt() const
transverse momentum
virtual void setStatus(int status)
set status word
key_type key() const
Accessor for product key.
Definition: Ref.h:264
int pixelLayersWithMeasurement() const
Definition: HitPattern.cc:499
virtual double vx() const
x coordinate of vertex position
virtual bool overlap(const reco::Candidate &) const
check overlap with another Candidate
#define nullptr
virtual bool isPhoton() const
virtual double eta() const
momentum pseudorapidity
virtual void setP4(const PolarLorentzVector &p4)
set 4-momentum
const reco::VertexRef vertexRef() const
PackedCandidate(PackedCandidate &&iOther)
math::PtEtaPhiMLorentzVector PolarLorentzVector
Lorentz vector.
#define constexpr
PackedCandidate(const reco::Candidate &c, const reco::VertexRefProd &pvRefProd, reco::VertexRef::key_type pvRefKey)
float pack(float value, int schema, int i, int j, float pt, float eta, int nHits, int pixelHits, float cii=1., float cjj=1.) const
bool hasTrackDetails()
Return true if a bestTrack can be extracted from this Candidate.
Ref masterRef() const
cast master clone reference to a concrete type
Definition: HeavyIon.h:7
PtEtaPhiMLorentzVectorD PtEtaPhiMLorentzVector
Lorentz vector with cartesian internal representation.
Definition: LorentzVector.h:25
reco::CandidateCollection daughters
collection of daughter candidates
virtual const reco::Candidate * daughter(size_type) const
return daughter at a given position (throws an exception)
virtual double phi() const
momentum azimuthal angle
XYZTLorentzVectorD XYZTLorentzVector
Lorentz vector with cylindrical internal representation using pseudorapidity.
Definition: LorentzVector.h:29
virtual bool isTrackerMuon() const
virtual void setLongLived()
set long lived flag
virtual double mass() const
mass
virtual bool isConvertedPhoton() const
friend struct component
virtual void setMassConstraint()
set mass constraint flag
std::atomic< reco::Track * > track_
reco::Track
virtual bool isMuon() const
const PVAssociationQuality pvAssociationQuality() const
virtual PackedCandidate * clone() const
returns a clone of the Candidate object
void setHcalFraction(float p)
Weight from PUPPI removing leptons.
math::XYZTLorentzVector LorentzVector
Lorentz vector.
virtual void setTrackProperties(const reco::Track &tk, int quality, int covarianceVersion)
void maybeUnpackCovariance() const
const PVAssoc fromPV(size_t ipv=0) const
CovarianceMatrix covariance() const
return track covariance matrix
Definition: TrackBase.h:726
T sqrt(T t)
Definition: SSEVec.h:18
virtual double py() const
y coordinate of momentum vector
The Signals That Services Can Subscribe To This is based on ActivityRegistry and is current per Services can connect to the signals distributed by the ActivityRegistry in order to monitor the activity of the application Each possible callback has some defined which we here list in angle e< void, edm::EventID const &, edm::Timestamp const & > We also list in braces which AR_WATCH_USING_METHOD_ is used for those or
Definition: Activities.doc:12
bool trackHighPurity() const
true if the track had the highPurity quality bit
LostInnerHits lostInnerHits() const
virtual int status() const
status word
PackedCandidate()
default constructor
virtual double rapidity() const
rapidity
virtual const reco::CandidateBaseRef & masterClone() const
edm::Ref< pat::PackedCandidateCollection > PackedCandidateRef
friend class ShallowCloneCandidate
static CovarianceParameterization covarianceParameterization_
virtual double energy() const
energy
virtual double ptTrk() const
pt from the track (normally identical to pt())
#define CMS_THREAD_GUARD(_var_)
double et2() const
transverse energy squared (use this for cuts)!
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
virtual bool isJet() const
int stripLayersWithMeasurement() const
virtual int charge() const
electric charge
virtual const reco::Track & pseudoTrack() const
Return reference to a pseudo track made with candidate kinematics, parameterized error for eta...
virtual double theta() const
momentum polar angle
std::atomic< PolarLorentzVector * > p4_
the four vector
virtual int threeCharge() const
electric charge
#define CMS_THREAD_SAFE
PackedCandidate(const PolarLorentzVector &p4, const Point &vtx, float trkPt, float etaAtVtx, float phiAtVtx, int pdgId, const reco::VertexRefProd &pvRefProd, reco::VertexRef::key_type pvRefKey)
virtual double vertexNormalizedChi2() const
chi-squared divided by n.d.o.f.
virtual void setThreeCharge(int threecharge)
set electric charge
virtual void setPz(double pz)
virtual double mt() const
transverse mass
edm::Ref< VertexCollection > VertexRef
persistent reference to a Vertex
Definition: VertexFwd.h:13
virtual float dzAssociatedPV() const
dz with respect to the PV ref
int numberOfPixelHits() const
virtual const reco::CandidatePtr & masterClonePtr() const
virtual double vy() const
y coordinate of vertex position
int trackerLayersWithMeasurement() const
std::atomic< LorentzVector * > p4c_
virtual const PolarLorentzVector & polarP4() const
four-momentum Lorentz vector
#define M_PI
std::atomic< reco::TrackBase::CovarianceMatrix * > m_
IP covariance.
LostInnerHits
Enumerator specifying the.
uint8_t normalizedChi2_
track quality information
PVAssoc
This refers to the association to PV=ipv. >=PVLoose corresponds to JME definition, >=PVTight to isolation definition.
virtual size_t numberOfSourceCandidatePtrs() const
edm::Ptr< Candidate > CandidatePtr
persistent reference to an object in a collection of Candidate objects
Definition: CandidateFwd.h:25
virtual Vector momentum() const
spatial momentum vector
virtual bool isGlobalMuon() const
virtual bool massConstraint() const
do mass constraint?
const HitPattern & hitPattern() const
Access the hit pattern, indicating in which Tracker layers the track has hits.
Definition: TrackBase.h:445
XYZVectorD XYZVector
spatial vector with cartesian internal representation
Definition: Vector3D.h:30
virtual double massSqr() const
mass squared
XYZPointD XYZPoint
point in space with cartesian internal representation
Definition: Point3D.h:12
edm::RefVector< pat::PackedCandidateCollection > PackedCandidateRefVector
def load(fileName)
Definition: svgfig.py:546
virtual Vector boostToCM() const
int stripLayersWithMeasurement() const
Definition: HitPattern.h:1035
static std::once_flag covariance_load_flag
virtual double vz() const
z coordinate of vertex position
int covarianceVersion() const
virtual void setMass(double m)
set particle mass
virtual reco::CandidatePtr sourceCandidatePtr(size_type i) const
static float kMinDEtaToStore_
virtual float phiAtVtx() const
momentum azimuthal angle from the track (normally identical to phi())
int pdgId_
PDG identifier.
virtual const Point & vertex() const
vertex position
edm::RefProd< VertexCollection > VertexRefProd
persistent reference to a Vertex
Definition: VertexFwd.h:15
virtual size_t numberOfDaughters() const
number of daughters
void unpackCovariance() const
CovarianceMatrix vertexCovariance() const
return SMatrix
virtual bool isStandAloneMuon() const
friend class ShallowClonePtrCandidate
fixed size matrix
Fraction of Ecal and Hcal for HF and neutral hadrons.
virtual bool longLived() const
is long lived?
PackedCandidate & operator=(PackedCandidate &&iOther)
virtual const reco::Candidate * mother(size_type) const
return mother at a given position (throws an exception)
virtual void setCharge(int charge)
set electric charge
void packVtx(bool unpackAfterwards=true)
void setLostInnerHits(LostInnerHits hits)
PackedCandidate(const LorentzVector &p4, const Point &vtx, float trkPt, float etaAtVtx, float phiAtVtx, int pdgId, const reco::VertexRefProd &pvRefProd, reco::VertexRef::key_type pvRefKey)
trackHitShiftsAndMasks
set impact parameters covariance
int numberOfValidPixelHits() const
Definition: HitPattern.h:838
virtual const LorentzVector & p4() const
four-momentum Lorentz vecto r
void pack(bool unpackAfterwards=true)
virtual bool isElectron() const
double et() const
transverse energy
virtual double px() const
x coordinate of momentum vector
void packCovariance(const reco::TrackBase::CovarianceMatrix &m, bool unpackAfterwards=true)
virtual float dxy() const
dxy with respect to the PV ref
virtual double vertexChi2() const
chi-squares
void setTrackHighPurity(bool highPurity)
set to true if the track had the highPurity quality bit
virtual void setTrackProperties(const reco::Track &tk, const reco::Track::CovarianceMatrix &covariance, int quality, int covarianceVersion)
virtual ~PackedCandidate()
destructor
virtual int pdgId() const
PDG identifier.
void maybeUnpackTrack() const
virtual void setHits(const reco::Track &tk)
const CovarianceParameterization & covarianceParameterization() const
virtual double pz() const
z coordinate of momentum vector
virtual float dxyError() const
uncertainty on dxy
math::XYZVector Vector
point in the space
def move(src, dest)
Definition: eostools.py:510
boost::remove_cv< typename boost::remove_reference< argument_type >::type >::type key_type
Definition: Ref.h:168
static float kMinDTrkPtToStore_
math::Error< dimension >::type CovarianceMatrix
5 parameter covariance matrix
Definition: TrackBase.h:77
virtual double p() const
magnitude of momentum vector
virtual bool hasMasterClone() const
reco::VertexRefProd pvRefProd_
Use these to build a Ref to primary vertex.
void setAssociationQuality(PVAssociationQuality q)