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
 
MeasurementPoint measurementPosition (const SiPixelCluster &, 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
 
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 computeAnglesFromDetPosition (const SiPixelCluster &cl, const GeomDetUnit &det) const
 
void computeAnglesFromTrajectory (const SiPixelCluster &cl, const GeomDetUnit &det, const LocalTrajectoryParameters &ltp) const
 
void computeLorentzShifts () const
 
LocalVector driftDirection (GlobalVector bfield) const
 
LocalVector driftDirectionCorrect (GlobalVector bfield) const
 
bool isFlipped () const
 
virtual float lorentzShiftX () const
 
virtual float lorentzShiftY () const
 
MeasurementError measurementError (const SiPixelCluster &, const GeomDetUnit &det) const
 
MeasurementPoint measurementPosition (const SiPixelCluster &, const GeomDetUnit &det) const
 
void setTheDet (const GeomDetUnit &det, const SiPixelCluster &cluster) const
 
void xCharge (const std::vector< SiPixelCluster::Pixel > &, const int &, const int &, float &q1, float &q2) const
 
void yCharge (const std::vector< SiPixelCluster::Pixel > &, const int &, const int &, float &q1, float &q2) 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
 
GeomDetType::SubDetector thePart
 
float thePitchX
 
float thePitchY
 
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:44
const SiPixelTemplateDBObject * templateDBobject_
Definition: PixelCPEBase.h:263
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 495 of file PixelCPETemplateReco.cc.

References edm::hlt::Exception, SiPixelCluster::getSplitClusterErrorX(), SiPixelCluster::getSplitClusterErrorY(), ierr, PixelTopology::isItEdgePixelInX(), PixelTopology::isItEdgePixelInY(), 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::theTopol, and PixelCPEBase::theVerboseLevel.

497 {
498  //cout << endl;
499  //cout << "Set PixelCPETemplate errors .............................................." << endl;
500 
501  //cout << "CPETemplate : " << endl;
502 
503  //--- Default is the maximum error used for edge clusters.
504  float xerr = thePitchX / sqrt(12.0);
505  float yerr = thePitchY / sqrt(12.0);
506 
507  // Check if the errors were already set at the clusters splitting level
508  if ( cluster.getSplitClusterErrorX() > 0.0 && cluster.getSplitClusterErrorX() < 7777.7 &&
509  cluster.getSplitClusterErrorY() > 0.0 && cluster.getSplitClusterErrorY() < 7777.7 )
510  {
511  xerr = cluster.getSplitClusterErrorX() * micronsToCm;
512  yerr = cluster.getSplitClusterErrorY() * micronsToCm;
513 
514  //cout << "Errors set at cluster splitting level : " << endl;
515  //cout << "xerr = " << xerr << endl;
516  //cout << "yerr = " << yerr << endl;
517  }
518  else
519  {
520  // If errors are not split at the cluster splitting level, set the errors here
521 
522  //cout << "Errors are not split at the cluster splitting level, set the errors here : " << endl;
523 
524  setTheDet( det, cluster );
525 
526  int maxPixelCol = cluster.maxPixelCol();
527  int maxPixelRow = cluster.maxPixelRow();
528  int minPixelCol = cluster.minPixelCol();
529  int minPixelRow = cluster.minPixelRow();
530 
531  //--- Are we near either of the edges?
532  bool edgex = ( theTopol->isItEdgePixelInX( minPixelRow ) || theTopol->isItEdgePixelInX( maxPixelRow ) );
533  bool edgey = ( theTopol->isItEdgePixelInY( minPixelCol ) || theTopol->isItEdgePixelInY( maxPixelCol ) );
534 
535  if ( ierr !=0 )
536  {
537  // If reconstruction fails the hit position is calculated from cluster center of gravity
538  // corrected in x by average Lorentz drift. Assign huge errors.
539  //xerr = 10.0 * (float)cluster.sizeX() * xerr;
540  //yerr = 10.0 * (float)cluster.sizeX() * yerr;
541 
542  // Assign better errors based on the residuals for failed template cases
544  {
545  xerr = 55.0 * micronsToCm;
546  yerr = 36.0 * micronsToCm;
547  }
549  {
550  xerr = 42.0 * micronsToCm;
551  yerr = 39.0 * micronsToCm;
552  }
553  else
554  throw cms::Exception("PixelCPETemplateReco::localError :") << "A non-pixel detector type in here?" ;
555 
556  //cout << "xerr = " << xerr << endl;
557  //cout << "yerr = " << yerr << endl;
558 
559  //return LocalError(xerr*xerr, 0, yerr*yerr);
560  }
561  else if ( edgex || edgey )
562  {
563  // for edge pixels assign errors according to observed residual RMS
564  if ( edgex && !edgey )
565  {
566  xerr = 23.0 * micronsToCm;
567  yerr = 39.0 * micronsToCm;
568  }
569  else if ( !edgex && edgey )
570  {
571  xerr = 24.0 * micronsToCm;
572  yerr = 96.0 * micronsToCm;
573  }
574  else if ( edgex && edgey )
575  {
576  xerr = 31.0 * micronsToCm;
577  yerr = 90.0 * micronsToCm;
578  }
579  else
580  {
581  throw cms::Exception(" PixelCPETemplateReco::localError: Something wrong with pixel edge flag !!!");
582  }
583 
584  //cout << "xerr = " << xerr << endl;
585  //cout << "yerr = " << yerr << endl;
586  }
587  else
588  {
589  // &&& need a class const
590  //const float micronsToCm = 1.0e-4;
591 
592  xerr = templSigmaX_ * micronsToCm;
593  yerr = templSigmaY_ * micronsToCm;
594 
595  //cout << "xerr = " << xerr << endl;
596  //cout << "yerr = " << yerr << endl;
597 
598  // &&& should also check ierr (saved as class variable) and return
599  // &&& nonsense (another class static) if the template fit failed.
600  }
601 
602  if (theVerboseLevel > 9)
603  {
604  LogDebug("PixelCPETemplateReco") <<
605  " Sizex = " << cluster.sizeX() << " Sizey = " << cluster.sizeY() << " Edgex = " << edgex << " Edgey = " << edgey <<
606  " ErrX = " << xerr << " ErrY = " << yerr;
607  }
608 
609  } // else
610 
611  if ( !(xerr > 0.0) )
612  throw cms::Exception("PixelCPETemplateReco::localError")
613  << "\nERROR: Negative pixel error xerr = " << xerr << "\n\n";
614 
615  if ( !(yerr > 0.0) )
616  throw cms::Exception("PixelCPETemplateReco::localError")
617  << "\nERROR: Negative pixel error yerr = " << yerr << "\n\n";
618 
619  //cout << "Final errors set to: " << endl;
620  //cout << "xerr = " << xerr << endl;
621  //cout << "yerr = " << yerr << endl;
622  //cout << "Out of PixelCPETemplateREco..........................................................................." << endl;
623  //cout << endl;
624 
625  return LocalError(xerr*xerr, 0, yerr*yerr);
626 }
#define LogDebug(id)
const float micronsToCm
GeomDetType::SubDetector thePart
Definition: PixelCPEBase.h:188
virtual bool isItEdgePixelInX(int ixbin) const =0
T sqrt(T t)
Definition: SSEVec.h:46
const PixelTopology * theTopol
Definition: PixelCPEBase.h:185
void setTheDet(const GeomDetUnit &det, const SiPixelCluster &cluster) const
Definition: PixelCPEBase.cc:95
virtual bool isItEdgePixelInY(int iybin) const =0
LocalPoint PixelCPETemplateReco::localPosition ( const SiPixelCluster cluster,
const GeomDetUnit det 
) const
virtual

Reimplemented from PixelCPEBase.

Definition at line 134 of file PixelCPETemplateReco.cc.

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

Referenced by measurementPosition().

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

Definition at line 106 of file PixelCPETemplateReco.cc.

References LocalTrajectoryParameters::dxdz(), LocalTrajectoryParameters::dydz(), PixelCPEBase::loc_traj_param_, localPosition(), Topology::measurementPosition(), PixelCPEBase::theTopol, and PixelCPEBase::with_track_angle.

108 {
109  LocalPoint lp = localPosition(cluster,det);
110 
111  // ggiurgiu@jhu.edu 12/09/2010 : trk angles needed to correct for bows/kinks
112  if ( with_track_angle )
114  else
115  {
116  edm::LogError("PixelCPETemplateReco")
117  << "@SUB = PixelCPETemplateReco::measurementPosition"
118  << "Should never be here. PixelCPETemplateReco should always be called with track angles. This is a bad error !!! ";
119 
120  return theTopol->measurementPosition( lp );
121  }
122 
123 }
bool with_track_angle
Definition: PixelCPEBase.h:220
LocalPoint localPosition(const SiPixelCluster &cluster, const GeomDetUnit &det) const
virtual MeasurementPoint measurementPosition(const LocalPoint &) const =0
LocalTrajectoryParameters loc_traj_param_
Definition: PixelCPEBase.h:272
const PixelTopology * theTopol
Definition: PixelCPEBase.h:185
float PixelCPETemplateReco::xpos ( const SiPixelCluster ) const
inlineprotectedvirtual

Implements PixelCPEBase.

Definition at line 56 of file PixelCPETemplateReco.h.

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

Implements PixelCPEBase.

Definition at line 57 of file PixelCPETemplateReco.h.

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

Member Data Documentation

bool PixelCPETemplateReco::DoCosmics_
mutableprivate

Definition at line 87 of file PixelCPETemplateReco.h.

Referenced by PixelCPETemplateReco().

int PixelCPETemplateReco::ierr
mutableprivate

Definition at line 83 of file PixelCPETemplateReco.h.

Referenced by localError(), and localPosition().

bool PixelCPETemplateReco::LoadTemplatesFromDB_
mutableprivate

Definition at line 89 of file PixelCPETemplateReco.h.

Referenced by localPosition(), and PixelCPETemplateReco().

int PixelCPETemplateReco::speed_
mutableprivate

Definition at line 81 of file PixelCPETemplateReco.h.

Referenced by localPosition(), and PixelCPETemplateReco().

SiPixelTemplate PixelCPETemplateReco::templ_
mutableprivate

Definition at line 61 of file PixelCPETemplateReco.h.

Referenced by localPosition(), and PixelCPETemplateReco().

int PixelCPETemplateReco::templID_
mutableprivate

Definition at line 65 of file PixelCPETemplateReco.h.

float PixelCPETemplateReco::templProbQ_
mutableprivate

Definition at line 77 of file PixelCPETemplateReco.h.

Referenced by localPosition().

float PixelCPETemplateReco::templProbX_
mutableprivate

Definition at line 74 of file PixelCPETemplateReco.h.

Referenced by localPosition().

float PixelCPETemplateReco::templProbY_
mutableprivate

Definition at line 75 of file PixelCPETemplateReco.h.

Referenced by localPosition().

int PixelCPETemplateReco::templQbin_
mutableprivate

Definition at line 79 of file PixelCPETemplateReco.h.

Referenced by localPosition().

float PixelCPETemplateReco::templSigmaX_
mutableprivate

Definition at line 70 of file PixelCPETemplateReco.h.

Referenced by localError(), and localPosition().

float PixelCPETemplateReco::templSigmaY_
mutableprivate

Definition at line 71 of file PixelCPETemplateReco.h.

Referenced by localError(), and localPosition().

float PixelCPETemplateReco::templXrec_
mutableprivate

Definition at line 68 of file PixelCPETemplateReco.h.

Referenced by localPosition().

float PixelCPETemplateReco::templYrec_
mutableprivate

Definition at line 69 of file PixelCPETemplateReco.h.

Referenced by localPosition().

bool PixelCPETemplateReco::UseClusterSplitter_
mutableprivate

Definition at line 85 of file PixelCPETemplateReco.h.

Referenced by localPosition(), and PixelCPETemplateReco().