CMS 3D CMS Logo

List of all members | Classes | Public Member Functions | Private Member Functions | Private Attributes
PixelCPEClusterRepair Class Reference

#include <PixelCPEClusterRepair.h>

Inheritance diagram for PixelCPEClusterRepair:
PixelCPEBase PixelClusterParameterEstimator

Classes

struct  ClusterParamTemplate
 

Public Member Functions

 PixelCPEClusterRepair (edm::ParameterSet const &conf, const MagneticField *, const TrackerGeometry &, const TrackerTopology &, const SiPixelLorentzAngle *, const SiPixelTemplateDBObject *, const SiPixel2DTemplateDBObject *)
 
 ~PixelCPEClusterRepair () override
 
- Public Member Functions inherited from PixelCPEBase
ReturnType getParameters (const SiPixelCluster &cl, const GeomDetUnit &det) const override
 
ReturnType getParameters (const SiPixelCluster &cl, const GeomDetUnit &det, const LocalTrajectoryParameters &ltp) const override
 
 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)
 
- Public Member Functions inherited from PixelClusterParameterEstimator
unsigned int clusterProbComputationFlag () const
 
virtual ReturnType getParameters (const SiPixelCluster &cl, const GeomDetUnit &det, const TrajectoryStateOnSurface &tsos) const
 
virtual VLocalValues localParametersV (const SiPixelCluster &cluster, const GeomDetUnit &gd) const
 
virtual VLocalValues localParametersV (const SiPixelCluster &cluster, const GeomDetUnit &gd, TrajectoryStateOnSurface &tsos) const
 
 PixelClusterParameterEstimator ()
 
virtual ~PixelClusterParameterEstimator ()
 

Private Member Functions

void callTempReco2D (DetParam const &theDetParam, ClusterParamTemplate &theClusterParam, SiPixelTemplateReco::ClusMatrix &clusterPayload, int ID, LocalPoint &lp) const
 
void callTempReco3D (DetParam const &theDetParam, ClusterParamTemplate &theClusterParam, SiPixelTemplateReco2D::ClusMatrix &clusterPayload, int ID, LocalPoint &lp) const
 
ClusterParamcreateClusterParam (const SiPixelCluster &cl) const override
 
LocalError localError (DetParam const &theDetParam, ClusterParam &theClusterParam) const override
 
LocalPoint localPosition (DetParam const &theDetParam, ClusterParam &theClusterParam) const override
 

Private Attributes

int barrelTemplateID_
 
int forwardTemplateID_
 
int maxSizeMismatchInY_
 
float minProbY_
 
int speed_
 
std::string templateDir_
 
std::vector< SiPixelTemplateStore2DthePixelTemp2D_
 
std::vector< SiPixelTemplateStorethePixelTemp_
 
bool UseClusterSplitter_
 

Additional Inherited Members

- Public Types inherited from PixelClusterParameterEstimator
typedef std::pair< LocalPoint, LocalErrorLocalValues
 
using ReturnType = std::tuple< LocalPoint, LocalError, SiPixelRecHitQuality::QualWordType >
 
typedef std::vector< LocalValuesVLocalValues
 
- Protected Types inherited from PixelCPEBase
using DetParams = std::vector< DetParam >
 
typedef GloballyPositioned< double > Frame
 
- Protected Member Functions inherited from PixelCPEBase
void computeAnglesFromDetPosition (DetParam const &theDetParam, ClusterParam &theClusterParam) const
 
void computeAnglesFromTrajectory (DetParam const &theDetParam, ClusterParam &theClusterParam, const LocalTrajectoryParameters &ltp) const
 
void computeLorentzShifts (DetParam &) const
 
DetParam const & detParam (const GeomDetUnit &det) const
 
LocalVector driftDirection (DetParam &theDetParam, GlobalVector bfield) const
 
LocalVector driftDirection (DetParam &theDetParam, LocalVector bfield) const
 
bool isFlipped (DetParam const &theDetParam) const
 
void setTheClu (DetParam const &, ClusterParam &theClusterParam) const
 
- Protected Attributes inherited from PixelCPEBase
bool alpha2Order
 
bool DoLorentz_
 
const SiPixelGenErrorDBObjectgenErrorDBObject_
 
const TrackerGeometrygeom_
 
float lAOffset_
 
float lAWidthBPix_
 
float lAWidthFPix_
 
bool LoadTemplatesFromDB_
 
const SiPixelLorentzAnglelorentzAngle_
 
const SiPixelLorentzAnglelorentzAngleWidth_
 
DetParams m_DetParams =DetParams(1440)
 
const MagneticFieldmagfield_
 
const SiPixelTemplateDBObjecttemplateDBobject_
 
int theFlag_
 
int theVerboseLevel
 
const TrackerTopologyttopo_
 
bool useLAOffsetFromConfig_
 
bool useLAWidthFromConfig_
 
bool useLAWidthFromDB_
 
- Protected Attributes inherited from PixelClusterParameterEstimator
unsigned int clusterProbComputationFlag_
 

Detailed Description

Definition at line 35 of file PixelCPEClusterRepair.h.

Constructor & Destructor Documentation

PixelCPEClusterRepair::PixelCPEClusterRepair ( edm::ParameterSet const &  conf,
const MagneticField mag,
const TrackerGeometry geom,
const TrackerTopology ttopo,
const SiPixelLorentzAngle lorentzAngle,
const SiPixelTemplateDBObject templateDBobject,
const SiPixel2DTemplateDBObject templateDBobject2D 
)

Definition at line 39 of file PixelCPEClusterRepair.cc.

References barrelTemplateID_, Exception, edm::ParameterSet::exists(), forwardTemplateID_, edm::ParameterSet::getParameter(), PixelCPEBase::LoadTemplatesFromDB_, LogDebug, maxSizeMismatchInY_, minProbY_, SiPixelTemplate2D::pushfile(), SiPixelTemplate::pushfile(), speed_, PixelCPEBase::templateDBobject_, templateDir_, thePixelTemp2D_, thePixelTemp_, and UseClusterSplitter_.

46 : PixelCPEBase(conf, mag, geom, ttopo, lorentzAngle, nullptr, templateDBobject, nullptr,1)
47 {
48  LogDebug("PixelCPEClusterRepair::(constructor)") << endl;
49 
50  //--- Parameter to decide between DB or text file template access
52  {
53  // Initialize template store to the selected ID [Morris, 6/25/08]
55  throw cms::Exception("PixelCPEClusterRepair")
56  << "\nERROR: Templates not filled correctly. Check the sqlite file. Using SiPixelTemplateDBObject version "
57  << (*templateDBobject_).version() << "\n\n";
58 
59  // Initialize template store to the selected ID [Morris, 6/25/08]
60  if ( !SiPixelTemplate2D::pushfile( *templateDBobject2D , thePixelTemp2D_) )
61  throw cms::Exception("PixelCPEClusterRepair")
62  << "\nERROR: Templates not filled correctly. Check the sqlite file. Using SiPixelTemplateDBObject version "
63  << (*templateDBobject_).version() << "\n\n";
64  }
65  else
66  {
67  LogDebug("PixelCPEClusterRepair") << "Loading templates for barrel and forward from ASCII files." << endl;
68  //--- (Archaic) Get configurable template IDs. This code executes only if we loading pixels from ASCII
69  // files, and then they are mandatory.
70  barrelTemplateID_ = conf.getParameter<int>( "barrelTemplateID" );
71  forwardTemplateID_ = conf.getParameter<int>( "forwardTemplateID" );
72  templateDir_ = conf.getParameter<int>( "directoryWithTemplates" );
73 
75  throw cms::Exception("PixelCPEClusterRepair")
76  << "\nERROR: Template ID " << barrelTemplateID_ << " not loaded correctly from text file. Reconstruction will fail.\n\n";
77 
78  if ( !SiPixelTemplate::pushfile( forwardTemplateID_ , thePixelTemp_ , templateDir_ ) )
79  throw cms::Exception("PixelCPEClusterRepair")
80  << "\nERROR: Template ID " << forwardTemplateID_ << " not loaded correctly from text file. Reconstruction will fail.\n\n";
81  }
82 
83  speed_ = conf.getParameter<int>( "speed");
84  LogDebug("PixelCPEClusterRepair::PixelCPEClusterRepair:") <<
85  "Template speed = " << speed_ << "\n";
86 
87  UseClusterSplitter_ = conf.getParameter<bool>("UseClusterSplitter");
88 
89 
90  //--- Configure 3D reco.
91  if ( conf.exists("MinProbY") )
92  minProbY_ = conf.getParameter<double>("MinProbY");
93  else
94  minProbY_ = 0.001; // probabilityY < 0.001
95 
96  if ( conf.exists("MaxSizeMismatchInY") )
97  maxSizeMismatchInY_ = conf.getParameter<int>("MaxSizeMismatchInY");
98  else
99  maxSizeMismatchInY_ = 1; // ( templ.clsleny() - nypix > 1)
100 
101 }
#define LogDebug(id)
std::vector< SiPixelTemplateStore > thePixelTemp_
bool LoadTemplatesFromDB_
Definition: PixelCPEBase.h:257
const SiPixelTemplateDBObject * templateDBobject_
Definition: PixelCPEBase.h:253
std::vector< SiPixelTemplateStore2D > thePixelTemp2D_
static bool pushfile(int filenum, std::vector< SiPixelTemplateStore2D > &pixelTemp, std::string dir="")
static bool pushfile(int filenum, std::vector< SiPixelTemplateStore > &pixelTemp, std::string dir="CalibTracker/SiPixelESProducers/data/")
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
PixelCPEClusterRepair::~PixelCPEClusterRepair ( )
override

Definition at line 108 of file PixelCPEClusterRepair.cc.

References thePixelTemp2D_, thePixelTemp_, and x.

109 {
110  for (auto x : thePixelTemp_) x.destroy();
111  for (auto x : thePixelTemp2D_) x.destroy();
112 }
std::vector< SiPixelTemplateStore > thePixelTemp_
std::vector< SiPixelTemplateStore2D > thePixelTemp2D_

Member Function Documentation

void PixelCPEClusterRepair::callTempReco2D ( DetParam const &  theDetParam,
ClusterParamTemplate theClusterParam,
SiPixelTemplateReco::ClusMatrix clusterPayload,
int  ID,
LocalPoint lp 
) const
private

Definition at line 305 of file PixelCPEClusterRepair.cc.

References PixelCPEBase::DetParam::bx, PixelCPEBase::DetParam::bz, SiPixelTemplate::clsleny(), PixelCPEBase::ClusterParam::cotalpha, PixelCPEBase::ClusterParam::cotbeta, PixelCPEBase::ClusterParam::hasFilledProb_, PixelCPEClusterRepair::ClusterParamTemplate::ierr, GeomDetEnumerators::isEndcap(), PixelCPEBase::ClusterParam::loc_trk_pred, PixelTopology::localX(), PixelTopology::localY(), LogDebug, minProbY_, SiPixelTemplateReco::PixelTempReco2D(), PixelCPEBase::ClusterParam::probabilityQ_, PixelCPEBase::ClusterParam::probabilityX_, PixelCPEBase::ClusterParam::probabilityY_, PixelCPEBase::ClusterParam::qBin_, PixelCPEClusterRepair::ClusterParamTemplate::recommended3D_, speed_, PixelCPEClusterRepair::ClusterParamTemplate::templSigmaX_, PixelCPEClusterRepair::ClusterParamTemplate::templSigmaY_, PixelCPEClusterRepair::ClusterParamTemplate::templXrec_, PixelCPEClusterRepair::ClusterParamTemplate::templYrec_, PixelCPEBase::ClusterParam::theCluster, PixelCPEBase::DetParam::thePart, thePixelTemp_, PixelCPEBase::DetParam::theTopol, UNLIKELY, PixelCPEBase::ClusterParam::with_track_angle, PV3DBase< T, PVType, FrameType >::x(), SiPixelCluster::x(), PV3DBase< T, PVType, FrameType >::y(), and SiPixelCluster::y().

Referenced by localPosition().

309 {
311 
312  // Output:
313  float nonsense = -99999.9f; // nonsense init value
314  theClusterParam.templXrec_ = theClusterParam.templYrec_ = theClusterParam.templSigmaX_ = theClusterParam.templSigmaY_ = nonsense;
315  // If the template recontruction fails, we want to return 1.0 for now
316  theClusterParam.probabilityX_ = theClusterParam.probabilityY_ = theClusterParam.probabilityQ_ = 1.f;
317  theClusterParam.qBin_ = 0;
318  // We have a boolean denoting whether the reco failed or not
319  theClusterParam.hasFilledProb_ = false;
320 
321  // ******************************************************************
322  //--- Call normal TemplateReco
323  //
324  float locBz = theDetParam.bz;
325  float locBx = theDetParam.bx;
326  //
327  const bool deadpix = false;
328  std::vector<std::pair<int, int> > zeropix;
329  int nypix =0, nxpix = 0;
330  //
331  theClusterParam.ierr =
332  PixelTempReco2D( ID, theClusterParam.cotalpha, theClusterParam.cotbeta,
333  locBz, locBx,
334  clusterPayload,
335  templ,
336  theClusterParam.templYrec_, theClusterParam.templSigmaY_, theClusterParam.probabilityY_,
337  theClusterParam.templXrec_, theClusterParam.templSigmaX_, theClusterParam.probabilityX_,
338  theClusterParam.qBin_,
339  speed_, deadpix, zeropix,
340  theClusterParam.probabilityQ_, nypix, nxpix
341  );
342  // ******************************************************************
343 
344  //--- Check exit status
345  if UNLIKELY( theClusterParam.ierr != 0 )
346  {
347  LogDebug("PixelCPEClusterRepair::localPosition") <<
348  "reconstruction failed with error " << theClusterParam.ierr << "\n";
349 
350  theClusterParam.probabilityX_ = theClusterParam.probabilityY_ = theClusterParam.probabilityQ_ = 0.f;
351  theClusterParam.qBin_ = 0;
352 
353  // Gavril: what do we do in this case ? For now, just return the cluster center of gravity in microns
354  // In the x case, apply a rough Lorentz drift average correction
355  // To do: call PixelCPEGeneric whenever PixelTempReco2D fails
356  float lorentz_drift = -999.9;
357  if ( ! GeomDetEnumerators::isEndcap(theDetParam.thePart) )
358  lorentz_drift = 60.0f; // in microns
359  else
360  lorentz_drift = 10.0f; // in microns
361  // GG: trk angles needed to correct for bows/kinks
362  if ( theClusterParam.with_track_angle )
363  {
364  theClusterParam.templXrec_ = theDetParam.theTopol->localX( theClusterParam.theCluster->x(), theClusterParam.loc_trk_pred ) - lorentz_drift * micronsToCm; // rough Lorentz drift correction
365  theClusterParam.templYrec_ = theDetParam.theTopol->localY( theClusterParam.theCluster->y(), theClusterParam.loc_trk_pred );
366  }
367  else
368  {
369  edm::LogError("PixelCPEClusterRepair")
370  << "@SUB = PixelCPEClusterRepair::localPosition"
371  << "Should never be here. PixelCPEClusterRepair should always be called with track angles. This is a bad error !!! ";
372 
373  theClusterParam.templXrec_ = theDetParam.theTopol->localX( theClusterParam.theCluster->x() ) - lorentz_drift * micronsToCm; // rough Lorentz drift correction
374  theClusterParam.templYrec_ = theDetParam.theTopol->localY( theClusterParam.theCluster->y() );
375  }
376  }
377  else
378  {
379  //--- Template Reco succeeded. The probabilities are filled.
380  theClusterParam.hasFilledProb_ = true;
381 
382  //--- templ.clsleny() is the expected length of the cluster along y axis.
383  if ( (theClusterParam.probabilityY_ < minProbY_ ) && (templ.clsleny() - nypix > 1) ) {
384  theClusterParam.recommended3D_ = true;
385  }
386 
387  //--- Go from microns to centimeters
388  theClusterParam.templXrec_ *= micronsToCm;
389  theClusterParam.templYrec_ *= micronsToCm;
390 
391  //--- Go back to the module coordinate system
392  theClusterParam.templXrec_ += lp.x();
393  theClusterParam.templYrec_ += lp.y();
394 
395  }
396  return;
397 }
#define LogDebug(id)
std::vector< SiPixelTemplateStore > thePixelTemp_
uint32_t ID
Definition: Definitions.h:26
T y() const
Definition: PV3DBase.h:63
int PixelTempReco2D(int id, float cotalpha, float cotbeta, float locBz, float locBx, ClusMatrix &cluster, SiPixelTemplate &templ, float &yrec, float &sigmay, float &proby, float &xrec, float &sigmax, float &probx, int &qbin, int speed, bool deadpix, std::vector< std::pair< int, int > > &zeropix, float &probQ, int &nypix, int &nxpix)
bool isEndcap(GeomDetEnumerators::SubDetector m)
T x() const
Definition: PV3DBase.h:62
#define UNLIKELY(x)
void PixelCPEClusterRepair::callTempReco3D ( DetParam const &  theDetParam,
ClusterParamTemplate theClusterParam,
SiPixelTemplateReco2D::ClusMatrix clusterPayload,
int  ID,
LocalPoint lp 
) const
private

Definition at line 406 of file PixelCPEClusterRepair.cc.

References PixelCPEBase::DetParam::bx, PixelCPEBase::DetParam::bz, PixelCPEBase::ClusterParam::cotalpha, PixelCPEBase::ClusterParam::cotbeta, PixelCPEBase::ClusterParam::edgeTypeX_, PixelCPEBase::ClusterParam::edgeTypeY_, PixelCPEBase::ClusterParam::hasFilledProb_, PixelCPEClusterRepair::ClusterParamTemplate::ierr2, GeomDetEnumerators::isEndcap(), PixelCPEBase::ClusterParam::loc_trk_pred, PixelTopology::localX(), PixelTopology::localY(), LogDebug, SiPixelTemplateReco2D::ClusMatrix::mrow, SiPixelTemplateReco2D::PixelTempReco3D(), PixelCPEBase::ClusterParam::probabilityQ_, PixelCPEBase::ClusterParam::probabilityX_, PixelCPEBase::ClusterParam::probabilityY_, PixelCPEBase::ClusterParam::qBin_, PixelCPEClusterRepair::ClusterParamTemplate::recommended3D_, PixelCPEClusterRepair::ClusterParamTemplate::templProbXY_, PixelCPEClusterRepair::ClusterParamTemplate::templSigmaX_, PixelCPEClusterRepair::ClusterParamTemplate::templSigmaY_, PixelCPEClusterRepair::ClusterParamTemplate::templXrec_, PixelCPEClusterRepair::ClusterParamTemplate::templYrec_, PixelCPEBase::ClusterParam::theCluster, PixelCPEBase::DetParam::thePart, thePixelTemp2D_, PixelCPEBase::DetParam::theTopol, UNLIKELY, PixelCPEBase::ClusterParam::with_track_angle, PV3DBase< T, PVType, FrameType >::x(), SiPixelCluster::x(), PV3DBase< T, PVType, FrameType >::y(), and SiPixelCluster::y().

Referenced by localPosition().

410 {
412 
413  // Output:
414  float nonsense = -99999.9f; // nonsense init value
415  theClusterParam.templXrec_ = theClusterParam.templYrec_ = theClusterParam.templSigmaX_ = theClusterParam.templSigmaY_ = nonsense;
416  // If the template recontruction fails, we want to return 1.0 for now
417  theClusterParam.probabilityX_ = theClusterParam.probabilityY_ = theClusterParam.probabilityQ_ = 1.f;
418  theClusterParam.qBin_ = 0;
419  // We have a boolean denoting whether the reco failed or not
420  theClusterParam.hasFilledProb_ = false;
421 
422  // ******************************************************************
423  //--- Call 2D TemplateReco
424  //
425  float locBz = theDetParam.bz;
426  float locBx = theDetParam.bx;
427 
428  //--- Input:
429  // edgeflagy - (input) flag to indicate the present of edges in y:
430  // 0=none (or interior gap),1=edge at small y, 2=edge at large y, 3=edge at either end
431  //
432  // edgeflagx - (input) flag to indicate the present of edges in x:
433  // 0=none, 1=edge at small x, 2=edge at large x
434  //
435  // These two variables are calculated in setTheClu() and stored in edgeTypeX_ and edgeTypeY_
436  //
437  //--- Output:
438  // deltay - (output) template y-length - cluster length [when > 0, possibly missing end]
439  // npixels - ??? &&& Ask Morris
440 
441  float edgeTypeY = theClusterParam.edgeTypeY_ ; // the default, from PixelCPEBase
442  if ( theClusterParam.recommended3D_ ) {
443  // Cluster is not on edge, but instead the normal TemplateReco discovered that it is
444  // shorter than expected. So let the 3D algorithm try extending it on both sides, in case
445  // there is a dead double-column on either side. (We don't know which.)
446  edgeTypeY = 3;
447  }
448 
449  float deltay = 0; // return param
450  int npixels = 0; // return param
451 
452  if(clusterPayload.mrow > 4){
453  // The cluster is too big, the 2D reco will perform horribly.
454  // Better to return immediately in error
455  theClusterParam.ierr2 = 8;
456 
457  }
458  else{
459  theClusterParam.ierr2 =
460  PixelTempReco3D( ID, theClusterParam.cotalpha, theClusterParam.cotbeta,
461  locBz, locBx,
462  edgeTypeY , theClusterParam.edgeTypeX_ ,
463  clusterPayload,
464  templ2d,
465  theClusterParam.templYrec_, theClusterParam.templSigmaY_,
466  theClusterParam.templXrec_, theClusterParam.templSigmaX_,
467  theClusterParam.templProbXY_,
468  theClusterParam.probabilityQ_,
469  theClusterParam.qBin_,
470  deltay, npixels
471  );
472  }
473  // ******************************************************************
474 
475  //--- Check exit status
476  if UNLIKELY( theClusterParam.ierr2 != 0 )
477  {
478  LogDebug("PixelCPEClusterRepair::localPosition") <<
479  "3D reconstruction failed with error " << theClusterParam.ierr2 << "\n";
480 
481  theClusterParam.probabilityX_ = theClusterParam.probabilityY_ = theClusterParam.probabilityQ_ = 0.f;
482  theClusterParam.qBin_ = 0;
483  // GG: what do we do in this case? For now, just return the cluster center of gravity in microns
484  // In the x case, apply a rough Lorentz drift average correction
485  float lorentz_drift = -999.9;
486  if ( ! GeomDetEnumerators::isEndcap(theDetParam.thePart) )
487  lorentz_drift = 60.0f; // in microns // &&& replace with a constant (globally)
488  else
489  lorentz_drift = 10.0f; // in microns
490  // GG: trk angles needed to correct for bows/kinks
491  if ( theClusterParam.with_track_angle )
492  {
493  theClusterParam.templXrec_ = theDetParam.theTopol->localX( theClusterParam.theCluster->x(), theClusterParam.loc_trk_pred ) - lorentz_drift * micronsToCm; // rough Lorentz drift correction
494  theClusterParam.templYrec_ = theDetParam.theTopol->localY( theClusterParam.theCluster->y(), theClusterParam.loc_trk_pred );
495  }
496  else
497  {
498  edm::LogError("PixelCPEClusterRepair")
499  << "@SUB = PixelCPEClusterRepair::localPosition"
500  << "Should never be here. PixelCPEClusterRepair should always be called with track angles. This is a bad error !!! ";
501 
502  theClusterParam.templXrec_ = theDetParam.theTopol->localX( theClusterParam.theCluster->x() ) - lorentz_drift * micronsToCm; // rough Lorentz drift correction
503  theClusterParam.templYrec_ = theDetParam.theTopol->localY( theClusterParam.theCluster->y() );
504  }
505  }
506  else
507  {
508  //--- Template Reco succeeded.
509  theClusterParam.hasFilledProb_ = true;
510 
511  //--- Go from microns to centimeters
512  theClusterParam.templXrec_ *= micronsToCm;
513  theClusterParam.templYrec_ *= micronsToCm;
514 
515  //--- Go back to the module coordinate system
516  theClusterParam.templXrec_ += lp.x();
517  theClusterParam.templYrec_ += lp.y();
518  }
519  return;
520 }
#define LogDebug(id)
uint32_t ID
Definition: Definitions.h:26
T y() const
Definition: PV3DBase.h:63
int PixelTempReco3D(int id, float cotalpha, float cotbeta, float locBz, float locBx, int edgeflagy, int edgeflagx, ClusMatrix &cluster, SiPixelTemplate2D &templ, float &yrec, float &sigmay, float &xrec, float &sigmax, float &probxy, float &probQ, int &qbin, float &deltay, int &npixel)
std::vector< SiPixelTemplateStore2D > thePixelTemp2D_
bool isEndcap(GeomDetEnumerators::SubDetector m)
T x() const
Definition: PV3DBase.h:62
#define UNLIKELY(x)
PixelCPEBase::ClusterParam * PixelCPEClusterRepair::createClusterParam ( const SiPixelCluster cl) const
overrideprivatevirtual

Implements PixelCPEBase.

Definition at line 114 of file PixelCPEClusterRepair.cc.

115 {
116  return new ClusterParamTemplate(cl);
117 }
LocalError PixelCPEClusterRepair::localError ( DetParam const &  theDetParam,
ClusterParam theClusterParam 
) const
overrideprivatevirtual

Implements PixelCPEBase.

Definition at line 529 of file PixelCPEClusterRepair.cc.

References PixelCPEBase::ClusterParam::edgeTypeX_, PixelCPEBase::ClusterParam::edgeTypeY_, Exception, f, PixelCPEClusterRepair::ClusterParamTemplate::ierr, PixelCPEClusterRepair::ClusterParamTemplate::ierr2, GeomDetEnumerators::isBarrel(), GeomDetEnumerators::isTrackerPixel(), LogDebug, SiPixelCluster::sizeX(), SiPixelCluster::sizeY(), PixelCPEClusterRepair::ClusterParamTemplate::templSigmaX_, PixelCPEClusterRepair::ClusterParamTemplate::templSigmaY_, PixelCPEBase::ClusterParam::theCluster, PixelCPEBase::DetParam::thePart, PixelCPEBase::theVerboseLevel, and UNLIKELY.

530 {
531 
532  ClusterParamTemplate & theClusterParam = static_cast<ClusterParamTemplate &>(theClusterParamBase);
533 
534  //--- Default is the maximum error used for edge clusters.
535  //--- (never used, in fact: let comment it out, shut up the complains of the static analyzer, and save a few CPU cycles)
536  float xerr = 0.0f, yerr = 0.0f;
537 
538  //--- Check status of both template calls.
539  if UNLIKELY ( (theClusterParam.ierr !=0) || (theClusterParam.ierr2 !=0) ) {
540  // If reconstruction fails the hit position is calculated from cluster center of gravity
541  // corrected in x by average Lorentz drift. Assign huge errors.
542  //
543  if UNLIKELY (!GeomDetEnumerators::isTrackerPixel(theDetParam.thePart))
545  << "A non-pixel detector type in here?";
546 
547  // Assign better errors based on the residuals for failed template cases
548  if ( GeomDetEnumerators::isBarrel(theDetParam.thePart)) {
549  xerr = 55.0f * micronsToCm; // &&& get errors from elsewhere?
550  yerr = 36.0f * micronsToCm;
551  }
552  else {
553  xerr = 42.0f * micronsToCm;
554  yerr = 39.0f * micronsToCm;
555  }
556  }
557  // Leave commented for now, until we study the interplay of failure modes
558  // of 1D template reco and edges. For edge hits we run 3D reco by default!
559  //
560  // else if ( theClusterParam.edgeTypeX_ || theClusterParam.edgeTypeY_ ) {
561  // // for edge pixels assign errors according to observed residual RMS
562  // if ( theClusterParam.edgeTypeX_ && !theClusterParam.edgeTypeY_ ) {
563  // xerr = 23.0f * micronsToCm;
564  // yerr = 39.0f * micronsToCm;
565  // }
566  // else if ( !theClusterParam.edgeTypeX_ && theClusterParam.edgeTypeY_ ) {
567  // xerr = 24.0f * micronsToCm;
568  // yerr = 96.0f * micronsToCm;
569  // }
570  // else if ( theClusterParam.edgeTypeX_ && theClusterParam.edgeTypeY_ ) {
571  // xerr = 31.0f * micronsToCm;
572  // yerr = 90.0f * micronsToCm;
573  // }
574  // }
575  else {
576  xerr = theClusterParam.templSigmaX_ * micronsToCm;
577  yerr = theClusterParam.templSigmaY_ * micronsToCm;
578  // &&& should also check ierr (saved as class variable) and return
579  // &&& nonsense (another class static) if the template fit failed.
580  }
581 
582  if (theVerboseLevel > 9) {
583  LogDebug("PixelCPEClusterRepair")
584  << " Sizex = " << theClusterParam.theCluster->sizeX()
585  << " Sizey = " << theClusterParam.theCluster->sizeY()
586  << " Edgex = " << theClusterParam.edgeTypeX_
587  << " Edgey = " << theClusterParam.edgeTypeY_
588  << " ErrX = " << xerr << " ErrY = " << yerr;
589  }
590 
591 
592  if ( !(xerr > 0.0f) )
593  throw cms::Exception("PixelCPEClusterRepair::localError")
594  << "\nERROR: Negative pixel error xerr = " << xerr << "\n\n";
595 
596  if ( !(yerr > 0.0f) )
597  throw cms::Exception("PixelCPEClusterRepair::localError")
598  << "\nERROR: Negative pixel error yerr = " << yerr << "\n\n";
599 
600  return LocalError(xerr*xerr, 0, yerr*yerr);
601 }
#define LogDebug(id)
type
Definition: HCALResponse.h:21
double f[11][100]
Namespace of DDCMS conversion namespace.
bool isTrackerPixel(GeomDetEnumerators::SubDetector m)
LocalPoint localPosition(DetParam const &theDetParam, ClusterParam &theClusterParam) const override
#define UNLIKELY(x)
LocalPoint PixelCPEClusterRepair::localPosition ( DetParam const &  theDetParam,
ClusterParam theClusterParam 
) const
overrideprivatevirtual

Implements PixelCPEBase.

Definition at line 129 of file PixelCPEClusterRepair.cc.

References barrelTemplateID_, callTempReco2D(), callTempReco3D(), PixelCPEBase::DetParam::detTemplateId, PixelCPEBase::ClusterParam::filled_from_2d, objects.autophobj::float, forwardTemplateID_, GeomDet::geographicalId(), SiPixelTemplateDBObject::getTemplateID(), PixelCPEBase::ClusterParam::hasBadPixels_, PixelCPEBase::ClusterParam::hasFilledProb_, mps_fire::i, PixelCPEClusterRepair::ClusterParamTemplate::ierr, PixelCPEClusterRepair::ClusterParamTemplate::ierr2, createfilelist::int, GeomDetEnumerators::isEndcap(), RectangularPixelTopology::isItBigPixelInX(), RectangularPixelTopology::isItBigPixelInY(), PixelCPEBase::ClusterParam::isOnEdge_, GeomDetEnumerators::isTrackerPixel(), PixelCPEBase::LoadTemplatesFromDB_, PixelCPEBase::ClusterParam::loc_trk_pred, Topology::localPosition(), SiStripPI::max, min(), SiPixelCluster::minPixelCol(), SiPixelCluster::minPixelRow(), SiPixelCluster::pixel(), PixelCPEBase::ClusterParam::probabilityQ_, PixelCPEBase::ClusterParam::probabilityX_, PixelCPEBase::ClusterParam::probabilityY_, PixelCPEBase::ClusterParam::qBin_, PixelCPEClusterRepair::ClusterParamTemplate::recommended3D_, SiPixelCluster::size(), PixelCPEBase::ClusterParam::spansTwoROCs_, PixelCPEBase::templateDBobject_, PixelCPEClusterRepair::ClusterParamTemplate::templProbXY_, PixelCPEClusterRepair::ClusterParamTemplate::templXrec_, PixelCPEClusterRepair::ClusterParamTemplate::templYrec_, PixelCPEBase::ClusterParam::theCluster, PixelCPEBase::DetParam::theDet, PixelCPEBase::DetParam::thePart, PixelCPEBase::DetParam::theRecTopol, PixelCPEBase::DetParam::theTopol, create_public_lumi_plots::tmp_x, create_public_lumi_plots::tmp_y, and PixelCPEBase::ClusterParam::with_track_angle.

130 {
131 
132  ClusterParamTemplate & theClusterParam = static_cast<ClusterParamTemplate &>(theClusterParamBase);
133  bool filled_from_2d = false;
134 
135  if(!GeomDetEnumerators::isTrackerPixel(theDetParam.thePart))
136  throw cms::Exception("PixelCPEClusterRepair::localPosition :")
137  << "A non-pixel detector type in here?";
138 
139  int ID = -9999;
140  if ( LoadTemplatesFromDB_ ) {
141  int ID0 = templateDBobject_->getTemplateID(theDetParam.theDet->geographicalId()); // just to comapre
142  ID = theDetParam.detTemplateId;
143  if(ID0!=ID) edm::LogError("PixelCPEClusterRepair") <<" different id"<< ID<<" "<<ID0<<endl;
144  } else { // from asci file
145  if ( ! GeomDetEnumerators::isEndcap(theDetParam.thePart) )
146  ID = barrelTemplateID_ ; // barrel
147  else
148  ID = forwardTemplateID_ ; // forward
149  }
150  //cout << "PixelCPEClusterRepair : ID = " << ID << endl;
151 
152  // &&& PM, note for later: PixelCPEBase calculates minInX,Y, and maxInX,Y
153  // Why can't we simply use that and save time with row_offset, col_offset
154  // and mrow = maxInX-minInX, mcol = maxInY-minInY ... Except that we
155  // also need to take into account cluster_matrix_size_x,y.
156 
157 
158  //--- Preparing to retrieve ADC counts from the SiPixeltheClusterParam.theCluster
159  // The pixels from minPixelRow() will go into clust_array_2d[0][*],
160  // and the pixels from minPixelCol() will go into clust_array_2d[*][0].
161  int row_offset = theClusterParam.theCluster->minPixelRow();
162  int col_offset = theClusterParam.theCluster->minPixelCol();
163 
164  //--- Store the coordinates of the center of the (0,0) pixel of the array that
165  // gets passed to PixelTempReco2D. Will add these values to the output of TemplReco2D
166  float tmp_x = float(row_offset) + 0.5f;
167  float tmp_y = float(col_offset) + 0.5f;
168 
169 
170  //--- Store these offsets (to be added later) in a LocalPoint after tranforming
171  // them from measurement units (pixel units) to local coordinates (cm)
172  LocalPoint lp;
173  if ( theClusterParam.with_track_angle )
174  //--- Update call with trk angles needed for bow/kink corrections // Gavril
175  lp = theDetParam.theTopol->localPosition( MeasurementPoint(tmp_x, tmp_y), theClusterParam.loc_trk_pred );
176  else
177  {
178  edm::LogError("PixelCPEClusterRepair")
179  << "@SUB = PixelCPEClusterRepair::localPosition"
180  << "Should never be here. PixelCPEClusterRepair should always be called with track angles. This is a bad error !!! ";
181  lp = theDetParam.theTopol->localPosition( MeasurementPoint(tmp_x, tmp_y) );
182  }
183 
184  //--- Compute the size of the matrix which will be passed to TemplateReco.
185  // We'll later make clustMatrix[ mrow ][ mcol ]
186  int mrow=0, mcol=0;
187  for (int i=0 ; i!=theClusterParam.theCluster->size(); ++i )
188  {
189  auto pix = theClusterParam.theCluster->pixel(i);
190  int irow = int(pix.x);
191  int icol = int(pix.y);
192  mrow = std::max(mrow,irow);
193  mcol = std::max(mcol,icol);
194  }
195  mrow -= row_offset; mrow+=1; mrow = std::min(mrow,cluster_matrix_size_x);
196  mcol -= col_offset; mcol+=1; mcol = std::min(mcol,cluster_matrix_size_y);
197  assert(mrow>0); assert(mcol>0);
198 
199 
200  //--- Make and fill the bool arrays flagging double pixels
201  bool xdouble[mrow], ydouble[mcol];
202  // x directions (shorter), rows
203  for (int irow = 0; irow < mrow; ++irow)
204  xdouble[irow] = theDetParam.theRecTopol->isItBigPixelInX( irow+row_offset );
205  //
206  // y directions (longer), columns
207  for (int icol = 0; icol < mcol; ++icol)
208  ydouble[icol] = theDetParam.theRecTopol->isItBigPixelInY( icol+col_offset );
209 
210  //--- C-style matrix. We'll need it in either case.
211  float clustMatrix[mrow][mcol];
212  float clustMatrix2[mrow][mcol];
213 
214  //--- Prepare struct that passes pointers to TemplateReco. It doesn't own anything.
215  SiPixelTemplateReco::ClusMatrix clusterPayload { &clustMatrix[0][0], xdouble, ydouble, mrow,mcol};
216  SiPixelTemplateReco2D::ClusMatrix clusterPayload2d{ &clustMatrix2[0][0], xdouble, ydouble, mrow,mcol};
217 
218 
219  //--- Copy clust's pixels (calibrated in electrons) into clustMatrix;
220  memset( clustMatrix, 0, sizeof(float)*mrow*mcol ); // Wipe it clean.
221  for (int i=0 ; i!=theClusterParam.theCluster->size(); ++i )
222  {
223  auto pix = theClusterParam.theCluster->pixel(i);
224  int irow = int(pix.x) - row_offset;
225  int icol = int(pix.y) - col_offset;
226  // &&& Do we ever get pixels that are out of bounds ??? Need to check.
227  if ( (irow<mrow) & (icol<mcol) ) clustMatrix[irow][icol] = float(pix.adc);
228  }
229  // &&& Save for later: fillClustMatrix( float * clustMatrix );
230 
231  //--- Save a copy of clustMatrix into clustMatrix2
232  memcpy( clustMatrix2, clustMatrix, sizeof(float)*mrow*mcol);
233 
234  //--- Set both return statuses, since we may call only one.
235  theClusterParam.ierr = 0;
236  theClusterParam.ierr2 = 0;
237 
238 
239 
240  //--- Are we on edge?
241  if ( theClusterParam.isOnEdge_ ) {
242  //--- Call the Template Reco 2d with cluster repair.0
243  filled_from_2d = true;
244  callTempReco3D( theDetParam, theClusterParam, clusterPayload2d, ID, lp );
245  }
246  else {
247  theClusterParam.recommended3D_ = false;
248  //--- Call the vanilla Template Reco
249  callTempReco2D( theDetParam, theClusterParam, clusterPayload, ID, lp );
250 
251  //--- Did we find a cluster which has bad probability and not enough charge?
252  if ( theClusterParam.recommended3D_ ) {
253  //--- Yes. So run Template Reco 2d with cluster repair.
254 
255  // //--- Once again (!) copy clust's pixels (calibrated in electrons) into
256  // // clustMatrix. We need to do that because the vanilla template reco
257  // // will modify the ADC counts in situ (during decapitation)
258  // memset( clustMatrix, 0, sizeof(float)*mrow*mcol ); // Wipe it clean.
259  // for (int i=0 ; i!=theClusterParam.theCluster->size(); ++i )
260  // {
261  // auto pix = theClusterParam.theCluster->pixel(i);
262  // int irow = int(pix.x) - row_offset;
263  // int icol = int(pix.y) - col_offset;
264  // // &&& Do we ever get pixels that are out of bounds ??? Need to check.
265  // if ( (irow<mrow) & (icol<mcol) ) clustMatrix[irow][icol] = float(pix.adc);
266  // }
267  // // fillClustMatrix( float * clustMatrix );
268 
269 
270  //--- Call the Template Reco 2d with cluster repair
271  callTempReco3D( theDetParam, theClusterParam, clusterPayload2d, ID, lp );
272  filled_from_2d = true;
273  }
274 
275  }
276 
277  //--- Make sure cluster repair returns all info about the hit back up to caller
278  //--- Necessary because it copied the base class so it does not modify it
279  theClusterParamBase.isOnEdge_ = theClusterParam.isOnEdge_;
280  theClusterParamBase.hasBadPixels_ = theClusterParam.hasBadPixels_;
281  theClusterParamBase.spansTwoROCs_ = theClusterParam.spansTwoROCs_;
282  theClusterParamBase.hasFilledProb_ = theClusterParam.hasFilledProb_;
283  theClusterParamBase.qBin_ = theClusterParam.qBin_;
284  theClusterParamBase.probabilityQ_ = theClusterParam.probabilityQ_;
285  theClusterParamBase.filled_from_2d = filled_from_2d;
286  if(filled_from_2d){
287  theClusterParamBase.probabilityX_ = theClusterParam.templProbXY_;
288  theClusterParamBase.probabilityY_ = 0.;
289  }
290  else{
291  theClusterParamBase.probabilityX_ = theClusterParam.probabilityX_;
292  theClusterParamBase.probabilityY_ = theClusterParam.probabilityY_;
293  }
294 
295 
296 
297  return LocalPoint( theClusterParam.templXrec_, theClusterParam.templYrec_ );
298 }
Point3DBase< Scalar, LocalTag > LocalPoint
Definition: Definitions.h:32
short getTemplateID(const uint32_t &detid) const
uint32_t ID
Definition: Definitions.h:26
Measurement2DPoint MeasurementPoint
Measurement points are two-dimensional by default.
bool LoadTemplatesFromDB_
Definition: PixelCPEBase.h:257
void callTempReco3D(DetParam const &theDetParam, ClusterParamTemplate &theClusterParam, SiPixelTemplateReco2D::ClusMatrix &clusterPayload, int ID, LocalPoint &lp) const
const SiPixelTemplateDBObject * templateDBobject_
Definition: PixelCPEBase.h:253
void callTempReco2D(DetParam const &theDetParam, ClusterParamTemplate &theClusterParam, SiPixelTemplateReco::ClusMatrix &clusterPayload, int ID, LocalPoint &lp) const
T min(T a, T b)
Definition: MathUtil.h:58
bool isEndcap(GeomDetEnumerators::SubDetector m)
bool isTrackerPixel(GeomDetEnumerators::SubDetector m)

Member Data Documentation

int PixelCPEClusterRepair::barrelTemplateID_
private

Definition at line 94 of file PixelCPEClusterRepair.h.

Referenced by localPosition(), and PixelCPEClusterRepair().

int PixelCPEClusterRepair::forwardTemplateID_
private

Definition at line 95 of file PixelCPEClusterRepair.h.

Referenced by localPosition(), and PixelCPEClusterRepair().

int PixelCPEClusterRepair::maxSizeMismatchInY_
private

Definition at line 100 of file PixelCPEClusterRepair.h.

Referenced by PixelCPEClusterRepair().

float PixelCPEClusterRepair::minProbY_
private

Definition at line 99 of file PixelCPEClusterRepair.h.

Referenced by callTempReco2D(), and PixelCPEClusterRepair().

int PixelCPEClusterRepair::speed_
private

Definition at line 89 of file PixelCPEClusterRepair.h.

Referenced by callTempReco2D(), and PixelCPEClusterRepair().

std::string PixelCPEClusterRepair::templateDir_
private

Definition at line 96 of file PixelCPEClusterRepair.h.

Referenced by PixelCPEClusterRepair().

std::vector< SiPixelTemplateStore2D > PixelCPEClusterRepair::thePixelTemp2D_
private
std::vector< SiPixelTemplateStore > PixelCPEClusterRepair::thePixelTemp_
private
bool PixelCPEClusterRepair::UseClusterSplitter_
private

Definition at line 91 of file PixelCPEClusterRepair.h.

Referenced by PixelCPEClusterRepair().