CMS 3D CMS Logo

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

#include <PixelCPETemplateReco.h>

Inheritance diagram for PixelCPETemplateReco:
PixelCPEBase PixelClusterParameterEstimator

Classes

struct  ClusterParamTemplate
 

Public Member Functions

 PixelCPETemplateReco (edm::ParameterSet const &conf, const MagneticField *, const TrackerGeometry &, const TrackerTopology &, const SiPixelLorentzAngle *, const std::vector< SiPixelTemplateStore > *, const SiPixelTemplateDBObject *)
 
 ~PixelCPETemplateReco () 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 ()
 

Static Public Member Functions

static void fillPSetDescription (edm::ParameterSetDescription &desc)
 
- Static Public Member Functions inherited from PixelCPEBase
static void fillPSetDescription (edm::ParameterSetDescription &desc)
 

Private Member Functions

std::unique_ptr< 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 speed_
 
std::string templateDir_
 
const std::vector< SiPixelTemplateStore > * thePixelTemp_
 
std::vector< SiPixelTemplateStorethePixelTempCache_
 
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 doLorentzFromAlignment_
 
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 useLAFromDB_
 
bool useLAOffsetFromConfig_
 
bool useLAWidthFromConfig_
 
bool useLAWidthFromDB_
 
- Protected Attributes inherited from PixelClusterParameterEstimator
unsigned int clusterProbComputationFlag_
 
- Static Protected Attributes inherited from PixelCPEBase
static constexpr float bothEdgeXError_ = 31.0f
 
static constexpr float bothEdgeYError_ = 90.0f
 
static constexpr float clusterSplitMaxError_ = 7777.7f
 
static constexpr float xEdgeXError_ = 23.0f
 
static constexpr float xEdgeYError_ = 39.0f
 
static constexpr float yEdgeXError_ = 24.0f
 
static constexpr float yEdgeYError_ = 96.0f
 

Detailed Description

Definition at line 32 of file PixelCPETemplateReco.h.

Constructor & Destructor Documentation

◆ PixelCPETemplateReco()

PixelCPETemplateReco::PixelCPETemplateReco ( edm::ParameterSet const &  conf,
const MagneticField mag,
const TrackerGeometry geom,
const TrackerTopology ttopo,
const SiPixelLorentzAngle lorentzAngle,
const std::vector< SiPixelTemplateStore > *  templateStore,
const SiPixelTemplateDBObject templateDBobject 
)

Definition at line 43 of file PixelCPETemplateReco.cc.

References barrelTemplateID_, forwardTemplateID_, edm::ParameterSet::getParameter(), PixelCPEBase::LoadTemplatesFromDB_, LogDebug, SiPixelTemplate::pushfile(), speed_, templateDir_, thePixelTemp_, thePixelTempCache_, and UseClusterSplitter_.

50  : PixelCPEBase(conf, mag, geom, ttopo, lorentzAngle, nullptr, templateDBobject, nullptr, 1) {
51  //cout << endl;
52  //cout << "Constructing PixelCPETemplateReco::PixelCPETemplateReco(...)................................................." << endl;
53  //cout << endl;
54 
55  // Configurable parameters
56  //DoCosmics_ = conf.getParameter<bool>("DoCosmics"); // Not used in templates
57  //LoadTemplatesFromDB_ = conf.getParameter<bool>("LoadTemplatesFromDB"); // Moved to Base
58 
59  //cout << " PixelCPETemplateReco : (int)LoadTemplatesFromDB_ = " << (int)LoadTemplatesFromDB_ << endl;
60  //cout << "field_magnitude = " << field_magnitude << endl;
61 
62  // configuration parameter to decide between DB or text file template access
63 
65  //cout << "PixelCPETemplateReco: Loading templates from database (DB) --------- " << endl;
66  thePixelTemp_ = templateStore;
67  } else {
68  //cout << "PixelCPETemplateReco : Loading templates for barrel and forward from ASCII files ----------" << endl;
69  barrelTemplateID_ = conf.getParameter<int>("barrelTemplateID");
70  forwardTemplateID_ = conf.getParameter<int>("forwardTemplateID");
71  templateDir_ = conf.getParameter<int>("directoryWithTemplates");
72 
75  throw cms::Exception("PixelCPETemplateReco")
76  << "\nERROR: Template ID " << barrelTemplateID_
77  << " not loaded correctly from text file. Reconstruction will fail.\n\n";
78 
80  throw cms::Exception("PixelCPETemplateReco")
81  << "\nERROR: Template ID " << forwardTemplateID_
82  << " not loaded correctly from text file. Reconstruction will fail.\n\n";
83  }
84 
85  speed_ = conf.getParameter<int>("speed");
86  LogDebug("PixelCPETemplateReco::PixelCPETemplateReco:") << "Template speed = " << speed_ << "\n";
87 
88  UseClusterSplitter_ = conf.getParameter<bool>("UseClusterSplitter");
89 }
const std::vector< SiPixelTemplateStore > * thePixelTemp_
bool LoadTemplatesFromDB_
Definition: PixelCPEBase.h:243
T mag() const
The vector magnitude. Equivalent to sqrt(vec.mag2())
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:30
std::vector< SiPixelTemplateStore > thePixelTempCache_
#define LogDebug(id)

◆ ~PixelCPETemplateReco()

PixelCPETemplateReco::~PixelCPETemplateReco ( )
override

Definition at line 94 of file PixelCPETemplateReco.cc.

94 {}

Member Function Documentation

◆ createClusterParam()

std::unique_ptr< PixelCPEBase::ClusterParam > PixelCPETemplateReco::createClusterParam ( const SiPixelCluster cl) const
overrideprivatevirtual

Implements PixelCPEBase.

Definition at line 96 of file PixelCPETemplateReco.cc.

References haddnano::cl.

96  {
97  return std::make_unique<ClusterParamTemplate>(cl);
98 }

◆ fillPSetDescription()

void PixelCPETemplateReco::fillPSetDescription ( edm::ParameterSetDescription desc)
static

Definition at line 527 of file PixelCPETemplateReco.cc.

References submitPVResolutionJobs::desc.

Referenced by PixelCPETemplateRecoESProducer::fillDescriptions().

527  {
528  desc.add<int>("barrelTemplateID", 0);
529  desc.add<int>("forwardTemplateID", 0);
530  desc.add<int>("directoryWithTemplates", 0);
531  desc.add<int>("speed", -2);
532  desc.add<bool>("UseClusterSplitter", false);
533 }

◆ localError()

LocalError PixelCPETemplateReco::localError ( DetParam const &  theDetParam,
ClusterParam theClusterParam 
) const
overrideprivatevirtual

Implements PixelCPEBase.

Definition at line 407 of file PixelCPETemplateReco.cc.

References PixelCPEBase::bothEdgeXError_, PixelCPEBase::bothEdgeYError_, PixelCPEBase::clusterSplitMaxError_, Exception, f, PixelCPETemplateReco::ClusterParamTemplate::ierr, GeomDetEnumerators::isBarrel(), RectangularPixelTopology::isItEdgePixelInX(), RectangularPixelTopology::isItEdgePixelInY(), GeomDetEnumerators::isTrackerPixel(), LogDebug, PixelCPETemplateReco::ClusterParamTemplate::templSigmaX_, PixelCPETemplateReco::ClusterParamTemplate::templSigmaY_, PixelCPEBase::DetParam::thePart, PixelCPEBase::DetParam::theRecTopol, PixelCPEBase::theVerboseLevel, PixelCPEBase::xEdgeXError_, PixelCPEBase::xEdgeYError_, PixelCPEBase::yEdgeXError_, and PixelCPEBase::yEdgeYError_.

407  {
408  ClusterParamTemplate& theClusterParam = static_cast<ClusterParamTemplate&>(theClusterParamBase);
409 
410  //cout << endl;
411  //cout << "Set PixelCPETemplate errors .............................................." << endl;
412 
413  //cout << "CPETemplate : " << endl;
414 
415  //--- Default is the maximum error used for edge clusters.
416  //--- (never used, in fact: let comment it out, shut up the complains of the static analyzer, and save a few CPU cycles)
417  // const float sig12 = 1./sqrt(12.0);
418  // float xerr = theDetParam.thePitchX *sig12;
419  // float yerr = theDetParam.thePitchY *sig12;
420  float xerr, yerr;
421 
422  // Check if the errors were already set at the clusters splitting level
423  if (theClusterParam.theCluster->getSplitClusterErrorX() > 0.0f &&
424  theClusterParam.theCluster->getSplitClusterErrorX() < clusterSplitMaxError_ &&
425  theClusterParam.theCluster->getSplitClusterErrorY() > 0.0f &&
426  theClusterParam.theCluster->getSplitClusterErrorY() < clusterSplitMaxError_) {
427  xerr = theClusterParam.theCluster->getSplitClusterErrorX() * micronsToCm;
428  yerr = theClusterParam.theCluster->getSplitClusterErrorY() * micronsToCm;
429 
430  //cout << "Errors set at cluster splitting level : " << endl;
431  //cout << "xerr = " << xerr << endl;
432  //cout << "yerr = " << yerr << endl;
433  } else {
434  // If errors are not split at the cluster splitting level, set the errors here
435 
436  //cout << "Errors are not split at the cluster splitting level, set the errors here : " << endl;
437 
438  int maxPixelCol = theClusterParam.theCluster->maxPixelCol();
439  int maxPixelRow = theClusterParam.theCluster->maxPixelRow();
440  int minPixelCol = theClusterParam.theCluster->minPixelCol();
441  int minPixelRow = theClusterParam.theCluster->minPixelRow();
442 
443  //--- Are we near either of the edges?
444  bool edgex = (theDetParam.theRecTopol->isItEdgePixelInX(minPixelRow) ||
445  theDetParam.theRecTopol->isItEdgePixelInX(maxPixelRow));
446  bool edgey = (theDetParam.theRecTopol->isItEdgePixelInY(minPixelCol) ||
447  theDetParam.theRecTopol->isItEdgePixelInY(maxPixelCol));
448 
449  if (theClusterParam.ierr != 0) {
450  // If reconstruction fails the hit position is calculated from cluster center of gravity
451  // corrected in x by average Lorentz drift. Assign huge errors.
452  //xerr = 10.0 * (float)theClusterParam.theCluster->sizeX() * xerr;
453  //yerr = 10.0 * (float)theClusterParam.theCluster->sizeX() * yerr;
454 
455  if (!GeomDetEnumerators::isTrackerPixel(theDetParam.thePart))
456  throw cms::Exception("PixelCPETemplateReco::localPosition :") << "A non-pixel detector type in here?";
457 
458  // Assign better errors based on the residuals for failed template cases
459  if (GeomDetEnumerators::isBarrel(theDetParam.thePart)) {
460  xerr = 55.0f * micronsToCm;
461  yerr = 36.0f * micronsToCm;
462  } else {
463  xerr = 42.0f * micronsToCm;
464  yerr = 39.0f * micronsToCm;
465  }
466 
467  //cout << "xerr = " << xerr << endl;
468  //cout << "yerr = " << yerr << endl;
469 
470  //return LocalError(xerr*xerr, 0, yerr*yerr);
471  } else if (edgex || edgey) {
472  // for edge pixels assign errors according to observed residual RMS
473  if (edgex && !edgey) {
474  xerr = xEdgeXError_ * micronsToCm;
475  yerr = xEdgeYError_ * micronsToCm;
476  } else if (!edgex && edgey) {
477  xerr = yEdgeXError_ * micronsToCm;
478  yerr = yEdgeYError_ * micronsToCm;
479  } else if (edgex && edgey) {
480  xerr = bothEdgeXError_ * micronsToCm;
481  yerr = bothEdgeYError_ * micronsToCm;
482  } else {
483  throw cms::Exception(" PixelCPETemplateReco::localError: Something wrong with pixel edge flag !!!");
484  }
485 
486  //cout << "xerr = " << xerr << endl;
487  //cout << "yerr = " << yerr << endl;
488  } else {
489  // &&& need a class const
490  //const float micronsToCm = 1.0e-4;
491 
492  xerr = theClusterParam.templSigmaX_ * micronsToCm;
493  yerr = theClusterParam.templSigmaY_ * micronsToCm;
494 
495  //cout << "xerr = " << xerr << endl;
496  //cout << "yerr = " << yerr << endl;
497 
498  // &&& should also check ierr (saved as class variable) and return
499  // &&& nonsense (another class static) if the template fit failed.
500  }
501 
502  if (theVerboseLevel > 9) {
503  LogDebug("PixelCPETemplateReco") << " Sizex = " << theClusterParam.theCluster->sizeX()
504  << " Sizey = " << theClusterParam.theCluster->sizeY() << " Edgex = " << edgex
505  << " Edgey = " << edgey << " ErrX = " << xerr << " ErrY = " << yerr;
506  }
507 
508  } // else
509 
510  if (!(xerr > 0.0f))
511  throw cms::Exception("PixelCPETemplateReco::localError")
512  << "\nERROR: Negative pixel error xerr = " << xerr << "\n\n";
513 
514  if (!(yerr > 0.0f))
515  throw cms::Exception("PixelCPETemplateReco::localError")
516  << "\nERROR: Negative pixel error yerr = " << yerr << "\n\n";
517 
518  //cout << "Final errors set to: " << endl;
519  //cout << "xerr = " << xerr << endl;
520  //cout << "yerr = " << yerr << endl;
521  //cout << "Out of PixelCPETemplateREco..........................................................................." << endl;
522  //cout << endl;
523 
524  return LocalError(xerr * xerr, 0, yerr * yerr);
525 }
static constexpr float xEdgeYError_
Definition: PixelCPEBase.h:248
bool isBarrel(GeomDetEnumerators::SubDetector m)
static constexpr float bothEdgeYError_
Definition: PixelCPEBase.h:254
static constexpr float yEdgeYError_
Definition: PixelCPEBase.h:251
double f[11][100]
static constexpr float xEdgeXError_
Definition: PixelCPEBase.h:247
static constexpr float clusterSplitMaxError_
Definition: PixelCPEBase.h:256
static constexpr float bothEdgeXError_
Definition: PixelCPEBase.h:253
static constexpr float yEdgeXError_
Definition: PixelCPEBase.h:250
bool isTrackerPixel(GeomDetEnumerators::SubDetector m)
#define LogDebug(id)

◆ localPosition()

LocalPoint PixelCPETemplateReco::localPosition ( DetParam const &  theDetParam,
ClusterParam theClusterParam 
) const
overrideprivatevirtual

std::vector< SiPixelTemplateStore2D > thePixelTemp2D_; SiPixelTemplate2D::pushfile(ID, thePixelTemp2D_); SiPixelTemplate2D templ2D_(thePixelTemp2D_);

Implements PixelCPEBase.

Definition at line 107 of file PixelCPETemplateReco.cc.

References funct::abs(), cms::cuda::assert(), barrelTemplateID_, PixelCPEBase::DetParam::bx, PixelCPEBase::DetParam::bz, PixelCPEBase::DetParam::detTemplateId, PixelCPEBase::doLorentzFromAlignment_, nano_mu_digi_cff::float, forwardTemplateID_, GeomDet::geographicalId(), SiPixelTemplateDBObject::getTemplateID(), mps_fire::i, PixelCPETemplateReco::ClusterParamTemplate::ierr, createfilelist::int, GeomDetEnumerators::isEndcap(), RectangularPixelTopology::isItBigPixelInX(), RectangularPixelTopology::isItBigPixelInY(), GeomDetEnumerators::isTrackerPixel(), PixelCPEBase::LoadTemplatesFromDB_, Topology::localPosition(), PixelTopology::localX(), PixelTopology::localY(), LogDebug, PixelCPEBase::DetParam::lorentzShiftInCmX, PixelCPEBase::DetParam::lorentzShiftInCmY, SiPixelTemplate::lorxbias(), SiPixelTemplate::lorybias(), SiStripPI::max, SiStripPI::min, SiPixelTemplateReco::PixelTempReco1D(), speed_, PixelCPEBase::templateDBobject_, PixelCPETemplateReco::ClusterParamTemplate::templProbQ_, PixelCPETemplateReco::ClusterParamTemplate::templProbX_, PixelCPETemplateReco::ClusterParamTemplate::templProbY_, PixelCPETemplateReco::ClusterParamTemplate::templQbin_, PixelCPETemplateReco::ClusterParamTemplate::templSigmaX_, PixelCPETemplateReco::ClusterParamTemplate::templSigmaY_, PixelCPETemplateReco::ClusterParamTemplate::templXrec_, PixelCPETemplateReco::ClusterParamTemplate::templYrec_, PixelCPEBase::DetParam::theDet, PixelCPEBase::DetParam::thePart, thePixelTemp_, PixelCPEBase::DetParam::theRecTopol, PixelCPEBase::DetParam::theTopol, UNLIKELY, UseClusterSplitter_, PV3DBase< T, PVType, FrameType >::x(), and PV3DBase< T, PVType, FrameType >::y().

107  {
108  ClusterParamTemplate& theClusterParam = static_cast<ClusterParamTemplate&>(theClusterParamBase);
109 
110  if (!GeomDetEnumerators::isTrackerPixel(theDetParam.thePart))
111  throw cms::Exception("PixelCPETemplateReco::localPosition :") << "A non-pixel detector type in here?";
112  // barrel(false) or forward(true)
113  const bool fpix = GeomDetEnumerators::isEndcap(theDetParam.thePart);
114 
115  int ID = -9999;
116  if (LoadTemplatesFromDB_) {
117  int ID0 = templateDBobject_->getTemplateID(theDetParam.theDet->geographicalId()); // just to comapre
118  ID = theDetParam.detTemplateId;
119  if (ID0 != ID)
120  edm::LogError("PixelCPETemplateReco") << " different id" << ID << " " << ID0 << endl;
121  } else { // from asci file
122  if (!fpix)
123  ID = barrelTemplateID_; // barrel
124  else
125  ID = forwardTemplateID_; // forward
126  }
127  //cout << "PixelCPETemplateReco : ID = " << ID << endl;
128 
130 
131  // Preparing to retrieve ADC counts from the SiPixeltheClusterParam.theCluster-> In the cluster,
132  // we have the following:
133  // int minPixelRow(); // Minimum pixel index in the x direction (low edge).
134  // int maxPixelRow(); // Maximum pixel index in the x direction (top edge).
135  // int minPixelCol(); // Minimum pixel index in the y direction (left edge).
136  // int maxPixelCol(); // Maximum pixel index in the y direction (right edge).
137  // So the pixels from minPixelRow() will go into clust_array_2d[0][*],
138  // and the pixels from minPixelCol() will go into clust_array_2d[*][0].
139 
140  int row_offset = theClusterParam.theCluster->minPixelRow();
141  int col_offset = theClusterParam.theCluster->minPixelCol();
142 
143  // Store the coordinates of the center of the (0,0) pixel of the array that
144  // gets passed to PixelTempReco1D
145  // Will add these values to the output of PixelTempReco1D
146  float tmp_x = float(row_offset) + 0.5f;
147  float tmp_y = float(col_offset) + 0.5f;
148 
149  // Store these offsets (to be added later) in a LocalPoint after tranforming
150  // them from measurement units (pixel units) to local coordinates (cm)
151  //
152  //
153 
154  // In case of template reco failure, these are the lorentz drift corrections
155  // to be applied
156  float lorentzshiftX = 0.5f * theDetParam.lorentzShiftInCmX;
157  float lorentzshiftY = 0.5f * theDetParam.lorentzShiftInCmY;
158 
159  // ggiurgiu@jhu.edu 12/09/2010 : update call with trk angles needed for bow/kink corrections
160  LocalPoint lp;
161 
162  if (theClusterParam.with_track_angle)
163  lp = theDetParam.theTopol->localPosition(MeasurementPoint(tmp_x, tmp_y), theClusterParam.loc_trk_pred);
164  else {
165  edm::LogError("PixelCPETemplateReco") << "@SUB = PixelCPETemplateReco::localPosition"
166  << "Should never be here. PixelCPETemplateReco should always be called with "
167  "track angles. This is a bad error !!! ";
168 
169  lp = theDetParam.theTopol->localPosition(MeasurementPoint(tmp_x, tmp_y));
170  }
171 
172  // first compute matrix size
173  int mrow = 0, mcol = 0;
174  for (int i = 0; i != theClusterParam.theCluster->size(); ++i) {
175  auto pix = theClusterParam.theCluster->pixel(i);
176  int irow = int(pix.x);
177  int icol = int(pix.y);
178  mrow = std::max(mrow, irow);
179  mcol = std::max(mcol, icol);
180  }
181  mrow -= row_offset;
182  mrow += 1;
183  mrow = std::min(mrow, cluster_matrix_size_x);
184  mcol -= col_offset;
185  mcol += 1;
186  mcol = std::min(mcol, cluster_matrix_size_y);
187  assert(mrow > 0);
188  assert(mcol > 0);
189 
190  float clustMatrix[mrow][mcol];
191  memset(clustMatrix, 0, sizeof(float) * mrow * mcol);
192 
193  // Copy clust's pixels (calibrated in electrons) into clusMatrix;
194  for (int i = 0; i != theClusterParam.theCluster->size(); ++i) {
195  auto pix = theClusterParam.theCluster->pixel(i);
196  int irow = int(pix.x) - row_offset;
197  int icol = int(pix.y) - col_offset;
198 
199  // Gavril : what do we do here if the row/column is larger than cluster_matrix_size_x/cluster_matrix_size_y ?
200  // Ignore them for the moment...
201  if ((irow < mrow) & (icol < mcol))
202  clustMatrix[irow][icol] = float(pix.adc);
203  }
204 
205  // Make and fill the bool arrays flagging double pixels
206  bool xdouble[mrow], ydouble[mcol];
207  // x directions (shorter), rows
208  for (int irow = 0; irow < mrow; ++irow)
209  xdouble[irow] = theDetParam.theRecTopol->isItBigPixelInX(irow + row_offset);
210 
211  // y directions (longer), columns
212  for (int icol = 0; icol < mcol; ++icol)
213  ydouble[icol] = theDetParam.theRecTopol->isItBigPixelInY(icol + col_offset);
214 
215  SiPixelTemplateReco::ClusMatrix clusterPayload{&clustMatrix[0][0], xdouble, ydouble, mrow, mcol};
216 
217  // Output:
218  float nonsense = -99999.9f; // nonsense init value
219  theClusterParam.templXrec_ = theClusterParam.templYrec_ = theClusterParam.templSigmaX_ =
220  theClusterParam.templSigmaY_ = nonsense;
221  // If the template recontruction fails, we want to return 1.0 for now
222  theClusterParam.templProbY_ = theClusterParam.templProbX_ = theClusterParam.templProbQ_ = 1.0f;
223  theClusterParam.templQbin_ = 0;
224  // We have a boolean denoting whether the reco failed or not
225  theClusterParam.hasFilledProb_ = false;
226 
227  float templYrec1_ = nonsense;
228  float templXrec1_ = nonsense;
229  float templYrec2_ = nonsense;
230  float templXrec2_ = nonsense;
231 
232  // ******************************************************************
233  // Do it! Use cotalpha_ and cotbeta_ calculated in PixelCPEBase
234 
235  float locBz = theDetParam.bz;
236  float locBx = theDetParam.bx;
237 
238  theClusterParam.ierr = PixelTempReco1D(ID,
239  theClusterParam.cotalpha,
240  theClusterParam.cotbeta,
241  locBz,
242  locBx,
243  clusterPayload,
244  templ,
245  theClusterParam.templYrec_,
246  theClusterParam.templSigmaY_,
247  theClusterParam.templProbY_,
248  theClusterParam.templXrec_,
249  theClusterParam.templSigmaX_,
250  theClusterParam.templProbX_,
251  theClusterParam.templQbin_,
252  speed_,
253  theClusterParam.templProbQ_);
254 
255  // ******************************************************************
256 
257  // Check exit status
258  if UNLIKELY (theClusterParam.ierr != 0) {
259  LogDebug("PixelCPETemplateReco::localPosition")
260  << "reconstruction failed with error " << theClusterParam.ierr << "\n";
261 
262  // Template reco has failed, compute position estimates based on cluster center of gravity + Lorentz drift
263  // Future improvement would be to call generic reco instead
264 
265  // ggiurgiu@jhu.edu, 21/09/2010 : trk angles needed to correct for bows/kinks
266  if (theClusterParam.with_track_angle) {
267  theClusterParam.templXrec_ =
268  theDetParam.theTopol->localX(theClusterParam.theCluster->x(), theClusterParam.loc_trk_pred) + lorentzshiftX;
269  theClusterParam.templYrec_ =
270  theDetParam.theTopol->localY(theClusterParam.theCluster->y(), theClusterParam.loc_trk_pred) + lorentzshiftY;
271  } else {
272  edm::LogError("PixelCPETemplateReco") << "@SUB = PixelCPETemplateReco::localPosition"
273  << "Should never be here. PixelCPETemplateReco should always be called "
274  "with track angles. This is a bad error !!! ";
275 
276  theClusterParam.templXrec_ = theDetParam.theTopol->localX(theClusterParam.theCluster->x()) + lorentzshiftX;
277  theClusterParam.templYrec_ = theDetParam.theTopol->localY(theClusterParam.theCluster->y()) + lorentzshiftY;
278  }
279  } else if UNLIKELY (UseClusterSplitter_ && theClusterParam.templQbin_ == 0) {
280  edm::LogError("PixelCPETemplateReco") << " PixelCPETemplateReco: Qbin = 0 but using cluster splitter, we should "
281  "never be here !!!!!!!!!!!!!!!!!!!!!! \n"
282  << "(int)UseClusterSplitter_ = " << (int)UseClusterSplitter_ << endl;
283 
284  //ierr =
285  //PixelTempSplit( ID, fpix, cotalpha_, cotbeta_,
286  // clust_array_2d, ydouble, xdouble,
287  // templ,
288  // templYrec1_, templYrec2_, templSigmaY_, templProbY_,
289  // templXrec1_, templXrec2_, templSigmaX_, templProbX_,
290  // templQbin_ );
291 
292  // Commented for now (3/10/17) until we figure out how to resuscitate 2D template splitter
296 
297  theClusterParam.ierr = -123;
298  /*
299  float dchisq;
300  float templProbQ_;
301  SiPixelTemplateSplit::PixelTempSplit( ID, theClusterParam.cotalpha, theClusterParam.cotbeta,
302  clust_array_2d,
303  ydouble, xdouble,
304  templ,
305  templYrec1_, templYrec2_, theClusterParam.templSigmaY_, theClusterParam.templProbY_,
306  templXrec1_, templXrec2_, theClusterParam.templSigmaX_, theClusterParam.templProbX_,
307  theClusterParam.templQbin_,
308  templProbQ_,
309  true,
310  dchisq,
311  templ2D_ );
312 
313  */
314  if (theClusterParam.ierr != 0) {
315  // Template reco has failed, compute position estimates based on cluster center of gravity + Lorentz drift
316  // Future improvement would be to call generic reco instead
317 
318  // ggiurgiu@jhu.edu, 12/09/2010 : trk angles needed to correct for bows/kinks
319  if (theClusterParam.with_track_angle) {
320  theClusterParam.templXrec_ =
321  theDetParam.theTopol->localX(theClusterParam.theCluster->x(), theClusterParam.loc_trk_pred) + lorentzshiftX;
322  theClusterParam.templYrec_ =
323  theDetParam.theTopol->localY(theClusterParam.theCluster->y(), theClusterParam.loc_trk_pred) + lorentzshiftY;
324  } else {
325  edm::LogError("PixelCPETemplateReco") << "@SUB = PixelCPETemplateReco::localPosition"
326  << "Should never be here. PixelCPETemplateReco should always be called "
327  "with track angles. This is a bad error !!! ";
328  theClusterParam.templXrec_ = theDetParam.theTopol->localX(theClusterParam.theCluster->x()) + lorentzshiftX;
329  theClusterParam.templYrec_ = theDetParam.theTopol->localY(theClusterParam.theCluster->y()) + lorentzshiftY;
330  }
331  } else {
332  // go from micrometer to centimeter
333  templXrec1_ *= micronsToCm;
334  templYrec1_ *= micronsToCm;
335  templXrec2_ *= micronsToCm;
336  templYrec2_ *= micronsToCm;
337 
338  // go back to the module coordinate system
339  templXrec1_ += lp.x();
340  templYrec1_ += lp.y();
341  templXrec2_ += lp.x();
342  templYrec2_ += lp.y();
343 
344  // calculate distance from each hit to the track and choose the hit closest to the track
345  float distX1 = std::abs(templXrec1_ - theClusterParam.trk_lp_x);
346  float distX2 = std::abs(templXrec2_ - theClusterParam.trk_lp_x);
347  float distY1 = std::abs(templYrec1_ - theClusterParam.trk_lp_y);
348  float distY2 = std::abs(templYrec2_ - theClusterParam.trk_lp_y);
349  theClusterParam.templXrec_ = (distX1 < distX2 ? templXrec1_ : templXrec2_);
350  theClusterParam.templYrec_ = (distY1 < distY2 ? templYrec1_ : templYrec2_);
351  }
352  } // else if ( UseClusterSplitter_ && templQbin_ == 0 )
353 
354  else // apparenly this is the good one!
355  {
356  // go from micrometer to centimeter
357  theClusterParam.templXrec_ *= micronsToCm;
358  theClusterParam.templYrec_ *= micronsToCm;
359 
360  // go back to the module coordinate system
361  theClusterParam.templXrec_ += lp.x();
362  theClusterParam.templYrec_ += lp.y();
363 
364  // Compute the Alignment Group Corrections [template ID should already be selected from call to reco procedure]
366  // Do only if the lotentzshift has meaningfull numbers
367  if (theDetParam.lorentzShiftInCmX != 0.0 || theDetParam.lorentzShiftInCmY != 0.0) {
368  // the LA width/shift returned by templates use (+)
369  // the LA width/shift produced by PixelCPEBase for positive LA is (-)
370  // correct this by iserting (-)
371  //float temp1 = -micronsToCm*templ.lorxwidth(); // old
372  //float temp2 = -micronsToCm*templ.lorywidth(); // does not incl 1/2
373  float templateLorbiasCmX = -micronsToCm * templ.lorxbias(); // new
374  float templateLorbiasCmY = -micronsToCm * templ.lorybias(); //incl. 1/2
375  // now, correctly, we can use the difference of shifts
376  //theClusterParam.templXrec_ += 0.5*(theDetParam.lorentzShiftInCmX - templateLorbiasCmX);
377  //theClusterParam.templYrec_ += 0.5*(theDetParam.lorentzShiftInCmY - templateLorbiasCmY);
378  theClusterParam.templXrec_ += (0.5 * (theDetParam.lorentzShiftInCmX) - templateLorbiasCmX);
379  theClusterParam.templYrec_ += (0.5 * (theDetParam.lorentzShiftInCmY) - templateLorbiasCmY);
380  //cout << "Templates: la lorentz offset = "
381  // <<(0.5*(theDetParam.lorentzShiftInCmX)-templateLorbiasCmX)
382  // <<" "<<templateLorbiasCmX<<" "<<templateLorbiasCmY
383  // <<" "<<temp1<<" "<<temp2
384  // <<" "<<theDetParam.lorentzShiftInCmX
385  // <<" "<<theDetParam.lorentzShiftInCmY
386  // << endl; //dk
387  } //else {cout<<" LA is 0, disable offset corrections "<<endl;} //dk
388  } //else {cout<<" Do not do LA offset correction "<<endl;} //dk
389  }
390 
391  // Save probabilities and qBin in the quantities given to us by the base class
392  // (for which there are also inline getters). &&& templProbX_ etc. should be retired...
393  theClusterParam.probabilityX_ = theClusterParam.templProbX_;
394  theClusterParam.probabilityY_ = theClusterParam.templProbY_;
395  theClusterParam.probabilityQ_ = theClusterParam.templProbQ_;
396  theClusterParam.qBin_ = theClusterParam.templQbin_;
397 
398  if (theClusterParam.ierr == 0) // always true here
399  theClusterParam.hasFilledProb_ = true;
400 
401  return LocalPoint(theClusterParam.templXrec_, theClusterParam.templYrec_);
402 }
Point3DBase< Scalar, LocalTag > LocalPoint
Definition: Definitions.h:30
const std::vector< SiPixelTemplateStore > * thePixelTemp_
uint32_t ID
Definition: Definitions.h:24
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 doLorentzFromAlignment_
Definition: PixelCPEBase.h:242
Log< level::Error, false > LogError
assert(be >=bs)
T x() const
Definition: PV3DBase.h:59
T y() const
Definition: PV3DBase.h:60
Measurement2DPoint MeasurementPoint
Measurement points are two-dimensional by default.
bool LoadTemplatesFromDB_
Definition: PixelCPEBase.h:243
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
const SiPixelTemplateDBObject * templateDBobject_
Definition: PixelCPEBase.h:237
bool isEndcap(GeomDetEnumerators::SubDetector m)
short getTemplateID(const uint32_t &detid) const
#define UNLIKELY(x)
Definition: Likely.h:21
bool isTrackerPixel(GeomDetEnumerators::SubDetector m)
#define LogDebug(id)

Member Data Documentation

◆ barrelTemplateID_

int PixelCPETemplateReco::barrelTemplateID_
private

Definition at line 86 of file PixelCPETemplateReco.h.

Referenced by localPosition(), and PixelCPETemplateReco().

◆ forwardTemplateID_

int PixelCPETemplateReco::forwardTemplateID_
private

Definition at line 87 of file PixelCPETemplateReco.h.

Referenced by localPosition(), and PixelCPETemplateReco().

◆ speed_

int PixelCPETemplateReco::speed_
private

Definition at line 81 of file PixelCPETemplateReco.h.

Referenced by localPosition(), and PixelCPETemplateReco().

◆ templateDir_

std::string PixelCPETemplateReco::templateDir_
private

Definition at line 88 of file PixelCPETemplateReco.h.

Referenced by PixelCPETemplateReco().

◆ thePixelTemp_

const std::vector<SiPixelTemplateStore>* PixelCPETemplateReco::thePixelTemp_
private

Definition at line 79 of file PixelCPETemplateReco.h.

Referenced by localPosition(), and PixelCPETemplateReco().

◆ thePixelTempCache_

std::vector<SiPixelTemplateStore> PixelCPETemplateReco::thePixelTempCache_
private

Definition at line 78 of file PixelCPETemplateReco.h.

Referenced by PixelCPETemplateReco().

◆ UseClusterSplitter_

bool PixelCPETemplateReco::UseClusterSplitter_
private

Definition at line 83 of file PixelCPETemplateReco.h.

Referenced by localPosition(), and PixelCPETemplateReco().