@@ -42,19 +42,17 @@ void PixelCPEFastParamsHost<TrackerTraits>::fillParamsForDevice() {
4242
4343 buffer_->commonParams ().theThicknessB = m_DetParams.front ().theThickness ;
4444 buffer_->commonParams ().theThicknessE = m_DetParams.back ().theThickness ;
45- buffer_->commonParams ().thePitchX = m_DetParams[0 ].thePitchX ;
46- buffer_->commonParams ().thePitchY = m_DetParams[0 ].thePitchY ;
47-
4845 buffer_->commonParams ().numberOfLaddersInBarrel = TrackerTraits::numberOfLaddersInBarrel;
4946
50- LogDebug (" PixelCPEFastParamsHost" ) << " pitch & thickness " << buffer_->commonParams ().thePitchX << ' '
51- << buffer_->commonParams ().thePitchY << " "
52- << buffer_->commonParams ().theThicknessB << ' '
47+ LogDebug (" PixelCPEFastParamsHost" ) << " thickness " << buffer_->commonParams ().theThicknessB << ' '
5348 << buffer_->commonParams ().theThicknessE ;
5449
5550 // zero average geometry
5651 memset (&buffer_->averageGeometry (), 0 , sizeof (pixelTopology::AverageGeometryT<TrackerTraits>));
52+ // zero layer geometry
53+ memset (&buffer_->layerGeometry (), 0 , sizeof (pixelCPEforDevice::LayerGeometryT<TrackerTraits>));
5754
55+ uint32_t nLayers = 0 ;
5856 uint32_t oldLayer = 0 ;
5957 uint32_t oldLadder = 0 ;
6058 float rl = 0 ;
@@ -64,6 +62,7 @@ void PixelCPEFastParamsHost<TrackerTraits>::fillParamsForDevice() {
6462 int nl = 0 ;
6563
6664 assert (m_DetParams.size () <= TrackerTraits::numberOfModules);
65+
6766 for (auto i = 0U ; i < m_DetParams.size (); ++i) {
6867 auto & p = m_DetParams[i];
6968 auto & g = buffer_->detParams (i);
@@ -76,8 +75,6 @@ void PixelCPEFastParamsHost<TrackerTraits>::fillParamsForDevice() {
7675 g.numPixsInModule = g.nRows * g.nCols ;
7776
7877 assert (p.theDet ->index () == int (i));
79- assert (buffer_->commonParams ().thePitchY == p.thePitchY );
80- assert (buffer_->commonParams ().thePitchX == p.thePitchX );
8178
8279 g.isBarrel = GeomDetEnumerators::isBarrel (p.thePart );
8380 g.isPosZ = p.theDet ->surface ().position ().z () > 0 ;
@@ -94,6 +91,10 @@ void PixelCPEFastParamsHost<TrackerTraits>::fillParamsForDevice() {
9491 << g.layer << " starting at " << g.rawId << ' \n '
9592 << " old layer had " << nl << " ladders" ;
9693 nl = 0 ;
94+
95+ assert (nLayers <= TrackerTraits::numberOfLayers);
96+ buffer_->layerGeometry ().layerStart [nLayers] = i;
97+ ++nLayers;
9798 }
9899 if (oldLadder != ladder) {
99100 oldLadder = ladder;
@@ -119,6 +120,9 @@ void PixelCPEFastParamsHost<TrackerTraits>::fillParamsForDevice() {
119120 g.y0 = p.theOrigin .y ();
120121 g.z0 = p.theOrigin .z ();
121122
123+ g.thePitchX = p.thePitchX ;
124+ g.thePitchY = p.thePitchY ;
125+
122126 auto vv = p.theDet ->surface ().position ();
123127 auto rr = pixelCPEforDevice::Rotation (p.theDet ->surface ().rotation ());
124128 g.frame = pixelCPEforDevice::Frame (vv.x (), vv.y (), vv.z (), rr);
@@ -144,7 +148,7 @@ void PixelCPEFastParamsHost<TrackerTraits>::fillParamsForDevice() {
144148 auto toMicron = [&](float x) { return std::min (511 , int (x * 1 .e4f + 0 .5f )); };
145149
146150 // average angle
147- auto gvx = p.theOrigin .x () + 40 .f * buffer_-> commonParams () .thePitchX ;
151+ auto gvx = p.theOrigin .x () + 40 .f * p .thePitchX ;
148152 auto gvy = p.theOrigin .y ();
149153 auto gvz = 1 .f / p.theOrigin .z ();
150154 // --- Note that the normalization is not required as only the ratio used
@@ -177,7 +181,7 @@ void PixelCPEFastParamsHost<TrackerTraits>::fillParamsForDevice() {
177181 // moduleOffsetX is the definition of TrackerTraits::xOffset,
178182 // needs to be calculated because for Phase2 the modules are not uniform
179183 float moduleOffsetX = -(0 .5f * float (g.nRows ) + TrackerTraits::bigPixXCorrection);
180- auto const xoff = moduleOffsetX * buffer_-> commonParams () .thePitchX ;
184+ auto const xoff = moduleOffsetX * g .thePitchX ;
181185
182186 for (int ix = 0 ; ix < pixelCPEforDevice::kNumErrorBins ; ++ix) {
183187 auto x = xoff * (1 .f - (0 .5f + float (ix)) / 8 .f );
@@ -197,11 +201,11 @@ void PixelCPEFastParamsHost<TrackerTraits>::fillParamsForDevice() {
197201 // sample yerr as function of position
198202 // moduleOffsetY is the definition of TrackerTraits::yOffset (removed)
199203 float moduleOffsetY = 0 .5f * float (g.nCols ) + TrackerTraits::bigPixYCorrection;
200- auto const yoff = -moduleOffsetY * buffer_-> commonParams () .thePitchY ;
204+ auto const yoff = -moduleOffsetY * p .thePitchY ;
201205
202206 for (int ix = 0 ; ix < pixelCPEforDevice::kNumErrorBins ; ++ix) {
203207 auto y = yoff * (1 .f - (0 .5f + float (ix)) / 8 .f );
204- auto gvx = p.theOrigin .x () + 40 .f * buffer_-> commonParams () .thePitchY ;
208+ auto gvx = p.theOrigin .x () + 40 .f * p .thePitchY ;
205209 auto gvy = p.theOrigin .y () - y;
206210 auto gvz = 1 .f / p.theOrigin .z ();
207211 cp.cotbeta = gvy * gvz;
@@ -267,8 +271,8 @@ void PixelCPEFastParamsHost<TrackerTraits>::fillParamsForDevice() {
267271 ys += 1 .f ; // first bin 0 is for size 9 (and size is in fixed point 2^3)
268272 if (pixelCPEforDevice::kNumErrorBins - 1 == iy)
269273 ys += 8 .f ; // last bin for "overflow"
270- // cp.cotalpha = ys*(buffer_->commonParams() .thePitchX/(8.f*thickness)); // use this to print sampling in "x" (and comment the line below)
271- cp.cotbeta = std::copysign (ys * (buffer_-> commonParams () .thePitchY / (8 .f * thickness)), aveCB);
274+ // cp.cotalpha = ys*(g .thePitchX/(8.f*thickness)); // use this to print sampling in "x" (and comment the line below)
275+ cp.cotbeta = std::copysign (ys * (g .thePitchY / (8 .f * thickness)), aveCB);
272276 errorFromTemplates (p, cp, 20000 .f );
273277 g.sigmay [iy] = toMicron (cp.sigmay );
274278 LogDebug (" PixelCPEFastParamsHost" ) << " sigmax/sigmay " << i << ' ' << (ys + 4 .f ) / 8 .f << ' ' << cp.cotalpha
@@ -277,6 +281,9 @@ void PixelCPEFastParamsHost<TrackerTraits>::fillParamsForDevice() {
277281 }
278282 } // loop over det
279283
284+ // store last module
285+ buffer_->layerGeometry ().layerStart [nLayers] = m_DetParams.size ();
286+
280287 constexpr int numberOfModulesInLadder = TrackerTraits::numberOfModulesInLadder;
281288 constexpr int numberOfLaddersInBarrel = TrackerTraits::numberOfLaddersInBarrel;
282289 constexpr int numberOfModulesInBarrel = TrackerTraits::numberOfModulesInBarrel;
@@ -334,11 +341,7 @@ void PixelCPEFastParamsHost<TrackerTraits>::fillParamsForDevice() {
334341 LogDebug (" PixelCPEFastParamsHost" ) << aveGeom.endCapZ [0 ] << ' ' << aveGeom.endCapZ [1 ];
335342#endif // EDM_ML_DEBUG
336343
337- // fill Layer and ladders geometry
338- memset (&buffer_->layerGeometry (), 0 , sizeof (pixelCPEforDevice::LayerGeometryT<TrackerTraits>));
339- memcpy (buffer_->layerGeometry ().layerStart ,
340- TrackerTraits::layerStart,
341- sizeof (pixelCPEforDevice::LayerGeometryT<TrackerTraits>::layerStart));
344+ // fill ladders geometry
342345 memcpy (buffer_->layerGeometry ().layer ,
343346 pixelTopology::layer<TrackerTraits>.data (),
344347 pixelTopology::layer<TrackerTraits>.size ());
0 commit comments