25 #include "boost/multi_array.hpp" 34 constexpr
float micronsToCm = 1.0e-4;
35 constexpr
int cluster_matrix_size_x = 13;
36 constexpr
int cluster_matrix_size_y = 21;
49 :
PixelCPEBase(conf,
mag,
geom, ttopo, lorentzAngle, nullptr, templateDBobject, nullptr, 1) {
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";
85 <<
" not loaded correctly from text file. Reconstruction will fail.\n\n";
89 LogDebug(
"PixelCPETemplateReco::PixelCPETemplateReco:") <<
"Template speed = " <<
speed_ <<
"\n";
100 return std::make_unique<ClusterParamTemplate>(
cl);
114 throw cms::Exception(
"PixelCPETemplateReco::localPosition :") <<
"A non-pixel detector type in here?";
123 edm::LogError(
"PixelCPETemplateReco") <<
" different id" <<
ID <<
" " << ID0 << endl;
143 int row_offset = theClusterParam.theCluster->minPixelRow();
144 int col_offset = theClusterParam.theCluster->minPixelCol();
149 float tmp_x =
float(row_offset) + 0.5f;
150 float tmp_y =
float(col_offset) + 0.5f;
165 if (theClusterParam.with_track_angle)
168 edm::LogError(
"PixelCPETemplateReco") <<
"@SUB = PixelCPETemplateReco::localPosition" 169 <<
"Should never be here. PixelCPETemplateReco should always be called with " 170 "track angles. This is a bad error !!! ";
176 int mrow = 0, mcol = 0;
177 for (
int i = 0;
i != theClusterParam.theCluster->size(); ++
i) {
178 auto pix = theClusterParam.theCluster->pixel(
i);
179 int irow =
int(pix.x);
180 int icol =
int(pix.y);
186 mrow =
std::min(mrow, cluster_matrix_size_x);
189 mcol =
std::min(mcol, cluster_matrix_size_y);
193 float clustMatrix[mrow][mcol];
194 memset(clustMatrix, 0,
sizeof(
float) * mrow * mcol);
197 for (
int i = 0;
i != theClusterParam.theCluster->size(); ++
i) {
198 auto pix = theClusterParam.theCluster->pixel(
i);
199 int irow =
int(pix.x) - row_offset;
200 int icol =
int(pix.y) - col_offset;
204 if ((irow < mrow) & (icol < mcol))
205 clustMatrix[irow][icol] =
float(pix.adc);
209 bool xdouble[mrow], ydouble[mcol];
211 for (
int irow = 0; irow < mrow; ++irow)
215 for (
int icol = 0; icol < mcol; ++icol)
221 float nonsense = -99999.9f;
228 theClusterParam.hasFilledProb_ =
false;
230 float templYrec1_ = nonsense;
231 float templXrec1_ = nonsense;
232 float templYrec2_ = nonsense;
233 float templXrec2_ = nonsense;
238 float locBz = theDetParam.
bz;
239 float locBx = theDetParam.
bx;
242 theClusterParam.cotalpha,
243 theClusterParam.cotbeta,
262 LogDebug(
"PixelCPETemplateReco::localPosition")
263 <<
"reconstruction failed with error " << theClusterParam.
ierr <<
"\n";
269 if (theClusterParam.with_track_angle) {
271 theDetParam.
theTopol->
localX(theClusterParam.theCluster->x(), theClusterParam.loc_trk_pred) + lorentzshiftX;
273 theDetParam.
theTopol->
localY(theClusterParam.theCluster->y(), theClusterParam.loc_trk_pred) + lorentzshiftY;
275 edm::LogError(
"PixelCPETemplateReco") <<
"@SUB = PixelCPETemplateReco::localPosition" 276 <<
"Should never be here. PixelCPETemplateReco should always be called " 277 "with track angles. This is a bad error !!! ";
283 edm::LogError(
"PixelCPETemplateReco") <<
" PixelCPETemplateReco: Qbin = 0 but using cluster splitter, we should " 284 "never be here !!!!!!!!!!!!!!!!!!!!!! \n" 300 theClusterParam.
ierr = -123;
317 if (theClusterParam.
ierr != 0) {
322 if (theClusterParam.with_track_angle) {
324 theDetParam.
theTopol->
localX(theClusterParam.theCluster->x(), theClusterParam.loc_trk_pred) + lorentzshiftX;
326 theDetParam.
theTopol->
localY(theClusterParam.theCluster->y(), theClusterParam.loc_trk_pred) + lorentzshiftY;
328 edm::LogError(
"PixelCPETemplateReco") <<
"@SUB = PixelCPETemplateReco::localPosition" 329 <<
"Should never be here. PixelCPETemplateReco should always be called " 330 "with track angles. This is a bad error !!! ";
336 templXrec1_ *= micronsToCm;
337 templYrec1_ *= micronsToCm;
338 templXrec2_ *= micronsToCm;
339 templYrec2_ *= micronsToCm;
342 templXrec1_ += lp.
x();
343 templYrec1_ += lp.
y();
344 templXrec2_ += lp.
x();
345 templYrec2_ += lp.
y();
348 float distX1 =
std::abs(templXrec1_ - theClusterParam.trk_lp_x);
349 float distX2 =
std::abs(templXrec2_ - theClusterParam.trk_lp_x);
350 float distY1 =
std::abs(templYrec1_ - theClusterParam.trk_lp_y);
351 float distY2 =
std::abs(templYrec2_ - theClusterParam.trk_lp_y);
352 theClusterParam.
templXrec_ = (distX1 < distX2 ? templXrec1_ : templXrec2_);
353 theClusterParam.
templYrec_ = (distY1 < distY2 ? templYrec1_ : templYrec2_);
376 float templateLorbiasCmX = -micronsToCm * templ.
lorxbias();
377 float templateLorbiasCmY = -micronsToCm * templ.
lorybias();
396 theClusterParam.probabilityX_ = theClusterParam.
templProbX_;
397 theClusterParam.probabilityY_ = theClusterParam.
templProbY_;
398 theClusterParam.probabilityQ_ = theClusterParam.
templProbQ_;
399 theClusterParam.qBin_ = theClusterParam.
templQbin_;
401 if (theClusterParam.
ierr == 0)
402 theClusterParam.hasFilledProb_ =
true;
426 if (theClusterParam.theCluster->getSplitClusterErrorX() > 0.0f &&
428 theClusterParam.theCluster->getSplitClusterErrorY() > 0.0f &&
430 xerr = theClusterParam.theCluster->getSplitClusterErrorX() * micronsToCm;
431 yerr = theClusterParam.theCluster->getSplitClusterErrorY() * micronsToCm;
441 int maxPixelCol = theClusterParam.theCluster->maxPixelCol();
442 int maxPixelRow = theClusterParam.theCluster->maxPixelRow();
443 int minPixelCol = theClusterParam.theCluster->minPixelCol();
444 int minPixelRow = theClusterParam.theCluster->minPixelRow();
452 if (theClusterParam.
ierr != 0) {
459 throw cms::Exception(
"PixelCPETemplateReco::localPosition :") <<
"A non-pixel detector type in here?";
463 xerr = 55.0f * micronsToCm;
464 yerr = 36.0f * micronsToCm;
466 xerr = 42.0f * micronsToCm;
467 yerr = 39.0f * micronsToCm;
474 }
else if (edgex || edgey) {
476 if (edgex && !edgey) {
479 }
else if (!edgex && edgey) {
482 }
else if (edgex && edgey) {
486 throw cms::Exception(
" PixelCPETemplateReco::localError: Something wrong with pixel edge flag !!!");
506 LogDebug(
"PixelCPETemplateReco") <<
" Sizex = " << theClusterParam.theCluster->sizeX()
507 <<
" Sizey = " << theClusterParam.theCluster->sizeY() <<
" Edgex = " << edgex
508 <<
" Edgey = " << edgey <<
" ErrX = " << xerr <<
" ErrY = " << yerr;
515 <<
"\nERROR: Negative pixel error xerr = " << xerr <<
"\n\n";
519 <<
"\nERROR: Negative pixel error yerr = " << yerr <<
"\n\n";
527 return LocalError(xerr * xerr, 0, yerr * yerr);
531 desc.add<
int>(
"barrelTemplateID", 0);
532 desc.add<
int>(
"forwardTemplateID", 0);
533 desc.add<
int>(
"directoryWithTemplates", 0);
534 desc.add<
int>(
"speed", -2);
535 desc.add<
bool>(
"UseClusterSplitter",
false);
std::unique_ptr< ClusterParam > createClusterParam(const SiPixelCluster &cl) const override
static constexpr float xEdgeYError_
T getParameter(std::string const &) const
Point3DBase< Scalar, LocalTag > LocalPoint
virtual LocalPoint localPosition(const MeasurementPoint &) const =0
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)
bool doLorentzFromAlignment_
Log< level::Error, false > LogError
static constexpr float bothEdgeYError_
const PixelGeomDetUnit * theDet
GeomDetType::SubDetector thePart
static constexpr float yEdgeYError_
const RectangularPixelTopology * theRecTopol
~PixelCPETemplateReco() override
PixelCPETemplateReco(edm::ParameterSet const &conf, const MagneticField *, const TrackerGeometry &, const TrackerTopology &, const SiPixelLorentzAngle *, const SiPixelTemplateDBObject *)
virtual float localX(float mpX) const =0
Measurement2DPoint MeasurementPoint
Measurement points are two-dimensional by default.
const PixelTopology * theTopol
bool LoadTemplatesFromDB_
bool isItBigPixelInX(const int ixbin) const override
Abs< T >::type abs(const T &t)
const SiPixelTemplateDBObject * templateDBobject_
bool isItEdgePixelInY(int iybin) const override
DetId geographicalId() const
The label of this GeomDet.
bool isEndcap(GeomDetEnumerators::SubDetector m)
T mag() const
The vector magnitude. Equivalent to sqrt(vec.mag2())
bool isItEdgePixelInX(int ixbin) const override
static constexpr float xEdgeXError_
float lorybias()
signed lorentz y-width (microns)
virtual float localY(float mpY) const =0
static constexpr float clusterSplitMaxError_
short getTemplateID(const uint32_t &detid) const
LocalError localError(DetParam const &theDetParam, ClusterParam &theClusterParam) const override
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)
static constexpr float bothEdgeXError_
bool isItBigPixelInY(const int iybin) const override
static constexpr float yEdgeXError_
static void fillPSetDescription(edm::ParameterSetDescription &desc)
std::vector< SiPixelTemplateStore > thePixelTemp_
bool isTrackerPixel(GeomDetEnumerators::SubDetector m)
LocalPoint localPosition(DetParam const &theDetParam, ClusterParam &theClusterParam) const override