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