CMS 3D CMS Logo

PixelCPEGeneric.cc
Go to the documentation of this file.
2 
6 
7 // Pixel templates contain the rec hit error parameterizaiton
9 
10 // The generic formula
12 
13 // Services
16 
17 #include "boost/multi_array.hpp"
18 
19 #include <iostream>
20 using namespace std;
21 
22 namespace {
23  constexpr float micronsToCm = 1.0e-4;
24  const bool MYDEBUG = false;
25 } // namespace
26 
27 //-----------------------------------------------------------------------------
29 //-----------------------------------------------------------------------------
31  const MagneticField* mag,
32  const TrackerGeometry& geom,
33  const TrackerTopology& ttopo,
34  const SiPixelLorentzAngle* lorentzAngle,
35  const SiPixelGenErrorDBObject* genErrorDBObject,
36  const SiPixelLorentzAngle* lorentzAngleWidth = nullptr)
37  : PixelCPEBase(conf, mag, geom, ttopo, lorentzAngle, genErrorDBObject, nullptr, lorentzAngleWidth, 0) {
38  if (theVerboseLevel > 0)
39  LogDebug("PixelCPEGeneric") << " constructing a generic algorithm for ideal pixel detector.\n"
40  << " CPEGeneric:: VerboseLevel = " << theVerboseLevel;
41 
42  // Externally settable cuts
43  the_eff_charge_cut_lowX = conf.getParameter<double>("eff_charge_cut_lowX");
44  the_eff_charge_cut_lowY = conf.getParameter<double>("eff_charge_cut_lowY");
45  the_eff_charge_cut_highX = conf.getParameter<double>("eff_charge_cut_highX");
46  the_eff_charge_cut_highY = conf.getParameter<double>("eff_charge_cut_highY");
47  the_size_cutX = conf.getParameter<double>("size_cutX");
48  the_size_cutY = conf.getParameter<double>("size_cutY");
49 
50  EdgeClusterErrorX_ = conf.getParameter<double>("EdgeClusterErrorX");
51  EdgeClusterErrorY_ = conf.getParameter<double>("EdgeClusterErrorY");
52 
53  // Externally settable flags to inflate errors
54  inflate_errors = conf.getParameter<bool>("inflate_errors");
55  inflate_all_errors_no_trk_angle = conf.getParameter<bool>("inflate_all_errors_no_trk_angle");
56 
57  NoTemplateErrorsWhenNoTrkAngles_ = conf.getParameter<bool>("NoTemplateErrorsWhenNoTrkAngles");
58  UseErrorsFromTemplates_ = conf.getParameter<bool>("UseErrorsFromTemplates");
59  TruncatePixelCharge_ = conf.getParameter<bool>("TruncatePixelCharge");
60  IrradiationBiasCorrection_ = conf.getParameter<bool>("IrradiationBiasCorrection");
61  DoCosmics_ = conf.getParameter<bool>("DoCosmics");
62 
63  // Upgrade means phase 2
64  isUpgrade_ = conf.getParameter<bool>("Upgrade");
65 
66  // For cosmics force the use of simple errors
67  if ((DoCosmics_))
69 
71  throw cms::Exception("PixelCPEGeneric::PixelCPEGeneric: ")
72  << "\nERROR: UseErrorsFromTemplates_ is set to False in PixelCPEGeneric_cfi.py. "
73  << " In this case it does not make sense to set any of the following to True: "
74  << " TruncatePixelCharge_, IrradiationBiasCorrection_, DoCosmics_, LoadTemplatesFromDB_ !!!"
75  << "\n\n";
76  }
77 
78  // Use errors from templates or from GenError
80  if (LoadTemplatesFromDB_) { // From DB
82  throw cms::Exception("InvalidCalibrationLoaded")
83  << "ERROR: GenErrors not filled correctly. Check the sqlite file. Using SiPixelTemplateDBObject version "
84  << (*genErrorDBObject_).version();
85  if (MYDEBUG)
86  cout << "Loaded genErrorDBObject v" << (*genErrorDBObject_).version() << endl;
87  } else { // From file
89  throw cms::Exception("InvalidCalibrationLoaded")
90  << "ERROR: GenErrors not loaded correctly from text file. Reconstruction will fail.";
91  } // if load from DB
92 
93  } else {
94  if (MYDEBUG)
95  cout << " Use simple parametrised errors " << endl;
96  } // if ( UseErrorsFromTemplates_ )
97 
98  // Rechit errors in case other, more correct, errors are not vailable
99  // This are constants. Maybe there is a more efficienct way to store them.
100  if (!isUpgrade_) { // normal case
101  xerr_barrel_l1_ = {0.00115, 0.00120, 0.00088};
102  xerr_barrel_l1_def_ = 0.01030;
103  yerr_barrel_l1_ = {0.00375, 0.00230, 0.00250, 0.00250, 0.00230, 0.00230, 0.00210, 0.00210, 0.00240};
104  yerr_barrel_l1_def_ = 0.00210;
105  xerr_barrel_ln_ = {0.00115, 0.00120, 0.00088};
106  xerr_barrel_ln_def_ = 0.01030;
107  yerr_barrel_ln_ = {0.00375, 0.00230, 0.00250, 0.00250, 0.00230, 0.00230, 0.00210, 0.00210, 0.00240};
108  yerr_barrel_ln_def_ = 0.00210;
109  xerr_endcap_ = {0.0020, 0.0020};
110  xerr_endcap_def_ = 0.0020;
111  yerr_endcap_ = {0.00210};
112  yerr_endcap_def_ = 0.00075;
113  } else { // isUpgrade=true
114  xerr_barrel_ln_ = {0.00025, 0.00030, 0.00035, 0.00035};
115  xerr_barrel_ln_def_ = 0.00035;
116  yerr_barrel_ln_ = {0.00210, 0.00115, 0.00125};
117  yerr_barrel_ln_def_ = 0.00125;
118  xerr_endcap_ = {0.00072, 0.00025};
119  xerr_endcap_def_ = 0.00060;
120  yerr_endcap_ = {0.00289, 0.00025};
121  yerr_endcap_def_ = 0.00180;
122 
123  if (conf.getParameter<bool>("SmallPitch")) {
124  xerr_barrel_l1_ = {0.00104, 0.000691, 0.00122};
125  xerr_barrel_l1_def_ = 0.00321;
126  yerr_barrel_l1_ = {0.00199, 0.00136, 0.0015, 0.00153, 0.00152, 0.00171, 0.00154, 0.00157, 0.00154};
127  yerr_barrel_l1_def_ = 0.00164;
128  } else {
129  xerr_barrel_l1_ = {0.00025, 0.00030, 0.00035, 0.00035};
130  xerr_barrel_l1_def_ = 0.00035;
131  yerr_barrel_l1_ = {0.00210, 0.00115, 0.00125};
132  yerr_barrel_l1_def_ = 0.00125;
133  }
134  } // if isUpgrade
135 
136  if (MYDEBUG) {
137  cout << "From PixelCPEGeneric::PixelCPEGeneric(...)" << endl;
138  cout << "(int)UseErrorsFromTemplates_ = " << (int)UseErrorsFromTemplates_ << endl;
139  cout << "TruncatePixelCharge_ = " << (int)TruncatePixelCharge_ << endl;
140  cout << "IrradiationBiasCorrection_ = " << (int)IrradiationBiasCorrection_ << endl;
141  cout << "(int)DoCosmics_ = " << (int)DoCosmics_ << endl;
142  cout << "(int)LoadTemplatesFromDB_ = " << (int)LoadTemplatesFromDB_ << endl;
143  }
144 }
145 
146 std::unique_ptr<PixelCPEBase::ClusterParam> PixelCPEGeneric::createClusterParam(const SiPixelCluster& cl) const {
147  return std::make_unique<ClusterParamGeneric>(cl);
148 }
149 
150 //-----------------------------------------------------------------------------
154 //-----------------------------------------------------------------------------
155 LocalPoint PixelCPEGeneric::localPosition(DetParam const& theDetParam, ClusterParam& theClusterParamBase) const {
156  ClusterParamGeneric& theClusterParam = static_cast<ClusterParamGeneric&>(theClusterParamBase);
157 
158  //cout<<" in PixelCPEGeneric:localPosition - "<<endl; //dk
159 
160  float chargeWidthX = (theDetParam.lorentzShiftInCmX * theDetParam.widthLAFractionX);
161  float chargeWidthY = (theDetParam.lorentzShiftInCmY * theDetParam.widthLAFractionY);
162  float shiftX = 0.5f * theDetParam.lorentzShiftInCmX;
163  float shiftY = 0.5f * theDetParam.lorentzShiftInCmY;
164 
165  //cout<<" main la width "<<chargeWidthX<<" "<<chargeWidthY<<endl;
166 
168  float qclus = theClusterParam.theCluster->charge();
169  float locBz = theDetParam.bz;
170  float locBx = theDetParam.bx;
171  //cout << "PixelCPEGeneric::localPosition(...) : locBz = " << locBz << endl;
172 
173  theClusterParam.pixmx = -999; // max pixel charge for truncation of 2-D cluster
174  theClusterParam.sigmay = -999.9; // CPE Generic y-error for multi-pixel cluster
175  theClusterParam.deltay = -999.9; // CPE Generic y-bias for multi-pixel cluster
176  theClusterParam.sigmax = -999.9; // CPE Generic x-error for multi-pixel cluster
177  theClusterParam.deltax = -999.9; // CPE Generic x-bias for multi-pixel cluster
178  theClusterParam.sy1 = -999.9; // CPE Generic y-error for single single-pixel
179  theClusterParam.dy1 = -999.9; // CPE Generic y-bias for single single-pixel cluster
180  theClusterParam.sy2 = -999.9; // CPE Generic y-error for single double-pixel cluster
181  theClusterParam.dy2 = -999.9; // CPE Generic y-bias for single double-pixel cluster
182  theClusterParam.sx1 = -999.9; // CPE Generic x-error for single single-pixel cluster
183  theClusterParam.dx1 = -999.9; // CPE Generic x-bias for single single-pixel cluster
184  theClusterParam.sx2 = -999.9; // CPE Generic x-error for single double-pixel cluster
185  theClusterParam.dx2 = -999.9; // CPE Generic x-bias for single double-pixel cluster
186 
188  int gtemplID_ = theDetParam.detTemplateId;
189 
190  //int gtemplID0 = genErrorDBObject_->getGenErrorID(theDetParam.theDet->geographicalId().rawId());
191  //if(gtemplID0!=gtemplID_) cout<<" different id "<< gtemplID_<<" "<<gtemplID0<<endl;
192 
193  theClusterParam.qBin_ = gtempl.qbin(gtemplID_,
194  theClusterParam.cotalpha,
195  theClusterParam.cotbeta,
196  locBz,
197  locBx,
198  qclus,
200  theClusterParam.pixmx,
201  theClusterParam.sigmay,
202  theClusterParam.deltay,
203  theClusterParam.sigmax,
204  theClusterParam.deltax,
205  theClusterParam.sy1,
206  theClusterParam.dy1,
207  theClusterParam.sy2,
208  theClusterParam.dy2,
209  theClusterParam.sx1,
210  theClusterParam.dx1,
211  theClusterParam.sx2,
212  theClusterParam.dx2);
213 
214  // now use the charge widths stored in the new generic template headers (change to the
215  // incorrect sign convention of the base class)
216  bool useLAWidthFromGenError = false;
217  if (useLAWidthFromGenError) {
218  chargeWidthX = (-micronsToCm * gtempl.lorxwidth());
219  chargeWidthY = (-micronsToCm * gtempl.lorywidth());
220  if (MYDEBUG)
221  cout << " redefine la width (gen-error) " << chargeWidthX << " " << chargeWidthY << endl;
222  }
223  if (MYDEBUG)
224  cout << " GenError: " << gtemplID_ << endl;
225 
226  // These numbers come in microns from the qbin(...) call. Transform them to cm.
227  theClusterParam.deltax = theClusterParam.deltax * micronsToCm;
228  theClusterParam.dx1 = theClusterParam.dx1 * micronsToCm;
229  theClusterParam.dx2 = theClusterParam.dx2 * micronsToCm;
230 
231  theClusterParam.deltay = theClusterParam.deltay * micronsToCm;
232  theClusterParam.dy1 = theClusterParam.dy1 * micronsToCm;
233  theClusterParam.dy2 = theClusterParam.dy2 * micronsToCm;
234 
235  theClusterParam.sigmax = theClusterParam.sigmax * micronsToCm;
236  theClusterParam.sx1 = theClusterParam.sx1 * micronsToCm;
237  theClusterParam.sx2 = theClusterParam.sx2 * micronsToCm;
238 
239  theClusterParam.sigmay = theClusterParam.sigmay * micronsToCm;
240  theClusterParam.sy1 = theClusterParam.sy1 * micronsToCm;
241  theClusterParam.sy2 = theClusterParam.sy2 * micronsToCm;
242 
243  } // if ( UseErrorsFromTemplates_ )
244  else {
245  theClusterParam.qBin_ = 0;
246  }
247 
248  int Q_f_X;
249  int Q_l_X;
250  int Q_f_Y;
251  int Q_l_Y;
252  collect_edge_charges(theClusterParam, Q_f_X, Q_l_X, Q_f_Y, Q_l_Y);
253 
254  //--- Find the inner widths along X and Y in one shot. We
255  //--- compute the upper right corner of the inner pixels
256  //--- (== lower left corner of upper right pixel) and
257  //--- the lower left corner of the inner pixels
258  //--- (== upper right corner of lower left pixel), and then
259  //--- subtract these two points in the formula.
260 
261  //--- Upper Right corner of Lower Left pixel -- in measurement frame
262  MeasurementPoint meas_URcorn_LLpix(theClusterParam.theCluster->minPixelRow() + 1.0,
263  theClusterParam.theCluster->minPixelCol() + 1.0);
264 
265  //--- Lower Left corner of Upper Right pixel -- in measurement frame
266  MeasurementPoint meas_LLcorn_URpix(theClusterParam.theCluster->maxPixelRow(),
267  theClusterParam.theCluster->maxPixelCol());
268 
269  //--- These two now converted into the local
270  LocalPoint local_URcorn_LLpix;
271  LocalPoint local_LLcorn_URpix;
272 
273  // PixelCPEGeneric can be used with or without track angles
274  // If PixelCPEGeneric is called with track angles, use them to correct for bows/kinks:
275  if (theClusterParam.with_track_angle) {
276  local_URcorn_LLpix = theDetParam.theTopol->localPosition(meas_URcorn_LLpix, theClusterParam.loc_trk_pred);
277  local_LLcorn_URpix = theDetParam.theTopol->localPosition(meas_LLcorn_URpix, theClusterParam.loc_trk_pred);
278  } else {
279  local_URcorn_LLpix = theDetParam.theTopol->localPosition(meas_URcorn_LLpix);
280  local_LLcorn_URpix = theDetParam.theTopol->localPosition(meas_LLcorn_URpix);
281  }
282 
283 #ifdef EDM_ML_DEBUG
284  if (theVerboseLevel > 20) {
285  cout << "\n\t >>> theClusterParam.theCluster->x = " << theClusterParam.theCluster->x()
286  << "\n\t >>> theClusterParam.theCluster->y = " << theClusterParam.theCluster->y()
287  << "\n\t >>> cluster: minRow = " << theClusterParam.theCluster->minPixelRow()
288  << " minCol = " << theClusterParam.theCluster->minPixelCol()
289  << "\n\t >>> cluster: maxRow = " << theClusterParam.theCluster->maxPixelRow()
290  << " maxCol = " << theClusterParam.theCluster->maxPixelCol()
291  << "\n\t >>> meas: inner lower left = " << meas_URcorn_LLpix.x() << "," << meas_URcorn_LLpix.y()
292  << "\n\t >>> meas: inner upper right = " << meas_LLcorn_URpix.x() << "," << meas_LLcorn_URpix.y() << endl;
293  }
294 #endif
295 
296  //--- &&& Note that the cuts below should not be hardcoded (like in Orca and
297  //--- &&& CPEFromDetPosition/PixelCPEInitial), but rather be
298  //--- &&& externally settable (but tracked) parameters.
299 
300  //--- Position, including the half lorentz shift
301 
302 #ifdef EDM_ML_DEBUG
303  if (theVerboseLevel > 20)
304  cout << "\t >>> Generic:: processing X" << endl;
305 #endif
306 
308  theClusterParam.theCluster->sizeX(),
309  Q_f_X,
310  Q_l_X,
311  local_URcorn_LLpix.x(),
312  local_LLcorn_URpix.x(),
313  chargeWidthX, // lorentz shift in cm
314  theDetParam.theThickness,
315  theClusterParam.cotalpha,
316  theDetParam.thePitchX,
317  theDetParam.theRecTopol->isItBigPixelInX(theClusterParam.theCluster->minPixelRow()),
318  theDetParam.theRecTopol->isItBigPixelInX(theClusterParam.theCluster->maxPixelRow()),
321  the_size_cutX); // cut for eff charge width &&&
322 
323  // apply the lorentz offset correction
324  xPos = xPos + shiftX;
325 
326 #ifdef EDM_ML_DEBUG
327  if (theVerboseLevel > 20)
328  cout << "\t >>> Generic:: processing Y" << endl;
329 #endif
330 
332  theClusterParam.theCluster->sizeY(),
333  Q_f_Y,
334  Q_l_Y,
335  local_URcorn_LLpix.y(),
336  local_LLcorn_URpix.y(),
337  chargeWidthY, // lorentz shift in cm
338  theDetParam.theThickness,
339  theClusterParam.cotbeta,
340  theDetParam.thePitchY,
341  theDetParam.theRecTopol->isItBigPixelInY(theClusterParam.theCluster->minPixelCol()),
342  theDetParam.theRecTopol->isItBigPixelInY(theClusterParam.theCluster->maxPixelCol()),
345  the_size_cutY); // cut for eff charge width &&&
346 
347  // apply the lorentz offset correction
348  yPos = yPos + shiftY;
349 
350  // Apply irradiation corrections
352  if (theClusterParam.theCluster->sizeX() == 1) { // size=1
353  // ggiurgiu@jhu.edu, 02/03/09 : for size = 1, the Lorentz shift is already accounted by the irradiation correction
354  //float tmp1 = (0.5 * theDetParam.lorentzShiftInCmX);
355  //cout << "Apply correction correction_dx1 = " << theClusterParam.dx1 << " to xPos = " << xPos;
356  xPos = xPos - (0.5f * theDetParam.lorentzShiftInCmX);
357  // Find if pixel is double (big).
358  bool bigInX = theDetParam.theRecTopol->isItBigPixelInX(theClusterParam.theCluster->maxPixelRow());
359  if (!bigInX)
360  xPos -= theClusterParam.dx1;
361  else
362  xPos -= theClusterParam.dx2;
363  //cout<<" to "<<xPos<<" "<<(tmp1+theClusterParam.dx1)<<endl;
364  } else { // size>1
365  //cout << "Apply correction correction_deltax = " << theClusterParam.deltax << " to xPos = " << xPos;
366  xPos -= theClusterParam.deltax;
367  //cout<<" to "<<xPos<<endl;
368  }
369 
370  if (theClusterParam.theCluster->sizeY() == 1) {
371  // ggiurgiu@jhu.edu, 02/03/09 : for size = 1, the Lorentz shift is already accounted by the irradiation correction
372  yPos = yPos - (0.5f * theDetParam.lorentzShiftInCmY);
373 
374  // Find if pixel is double (big).
375  bool bigInY = theDetParam.theRecTopol->isItBigPixelInY(theClusterParam.theCluster->maxPixelCol());
376  if (!bigInY)
377  yPos -= theClusterParam.dy1;
378  else
379  yPos -= theClusterParam.dy2;
380 
381  } else {
382  //cout << "Apply correction correction_deltay = " << theClusterParam.deltay << " to yPos = " << yPos << endl;
383  yPos -= theClusterParam.deltay;
384  }
385 
386  } // if ( IrradiationBiasCorrection_ )
387 
388  //cout<<" in PixelCPEGeneric:localPosition - pos = "<<xPos<<" "<<yPos<<endl; //dk
389 
390  //--- Now put the two together
391  LocalPoint pos_in_local(xPos, yPos);
392  return pos_in_local;
393 }
394 
395 //-----------------------------------------------------------------------------
399 //-----------------------------------------------------------------------------
401  int& Q_f_X,
402  int& Q_l_X,
403  int& Q_f_Y,
404  int& Q_l_Y
405 ) const {
406  ClusterParamGeneric& theClusterParam = static_cast<ClusterParamGeneric&>(theClusterParamBase);
407 
408  // Initialize return variables.
409  Q_f_X = Q_l_X = 0.0;
410  Q_f_Y = Q_l_Y = 0.0;
411 
412  // Obtain boundaries in index units
413  int xmin = theClusterParam.theCluster->minPixelRow();
414  int xmax = theClusterParam.theCluster->maxPixelRow();
415  int ymin = theClusterParam.theCluster->minPixelCol();
416  int ymax = theClusterParam.theCluster->maxPixelCol();
417 
418  // Iterate over the pixels.
419  int isize = theClusterParam.theCluster->size();
420  for (int i = 0; i != isize; ++i) {
421  auto const& pixel = theClusterParam.theCluster->pixel(i);
422  // ggiurgiu@fnal.gov: add pixel charge truncation
423  int pix_adc = pixel.adc;
425  pix_adc = std::min(pix_adc, theClusterParam.pixmx);
426 
427  //
428  // X projection
429  if (pixel.x == xmin)
430  Q_f_X += pix_adc;
431  if (pixel.x == xmax)
432  Q_l_X += pix_adc;
433  //
434  // Y projection
435  if (pixel.y == ymin)
436  Q_f_Y += pix_adc;
437  if (pixel.y == ymax)
438  Q_l_Y += pix_adc;
439  }
440 
441  return;
442 }
443 
444 //============== INFLATED ERROR AND ERRORS FROM DB BELOW ================
445 
446 //-------------------------------------------------------------------------
447 // Hit error in the local frame
448 //-------------------------------------------------------------------------
449 LocalError PixelCPEGeneric::localError(DetParam const& theDetParam, ClusterParam& theClusterParamBase) const {
450  ClusterParamGeneric& theClusterParam = static_cast<ClusterParamGeneric&>(theClusterParamBase);
451 
452  const bool localPrint = false;
453  // Default errors are the maximum error used for edge clusters.
454  // These are determined by looking at residuals for edge clusters
455  float xerr = EdgeClusterErrorX_ * micronsToCm;
456  float yerr = EdgeClusterErrorY_ * micronsToCm;
457 
458  // Find if cluster is at the module edge.
459  int maxPixelCol = theClusterParam.theCluster->maxPixelCol();
460  int maxPixelRow = theClusterParam.theCluster->maxPixelRow();
461  int minPixelCol = theClusterParam.theCluster->minPixelCol();
462  int minPixelRow = theClusterParam.theCluster->minPixelRow();
463 
464  bool edgex = (theDetParam.theRecTopol->isItEdgePixelInX(minPixelRow)) ||
465  (theDetParam.theRecTopol->isItEdgePixelInX(maxPixelRow));
466  bool edgey = (theDetParam.theRecTopol->isItEdgePixelInY(minPixelCol)) ||
467  (theDetParam.theRecTopol->isItEdgePixelInY(maxPixelCol));
468 
469  unsigned int sizex = theClusterParam.theCluster->sizeX();
470  unsigned int sizey = theClusterParam.theCluster->sizeY();
471  if (MYDEBUG) {
472  if (int(sizex) != (maxPixelRow - minPixelRow + 1))
473  cout << " wrong x" << endl;
474  if (int(sizey) != (maxPixelCol - minPixelCol + 1))
475  cout << " wrong y" << endl;
476  }
477 
478  // Find if cluster contains double (big) pixels.
479  bool bigInX = theDetParam.theRecTopol->containsBigPixelInX(minPixelRow, maxPixelRow);
480  bool bigInY = theDetParam.theRecTopol->containsBigPixelInY(minPixelCol, maxPixelCol);
481 
482  if (localPrint) {
483  cout << " edge clus " << xerr << " " << yerr << endl; //dk
484  if (bigInX || bigInY)
485  cout << " big " << bigInX << " " << bigInY << endl;
486  if (edgex || edgey)
487  cout << " edge " << edgex << " " << edgey << endl;
488  cout << " before if " << UseErrorsFromTemplates_ << " " << theClusterParam.qBin_ << endl;
489  if (theClusterParam.qBin_ == 0)
490  cout << " qbin 0! " << edgex << " " << edgey << " " << bigInX << " " << bigInY << " " << sizex << " " << sizey
491  << endl;
492  }
493 
494  bool useTempErrors =
496 
497  if
498  LIKELY(useTempErrors) {
499  //
500  // Use template errors
501 
502  if (!edgex) { // Only use this for non-edge clusters
503  if (sizex == 1) {
504  if (!bigInX) {
505  xerr = theClusterParam.sx1;
506  } else {
507  xerr = theClusterParam.sx2;
508  }
509  } else {
510  xerr = theClusterParam.sigmax;
511  }
512  }
513 
514  if (!edgey) { // Only use for non-edge clusters
515  if (sizey == 1) {
516  if (!bigInY) {
517  yerr = theClusterParam.sy1;
518  } else {
519  yerr = theClusterParam.sy2;
520  }
521  } else {
522  yerr = theClusterParam.sigmay;
523  }
524  }
525 
526  if (localPrint) {
527  cout << " in if " << edgex << " " << edgey << " " << sizex << " " << sizey << endl;
528  cout << " errors " << xerr << " " << yerr << " " << theClusterParam.sx1 << " " << theClusterParam.sx2 << " "
529  << theClusterParam.sigmax << endl; //dk
530  }
531  }
532  else { // simple errors
533 
534  // This are the simple errors, hardcoded in the code
535  //cout << "Track angles are not known " << endl;
536  //cout << "Default angle estimation which assumes track from PV (0,0,0) does not work." << endl;
537 
538  if (GeomDetEnumerators::isTrackerPixel(theDetParam.thePart)) {
539  if (GeomDetEnumerators::isBarrel(theDetParam.thePart)) {
540  DetId id = (theDetParam.theDet->geographicalId());
541  int layer = ttopo_.layer(id);
542  if (layer == 1) {
543  if (!edgex) {
544  if (sizex <= xerr_barrel_l1_.size())
545  xerr = xerr_barrel_l1_[sizex - 1];
546  else
547  xerr = xerr_barrel_l1_def_;
548  }
549 
550  if (!edgey) {
551  if (sizey <= yerr_barrel_l1_.size())
552  yerr = yerr_barrel_l1_[sizey - 1];
553  else
554  yerr = yerr_barrel_l1_def_;
555  }
556  } else { // layer 2,3
557  if (!edgex) {
558  if (sizex <= xerr_barrel_ln_.size())
559  xerr = xerr_barrel_ln_[sizex - 1];
560  else
561  xerr = xerr_barrel_ln_def_;
562  }
563 
564  if (!edgey) {
565  if (sizey <= yerr_barrel_ln_.size())
566  yerr = yerr_barrel_ln_[sizey - 1];
567  else
568  yerr = yerr_barrel_ln_def_;
569  }
570  }
571 
572  } else { // EndCap
573 
574  if (!edgex) {
575  if (sizex <= xerr_endcap_.size())
576  xerr = xerr_endcap_[sizex - 1];
577  else
578  xerr = xerr_endcap_def_;
579  }
580 
581  if (!edgey) {
582  if (sizey <= yerr_endcap_.size())
583  yerr = yerr_endcap_[sizey - 1];
584  else
585  yerr = yerr_endcap_def_;
586  }
587  } // end endcap
588  }
589 
590  if (inflate_errors) {
591  int n_bigx = 0;
592  int n_bigy = 0;
593 
594  for (int irow = 0; irow < 7; ++irow) {
595  if (theDetParam.theRecTopol->isItBigPixelInX(irow + minPixelRow))
596  ++n_bigx;
597  }
598 
599  for (int icol = 0; icol < 21; ++icol) {
600  if (theDetParam.theRecTopol->isItBigPixelInY(icol + minPixelCol))
601  ++n_bigy;
602  }
603 
604  xerr = (float)(sizex + n_bigx) * theDetParam.thePitchX / std::sqrt(12.0f);
605  yerr = (float)(sizey + n_bigy) * theDetParam.thePitchY / std::sqrt(12.0f);
606 
607  } // if(inflate_errors)
608 
609  } // end
610 
611 #ifdef EDM_ML_DEBUG
612  if (!(xerr > 0.0))
613  throw cms::Exception("PixelCPEGeneric::localError") << "\nERROR: Negative pixel error xerr = " << xerr << "\n\n";
614 
615  if (!(yerr > 0.0))
616  throw cms::Exception("PixelCPEGeneric::localError") << "\nERROR: Negative pixel error yerr = " << yerr << "\n\n";
617 #endif
618 
619  //if(localPrint) {
620  //cout<<" errors "<<xerr<<" "<<yerr<<endl; //dk
621  //if(theClusterParam.qBin_ == 0) cout<<" qbin 0 "<<xerr<<" "<<yerr<<endl;
622  //}
623 
624  auto xerr_sq = xerr * xerr;
625  auto yerr_sq = yerr * yerr;
626 
627  return LocalError(xerr_sq, 0, yerr_sq);
628 }
629 
631  desc.add<double>("eff_charge_cut_highX", 1.0);
632  desc.add<double>("eff_charge_cut_highY", 1.0);
633  desc.add<double>("eff_charge_cut_lowX", 0.0);
634  desc.add<double>("eff_charge_cut_lowY", 0.0);
635  desc.add<double>("size_cutX", 3.0);
636  desc.add<double>("size_cutY", 3.0);
637  desc.add<double>("EdgeClusterErrorX", 50.0);
638  desc.add<double>("EdgeClusterErrorY", 85.0);
639  desc.add<bool>("inflate_errors", false);
640  desc.add<bool>("inflate_all_errors_no_trk_angle", false);
641  desc.add<bool>("NoTemplateErrorsWhenNoTrkAngles", false);
642  desc.add<bool>("UseErrorsFromTemplates", true);
643  desc.add<bool>("TruncatePixelCharge", true);
644  desc.add<bool>("IrradiationBiasCorrection", false);
645  desc.add<bool>("DoCosmics", false);
646  desc.add<bool>("Upgrade", false);
647  desc.add<bool>("SmallPitch", false);
648 }
Point2DBase
Definition: Point2DBase.h:9
PixelCPEGeneric::localError
LocalError localError(DetParam const &theDetParam, ClusterParam &theClusterParam) const override
Definition: PixelCPEGeneric.cc:449
SiPixelCluster::minPixelCol
int minPixelCol() const
Definition: SiPixelCluster.h:140
PixelCPEBase::ClusterParam
Definition: PixelCPEBase.h:80
PixelCPEBase::DetParam::bz
float bz
Definition: PixelCPEBase.h:69
PixelCPEBase::DetParam::bx
float bx
Definition: PixelCPEBase.h:70
PixelCPEBase::DetParam::theTopol
const PixelTopology * theTopol
Definition: PixelCPEBase.h:60
PixelCPEBase::DetParam::lorentzShiftInCmY
float lorentzShiftInCmY
Definition: PixelCPEBase.h:75
PixelCPEGeneric::yerr_barrel_ln_def_
float yerr_barrel_ln_def_
Definition: PixelCPEGeneric.h:135
PixelCPEBase::DetParam::thePitchX
float thePitchX
Definition: PixelCPEBase.h:66
PixelCPEBase::DetParam::widthLAFractionX
float widthLAFractionX
Definition: PixelCPEBase.h:72
PixelCPEGeneric::xerr_barrel_l1_def_
float xerr_barrel_l1_def_
Definition: PixelCPEGeneric.h:134
mps_fire.i
i
Definition: mps_fire.py:428
PixelCPEGeneric::ClusterParamGeneric::pixmx
int pixmx
Definition: PixelCPEGeneric.h:60
MessageLogger.h
dqmMemoryStats.float
float
Definition: dqmMemoryStats.py:127
PixelCPEGeneric::collect_edge_charges
void collect_edge_charges(ClusterParam &theClusterParam, int &Q_f_X, int &Q_l_X, int &Q_f_Y, int &Q_l_Y) const
Definition: PixelCPEGeneric.cc:400
PixelCPEGeneric::ClusterParamGeneric::dy1
float dy1
Definition: PixelCPEGeneric.h:73
PixelCPEGeneric::ClusterParamGeneric::sy2
float sy2
Definition: PixelCPEGeneric.h:66
RectangularPixelTopology.h
f
double f[11][100]
Definition: MuScleFitUtils.cc:78
PixelCPEBase::DetParam::theRecTopol
const RectangularPixelTopology * theRecTopol
Definition: PixelCPEBase.h:61
PV3DBase::x
T x() const
Definition: PV3DBase.h:59
min
T min(T a, T b)
Definition: MathUtil.h:58
PixelCPEBase::DetParam::theThickness
float theThickness
Definition: PixelCPEBase.h:65
TrackerTopology
Definition: TrackerTopology.h:16
PixelCPEBase::genErrorDBObject_
const SiPixelGenErrorDBObject * genErrorDBObject_
Definition: PixelCPEBase.h:245
SiPixelCluster::y
float y() const
Definition: SiPixelCluster.h:113
PixelCPEBase::ttopo_
const TrackerTopology & ttopo_
Definition: PixelCPEBase.h:240
gather_cfg.cout
cout
Definition: gather_cfg.py:144
SiPixelGenError::lorxwidth
float lorxwidth()
signed lorentz x-width (microns)
Definition: SiPixelGenError.h:179
SiPixelCluster::maxPixelCol
int maxPixelCol() const
Definition: SiPixelCluster.h:141
PixelCPEGeneric::EdgeClusterErrorY_
float EdgeClusterErrorY_
Definition: PixelCPEGeneric.h:130
PixelCPEBase::DetParam::widthLAFractionY
float widthLAFractionY
Definition: PixelCPEBase.h:73
edm::ParameterSetDescription
Definition: ParameterSetDescription.h:52
PixelCPEBase::DetParam::thePitchY
float thePitchY
Definition: PixelCPEBase.h:67
muonClassificationByHits_cfi.pixel
pixel
Definition: muonClassificationByHits_cfi.py:9
SiPixelCluster::maxPixelRow
int maxPixelRow() const
Definition: SiPixelCluster.h:139
SiPixelGenError::qbin
int qbin(int id, float cotalpha, float cotbeta, float locBz, float locBx, float qclus, bool irradiationCorrections, int &pixmx, float &sigmay, float &deltay, float &sigmax, float &deltax, float &sy1, float &dy1, float &sy2, float &dy2, float &sx1, float &dx1, float &sx2, float &dx2)
Definition: SiPixelGenError.cc:538
PixelCPEGeneric::ClusterParamGeneric::sx1
float sx1
Definition: PixelCPEGeneric.h:67
TrackerTopology::layer
unsigned int layer(const DetId &id) const
Definition: TrackerTopology.cc:47
Topology::localPosition
virtual LocalPoint localPosition(const MeasurementPoint &) const =0
PixelCPEGeneric::DoCosmics_
bool DoCosmics_
Definition: PixelCPEGeneric.h:123
SiPixelCluster
Pixel cluster – collection of neighboring pixels above threshold.
Definition: SiPixelCluster.h:27
RectangularPixelTopology::containsBigPixelInY
bool containsBigPixelInY(int iymin, int iymax) const override
Definition: RectangularPixelTopology.h:135
PixelCPEGeneric::createClusterParam
std::unique_ptr< ClusterParam > createClusterParam(const SiPixelCluster &cl) const override
Definition: PixelCPEGeneric.cc:146
PixelCPEBase::DetParam::theDet
const PixelGeomDetUnit * theDet
Definition: PixelCPEBase.h:58
PixelCPEGeneric::localPosition
LocalPoint localPosition(DetParam const &theDetParam, ClusterParam &theClusterParam) const override
Definition: PixelCPEGeneric.cc:155
PixelCPEBase::ClusterParam::theCluster
const SiPixelCluster * theCluster
Definition: PixelCPEBase.h:85
PixelCPEGeneric::thePixelGenError_
std::vector< SiPixelGenErrorStore > thePixelGenError_
Definition: PixelCPEGeneric.h:138
RectangularPixelTopology::isItBigPixelInY
bool isItBigPixelInY(const int iybin) const override
Definition: RectangularPixelTopology.h:118
GetRecoTauVFromDQM_MC_cff.cl
cl
Definition: GetRecoTauVFromDQM_MC_cff.py:38
PixelCPEGeneric::ClusterParamGeneric::dx1
float dx1
Definition: PixelCPEGeneric.h:75
DetId
Definition: DetId.h:17
PixelCPEGeneric::xerr_barrel_l1_
std::vector< float > xerr_barrel_l1_
Definition: PixelCPEGeneric.h:132
RectangularPixelTopology::containsBigPixelInX
bool containsBigPixelInX(int ixmin, int ixmax) const override
Definition: RectangularPixelTopology.h:132
SiPixelCluster::sizeY
int sizeY() const
Definition: SiPixelCluster.h:128
PixelCPEGeneric::the_size_cutX
float the_size_cutX
Definition: PixelCPEGeneric.h:116
SiPixelTemplate.h
PixelCPEGeneric::EdgeClusterErrorX_
float EdgeClusterErrorX_
Definition: PixelCPEGeneric.h:129
PixelCPEGeneric::ClusterParamGeneric
Definition: PixelCPEGeneric.h:54
L1TOccupancyClient_cfi.ymax
ymax
Definition: L1TOccupancyClient_cfi.py:43
PixelCPEGeneric::the_eff_charge_cut_lowX
float the_eff_charge_cut_lowX
Definition: PixelCPEGeneric.h:112
RectangularPixelTopology::isItBigPixelInX
bool isItBigPixelInX(const int ixbin) const override
Definition: RectangularPixelTopology.h:114
PixelCPEGeneric::IrradiationBiasCorrection_
bool IrradiationBiasCorrection_
Definition: PixelCPEGeneric.h:125
PixelCPEGeneric::the_size_cutY
float the_size_cutY
Definition: PixelCPEGeneric.h:117
PixelCPEGeneric::ClusterParamGeneric::sy1
float sy1
Definition: PixelCPEGeneric.h:65
PixelCPEGeneric::NoTemplateErrorsWhenNoTrkAngles_
bool NoTemplateErrorsWhenNoTrkAngles_
Definition: PixelCPEGeneric.h:127
SiPixelCluster::minPixelRow
int minPixelRow() const
Definition: SiPixelCluster.h:138
mathSSE::sqrt
T sqrt(T t)
Definition: SSEVec.h:19
PixelCPEGeneric::the_eff_charge_cut_lowY
float the_eff_charge_cut_lowY
Definition: PixelCPEGeneric.h:113
SiPixelLorentzAngle
Definition: SiPixelLorentzAngle.h:11
relativeConstraints.geom
geom
Definition: relativeConstraints.py:72
PixelCPEGeneric::PixelCPEGeneric
PixelCPEGeneric(edm::ParameterSet const &conf, const MagneticField *, const TrackerGeometry &, const TrackerTopology &, const SiPixelLorentzAngle *, const SiPixelGenErrorDBObject *, const SiPixelLorentzAngle *)
The constructor.
Definition: PixelCPEGeneric.cc:30
Point3DBase< float, LocalTag >
SiPixelUtils.h
PixelCPEGeneric::TruncatePixelCharge_
bool TruncatePixelCharge_
Definition: PixelCPEGeneric.h:124
PixelCPEGeneric::ClusterParamGeneric::sigmax
float sigmax
Definition: PixelCPEGeneric.h:64
PixelCPEGeneric::the_eff_charge_cut_highX
float the_eff_charge_cut_highX
Definition: PixelCPEGeneric.h:114
RectangularPixelTopology::isItEdgePixelInX
bool isItEdgePixelInX(int ixbin) const override
Definition: RectangularPixelTopology.h:143
GeomDet::geographicalId
DetId geographicalId() const
The label of this GeomDet.
Definition: GeomDet.h:64
PixelCPEGeneric::xerr_barrel_ln_def_
float xerr_barrel_ln_def_
Definition: PixelCPEGeneric.h:134
LogDebug
#define LogDebug(id)
Definition: MessageLogger.h:223
SiPixelGenError
Definition: SiPixelGenError.h:113
edm::ParameterSet
Definition: ParameterSet.h:47
SiPixelCluster::x
float x() const
Definition: SiPixelCluster.h:105
LocalError
Definition: LocalError.h:12
PixelCPEGeneric::ClusterParamGeneric::dy2
float dy2
Definition: PixelCPEGeneric.h:74
PV2DBase::y
T y() const
Definition: PV2DBase.h:44
PixelCPEGeneric::ClusterParamGeneric::sigmay
float sigmay
Definition: PixelCPEGeneric.h:63
PV2DBase::x
T x() const
Definition: PV2DBase.h:43
PV3DBase::y
T y() const
Definition: PV3DBase.h:60
createfilelist.int
int
Definition: createfilelist.py:10
GeomDetEnumerators::isTrackerPixel
bool isTrackerPixel(GeomDetEnumerators::SubDetector m)
Definition: GeomDetEnumerators.cc:68
PixelCPEGeneric::yerr_barrel_l1_
std::vector< float > yerr_barrel_l1_
Definition: PixelCPEGeneric.h:132
PixelCPEGeneric::the_eff_charge_cut_highY
float the_eff_charge_cut_highY
Definition: PixelCPEGeneric.h:115
PixelCPEBase::theVerboseLevel
int theVerboseLevel
Definition: PixelCPEBase.h:235
GeomDetEnumerators::isBarrel
bool isBarrel(GeomDetEnumerators::SubDetector m)
Definition: GeomDetEnumerators.cc:57
PixelCPEGeneric::ClusterParamGeneric::deltay
float deltay
Definition: PixelCPEGeneric.h:71
PixelCPEGeneric::yerr_endcap_
std::vector< float > yerr_endcap_
Definition: PixelCPEGeneric.h:133
PixelCPEGeneric::xerr_barrel_ln_
std::vector< float > xerr_barrel_ln_
Definition: PixelCPEGeneric.h:132
PixelCPEGeneric::xerr_endcap_
std::vector< float > xerr_endcap_
Definition: PixelCPEGeneric.h:133
MagneticField.h
SiPixelCluster::size
int size() const
Definition: SiPixelCluster.h:122
SiPixelCluster::pixel
Pixel pixel(int i) const
Definition: SiPixelCluster.h:158
PixelCPEGeneric::yerr_barrel_l1_def_
float yerr_barrel_l1_def_
Definition: PixelCPEGeneric.h:134
PixelCPEBase::LoadTemplatesFromDB_
bool LoadTemplatesFromDB_
Definition: PixelCPEBase.h:252
PixelCPEGeneric::ClusterParamGeneric::dx2
float dx2
Definition: PixelCPEGeneric.h:76
PixelCPEGeneric.h
SiPixelGenError::pushfile
static bool pushfile(int filenum, std::vector< SiPixelGenErrorStore > &pixelTemp, std::string dir="")
Definition: SiPixelGenError.cc:55
PixelCPEGeneric::UseErrorsFromTemplates_
bool UseErrorsFromTemplates_
Definition: PixelCPEGeneric.h:122
PixelCPEBase::DetParam::detTemplateId
int detTemplateId
Definition: PixelCPEBase.h:76
PixelCPEBase::DetParam::thePart
GeomDetType::SubDetector thePart
Definition: PixelCPEBase.h:63
PixelCPEBase::DetParam::lorentzShiftInCmX
float lorentzShiftInCmX
Definition: PixelCPEBase.h:74
mag
T mag() const
The vector magnitude. Equivalent to sqrt(vec.mag2())
Definition: Basic3DVectorLD.h:127
PixelCPEBase::DetParam
Definition: PixelCPEBase.h:56
submitPVResolutionJobs.desc
string desc
Definition: submitPVResolutionJobs.py:251
std
Definition: JetResolutionObject.h:76
PixelCPEGeneric::yerr_endcap_def_
float yerr_endcap_def_
Definition: PixelCPEGeneric.h:135
RectangularPixelTopology::isItEdgePixelInY
bool isItEdgePixelInY(int iybin) const override
Definition: RectangularPixelTopology.h:144
L1TOccupancyClient_cfi.ymin
ymin
Definition: L1TOccupancyClient_cfi.py:43
DetId.h
LIKELY
#define LIKELY(x)
Definition: Likely.h:20
TrackerOfflineValidation_Dqm_cff.xmax
xmax
Definition: TrackerOfflineValidation_Dqm_cff.py:11
SiPixelGenError::lorywidth
float lorywidth()
signed lorentz y-width (microns)
Definition: SiPixelGenError.h:178
Exception
Definition: hltDiff.cc:246
PixelCPEBase
Definition: PixelCPEBase.h:54
PixelCPEGeneric::fillPSetDescription
static void fillPSetDescription(edm::ParameterSetDescription &desc)
Definition: PixelCPEGeneric.cc:630
PixelGeomDetUnit.h
PixelCPEBase::ClusterParam::loc_trk_pred
Topology::LocalTrackPred loc_trk_pred
Definition: PixelCPEBase.h:99
SiPixelCluster::charge
int charge() const
Definition: SiPixelCluster.h:130
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
PixelCPEBase::ClusterParam::cotbeta
float cotbeta
Definition: PixelCPEBase.h:89
SiPixelGenErrorDBObject
Definition: SiPixelGenErrorDBObject.h:16
PixelCPEGeneric::ClusterParamGeneric::sx2
float sx2
Definition: PixelCPEGeneric.h:68
PixelCPEGeneric::yerr_barrel_ln_
std::vector< float > yerr_barrel_ln_
Definition: PixelCPEGeneric.h:133
PixelCPEBase::ClusterParam::cotalpha
float cotalpha
Definition: PixelCPEBase.h:88
TrackerOfflineValidation_Dqm_cff.xmin
xmin
Definition: TrackerOfflineValidation_Dqm_cff.py:10
SiPixelCluster::sizeX
int sizeX() const
Definition: SiPixelCluster.h:125
MagneticField
Definition: MagneticField.h:19
PixelCPEGeneric::ClusterParamGeneric::deltax
float deltax
Definition: PixelCPEGeneric.h:72
PixelCPEGeneric::inflate_errors
bool inflate_errors
Definition: PixelCPEGeneric.h:119
PixelCPEGeneric::isUpgrade_
bool isUpgrade_
Definition: PixelCPEGeneric.h:126
PixelCPEGeneric::xerr_endcap_def_
float xerr_endcap_def_
Definition: PixelCPEGeneric.h:135
SiPixelUtils::generic_position_formula
float generic_position_formula(int size, int Q_f, int Q_l, float upper_edge_first_pix, float lower_edge_last_pix, float lorentz_shift, float theThickness, float cot_angle, float pitch, bool first_is_big, bool last_is_big, float eff_charge_cut_low, float eff_charge_cut_high, float size_cut)
Definition: SiPixelUtils.cc:16
PixelCPEBase::ClusterParam::with_track_angle
bool with_track_angle
Definition: PixelCPEBase.h:112
PixelCPEGeneric::inflate_all_errors_no_trk_angle
bool inflate_all_errors_no_trk_angle
Definition: PixelCPEGeneric.h:120
TrackerGeometry
Definition: TrackerGeometry.h:14
PixelCPEBase::ClusterParam::qBin_
int qBin_
Definition: PixelCPEBase.h:105