17 #include "boost/multi_array.hpp"
23 constexpr
float micronsToCm = 1.0e-4;
24 const bool MYDEBUG =
false;
39 LogDebug(
"PixelCPEGeneric") <<
" constructing a generic algorithm for ideal pixel detector.\n"
67 <<
"\nERROR: useErrorsFromTemplates_ is set to False in PixelCPEGeneric_cfi.py. "
68 <<
" In this case it does not make sense to set any of the following to True: "
69 <<
" truncatePixelCharge_, IrradiationBiasCorrection_, DoCosmics_, LoadTemplatesFromDB_ !!!"
78 <<
"ERROR: GenErrors not filled correctly. Check the sqlite file. Using SiPixelTemplateDBObject version "
79 << (*genErrorDBObject_).version();
81 cout <<
"Loaded genErrorDBObject v" << (*genErrorDBObject_).version() << endl;
85 <<
"ERROR: GenErrors not loaded correctly from text file. Reconstruction will fail.";
90 cout <<
" Use simple parametrised errors " << endl;
94 cout <<
"From PixelCPEGeneric::PixelCPEGeneric(...)" << endl;
109 ClusterParamGeneric& theClusterParam = static_cast<ClusterParamGeneric&>(theClusterParamBase);
120 if (useErrorsFromTemplates_) {
122 float locBz = theDetParam.
bz;
123 float locBx = theDetParam.
bx;
126 theClusterParam.
pixmx = -999;
127 theClusterParam.
sigmay = -999.9;
128 theClusterParam.
deltay = -999.9;
129 theClusterParam.
sigmax = -999.9;
130 theClusterParam.
deltax = -999.9;
131 theClusterParam.
sy1 = -999.9;
132 theClusterParam.
dy1 = -999.9;
133 theClusterParam.
sy2 = -999.9;
134 theClusterParam.
dy2 = -999.9;
135 theClusterParam.
sx1 = -999.9;
136 theClusterParam.
dx1 = -999.9;
137 theClusterParam.
sx2 = -999.9;
138 theClusterParam.
dx2 = -999.9;
146 theClusterParam.
qBin_ = gtempl.
qbin(gtemplID_,
152 IrradiationBiasCorrection_,
153 theClusterParam.
pixmx,
165 theClusterParam.
dx2);
169 bool useLAWidthFromGenError =
false;
170 if (useLAWidthFromGenError) {
171 chargeWidthX = (-micronsToCm * gtempl.
lorxwidth());
172 chargeWidthY = (-micronsToCm * gtempl.
lorywidth());
174 cout <<
" redefine la width (gen-error) " << chargeWidthX <<
" " << chargeWidthY << endl;
177 cout <<
" GenError: " << gtemplID_ << endl;
180 theClusterParam.
deltax = theClusterParam.
deltax * micronsToCm;
181 theClusterParam.
dx1 = theClusterParam.
dx1 * micronsToCm;
182 theClusterParam.
dx2 = theClusterParam.
dx2 * micronsToCm;
184 theClusterParam.
deltay = theClusterParam.
deltay * micronsToCm;
185 theClusterParam.
dy1 = theClusterParam.
dy1 * micronsToCm;
186 theClusterParam.
dy2 = theClusterParam.
dy2 * micronsToCm;
188 theClusterParam.
sigmax = theClusterParam.
sigmax * micronsToCm;
189 theClusterParam.
sx1 = theClusterParam.
sx1 * micronsToCm;
190 theClusterParam.
sx2 = theClusterParam.
sx2 * micronsToCm;
192 theClusterParam.
sigmay = theClusterParam.
sigmay * micronsToCm;
193 theClusterParam.
sy1 = theClusterParam.
sy1 * micronsToCm;
194 theClusterParam.
sy2 = theClusterParam.
sy2 * micronsToCm;
198 theClusterParam.
qBin_ = 0;
205 collect_edge_charges(theClusterParam, q_f_X, q_l_X, q_f_Y, q_l_Y, useErrorsFromTemplates_ && truncatePixelCharge_);
238 cout <<
"\n\t >>> theClusterParam.theCluster->x = " << theClusterParam.
theCluster->
x()
239 <<
"\n\t >>> theClusterParam.theCluster->y = " << theClusterParam.
theCluster->
y()
244 <<
"\n\t >>> meas: inner lower left = " << meas_URcorn_LLpix.
x() <<
"," << meas_URcorn_LLpix.
y()
245 <<
"\n\t >>> meas: inner upper right = " << meas_LLcorn_URpix.x() <<
"," << meas_LLcorn_URpix.y() << endl;
257 cout <<
"\t >>> Generic:: processing X" << endl;
264 local_URcorn_LLpix.x(),
265 local_LLcorn_URpix.
x(),
272 the_eff_charge_cut_lowX,
273 the_eff_charge_cut_highX,
277 xPos = xPos + shiftX;
281 cout <<
"\t >>> Generic:: processing Y" << endl;
288 local_URcorn_LLpix.y(),
289 local_LLcorn_URpix.
y(),
296 the_eff_charge_cut_lowY,
297 the_eff_charge_cut_highY,
301 yPos = yPos + shiftY;
304 if (IrradiationBiasCorrection_) {
313 xPos -= theClusterParam.
dx1;
315 xPos -= theClusterParam.
dx2;
319 xPos -= theClusterParam.
deltax;
330 yPos -= theClusterParam.
dy1;
332 yPos -= theClusterParam.
dy2;
336 yPos -= theClusterParam.
deltay;
354 ClusterParamGeneric& theClusterParam = static_cast<ClusterParamGeneric&>(theClusterParamBase);
358 bool edgex, edgey, bigInX, bigInY;
359 int maxPixelCol, maxPixelRow, minPixelCol, minPixelRow;
362 initializeLocalErrorVariables(xerr,
378 useErrorsFromTemplates_ && (!NoTemplateErrorsWhenNoTrkAngles_ || theClusterParam.
with_track_angle);
380 if (
int(sizex) != (maxPixelRow - minPixelRow + 1))
381 LogDebug(
"PixelCPEGeneric") <<
" wrong x" << endl;
382 if (
int(sizey) != (maxPixelCol - minPixelCol + 1))
383 LogDebug(
"PixelCPEGeneric") <<
" wrong y" << endl;
385 LogDebug(
"PixelCPEGeneric") <<
" edge clus " << xerr <<
" " << yerr << endl;
386 if (bigInX || bigInY)
387 LogDebug(
"PixelCPEGeneric") <<
" big " << bigInX <<
" " << bigInY << endl;
389 LogDebug(
"PixelCPEGeneric") <<
" edge " << edgex <<
" " << edgey << endl;
390 LogDebug(
"PixelCPEGeneric") <<
" before if " << useErrorsFromTemplates_ <<
" " << theClusterParam.
qBin_ << endl;
391 if (theClusterParam.
qBin_ == 0)
392 LogDebug(
"PixelCPEGeneric") <<
" qbin 0! " << edgex <<
" " << edgey <<
" " << bigInX <<
" " << bigInY <<
" "
393 << sizex <<
" " << sizey << endl;
396 setXYErrors(xerr, yerr, edgex, edgey, sizex, sizey, bigInX, bigInY, useTempErrors, theDetParam, theClusterParam);
398 if (!useTempErrors) {
399 LogDebug(
"PixelCPEGeneric") <<
"Track angles are not known.\n"
400 <<
"Default angle estimation which assumes track from PV (0,0,0) does not work.";
407 for (
int irow = 0; irow < 7; ++irow) {
412 for (
int icol = 0; icol < 21; ++icol) {
423 throw cms::Exception(
"PixelCPEGeneric::localError") <<
"\nERROR: Negative pixel error xerr = " << xerr <<
"\n\n";
426 throw cms::Exception(
"PixelCPEGeneric::localError") <<
"\nERROR: Negative pixel error yerr = " << yerr <<
"\n\n";
429 LogDebug(
"PixelCPEGeneric") <<
" errors " << xerr <<
" " << yerr << endl;
430 if (theClusterParam.
qBin_ == 0)
431 LogDebug(
"PixelCPEGeneric") <<
" qbin 0 " << xerr <<
" " << yerr << endl;
433 auto xerr_sq = xerr * xerr;
434 auto yerr_sq = yerr * yerr;
441 desc.add<
double>(
"eff_charge_cut_highX", 1.0);
442 desc.add<
double>(
"eff_charge_cut_highY", 1.0);
443 desc.add<
double>(
"eff_charge_cut_lowX", 0.0);
444 desc.add<
double>(
"eff_charge_cut_lowY", 0.0);
445 desc.add<
double>(
"size_cutX", 3.0);
446 desc.add<
double>(
"size_cutY", 3.0);
447 desc.add<
double>(
"EdgeClusterErrorX", 50.0);
448 desc.add<
double>(
"EdgeClusterErrorY", 85.0);
449 desc.add<
bool>(
"inflate_errors",
false);
450 desc.add<
bool>(
"inflate_all_errors_no_trk_angle",
false);
451 desc.add<
bool>(
"NoTemplateErrorsWhenNoTrkAngles",
false);
452 desc.add<
bool>(
"UseErrorsFromTemplates",
true);
453 desc.add<
bool>(
"TruncatePixelCharge",
true);
454 desc.add<
bool>(
"IrradiationBiasCorrection",
false);
455 desc.add<
bool>(
"DoCosmics",
false);
456 desc.add<
bool>(
"Upgrade",
false);
457 desc.add<
bool>(
"SmallPitch",
false);