test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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  //cout<<" new errors "<<genErrorDBObject<<" "<<genErrorDBObject_<<endl;
59 
60  //-- Template Calibration Object from DB
61  if(theFlag_!=0) templateDBobject_ = templateDBobject; // flag to check if it is generic or templates
62 
63  // Configurables
64  // For both templates & generic
65 
66  // Read templates and/or generic errors from DB
67  LoadTemplatesFromDB_ = conf.getParameter<bool>("LoadTemplatesFromDB");
68  //cout<<" use generros/templaets "<<LoadTemplatesFromDB_<<endl;
69 
70  //--- Algorithm's verbosity
72  conf.getUntrackedParameter<int>("VerboseLevel",0);
73 
74  //-- Switch on/off E.B
75  alpha2Order = conf.getParameter<bool>("Alpha2Order");
76 
77  //--- A flag that could be used to change the behavior of
78  //--- clusterProbability() in TSiPixelRecHit (the *transient* one).
79  //--- The problem is that the transient hits are made after the CPE runs
80  //--- and they don't get the access to the PSet, so we pass it via the
81  //--- CPE itself...
82  //
84  = (unsigned int) conf.getParameter<int>("ClusterProbComputationFlag");
85 
86  // This LA related parameters are only relevant for the Generic algo
87  // They still have to be used in Base since the LA computation is in Base
88 
89  // Use LA-width from DB.
90  // If both (this and from config) are false LA-width is calcuated from LA-offset
91  useLAWidthFromDB_ = conf.existsAs<bool>("useLAWidthFromDB")?
92  conf.getParameter<bool>("useLAWidthFromDB"):false;
93 
94  // Use Alignment LA-offset in generic
95  //useLAAlignmentOffsets_ = conf.existsAs<bool>("useLAAlignmentOffsets")?
96  //conf.getParameter<bool>("useLAAlignmentOffsets"):false;
97 
98  // Used only for testing
99  lAOffset_ = conf.existsAs<double>("lAOffset")? // fixed LA value
100  conf.getParameter<double>("lAOffset"):0.0;
101  lAWidthBPix_ = conf.existsAs<double>("lAWidthBPix")? // fixed LA width
102  conf.getParameter<double>("lAWidthBPix"):0.0;
103  lAWidthFPix_ = conf.existsAs<double>("lAWidthFPix")? // fixed LA width
104  conf.getParameter<double>("lAWidthFPix"):0.0;
105 
106  // Use LA-offset from config, for testing only
107  if(lAOffset_>0.0) useLAOffsetFromConfig_ = true;
108  // Use LA-width from config, split into fpix & bpix, for testing only
109  if(lAWidthBPix_>0.0 || lAWidthFPix_>0.0) useLAWidthFromConfig_ = true;
110 
111 
112  // For Templates only
113  // Compute the Lorentz shifts for this detector element for templates (from Alignment)
114  DoLorentz_ = conf.existsAs<bool>("DoLorentz")?conf.getParameter<bool>("DoLorentz"):false;
115 
116  LogDebug("PixelCPEBase") <<" LA constants - "
117  <<lAOffset_<<" "<<lAWidthBPix_<<" "<<lAWidthFPix_<<endl; //dk
118 
119  fillDetParams();
120 
121  //cout<<" LA "<<lAOffset_<<" "<<lAWidthBPix_<<" "<<lAWidthFPix_<<endl; //dk
122 }
123 
124 //-----------------------------------------------------------------------------
125 // Fill all variables which are constant for an event (geometry)
126 //-----------------------------------------------------------------------------
128 {
129  //cout<<" in fillDetParams "<<theFlag_<<endl;
130 
131  auto const & dus = geom_.detUnits();
132  unsigned m_detectors = dus.size();
133  for(unsigned int i=1;i<7;++i) {
134  LogDebug("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  //cout<<"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  //cout<<" in PixelCPEBase - in det "<<thePart<<endl; //dk
161 
162  //--- The location in of this DetUnit in a cyllindrical coord system (R,Z)
163  //--- The call goes via BoundSurface, returned by p.theDet->surface(), but
164  //--- position() is implemented in GloballyPositioned<> template
165  //--- ( BoundSurface : Surface : GloballyPositioned<float> )
166  //p.theDetR = p.theDet->surface().position().perp(); //Not used, AH
167  //p.theDetZ = p.theDet->surface().position().z(); //Not used, AH
168  //--- Define parameters for chargewidth calculation
169 
170  //--- bounds() is implemented in BoundSurface itself.
171  p.theThickness = p.theDet->surface().bounds().thickness();
172 
173  // Cache the det id for templates and generic erros
174 
175  if(theFlag_==0) { // for generic
176  if(LoadTemplatesFromDB_ ) // do only if genError requested
177  p.detTemplateId = genErrorDBObject_->getGenErrorID(p.theDet->geographicalId().rawId());
178  } else { // for templates
179  p.detTemplateId = templateDBobject_->getTemplateID(p.theDet->geographicalId());
180  }
181 
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
199  //p.theNumOfCol = p.theRecTopol->ncolumns(); // cols in y //Not used, AH
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
205 
206  LocalVector Bfield = p.theDet->surface().toLocal(magfield_->inTesla(p.theDet->surface().position()));
207  p.bz = Bfield.z();
208 
209 
210  // Compute the Lorentz shifts for this detector element
211  if ( (theFlag_==0) || DoLorentz_ ) { // do always for generic and if(DOLorentz) for templates
212  p.driftDirection = driftDirection(p, Bfield );
214  }
215 
216 
217  LogDebug("PixelCPEBase") << "***** PIXEL LAYOUT *****"
218  << " thePart = " << p.thePart
219  << " theThickness = " << p.theThickness
220  << " thePitchX = " << p.thePitchX
221  << " thePitchY = " << p.thePitchY;
222  // << " theLShiftX = " << p.theLShiftX;
223 
224 
225  }
226 }
227 
228 //-----------------------------------------------------------------------------
229 // One function to cache the variables common for one DetUnit.
230 //-----------------------------------------------------------------------------
231 void
232 PixelCPEBase::setTheClu( DetParam const & theDetParam, ClusterParam & theClusterParam ) const
233 {
234 
235  //--- Geometric Quality Information
236  int minInX,minInY,maxInX,maxInY=0;
237  minInX = theClusterParam.theCluster->minPixelRow();
238  minInY = theClusterParam.theCluster->minPixelCol();
239  maxInX = theClusterParam.theCluster->maxPixelRow();
240  maxInY = theClusterParam.theCluster->maxPixelCol();
241 
242  theClusterParam.isOnEdge_ = theDetParam.theRecTopol->isItEdgePixelInX(minInX) | theDetParam.theRecTopol->isItEdgePixelInX(maxInX) |
243  theDetParam.theRecTopol->isItEdgePixelInY(minInY) | theDetParam.theRecTopol->isItEdgePixelInY(maxInY) ;
244 
245  // FOR NOW UNUSED. KEEP IT IN CASE WE WANT TO USE IT IN THE FUTURE
246  // Bad Pixels have their charge set to 0 in the clusterizer
247  //hasBadPixels_ = false;
248  //for(unsigned int i=0; i<theClusterParam.theCluster->pixelADC().size(); ++i) {
249  //if(theClusterParam.theCluster->pixelADC()[i] == 0) { hasBadPixels_ = true; break;}
250  //}
251 
252  theClusterParam.spansTwoROCs_ = theDetParam.theRecTopol->containsBigPixelInX(minInX,maxInX) |
253  theDetParam.theRecTopol->containsBigPixelInY(minInY,maxInY);
254 
255 }
256 
257 
258 //-----------------------------------------------------------------------------
259 // Compute alpha_ and beta_ from the LocalTrajectoryParameters.
260 // Note: should become const after both localParameters() become const.
261 //-----------------------------------------------------------------------------
262 void PixelCPEBase::
263 computeAnglesFromTrajectory( DetParam const & theDetParam, ClusterParam & theClusterParam,
264  const LocalTrajectoryParameters & ltp) const
265 {
266  //cout<<" in PixelCPEBase:computeAnglesFromTrajectory - "<<endl; //dk
267 
268  //theClusterParam.loc_traj_param = ltp;
269 
270  LocalVector localDir = ltp.momentum();
271 
272 
273  float locx = localDir.x();
274  float locy = localDir.y();
275  float locz = localDir.z();
276 
277  /*
278  // Danek's definition
279  alpha_ = acos(locx/sqrt(locx*locx+locz*locz));
280  if ( isFlipped() ) // &&& check for FPIX !!!
281  alpha_ = PI - alpha_ ;
282  beta_ = acos(locy/sqrt(locy*locy+locz*locz));
283  */
284 
285 
286  theClusterParam.cotalpha = locx/locz;
287  theClusterParam.cotbeta = locy/locz;
288  //theClusterParam.zneg = (locz < 0); // Not used, AH
289 
290 
291  LocalPoint trk_lp = ltp.position();
292  theClusterParam.trk_lp_x = trk_lp.x();
293  theClusterParam.trk_lp_y = trk_lp.y();
294 
295  theClusterParam.with_track_angle = true;
296 
297 
298  // ggiurgiu@jhu.edu 12/09/2010 : needed to correct for bows/kinks
299  AlgebraicVector5 vec_trk_parameters = ltp.mixedFormatVector();
300  theClusterParam.loc_trk_pred = Topology::LocalTrackPred( vec_trk_parameters );
301 
302 }
303 
304 //-----------------------------------------------------------------------------
305 // Estimate theAlpha for barrel, based on the det position.
306 // &&& Needs to be consolidated from the above.
307 //-----------------------------------------------------------------------------
308 //float
309 //PixelCPEBase::estimatedAlphaForBarrel(float centerx) const
310 //{
311 // float tanalpha = theSign * (centerx-theOffsetX) * thePitchX / theDetR;
312 // return PI/2.0 - atan(tanalpha);
313 //}
314 
315 
316 
317 
318 //-----------------------------------------------------------------------------
319 // Compute alpha_ and beta_ from the position of this DetUnit.
320 // &&& DOES NOT WORK FOR NOW. d.k. 6/06
321 // The angles from dets are calculated internaly in the PixelCPEInitial class
322 //-----------------------------------------------------------------------------
323 // G. Giurgiu, 12/01/06 : implement the function
324 void PixelCPEBase::
325 computeAnglesFromDetPosition(DetParam const & theDetParam, ClusterParam & theClusterParam ) const
326 {
327 
328 
329  /*
330  // get cluster center of gravity (of charge)
331  float xcenter = cl.x();
332  float ycenter = cl.y();
333 
334  // get the cluster position in local coordinates (cm)
335 
336  // ggiurgiu@jhu.edu 12/09/2010 : This function is called without track info, therefore there are no track
337  // angles to provide here. Call the default localPosition (without track info)
338  LocalPoint lp = theTopol->localPosition( MeasurementPoint(xcenter, ycenter) );
339 
340 
341  // get the cluster position in global coordinates (cm)
342  GlobalPoint gp = theDet->surface().toGlobal( lp );
343  float gp_mod = sqrt( gp.x()*gp.x() + gp.y()*gp.y() + gp.z()*gp.z() );
344 
345  // normalize
346  float gpx = gp.x()/gp_mod;
347  float gpy = gp.y()/gp_mod;
348  float gpz = gp.z()/gp_mod;
349 
350  // make a global vector out of the global point; this vector will point from the
351  // origin of the detector to the cluster
352  GlobalVector gv(gpx, gpy, gpz);
353 
354  // make local unit vector along local X axis
355  const Local3DVector lvx(1.0, 0.0, 0.0);
356 
357  // get the unit X vector in global coordinates/
358  GlobalVector gvx = theDet->surface().toGlobal( lvx );
359 
360  // make local unit vector along local Y axis
361  const Local3DVector lvy(0.0, 1.0, 0.0);
362 
363  // get the unit Y vector in global coordinates
364  GlobalVector gvy = theDet->surface().toGlobal( lvy );
365 
366  // make local unit vector along local Z axis
367  const Local3DVector lvz(0.0, 0.0, 1.0);
368 
369  // get the unit Z vector in global coordinates
370  GlobalVector gvz = theDet->surface().toGlobal( lvz );
371 
372  // calculate the components of gv (the unit vector pointing to the cluster)
373  // in the local coordinate system given by the basis {gvx, gvy, gvz}
374  // note that both gv and the basis {gvx, gvy, gvz} are given in global coordinates
375  float gv_dot_gvx = gv.x()*gvx.x() + gv.y()*gvx.y() + gv.z()*gvx.z();
376  float gv_dot_gvy = gv.x()*gvy.x() + gv.y()*gvy.y() + gv.z()*gvy.z();
377  float gv_dot_gvz = gv.x()*gvz.x() + gv.y()*gvz.y() + gv.z()*gvz.z();
378  */
379 
380  // all the above is equivalent to
381  LocalPoint lp = theDetParam.theTopol->localPosition( MeasurementPoint(theClusterParam.theCluster->x(), theClusterParam.theCluster->y()) );
382  auto gvx = lp.x()-theDetParam.theOrigin.x();
383  auto gvy = lp.y()-theDetParam.theOrigin.y();
384  auto gvz = -1.f/theDetParam.theOrigin.z();
385  // normalization not required as only ratio used...
386 
387 
388  //theClusterParam.zneg = (gvz < 0); // Not used, AH
389 
390  // calculate angles
391  theClusterParam.cotalpha = gvx*gvz;
392  theClusterParam.cotbeta = gvy*gvz;
393 
394  theClusterParam.with_track_angle = false;
395 
396 
397  /*
398  // used only in dberror param...
399  auto alpha = HALF_PI - std::atan(cotalpha_);
400  auto beta = HALF_PI - std::atan(cotbeta_);
401  if (zneg) { beta -=PI; alpha -=PI;}
402 
403  auto alpha_ = atan2( gv_dot_gvz, gv_dot_gvx );
404  auto beta_ = atan2( gv_dot_gvz, gv_dot_gvy );
405 
406  assert(std::abs(std::round(alpha*10000.f)-std::round(alpha_*10000.f))<2);
407  assert(std::abs(std::round(beta*10000.f)-std::round(beta_*10000.f))<2);
408  */
409 
410 }
411 
412 
413 
414 //-----------------------------------------------------------------------------
415 // The isFlipped() is a silly way to determine which detectors are inverted.
416 // In the barrel for every 2nd ladder the E field direction is in the
417 // global r direction (points outside from the z axis), every other
418 // ladder has the E field inside. Something similar is in the
419 // forward disks (2 sides of the blade). This has to be recognised
420 // because the charge sharing effect is different.
421 //
422 // The isFliped does it by looking and the relation of the local (z always
423 // in the E direction) to global coordinates. There is probably a much
424 // better way.
425 //-----------------------------------------------------------------------------
426 bool PixelCPEBase::isFlipped(DetParam const & theDetParam) const
427 {
428  // Check the relative position of the local +/- z in global coordinates.
429  float tmp1 = theDetParam.theDet->surface().toGlobal(Local3DPoint(0.,0.,0.)).perp2();
430  float tmp2 = theDetParam.theDet->surface().toGlobal(Local3DPoint(0.,0.,1.)).perp2();
431  //cout << " 1: " << tmp1 << " 2: " << tmp2 << endl;
432  if ( tmp2<tmp1 ) return true;
433  else return false;
434 }
435 //------------------------------------------------------------------------
437  auto i = det.index();
438  //cout << "get parameters of detector " << i << endl;
439  assert(i<int(m_DetParams.size()));
440  //if (i>=int(m_DetParams.size())) m_DetParams.resize(i+1); // should never happen!
441  const DetParam & p = m_DetParams[i];
442  return p;
443 }
444 
445 //-----------------------------------------------------------------------------
446 // Drift direction.
447 // Works OK for barrel and forward.
448 // The formulas used for dir_x,y,z have to be exactly the same as the ones
449 // used in the digitizer (SiPixelDigitizerAlgorithm.cc).
450 //
451 //-----------------------------------------------------------------------------
453 PixelCPEBase::driftDirection(DetParam & theDetParam, GlobalVector bfield ) const {
454 
455  Frame detFrame(theDetParam.theDet->surface().position(), theDetParam.theDet->surface().rotation());
456  LocalVector Bfield = detFrame.toLocal(bfield);
457  return driftDirection(theDetParam,Bfield);
458 
459 }
460 
462 PixelCPEBase::driftDirection(DetParam & theDetParam, LocalVector Bfield ) const {
463  const bool LocalPrint = false;
464 
465  // Use LA from DB or from config
466  float langle = 0.;
467  if( !useLAOffsetFromConfig_ ) { // get it from DB
468  if(lorentzAngle_ != NULL) { // a real LA object
469  langle = lorentzAngle_->getLorentzAngle(theDetParam.theDet->geographicalId().rawId());
470  //cout<<" la "<<langle<<" "<< theDetParam.theDet->geographicalId().rawId() <<endl;
471  } else { // no LA, unused
472  //cout<<" LA object is NULL, assume LA = 0"<<endl; //dk
473  langle = 0; // set to a fake value
474  }
475  if(LocalPrint) cout<<" Will use LA Offset from DB "<<langle<<endl;
476  } else { // from config file
477  langle = lAOffset_;
478  if(LocalPrint) cout<<" Will use LA Offset from config "<<langle<<endl;
479  }
480 
481  // Now do the LA width stuff
482  theDetParam.widthLAFractionX = 1.; // predefine to 1 (default) if things fail
483  theDetParam.widthLAFractionY = 1.;
484 
485  // Compute the charge width, generic only
486  if(theFlag_==0) {
487 
489  // take it from a seperate, special LA DB object (forWidth)
490 
491  auto langleWidth = lorentzAngleWidth_->getLorentzAngle(theDetParam.theDet->geographicalId().rawId());
492  if(langleWidth!=0.0) theDetParam.widthLAFractionX = std::abs(langleWidth/langle);
493  // leave the widthLAFractionY=1.
494  //cout<<" LAWidth lorentz width "<<theDetParam.widthLAFractionX<<" "<<theDetParam.widthLAFractionY<<endl;
495 
496  } else if(useLAWidthFromConfig_) { // get from config
497 
498  double lAWidth=0;
499  if( GeomDetEnumerators::isTrackerPixel(theDetParam.thePart) && GeomDetEnumerators::isBarrel(theDetParam.thePart) ) lAWidth = lAWidthBPix_; // barrel
500  else lAWidth = lAWidthFPix_;
501 
502  if(langle!=0.0) theDetParam.widthLAFractionX = std::abs(lAWidth/langle);
503  // fix the FractionY at 1
504 
505  //cout<<" Lorentz width from config "<<theDetParam.widthLAFractionX<<" "<<theDetParam.widthLAFractionY<<endl;
506 
507  } else { // get if from the offset LA (old method used until 2013)
508  // do nothing
509  //cout<<" Old default LA width method "<<theDetParam.widthLAFractionX<<" "<<theDetParam.widthLAFractionY<<endl;
510 
511  }
512 
513  //cout<<" Final LA fraction "<<theDetParam.widthLAFractionX<<" "<<theDetParam.widthLAFractionY<<endl;
514 
515  } // if flag
516 
517 
518  if(LocalPrint) cout<<" in PixelCPEBase:driftDirection - "<<langle<<" "<<Bfield<<endl; //dk
519 
520  float alpha2 = alpha2Order ? langle*langle : 0; //
521 
522  // **********************************************************************
523  // Our convention is the following:
524  // +x is defined by the direction of the Lorentz drift!
525  // +z is defined by the direction of E field (so electrons always go into -z!)
526  // +y is defined by +x and +z, and it turns out to be always opposite to the +B field.
527  // **********************************************************************
528 
529  float dir_x = -( langle * Bfield.y() + alpha2* Bfield.z()* Bfield.x() );
530  float dir_y = ( langle * Bfield.x() - alpha2* Bfield.z()* Bfield.y() );
531  float dir_z = -( 1.f + alpha2* Bfield.z()*Bfield.z() );
532  auto scale = 1.f/std::abs( dir_z ); // same as 1 + alpha2*Bfield.z()*Bfield.z()
533  LocalVector dd(dir_x*scale, dir_y*scale, -1.f ); // last is -1 !
534 
535  LogDebug("PixelCPEBase") << " The drift direction in local coordinate is " << dd ;
536 
537  return dd;
538 }
539 
540 //-----------------------------------------------------------------------------
541 // One-shot computation of the driftDirection and both lorentz shifts
542 //-----------------------------------------------------------------------------
543 void
545 
546  //cout<<" in PixelCPEBase:computeLorentzShifts - "<<driftDirection_<<endl; //dk
547 
548  // Max shift (at the other side of the sensor) in cm
549  theDetParam.lorentzShiftInCmX = theDetParam.driftDirection.x()/theDetParam.driftDirection.z() * theDetParam.theThickness; //
550  theDetParam.lorentzShiftInCmY = theDetParam.driftDirection.y()/theDetParam.driftDirection.z() * theDetParam.theThickness; //
551 
552  //cout<<" in PixelCPEBase:computeLorentzShifts - "
553  //<<lorentzShiftInCmX_<<" "
554  //<<lorentzShiftInCmY_<<" "
555  //<<endl; //dk
556 
557  LogDebug("PixelCPEBase") << " The drift direction in local coordinate is "
558  << theDetParam.driftDirection ;
559 }
560 
561 //-----------------------------------------------------------------------------
566 //-----------------------------------------------------------------------------
569 {
571  float probabilityXY;
572  if ( theClusterParam.probabilityX_ !=0 && theClusterParam.probabilityY_ !=0 )
573  probabilityXY = theClusterParam.probabilityX_ * theClusterParam.probabilityY_ * (1.f - std::log(theClusterParam.probabilityX_ * theClusterParam.probabilityY_) ) ;
574  else
575  probabilityXY = 0;
577  qualWord );
578 
580  qualWord );
581 
582  SiPixelRecHitQuality::thePacking.setQBin ( (int)theClusterParam.qBin_,
583  qualWord );
584 
586  qualWord );
587 
589  qualWord );
590 
592  qualWord );
593 
595  qualWord );
596 
597  return qualWord;
598 }
#define LogDebug(id)
GlobalPoint toGlobal(const Point2DBase< Scalar, LocalTag > lp) const
Definition: Surface.h:106
T getParameter(std::string const &) const
bool containsBigPixelInY(int iymin, int iymax) const
void setProbabilityXY(float prob, QualWordType &qualWord) const
T getUntrackedParameter(std::string const &, T const &) const
int i
Definition: DBlmapReader.cc:9
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
bool isItEdgePixelInY(int iybin) const
virtual LocalPoint localPosition(const MeasurementPoint &) const =0
const SiPixelLorentzAngle * lorentzAngleWidth_
Definition: PixelCPEBase.h:246
LocalVector driftDirection(DetParam &theDetParam, GlobalVector bfield) const
short getTemplateID(const uint32_t &detid) const
LocalPoint position() const
Local x and y position coordinates.
virtual GlobalVector inTesla(const GlobalPoint &gp) const =0
Field value ad specified global point, in Tesla.
T mag() const
The vector magnitude. Equivalent to sqrt(vec.mag2())
const SiPixelCluster * theCluster
Definition: PixelCPEBase.h:90
bool isBarrel(GeomDetEnumerators::SubDetector m)
assert(m_qm.get())
bool isItEdgePixelInX(int ixbin) const
Global3DPoint GlobalPoint
Definition: GlobalPoint.h:10
T y() const
Definition: PV3DBase.h:63
bool isFlipped(DetParam const &theDetParam) const
#define NULL
Definition: scimark2.h:8
DetParams m_DetParams
Definition: PixelCPEBase.h:282
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:235
float lAWidthBPix_
Definition: PixelCPEBase.h:230
int maxPixelRow() const
uint32_t rawId() const
get the raw id
Definition: DetId.h:43
bool useLAWidthFromConfig_
Definition: PixelCPEBase.h:234
Measurement2DPoint MeasurementPoint
Measurement points are two-dimensional by default.
const PixelTopology * theTopol
Definition: PixelCPEBase.h:62
int minPixelRow() const
bool LoadTemplatesFromDB_
Definition: PixelCPEBase.h:255
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:251
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:241
LocalVector momentum() const
Momentum vector in the local frame.
int index() const
Definition: GeomDet.h:99
void computeAnglesFromDetPosition(DetParam const &theDetParam, ClusterParam &theClusterParam) const
void setProbabilityQ(float prob, QualWordType &qualWord) const
bool containsBigPixelInX(int ixmin, int ixmax) const
SiPixelRecHitQuality::QualWordType rawQualityWord(ClusterParam &theClusterParam) const
SubDetector tkDetEnum[8]
void setSpansTwoROCs(bool flag, QualWordType &qualWord) const
Point3DBase< float, LocalTag > Local3DPoint
Definition: LocalPoint.h:9
Topology::LocalTrackPred loc_trk_pred
Definition: PixelCPEBase.h:103
void setIsOnEdge(bool flag, QualWordType &qualWord) const
ROOT::Math::SVector< double, 5 > AlgebraicVector5
const SiPixelLorentzAngle * lorentzAngle_
Definition: PixelCPEBase.h:245
const SiPixelGenErrorDBObject * genErrorDBObject_
Definition: PixelCPEBase.h:248
void setTheClu(DetParam const &, ClusterParam &theClusterParam) const
int maxPixelCol() const
bool isTrackerPixel(const GeomDetEnumerators::SubDetector m)
AlgebraicVector5 mixedFormatVector() const
bool useLAOffsetFromConfig_
Definition: PixelCPEBase.h:233
const TrackerGeometry & geom_
Definition: PixelCPEBase.h:242
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:77
const RotationType & rotation() const
tuple cout
Definition: gather_cfg.py:145
volatile std::atomic< bool > shutdown_flag false
void setHasFilledProb(bool flag, QualWordType &qualWord) const
T x() const
Definition: PV3DBase.h:62
const PositionType & position() const
void setQBin(int qbin, QualWordType &qualWord) const
float x() const
float lAWidthFPix_
Definition: PixelCPEBase.h:231
const DetUnitContainer & detUnits() const
Returm a vector of all GeomDetUnit.
DetParam const & detParam(const GeomDetUnit &det) const