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