CMS 3D CMS Logo

PixelCPETemplateReco.cc
Go to the documentation of this file.
1 // Include our own header first
3 
4 // Geometry services
7 
8 //#define DEBUG
9 
10 // MessageLogger
12 
13 // Magnetic field
15 
16 // The template header files
18 
19 // Commented for now (3/10/17) until we figure out how to resuscitate 2D template splitter
21 
23 
24 #include <vector>
25 #include "boost/multi_array.hpp"
26 
27 #include <iostream>
28 
29 using namespace SiPixelTemplateReco;
30 //using namespace SiPixelTemplateSplit;
31 using namespace std;
32 
33 namespace {
34  constexpr float micronsToCm = 1.0e-4;
35  constexpr int cluster_matrix_size_x = 13;
36  constexpr int cluster_matrix_size_y = 21;
37 }
38 
39 //-----------------------------------------------------------------------------
40 // Constructor.
41 //
42 //-----------------------------------------------------------------------------
44  const MagneticField * mag,
45  const TrackerGeometry& geom,
46  const TrackerTopology& ttopo,
47  const SiPixelLorentzAngle * lorentzAngle,
48  const SiPixelTemplateDBObject * templateDBobject)
49 : PixelCPEBase(conf, mag, geom, ttopo, lorentzAngle, nullptr, templateDBobject, nullptr,1)
50 {
51  //cout << endl;
52  //cout << "Constructing PixelCPETemplateReco::PixelCPETemplateReco(...)................................................." << endl;
53  //cout << endl;
54 
55  // Configurable parameters
56  //DoCosmics_ = conf.getParameter<bool>("DoCosmics"); // Not used in templates
57  //LoadTemplatesFromDB_ = conf.getParameter<bool>("LoadTemplatesFromDB"); // Moved to Base
58 
59  //cout << " PixelCPETemplateReco : (int)LoadTemplatesFromDB_ = " << (int)LoadTemplatesFromDB_ << endl;
60  //cout << "field_magnitude = " << field_magnitude << endl;
61 
62  // configuration parameter to decide between DB or text file template access
63 
65  {
66  //cout << "PixelCPETemplateReco: Loading templates from database (DB) --------- " << endl;
67 
68  // Initialize template store to the selected ID [Morris, 6/25/08]
70  throw cms::Exception("PixelCPETemplateReco")
71  << "\nERROR: Templates not filled correctly. Check the sqlite file. Using SiPixelTemplateDBObject version "
72  << (*templateDBobject_).version() << "\n\n";
73  }
74  else
75  {
76  //cout << "PixelCPETemplateReco : Loading templates for barrel and forward from ASCII files ----------" << endl;
77  barrelTemplateID_ = conf.getParameter<int>( "barrelTemplateID" );
78  forwardTemplateID_ = conf.getParameter<int>( "forwardTemplateID" );
79  templateDir_ = conf.getParameter<int>( "directoryWithTemplates" );
80 
82  throw cms::Exception("PixelCPETemplateReco")
83  << "\nERROR: Template ID " << barrelTemplateID_ << " not loaded correctly from text file. Reconstruction will fail.\n\n";
84 
85  if ( !SiPixelTemplate::pushfile( forwardTemplateID_ , thePixelTemp_ , templateDir_ ) )
86  throw cms::Exception("PixelCPETemplateReco")
87  << "\nERROR: Template ID " << forwardTemplateID_ << " not loaded correctly from text file. Reconstruction will fail.\n\n";
88  }
89 
90  speed_ = conf.getParameter<int>( "speed");
91  LogDebug("PixelCPETemplateReco::PixelCPETemplateReco:") <<
92  "Template speed = " << speed_ << "\n";
93 
94  UseClusterSplitter_ = conf.getParameter<bool>("UseClusterSplitter");
95 
96 }
97 
98 //-----------------------------------------------------------------------------
99 // Clean up.
100 //-----------------------------------------------------------------------------
102 {
103  for(auto x : thePixelTemp_) x.destroy();
104 }
105 
107 {
108  return new ClusterParamTemplate(cl);
109 }
110 
111 
112 //------------------------------------------------------------------
113 // Public methods mandated by the base class.
114 //------------------------------------------------------------------
115 
116 //------------------------------------------------------------------
117 // The main call to the template code.
118 //------------------------------------------------------------------
120 PixelCPETemplateReco::localPosition(DetParam const & theDetParam, ClusterParam & theClusterParamBase) const
121 {
122 
123  ClusterParamTemplate & theClusterParam = static_cast<ClusterParamTemplate &>(theClusterParamBase);
124 
126  throw cms::Exception("PixelCPETemplateReco::localPosition :")
127  << "A non-pixel detector type in here?";
128  // barrel(false) or forward(true)
129  const bool fpix = GeomDetEnumerators::isEndcap(theDetParam.thePart);
130 
131  int ID = -9999;
132  if ( LoadTemplatesFromDB_ ) {
133  int ID0 = templateDBobject_->getTemplateID(theDetParam.theDet->geographicalId()); // just to comapre
134  ID = theDetParam.detTemplateId;
135  if(ID0!=ID) edm::LogError("PixelCPETemplateReco") <<" different id"<< ID<<" "<<ID0<<endl;
136  } else { // from asci file
137  if ( !fpix )
138  ID = barrelTemplateID_ ; // barrel
139  else
140  ID = forwardTemplateID_ ; // forward
141  }
142  //cout << "PixelCPETemplateReco : ID = " << ID << endl;
143 
145 
146  // Preparing to retrieve ADC counts from the SiPixeltheClusterParam.theCluster-> In the cluster,
147  // we have the following:
148  // int minPixelRow(); // Minimum pixel index in the x direction (low edge).
149  // int maxPixelRow(); // Maximum pixel index in the x direction (top edge).
150  // int minPixelCol(); // Minimum pixel index in the y direction (left edge).
151  // int maxPixelCol(); // Maximum pixel index in the y direction (right edge).
152  // So the pixels from minPixelRow() will go into clust_array_2d[0][*],
153  // and the pixels from minPixelCol() will go into clust_array_2d[*][0].
154 
155  int row_offset = theClusterParam.theCluster->minPixelRow();
156  int col_offset = theClusterParam.theCluster->minPixelCol();
157 
158  // Store the coordinates of the center of the (0,0) pixel of the array that
159  // gets passed to PixelTempReco1D
160  // Will add these values to the output of PixelTempReco1D
161  float tmp_x = float(row_offset) + 0.5f;
162  float tmp_y = float(col_offset) + 0.5f;
163 
164  // Store these offsets (to be added later) in a LocalPoint after tranforming
165  // them from measurement units (pixel units) to local coordinates (cm)
166 
167  // ggiurgiu@jhu.edu 12/09/2010 : update call with trk angles needed for bow/kink corrections
168  LocalPoint lp;
169 
170  if ( theClusterParam.with_track_angle )
171  lp = theDetParam.theTopol->localPosition( MeasurementPoint(tmp_x, tmp_y), theClusterParam.loc_trk_pred );
172  else
173  {
174  edm::LogError("PixelCPETemplateReco")
175  << "@SUB = PixelCPETemplateReco::localPosition"
176  << "Should never be here. PixelCPETemplateReco should always be called with track angles. This is a bad error !!! ";
177 
178  lp = theDetParam.theTopol->localPosition( MeasurementPoint(tmp_x, tmp_y) );
179  }
180 
181  // first compute matrix size
182  int mrow=0, mcol=0;
183  for (int i=0 ; i!=theClusterParam.theCluster->size(); ++i )
184  {
185  auto pix = theClusterParam.theCluster->pixel(i);
186  int irow = int(pix.x);
187  int icol = int(pix.y);
188  mrow = std::max(mrow,irow);
189  mcol = std::max(mcol,icol);
190  }
191  mrow -= row_offset; mrow+=1; mrow = std::min(mrow,cluster_matrix_size_x);
192  mcol -= col_offset; mcol+=1; mcol = std::min(mcol,cluster_matrix_size_y);
193  assert(mrow>0); assert(mcol>0);
194 
195  float clustMatrix[mrow][mcol];
196  memset(clustMatrix,0,sizeof(float)*mrow*mcol);
197 
198  // Copy clust's pixels (calibrated in electrons) into clusMatrix;
199  for (int i=0 ; i!=theClusterParam.theCluster->size(); ++i )
200  {
201  auto pix = theClusterParam.theCluster->pixel(i);
202  int irow = int(pix.x) - row_offset;
203  int icol = int(pix.y) - col_offset;
204 
205  // Gavril : what do we do here if the row/column is larger than cluster_matrix_size_x/cluster_matrix_size_y ?
206  // Ignore them for the moment...
207  if ( (irow<mrow) & (icol<mcol) ) clustMatrix[irow][icol] = float(pix.adc);
208 
209  }
210 
211 
212  // Make and fill the bool arrays flagging double pixels
213  bool xdouble[mrow], ydouble[mcol];
214  // x directions (shorter), rows
215  for (int irow = 0; irow < mrow; ++irow)
216  xdouble[irow] = theDetParam.theRecTopol->isItBigPixelInX( irow+row_offset );
217 
218  // y directions (longer), columns
219  for (int icol = 0; icol < mcol; ++icol)
220  ydouble[icol] = theDetParam.theRecTopol->isItBigPixelInY( icol+col_offset );
221 
222  SiPixelTemplateReco::ClusMatrix clusterPayload{&clustMatrix[0][0], xdouble, ydouble, mrow,mcol};
223 
224  // Output:
225  float nonsense = -99999.9f; // nonsense init value
226  theClusterParam.templXrec_ = theClusterParam.templYrec_ = theClusterParam.templSigmaX_ = theClusterParam.templSigmaY_ = nonsense;
227  // If the template recontruction fails, we want to return 1.0 for now
228  theClusterParam.templProbY_ = theClusterParam.templProbX_ = theClusterParam.templProbQ_ = 1.0f;
229  theClusterParam.templQbin_ = 0;
230  // We have a boolean denoting whether the reco failed or not
231  theClusterParam.hasFilledProb_ = false;
232 
233  float templYrec1_ = nonsense;
234  float templXrec1_ = nonsense;
235  float templYrec2_ = nonsense;
236  float templXrec2_ = nonsense;
237 
238  // ******************************************************************
239  // Do it! Use cotalpha_ and cotbeta_ calculated in PixelCPEBase
240 
241 
242  float locBz = theDetParam.bz;
243  float locBx = theDetParam.bx;
244 
245  theClusterParam.ierr =
246  PixelTempReco1D( ID, theClusterParam.cotalpha, theClusterParam.cotbeta,
247  locBz, locBx,
248  clusterPayload,
249  templ,
250  theClusterParam.templYrec_, theClusterParam.templSigmaY_, theClusterParam.templProbY_,
251  theClusterParam.templXrec_, theClusterParam.templSigmaX_, theClusterParam.templProbX_,
252  theClusterParam.templQbin_,
253  speed_,
254  theClusterParam.templProbQ_
255  );
256 
257  // ******************************************************************
258 
259  // Check exit status
260  if UNLIKELY( theClusterParam.ierr != 0 )
261  {
262  LogDebug("PixelCPETemplateReco::localPosition") <<
263  "reconstruction failed with error " << theClusterParam.ierr << "\n";
264 
265  // Gavril: what do we do in this case ? For now, just return the cluster center of gravity in microns
266  // In the x case, apply a rough Lorentz drift average correction
267  // To do: call PixelCPEGeneric whenever PixelTempReco1D fails
268  float lorentz_drift = -999.9;
269  if ( !fpix )
270  lorentz_drift = 60.0f; // in microns
271  else
272  lorentz_drift = 10.0f; // in microns
273  // ggiurgiu@jhu.edu, 21/09/2010 : trk angles needed to correct for bows/kinks
274  if ( theClusterParam.with_track_angle )
275  {
276  theClusterParam.templXrec_ = theDetParam.theTopol->localX( theClusterParam.theCluster->x(), theClusterParam.loc_trk_pred ) - lorentz_drift * micronsToCm; // rough Lorentz drift correction
277  theClusterParam.templYrec_ = theDetParam.theTopol->localY( theClusterParam.theCluster->y(), theClusterParam.loc_trk_pred );
278  }
279  else
280  {
281  edm::LogError("PixelCPETemplateReco")
282  << "@SUB = PixelCPETemplateReco::localPosition"
283  << "Should never be here. PixelCPETemplateReco should always be called with track angles. This is a bad error !!! ";
284 
285  theClusterParam.templXrec_ = theDetParam.theTopol->localX( theClusterParam.theCluster->x() ) - lorentz_drift * micronsToCm; // rough Lorentz drift correction
286  theClusterParam.templYrec_ = theDetParam.theTopol->localY( theClusterParam.theCluster->y() );
287  }
288  }
289  else if UNLIKELY( UseClusterSplitter_ && theClusterParam.templQbin_ == 0 )
290  {
291  cout << " PixelCPETemplateReco : We should never be here !!!!!!!!!!!!!!!!!!!!!!" << endl;
292  cout << " (int)UseClusterSplitter_ = " << (int)UseClusterSplitter_ << endl;
293 
294  //ierr =
295  //PixelTempSplit( ID, fpix, cotalpha_, cotbeta_,
296  // clust_array_2d, ydouble, xdouble,
297  // templ,
298  // templYrec1_, templYrec2_, templSigmaY_, templProbY_,
299  // templXrec1_, templXrec2_, templSigmaX_, templProbX_,
300  // templQbin_ );
301 
302 
303  // Commented for now (3/10/17) until we figure out how to resuscitate 2D template splitter
307 
308  theClusterParam.ierr = -123;
309  /*
310  float dchisq;
311  float templProbQ_;
312  SiPixelTemplateSplit::PixelTempSplit( ID, theClusterParam.cotalpha, theClusterParam.cotbeta,
313  clust_array_2d,
314  ydouble, xdouble,
315  templ,
316  templYrec1_, templYrec2_, theClusterParam.templSigmaY_, theClusterParam.templProbY_,
317  templXrec1_, templXrec2_, theClusterParam.templSigmaX_, theClusterParam.templProbX_,
318  theClusterParam.templQbin_,
319  templProbQ_,
320  true,
321  dchisq,
322  templ2D_ );
323 
324  */
325  if ( theClusterParam.ierr != 0 )
326  {
327  LogDebug("PixelCPETemplateReco::localPosition") <<
328  "reconstruction failed with error " << theClusterParam.ierr << "\n";
329 
330  // Gavril: what do we do in this case ? For now, just return the cluster center of gravity in microns
331  // In the x case, apply a rough Lorentz drift average correction
332  // To do: call PixelCPEGeneric whenever PixelTempReco1D fails
333  float lorentz_drift = -999.9f;
334  if ( !fpix )
335  lorentz_drift = 60.0f; // in microns
336  else
337  lorentz_drift = 10.0f; // in microns
338 
339  // ggiurgiu@jhu.edu, 12/09/2010 : trk angles needed to correct for bows/kinks
340  if ( theClusterParam.with_track_angle )
341  {
342  theClusterParam.templXrec_ = theDetParam.theTopol->localX( theClusterParam.theCluster->x(),theClusterParam.loc_trk_pred ) - lorentz_drift * micronsToCm; // rough Lorentz drift correction
343  theClusterParam.templYrec_ = theDetParam.theTopol->localY( theClusterParam.theCluster->y(),theClusterParam.loc_trk_pred );
344  }
345  else
346  {
347  edm::LogError("PixelCPETemplateReco")
348  << "@SUB = PixelCPETemplateReco::localPosition"
349  << "Should never be here. PixelCPETemplateReco should always be called with track angles. This is a bad error !!! ";
350 
351  theClusterParam.templXrec_ = theDetParam.theTopol->localX( theClusterParam.theCluster->x() ) - lorentz_drift * micronsToCm; // very rough Lorentz drift correction
352  theClusterParam.templYrec_ = theDetParam.theTopol->localY( theClusterParam.theCluster->y() );
353 
354  }
355  }
356  else
357  {
358  // go from micrometer to centimeter
359  templXrec1_ *= micronsToCm;
360  templYrec1_ *= micronsToCm;
361  templXrec2_ *= micronsToCm;
362  templYrec2_ *= micronsToCm;
363 
364  // go back to the module coordinate system
365  templXrec1_ += lp.x();
366  templYrec1_ += lp.y();
367  templXrec2_ += lp.x();
368  templYrec2_ += lp.y();
369 
370  // calculate distance from each hit to the track and choose the hit closest to the track
371  float distX1 = std::abs (templXrec1_ - theClusterParam.trk_lp_x);
372  float distX2 = std::abs (templXrec2_ - theClusterParam.trk_lp_x);
373  float distY1 = std::abs (templYrec1_ - theClusterParam.trk_lp_y);
374  float distY2 = std::abs (templYrec2_ - theClusterParam.trk_lp_y);
375  theClusterParam.templXrec_ = (distX1<distX2? templXrec1_ : templXrec2_);
376  theClusterParam.templYrec_ = (distY1<distY2? templYrec1_ : templYrec2_);
377  }
378  } // else if ( UseClusterSplitter_ && templQbin_ == 0 )
379 
380  else // apparenly this is the good one!
381  {
382  // go from micrometer to centimeter
383  theClusterParam.templXrec_ *= micronsToCm;
384  theClusterParam.templYrec_ *= micronsToCm;
385 
386  // go back to the module coordinate system
387  theClusterParam.templXrec_ += lp.x();
388  theClusterParam.templYrec_ += lp.y();
389 
390  // Compute the Alignment Group Corrections [template ID should already be selected from call to reco procedure]
391  if ( DoLorentz_ ) {
392  // Do only if the lotentzshift has meaningfull numbers
393  if( theDetParam.lorentzShiftInCmX!= 0.0 || theDetParam.lorentzShiftInCmY!= 0.0 ) {
394  // the LA width/shift returned by templates use (+)
395  // the LA width/shift produced by PixelCPEBase for positive LA is (-)
396  // correct this by iserting (-)
397  //float temp1 = -micronsToCm*templ.lorxwidth(); // old
398  //float temp2 = -micronsToCm*templ.lorywidth(); // does not incl 1/2
399  float templateLorbiasCmX = -micronsToCm*templ.lorxbias(); // new
400  float templateLorbiasCmY = -micronsToCm*templ.lorybias(); //incl. 1/2
401  // now, correctly, we can use the difference of shifts
402  //theClusterParam.templXrec_ += 0.5*(theDetParam.lorentzShiftInCmX - templateLorbiasCmX);
403  //theClusterParam.templYrec_ += 0.5*(theDetParam.lorentzShiftInCmY - templateLorbiasCmY);
404  theClusterParam.templXrec_ += (0.5*(theDetParam.lorentzShiftInCmX) - templateLorbiasCmX);
405  theClusterParam.templYrec_ += (0.5*(theDetParam.lorentzShiftInCmY) - templateLorbiasCmY);
406  //cout << "Templates: la lorentz offset = "
407  // <<(0.5*(theDetParam.lorentzShiftInCmX)-templateLorbiasCmX)
408  // <<" "<<templateLorbiasCmX<<" "<<templateLorbiasCmY
409  // <<" "<<temp1<<" "<<temp2
410  // <<" "<<theDetParam.lorentzShiftInCmX
411  // <<" "<<theDetParam.lorentzShiftInCmY
412  // << endl; //dk
413  } //else {cout<<" LA is 0, disable offset corrections "<<endl;} //dk
414  } //else {cout<<" Do not do LA offset correction "<<endl;} //dk
415 
416  }
417 
418  // Save probabilities and qBin in the quantities given to us by the base class
419  // (for which there are also inline getters). &&& templProbX_ etc. should be retired...
420  theClusterParam.probabilityX_ = theClusterParam.templProbX_;
421  theClusterParam.probabilityY_ = theClusterParam.templProbY_;
422  theClusterParam.probabilityQ_ = theClusterParam.templProbQ_;
423  theClusterParam.qBin_ = theClusterParam.templQbin_;
424 
425  if ( theClusterParam.ierr == 0 ) // always true here
426  theClusterParam.hasFilledProb_ = true;
427 
428  return LocalPoint( theClusterParam.templXrec_, theClusterParam.templYrec_ );
429 
430 }
431 
432 //------------------------------------------------------------------
433 // localError() relies on localPosition() being called FIRST!!!
434 //------------------------------------------------------------------
436 PixelCPETemplateReco::localError(DetParam const & theDetParam, ClusterParam & theClusterParamBase) const
437 {
438 
439  ClusterParamTemplate & theClusterParam = static_cast<ClusterParamTemplate &>(theClusterParamBase);
440 
441  //cout << endl;
442  //cout << "Set PixelCPETemplate errors .............................................." << endl;
443 
444  //cout << "CPETemplate : " << endl;
445 
446  //--- Default is the maximum error used for edge clusters.
447  //--- (never used, in fact: let comment it out, shut up the complains of the static analyzer, and save a few CPU cycles)
448  // const float sig12 = 1./sqrt(12.0);
449  // float xerr = theDetParam.thePitchX *sig12;
450  // float yerr = theDetParam.thePitchY *sig12;
451  float xerr, yerr;
452 
453  // Check if the errors were already set at the clusters splitting level
454  if ( theClusterParam.theCluster->getSplitClusterErrorX() > 0.0f && theClusterParam.theCluster->getSplitClusterErrorX() < 7777.7f &&
455  theClusterParam.theCluster->getSplitClusterErrorY() > 0.0f && theClusterParam.theCluster->getSplitClusterErrorY() < 7777.7f )
456  {
457  xerr = theClusterParam.theCluster->getSplitClusterErrorX() * micronsToCm;
458  yerr = theClusterParam.theCluster->getSplitClusterErrorY() * micronsToCm;
459 
460  //cout << "Errors set at cluster splitting level : " << endl;
461  //cout << "xerr = " << xerr << endl;
462  //cout << "yerr = " << yerr << endl;
463  }
464  else
465  {
466  // If errors are not split at the cluster splitting level, set the errors here
467 
468  //cout << "Errors are not split at the cluster splitting level, set the errors here : " << endl;
469 
470  int maxPixelCol = theClusterParam.theCluster->maxPixelCol();
471  int maxPixelRow = theClusterParam.theCluster->maxPixelRow();
472  int minPixelCol = theClusterParam.theCluster->minPixelCol();
473  int minPixelRow = theClusterParam.theCluster->minPixelRow();
474 
475  //--- Are we near either of the edges?
476  bool edgex = ( theDetParam.theRecTopol->isItEdgePixelInX( minPixelRow ) || theDetParam.theRecTopol->isItEdgePixelInX( maxPixelRow ) );
477  bool edgey = ( theDetParam.theRecTopol->isItEdgePixelInY( minPixelCol ) || theDetParam.theRecTopol->isItEdgePixelInY( maxPixelCol ) );
478 
479  if ( theClusterParam.ierr !=0 )
480  {
481  // If reconstruction fails the hit position is calculated from cluster center of gravity
482  // corrected in x by average Lorentz drift. Assign huge errors.
483  //xerr = 10.0 * (float)theClusterParam.theCluster->sizeX() * xerr;
484  //yerr = 10.0 * (float)theClusterParam.theCluster->sizeX() * yerr;
485 
487  throw cms::Exception("PixelCPETemplateReco::localPosition :")
488  << "A non-pixel detector type in here?";
489 
490  // Assign better errors based on the residuals for failed template cases
491  if ( GeomDetEnumerators::isBarrel(theDetParam.thePart) )
492  {
493  xerr = 55.0f * micronsToCm;
494  yerr = 36.0f * micronsToCm;
495  }
496  else
497  {
498  xerr = 42.0f * micronsToCm;
499  yerr = 39.0f * micronsToCm;
500  }
501 
502  //cout << "xerr = " << xerr << endl;
503  //cout << "yerr = " << yerr << endl;
504 
505  //return LocalError(xerr*xerr, 0, yerr*yerr);
506  }
507  else if ( edgex || edgey )
508  {
509  // for edge pixels assign errors according to observed residual RMS
510  if ( edgex && !edgey )
511  {
512  xerr = 23.0f * micronsToCm;
513  yerr = 39.0f * micronsToCm;
514  }
515  else if ( !edgex && edgey )
516  {
517  xerr = 24.0f * micronsToCm;
518  yerr = 96.0f * micronsToCm;
519  }
520  else if ( edgex && edgey )
521  {
522  xerr = 31.0f * micronsToCm;
523  yerr = 90.0f * micronsToCm;
524  }
525  else
526  {
527  throw cms::Exception(" PixelCPETemplateReco::localError: Something wrong with pixel edge flag !!!");
528  }
529 
530  //cout << "xerr = " << xerr << endl;
531  //cout << "yerr = " << yerr << endl;
532  }
533  else
534  {
535  // &&& need a class const
536  //const float micronsToCm = 1.0e-4;
537 
538  xerr = theClusterParam.templSigmaX_ * micronsToCm;
539  yerr = theClusterParam.templSigmaY_ * micronsToCm;
540 
541  //cout << "xerr = " << xerr << endl;
542  //cout << "yerr = " << yerr << endl;
543 
544  // &&& should also check ierr (saved as class variable) and return
545  // &&& nonsense (another class static) if the template fit failed.
546  }
547 
548  if (theVerboseLevel > 9)
549  {
550  LogDebug("PixelCPETemplateReco") <<
551  " Sizex = " << theClusterParam.theCluster->sizeX() << " Sizey = " << theClusterParam.theCluster->sizeY() << " Edgex = " << edgex << " Edgey = " << edgey <<
552  " ErrX = " << xerr << " ErrY = " << yerr;
553  }
554 
555  } // else
556 
557  if ( !(xerr > 0.0f) )
558  throw cms::Exception("PixelCPETemplateReco::localError")
559  << "\nERROR: Negative pixel error xerr = " << xerr << "\n\n";
560 
561  if ( !(yerr > 0.0f) )
562  throw cms::Exception("PixelCPETemplateReco::localError")
563  << "\nERROR: Negative pixel error yerr = " << yerr << "\n\n";
564 
565  //cout << "Final errors set to: " << endl;
566  //cout << "xerr = " << xerr << endl;
567  //cout << "yerr = " << yerr << endl;
568  //cout << "Out of PixelCPETemplateREco..........................................................................." << endl;
569  //cout << endl;
570 
571  return LocalError(xerr*xerr, 0, yerr*yerr);
572 }
573 
#define LogDebug(id)
T getParameter(std::string const &) const
Point3DBase< Scalar, LocalTag > LocalPoint
Definition: Definitions.h:32
short getTemplateID(const uint32_t &detid) const
T mag() const
The vector magnitude. Equivalent to sqrt(vec.mag2())
uint32_t ID
Definition: Definitions.h:26
bool isBarrel(GeomDetEnumerators::SubDetector m)
T y() const
Definition: PV3DBase.h:63
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
std::vector< SiPixelTemplateStore > thePixelTemp_
PixelCPETemplateReco(edm::ParameterSet const &conf, const MagneticField *, const TrackerGeometry &, const TrackerTopology &, const SiPixelLorentzAngle *, const SiPixelTemplateDBObject *)
Measurement2DPoint MeasurementPoint
Measurement points are two-dimensional by default.
bool isItEdgePixelInX(int ixbin) const override
const PixelTopology * theTopol
Definition: PixelCPEBase.h:62
bool LoadTemplatesFromDB_
Definition: PixelCPEBase.h:257
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
LocalError localError(DetParam const &theDetParam, ClusterParam &theClusterParam) const override
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]
T min(T a, T b)
Definition: MathUtil.h:58
bool isEndcap(GeomDetEnumerators::SubDetector m)
bool isItBigPixelInY(const int iybin) const override
bool isItBigPixelInX(const int ixbin) const override
float lorybias()
signed lorentz y-width (microns)
virtual LocalPoint localPosition(const MeasurementPoint &) const =0
static bool pushfile(int filenum, std::vector< SiPixelTemplateStore > &pixelTemp, std::string dir="CalibTracker/SiPixelESProducers/data/")
Pixel cluster – collection of neighboring pixels above threshold.
float lorxbias()
signed lorentz x-width (microns)
LocalPoint localPosition(DetParam const &theDetParam, ClusterParam &theClusterParam) const override
virtual float localY(float mpY) const =0
bool isItEdgePixelInY(int iybin) const override
T x() const
Definition: PV3DBase.h:62
bool isTrackerPixel(GeomDetEnumerators::SubDetector m)
#define UNLIKELY(x)