25 #include "boost/multi_array.hpp" 48 const std::vector<SiPixelTemplateStore>* templateStore,
50 :
PixelCPEBase(conf,
mag,
geom, ttopo, lorentzAngle, nullptr, templateDBobject, nullptr, 1) {
77 <<
" not loaded correctly from text file. Reconstruction will fail.\n\n";
82 <<
" not loaded correctly from text file. Reconstruction will fail.\n\n";
86 LogDebug(
"PixelCPETemplateReco::PixelCPETemplateReco:") <<
"Template speed = " <<
speed_ <<
"\n";
97 return std::make_unique<ClusterParamTemplate>(
cl);
111 throw cms::Exception(
"PixelCPETemplateReco::localPosition :") <<
"A non-pixel detector type in here?";
120 edm::LogError(
"PixelCPETemplateReco") <<
" different id" <<
ID <<
" " << ID0 << endl;
140 int row_offset = theClusterParam.theCluster->minPixelRow();
141 int col_offset = theClusterParam.theCluster->minPixelCol();
146 float tmp_x =
float(row_offset) + 0.5f;
147 float tmp_y =
float(col_offset) + 0.5f;
162 if (theClusterParam.with_track_angle)
165 edm::LogError(
"PixelCPETemplateReco") <<
"@SUB = PixelCPETemplateReco::localPosition" 166 <<
"Should never be here. PixelCPETemplateReco should always be called with " 167 "track angles. This is a bad error !!! ";
173 int mrow = 0, mcol = 0;
174 for (
int i = 0;
i != theClusterParam.theCluster->size(); ++
i) {
175 auto pix = theClusterParam.theCluster->pixel(
i);
176 int irow =
int(pix.x);
177 int icol =
int(pix.y);
183 mrow =
std::min(mrow, cluster_matrix_size_x);
186 mcol =
std::min(mcol, cluster_matrix_size_y);
190 float clustMatrix[mrow][mcol];
191 memset(clustMatrix, 0,
sizeof(
float) * mrow * mcol);
194 for (
int i = 0;
i != theClusterParam.theCluster->size(); ++
i) {
195 auto pix = theClusterParam.theCluster->pixel(
i);
196 int irow =
int(pix.x) - row_offset;
197 int icol =
int(pix.y) - col_offset;
201 if ((irow < mrow) & (icol < mcol))
202 clustMatrix[irow][icol] =
float(pix.adc);
206 bool xdouble[mrow], ydouble[mcol];
208 for (
int irow = 0; irow < mrow; ++irow)
212 for (
int icol = 0; icol < mcol; ++icol)
218 float nonsense = -99999.9f;
225 theClusterParam.hasFilledProb_ =
false;
227 float templYrec1_ = nonsense;
228 float templXrec1_ = nonsense;
229 float templYrec2_ = nonsense;
230 float templXrec2_ = nonsense;
235 float locBz = theDetParam.
bz;
236 float locBx = theDetParam.
bx;
239 theClusterParam.cotalpha,
240 theClusterParam.cotbeta,
259 LogDebug(
"PixelCPETemplateReco::localPosition")
260 <<
"reconstruction failed with error " << theClusterParam.
ierr <<
"\n";
266 if (theClusterParam.with_track_angle) {
268 theDetParam.
theTopol->
localX(theClusterParam.theCluster->x(), theClusterParam.loc_trk_pred) + lorentzshiftX;
270 theDetParam.
theTopol->
localY(theClusterParam.theCluster->y(), theClusterParam.loc_trk_pred) + lorentzshiftY;
272 edm::LogError(
"PixelCPETemplateReco") <<
"@SUB = PixelCPETemplateReco::localPosition" 273 <<
"Should never be here. PixelCPETemplateReco should always be called " 274 "with track angles. This is a bad error !!! ";
280 edm::LogError(
"PixelCPETemplateReco") <<
" PixelCPETemplateReco: Qbin = 0 but using cluster splitter, we should " 281 "never be here !!!!!!!!!!!!!!!!!!!!!! \n" 297 theClusterParam.
ierr = -123;
314 if (theClusterParam.
ierr != 0) {
319 if (theClusterParam.with_track_angle) {
321 theDetParam.
theTopol->
localX(theClusterParam.theCluster->x(), theClusterParam.loc_trk_pred) + lorentzshiftX;
323 theDetParam.
theTopol->
localY(theClusterParam.theCluster->y(), theClusterParam.loc_trk_pred) + lorentzshiftY;
325 edm::LogError(
"PixelCPETemplateReco") <<
"@SUB = PixelCPETemplateReco::localPosition" 326 <<
"Should never be here. PixelCPETemplateReco should always be called " 327 "with track angles. This is a bad error !!! ";
339 templXrec1_ += lp.
x();
340 templYrec1_ += lp.
y();
341 templXrec2_ += lp.
x();
342 templYrec2_ += lp.
y();
345 float distX1 =
std::abs(templXrec1_ - theClusterParam.trk_lp_x);
346 float distX2 =
std::abs(templXrec2_ - theClusterParam.trk_lp_x);
347 float distY1 =
std::abs(templYrec1_ - theClusterParam.trk_lp_y);
348 float distY2 =
std::abs(templYrec2_ - theClusterParam.trk_lp_y);
349 theClusterParam.
templXrec_ = (distX1 < distX2 ? templXrec1_ : templXrec2_);
350 theClusterParam.
templYrec_ = (distY1 < distY2 ? templYrec1_ : templYrec2_);
393 theClusterParam.probabilityX_ = theClusterParam.
templProbX_;
394 theClusterParam.probabilityY_ = theClusterParam.
templProbY_;
395 theClusterParam.probabilityQ_ = theClusterParam.
templProbQ_;
396 theClusterParam.qBin_ = theClusterParam.
templQbin_;
398 if (theClusterParam.
ierr == 0)
399 theClusterParam.hasFilledProb_ =
true;
423 if (theClusterParam.theCluster->getSplitClusterErrorX() > 0.0f &&
425 theClusterParam.theCluster->getSplitClusterErrorY() > 0.0f &&
427 xerr = theClusterParam.theCluster->getSplitClusterErrorX() *
micronsToCm;
428 yerr = theClusterParam.theCluster->getSplitClusterErrorY() *
micronsToCm;
438 int maxPixelCol = theClusterParam.theCluster->maxPixelCol();
439 int maxPixelRow = theClusterParam.theCluster->maxPixelRow();
440 int minPixelCol = theClusterParam.theCluster->minPixelCol();
441 int minPixelRow = theClusterParam.theCluster->minPixelRow();
449 if (theClusterParam.
ierr != 0) {
456 throw cms::Exception(
"PixelCPETemplateReco::localPosition :") <<
"A non-pixel detector type in here?";
471 }
else if (edgex || edgey) {
473 if (edgex && !edgey) {
476 }
else if (!edgex && edgey) {
479 }
else if (edgex && edgey) {
483 throw cms::Exception(
" PixelCPETemplateReco::localError: Something wrong with pixel edge flag !!!");
503 LogDebug(
"PixelCPETemplateReco") <<
" Sizex = " << theClusterParam.theCluster->sizeX()
504 <<
" Sizey = " << theClusterParam.theCluster->sizeY() <<
" Edgex = " << edgex
505 <<
" Edgey = " << edgey <<
" ErrX = " << xerr <<
" ErrY = " << yerr;
512 <<
"\nERROR: Negative pixel error xerr = " << xerr <<
"\n\n";
516 <<
"\nERROR: Negative pixel error yerr = " << yerr <<
"\n\n";
524 return LocalError(xerr * xerr, 0, yerr * yerr);
528 desc.add<
int>(
"barrelTemplateID", 0);
529 desc.add<
int>(
"forwardTemplateID", 0);
530 desc.add<
int>(
"directoryWithTemplates", 0);
531 desc.add<
int>(
"speed", -2);
532 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
const std::vector< SiPixelTemplateStore > * thePixelTemp_
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
virtual float localX(float mpX) const =0
constexpr float micronsToCm
PixelCPETemplateReco(edm::ParameterSet const &conf, const MagneticField *, const TrackerGeometry &, const TrackerTopology &, const SiPixelLorentzAngle *, const std::vector< SiPixelTemplateStore > *, const SiPixelTemplateDBObject *)
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)
std::vector< SiPixelTemplateStore > thePixelTempCache_
static constexpr float bothEdgeXError_
bool isItBigPixelInY(const int iybin) const override
static constexpr float yEdgeXError_
static void fillPSetDescription(edm::ParameterSetDescription &desc)
bool isTrackerPixel(GeomDetEnumerators::SubDetector m)
LocalPoint localPosition(DetParam const &theDetParam, ClusterParam &theClusterParam) const override