forked from cms-sw/cmssw
-
Notifications
You must be signed in to change notification settings - Fork 5
/
PixelCPEFast.cc
561 lines (481 loc) · 22.7 KB
/
PixelCPEFast.cc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
#include <cuda_runtime.h>
#include "CondFormats/SiPixelTransient/interface/SiPixelTemplate.h"
#include "DataFormats/DetId/interface/DetId.h"
#include "FWCore/MessageLogger/interface/MessageLogger.h"
#include "Geometry/CommonDetUnit/interface/PixelGeomDetUnit.h"
#include "Geometry/TrackerGeometryBuilder/interface/RectangularPixelTopology.h"
#include "Geometry/TrackerGeometryBuilder/interface/phase1PixelTopology.h"
#include "HeterogeneousCore/CUDAUtilities/interface/cudaCheck.h"
#include "MagneticField/Engine/interface/MagneticField.h"
#include "RecoLocalTracker/SiPixelRecHits/interface/PixelCPEFast.h"
// Services
// this is needed to get errors from templates
namespace {
constexpr float micronsToCm = 1.0e-4;
}
//-----------------------------------------------------------------------------
//! The constructor.
//-----------------------------------------------------------------------------
PixelCPEFast::PixelCPEFast(edm::ParameterSet const& conf,
const MagneticField* mag,
const TrackerGeometry& geom,
const TrackerTopology& ttopo,
const SiPixelLorentzAngle* lorentzAngle,
const SiPixelGenErrorDBObject* genErrorDBObject,
const SiPixelLorentzAngle* lorentzAngleWidth)
: PixelCPEBase(conf, mag, geom, ttopo, lorentzAngle, genErrorDBObject, nullptr, lorentzAngleWidth, 0),
edgeClusterErrorX_(conf.getParameter<double>("EdgeClusterErrorX")),
edgeClusterErrorY_(conf.getParameter<double>("EdgeClusterErrorY")),
useErrorsFromTemplates_(conf.getParameter<bool>("UseErrorsFromTemplates")),
truncatePixelCharge_(conf.getParameter<bool>("TruncatePixelCharge")) {
// Use errors from templates or from GenError
if (useErrorsFromTemplates_) {
if (!SiPixelGenError::pushfile(*genErrorDBObject_, thePixelGenError_))
throw cms::Exception("InvalidCalibrationLoaded")
<< "ERROR: GenErrors not filled correctly. Check the sqlite file. Using SiPixelTemplateDBObject version "
<< (*genErrorDBObject_).version();
}
// Rechit errors in case other, more correct, errors are not vailable
// These are constants. Maybe there is a more efficienct way to store them.
xerr_barrel_l1_ = {0.00115, 0.00120, 0.00088};
xerr_barrel_l1_def_ = 0.01030;
yerr_barrel_l1_ = {0.00375, 0.00230, 0.00250, 0.00250, 0.00230, 0.00230, 0.00210, 0.00210, 0.00240};
yerr_barrel_l1_def_ = 0.00210;
xerr_barrel_ln_ = {0.00115, 0.00120, 0.00088};
xerr_barrel_ln_def_ = 0.01030;
yerr_barrel_ln_ = {0.00375, 0.00230, 0.00250, 0.00250, 0.00230, 0.00230, 0.00210, 0.00210, 0.00240};
yerr_barrel_ln_def_ = 0.00210;
xerr_endcap_ = {0.0020, 0.0020};
xerr_endcap_def_ = 0.0020;
yerr_endcap_ = {0.00210};
yerr_endcap_def_ = 0.00075;
fillParamsForGpu();
cpuData_ = {
&commonParamsGPU_,
detParamsGPU_.data(),
&layerGeometry_,
&averageGeometry_,
};
}
const pixelCPEforGPU::ParamsOnGPU* PixelCPEFast::getGPUProductAsync(cudaStream_t cudaStream) const {
const auto& data = gpuData_.dataForCurrentDeviceAsync(cudaStream, [this](GPUData& data, cudaStream_t stream) {
// and now copy to device...
cudaCheck(cudaMalloc((void**)&data.paramsOnGPU_h.m_commonParams, sizeof(pixelCPEforGPU::CommonParams)));
cudaCheck(cudaMalloc((void**)&data.paramsOnGPU_h.m_detParams,
this->detParamsGPU_.size() * sizeof(pixelCPEforGPU::DetParams)));
cudaCheck(cudaMalloc((void**)&data.paramsOnGPU_h.m_averageGeometry, sizeof(pixelCPEforGPU::AverageGeometry)));
cudaCheck(cudaMalloc((void**)&data.paramsOnGPU_h.m_layerGeometry, sizeof(pixelCPEforGPU::LayerGeometry)));
cudaCheck(cudaMalloc((void**)&data.paramsOnGPU_d, sizeof(pixelCPEforGPU::ParamsOnGPU)));
cudaCheck(cudaMemcpyAsync(
data.paramsOnGPU_d, &data.paramsOnGPU_h, sizeof(pixelCPEforGPU::ParamsOnGPU), cudaMemcpyDefault, stream));
cudaCheck(cudaMemcpyAsync((void*)data.paramsOnGPU_h.m_commonParams,
&this->commonParamsGPU_,
sizeof(pixelCPEforGPU::CommonParams),
cudaMemcpyDefault,
stream));
cudaCheck(cudaMemcpyAsync((void*)data.paramsOnGPU_h.m_averageGeometry,
&this->averageGeometry_,
sizeof(pixelCPEforGPU::AverageGeometry),
cudaMemcpyDefault,
stream));
cudaCheck(cudaMemcpyAsync((void*)data.paramsOnGPU_h.m_layerGeometry,
&this->layerGeometry_,
sizeof(pixelCPEforGPU::LayerGeometry),
cudaMemcpyDefault,
stream));
cudaCheck(cudaMemcpyAsync((void*)data.paramsOnGPU_h.m_detParams,
this->detParamsGPU_.data(),
this->detParamsGPU_.size() * sizeof(pixelCPEforGPU::DetParams),
cudaMemcpyDefault,
stream));
});
return data.paramsOnGPU_d;
}
void PixelCPEFast::fillParamsForGpu() {
commonParamsGPU_.theThicknessB = m_DetParams.front().theThickness;
commonParamsGPU_.theThicknessE = m_DetParams.back().theThickness;
commonParamsGPU_.thePitchX = m_DetParams[0].thePitchX;
commonParamsGPU_.thePitchY = m_DetParams[0].thePitchY;
LogDebug("PixelCPEFast") << "pitch & thickness " << commonParamsGPU_.thePitchX << ' ' << commonParamsGPU_.thePitchY
<< " " << commonParamsGPU_.theThicknessB << ' ' << commonParamsGPU_.theThicknessE;
// zero average geometry
memset(&averageGeometry_, 0, sizeof(pixelCPEforGPU::AverageGeometry));
uint32_t oldLayer = 0;
uint32_t oldLadder = 0;
float rl = 0;
float zl = 0;
float miz = 90, mxz = 0;
float pl = 0;
int nl = 0;
detParamsGPU_.resize(m_DetParams.size());
for (auto i = 0U; i < m_DetParams.size(); ++i) {
auto& p = m_DetParams[i];
auto& g = detParamsGPU_[i];
assert(p.theDet->index() == int(i));
assert(commonParamsGPU_.thePitchY == p.thePitchY);
assert(commonParamsGPU_.thePitchX == p.thePitchX);
g.isBarrel = GeomDetEnumerators::isBarrel(p.thePart);
g.isPosZ = p.theDet->surface().position().z() > 0;
g.layer = ttopo_.layer(p.theDet->geographicalId());
g.index = i; // better be!
g.rawId = p.theDet->geographicalId();
assert((g.isBarrel ? commonParamsGPU_.theThicknessB : commonParamsGPU_.theThicknessE) == p.theThickness);
auto ladder = ttopo_.pxbLadder(p.theDet->geographicalId());
if (oldLayer != g.layer) {
oldLayer = g.layer;
LogDebug("PixelCPEFast") << "new layer at " << i << (g.isBarrel ? " B " : (g.isPosZ ? " E+ " : " E- "))
<< g.layer << " starting at " << g.rawId << '\n'
<< "old layer had " << nl << " ladders";
nl = 0;
}
if (oldLadder != ladder) {
oldLadder = ladder;
LogDebug("PixelCPEFast") << "new ladder at " << i << (g.isBarrel ? " B " : (g.isPosZ ? " E+ " : " E- "))
<< ladder << " starting at " << g.rawId << '\n'
<< "old ladder ave z,r,p mz " << zl / 8.f << " " << rl / 8.f << " " << pl / 8.f << ' '
<< miz << ' ' << mxz;
rl = 0;
zl = 0;
pl = 0;
miz = 90;
mxz = 0;
nl++;
}
g.shiftX = 0.5f * p.lorentzShiftInCmX;
g.shiftY = 0.5f * p.lorentzShiftInCmY;
g.chargeWidthX = p.lorentzShiftInCmX * p.widthLAFractionX;
g.chargeWidthY = p.lorentzShiftInCmY * p.widthLAFractionY;
g.x0 = p.theOrigin.x();
g.y0 = p.theOrigin.y();
g.z0 = p.theOrigin.z();
auto vv = p.theDet->surface().position();
auto rr = pixelCPEforGPU::Rotation(p.theDet->surface().rotation());
g.frame = pixelCPEforGPU::Frame(vv.x(), vv.y(), vv.z(), rr);
zl += vv.z();
miz = std::min(miz, std::abs(vv.z()));
mxz = std::max(mxz, std::abs(vv.z()));
rl += vv.perp();
pl += vv.phi(); // (not obvious)
// errors .....
ClusterParamGeneric cp;
auto gvx = p.theOrigin.x() + 40.f * commonParamsGPU_.thePitchX;
auto gvy = p.theOrigin.y();
auto gvz = 1.f / p.theOrigin.z();
//--- Note that the normalization is not required as only the ratio used
// calculate angles
cp.cotalpha = gvx * gvz;
cp.cotbeta = gvy * gvz;
cp.with_track_angle = false;
auto lape = p.theDet->localAlignmentError();
if (lape.invalid())
lape = LocalError(); // zero....
#ifdef EDM_ML_DEBUG
auto m = 10000.f;
for (float qclus = 15000; qclus < 35000; qclus += 15000) {
errorFromTemplates(p, cp, qclus);
LogDebug("PixelCPEFast") << i << ' ' << qclus << ' ' << cp.pixmx << ' ' << m * cp.sigmax << ' ' << m * cp.sx1
<< ' ' << m * cp.sx2 << ' ' << m * cp.sigmay << ' ' << m * cp.sy1 << ' ' << m * cp.sy2;
}
LogDebug("PixelCPEFast") << i << ' ' << m * std::sqrt(lape.xx()) << ' ' << m * std::sqrt(lape.yy());
#endif // EDM_ML_DEBUG
errorFromTemplates(p, cp, 20000.f);
g.pixmx = std::max(0, cp.pixmx);
g.sx[0] = cp.sigmax;
g.sx[1] = cp.sx1;
g.sx[2] = cp.sx2;
g.sy[0] = cp.sigmay;
g.sy[1] = cp.sy1;
g.sy[2] = cp.sy2;
for (int i = 0; i < 3; ++i) {
g.sx[i] = std::sqrt(g.sx[i] * g.sx[i] + lape.xx());
g.sy[i] = std::sqrt(g.sy[i] * g.sy[i] + lape.yy());
}
}
// compute ladder baricenter (only in global z) for the barrel
auto& aveGeom = averageGeometry_;
int il = 0;
for (int im = 0, nm = phase1PixelTopology::numberOfModulesInBarrel; im < nm; ++im) {
auto const& g = detParamsGPU_[im];
il = im / 8;
assert(il < int(phase1PixelTopology::numberOfLaddersInBarrel));
auto z = g.frame.z();
aveGeom.ladderZ[il] += 0.125f * z;
aveGeom.ladderMinZ[il] = std::min(aveGeom.ladderMinZ[il], z);
aveGeom.ladderMaxZ[il] = std::max(aveGeom.ladderMaxZ[il], z);
aveGeom.ladderX[il] += 0.125f * g.frame.x();
aveGeom.ladderY[il] += 0.125f * g.frame.y();
aveGeom.ladderR[il] += 0.125f * sqrt(g.frame.x() * g.frame.x() + g.frame.y() * g.frame.y());
}
assert(il + 1 == int(phase1PixelTopology::numberOfLaddersInBarrel));
// add half_module and tollerance
constexpr float module_length = 6.7f;
constexpr float module_tolerance = 0.2f;
for (int il = 0, nl = phase1PixelTopology::numberOfLaddersInBarrel; il < nl; ++il) {
aveGeom.ladderMinZ[il] -= (0.5f * module_length - module_tolerance);
aveGeom.ladderMaxZ[il] += (0.5f * module_length - module_tolerance);
}
// compute "max z" for first layer in endcap (should we restrict to the outermost ring?)
for (auto im = phase1PixelTopology::layerStart[4]; im < phase1PixelTopology::layerStart[5]; ++im) {
auto const& g = detParamsGPU_[im];
aveGeom.endCapZ[0] = std::max(aveGeom.endCapZ[0], g.frame.z());
}
for (auto im = phase1PixelTopology::layerStart[7]; im < phase1PixelTopology::layerStart[8]; ++im) {
auto const& g = detParamsGPU_[im];
aveGeom.endCapZ[1] = std::min(aveGeom.endCapZ[1], g.frame.z());
}
// correct for outer ring being closer
aveGeom.endCapZ[0] -= 1.5f;
aveGeom.endCapZ[1] += 1.5f;
#ifdef EDM_ML_DEBUG
for (int jl = 0, nl = phase1PixelTopology::numberOfLaddersInBarrel; jl < nl; ++jl) {
LogDebug("PixelCPEFast") << jl << ':' << aveGeom.ladderR[jl] << '/'
<< std::sqrt(aveGeom.ladderX[jl] * aveGeom.ladderX[jl] +
aveGeom.ladderY[jl] * aveGeom.ladderY[jl])
<< ',' << aveGeom.ladderZ[jl] << ',' << aveGeom.ladderMinZ[jl] << ','
<< aveGeom.ladderMaxZ[jl] << '\n';
}
LogDebug("PixelCPEFast") << aveGeom.endCapZ[0] << ' ' << aveGeom.endCapZ[1];
#endif // EDM_ML_DEBUG
// fill Layer and ladders geometry
memcpy(layerGeometry_.layerStart, phase1PixelTopology::layerStart, sizeof(phase1PixelTopology::layerStart));
memcpy(layerGeometry_.layer, phase1PixelTopology::layer.data(), phase1PixelTopology::layer.size());
}
PixelCPEFast::GPUData::~GPUData() {
if (paramsOnGPU_d != nullptr) {
cudaFree((void*)paramsOnGPU_h.m_commonParams);
cudaFree((void*)paramsOnGPU_h.m_detParams);
cudaFree((void*)paramsOnGPU_h.m_averageGeometry);
cudaFree((void*)paramsOnGPU_h.m_layerGeometry);
cudaFree(paramsOnGPU_d);
}
}
std::unique_ptr<PixelCPEBase::ClusterParam> PixelCPEFast::createClusterParam(const SiPixelCluster& cl) const {
return std::make_unique<ClusterParamGeneric>(cl);
}
void PixelCPEFast::errorFromTemplates(DetParam const& theDetParam,
ClusterParamGeneric& theClusterParam,
float qclus) const {
float locBz = theDetParam.bz;
float locBx = theDetParam.bx;
LogDebug("PixelCPEFast") << "PixelCPEFast::localPosition(...) : locBz = " << locBz;
theClusterParam.pixmx = std::numeric_limits<int>::max(); // max pixel charge for truncation of 2-D cluster
theClusterParam.sigmay = -999.9; // CPE Generic y-error for multi-pixel cluster
theClusterParam.sigmax = -999.9; // CPE Generic x-error for multi-pixel cluster
theClusterParam.sy1 = -999.9; // CPE Generic y-error for single single-pixel
theClusterParam.sy2 = -999.9; // CPE Generic y-error for single double-pixel cluster
theClusterParam.sx1 = -999.9; // CPE Generic x-error for single single-pixel cluster
theClusterParam.sx2 = -999.9; // CPE Generic x-error for single double-pixel cluster
float dummy;
SiPixelGenError gtempl(thePixelGenError_);
int gtemplID = theDetParam.detTemplateId;
theClusterParam.qBin_ = gtempl.qbin(gtemplID,
theClusterParam.cotalpha,
theClusterParam.cotbeta,
locBz,
locBx,
qclus,
false,
theClusterParam.pixmx,
theClusterParam.sigmay,
dummy,
theClusterParam.sigmax,
dummy,
theClusterParam.sy1,
dummy,
theClusterParam.sy2,
dummy,
theClusterParam.sx1,
dummy,
theClusterParam.sx2,
dummy);
theClusterParam.sigmax = theClusterParam.sigmax * micronsToCm;
theClusterParam.sx1 = theClusterParam.sx1 * micronsToCm;
theClusterParam.sx2 = theClusterParam.sx2 * micronsToCm;
theClusterParam.sigmay = theClusterParam.sigmay * micronsToCm;
theClusterParam.sy1 = theClusterParam.sy1 * micronsToCm;
theClusterParam.sy2 = theClusterParam.sy2 * micronsToCm;
}
//-----------------------------------------------------------------------------
//! Hit position in the local frame (in cm). Unlike other CPE's, this
//! one converts everything from the measurement frame (in channel numbers)
//! into the local frame (in centimeters).
//-----------------------------------------------------------------------------
LocalPoint PixelCPEFast::localPosition(DetParam const& theDetParam, ClusterParam& theClusterParamBase) const {
ClusterParamGeneric& theClusterParam = static_cast<ClusterParamGeneric&>(theClusterParamBase);
assert(!theClusterParam.with_track_angle);
if (useErrorsFromTemplates_) {
errorFromTemplates(theDetParam, theClusterParam, theClusterParam.theCluster->charge());
} else {
theClusterParam.qBin_ = 0;
}
int q_f_X; //!< Q of the first pixel in X
int q_l_X; //!< Q of the last pixel in X
int q_f_Y; //!< Q of the first pixel in Y
int q_l_Y; //!< Q of the last pixel in Y
collect_edge_charges(theClusterParam, q_f_X, q_l_X, q_f_Y, q_l_Y, useErrorsFromTemplates_ && truncatePixelCharge_);
// do GPU like ...
pixelCPEforGPU::ClusParams cp;
cp.minRow[0] = theClusterParam.theCluster->minPixelRow();
cp.maxRow[0] = theClusterParam.theCluster->maxPixelRow();
cp.minCol[0] = theClusterParam.theCluster->minPixelCol();
cp.maxCol[0] = theClusterParam.theCluster->maxPixelCol();
cp.q_f_X[0] = q_f_X;
cp.q_l_X[0] = q_l_X;
cp.q_f_Y[0] = q_f_Y;
cp.q_l_Y[0] = q_l_Y;
auto ind = theDetParam.theDet->index();
pixelCPEforGPU::position(commonParamsGPU_, detParamsGPU_[ind], cp, 0);
auto xPos = cp.xpos[0];
auto yPos = cp.ypos[0];
LogDebug("PixelCPEFast") << " in PixelCPEFast:localPosition - pos = " << xPos << " " << yPos << " size "
<< cp.maxRow[0] - cp.minRow[0] << ' ' << cp.maxCol[0] - cp.minCol[0];
//--- Now put the two together
LocalPoint pos_in_local(xPos, yPos);
return pos_in_local;
}
//-----------------------------------------------------------------------------
//! Collect the edge charges in x and y, in a single pass over the pixel vector.
//! Calculate charge in the first and last pixel projected in x and y
//! and the inner cluster charge, projected in x and y.
//-----------------------------------------------------------------------------
void PixelCPEFast::collect_edge_charges(ClusterParam& theClusterParamBase, //!< input, the cluster
int& q_f_X, //!< output, Q first in X
int& q_l_X, //!< output, Q last in X
int& q_f_Y, //!< output, Q first in Y
int& q_l_Y, //!< output, Q last in Y
bool truncate) {
ClusterParamGeneric& theClusterParam = static_cast<ClusterParamGeneric&>(theClusterParamBase);
// Initialize return variables.
q_f_X = q_l_X = 0;
q_f_Y = q_l_Y = 0;
// Obtain boundaries in index units
int xmin = theClusterParam.theCluster->minPixelRow();
int xmax = theClusterParam.theCluster->maxPixelRow();
int ymin = theClusterParam.theCluster->minPixelCol();
int ymax = theClusterParam.theCluster->maxPixelCol();
// Iterate over the pixels.
int isize = theClusterParam.theCluster->size();
for (int i = 0; i != isize; ++i) {
auto const& pixel = theClusterParam.theCluster->pixel(i);
// ggiurgiu@fnal.gov: add pixel charge truncation
int pix_adc = pixel.adc;
if (truncate)
pix_adc = std::min(pix_adc, theClusterParam.pixmx);
//
// X projection
if (pixel.x == xmin)
q_f_X += pix_adc;
if (pixel.x == xmax)
q_l_X += pix_adc;
//
// Y projection
if (pixel.y == ymin)
q_f_Y += pix_adc;
if (pixel.y == ymax)
q_l_Y += pix_adc;
}
}
//============== INFLATED ERROR AND ERRORS FROM DB BELOW ================
//-------------------------------------------------------------------------
// Hit error in the local frame
//-------------------------------------------------------------------------
LocalError PixelCPEFast::localError(DetParam const& theDetParam, ClusterParam& theClusterParamBase) const {
ClusterParamGeneric& theClusterParam = static_cast<ClusterParamGeneric&>(theClusterParamBase);
// Default errors are the maximum error used for edge clusters.
// These are determined by looking at residuals for edge clusters
float xerr = edgeClusterErrorX_ * micronsToCm;
float yerr = edgeClusterErrorY_ * micronsToCm;
// Find if cluster is at the module edge.
int maxPixelCol = theClusterParam.theCluster->maxPixelCol();
int maxPixelRow = theClusterParam.theCluster->maxPixelRow();
int minPixelCol = theClusterParam.theCluster->minPixelCol();
int minPixelRow = theClusterParam.theCluster->minPixelRow();
bool edgex = phase1PixelTopology::isEdgeX(minPixelRow) | phase1PixelTopology::isEdgeX(maxPixelRow);
bool edgey = phase1PixelTopology::isEdgeY(minPixelCol) | phase1PixelTopology::isEdgeY(maxPixelCol);
unsigned int sizex = theClusterParam.theCluster->sizeX();
unsigned int sizey = theClusterParam.theCluster->sizeY();
// Find if cluster contains double (big) pixels.
bool bigInX = theDetParam.theRecTopol->containsBigPixelInX(minPixelRow, maxPixelRow);
bool bigInY = theDetParam.theRecTopol->containsBigPixelInY(minPixelCol, maxPixelCol);
if (useErrorsFromTemplates_) {
//
// Use template errors
if (!edgex) { // Only use this for non-edge clusters
if (sizex == 1) {
if (!bigInX) {
xerr = theClusterParam.sx1;
} else {
xerr = theClusterParam.sx2;
}
} else {
xerr = theClusterParam.sigmax;
}
}
if (!edgey) { // Only use for non-edge clusters
if (sizey == 1) {
if (!bigInY) {
yerr = theClusterParam.sy1;
} else {
yerr = theClusterParam.sy2;
}
} else {
yerr = theClusterParam.sigmay;
}
}
} else { // simple errors
// This are the simple errors, hardcoded in the code
LogDebug("PixelCPEFast") << "Track angles are not known.\n"
<< "Default angle estimation which assumes track from PV (0,0,0) does not work.";
if (GeomDetEnumerators::isTrackerPixel(theDetParam.thePart)) {
if (GeomDetEnumerators::isBarrel(theDetParam.thePart)) {
DetId id = (theDetParam.theDet->geographicalId());
int layer = ttopo_.layer(id);
if (layer == 1) {
if (!edgex) {
if (sizex <= xerr_barrel_l1_.size())
xerr = xerr_barrel_l1_[sizex - 1];
else
xerr = xerr_barrel_l1_def_;
}
if (!edgey) {
if (sizey <= yerr_barrel_l1_.size())
yerr = yerr_barrel_l1_[sizey - 1];
else
yerr = yerr_barrel_l1_def_;
}
} else { // layer 2,3
if (!edgex) {
if (sizex <= xerr_barrel_ln_.size())
xerr = xerr_barrel_ln_[sizex - 1];
else
xerr = xerr_barrel_ln_def_;
}
if (!edgey) {
if (sizey <= yerr_barrel_ln_.size())
yerr = yerr_barrel_ln_[sizey - 1];
else
yerr = yerr_barrel_ln_def_;
}
}
} else { // EndCap
if (!edgex) {
if (sizex <= xerr_endcap_.size())
xerr = xerr_endcap_[sizex - 1];
else
xerr = xerr_endcap_def_;
}
if (!edgey) {
if (sizey <= yerr_endcap_.size())
yerr = yerr_endcap_[sizey - 1];
else
yerr = yerr_endcap_def_;
}
} // end endcap
}
} // end
LogDebug("PixelCPEFast") << " errors " << xerr << " " << yerr;
auto xerr_sq = xerr * xerr;
auto yerr_sq = yerr * yerr;
return LocalError(xerr_sq, 0, yerr_sq);
}
void PixelCPEFast::fillPSetDescription(edm::ParameterSetDescription& desc) {}