New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Small miniAOD improvements #20367
Small miniAOD improvements #20367
Changes from 3 commits
863334d
68f737b
78b19b4
9f31d22
d5d893e
c5e1951
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,8 @@ | |
#define libminifloat_h | ||
#include "FWCore/Utilities/interface/thread_safety_macros.h" | ||
#include <cstdint> | ||
#include <cassert> | ||
#include <algorithm> | ||
|
||
// ftp://ftp.fox-toolkit.org/pub/fasthalffloatconversion.pdf | ||
class MiniFloatConverter { | ||
|
@@ -76,6 +78,44 @@ class MiniFloatConverter { | |
return conv.flt; | ||
} | ||
|
||
class ReduceMantissaToNbitsRounding { | ||
public: | ||
ReduceMantissaToNbitsRounding(int bits) : | ||
shift(23-bits), mask((0xFFFFFFFF >> (shift)) << (shift)), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. it looks like this duplicates the functionality of There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. is the solution in 9f31d22 ok for you? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yes, it looks OK. |
||
test(1 << (shift-1)), maxn((1<<bits)-2) { | ||
assert(bits <= 23); // "max mantissa size is 23 bits" | ||
} | ||
float operator()(float f) const { | ||
constexpr uint32_t low23 = (0x007FFFFF); // mask to keep lowest 23 bits = mantissa | ||
constexpr uint32_t hi9 = (0xFF800000); // mask to keep highest 9 bits = the rest | ||
union { float flt; uint32_t i32; } conv; | ||
conv.flt=f; | ||
if (conv.i32 & test) { // need to round | ||
uint32_t mantissa = (conv.i32 & low23) >> shift; | ||
if (mantissa < maxn) mantissa++; | ||
conv.i32 = (conv.i32 & hi9) | (mantissa << shift); | ||
} else { | ||
conv.i32 &= mask; | ||
} | ||
return conv.flt; | ||
} | ||
private: | ||
const int shift; | ||
const uint32_t mask, test, maxn; | ||
}; | ||
|
||
inline static float reduceMantissaToNbitsRounding(float f, int bits) | ||
{ | ||
return ReduceMantissaToNbitsRounding(bits)(f); | ||
} | ||
|
||
template<typename InItr, typename OutItr> | ||
static void reduceMantissaToNbitsRounding(int bits, InItr begin, InItr end, OutItr out) | ||
{ | ||
std::transform(begin, end, out, ReduceMantissaToNbitsRounding(bits)); | ||
} | ||
|
||
|
||
inline static float max() { | ||
union { float flt; uint32_t i32; } conv; | ||
conv.i32 = 0x477fe000; // = mantissatable[offsettable[0x1e]+0x3ff]+exponenttable[0x1e] | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1174,6 +1174,9 @@ void PATElectronProducer::embedHighLevel( pat::Electron & anElectron, | |
d0_corr = result.second.value(); | ||
d0_err = beamspotIsValid ? result.second.error() : -1.0; | ||
anElectron.setDB( d0_corr, d0_err, pat::Electron::BS3D); | ||
|
||
// PVDZ | ||
anElectron.setDB( track->dz(primaryVertex.position()), track->dzError(), pat::Electron::PVDZ ); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. shouldn't this include the PV z error? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. based on the PR description
it sounds like the PV error on z should be added. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For d0 and ip3d, the b-tag tool does the right error propagation but I don't think it's implemented for dz. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. it seems good enough. It's used in a few places (e.g. CommonTools/ParticleFlow/interface/IPCutPFCandidateSelectorDefinition.h, Alignment/OfflineValidation/plugins/PrimaryVertexValidation.cc, DQM/TrackingMonitor/src/TrackAnalyzer.cc, and at least as many more, based on git grep) perhaps a more complete would be to deconstruct the Track::dz method and propagate all relevant uncertainties, (to be added to TrackBase? or to the IPTools) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. pushed the simple hypot version |
||
} | ||
|
||
#include "FWCore/Framework/interface/MakerMacros.h" | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please make a backport for this part to 93X and 92X.