24 #include "boost/multi_array.hpp"
28 using namespace SiPixelTemplateReco;
48 :
PixelCPEBase(conf, mag, geom, ttopo, lorentzAngle, 0, templateDBobject, 0,1)
70 <<
"\nERROR: Templates not filled correctly. Check the sqlite file. Using SiPixelTemplateDBObject version "
71 << (*templateDBobject_).version() <<
"\n\n";
79 <<
"\nERROR: Templates 40 not loaded correctly from text file. Reconstruction will fail.\n\n";
83 <<
"\nERROR: Templates 41 not loaded correctly from text file. Reconstruction will fail.\n\n";
87 LogDebug(
"PixelCPETemplateReco::PixelCPETemplateReco:") <<
88 "Template speed = " <<
speed_ <<
"\n";
131 if(ID0!=ID)
cout<<
" different id"<< ID<<
" "<<ID0<<endl;
133 if ( !fpix ) ID = 40;
142 boost::multi_array<float, 2> clust_array_2d(boost::extents[cluster_matrix_size_x][cluster_matrix_size_y]);
153 int row_offset = theClusterParam.theCluster->minPixelRow();
154 int col_offset = theClusterParam.theCluster->minPixelCol();
159 float tmp_x = float(row_offset) + 0.5f;
160 float tmp_y = float(col_offset) + 0.5f;
168 if ( theClusterParam.with_track_angle )
173 <<
"@SUB = PixelCPETemplateReco::localPosition"
174 <<
"Should never be here. PixelCPETemplateReco should always be called with track angles. This is a bad error !!! ";
180 for (
int i=0 ;
i!=theClusterParam.theCluster->size(); ++
i )
182 auto pix = theClusterParam.theCluster->pixel(
i);
187 int irow = int(pix.x) - row_offset;
188 int icol = int(pix.y) - col_offset;
192 if ( irow<cluster_matrix_size_x && icol<cluster_matrix_size_y )
194 clust_array_2d[irow][icol] = (float)pix.adc;
198 std::vector<bool> ydouble(cluster_matrix_size_y), xdouble(cluster_matrix_size_x);
200 for (
int irow = 0; irow < cluster_matrix_size_x; ++irow)
206 for (
int icol = 0; icol < cluster_matrix_size_y; ++icol)
212 float nonsense = -99999.9f;
218 theClusterParam.hasFilledProb_ =
false;
220 float templYrec1_ = nonsense;
221 float templXrec1_ = nonsense;
222 float templYrec2_ = nonsense;
223 float templXrec2_ = nonsense;
229 float locBz = theDetParam.
bz;
231 theClusterParam.
ierr =
232 PixelTempReco2D( ID, theClusterParam.cotalpha, theClusterParam.cotbeta,
234 clust_array_2d, ydouble, xdouble,
248 LogDebug(
"PixelCPETemplateReco::localPosition") <<
249 "reconstruction failed with error " << theClusterParam.
ierr <<
"\n";
254 float lorentz_drift = -999.9;
256 lorentz_drift = 60.0f;
258 lorentz_drift = 10.0f;
261 <<
"A non-pixel detector type in here?" <<
"\n";
263 if ( theClusterParam.with_track_angle )
265 theClusterParam.
templXrec_ = theDetParam.
theTopol->
localX( theClusterParam.theCluster->x(), theClusterParam.loc_trk_pred ) - lorentz_drift * micronsToCm;
266 theClusterParam.
templYrec_ = theDetParam.
theTopol->
localY( theClusterParam.theCluster->y(), theClusterParam.loc_trk_pred );
271 <<
"@SUB = PixelCPETemplateReco::localPosition"
272 <<
"Should never be here. PixelCPETemplateReco should always be called with track angles. This is a bad error !!! ";
274 theClusterParam.
templXrec_ = theDetParam.
theTopol->
localX( theClusterParam.theCluster->x() ) - lorentz_drift * micronsToCm;
280 cout <<
" PixelCPETemplateReco : We should never be here !!!!!!!!!!!!!!!!!!!!!!" << endl;
294 std::vector< SiPixelTemplateStore2D > thePixelTemp2D_;
298 theClusterParam.
ierr =
312 if ( theClusterParam.
ierr != 0 )
314 LogDebug(
"PixelCPETemplateReco::localPosition") <<
315 "reconstruction failed with error " << theClusterParam.
ierr <<
"\n";
320 float lorentz_drift = -999.9f;
322 lorentz_drift = 60.0f;
324 lorentz_drift = 10.0f;
327 <<
"A non-pixel detector type in here?" <<
"\n";
330 if ( theClusterParam.with_track_angle )
332 theClusterParam.
templXrec_ = theDetParam.
theTopol->
localX( theClusterParam.theCluster->x(),theClusterParam.loc_trk_pred ) - lorentz_drift * micronsToCm;
333 theClusterParam.
templYrec_ = theDetParam.
theTopol->
localY( theClusterParam.theCluster->y(),theClusterParam.loc_trk_pred );
338 <<
"@SUB = PixelCPETemplateReco::localPosition"
339 <<
"Should never be here. PixelCPETemplateReco should always be called with track angles. This is a bad error !!! ";
341 theClusterParam.
templXrec_ = theDetParam.
theTopol->
localX( theClusterParam.theCluster->x() ) - lorentz_drift * micronsToCm;
349 templXrec1_ *= micronsToCm;
350 templYrec1_ *= micronsToCm;
351 templXrec2_ *= micronsToCm;
352 templYrec2_ *= micronsToCm;
355 templXrec1_ += lp.
x();
356 templYrec1_ += lp.
y();
357 templXrec2_ += lp.
x();
358 templYrec2_ += lp.
y();
362 float distance11 =
sqrt( (templXrec1_ - theClusterParam.trk_lp_x)*(templXrec1_ - theClusterParam.trk_lp_x) +
363 (templYrec1_ - theClusterParam.trk_lp_y)*(templYrec1_ - theClusterParam.trk_lp_y) );
365 float distance12 =
sqrt( (templXrec1_ - theClusterParam.trk_lp_x)*(templXrec1_ - theClusterParam.trk_lp_x) +
366 (templYrec2_ - theClusterParam.trk_lp_y)*(templYrec2_ - theClusterParam.trk_lp_y) );
368 float distance21 =
sqrt( (templXrec2_ - theClusterParam.trk_lp_x)*(templXrec2_ - theClusterParam.trk_lp_x) +
369 (templYrec1_ - theClusterParam.trk_lp_y)*(templYrec1_ - theClusterParam.trk_lp_y) );
371 float distance22 =
sqrt( (templXrec2_ - theClusterParam.trk_lp_x)*(templXrec2_ - theClusterParam.trk_lp_x) +
372 (templYrec2_ - theClusterParam.trk_lp_y)*(templYrec2_ - theClusterParam.trk_lp_y) );
374 float min_templXrec_ = -999.9;
375 float min_templYrec_ = -999.9;
376 float distance_min = 9999999999.9;
377 if ( distance11 < distance_min )
379 distance_min = distance11;
380 min_templXrec_ = templXrec1_;
381 min_templYrec_ = templYrec1_;
383 if ( distance12 < distance_min )
385 distance_min = distance12;
386 min_templXrec_ = templXrec1_;
387 min_templYrec_ = templYrec2_;
389 if ( distance21 < distance_min )
391 distance_min = distance21;
392 min_templXrec_ = templXrec2_;
393 min_templYrec_ = templYrec1_;
395 if ( distance22 < distance_min )
397 distance_min = distance22;
398 min_templXrec_ = templXrec2_;
399 min_templYrec_ = templYrec2_;
426 float templateLorbiasCmX = -micronsToCm*templ.
lorxbias();
427 float templateLorbiasCmY = -micronsToCm*templ.
lorybias();
447 theClusterParam.probabilityX_ = theClusterParam.
templProbX_;
448 theClusterParam.probabilityY_ = theClusterParam.
templProbY_;
449 theClusterParam.probabilityQ_ = theClusterParam.
templProbQ_;
450 theClusterParam.qBin_ = theClusterParam.
templQbin_;
452 if ( theClusterParam.
ierr == 0 )
453 theClusterParam.hasFilledProb_ =
true;
474 const float sig12 = 1./
sqrt(12.0);
475 float xerr = theDetParam.
thePitchX *sig12;
476 float yerr = theDetParam.
thePitchY *sig12;
479 if ( theClusterParam.theCluster->getSplitClusterErrorX() > 0.0f && theClusterParam.theCluster->getSplitClusterErrorX() < 7777.7f &&
480 theClusterParam.theCluster->getSplitClusterErrorY() > 0.0f && theClusterParam.theCluster->getSplitClusterErrorY() < 7777.7f )
482 xerr = theClusterParam.theCluster->getSplitClusterErrorX() * micronsToCm;
483 yerr = theClusterParam.theCluster->getSplitClusterErrorY() * micronsToCm;
495 int maxPixelCol = theClusterParam.theCluster->maxPixelCol();
496 int maxPixelRow = theClusterParam.theCluster->maxPixelRow();
497 int minPixelCol = theClusterParam.theCluster->minPixelCol();
498 int minPixelRow = theClusterParam.theCluster->minPixelRow();
504 if ( theClusterParam.
ierr !=0 )
514 xerr = 55.0f * micronsToCm;
515 yerr = 36.0f * micronsToCm;
519 xerr = 42.0f * micronsToCm;
520 yerr = 39.0f * micronsToCm;
523 throw cms::Exception(
"PixelCPETemplateReco::localError :") <<
"A non-pixel detector type in here?" ;
530 else if ( edgex || edgey )
533 if ( edgex && !edgey )
535 xerr = 23.0f * micronsToCm;
536 yerr = 39.0f * micronsToCm;
538 else if ( !edgex && edgey )
540 xerr = 24.0f * micronsToCm;
541 yerr = 96.0f * micronsToCm;
543 else if ( edgex && edgey )
545 xerr = 31.0f * micronsToCm;
546 yerr = 90.0f * micronsToCm;
550 throw cms::Exception(
" PixelCPETemplateReco::localError: Something wrong with pixel edge flag !!!");
574 " Sizex = " << theClusterParam.theCluster->sizeX() <<
" Sizey = " << theClusterParam.theCluster->sizeY() <<
" Edgex = " << edgex <<
" Edgey = " << edgey <<
575 " ErrX = " << xerr <<
" ErrY = " << yerr;
580 if ( !(xerr > 0.0
f) )
582 <<
"\nERROR: Negative pixel error xerr = " << xerr <<
"\n\n";
584 if ( !(yerr > 0.0
f) )
586 <<
"\nERROR: Negative pixel error yerr = " << yerr <<
"\n\n";
T getParameter(std::string const &) const
LocalError localError(DetParam const &theDetParam, ClusterParam &theClusterParam) const
bool isItEdgePixelInY(int iybin) const
virtual LocalPoint localPosition(const MeasurementPoint &) const =0
short getTemplateID(const uint32_t &detid) const
T mag() const
The vector magnitude. Equivalent to sqrt(vec.mag2())
virtual bool isItBigPixelInY(const int iybin) const
static bool pushfile(int filenum, std::vector< SiPixelTemplateStore2D > &thePixelTemp_)
bool isItEdgePixelInX(int ixbin) const
static bool pushfile(int filenum, std::vector< SiPixelTemplateStore > &thePixelTemp_)
const PixelGeomDetUnit * theDet
GeomDetType::SubDetector thePart
const RectangularPixelTopology * theRecTopol
std::vector< SiPixelTemplateStore > thePixelTemp_
PixelCPETemplateReco(edm::ParameterSet const &conf, const MagneticField *, const TrackerGeometry &, const TrackerTopology &, const SiPixelLorentzAngle *, const SiPixelTemplateDBObject *)
Measurement2DPoint MeasurementPoint
Measurement points are two-dimensional by default.
const PixelTopology * theTopol
bool LoadTemplatesFromDB_
int PixelTempSplit(int id, float cotalpha, float cotbeta, array_2d &cluster, std::vector< bool > &ydouble, std::vector< bool > &xdouble, SiPixelTemplate &templ, float &yrec1, float &yrec2, float &sigmay, float &prob2y, float &xrec1, float &xrec2, float &sigmax, float &prob2x, int &q2bin, float &prob2Q, bool resolve, int speed, float &dchisq, bool deadpix, std::vector< std::pair< int, int > > &zeropix, SiPixelTemplate2D &templ2D)
const SiPixelTemplateDBObject * templateDBobject_
DetId geographicalId() const
The label of this GeomDet.
int PixelTempReco2D(int id, float cotalpha, float cotbeta, float locBz, array_2d &cluster, std::vector< bool > &ydouble, std::vector< bool > &xdouble, 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)
virtual float localX(const float mpX) const =0
float lorybias()
signed lorentz y-width (microns)
ClusterParam * createClusterParam(const SiPixelCluster &cl) const
Pixel cluster – collection of neighboring pixels above threshold.
float lorxbias()
signed lorentz x-width (microns)
virtual bool isItBigPixelInX(const int ixbin) const
LocalPoint localPosition(DetParam const &theDetParam, ClusterParam &theClusterParam) const
virtual float localY(const float mpY) const =0