CMS 3D CMS Logo

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

#include <PixelCPETemplateReco.h>

Inheritance diagram for PixelCPETemplateReco:
PixelCPEBase PixelClusterParameterEstimator ClusterParameterEstimator< SiPixelCluster >

Public Member Functions

 PixelCPETemplateReco (edm::ParameterSet const &conf, const MagneticField *, const SiPixelLorentzAngle *, const SiPixelTemplateDBObject *)
 
 ~PixelCPETemplateReco ()
 
- Public Member Functions inherited from PixelCPEBase
unsigned int clusterProbComputationFlag () 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
 
 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 ()
 
virtual std::unique_ptr
< ClusterParameterEstimator
< SiPixelCluster > > 
clone () const
 
virtual void enterLocalParameters (unsigned int id, std::pair< int, int > &row_col, LocalValues pos_err_info)
 
virtual void enterLocalParameters (uint32_t id, uint16_t firstStrip, LocalValues pos_err_info)
 
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 ()
 

Private Member Functions

LocalError localError (const SiPixelCluster &cl) const
 
LocalPoint localPosition (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 Member Functions inherited from PixelCPEBase
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
 
Param const & param () const
 
void setTheDet (const GeomDetUnit &det, const SiPixelCluster &cluster) const
 
- Protected Attributes inherited from PixelCPEBase
bool alpha2Order
 
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_
 
float lorentzShiftInCmX_
 
float lorentzShiftInCmY_
 
float lorentzShiftX_
 
float 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
 
Local3DPoint theOrigin
 
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
 
bool zneg
 
- 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:49
const SiPixelTemplateDBObject * templateDBobject_
Definition: PixelCPEBase.h:246
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
privatevirtual

Implements PixelCPEBase.

Definition at line 467 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, SiPixelCluster::sizeX(), SiPixelCluster::sizeY(), mathSSE::sqrt(), templSigmaX_, templSigmaY_, PixelCPEBase::thePart, PixelCPEBase::thePitchX, PixelCPEBase::thePitchY, PixelCPEBase::theRecTopol, and PixelCPEBase::theVerboseLevel.

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

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

Member Data Documentation

bool PixelCPETemplateReco::DoCosmics_
mutableprivate

Definition at line 79 of file PixelCPETemplateReco.h.

Referenced by PixelCPETemplateReco().

int PixelCPETemplateReco::ierr
mutableprivate

Definition at line 75 of file PixelCPETemplateReco.h.

Referenced by localError(), and localPosition().

bool PixelCPETemplateReco::LoadTemplatesFromDB_
mutableprivate

Definition at line 81 of file PixelCPETemplateReco.h.

Referenced by localPosition(), and PixelCPETemplateReco().

int PixelCPETemplateReco::speed_
mutableprivate

Definition at line 73 of file PixelCPETemplateReco.h.

Referenced by localPosition(), and PixelCPETemplateReco().

SiPixelTemplate PixelCPETemplateReco::templ_
mutableprivate

Definition at line 53 of file PixelCPETemplateReco.h.

Referenced by localPosition(), and PixelCPETemplateReco().

int PixelCPETemplateReco::templID_
mutableprivate

Definition at line 57 of file PixelCPETemplateReco.h.

float PixelCPETemplateReco::templProbQ_
mutableprivate

Definition at line 69 of file PixelCPETemplateReco.h.

Referenced by localPosition().

float PixelCPETemplateReco::templProbX_
mutableprivate

Definition at line 66 of file PixelCPETemplateReco.h.

Referenced by localPosition().

float PixelCPETemplateReco::templProbY_
mutableprivate

Definition at line 67 of file PixelCPETemplateReco.h.

Referenced by localPosition().

int PixelCPETemplateReco::templQbin_
mutableprivate

Definition at line 71 of file PixelCPETemplateReco.h.

Referenced by localPosition().

float PixelCPETemplateReco::templSigmaX_
mutableprivate

Definition at line 62 of file PixelCPETemplateReco.h.

Referenced by localError(), and localPosition().

float PixelCPETemplateReco::templSigmaY_
mutableprivate

Definition at line 63 of file PixelCPETemplateReco.h.

Referenced by localError(), and localPosition().

float PixelCPETemplateReco::templXrec_
mutableprivate

Definition at line 60 of file PixelCPETemplateReco.h.

Referenced by localPosition().

float PixelCPETemplateReco::templYrec_
mutableprivate

Definition at line 61 of file PixelCPETemplateReco.h.

Referenced by localPosition().

bool PixelCPETemplateReco::UseClusterSplitter_
mutableprivate

Definition at line 77 of file PixelCPETemplateReco.h.

Referenced by localPosition(), and PixelCPETemplateReco().