CMS 3D CMS Logo

List of all members | Classes | Public Types | Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes
PixelCPEFast< TrackerTraits > Class Template Referencefinal

#include <PixelCPEFast.h>

Inheritance diagram for PixelCPEFast< TrackerTraits >:
PixelCPEGenericBase PixelCPEBase PixelClusterParameterEstimator

Classes

struct  GPUData
 

Public Types

using AverageGeometry = pixelTopology::AverageGeometryT< TrackerTraits >
 
using LayerGeometry = pixelCPEforGPU::LayerGeometryT< TrackerTraits >
 
using ParamsOnGPU = pixelCPEforGPU::ParamsOnGPUT< TrackerTraits >
 
- Public Types inherited from PixelClusterParameterEstimator
typedef std::pair< LocalPoint, LocalErrorLocalValues
 
using ReturnType = std::tuple< LocalPoint, LocalError, SiPixelRecHitQuality::QualWordType >
 
typedef std::vector< LocalValuesVLocalValues
 

Public Member Functions

ParamsOnGPU const & getCPUProduct () const
 
const ParamsOnGPUgetGPUProductAsync (cudaStream_t cudaStream) const
 
 PixelCPEFast (edm::ParameterSet const &conf, const MagneticField *, const TrackerGeometry &, const TrackerTopology &, const SiPixelLorentzAngle *, const SiPixelGenErrorDBObject *, const SiPixelLorentzAngle *)
 The constructor. More...
 
 ~PixelCPEFast () override=default
 
- Public Member Functions inherited from PixelCPEGenericBase
 PixelCPEGenericBase (edm::ParameterSet const &conf, const MagneticField *mag, const TrackerGeometry &geom, const TrackerTopology &ttopo, const SiPixelLorentzAngle *lorentzAngle, const SiPixelGenErrorDBObject *genErrorDBObject, const SiPixelLorentzAngle *lorentzAngleWidth)
 
 ~PixelCPEGenericBase () override=default
 
- Public Member Functions inherited from PixelCPEBase
ReturnType getParameters (const SiPixelCluster &cl, const GeomDetUnit &det) const override
 
ReturnType getParameters (const SiPixelCluster &cl, const GeomDetUnit &det, const LocalTrajectoryParameters &ltp) const override
 
 PixelCPEBase (edm::ParameterSet const &conf, const MagneticField *mag, const TrackerGeometry &geom, const TrackerTopology &ttopo, const SiPixelLorentzAngle *lorentzAngle, const SiPixelGenErrorDBObject *genErrorDBObject, const SiPixelTemplateDBObject *templateDBobject, const SiPixelLorentzAngle *lorentzAngleWidth, int flag=0)
 
- Public Member Functions inherited from PixelClusterParameterEstimator
unsigned int clusterProbComputationFlag () const
 
virtual ReturnType getParameters (const SiPixelCluster &cl, const GeomDetUnit &det, const TrajectoryStateOnSurface &tsos) const
 
virtual VLocalValues localParametersV (const SiPixelCluster &cluster, const GeomDetUnit &gd) const
 
virtual VLocalValues localParametersV (const SiPixelCluster &cluster, const GeomDetUnit &gd, TrajectoryStateOnSurface &tsos) const
 
 PixelClusterParameterEstimator ()
 
virtual ~PixelClusterParameterEstimator ()
 

Static Public Member Functions

static void fillPSetDescription (edm::ParameterSetDescription &desc)
 
- Static Public Member Functions inherited from PixelCPEGenericBase
static void fillPSetDescription (edm::ParameterSetDescription &desc)
 
- Static Public Member Functions inherited from PixelCPEBase
static void fillPSetDescription (edm::ParameterSetDescription &desc)
 

Private Member Functions

void errorFromTemplates (DetParam const &theDetParam, ClusterParamGeneric &theClusterParam, float qclus) const
 
void fillParamsForGpu ()
 
LocalError localError (DetParam const &theDetParam, ClusterParam &theClusterParam) const override
 
LocalPoint localPosition (DetParam const &theDetParam, ClusterParam &theClusterParam) const override
 

Private Attributes

AverageGeometry averageGeometry_
 
pixelCPEforGPU::CommonParams commonParamsGPU_
 
ParamsOnGPU cpuData_
 
std::vector< pixelCPEforGPU::DetParamsdetParamsGPU_
 
cms::cuda::ESProduct< GPUDatagpuData_
 
LayerGeometry layerGeometry_
 
std::vector< SiPixelGenErrorStorethePixelGenError_
 

Additional Inherited Members

- Protected Types inherited from PixelCPEBase
using DetParams = std::vector< DetParam >
 
typedef GloballyPositioned< double > Frame
 
- Protected Member Functions inherited from PixelCPEGenericBase
std::unique_ptr< ClusterParamcreateClusterParam (const SiPixelCluster &cl) const override
 
void initializeLocalErrorVariables (float &xerr, float &yerr, bool &edgex, bool &edgey, bool &bigInX, bool &bigInY, int &maxPixelCol, int &maxPixelRow, int &minPixelCol, int &minPixelRow, uint &sizex, uint &sizey, DetParam const &theDetParam, ClusterParamGeneric const &theClusterParam) const
 
void setXYErrors (float &xerr, float &yerr, const bool edgex, const bool edgey, const unsigned int sizex, const unsigned int sizey, const bool bigInX, const bool bigInY, const bool useTemplateErrors, DetParam const &theDetParam, ClusterParamGeneric const &theClusterParam) const
 
- Protected Member Functions inherited from PixelCPEBase
void computeAnglesFromDetPosition (DetParam const &theDetParam, ClusterParam &theClusterParam) const
 
void computeAnglesFromTrajectory (DetParam const &theDetParam, ClusterParam &theClusterParam, const LocalTrajectoryParameters &ltp) const
 
void computeLorentzShifts (DetParam &) const
 
DetParam const & detParam (const GeomDetUnit &det) const
 
LocalVector driftDirection (DetParam &theDetParam, GlobalVector bfield) const
 
LocalVector driftDirection (DetParam &theDetParam, LocalVector bfield) const
 
void setTheClu (DetParam const &, ClusterParam &theClusterParam) const
 
- Static Protected Member Functions inherited from PixelCPEGenericBase
static void collect_edge_charges (ClusterParam &theClusterParam, int &q_f_X, int &q_l_X, int &q_f_Y, int &q_l_Y, bool truncate)
 
- Protected Attributes inherited from PixelCPEGenericBase
const float edgeClusterErrorX_
 
const float edgeClusterErrorY_
 
const bool truncatePixelCharge_
 
bool useErrorsFromTemplates_
 
const std::vector< float > xerr_barrel_l1_
 
const float xerr_barrel_l1_def_
 
const std::vector< float > xerr_barrel_ln_
 
const float xerr_barrel_ln_def_
 
const std::vector< float > xerr_endcap_
 
const float xerr_endcap_def_
 
const std::vector< float > yerr_barrel_l1_
 
const float yerr_barrel_l1_def_
 
const std::vector< float > yerr_barrel_ln_
 
const float yerr_barrel_ln_def_
 
const std::vector< float > yerr_endcap_
 
const float yerr_endcap_def_
 
- Protected Attributes inherited from PixelCPEBase
bool alpha2Order
 
bool doLorentzFromAlignment_
 
const SiPixelGenErrorDBObjectgenErrorDBObject_
 
const TrackerGeometrygeom_
 
float lAOffset_
 
float lAWidthBPix_
 
float lAWidthFPix_
 
bool LoadTemplatesFromDB_
 
const SiPixelLorentzAnglelorentzAngle_
 
const SiPixelLorentzAnglelorentzAngleWidth_
 
DetParams m_DetParams = DetParams(1440)
 
const MagneticFieldmagfield_
 
const SiPixelTemplateDBObjecttemplateDBobject_
 
int theFlag_
 
int theVerboseLevel
 
const TrackerTopologyttopo_
 
bool useLAFromDB_
 
bool useLAOffsetFromConfig_
 
bool useLAWidthFromConfig_
 
bool useLAWidthFromDB_
 
- Protected Attributes inherited from PixelClusterParameterEstimator
unsigned int clusterProbComputationFlag_
 
- Static Protected Attributes inherited from PixelCPEBase
static constexpr float bothEdgeXError_ = 31.0f
 
static constexpr float bothEdgeYError_ = 90.0f
 
static constexpr float clusterSplitMaxError_ = 7777.7f
 
static constexpr float xEdgeXError_ = 23.0f
 
static constexpr float xEdgeYError_ = 39.0f
 
static constexpr float yEdgeXError_ = 24.0f
 
static constexpr float yEdgeYError_ = 96.0f
 

Detailed Description

template<typename TrackerTraits>
class PixelCPEFast< TrackerTraits >

Definition at line 16 of file PixelCPEFast.h.

Member Typedef Documentation

◆ AverageGeometry

template<typename TrackerTraits>
using PixelCPEFast< TrackerTraits >::AverageGeometry = pixelTopology::AverageGeometryT<TrackerTraits>

Definition at line 34 of file PixelCPEFast.h.

◆ LayerGeometry

template<typename TrackerTraits>
using PixelCPEFast< TrackerTraits >::LayerGeometry = pixelCPEforGPU::LayerGeometryT<TrackerTraits>

Definition at line 33 of file PixelCPEFast.h.

◆ ParamsOnGPU

template<typename TrackerTraits>
using PixelCPEFast< TrackerTraits >::ParamsOnGPU = pixelCPEforGPU::ParamsOnGPUT<TrackerTraits>

Definition at line 32 of file PixelCPEFast.h.

Constructor & Destructor Documentation

◆ PixelCPEFast()

template<typename TrackerTraits >
PixelCPEFast< TrackerTraits >::PixelCPEFast ( edm::ParameterSet const &  conf,
const MagneticField mag,
const TrackerGeometry geom,
const TrackerTopology ttopo,
const SiPixelLorentzAngle lorentzAngle,
const SiPixelGenErrorDBObject genErrorDBObject,
const SiPixelLorentzAngle lorentzAngleWidth 
)

The constructor.

Definition at line 23 of file PixelCPEFast.cc.

References PixelCPEFast< TrackerTraits >::averageGeometry_, PixelCPEFast< TrackerTraits >::commonParamsGPU_, PixelCPEFast< TrackerTraits >::cpuData_, PixelCPEFast< TrackerTraits >::detParamsGPU_, Exception, PixelCPEFast< TrackerTraits >::fillParamsForGpu(), PixelCPEBase::genErrorDBObject_, PixelCPEFast< TrackerTraits >::layerGeometry_, SiPixelGenError::pushfile(), PixelCPEFast< TrackerTraits >::thePixelGenError_, and PixelCPEGenericBase::useErrorsFromTemplates_.

30  : PixelCPEGenericBase(conf, mag, geom, ttopo, lorentzAngle, genErrorDBObject, lorentzAngleWidth) {
31  // Use errors from templates or from GenError
34  throw cms::Exception("InvalidCalibrationLoaded")
35  << "ERROR: GenErrors not filled correctly. Check the sqlite file. Using SiPixelTemplateDBObject version "
36  << (*genErrorDBObject_).version();
37  }
38 
40 
41  cpuData_ = {
43  detParamsGPU_.data(),
46  };
47 }
static bool pushfile(int filenum, std::vector< SiPixelGenErrorStore > &pixelTemp, std::string dir="")
std::vector< SiPixelGenErrorStore > thePixelGenError_
Definition: PixelCPEFast.h:47
std::vector< pixelCPEforGPU::DetParams > detParamsGPU_
Definition: PixelCPEFast.h:50
ParamsOnGPU cpuData_
Definition: PixelCPEFast.h:54
LayerGeometry layerGeometry_
Definition: PixelCPEFast.h:52
void fillParamsForGpu()
Definition: PixelCPEFast.cc:91
PixelCPEGenericBase(edm::ParameterSet const &conf, const MagneticField *mag, const TrackerGeometry &geom, const TrackerTopology &ttopo, const SiPixelLorentzAngle *lorentzAngle, const SiPixelGenErrorDBObject *genErrorDBObject, const SiPixelLorentzAngle *lorentzAngleWidth)
T mag() const
The vector magnitude. Equivalent to sqrt(vec.mag2())
const SiPixelGenErrorDBObject * genErrorDBObject_
Definition: PixelCPEBase.h:234
AverageGeometry averageGeometry_
Definition: PixelCPEFast.h:53
pixelCPEforGPU::CommonParams commonParamsGPU_
Definition: PixelCPEFast.h:51

◆ ~PixelCPEFast()

template<typename TrackerTraits>
PixelCPEFast< TrackerTraits >::~PixelCPEFast ( )
overridedefault

Member Function Documentation

◆ errorFromTemplates()

template<typename TrackerTraits >
void PixelCPEFast< TrackerTraits >::errorFromTemplates ( DetParam const &  theDetParam,
ClusterParamGeneric theClusterParam,
float  qclus 
) const
private

Definition at line 396 of file PixelCPEFast.cc.

References PixelCPEBase::DetParam::bx, PixelCPEBase::DetParam::bz, PixelCPEBase::ClusterParam::cotalpha, PixelCPEBase::ClusterParam::cotbeta, PixelCPEBase::DetParam::detTemplateId, LogDebug, SiStripPI::max, pixelCPEforDevice::micronsToCm, PixelCPEGenericBase::ClusterParamGeneric::pixmx, SiPixelGenError::qbin(), PixelCPEBase::ClusterParam::qBin_, PixelCPEGenericBase::ClusterParamGeneric::sigmax, PixelCPEGenericBase::ClusterParamGeneric::sigmay, PixelCPEGenericBase::ClusterParamGeneric::sx1, PixelCPEGenericBase::ClusterParamGeneric::sx2, PixelCPEGenericBase::ClusterParamGeneric::sy1, PixelCPEGenericBase::ClusterParamGeneric::sy2, and PixelCPEFast< TrackerTraits >::thePixelGenError_.

Referenced by PixelCPEFast< TrackerTraits >::localPosition().

398  {
399  float locBz = theDetParam.bz;
400  float locBx = theDetParam.bx;
401  LogDebug("PixelCPEFast") << "PixelCPEFast::localPosition(...) : locBz = " << locBz;
402 
403  theClusterParam.pixmx = std::numeric_limits<int>::max(); // max pixel charge for truncation of 2-D cluster
404 
405  theClusterParam.sigmay = -999.9; // CPE Generic y-error for multi-pixel cluster
406  theClusterParam.sigmax = -999.9; // CPE Generic x-error for multi-pixel cluster
407  theClusterParam.sy1 = -999.9; // CPE Generic y-error for single single-pixel
408  theClusterParam.sy2 = -999.9; // CPE Generic y-error for single double-pixel cluster
409  theClusterParam.sx1 = -999.9; // CPE Generic x-error for single single-pixel cluster
410  theClusterParam.sx2 = -999.9; // CPE Generic x-error for single double-pixel cluster
411 
412  float dummy;
413 
415  int gtemplID = theDetParam.detTemplateId;
416 
417  theClusterParam.qBin_ = gtempl.qbin(gtemplID,
418  theClusterParam.cotalpha,
419  theClusterParam.cotbeta,
420  locBz,
421  locBx,
422  qclus,
423  false,
424  theClusterParam.pixmx,
425  theClusterParam.sigmay,
426  dummy,
427  theClusterParam.sigmax,
428  dummy,
429  theClusterParam.sy1,
430  dummy,
431  theClusterParam.sy2,
432  dummy,
433  theClusterParam.sx1,
434  dummy,
435  theClusterParam.sx2,
436  dummy);
437 
438  theClusterParam.sigmax = theClusterParam.sigmax * micronsToCm;
439  theClusterParam.sx1 = theClusterParam.sx1 * micronsToCm;
440  theClusterParam.sx2 = theClusterParam.sx2 * micronsToCm;
441 
442  theClusterParam.sigmay = theClusterParam.sigmay * micronsToCm;
443  theClusterParam.sy1 = theClusterParam.sy1 * micronsToCm;
444  theClusterParam.sy2 = theClusterParam.sy2 * micronsToCm;
445 }
constexpr float micronsToCm
std::vector< SiPixelGenErrorStore > thePixelGenError_
Definition: PixelCPEFast.h:47
#define LogDebug(id)

◆ fillParamsForGpu()

template<typename TrackerTraits >
void PixelCPEFast< TrackerTraits >::fillParamsForGpu ( )
private

Definition at line 91 of file PixelCPEFast.cc.

References funct::abs(), cms::cuda::assert(), ALPAKA_ACCELERATOR_NAMESPACE::brokenline::constexpr(), CommonMethods::cp(), f, nano_mu_digi_cff::float, g, mps_fire::i, createfilelist::int, GeomDetEnumerators::isBarrel(), ALPAKA_ACCELERATOR_NAMESPACE::ecal::reconstruction::internal::endcap::ix(), ALPAKA_ACCELERATOR_NAMESPACE::ecal::reconstruction::internal::endcap::iy(), dqmdumpme::k, CPEFastParametrisation::kGenErrorQBins, GetRecoTauVFromDQM_MC_cff::kk, CPEFastParametrisation::kNumErrorBins, PVValHelper::ladder, phase1PixelTopology::layerStart, LogDebug, visualization-live-secondInstance_cfg::m, SiStripPI::max, SiStripPI::min, AlCaHLTBitMon_ParallelJobs::p, findQualityFiles::rr, mathSSE::sqrt(), Calorimetry_cff::thickness, mitigatedMETSequence_cff::U, x, detailsBasic3DVector::y, detailsBasic3DVector::z, and SOAFrame< T >::z().

Referenced by PixelCPEFast< TrackerTraits >::PixelCPEFast().

91  {
92  //
93  // this code executes only once per job, computation inefficiency is not an issue
94  // many code blocks are repeated: better keep the computation local and self oconsistent as blocks may in future move around, be deleted ...
95  // It is valid only for Phase1 and the version of GenError in DB used in late 2018 and in 2021
96 
97  commonParamsGPU_.theThicknessB = m_DetParams.front().theThickness;
98  commonParamsGPU_.theThicknessE = m_DetParams.back().theThickness;
99  commonParamsGPU_.thePitchX = m_DetParams[0].thePitchX;
100  commonParamsGPU_.thePitchY = m_DetParams[0].thePitchY;
101 
102  commonParamsGPU_.numberOfLaddersInBarrel = TrackerTraits::numberOfLaddersInBarrel;
103 
104  LogDebug("PixelCPEFast") << "pitch & thickness " << commonParamsGPU_.thePitchX << ' ' << commonParamsGPU_.thePitchY
106 
107  // zero average geometry
109 
110  uint32_t oldLayer = 0;
111  uint32_t oldLadder = 0;
112  float rl = 0;
113  float zl = 0;
114  float miz = 500, mxz = 0;
115  float pl = 0;
116  int nl = 0;
117  detParamsGPU_.resize(m_DetParams.size());
118 
119  for (auto i = 0U; i < m_DetParams.size(); ++i) {
120  auto& p = m_DetParams[i];
121  auto& g = detParamsGPU_[i];
122 
123  g.nRowsRoc = p.theDet->specificTopology().rowsperroc();
124  g.nColsRoc = p.theDet->specificTopology().colsperroc();
125  g.nRows = p.theDet->specificTopology().rocsX() * g.nRowsRoc;
126  g.nCols = p.theDet->specificTopology().rocsY() * g.nColsRoc;
127 
128  g.numPixsInModule = g.nRows * g.nCols;
129 
130  assert(p.theDet->index() == int(i));
131  assert(commonParamsGPU_.thePitchY == p.thePitchY);
132  assert(commonParamsGPU_.thePitchX == p.thePitchX);
133 
134  g.isBarrel = GeomDetEnumerators::isBarrel(p.thePart);
135  g.isPosZ = p.theDet->surface().position().z() > 0;
136  g.layer = ttopo_.layer(p.theDet->geographicalId());
137  g.index = i; // better be!
138  g.rawId = p.theDet->geographicalId();
140  assert(thickness == p.theThickness);
141 
142  auto ladder = ttopo_.pxbLadder(p.theDet->geographicalId());
143  if (oldLayer != g.layer) {
144  oldLayer = g.layer;
145  LogDebug("PixelCPEFast") << "new layer at " << i << (g.isBarrel ? " B " : (g.isPosZ ? " E+ " : " E- "))
146  << g.layer << " starting at " << g.rawId << '\n'
147  << "old layer had " << nl << " ladders";
148  nl = 0;
149  }
150  if (oldLadder != ladder) {
151  oldLadder = ladder;
152  LogDebug("PixelCPEFast") << "new ladder at " << i << (g.isBarrel ? " B " : (g.isPosZ ? " E+ " : " E- "))
153  << ladder << " starting at " << g.rawId << '\n'
154  << "old ladder ave z,r,p mz " << zl / 8.f << " " << rl / 8.f << " " << pl / 8.f << ' '
155  << miz << ' ' << mxz;
156  rl = 0;
157  zl = 0;
158  pl = 0;
159  miz = 500;
160  mxz = 0;
161  nl++;
162  }
163 
164  g.shiftX = 0.5f * p.lorentzShiftInCmX;
165  g.shiftY = 0.5f * p.lorentzShiftInCmY;
166  g.chargeWidthX = p.lorentzShiftInCmX * p.widthLAFractionX;
167  g.chargeWidthY = p.lorentzShiftInCmY * p.widthLAFractionY;
168 
169  g.x0 = p.theOrigin.x();
170  g.y0 = p.theOrigin.y();
171  g.z0 = p.theOrigin.z();
172 
173  auto vv = p.theDet->surface().position();
174  auto rr = pixelCPEforGPU::Rotation(p.theDet->surface().rotation());
175  g.frame = pixelCPEforGPU::Frame(vv.x(), vv.y(), vv.z(), rr);
176 
177  zl += vv.z();
178  miz = std::min(miz, std::abs(vv.z()));
179  mxz = std::max(mxz, std::abs(vv.z()));
180  rl += vv.perp();
181  pl += vv.phi(); // (not obvious)
182 
183  // errors .....
184  ClusterParamGeneric cp;
185 
186  cp.with_track_angle = false;
187 
188  auto lape = p.theDet->localAlignmentError();
189  if (lape.invalid())
190  lape = LocalError(); // zero....
191 
192  g.apeXX = lape.xx();
193  g.apeYY = lape.yy();
194 
195  auto toMicron = [&](float x) { return std::min(511, int(x * 1.e4f + 0.5f)); };
196 
197  // average angle
198  auto gvx = p.theOrigin.x() + 40.f * commonParamsGPU_.thePitchX;
199  auto gvy = p.theOrigin.y();
200  auto gvz = 1.f / p.theOrigin.z();
201  //--- Note that the normalization is not required as only the ratio used
202 
203  {
204  // calculate angles (fed into errorFromTemplates)
205  cp.cotalpha = gvx * gvz;
206  cp.cotbeta = gvy * gvz;
207 
208  errorFromTemplates(p, cp, 20000.);
209  }
210 
211 #ifdef EDM_ML_DEBUG
212  auto m = 10000.f;
213  for (float qclus = 15000; qclus < 35000; qclus += 15000) {
214  errorFromTemplates(p, cp, qclus);
215  LogDebug("PixelCPEFast") << i << ' ' << qclus << ' ' << cp.pixmx << ' ' << m * cp.sigmax << ' ' << m * cp.sx1
216  << ' ' << m * cp.sx2 << ' ' << m * cp.sigmay << ' ' << m * cp.sy1 << ' ' << m * cp.sy2;
217  }
218  LogDebug("PixelCPEFast") << i << ' ' << m * std::sqrt(lape.xx()) << ' ' << m * std::sqrt(lape.yy());
219 #endif // EDM_ML_DEBUG
220 
221  g.pixmx = std::max(0, cp.pixmx);
222  g.sx2 = toMicron(cp.sx2);
223  g.sy1 = std::max(21, toMicron(cp.sy1)); // for some angles sy1 is very small
224  g.sy2 = std::max(55, toMicron(cp.sy2)); // sometimes sy2 is smaller than others (due to angle?)
225 
226  //sample xerr as function of position
227  // moduleOffsetX is the definition of TrackerTraits::xOffset,
228  // needs to be calculated because for Phase2 the modules are not uniform
229  float moduleOffsetX = -(0.5f * float(g.nRows) + TrackerTraits::bigPixXCorrection);
230  auto const xoff = moduleOffsetX * commonParamsGPU_.thePitchX;
231 
232  for (int ix = 0; ix < CPEFastParametrisation::kNumErrorBins; ++ix) {
233  auto x = xoff * (1.f - (0.5f + float(ix)) / 8.f);
234  auto gvx = p.theOrigin.x() - x;
235  auto gvy = p.theOrigin.y();
236  auto gvz = 1.f / p.theOrigin.z();
237  cp.cotbeta = gvy * gvz;
238  cp.cotalpha = gvx * gvz;
239  errorFromTemplates(p, cp, 20000.f);
240  g.sigmax[ix] = toMicron(cp.sigmax);
241  g.sigmax1[ix] = toMicron(cp.sx1);
242  LogDebug("PixelCPEFast") << "sigmax vs x " << i << ' ' << x << ' ' << cp.cotalpha << ' ' << int(g.sigmax[ix])
243  << ' ' << int(g.sigmax1[ix]) << ' ' << 10000.f * cp.sigmay << std::endl;
244  }
245 #ifdef EDM_ML_DEBUG
246  // sample yerr as function of position
247  // moduleOffsetY is the definition of TrackerTraits::yOffset (removed)
248  float moduleOffsetY = 0.5f * float(g.nCols) + TrackerTraits::bigPixYCorrection;
249  auto const yoff = -moduleOffsetY * commonParamsGPU_.thePitchY;
250 
251  for (int ix = 0; ix < CPEFastParametrisation::kNumErrorBins; ++ix) {
252  auto y = yoff * (1.f - (0.5f + float(ix)) / 8.f);
253  auto gvx = p.theOrigin.x() + 40.f * commonParamsGPU_.thePitchY;
254  auto gvy = p.theOrigin.y() - y;
255  auto gvz = 1.f / p.theOrigin.z();
256  cp.cotbeta = gvy * gvz;
257  cp.cotalpha = gvx * gvz;
258  errorFromTemplates(p, cp, 20000.f);
259  LogDebug("PixelCPEFast") << "sigmay vs y " << i << ' ' << y << ' ' << cp.cotbeta << ' ' << 10000.f * cp.sigmay
260  << std::endl;
261  }
262 #endif // EDM_ML_DEBUG
263 
264  // calculate angles (repeated)
265  cp.cotalpha = gvx * gvz;
266  cp.cotbeta = gvy * gvz;
267  auto aveCB = cp.cotbeta;
268 
269  // sample x by charge
270  int qbin = CPEFastParametrisation::kGenErrorQBins; // low charge
271  int k = 0;
272  for (int qclus = 1000; qclus < 200000; qclus += 1000) {
273  errorFromTemplates(p, cp, qclus);
274  if (cp.qBin_ == qbin)
275  continue;
276  qbin = cp.qBin_;
277  g.xfact[k] = cp.sigmax;
278  g.yfact[k] = cp.sigmay;
279  g.minCh[k++] = qclus;
280 #ifdef EDM_ML_DEBUG
281  LogDebug("PixelCPEFast") << i << ' ' << g.rawId << ' ' << cp.cotalpha << ' ' << qclus << ' ' << cp.qBin_ << ' '
282  << cp.pixmx << ' ' << m * cp.sigmax << ' ' << m * cp.sx1 << ' ' << m * cp.sx2 << ' '
283  << m * cp.sigmay << ' ' << m * cp.sy1 << ' ' << m * cp.sy2 << std::endl;
284 #endif // EDM_ML_DEBUG
285  }
286 
288 
289  // fill the rest (sometimes bin 4 is missing)
290  for (int kk = k; kk < CPEFastParametrisation::kGenErrorQBins; ++kk) {
291  g.xfact[kk] = g.xfact[k - 1];
292  g.yfact[kk] = g.yfact[k - 1];
293  g.minCh[kk] = g.minCh[k - 1];
294  }
295  auto detx = 1.f / g.xfact[0];
296  auto dety = 1.f / g.yfact[0];
297  for (int kk = 0; kk < CPEFastParametrisation::kGenErrorQBins; ++kk) {
298  g.xfact[kk] *= detx;
299  g.yfact[kk] *= dety;
300  }
301  // sample y in "angle" (estimated from cluster size)
302  float ys = 8.f - 4.f; // apperent bias of half pixel (see plot)
303  // plot: https://indico.cern.ch/event/934821/contributions/3974619/attachments/2091853/3515041/DigilessReco.pdf page 25
304  // sample yerr as function of "size"
305  for (int iy = 0; iy < CPEFastParametrisation::kNumErrorBins; ++iy) {
306  ys += 1.f; // first bin 0 is for size 9 (and size is in fixed point 2^3)
308  ys += 8.f; // last bin for "overflow"
309  // cp.cotalpha = ys*(commonParamsGPU_.thePitchX/(8.f*thickness)); // use this to print sampling in "x" (and comment the line below)
310  cp.cotbeta = std::copysign(ys * (commonParamsGPU_.thePitchY / (8.f * thickness)), aveCB);
311  errorFromTemplates(p, cp, 20000.f);
312  g.sigmay[iy] = toMicron(cp.sigmay);
313  LogDebug("PixelCPEFast") << "sigmax/sigmay " << i << ' ' << (ys + 4.f) / 8.f << ' ' << cp.cotalpha << '/'
314  << cp.cotbeta << ' ' << 10000.f * cp.sigmax << '/' << int(g.sigmay[iy]) << std::endl;
315  }
316  } // loop over det
317 
318  constexpr int numberOfModulesInLadder = TrackerTraits::numberOfModulesInLadder;
319  constexpr int numberOfLaddersInBarrel = TrackerTraits::numberOfLaddersInBarrel;
320  constexpr int numberOfModulesInBarrel = TrackerTraits::numberOfModulesInBarrel;
321 
322  constexpr float ladderFactor = 1.f / float(numberOfModulesInLadder);
323 
324  constexpr int firstEndcapPos = TrackerTraits::firstEndcapPos;
325  constexpr int firstEndcapNeg = TrackerTraits::firstEndcapNeg;
326 
327  // compute ladder baricenter (only in global z) for the barrel
328  //
329  auto& aveGeom = averageGeometry_;
330  int il = 0;
331  for (int im = 0, nm = numberOfModulesInBarrel; im < nm; ++im) {
332  auto const& g = detParamsGPU_[im];
333  il = im / numberOfModulesInLadder;
334  assert(il < int(numberOfLaddersInBarrel));
335  auto z = g.frame.z();
336  aveGeom.ladderZ[il] += ladderFactor * z;
337  aveGeom.ladderMinZ[il] = std::min(aveGeom.ladderMinZ[il], z);
338  aveGeom.ladderMaxZ[il] = std::max(aveGeom.ladderMaxZ[il], z);
339  aveGeom.ladderX[il] += ladderFactor * g.frame.x();
340  aveGeom.ladderY[il] += ladderFactor * g.frame.y();
341  aveGeom.ladderR[il] += ladderFactor * sqrt(g.frame.x() * g.frame.x() + g.frame.y() * g.frame.y());
342  }
343  assert(il + 1 == int(numberOfLaddersInBarrel));
344  // add half_module and tollerance
345  constexpr float moduleLength = TrackerTraits::moduleLength;
346  constexpr float module_tolerance = 0.2f;
347  for (int il = 0, nl = numberOfLaddersInBarrel; il < nl; ++il) {
348  aveGeom.ladderMinZ[il] -= (0.5f * moduleLength - module_tolerance);
349  aveGeom.ladderMaxZ[il] += (0.5f * moduleLength - module_tolerance);
350  }
351 
352  // compute "max z" for first layer in endcap (should we restrict to the outermost ring?)
353  for (auto im = TrackerTraits::layerStart[firstEndcapPos]; im < TrackerTraits::layerStart[firstEndcapPos + 1]; ++im) {
354  auto const& g = detParamsGPU_[im];
355  aveGeom.endCapZ[0] = std::max(aveGeom.endCapZ[0], g.frame.z());
356  }
357  for (auto im = TrackerTraits::layerStart[firstEndcapNeg]; im < TrackerTraits::layerStart[firstEndcapNeg + 1]; ++im) {
358  auto const& g = detParamsGPU_[im];
359  aveGeom.endCapZ[1] = std::min(aveGeom.endCapZ[1], g.frame.z());
360  }
361  // correct for outer ring being closer
362  aveGeom.endCapZ[0] -= TrackerTraits::endcapCorrection;
363  aveGeom.endCapZ[1] += TrackerTraits::endcapCorrection;
364 #ifdef EDM_ML_DEBUG
365  for (int jl = 0, nl = numberOfLaddersInBarrel; jl < nl; ++jl) {
366  LogDebug("PixelCPEFast") << jl << ':' << aveGeom.ladderR[jl] << '/'
367  << std::sqrt(aveGeom.ladderX[jl] * aveGeom.ladderX[jl] +
368  aveGeom.ladderY[jl] * aveGeom.ladderY[jl])
369  << ',' << aveGeom.ladderZ[jl] << ',' << aveGeom.ladderMinZ[jl] << ','
370  << aveGeom.ladderMaxZ[jl] << '\n';
371  }
372  LogDebug("PixelCPEFast") << aveGeom.endCapZ[0] << ' ' << aveGeom.endCapZ[1];
373 #endif // EDM_ML_DEBUG
374 
375  // fill Layer and ladders geometry
377  memcpy(layerGeometry_.layerStart,
380  memcpy(layerGeometry_.layer, pixelTopology::layer<TrackerTraits>.data(), pixelTopology::layer<TrackerTraits>.size());
381  layerGeometry_.maxModuleStride = pixelTopology::maxModuleStride<TrackerTraits>;
382 }
SOAFrame< float > Frame
bool isBarrel(GeomDetEnumerators::SubDetector m)
DetParams m_DetParams
Definition: PixelCPEBase.h:280
constexpr int kGenErrorQBins
unsigned int pxbLadder(const DetId &id) const
assert(be >=bs)
The Signals That Services Can Subscribe To This is based on ActivityRegistry and is current per Services can connect to the signals distributed by the ActivityRegistry in order to monitor the activity of the application Each possible callback has some defined which we here list in angle e g
Definition: Activities.doc:4
unsigned int layer(const DetId &id) const
std::vector< pixelCPEforGPU::DetParams > detParamsGPU_
Definition: PixelCPEFast.h:50
T sqrt(T t)
Definition: SSEVec.h:23
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
constexpr T z() const
Definition: SOARotation.h:133
LayerGeometry layerGeometry_
Definition: PixelCPEFast.h:52
double f[11][100]
ALPAKA_FN_ACC ALPAKA_FN_INLINE uint32_t ix(uint32_t id)
SOARotation< float > Rotation
const TrackerTopology & ttopo_
Definition: PixelCPEBase.h:229
AverageGeometry averageGeometry_
Definition: PixelCPEFast.h:53
pixelCPEforGPU::CommonParams commonParamsGPU_
Definition: PixelCPEFast.h:51
static constexpr uint32_t layerStart[numberOfLayers+1]
ALPAKA_FN_ACC ALPAKA_FN_INLINE uint32_t iy(uint32_t id)
uint8_t layer[pixelTopology::layerIndexSize< TrackerTopology >]
void errorFromTemplates(DetParam const &theDetParam, ClusterParamGeneric &theClusterParam, float qclus) const
constexpr int kNumErrorBins
uint32_t layerStart[TrackerTopology::numberOfLayers+1]
def cp(fromDir, toDir, listOfFiles, overwrite=False, smallList=False)
#define LogDebug(id)

◆ fillPSetDescription()

template<typename TrackerTraits >
void PixelCPEFast< TrackerTraits >::fillPSetDescription ( edm::ParameterSetDescription desc)
static

Definition at line 524 of file PixelCPEFast.cc.

References submitPVResolutionJobs::desc, and PixelCPEGenericBase::fillPSetDescription().

Referenced by PixelCPEFastESProducerT< TrackerTraits >::fillDescriptions().

524  {
525  // call PixelCPEGenericBase fillPSetDescription to add common rechit errors
527 }
static void fillPSetDescription(edm::ParameterSetDescription &desc)

◆ getCPUProduct()

template<typename TrackerTraits>
ParamsOnGPU const& PixelCPEFast< TrackerTraits >::getCPUProduct ( ) const
inline

Definition at line 38 of file PixelCPEFast.h.

References PixelCPEFast< TrackerTraits >::cpuData_.

38 { return cpuData_; }
ParamsOnGPU cpuData_
Definition: PixelCPEFast.h:54

◆ getGPUProductAsync()

template<typename TrackerTraits >
const pixelCPEforGPU::ParamsOnGPUT< TrackerTraits > * PixelCPEFast< TrackerTraits >::getGPUProductAsync ( cudaStream_t  cudaStream) const

Definition at line 50 of file PixelCPEFast.cc.

References cudaCheck, data, and cms::cuda::stream.

51  {
55 
56  const auto& data = gpuData_.dataForCurrentDeviceAsync(cudaStream, [this](GPUData& data, cudaStream_t stream) {
57  // and now copy to device...
58 
59  cudaCheck(cudaMalloc((void**)&data.paramsOnGPU_h.m_commonParams, sizeof(pixelCPEforGPU::CommonParams)));
60  cudaCheck(cudaMalloc((void**)&data.paramsOnGPU_h.m_detParams,
61  this->detParamsGPU_.size() * sizeof(pixelCPEforGPU::DetParams)));
62  cudaCheck(cudaMalloc((void**)&data.paramsOnGPU_h.m_averageGeometry, sizeof(AverageGeometry)));
63  cudaCheck(cudaMalloc((void**)&data.paramsOnGPU_h.m_layerGeometry, sizeof(LayerGeometry)));
64  cudaCheck(cudaMalloc((void**)&data.paramsOnGPU_d, sizeof(ParamsOnGPU)));
65  cudaCheck(cudaMemcpyAsync(data.paramsOnGPU_d, &data.paramsOnGPU_h, sizeof(ParamsOnGPU), cudaMemcpyDefault, stream));
66  cudaCheck(cudaMemcpyAsync((void*)data.paramsOnGPU_h.m_commonParams,
67  &this->commonParamsGPU_,
69  cudaMemcpyDefault,
70  stream));
71  cudaCheck(cudaMemcpyAsync((void*)data.paramsOnGPU_h.m_averageGeometry,
72  &this->averageGeometry_,
73  sizeof(AverageGeometry),
74  cudaMemcpyDefault,
75  stream));
76  cudaCheck(cudaMemcpyAsync((void*)data.paramsOnGPU_h.m_layerGeometry,
77  &this->layerGeometry_,
78  sizeof(LayerGeometry),
79  cudaMemcpyDefault,
80  stream));
81  cudaCheck(cudaMemcpyAsync((void*)data.paramsOnGPU_h.m_detParams,
82  this->detParamsGPU_.data(),
83  this->detParamsGPU_.size() * sizeof(pixelCPEforGPU::DetParams),
84  cudaMemcpyDefault,
85  stream));
86  });
87  return data.paramsOnGPU_d;
88 }
pixelCPEforGPU::ParamsOnGPUT< TrackerTraits > ParamsOnGPU
Definition: PixelCPEFast.h:32
uint32_t T const *__restrict__ uint32_t const *__restrict__ int32_t int Histo::index_type cudaStream_t stream
std::vector< pixelCPEforGPU::DetParams > detParamsGPU_
Definition: PixelCPEFast.h:50
cms::cuda::ESProduct< GPUData > gpuData_
Definition: PixelCPEFast.h:62
pixelTopology::AverageGeometryT< TrackerTraits > AverageGeometry
Definition: PixelCPEFast.h:34
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:80
#define cudaCheck(ARG,...)
Definition: cudaCheck.h:69
pixelCPEforGPU::LayerGeometryT< TrackerTraits > LayerGeometry
Definition: PixelCPEFast.h:33

◆ localError()

template<typename TrackerTraits >
LocalError PixelCPEFast< TrackerTraits >::localError ( DetParam const &  theDetParam,
ClusterParam theClusterParam 
) const
overrideprivatevirtual

Implements PixelCPEBase.

Definition at line 508 of file PixelCPEFast.cc.

References LogDebug, PixelCPEGenericBase::ClusterParamGeneric::sigmax, and PixelCPEGenericBase::ClusterParamGeneric::sigmay.

509  {
510  ClusterParamGeneric& theClusterParam = static_cast<ClusterParamGeneric&>(theClusterParamBase);
511 
512  auto xerr = theClusterParam.sigmax;
513  auto yerr = theClusterParam.sigmay;
514 
515  LogDebug("PixelCPEFast") << " errors " << xerr << " " << yerr;
516 
517  auto xerr_sq = xerr * xerr;
518  auto yerr_sq = yerr * yerr;
519 
520  return LocalError(xerr_sq, 0, yerr_sq);
521 }
#define LogDebug(id)

◆ localPosition()

template<typename TrackerTraits >
LocalPoint PixelCPEFast< TrackerTraits >::localPosition ( DetParam const &  theDetParam,
ClusterParam theClusterParamBase 
) const
overrideprivatevirtual

Hit position in the local frame (in cm). Unlike other CPE's, this one converts everything from the measurement frame (in channel numbers) into the local frame (in centimeters).

< Q of the first pixel in X

< Q of the last pixel in X

< Q of the first pixel in Y

< Q of the last pixel in Y

Implements PixelCPEBase.

Definition at line 453 of file PixelCPEFast.cc.

References SiPixelCluster::charge(), PixelCPEGenericBase::collect_edge_charges(), PixelCPEFast< TrackerTraits >::commonParamsGPU_, CommonMethods::cp(), PixelCPEFast< TrackerTraits >::detParamsGPU_, PixelCPEFast< TrackerTraits >::errorFromTemplates(), GeomDet::index(), LogDebug, SiPixelCluster::maxPixelCol(), SiPixelCluster::maxPixelRow(), SiPixelCluster::minPixelCol(), SiPixelCluster::minPixelRow(), PixelCPEBase::ClusterParam::qBin_, PixelCPEGenericBase::ClusterParamGeneric::sigmax, PixelCPEGenericBase::ClusterParamGeneric::sigmay, PixelCPEBase::ClusterParam::theCluster, PixelCPEBase::DetParam::theDet, PixelCPEGenericBase::truncatePixelCharge_, and PixelCPEGenericBase::useErrorsFromTemplates_.

454  {
455  ClusterParamGeneric& theClusterParam = static_cast<ClusterParamGeneric&>(theClusterParamBase);
456 
458  errorFromTemplates(theDetParam, theClusterParam, theClusterParam.theCluster->charge());
459  } else {
460  theClusterParam.qBin_ = 0;
461  }
462 
463  int q_f_X;
464  int q_l_X;
465  int q_f_Y;
466  int q_l_Y;
467  collect_edge_charges(theClusterParam, q_f_X, q_l_X, q_f_Y, q_l_Y, useErrorsFromTemplates_ && truncatePixelCharge_);
468 
469  // do GPU like ...
471 
472  cp.minRow[0] = theClusterParam.theCluster->minPixelRow();
473  cp.maxRow[0] = theClusterParam.theCluster->maxPixelRow();
474  cp.minCol[0] = theClusterParam.theCluster->minPixelCol();
475  cp.maxCol[0] = theClusterParam.theCluster->maxPixelCol();
476 
477  cp.q_f_X[0] = q_f_X;
478  cp.q_l_X[0] = q_l_X;
479  cp.q_f_Y[0] = q_f_Y;
480  cp.q_l_Y[0] = q_l_Y;
481 
482  cp.charge[0] = theClusterParam.theCluster->charge();
483 
484  auto ind = theDetParam.theDet->index();
485  pixelCPEforGPU::position<TrackerTraits>(commonParamsGPU_, detParamsGPU_[ind], cp, 0);
486  auto xPos = cp.xpos[0];
487  auto yPos = cp.ypos[0];
488 
489  // set the error (mind ape....)
490  pixelCPEforGPU::errorFromDB<TrackerTraits>(commonParamsGPU_, detParamsGPU_[ind], cp, 0);
491  theClusterParam.sigmax = cp.xerr[0];
492  theClusterParam.sigmay = cp.yerr[0];
493 
494  LogDebug("PixelCPEFast") << " in PixelCPEFast:localPosition - pos = " << xPos << " " << yPos << " size "
495  << cp.maxRow[0] - cp.minRow[0] << ' ' << cp.maxCol[0] - cp.minCol[0];
496 
497  //--- Now put the two together
498  LocalPoint pos_in_local(xPos, yPos);
499  return pos_in_local;
500 }
static void collect_edge_charges(ClusterParam &theClusterParam, int &q_f_X, int &q_l_X, int &q_f_Y, int &q_l_Y, bool truncate)
std::vector< pixelCPEforGPU::DetParams > detParamsGPU_
Definition: PixelCPEFast.h:50
pixelCPEforGPU::CommonParams commonParamsGPU_
Definition: PixelCPEFast.h:51
void errorFromTemplates(DetParam const &theDetParam, ClusterParamGeneric &theClusterParam, float qclus) const
def cp(fromDir, toDir, listOfFiles, overwrite=False, smallList=False)
#define LogDebug(id)

Member Data Documentation

◆ averageGeometry_

template<typename TrackerTraits>
AverageGeometry PixelCPEFast< TrackerTraits >::averageGeometry_
private

Definition at line 53 of file PixelCPEFast.h.

Referenced by PixelCPEFast< TrackerTraits >::PixelCPEFast().

◆ commonParamsGPU_

template<typename TrackerTraits>
pixelCPEforGPU::CommonParams PixelCPEFast< TrackerTraits >::commonParamsGPU_
private

◆ cpuData_

template<typename TrackerTraits>
ParamsOnGPU PixelCPEFast< TrackerTraits >::cpuData_
private

◆ detParamsGPU_

template<typename TrackerTraits>
std::vector<pixelCPEforGPU::DetParams> PixelCPEFast< TrackerTraits >::detParamsGPU_
private

◆ gpuData_

template<typename TrackerTraits>
cms::cuda::ESProduct<GPUData> PixelCPEFast< TrackerTraits >::gpuData_
private

Definition at line 62 of file PixelCPEFast.h.

◆ layerGeometry_

template<typename TrackerTraits>
LayerGeometry PixelCPEFast< TrackerTraits >::layerGeometry_
private

Definition at line 52 of file PixelCPEFast.h.

Referenced by PixelCPEFast< TrackerTraits >::PixelCPEFast().

◆ thePixelGenError_

template<typename TrackerTraits>
std::vector<SiPixelGenErrorStore> PixelCPEFast< TrackerTraits >::thePixelGenError_
private