25 #include "boost/multi_array.hpp" 71 <<
"\nERROR: Templates not filled correctly. Check the sqlite file. Using SiPixelTemplateDBObject version " 72 << (*templateDBobject_).version() <<
"\n\n";
80 <<
"\nERROR: Templates 40 not loaded correctly from text file. Reconstruction will fail.\n\n";
84 <<
"\nERROR: Templates 41 not loaded correctly from text file. Reconstruction will fail.\n\n";
88 LogDebug(
"PixelCPETemplateReco::PixelCPETemplateReco:") <<
89 "Template speed = " <<
speed_ <<
"\n";
124 <<
"A non-pixel detector type in here?";
132 if(ID0!=ID)
cout<<
" different id"<< ID<<
" "<<ID0<<endl;
134 if ( !fpix ) ID = 40;
150 int row_offset = theClusterParam.theCluster->minPixelRow();
151 int col_offset = theClusterParam.theCluster->minPixelCol();
165 if ( theClusterParam.with_track_angle )
170 <<
"@SUB = PixelCPETemplateReco::localPosition" 171 <<
"Should never be here. PixelCPETemplateReco should always be called with track angles. This is a bad error !!! ";
178 for (
int i=0 ;
i!=theClusterParam.theCluster->size(); ++
i )
180 auto pix = theClusterParam.theCluster->pixel(
i);
181 int irow =
int(pix.x);
182 int icol =
int(pix.y);
186 mrow -= row_offset; mrow+=1; mrow =
std::min(mrow,cluster_matrix_size_x);
187 mcol -= col_offset; mcol+=1; mcol =
std::min(mcol,cluster_matrix_size_y);
188 assert(mrow>0); assert(mcol>0);
190 float clustMatrix[mrow][mcol];
191 memset(clustMatrix,0,
sizeof(
float)*mrow*mcol);
194 for (
int i=0 ;
i!=theClusterParam.theCluster->size(); ++
i )
196 auto pix = theClusterParam.theCluster->pixel(
i);
197 int irow =
int(pix.x) - row_offset;
198 int icol =
int(pix.y) - col_offset;
202 if ( (irow<mrow) & (icol<mcol) ) clustMatrix[irow][icol] =
float(pix.adc);
208 bool xdouble[mrow], ydouble[mcol];
210 for (
int irow = 0; irow < mrow; ++irow)
214 for (
int icol = 0; icol < mcol; ++icol)
220 float nonsense = -99999.9f;
226 theClusterParam.hasFilledProb_ =
false;
228 float templYrec1_ = nonsense;
229 float templXrec1_ = nonsense;
230 float templYrec2_ = nonsense;
231 float templXrec2_ = nonsense;
237 float locBz = theDetParam.
bz;
238 float locBx = theDetParam.
bx;
240 theClusterParam.
ierr =
241 PixelTempReco2D( ID, theClusterParam.cotalpha, theClusterParam.cotbeta,
257 LogDebug(
"PixelCPETemplateReco::localPosition") <<
258 "reconstruction failed with error " << theClusterParam.
ierr <<
"\n";
263 float lorentz_drift = -999.9;
265 lorentz_drift = 60.0f;
267 lorentz_drift = 10.0f;
269 if ( theClusterParam.with_track_angle )
271 theClusterParam.
templXrec_ = theDetParam.
theTopol->
localX( theClusterParam.theCluster->x(), theClusterParam.loc_trk_pred ) - lorentz_drift * micronsToCm;
272 theClusterParam.
templYrec_ = theDetParam.
theTopol->
localY( theClusterParam.theCluster->y(), theClusterParam.loc_trk_pred );
277 <<
"@SUB = PixelCPETemplateReco::localPosition" 278 <<
"Should never be here. PixelCPETemplateReco should always be called with track angles. This is a bad error !!! ";
280 theClusterParam.
templXrec_ = theDetParam.
theTopol->
localX( theClusterParam.theCluster->x() ) - lorentz_drift * micronsToCm;
286 cout <<
" PixelCPETemplateReco : We should never be here !!!!!!!!!!!!!!!!!!!!!!" << endl;
303 theClusterParam.
ierr = -123;
320 if ( theClusterParam.
ierr != 0 )
322 LogDebug(
"PixelCPETemplateReco::localPosition") <<
323 "reconstruction failed with error " << theClusterParam.
ierr <<
"\n";
328 float lorentz_drift = -999.9f;
330 lorentz_drift = 60.0f;
332 lorentz_drift = 10.0f;
335 if ( theClusterParam.with_track_angle )
337 theClusterParam.
templXrec_ = theDetParam.
theTopol->
localX( theClusterParam.theCluster->x(),theClusterParam.loc_trk_pred ) - lorentz_drift * micronsToCm;
338 theClusterParam.
templYrec_ = theDetParam.
theTopol->
localY( theClusterParam.theCluster->y(),theClusterParam.loc_trk_pred );
343 <<
"@SUB = PixelCPETemplateReco::localPosition" 344 <<
"Should never be here. PixelCPETemplateReco should always be called with track angles. This is a bad error !!! ";
346 theClusterParam.
templXrec_ = theDetParam.
theTopol->
localX( theClusterParam.theCluster->x() ) - lorentz_drift * micronsToCm;
354 templXrec1_ *= micronsToCm;
355 templYrec1_ *= micronsToCm;
356 templXrec2_ *= micronsToCm;
357 templYrec2_ *= micronsToCm;
360 templXrec1_ += lp.
x();
361 templYrec1_ += lp.
y();
362 templXrec2_ += lp.
x();
363 templYrec2_ += lp.
y();
366 float distX1 =
std::abs (templXrec1_ - theClusterParam.trk_lp_x);
367 float distX2 =
std::abs (templXrec2_ - theClusterParam.trk_lp_x);
368 float distY1 =
std::abs (templYrec1_ - theClusterParam.trk_lp_y);
369 float distY2 =
std::abs (templYrec2_ - theClusterParam.trk_lp_y);
370 theClusterParam.
templXrec_ = (distX1<distX2? templXrec1_ : templXrec2_);
371 theClusterParam.
templYrec_ = (distY1<distY2? templYrec1_ : templYrec2_);
394 float templateLorbiasCmX = -micronsToCm*templ.
lorxbias();
395 float templateLorbiasCmY = -micronsToCm*templ.
lorybias();
415 theClusterParam.probabilityX_ = theClusterParam.
templProbX_;
416 theClusterParam.probabilityY_ = theClusterParam.
templProbY_;
417 theClusterParam.probabilityQ_ = theClusterParam.
templProbQ_;
418 theClusterParam.qBin_ = theClusterParam.
templQbin_;
420 if ( theClusterParam.
ierr == 0 )
421 theClusterParam.hasFilledProb_ =
true;
449 if ( theClusterParam.theCluster->getSplitClusterErrorX() > 0.0f && theClusterParam.theCluster->getSplitClusterErrorX() < 7777.7f &&
450 theClusterParam.theCluster->getSplitClusterErrorY() > 0.0f && theClusterParam.theCluster->getSplitClusterErrorY() < 7777.7f )
452 xerr = theClusterParam.theCluster->getSplitClusterErrorX() * micronsToCm;
453 yerr = theClusterParam.theCluster->getSplitClusterErrorY() * micronsToCm;
465 int maxPixelCol = theClusterParam.theCluster->maxPixelCol();
466 int maxPixelRow = theClusterParam.theCluster->maxPixelRow();
467 int minPixelCol = theClusterParam.theCluster->minPixelCol();
468 int minPixelRow = theClusterParam.theCluster->minPixelRow();
474 if ( theClusterParam.
ierr !=0 )
483 <<
"A non-pixel detector type in here?";
488 xerr = 55.0f * micronsToCm;
489 yerr = 36.0f * micronsToCm;
493 xerr = 42.0f * micronsToCm;
494 yerr = 39.0f * micronsToCm;
502 else if ( edgex || edgey )
505 if ( edgex && !edgey )
507 xerr = 23.0f * micronsToCm;
508 yerr = 39.0f * micronsToCm;
510 else if ( !edgex && edgey )
512 xerr = 24.0f * micronsToCm;
513 yerr = 96.0f * micronsToCm;
515 else if ( edgex && edgey )
517 xerr = 31.0f * micronsToCm;
518 yerr = 90.0f * micronsToCm;
522 throw cms::Exception(
" PixelCPETemplateReco::localError: Something wrong with pixel edge flag !!!");
546 " Sizex = " << theClusterParam.theCluster->sizeX() <<
" Sizey = " << theClusterParam.theCluster->sizeY() <<
" Edgex = " << edgex <<
" Edgey = " << edgey <<
547 " ErrX = " << xerr <<
" ErrY = " << yerr;
552 if ( !(xerr > 0.0
f) )
554 <<
"\nERROR: Negative pixel error xerr = " << xerr <<
"\n\n";
556 if ( !(yerr > 0.0
f) )
558 <<
"\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)
static bool pushfile(int filenum, std::vector< SiPixelTemplateStore > &thePixelTemp_)
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
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)