25 #include "boost/multi_array.hpp" 71 <<
"\nERROR: Templates not filled correctly. Check the sqlite file. Using SiPixelTemplateDBObject version " 72 << (*templateDBobject_).version() <<
"\n\n";
83 <<
"\nERROR: Template ID " <<
barrelTemplateID_ <<
" not loaded correctly from text file. Reconstruction will fail.\n\n";
87 <<
"\nERROR: Template ID " << forwardTemplateID_ <<
" not loaded correctly from text file. Reconstruction will fail.\n\n";
91 LogDebug(
"PixelCPETemplateReco::PixelCPETemplateReco:") <<
92 "Template speed = " <<
speed_ <<
"\n";
127 <<
"A non-pixel detector type in here?";
135 if(ID0!=ID)
edm::LogError(
"PixelCPETemplateReco") <<
" different id"<< ID<<
" "<<ID0<<endl;
155 int row_offset = theClusterParam.theCluster->minPixelRow();
156 int col_offset = theClusterParam.theCluster->minPixelCol();
170 if ( theClusterParam.with_track_angle )
175 <<
"@SUB = PixelCPETemplateReco::localPosition" 176 <<
"Should never be here. PixelCPETemplateReco should always be called with track angles. This is a bad error !!! ";
183 for (
int i=0 ;
i!=theClusterParam.theCluster->size(); ++
i )
185 auto pix = theClusterParam.theCluster->pixel(
i);
186 int irow =
int(pix.x);
187 int icol =
int(pix.y);
191 mrow -= row_offset; mrow+=1; mrow =
std::min(mrow,cluster_matrix_size_x);
192 mcol -= col_offset; mcol+=1; mcol =
std::min(mcol,cluster_matrix_size_y);
193 assert(mrow>0); assert(mcol>0);
195 float clustMatrix[mrow][mcol];
196 memset(clustMatrix,0,
sizeof(
float)*mrow*mcol);
199 for (
int i=0 ;
i!=theClusterParam.theCluster->size(); ++
i )
201 auto pix = theClusterParam.theCluster->pixel(
i);
202 int irow =
int(pix.x) - row_offset;
203 int icol =
int(pix.y) - col_offset;
207 if ( (irow<mrow) & (icol<mcol) ) clustMatrix[irow][icol] =
float(pix.adc);
213 bool xdouble[mrow], ydouble[mcol];
215 for (
int irow = 0; irow < mrow; ++irow)
219 for (
int icol = 0; icol < mcol; ++icol)
225 float nonsense = -99999.9f;
231 theClusterParam.hasFilledProb_ =
false;
233 float templYrec1_ = nonsense;
234 float templXrec1_ = nonsense;
235 float templYrec2_ = nonsense;
236 float templXrec2_ = nonsense;
242 float locBz = theDetParam.
bz;
243 float locBx = theDetParam.
bx;
245 theClusterParam.
ierr =
246 PixelTempReco2D( ID, theClusterParam.cotalpha, theClusterParam.cotbeta,
262 LogDebug(
"PixelCPETemplateReco::localPosition") <<
263 "reconstruction failed with error " << theClusterParam.
ierr <<
"\n";
268 float lorentz_drift = -999.9;
270 lorentz_drift = 60.0f;
272 lorentz_drift = 10.0f;
274 if ( theClusterParam.with_track_angle )
276 theClusterParam.
templXrec_ = theDetParam.
theTopol->
localX( theClusterParam.theCluster->x(), theClusterParam.loc_trk_pred ) - lorentz_drift * micronsToCm;
277 theClusterParam.
templYrec_ = theDetParam.
theTopol->
localY( theClusterParam.theCluster->y(), theClusterParam.loc_trk_pred );
282 <<
"@SUB = PixelCPETemplateReco::localPosition" 283 <<
"Should never be here. PixelCPETemplateReco should always be called with track angles. This is a bad error !!! ";
285 theClusterParam.
templXrec_ = theDetParam.
theTopol->
localX( theClusterParam.theCluster->x() ) - lorentz_drift * micronsToCm;
291 cout <<
" PixelCPETemplateReco : We should never be here !!!!!!!!!!!!!!!!!!!!!!" << endl;
308 theClusterParam.
ierr = -123;
325 if ( theClusterParam.
ierr != 0 )
327 LogDebug(
"PixelCPETemplateReco::localPosition") <<
328 "reconstruction failed with error " << theClusterParam.
ierr <<
"\n";
333 float lorentz_drift = -999.9f;
335 lorentz_drift = 60.0f;
337 lorentz_drift = 10.0f;
340 if ( theClusterParam.with_track_angle )
342 theClusterParam.
templXrec_ = theDetParam.
theTopol->
localX( theClusterParam.theCluster->x(),theClusterParam.loc_trk_pred ) - lorentz_drift * micronsToCm;
343 theClusterParam.
templYrec_ = theDetParam.
theTopol->
localY( theClusterParam.theCluster->y(),theClusterParam.loc_trk_pred );
348 <<
"@SUB = PixelCPETemplateReco::localPosition" 349 <<
"Should never be here. PixelCPETemplateReco should always be called with track angles. This is a bad error !!! ";
351 theClusterParam.
templXrec_ = theDetParam.
theTopol->
localX( theClusterParam.theCluster->x() ) - lorentz_drift * micronsToCm;
359 templXrec1_ *= micronsToCm;
360 templYrec1_ *= micronsToCm;
361 templXrec2_ *= micronsToCm;
362 templYrec2_ *= micronsToCm;
365 templXrec1_ += lp.
x();
366 templYrec1_ += lp.
y();
367 templXrec2_ += lp.
x();
368 templYrec2_ += lp.
y();
371 float distX1 =
std::abs (templXrec1_ - theClusterParam.trk_lp_x);
372 float distX2 =
std::abs (templXrec2_ - theClusterParam.trk_lp_x);
373 float distY1 =
std::abs (templYrec1_ - theClusterParam.trk_lp_y);
374 float distY2 =
std::abs (templYrec2_ - theClusterParam.trk_lp_y);
375 theClusterParam.
templXrec_ = (distX1<distX2? templXrec1_ : templXrec2_);
376 theClusterParam.
templYrec_ = (distY1<distY2? templYrec1_ : templYrec2_);
399 float templateLorbiasCmX = -micronsToCm*templ.
lorxbias();
400 float templateLorbiasCmY = -micronsToCm*templ.
lorybias();
420 theClusterParam.probabilityX_ = theClusterParam.
templProbX_;
421 theClusterParam.probabilityY_ = theClusterParam.
templProbY_;
422 theClusterParam.probabilityQ_ = theClusterParam.
templProbQ_;
423 theClusterParam.qBin_ = theClusterParam.
templQbin_;
425 if ( theClusterParam.
ierr == 0 )
426 theClusterParam.hasFilledProb_ =
true;
454 if ( theClusterParam.theCluster->getSplitClusterErrorX() > 0.0f && theClusterParam.theCluster->getSplitClusterErrorX() < 7777.7f &&
455 theClusterParam.theCluster->getSplitClusterErrorY() > 0.0f && theClusterParam.theCluster->getSplitClusterErrorY() < 7777.7f )
457 xerr = theClusterParam.theCluster->getSplitClusterErrorX() * micronsToCm;
458 yerr = theClusterParam.theCluster->getSplitClusterErrorY() * micronsToCm;
470 int maxPixelCol = theClusterParam.theCluster->maxPixelCol();
471 int maxPixelRow = theClusterParam.theCluster->maxPixelRow();
472 int minPixelCol = theClusterParam.theCluster->minPixelCol();
473 int minPixelRow = theClusterParam.theCluster->minPixelRow();
479 if ( theClusterParam.
ierr !=0 )
488 <<
"A non-pixel detector type in here?";
493 xerr = 55.0f * micronsToCm;
494 yerr = 36.0f * micronsToCm;
498 xerr = 42.0f * micronsToCm;
499 yerr = 39.0f * micronsToCm;
507 else if ( edgex || edgey )
510 if ( edgex && !edgey )
512 xerr = 23.0f * micronsToCm;
513 yerr = 39.0f * micronsToCm;
515 else if ( !edgex && edgey )
517 xerr = 24.0f * micronsToCm;
518 yerr = 96.0f * micronsToCm;
520 else if ( edgex && edgey )
522 xerr = 31.0f * micronsToCm;
523 yerr = 90.0f * micronsToCm;
527 throw cms::Exception(
" PixelCPETemplateReco::localError: Something wrong with pixel edge flag !!!");
551 " Sizex = " << theClusterParam.theCluster->sizeX() <<
" Sizey = " << theClusterParam.theCluster->sizeY() <<
" Edgex = " << edgex <<
" Edgey = " << edgey <<
552 " ErrX = " << xerr <<
" ErrY = " << yerr;
557 if ( !(xerr > 0.0
f) )
559 <<
"\nERROR: Negative pixel error xerr = " << xerr <<
"\n\n";
561 if ( !(yerr > 0.0
f) )
563 <<
"\nERROR: Negative pixel error yerr = " << yerr <<
"\n\n";
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)
ClusterParam * createClusterParam(const SiPixelCluster &cl) const override
int PixelTempReco2D(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)
const PixelGeomDetUnit * theDet
GeomDetType::SubDetector thePart
const RectangularPixelTopology * theRecTopol
std::vector< SiPixelTemplateStore > thePixelTemp_
~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.
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
bool isTrackerPixel(GeomDetEnumerators::SubDetector m)