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 
167  if (UseErrorsFromTemplates_) {
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 
187  SiPixelGenError gtempl(thePixelGenError_);
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,
199  IrradiationBiasCorrection_,
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()),
319  the_eff_charge_cut_lowX,
320  the_eff_charge_cut_highX,
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()),
343  the_eff_charge_cut_lowY,
344  the_eff_charge_cut_highY,
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
351  if (IrradiationBiasCorrection_) {
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;
424  if (UseErrorsFromTemplates_ && TruncatePixelCharge_)
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 =
495  UseErrorsFromTemplates_ && (!NoTemplateErrorsWhenNoTrkAngles_ || theClusterParam.with_track_angle);
496 
497  if LIKELY (useTempErrors) {
498  //
499  // Use template errors
500 
501  if (!edgex) { // Only use this for non-edge clusters
502  if (sizex == 1) {
503  if (!bigInX) {
504  xerr = theClusterParam.sx1;
505  } else {
506  xerr = theClusterParam.sx2;
507  }
508  } else {
509  xerr = theClusterParam.sigmax;
510  }
511  }
512 
513  if (!edgey) { // Only use for non-edge clusters
514  if (sizey == 1) {
515  if (!bigInY) {
516  yerr = theClusterParam.sy1;
517  } else {
518  yerr = theClusterParam.sy2;
519  }
520  } else {
521  yerr = theClusterParam.sigmay;
522  }
523  }
524 
525  if (localPrint) {
526  cout << " in if " << edgex << " " << edgey << " " << sizex << " " << sizey << endl;
527  cout << " errors " << xerr << " " << yerr << " " << theClusterParam.sx1 << " " << theClusterParam.sx2 << " "
528  << theClusterParam.sigmax << endl; //dk
529  }
530  } else { // simple errors
531 
532  // This are the simple errors, hardcoded in the code
533  //cout << "Track angles are not known " << endl;
534  //cout << "Default angle estimation which assumes track from PV (0,0,0) does not work." << endl;
535 
536  if (GeomDetEnumerators::isTrackerPixel(theDetParam.thePart)) {
537  if (GeomDetEnumerators::isBarrel(theDetParam.thePart)) {
538  DetId id = (theDetParam.theDet->geographicalId());
539  int layer = ttopo_.layer(id);
540  if (layer == 1) {
541  if (!edgex) {
542  if (sizex <= xerr_barrel_l1_.size())
543  xerr = xerr_barrel_l1_[sizex - 1];
544  else
545  xerr = xerr_barrel_l1_def_;
546  }
547 
548  if (!edgey) {
549  if (sizey <= yerr_barrel_l1_.size())
550  yerr = yerr_barrel_l1_[sizey - 1];
551  else
552  yerr = yerr_barrel_l1_def_;
553  }
554  } else { // layer 2,3
555  if (!edgex) {
556  if (sizex <= xerr_barrel_ln_.size())
557  xerr = xerr_barrel_ln_[sizex - 1];
558  else
559  xerr = xerr_barrel_ln_def_;
560  }
561 
562  if (!edgey) {
563  if (sizey <= yerr_barrel_ln_.size())
564  yerr = yerr_barrel_ln_[sizey - 1];
565  else
566  yerr = yerr_barrel_ln_def_;
567  }
568  }
569 
570  } else { // EndCap
571 
572  if (!edgex) {
573  if (sizex <= xerr_endcap_.size())
574  xerr = xerr_endcap_[sizex - 1];
575  else
576  xerr = xerr_endcap_def_;
577  }
578 
579  if (!edgey) {
580  if (sizey <= yerr_endcap_.size())
581  yerr = yerr_endcap_[sizey - 1];
582  else
583  yerr = yerr_endcap_def_;
584  }
585  } // end endcap
586  }
587 
588  if (inflate_errors) {
589  int n_bigx = 0;
590  int n_bigy = 0;
591 
592  for (int irow = 0; irow < 7; ++irow) {
593  if (theDetParam.theRecTopol->isItBigPixelInX(irow + minPixelRow))
594  ++n_bigx;
595  }
596 
597  for (int icol = 0; icol < 21; ++icol) {
598  if (theDetParam.theRecTopol->isItBigPixelInY(icol + minPixelCol))
599  ++n_bigy;
600  }
601 
602  xerr = (float)(sizex + n_bigx) * theDetParam.thePitchX / std::sqrt(12.0f);
603  yerr = (float)(sizey + n_bigy) * theDetParam.thePitchY / std::sqrt(12.0f);
604 
605  } // if(inflate_errors)
606 
607  } // end
608 
609 #ifdef EDM_ML_DEBUG
610  if (!(xerr > 0.0))
611  throw cms::Exception("PixelCPEGeneric::localError") << "\nERROR: Negative pixel error xerr = " << xerr << "\n\n";
612 
613  if (!(yerr > 0.0))
614  throw cms::Exception("PixelCPEGeneric::localError") << "\nERROR: Negative pixel error yerr = " << yerr << "\n\n";
615 #endif
616 
617  //if(localPrint) {
618  //cout<<" errors "<<xerr<<" "<<yerr<<endl; //dk
619  //if(theClusterParam.qBin_ == 0) cout<<" qbin 0 "<<xerr<<" "<<yerr<<endl;
620  //}
621 
622  auto xerr_sq = xerr * xerr;
623  auto yerr_sq = yerr * yerr;
624 
625  return LocalError(xerr_sq, 0, yerr_sq);
626 }
627 
629  desc.add<double>("eff_charge_cut_highX", 1.0);
630  desc.add<double>("eff_charge_cut_highY", 1.0);
631  desc.add<double>("eff_charge_cut_lowX", 0.0);
632  desc.add<double>("eff_charge_cut_lowY", 0.0);
633  desc.add<double>("size_cutX", 3.0);
634  desc.add<double>("size_cutY", 3.0);
635  desc.add<double>("EdgeClusterErrorX", 50.0);
636  desc.add<double>("EdgeClusterErrorY", 85.0);
637  desc.add<bool>("inflate_errors", false);
638  desc.add<bool>("inflate_all_errors_no_trk_angle", false);
639  desc.add<bool>("NoTemplateErrorsWhenNoTrkAngles", false);
640  desc.add<bool>("UseErrorsFromTemplates", true);
641  desc.add<bool>("TruncatePixelCharge", true);
642  desc.add<bool>("IrradiationBiasCorrection", false);
643  desc.add<bool>("DoCosmics", false);
644  desc.add<bool>("Upgrade", false);
645  desc.add<bool>("SmallPitch", false);
646 }
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:144
PixelCPEBase::ClusterParam
Definition: PixelCPEBase.h:69
PixelCPEBase::DetParam::bz
float bz
Definition: PixelCPEBase.h:58
PixelCPEBase::DetParam::bx
float bx
Definition: PixelCPEBase.h:59
PixelCPEBase::DetParam::theTopol
const PixelTopology * theTopol
Definition: PixelCPEBase.h:49
PixelCPEBase::DetParam::lorentzShiftInCmY
float lorentzShiftInCmY
Definition: PixelCPEBase.h:64
PixelCPEGeneric::yerr_barrel_ln_def_
float yerr_barrel_ln_def_
Definition: PixelCPEGeneric.h:135
PixelCPEBase::DetParam::thePitchX
float thePitchX
Definition: PixelCPEBase.h:55
PixelCPEBase::DetParam::widthLAFractionX
float widthLAFractionX
Definition: PixelCPEBase.h:61
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::ClusterParamGeneric::dy1
float dy1
Definition: PixelCPEGeneric.h:73
theVerboseLevel
static const int theVerboseLevel
Definition: SiPixelTemplateReco.cc:68
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:50
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:54
TrackerTopology
Definition: TrackerTopology.h:16
PixelCPEBase::genErrorDBObject_
const SiPixelGenErrorDBObject * genErrorDBObject_
Definition: PixelCPEBase.h:235
SiPixelCluster::y
float y() const
Definition: SiPixelCluster.h:117
gather_cfg.cout
cout
Definition: gather_cfg.py:144
SiPixelGenError::lorxwidth
float lorxwidth()
signed lorentz x-width (microns)
Definition: SiPixelGenError.h:187
SiPixelCluster::maxPixelCol
int maxPixelCol() const
Definition: SiPixelCluster.h:145
PixelCPEGeneric::EdgeClusterErrorY_
float EdgeClusterErrorY_
Definition: PixelCPEGeneric.h:130
PixelCPEBase::DetParam::widthLAFractionY
float widthLAFractionY
Definition: PixelCPEBase.h:62
edm::ParameterSetDescription
Definition: ParameterSetDescription.h:52
PixelCPEBase::DetParam::thePitchY
float thePitchY
Definition: PixelCPEBase.h:56
muonClassificationByHits_cfi.pixel
pixel
Definition: muonClassificationByHits_cfi.py:9
SiPixelCluster::maxPixelRow
int maxPixelRow() const
Definition: SiPixelCluster.h:143
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
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:28
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:47
PixelCPEGeneric::localPosition
LocalPoint localPosition(DetParam const &theDetParam, ClusterParam &theClusterParam) const override
Definition: PixelCPEGeneric.cc:155
PixelCPEBase::ClusterParam::theCluster
const SiPixelCluster * theCluster
Definition: PixelCPEBase.h:75
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:132
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:142
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
phase1PixelTopology::layer
constexpr std::array< uint8_t, layerIndexSize > layer
Definition: phase1PixelTopology.h:99
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
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
LogDebug
#define LogDebug(id)
Definition: MessageLogger.h:233
SiPixelGenError
Definition: SiPixelGenError.h:113
edm::ParameterSet
Definition: ParameterSet.h:47
SiPixelCluster::x
float x() const
Definition: SiPixelCluster.h:109
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:225
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:126
SiPixelCluster::pixel
Pixel pixel(int i) const
Definition: SiPixelCluster.h:162
PixelCPEGeneric::yerr_barrel_l1_def_
float yerr_barrel_l1_def_
Definition: PixelCPEGeneric.h:134
PixelCPEBase::LoadTemplatesFromDB_
bool LoadTemplatesFromDB_
Definition: PixelCPEBase.h:242
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:65
PixelCPEBase::DetParam::thePart
GeomDetType::SubDetector thePart
Definition: PixelCPEBase.h:52
PixelCPEBase::DetParam::lorentzShiftInCmX
float lorentzShiftInCmX
Definition: PixelCPEBase.h:63
HLTSiStripMonitoring_cff.inflate_errors
inflate_errors
Definition: HLTSiStripMonitoring_cff.py:38
mag
T mag() const
The vector magnitude. Equivalent to sqrt(vec.mag2())
Definition: Basic3DVectorLD.h:127
PixelCPEBase::DetParam
Definition: PixelCPEBase.h:45
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:186
Exception
Definition: hltDiff.cc:245
PixelCPEBase
Definition: PixelCPEBase.h:43
PixelCPEGeneric::fillPSetDescription
static void fillPSetDescription(edm::ParameterSetDescription &desc)
Definition: PixelCPEGeneric.cc:628
PixelGeomDetUnit.h
PixelCPEBase::ClusterParam::loc_trk_pred
Topology::LocalTrackPred loc_trk_pred
Definition: PixelCPEBase.h:89
SiPixelCluster::charge
int charge() const
Definition: SiPixelCluster.h:134
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
PixelCPEBase::ClusterParam::cotbeta
float cotbeta
Definition: PixelCPEBase.h:79
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:78
TrackerOfflineValidation_Dqm_cff.xmin
xmin
Definition: TrackerOfflineValidation_Dqm_cff.py:10
SiPixelCluster::sizeX
int sizeX() const
Definition: SiPixelCluster.h:129
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:102
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:95