24 #include "boost/multi_array.hpp" 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;
149 int row_offset = theClusterParam.theCluster->minPixelRow();
150 int col_offset = theClusterParam.theCluster->minPixelCol();
164 if ( theClusterParam.with_track_angle )
169 <<
"@SUB = PixelCPETemplateReco::localPosition" 170 <<
"Should never be here. PixelCPETemplateReco should always be called with track angles. This is a bad error !!! ";
177 for (
int i=0 ;
i!=theClusterParam.theCluster->size(); ++
i )
179 auto pix = theClusterParam.theCluster->pixel(
i);
180 int irow =
int(pix.x);
181 int icol =
int(pix.y);
185 mrow -= row_offset; mrow+=1; mrow =
std::min(mrow,cluster_matrix_size_x);
186 mcol -= col_offset; mcol+=1; mcol =
std::min(mcol,cluster_matrix_size_y);
187 assert(mrow>0); assert(mcol>0);
189 float clustMatrix[mrow][mcol];
190 memset(clustMatrix,0,
sizeof(
float)*mrow*mcol);
193 for (
int i=0 ;
i!=theClusterParam.theCluster->size(); ++
i )
195 auto pix = theClusterParam.theCluster->pixel(
i);
196 int irow =
int(pix.x) - row_offset;
197 int icol =
int(pix.y) - col_offset;
201 if ( (irow<mrow) & (icol<mcol) ) clustMatrix[irow][icol] =
float(pix.adc);
207 bool xdouble[mrow], ydouble[mcol];
209 for (
int irow = 0; irow < mrow; ++irow)
213 for (
int icol = 0; icol < mcol; ++icol)
219 float nonsense = -99999.9f;
225 theClusterParam.hasFilledProb_ =
false;
227 float templYrec1_ = nonsense;
228 float templXrec1_ = nonsense;
229 float templYrec2_ = nonsense;
230 float templXrec2_ = nonsense;
236 float locBz = theDetParam.
bz;
238 theClusterParam.
ierr =
239 PixelTempReco2D( ID, theClusterParam.cotalpha, theClusterParam.cotbeta,
255 LogDebug(
"PixelCPETemplateReco::localPosition") <<
256 "reconstruction failed with error " << theClusterParam.
ierr <<
"\n";
261 float lorentz_drift = -999.9;
263 lorentz_drift = 60.0f;
265 lorentz_drift = 10.0f;
267 if ( theClusterParam.with_track_angle )
269 theClusterParam.
templXrec_ = theDetParam.
theTopol->
localX( theClusterParam.theCluster->x(), theClusterParam.loc_trk_pred ) - lorentz_drift * micronsToCm;
270 theClusterParam.
templYrec_ = theDetParam.
theTopol->
localY( theClusterParam.theCluster->y(), theClusterParam.loc_trk_pred );
275 <<
"@SUB = PixelCPETemplateReco::localPosition" 276 <<
"Should never be here. PixelCPETemplateReco should always be called with track angles. This is a bad error !!! ";
278 theClusterParam.
templXrec_ = theDetParam.
theTopol->
localX( theClusterParam.theCluster->x() ) - lorentz_drift * micronsToCm;
284 cout <<
" PixelCPETemplateReco : We should never be here !!!!!!!!!!!!!!!!!!!!!!" << endl;
296 std::vector< SiPixelTemplateStore2D > thePixelTemp2D_;
300 theClusterParam.
ierr = -123;
317 if ( theClusterParam.
ierr != 0 )
319 LogDebug(
"PixelCPETemplateReco::localPosition") <<
320 "reconstruction failed with error " << theClusterParam.
ierr <<
"\n";
325 float lorentz_drift = -999.9f;
327 lorentz_drift = 60.0f;
329 lorentz_drift = 10.0f;
332 if ( theClusterParam.with_track_angle )
334 theClusterParam.
templXrec_ = theDetParam.
theTopol->
localX( theClusterParam.theCluster->x(),theClusterParam.loc_trk_pred ) - lorentz_drift * micronsToCm;
335 theClusterParam.
templYrec_ = theDetParam.
theTopol->
localY( theClusterParam.theCluster->y(),theClusterParam.loc_trk_pred );
340 <<
"@SUB = PixelCPETemplateReco::localPosition" 341 <<
"Should never be here. PixelCPETemplateReco should always be called with track angles. This is a bad error !!! ";
343 theClusterParam.
templXrec_ = theDetParam.
theTopol->
localX( theClusterParam.theCluster->x() ) - lorentz_drift * micronsToCm;
351 templXrec1_ *= micronsToCm;
352 templYrec1_ *= micronsToCm;
353 templXrec2_ *= micronsToCm;
354 templYrec2_ *= micronsToCm;
357 templXrec1_ += lp.
x();
358 templYrec1_ += lp.
y();
359 templXrec2_ += lp.
x();
360 templYrec2_ += lp.
y();
364 float distance11 =
sqrt( (templXrec1_ - theClusterParam.trk_lp_x)*(templXrec1_ - theClusterParam.trk_lp_x) +
365 (templYrec1_ - theClusterParam.trk_lp_y)*(templYrec1_ - theClusterParam.trk_lp_y) );
367 float distance12 =
sqrt( (templXrec1_ - theClusterParam.trk_lp_x)*(templXrec1_ - theClusterParam.trk_lp_x) +
368 (templYrec2_ - theClusterParam.trk_lp_y)*(templYrec2_ - theClusterParam.trk_lp_y) );
370 float distance21 =
sqrt( (templXrec2_ - theClusterParam.trk_lp_x)*(templXrec2_ - theClusterParam.trk_lp_x) +
371 (templYrec1_ - theClusterParam.trk_lp_y)*(templYrec1_ - theClusterParam.trk_lp_y) );
373 float distance22 =
sqrt( (templXrec2_ - theClusterParam.trk_lp_x)*(templXrec2_ - theClusterParam.trk_lp_x) +
374 (templYrec2_ - theClusterParam.trk_lp_y)*(templYrec2_ - theClusterParam.trk_lp_y) );
376 float min_templXrec_ = -999.9;
377 float min_templYrec_ = -999.9;
378 float distance_min = 9999999999.9;
379 if ( distance11 < distance_min )
381 distance_min = distance11;
382 min_templXrec_ = templXrec1_;
383 min_templYrec_ = templYrec1_;
385 if ( distance12 < distance_min )
387 distance_min = distance12;
388 min_templXrec_ = templXrec1_;
389 min_templYrec_ = templYrec2_;
391 if ( distance21 < distance_min )
393 distance_min = distance21;
394 min_templXrec_ = templXrec2_;
395 min_templYrec_ = templYrec1_;
397 if ( distance22 < distance_min )
399 distance_min = distance22;
400 min_templXrec_ = templXrec2_;
401 min_templYrec_ = templYrec2_;
428 float templateLorbiasCmX = -micronsToCm*templ.
lorxbias();
429 float templateLorbiasCmY = -micronsToCm*templ.
lorybias();
449 theClusterParam.probabilityX_ = theClusterParam.
templProbX_;
450 theClusterParam.probabilityY_ = theClusterParam.
templProbY_;
451 theClusterParam.probabilityQ_ = theClusterParam.
templProbQ_;
452 theClusterParam.qBin_ = theClusterParam.
templQbin_;
454 if ( theClusterParam.
ierr == 0 )
455 theClusterParam.hasFilledProb_ =
true;
476 const float sig12 = 1./
sqrt(12.0);
477 float xerr = theDetParam.
thePitchX *sig12;
478 float yerr = theDetParam.
thePitchY *sig12;
481 if ( theClusterParam.theCluster->getSplitClusterErrorX() > 0.0f && theClusterParam.theCluster->getSplitClusterErrorX() < 7777.7f &&
482 theClusterParam.theCluster->getSplitClusterErrorY() > 0.0f && theClusterParam.theCluster->getSplitClusterErrorY() < 7777.7f )
484 xerr = theClusterParam.theCluster->getSplitClusterErrorX() * micronsToCm;
485 yerr = theClusterParam.theCluster->getSplitClusterErrorY() * micronsToCm;
497 int maxPixelCol = theClusterParam.theCluster->maxPixelCol();
498 int maxPixelRow = theClusterParam.theCluster->maxPixelRow();
499 int minPixelCol = theClusterParam.theCluster->minPixelCol();
500 int minPixelRow = theClusterParam.theCluster->minPixelRow();
506 if ( theClusterParam.
ierr !=0 )
515 <<
"A non-pixel detector type in here?";
520 xerr = 55.0f * micronsToCm;
521 yerr = 36.0f * micronsToCm;
525 xerr = 42.0f * micronsToCm;
526 yerr = 39.0f * micronsToCm;
534 else if ( edgex || edgey )
537 if ( edgex && !edgey )
539 xerr = 23.0f * micronsToCm;
540 yerr = 39.0f * micronsToCm;
542 else if ( !edgex && edgey )
544 xerr = 24.0f * micronsToCm;
545 yerr = 96.0f * micronsToCm;
547 else if ( edgex && edgey )
549 xerr = 31.0f * micronsToCm;
550 yerr = 90.0f * micronsToCm;
554 throw cms::Exception(
" PixelCPETemplateReco::localError: Something wrong with pixel edge flag !!!");
578 " Sizex = " << theClusterParam.theCluster->sizeX() <<
" Sizey = " << theClusterParam.theCluster->sizeY() <<
" Edgex = " << edgex <<
" Edgey = " << edgey <<
579 " ErrX = " << xerr <<
" ErrY = " << yerr;
584 if ( !(xerr > 0.0
f) )
586 <<
"\nERROR: Negative pixel error xerr = " << xerr <<
"\n\n";
588 if ( !(yerr > 0.0
f) )
590 <<
"\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
int PixelTempReco2D(int id, float cotalpha, float cotbeta, float locBz, 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)
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.
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