119 ClusterParamTemplate & theClusterParam =
static_cast<ClusterParamTemplate &
>(theClusterParamBase);
130 ID = theDetParam.detTemplateId;
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 )
169 lp = theDetParam.theTopol->localPosition(
MeasurementPoint(tmp_x, tmp_y), theClusterParam.loc_trk_pred );
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)
202 xdouble[irow] = theDetParam.theRecTopol->isItBigPixelInX( irow+row_offset );
206 for (
int icol = 0; icol < cluster_matrix_size_y; ++icol)
208 ydouble[icol] = theDetParam.theRecTopol->isItBigPixelInY( icol+col_offset );
212 float nonsense = -99999.9f;
213 theClusterParam.templXrec_ = theClusterParam.templYrec_ = theClusterParam.templSigmaX_ = theClusterParam.templSigmaY_ = nonsense;
215 theClusterParam.templProbY_ = theClusterParam.templProbX_ = theClusterParam.templProbQ_ = 1.0f;
216 theClusterParam.templQbin_ = 0;
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,
236 theClusterParam.templYrec_, theClusterParam.templSigmaY_, theClusterParam.templProbY_,
237 theClusterParam.templXrec_, theClusterParam.templSigmaX_, theClusterParam.templProbX_,
238 theClusterParam.templQbin_,
240 theClusterParam.templProbQ_
246 if unlikely( theClusterParam.ierr != 0 )
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;
261 <<
"A non-pixel detector type in here?" <<
"\n";
263 if ( theClusterParam.with_track_angle )
265 theClusterParam.templXrec_ = theDetParam.theTopol->localX( theClusterParam.theCluster->x(), theClusterParam.loc_trk_pred ) - lorentz_drift * micronsToCm;
266 theClusterParam.templYrec_ = theDetParam.theTopol->localY( theClusterParam.theCluster->y(), theClusterParam.loc_trk_pred );
271 <<
"@SUB = PixelCPETemplateReco::localPosition"
272 <<
"Should never be here. PixelCPETemplateReco should always be called with track angles. This is a bad error !!! ";
274 theClusterParam.templXrec_ = theDetParam.theTopol->localX( theClusterParam.theCluster->x() ) - lorentz_drift * micronsToCm;
275 theClusterParam.templYrec_ = theDetParam.theTopol->localY( theClusterParam.theCluster->y() );
280 cout <<
" PixelCPETemplateReco : We should never be here !!!!!!!!!!!!!!!!!!!!!!" << endl;
294 std::vector< SiPixelTemplateStore2D > thePixelTemp2D_;
298 theClusterParam.ierr =
303 templYrec1_, templYrec2_, theClusterParam.templSigmaY_, theClusterParam.templProbY_,
304 templXrec1_, templXrec2_, theClusterParam.templSigmaX_, theClusterParam.templProbX_,
305 theClusterParam.templQbin_,
312 if ( theClusterParam.ierr != 0 )
314 LogDebug(
"PixelCPETemplateReco::localPosition") <<
315 "reconstruction failed with error " << theClusterParam.ierr <<
"\n";
320 float lorentz_drift = -999.9f;
322 lorentz_drift = 60.0f;
324 lorentz_drift = 10.0f;
327 <<
"A non-pixel detector type in here?" <<
"\n";
330 if ( theClusterParam.with_track_angle )
332 theClusterParam.templXrec_ = theDetParam.theTopol->localX( theClusterParam.theCluster->x(),theClusterParam.loc_trk_pred ) - lorentz_drift * micronsToCm;
333 theClusterParam.templYrec_ = theDetParam.theTopol->localY( theClusterParam.theCluster->y(),theClusterParam.loc_trk_pred );
338 <<
"@SUB = PixelCPETemplateReco::localPosition"
339 <<
"Should never be here. PixelCPETemplateReco should always be called with track angles. This is a bad error !!! ";
341 theClusterParam.templXrec_ = theDetParam.theTopol->localX( theClusterParam.theCluster->x() ) - lorentz_drift * micronsToCm;
342 theClusterParam.templYrec_ = theDetParam.theTopol->localY( theClusterParam.theCluster->y() );
349 templXrec1_ *= micronsToCm;
350 templYrec1_ *= micronsToCm;
351 templXrec2_ *= micronsToCm;
352 templYrec2_ *= micronsToCm;
355 templXrec1_ += lp.
x();
356 templYrec1_ += lp.
y();
357 templXrec2_ += lp.
x();
358 templYrec2_ += lp.
y();
362 float distance11 =
sqrt( (templXrec1_ - theClusterParam.trk_lp_x)*(templXrec1_ - theClusterParam.trk_lp_x) +
363 (templYrec1_ - theClusterParam.trk_lp_y)*(templYrec1_ - theClusterParam.trk_lp_y) );
365 float distance12 =
sqrt( (templXrec1_ - theClusterParam.trk_lp_x)*(templXrec1_ - theClusterParam.trk_lp_x) +
366 (templYrec2_ - theClusterParam.trk_lp_y)*(templYrec2_ - theClusterParam.trk_lp_y) );
368 float distance21 =
sqrt( (templXrec2_ - theClusterParam.trk_lp_x)*(templXrec2_ - theClusterParam.trk_lp_x) +
369 (templYrec1_ - theClusterParam.trk_lp_y)*(templYrec1_ - theClusterParam.trk_lp_y) );
371 float distance22 =
sqrt( (templXrec2_ - theClusterParam.trk_lp_x)*(templXrec2_ - theClusterParam.trk_lp_x) +
372 (templYrec2_ - theClusterParam.trk_lp_y)*(templYrec2_ - theClusterParam.trk_lp_y) );
374 float min_templXrec_ = -999.9;
375 float min_templYrec_ = -999.9;
376 float distance_min = 9999999999.9;
377 if ( distance11 < distance_min )
379 distance_min = distance11;
380 min_templXrec_ = templXrec1_;
381 min_templYrec_ = templYrec1_;
383 if ( distance12 < distance_min )
385 distance_min = distance12;
386 min_templXrec_ = templXrec1_;
387 min_templYrec_ = templYrec2_;
389 if ( distance21 < distance_min )
391 distance_min = distance21;
392 min_templXrec_ = templXrec2_;
393 min_templYrec_ = templYrec1_;
395 if ( distance22 < distance_min )
397 distance_min = distance22;
398 min_templXrec_ = templXrec2_;
399 min_templYrec_ = templYrec2_;
402 theClusterParam.templXrec_ = min_templXrec_;
403 theClusterParam.templYrec_ = min_templYrec_;
410 theClusterParam.templXrec_ *= micronsToCm;
411 theClusterParam.templYrec_ *= micronsToCm;
414 theClusterParam.templXrec_ += lp.
x();
415 theClusterParam.templYrec_ += lp.
y();
420 if( theDetParam.lorentzShiftInCmX!= 0.0 || theDetParam.lorentzShiftInCmY!= 0.0 ) {
426 float templateLorbiasCmX = -micronsToCm*templ.lorxbias();
427 float templateLorbiasCmY = -micronsToCm*templ.lorybias();
431 theClusterParam.templXrec_ += (0.5*(theDetParam.lorentzShiftInCmX) - templateLorbiasCmX);
432 theClusterParam.templYrec_ += (0.5*(theDetParam.lorentzShiftInCmY) - templateLorbiasCmY);
447 theClusterParam.probabilityX_ = theClusterParam.templProbX_;
448 theClusterParam.probabilityY_ = theClusterParam.templProbY_;
449 theClusterParam.probabilityQ_ = theClusterParam.templProbQ_;
450 theClusterParam.qBin_ = theClusterParam.templQbin_;
452 if ( theClusterParam.ierr == 0 )
453 theClusterParam.hasFilledProb_ =
true;
455 return LocalPoint( theClusterParam.templXrec_, theClusterParam.templYrec_ );
short getTemplateID(const uint32_t &detid) const
static bool pushfile(int filenum, std::vector< SiPixelTemplateStore2D > &thePixelTemp_)
std::vector< SiPixelTemplateStore > thePixelTemp_
Measurement2DPoint MeasurementPoint
Measurement points are two-dimensional by default.
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_
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)