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 callTempReco1D (DetParam const &theDetParam, ClusterParamTemplate &theClusterParam, SiPixelTemplateReco::ClusMatrix &clusterPayload, int ID, LocalPoint &lp) const
 
void callTempReco2D (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
 
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 2D 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::callTempReco1D ( DetParam const &  theDetParam,
ClusterParamTemplate theClusterParam,
SiPixelTemplateReco::ClusMatrix clusterPayload,
int  ID,
LocalPoint lp 
) const
private

Definition at line 290 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::PixelTempReco1D(), PixelCPEBase::ClusterParam::probabilityQ_, PixelCPEBase::ClusterParam::probabilityX_, PixelCPEBase::ClusterParam::probabilityY_, PixelCPEBase::ClusterParam::qBin_, PixelCPEClusterRepair::ClusterParamTemplate::recommended2D_, 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().

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

Definition at line 391 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::PixelTempReco2D(), PixelCPEBase::ClusterParam::probabilityQ_, PixelCPEBase::ClusterParam::probabilityX_, PixelCPEBase::ClusterParam::probabilityY_, PixelCPEBase::ClusterParam::qBin_, PixelCPEClusterRepair::ClusterParamTemplate::recommended2D_, 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().

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

515 {
516 
517  ClusterParamTemplate & theClusterParam = static_cast<ClusterParamTemplate &>(theClusterParamBase);
518 
519  //--- Default is the maximum error used for edge clusters.
520  //--- (never used, in fact: let comment it out, shut up the complains of the static analyzer, and save a few CPU cycles)
521  float xerr = 0.0f, yerr = 0.0f;
522 
523  //--- Check status of both template calls.
524  if UNLIKELY ( (theClusterParam.ierr !=0) || (theClusterParam.ierr2 !=0) ) {
525  // If reconstruction fails the hit position is calculated from cluster center of gravity
526  // corrected in x by average Lorentz drift. Assign huge errors.
527  //
528  if UNLIKELY (!GeomDetEnumerators::isTrackerPixel(theDetParam.thePart))
530  << "A non-pixel detector type in here?";
531 
532  // Assign better errors based on the residuals for failed template cases
533  if ( GeomDetEnumerators::isBarrel(theDetParam.thePart)) {
534  xerr = 55.0f * micronsToCm; // &&& get errors from elsewhere?
535  yerr = 36.0f * micronsToCm;
536  }
537  else {
538  xerr = 42.0f * micronsToCm;
539  yerr = 39.0f * micronsToCm;
540  }
541  }
542  // Leave commented for now, until we study the interplay of failure modes
543  // of 1D template reco and edges. For edge hits we run 2D reco by default!
544  //
545  // else if ( theClusterParam.edgeTypeX_ || theClusterParam.edgeTypeY_ ) {
546  // // for edge pixels assign errors according to observed residual RMS
547  // if ( theClusterParam.edgeTypeX_ && !theClusterParam.edgeTypeY_ ) {
548  // xerr = 23.0f * micronsToCm;
549  // yerr = 39.0f * micronsToCm;
550  // }
551  // else if ( !theClusterParam.edgeTypeX_ && theClusterParam.edgeTypeY_ ) {
552  // xerr = 24.0f * micronsToCm;
553  // yerr = 96.0f * micronsToCm;
554  // }
555  // else if ( theClusterParam.edgeTypeX_ && theClusterParam.edgeTypeY_ ) {
556  // xerr = 31.0f * micronsToCm;
557  // yerr = 90.0f * micronsToCm;
558  // }
559  // }
560  else {
561  xerr = theClusterParam.templSigmaX_ * micronsToCm;
562  yerr = theClusterParam.templSigmaY_ * micronsToCm;
563  // &&& should also check ierr (saved as class variable) and return
564  // &&& nonsense (another class static) if the template fit failed.
565  }
566 
567  if (theVerboseLevel > 9) {
568  LogDebug("PixelCPEClusterRepair")
569  << " Sizex = " << theClusterParam.theCluster->sizeX()
570  << " Sizey = " << theClusterParam.theCluster->sizeY()
571  << " Edgex = " << theClusterParam.edgeTypeX_
572  << " Edgey = " << theClusterParam.edgeTypeY_
573  << " ErrX = " << xerr << " ErrY = " << yerr;
574  }
575 
576 
577  if ( !(xerr > 0.0f) )
578  throw cms::Exception("PixelCPEClusterRepair::localError")
579  << "\nERROR: Negative pixel error xerr = " << xerr << "\n\n";
580 
581  if ( !(yerr > 0.0f) )
582  throw cms::Exception("PixelCPEClusterRepair::localError")
583  << "\nERROR: Negative pixel error yerr = " << yerr << "\n\n";
584 
585  return LocalError(xerr*xerr, 0, yerr*yerr);
586 }
#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_, callTempReco1D(), callTempReco2D(), 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::recommended2D_, 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  callTempReco2D( theDetParam, theClusterParam, clusterPayload2d, ID, lp );
245  }
246  else {
247  theClusterParam.recommended2D_ = false;
248  //--- Call the vanilla Template Reco
249  callTempReco1D( theDetParam, theClusterParam, clusterPayload, ID, lp );
250 
251  //--- Did we find a cluster which has bad probability and not enough charge?
252  if ( theClusterParam.recommended2D_ ) {
253  //--- Yes. So run Template Reco 2d with cluster repair.
254 
255  //--- Call the Template Reco 2d with cluster repair
256  callTempReco2D( theDetParam, theClusterParam, clusterPayload2d, ID, lp );
257  filled_from_2d = true;
258  }
259 
260  }
261 
262  //--- Make sure cluster repair returns all info about the hit back up to caller
263  //--- Necessary because it copied the base class so it does not modify it
264  theClusterParamBase.isOnEdge_ = theClusterParam.isOnEdge_;
265  theClusterParamBase.hasBadPixels_ = theClusterParam.hasBadPixels_;
266  theClusterParamBase.spansTwoROCs_ = theClusterParam.spansTwoROCs_;
267  theClusterParamBase.hasFilledProb_ = theClusterParam.hasFilledProb_;
268  theClusterParamBase.qBin_ = theClusterParam.qBin_;
269  theClusterParamBase.probabilityQ_ = theClusterParam.probabilityQ_;
270  theClusterParamBase.filled_from_2d = filled_from_2d;
271  if(filled_from_2d){
272  theClusterParamBase.probabilityX_ = theClusterParam.templProbXY_;
273  theClusterParamBase.probabilityY_ = 0.;
274  }
275  else{
276  theClusterParamBase.probabilityX_ = theClusterParam.probabilityX_;
277  theClusterParamBase.probabilityY_ = theClusterParam.probabilityY_;
278  }
279 
280 
281 
282  return LocalPoint( theClusterParam.templXrec_, theClusterParam.templYrec_ );
283 }
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
const SiPixelTemplateDBObject * templateDBobject_
Definition: PixelCPEBase.h:253
T min(T a, T b)
Definition: MathUtil.h:58
void callTempReco2D(DetParam const &theDetParam, ClusterParamTemplate &theClusterParam, SiPixelTemplateReco2D::ClusMatrix &clusterPayload, int ID, LocalPoint &lp) const
bool isEndcap(GeomDetEnumerators::SubDetector m)
void callTempReco1D(DetParam const &theDetParam, ClusterParamTemplate &theClusterParam, SiPixelTemplateReco::ClusMatrix &clusterPayload, int ID, LocalPoint &lp) const
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 callTempReco1D(), and PixelCPEClusterRepair().

int PixelCPEClusterRepair::speed_
private

Definition at line 89 of file PixelCPEClusterRepair.h.

Referenced by callTempReco1D(), 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().