119 ClusterParamTemplate & theClusterParam =
static_cast<ClusterParamTemplate &
>(theClusterParamBase);
123 <<
"A non-pixel detector type in here?";
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;
260 if ( theClusterParam.with_track_angle )
262 theClusterParam.templXrec_ = theDetParam.theTopol->localX( theClusterParam.theCluster->x(), theClusterParam.loc_trk_pred ) - lorentz_drift * micronsToCm;
263 theClusterParam.templYrec_ = theDetParam.theTopol->localY( theClusterParam.theCluster->y(), theClusterParam.loc_trk_pred );
268 <<
"@SUB = PixelCPETemplateReco::localPosition"
269 <<
"Should never be here. PixelCPETemplateReco should always be called with track angles. This is a bad error !!! ";
271 theClusterParam.templXrec_ = theDetParam.theTopol->localX( theClusterParam.theCluster->x() ) - lorentz_drift * micronsToCm;
272 theClusterParam.templYrec_ = theDetParam.theTopol->localY( theClusterParam.theCluster->y() );
277 cout <<
" PixelCPETemplateReco : We should never be here !!!!!!!!!!!!!!!!!!!!!!" << endl;
291 std::vector< SiPixelTemplateStore2D > thePixelTemp2D_;
295 theClusterParam.ierr =
300 templYrec1_, templYrec2_, theClusterParam.templSigmaY_, theClusterParam.templProbY_,
301 templXrec1_, templXrec2_, theClusterParam.templSigmaX_, theClusterParam.templProbX_,
302 theClusterParam.templQbin_,
309 if ( theClusterParam.ierr != 0 )
311 LogDebug(
"PixelCPETemplateReco::localPosition") <<
312 "reconstruction failed with error " << theClusterParam.ierr <<
"\n";
317 float lorentz_drift = -999.9f;
319 lorentz_drift = 60.0f;
321 lorentz_drift = 10.0f;
324 if ( theClusterParam.with_track_angle )
326 theClusterParam.templXrec_ = theDetParam.theTopol->localX( theClusterParam.theCluster->x(),theClusterParam.loc_trk_pred ) - lorentz_drift * micronsToCm;
327 theClusterParam.templYrec_ = theDetParam.theTopol->localY( theClusterParam.theCluster->y(),theClusterParam.loc_trk_pred );
332 <<
"@SUB = PixelCPETemplateReco::localPosition"
333 <<
"Should never be here. PixelCPETemplateReco should always be called with track angles. This is a bad error !!! ";
335 theClusterParam.templXrec_ = theDetParam.theTopol->localX( theClusterParam.theCluster->x() ) - lorentz_drift * micronsToCm;
336 theClusterParam.templYrec_ = theDetParam.theTopol->localY( theClusterParam.theCluster->y() );
343 templXrec1_ *= micronsToCm;
344 templYrec1_ *= micronsToCm;
345 templXrec2_ *= micronsToCm;
346 templYrec2_ *= micronsToCm;
349 templXrec1_ += lp.
x();
350 templYrec1_ += lp.
y();
351 templXrec2_ += lp.
x();
352 templYrec2_ += lp.
y();
356 float distance11 =
sqrt( (templXrec1_ - theClusterParam.trk_lp_x)*(templXrec1_ - theClusterParam.trk_lp_x) +
357 (templYrec1_ - theClusterParam.trk_lp_y)*(templYrec1_ - theClusterParam.trk_lp_y) );
359 float distance12 =
sqrt( (templXrec1_ - theClusterParam.trk_lp_x)*(templXrec1_ - theClusterParam.trk_lp_x) +
360 (templYrec2_ - theClusterParam.trk_lp_y)*(templYrec2_ - theClusterParam.trk_lp_y) );
362 float distance21 =
sqrt( (templXrec2_ - theClusterParam.trk_lp_x)*(templXrec2_ - theClusterParam.trk_lp_x) +
363 (templYrec1_ - theClusterParam.trk_lp_y)*(templYrec1_ - theClusterParam.trk_lp_y) );
365 float distance22 =
sqrt( (templXrec2_ - theClusterParam.trk_lp_x)*(templXrec2_ - theClusterParam.trk_lp_x) +
366 (templYrec2_ - theClusterParam.trk_lp_y)*(templYrec2_ - theClusterParam.trk_lp_y) );
368 float min_templXrec_ = -999.9;
369 float min_templYrec_ = -999.9;
370 float distance_min = 9999999999.9;
371 if ( distance11 < distance_min )
373 distance_min = distance11;
374 min_templXrec_ = templXrec1_;
375 min_templYrec_ = templYrec1_;
377 if ( distance12 < distance_min )
379 distance_min = distance12;
380 min_templXrec_ = templXrec1_;
381 min_templYrec_ = templYrec2_;
383 if ( distance21 < distance_min )
385 distance_min = distance21;
386 min_templXrec_ = templXrec2_;
387 min_templYrec_ = templYrec1_;
389 if ( distance22 < distance_min )
391 distance_min = distance22;
392 min_templXrec_ = templXrec2_;
393 min_templYrec_ = templYrec2_;
396 theClusterParam.templXrec_ = min_templXrec_;
397 theClusterParam.templYrec_ = min_templYrec_;
404 theClusterParam.templXrec_ *= micronsToCm;
405 theClusterParam.templYrec_ *= micronsToCm;
408 theClusterParam.templXrec_ += lp.
x();
409 theClusterParam.templYrec_ += lp.
y();
414 if( theDetParam.lorentzShiftInCmX!= 0.0 || theDetParam.lorentzShiftInCmY!= 0.0 ) {
420 float templateLorbiasCmX = -micronsToCm*templ.lorxbias();
421 float templateLorbiasCmY = -micronsToCm*templ.lorybias();
425 theClusterParam.templXrec_ += (0.5*(theDetParam.lorentzShiftInCmX) - templateLorbiasCmX);
426 theClusterParam.templYrec_ += (0.5*(theDetParam.lorentzShiftInCmY) - templateLorbiasCmY);
441 theClusterParam.probabilityX_ = theClusterParam.templProbX_;
442 theClusterParam.probabilityY_ = theClusterParam.templProbY_;
443 theClusterParam.probabilityQ_ = theClusterParam.templProbQ_;
444 theClusterParam.qBin_ = theClusterParam.templQbin_;
446 if ( theClusterParam.ierr == 0 )
447 theClusterParam.hasFilledProb_ =
true;
449 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)
bool isEndcap(GeomDetEnumerators::SubDetector m)
bool isTrackerPixel(const GeomDetEnumerators::SubDetector m)