118 ClusterParamTemplate & theClusterParam =
static_cast<ClusterParamTemplate &
>(theClusterParamBase);
129 ID = theDetParam.detTemplateId;
130 if(ID0!=ID)
cout<<
" different id"<< ID<<
" "<<ID0<<endl;
132 if ( !fpix ) ID = 40;
141 boost::multi_array<float, 2> clust_array_2d(boost::extents[cluster_matrix_size_x][cluster_matrix_size_y]);
152 int row_offset = theClusterParam.theCluster->minPixelRow();
153 int col_offset = theClusterParam.theCluster->minPixelCol();
158 float tmp_x = float(row_offset) + 0.5f;
159 float tmp_y = float(col_offset) + 0.5f;
167 if ( theClusterParam.with_track_angle )
168 lp = theDetParam.theTopol->localPosition(
MeasurementPoint(tmp_x, tmp_y), theClusterParam.loc_trk_pred );
172 <<
"@SUB = PixelCPETemplateReco::localPosition"
173 <<
"Should never be here. PixelCPETemplateReco should always be called with track angles. This is a bad error !!! ";
179 for (
int i=0 ;
i!=theClusterParam.theCluster->size(); ++
i )
181 auto pix = theClusterParam.theCluster->pixel(
i);
186 int irow = int(pix.x) - row_offset;
187 int icol = int(pix.y) - col_offset;
191 if ( irow<cluster_matrix_size_x && icol<cluster_matrix_size_y )
193 clust_array_2d[irow][icol] = (float)pix.adc;
197 std::vector<bool> ydouble(cluster_matrix_size_y), xdouble(cluster_matrix_size_x);
199 for (
int irow = 0; irow < cluster_matrix_size_x; ++irow)
201 xdouble[irow] = theDetParam.theRecTopol->isItBigPixelInX( irow+row_offset );
205 for (
int icol = 0; icol < cluster_matrix_size_y; ++icol)
207 ydouble[icol] = theDetParam.theRecTopol->isItBigPixelInY( icol+col_offset );
211 float nonsense = -99999.9f;
212 theClusterParam.templXrec_ = theClusterParam.templYrec_ = theClusterParam.templSigmaX_ = theClusterParam.templSigmaY_ = nonsense;
214 theClusterParam.templProbY_ = theClusterParam.templProbX_ = theClusterParam.templProbQ_ = 1.0f;
215 theClusterParam.templQbin_ = 0;
217 theClusterParam.hasFilledProb_ =
false;
219 float templYrec1_ = nonsense;
220 float templXrec1_ = nonsense;
221 float templYrec2_ = nonsense;
222 float templXrec2_ = nonsense;
228 float locBz = theDetParam.bz;
230 theClusterParam.ierr =
231 PixelTempReco2D( ID, theClusterParam.cotalpha, theClusterParam.cotbeta,
233 clust_array_2d, ydouble, xdouble,
235 theClusterParam.templYrec_, theClusterParam.templSigmaY_, theClusterParam.templProbY_,
236 theClusterParam.templXrec_, theClusterParam.templSigmaX_, theClusterParam.templProbX_,
237 theClusterParam.templQbin_,
239 theClusterParam.templProbQ_
245 if unlikely( theClusterParam.ierr != 0 )
247 LogDebug(
"PixelCPETemplateReco::localPosition") <<
248 "reconstruction failed with error " << theClusterParam.ierr <<
"\n";
253 float lorentz_drift = -999.9;
255 lorentz_drift = 60.0f;
257 lorentz_drift = 10.0f;
260 <<
"A non-pixel detector type in here?" <<
"\n";
262 if ( theClusterParam.with_track_angle )
264 theClusterParam.templXrec_ = theDetParam.theTopol->localX( theClusterParam.theCluster->x(), theClusterParam.loc_trk_pred ) - lorentz_drift * micronsToCm;
265 theClusterParam.templYrec_ = theDetParam.theTopol->localY( theClusterParam.theCluster->y(), theClusterParam.loc_trk_pred );
270 <<
"@SUB = PixelCPETemplateReco::localPosition"
271 <<
"Should never be here. PixelCPETemplateReco should always be called with track angles. This is a bad error !!! ";
273 theClusterParam.templXrec_ = theDetParam.theTopol->localX( theClusterParam.theCluster->x() ) - lorentz_drift * micronsToCm;
274 theClusterParam.templYrec_ = theDetParam.theTopol->localY( theClusterParam.theCluster->y() );
279 cout <<
" PixelCPETemplateReco : We should never be here !!!!!!!!!!!!!!!!!!!!!!" << endl;
293 std::vector< SiPixelTemplateStore2D > thePixelTemp2D_;
297 theClusterParam.ierr =
302 templYrec1_, templYrec2_, theClusterParam.templSigmaY_, theClusterParam.templProbY_,
303 templXrec1_, templXrec2_, theClusterParam.templSigmaX_, theClusterParam.templProbX_,
304 theClusterParam.templQbin_,
311 if ( theClusterParam.ierr != 0 )
313 LogDebug(
"PixelCPETemplateReco::localPosition") <<
314 "reconstruction failed with error " << theClusterParam.ierr <<
"\n";
319 float lorentz_drift = -999.9f;
321 lorentz_drift = 60.0f;
323 lorentz_drift = 10.0f;
326 <<
"A non-pixel detector type in here?" <<
"\n";
329 if ( theClusterParam.with_track_angle )
331 theClusterParam.templXrec_ = theDetParam.theTopol->localX( theClusterParam.theCluster->x(),theClusterParam.loc_trk_pred ) - lorentz_drift * micronsToCm;
332 theClusterParam.templYrec_ = theDetParam.theTopol->localY( theClusterParam.theCluster->y(),theClusterParam.loc_trk_pred );
337 <<
"@SUB = PixelCPETemplateReco::localPosition"
338 <<
"Should never be here. PixelCPETemplateReco should always be called with track angles. This is a bad error !!! ";
340 theClusterParam.templXrec_ = theDetParam.theTopol->localX( theClusterParam.theCluster->x() ) - lorentz_drift * micronsToCm;
341 theClusterParam.templYrec_ = theDetParam.theTopol->localY( theClusterParam.theCluster->y() );
348 templXrec1_ *= micronsToCm;
349 templYrec1_ *= micronsToCm;
350 templXrec2_ *= micronsToCm;
351 templYrec2_ *= micronsToCm;
354 templXrec1_ += lp.
x();
355 templYrec1_ += lp.
y();
356 templXrec2_ += lp.
x();
357 templYrec2_ += lp.
y();
361 float distance11 =
sqrt( (templXrec1_ - theClusterParam.trk_lp_x)*(templXrec1_ - theClusterParam.trk_lp_x) +
362 (templYrec1_ - theClusterParam.trk_lp_y)*(templYrec1_ - theClusterParam.trk_lp_y) );
364 float distance12 =
sqrt( (templXrec1_ - theClusterParam.trk_lp_x)*(templXrec1_ - theClusterParam.trk_lp_x) +
365 (templYrec2_ - theClusterParam.trk_lp_y)*(templYrec2_ - theClusterParam.trk_lp_y) );
367 float distance21 =
sqrt( (templXrec2_ - theClusterParam.trk_lp_x)*(templXrec2_ - theClusterParam.trk_lp_x) +
368 (templYrec1_ - theClusterParam.trk_lp_y)*(templYrec1_ - theClusterParam.trk_lp_y) );
370 float distance22 =
sqrt( (templXrec2_ - theClusterParam.trk_lp_x)*(templXrec2_ - theClusterParam.trk_lp_x) +
371 (templYrec2_ - theClusterParam.trk_lp_y)*(templYrec2_ - theClusterParam.trk_lp_y) );
373 float min_templXrec_ = -999.9;
374 float min_templYrec_ = -999.9;
375 float distance_min = 9999999999.9;
376 if ( distance11 < distance_min )
378 distance_min = distance11;
379 min_templXrec_ = templXrec1_;
380 min_templYrec_ = templYrec1_;
382 if ( distance12 < distance_min )
384 distance_min = distance12;
385 min_templXrec_ = templXrec1_;
386 min_templYrec_ = templYrec2_;
388 if ( distance21 < distance_min )
390 distance_min = distance21;
391 min_templXrec_ = templXrec2_;
392 min_templYrec_ = templYrec1_;
394 if ( distance22 < distance_min )
396 distance_min = distance22;
397 min_templXrec_ = templXrec2_;
398 min_templYrec_ = templYrec2_;
401 theClusterParam.templXrec_ = min_templXrec_;
402 theClusterParam.templYrec_ = min_templYrec_;
409 theClusterParam.templXrec_ *= micronsToCm;
410 theClusterParam.templYrec_ *= micronsToCm;
413 theClusterParam.templXrec_ += lp.
x();
414 theClusterParam.templYrec_ += lp.
y();
419 if( theDetParam.lorentzShiftInCmX!= 0.0 || theDetParam.lorentzShiftInCmY!= 0.0 ) {
425 float templateLorbiasCmX = -micronsToCm*templ.lorxbias();
426 float templateLorbiasCmY = -micronsToCm*templ.lorybias();
428 theClusterParam.templXrec_ += 0.5*(theDetParam.lorentzShiftInCmX - templateLorbiasCmX);
429 theClusterParam.templYrec_ += 0.5*(theDetParam.lorentzShiftInCmY - templateLorbiasCmY);
438 theClusterParam.probabilityX_ = theClusterParam.templProbX_;
439 theClusterParam.probabilityY_ = theClusterParam.templProbY_;
440 theClusterParam.probabilityQ_ = theClusterParam.templProbQ_;
441 theClusterParam.qBin_ = theClusterParam.templQbin_;
443 if ( theClusterParam.ierr == 0 )
444 theClusterParam.hasFilledProb_ =
true;
446 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)