24 #include "boost/multi_array.hpp" 47 const std::vector<SiPixelTemplateStore>* templateStore,
49 :
PixelCPEBase(conf,
mag,
geom, ttopo, lorentzAngle, nullptr, templateDBobject, nullptr, 1) {
76 <<
" not loaded correctly from text file. Reconstruction will fail.\n\n";
81 <<
" not loaded correctly from text file. Reconstruction will fail.\n\n";
85 LogDebug(
"PixelCPETemplateReco::PixelCPETemplateReco:") <<
"Template speed = " <<
speed_ <<
"\n";
96 return std::make_unique<ClusterParamTemplate>(
cl);
110 throw cms::Exception(
"PixelCPETemplateReco::localPosition :") <<
"A non-pixel detector type in here?";
119 edm::LogError(
"PixelCPETemplateReco") <<
" different id" <<
ID <<
" " << ID0 << endl;
139 int row_offset = theClusterParam.theCluster->minPixelRow();
140 int col_offset = theClusterParam.theCluster->minPixelCol();
145 float tmp_x =
float(row_offset) + 0.5f;
146 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,
258 LogDebug(
"PixelCPETemplateReco::localPosition")
259 <<
"reconstruction failed with error " << theClusterParam.
ierr <<
"\n";
265 if (theClusterParam.with_track_angle) {
267 theDetParam.
theTopol->
localX(theClusterParam.theCluster->x(), theClusterParam.loc_trk_pred) + lorentzshiftX;
269 theDetParam.
theTopol->
localY(theClusterParam.theCluster->y(), theClusterParam.loc_trk_pred) + lorentzshiftY;
271 edm::LogError(
"PixelCPETemplateReco") <<
"@SUB = PixelCPETemplateReco::localPosition" 272 <<
"Should never be here. PixelCPETemplateReco should always be called " 273 "with track angles. This is a bad error !!! ";
279 edm::LogError(
"PixelCPETemplateReco") <<
" PixelCPETemplateReco: Qbin = 0 but using cluster splitter, we should " 280 "never be here !!!!!!!!!!!!!!!!!!!!!! \n" 296 theClusterParam.
ierr = -123;
313 if (theClusterParam.
ierr != 0) {
318 if (theClusterParam.with_track_angle) {
320 theDetParam.
theTopol->
localX(theClusterParam.theCluster->x(), theClusterParam.loc_trk_pred) + lorentzshiftX;
322 theDetParam.
theTopol->
localY(theClusterParam.theCluster->y(), theClusterParam.loc_trk_pred) + lorentzshiftY;
324 edm::LogError(
"PixelCPETemplateReco") <<
"@SUB = PixelCPETemplateReco::localPosition" 325 <<
"Should never be here. PixelCPETemplateReco should always be called " 326 "with track angles. This is a bad error !!! ";
338 templXrec1_ += lp.
x();
339 templYrec1_ += lp.
y();
340 templXrec2_ += lp.
x();
341 templYrec2_ += lp.
y();
344 float distX1 =
std::abs(templXrec1_ - theClusterParam.trk_lp_x);
345 float distX2 =
std::abs(templXrec2_ - theClusterParam.trk_lp_x);
346 float distY1 =
std::abs(templYrec1_ - theClusterParam.trk_lp_y);
347 float distY2 =
std::abs(templYrec2_ - theClusterParam.trk_lp_y);
348 theClusterParam.
templXrec_ = (distX1 < distX2 ? templXrec1_ : templXrec2_);
349 theClusterParam.
templYrec_ = (distY1 < distY2 ? templYrec1_ : templYrec2_);
392 theClusterParam.probabilityX_ = theClusterParam.
templProbX_;
393 theClusterParam.probabilityY_ = theClusterParam.
templProbY_;
394 theClusterParam.probabilityQ_ = theClusterParam.
templProbQ_;
395 theClusterParam.qBin_ = theClusterParam.
templQbin_;
397 if (theClusterParam.
ierr == 0)
398 theClusterParam.hasFilledProb_ =
true;
422 if (theClusterParam.theCluster->getSplitClusterErrorX() > 0.0f &&
424 theClusterParam.theCluster->getSplitClusterErrorY() > 0.0f &&
426 xerr = theClusterParam.theCluster->getSplitClusterErrorX() *
micronsToCm;
427 yerr = theClusterParam.theCluster->getSplitClusterErrorY() *
micronsToCm;
437 int maxPixelCol = theClusterParam.theCluster->maxPixelCol();
438 int maxPixelRow = theClusterParam.theCluster->maxPixelRow();
439 int minPixelCol = theClusterParam.theCluster->minPixelCol();
440 int minPixelRow = theClusterParam.theCluster->minPixelRow();
448 if (theClusterParam.
ierr != 0) {
455 throw cms::Exception(
"PixelCPETemplateReco::localPosition :") <<
"A non-pixel detector type in here?";
470 }
else if (edgex || edgey) {
472 if (edgex && !edgey) {
475 }
else if (!edgex && edgey) {
478 }
else if (edgex && edgey) {
482 throw cms::Exception(
" PixelCPETemplateReco::localError: Something wrong with pixel edge flag !!!");
502 LogDebug(
"PixelCPETemplateReco") <<
" Sizex = " << theClusterParam.theCluster->sizeX()
503 <<
" Sizey = " << theClusterParam.theCluster->sizeY() <<
" Edgex = " << edgex
504 <<
" Edgey = " << edgey <<
" ErrX = " << xerr <<
" ErrY = " << yerr;
511 <<
"\nERROR: Negative pixel error xerr = " << xerr <<
"\n\n";
515 <<
"\nERROR: Negative pixel error yerr = " << yerr <<
"\n\n";
523 return LocalError(xerr * xerr, 0, yerr * yerr);
527 desc.add<
int>(
"barrelTemplateID", 0);
528 desc.add<
int>(
"forwardTemplateID", 0);
529 desc.add<
int>(
"directoryWithTemplates", 0);
530 desc.add<
int>(
"speed", -2);
531 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_
~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.
virtual bool isItEdgePixelInX(int ixbin) const =0
const PixelTopology * theTopol
bool LoadTemplatesFromDB_
virtual bool isItBigPixelInX(int ixbin) const =0
virtual bool isItBigPixelInY(int iybin) const =0
Abs< T >::type abs(const T &t)
const SiPixelTemplateDBObject * templateDBobject_
DetId geographicalId() const
The label of this GeomDet.
bool isEndcap(GeomDetEnumerators::SubDetector m)
T mag() const
The vector magnitude. Equivalent to sqrt(vec.mag2())
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.
virtual bool isItEdgePixelInY(int iybin) const =0
float lorxbias()
signed lorentz x-width (microns)
std::vector< SiPixelTemplateStore > thePixelTempCache_
static constexpr float bothEdgeXError_
static constexpr float yEdgeXError_
static void fillPSetDescription(edm::ParameterSetDescription &desc)
bool isTrackerPixel(GeomDetEnumerators::SubDetector m)
LocalPoint localPosition(DetParam const &theDetParam, ClusterParam &theClusterParam) const override