1 #include <cuda_runtime.h>
17 constexpr
float micronsToCm = 1.0e-4;
30 :
PixelCPEGenericBase(conf, mag, geom, ttopo, lorentzAngle, genErrorDBObject, lorentzAngleWidth) {
35 <<
"ERROR: GenErrors not filled correctly. Check the sqlite file. Using SiPixelTemplateDBObject version "
36 << (*genErrorDBObject_).version();
62 &this->commonParamsGPU_,
67 &this->averageGeometry_,
72 &this->layerGeometry_,
77 this->detParamsGPU_.data(),
102 uint32_t oldLayer = 0;
103 uint32_t oldLadder = 0;
106 float miz = 90, mxz = 0;
114 assert(
p.theDet->index() == int(
i));
119 g.isPosZ =
p.theDet->surface().position().z() > 0;
122 g.rawId =
p.theDet->geographicalId();
127 if (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";
134 if (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;
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;
153 g.x0 =
p.theOrigin.x();
154 g.y0 =
p.theOrigin.y();
155 g.z0 =
p.theOrigin.z();
157 auto vv =
p.theDet->surface().position();
172 auto lape =
p.theDet->localAlignmentError();
179 auto toMicron = [&](
float x) {
return std::min(511,
int(
x * 1.e4f + 0.5
f)); };
183 auto gvy =
p.theOrigin.y();
184 auto gvz = 1.f /
p.theOrigin.z();
196 for (
float qclus = 15000; qclus < 35000; qclus += 15000) {
202 #endif // EDM_ML_DEBUG
205 g.sx2 = toMicron(cp.
sx2);
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();
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;
229 auto y = yoff * (1.f - (0.5f + float(ix)) / 8.
f);
231 auto gvy =
p.theOrigin.y() -
y;
232 auto gvz = 1.f /
p.theOrigin.z();
239 #endif // EDM_ML_DEBUG
249 for (
int qclus = 1000; qclus < 200000; qclus += 1000) {
251 if (cp.
qBin_ == qbin)
256 g.minCh[k++] = qclus;
258 LogDebug(
"PixelCPEFast") <<
i <<
' ' <<
g.rawId <<
' ' << cp.
cotalpha <<
' ' << qclus <<
' ' << cp.
qBin_ <<
' '
260 <<
m * cp.
sigmay <<
' ' <<
m * cp.
sy1 <<
' ' <<
m * cp.
sy2 << std::endl;
261 #endif // EDM_ML_DEBUG
266 g.xfact[
kk] =
g.xfact[k - 1];
267 g.yfact[
kk] =
g.yfact[k - 1];
268 g.minCh[
kk] =
g.minCh[k - 1];
270 auto detx = 1.f /
g.xfact[0];
271 auto dety = 1.f /
g.yfact[0];
277 float ys = 8.f - 4.f;
282 if (CPEFastParametrisation::kNumErrorBins - 1 == iy)
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;
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());
312 constexpr
float module_length = 6.7f;
313 constexpr
float module_tolerance = 0.2f;
315 aveGeom.ladderMinZ[il] -= (0.5f * module_length - module_tolerance);
316 aveGeom.ladderMaxZ[il] += (0.5f * module_length - module_tolerance);
322 aveGeom.endCapZ[0] =
std::max(aveGeom.endCapZ[0],
g.frame.z());
324 for (
auto im = phase1PixelTopology::layerStart[7]; im < phase1PixelTopology::layerStart[8]; ++im) {
326 aveGeom.endCapZ[1] =
std::min(aveGeom.endCapZ[1],
g.frame.z());
329 aveGeom.endCapZ[0] -= 1.5f;
330 aveGeom.endCapZ[1] += 1.5f;
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';
339 LogDebug(
"PixelCPEFast") << aveGeom.endCapZ[0] <<
' ' << aveGeom.endCapZ[1];
359 float locBz = theDetParam.
bz;
360 float locBx = theDetParam.
bx;
361 LogDebug(
"PixelCPEFast") <<
"PixelCPEFast::localPosition(...) : locBz = " << locBz;
365 theClusterParam.
sigmay = -999.9;
366 theClusterParam.
sigmax = -999.9;
367 theClusterParam.
sy1 = -999.9;
368 theClusterParam.
sy2 = -999.9;
369 theClusterParam.
sx1 = -999.9;
370 theClusterParam.
sx2 = -999.9;
377 theClusterParam.
qBin_ = gtempl.
qbin(gtemplID,
384 theClusterParam.
pixmx,
398 theClusterParam.
sigmax = theClusterParam.
sigmax * micronsToCm;
399 theClusterParam.
sx1 = theClusterParam.
sx1 * micronsToCm;
400 theClusterParam.
sx2 = theClusterParam.
sx2 * micronsToCm;
402 theClusterParam.
sigmay = theClusterParam.
sigmay * micronsToCm;
403 theClusterParam.
sy1 = theClusterParam.
sy1 * micronsToCm;
404 theClusterParam.
sy2 = theClusterParam.
sy2 * micronsToCm;
420 theClusterParam.
qBin_ = 0;
446 auto xPos = cp.
xpos[0];
447 auto yPos = cp.
ypos[0];
454 LogDebug(
"PixelCPEFast") <<
" in PixelCPEFast:localPosition - pos = " << xPos <<
" " << yPos <<
" size "
470 auto xerr = theClusterParam.
sigmax;
471 auto yerr = theClusterParam.
sigmay;
473 LogDebug(
"PixelCPEFast") <<
" errors " << xerr <<
" " << yerr;
475 auto xerr_sq = xerr * xerr;
476 auto yerr_sq = yerr * yerr;
void errorFromTemplates(DetParam const &theDetParam, ClusterParamGeneric &theClusterParam, float qclus) const
std::vector< SiPixelGenErrorStore > thePixelGenError_
LocalPoint localPosition(DetParam const &theDetParam, ClusterParam &theClusterParam) const override
pixelCPEforGPU::AverageGeometry averageGeometry_
static bool pushfile(int filenum, std::vector< SiPixelGenErrorStore > &pixelTemp, std::string dir="")
constexpr uint32_t numberOfModulesInBarrel
std::vector< pixelCPEforGPU::DetParams > detParamsGPU_
static void fillPSetDescription(edm::ParameterSetDescription &desc)
T mag() const
The vector magnitude. Equivalent to sqrt(vec.mag2())
const SiPixelCluster * theCluster
pixelCPEforGPU::CommonParams commonParamsGPU_
bool isBarrel(GeomDetEnumerators::SubDetector m)
DetParams const * m_detParams
unsigned int pxbLadder(const DetId &id) const
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)
uint32_t layerStart[phase1PixelTopology::numberOfLayers+1]
constexpr void position(CommonParams const &__restrict__ comParams, DetParams const &__restrict__ detParams, ClusParams &cp, uint32_t ic)
constexpr int kGenErrorQBins
pixelCPEforGPU::ParamsOnGPU paramsOnGPU_h
uint32_t T const *__restrict__ uint32_t const *__restrict__ int32_t int Histo::index_type cudaStream_t stream
cms::cuda::ESProduct< GPUData > gpuData_
const PixelGeomDetUnit * theDet
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
LayerGeometry const * m_layerGeometry
constexpr std::array< uint8_t, layerIndexSize > layer
PixelCPEFast(edm::ParameterSet const &conf, const MagneticField *, const TrackerGeometry &, const TrackerTopology &, const SiPixelLorentzAngle *, const SiPixelGenErrorDBObject *, const SiPixelLorentzAngle *)
The constructor.
AverageGeometry const * m_averageGeometry
int qbin(int id, float cotalpha, float cotbeta, float locBz, float locBx, float qclus, bool irradiationCorrections, int &pixmx, float &sigmay, float &deltay, float &sigmax, float &deltax, float &sy1, float &dy1, float &sy2, float &dy2, float &sx1, float &dx1, float &sx2, float &dx2)
const pixelCPEforGPU::ParamsOnGPU * getGPUProductAsync(cudaStream_t cudaStream) const
bool useErrorsFromTemplates_
constexpr uint32_t numberOfLaddersInBarrel
const bool truncatePixelCharge_
Abs< T >::type abs(const T &t)
static void fillPSetDescription(edm::ParameterSetDescription &desc)
pixelCPEforGPU::ParamsOnGPU cpuData_
LocalError localError(DetParam const &theDetParam, ClusterParam &theClusterParam) const override
SOARotation< float > Rotation
constexpr int16_t xOffset
CommonParams const * m_commonParams
const TrackerTopology & ttopo_
const SiPixelGenErrorDBObject * genErrorDBObject_
unsigned int layer(const DetId &id) const
char data[epos_bytes_allocation]
constexpr uint32_t layerStart[numberOfLayers+1]
constexpr void errorFromDB(CommonParams const &__restrict__ comParams, DetParams const &__restrict__ detParams, ClusParams &cp, uint32_t ic)
#define cudaCheck(ARG,...)
constexpr int16_t yOffset
uint8_t layer[phase1PixelTopology::layerIndexSize]
constexpr int kNumErrorBins
pixelCPEforGPU::ParamsOnGPU * paramsOnGPU_d
pixelCPEforGPU::LayerGeometry layerGeometry_