CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Protected Member Functions | Private Attributes
PixelCPETemplateReco Class Reference

#include <PixelCPETemplateReco.h>

Inheritance diagram for PixelCPETemplateReco:
PixelCPEBase PixelClusterParameterEstimator ClusterParameterEstimator< SiPixelCluster >

Public Member Functions

LocalError localError (const SiPixelCluster &cl, const GeomDetUnit &det) const
 
LocalPoint localPosition (const SiPixelCluster &cluster, const GeomDetUnit &det) const
 
 PixelCPETemplateReco (edm::ParameterSet const &conf, const MagneticField *, const SiPixelLorentzAngle *, const SiPixelTemplateDBObject *)
 
 ~PixelCPETemplateReco ()
 
- Public Member Functions inherited from PixelCPEBase
unsigned int clusterProbComputationFlag () const
 
void computeAnglesFromDetPosition (const SiPixelCluster &cl, const GeomDetUnit &det) const
 
bool hasBadPixels () const
 
bool hasFilledProb () const
 
bool isOnEdge () const
 
LocalValues localParameters (const SiPixelCluster &cl, const GeomDetUnit &det) const
 
LocalValues localParameters (const SiPixelCluster &cl, const GeomDetUnit &det, const LocalTrajectoryParameters &ltp) const
 
LocalValues localParameters (const SiPixelCluster &cl, const GeomDetUnit &det, float alpha, float beta) const
 
 PixelCPEBase (edm::ParameterSet const &conf, const MagneticField *mag=0, const SiPixelLorentzAngle *lorentzAngle=0, const SiPixelCPEGenericErrorParm *genErrorParm=0, const SiPixelTemplateDBObject *templateDBobject=0)
 
float probabilityQ () const
 
float probabilityX () const
 
float probabilityXY () const
 
float probabilityY () const
 
float qBin () const
 
SiPixelRecHitQuality::QualWordType rawQualityWord () const
 
void setMagField (const MagneticField *mag) const
 
bool spansTwoRocks () const
 
- Public Member Functions inherited from PixelClusterParameterEstimator
unsigned int clusterProbComputationFlag () const
 
 PixelClusterParameterEstimator ()
 
- Public Member Functions inherited from ClusterParameterEstimator< SiPixelCluster >
virtual void clearParameters () const
 
virtual void enterLocalParameters (unsigned int id, std::pair< int, int > &row_col, LocalValues pos_err_info) const
 
virtual void enterLocalParameters (uint32_t id, uint16_t firstStrip, LocalValues pos_err_info) const
 
virtual LocalValues localParameters (const SiPixelCluster &cluster, const GeomDetUnit &gd, const TrajectoryStateOnSurface &tsos) const
 
virtual VLocalValues localParametersV (const SiPixelCluster &cluster, const GeomDetUnit &gd) const
 
virtual VLocalValues localParametersV (const SiPixelCluster &cluster, const GeomDetUnit &gd, const TrajectoryStateOnSurface &tsos) const
 
virtual ~ClusterParameterEstimator ()
 

Protected Member Functions

float xpos (const SiPixelCluster &) const
 
float ypos (const SiPixelCluster &) const
 
- Protected Member Functions inherited from PixelCPEBase
void computeAnglesFromTrajectory (const SiPixelCluster &cl, const GeomDetUnit &det, const LocalTrajectoryParameters &ltp) const
 
void computeLorentzShifts () const
 
LocalVector driftDirection (GlobalVector bfield) const
 
LocalVector driftDirection (LocalVector bfield) const
 
LocalVector driftDirectionCorrect (GlobalVector bfield) const
 
LocalVector const & getDrift () const
 
bool isFlipped () const
 
float lorentzShiftX () const
 
float lorentzShiftY () const
 
MeasurementError measurementError (const SiPixelCluster &, const GeomDetUnit &det) const
 
MeasurementPoint measurementPosition (const SiPixelCluster &cluster, const GeomDetUnit &det) const
 
Param const & param () const
 
void setTheDet (const GeomDetUnit &det, const SiPixelCluster &cluster) const
 

Private Attributes

bool DoCosmics_
 
int ierr
 
bool LoadTemplatesFromDB_
 
int speed_
 
SiPixelTemplate templ_
 
int templID_
 
float templProbQ_
 
float templProbX_
 
float templProbY_
 
int templQbin_
 
float templSigmaX_
 
float templSigmaY_
 
float templXrec_
 
float templYrec_
 
bool UseClusterSplitter_
 

Additional Inherited Members

- Public Types inherited from ClusterParameterEstimator< SiPixelCluster >
typedef std::pair< LocalPoint,
LocalError
LocalValues
 
typedef std::vector< LocalValuesVLocalValues
 
- Protected Types inherited from PixelCPEBase
typedef GloballyPositioned
< double > 
Frame
 
- Protected Attributes inherited from PixelCPEBase
bool alpha2Order
 
float alpha_
 
float beta_
 
unsigned int clusterProbComputationFlag_
 
float cotalpha_
 
float cotbeta_
 
LocalVector driftDirection_
 
const SiPixelCPEGenericErrorParmgenErrorParm_
 
bool hasBadPixels_
 
bool hasFilledProb_
 
bool isOnEdge_
 
LocalTrajectoryParameters loc_traj_param_
 
Topology::LocalTrackPred loc_trk_pred_
 
const SiPixelLorentzAnglelorentzAngle_
 
double lorentzShiftInCmX_
 
double lorentzShiftInCmY_
 
double lorentzShiftX_
 
double lorentzShiftY_
 
const MagneticFieldmagfield_
 
int nRecHitsTotal_
 
int nRecHitsUsedEdge_
 
float probabilityQ_
 
float probabilityX_
 
float probabilityY_
 
float qBin_
 
bool spansTwoROCs_
 
const SiPixelTemplateDBObjecttemplateDBobject_
 
const PixelGeomDetUnittheDet
 
float theDetR
 
float theDetZ
 
float theLShiftX
 
float theLShiftY
 
float theNumOfCol
 
float theNumOfRow
 
Param const * theParam
 
GeomDetType::SubDetector thePart
 
float thePitchX
 
float thePitchY
 
const RectangularPixelTopology * theRecTopol
 
float theSign
 
float theThickness
 
const PixelTopologytheTopol
 
int theVerboseLevel
 
float trk_lp_x
 
float trk_lp_y
 
bool with_track_angle
 
- 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 SiPixelLorentzAngle lorentzAngle,
const SiPixelTemplateDBObject templateDBobject 
)

Definition at line 46 of file PixelCPETemplateReco.cc.

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

49  : PixelCPEBase(conf, mag, lorentzAngle, 0, templateDBobject)
50 {
51  //cout << endl;
52  //cout << "Constructing PixelCPETemplateReco::PixelCPETemplateReco(...)................................................." << endl;
53  //cout << endl;
54 
55  // &&& initialize the templates, etc.
56 
57  //-- Use Magnetic field at (0,0,0) to select a template ID [Morris, 6/25/08] (temporary until we implement DB access)
58 
59  DoCosmics_ = conf.getParameter<bool>("DoCosmics");
60  LoadTemplatesFromDB_ = conf.getParameter<bool>("LoadTemplatesFromDB");
61  //cout << " PixelCPETemplateReco : (int)LoadTemplatesFromDB_ = " << (int)LoadTemplatesFromDB_ << endl;
62  //cout << "field_magnitude = " << field_magnitude << endl;
63 
64  // ggiurgiu@fnal.gov, 12/17/2008: use configuration parameter to decide between DB or text file template access
65  if ( LoadTemplatesFromDB_ )
66  {
67  //cout << "PixelCPETemplateReco: Loading templates from database (DB) ------------------------------- " << endl;
68 
69  // Initialize template store to the selected ID [Morris, 6/25/08]
71  throw cms::Exception("PixelCPETemplateReco")
72  << "\nERROR: Templates not filled correctly. Check the sqlite file. Using SiPixelTemplateDBObject version "
73  << (*templateDBobject_).version() << "\n\n";
74  }
75  else
76  {
77  //cout << "PixelCPETemplateReco : Loading templates 40 and 41 from ASCII files ------------------------" << endl;
78 
79  if ( !templ_.pushfile( 40 ) )
80  throw cms::Exception("PixelCPETemplateReco")
81  << "\nERROR: Templates 40 not loaded correctly from text file. Reconstruction will fail.\n\n";
82 
83  if ( !templ_.pushfile( 41 ) )
84  throw cms::Exception("PixelCPETemplateReco")
85  << "\nERROR: Templates 41 not loaded correctly from text file. Reconstruction will fail.\n\n";
86  }
87 
88  speed_ = conf.getParameter<int>( "speed");
89  LogDebug("PixelCPETemplateReco::PixelCPETemplateReco:") <<
90  "Template speed = " << speed_ << "\n";
91 
92  UseClusterSplitter_ = conf.getParameter<bool>("UseClusterSplitter");
93 
94 }
#define LogDebug(id)
PixelCPEBase(edm::ParameterSet const &conf, const MagneticField *mag=0, const SiPixelLorentzAngle *lorentzAngle=0, const SiPixelCPEGenericErrorParm *genErrorParm=0, const SiPixelTemplateDBObject *templateDBobject=0)
Definition: PixelCPEBase.cc:45
const SiPixelTemplateDBObject * templateDBobject_
Definition: PixelCPEBase.h:269
tuple conf
Definition: dbtoconf.py:185
bool pushfile(int filenum)
PixelCPETemplateReco::~PixelCPETemplateReco ( )

Definition at line 99 of file PixelCPETemplateReco.cc.

100 {
101  // &&& delete template store?
102 }

Member Function Documentation

LocalError PixelCPETemplateReco::localError ( const SiPixelCluster cl,
const GeomDetUnit det 
) const
virtual

Implements PixelCPEBase.

Definition at line 469 of file PixelCPETemplateReco.cc.

References edm::hlt::Exception, f, SiPixelCluster::getSplitClusterErrorX(), SiPixelCluster::getSplitClusterErrorY(), ierr, LogDebug, SiPixelCluster::maxPixelCol(), SiPixelCluster::maxPixelRow(), micronsToCm, SiPixelCluster::minPixelCol(), SiPixelCluster::minPixelRow(), GeomDetEnumerators::PixelBarrel, GeomDetEnumerators::PixelEndcap, PixelCPEBase::setTheDet(), SiPixelCluster::sizeX(), SiPixelCluster::sizeY(), mathSSE::sqrt(), templSigmaX_, templSigmaY_, PixelCPEBase::thePart, PixelCPEBase::thePitchX, PixelCPEBase::thePitchY, PixelCPEBase::theRecTopol, and PixelCPEBase::theVerboseLevel.

471 {
472  //cout << endl;
473  //cout << "Set PixelCPETemplate errors .............................................." << endl;
474 
475  //cout << "CPETemplate : " << endl;
476 
477  //--- Default is the maximum error used for edge clusters.
478  const float sig12 = 1./sqrt(12.0);
479  float xerr = thePitchX *sig12;
480  float yerr = thePitchY *sig12;
481 
482  // Check if the errors were already set at the clusters splitting level
483  if ( cluster.getSplitClusterErrorX() > 0.0f && cluster.getSplitClusterErrorX() < 7777.7f &&
484  cluster.getSplitClusterErrorY() > 0.0f && cluster.getSplitClusterErrorY() < 7777.7f )
485  {
486  xerr = cluster.getSplitClusterErrorX() * micronsToCm;
487  yerr = cluster.getSplitClusterErrorY() * micronsToCm;
488 
489  //cout << "Errors set at cluster splitting level : " << endl;
490  //cout << "xerr = " << xerr << endl;
491  //cout << "yerr = " << yerr << endl;
492  }
493  else
494  {
495  // If errors are not split at the cluster splitting level, set the errors here
496 
497  //cout << "Errors are not split at the cluster splitting level, set the errors here : " << endl;
498 
499  setTheDet( det, cluster );
500 
501  int maxPixelCol = cluster.maxPixelCol();
502  int maxPixelRow = cluster.maxPixelRow();
503  int minPixelCol = cluster.minPixelCol();
504  int minPixelRow = cluster.minPixelRow();
505 
506  //--- Are we near either of the edges?
507  bool edgex = ( theRecTopol->isItEdgePixelInX( minPixelRow ) || theRecTopol->isItEdgePixelInX( maxPixelRow ) );
508  bool edgey = ( theRecTopol->isItEdgePixelInY( minPixelCol ) || theRecTopol->isItEdgePixelInY( maxPixelCol ) );
509 
510  if ( ierr !=0 )
511  {
512  // If reconstruction fails the hit position is calculated from cluster center of gravity
513  // corrected in x by average Lorentz drift. Assign huge errors.
514  //xerr = 10.0 * (float)cluster.sizeX() * xerr;
515  //yerr = 10.0 * (float)cluster.sizeX() * yerr;
516 
517  // Assign better errors based on the residuals for failed template cases
519  {
520  xerr = 55.0f * micronsToCm;
521  yerr = 36.0f * micronsToCm;
522  }
524  {
525  xerr = 42.0f * micronsToCm;
526  yerr = 39.0f * micronsToCm;
527  }
528  else
529  throw cms::Exception("PixelCPETemplateReco::localError :") << "A non-pixel detector type in here?" ;
530 
531  //cout << "xerr = " << xerr << endl;
532  //cout << "yerr = " << yerr << endl;
533 
534  //return LocalError(xerr*xerr, 0, yerr*yerr);
535  }
536  else if ( edgex || edgey )
537  {
538  // for edge pixels assign errors according to observed residual RMS
539  if ( edgex && !edgey )
540  {
541  xerr = 23.0f * micronsToCm;
542  yerr = 39.0f * micronsToCm;
543  }
544  else if ( !edgex && edgey )
545  {
546  xerr = 24.0f * micronsToCm;
547  yerr = 96.0f * micronsToCm;
548  }
549  else if ( edgex && edgey )
550  {
551  xerr = 31.0f * micronsToCm;
552  yerr = 90.0f * micronsToCm;
553  }
554  else
555  {
556  throw cms::Exception(" PixelCPETemplateReco::localError: Something wrong with pixel edge flag !!!");
557  }
558 
559  //cout << "xerr = " << xerr << endl;
560  //cout << "yerr = " << yerr << endl;
561  }
562  else
563  {
564  // &&& need a class const
565  //const float micronsToCm = 1.0e-4;
566 
567  xerr = templSigmaX_ * micronsToCm;
568  yerr = templSigmaY_ * micronsToCm;
569 
570  //cout << "xerr = " << xerr << endl;
571  //cout << "yerr = " << yerr << endl;
572 
573  // &&& should also check ierr (saved as class variable) and return
574  // &&& nonsense (another class static) if the template fit failed.
575  }
576 
577  if (theVerboseLevel > 9)
578  {
579  LogDebug("PixelCPETemplateReco") <<
580  " Sizex = " << cluster.sizeX() << " Sizey = " << cluster.sizeY() << " Edgex = " << edgex << " Edgey = " << edgey <<
581  " ErrX = " << xerr << " ErrY = " << yerr;
582  }
583 
584  } // else
585 
586  if ( !(xerr > 0.0f) )
587  throw cms::Exception("PixelCPETemplateReco::localError")
588  << "\nERROR: Negative pixel error xerr = " << xerr << "\n\n";
589 
590  if ( !(yerr > 0.0f) )
591  throw cms::Exception("PixelCPETemplateReco::localError")
592  << "\nERROR: Negative pixel error yerr = " << yerr << "\n\n";
593 
594  //cout << "Final errors set to: " << endl;
595  //cout << "xerr = " << xerr << endl;
596  //cout << "yerr = " << yerr << endl;
597  //cout << "Out of PixelCPETemplateREco..........................................................................." << endl;
598  //cout << endl;
599 
600  return LocalError(xerr*xerr, 0, yerr*yerr);
601 }
#define LogDebug(id)
const float micronsToCm
GeomDetType::SubDetector thePart
Definition: PixelCPEBase.h:194
T sqrt(T t)
Definition: SSEVec.h:48
double f[11][100]
const RectangularPixelTopology * theRecTopol
Definition: PixelCPEBase.h:190
void setTheDet(const GeomDetUnit &det, const SiPixelCluster &cluster) const
Definition: PixelCPEBase.cc:89
LocalPoint PixelCPETemplateReco::localPosition ( const SiPixelCluster cluster,
const GeomDetUnit det 
) const
virtual

Reimplemented from PixelCPEBase.

Definition at line 114 of file PixelCPETemplateReco.cc.

References SiPixelCluster::Pixel::adc, cluster_matrix_size_x, cluster_matrix_size_y, PixelCPEBase::cotalpha_, PixelCPEBase::cotbeta_, gather_cfg::cout, edm::hlt::Exception, GeomDet::geographicalId(), SiPixelTemplateDBObject::getTemplateID(), PixelCPEBase::hasFilledProb_, i, ierr, LoadTemplatesFromDB_, PixelCPEBase::loc_trk_pred_, Topology::localPosition(), PixelTopology::localX(), PixelTopology::localY(), LogDebug, micronsToCm, SiPixelCluster::minPixelCol(), SiPixelCluster::minPixelRow(), SiPixelCluster::pixel(), GeomDetEnumerators::PixelBarrel, GeomDetEnumerators::PixelEndcap, SiPixelTemplateReco::PixelTempReco2D(), SiPixelTemplateSplit::PixelTempSplit(), PixelCPEBase::probabilityQ_, PixelCPEBase::probabilityX_, PixelCPEBase::probabilityY_, SiPixelTemplate2D::pushfile(), PixelCPEBase::qBin_, PixelCPEBase::setTheDet(), SiPixelCluster::size(), speed_, mathSSE::sqrt(), templ_, PixelCPEBase::templateDBobject_, templProbQ_, templProbX_, templProbY_, templQbin_, templSigmaX_, templSigmaY_, templXrec_, templYrec_, PixelCPEBase::theDet, PixelCPEBase::thePart, PixelCPEBase::theRecTopol, PixelCPEBase::theTopol, create_public_lumi_plots::tmp_x, create_public_lumi_plots::tmp_y, PixelCPEBase::trk_lp_x, PixelCPEBase::trk_lp_y, unlikely, UseClusterSplitter_, PixelCPEBase::with_track_angle, PV3DBase< T, PVType, FrameType >::x(), SiPixelCluster::x(), PV3DBase< T, PVType, FrameType >::y(), and SiPixelCluster::y().

115 {
116  setTheDet( det, cluster );
117 
118  bool fpix; // barrel(false) or forward(true)
120  fpix = false; // no, it's not forward -- it's barrel
121  else
122  fpix = true; // yes, it's forward
123 
124  int ID = -9999;
125 
126  if ( LoadTemplatesFromDB_ )
127  {
129  }
130  else
131  {
132  if ( !fpix )
133  ID = 40; // barrel
134  else
135  ID = 41; // endcap
136  }
137 
138  //cout << "PixelCPETemplateReco : ID = " << ID << endl;
139 
140 
141  // Make from cluster (a SiPixelCluster) a boost multi_array_2d called
142  // clust_array_2d.
143  boost::multi_array<float, 2> clust_array_2d(boost::extents[cluster_matrix_size_x][cluster_matrix_size_y]);
144 
145  // Preparing to retrieve ADC counts from the SiPixelCluster. In the cluster,
146  // we have the following:
147  // int minPixelRow(); // Minimum pixel index in the x direction (low edge).
148  // int maxPixelRow(); // Maximum pixel index in the x direction (top edge).
149  // int minPixelCol(); // Minimum pixel index in the y direction (left edge).
150  // int maxPixelCol(); // Maximum pixel index in the y direction (right edge).
151  // So the pixels from minPixelRow() will go into clust_array_2d[0][*],
152  // and the pixels from minPixelCol() will go into clust_array_2d[*][0].
153 
154  int row_offset = cluster.minPixelRow();
155  int col_offset = cluster.minPixelCol();
156 
157  // Store the coordinates of the center of the (0,0) pixel of the array that
158  // gets passed to PixelTempReco2D
159  // Will add these values to the output of PixelTempReco2D
160  float tmp_x = float(row_offset) + 0.5f;
161  float tmp_y = float(col_offset) + 0.5f;
162 
163  // Store these offsets (to be added later) in a LocalPoint after tranforming
164  // them from measurement units (pixel units) to local coordinates (cm)
165 
166  // ggiurgiu@jhu.edu 12/09/2010 : update call with trk angles needed for bow/kink corrections
167  LocalPoint lp;
168 
169  if ( with_track_angle )
170  lp = theTopol->localPosition( MeasurementPoint(tmp_x, tmp_y), loc_trk_pred_ );
171  else
172  {
173  edm::LogError("PixelCPETemplateReco")
174  << "@SUB = PixelCPETemplateReco::localPosition"
175  << "Should never be here. PixelCPETemplateReco should always be called with track angles. This is a bad error !!! ";
176 
177  lp = theTopol->localPosition( MeasurementPoint(tmp_x, tmp_y) );
178  }
179 
180 
181  // Visualize large clusters ---------------------------------------------------------
182  // From Petar: maybe this should be moved into a method in the base class?
183  /*
184  char cluster_matrix[100][100];
185  for (int i=0; i<100; i++)
186  for (int j=0; j<100; j++)
187  cluster_matrix[i][j] = '.';
188 
189  if ( cluster.sizeX()>cluster_matrix_size_x || cluster.sizeY()>cluster_matrix_size_y )
190  {
191  cout << "cluster.size() = " << cluster.size() << endl;
192  cout << "cluster.sizeX() = " << cluster.sizeX() << endl;
193  cout << "cluster.sizeY() = " << cluster.sizeY() << endl;
194 
195  for ( std::vector<SiPixelCluster::Pixel>::const_iterator pix = pixVec.begin(); pix != pixVec.end(); ++pix )
196  {
197  int i = (int)(pix->x) - row_offset;
198  int j = (int)(pix->y) - col_offset;
199  cluster_matrix[i][j] = '*';
200  }
201 
202  for (int i=0; i<(int)cluster.sizeX()+2; i++)
203  {
204  for (int j=0; j<(int)cluster.sizeY()+2; j++)
205  cout << cluster_matrix[i][j];
206  cout << endl;
207  }
208  } // if ( cluster.sizeX()>cluster_matrix_size_x || cluster.sizeY()>cluster_matrix_size_y )
209  */
210  // End Visualize clusters ---------------------------------------------------------
211 
212 
213  // Copy clust's pixels (calibrated in electrons) into clust_array_2d;
214  for (int i=0 ; i!=cluster.size(); ++i )
215  {
216  auto pix = cluster.pixel(i);
217  // *pixIter dereferences to Pixel struct, with public vars x, y, adc (all float)
218  // 02/13/2008 ggiurgiu@fnal.gov: type of x, y and adc has been changed to unsigned char, unsigned short, unsigned short
219  // in DataFormats/SiPixelCluster/interface/SiPixelCluster.h so the type cast to int is redundant. Leave it there, it
220  // won't hurt.
221  int irow = int(pix.x) - row_offset; // &&& do we need +0.5 ???
222  int icol = int(pix.y) - col_offset; // &&& do we need +0.5 ???
223 
224  // Gavril : what do we do here if the row/column is larger than cluster_matrix_size_x/cluster_matrix_size_y = 7/21 ?
225  // Ignore them for the moment...
226  if ( irow<cluster_matrix_size_x && icol<cluster_matrix_size_y )
227  // 02/13/2008 ggiurgiu@fnal.gov typecast pixIter->adc to float
228  clust_array_2d[irow][icol] = (float)pix.adc;
229  }
230 
231  // Make and fill the bool arrays flagging double pixels
232  std::vector<bool> ydouble(cluster_matrix_size_y), xdouble(cluster_matrix_size_x);
233  // x directions (shorter), rows
234  for (int irow = 0; irow < cluster_matrix_size_x; ++irow)
235  {
236  xdouble[irow] = theRecTopol->isItBigPixelInX( irow+row_offset );
237  }
238 
239  // y directions (longer), columns
240  for (int icol = 0; icol < cluster_matrix_size_y; ++icol)
241  {
242  ydouble[icol] = theRecTopol->isItBigPixelInY( icol+col_offset );
243  }
244 
245  // Output:
246  float nonsense = -99999.9f; // nonsense init value
248  // If the template recontruction fails, we want to return 1.0 for now
250  templQbin_ = 0;
251  // We have a boolean denoting whether the reco failed or not
252  hasFilledProb_ = false;
253 
254  float templYrec1_ = nonsense;
255  float templXrec1_ = nonsense;
256  float templYrec2_ = nonsense;
257  float templXrec2_ = nonsense;
258 
259  // ******************************************************************
260  // Do it! Use cotalpha_ and cotbeta_ calculated in PixelCPEBase
261 
262 
263  float locBz = (*theParam).bz;
264 
265  ierr =
267  locBz,
268  clust_array_2d, ydouble, xdouble,
269  templ_,
272  templQbin_,
273  speed_,
275  );
276 
277  // ******************************************************************
278 
279  // Check exit status
280  if unlikely( ierr != 0 )
281  {
282  LogDebug("PixelCPETemplateReco::localPosition") <<
283  "reconstruction failed with error " << ierr << "\n";
284 
285  // Gavril: what do we do in this case ? For now, just return the cluster center of gravity in microns
286  // In the x case, apply a rough Lorentz drift average correction
287  // To do: call PixelCPEGeneric whenever PixelTempReco2D fails
288  float lorentz_drift = -999.9;
290  lorentz_drift = 60.0f; // in microns
292  lorentz_drift = 10.0f; // in microns
293  else
294  throw cms::Exception("PixelCPETemplateReco::localPosition :")
295  << "A non-pixel detector type in here?" << "\n";
296  // ggiurgiu@jhu.edu, 21/09/2010 : trk angles needed to correct for bows/kinks
297  if ( with_track_angle )
298  {
299  templXrec_ = theTopol->localX( cluster.x(), loc_trk_pred_ ) - lorentz_drift * micronsToCm; // rough Lorentz drift correction
300  templYrec_ = theTopol->localY( cluster.y(), loc_trk_pred_ );
301  }
302  else
303  {
304  edm::LogError("PixelCPETemplateReco")
305  << "@SUB = PixelCPETemplateReco::localPosition"
306  << "Should never be here. PixelCPETemplateReco should always be called with track angles. This is a bad error !!! ";
307 
308  templXrec_ = theTopol->localX( cluster.x() ) - lorentz_drift * micronsToCm; // rough Lorentz drift correction
309  templYrec_ = theTopol->localY( cluster.y() );
310  }
311  }
312  else if unlikely( UseClusterSplitter_ && templQbin_ == 0 )
313  {
314  cout << " PixelCPETemplateReco : We should never be here !!!!!!!!!!!!!!!!!!!!!!" << endl;
315  cout << " (int)UseClusterSplitter_ = " << (int)UseClusterSplitter_ << endl;
316 
317  //ierr =
318  //PixelTempSplit( ID, fpix, cotalpha_, cotbeta_,
319  // clust_array_2d, ydouble, xdouble,
320  // templ_,
321  // templYrec1_, templYrec2_, templSigmaY_, templProbY_,
322  // templXrec1_, templXrec2_, templSigmaX_, templProbX_,
323  // templQbin_ );
324 
325 
326  float dchisq;
327  float templProbQ_;
328  SiPixelTemplate2D templ2D_;
329  templ2D_.pushfile(ID);
330 
331  ierr =
333  clust_array_2d,
334  ydouble, xdouble,
335  templ_,
336  templYrec1_, templYrec2_, templSigmaY_, templProbY_,
337  templXrec1_, templXrec2_, templSigmaX_, templProbX_,
338  templQbin_,
339  templProbQ_,
340  true,
341  dchisq,
342  templ2D_ );
343 
344 
345  if ( ierr != 0 )
346  {
347  LogDebug("PixelCPETemplateReco::localPosition") <<
348  "reconstruction failed with error " << ierr << "\n";
349 
350  // Gavril: what do we do in this case ? For now, just return the cluster center of gravity in microns
351  // In the x case, apply a rough Lorentz drift average correction
352  // To do: call PixelCPEGeneric whenever PixelTempReco2D fails
353  float lorentz_drift = -999.9f;
355  lorentz_drift = 60.0f; // in microns
357  lorentz_drift = 10.0f; // in microns
358  else
359  throw cms::Exception("PixelCPETemplateReco::localPosition :")
360  << "A non-pixel detector type in here?" << "\n";
361 
362  // ggiurgiu@jhu.edu, 12/09/2010 : trk angles needed to correct for bows/kinks
363  if ( with_track_angle )
364  {
365  templXrec_ = theTopol->localX( cluster.x(),loc_trk_pred_ ) - lorentz_drift * micronsToCm; // rough Lorentz drift correction
366  templYrec_ = theTopol->localY( cluster.y(),loc_trk_pred_ );
367  }
368  else
369  {
370  edm::LogError("PixelCPETemplateReco")
371  << "@SUB = PixelCPETemplateReco::localPosition"
372  << "Should never be here. PixelCPETemplateReco should always be called with track angles. This is a bad error !!! ";
373 
374  templXrec_ = theTopol->localX( cluster.x() ) - lorentz_drift * micronsToCm; // very rough Lorentz drift correction
375  templYrec_ = theTopol->localY( cluster.y() );
376 
377  }
378  }
379  else
380  {
381  // go from micrometer to centimeter
382  templXrec1_ *= micronsToCm;
383  templYrec1_ *= micronsToCm;
384  templXrec2_ *= micronsToCm;
385  templYrec2_ *= micronsToCm;
386 
387  // go back to the module coordinate system
388  templXrec1_ += lp.x();
389  templYrec1_ += lp.y();
390  templXrec2_ += lp.x();
391  templYrec2_ += lp.y();
392 
393  // calculate distance from each hit to the track and choose the
394  // hit closest to the track
395  float distance11 = sqrt( (templXrec1_ - trk_lp_x)*(templXrec1_ - trk_lp_x) +
396  (templYrec1_ - trk_lp_y)*(templYrec1_ - trk_lp_y) );
397 
398  float distance12 = sqrt( (templXrec1_ - trk_lp_x)*(templXrec1_ - trk_lp_x) +
399  (templYrec2_ - trk_lp_y)*(templYrec2_ - trk_lp_y) );
400 
401  float distance21 = sqrt( (templXrec2_ - trk_lp_x)*(templXrec2_ - trk_lp_x) +
402  (templYrec1_ - trk_lp_y)*(templYrec1_ - trk_lp_y) );
403 
404  float distance22 = sqrt( (templXrec2_ - trk_lp_x)*(templXrec2_ - trk_lp_x) +
405  (templYrec2_ - trk_lp_y)*(templYrec2_ - trk_lp_y) );
406 
407  float min_templXrec_ = -999.9;
408  float min_templYrec_ = -999.9;
409  float distance_min = 9999999999.9;
410  if ( distance11 < distance_min )
411  {
412  distance_min = distance11;
413  min_templXrec_ = templXrec1_;
414  min_templYrec_ = templYrec1_;
415  }
416  if ( distance12 < distance_min )
417  {
418  distance_min = distance12;
419  min_templXrec_ = templXrec1_;
420  min_templYrec_ = templYrec2_;
421  }
422  if ( distance21 < distance_min )
423  {
424  distance_min = distance21;
425  min_templXrec_ = templXrec2_;
426  min_templYrec_ = templYrec1_;
427  }
428  if ( distance22 < distance_min )
429  {
430  distance_min = distance22;
431  min_templXrec_ = templXrec2_;
432  min_templYrec_ = templYrec2_;
433  }
434 
435  templXrec_ = min_templXrec_;
436  templYrec_ = min_templYrec_;
437  }
438  } // else if ( UseClusterSplitter_ && templQbin_ == 0 )
439 
440  else // apparenly this is he good one!
441  {
442  // go from micrometer to centimeter
445 
446  // go back to the module coordinate system
447  templXrec_ += lp.x();
448  templYrec_ += lp.y();
449  }
450 
451  // Save probabilities and qBin in the quantities given to us by the base class
452  // (for which there are also inline getters). &&& templProbX_ etc. should be retired...
456  qBin_ = templQbin_;
457 
458  if ( ierr == 0 ) // always true here
459  hasFilledProb_ = true;
460 
461  return LocalPoint( templXrec_, templYrec_ );
462 
463 }
#define LogDebug(id)
int i
Definition: DBlmapReader.cc:9
Topology::LocalTrackPred loc_trk_pred_
Definition: PixelCPEBase.h:276
int minPixelCol() const
const float micronsToCm
bool with_track_angle
Definition: PixelCPEBase.h:226
virtual LocalPoint localPosition(const MeasurementPoint &) const =0
short getTemplateID(const uint32_t &detid) const
uint32_t ID
Definition: Definitions.h:26
T y() const
Definition: PV3DBase.h:63
float probabilityQ_
Definition: PixelCPEBase.h:231
GeomDetType::SubDetector thePart
Definition: PixelCPEBase.h:194
#define unlikely(x)
Definition: Likely.h:21
float probabilityY_
Definition: PixelCPEBase.h:230
Measurement2DPoint MeasurementPoint
Measurement points are two-dimensional by default.
int minPixelRow() const
T sqrt(T t)
Definition: SSEVec.h:48
bool hasFilledProb_
Definition: PixelCPEBase.h:236
int PixelTempSplit(int id, float cotalpha, float cotbeta, array_2d &cluster, std::vector< bool > &ydouble, std::vector< bool > &xdouble, SiPixelTemplate &templ, float &yrec1, float &yrec2, float &sigmay, float &prob2y, float &xrec1, float &xrec2, float &sigmax, float &prob2x, int &q2bin, float &prob2Q, bool resolve, int speed, float &dchisq, bool deadpix, std::vector< std::pair< int, int > > &zeropix, SiPixelTemplate2D &templ2D)
const SiPixelTemplateDBObject * templateDBobject_
Definition: PixelCPEBase.h:269
DetId geographicalId() const
The label of this GeomDet.
Definition: GeomDet.h:72
int PixelTempReco2D(int id, float cotalpha, float cotbeta, float locBz, array_2d &cluster, std::vector< bool > &ydouble, std::vector< bool > &xdouble, 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)
virtual float localX(const float mpX) const =0
const RectangularPixelTopology * theRecTopol
Definition: PixelCPEBase.h:190
const PixelTopology * theTopol
Definition: PixelCPEBase.h:189
const int cluster_matrix_size_y
void setTheDet(const GeomDetUnit &det, const SiPixelCluster &cluster) const
Definition: PixelCPEBase.cc:89
Pixel pixel(int i) const
float y() const
Local3DPoint LocalPoint
Definition: LocalPoint.h:11
bool pushfile(int filenum)
const int cluster_matrix_size_x
tuple cout
Definition: gather_cfg.py:121
const PixelGeomDetUnit * theDet
Definition: PixelCPEBase.h:185
T x() const
Definition: PV3DBase.h:62
float probabilityX_
Definition: PixelCPEBase.h:229
float x() const
virtual float localY(const float mpY) const =0
int size() const
float PixelCPETemplateReco::xpos ( const SiPixelCluster ) const
inlineprotectedvirtual

Implements PixelCPEBase.

Definition at line 52 of file PixelCPETemplateReco.h.

52 { return -999000.0; } // &&& should abort
float PixelCPETemplateReco::ypos ( const SiPixelCluster ) const
inlineprotectedvirtual

Implements PixelCPEBase.

Definition at line 53 of file PixelCPETemplateReco.h.

53 { return -999000.0; } // &&& should abort

Member Data Documentation

bool PixelCPETemplateReco::DoCosmics_
mutableprivate

Definition at line 83 of file PixelCPETemplateReco.h.

Referenced by PixelCPETemplateReco().

int PixelCPETemplateReco::ierr
mutableprivate

Definition at line 79 of file PixelCPETemplateReco.h.

Referenced by localError(), and localPosition().

bool PixelCPETemplateReco::LoadTemplatesFromDB_
mutableprivate

Definition at line 85 of file PixelCPETemplateReco.h.

Referenced by localPosition(), and PixelCPETemplateReco().

int PixelCPETemplateReco::speed_
mutableprivate

Definition at line 77 of file PixelCPETemplateReco.h.

Referenced by localPosition(), and PixelCPETemplateReco().

SiPixelTemplate PixelCPETemplateReco::templ_
mutableprivate

Definition at line 57 of file PixelCPETemplateReco.h.

Referenced by localPosition(), and PixelCPETemplateReco().

int PixelCPETemplateReco::templID_
mutableprivate

Definition at line 61 of file PixelCPETemplateReco.h.

float PixelCPETemplateReco::templProbQ_
mutableprivate

Definition at line 73 of file PixelCPETemplateReco.h.

Referenced by localPosition().

float PixelCPETemplateReco::templProbX_
mutableprivate

Definition at line 70 of file PixelCPETemplateReco.h.

Referenced by localPosition().

float PixelCPETemplateReco::templProbY_
mutableprivate

Definition at line 71 of file PixelCPETemplateReco.h.

Referenced by localPosition().

int PixelCPETemplateReco::templQbin_
mutableprivate

Definition at line 75 of file PixelCPETemplateReco.h.

Referenced by localPosition().

float PixelCPETemplateReco::templSigmaX_
mutableprivate

Definition at line 66 of file PixelCPETemplateReco.h.

Referenced by localError(), and localPosition().

float PixelCPETemplateReco::templSigmaY_
mutableprivate

Definition at line 67 of file PixelCPETemplateReco.h.

Referenced by localError(), and localPosition().

float PixelCPETemplateReco::templXrec_
mutableprivate

Definition at line 64 of file PixelCPETemplateReco.h.

Referenced by localPosition().

float PixelCPETemplateReco::templYrec_
mutableprivate

Definition at line 65 of file PixelCPETemplateReco.h.

Referenced by localPosition().

bool PixelCPETemplateReco::UseClusterSplitter_
mutableprivate

Definition at line 81 of file PixelCPETemplateReco.h.

Referenced by localPosition(), and PixelCPETemplateReco().