25 #include "boost/multi_array.hpp" 69 <<
"\nERROR: Templates not filled correctly. Check the sqlite file. Using SiPixelTemplateDBObject version " 70 << (*templateDBobject_).version() <<
"\n\n";
80 <<
" not loaded correctly from text file. Reconstruction will fail.\n\n";
84 <<
"\nERROR: Template ID " << forwardTemplateID_
85 <<
" not loaded correctly from text file. Reconstruction will fail.\n\n";
89 LogDebug(
"PixelCPETemplateReco::PixelCPETemplateReco:") <<
"Template speed = " <<
speed_ <<
"\n";
117 throw cms::Exception(
"PixelCPETemplateReco::localPosition :") <<
"A non-pixel detector type in here?";
126 edm::LogError(
"PixelCPETemplateReco") <<
" different id" << ID <<
" " << ID0 << endl;
146 int row_offset = theClusterParam.theCluster->minPixelRow();
147 int col_offset = theClusterParam.theCluster->minPixelCol();
152 float tmp_x =
float(row_offset) + 0.5f;
153 float tmp_y =
float(col_offset) + 0.5f;
161 if (theClusterParam.with_track_angle)
164 edm::LogError(
"PixelCPETemplateReco") <<
"@SUB = PixelCPETemplateReco::localPosition" 165 <<
"Should never be here. PixelCPETemplateReco should always be called with " 166 "track angles. This is a bad error !!! ";
172 int mrow = 0, mcol = 0;
173 for (
int i = 0;
i != theClusterParam.theCluster->size(); ++
i) {
174 auto pix = theClusterParam.theCluster->pixel(
i);
175 int irow =
int(pix.x);
176 int icol =
int(pix.y);
182 mrow =
std::min(mrow, cluster_matrix_size_x);
185 mcol =
std::min(mcol, cluster_matrix_size_y);
189 float clustMatrix[mrow][mcol];
190 memset(clustMatrix, 0,
sizeof(
float) * mrow * mcol);
193 for (
int i = 0;
i != theClusterParam.theCluster->size(); ++
i) {
194 auto pix = theClusterParam.theCluster->pixel(
i);
195 int irow =
int(pix.x) - row_offset;
196 int icol =
int(pix.y) - col_offset;
200 if ((irow < mrow) & (icol < mcol))
201 clustMatrix[irow][icol] =
float(pix.adc);
205 bool xdouble[mrow], ydouble[mcol];
207 for (
int irow = 0; irow < mrow; ++irow)
211 for (
int icol = 0; icol < mcol; ++icol)
217 float nonsense = -99999.9f;
224 theClusterParam.hasFilledProb_ =
false;
226 float templYrec1_ = nonsense;
227 float templXrec1_ = nonsense;
228 float templYrec2_ = nonsense;
229 float templXrec2_ = nonsense;
234 float locBz = theDetParam.
bz;
235 float locBx = theDetParam.
bx;
238 theClusterParam.cotalpha,
239 theClusterParam.cotbeta,
259 LogDebug(
"PixelCPETemplateReco::localPosition")
260 <<
"reconstruction failed with error " << theClusterParam.
ierr <<
"\n";
265 float lorentz_drift = -999.9;
267 lorentz_drift = 60.0f;
269 lorentz_drift = 10.0f;
271 if (theClusterParam.with_track_angle) {
273 theDetParam.
theTopol->
localX(theClusterParam.theCluster->x(), theClusterParam.loc_trk_pred) -
274 lorentz_drift * micronsToCm;
276 theDetParam.
theTopol->
localY(theClusterParam.theCluster->y(), theClusterParam.loc_trk_pred);
278 edm::LogError(
"PixelCPETemplateReco") <<
"@SUB = PixelCPETemplateReco::localPosition" 279 <<
"Should never be here. PixelCPETemplateReco should always be called " 280 "with track angles. This is a bad error !!! ";
283 lorentz_drift * micronsToCm;
289 cout <<
" PixelCPETemplateReco : We should never be here !!!!!!!!!!!!!!!!!!!!!!" << endl;
305 theClusterParam.
ierr = -123;
322 if (theClusterParam.
ierr != 0) {
323 LogDebug(
"PixelCPETemplateReco::localPosition")
324 <<
"reconstruction failed with error " << theClusterParam.
ierr <<
"\n";
329 float lorentz_drift = -999.9f;
331 lorentz_drift = 60.0f;
333 lorentz_drift = 10.0f;
336 if (theClusterParam.with_track_angle) {
338 theDetParam.
theTopol->
localX(theClusterParam.theCluster->x(), theClusterParam.loc_trk_pred) -
339 lorentz_drift * micronsToCm;
341 theDetParam.
theTopol->
localY(theClusterParam.theCluster->y(), theClusterParam.loc_trk_pred);
343 edm::LogError(
"PixelCPETemplateReco") <<
"@SUB = PixelCPETemplateReco::localPosition" 344 <<
"Should never be here. PixelCPETemplateReco should always be called " 345 "with track angles. This is a bad error !!! ";
348 lorentz_drift * micronsToCm;
353 templXrec1_ *= micronsToCm;
354 templYrec1_ *= micronsToCm;
355 templXrec2_ *= micronsToCm;
356 templYrec2_ *= micronsToCm;
359 templXrec1_ += lp.
x();
360 templYrec1_ += lp.
y();
361 templXrec2_ += lp.
x();
362 templYrec2_ += lp.
y();
365 float distX1 =
std::abs(templXrec1_ - theClusterParam.trk_lp_x);
366 float distX2 =
std::abs(templXrec2_ - theClusterParam.trk_lp_x);
367 float distY1 =
std::abs(templYrec1_ - theClusterParam.trk_lp_y);
368 float distY2 =
std::abs(templYrec2_ - theClusterParam.trk_lp_y);
369 theClusterParam.
templXrec_ = (distX1 < distX2 ? templXrec1_ : templXrec2_);
370 theClusterParam.
templYrec_ = (distY1 < distY2 ? templYrec1_ : templYrec2_);
393 float templateLorbiasCmX = -micronsToCm * templ.
lorxbias();
394 float templateLorbiasCmY = -micronsToCm * templ.
lorybias();
413 theClusterParam.probabilityX_ = theClusterParam.
templProbX_;
414 theClusterParam.probabilityY_ = theClusterParam.
templProbY_;
415 theClusterParam.probabilityQ_ = theClusterParam.
templProbQ_;
416 theClusterParam.qBin_ = theClusterParam.
templQbin_;
418 if (theClusterParam.
ierr == 0)
419 theClusterParam.hasFilledProb_ =
true;
443 if (theClusterParam.theCluster->getSplitClusterErrorX() > 0.0f &&
444 theClusterParam.theCluster->getSplitClusterErrorX() < 7777.7f &&
445 theClusterParam.theCluster->getSplitClusterErrorY() > 0.0f &&
446 theClusterParam.theCluster->getSplitClusterErrorY() < 7777.7f) {
447 xerr = theClusterParam.theCluster->getSplitClusterErrorX() * micronsToCm;
448 yerr = theClusterParam.theCluster->getSplitClusterErrorY() * micronsToCm;
458 int maxPixelCol = theClusterParam.theCluster->maxPixelCol();
459 int maxPixelRow = theClusterParam.theCluster->maxPixelRow();
460 int minPixelCol = theClusterParam.theCluster->minPixelCol();
461 int minPixelRow = theClusterParam.theCluster->minPixelRow();
469 if (theClusterParam.
ierr != 0) {
476 throw cms::Exception(
"PixelCPETemplateReco::localPosition :") <<
"A non-pixel detector type in here?";
480 xerr = 55.0f * micronsToCm;
481 yerr = 36.0f * micronsToCm;
483 xerr = 42.0f * micronsToCm;
484 yerr = 39.0f * micronsToCm;
491 }
else if (edgex || edgey) {
493 if (edgex && !edgey) {
494 xerr = 23.0f * micronsToCm;
495 yerr = 39.0f * micronsToCm;
496 }
else if (!edgex && edgey) {
497 xerr = 24.0f * micronsToCm;
498 yerr = 96.0f * micronsToCm;
499 }
else if (edgex && edgey) {
500 xerr = 31.0f * micronsToCm;
501 yerr = 90.0f * micronsToCm;
503 throw cms::Exception(
" PixelCPETemplateReco::localError: Something wrong with pixel edge flag !!!");
523 LogDebug(
"PixelCPETemplateReco") <<
" Sizex = " << theClusterParam.theCluster->sizeX()
524 <<
" Sizey = " << theClusterParam.theCluster->sizeY() <<
" Edgex = " << edgex
525 <<
" Edgey = " << edgey <<
" ErrX = " << xerr <<
" ErrY = " << yerr;
532 <<
"\nERROR: Negative pixel error xerr = " << xerr <<
"\n\n";
536 <<
"\nERROR: Negative pixel error yerr = " << yerr <<
"\n\n";
544 return LocalError(xerr * xerr, 0, yerr * yerr);
548 desc.
add<
int>(
"barrelTemplateID", 0);
549 desc.
add<
int>(
"forwardTemplateID", 0);
550 desc.
add<
int>(
"directoryWithTemplates", 0);
551 desc.
add<
int>(
"speed", -2);
552 desc.
add<
bool>(
"UseClusterSplitter",
false);
T getParameter(std::string const &) const
Point3DBase< Scalar, LocalTag > LocalPoint
short getTemplateID(const uint32_t &detid) const
T mag() const
The vector magnitude. Equivalent to sqrt(vec.mag2())
bool isBarrel(GeomDetEnumerators::SubDetector m)
int PixelTempReco1D(int id, float cotalpha, float cotbeta, float locBz, float locBx, ClusMatrix &cluster, SiPixelTemplate &templ, float &yrec, float &sigmay, float &proby, float &xrec, float &sigmax, float &probx, int &qbin, int speed, bool deadpix, std::vector< std::pair< int, int > > &zeropix, float &probQ, int &nypix, int &nxpix)
ClusterParam * createClusterParam(const SiPixelCluster &cl) const override
const PixelGeomDetUnit * theDet
GeomDetType::SubDetector thePart
const RectangularPixelTopology * theRecTopol
~PixelCPETemplateReco() override
PixelCPETemplateReco(edm::ParameterSet const &conf, const MagneticField *, const TrackerGeometry &, const TrackerTopology &, const SiPixelLorentzAngle *, const SiPixelTemplateDBObject *)
Measurement2DPoint MeasurementPoint
Measurement points are two-dimensional by default.
bool isItEdgePixelInX(int ixbin) const override
const PixelTopology * theTopol
bool LoadTemplatesFromDB_
Abs< T >::type abs(const T &t)
LocalError localError(DetParam const &theDetParam, ClusterParam &theClusterParam) const override
const SiPixelTemplateDBObject * templateDBobject_
virtual float localX(float mpX) const =0
DetId geographicalId() const
The label of this GeomDet.
ParameterDescriptionBase * add(U const &iLabel, T const &value)
bool isEndcap(GeomDetEnumerators::SubDetector m)
bool isItBigPixelInY(const int iybin) const override
bool isItBigPixelInX(const int ixbin) const override
float lorybias()
signed lorentz y-width (microns)
virtual LocalPoint localPosition(const MeasurementPoint &) const =0
static bool pushfile(int filenum, std::vector< SiPixelTemplateStore > &pixelTemp, std::string dir="CalibTracker/SiPixelESProducers/data/")
Pixel cluster – collection of neighboring pixels above threshold.
float lorxbias()
signed lorentz x-width (microns)
LocalPoint localPosition(DetParam const &theDetParam, ClusterParam &theClusterParam) const override
virtual float localY(float mpY) const =0
bool isItEdgePixelInY(int iybin) const override
static void fillPSetDescription(edm::ParameterSetDescription &desc)
std::vector< SiPixelTemplateStore > thePixelTemp_
bool isTrackerPixel(GeomDetEnumerators::SubDetector m)