16 packedEta_ = int16_t(std::round(p4_.load()->Eta() / 6.0f *
18 packedPhi_ = int16_t(std::round(p4_.load()->Phi() / 3.2f *
21 if (unpackAfterwards) {
22 delete p4_.exchange(
nullptr);
23 delete p4c_.exchange(
nullptr);
31 float dxPV = vertex_.load()->X() - pv.X(),
32 dyPV = vertex_.load()->Y() - pv.Y();
33 float s =
std::sin(
float(p4_.load()->Phi()) + dphi_),
35 float(p4_.load()->Phi() +
38 dxy_ = -dxPV * s + dyPV *
c;
42 float pzpt = p4_.load()->Pz() / p4_.load()->Pt();
43 dz_ = vertex_.load()->Z() - pv.Z() - (dxPV * c + dyPV *
s) * pzpt;
47 : int16_t(std::round(dz_ / 40.
f *
54 if (unpackAfterwards) {
55 delete vertex_.exchange(
nullptr);
63 (pt < 1. ? 0.1 * pt : 0.1 /
pt);
65 double sign = ((
int(pt * 10) % 2 == 0)
71 auto p4 = std::make_unique<PolarLorentzVector>(
74 auto p4c = std::make_unique<LorentzVector>(*p4);
76 if (p4_.compare_exchange_strong(expectp4, p4.get())) {
83 if (p4c_.compare_exchange_strong(expectp4c, p4c.get())) {
90 packedCovariance_.dptdpt = packCovarianceElement(m, 0, 0);
91 packedCovariance_.detadeta = packCovarianceElement(m, 1, 1);
92 packedCovariance_.dphidphi = packCovarianceElement(m, 2, 2);
93 packedCovariance_.dxydxy = packCovarianceElement(m, 3, 3);
94 packedCovariance_.dzdz = packCovarianceElement(m, 4, 4);
95 packedCovariance_.dxydz = packCovarianceElement(m, 3, 4);
96 packedCovariance_.dlambdadz = packCovarianceElement(m, 1, 4);
97 packedCovariance_.dphidxy = packCovarianceElement(m, 2, 3);
106 auto m = std::make_unique<reco::TrackBase::CovarianceMatrix>();
107 for (
int i = 0;
i < 5;
i++)
108 for (
int j = 0; j < 5; j++) {
111 unpackCovarianceElement(*
m, packedCovariance_.dptdpt, 0, 0);
112 unpackCovarianceElement(*
m, packedCovariance_.detadeta, 1, 1);
113 unpackCovarianceElement(*
m, packedCovariance_.dphidphi, 2, 2);
114 unpackCovarianceElement(*
m, packedCovariance_.dxydxy, 3, 3);
115 unpackCovarianceElement(*
m, packedCovariance_.dzdz, 4, 4);
116 unpackCovarianceElement(*
m, packedCovariance_.dxydz, 3, 4);
117 unpackCovarianceElement(*
m, packedCovariance_.dlambdadz, 1, 4);
118 unpackCovarianceElement(*
m, packedCovariance_.dphidxy, 2, 3);
120 if (m_.compare_exchange_strong(expected,
m.get())) {
126 <<
"You do not have a valid track parameters file loaded. " 127 <<
"Please check that the release version is compatible with your " 129 <<
"or avoid accessing track parameter uncertainties. ";
144 auto vertex = std::make_unique<Point>(
145 pv.X() - dxy_ *
s, pv.Y() + dxy_ *
c,
150 Point *expected =
nullptr;
151 if (vertex_.compare_exchange_strong(expected, vertex.get())) {
159 delete vertex_.load();
160 delete track_.load();
166 const float phi =
float(p4_.load()->Phi()) + dphi_;
167 return -(vertex_.load()->X() - p.X()) *
std::sin(phi) +
168 (vertex_.load()->Y() - p.Y()) *
std::cos(phi);
172 const float phi =
float(p4_.load()->Phi()) + dphi_;
174 deta_ ? std::sinh(etaAtVtx()) : p4_.load()->Pz() / p4_.load()->Pt();
175 return (vertex_.load()->Z() - p.Z()) -
176 ((vertex_.load()->X() - p.X()) *
std::cos(phi) +
177 (vertex_.load()->Y() - p.Y()) *
std::sin(phi)) *
184 maybeUnpackCovariance();
185 int numberOfStripLayers = stripLayersWithMeasurement(),
186 numberOfPixelLayers = pixelLayersWithMeasurement();
187 int numberOfPixelHits = this->numberOfPixelHits();
188 int numberOfHits = this->numberOfHits();
190 int ndof = numberOfHits + numberOfPixelHits - 5;
193 auto track = std::make_unique<reco::Track>(
194 normalizedChi2_ *
ndof,
ndof, *vertex_,
198 if (firstHit_ == 0) {
199 if (innerLost == validHitInFirstPixelBarrelLayer) {
212 if (innerLost == validHitInFirstPixelBarrelLayer) {
215 for (; i < numberOfPixelLayers; i++) {
236 for (; i < numberOfPixelLayers; i++) {
237 if (i + iOffset <= 2) {
243 i + iOffset - 3 + 1, 0,
250 for (; i < numberOfPixelHits; i++) {
252 track->appendTrackerHitPattern(
256 track->appendTrackerHitPattern(
258 (innerLost == validHitInFirstPixelBarrelLayer ? 1 : 2), 0,
279 for (
int sl = slOffset; sl < numberOfStripLayers + slOffset; ++sl, ++
i) {
289 else if (sl < 13 + 9)
298 for (; i < numberOfHits; i++) {
300 track->appendTrackerHitPattern(
310 case validHitInFirstPixelBarrelLayer:
312 case noLostInnerHits:
314 case oneLostInnerHit:
318 case moreLostInnerHits:
326 if (trackHighPurity())
330 if (track_.compare_exchange_strong(expected,
track.get())) {
339 <<
"this Candidate has no master clone reference." 340 <<
"Can't call masterClone() method.\n";
349 <<
"this Candidate has no master clone ptr." 350 <<
"Can't call masterClonePtr() method.\n";
373 <<
"This Candidate type does not implement daughter(std::string). " 374 <<
"Please use CompositeCandidate or NamedCompositeCandidate.\n";
379 <<
"This Candidate type does not implement daughter(std::string). " 380 <<
"Please use CompositeCandidate or NamedCompositeCandidate.\n";
393 <<
"reco::ConcreteCandidate does not implement vertex covariant " 399 <<
"reco::ConcreteCandidate does not implement vertex covariant " 412 packedPuppiweightNoLepDiff_ =
421 return 1.f * packedPuppiweightNoLepDiff_ /
431 rawCaloFraction_ = 100 *
p;
435 rawHcalFraction_ = 100 *
p;
443 isIsolatedChargedHadron_ =
p;
447 if (aTime == 0 && aTimeError == 0) {
449 packedTimeError_ = 0;
450 }
else if (aTimeError == 0) {
451 packedTimeError_ = 0;
452 packedTime_ = packTimeNoError(aTime);
454 packedTimeError_ = packTimeError(aTimeError);
455 aTimeError = unpackTimeError(packedTimeError_);
456 packedTime_ = packTimeWithError(aTime, aTimeError);
469 return std::max<uint8_t>(
470 std::min(std::round(std::ldexp(std::log2(timeError / MIN_TIMEERROR),
478 std::exp2(std::ldexp(
float(timeError), -EXPO_TIMEERROR))
484 return (time > 0 ? MIN_TIME_NOERROR : -MIN_TIME_NOERROR) *
485 std::exp2(std::ldexp(
float(
std::abs(time)), -EXPO_TIME_NOERROR));
494 if (
std::abs(time) < MIN_TIME_NOERROR)
496 float fpacked = std::ldexp(std::log2(
std::abs(time / MIN_TIME_NOERROR)),
498 return (time > 0 ? +1 : -1) *
std::min(std::round(fpacked), 2047.
f);
504 return std::ldexp(unpackTimeError(timeError), EXPO_TIME_WITHERROR) *
519 float fpacked = std::round(time / std::ldexp(timeError, EXPO_TIME_WITHERROR));
522 return int16_t(fpacked) * 2;
524 int16_t packed = packTimeNoError(time);
float puppiWeight() const
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)
Fraction of ECAL+HCAL energy over candidate energy.
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.
void setRawHcalFraction(float p)
Raw ECAL+HCAL energy over candidate energy for isolated charged hadrons.
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
Structure Point Contains parameters of Gaussian fits to DMRs.
size_t numberOfDaughters() const override
number of daughters
void packVtx(bool unpackAfterwards=true)
static unsigned int const shift
void setIsIsolatedChargedHadron(bool p)
Fraction of Hcal for HF, neutral hadrons, and charged particles.
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
void setCaloFraction(float p)
Fraction of Hcal for isolated charged hadrons.
math::PtEtaPhiMLorentzVector PolarLorentzVector
Lorentz vector.