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();
64 &this->commonParamsGPU_,
69 &this->averageGeometry_,
74 &this->layerGeometry_,
79 this->detParamsGPU_.data(),
108 uint32_t oldLayer = 0;
109 uint32_t oldLadder = 0;
112 float miz = 500, mxz = 0;
127 g.numPixsInModule =
g.nRows *
g.nCols;
130 g.nRowsRoc =
p.theDet->specificTopology().rowsperroc();
131 g.nColsRoc =
p.theDet->specificTopology().colsperroc();
132 g.nRows =
p.theDet->specificTopology().rocsX() *
g.nRowsRoc;
133 g.nCols =
p.theDet->specificTopology().rocsY() *
g.nColsRoc;
135 g.numPixsInModule =
g.nRows *
g.nCols;
138 assert(
p.theDet->index() == int(
i));
143 g.isPosZ =
p.theDet->surface().position().z() > 0;
146 g.rawId =
p.theDet->geographicalId();
151 if (oldLayer !=
g.layer) {
153 LogDebug(
"PixelCPEFast") <<
"new layer at " <<
i << (
g.isBarrel ?
" B " : (
g.isPosZ ?
" E+ " :
" E- "))
154 <<
g.layer <<
" starting at " <<
g.rawId <<
'\n'
155 <<
"old layer had " << nl <<
" ladders";
158 if (oldLadder !=
ladder) {
160 LogDebug(
"PixelCPEFast") <<
"new ladder at " <<
i << (
g.isBarrel ?
" B " : (
g.isPosZ ?
" E+ " :
" E- "))
161 <<
ladder <<
" starting at " <<
g.rawId <<
'\n'
162 <<
"old ladder ave z,r,p mz " << zl / 8.f <<
" " << rl / 8.f <<
" " << pl / 8.f <<
' '
163 << miz <<
' ' << mxz;
172 g.shiftX = 0.5f *
p.lorentzShiftInCmX;
173 g.shiftY = 0.5f *
p.lorentzShiftInCmY;
174 g.chargeWidthX =
p.lorentzShiftInCmX *
p.widthLAFractionX;
175 g.chargeWidthY =
p.lorentzShiftInCmY *
p.widthLAFractionY;
177 g.x0 =
p.theOrigin.x();
178 g.y0 =
p.theOrigin.y();
179 g.z0 =
p.theOrigin.z();
181 auto vv =
p.theDet->surface().position();
196 auto lape =
p.theDet->localAlignmentError();
203 auto toMicron = [&](
float x) {
return std::min(511,
int(
x * 1.e4f + 0.5
f)); };
207 auto gvy =
p.theOrigin.y();
208 auto gvz = 1.f /
p.theOrigin.z();
224 for (
float qclus = 15000; qclus < 35000; qclus += 15000) {
230 #endif // EDM_ML_DEBUG
233 g.sx2 = toMicron(cp.
sx2);
241 auto x = xoff * (1.f - (0.5f + float(ix)) / 8.
f);
242 auto gvx =
p.theOrigin.x() -
x;
243 auto gvy =
p.theOrigin.y();
244 auto gvz = 1.f /
p.theOrigin.z();
248 g.sigmax[ix] = toMicron(cp.
sigmax);
249 g.sigmax1[ix] = toMicron(cp.
sx1);
250 LogDebug(
"PixelCPEFast") <<
"sigmax vs x " <<
i <<
' ' <<
x <<
' ' << cp.
cotalpha <<
' ' << int(
g.sigmax[ix])
251 <<
' ' << int(
g.sigmax1[ix]) <<
' ' << 10000.f * cp.
sigmay << std::endl;
257 auto y = yoff * (1.f - (0.5f + float(ix)) / 8.
f);
259 auto gvy =
p.theOrigin.y() -
y;
260 auto gvz = 1.f /
p.theOrigin.z();
267 #endif // EDM_ML_DEBUG
277 for (
int qclus = 1000; qclus < 200000; qclus += 1000) {
279 if (cp.
qBin_ == qbin)
284 g.minCh[k++] = qclus;
286 LogDebug(
"PixelCPEFast") <<
i <<
' ' <<
g.rawId <<
' ' << cp.
cotalpha <<
' ' << qclus <<
' ' << cp.
qBin_ <<
' '
288 <<
m * cp.
sigmay <<
' ' <<
m * cp.
sy1 <<
' ' <<
m * cp.
sy2 << std::endl;
289 #endif // EDM_ML_DEBUG
296 g.xfact[
kk] =
g.xfact[k - 1];
297 g.yfact[
kk] =
g.yfact[k - 1];
298 g.minCh[
kk] =
g.minCh[k - 1];
300 auto detx = 1.f /
g.xfact[0];
301 auto dety = 1.f /
g.yfact[0];
307 float ys = 8.f - 4.f;
312 if (CPEFastParametrisation::kNumErrorBins - 1 == iy)
317 g.sigmay[iy] = toMicron(cp.
sigmay);
318 LogDebug(
"PixelCPEFast") <<
"sigmax/sigmay " <<
i <<
' ' << (ys + 4.f) / 8.
f <<
' ' << cp.
cotalpha <<
'/'
319 << cp.
cotbeta <<
' ' << 10000.f * cp.
sigmax <<
'/' <<
int(
g.sigmay[iy]) << std::endl;
329 const int firstEndcapPos = 4, firstEndcapNeg =
isPhase2_ ? 16 : 7;
330 const float ladderFactor = 1.f / float(numberOfModulesInLadder);
336 for (
int im = 0, nm = numberOfModulesInBarrel; im < nm; ++im) {
339 assert(il <
int(numberOfLaddersInBarrel));
340 auto z =
g.frame.z();
341 aveGeom.ladderZ[il] += ladderFactor *
z;
342 aveGeom.ladderMinZ[il] =
std::min(aveGeom.ladderMinZ[il], z);
343 aveGeom.ladderMaxZ[il] =
std::max(aveGeom.ladderMaxZ[il], z);
344 aveGeom.ladderX[il] += ladderFactor *
g.frame.x();
345 aveGeom.ladderY[il] += ladderFactor *
g.frame.y();
346 aveGeom.ladderR[il] += ladderFactor *
sqrt(
g.frame.x() *
g.frame.x() +
g.frame.y() *
g.frame.y());
348 assert(il + 1 ==
int(numberOfLaddersInBarrel));
350 const float module_length =
isPhase2_ ? 4.345f : 6.7f;
351 constexpr
float module_tolerance = 0.2f;
352 for (
int il = 0, nl = numberOfLaddersInBarrel; il < nl; ++il) {
353 aveGeom.ladderMinZ[il] -= (0.5f * module_length - module_tolerance);
354 aveGeom.ladderMaxZ[il] += (0.5f * module_length - module_tolerance);
363 aveGeom.endCapZ[0] =
std::max(aveGeom.endCapZ[0],
g.frame.z());
365 for (
auto im = phase1PixelTopology::layerStart[firstEndcapNeg];
366 im < phase1PixelTopology::layerStart[firstEndcapNeg + 1];
369 aveGeom.endCapZ[1] =
std::min(aveGeom.endCapZ[1],
g.frame.z());
372 aveGeom.endCapZ[0] -= 1.5f;
373 aveGeom.endCapZ[1] += 1.5f;
379 aveGeom.endCapZ[0] =
std::max(aveGeom.endCapZ[0],
g.frame.z());
381 for (
auto im = phase2PixelTopology::layerStart[firstEndcapNeg];
382 im < phase2PixelTopology::layerStart[firstEndcapNeg + 1];
385 aveGeom.endCapZ[1] =
std::min(aveGeom.endCapZ[1],
g.frame.z());
389 for (
int jl = 0, nl = numberOfLaddersInBarrel; jl < nl; ++jl) {
390 LogDebug(
"PixelCPEFast") << jl <<
':' << aveGeom.ladderR[jl] <<
'/'
391 <<
std::sqrt(aveGeom.ladderX[jl] * aveGeom.ladderX[jl] +
392 aveGeom.ladderY[jl] * aveGeom.ladderY[jl])
393 <<
',' << aveGeom.ladderZ[jl] <<
',' << aveGeom.ladderMinZ[jl] <<
','
394 << aveGeom.ladderMaxZ[jl] <<
'\n';
396 LogDebug(
"PixelCPEFast") << aveGeom.endCapZ[0] <<
' ' << aveGeom.endCapZ[1];
397 #endif // EDM_ML_DEBUG
425 float locBz = theDetParam.
bz;
426 float locBx = theDetParam.
bx;
427 LogDebug(
"PixelCPEFast") <<
"PixelCPEFast::localPosition(...) : locBz = " << locBz;
431 theClusterParam.
sigmay = -999.9;
432 theClusterParam.
sigmax = -999.9;
433 theClusterParam.
sy1 = -999.9;
434 theClusterParam.
sy2 = -999.9;
435 theClusterParam.
sx1 = -999.9;
436 theClusterParam.
sx2 = -999.9;
443 theClusterParam.
qBin_ = gtempl.
qbin(gtemplID,
450 theClusterParam.
pixmx,
464 theClusterParam.
sigmax = theClusterParam.
sigmax * micronsToCm;
465 theClusterParam.
sx1 = theClusterParam.
sx1 * micronsToCm;
466 theClusterParam.
sx2 = theClusterParam.
sx2 * micronsToCm;
468 theClusterParam.
sigmay = theClusterParam.
sigmay * micronsToCm;
469 theClusterParam.
sy1 = theClusterParam.
sy1 * micronsToCm;
470 theClusterParam.
sy2 = theClusterParam.
sy2 * micronsToCm;
486 theClusterParam.
qBin_ = 0;
512 auto xPos = cp.
xpos[0];
513 auto yPos = cp.
ypos[0];
520 LogDebug(
"PixelCPEFast") <<
" in PixelCPEFast:localPosition - pos = " << xPos <<
" " << yPos <<
" size "
536 auto xerr = theClusterParam.
sigmax;
537 auto yerr = theClusterParam.
sigmay;
539 LogDebug(
"PixelCPEFast") <<
" errors " << xerr <<
" " << yerr;
541 auto xerr_sq = xerr * xerr;
542 auto yerr_sq = yerr * yerr;
550 desc.
add<
bool>(
"isPhase2",
false);
void errorFromTemplates(DetParam const &theDetParam, ClusterParamGeneric &theClusterParam, float qclus) const
constexpr uint16_t maxModuleStride
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_
constexpr uint32_t layerStart[numberOfLayers+1]
bool isBarrel(GeomDetEnumerators::SubDetector m)
DetParams const * m_detParams
unsigned int pxbLadder(const DetId &id) const
uint8_t numberOfLaddersInBarrel
constexpr uint16_t numRowsInRoc
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)
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_
constexpr uint16_t numColsInModule
const PixelGeomDetUnit * theDet
constexpr uint16_t numberOfLaddersInBarrel
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
constexpr uint16_t numRowsInModule
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_
uint32_t layerStart[phase2PixelTopology::numberOfLayers+1]
const bool truncatePixelCharge_
Abs< T >::type abs(const T &t)
constexpr uint16_t numColsInRoc
ParameterDescriptionBase * add(U const &iLabel, T const &value)
static void fillPSetDescription(edm::ParameterSetDescription &desc)
pixelCPEforGPU::ParamsOnGPU cpuData_
constexpr uint32_t numberOfLaddersInBarrel
LocalError localError(DetParam const &theDetParam, ClusterParam &theClusterParam) const override
SOARotation< float > Rotation
constexpr int16_t xOffset
CommonParams const * m_commonParams
const TrackerTopology & ttopo_
constexpr uint16_t maxModuleStride
constexpr std::array< uint8_t, layerIndexSize > layer
const SiPixelGenErrorDBObject * genErrorDBObject_
T getParameter(std::string const &) const
unsigned int layer(const DetId &id) const
constexpr uint16_t numberOfModulesInBarrel
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)
uint8_t layer[phase2PixelTopology::layerIndexSize]
#define cudaCheck(ARG,...)
constexpr uint16_t numberOfModulesInLadder
constexpr uint32_t numberOfModulesInLadder
constexpr int16_t yOffset
constexpr int kNumErrorBins
pixelCPEforGPU::ParamsOnGPU * paramsOnGPU_d
pixelCPEforGPU::LayerGeometry layerGeometry_