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";
123 <<
"A non-pixel detector type in here?";
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;
260 if ( theClusterParam.with_track_angle )
262 theClusterParam.
templXrec_ = theDetParam.
theTopol->
localX( theClusterParam.theCluster->x(), theClusterParam.loc_trk_pred ) - lorentz_drift * micronsToCm;
263 theClusterParam.
templYrec_ = theDetParam.
theTopol->
localY( theClusterParam.theCluster->y(), theClusterParam.loc_trk_pred );
268 <<
"@SUB = PixelCPETemplateReco::localPosition"
269 <<
"Should never be here. PixelCPETemplateReco should always be called with track angles. This is a bad error !!! ";
271 theClusterParam.
templXrec_ = theDetParam.
theTopol->
localX( theClusterParam.theCluster->x() ) - lorentz_drift * micronsToCm;
277 cout <<
" PixelCPETemplateReco : We should never be here !!!!!!!!!!!!!!!!!!!!!!" << endl;
291 std::vector< SiPixelTemplateStore2D > thePixelTemp2D_;
295 theClusterParam.
ierr =
309 if ( theClusterParam.
ierr != 0 )
311 LogDebug(
"PixelCPETemplateReco::localPosition") <<
312 "reconstruction failed with error " << theClusterParam.
ierr <<
"\n";
317 float lorentz_drift = -999.9f;
319 lorentz_drift = 60.0f;
321 lorentz_drift = 10.0f;
324 if ( theClusterParam.with_track_angle )
326 theClusterParam.
templXrec_ = theDetParam.
theTopol->
localX( theClusterParam.theCluster->x(),theClusterParam.loc_trk_pred ) - lorentz_drift * micronsToCm;
327 theClusterParam.
templYrec_ = theDetParam.
theTopol->
localY( theClusterParam.theCluster->y(),theClusterParam.loc_trk_pred );
332 <<
"@SUB = PixelCPETemplateReco::localPosition"
333 <<
"Should never be here. PixelCPETemplateReco should always be called with track angles. This is a bad error !!! ";
335 theClusterParam.
templXrec_ = theDetParam.
theTopol->
localX( theClusterParam.theCluster->x() ) - lorentz_drift * micronsToCm;
343 templXrec1_ *= micronsToCm;
344 templYrec1_ *= micronsToCm;
345 templXrec2_ *= micronsToCm;
346 templYrec2_ *= micronsToCm;
349 templXrec1_ += lp.
x();
350 templYrec1_ += lp.
y();
351 templXrec2_ += lp.
x();
352 templYrec2_ += lp.
y();
356 float distance11 =
sqrt( (templXrec1_ - theClusterParam.trk_lp_x)*(templXrec1_ - theClusterParam.trk_lp_x) +
357 (templYrec1_ - theClusterParam.trk_lp_y)*(templYrec1_ - theClusterParam.trk_lp_y) );
359 float distance12 =
sqrt( (templXrec1_ - theClusterParam.trk_lp_x)*(templXrec1_ - theClusterParam.trk_lp_x) +
360 (templYrec2_ - theClusterParam.trk_lp_y)*(templYrec2_ - theClusterParam.trk_lp_y) );
362 float distance21 =
sqrt( (templXrec2_ - theClusterParam.trk_lp_x)*(templXrec2_ - theClusterParam.trk_lp_x) +
363 (templYrec1_ - theClusterParam.trk_lp_y)*(templYrec1_ - theClusterParam.trk_lp_y) );
365 float distance22 =
sqrt( (templXrec2_ - theClusterParam.trk_lp_x)*(templXrec2_ - theClusterParam.trk_lp_x) +
366 (templYrec2_ - theClusterParam.trk_lp_y)*(templYrec2_ - theClusterParam.trk_lp_y) );
368 float min_templXrec_ = -999.9;
369 float min_templYrec_ = -999.9;
370 float distance_min = 9999999999.9;
371 if ( distance11 < distance_min )
373 distance_min = distance11;
374 min_templXrec_ = templXrec1_;
375 min_templYrec_ = templYrec1_;
377 if ( distance12 < distance_min )
379 distance_min = distance12;
380 min_templXrec_ = templXrec1_;
381 min_templYrec_ = templYrec2_;
383 if ( distance21 < distance_min )
385 distance_min = distance21;
386 min_templXrec_ = templXrec2_;
387 min_templYrec_ = templYrec1_;
389 if ( distance22 < distance_min )
391 distance_min = distance22;
392 min_templXrec_ = templXrec2_;
393 min_templYrec_ = templYrec2_;
420 float templateLorbiasCmX = -micronsToCm*templ.
lorxbias();
421 float templateLorbiasCmY = -micronsToCm*templ.
lorybias();
441 theClusterParam.probabilityX_ = theClusterParam.
templProbX_;
442 theClusterParam.probabilityY_ = theClusterParam.
templProbY_;
443 theClusterParam.probabilityQ_ = theClusterParam.
templProbQ_;
444 theClusterParam.qBin_ = theClusterParam.
templQbin_;
446 if ( theClusterParam.
ierr == 0 )
447 theClusterParam.hasFilledProb_ =
true;
468 const float sig12 = 1./
sqrt(12.0);
469 float xerr = theDetParam.
thePitchX *sig12;
470 float yerr = theDetParam.
thePitchY *sig12;
473 if ( theClusterParam.theCluster->getSplitClusterErrorX() > 0.0f && theClusterParam.theCluster->getSplitClusterErrorX() < 7777.7f &&
474 theClusterParam.theCluster->getSplitClusterErrorY() > 0.0f && theClusterParam.theCluster->getSplitClusterErrorY() < 7777.7f )
476 xerr = theClusterParam.theCluster->getSplitClusterErrorX() * micronsToCm;
477 yerr = theClusterParam.theCluster->getSplitClusterErrorY() * micronsToCm;
489 int maxPixelCol = theClusterParam.theCluster->maxPixelCol();
490 int maxPixelRow = theClusterParam.theCluster->maxPixelRow();
491 int minPixelCol = theClusterParam.theCluster->minPixelCol();
492 int minPixelRow = theClusterParam.theCluster->minPixelRow();
498 if ( theClusterParam.
ierr !=0 )
507 <<
"A non-pixel detector type in here?";
512 xerr = 55.0f * micronsToCm;
513 yerr = 36.0f * micronsToCm;
517 xerr = 42.0f * micronsToCm;
518 yerr = 39.0f * micronsToCm;
526 else if ( edgex || edgey )
529 if ( edgex && !edgey )
531 xerr = 23.0f * micronsToCm;
532 yerr = 39.0f * micronsToCm;
534 else if ( !edgex && edgey )
536 xerr = 24.0f * micronsToCm;
537 yerr = 96.0f * micronsToCm;
539 else if ( edgex && edgey )
541 xerr = 31.0f * micronsToCm;
542 yerr = 90.0f * micronsToCm;
546 throw cms::Exception(
" PixelCPETemplateReco::localError: Something wrong with pixel edge flag !!!");
570 " Sizex = " << theClusterParam.theCluster->sizeX() <<
" Sizey = " << theClusterParam.theCluster->sizeY() <<
" Edgex = " << edgex <<
" Edgey = " << edgey <<
571 " ErrX = " << xerr <<
" ErrY = " << yerr;
576 if ( !(xerr > 0.0
f) )
578 <<
"\nERROR: Negative pixel error xerr = " << xerr <<
"\n\n";
580 if ( !(yerr > 0.0
f) )
582 <<
"\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 isBarrel(GeomDetEnumerators::SubDetector m)
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)
bool isEndcap(GeomDetEnumerators::SubDetector m)
virtual float localX(const float mpX) const =0
float lorybias()
signed lorentz y-width (microns)
bool isTrackerPixel(const GeomDetEnumerators::SubDetector m)
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