CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
List of all members | Classes | Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes
PixelCPEFast Class Referencefinal

#include <PixelCPEFast.h>

Inheritance diagram for PixelCPEFast:
PixelCPEGenericBase PixelCPEBase PixelClusterParameterEstimator

Classes

struct  GPUData
 

Public Member Functions

pixelCPEforGPU::ParamsOnGPU const & getCPUProduct () const
 
const pixelCPEforGPU::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

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

Additional Inherited Members

- Public Types inherited from PixelClusterParameterEstimator
typedef std::pair< LocalPoint,
LocalError
LocalValues
 
using ReturnType = std::tuple< LocalPoint, LocalError, SiPixelRecHitQuality::QualWordType >
 
typedef std::vector< LocalValuesVLocalValues
 
- 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

Definition at line 14 of file PixelCPEFast.h.

Constructor & Destructor Documentation

PixelCPEFast::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 averageGeometry_, commonParamsGPU_, cpuData_, detParamsGPU_, Exception, fillParamsForGpu(), PixelCPEBase::genErrorDBObject_, layerGeometry_, SiPixelGenError::pushfile(), 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 }
std::vector< SiPixelGenErrorStore > thePixelGenError_
Definition: PixelCPEFast.h:41
pixelCPEforGPU::AverageGeometry averageGeometry_
Definition: PixelCPEFast.h:47
void fillParamsForGpu()
Definition: PixelCPEFast.cc:85
static bool pushfile(int filenum, std::vector< SiPixelGenErrorStore > &pixelTemp, std::string dir="")
std::vector< pixelCPEforGPU::DetParams > detParamsGPU_
Definition: PixelCPEFast.h:44
pixelCPEforGPU::CommonParams commonParamsGPU_
Definition: PixelCPEFast.h:45
PixelCPEGenericBase(edm::ParameterSet const &conf, const MagneticField *mag, const TrackerGeometry &geom, const TrackerTopology &ttopo, const SiPixelLorentzAngle *lorentzAngle, const SiPixelGenErrorDBObject *genErrorDBObject, const SiPixelLorentzAngle *lorentzAngleWidth)
pixelCPEforGPU::ParamsOnGPU cpuData_
Definition: PixelCPEFast.h:48
const SiPixelGenErrorDBObject * genErrorDBObject_
Definition: PixelCPEBase.h:235
pixelCPEforGPU::LayerGeometry layerGeometry_
Definition: PixelCPEFast.h:46
PixelCPEFast::~PixelCPEFast ( )
overridedefault

Member Function Documentation

void PixelCPEFast::errorFromTemplates ( DetParam const &  theDetParam,
ClusterParamGeneric theClusterParam,
float  qclus 
) const
private

Definition at line 356 of file PixelCPEFast.cc.

References PixelCPEBase::DetParam::bx, PixelCPEBase::DetParam::bz, PixelCPEBase::ClusterParam::cotalpha, PixelCPEBase::ClusterParam::cotbeta, PixelCPEBase::DetParam::detTemplateId, LogDebug, SiStripPI::max, 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 thePixelGenError_.

Referenced by fillParamsForGpu(), and localPosition().

358  {
359  float locBz = theDetParam.bz;
360  float locBx = theDetParam.bx;
361  LogDebug("PixelCPEFast") << "PixelCPEFast::localPosition(...) : locBz = " << locBz;
362 
363  theClusterParam.pixmx = std::numeric_limits<int>::max(); // max pixel charge for truncation of 2-D cluster
364 
365  theClusterParam.sigmay = -999.9; // CPE Generic y-error for multi-pixel cluster
366  theClusterParam.sigmax = -999.9; // CPE Generic x-error for multi-pixel cluster
367  theClusterParam.sy1 = -999.9; // CPE Generic y-error for single single-pixel
368  theClusterParam.sy2 = -999.9; // CPE Generic y-error for single double-pixel cluster
369  theClusterParam.sx1 = -999.9; // CPE Generic x-error for single single-pixel cluster
370  theClusterParam.sx2 = -999.9; // CPE Generic x-error for single double-pixel cluster
371 
372  float dummy;
373 
375  int gtemplID = theDetParam.detTemplateId;
376 
377  theClusterParam.qBin_ = gtempl.qbin(gtemplID,
378  theClusterParam.cotalpha,
379  theClusterParam.cotbeta,
380  locBz,
381  locBx,
382  qclus,
383  false,
384  theClusterParam.pixmx,
385  theClusterParam.sigmay,
386  dummy,
387  theClusterParam.sigmax,
388  dummy,
389  theClusterParam.sy1,
390  dummy,
391  theClusterParam.sy2,
392  dummy,
393  theClusterParam.sx1,
394  dummy,
395  theClusterParam.sx2,
396  dummy);
397 
398  theClusterParam.sigmax = theClusterParam.sigmax * micronsToCm;
399  theClusterParam.sx1 = theClusterParam.sx1 * micronsToCm;
400  theClusterParam.sx2 = theClusterParam.sx2 * micronsToCm;
401 
402  theClusterParam.sigmay = theClusterParam.sigmay * micronsToCm;
403  theClusterParam.sy1 = theClusterParam.sy1 * micronsToCm;
404  theClusterParam.sy2 = theClusterParam.sy2 * micronsToCm;
405 }
std::vector< SiPixelGenErrorStore > thePixelGenError_
Definition: PixelCPEFast.h:41
#define LogDebug(id)
void PixelCPEFast::fillParamsForGpu ( )
private

Definition at line 85 of file PixelCPEFast.cc.

References funct::abs(), cms::cuda::assert(), averageGeometry_, commonParamsGPU_, PixelCPEBase::ClusterParam::cotalpha, PixelCPEBase::ClusterParam::cotbeta, CommonMethods::cp(), detParamsGPU_, errorFromTemplates(), validate-o2o-wbm::f, g, mps_fire::i, GeomDetEnumerators::isBarrel(), isotrackApplyRegressor::k, CPEFastParametrisation::kGenErrorQBins, GetRecoTauVFromDQM_MC_cff::kk, CPEFastParametrisation::kNumErrorBins, PVValHelper::ladder, pixelCPEforGPU::LayerGeometry::layer, phase1PixelTopology::layer, TrackerTopology::layer(), layerGeometry_, phase1PixelTopology::layerStart, pixelCPEforGPU::LayerGeometry::layerStart, LogDebug, visualization-live-secondInstance_cfg::m, PixelCPEBase::m_DetParams, SiStripPI::max, min(), phase1PixelTopology::numberOfLaddersInBarrel, phase1PixelTopology::numberOfModulesInBarrel, AlCaHLTBitMon_ParallelJobs::p, PixelCPEGenericBase::ClusterParamGeneric::pixmx, TrackerTopology::pxbLadder(), PixelCPEBase::ClusterParam::qBin_, findQualityFiles::rr, PixelCPEGenericBase::ClusterParamGeneric::sigmax, PixelCPEGenericBase::ClusterParamGeneric::sigmay, mathSSE::sqrt(), PixelCPEGenericBase::ClusterParamGeneric::sx1, PixelCPEGenericBase::ClusterParamGeneric::sx2, PixelCPEGenericBase::ClusterParamGeneric::sy1, PixelCPEGenericBase::ClusterParamGeneric::sy2, pixelCPEforGPU::CommonParams::thePitchX, pixelCPEforGPU::CommonParams::thePitchY, pixelCPEforGPU::CommonParams::theThicknessB, pixelCPEforGPU::CommonParams::theThicknessE, TrackerMaterial_cfi::thickness, PixelCPEBase::ttopo_, PixelCPEBase::ClusterParam::with_track_angle, x, phase1PixelTopology::xOffset, y, phase1PixelTopology::yOffset, z, and SOAFrame< T >::z().

Referenced by PixelCPEFast().

85  {
86  //
87  // this code executes only once per job, computation inefficiency is not an issue
88  // many code blocks are repeated: better keep the computation local and self oconsistent as blocks may in future move around, be deleted ...
89  // It is valid only for Phase1 and the version of GenError in DB used in late 2018 and in 2021
90 
91  commonParamsGPU_.theThicknessB = m_DetParams.front().theThickness;
92  commonParamsGPU_.theThicknessE = m_DetParams.back().theThickness;
93  commonParamsGPU_.thePitchX = m_DetParams[0].thePitchX;
94  commonParamsGPU_.thePitchY = m_DetParams[0].thePitchY;
95 
96  LogDebug("PixelCPEFast") << "pitch & thickness " << commonParamsGPU_.thePitchX << ' ' << commonParamsGPU_.thePitchY
98 
99  // zero average geometry
101 
102  uint32_t oldLayer = 0;
103  uint32_t oldLadder = 0;
104  float rl = 0;
105  float zl = 0;
106  float miz = 90, mxz = 0;
107  float pl = 0;
108  int nl = 0;
109  detParamsGPU_.resize(m_DetParams.size());
110  for (auto i = 0U; i < m_DetParams.size(); ++i) {
111  auto& p = m_DetParams[i];
112  auto& g = detParamsGPU_[i];
113 
114  assert(p.theDet->index() == int(i));
115  assert(commonParamsGPU_.thePitchY == p.thePitchY);
116  assert(commonParamsGPU_.thePitchX == p.thePitchX);
117 
118  g.isBarrel = GeomDetEnumerators::isBarrel(p.thePart);
119  g.isPosZ = p.theDet->surface().position().z() > 0;
120  g.layer = ttopo_.layer(p.theDet->geographicalId());
121  g.index = i; // better be!
122  g.rawId = p.theDet->geographicalId();
124  assert(thickness == p.theThickness);
125 
126  auto ladder = ttopo_.pxbLadder(p.theDet->geographicalId());
127  if (oldLayer != g.layer) {
128  oldLayer = g.layer;
129  LogDebug("PixelCPEFast") << "new layer at " << i << (g.isBarrel ? " B " : (g.isPosZ ? " E+ " : " E- "))
130  << g.layer << " starting at " << g.rawId << '\n'
131  << "old layer had " << nl << " ladders";
132  nl = 0;
133  }
134  if (oldLadder != ladder) {
135  oldLadder = ladder;
136  LogDebug("PixelCPEFast") << "new ladder at " << i << (g.isBarrel ? " B " : (g.isPosZ ? " E+ " : " E- "))
137  << ladder << " starting at " << g.rawId << '\n'
138  << "old ladder ave z,r,p mz " << zl / 8.f << " " << rl / 8.f << " " << pl / 8.f << ' '
139  << miz << ' ' << mxz;
140  rl = 0;
141  zl = 0;
142  pl = 0;
143  miz = 90;
144  mxz = 0;
145  nl++;
146  }
147 
148  g.shiftX = 0.5f * p.lorentzShiftInCmX;
149  g.shiftY = 0.5f * p.lorentzShiftInCmY;
150  g.chargeWidthX = p.lorentzShiftInCmX * p.widthLAFractionX;
151  g.chargeWidthY = p.lorentzShiftInCmY * p.widthLAFractionY;
152 
153  g.x0 = p.theOrigin.x();
154  g.y0 = p.theOrigin.y();
155  g.z0 = p.theOrigin.z();
156 
157  auto vv = p.theDet->surface().position();
158  auto rr = pixelCPEforGPU::Rotation(p.theDet->surface().rotation());
159  g.frame = pixelCPEforGPU::Frame(vv.x(), vv.y(), vv.z(), rr);
160 
161  zl += vv.z();
162  miz = std::min(miz, std::abs(vv.z()));
163  mxz = std::max(mxz, std::abs(vv.z()));
164  rl += vv.perp();
165  pl += vv.phi(); // (not obvious)
166 
167  // errors .....
168  ClusterParamGeneric cp;
169 
170  cp.with_track_angle = false;
171 
172  auto lape = p.theDet->localAlignmentError();
173  if (lape.invalid())
174  lape = LocalError(); // zero....
175 
176  g.apeXX = lape.xx();
177  g.apeYY = lape.yy();
178 
179  auto toMicron = [&](float x) { return std::min(511, int(x * 1.e4f + 0.5f)); };
180 
181  // average angle
182  auto gvx = p.theOrigin.x() + 40.f * commonParamsGPU_.thePitchX;
183  auto gvy = p.theOrigin.y();
184  auto gvz = 1.f / p.theOrigin.z();
185  //--- Note that the normalization is not required as only the ratio used
186 
187  {
188  // calculate angles (fed into errorFromTemplates)
189  cp.cotalpha = gvx * gvz;
190  cp.cotbeta = gvy * gvz;
191  errorFromTemplates(p, cp, 20000.);
192  }
193 
194 #ifdef EDM_ML_DEBUG
195  auto m = 10000.f;
196  for (float qclus = 15000; qclus < 35000; qclus += 15000) {
197  errorFromTemplates(p, cp, qclus);
198  LogDebug("PixelCPEFast") << i << ' ' << qclus << ' ' << cp.pixmx << ' ' << m * cp.sigmax << ' ' << m * cp.sx1
199  << ' ' << m * cp.sx2 << ' ' << m * cp.sigmay << ' ' << m * cp.sy1 << ' ' << m * cp.sy2;
200  }
201  LogDebug("PixelCPEFast") << i << ' ' << m * std::sqrt(lape.xx()) << ' ' << m * std::sqrt(lape.yy());
202 #endif // EDM_ML_DEBUG
203 
204  g.pixmx = std::max(0, cp.pixmx);
205  g.sx2 = toMicron(cp.sx2);
206  g.sy1 = std::max(21, toMicron(cp.sy1)); // for some angles sy1 is very small
207  g.sy2 = std::max(55, toMicron(cp.sy2)); // sometimes sy2 is smaller than others (due to angle?)
208 
209  // sample xerr as function of position
210  auto const xoff = float(phase1PixelTopology::xOffset) * commonParamsGPU_.thePitchX;
211 
212  for (int ix = 0; ix < CPEFastParametrisation::kNumErrorBins; ++ix) {
213  auto x = xoff * (1.f - (0.5f + float(ix)) / 8.f);
214  auto gvx = p.theOrigin.x() - x;
215  auto gvy = p.theOrigin.y();
216  auto gvz = 1.f / p.theOrigin.z();
217  cp.cotbeta = gvy * gvz;
218  cp.cotalpha = gvx * gvz;
219  errorFromTemplates(p, cp, 20000.f);
220  g.sigmax[ix] = toMicron(cp.sigmax);
221  g.sigmax1[ix] = toMicron(cp.sx1);
222  LogDebug("PixelCPEFast") << "sigmax vs x " << i << ' ' << x << ' ' << cp.cotalpha << ' ' << int(g.sigmax[ix])
223  << ' ' << int(g.sigmax1[ix]) << ' ' << 10000.f * cp.sigmay << std::endl;
224  }
225 #ifdef EDM_ML_DEBUG
226  // sample yerr as function of position
227  auto const yoff = float(phase1PixelTopology::yOffset) * commonParamsGPU_.thePitchY;
228  for (int ix = 0; ix < CPEFastParametrisation::kNumErrorBins; ++ix) {
229  auto y = yoff * (1.f - (0.5f + float(ix)) / 8.f);
230  auto gvx = p.theOrigin.x() + 40.f * commonParamsGPU_.thePitchY;
231  auto gvy = p.theOrigin.y() - y;
232  auto gvz = 1.f / p.theOrigin.z();
233  cp.cotbeta = gvy * gvz;
234  cp.cotalpha = gvx * gvz;
235  errorFromTemplates(p, cp, 20000.f);
236  LogDebug("PixelCPEFast") << "sigmay vs y " << i << ' ' << y << ' ' << cp.cotbeta << ' ' << 10000.f * cp.sigmay
237  << std::endl;
238  }
239 #endif // EDM_ML_DEBUG
240 
241  // calculate angles (repeated)
242  cp.cotalpha = gvx * gvz;
243  cp.cotbeta = gvy * gvz;
244  auto aveCB = cp.cotbeta;
245 
246  // sample x by charge
247  int qbin = CPEFastParametrisation::kGenErrorQBins; // low charge
248  int k = 0;
249  for (int qclus = 1000; qclus < 200000; qclus += 1000) {
250  errorFromTemplates(p, cp, qclus);
251  if (cp.qBin_ == qbin)
252  continue;
253  qbin = cp.qBin_;
254  g.xfact[k] = cp.sigmax;
255  g.yfact[k] = cp.sigmay;
256  g.minCh[k++] = qclus;
257 #ifdef EDM_ML_DEBUG
258  LogDebug("PixelCPEFast") << i << ' ' << g.rawId << ' ' << cp.cotalpha << ' ' << qclus << ' ' << cp.qBin_ << ' '
259  << cp.pixmx << ' ' << m * cp.sigmax << ' ' << m * cp.sx1 << ' ' << m * cp.sx2 << ' '
260  << m * cp.sigmay << ' ' << m * cp.sy1 << ' ' << m * cp.sy2 << std::endl;
261 #endif // EDM_ML_DEBUG
262  }
264  // fill the rest (sometimes bin 4 is missing)
265  for (int kk = k; kk < CPEFastParametrisation::kGenErrorQBins; ++kk) {
266  g.xfact[kk] = g.xfact[k - 1];
267  g.yfact[kk] = g.yfact[k - 1];
268  g.minCh[kk] = g.minCh[k - 1];
269  }
270  auto detx = 1.f / g.xfact[0];
271  auto dety = 1.f / g.yfact[0];
272  for (int kk = 0; kk < CPEFastParametrisation::kGenErrorQBins; ++kk) {
273  g.xfact[kk] *= detx;
274  g.yfact[kk] *= dety;
275  }
276  // sample y in "angle" (estimated from cluster size)
277  float ys = 8.f - 4.f; // apperent bias of half pixel (see plot)
278  // plot: https://indico.cern.ch/event/934821/contributions/3974619/attachments/2091853/3515041/DigilessReco.pdf page 25
279  // sample yerr as function of "size"
280  for (int iy = 0; iy < CPEFastParametrisation::kNumErrorBins; ++iy) {
281  ys += 1.f; // first bin 0 is for size 9 (and size is in fixed point 2^3)
282  if (CPEFastParametrisation::kNumErrorBins - 1 == iy)
283  ys += 8.f; // last bin for "overflow"
284  // cp.cotalpha = ys*(commonParamsGPU_.thePitchX/(8.f*thickness)); // use this to print sampling in "x" (and comment the line below)
285  cp.cotbeta = std::copysign(ys * (commonParamsGPU_.thePitchY / (8.f * thickness)), aveCB);
286  errorFromTemplates(p, cp, 20000.f);
287  g.sigmay[iy] = toMicron(cp.sigmay);
288  LogDebug("PixelCPEFast") << "sigmax/sigmay " << i << ' ' << (ys + 4.f) / 8.f << ' ' << cp.cotalpha << '/'
289  << cp.cotbeta << ' ' << 10000.f * cp.sigmax << '/' << int(g.sigmay[iy]) << std::endl;
290  }
291  } // loop over det
292 
293  //
294  // compute ladder baricenter (only in global z) for the barrel
295  //
296  auto& aveGeom = averageGeometry_;
297  int il = 0;
298  for (int im = 0, nm = phase1PixelTopology::numberOfModulesInBarrel; im < nm; ++im) {
299  auto const& g = detParamsGPU_[im];
300  il = im / 8;
302  auto z = g.frame.z();
303  aveGeom.ladderZ[il] += 0.125f * z;
304  aveGeom.ladderMinZ[il] = std::min(aveGeom.ladderMinZ[il], z);
305  aveGeom.ladderMaxZ[il] = std::max(aveGeom.ladderMaxZ[il], z);
306  aveGeom.ladderX[il] += 0.125f * g.frame.x();
307  aveGeom.ladderY[il] += 0.125f * g.frame.y();
308  aveGeom.ladderR[il] += 0.125f * sqrt(g.frame.x() * g.frame.x() + g.frame.y() * g.frame.y());
309  }
311  // add half_module and tollerance
312  constexpr float module_length = 6.7f;
313  constexpr float module_tolerance = 0.2f;
314  for (int il = 0, nl = phase1PixelTopology::numberOfLaddersInBarrel; il < nl; ++il) {
315  aveGeom.ladderMinZ[il] -= (0.5f * module_length - module_tolerance);
316  aveGeom.ladderMaxZ[il] += (0.5f * module_length - module_tolerance);
317  }
318 
319  // compute "max z" for first layer in endcap (should we restrict to the outermost ring?)
320  for (auto im = phase1PixelTopology::layerStart[4]; im < phase1PixelTopology::layerStart[5]; ++im) {
321  auto const& g = detParamsGPU_[im];
322  aveGeom.endCapZ[0] = std::max(aveGeom.endCapZ[0], g.frame.z());
323  }
324  for (auto im = phase1PixelTopology::layerStart[7]; im < phase1PixelTopology::layerStart[8]; ++im) {
325  auto const& g = detParamsGPU_[im];
326  aveGeom.endCapZ[1] = std::min(aveGeom.endCapZ[1], g.frame.z());
327  }
328  // correct for outer ring being closer
329  aveGeom.endCapZ[0] -= 1.5f;
330  aveGeom.endCapZ[1] += 1.5f;
331 
332  for (int jl = 0, nl = phase1PixelTopology::numberOfLaddersInBarrel; jl < nl; ++jl) {
333  LogDebug("PixelCPEFast") << jl << ':' << aveGeom.ladderR[jl] << '/'
334  << std::sqrt(aveGeom.ladderX[jl] * aveGeom.ladderX[jl] +
335  aveGeom.ladderY[jl] * aveGeom.ladderY[jl])
336  << ',' << aveGeom.ladderZ[jl] << ',' << aveGeom.ladderMinZ[jl] << ','
337  << aveGeom.ladderMaxZ[jl] << '\n';
338  }
339  LogDebug("PixelCPEFast") << aveGeom.endCapZ[0] << ' ' << aveGeom.endCapZ[1];
340 
341  // fill Layer and ladders geometry
342  memcpy(layerGeometry_.layerStart, phase1PixelTopology::layerStart, sizeof(phase1PixelTopology::layerStart));
344 }
void errorFromTemplates(DetParam const &theDetParam, ClusterParamGeneric &theClusterParam, float qclus) const
pixelCPEforGPU::AverageGeometry averageGeometry_
Definition: PixelCPEFast.h:47
constexpr uint32_t numberOfModulesInBarrel
SOAFrame< float > Frame
std::vector< pixelCPEforGPU::DetParams > detParamsGPU_
Definition: PixelCPEFast.h:44
pixelCPEforGPU::CommonParams commonParamsGPU_
Definition: PixelCPEFast.h:45
bool isBarrel(GeomDetEnumerators::SubDetector m)
unsigned int pxbLadder(const DetId &id) const
DetParams m_DetParams
Definition: PixelCPEBase.h:281
uint32_t layerStart[phase1PixelTopology::numberOfLayers+1]
constexpr int kGenErrorQBins
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
constexpr std::array< uint8_t, layerIndexSize > layer
T sqrt(T t)
Definition: SSEVec.h:19
constexpr uint32_t numberOfLaddersInBarrel
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
T min(T a, T b)
Definition: MathUtil.h:58
SOARotation< float > Rotation
constexpr int16_t xOffset
const TrackerTopology & ttopo_
Definition: PixelCPEBase.h:230
constexpr T z() const
Definition: SOARotation.h:133
unsigned int layer(const DetId &id) const
constexpr uint32_t layerStart[numberOfLayers+1]
constexpr int16_t yOffset
uint8_t layer[phase1PixelTopology::layerIndexSize]
constexpr int kNumErrorBins
pixelCPEforGPU::LayerGeometry layerGeometry_
Definition: PixelCPEFast.h:46
#define LogDebug(id)
void PixelCPEFast::fillPSetDescription ( edm::ParameterSetDescription desc)
static

Definition at line 481 of file PixelCPEFast.cc.

References PixelCPEGenericBase::fillPSetDescription().

Referenced by PixelCPEFastESProducer::fillDescriptions().

481  {
482  // call PixelCPEGenericBase fillPSetDescription to add common rechit errors
484 }
static void fillPSetDescription(edm::ParameterSetDescription &desc)
pixelCPEforGPU::ParamsOnGPU const& PixelCPEFast::getCPUProduct ( ) const
inline

Definition at line 32 of file PixelCPEFast.h.

References cpuData_.

32 { return cpuData_; }
pixelCPEforGPU::ParamsOnGPU cpuData_
Definition: PixelCPEFast.h:48
const pixelCPEforGPU::ParamsOnGPU * PixelCPEFast::getGPUProductAsync ( cudaStream_t  cudaStream) const

Definition at line 49 of file PixelCPEFast.cc.

References cudaCheck, data, detParamsGPU_, gpuData_, pixelCPEforGPU::ParamsOnGPU::m_averageGeometry, pixelCPEforGPU::ParamsOnGPU::m_commonParams, pixelCPEforGPU::ParamsOnGPU::m_detParams, pixelCPEforGPU::ParamsOnGPU::m_layerGeometry, PixelCPEFast::GPUData::paramsOnGPU_d, PixelCPEFast::GPUData::paramsOnGPU_h, and cms::cuda::stream.

49  {
50  const auto& data = gpuData_.dataForCurrentDeviceAsync(cudaStream, [this](GPUData& data, cudaStream_t stream) {
51  // and now copy to device...
52  cudaCheck(cudaMalloc((void**)&data.paramsOnGPU_h.m_commonParams, sizeof(pixelCPEforGPU::CommonParams)));
53  cudaCheck(cudaMalloc((void**)&data.paramsOnGPU_h.m_detParams,
54  this->detParamsGPU_.size() * sizeof(pixelCPEforGPU::DetParams)));
55  cudaCheck(cudaMalloc((void**)&data.paramsOnGPU_h.m_averageGeometry, sizeof(pixelCPEforGPU::AverageGeometry)));
56  cudaCheck(cudaMalloc((void**)&data.paramsOnGPU_h.m_layerGeometry, sizeof(pixelCPEforGPU::LayerGeometry)));
57  cudaCheck(cudaMalloc((void**)&data.paramsOnGPU_d, sizeof(pixelCPEforGPU::ParamsOnGPU)));
58 
59  cudaCheck(cudaMemcpyAsync(
60  data.paramsOnGPU_d, &data.paramsOnGPU_h, sizeof(pixelCPEforGPU::ParamsOnGPU), cudaMemcpyDefault, stream));
61  cudaCheck(cudaMemcpyAsync((void*)data.paramsOnGPU_h.m_commonParams,
62  &this->commonParamsGPU_,
64  cudaMemcpyDefault,
65  stream));
66  cudaCheck(cudaMemcpyAsync((void*)data.paramsOnGPU_h.m_averageGeometry,
67  &this->averageGeometry_,
69  cudaMemcpyDefault,
70  stream));
71  cudaCheck(cudaMemcpyAsync((void*)data.paramsOnGPU_h.m_layerGeometry,
72  &this->layerGeometry_,
74  cudaMemcpyDefault,
75  stream));
76  cudaCheck(cudaMemcpyAsync((void*)data.paramsOnGPU_h.m_detParams,
77  this->detParamsGPU_.data(),
78  this->detParamsGPU_.size() * sizeof(pixelCPEforGPU::DetParams),
79  cudaMemcpyDefault,
80  stream));
81  });
82  return data.paramsOnGPU_d;
83 }
std::vector< pixelCPEforGPU::DetParams > detParamsGPU_
Definition: PixelCPEFast.h:44
uint32_t T const *__restrict__ uint32_t const *__restrict__ int32_t int Histo::index_type cudaStream_t stream
cms::cuda::ESProduct< GPUData > gpuData_
Definition: PixelCPEFast.h:56
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:79
#define cudaCheck(ARG,...)
Definition: cudaCheck.h:69
LocalError PixelCPEFast::localError ( DetParam const &  theDetParam,
ClusterParam theClusterParam 
) const
overrideprivatevirtual

Implements PixelCPEBase.

Definition at line 467 of file PixelCPEFast.cc.

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

467  {
468  ClusterParamGeneric& theClusterParam = static_cast<ClusterParamGeneric&>(theClusterParamBase);
469 
470  auto xerr = theClusterParam.sigmax;
471  auto yerr = theClusterParam.sigmay;
472 
473  LogDebug("PixelCPEFast") << " errors " << xerr << " " << yerr;
474 
475  auto xerr_sq = xerr * xerr;
476  auto yerr_sq = yerr * yerr;
477 
478  return LocalError(xerr_sq, 0, yerr_sq);
479 }
#define LogDebug(id)
LocalPoint PixelCPEFast::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 412 of file PixelCPEFast.cc.

References cms::cuda::assert(), pixelCPEforGPU::ClusParamsT< N >::charge, SiPixelCluster::charge(), PixelCPEGenericBase::collect_edge_charges(), commonParamsGPU_, CommonMethods::cp(), detParamsGPU_, pixelCPEforGPU::errorFromDB(), errorFromTemplates(), GeomDet::index(), LogDebug, pixelCPEforGPU::ClusParamsT< N >::maxCol, SiPixelCluster::maxPixelCol(), SiPixelCluster::maxPixelRow(), pixelCPEforGPU::ClusParamsT< N >::maxRow, pixelCPEforGPU::ClusParamsT< N >::minCol, SiPixelCluster::minPixelCol(), SiPixelCluster::minPixelRow(), pixelCPEforGPU::ClusParamsT< N >::minRow, pixelCPEforGPU::position(), pixelCPEforGPU::ClusParamsT< N >::q_f_X, pixelCPEforGPU::ClusParamsT< N >::q_f_Y, pixelCPEforGPU::ClusParamsT< N >::q_l_X, pixelCPEforGPU::ClusParamsT< N >::q_l_Y, PixelCPEBase::ClusterParam::qBin_, PixelCPEGenericBase::ClusterParamGeneric::sigmax, PixelCPEGenericBase::ClusterParamGeneric::sigmay, PixelCPEBase::ClusterParam::theCluster, PixelCPEBase::DetParam::theDet, PixelCPEGenericBase::truncatePixelCharge_, PixelCPEGenericBase::useErrorsFromTemplates_, PixelCPEBase::ClusterParam::with_track_angle, pixelCPEforGPU::ClusParamsT< N >::xerr, pixelCPEforGPU::ClusParamsT< N >::xpos, pixelCPEforGPU::ClusParamsT< N >::yerr, and pixelCPEforGPU::ClusParamsT< N >::ypos.

412  {
413  ClusterParamGeneric& theClusterParam = static_cast<ClusterParamGeneric&>(theClusterParamBase);
414 
415  assert(!theClusterParam.with_track_angle);
416 
418  errorFromTemplates(theDetParam, theClusterParam, theClusterParam.theCluster->charge());
419  } else {
420  theClusterParam.qBin_ = 0;
421  }
422 
423  int q_f_X;
424  int q_l_X;
425  int q_f_Y;
426  int q_l_Y;
427  collect_edge_charges(theClusterParam, q_f_X, q_l_X, q_f_Y, q_l_Y, useErrorsFromTemplates_ && truncatePixelCharge_);
428 
429  // do GPU like ...
431 
432  cp.minRow[0] = theClusterParam.theCluster->minPixelRow();
433  cp.maxRow[0] = theClusterParam.theCluster->maxPixelRow();
434  cp.minCol[0] = theClusterParam.theCluster->minPixelCol();
435  cp.maxCol[0] = theClusterParam.theCluster->maxPixelCol();
436 
437  cp.q_f_X[0] = q_f_X;
438  cp.q_l_X[0] = q_l_X;
439  cp.q_f_Y[0] = q_f_Y;
440  cp.q_l_Y[0] = q_l_Y;
441 
442  cp.charge[0] = theClusterParam.theCluster->charge();
443 
444  auto ind = theDetParam.theDet->index();
446  auto xPos = cp.xpos[0];
447  auto yPos = cp.ypos[0];
448 
449  // set the error (mind ape....)
451  theClusterParam.sigmax = cp.xerr[0];
452  theClusterParam.sigmay = cp.yerr[0];
453 
454  LogDebug("PixelCPEFast") << " in PixelCPEFast:localPosition - pos = " << xPos << " " << yPos << " size "
455  << cp.maxRow[0] - cp.minRow[0] << ' ' << cp.maxCol[0] - cp.minCol[0];
456 
457  //--- Now put the two together
458  LocalPoint pos_in_local(xPos, yPos);
459  return pos_in_local;
460 }
void errorFromTemplates(DetParam const &theDetParam, ClusterParamGeneric &theClusterParam, float qclus) const
std::vector< pixelCPEforGPU::DetParams > detParamsGPU_
Definition: PixelCPEFast.h:44
pixelCPEforGPU::CommonParams commonParamsGPU_
Definition: PixelCPEFast.h:45
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)
constexpr void position(CommonParams const &__restrict__ comParams, DetParams const &__restrict__ detParams, ClusParams &cp, uint32_t ic)
assert(be >=bs)
constexpr void errorFromDB(CommonParams const &__restrict__ comParams, DetParams const &__restrict__ detParams, ClusParams &cp, uint32_t ic)
#define LogDebug(id)

Member Data Documentation

pixelCPEforGPU::AverageGeometry PixelCPEFast::averageGeometry_
private

Definition at line 47 of file PixelCPEFast.h.

Referenced by fillParamsForGpu(), and PixelCPEFast().

pixelCPEforGPU::CommonParams PixelCPEFast::commonParamsGPU_
private

Definition at line 45 of file PixelCPEFast.h.

Referenced by fillParamsForGpu(), localPosition(), and PixelCPEFast().

pixelCPEforGPU::ParamsOnGPU PixelCPEFast::cpuData_
private

Definition at line 48 of file PixelCPEFast.h.

Referenced by getCPUProduct(), and PixelCPEFast().

std::vector<pixelCPEforGPU::DetParams> PixelCPEFast::detParamsGPU_
private

Definition at line 44 of file PixelCPEFast.h.

Referenced by fillParamsForGpu(), getGPUProductAsync(), localPosition(), and PixelCPEFast().

cms::cuda::ESProduct<GPUData> PixelCPEFast::gpuData_
private

Definition at line 56 of file PixelCPEFast.h.

Referenced by getGPUProductAsync().

pixelCPEforGPU::LayerGeometry PixelCPEFast::layerGeometry_
private

Definition at line 46 of file PixelCPEFast.h.

Referenced by fillParamsForGpu(), and PixelCPEFast().

std::vector<SiPixelGenErrorStore> PixelCPEFast::thePixelGenError_
private

Definition at line 41 of file PixelCPEFast.h.

Referenced by errorFromTemplates(), and PixelCPEFast().