24 #include "boost/multi_array.hpp"
28 using namespace SiPixelTemplateReco;
32 const float PI = 3.141593;
49 :
PixelCPEBase(conf, mag, lorentzAngle, 0, templateDBobject)
65 if ( LoadTemplatesFromDB_ )
72 <<
"\nERROR: Templates not filled correctly. Check the sqlite file. Using SiPixelTemplateDBObject version "
73 << (*templateDBobject_).version() <<
"\n\n";
81 <<
"\nERROR: Templates 40 not loaded correctly from text file. Reconstruction will fail.\n\n";
85 <<
"\nERROR: Templates 41 not loaded correctly from text file. Reconstruction will fail.\n\n";
89 LogDebug(
"PixelCPETemplateReco::PixelCPETemplateReco:") <<
90 "Template speed = " <<
speed_ <<
"\n";
160 float tmp_x = float(row_offset) + 0.5f;
161 float tmp_y = float(col_offset) + 0.5f;
174 <<
"@SUB = PixelCPETemplateReco::localPosition"
175 <<
"Should never be here. PixelCPETemplateReco should always be called with track angles. This is a bad error !!! ";
214 for (
int i=0 ;
i!=cluster.
size(); ++
i )
216 auto pix = cluster.
pixel(
i);
221 int irow = int(pix.x) - row_offset;
222 int icol = int(pix.y) - col_offset;
228 clust_array_2d[irow][icol] = (float)pix.
adc;
236 xdouble[irow] =
theRecTopol->isItBigPixelInX( irow+row_offset );
242 ydouble[icol] =
theRecTopol->isItBigPixelInY( icol+col_offset );
246 float nonsense = -99999.9f;
254 float templYrec1_ = nonsense;
255 float templXrec1_ = nonsense;
256 float templYrec2_ = nonsense;
257 float templXrec2_ = nonsense;
263 float locBz = (*theParam).bz;
268 clust_array_2d, ydouble, xdouble,
282 LogDebug(
"PixelCPETemplateReco::localPosition") <<
283 "reconstruction failed with error " <<
ierr <<
"\n";
288 float lorentz_drift = -999.9;
290 lorentz_drift = 60.0f;
292 lorentz_drift = 10.0f;
295 <<
"A non-pixel detector type in here?" <<
"\n";
305 <<
"@SUB = PixelCPETemplateReco::localPosition"
306 <<
"Should never be here. PixelCPETemplateReco should always be called with track angles. This is a bad error !!! ";
314 cout <<
" PixelCPETemplateReco : We should never be here !!!!!!!!!!!!!!!!!!!!!!" << endl;
347 LogDebug(
"PixelCPETemplateReco::localPosition") <<
348 "reconstruction failed with error " <<
ierr <<
"\n";
353 float lorentz_drift = -999.9f;
355 lorentz_drift = 60.0f;
357 lorentz_drift = 10.0f;
360 <<
"A non-pixel detector type in here?" <<
"\n";
371 <<
"@SUB = PixelCPETemplateReco::localPosition"
372 <<
"Should never be here. PixelCPETemplateReco should always be called with track angles. This is a bad error !!! ";
388 templXrec1_ += lp.
x();
389 templYrec1_ += lp.
y();
390 templXrec2_ += lp.
x();
391 templYrec2_ += lp.
y();
407 float min_templXrec_ = -999.9;
408 float min_templYrec_ = -999.9;
409 float distance_min = 9999999999.9;
410 if ( distance11 < distance_min )
412 distance_min = distance11;
413 min_templXrec_ = templXrec1_;
414 min_templYrec_ = templYrec1_;
416 if ( distance12 < distance_min )
418 distance_min = distance12;
419 min_templXrec_ = templXrec1_;
420 min_templYrec_ = templYrec2_;
422 if ( distance21 < distance_min )
424 distance_min = distance21;
425 min_templXrec_ = templXrec2_;
426 min_templYrec_ = templYrec1_;
428 if ( distance22 < distance_min )
430 distance_min = distance22;
431 min_templXrec_ = templXrec2_;
432 min_templYrec_ = templYrec2_;
478 const float sig12 = 1./
sqrt(12.0);
507 bool edgex = (
theRecTopol->isItEdgePixelInX( minPixelRow ) ||
theRecTopol->isItEdgePixelInX( maxPixelRow ) );
508 bool edgey = (
theRecTopol->isItEdgePixelInY( minPixelCol ) ||
theRecTopol->isItEdgePixelInY( maxPixelCol ) );
529 throw cms::Exception(
"PixelCPETemplateReco::localError :") <<
"A non-pixel detector type in here?" ;
536 else if ( edgex || edgey )
539 if ( edgex && !edgey )
544 else if ( !edgex && edgey )
549 else if ( edgex && edgey )
556 throw cms::Exception(
" PixelCPETemplateReco::localError: Something wrong with pixel edge flag !!!");
580 " Sizex = " << cluster.
sizeX() <<
" Sizey = " << cluster.
sizeY() <<
" Edgex = " << edgex <<
" Edgey = " << edgey <<
581 " ErrX = " << xerr <<
" ErrY = " << yerr;
586 if ( !(xerr > 0.0
f) )
588 <<
"\nERROR: Negative pixel error xerr = " << xerr <<
"\n\n";
590 if ( !(yerr > 0.0
f) )
592 <<
"\nERROR: Negative pixel error yerr = " << yerr <<
"\n\n";
T getParameter(std::string const &) const
Topology::LocalTrackPred loc_trk_pred_
bool LoadTemplatesFromDB_
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())
LocalError localError(const SiPixelCluster &cl, const GeomDetUnit &det) const
GeomDetType::SubDetector thePart
Measurement2DPoint MeasurementPoint
Measurement points are two-dimensional by default.
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_
LocalPoint localPosition(const SiPixelCluster &cluster, const GeomDetUnit &det) const
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
bool pushfile(int filenum)
float getSplitClusterErrorY() const
const RectangularPixelTopology * theRecTopol
const PixelTopology * theTopol
const int cluster_matrix_size_y
PixelCPETemplateReco(edm::ParameterSet const &conf, const MagneticField *, const SiPixelLorentzAngle *, const SiPixelTemplateDBObject *)
void setTheDet(const GeomDetUnit &det, const SiPixelCluster &cluster) const
Pixel cluster – collection of neighboring pixels above threshold.
float getSplitClusterErrorX() const
bool pushfile(int filenum)
const int cluster_matrix_size_x
const PixelGeomDetUnit * theDet
virtual float localY(const float mpY) const =0