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;
149 int row_offset = theClusterParam.theCluster->minPixelRow();
150 int col_offset = theClusterParam.theCluster->minPixelCol();
155 float tmp_x = float(row_offset) + 0.5f;
156 float tmp_y = float(col_offset) + 0.5f;
164 if ( theClusterParam.with_track_angle )
165 lp = theDetParam.theTopol->localPosition(
MeasurementPoint(tmp_x, tmp_y), theClusterParam.loc_trk_pred );
169 <<
"@SUB = PixelCPETemplateReco::localPosition"
170 <<
"Should never be here. PixelCPETemplateReco should always be called with track angles. This is a bad error !!! ";
177 for (
int i=0 ;
i!=theClusterParam.theCluster->size(); ++
i )
179 auto pix = theClusterParam.theCluster->pixel(
i);
180 int irow = int(pix.x);
181 int icol = int(pix.y);
185 mrow -= row_offset; mrow+=1; mrow =
std::min(mrow,cluster_matrix_size_x);
186 mcol -= col_offset; mcol+=1; mcol =
std::min(mcol,cluster_matrix_size_y);
189 float clustMatrix[mrow][mcol];
190 memset(clustMatrix,0,
sizeof(
float)*mrow*mcol);
193 for (
int i=0 ;
i!=theClusterParam.theCluster->size(); ++
i )
195 auto pix = theClusterParam.theCluster->pixel(
i);
196 int irow = int(pix.x) - row_offset;
197 int icol = int(pix.y) - col_offset;
201 if ( (irow<mrow) & (icol<mcol) ) clustMatrix[irow][icol] = float(pix.adc);
207 bool xdouble[mrow], ydouble[mcol];
209 for (
int irow = 0; irow < mrow; ++irow)
210 xdouble[irow] = theDetParam.theRecTopol->isItBigPixelInX( irow+row_offset );
213 for (
int icol = 0; icol < mcol; ++icol)
214 ydouble[icol] = theDetParam.theRecTopol->isItBigPixelInY( icol+col_offset );
219 float nonsense = -99999.9f;
220 theClusterParam.templXrec_ = theClusterParam.templYrec_ = theClusterParam.templSigmaX_ = theClusterParam.templSigmaY_ = nonsense;
222 theClusterParam.templProbY_ = theClusterParam.templProbX_ = theClusterParam.templProbQ_ = 1.0f;
223 theClusterParam.templQbin_ = 0;
225 theClusterParam.hasFilledProb_ =
false;
227 float templYrec1_ = nonsense;
228 float templXrec1_ = nonsense;
229 float templYrec2_ = nonsense;
230 float templXrec2_ = nonsense;
236 float locBz = theDetParam.bz;
238 theClusterParam.ierr =
239 PixelTempReco2D( ID, theClusterParam.cotalpha, theClusterParam.cotbeta,
243 theClusterParam.templYrec_, theClusterParam.templSigmaY_, theClusterParam.templProbY_,
244 theClusterParam.templXrec_, theClusterParam.templSigmaX_, theClusterParam.templProbX_,
245 theClusterParam.templQbin_,
247 theClusterParam.templProbQ_
253 if unlikely( theClusterParam.ierr != 0 )
255 LogDebug(
"PixelCPETemplateReco::localPosition") <<
256 "reconstruction failed with error " << theClusterParam.ierr <<
"\n";
261 float lorentz_drift = -999.9;
263 lorentz_drift = 60.0f;
265 lorentz_drift = 10.0f;
267 if ( theClusterParam.with_track_angle )
269 theClusterParam.templXrec_ = theDetParam.theTopol->localX( theClusterParam.theCluster->x(), theClusterParam.loc_trk_pred ) - lorentz_drift * micronsToCm;
270 theClusterParam.templYrec_ = theDetParam.theTopol->localY( theClusterParam.theCluster->y(), theClusterParam.loc_trk_pred );
275 <<
"@SUB = PixelCPETemplateReco::localPosition"
276 <<
"Should never be here. PixelCPETemplateReco should always be called with track angles. This is a bad error !!! ";
278 theClusterParam.templXrec_ = theDetParam.theTopol->localX( theClusterParam.theCluster->x() ) - lorentz_drift * micronsToCm;
279 theClusterParam.templYrec_ = theDetParam.theTopol->localY( theClusterParam.theCluster->y() );
284 cout <<
" PixelCPETemplateReco : We should never be here !!!!!!!!!!!!!!!!!!!!!!" << endl;
296 std::vector< SiPixelTemplateStore2D > thePixelTemp2D_;
300 theClusterParam.ierr = -123;
317 if ( theClusterParam.ierr != 0 )
319 LogDebug(
"PixelCPETemplateReco::localPosition") <<
320 "reconstruction failed with error " << theClusterParam.ierr <<
"\n";
325 float lorentz_drift = -999.9f;
327 lorentz_drift = 60.0f;
329 lorentz_drift = 10.0f;
332 if ( theClusterParam.with_track_angle )
334 theClusterParam.templXrec_ = theDetParam.theTopol->localX( theClusterParam.theCluster->x(),theClusterParam.loc_trk_pred ) - lorentz_drift * micronsToCm;
335 theClusterParam.templYrec_ = theDetParam.theTopol->localY( theClusterParam.theCluster->y(),theClusterParam.loc_trk_pred );
340 <<
"@SUB = PixelCPETemplateReco::localPosition"
341 <<
"Should never be here. PixelCPETemplateReco should always be called with track angles. This is a bad error !!! ";
343 theClusterParam.templXrec_ = theDetParam.theTopol->localX( theClusterParam.theCluster->x() ) - lorentz_drift * micronsToCm;
344 theClusterParam.templYrec_ = theDetParam.theTopol->localY( theClusterParam.theCluster->y() );
351 templXrec1_ *= micronsToCm;
352 templYrec1_ *= micronsToCm;
353 templXrec2_ *= micronsToCm;
354 templYrec2_ *= micronsToCm;
357 templXrec1_ += lp.
x();
358 templYrec1_ += lp.
y();
359 templXrec2_ += lp.
x();
360 templYrec2_ += lp.
y();
364 float distance11 =
sqrt( (templXrec1_ - theClusterParam.trk_lp_x)*(templXrec1_ - theClusterParam.trk_lp_x) +
365 (templYrec1_ - theClusterParam.trk_lp_y)*(templYrec1_ - theClusterParam.trk_lp_y) );
367 float distance12 =
sqrt( (templXrec1_ - theClusterParam.trk_lp_x)*(templXrec1_ - theClusterParam.trk_lp_x) +
368 (templYrec2_ - theClusterParam.trk_lp_y)*(templYrec2_ - theClusterParam.trk_lp_y) );
370 float distance21 =
sqrt( (templXrec2_ - theClusterParam.trk_lp_x)*(templXrec2_ - theClusterParam.trk_lp_x) +
371 (templYrec1_ - theClusterParam.trk_lp_y)*(templYrec1_ - theClusterParam.trk_lp_y) );
373 float distance22 =
sqrt( (templXrec2_ - theClusterParam.trk_lp_x)*(templXrec2_ - theClusterParam.trk_lp_x) +
374 (templYrec2_ - theClusterParam.trk_lp_y)*(templYrec2_ - theClusterParam.trk_lp_y) );
376 float min_templXrec_ = -999.9;
377 float min_templYrec_ = -999.9;
378 float distance_min = 9999999999.9;
379 if ( distance11 < distance_min )
381 distance_min = distance11;
382 min_templXrec_ = templXrec1_;
383 min_templYrec_ = templYrec1_;
385 if ( distance12 < distance_min )
387 distance_min = distance12;
388 min_templXrec_ = templXrec1_;
389 min_templYrec_ = templYrec2_;
391 if ( distance21 < distance_min )
393 distance_min = distance21;
394 min_templXrec_ = templXrec2_;
395 min_templYrec_ = templYrec1_;
397 if ( distance22 < distance_min )
399 distance_min = distance22;
400 min_templXrec_ = templXrec2_;
401 min_templYrec_ = templYrec2_;
404 theClusterParam.templXrec_ = min_templXrec_;
405 theClusterParam.templYrec_ = min_templYrec_;
412 theClusterParam.templXrec_ *= micronsToCm;
413 theClusterParam.templYrec_ *= micronsToCm;
416 theClusterParam.templXrec_ += lp.
x();
417 theClusterParam.templYrec_ += lp.
y();
422 if( theDetParam.lorentzShiftInCmX!= 0.0 || theDetParam.lorentzShiftInCmY!= 0.0 ) {
428 float templateLorbiasCmX = -micronsToCm*templ.lorxbias();
429 float templateLorbiasCmY = -micronsToCm*templ.lorybias();
433 theClusterParam.templXrec_ += (0.5*(theDetParam.lorentzShiftInCmX) - templateLorbiasCmX);
434 theClusterParam.templYrec_ += (0.5*(theDetParam.lorentzShiftInCmY) - templateLorbiasCmY);
449 theClusterParam.probabilityX_ = theClusterParam.templProbX_;
450 theClusterParam.probabilityY_ = theClusterParam.templProbY_;
451 theClusterParam.probabilityQ_ = theClusterParam.templProbQ_;
452 theClusterParam.qBin_ = theClusterParam.templQbin_;
454 if ( theClusterParam.ierr == 0 )
455 theClusterParam.hasFilledProb_ =
true;
457 return LocalPoint( theClusterParam.templXrec_, theClusterParam.templYrec_ );
int PixelTempReco2D(int id, float cotalpha, float cotbeta, float locBz, ClusMatrix &cluster, 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)
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_
const SiPixelTemplateDBObject * templateDBobject_
bool isEndcap(GeomDetEnumerators::SubDetector m)
bool isTrackerPixel(const GeomDetEnumerators::SubDetector m)