CMS 3D CMS Logo

PixelCPEBase.cc
Go to the documentation of this file.
1 // Move geomCorrection to the concrete class. d.k. 06/06.
2 // Change drift direction. d.k. 06/06
3 // G. Giurgiu (ggiurgiu@pha.jhu.edu), 12/01/06, implemented the function:
4 // computeAnglesFromDetPosition(const SiPixelCluster & cl,
5 // change to use Lorentz angle from DB Lotte Wilke, Jan. 31st, 2008
6 // Change to use Generic error & Template calibration from DB - D.Fehling 11/08
7 
8 
12 
14 
15 #define CORRECT_FOR_BIG_PIXELS
16 
17 // MessageLogger
19 
20 // Magnetic field
22 
23 
24 #include <iostream>
25 
26 using namespace std;
27 
28 //-----------------------------------------------------------------------------
29 // A constructor run for generic and templates
30 //
31 //-----------------------------------------------------------------------------
33  const MagneticField *mag,
34  const TrackerGeometry& geom,
35  const TrackerTopology& ttopo,
36  const SiPixelLorentzAngle * lorentzAngle,
37  const SiPixelGenErrorDBObject * genErrorDBObject,
38  const SiPixelTemplateDBObject * templateDBobject,
39  const SiPixelLorentzAngle * lorentzAngleWidth,
40  int flag)
41 // : useLAAlignmentOffsets_(false), useLAOffsetFromConfig_(false),
42 : useLAOffsetFromConfig_(false),
43 useLAWidthFromConfig_(false), useLAWidthFromDB_(false), theFlag_(flag),
44 magfield_(mag), geom_(geom), ttopo_(ttopo)
45 {
46 
47 #ifdef EDM_ML_DEBUG
48  nRecHitsTotal_=0;
49  nRecHitsUsedEdge_=0,
50 #endif
51 
52  //--- Lorentz angle tangent per Tesla
53  lorentzAngle_ = lorentzAngle;
54  lorentzAngleWidth_ = lorentzAngleWidth;
55 
56  //-- GenError Calibration Object (different from SiPixelCPEGenericErrorParm) from DB
57  genErrorDBObject_ = genErrorDBObject;
58 
59  //-- Template Calibration Object from DB
60  if(theFlag_!=0) templateDBobject_ = templateDBobject; // flag to check if it is generic or templates
61 
62  // Configurables
63  // For both templates & generic
64 
65  // Read templates and/or generic errors from DB
66  LoadTemplatesFromDB_ = conf.getParameter<bool>("LoadTemplatesFromDB");
67 
68  //--- Algorithm's verbosity
70  conf.getUntrackedParameter<int>("VerboseLevel",0);
71 
72  //-- Switch on/off E.B
73  alpha2Order = conf.getParameter<bool>("Alpha2Order");
74 
75  //--- A flag that could be used to change the behavior of
76  //--- clusterProbability() in TSiPixelRecHit (the *transient* one).
77  //--- The problem is that the transient hits are made after the CPE runs
78  //--- and they don't get the access to the PSet, so we pass it via the
79  //--- CPE itself...
80  //
82  = (unsigned int) conf.getParameter<int>("ClusterProbComputationFlag");
83 
84  // This LA related parameters are only relevant for the Generic algo
85  // They still have to be used in Base since the LA computation is in Base
86 
87  // Use LA-width from DB.
88  // If both (this and from config) are false LA-width is calcuated from LA-offset
89  useLAWidthFromDB_ = conf.existsAs<bool>("useLAWidthFromDB")?
90  conf.getParameter<bool>("useLAWidthFromDB"):false;
91 
92  // Use Alignment LA-offset in generic
93  // (Experimental; leave commented out)
94  //useLAAlignmentOffsets_ = conf.existsAs<bool>("useLAAlignmentOffsets")?
95  //conf.getParameter<bool>("useLAAlignmentOffsets"):false;
96 
97  // Used only for testing
98  lAOffset_ = conf.existsAs<double>("lAOffset")? // fixed LA value
99  conf.getParameter<double>("lAOffset"):0.0;
100  lAWidthBPix_ = conf.existsAs<double>("lAWidthBPix")? // fixed LA width
101  conf.getParameter<double>("lAWidthBPix"):0.0;
102  lAWidthFPix_ = conf.existsAs<double>("lAWidthFPix")? // fixed LA width
103  conf.getParameter<double>("lAWidthFPix"):0.0;
104 
105  // Use LA-offset from config, for testing only
106  if (lAOffset_>0.0)
107  useLAOffsetFromConfig_ = true;
108  // Use LA-width from config, split into fpix & bpix, for testing only
109  if (lAWidthBPix_>0.0 || lAWidthFPix_>0.0)
110  useLAWidthFromConfig_ = true;
111 
112 
113  // For Templates only
114  // Compute the Lorentz shifts for this detector element for templates (from Alignment)
115  DoLorentz_ = conf.existsAs<bool>("DoLorentz")?conf.getParameter<bool>("DoLorentz"):false;
116 
117  LogDebug("PixelCPEBase") <<" LA constants - "
118  << lAOffset_ << " " << lAWidthBPix_ << " " <<lAWidthFPix_ << endl; //dk
119 
120  fillDetParams();
121 }
122 
123 
124 //-----------------------------------------------------------------------------
125 // Fill all variables which are constant for an event (geometry)
126 //-----------------------------------------------------------------------------
128 {
129  // &&& PM: I have no idea what this code is doing, and what it is doing here!???
130  //
131  auto const & dus = geom_.detUnits();
132  unsigned m_detectors = dus.size();
133  for(unsigned int i=1;i<7;++i) {
134  LogDebug("PixelCPEBase:: LookingForFirstStrip") << "Subdetector " << i
135  << " GeomDetEnumerator " << GeomDetEnumerators::tkDetEnum[i]
136  << " offset " << geom_.offsetDU(GeomDetEnumerators::tkDetEnum[i])
137  << " is it strip? " << (geom_.offsetDU(GeomDetEnumerators::tkDetEnum[i]) != dus.size() ?
138  dus[geom_.offsetDU(GeomDetEnumerators::tkDetEnum[i])]->type().isTrackerStrip() : false);
139  if(geom_.offsetDU(GeomDetEnumerators::tkDetEnum[i]) != dus.size() &&
140  dus[geom_.offsetDU(GeomDetEnumerators::tkDetEnum[i])]->type().isTrackerStrip()) {
142  }
143  }
144  LogDebug("LookingForFirstStrip") << " Chosen offset: " << m_detectors;
145 
146 
147  m_DetParams.resize(m_detectors);
148  LogDebug("PixelCPEBase::fillDetParams():") <<"caching "<<m_detectors<<" pixel detectors"<<endl;
149  for (unsigned i=0; i!=m_detectors;++i) {
150  auto & p=m_DetParams[i];
151  p.theDet = dynamic_cast<const PixelGeomDetUnit*>(dus[i]);
152  assert(p.theDet);
153  assert(p.theDet->index()==int(i));
154 
155  p.theOrigin = p.theDet->surface().toLocal(GlobalPoint(0,0,0));
156 
157  //--- p.theDet->type() returns a GeomDetType, which implements subDetector()
158  p.thePart = p.theDet->type().subDetector();
159 
160 
161  //--- The location in of this DetUnit in a cyllindrical coord system (R,Z)
162  //--- The call goes via BoundSurface, returned by p.theDet->surface(), but
163  //--- position() is implemented in GloballyPositioned<> template
164  //--- ( BoundSurface : Surface : GloballyPositioned<float> )
165  //p.theDetR = p.theDet->surface().position().perp(); //Not used, AH
166  //p.theDetZ = p.theDet->surface().position().z(); //Not used, AH
167  //--- Define parameters for chargewidth calculation
168 
169  //--- bounds() is implemented in BoundSurface itself.
170  p.theThickness = p.theDet->surface().bounds().thickness();
171 
172  // Cache the det id for templates and generic erros
173 
174  if(theFlag_==0) { // for generic
175  if(LoadTemplatesFromDB_ ) // do only if genError requested
176  p.detTemplateId = genErrorDBObject_->getGenErrorID(p.theDet->geographicalId().rawId());
177  } else { // for templates
178  p.detTemplateId = templateDBobject_->getTemplateID(p.theDet->geographicalId());
179  }
180 
181  // &&& PM: I'm not sure what this does. Ask around.
182  // just for testing
183  //int i1 = 0;
184  //if(theFlag_==0) i1 = genErrorDBObject_->getGenErrorID(p.theDet->geographicalId().rawId());
185  //int i2= templateDBobject_->getTemplateID(p.theDet->geographicalId().rawId());
186  //int i3= templateDBobject_->getTemplateID(p.theDet->geographicalId());
187  //if(i2!=i3) cout<<i2<<" != "<<i3<<endl;
188  //cout<<i<<" "<<p.detTemplateId<<" "<<i1<<" "<<i2<<" "<<i3<<endl;
189 
190  auto topol = &(p.theDet->specificTopology());
191  p.theTopol=topol;
192  auto const proxyT = dynamic_cast<const ProxyPixelTopology*>(p.theTopol);
193  if (proxyT) p.theRecTopol = dynamic_cast<const RectangularPixelTopology*>(&(proxyT->specificTopology()));
194  else p.theRecTopol = dynamic_cast<const RectangularPixelTopology*>(p.theTopol);
195  assert(p.theRecTopol);
196 
197  //--- The geometrical description of one module/plaquette
198  //p.theNumOfRow = p.theRecTopol->nrows(); // rows in x //Not used, AH. PM: leave commented out.
199  //p.theNumOfCol = p.theRecTopol->ncolumns(); // cols in y //Not used, AH. PM: leave commented out.
200  std::pair<float,float> pitchxy = p.theRecTopol->pitch();
201  p.thePitchX = pitchxy.first; // pitch along x
202  p.thePitchY = pitchxy.second; // pitch along y
203 
204  //p.theSign = isFlipped(&p) ? -1 : 1; //Not used, AH. PM: leave commented out.
205 
206  LocalVector Bfield = p.theDet->surface().toLocal(magfield_->inTesla(p.theDet->surface().position()));
207  p.bz = Bfield.z();
208  p.bx = Bfield.x();
209 
210 
211  //--- Compute the Lorentz shifts for this detector element
212  if ( (theFlag_==0) || DoLorentz_ ) { // do always for generic and if(DOLorentz) for templates
213  p.driftDirection = driftDirection(p, Bfield );
215  }
216 
217 
218  LogDebug("PixelCPEBase::fillDetParams()") << "***** PIXEL LAYOUT *****"
219  << " thePart = " << p.thePart
220  << " theThickness = " << p.theThickness
221  << " thePitchX = " << p.thePitchX
222  << " thePitchY = " << p.thePitchY;
223  // << " theLShiftX = " << p.theLShiftX;
224 
225 
226  }
227 }
228 
229 //-----------------------------------------------------------------------------
230 // One function to cache the variables common for one DetUnit.
231 //-----------------------------------------------------------------------------
232 void
233 PixelCPEBase::setTheClu( DetParam const & theDetParam, ClusterParam & theClusterParam ) const
234 {
235 
236  //--- Geometric Quality Information
237  int minInX,minInY,maxInX,maxInY=0;
238  minInX = theClusterParam.theCluster->minPixelRow();
239  minInY = theClusterParam.theCluster->minPixelCol();
240  maxInX = theClusterParam.theCluster->maxPixelRow();
241  maxInY = theClusterParam.theCluster->maxPixelCol();
242 
243  if ( theDetParam.theRecTopol->isItEdgePixelInX(minInX) )
244  theClusterParam.edgeTypeX_ = 1;
245  else if ( theDetParam.theRecTopol->isItEdgePixelInX(maxInX) )
246  theClusterParam.edgeTypeX_ = 2;
247  else
248  theClusterParam.edgeTypeX_ = 0;
249 
250  if ( theDetParam.theRecTopol->isItEdgePixelInY(minInY) )
251  theClusterParam.edgeTypeY_ = 1;
252  else if ( theDetParam.theRecTopol->isItEdgePixelInY(maxInY) )
253  theClusterParam.edgeTypeY_ = 2;
254  else
255  theClusterParam.edgeTypeY_ = 0;
256 
257  theClusterParam.isOnEdge_ = ( theClusterParam.edgeTypeX_ || theClusterParam.edgeTypeY_ );
258 
259  // &&& FOR NOW UNUSED. KEEP IT IN CASE WE WANT TO USE IT IN THE FUTURE
260  // Bad Pixels have their charge set to 0 in the clusterizer
261  //hasBadPixels_ = false;
262  //for(unsigned int i=0; i<theClusterParam.theCluster->pixelADC().size(); ++i) {
263  //if(theClusterParam.theCluster->pixelADC()[i] == 0) { hasBadPixels_ = true; break;}
264  //}
265 
266  theClusterParam.spansTwoROCs_ = theDetParam.theRecTopol->containsBigPixelInX(minInX,maxInX) |
267  theDetParam.theRecTopol->containsBigPixelInY(minInY,maxInY);
268 
269 }
270 
271 
272 //-----------------------------------------------------------------------------
273 // Compute alpha_ and beta_ from the LocalTrajectoryParameters.
274 // Note: should become const after both localParameters() become const.
275 //-----------------------------------------------------------------------------
276 void PixelCPEBase::
277 computeAnglesFromTrajectory( DetParam const & theDetParam, ClusterParam & theClusterParam,
278  const LocalTrajectoryParameters & ltp) const
279 {
280  // &&& PM: this comment is a candidate for deletion, but ask around first.
281  //cout<<" in PixelCPEBase:computeAnglesFromTrajectory - "<<endl; //dk
282  /*
283  //theClusterParam.loc_traj_param = ltp;
284  LocalVector localDir = ltp.momentum();
285  float locx = localDir.x();
286  float locy = localDir.y();
287  float locz = localDir.z();
288  // Danek's definition
289  alpha_ = acos(locx/sqrt(locx*locx+locz*locz));
290  if ( isFlipped() ) // &&& check for FPIX !!!
291  alpha_ = PI - alpha_ ;
292  beta_ = acos(locy/sqrt(locy*locy+locz*locz));
293  */
294 
295 
296  theClusterParam.cotalpha = ltp.dxdz();
297  theClusterParam.cotbeta = ltp.dydz();
298 
299 
300  LocalPoint trk_lp = ltp.position();
301  theClusterParam.trk_lp_x = trk_lp.x();
302  theClusterParam.trk_lp_y = trk_lp.y();
303 
304  theClusterParam.with_track_angle = true;
305 
306  // GG: needed to correct for bows/kinks
307  theClusterParam.loc_trk_pred =
308  Topology::LocalTrackPred(theClusterParam.trk_lp_x, theClusterParam.trk_lp_y,
309  theClusterParam.cotalpha,theClusterParam.cotbeta);
310 
311 }
312 
313 //-----------------------------------------------------------------------------
314 // Estimate theAlpha for barrel, based on the det position.
315 // &&& Needs to be consolidated from the above.
316 //-----------------------------------------------------------------------------
317 //float
318 //PixelCPEBase::estimatedAlphaForBarrel(float centerx) const
319 //{
320 // float tanalpha = theSign * (centerx-theOffsetX) * thePitchX / theDetR;
321 // return PI/2.0 - atan(tanalpha);
322 //}
323 
324 
325 
326 
327 //-----------------------------------------------------------------------------
328 // Compute alpha_ and beta_ from the position of this DetUnit.
329 // &&& DOES NOT WORK FOR NOW. d.k. 6/06
330 // The angles from dets are calculated internaly in the PixelCPEInitial class
331 //-----------------------------------------------------------------------------
332 // G. Giurgiu, 12/01/06 : implement the function
333 void PixelCPEBase::
334 computeAnglesFromDetPosition(DetParam const & theDetParam, ClusterParam & theClusterParam ) const
335 {
336  // &&& PM: darn, we have a lot of junk here. Need to clean up.
337 
338  /*
339  // get cluster center of gravity (of charge)
340  float xcenter = cl.x();
341  float ycenter = cl.y();
342 
343  // get the cluster position in local coordinates (cm)
344 
345  // ggiurgiu@jhu.edu 12/09/2010 : This function is called without track info, therefore there are no track
346  // angles to provide here. Call the default localPosition (without track info)
347  LocalPoint lp = theTopol->localPosition( MeasurementPoint(xcenter, ycenter) );
348 
349 
350  // get the cluster position in global coordinates (cm)
351  GlobalPoint gp = theDet->surface().toGlobal( lp );
352  float gp_mod = sqrt( gp.x()*gp.x() + gp.y()*gp.y() + gp.z()*gp.z() );
353 
354  // normalize
355  float gpx = gp.x()/gp_mod;
356  float gpy = gp.y()/gp_mod;
357  float gpz = gp.z()/gp_mod;
358 
359  // make a global vector out of the global point; this vector will point from the
360  // origin of the detector to the cluster
361  GlobalVector gv(gpx, gpy, gpz);
362 
363  // make local unit vector along local X axis
364  const Local3DVector lvx(1.0, 0.0, 0.0);
365 
366  // get the unit X vector in global coordinates/
367  GlobalVector gvx = theDet->surface().toGlobal( lvx );
368 
369  // make local unit vector along local Y axis
370  const Local3DVector lvy(0.0, 1.0, 0.0);
371 
372  // get the unit Y vector in global coordinates
373  GlobalVector gvy = theDet->surface().toGlobal( lvy );
374 
375  // make local unit vector along local Z axis
376  const Local3DVector lvz(0.0, 0.0, 1.0);
377 
378  // get the unit Z vector in global coordinates
379  GlobalVector gvz = theDet->surface().toGlobal( lvz );
380 
381  // calculate the components of gv (the unit vector pointing to the cluster)
382  // in the local coordinate system given by the basis {gvx, gvy, gvz}
383  // note that both gv and the basis {gvx, gvy, gvz} are given in global coordinates
384  float gv_dot_gvx = gv.x()*gvx.x() + gv.y()*gvx.y() + gv.z()*gvx.z();
385  float gv_dot_gvy = gv.x()*gvy.x() + gv.y()*gvy.y() + gv.z()*gvy.z();
386  float gv_dot_gvz = gv.x()*gvz.x() + gv.y()*gvz.y() + gv.z()*gvz.z();
387  */
388 
389  // all the above is equivalent to
390  LocalPoint lp = theDetParam.theTopol->localPosition( MeasurementPoint(theClusterParam.theCluster->x(), theClusterParam.theCluster->y()) );
391  auto gvx = lp.x()-theDetParam.theOrigin.x();
392  auto gvy = lp.y()-theDetParam.theOrigin.y();
393  auto gvz = -1.f/theDetParam.theOrigin.z();
394  //--- Note that the normalization is not required as only the ratio used
395 
396  //theClusterParam.zneg = (gvz < 0); // Not used, AH
397 
398  // calculate angles
399  theClusterParam.cotalpha = gvx*gvz;
400  theClusterParam.cotbeta = gvy*gvz;
401 
402  theClusterParam.with_track_angle = false;
403 
404 
405  /*
406  // used only in dberror param...
407  auto alpha = HALF_PI - std::atan(cotalpha_);
408  auto beta = HALF_PI - std::atan(cotbeta_);
409  if (zneg) { beta -=PI; alpha -=PI;}
410 
411  auto alpha_ = atan2( gv_dot_gvz, gv_dot_gvx );
412  auto beta_ = atan2( gv_dot_gvz, gv_dot_gvy );
413 
414  assert(std::abs(std::round(alpha*10000.f)-std::round(alpha_*10000.f))<2);
415  assert(std::abs(std::round(beta*10000.f)-std::round(beta_*10000.f))<2);
416  */
417 
418 }
419 
420 
421 
422 //-----------------------------------------------------------------------------
423 // The isFlipped() is a silly way to determine which detectors are inverted.
424 // In the barrel for every 2nd ladder the E field direction is in the
425 // global r direction (points outside from the z axis), every other
426 // ladder has the E field inside. Something similar is in the
427 // forward disks (2 sides of the blade). This has to be recognised
428 // because the charge sharing effect is different.
429 //
430 // The isFliped does it by looking and the relation of the local (z always
431 // in the E direction) to global coordinates. There is probably a much
432 // better way.
433 //-----------------------------------------------------------------------------
434 bool PixelCPEBase::isFlipped(DetParam const & theDetParam) const
435 {
436  // Check the relative position of the local +/- z in global coordinates.
437  float tmp1 = theDetParam.theDet->surface().toGlobal(Local3DPoint(0.,0.,0.)).perp2();
438  float tmp2 = theDetParam.theDet->surface().toGlobal(Local3DPoint(0.,0.,1.)).perp2();
439  if ( tmp2 < tmp1 ) return true;
440  else return false;
441 }
442 //------------------------------------------------------------------------
444 {
445  auto i = det.index();
446  //cout << "get parameters of detector " << i << endl;
447  assert(i<int(m_DetParams.size()));
448  //if (i>=int(m_DetParams.size())) m_DetParams.resize(i+1); // should never happen!
449  const DetParam & p = m_DetParams[i];
450  return p;
451 }
452 
453 //-----------------------------------------------------------------------------
454 // Drift direction.
455 // Works OK for barrel and forward.
456 // The formulas used for dir_x,y,z have to be exactly the same as the ones
457 // used in the digitizer (SiPixelDigitizerAlgorithm.cc).
458 // &&& PM: needs to be consolidated, discuss with PS.
459 //-----------------------------------------------------------------------------
461 PixelCPEBase::driftDirection(DetParam & theDetParam, GlobalVector bfield ) const
462 {
463  Frame detFrame(theDetParam.theDet->surface().position(), theDetParam.theDet->surface().rotation());
464  LocalVector Bfield = detFrame.toLocal(bfield);
465  return driftDirection(theDetParam,Bfield);
466 }
467 
468 
470 PixelCPEBase::driftDirection(DetParam & theDetParam, LocalVector Bfield ) const
471 {
472  // Use LA from DB or from config
473  float langle = 0.;
474  if( !useLAOffsetFromConfig_ ) { // get it from DB
475  if(lorentzAngle_ != nullptr) { // a real LA object
476  langle = lorentzAngle_->getLorentzAngle(theDetParam.theDet->geographicalId().rawId());
477  LogDebug("PixelCPEBase::driftDirection()")
478  <<" la "<<langle<<" "<< theDetParam.theDet->geographicalId().rawId() <<endl;
479  } else { // no LA, unused
480  langle = 0; // set to a fake value
481  LogDebug("PixelCPEBase::driftDirection()") <<" LA object is NULL, assume LA = 0"<<endl; //dk
482  }
483  LogDebug("PixelCPEBase::driftDirection()") << " Will use LA Offset from DB "<<langle<<endl;
484  } else { // from config file
485  langle = lAOffset_;
486  LogDebug("PixelCPEBase::driftDirection()") << " Will use LA Offset from config "<<langle<<endl;
487  }
488 
489  // Now do the LA width stuff
490  theDetParam.widthLAFractionX = 1.; // predefine to 1 (default) if things fail
491  theDetParam.widthLAFractionY = 1.;
492 
493  // Compute the charge width, generic only
494  if(theFlag_==0) {
495 
496  if(useLAWidthFromDB_ && (lorentzAngleWidth_ != nullptr) ) {
497  // take it from a separate, special LA DB object (forWidth)
498 
499  auto langleWidth = lorentzAngleWidth_->getLorentzAngle(theDetParam.theDet->geographicalId().rawId());
500  if(langleWidth!=0.0) theDetParam.widthLAFractionX = std::abs(langleWidth/langle);
501  // leave the widthLAFractionY=1.
502  //cout<<" LAWidth lorentz width "<<theDetParam.widthLAFractionX<<" "<<theDetParam.widthLAFractionY<<endl;
503 
504  } else if(useLAWidthFromConfig_) { // get from config
505 
506  double lAWidth=0;
507  if( GeomDetEnumerators::isTrackerPixel(theDetParam.thePart) && GeomDetEnumerators::isBarrel(theDetParam.thePart) ) lAWidth = lAWidthBPix_; // barrel
508  else lAWidth = lAWidthFPix_;
509 
510  if(langle!=0.0) theDetParam.widthLAFractionX = std::abs(lAWidth/langle);
511  // fix the FractionY at 1
512 
513  //cout<<" Lorentz width from config "<<theDetParam.widthLAFractionX<<" "<<theDetParam.widthLAFractionY<<endl;
514 
515  } else { // get if from the offset LA (old method used until 2013)
516  // do nothing
517  //cout<<" Old default LA width method "<<theDetParam.widthLAFractionX<<" "<<theDetParam.widthLAFractionY<<endl;
518 
519  }
520 
521  //cout<<" Final LA fraction "<<theDetParam.widthLAFractionX<<" "<<theDetParam.widthLAFractionY<<endl;
522 
523  } // if flag
524 
525 
526  float alpha2 = alpha2Order ? langle*langle : 0; //
527 
528  // **********************************************************************
529  // Our convention is the following:
530  // +x is defined by the direction of the Lorentz drift!
531  // +z is defined by the direction of E field (so electrons always go into -z!)
532  // +y is defined by +x and +z, and it turns out to be always opposite to the +B field.
533  // **********************************************************************
534 
535  float dir_x = -( langle * Bfield.y() + alpha2* Bfield.z()* Bfield.x() );
536  float dir_y = ( langle * Bfield.x() - alpha2* Bfield.z()* Bfield.y() );
537  float dir_z = -( 1.f + alpha2* Bfield.z()*Bfield.z() );
538  auto scale = 1.f/std::abs( dir_z ); // same as 1 + alpha2*Bfield.z()*Bfield.z()
539  LocalVector dd(dir_x*scale, dir_y*scale, -1.f ); // last is -1 !
540 
541  LogDebug("PixelCPEBase") << " The drift direction in local coordinate is " << dd ;
542 
543  return dd;
544 }
545 
546 //-----------------------------------------------------------------------------
547 // One-shot computation of the driftDirection and both lorentz shifts
548 //-----------------------------------------------------------------------------
549 void
551 {
552  // Max shift (at the other side of the sensor) in cm
553  theDetParam.lorentzShiftInCmX = theDetParam.driftDirection.x()/theDetParam.driftDirection.z() * theDetParam.theThickness; //
554  theDetParam.lorentzShiftInCmY = theDetParam.driftDirection.y()/theDetParam.driftDirection.z() * theDetParam.theThickness; //
555 
556  LogDebug("PixelCPEBase::computeLorentzShifts()") << " lorentzShiftsInCmX,Y = "
557  << theDetParam.lorentzShiftInCmX <<" "
558  << theDetParam.lorentzShiftInCmY <<" "
559  << theDetParam.driftDirection;
560 }
561 
562 //-----------------------------------------------------------------------------
567 //-----------------------------------------------------------------------------
570 {
572  if (theClusterParam.hasFilledProb_) {
573  float probabilityXY=0;
574  if(theClusterParam.filled_from_2d) probabilityXY = theClusterParam.probabilityX_;
575  else if ( theClusterParam.probabilityX_ !=0 && theClusterParam.probabilityY_ !=0 )
576  probabilityXY = theClusterParam.probabilityX_ * theClusterParam.probabilityY_ * (1.f - std::log(theClusterParam.probabilityX_ * theClusterParam.probabilityY_) ) ;
578  qualWord );
579 
581  qualWord );
582  }
584  qualWord );
585 
587  qualWord );
588 
590  qualWord );
591 
593  qualWord );
594 
596  qualWord );
597 
598  return qualWord;
599 }
#define LogDebug(id)
GlobalPoint toGlobal(const Point2DBase< Scalar, LocalTag > lp) const
Definition: Surface.h:106
T getParameter(std::string const &) const
void setProbabilityXY(float prob, QualWordType &qualWord) const
T getUntrackedParameter(std::string const &, T const &) const
static const Packing thePacking
int minPixelCol() const
bool existsAs(std::string const &parameterName, bool trackiness=true) const
checks if a parameter exists as a given type
Definition: ParameterSet.h:186
Local3DPoint theOrigin
Definition: PixelCPEBase.h:66
const SiPixelLorentzAngle * lorentzAngleWidth_
Definition: PixelCPEBase.h:248
const DetContainer & detUnits() const override
Returm a vector of all GeomDet.
LocalVector driftDirection(DetParam &theDetParam, GlobalVector bfield) const
short getTemplateID(const uint32_t &detid) const
LocalPoint position() const
Local x and y position coordinates.
T mag() const
The vector magnitude. Equivalent to sqrt(vec.mag2())
const SiPixelCluster * theCluster
Definition: PixelCPEBase.h:87
bool isBarrel(GeomDetEnumerators::SubDetector m)
Global3DPoint GlobalPoint
Definition: GlobalPoint.h:10
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:47
T y() const
Definition: PV3DBase.h:63
bool isFlipped(DetParam const &theDetParam) const
DetParams m_DetParams
Definition: PixelCPEBase.h:284
T perp2() const
Definition: PV3DBase.h:71
void fillDetParams()
short getGenErrorID(const uint32_t &detid) const
const Plane & surface() const
The nominal surface of the GeomDet.
Definition: GeomDet.h:42
const PixelGeomDetUnit * theDet
Definition: PixelCPEBase.h:60
GeomDetType::SubDetector thePart
Definition: PixelCPEBase.h:65
const RectangularPixelTopology * theRecTopol
Definition: PixelCPEBase.h:63
bool useLAWidthFromDB_
Definition: PixelCPEBase.h:237
float lAWidthBPix_
Definition: PixelCPEBase.h:232
int maxPixelRow() const
bool useLAWidthFromConfig_
Definition: PixelCPEBase.h:236
Measurement2DPoint MeasurementPoint
Measurement points are two-dimensional by default.
bool isItEdgePixelInX(int ixbin) const override
const PixelTopology * theTopol
Definition: PixelCPEBase.h:62
int minPixelRow() const
bool LoadTemplatesFromDB_
Definition: PixelCPEBase.h:257
void computeAnglesFromTrajectory(DetParam const &theDetParam, ClusterParam &theClusterParam, const LocalTrajectoryParameters &ltp) const
unsigned int offsetDU(SubDetector sid) const
T z() const
Definition: PV3DBase.h:64
void computeLorentzShifts(DetParam &) const
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
const SiPixelTemplateDBObject * templateDBobject_
Definition: PixelCPEBase.h:253
void setHasBadPixels(bool flag, QualWordType &qualWord) const
DetId geographicalId() const
The label of this GeomDet.
Definition: GeomDet.h:79
double f[11][100]
const MagneticField * magfield_
Definition: PixelCPEBase.h:243
int index() const
Definition: GeomDet.h:99
void computeAnglesFromDetPosition(DetParam const &theDetParam, ClusterParam &theClusterParam) const
void setProbabilityQ(float prob, QualWordType &qualWord) const
SiPixelRecHitQuality::QualWordType rawQualityWord(ClusterParam &theClusterParam) const
SubDetector tkDetEnum[8]
void setSpansTwoROCs(bool flag, QualWordType &qualWord) const
virtual GlobalVector inTesla(const GlobalPoint &gp) const =0
Field value ad specified global point, in Tesla.
Point3DBase< float, LocalTag > Local3DPoint
Definition: LocalPoint.h:9
Topology::LocalTrackPred loc_trk_pred
Definition: PixelCPEBase.h:101
void setIsOnEdge(bool flag, QualWordType &qualWord) const
const SiPixelLorentzAngle * lorentzAngle_
Definition: PixelCPEBase.h:247
const SiPixelGenErrorDBObject * genErrorDBObject_
Definition: PixelCPEBase.h:250
void setTheClu(DetParam const &, ClusterParam &theClusterParam) const
int maxPixelCol() const
virtual LocalPoint localPosition(const MeasurementPoint &) const =0
bool useLAOffsetFromConfig_
Definition: PixelCPEBase.h:235
const TrackerGeometry & geom_
Definition: PixelCPEBase.h:244
PixelCPEBase(edm::ParameterSet const &conf, const MagneticField *mag, const TrackerGeometry &geom, const TrackerTopology &ttopo, const SiPixelLorentzAngle *lorentzAngle, const SiPixelGenErrorDBObject *genErrorDBObject, const SiPixelTemplateDBObject *templateDBobject, const SiPixelLorentzAngle *lorentzAngleWidth, int flag=0)
Definition: PixelCPEBase.cc:32
float getLorentzAngle(const uint32_t &) const
float y() const
LocalVector driftDirection
Definition: PixelCPEBase.h:73
const RotationType & rotation() const
bool containsBigPixelInY(int iymin, int iymax) const override
bool containsBigPixelInX(int ixmin, int ixmax) const override
void setHasFilledProb(bool flag, QualWordType &qualWord) const
bool isItEdgePixelInY(int iybin) const override
T x() const
Definition: PV3DBase.h:62
const PositionType & position() const
void setQBin(int qbin, QualWordType &qualWord) const
float x() const
bool isTrackerPixel(GeomDetEnumerators::SubDetector m)
float lAWidthFPix_
Definition: PixelCPEBase.h:233
DetParam const & detParam(const GeomDetUnit &det) const