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 const float pzpt = deta_ ? std::sinh(etaAtVtx()) : p4_.load()->Pz()/p4_.load()->Pt();
154 return (vertex_.load()->Z()-p.Z()) - ((vertex_.load()->X()-p.X()) *
std::cos(phi) + (vertex_.load()->Y()-p.Y()) *
std::sin(phi)) * pzpt;
160 maybeUnpackCovariance();
161 int numberOfStripLayers = stripLayersWithMeasurement(), numberOfPixelLayers = pixelLayersWithMeasurement();
162 int numberOfPixelHits = this->numberOfPixelHits();
163 int numberOfHits = this->numberOfHits();
165 int ndof = numberOfHits+numberOfPixelHits-5;
170 if ( firstHit_ == 0) {
171 if(innerLost == validHitInFirstPixelBarrelLayer){
182 if(innerLost == validHitInFirstPixelBarrelLayer){
184 for(; i<numberOfPixelLayers; i++) {
198 for(;i<numberOfPixelLayers; i++) {
205 for(;i<numberOfPixelHits; i++) {
223 for(
int sl=slOffset; sl < numberOfStripLayers+slOffset; ++sl, ++
i) {
232 for(;i<numberOfHits;i++) {
242 case validHitInFirstPixelBarrelLayer:
244 case noLostInnerHits:
246 case oneLostInnerHit:
249 case moreLostInnerHits:
258 if( track_.compare_exchange_strong(expected,
track.get()) ) {
269 <<
"this Candidate has no master clone reference." 270 <<
"Can't call masterClone() method.\n";
284 <<
"this Candidate has no master clone ptr." 285 <<
"Can't call masterClonePtr() method.\n";
311 <<
"This Candidate type does not implement daughter(std::string). " 312 <<
"Please use CompositeCandidate or NamedCompositeCandidate.\n";
317 <<
"This Candidate type does not implement daughter(std::string). " 318 <<
"Please use CompositeCandidate or NamedCompositeCandidate.\n";
341 <<
"reco::ConcreteCandidate does not implement vertex covariant matrix.\n";
346 <<
"reco::ConcreteCandidate does not implement vertex covariant matrix.\n";
369 rawCaloFraction_ = 100*
p;
373 hcalFraction_ = 100*
p;
377 isIsolatedChargedHadron_ =
p;
381 if (aTime == 0 && aTimeError == 0) {
382 packedTime_ = 0; packedTimeError_ = 0;
383 }
else if (aTimeError == 0) {
384 packedTimeError_ = 0;
385 packedTime_ = packTimeNoError(aTime);
387 packedTimeError_ = packTimeError(aTimeError);
388 aTimeError = unpackTimeError(packedTimeError_);
389 packedTime_ = packTimeWithError(aTime, aTimeError);
395 if (timeError <= 0)
return 0;
401 return std::max<uint8_t>(
std::min(std::round(std::ldexp(std::log2(timeError/MIN_TIMEERROR), +EXPO_TIMEERROR)), 255.
f), 1);
404 return timeError > 0 ? MIN_TIMEERROR * std::exp2(std::ldexp(
float(timeError),-EXPO_TIMEERROR)) : -1.0f;
407 if (time == 0)
return 0.f;
408 return (time > 0 ? MIN_TIME_NOERROR : -MIN_TIME_NOERROR) * std::exp2(std::ldexp(
float(
std::abs(time)),-EXPO_TIME_NOERROR));
417 if (
std::abs(time) < MIN_TIME_NOERROR)
return 0;
418 float fpacked = std::ldexp(std::log2(
std::abs(time/MIN_TIME_NOERROR)),+EXPO_TIME_NOERROR);
419 return (time > 0 ? +1 : -1)*
std::min(std::round(fpacked), 2047.
f);
424 return std::ldexp(unpackTimeError(timeError), EXPO_TIME_WITHERROR) *
float(time/2);
436 float fpacked = std::round(time/std::ldexp(timeError, EXPO_TIME_WITHERROR));
438 return int16_t(fpacked) * 2;
440 int16_t packed = packTimeNoError(time);
441 return packed * 2 + (time > 0 ? +1 : -1);
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]
static uint32_t getLayer(uint16_t pattern)
const reco::Candidate * daughter(size_type) const override
return daughter at a given position (throws an exception)
bool isNonnull() const
Checks for non-null.
static bool pixelHitFilter(uint16_t pattern)
void fillVertexCovariance(CovarianceMatrix &v) const override
fill SMatrix
float puppiWeightNoLep() const
Weight from full PUPPI.
void setPuppiWeight(float p, float p_nolep=0.0)
CovarianceMatrix vertexCovariance() const override
return SMatrix
bool hasMasterClonePtr() const override
Sin< T >::type sin(const T &t)
double vertexChi2() const override
chi-squares
bool longLived() const override
is long lived?
static float unpackTimeNoError(int16_t time)
double vertexNdof() const override
void setRawCaloFraction(float p)
Weight from PUPPI removing leptons.
const reco::CandidatePtr & masterClonePtr() const override
static int16_t packTimeNoError(float time)
static int16_t packTimeWithError(float time, float timeError)
static uint8_t packTimeError(float timeError)
static to allow unit testing
RhoEtaPhiVectorD RhoEtaPhiVector
spatial vector with cylindrical internal representation using pseudorapidity
static float float16to32(uint16_t h)
bool massConstraint() const override
do mass constraint?
size_t numberOfMothers() const override
number of mothers
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)
static bool stripHitFilter(uint16_t pattern)
static CovarianceParameterization covarianceParameterization_
Abs< T >::type abs(const T &t)
double vertexNormalizedChi2() const override
chi-squared divided by n.d.o.f.
~PackedCandidate() override
destructor
static uint32_t getSubStructure(uint16_t pattern)
LostInnerHits
Enumerator specifying the.
XYZVectorD XYZVector
spatial vector with cartesian internal representation
const reco::Candidate * mother(size_type) const override
return mother at a given position (throws an exception)
static std::once_flag covariance_load_flag
math::XYZTLorentzVector LorentzVector
Lorentz vector.
void unpackCovariance() const
void setDTimeAssociatedPV(float aTime, float aTimeError=0)
set time measurement
virtual int charge() const =0
electric charge
size_t numberOfDaughters() const override
number of daughters
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)
const reco::CandidateBaseRef & masterClone() const override
virtual float dxy() const
dxy with respect to the PV ref
bool overlap(const reco::Candidate &) const override
check overlap with another Candidate
static float unpackTimeWithError(int16_t time, uint8_t timeError)
bool hasMasterClone() const override
static float unpackTimeError(uint8_t timeError)
math::Error< dimension >::type CovarianceMatrix
5 parameter covariance matrix
math::PtEtaPhiMLorentzVector PolarLorentzVector
Lorentz vector.