1 #include <cuda_runtime.h> 17 constexpr
float micronsToCm = 1.0e-4;
35 <<
"ERROR: GenErrors not filled correctly. Check the sqlite file. Using SiPixelTemplateDBObject version " 36 << (*genErrorDBObject_).version();
63 cudaCheck(cudaMemcpyAsync((
void*)
data.paramsOnGPU_h.m_commonParams,
64 &this->commonParamsGPU_,
68 cudaCheck(cudaMemcpyAsync((
void*)
data.paramsOnGPU_h.m_averageGeometry,
69 &this->averageGeometry_,
73 cudaCheck(cudaMemcpyAsync((
void*)
data.paramsOnGPU_h.m_layerGeometry,
74 &this->layerGeometry_,
78 cudaCheck(cudaMemcpyAsync((
void*)
data.paramsOnGPU_h.m_detParams,
79 this->detParamsGPU_.data(),
84 return data.paramsOnGPU_d;
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;
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();
194 cp.with_track_angle =
false;
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();
213 cp.cotalpha = gvx * gvz;
214 cp.cotbeta = gvy * gvz;
224 for (
float qclus = 15000; qclus < 35000; qclus += 15000) {
226 LogDebug(
"PixelCPEFast") <<
i <<
' ' << qclus <<
' ' <<
cp.pixmx <<
' ' <<
m *
cp.sigmax <<
' ' <<
m *
cp.sx1
227 <<
' ' <<
m *
cp.sx2 <<
' ' <<
m *
cp.sigmay <<
' ' <<
m *
cp.sy1 <<
' ' <<
m *
cp.sy2;
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();
245 cp.cotbeta = gvy * gvz;
246 cp.cotalpha = gvx * gvz;
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();
261 cp.cotbeta = gvy * gvz;
262 cp.cotalpha = gvx * gvz;
264 LogDebug(
"PixelCPEFast") <<
"sigmay vs y " <<
i <<
' ' <<
y <<
' ' <<
cp.cotbeta <<
' ' << 10000.f *
cp.sigmay
267 #endif // EDM_ML_DEBUG 270 cp.cotalpha = gvx * gvz;
271 cp.cotbeta = gvy * gvz;
272 auto aveCB =
cp.cotbeta;
277 for (
int qclus = 1000; qclus < 200000; qclus += 1000) {
279 if (
cp.qBin_ == qbin)
282 g.xfact[
k] =
cp.sigmax;
283 g.yfact[
k] =
cp.sigmay;
284 g.minCh[
k++] = qclus;
286 LogDebug(
"PixelCPEFast") <<
i <<
' ' <<
g.rawId <<
' ' <<
cp.cotalpha <<
' ' << qclus <<
' ' <<
cp.qBin_ <<
' ' 287 <<
cp.pixmx <<
' ' <<
m *
cp.sigmax <<
' ' <<
m *
cp.sx1 <<
' ' <<
m *
cp.sx2 <<
' ' 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;
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;
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());
350 const float module_length =
isPhase2_ ? 4.345f : 6.7f;
351 constexpr
float module_tolerance = 0.2f;
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());
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());
385 aveGeom.endCapZ[1] =
std::min(aveGeom.endCapZ[1],
g.frame.z());
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;
484 theClusterParam.
qBin_ = 0;
510 auto xPos =
cp.xpos[0];
511 auto yPos =
cp.ypos[0];
515 theClusterParam.
sigmax =
cp.xerr[0];
516 theClusterParam.
sigmay =
cp.yerr[0];
518 LogDebug(
"PixelCPEFast") <<
" in PixelCPEFast:localPosition - pos = " << xPos <<
" " << yPos <<
" size " 519 <<
cp.maxRow[0] -
cp.minRow[0] <<
' ' <<
cp.maxCol[0] -
cp.minCol[0];
534 auto xerr = theClusterParam.
sigmax;
535 auto yerr = theClusterParam.
sigmay;
537 LogDebug(
"PixelCPEFast") <<
" errors " << xerr <<
" " << yerr;
539 auto xerr_sq = xerr * xerr;
540 auto yerr_sq = yerr * yerr;
548 desc.add<
bool>(
"isPhase2",
false);
constexpr uint16_t maxModuleStride
T getParameter(std::string const &) 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)
const SiPixelCluster * theCluster
pixelCPEforGPU::CommonParams commonParamsGPU_
constexpr uint32_t layerStart[numberOfLayers+1]
bool isBarrel(GeomDetEnumerators::SubDetector m)
DetParams const * m_detParams
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
unsigned int pxbLadder(const DetId &id) const
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
unsigned int layer(const DetId &id) const
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)
bool useErrorsFromTemplates_
uint32_t layerStart[phase2PixelTopology::numberOfLayers+1]
const bool truncatePixelCharge_
Abs< T >::type abs(const T &t)
constexpr uint16_t numColsInRoc
static void fillPSetDescription(edm::ParameterSetDescription &desc)
pixelCPEforGPU::ParamsOnGPU cpuData_
constexpr uint32_t numberOfLaddersInBarrel
LocalError localError(DetParam const &theDetParam, ClusterParam &theClusterParam) const override
T mag() const
The vector magnitude. Equivalent to sqrt(vec.mag2())
SOARotation< float > Rotation
constexpr int16_t xOffset
CommonParams const * m_commonParams
const TrackerTopology & ttopo_
constexpr uint16_t maxModuleStride
const pixelCPEforGPU::ParamsOnGPU * getGPUProductAsync(cudaStream_t cudaStream) const
constexpr std::array< uint8_t, layerIndexSize > layer
const SiPixelGenErrorDBObject * genErrorDBObject_
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,...)
void errorFromTemplates(DetParam const &theDetParam, ClusterParamGeneric &theClusterParam, float qclus) const
constexpr uint16_t numberOfModulesInLadder
constexpr uint32_t numberOfModulesInLadder
constexpr int16_t yOffset
constexpr int kNumErrorBins
pixelCPEforGPU::ParamsOnGPU * paramsOnGPU_d
pixelCPEforGPU::LayerGeometry layerGeometry_
def cp(fromDir, toDir, listOfFiles, overwrite=False, smallList=False)