17 #include "boost/multi_array.hpp"
23 constexpr
float micronsToCm = 1.0e-4;
36 :
PixelCPEGenericBase(conf, mag, geom, ttopo, lorentzAngle, genErrorDBObject, lorentzAngleWidth) {
38 LogDebug(
"PixelCPEGeneric") <<
" constructing a generic algorithm for ideal pixel detector.\n"
66 <<
"\nERROR: useErrorsFromTemplates_ is set to False in PixelCPEGeneric_cfi.py. "
67 <<
" In this case it does not make sense to set any of the following to True: "
68 <<
" truncatePixelCharge_, IrradiationBiasCorrection_, DoCosmics_, LoadTemplatesFromDB_ !!!"
77 <<
"ERROR: GenErrors not filled correctly. Check the sqlite file. Using SiPixelTemplateDBObject version "
78 << (*genErrorDBObject_).version();
79 LogDebug(
"PixelCPEGeneric") <<
"Loaded genErrorDBObject v" << (*genErrorDBObject_).version();
83 <<
"ERROR: GenErrors not loaded correctly from text file. Reconstruction will fail.";
88 cout <<
" Use simple parametrised errors " << endl;
93 cout <<
"From PixelCPEGeneric::PixelCPEGeneric(...)" << endl;
96 cout <<
"IrradiationBiasCorrection_ = " << (int)IrradiationBiasCorrection_ << endl;
97 cout <<
"(int)DoCosmics_ = " << (int)DoCosmics_ << endl;
119 if (useErrorsFromTemplates_) {
121 float locBz = theDetParam.
bz;
122 float locBx = theDetParam.
bx;
125 theClusterParam.
pixmx = -999;
126 theClusterParam.
sigmay = -999.9;
127 theClusterParam.
deltay = -999.9;
128 theClusterParam.
sigmax = -999.9;
129 theClusterParam.
deltax = -999.9;
130 theClusterParam.
sy1 = -999.9;
131 theClusterParam.
dy1 = -999.9;
132 theClusterParam.
sy2 = -999.9;
133 theClusterParam.
dy2 = -999.9;
134 theClusterParam.
sx1 = -999.9;
135 theClusterParam.
dx1 = -999.9;
136 theClusterParam.
sx2 = -999.9;
137 theClusterParam.
dx2 = -999.9;
145 theClusterParam.
qBin_ = gtempl.
qbin(gtemplID_,
151 IrradiationBiasCorrection_,
152 theClusterParam.
pixmx,
164 theClusterParam.
dx2);
168 bool useLAWidthFromGenError =
false;
169 if (useLAWidthFromGenError) {
170 chargeWidthX = (-micronsToCm * gtempl.
lorxwidth());
171 chargeWidthY = (-micronsToCm * gtempl.
lorywidth());
172 LogDebug(
"PixelCPE localPosition():") <<
"redefine la width (gen-error)" << chargeWidthX << chargeWidthY;
174 LogDebug(
"PixelCPE localPosition():") <<
"GenError:" << gtemplID_;
177 theClusterParam.
deltax = theClusterParam.
deltax * micronsToCm;
178 theClusterParam.
dx1 = theClusterParam.
dx1 * micronsToCm;
179 theClusterParam.
dx2 = theClusterParam.
dx2 * micronsToCm;
181 theClusterParam.
deltay = theClusterParam.
deltay * micronsToCm;
182 theClusterParam.
dy1 = theClusterParam.
dy1 * micronsToCm;
183 theClusterParam.
dy2 = theClusterParam.
dy2 * micronsToCm;
185 theClusterParam.
sigmax = theClusterParam.
sigmax * micronsToCm;
186 theClusterParam.
sx1 = theClusterParam.
sx1 * micronsToCm;
187 theClusterParam.
sx2 = theClusterParam.
sx2 * micronsToCm;
189 theClusterParam.
sigmay = theClusterParam.
sigmay * micronsToCm;
190 theClusterParam.
sy1 = theClusterParam.
sy1 * micronsToCm;
191 theClusterParam.
sy2 = theClusterParam.
sy2 * micronsToCm;
195 theClusterParam.
qBin_ = 0;
202 collect_edge_charges(theClusterParam, q_f_X, q_l_X, q_f_Y, q_l_Y, useErrorsFromTemplates_ && truncatePixelCharge_);
235 cout <<
"\n\t >>> theClusterParam.theCluster->x = " << theClusterParam.
theCluster->
x()
236 <<
"\n\t >>> theClusterParam.theCluster->y = " << theClusterParam.
theCluster->
y()
241 <<
"\n\t >>> meas: inner lower left = " << meas_URcorn_LLpix.
x() <<
"," << meas_URcorn_LLpix.
y()
242 <<
"\n\t >>> meas: inner upper right = " << meas_LLcorn_URpix.x() <<
"," << meas_LLcorn_URpix.y() << endl;
254 cout <<
"\t >>> Generic:: processing X" << endl;
261 local_URcorn_LLpix.x(),
262 local_LLcorn_URpix.
x(),
269 the_eff_charge_cut_lowX,
270 the_eff_charge_cut_highX,
274 xPos = xPos + shiftX;
278 cout <<
"\t >>> Generic:: processing Y" << endl;
285 local_URcorn_LLpix.y(),
286 local_LLcorn_URpix.
y(),
293 the_eff_charge_cut_lowY,
294 the_eff_charge_cut_highY,
298 yPos = yPos + shiftY;
301 if (IrradiationBiasCorrection_) {
310 xPos -= theClusterParam.
dx1;
312 xPos -= theClusterParam.
dx2;
316 xPos -= theClusterParam.
deltax;
327 yPos -= theClusterParam.
dy1;
329 yPos -= theClusterParam.
dy2;
333 yPos -= theClusterParam.
deltay;
355 bool edgex, edgey, bigInX, bigInY;
356 int maxPixelCol, maxPixelRow, minPixelCol, minPixelRow;
359 initializeLocalErrorVariables(xerr,
375 useErrorsFromTemplates_ && (!NoTemplateErrorsWhenNoTrkAngles_ || theClusterParam.
with_track_angle);
377 if (
int(sizex) != (maxPixelRow - minPixelRow + 1))
378 LogDebug(
"PixelCPEGeneric") <<
" wrong x";
379 if (
int(sizey) != (maxPixelCol - minPixelCol + 1))
380 LogDebug(
"PixelCPEGeneric") <<
" wrong y";
382 LogDebug(
"PixelCPEGeneric") <<
" edge clus " << xerr <<
" " << yerr;
383 if (bigInX || bigInY)
384 LogDebug(
"PixelCPEGeneric") <<
" big " << bigInX <<
" " << bigInY;
386 LogDebug(
"PixelCPEGeneric") <<
" edge " << edgex <<
" " << edgey;
387 LogDebug(
"PixelCPEGeneric") <<
" before if " << useErrorsFromTemplates_ <<
" " << theClusterParam.
qBin_;
388 if (theClusterParam.
qBin_ == 0)
389 LogDebug(
"PixelCPEGeneric") <<
" qbin 0! " << edgex <<
" " << edgey <<
" " << bigInX <<
" " << bigInY <<
" "
390 << sizex <<
" " << sizey;
393 setXYErrors(xerr, yerr, edgex, edgey, sizex, sizey, bigInX, bigInY, useTempErrors, theDetParam, theClusterParam);
395 if (!useTempErrors) {
396 LogDebug(
"PixelCPEGeneric") <<
"Track angles are not known.\n"
397 <<
"Default angle estimation which assumes track from PV (0,0,0) does not work.";
404 for (
int irow = 0; irow < 7; ++irow) {
409 for (
int icol = 0; icol < 21; ++icol) {
420 throw cms::Exception(
"PixelCPEGeneric::localError") <<
"\nERROR: Negative pixel error xerr = " << xerr <<
"\n\n";
423 throw cms::Exception(
"PixelCPEGeneric::localError") <<
"\nERROR: Negative pixel error yerr = " << yerr <<
"\n\n";
426 LogDebug(
"PixelCPEGeneric") <<
" errors " << xerr <<
" " << yerr;
427 if (theClusterParam.
qBin_ == 0)
428 LogDebug(
"PixelCPEGeneric") <<
" qbin 0 " << xerr <<
" " << yerr;
430 auto xerr_sq = xerr * xerr;
431 auto yerr_sq = yerr * yerr;
438 desc.
add<
double>(
"eff_charge_cut_highX", 1.0);
439 desc.
add<
double>(
"eff_charge_cut_highY", 1.0);
440 desc.
add<
double>(
"eff_charge_cut_lowX", 0.0);
441 desc.
add<
double>(
"eff_charge_cut_lowY", 0.0);
442 desc.
add<
double>(
"size_cutX", 3.0);
443 desc.
add<
double>(
"size_cutY", 3.0);
444 desc.
add<
double>(
"EdgeClusterErrorX", 50.0);
445 desc.
add<
double>(
"EdgeClusterErrorY", 85.0);
446 desc.
add<
bool>(
"inflate_errors",
false);
447 desc.
add<
bool>(
"inflate_all_errors_no_trk_angle",
false);
448 desc.
add<
bool>(
"NoTemplateErrorsWhenNoTrkAngles",
false);
449 desc.
add<
bool>(
"UseErrorsFromTemplates",
true);
450 desc.
add<
bool>(
"TruncatePixelCharge",
true);
451 desc.
add<
bool>(
"IrradiationBiasCorrection",
false);
452 desc.
add<
bool>(
"DoCosmics",
false);
453 desc.
add<
bool>(
"Upgrade",
false);
454 desc.
add<
bool>(
"SmallPitch",
false);
virtual LocalPoint localPosition(const MeasurementPoint &) const =0
static bool pushfile(int filenum, std::vector< SiPixelGenErrorStore > &pixelTemp, std::string dir="")
float the_eff_charge_cut_highY
T mag() const
The vector magnitude. Equivalent to sqrt(vec.mag2())
const SiPixelCluster * theCluster
LocalPoint localPosition(DetParam const &theDetParam, ClusterParam &theClusterParam) const override
std::vector< SiPixelGenErrorStore > thePixelGenError_
bool IrradiationBiasCorrection_
bool NoTemplateErrorsWhenNoTrkAngles_
const RectangularPixelTopology * theRecTopol
PixelCPEGeneric(edm::ParameterSet const &conf, const MagneticField *, const TrackerGeometry &, const TrackerTopology &, const SiPixelLorentzAngle *, const SiPixelGenErrorDBObject *, const SiPixelLorentzAngle *)
The constructor.
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)
const PixelTopology * theTopol
bool LoadTemplatesFromDB_
bool isItBigPixelInX(const int ixbin) const override
bool useErrorsFromTemplates_
float the_eff_charge_cut_lowX
bool inflate_all_errors_no_trk_angle
const bool truncatePixelCharge_
float lorxwidth()
signed lorentz x-width (microns)
ParameterDescriptionBase * add(U const &iLabel, T const &value)
static void fillPSetDescription(edm::ParameterSetDescription &desc)
Topology::LocalTrackPred loc_trk_pred
static const int theVerboseLevel
const SiPixelGenErrorDBObject * genErrorDBObject_
T getParameter(std::string const &) const
float the_eff_charge_cut_lowY
float lorywidth()
signed lorentz y-width (microns)
bool isItBigPixelInY(const int iybin) const override
static void fillPSetDescription(edm::ParameterSetDescription &desc)
float generic_position_formula(int size, int q_f, int q_l, float upper_edge_first_pix, float lower_edge_last_pix, float lorentz_shift, float theThickness, float cot_angle, float pitch, bool first_is_big, bool last_is_big, float eff_charge_cut_low, float eff_charge_cut_high, float size_cut)
LocalError localError(DetParam const &theDetParam, ClusterParam &theClusterParam) const override
float the_eff_charge_cut_highX