25 #include "boost/multi_array.hpp" 49 :
PixelCPEBase(conf, mag, geom, ttopo, lorentzAngle, 0, templateDBobject, 0,1)
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();
367 float distance11 =
sqrt( (templXrec1_ - theClusterParam.trk_lp_x)*(templXrec1_ - theClusterParam.trk_lp_x) +
368 (templYrec1_ - theClusterParam.trk_lp_y)*(templYrec1_ - theClusterParam.trk_lp_y) );
370 float distance12 =
sqrt( (templXrec1_ - theClusterParam.trk_lp_x)*(templXrec1_ - theClusterParam.trk_lp_x) +
371 (templYrec2_ - theClusterParam.trk_lp_y)*(templYrec2_ - theClusterParam.trk_lp_y) );
373 float distance21 =
sqrt( (templXrec2_ - theClusterParam.trk_lp_x)*(templXrec2_ - theClusterParam.trk_lp_x) +
374 (templYrec1_ - theClusterParam.trk_lp_y)*(templYrec1_ - theClusterParam.trk_lp_y) );
376 float distance22 =
sqrt( (templXrec2_ - theClusterParam.trk_lp_x)*(templXrec2_ - theClusterParam.trk_lp_x) +
377 (templYrec2_ - theClusterParam.trk_lp_y)*(templYrec2_ - theClusterParam.trk_lp_y) );
379 float min_templXrec_ = -999.9;
380 float min_templYrec_ = -999.9;
381 float distance_min = 9999999999.9;
382 if ( distance11 < distance_min )
384 distance_min = distance11;
385 min_templXrec_ = templXrec1_;
386 min_templYrec_ = templYrec1_;
388 if ( distance12 < distance_min )
390 distance_min = distance12;
391 min_templXrec_ = templXrec1_;
392 min_templYrec_ = templYrec2_;
394 if ( distance21 < distance_min )
396 distance_min = distance21;
397 min_templXrec_ = templXrec2_;
398 min_templYrec_ = templYrec1_;
400 if ( distance22 < distance_min )
402 distance_min = distance22;
403 min_templXrec_ = templXrec2_;
404 min_templYrec_ = templYrec2_;
431 float templateLorbiasCmX = -micronsToCm*templ.
lorxbias();
432 float templateLorbiasCmY = -micronsToCm*templ.
lorybias();
452 theClusterParam.probabilityX_ = theClusterParam.
templProbX_;
453 theClusterParam.probabilityY_ = theClusterParam.
templProbY_;
454 theClusterParam.probabilityQ_ = theClusterParam.
templProbQ_;
455 theClusterParam.qBin_ = theClusterParam.
templQbin_;
457 if ( theClusterParam.
ierr == 0 )
458 theClusterParam.hasFilledProb_ =
true;
479 const float sig12 = 1./
sqrt(12.0);
480 float xerr = theDetParam.
thePitchX *sig12;
481 float yerr = theDetParam.
thePitchY *sig12;
484 if ( theClusterParam.theCluster->getSplitClusterErrorX() > 0.0f && theClusterParam.theCluster->getSplitClusterErrorX() < 7777.7f &&
485 theClusterParam.theCluster->getSplitClusterErrorY() > 0.0f && theClusterParam.theCluster->getSplitClusterErrorY() < 7777.7f )
487 xerr = theClusterParam.theCluster->getSplitClusterErrorX() * micronsToCm;
488 yerr = theClusterParam.theCluster->getSplitClusterErrorY() * micronsToCm;
500 int maxPixelCol = theClusterParam.theCluster->maxPixelCol();
501 int maxPixelRow = theClusterParam.theCluster->maxPixelRow();
502 int minPixelCol = theClusterParam.theCluster->minPixelCol();
503 int minPixelRow = theClusterParam.theCluster->minPixelRow();
509 if ( theClusterParam.
ierr !=0 )
518 <<
"A non-pixel detector type in here?";
523 xerr = 55.0f * micronsToCm;
524 yerr = 36.0f * micronsToCm;
528 xerr = 42.0f * micronsToCm;
529 yerr = 39.0f * micronsToCm;
537 else if ( edgex || edgey )
540 if ( edgex && !edgey )
542 xerr = 23.0f * micronsToCm;
543 yerr = 39.0f * micronsToCm;
545 else if ( !edgex && edgey )
547 xerr = 24.0f * micronsToCm;
548 yerr = 96.0f * micronsToCm;
550 else if ( edgex && edgey )
552 xerr = 31.0f * micronsToCm;
553 yerr = 90.0f * micronsToCm;
557 throw cms::Exception(
" PixelCPETemplateReco::localError: Something wrong with pixel edge flag !!!");
581 " Sizex = " << theClusterParam.theCluster->sizeX() <<
" Sizey = " << theClusterParam.theCluster->sizeY() <<
" Edgex = " << edgex <<
" Edgey = " << edgey <<
582 " ErrX = " << xerr <<
" ErrY = " << yerr;
587 if ( !(xerr > 0.0
f) )
589 <<
"\nERROR: Negative pixel error xerr = " << xerr <<
"\n\n";
591 if ( !(yerr > 0.0
f) )
593 <<
"\nERROR: Negative pixel error yerr = " << yerr <<
"\n\n";
T getParameter(std::string const &) const
Point3DBase< Scalar, LocalTag > LocalPoint
LocalError localError(DetParam const &theDetParam, ClusterParam &theClusterParam) const
bool isItEdgePixelInY(int iybin) const
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
bool isBarrel(GeomDetEnumerators::SubDetector m)
bool isItEdgePixelInX(int ixbin) const
static bool pushfile(int filenum, std::vector< SiPixelTemplateStore > &thePixelTemp_)
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(edm::ParameterSet const &conf, const MagneticField *, const TrackerGeometry &, const TrackerTopology &, const SiPixelLorentzAngle *, const SiPixelTemplateDBObject *)
Measurement2DPoint MeasurementPoint
Measurement points are two-dimensional by default.
virtual float localX(const float mpX) const =0
const PixelTopology * theTopol
bool LoadTemplatesFromDB_
const SiPixelTemplateDBObject * templateDBobject_
DetId geographicalId() const
The label of this GeomDet.
bool isEndcap(GeomDetEnumerators::SubDetector m)
float lorybias()
signed lorentz y-width (microns)
virtual LocalPoint localPosition(const MeasurementPoint &) const =0
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