19 if (unpackAfterwards) {
20 delete p4_.exchange(
nullptr);
21 delete p4c_.exchange(
nullptr);
29 float dxPV = vertex_.load()->X() -
pv.X(),
30 dyPV = vertex_.load()->Y() -
pv.Y();
31 float s =
std::sin(
float(p4_.load()->Phi()) + dphi_),
32 c =
std::cos(
float(p4_.load()->Phi() + dphi_));
34 dxy_ = -dxPV *
s + dyPV *
c;
38 float pzpt = p4_.load()->Pz() / p4_.load()->Pt();
39 dz_ = vertex_.load()->Z() -
pv.Z() - (dxPV *
c + dyPV *
s) * pzpt;
47 if (unpackAfterwards) {
48 delete vertex_.exchange(
nullptr);
57 double sign = ((
int(
pt * 10) % 2 == 0) ? 1 : -1);
60 auto p4 = std::make_unique<PolarLorentzVector>(
pt,
64 auto p4c = std::make_unique<LorentzVector>(*p4);
66 if (p4_.compare_exchange_strong(expectp4, p4.get())) {
73 if (p4c_.compare_exchange_strong(expectp4c, p4c.get())) {
79 packedCovariance_.dptdpt = packCovarianceElement(
m, 0, 0);
80 packedCovariance_.detadeta = packCovarianceElement(
m, 1, 1);
81 packedCovariance_.dphidphi = packCovarianceElement(
m, 2, 2);
82 packedCovariance_.dxydxy = packCovarianceElement(
m, 3, 3);
83 packedCovariance_.dzdz = packCovarianceElement(
m, 4, 4);
84 packedCovariance_.dxydz = packCovarianceElement(
m, 3, 4);
85 packedCovariance_.dlambdadz = packCovarianceElement(
m, 1, 4);
86 packedCovariance_.dphidxy = packCovarianceElement(
m, 2, 3);
95 auto m = std::make_unique<reco::TrackBase::CovarianceMatrix>();
96 for (
int i = 0;
i < 5;
i++)
97 for (
int j = 0;
j < 5;
j++) {
100 unpackCovarianceElement(*
m, packedCovariance_.dptdpt, 0, 0);
101 unpackCovarianceElement(*
m, packedCovariance_.detadeta, 1, 1);
102 unpackCovarianceElement(*
m, packedCovariance_.dphidphi, 2, 2);
103 unpackCovarianceElement(*
m, packedCovariance_.dxydxy, 3, 3);
104 unpackCovarianceElement(*
m, packedCovariance_.dzdz, 4, 4);
105 unpackCovarianceElement(*
m, packedCovariance_.dxydz, 3, 4);
106 unpackCovarianceElement(*
m, packedCovariance_.dlambdadz, 1, 4);
107 unpackCovarianceElement(*
m, packedCovariance_.dphidxy, 2, 3);
109 if (m_.compare_exchange_strong(expected,
m.get())) {
115 <<
"You do not have a valid track parameters file loaded. " 116 <<
"Please check that the release version is compatible with your " 118 <<
"or avoid accessing track parameter uncertainties. ";
132 auto vertex = std::make_unique<Point>(
pv.X() - dxy_ *
s,
137 Point *expected =
nullptr;
138 if (vertex_.compare_exchange_strong(expected,
vertex.get())) {
146 delete vertex_.load();
147 delete track_.load();
153 const float phi =
float(p4_.load()->Phi()) + dphi_;
158 const float phi =
float(p4_.load()->Phi()) + dphi_;
159 const float pzpt = deta_ ? std::sinh(etaAtVtx()) : p4_.load()->Pz() / p4_.load()->Pt();
160 return (vertex_.load()->Z() -
p.Z()) -
167 maybeUnpackCovariance();
168 int numberOfStripLayers = stripLayersWithMeasurement(), numberOfPixelLayers = pixelLayersWithMeasurement();
169 int numberOfPixelHits = this->numberOfPixelHits();
170 int numberOfHits = this->numberOfHits();
172 int ndof = numberOfHits + numberOfPixelHits - 5;
175 auto track = std::make_unique<reco::Track>(normalizedChi2_ *
ndof,
184 if (firstHit_ == 0) {
185 if (innerLost == validHitInFirstPixelBarrelLayer) {
197 if (innerLost == validHitInFirstPixelBarrelLayer) {
200 for (;
i < numberOfPixelLayers;
i++) {
218 for (;
i < numberOfPixelLayers;
i++) {
219 if (
i + iOffset <= 2) {
228 for (;
i < numberOfPixelHits;
i++) {
236 (innerLost == validHitInFirstPixelBarrelLayer ? 1 : 2),
258 for (
int sl = slOffset; sl < numberOfStripLayers + slOffset; ++sl, ++
i) {
265 else if (sl < 13 + 9)
273 for (;
i < numberOfHits;
i++) {
285 case validHitInFirstPixelBarrelLayer:
287 case noLostInnerHits:
289 case oneLostInnerHit:
292 case moreLostInnerHits:
298 if (trackHighPurity())
302 if (track_.compare_exchange_strong(expected,
track.get())) {
310 throw cms::Exception(
"Invalid Reference") <<
"this Candidate has no master clone reference." 311 <<
"Can't call masterClone() method.\n";
319 throw cms::Exception(
"Invalid Reference") <<
"this Candidate has no master clone ptr." 320 <<
"Can't call masterClonePtr() method.\n";
328 return p4() ==
o.p4() &&
vertex() ==
o.vertex() &&
charge() ==
o.charge();
338 <<
"This Candidate type does not implement daughter(std::string). " 339 <<
"Please use CompositeCandidate or NamedCompositeCandidate.\n";
344 <<
"This Candidate type does not implement daughter(std::string). " 345 <<
"Please use CompositeCandidate or NamedCompositeCandidate.\n";
358 <<
"reco::ConcreteCandidate does not implement vertex covariant " 364 <<
"reco::ConcreteCandidate does not implement vertex covariant " 393 rawCaloFraction_ = 100 *
p;
405 if (aTime == 0 && aTimeError == 0) {
407 packedTimeError_ = 0;
408 }
else if (aTimeError == 0) {
409 packedTimeError_ = 0;
410 packedTime_ = packTimeNoError(aTime);
412 packedTimeError_ = packTimeError(aTimeError);
413 aTimeError = unpackTimeError(packedTimeError_);
414 packedTime_ = packTimeWithError(aTime, aTimeError);
427 return std::max<uint8_t>(
428 std::min(std::round(std::ldexp(std::log2(timeError / MIN_TIMEERROR), +EXPO_TIMEERROR)), 255.
f), 1);
431 return timeError > 0 ? MIN_TIMEERROR * std::exp2(std::ldexp(
float(timeError), -EXPO_TIMEERROR)) : -1.0f;
436 return (
time > 0 ? MIN_TIME_NOERROR : -MIN_TIME_NOERROR) *
437 std::exp2(std::ldexp(
float(
std::abs(
time)), -EXPO_TIME_NOERROR));
448 float fpacked = std::ldexp(std::log2(
std::abs(
time / MIN_TIME_NOERROR)), +EXPO_TIME_NOERROR);
449 return (
time > 0 ? +1 : -1) *
std::min(std::round(fpacked), 2047.
f);
454 return std::ldexp(unpackTimeError(timeError), EXPO_TIME_WITHERROR) *
float(
time / 2);
468 float fpacked = std::round(
time / std::ldexp(timeError, EXPO_TIME_WITHERROR));
471 return int16_t(fpacked) * 2;
473 int16_t packed = packTimeNoError(
time);
474 return packed * 2 + (
time > 0 ? +1 : -1);
float puppiWeight() const
double vertexNormalizedChi2() const override
chi-squared divided by n.d.o.f.
static constexpr auto TEC
bool massConstraint() const override
do mass constraint?
static uint32_t getLayer(uint16_t pattern)
float puppiWeightNoLep() const
Weight from full PUPPI.
double vertexNdof() const override
bool overlap(const reco::Candidate &) const override
check overlap with another Candidate
static bool pixelHitFilter(uint16_t pattern)
std::pair< unsigned int, unsigned int > unpack(cond::Time_t since)
void setPuppiWeight(float p, float p_nolep=0.0)
bool hasMasterClonePtr() const override
Sin< T >::type sin(const T &t)
static float unpackTimeNoError(int16_t time)
void setRawCaloFraction(float p)
Weight from PUPPI removing leptons.
static int16_t packTimeNoError(float time)
bool isNonnull() const
Checks for non-null.
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)
size_t numberOfMothers() const override
number of mothers
const reco::CandidateBaseRef & masterClone() const override
const reco::CandidatePtr & masterClonePtr() const override
void unpackCovariance() const
void setHcalFraction(float p)
Fraction of ECAL+HCAL energy over candidate energy.
static uint16_t float32to16(float x)
Cos< T >::type cos(const T &t)
static bool stripHitFilter(uint16_t pattern)
size_t numberOfDaughters() const override
number of daughters
static CovarianceParameterization covarianceParameterization_
void fillVertexCovariance(CovarianceMatrix &v) const override
fill SMatrix
Abs< T >::type abs(const T &t)
~PackedCandidate() override
destructor
static constexpr auto TOB
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.
static constexpr auto TIB
XYZVectorD XYZVector
spatial vector with cartesian internal representation
static std::once_flag covariance_load_flag
math::XYZTLorentzVector LorentzVector
Lorentz vector.
void setDTimeAssociatedPV(float aTime, float aTimeError=0)
set time measurement
Structure Point Contains parameters of Gaussian fits to DMRs.
const reco::Candidate * mother(size_type) const override
return mother at a given position (throws an exception)
void packVtx(bool unpackAfterwards=true)
const reco::Candidate * daughter(size_type) const override
return daughter at a given position (throws an exception)
static unsigned int const shift
void setIsIsolatedChargedHadron(bool p)
Fraction of Hcal for HF, neutral hadrons, and charged particles.
double vertexChi2() const override
chi-squares
CovarianceMatrix vertexCovariance() const override
return SMatrix
virtual float dxy() const
dxy with respect to the PV ref
void pack(bool unpackAfterwards=true)
virtual float dz(size_t ipv=0) const
dz with respect to the PV[ipv]
void packCovariance(const reco::TrackBase::CovarianceMatrix &m, bool unpackAfterwards=true)
static float unpackTimeWithError(int16_t time, uint8_t timeError)
bool hasMasterClone() const override
static constexpr auto TID
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.
bool longLived() const override
is long lived?
math::PtEtaPhiMLorentzVector PolarLorentzVector
Lorentz vector.