CMS 3D CMS Logo

List of all members | Classes | 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 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 ()
 

Private Member Functions

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 speed_
 
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
typedef GloballyPositioned< double > Frame
 
- 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_
 
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 34 of file PixelCPETemplateReco.h.

Constructor & Destructor Documentation

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

Definition at line 43 of file PixelCPETemplateReco.cc.

References Exception, edm::ParameterSet::getParameter(), PixelCPEBase::LoadTemplatesFromDB_, LogDebug, SiPixelTemplate::pushfile(), speed_, PixelCPEBase::templateDBobject_, thePixelTemp_, and UseClusterSplitter_.

49 : PixelCPEBase(conf, mag, geom, ttopo, lorentzAngle, nullptr, templateDBobject, nullptr,1)
50 {
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  {
66  //cout << "PixelCPETemplateReco: Loading templates from database (DB) --------- " << endl;
67 
68  // Initialize template store to the selected ID [Morris, 6/25/08]
70  throw cms::Exception("PixelCPETemplateReco")
71  << "\nERROR: Templates not filled correctly. Check the sqlite file. Using SiPixelTemplateDBObject version "
72  << (*templateDBobject_).version() << "\n\n";
73  }
74  else
75  {
76  //cout << "PixelCPETemplateReco : Loading templates 40 and 41 from ASCII files ------------------------" << endl;
77 
79  throw cms::Exception("PixelCPETemplateReco")
80  << "\nERROR: Templates 40 not loaded correctly from text file. Reconstruction will fail.\n\n";
81 
83  throw cms::Exception("PixelCPETemplateReco")
84  << "\nERROR: Templates 41 not loaded correctly from text file. Reconstruction will fail.\n\n";
85  }
86 
87  speed_ = conf.getParameter<int>( "speed");
88  LogDebug("PixelCPETemplateReco::PixelCPETemplateReco:") <<
89  "Template speed = " << speed_ << "\n";
90 
91  UseClusterSplitter_ = conf.getParameter<bool>("UseClusterSplitter");
92 
93 }
#define LogDebug(id)
static bool pushfile(int filenum, std::vector< SiPixelTemplateStore > &thePixelTemp_)
std::vector< SiPixelTemplateStore > thePixelTemp_
bool LoadTemplatesFromDB_
Definition: PixelCPEBase.h:253
const SiPixelTemplateDBObject * templateDBobject_
Definition: PixelCPEBase.h:249
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
PixelCPETemplateReco::~PixelCPETemplateReco ( )
override

Definition at line 98 of file PixelCPETemplateReco.cc.

References thePixelTemp_, and x.

99 {
100  for(auto x : thePixelTemp_) x.destroy();
101 }
std::vector< SiPixelTemplateStore > thePixelTemp_

Member Function Documentation

PixelCPEBase::ClusterParam * PixelCPETemplateReco::createClusterParam ( const SiPixelCluster cl) const
overrideprivatevirtual

Implements PixelCPEBase.

Definition at line 103 of file PixelCPETemplateReco.cc.

104 {
105  return new ClusterParamTemplate(cl);
106 }
LocalError PixelCPETemplateReco::localError ( DetParam const &  theDetParam,
ClusterParam theClusterParam 
) const
overrideprivatevirtual

Implements PixelCPEBase.

Definition at line 431 of file PixelCPETemplateReco.cc.

References 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, and PixelCPEBase::theVerboseLevel.

432 {
433 
434  ClusterParamTemplate & theClusterParam = static_cast<ClusterParamTemplate &>(theClusterParamBase);
435 
436  //cout << endl;
437  //cout << "Set PixelCPETemplate errors .............................................." << endl;
438 
439  //cout << "CPETemplate : " << endl;
440 
441  //--- Default is the maximum error used for edge clusters.
442  //--- (never used, in fact: let comment it out, shut up the complains of the static analyzer, and save a few CPU cycles)
443  // const float sig12 = 1./sqrt(12.0);
444  // float xerr = theDetParam.thePitchX *sig12;
445  // float yerr = theDetParam.thePitchY *sig12;
446  float xerr, yerr;
447 
448  // Check if the errors were already set at the clusters splitting level
449  if ( theClusterParam.theCluster->getSplitClusterErrorX() > 0.0f && theClusterParam.theCluster->getSplitClusterErrorX() < 7777.7f &&
450  theClusterParam.theCluster->getSplitClusterErrorY() > 0.0f && theClusterParam.theCluster->getSplitClusterErrorY() < 7777.7f )
451  {
452  xerr = theClusterParam.theCluster->getSplitClusterErrorX() * micronsToCm;
453  yerr = theClusterParam.theCluster->getSplitClusterErrorY() * micronsToCm;
454 
455  //cout << "Errors set at cluster splitting level : " << endl;
456  //cout << "xerr = " << xerr << endl;
457  //cout << "yerr = " << yerr << endl;
458  }
459  else
460  {
461  // If errors are not split at the cluster splitting level, set the errors here
462 
463  //cout << "Errors are not split at the cluster splitting level, set the errors here : " << endl;
464 
465  int maxPixelCol = theClusterParam.theCluster->maxPixelCol();
466  int maxPixelRow = theClusterParam.theCluster->maxPixelRow();
467  int minPixelCol = theClusterParam.theCluster->minPixelCol();
468  int minPixelRow = theClusterParam.theCluster->minPixelRow();
469 
470  //--- Are we near either of the edges?
471  bool edgex = ( theDetParam.theRecTopol->isItEdgePixelInX( minPixelRow ) || theDetParam.theRecTopol->isItEdgePixelInX( maxPixelRow ) );
472  bool edgey = ( theDetParam.theRecTopol->isItEdgePixelInY( minPixelCol ) || theDetParam.theRecTopol->isItEdgePixelInY( maxPixelCol ) );
473 
474  if ( theClusterParam.ierr !=0 )
475  {
476  // If reconstruction fails the hit position is calculated from cluster center of gravity
477  // corrected in x by average Lorentz drift. Assign huge errors.
478  //xerr = 10.0 * (float)theClusterParam.theCluster->sizeX() * xerr;
479  //yerr = 10.0 * (float)theClusterParam.theCluster->sizeX() * yerr;
480 
481  if(!GeomDetEnumerators::isTrackerPixel(theDetParam.thePart))
482  throw cms::Exception("PixelCPETemplateReco::localPosition :")
483  << "A non-pixel detector type in here?";
484 
485  // Assign better errors based on the residuals for failed template cases
486  if ( GeomDetEnumerators::isBarrel(theDetParam.thePart) )
487  {
488  xerr = 55.0f * micronsToCm;
489  yerr = 36.0f * micronsToCm;
490  }
491  else
492  {
493  xerr = 42.0f * micronsToCm;
494  yerr = 39.0f * micronsToCm;
495  }
496 
497  //cout << "xerr = " << xerr << endl;
498  //cout << "yerr = " << yerr << endl;
499 
500  //return LocalError(xerr*xerr, 0, yerr*yerr);
501  }
502  else if ( edgex || edgey )
503  {
504  // for edge pixels assign errors according to observed residual RMS
505  if ( edgex && !edgey )
506  {
507  xerr = 23.0f * micronsToCm;
508  yerr = 39.0f * micronsToCm;
509  }
510  else if ( !edgex && edgey )
511  {
512  xerr = 24.0f * micronsToCm;
513  yerr = 96.0f * micronsToCm;
514  }
515  else if ( edgex && edgey )
516  {
517  xerr = 31.0f * micronsToCm;
518  yerr = 90.0f * micronsToCm;
519  }
520  else
521  {
522  throw cms::Exception(" PixelCPETemplateReco::localError: Something wrong with pixel edge flag !!!");
523  }
524 
525  //cout << "xerr = " << xerr << endl;
526  //cout << "yerr = " << yerr << endl;
527  }
528  else
529  {
530  // &&& need a class const
531  //const float micronsToCm = 1.0e-4;
532 
533  xerr = theClusterParam.templSigmaX_ * micronsToCm;
534  yerr = theClusterParam.templSigmaY_ * micronsToCm;
535 
536  //cout << "xerr = " << xerr << endl;
537  //cout << "yerr = " << yerr << endl;
538 
539  // &&& should also check ierr (saved as class variable) and return
540  // &&& nonsense (another class static) if the template fit failed.
541  }
542 
543  if (theVerboseLevel > 9)
544  {
545  LogDebug("PixelCPETemplateReco") <<
546  " Sizex = " << theClusterParam.theCluster->sizeX() << " Sizey = " << theClusterParam.theCluster->sizeY() << " Edgex = " << edgex << " Edgey = " << edgey <<
547  " ErrX = " << xerr << " ErrY = " << yerr;
548  }
549 
550  } // else
551 
552  if ( !(xerr > 0.0f) )
553  throw cms::Exception("PixelCPETemplateReco::localError")
554  << "\nERROR: Negative pixel error xerr = " << xerr << "\n\n";
555 
556  if ( !(yerr > 0.0f) )
557  throw cms::Exception("PixelCPETemplateReco::localError")
558  << "\nERROR: Negative pixel error yerr = " << yerr << "\n\n";
559 
560  //cout << "Final errors set to: " << endl;
561  //cout << "xerr = " << xerr << endl;
562  //cout << "yerr = " << yerr << endl;
563  //cout << "Out of PixelCPETemplateREco..........................................................................." << endl;
564  //cout << endl;
565 
566  return LocalError(xerr*xerr, 0, yerr*yerr);
567 }
#define LogDebug(id)
bool isBarrel(GeomDetEnumerators::SubDetector m)
double f[11][100]
bool isTrackerPixel(GeomDetEnumerators::SubDetector m)
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 117 of file PixelCPETemplateReco.cc.

References funct::abs(), PixelCPEBase::DetParam::bx, PixelCPEBase::DetParam::bz, gather_cfg::cout, PixelCPEBase::DetParam::detTemplateId, PixelCPEBase::DoLorentz_, objects.autophobj::float, 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, min(), SiPixelTemplateReco::PixelTempReco2D(), 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, create_public_lumi_plots::tmp_x, create_public_lumi_plots::tmp_y, unlikely, UseClusterSplitter_, PV3DBase< T, PVType, FrameType >::x(), and PV3DBase< T, PVType, FrameType >::y().

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

Member Data Documentation

int PixelCPETemplateReco::speed_
private

Definition at line 78 of file PixelCPETemplateReco.h.

Referenced by localPosition(), and PixelCPETemplateReco().

std::vector< SiPixelTemplateStore > PixelCPETemplateReco::thePixelTemp_
private
bool PixelCPETemplateReco::UseClusterSplitter_
private

Definition at line 80 of file PixelCPETemplateReco.h.

Referenced by localPosition(), and PixelCPETemplateReco().