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 int qClusIncrement = 100;
225 qclus += qClusIncrement) {
226 errorFromTemplates(
p,
cp, qclus);
227 if (
cp.qBin_ == qbin)
235 qClusIncrement = 1000;
237 g.xfact[
k] =
cp.sigmax;
238 g.yfact[
k] =
cp.sigmay;
239 g.minCh[
k++] = qclus;
241 LogDebug(
"PixelCPEFastParamsHost") <<
i <<
' ' <<
g.rawId <<
' ' <<
cp.cotalpha <<
' ' << qclus <<
' ' <<
cp.qBin_
242 <<
' ' <<
cp.pixmx <<
' ' <<
m *
cp.sigmax <<
' ' <<
m *
cp.sx1 <<
' ' 243 <<
m *
cp.sx2 <<
' ' <<
m *
cp.sigmay <<
' ' <<
m *
cp.sy1 <<
' ' <<
m *
cp.sy2
245 #endif // EDM_ML_DEBUG 252 g.xfact[
kk] =
g.xfact[
k - 1];
253 g.yfact[
kk] =
g.yfact[
k - 1];
254 g.minCh[
kk] =
g.minCh[
k - 1];
256 auto detx = 1.f /
g.xfact[0];
257 auto dety = 1.f /
g.yfact[0];
263 float ys = 8.f - 4.f;
271 cp.cotbeta = std::copysign(ys * (buffer_->commonParams().thePitchY / (8.f *
thickness)), aveCB);
272 errorFromTemplates(
p,
cp, 20000.
f);
273 g.sigmay[
iy] = toMicron(
cp.sigmay);
274 LogDebug(
"PixelCPEFastParamsHost") <<
"sigmax/sigmay " <<
i <<
' ' << (ys + 4.f) / 8.
f <<
' ' <<
cp.cotalpha
275 <<
'/' <<
cp.cotbeta <<
' ' << 10000.f *
cp.sigmax <<
'/' <<
int(
g.sigmay[
iy])
280 constexpr int numberOfModulesInLadder = TrackerTraits::numberOfModulesInLadder;
281 constexpr int numberOfLaddersInBarrel = TrackerTraits::numberOfLaddersInBarrel;
282 constexpr int numberOfModulesInBarrel = TrackerTraits::numberOfModulesInBarrel;
284 constexpr float ladderFactor = 1.f /
float(numberOfModulesInLadder);
286 constexpr int firstEndcapPos = TrackerTraits::firstEndcapPos;
287 constexpr int firstEndcapNeg = TrackerTraits::firstEndcapNeg;
291 auto& aveGeom = buffer_->averageGeometry();
293 for (
int im = 0, nm = numberOfModulesInBarrel; im < nm; ++im) {
294 auto const&
g = buffer_->detParams(im);
295 il = im / numberOfModulesInLadder;
296 assert(il <
int(numberOfLaddersInBarrel));
297 auto z =
g.frame.z();
298 aveGeom.ladderZ[il] += ladderFactor *
z;
299 aveGeom.ladderMinZ[il] =
std::min(aveGeom.ladderMinZ[il],
z);
300 aveGeom.ladderMaxZ[il] =
std::max(aveGeom.ladderMaxZ[il],
z);
301 aveGeom.ladderX[il] += ladderFactor *
g.frame.x();
302 aveGeom.ladderY[il] += ladderFactor *
g.frame.y();
303 aveGeom.ladderR[il] += ladderFactor *
sqrt(
g.frame.x() *
g.frame.x() +
g.frame.y() *
g.frame.y());
305 assert(il + 1 ==
int(numberOfLaddersInBarrel));
307 constexpr float moduleLength = TrackerTraits::moduleLength;
309 for (
int il = 0, nl = numberOfLaddersInBarrel; il < nl; ++il) {
310 aveGeom.ladderMinZ[il] -= (0.5f * moduleLength - module_tolerance);
311 aveGeom.ladderMaxZ[il] += (0.5f * moduleLength - module_tolerance);
316 auto const&
g = buffer_->detParams(im);
317 aveGeom.endCapZ[0] =
std::max(aveGeom.endCapZ[0],
g.frame.z());
320 auto const&
g = buffer_->detParams(im);
321 aveGeom.endCapZ[1] =
std::min(aveGeom.endCapZ[1],
g.frame.z());
324 aveGeom.endCapZ[0] -= TrackerTraits::endcapCorrection;
325 aveGeom.endCapZ[1] += TrackerTraits::endcapCorrection;
327 for (
int jl = 0, nl = numberOfLaddersInBarrel; jl < nl; ++jl) {
328 LogDebug(
"PixelCPEFastParamsHost") << jl <<
':' << aveGeom.ladderR[jl] <<
'/' 329 <<
std::sqrt(aveGeom.ladderX[jl] * aveGeom.ladderX[jl] +
330 aveGeom.ladderY[jl] * aveGeom.ladderY[jl])
331 <<
',' << aveGeom.ladderZ[jl] <<
',' << aveGeom.ladderMinZ[jl] <<
',' 332 << aveGeom.ladderMaxZ[jl] <<
'\n';
334 LogDebug(
"PixelCPEFastParamsHost") << aveGeom.endCapZ[0] <<
' ' << aveGeom.endCapZ[1];
335 #endif // EDM_ML_DEBUG 339 memcpy(buffer_->layerGeometry().layerStart,
342 memcpy(buffer_->layerGeometry().layer,
343 pixelTopology::layer<TrackerTraits>.data(),
344 pixelTopology::layer<TrackerTraits>.size());
345 buffer_->layerGeometry().maxModuleStride = pixelTopology::maxModuleStride<TrackerTraits>;
348 template <
typename TrackerTraits>
352 float locBz = theDetParam.
bz;
353 float locBx = theDetParam.
bx;
354 LogDebug(
"PixelCPEFastParamsHost") <<
"PixelCPEFastParamsHost::localPosition(...) : locBz = " << locBz;
358 theClusterParam.
sigmay = -999.9;
359 theClusterParam.
sigmax = -999.9;
360 theClusterParam.
sy1 = -999.9;
361 theClusterParam.
sy2 = -999.9;
362 theClusterParam.
sx1 = -999.9;
363 theClusterParam.
sx2 = -999.9;
370 theClusterParam.
qBin_ = gtempl.
qbin(gtemplID,
377 theClusterParam.
pixmx,
404 theClusterParam.
qBin_ = 0.0f;
412 template <
typename TrackerTraits>
417 if (useErrorsFromTemplates_) {
418 errorFromTemplates(theDetParam, theClusterParam, theClusterParam.
theCluster->
charge());
420 theClusterParam.
qBin_ = 0;
427 collect_edge_charges(theClusterParam, q_f_X, q_l_X, q_f_Y, q_l_Y, useErrorsFromTemplates_ && truncatePixelCharge_);
445 pixelCPEforDevice::position<TrackerTraits>(buffer_->commonParams(), buffer_->detParams(ind),
cp, 0);
446 auto xPos =
cp.xpos[0];
447 auto yPos =
cp.ypos[0];
450 pixelCPEforDevice::errorFromDB<TrackerTraits>(buffer_->commonParams(), buffer_->detParams(ind),
cp, 0);
451 theClusterParam.
sigmax =
cp.xerr[0];
452 theClusterParam.
sigmay =
cp.yerr[0];
454 LogDebug(
"PixelCPEFastParamsHost") <<
" in PixelCPEFastParamsHost:localPosition - pos = " << xPos <<
" " << yPos
455 <<
" size " <<
cp.maxRow[0] -
cp.minRow[0] <<
' ' <<
cp.maxCol[0] -
cp.minCol[0];
467 template <
typename TrackerTraits>
472 auto xerr = theClusterParam.
sigmax;
473 auto yerr = theClusterParam.
sigmay;
475 LogDebug(
"PixelCPEFastParamsHost") <<
" errors " << xerr <<
" " << yerr;
477 auto xerr_sq = xerr * xerr;
478 auto yerr_sq = yerr * yerr;
483 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