17 #include "boost/multi_array.hpp"
23 constexpr
float micronsToCm = 1.0e-4;
24 const bool MYDEBUG =
false;
37 :
PixelCPEBase(conf,
mag,
geom, ttopo, lorentzAngle, genErrorDBObject, nullptr, lorentzAngleWidth, 0) {
39 LogDebug(
"PixelCPEGeneric") <<
" constructing a generic algorithm for ideal pixel detector.\n"
72 <<
"\nERROR: UseErrorsFromTemplates_ is set to False in PixelCPEGeneric_cfi.py. "
73 <<
" In this case it does not make sense to set any of the following to True: "
74 <<
" TruncatePixelCharge_, IrradiationBiasCorrection_, DoCosmics_, LoadTemplatesFromDB_ !!!"
83 <<
"ERROR: GenErrors not filled correctly. Check the sqlite file. Using SiPixelTemplateDBObject version "
84 << (*genErrorDBObject_).version();
86 cout <<
"Loaded genErrorDBObject v" << (*genErrorDBObject_).version() << endl;
90 <<
"ERROR: GenErrors not loaded correctly from text file. Reconstruction will fail.";
95 cout <<
" Use simple parametrised errors " << endl;
103 yerr_barrel_l1_ = {0.00375, 0.00230, 0.00250, 0.00250, 0.00230, 0.00230, 0.00210, 0.00210, 0.00240};
107 yerr_barrel_ln_ = {0.00375, 0.00230, 0.00250, 0.00250, 0.00230, 0.00230, 0.00210, 0.00210, 0.00240};
126 yerr_barrel_l1_ = {0.00199, 0.00136, 0.0015, 0.00153, 0.00152, 0.00171, 0.00154, 0.00157, 0.00154};
137 cout <<
"From PixelCPEGeneric::PixelCPEGeneric(...)" << endl;
147 return std::make_unique<ClusterParamGeneric>(
cl);
156 ClusterParamGeneric& theClusterParam = static_cast<ClusterParamGeneric&>(theClusterParamBase);
167 if (UseErrorsFromTemplates_) {
169 float locBz = theDetParam.
bz;
170 float locBx = theDetParam.
bx;
173 theClusterParam.
pixmx = -999;
174 theClusterParam.
sigmay = -999.9;
175 theClusterParam.
deltay = -999.9;
176 theClusterParam.
sigmax = -999.9;
177 theClusterParam.
deltax = -999.9;
178 theClusterParam.
sy1 = -999.9;
179 theClusterParam.
dy1 = -999.9;
180 theClusterParam.
sy2 = -999.9;
181 theClusterParam.
dy2 = -999.9;
182 theClusterParam.
sx1 = -999.9;
183 theClusterParam.
dx1 = -999.9;
184 theClusterParam.
sx2 = -999.9;
185 theClusterParam.
dx2 = -999.9;
193 theClusterParam.
qBin_ = gtempl.
qbin(gtemplID_,
199 IrradiationBiasCorrection_,
200 theClusterParam.
pixmx,
212 theClusterParam.
dx2);
216 bool useLAWidthFromGenError =
false;
217 if (useLAWidthFromGenError) {
218 chargeWidthX = (-micronsToCm * gtempl.
lorxwidth());
219 chargeWidthY = (-micronsToCm * gtempl.
lorywidth());
221 cout <<
" redefine la width (gen-error) " << chargeWidthX <<
" " << chargeWidthY << endl;
224 cout <<
" GenError: " << gtemplID_ << endl;
227 theClusterParam.
deltax = theClusterParam.
deltax * micronsToCm;
228 theClusterParam.
dx1 = theClusterParam.
dx1 * micronsToCm;
229 theClusterParam.
dx2 = theClusterParam.
dx2 * micronsToCm;
231 theClusterParam.
deltay = theClusterParam.
deltay * micronsToCm;
232 theClusterParam.
dy1 = theClusterParam.
dy1 * micronsToCm;
233 theClusterParam.
dy2 = theClusterParam.
dy2 * micronsToCm;
235 theClusterParam.
sigmax = theClusterParam.
sigmax * micronsToCm;
236 theClusterParam.
sx1 = theClusterParam.
sx1 * micronsToCm;
237 theClusterParam.
sx2 = theClusterParam.
sx2 * micronsToCm;
239 theClusterParam.
sigmay = theClusterParam.
sigmay * micronsToCm;
240 theClusterParam.
sy1 = theClusterParam.
sy1 * micronsToCm;
241 theClusterParam.
sy2 = theClusterParam.
sy2 * micronsToCm;
245 theClusterParam.
qBin_ = 0;
252 collect_edge_charges(theClusterParam, q_f_X, q_l_X, q_f_Y, q_l_Y);
285 cout <<
"\n\t >>> theClusterParam.theCluster->x = " << theClusterParam.
theCluster->
x()
286 <<
"\n\t >>> theClusterParam.theCluster->y = " << theClusterParam.
theCluster->
y()
291 <<
"\n\t >>> meas: inner lower left = " << meas_URcorn_LLpix.
x() <<
"," << meas_URcorn_LLpix.
y()
292 <<
"\n\t >>> meas: inner upper right = " << meas_LLcorn_URpix.x() <<
"," << meas_LLcorn_URpix.y() << endl;
304 cout <<
"\t >>> Generic:: processing X" << endl;
311 local_URcorn_LLpix.x(),
312 local_LLcorn_URpix.
x(),
319 the_eff_charge_cut_lowX,
320 the_eff_charge_cut_highX,
324 xPos = xPos + shiftX;
328 cout <<
"\t >>> Generic:: processing Y" << endl;
335 local_URcorn_LLpix.y(),
336 local_LLcorn_URpix.
y(),
343 the_eff_charge_cut_lowY,
344 the_eff_charge_cut_highY,
348 yPos = yPos + shiftY;
351 if (IrradiationBiasCorrection_) {
360 xPos -= theClusterParam.
dx1;
362 xPos -= theClusterParam.
dx2;
366 xPos -= theClusterParam.
deltax;
377 yPos -= theClusterParam.
dy1;
379 yPos -= theClusterParam.
dy2;
383 yPos -= theClusterParam.
deltay;
406 ClusterParamGeneric& theClusterParam = static_cast<ClusterParamGeneric&>(theClusterParamBase);
420 for (
int i = 0;
i != isize; ++
i) {
423 int pix_adc =
pixel.adc;
424 if (UseErrorsFromTemplates_ && TruncatePixelCharge_)
450 ClusterParamGeneric& theClusterParam = static_cast<ClusterParamGeneric&>(theClusterParamBase);
452 const bool localPrint =
false;
455 float xerr = EdgeClusterErrorX_ * micronsToCm;
456 float yerr = EdgeClusterErrorY_ * micronsToCm;
472 if (
int(sizex) != (maxPixelRow - minPixelRow + 1))
473 cout <<
" wrong x" << endl;
474 if (
int(sizey) != (maxPixelCol - minPixelCol + 1))
475 cout <<
" wrong y" << endl;
483 cout <<
" edge clus " << xerr <<
" " << yerr << endl;
484 if (bigInX || bigInY)
485 cout <<
" big " << bigInX <<
" " << bigInY << endl;
487 cout <<
" edge " << edgex <<
" " << edgey << endl;
488 cout <<
" before if " << UseErrorsFromTemplates_ <<
" " << theClusterParam.
qBin_ << endl;
489 if (theClusterParam.
qBin_ == 0)
490 cout <<
" qbin 0! " << edgex <<
" " << edgey <<
" " << bigInX <<
" " << bigInY <<
" " << sizex <<
" " << sizey
495 UseErrorsFromTemplates_ && (!NoTemplateErrorsWhenNoTrkAngles_ || theClusterParam.
with_track_angle);
497 if LIKELY (useTempErrors) {
504 xerr = theClusterParam.
sx1;
506 xerr = theClusterParam.
sx2;
509 xerr = theClusterParam.
sigmax;
516 yerr = theClusterParam.
sy1;
518 yerr = theClusterParam.
sy2;
521 yerr = theClusterParam.
sigmay;
526 cout <<
" in if " << edgex <<
" " << edgey <<
" " << sizex <<
" " << sizey << endl;
527 cout <<
" errors " << xerr <<
" " << yerr <<
" " << theClusterParam.
sx1 <<
" " << theClusterParam.
sx2 <<
" "
528 << theClusterParam.
sigmax << endl;
539 int layer = ttopo_.layer(
id);
542 if (sizex <= xerr_barrel_l1_.size())
543 xerr = xerr_barrel_l1_[sizex - 1];
545 xerr = xerr_barrel_l1_def_;
549 if (sizey <= yerr_barrel_l1_.size())
550 yerr = yerr_barrel_l1_[sizey - 1];
552 yerr = yerr_barrel_l1_def_;
556 if (sizex <= xerr_barrel_ln_.size())
557 xerr = xerr_barrel_ln_[sizex - 1];
559 xerr = xerr_barrel_ln_def_;
563 if (sizey <= yerr_barrel_ln_.size())
564 yerr = yerr_barrel_ln_[sizey - 1];
566 yerr = yerr_barrel_ln_def_;
573 if (sizex <= xerr_endcap_.size())
574 xerr = xerr_endcap_[sizex - 1];
576 xerr = xerr_endcap_def_;
580 if (sizey <= yerr_endcap_.size())
581 yerr = yerr_endcap_[sizey - 1];
583 yerr = yerr_endcap_def_;
592 for (
int irow = 0; irow < 7; ++irow) {
597 for (
int icol = 0; icol < 21; ++icol) {
611 throw cms::Exception(
"PixelCPEGeneric::localError") <<
"\nERROR: Negative pixel error xerr = " << xerr <<
"\n\n";
614 throw cms::Exception(
"PixelCPEGeneric::localError") <<
"\nERROR: Negative pixel error yerr = " << yerr <<
"\n\n";
622 auto xerr_sq = xerr * xerr;
623 auto yerr_sq = yerr * yerr;
629 desc.add<
double>(
"eff_charge_cut_highX", 1.0);
630 desc.add<
double>(
"eff_charge_cut_highY", 1.0);
631 desc.add<
double>(
"eff_charge_cut_lowX", 0.0);
632 desc.add<
double>(
"eff_charge_cut_lowY", 0.0);
633 desc.add<
double>(
"size_cutX", 3.0);
634 desc.add<
double>(
"size_cutY", 3.0);
635 desc.add<
double>(
"EdgeClusterErrorX", 50.0);
636 desc.add<
double>(
"EdgeClusterErrorY", 85.0);
637 desc.add<
bool>(
"inflate_errors",
false);
638 desc.add<
bool>(
"inflate_all_errors_no_trk_angle",
false);
639 desc.add<
bool>(
"NoTemplateErrorsWhenNoTrkAngles",
false);
640 desc.add<
bool>(
"UseErrorsFromTemplates",
true);
641 desc.add<
bool>(
"TruncatePixelCharge",
true);
642 desc.add<
bool>(
"IrradiationBiasCorrection",
false);
643 desc.add<
bool>(
"DoCosmics",
false);
644 desc.add<
bool>(
"Upgrade",
false);
645 desc.add<
bool>(
"SmallPitch",
false);