1 #include <alpaka/alpaka.hpp> 16 template <
typename TrackerTraits>
30 <<
"ERROR: GenErrors not filled correctly. Check the sqlite file. Using SiPixelTemplateDBObject version " 31 << (*genErrorDBObject_).version();
37 template <
typename TrackerTraits>
43 buffer_->commonParams().theThicknessB = m_DetParams.front().theThickness;
44 buffer_->commonParams().theThicknessE = m_DetParams.back().theThickness;
45 buffer_->commonParams().thePitchX = m_DetParams[0].thePitchX;
46 buffer_->commonParams().thePitchY = m_DetParams[0].thePitchY;
48 buffer_->commonParams().numberOfLaddersInBarrel = TrackerTraits::numberOfLaddersInBarrel;
50 LogDebug(
"PixelCPEFastParamsHost") <<
"pitch & thickness " << buffer_->commonParams().thePitchX <<
' ' 51 << buffer_->commonParams().thePitchY <<
" " 52 << buffer_->commonParams().theThicknessB <<
' ' 53 << buffer_->commonParams().theThicknessE;
58 uint32_t oldLayer = 0;
59 uint32_t oldLadder = 0;
62 float miz = 500, mxz = 0;
67 for (
auto i = 0
U;
i < m_DetParams.size(); ++
i) {
68 auto&
p = m_DetParams[
i];
69 auto&
g = buffer_->detParams(
i);
71 g.nRowsRoc =
p.theDet->specificTopology().rowsperroc();
72 g.nColsRoc =
p.theDet->specificTopology().colsperroc();
73 g.nRows =
p.theDet->specificTopology().rocsX() *
g.nRowsRoc;
74 g.nCols =
p.theDet->specificTopology().rocsY() *
g.nColsRoc;
76 g.numPixsInModule =
g.nRows *
g.nCols;
79 assert(buffer_->commonParams().thePitchY ==
p.thePitchY);
80 assert(buffer_->commonParams().thePitchX ==
p.thePitchX);
83 g.isPosZ =
p.theDet->surface().position().z() > 0;
84 g.layer = ttopo_.layer(
p.theDet->geographicalId());
86 g.rawId =
p.theDet->geographicalId();
87 auto thickness =
g.isBarrel ? buffer_->commonParams().theThicknessB : buffer_->commonParams().theThicknessE;
90 auto ladder = ttopo_.pxbLadder(
p.theDet->geographicalId());
91 if (oldLayer !=
g.layer) {
93 LogDebug(
"PixelCPEFastParamsHost") <<
"new layer at " <<
i << (
g.isBarrel ?
" B " : (
g.isPosZ ?
" E+ " :
" E- "))
94 <<
g.layer <<
" starting at " <<
g.rawId <<
'\n' 95 <<
"old layer had " << nl <<
" ladders";
100 LogDebug(
"PixelCPEFastParamsHost") <<
"new ladder at " <<
i 101 << (
g.isBarrel ?
" B " : (
g.isPosZ ?
" E+ " :
" E- ")) <<
ladder 102 <<
" starting at " <<
g.rawId <<
'\n' 103 <<
"old ladder ave z,r,p mz " << zl / 8.f <<
" " << rl / 8.f <<
" " << pl / 8.f
104 <<
' ' << miz <<
' ' << mxz;
113 g.shiftX = 0.5f *
p.lorentzShiftInCmX;
114 g.shiftY = 0.5f *
p.lorentzShiftInCmY;
115 g.chargeWidthX =
p.lorentzShiftInCmX *
p.widthLAFractionX;
116 g.chargeWidthY =
p.lorentzShiftInCmY *
p.widthLAFractionY;
118 g.x0 =
p.theOrigin.x();
119 g.y0 =
p.theOrigin.y();
120 g.z0 =
p.theOrigin.z();
122 auto vv =
p.theDet->surface().position();
135 cp.with_track_angle =
false;
137 auto lape =
p.theDet->localAlignmentError();
144 auto toMicron = [&](
float x) {
return std::min(511,
int(
x * 1.e4f + 0.5
f)); };
147 auto gvx =
p.theOrigin.x() + 40.f * buffer_->commonParams().thePitchX;
148 auto gvy =
p.theOrigin.y();
149 auto gvz = 1.f /
p.theOrigin.z();
154 cp.cotalpha = gvx * gvz;
155 cp.cotbeta = gvy * gvz;
157 errorFromTemplates(
p,
cp, 20000.);
162 for (
float qclus = 15000; qclus < 35000; qclus += 15000) {
163 errorFromTemplates(
p,
cp, qclus);
164 LogDebug(
"PixelCPEFastParamsHost") <<
i <<
' ' << qclus <<
' ' <<
cp.pixmx <<
' ' <<
m *
cp.sigmax <<
' ' 165 <<
m *
cp.sx1 <<
' ' <<
m *
cp.sx2 <<
' ' <<
m *
cp.sigmay <<
' ' <<
m *
cp.sy1
166 <<
' ' <<
m *
cp.sy2;
169 #endif // EDM_ML_DEBUG 172 g.sx2 = toMicron(
cp.sx2);
179 float moduleOffsetX = -(0.5f *
float(
g.nRows) + TrackerTraits::bigPixXCorrection);
180 auto const xoff = moduleOffsetX * buffer_->commonParams().thePitchX;
183 auto x = xoff * (1.f - (0.5f +
float(
ix)) / 8.
f);
184 auto gvx =
p.theOrigin.x() -
x;
185 auto gvy =
p.theOrigin.y();
186 auto gvz = 1.f /
p.theOrigin.z();
187 cp.cotbeta = gvy * gvz;
188 cp.cotalpha = gvx * gvz;
189 errorFromTemplates(
p,
cp, 20000.
f);
190 g.sigmax[
ix] = toMicron(
cp.sigmax);
191 g.sigmax1[
ix] = toMicron(
cp.sx1);
192 LogDebug(
"PixelCPEFastParamsHost") <<
"sigmax vs x " <<
i <<
' ' <<
x <<
' ' <<
cp.cotalpha <<
' ' 193 <<
int(
g.sigmax[
ix]) <<
' ' <<
int(
g.sigmax1[
ix]) <<
' ' << 10000.f *
cp.sigmay
199 float moduleOffsetY = 0.5f *
float(
g.nCols) + TrackerTraits::bigPixYCorrection;
200 auto const yoff = -moduleOffsetY * buffer_->commonParams().thePitchY;
203 auto y = yoff * (1.f - (0.5f +
float(
ix)) / 8.
f);
204 auto gvx =
p.theOrigin.x() + 40.f * buffer_->commonParams().thePitchY;
205 auto gvy =
p.theOrigin.y() -
y;
206 auto gvz = 1.f /
p.theOrigin.z();
207 cp.cotbeta = gvy * gvz;
208 cp.cotalpha = gvx * gvz;
209 errorFromTemplates(
p,
cp, 20000.
f);
210 LogDebug(
"PixelCPEFastParamsHost") <<
"sigmay vs y " <<
i <<
' ' <<
y <<
' ' <<
cp.cotbeta <<
' ' 211 << 10000.f *
cp.sigmay << std::endl;
213 #endif // EDM_ML_DEBUG 216 cp.cotalpha = gvx * gvz;
217 cp.cotbeta = gvy * gvz;
218 auto aveCB =
cp.cotbeta;
223 for (
int qclus = 1000; qclus < 200000; qclus += 1000) {
224 errorFromTemplates(
p,
cp, qclus);
225 if (
cp.qBin_ == qbin)
228 g.xfact[
k] =
cp.sigmax;
229 g.yfact[
k] =
cp.sigmay;
230 g.minCh[
k++] = qclus;
232 LogDebug(
"PixelCPEFastParamsHost") <<
i <<
' ' <<
g.rawId <<
' ' <<
cp.cotalpha <<
' ' << qclus <<
' ' <<
cp.qBin_
233 <<
' ' <<
cp.pixmx <<
' ' <<
m *
cp.sigmax <<
' ' <<
m *
cp.sx1 <<
' ' 234 <<
m *
cp.sx2 <<
' ' <<
m *
cp.sigmay <<
' ' <<
m *
cp.sy1 <<
' ' <<
m *
cp.sy2
236 #endif // EDM_ML_DEBUG 243 g.xfact[
kk] =
g.xfact[
k - 1];
244 g.yfact[
kk] =
g.yfact[
k - 1];
245 g.minCh[
kk] =
g.minCh[
k - 1];
247 auto detx = 1.f /
g.xfact[0];
248 auto dety = 1.f /
g.yfact[0];
254 float ys = 8.f - 4.f;
262 cp.cotbeta = std::copysign(ys * (buffer_->commonParams().thePitchY / (8.f *
thickness)), aveCB);
263 errorFromTemplates(
p,
cp, 20000.
f);
264 g.sigmay[
iy] = toMicron(
cp.sigmay);
265 LogDebug(
"PixelCPEFastParamsHost") <<
"sigmax/sigmay " <<
i <<
' ' << (ys + 4.f) / 8.
f <<
' ' <<
cp.cotalpha
266 <<
'/' <<
cp.cotbeta <<
' ' << 10000.f *
cp.sigmax <<
'/' <<
int(
g.sigmay[
iy])
271 constexpr int numberOfModulesInLadder = TrackerTraits::numberOfModulesInLadder;
272 constexpr int numberOfLaddersInBarrel = TrackerTraits::numberOfLaddersInBarrel;
273 constexpr int numberOfModulesInBarrel = TrackerTraits::numberOfModulesInBarrel;
275 constexpr float ladderFactor = 1.f /
float(numberOfModulesInLadder);
277 constexpr int firstEndcapPos = TrackerTraits::firstEndcapPos;
278 constexpr int firstEndcapNeg = TrackerTraits::firstEndcapNeg;
282 auto& aveGeom = buffer_->averageGeometry();
284 for (
int im = 0, nm = numberOfModulesInBarrel; im < nm; ++im) {
285 auto const&
g = buffer_->detParams(im);
286 il = im / numberOfModulesInLadder;
287 assert(il <
int(numberOfLaddersInBarrel));
288 auto z =
g.frame.z();
289 aveGeom.ladderZ[il] += ladderFactor *
z;
290 aveGeom.ladderMinZ[il] =
std::min(aveGeom.ladderMinZ[il],
z);
291 aveGeom.ladderMaxZ[il] =
std::max(aveGeom.ladderMaxZ[il],
z);
292 aveGeom.ladderX[il] += ladderFactor *
g.frame.x();
293 aveGeom.ladderY[il] += ladderFactor *
g.frame.y();
294 aveGeom.ladderR[il] += ladderFactor *
sqrt(
g.frame.x() *
g.frame.x() +
g.frame.y() *
g.frame.y());
296 assert(il + 1 ==
int(numberOfLaddersInBarrel));
298 constexpr float moduleLength = TrackerTraits::moduleLength;
300 for (
int il = 0, nl = numberOfLaddersInBarrel; il < nl; ++il) {
301 aveGeom.ladderMinZ[il] -= (0.5f * moduleLength - module_tolerance);
302 aveGeom.ladderMaxZ[il] += (0.5f * moduleLength - module_tolerance);
307 auto const&
g = buffer_->detParams(im);
308 aveGeom.endCapZ[0] =
std::max(aveGeom.endCapZ[0],
g.frame.z());
311 auto const&
g = buffer_->detParams(im);
312 aveGeom.endCapZ[1] =
std::min(aveGeom.endCapZ[1],
g.frame.z());
315 aveGeom.endCapZ[0] -= TrackerTraits::endcapCorrection;
316 aveGeom.endCapZ[1] += TrackerTraits::endcapCorrection;
318 for (
int jl = 0, nl = numberOfLaddersInBarrel; jl < nl; ++jl) {
319 LogDebug(
"PixelCPEFastParamsHost") << jl <<
':' << aveGeom.ladderR[jl] <<
'/' 320 <<
std::sqrt(aveGeom.ladderX[jl] * aveGeom.ladderX[jl] +
321 aveGeom.ladderY[jl] * aveGeom.ladderY[jl])
322 <<
',' << aveGeom.ladderZ[jl] <<
',' << aveGeom.ladderMinZ[jl] <<
',' 323 << aveGeom.ladderMaxZ[jl] <<
'\n';
325 LogDebug(
"PixelCPEFastParamsHost") << aveGeom.endCapZ[0] <<
' ' << aveGeom.endCapZ[1];
326 #endif // EDM_ML_DEBUG 330 memcpy(buffer_->layerGeometry().layerStart,
333 memcpy(buffer_->layerGeometry().layer,
334 pixelTopology::layer<TrackerTraits>.data(),
335 pixelTopology::layer<TrackerTraits>.size());
336 buffer_->layerGeometry().maxModuleStride = pixelTopology::maxModuleStride<TrackerTraits>;
339 template <
typename TrackerTraits>
343 float locBz = theDetParam.
bz;
344 float locBx = theDetParam.
bx;
345 LogDebug(
"PixelCPEFastParamsHost") <<
"PixelCPEFastParamsHost::localPosition(...) : locBz = " << locBz;
349 theClusterParam.
sigmay = -999.9;
350 theClusterParam.
sigmax = -999.9;
351 theClusterParam.
sy1 = -999.9;
352 theClusterParam.
sy2 = -999.9;
353 theClusterParam.
sx1 = -999.9;
354 theClusterParam.
sx2 = -999.9;
361 theClusterParam.
qBin_ = gtempl.
qbin(gtemplID,
368 theClusterParam.
pixmx,
395 theClusterParam.
qBin_ = 0.0f;
403 template <
typename TrackerTraits>
408 if (useErrorsFromTemplates_) {
409 errorFromTemplates(theDetParam, theClusterParam, theClusterParam.
theCluster->
charge());
411 theClusterParam.
qBin_ = 0;
418 collect_edge_charges(theClusterParam, q_f_X, q_l_X, q_f_Y, q_l_Y, useErrorsFromTemplates_ && truncatePixelCharge_);
436 pixelCPEforDevice::position<TrackerTraits>(buffer_->commonParams(), buffer_->detParams(ind),
cp, 0);
437 auto xPos =
cp.xpos[0];
438 auto yPos =
cp.ypos[0];
441 pixelCPEforDevice::errorFromDB<TrackerTraits>(buffer_->commonParams(), buffer_->detParams(ind),
cp, 0);
442 theClusterParam.
sigmax =
cp.xerr[0];
443 theClusterParam.
sigmay =
cp.yerr[0];
445 LogDebug(
"PixelCPEFastParamsHost") <<
" in PixelCPEFastParamsHost:localPosition - pos = " << xPos <<
" " << yPos
446 <<
" size " <<
cp.maxRow[0] -
cp.minRow[0] <<
' ' <<
cp.maxCol[0] -
cp.minCol[0];
458 template <
typename TrackerTraits>
463 auto xerr = theClusterParam.
sigmax;
464 auto yerr = theClusterParam.
sigmay;
466 LogDebug(
"PixelCPEFastParamsHost") <<
" errors " << xerr <<
" " << yerr;
468 auto xerr_sq = xerr * xerr;
469 auto yerr_sq = yerr * yerr;
474 template <
typename TrackerTraits>
static bool pushfile(int filenum, std::vector< SiPixelGenErrorStore > &pixelTemp, std::string dir="")
const SiPixelCluster * theCluster
bool isBarrel(GeomDetEnumerators::SubDetector m)
PixelCPEFastParamsHost(edm::ParameterSet const &conf, const MagneticField *mag, const TrackerGeometry &geom, const TrackerTopology &ttopo, const SiPixelLorentzAngle *lorentzAngle, const SiPixelGenErrorDBObject *genErrorDBObject, const SiPixelLorentzAngle *lorentzAngleWidth)
The constructor.
std::vector< SiPixelGenErrorStore > thePixelGenError_
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
constexpr uint16_t numberOfModules
constexpr int kNumErrorBins
constexpr float micronsToCm
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_
Abs< T >::type abs(const T &t)
static void fillPSetDescription(edm::ParameterSetDescription &desc)
void errorFromTemplates(DetParam const &theDetParam, ClusterParamGeneric &theClusterParam, float qclus) const
Namespace of DDCMS conversion namespace.
ALPAKA_FN_ACC ALPAKA_FN_INLINE uint32_t ix(uint32_t id)
LocalPoint localPosition(DetParam const &theDetParam, ClusterParam &theClusterParam) const override
constexpr int kGenErrorQBins
T mag() const
The vector magnitude. Equivalent to sqrt(vec.mag2())
const SiPixelGenErrorDBObject * genErrorDBObject_
void fillParamsForDevice()
LocalError localError(DetParam const &theDetParam, ClusterParam &theClusterParam) const override
static constexpr uint32_t layerStart[numberOfLayers+1]
ALPAKA_FN_ACC ALPAKA_FN_INLINE uint32_t iy(uint32_t id)
static void fillPSetDescription(edm::ParameterSetDescription &desc)
def cp(fromDir, toDir, listOfFiles, overwrite=False, smallList=False)
SOARotation< float > Rotation