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";
158 float tmp_x = float(row_offset) + 0.5f;
159 float tmp_y = float(col_offset) + 0.5f;
172 <<
"@SUB = PixelCPETemplateReco::localPosition"
173 <<
"Should never be here. PixelCPETemplateReco should always be called with track angles. This is a bad error !!! ";
212 for (
int i=0 ;
i!=cluster.
size(); ++
i )
214 auto pix = cluster.
pixel(
i);
219 int irow = int(pix.x) - row_offset;
220 int icol = int(pix.y) - col_offset;
226 clust_array_2d[irow][icol] = (float)pix.
adc;
234 xdouble[irow] =
theRecTopol->isItBigPixelInX( irow+row_offset );
240 ydouble[icol] =
theRecTopol->isItBigPixelInY( icol+col_offset );
244 float nonsense = -99999.9f;
252 float templYrec1_ = nonsense;
253 float templXrec1_ = nonsense;
254 float templYrec2_ = nonsense;
255 float templXrec2_ = nonsense;
261 float locBz = (*theParam).bz;
266 clust_array_2d, ydouble, xdouble,
280 LogDebug(
"PixelCPETemplateReco::localPosition") <<
281 "reconstruction failed with error " <<
ierr <<
"\n";
286 float lorentz_drift = -999.9;
288 lorentz_drift = 60.0f;
290 lorentz_drift = 10.0f;
293 <<
"A non-pixel detector type in here?" <<
"\n";
303 <<
"@SUB = PixelCPETemplateReco::localPosition"
304 <<
"Should never be here. PixelCPETemplateReco should always be called with track angles. This is a bad error !!! ";
312 cout <<
" PixelCPETemplateReco : We should never be here !!!!!!!!!!!!!!!!!!!!!!" << endl;
345 LogDebug(
"PixelCPETemplateReco::localPosition") <<
346 "reconstruction failed with error " <<
ierr <<
"\n";
351 float lorentz_drift = -999.9f;
353 lorentz_drift = 60.0f;
355 lorentz_drift = 10.0f;
358 <<
"A non-pixel detector type in here?" <<
"\n";
369 <<
"@SUB = PixelCPETemplateReco::localPosition"
370 <<
"Should never be here. PixelCPETemplateReco should always be called with track angles. This is a bad error !!! ";
386 templXrec1_ += lp.
x();
387 templYrec1_ += lp.
y();
388 templXrec2_ += lp.
x();
389 templYrec2_ += lp.
y();
405 float min_templXrec_ = -999.9;
406 float min_templYrec_ = -999.9;
407 float distance_min = 9999999999.9;
408 if ( distance11 < distance_min )
410 distance_min = distance11;
411 min_templXrec_ = templXrec1_;
412 min_templYrec_ = templYrec1_;
414 if ( distance12 < distance_min )
416 distance_min = distance12;
417 min_templXrec_ = templXrec1_;
418 min_templYrec_ = templYrec2_;
420 if ( distance21 < distance_min )
422 distance_min = distance21;
423 min_templXrec_ = templXrec2_;
424 min_templYrec_ = templYrec1_;
426 if ( distance22 < distance_min )
428 distance_min = distance22;
429 min_templXrec_ = templXrec2_;
430 min_templYrec_ = templYrec2_;
475 const float sig12 = 1./
sqrt(12.0);
502 bool edgex = (
theRecTopol->isItEdgePixelInX( minPixelRow ) ||
theRecTopol->isItEdgePixelInX( maxPixelRow ) );
503 bool edgey = (
theRecTopol->isItEdgePixelInY( minPixelCol ) ||
theRecTopol->isItEdgePixelInY( maxPixelCol ) );
524 throw cms::Exception(
"PixelCPETemplateReco::localError :") <<
"A non-pixel detector type in here?" ;
531 else if ( edgex || edgey )
534 if ( edgex && !edgey )
539 else if ( !edgex && edgey )
544 else if ( edgex && edgey )
551 throw cms::Exception(
" PixelCPETemplateReco::localError: Something wrong with pixel edge flag !!!");
575 " Sizex = " << cluster.
sizeX() <<
" Sizey = " << cluster.
sizeY() <<
" Edgex = " << edgex <<
" Edgey = " << edgey <<
576 " ErrX = " << xerr <<
" ErrY = " << yerr;
581 if ( !(xerr > 0.0
f) )
583 <<
"\nERROR: Negative pixel error xerr = " << xerr <<
"\n\n";
585 if ( !(yerr > 0.0
f) )
587 <<
"\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
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_
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 *)
Pixel cluster – collection of neighboring pixels above threshold.
LocalPoint localPosition(const SiPixelCluster &cluster) const
float getSplitClusterErrorX() const
bool pushfile(int filenum)
const int cluster_matrix_size_x
const PixelGeomDetUnit * theDet
virtual float localY(const float mpY) const =0