1 #include <cuda_runtime.h>
17 constexpr
float micronsToCm = 1.0e-4;
30 :
PixelCPEBase(conf,
mag,
geom, ttopo, lorentzAngle, genErrorDBObject, nullptr, lorentzAngleWidth, 0),
31 edgeClusterErrorX_(conf.getParameter<double>(
"EdgeClusterErrorX")),
32 edgeClusterErrorY_(conf.getParameter<double>(
"EdgeClusterErrorY")),
33 useErrorsFromTemplates_(conf.getParameter<
bool>(
"UseErrorsFromTemplates")),
34 truncatePixelCharge_(conf.getParameter<
bool>(
"TruncatePixelCharge")) {
39 <<
"ERROR: GenErrors not filled correctly. Check the sqlite file. Using SiPixelTemplateDBObject version "
40 << (*genErrorDBObject_).version();
47 yerr_barrel_l1_ = {0.00375, 0.00230, 0.00250, 0.00250, 0.00230, 0.00230, 0.00210, 0.00210, 0.00240};
51 yerr_barrel_ln_ = {0.00375, 0.00230, 0.00250, 0.00250, 0.00230, 0.00230, 0.00210, 0.00210, 0.00240};
80 cudaCheck(cudaMemcpyAsync((
void*)
data.paramsOnGPU_h.m_commonParams,
81 &this->commonParamsGPU_,
85 cudaCheck(cudaMemcpyAsync((
void*)
data.paramsOnGPU_h.m_averageGeometry,
86 &this->averageGeometry_,
90 cudaCheck(cudaMemcpyAsync((
void*)
data.paramsOnGPU_h.m_layerGeometry,
91 &this->layerGeometry_,
95 cudaCheck(cudaMemcpyAsync((
void*)
data.paramsOnGPU_h.m_detParams,
96 this->detParamsGPU_.data(),
101 return data.paramsOnGPU_d;
116 uint32_t oldLayer = 0;
117 uint32_t oldLadder = 0;
120 float miz = 90, mxz = 0;
133 g.isPosZ =
p.theDet->surface().position().z() > 0;
136 g.rawId =
p.theDet->geographicalId();
140 if (oldLayer !=
g.layer) {
142 LogDebug(
"PixelCPEFast") <<
"new layer at " <<
i << (
g.isBarrel ?
" B " : (
g.isPosZ ?
" E+ " :
" E- "))
143 <<
g.layer <<
" starting at " <<
g.rawId <<
'\n'
144 <<
"old layer had " << nl <<
" ladders";
147 if (oldLadder !=
ladder) {
149 LogDebug(
"PixelCPEFast") <<
"new ladder at " <<
i << (
g.isBarrel ?
" B " : (
g.isPosZ ?
" E+ " :
" E- "))
150 <<
ladder <<
" starting at " <<
g.rawId <<
'\n'
151 <<
"old ladder ave z,r,p mz " << zl / 8.f <<
" " << rl / 8.f <<
" " << pl / 8.f <<
' '
152 << miz <<
' ' << mxz;
161 g.shiftX = 0.5f *
p.lorentzShiftInCmX;
162 g.shiftY = 0.5f *
p.lorentzShiftInCmY;
163 g.chargeWidthX =
p.lorentzShiftInCmX *
p.widthLAFractionX;
164 g.chargeWidthY =
p.lorentzShiftInCmY *
p.widthLAFractionY;
166 g.x0 =
p.theOrigin.x();
167 g.y0 =
p.theOrigin.y();
168 g.z0 =
p.theOrigin.z();
170 auto vv =
p.theDet->surface().position();
183 auto gvy =
p.theOrigin.y();
184 auto gvz = 1.f /
p.theOrigin.z();
188 cp.cotalpha = gvx * gvz;
189 cp.cotbeta = gvy * gvz;
191 cp.with_track_angle =
false;
193 auto lape =
p.theDet->localAlignmentError();
199 for (
float qclus = 15000; qclus < 35000; qclus += 15000) {
201 LogDebug(
"PixelCPEFast") <<
i <<
' ' << qclus <<
' ' <<
cp.pixmx <<
' ' <<
m *
cp.sigmax <<
' ' <<
m *
cp.sx1
202 <<
' ' <<
m *
cp.sx2 <<
' ' <<
m *
cp.sigmay <<
' ' <<
m *
cp.sy1 <<
' ' <<
m *
cp.sy2;
205 #endif // EDM_ML_DEBUG
217 for (
int i = 0;
i < 3; ++
i) {
230 auto z =
g.frame.z();
231 aveGeom.ladderZ[il] += 0.125f *
z;
232 aveGeom.ladderMinZ[il] =
std::min(aveGeom.ladderMinZ[il],
z);
233 aveGeom.ladderMaxZ[il] =
std::max(aveGeom.ladderMaxZ[il],
z);
234 aveGeom.ladderX[il] += 0.125f *
g.frame.x();
235 aveGeom.ladderY[il] += 0.125f *
g.frame.y();
236 aveGeom.ladderR[il] += 0.125f *
sqrt(
g.frame.x() *
g.frame.x() +
g.frame.y() *
g.frame.y());
240 constexpr
float module_length = 6.7f;
241 constexpr
float module_tolerance = 0.2f;
243 aveGeom.ladderMinZ[il] -= (0.5f * module_length - module_tolerance);
244 aveGeom.ladderMaxZ[il] += (0.5f * module_length - module_tolerance);
250 aveGeom.endCapZ[0] =
std::max(aveGeom.endCapZ[0],
g.frame.z());
254 aveGeom.endCapZ[1] =
std::min(aveGeom.endCapZ[1],
g.frame.z());
257 aveGeom.endCapZ[0] -= 1.5f;
258 aveGeom.endCapZ[1] += 1.5f;
262 LogDebug(
"PixelCPEFast") << jl <<
':' << aveGeom.ladderR[jl] <<
'/'
263 <<
std::sqrt(aveGeom.ladderX[jl] * aveGeom.ladderX[jl] +
264 aveGeom.ladderY[jl] * aveGeom.ladderY[jl])
265 <<
',' << aveGeom.ladderZ[jl] <<
',' << aveGeom.ladderMinZ[jl] <<
','
266 << aveGeom.ladderMaxZ[jl] <<
'\n';
268 LogDebug(
"PixelCPEFast") << aveGeom.endCapZ[0] <<
' ' << aveGeom.endCapZ[1];
269 #endif // EDM_ML_DEBUG
287 return std::make_unique<ClusterParamGeneric>(
cl);
293 float locBz = theDetParam.
bz;
294 float locBx = theDetParam.
bx;
295 LogDebug(
"PixelCPEFast") <<
"PixelCPEFast::localPosition(...) : locBz = " << locBz;
299 theClusterParam.
sigmay = -999.9;
300 theClusterParam.
sigmax = -999.9;
301 theClusterParam.
sy1 = -999.9;
302 theClusterParam.
sy2 = -999.9;
303 theClusterParam.
sx1 = -999.9;
304 theClusterParam.
sx2 = -999.9;
311 theClusterParam.qBin_ = gtempl.
qbin(gtemplID,
312 theClusterParam.cotalpha,
313 theClusterParam.cotbeta,
318 theClusterParam.
pixmx,
332 theClusterParam.
sigmax = theClusterParam.
sigmax * micronsToCm;
333 theClusterParam.
sx1 = theClusterParam.
sx1 * micronsToCm;
334 theClusterParam.
sx2 = theClusterParam.
sx2 * micronsToCm;
336 theClusterParam.
sigmay = theClusterParam.
sigmay * micronsToCm;
337 theClusterParam.
sy1 = theClusterParam.
sy1 * micronsToCm;
338 theClusterParam.
sy2 = theClusterParam.
sy2 * micronsToCm;
347 ClusterParamGeneric& theClusterParam = static_cast<ClusterParamGeneric&>(theClusterParamBase);
349 assert(!theClusterParam.with_track_angle);
352 errorFromTemplates(theDetParam, theClusterParam, theClusterParam.theCluster->charge());
354 theClusterParam.qBin_ = 0;
366 cp.minRow[0] = theClusterParam.theCluster->minPixelRow();
367 cp.maxRow[0] = theClusterParam.theCluster->maxPixelRow();
368 cp.minCol[0] = theClusterParam.theCluster->minPixelCol();
369 cp.maxCol[0] = theClusterParam.theCluster->maxPixelCol();
378 auto xPos =
cp.xpos[0];
379 auto yPos =
cp.ypos[0];
381 LogDebug(
"PixelCPEFast") <<
" in PixelCPEFast:localPosition - pos = " << xPos <<
" " << yPos <<
" size "
382 <<
cp.maxRow[0] -
cp.minRow[0] <<
' ' <<
cp.maxCol[0] -
cp.minCol[0];
400 ClusterParamGeneric& theClusterParam = static_cast<ClusterParamGeneric&>(theClusterParamBase);
407 int xmin = theClusterParam.theCluster->minPixelRow();
408 int xmax = theClusterParam.theCluster->maxPixelRow();
409 int ymin = theClusterParam.theCluster->minPixelCol();
410 int ymax = theClusterParam.theCluster->maxPixelCol();
413 int isize = theClusterParam.theCluster->size();
414 for (
int i = 0;
i != isize; ++
i) {
415 auto const&
pixel = theClusterParam.theCluster->pixel(
i);
417 int pix_adc =
pixel.adc;
442 ClusterParamGeneric& theClusterParam = static_cast<ClusterParamGeneric&>(theClusterParamBase);
450 int maxPixelCol = theClusterParam.theCluster->maxPixelCol();
451 int maxPixelRow = theClusterParam.theCluster->maxPixelRow();
452 int minPixelCol = theClusterParam.theCluster->minPixelCol();
453 int minPixelRow = theClusterParam.theCluster->minPixelRow();
458 unsigned int sizex = theClusterParam.theCluster->sizeX();
459 unsigned int sizey = theClusterParam.theCluster->sizeY();
472 xerr = theClusterParam.
sx1;
474 xerr = theClusterParam.
sx2;
477 xerr = theClusterParam.
sigmax;
484 yerr = theClusterParam.
sy1;
486 yerr = theClusterParam.
sy2;
489 yerr = theClusterParam.
sigmay;
496 LogDebug(
"PixelCPEFast") <<
"Track angles are not known.\n"
497 <<
"Default angle estimation which assumes track from PV (0,0,0) does not work.";
553 LogDebug(
"PixelCPEFast") <<
" errors " << xerr <<
" " << yerr;
555 auto xerr_sq = xerr * xerr;
556 auto yerr_sq = yerr * yerr;