18 if (unpackAfterwards) {
19 delete p4_.exchange(
nullptr);
20 delete p4c_.exchange(
nullptr);
28 float dxPV = vertex_.load()->X() - pv.X(), dyPV = vertex_.load()->Y() - pv.Y();
29 float s =
std::sin(
float(p4_.load()->Phi())+dphi_),
c =
std::cos(
float(p4_.load()->Phi()+dphi_));
30 dxy_ = - dxPV * s + dyPV *
c;
34 float pzpt = p4_.load()->Pz()/p4_.load()->Pt();
35 dz_ = vertex_.load()->Z() - pv.Z() - (dxPV*c + dyPV*
s) * pzpt;
42 if (unpackAfterwards) {
43 delete vertex_.exchange(
nullptr);
50 double shift = (pt<1. ? 0.1*pt : 0.1/
pt);
51 double sign = ( (
int(pt*10) % 2 == 0 ) ? 1 : -1 );
53 auto p4 = std::make_unique<PolarLorentzVector>(
pt,
57 auto p4c = std::make_unique<LorentzVector>( *p4 );
59 if( p4_.compare_exchange_strong(expectp4,p4.get()) ) {
66 if(p4c_.compare_exchange_strong(expectp4c, p4c.get()) ) {
72 packedCovariance_.dptdpt = packCovarianceElement(m,0,0);
73 packedCovariance_.detadeta = packCovarianceElement(m,1,1);
74 packedCovariance_.dphidphi = packCovarianceElement(m,2,2);
75 packedCovariance_.dxydxy =packCovarianceElement(m,3,3);
76 packedCovariance_.dzdz = packCovarianceElement(m,4,4);
77 packedCovariance_.dxydz = packCovarianceElement(m,3,4);
78 packedCovariance_.dlambdadz = packCovarianceElement(m,1,4);
79 packedCovariance_.dphidxy = packCovarianceElement(m,2,3);
81 if(unpackAfterwards) unpackCovariance();
88 auto m = std::make_unique<reco::TrackBase::CovarianceMatrix>() ;
93 unpackCovarianceElement(*
m,packedCovariance_.dptdpt,0,0);
94 unpackCovarianceElement(*
m,packedCovariance_.detadeta,1,1);
95 unpackCovarianceElement(*
m,packedCovariance_.dphidphi,2,2);
96 unpackCovarianceElement(*
m,packedCovariance_.dxydxy,3,3);
97 unpackCovarianceElement(*
m,packedCovariance_.dzdz,4,4);
98 unpackCovarianceElement(*
m,packedCovariance_.dxydz,3,4);
99 unpackCovarianceElement(*
m,packedCovariance_.dlambdadz,1,4);
100 unpackCovarianceElement(*
m,packedCovariance_.dphidxy,2,3);
102 if( m_.compare_exchange_strong(expected,
m.get()) ) {
108 <<
"You do not have a valid track parameters file loaded. " 109 <<
"Please check that the release version is compatible with your input data" 110 <<
"or avoid accessing track parameter uncertainties. ";
123 auto vertex = std::make_unique<Point>(pv.X() - dxy_ *
s,
130 Point* expected =
nullptr;
131 if( vertex_.compare_exchange_strong(expected,vertex.get()) ) {
139 delete vertex_.load();
140 delete track_.load();
147 const float phi =
float(p4_.load()->Phi())+dphi_;
148 return -(vertex_.load()->X()-p.X()) *
std::sin(phi) + (vertex_.load()->Y()-p.Y()) *
std::cos(phi);
152 const float phi =
float(p4_.load()->Phi())+dphi_;
153 return (vertex_.load()->Z()-p.Z()) - ((vertex_.load()->X()-p.X()) *
std::cos(phi) + (vertex_.load()->Y()-p.Y()) *
std::sin(phi)) * p4_.load()->Pz()/p4_.load()->Pt();
159 maybeUnpackCovariance();
160 int numberOfStripLayers = stripLayersWithMeasurement(), numberOfPixelLayers = pixelLayersWithMeasurement();
161 int numberOfPixelHits = this->numberOfPixelHits();
162 int numberOfHits = this->numberOfHits();
164 int ndof = numberOfHits+numberOfPixelHits-5;
172 if(innerLost == validHitInFirstPixelBarrelLayer){
176 for(i++; i<numberOfPixelLayers; i++) {
185 for(;i<numberOfPixelLayers; i++) {
194 for(;i<numberOfPixelHits; i++) {
200 for(
int sl = 0; sl < numberOfStripLayers; ++sl, ++
i) {
209 for(;i<numberOfHits;i++) {
215 case validHitInFirstPixelBarrelLayer:
217 case noLostInnerHits:
219 case oneLostInnerHit:
222 case moreLostInnerHits:
231 if( track_.compare_exchange_strong(expected,
track.get()) ) {
242 <<
"this Candidate has no master clone reference." 243 <<
"Can't call masterClone() method.\n";
257 <<
"this Candidate has no master clone ptr." 258 <<
"Can't call masterClonePtr() method.\n";
284 <<
"This Candidate type does not implement daughter(std::string). " 285 <<
"Please use CompositeCandidate or NamedCompositeCandidate.\n";
290 <<
"This Candidate type does not implement daughter(std::string). " 291 <<
"Please use CompositeCandidate or NamedCompositeCandidate.\n";
314 <<
"reco::ConcreteCandidate does not implement vertex covariant matrix.\n";
319 <<
"reco::ConcreteCandidate does not implement vertex covariant matrix.\n";
331 packedPuppiweightNoLepDiff_ =
pack8logClosed((p_nolep-0.5)*2,-2,0,64) - packedPuppiweight_;
342 rawCaloFraction_ = 100*
p;
346 hcalFraction_ = 100*
p;
350 isIsolatedChargedHadron_ =
p;
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]
bool isNonnull() const
Checks for non-null.
virtual size_t numberOfMothers() const
number of mothers
virtual bool hasMasterClonePtr() const
float puppiWeightNoLep() const
Weight from full PUPPI.
void setPuppiWeight(float p, float p_nolep=0.0)
virtual void fillVertexCovariance(CovarianceMatrix &v) const
fill SMatrix
Sin< T >::type sin(const T &t)
virtual double vertexNdof() const
void setRawCaloFraction(float p)
Weight from PUPPI removing leptons.
virtual bool overlap(const reco::Candidate &) const
check overlap with another Candidate
RhoEtaPhiVectorD RhoEtaPhiVector
spatial vector with cylindrical internal representation using pseudorapidity
static float float16to32(uint16_t h)
virtual const reco::Candidate * daughter(size_type) const
return daughter at a given position (throws an exception)
int8_t pack8logClosed(double x, double lmin, double lmax, uint8_t base=128)
void setHcalFraction(float p)
Raw ECAL+HCAL energy over candidate energy for isolated charged hadrons.
virtual const LorentzVector & p4() const =0
four-momentum Lorentz vector
static uint16_t float32to16(float x)
Cos< T >::type cos(const T &t)
virtual const reco::CandidateBaseRef & masterClone() const
static CovarianceParameterization covarianceParameterization_
virtual double vertexNormalizedChi2() const
chi-squared divided by n.d.o.f.
virtual const reco::CandidatePtr & masterClonePtr() const
LostInnerHits
Enumerator specifying the.
virtual bool massConstraint() const
do mass constraint?
XYZVectorD XYZVector
spatial vector with cartesian internal representation
static std::once_flag covariance_load_flag
math::XYZTLorentzVector LorentzVector
Lorentz vector.
virtual size_t numberOfDaughters() const
number of daughters
void unpackCovariance() const
virtual int charge() const =0
electric charge
CovarianceMatrix vertexCovariance() const
return SMatrix
double unpack8logClosed(int8_t i, double lmin, double lmax, uint8_t base=128)
reverse of pack8logClosed
virtual bool longLived() const
is long lived?
virtual const reco::Candidate * mother(size_type) const
return mother at a given position (throws an exception)
void packVtx(bool unpackAfterwards=true)
static unsigned int const shift
void setIsIsolatedChargedHadron(bool p)
Fraction of Ecal and Hcal for HF and neutral hadrons and isolated charged hadrons.
math::XYZPoint Point
point in the space
virtual const Point & vertex() const =0
vertex position
void pack(bool unpackAfterwards=true)
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
virtual ~PackedCandidate()
destructor
math::Error< dimension >::type CovarianceMatrix
5 parameter covariance matrix
virtual bool hasMasterClone() const
math::PtEtaPhiMLorentzVector PolarLorentzVector
Lorentz vector.