Skip to content

Commit

Permalink
apply coding rules
Browse files Browse the repository at this point in the history
  • Loading branch information
czangela committed Aug 24, 2021
1 parent 11f56a7 commit 6bc85e6
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 22 deletions.
23 changes: 11 additions & 12 deletions RecoLocalTracker/SiPixelRecHits/interface/pixelCPEforGPU.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,11 @@ namespace CPEFastParametrisation {
// From https://cmssdt.cern.ch/dxr/CMSSW/source/CondFormats/SiPixelTransient/src/SiPixelGenError.cc#485-486
// qbin: int (0-4) describing the charge of the cluster
// [0: 1.5<Q/Qavg, 1: 1<Q/Qavg<1.5, 2: 0.85<Q/Qavg<1, 3: 0.95Qmin<Q<0.85Qavg, 4: Q<0.95Qmin]
constexpr int GenErrorQBins = 5;
constexpr int kGenErrorQBins = 5;
// arbitrary number of bins for sampling errors
constexpr int NumErrorBins = 16;
constexpr int kNumErrorBins = 16;
} // namespace CPEFastParametrisation

using namespace CPEFastParametrisation;

namespace pixelCPEforGPU {

using Status = SiPixelHitStatus;
Expand Down Expand Up @@ -54,9 +52,10 @@ namespace pixelCPEforGPU {

float apeXX, apeYY; // ape^2
uint8_t sx2, sy1, sy2;
uint8_t sigmax[NumErrorBins], sigmax1[NumErrorBins], sigmay[NumErrorBins]; // in micron
float xfact[GenErrorQBins], yfact[GenErrorQBins];
int minCh[GenErrorQBins];
uint8_t sigmax[CPEFastParametrisation::kNumErrorBins], sigmax1[CPEFastParametrisation::kNumErrorBins],
sigmay[CPEFastParametrisation::kNumErrorBins]; // in micron
float xfact[CPEFastParametrisation::kGenErrorQBins], yfact[CPEFastParametrisation::kGenErrorQBins];
int minCh[CPEFastParametrisation::kGenErrorQBins];

Frame frame;
};
Expand Down Expand Up @@ -353,24 +352,24 @@ namespace pixelCPEforGPU {

auto ch = cp.charge[ic];
auto bin = 0;
for (; bin < GenErrorQBins - 1; ++bin)
for (; bin < CPEFastParametrisation::kGenErrorQBins - 1; ++bin)
// find first bin which minimum charge exceeds cluster charge
if (ch < detParams.minCh[bin + 1])
break;

// in detParams qBins are reversed bin0 -> smallest charge, bin4-> largest charge
// whereas in CondFormats/SiPixelTransient/src/SiPixelGenError.cc it is the opposite
// so we reverse the bin here -> GenErrorQBins - 1 - bin
cp.status[ic].qBin = GenErrorQBins - 1 - bin;
// so we reverse the bin here -> kGenErrorQBins - 1 - bin
cp.status[ic].qBin = CPEFastParametrisation::kGenErrorQBins - 1 - bin;
cp.status[ic].isOneX = isOneX;
cp.status[ic].isBigX = (isOneX & isBigX) | isEdgeX;
cp.status[ic].isOneY = isOneY;
cp.status[ic].isBigY = (isOneY & isBigY) | isEdgeY;

auto xoff = -float(phase1PixelTopology::xOffset) * comParams.thePitchX;
int low_value = 0;
int high_value = NumErrorBins - 1;
int bin_value = float(NumErrorBins) * (cp.xpos[ic] + xoff) / (2 * xoff);
int high_value = CPEFastParametrisation::kNumErrorBins - 1;
int bin_value = float(CPEFastParametrisation::kNumErrorBins) * (cp.xpos[ic] + xoff) / (2 * xoff);
// return estimated bin value truncated to [0, 15]
int jx = std::clamp(bin_value, low_value, high_value);

Expand Down
16 changes: 8 additions & 8 deletions RecoLocalTracker/SiPixelRecHits/src/PixelCPEFast.cc
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ void PixelCPEFast::fillParamsForGpu() {
// sample xerr as function of position
auto const xoff = float(phase1PixelTopology::xOffset) * commonParamsGPU_.thePitchX;

for (int ix = 0; ix < CPEFastParametrisation::NumErrorBins; ++ix) {
for (int ix = 0; ix < CPEFastParametrisation::kNumErrorBins; ++ix) {
auto x = xoff * (1.f - (0.5f + float(ix)) / 8.f);
auto gvx = p.theOrigin.x() - x;
auto gvy = p.theOrigin.y();
Expand All @@ -225,7 +225,7 @@ void PixelCPEFast::fillParamsForGpu() {
#ifdef EDM_ML_DEBUG
// sample yerr as function of position
auto const yoff = float(phase1PixelTopology::yOffset) * commonParamsGPU_.thePitchY;
for (int ix = 0; ix < CPEFastParametrisation::NumErrorBins; ++ix) {
for (int ix = 0; ix < CPEFastParametrisation::kNumErrorBins; ++ix) {
auto y = yoff * (1.f - (0.5f + float(ix)) / 8.f);
auto gvx = p.theOrigin.x() + 40.f * commonParamsGPU_.thePitchY;
auto gvy = p.theOrigin.y() - y;
Expand All @@ -244,7 +244,7 @@ void PixelCPEFast::fillParamsForGpu() {
auto aveCB = cp.cotbeta;

// sample x by charge
int qbin = CPEFastParametrisation::GenErrorQBins; // low charge
int qbin = CPEFastParametrisation::kGenErrorQBins; // low charge
int k = 0;
for (int qclus = 1000; qclus < 200000; qclus += 1000) {
errorFromTemplates(p, cp, qclus);
Expand All @@ -260,26 +260,26 @@ void PixelCPEFast::fillParamsForGpu() {
<< m * cp.sigmay << ' ' << m * cp.sy1 << ' ' << m * cp.sy2 << std::endl;
#endif // EDM_ML_DEBUG
}
assert(k <= CPEFastParametrisation::GenErrorQBins);
assert(k <= CPEFastParametrisation::kGenErrorQBins);
// fill the rest (sometimes bin 4 is missing)
for (int kk = k; kk < CPEFastParametrisation::GenErrorQBins; ++kk) {
for (int kk = k; kk < CPEFastParametrisation::kGenErrorQBins; ++kk) {
g.xfact[kk] = g.xfact[k - 1];
g.yfact[kk] = g.yfact[k - 1];
g.minCh[kk] = g.minCh[k - 1];
}
auto detx = 1.f / g.xfact[0];
auto dety = 1.f / g.yfact[0];
for (int kk = 0; kk < CPEFastParametrisation::GenErrorQBins; ++kk) {
for (int kk = 0; kk < CPEFastParametrisation::kGenErrorQBins; ++kk) {
g.xfact[kk] *= detx;
g.yfact[kk] *= dety;
}
// sample y in "angle" (estimated from cluster size)
float ys = 8.f - 4.f; // apperent bias of half pixel (see plot)
// plot: https://indico.cern.ch/event/934821/contributions/3974619/attachments/2091853/3515041/DigilessReco.pdf page 25
// sample yerr as function of "size"
for (int iy = 0; iy < CPEFastParametrisation::NumErrorBins; ++iy) {
for (int iy = 0; iy < CPEFastParametrisation::kNumErrorBins; ++iy) {
ys += 1.f; // first bin 0 is for size 9 (and size is in fixed point 2^3)
if (CPEFastParametrisation::NumErrorBins - 1 == iy)
if (CPEFastParametrisation::kNumErrorBins - 1 == iy)
ys += 8.f; // last bin for "overflow"
// cp.cotalpha = ys*(commonParamsGPU_.thePitchX/(8.f*thickness)); // use this to print sampling in "x" (and comment the line below)
cp.cotbeta = std::copysign(ys * (commonParamsGPU_.thePitchY / (8.f * thickness)), aveCB);
Expand Down
4 changes: 2 additions & 2 deletions RecoPixelVertexing/PixelTriplets/plugins/BrokenLineFitOnGPU.h
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ __global__ void kernel_BLFastFit(Tuples const *__restrict__ foundNtuplets,
#ifdef YERR_FROM_DC
auto const &dp = hhp->cpeParams().detParams(hhp->detectorIndex(hit));
auto status = hhp->status(hit);
int qbin = CPEFastParametrisation::GenErrorQBins - 1 - status.qBin;
int qbin = CPEFastParametrisation::kGenErrorQBins - 1 - status.qBin;
assert(qbin >= 0 && qbin < 5);
bool nok = (status.isBigY | status.isOneY);
// compute cotanbeta and use it to recompute error
Expand All @@ -99,7 +99,7 @@ __global__ void kernel_BLFastFit(Tuples const *__restrict__ foundNtuplets,
int bin =
int(cb * (float(phase1PixelTopology::pixelThickess) / float(phase1PixelTopology::pixelPitchY)) * 8.f) - 4;
int low_value = 0;
int high_value = CPEFastParametrisation::NumErrorBins - 1;
int high_value = CPEFastParametrisation::kNumErrorBins - 1;
// return estimated bin value truncated to [0, 15]
bin = std::clamp(bin, low_value, high_value);
float yerr = dp.sigmay[bin] * 1.e-4f; // toCM
Expand Down

0 comments on commit 6bc85e6

Please sign in to comment.