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;
169 if ( firstHit_ == 0) {
170 if(innerLost == validHitInFirstPixelBarrelLayer){
181 if(innerLost == validHitInFirstPixelBarrelLayer){
183 for(; i<numberOfPixelLayers; i++) {
197 for(;i<numberOfPixelLayers; i++) {
204 for(;i<numberOfPixelHits; i++) {
222 for(
int sl=slOffset; sl < numberOfStripLayers+slOffset; ++sl, ++
i) {
231 for(;i<numberOfHits;i++) {
241 case validHitInFirstPixelBarrelLayer:
243 case noLostInnerHits:
245 case oneLostInnerHit:
248 case moreLostInnerHits:
257 if( track_.compare_exchange_strong(expected,
track.get()) ) {
268 <<
"this Candidate has no master clone reference." 269 <<
"Can't call masterClone() method.\n";
283 <<
"this Candidate has no master clone ptr." 284 <<
"Can't call masterClonePtr() method.\n";
310 <<
"This Candidate type does not implement daughter(std::string). " 311 <<
"Please use CompositeCandidate or NamedCompositeCandidate.\n";
316 <<
"This Candidate type does not implement daughter(std::string). " 317 <<
"Please use CompositeCandidate or NamedCompositeCandidate.\n";
340 <<
"reco::ConcreteCandidate does not implement vertex covariant matrix.\n";
345 <<
"reco::ConcreteCandidate does not implement vertex covariant matrix.\n";
357 packedPuppiweightNoLepDiff_ =
pack8logClosed((p_nolep-0.5)*2,-2,0,64) - packedPuppiweight_;
368 rawCaloFraction_ = 100*
p;
372 hcalFraction_ = 100*
p;
376 isIsolatedChargedHadron_ =
p;
380 if (aTime == 0 && aTimeError == 0) {
381 packedTime_ = 0; packedTimeError_ = 0;
382 }
else if (aTimeError == 0) {
383 packedTimeError_ = 0;
384 packedTime_ = packTimeNoError(aTime);
386 packedTimeError_ = packTimeError(aTimeError);
387 aTimeError = unpackTimeError(packedTimeError_);
388 packedTime_ = packTimeWithError(aTime, aTimeError);
394 if (timeError <= 0)
return 0;
400 return std::max<uint8_t>(
std::min(std::round(std::ldexp(std::log2(timeError/MIN_TIMEERROR), +EXPO_TIMEERROR)), 255.
f), 1);
403 return timeError > 0 ? MIN_TIMEERROR * std::exp2(std::ldexp(
float(timeError),-EXPO_TIMEERROR)) : -1.0f;
406 if (time == 0)
return 0.f;
407 return (time > 0 ? MIN_TIME_NOERROR : -MIN_TIME_NOERROR) * std::exp2(std::ldexp(
float(
std::abs(time)),-EXPO_TIME_NOERROR));
416 if (
std::abs(time) < MIN_TIME_NOERROR)
return 0;
417 float fpacked = std::ldexp(std::log2(
std::abs(time/MIN_TIME_NOERROR)),+EXPO_TIME_NOERROR);
418 return (time > 0 ? +1 : -1)*
std::min(std::round(fpacked), 2047.
f);
423 return std::ldexp(unpackTimeError(timeError), EXPO_TIME_WITHERROR) *
float(time/2);
435 float fpacked = std::round(time/std::ldexp(timeError, EXPO_TIME_WITHERROR));
437 return int16_t(fpacked) * 2;
439 int16_t packed = packTimeNoError(time);
440 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
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)
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
double unpack8logClosed(int8_t i, double lmin, double lmax, uint8_t base=128)
reverse of pack8logClosed
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.