CMS 3D CMS Logo

PixelCPEClusterRepair.cc
Go to the documentation of this file.
1 // Include our own header first
3 
4 // Geometry services
7 
8 // MessageLogger
10 
11 // Magnetic field
13 
14 
15 // Commented for now (3/10/17) until we figure out how to resuscitate 2D template splitter
17 
19 
20 #include <vector>
21 #include "boost/multi_array.hpp"
22 
23 #include <iostream>
24 
25 using namespace SiPixelTemplateReco;
26 //using namespace SiPixelTemplateSplit;
27 using namespace std;
28 
29 namespace {
30  constexpr float micronsToCm = 1.0e-4;
31  constexpr int cluster_matrix_size_x = 13;
32  constexpr int cluster_matrix_size_y = 21;
33 }
34 
35 //-----------------------------------------------------------------------------
36 // Constructor.
37 //
38 //-----------------------------------------------------------------------------
40  const MagneticField * mag,
41  const TrackerGeometry& geom,
42  const TrackerTopology& ttopo,
43  const SiPixelLorentzAngle * lorentzAngle,
44  const SiPixelTemplateDBObject * templateDBobject,
45  const SiPixel2DTemplateDBObject * templateDBobject2D )
46 : PixelCPEBase(conf, mag, geom, ttopo, lorentzAngle, nullptr, templateDBobject, nullptr,1)
47 {
48  LogDebug("PixelCPEClusterRepair::(constructor)") << endl;
49 
50  //--- Parameter to decide between DB or text file template access
52  {
53  // Initialize template store to the selected ID [Morris, 6/25/08]
55  throw cms::Exception("PixelCPEClusterRepair")
56  << "\nERROR: Templates not filled correctly. Check the sqlite file. Using SiPixelTemplateDBObject version "
57  << (*templateDBobject_).version() << "\n\n";
58 
59  // Initialize template store to the selected ID [Morris, 6/25/08]
60  if ( !SiPixelTemplate2D::pushfile( *templateDBobject2D , thePixelTemp2D_) )
61  throw cms::Exception("PixelCPEClusterRepair")
62  << "\nERROR: Templates not filled correctly. Check the sqlite file. Using SiPixelTemplateDBObject version "
63  << (*templateDBobject_).version() << "\n\n";
64  }
65  else
66  {
67  LogDebug("PixelCPEClusterRepair") << "Loading templates for barrel and forward from ASCII files." << endl;
68  //--- (Archaic) Get configurable template IDs. This code executes only if we loading pixels from ASCII
69  // files, and then they are mandatory.
70  barrelTemplateID_ = conf.getParameter<int>( "barrelTemplateID" );
71  forwardTemplateID_ = conf.getParameter<int>( "forwardTemplateID" );
72  templateDir_ = conf.getParameter<int>( "directoryWithTemplates" );
73 
75  throw cms::Exception("PixelCPEClusterRepair")
76  << "\nERROR: Template ID " << barrelTemplateID_ << " not loaded correctly from text file. Reconstruction will fail.\n\n";
77 
78  if ( !SiPixelTemplate::pushfile( forwardTemplateID_ , thePixelTemp_ , templateDir_ ) )
79  throw cms::Exception("PixelCPEClusterRepair")
80  << "\nERROR: Template ID " << forwardTemplateID_ << " not loaded correctly from text file. Reconstruction will fail.\n\n";
81  }
82 
83  speed_ = conf.getParameter<int>( "speed");
84  LogDebug("PixelCPEClusterRepair::PixelCPEClusterRepair:") <<
85  "Template speed = " << speed_ << "\n";
86 
87  UseClusterSplitter_ = conf.getParameter<bool>("UseClusterSplitter");
88 
89 
90  //--- Configure 2D reco.
91  if ( conf.exists("MinProbY") )
92  minProbY_ = conf.getParameter<double>("MinProbY");
93  else
94  minProbY_ = 0.001; // probabilityY < 0.001
95 
96  if ( conf.exists("MaxSizeMismatchInY") )
97  maxSizeMismatchInY_ = conf.getParameter<int>("MaxSizeMismatchInY");
98  else
99  maxSizeMismatchInY_ = 1; // ( templ.clsleny() - nypix > 1)
100 
101 }
102 
103 
104 
105 //-----------------------------------------------------------------------------
106 // Clean up.
107 //-----------------------------------------------------------------------------
109 {
110  for (auto x : thePixelTemp_) x.destroy();
111  for (auto x : thePixelTemp2D_) x.destroy();
112 }
113 
115 {
116  return new ClusterParamTemplate(cl);
117 }
118 
119 
120 
121 //------------------------------------------------------------------
122 // Public methods mandated by the base class.
123 //------------------------------------------------------------------
124 
125 //------------------------------------------------------------------
126 // The main call to the template code.
127 //------------------------------------------------------------------
129 PixelCPEClusterRepair::localPosition(DetParam const & theDetParam, ClusterParam & theClusterParamBase) const
130 {
131 
132  ClusterParamTemplate & theClusterParam = static_cast<ClusterParamTemplate &>(theClusterParamBase);
133  bool filled_from_2d = false;
134 
136  throw cms::Exception("PixelCPEClusterRepair::localPosition :")
137  << "A non-pixel detector type in here?";
138 
139  int ID = -9999;
140  if ( LoadTemplatesFromDB_ ) {
141  int ID0 = templateDBobject_->getTemplateID(theDetParam.theDet->geographicalId()); // just to comapre
142  ID = theDetParam.detTemplateId;
143  if(ID0!=ID) edm::LogError("PixelCPEClusterRepair") <<" different id"<< ID<<" "<<ID0<<endl;
144  } else { // from asci file
145  if ( ! GeomDetEnumerators::isEndcap(theDetParam.thePart) )
146  ID = barrelTemplateID_ ; // barrel
147  else
148  ID = forwardTemplateID_ ; // forward
149  }
150  //cout << "PixelCPEClusterRepair : ID = " << ID << endl;
151 
152  // &&& PM, note for later: PixelCPEBase calculates minInX,Y, and maxInX,Y
153  // Why can't we simply use that and save time with row_offset, col_offset
154  // and mrow = maxInX-minInX, mcol = maxInY-minInY ... Except that we
155  // also need to take into account cluster_matrix_size_x,y.
156 
157 
158  //--- Preparing to retrieve ADC counts from the SiPixeltheClusterParam.theCluster
159  // The pixels from minPixelRow() will go into clust_array_2d[0][*],
160  // and the pixels from minPixelCol() will go into clust_array_2d[*][0].
161  int row_offset = theClusterParam.theCluster->minPixelRow();
162  int col_offset = theClusterParam.theCluster->minPixelCol();
163 
164  //--- Store the coordinates of the center of the (0,0) pixel of the array that
165  // gets passed to PixelTempReco2D. Will add these values to the output of TemplReco2D
166  float tmp_x = float(row_offset) + 0.5f;
167  float tmp_y = float(col_offset) + 0.5f;
168 
169 
170  //--- Store these offsets (to be added later) in a LocalPoint after tranforming
171  // them from measurement units (pixel units) to local coordinates (cm)
172  LocalPoint lp;
173  if ( theClusterParam.with_track_angle )
174  //--- Update call with trk angles needed for bow/kink corrections // Gavril
175  lp = theDetParam.theTopol->localPosition( MeasurementPoint(tmp_x, tmp_y), theClusterParam.loc_trk_pred );
176  else
177  {
178  edm::LogError("PixelCPEClusterRepair")
179  << "@SUB = PixelCPEClusterRepair::localPosition"
180  << "Should never be here. PixelCPEClusterRepair should always be called with track angles. This is a bad error !!! ";
181  lp = theDetParam.theTopol->localPosition( MeasurementPoint(tmp_x, tmp_y) );
182  }
183 
184  //--- Compute the size of the matrix which will be passed to TemplateReco.
185  // We'll later make clustMatrix[ mrow ][ mcol ]
186  int mrow=0, mcol=0;
187  for (int i=0 ; i!=theClusterParam.theCluster->size(); ++i )
188  {
189  auto pix = theClusterParam.theCluster->pixel(i);
190  int irow = int(pix.x);
191  int icol = int(pix.y);
192  mrow = std::max(mrow,irow);
193  mcol = std::max(mcol,icol);
194  }
195  mrow -= row_offset; mrow+=1; mrow = std::min(mrow,cluster_matrix_size_x);
196  mcol -= col_offset; mcol+=1; mcol = std::min(mcol,cluster_matrix_size_y);
197  assert(mrow>0); assert(mcol>0);
198 
199 
200  //--- Make and fill the bool arrays flagging double pixels
201  bool xdouble[mrow], ydouble[mcol];
202  // x directions (shorter), rows
203  for (int irow = 0; irow < mrow; ++irow)
204  xdouble[irow] = theDetParam.theRecTopol->isItBigPixelInX( irow+row_offset );
205  //
206  // y directions (longer), columns
207  for (int icol = 0; icol < mcol; ++icol)
208  ydouble[icol] = theDetParam.theRecTopol->isItBigPixelInY( icol+col_offset );
209 
210  //--- C-style matrix. We'll need it in either case.
211  float clustMatrix[mrow][mcol];
212  float clustMatrix2[mrow][mcol];
213 
214  //--- Prepare struct that passes pointers to TemplateReco. It doesn't own anything.
215  SiPixelTemplateReco::ClusMatrix clusterPayload { &clustMatrix[0][0], xdouble, ydouble, mrow,mcol};
216  SiPixelTemplateReco2D::ClusMatrix clusterPayload2d{ &clustMatrix2[0][0], xdouble, ydouble, mrow,mcol};
217 
218 
219  //--- Copy clust's pixels (calibrated in electrons) into clustMatrix;
220  memset( clustMatrix, 0, sizeof(float)*mrow*mcol ); // Wipe it clean.
221  for (int i=0 ; i!=theClusterParam.theCluster->size(); ++i )
222  {
223  auto pix = theClusterParam.theCluster->pixel(i);
224  int irow = int(pix.x) - row_offset;
225  int icol = int(pix.y) - col_offset;
226  // &&& Do we ever get pixels that are out of bounds ??? Need to check.
227  if ( (irow<mrow) & (icol<mcol) ) clustMatrix[irow][icol] = float(pix.adc);
228  }
229  // &&& Save for later: fillClustMatrix( float * clustMatrix );
230 
231  //--- Save a copy of clustMatrix into clustMatrix2
232  memcpy( clustMatrix2, clustMatrix, sizeof(float)*mrow*mcol);
233 
234  //--- Set both return statuses, since we may call only one.
235  theClusterParam.ierr = 0;
236  theClusterParam.ierr2 = 0;
237 
238 
239 
240  //--- Are we on edge?
241  if ( theClusterParam.isOnEdge_ ) {
242  //--- Call the Template Reco 2d with cluster repair.0
243  filled_from_2d = true;
244  callTempReco2D( theDetParam, theClusterParam, clusterPayload2d, ID, lp );
245  }
246  else {
247  theClusterParam.recommended2D_ = false;
248  //--- Call the vanilla Template Reco
249  callTempReco1D( theDetParam, theClusterParam, clusterPayload, ID, lp );
250 
251  //--- Did we find a cluster which has bad probability and not enough charge?
252  if ( theClusterParam.recommended2D_ ) {
253  //--- Yes. So run Template Reco 2d with cluster repair.
254 
255  //--- Call the Template Reco 2d with cluster repair
256  callTempReco2D( theDetParam, theClusterParam, clusterPayload2d, ID, lp );
257  filled_from_2d = true;
258  }
259 
260  }
261 
262  //--- Make sure cluster repair returns all info about the hit back up to caller
263  //--- Necessary because it copied the base class so it does not modify it
264  theClusterParamBase.isOnEdge_ = theClusterParam.isOnEdge_;
265  theClusterParamBase.hasBadPixels_ = theClusterParam.hasBadPixels_;
266  theClusterParamBase.spansTwoROCs_ = theClusterParam.spansTwoROCs_;
267  theClusterParamBase.hasFilledProb_ = theClusterParam.hasFilledProb_;
268  theClusterParamBase.qBin_ = theClusterParam.qBin_;
269  theClusterParamBase.probabilityQ_ = theClusterParam.probabilityQ_;
270  theClusterParamBase.filled_from_2d = filled_from_2d;
271  if(filled_from_2d){
272  theClusterParamBase.probabilityX_ = theClusterParam.templProbXY_;
273  theClusterParamBase.probabilityY_ = 0.;
274  }
275  else{
276  theClusterParamBase.probabilityX_ = theClusterParam.probabilityX_;
277  theClusterParamBase.probabilityY_ = theClusterParam.probabilityY_;
278  }
279 
280 
281 
282  return LocalPoint( theClusterParam.templXrec_, theClusterParam.templYrec_ );
283 }
284 
285 
286 //------------------------------------------------------------------
287 // Helper function to aggregate call & handling of Template Reco
288 //------------------------------------------------------------------
289 void
291  ClusterParamTemplate & theClusterParam,
292  SiPixelTemplateReco::ClusMatrix & clusterPayload,
293  int ID, LocalPoint & lp ) const
294 {
296 
297  // Output:
298  float nonsense = -99999.9f; // nonsense init value
299  theClusterParam.templXrec_ = theClusterParam.templYrec_ = theClusterParam.templSigmaX_ = theClusterParam.templSigmaY_ = nonsense;
300  // If the template recontruction fails, we want to return 1.0 for now
301  theClusterParam.probabilityX_ = theClusterParam.probabilityY_ = theClusterParam.probabilityQ_ = 1.f;
302  theClusterParam.qBin_ = 0;
303  // We have a boolean denoting whether the reco failed or not
304  theClusterParam.hasFilledProb_ = false;
305 
306  // ******************************************************************
307  //--- Call normal TemplateReco
308  //
309  float locBz = theDetParam.bz;
310  float locBx = theDetParam.bx;
311  //
312  const bool deadpix = false;
313  std::vector<std::pair<int, int> > zeropix;
314  int nypix =0, nxpix = 0;
315  //
316  theClusterParam.ierr =
317  PixelTempReco1D( ID, theClusterParam.cotalpha, theClusterParam.cotbeta,
318  locBz, locBx,
319  clusterPayload,
320  templ,
321  theClusterParam.templYrec_, theClusterParam.templSigmaY_, theClusterParam.probabilityY_,
322  theClusterParam.templXrec_, theClusterParam.templSigmaX_, theClusterParam.probabilityX_,
323  theClusterParam.qBin_,
324  speed_, deadpix, zeropix,
325  theClusterParam.probabilityQ_, nypix, nxpix
326  );
327  // ******************************************************************
328 
329  //--- Check exit status
330  if UNLIKELY( theClusterParam.ierr != 0 )
331  {
332  LogDebug("PixelCPEClusterRepair::localPosition") <<
333  "reconstruction failed with error " << theClusterParam.ierr << "\n";
334 
335  theClusterParam.probabilityX_ = theClusterParam.probabilityY_ = theClusterParam.probabilityQ_ = 0.f;
336  theClusterParam.qBin_ = 0;
337 
338  // Gavril: what do we do in this case ? For now, just return the cluster center of gravity in microns
339  // In the x case, apply a rough Lorentz drift average correction
340  // To do: call PixelCPEGeneric whenever PixelTempReco1D fails
341  float lorentz_drift = -999.9;
342  if ( ! GeomDetEnumerators::isEndcap(theDetParam.thePart) )
343  lorentz_drift = 60.0f; // in microns
344  else
345  lorentz_drift = 10.0f; // in microns
346  // GG: trk angles needed to correct for bows/kinks
347  if ( theClusterParam.with_track_angle )
348  {
349  theClusterParam.templXrec_ = theDetParam.theTopol->localX( theClusterParam.theCluster->x(), theClusterParam.loc_trk_pred ) - lorentz_drift * micronsToCm; // rough Lorentz drift correction
350  theClusterParam.templYrec_ = theDetParam.theTopol->localY( theClusterParam.theCluster->y(), theClusterParam.loc_trk_pred );
351  }
352  else
353  {
354  edm::LogError("PixelCPEClusterRepair")
355  << "@SUB = PixelCPEClusterRepair::localPosition"
356  << "Should never be here. PixelCPEClusterRepair should always be called with track angles. This is a bad error !!! ";
357 
358  theClusterParam.templXrec_ = theDetParam.theTopol->localX( theClusterParam.theCluster->x() ) - lorentz_drift * micronsToCm; // rough Lorentz drift correction
359  theClusterParam.templYrec_ = theDetParam.theTopol->localY( theClusterParam.theCluster->y() );
360  }
361  }
362  else
363  {
364  //--- Template Reco succeeded. The probabilities are filled.
365  theClusterParam.hasFilledProb_ = true;
366 
367  //--- templ.clsleny() is the expected length of the cluster along y axis.
368  if ( (theClusterParam.probabilityY_ < minProbY_ ) && (templ.clsleny() - nypix > 1) ) {
369  theClusterParam.recommended2D_ = true;
370  }
371 
372  //--- Go from microns to centimeters
373  theClusterParam.templXrec_ *= micronsToCm;
374  theClusterParam.templYrec_ *= micronsToCm;
375 
376  //--- Go back to the module coordinate system
377  theClusterParam.templXrec_ += lp.x();
378  theClusterParam.templYrec_ += lp.y();
379 
380  }
381  return;
382 }
383 
384 
385 
386 
387 //------------------------------------------------------------------
388 // Helper function to aggregate call & handling of Template 2D fit
389 //------------------------------------------------------------------
390 void
392  ClusterParamTemplate & theClusterParam,
393  SiPixelTemplateReco2D::ClusMatrix & clusterPayload,
394  int ID, LocalPoint & lp ) const
395 {
397 
398  // Output:
399  float nonsense = -99999.9f; // nonsense init value
400  theClusterParam.templXrec_ = theClusterParam.templYrec_ = theClusterParam.templSigmaX_ = theClusterParam.templSigmaY_ = nonsense;
401  // If the template recontruction fails, we want to return 1.0 for now
402  theClusterParam.probabilityX_ = theClusterParam.probabilityY_ = theClusterParam.probabilityQ_ = 1.f;
403  theClusterParam.qBin_ = 0;
404  // We have a boolean denoting whether the reco failed or not
405  theClusterParam.hasFilledProb_ = false;
406 
407  // ******************************************************************
408  //--- Call 2D TemplateReco
409  //
410  float locBz = theDetParam.bz;
411  float locBx = theDetParam.bx;
412 
413  //--- Input:
414  // edgeflagy - (input) flag to indicate the present of edges in y:
415  // 0=none (or interior gap),1=edge at small y, 2=edge at large y, 3=edge at either end
416  //
417  // edgeflagx - (input) flag to indicate the present of edges in x:
418  // 0=none, 1=edge at small x, 2=edge at large x
419  //
420  // These two variables are calculated in setTheClu() and stored in edgeTypeX_ and edgeTypeY_
421  //
422  //--- Output:
423  // deltay - (output) template y-length - cluster length [when > 0, possibly missing end]
424  // npixels - ??? &&& Ask Morris
425 
426  float edgeTypeY = theClusterParam.edgeTypeY_ ; // the default, from PixelCPEBase
427  if ( theClusterParam.recommended2D_ ) {
428  // Cluster is not on edge, but instead the normal TemplateReco discovered that it is
429  // shorter than expected. So let the 2D algorithm try extending it on both sides, in case
430  // there is a dead double-column on either side. (We don't know which.)
431  edgeTypeY = 3;
432  }
433 
434  float deltay = 0; // return param
435  int npixels = 0; // return param
436 
437  if(clusterPayload.mrow > 4){
438  // The cluster is too big, the 2D reco will perform horribly.
439  // Better to return immediately in error
440  theClusterParam.ierr2 = 8;
441 
442  }
443  else{
444  theClusterParam.ierr2 =
445  PixelTempReco2D( ID, theClusterParam.cotalpha, theClusterParam.cotbeta,
446  locBz, locBx,
447  edgeTypeY , theClusterParam.edgeTypeX_ ,
448  clusterPayload,
449  templ2d,
450  theClusterParam.templYrec_, theClusterParam.templSigmaY_,
451  theClusterParam.templXrec_, theClusterParam.templSigmaX_,
452  theClusterParam.templProbXY_,
453  theClusterParam.probabilityQ_,
454  theClusterParam.qBin_,
455  deltay, npixels
456  );
457  }
458  // ******************************************************************
459 
460  //--- Check exit status
461  if UNLIKELY( theClusterParam.ierr2 != 0 )
462  {
463  LogDebug("PixelCPEClusterRepair::localPosition") <<
464  "2D reconstruction failed with error " << theClusterParam.ierr2 << "\n";
465 
466  theClusterParam.probabilityX_ = theClusterParam.probabilityY_ = theClusterParam.probabilityQ_ = 0.f;
467  theClusterParam.qBin_ = 0;
468  // GG: what do we do in this case? For now, just return the cluster center of gravity in microns
469  // In the x case, apply a rough Lorentz drift average correction
470  float lorentz_drift = -999.9;
471  if ( ! GeomDetEnumerators::isEndcap(theDetParam.thePart) )
472  lorentz_drift = 60.0f; // in microns // &&& replace with a constant (globally)
473  else
474  lorentz_drift = 10.0f; // in microns
475  // GG: trk angles needed to correct for bows/kinks
476  if ( theClusterParam.with_track_angle )
477  {
478  theClusterParam.templXrec_ = theDetParam.theTopol->localX( theClusterParam.theCluster->x(), theClusterParam.loc_trk_pred ) - lorentz_drift * micronsToCm; // rough Lorentz drift correction
479  theClusterParam.templYrec_ = theDetParam.theTopol->localY( theClusterParam.theCluster->y(), theClusterParam.loc_trk_pred );
480  }
481  else
482  {
483  edm::LogError("PixelCPEClusterRepair")
484  << "@SUB = PixelCPEClusterRepair::localPosition"
485  << "Should never be here. PixelCPEClusterRepair should always be called with track angles. This is a bad error !!! ";
486 
487  theClusterParam.templXrec_ = theDetParam.theTopol->localX( theClusterParam.theCluster->x() ) - lorentz_drift * micronsToCm; // rough Lorentz drift correction
488  theClusterParam.templYrec_ = theDetParam.theTopol->localY( theClusterParam.theCluster->y() );
489  }
490  }
491  else
492  {
493  //--- Template Reco succeeded.
494  theClusterParam.hasFilledProb_ = true;
495 
496  //--- Go from microns to centimeters
497  theClusterParam.templXrec_ *= micronsToCm;
498  theClusterParam.templYrec_ *= micronsToCm;
499 
500  //--- Go back to the module coordinate system
501  theClusterParam.templXrec_ += lp.x();
502  theClusterParam.templYrec_ += lp.y();
503  }
504  return;
505 }
506 
507 
508 
509 
510 //------------------------------------------------------------------
511 // localError() relies on localPosition() being called FIRST!!!
512 //------------------------------------------------------------------
514 PixelCPEClusterRepair::localError(DetParam const & theDetParam, ClusterParam & theClusterParamBase) const
515 {
516 
517  ClusterParamTemplate & theClusterParam = static_cast<ClusterParamTemplate &>(theClusterParamBase);
518 
519  //--- Default is the maximum error used for edge clusters.
520  //--- (never used, in fact: let comment it out, shut up the complains of the static analyzer, and save a few CPU cycles)
521  float xerr = 0.0f, yerr = 0.0f;
522 
523  //--- Check status of both template calls.
524  if UNLIKELY ( (theClusterParam.ierr !=0) || (theClusterParam.ierr2 !=0) ) {
525  // If reconstruction fails the hit position is calculated from cluster center of gravity
526  // corrected in x by average Lorentz drift. Assign huge errors.
527  //
529  throw cms::Exception("PixelCPEClusterRepair::localPosition :")
530  << "A non-pixel detector type in here?";
531 
532  // Assign better errors based on the residuals for failed template cases
533  if ( GeomDetEnumerators::isBarrel(theDetParam.thePart)) {
534  xerr = 55.0f * micronsToCm; // &&& get errors from elsewhere?
535  yerr = 36.0f * micronsToCm;
536  }
537  else {
538  xerr = 42.0f * micronsToCm;
539  yerr = 39.0f * micronsToCm;
540  }
541  }
542  // Leave commented for now, until we study the interplay of failure modes
543  // of 1D template reco and edges. For edge hits we run 2D reco by default!
544  //
545  // else if ( theClusterParam.edgeTypeX_ || theClusterParam.edgeTypeY_ ) {
546  // // for edge pixels assign errors according to observed residual RMS
547  // if ( theClusterParam.edgeTypeX_ && !theClusterParam.edgeTypeY_ ) {
548  // xerr = 23.0f * micronsToCm;
549  // yerr = 39.0f * micronsToCm;
550  // }
551  // else if ( !theClusterParam.edgeTypeX_ && theClusterParam.edgeTypeY_ ) {
552  // xerr = 24.0f * micronsToCm;
553  // yerr = 96.0f * micronsToCm;
554  // }
555  // else if ( theClusterParam.edgeTypeX_ && theClusterParam.edgeTypeY_ ) {
556  // xerr = 31.0f * micronsToCm;
557  // yerr = 90.0f * micronsToCm;
558  // }
559  // }
560  else {
561  xerr = theClusterParam.templSigmaX_ * micronsToCm;
562  yerr = theClusterParam.templSigmaY_ * micronsToCm;
563  // &&& should also check ierr (saved as class variable) and return
564  // &&& nonsense (another class static) if the template fit failed.
565  }
566 
567  if (theVerboseLevel > 9) {
568  LogDebug("PixelCPEClusterRepair")
569  << " Sizex = " << theClusterParam.theCluster->sizeX()
570  << " Sizey = " << theClusterParam.theCluster->sizeY()
571  << " Edgex = " << theClusterParam.edgeTypeX_
572  << " Edgey = " << theClusterParam.edgeTypeY_
573  << " ErrX = " << xerr << " ErrY = " << yerr;
574  }
575 
576 
577  if ( !(xerr > 0.0f) )
578  throw cms::Exception("PixelCPEClusterRepair::localError")
579  << "\nERROR: Negative pixel error xerr = " << xerr << "\n\n";
580 
581  if ( !(yerr > 0.0f) )
582  throw cms::Exception("PixelCPEClusterRepair::localError")
583  << "\nERROR: Negative pixel error yerr = " << yerr << "\n\n";
584 
585  return LocalError(xerr*xerr, 0, yerr*yerr);
586 }
587 
#define LogDebug(id)
LocalError localError(DetParam const &theDetParam, ClusterParam &theClusterParam) const override
T getParameter(std::string const &) const
int minPixelCol() const
Point3DBase< Scalar, LocalTag > LocalPoint
Definition: Definitions.h:32
std::vector< SiPixelTemplateStore > thePixelTemp_
int PixelTempReco2D(int id, float cotalpha, float cotbeta, float locBz, float locBx, int edgeflagy, int edgeflagx, ClusMatrix &cluster, SiPixelTemplate2D &templ, float &yrec, float &sigmay, float &xrec, float &sigmax, float &probxy, float &probQ, int &qbin, float &deltay, int &npixel)
short getTemplateID(const uint32_t &detid) const
T mag() const
The vector magnitude. Equivalent to sqrt(vec.mag2())
const SiPixelCluster * theCluster
Definition: PixelCPEBase.h:87
uint32_t ID
Definition: Definitions.h:26
bool isBarrel(GeomDetEnumerators::SubDetector m)
T y() const
Definition: PV3DBase.h:63
bool exists(std::string const &parameterName) const
checks if a parameter exists
int PixelTempReco1D(int id, float cotalpha, float cotbeta, float locBz, float locBx, 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, int &nypix, int &nxpix)
ClusterParam * createClusterParam(const SiPixelCluster &cl) const override
#define nullptr
const PixelGeomDetUnit * theDet
Definition: PixelCPEBase.h:60
GeomDetType::SubDetector thePart
Definition: PixelCPEBase.h:65
#define constexpr
const RectangularPixelTopology * theRecTopol
Definition: PixelCPEBase.h:63
PixelCPEClusterRepair(edm::ParameterSet const &conf, const MagneticField *, const TrackerGeometry &, const TrackerTopology &, const SiPixelLorentzAngle *, const SiPixelTemplateDBObject *, const SiPixel2DTemplateDBObject *)
Measurement2DPoint MeasurementPoint
Measurement points are two-dimensional by default.
const PixelTopology * theTopol
Definition: PixelCPEBase.h:62
int minPixelRow() const
bool LoadTemplatesFromDB_
Definition: PixelCPEBase.h:257
float clsleny()
y-size of smaller interpolated template in pixels
const SiPixelTemplateDBObject * templateDBobject_
Definition: PixelCPEBase.h:253
virtual float localX(float mpX) const =0
DetId geographicalId() const
The label of this GeomDet.
Definition: GeomDet.h:79
double f[11][100]
std::vector< SiPixelTemplateStore2D > thePixelTemp2D_
T min(T a, T b)
Definition: MathUtil.h:58
void callTempReco2D(DetParam const &theDetParam, ClusterParamTemplate &theClusterParam, SiPixelTemplateReco2D::ClusMatrix &clusterPayload, int ID, LocalPoint &lp) const
bool isEndcap(GeomDetEnumerators::SubDetector m)
bool isItBigPixelInY(const int iybin) const override
bool isItBigPixelInX(const int ixbin) const override
Topology::LocalTrackPred loc_trk_pred
Definition: PixelCPEBase.h:101
static bool pushfile(int filenum, std::vector< SiPixelTemplateStore2D > &pixelTemp, std::string dir="")
virtual LocalPoint localPosition(const MeasurementPoint &) const =0
void callTempReco1D(DetParam const &theDetParam, ClusterParamTemplate &theClusterParam, SiPixelTemplateReco::ClusMatrix &clusterPayload, int ID, LocalPoint &lp) const
static bool pushfile(int filenum, std::vector< SiPixelTemplateStore > &pixelTemp, std::string dir="CalibTracker/SiPixelESProducers/data/")
int sizeY() const
Pixel cluster – collection of neighboring pixels above threshold.
Pixel pixel(int i) const
float y() const
virtual float localY(float mpY) const =0
int sizeX() const
T x() const
Definition: PV3DBase.h:62
float x() const
bool isTrackerPixel(GeomDetEnumerators::SubDetector m)
LocalPoint localPosition(DetParam const &theDetParam, ClusterParam &theClusterParam) const override
#define UNLIKELY(x)
int size() const