CMS 3D CMS Logo

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

#include <PixelCPETemplateReco.h>

Inheritance diagram for PixelCPETemplateReco:
PixelCPEBase PixelClusterParameterEstimator

Classes

struct  ClusterParamTemplate
 

Public Member Functions

 PixelCPETemplateReco (edm::ParameterSet const &conf, const MagneticField *, const TrackerGeometry &, const TrackerTopology &, const SiPixelLorentzAngle *, const SiPixelTemplateDBObject *)
 
 ~PixelCPETemplateReco ()
 
- Public Member Functions inherited from PixelCPEBase
ReturnType getParameters (const SiPixelCluster &cl, const GeomDetUnit &det) const
 
ReturnType getParameters (const SiPixelCluster &cl, const GeomDetUnit &det, const LocalTrajectoryParameters &ltp) const
 
 PixelCPEBase (edm::ParameterSet const &conf, const MagneticField *mag, const TrackerGeometry &geom, const TrackerTopology &ttopo, const SiPixelLorentzAngle *lorentzAngle, const SiPixelGenErrorDBObject *genErrorDBObject, const SiPixelTemplateDBObject *templateDBobject, const SiPixelLorentzAngle *lorentzAngleWidth, int flag=0)
 
- Public Member Functions inherited from PixelClusterParameterEstimator
unsigned int clusterProbComputationFlag () const
 
virtual ReturnType getParameters (const SiPixelCluster &cl, const GeomDetUnit &det, const TrajectoryStateOnSurface &tsos) const
 
virtual VLocalValues localParametersV (const SiPixelCluster &cluster, const GeomDetUnit &gd) const
 
virtual VLocalValues localParametersV (const SiPixelCluster &cluster, const GeomDetUnit &gd, TrajectoryStateOnSurface &tsos) const
 
 PixelClusterParameterEstimator ()
 
virtual ~PixelClusterParameterEstimator ()
 

Private Member Functions

ClusterParamcreateClusterParam (const SiPixelCluster &cl) const
 
LocalError localError (DetParam const &theDetParam, ClusterParam &theClusterParam) const
 
LocalPoint localPosition (DetParam const &theDetParam, ClusterParam &theClusterParam) const
 

Private Attributes

int speed_
 
std::vector< SiPixelTemplateStorethePixelTemp_
 
bool UseClusterSplitter_
 

Additional Inherited Members

- Public Types inherited from PixelClusterParameterEstimator
typedef std::pair< LocalPoint,
LocalError
LocalValues
 
using ReturnType = std::tuple< LocalPoint, LocalError, SiPixelRecHitQuality::QualWordType >
 
typedef std::vector< LocalValuesVLocalValues
 
- Protected Types inherited from PixelCPEBase
typedef GloballyPositioned
< double > 
Frame
 
- Protected Attributes inherited from PixelCPEBase
bool alpha2Order
 
bool DoLorentz_
 
const SiPixelGenErrorDBObjectgenErrorDBObject_
 
const TrackerGeometrygeom_
 
float lAOffset_
 
float lAWidthBPix_
 
float lAWidthFPix_
 
bool LoadTemplatesFromDB_
 
const SiPixelLorentzAnglelorentzAngle_
 
const SiPixelLorentzAnglelorentzAngleWidth_
 
const MagneticFieldmagfield_
 
const SiPixelTemplateDBObjecttemplateDBobject_
 
int theFlag_
 
int theVerboseLevel
 
const TrackerTopologyttopo_
 
bool useLAOffsetFromConfig_
 
bool useLAWidthFromConfig_
 
bool useLAWidthFromDB_
 
- Protected Attributes inherited from PixelClusterParameterEstimator
unsigned int clusterProbComputationFlag_
 

Detailed Description

Definition at line 34 of file PixelCPETemplateReco.h.

Constructor & Destructor Documentation

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

Definition at line 42 of file PixelCPETemplateReco.cc.

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

48  : PixelCPEBase(conf, mag, geom, ttopo, lorentzAngle, 0, templateDBobject, 0,1)
49 {
50  //cout << endl;
51  //cout << "Constructing PixelCPETemplateReco::PixelCPETemplateReco(...)................................................." << endl;
52  //cout << endl;
53 
54  // Configurable parameters
55  //DoCosmics_ = conf.getParameter<bool>("DoCosmics"); // Not used in templates
56  //LoadTemplatesFromDB_ = conf.getParameter<bool>("LoadTemplatesFromDB"); // Moved to Base
57 
58  //cout << " PixelCPETemplateReco : (int)LoadTemplatesFromDB_ = " << (int)LoadTemplatesFromDB_ << endl;
59  //cout << "field_magnitude = " << field_magnitude << endl;
60 
61  // configuration parameter to decide between DB or text file template access
62 
64  {
65  //cout << "PixelCPETemplateReco: Loading templates from database (DB) --------- " << endl;
66 
67  // Initialize template store to the selected ID [Morris, 6/25/08]
69  throw cms::Exception("PixelCPETemplateReco")
70  << "\nERROR: Templates not filled correctly. Check the sqlite file. Using SiPixelTemplateDBObject version "
71  << (*templateDBobject_).version() << "\n\n";
72  }
73  else
74  {
75  //cout << "PixelCPETemplateReco : Loading templates 40 and 41 from ASCII files ------------------------" << endl;
76 
78  throw cms::Exception("PixelCPETemplateReco")
79  << "\nERROR: Templates 40 not loaded correctly from text file. Reconstruction will fail.\n\n";
80 
82  throw cms::Exception("PixelCPETemplateReco")
83  << "\nERROR: Templates 41 not loaded correctly from text file. Reconstruction will fail.\n\n";
84  }
85 
86  speed_ = conf.getParameter<int>( "speed");
87  LogDebug("PixelCPETemplateReco::PixelCPETemplateReco:") <<
88  "Template speed = " << speed_ << "\n";
89 
90  UseClusterSplitter_ = conf.getParameter<bool>("UseClusterSplitter");
91 
92 }
#define LogDebug(id)
static bool pushfile(int filenum, std::vector< SiPixelTemplateStore > &thePixelTemp_)
std::vector< SiPixelTemplateStore > thePixelTemp_
bool LoadTemplatesFromDB_
Definition: PixelCPEBase.h:255
const SiPixelTemplateDBObject * templateDBobject_
Definition: PixelCPEBase.h:251
tuple conf
Definition: dbtoconf.py:185
PixelCPEBase(edm::ParameterSet const &conf, const MagneticField *mag, const TrackerGeometry &geom, const TrackerTopology &ttopo, const SiPixelLorentzAngle *lorentzAngle, const SiPixelGenErrorDBObject *genErrorDBObject, const SiPixelTemplateDBObject *templateDBobject, const SiPixelLorentzAngle *lorentzAngleWidth, int flag=0)
Definition: PixelCPEBase.cc:41
PixelCPETemplateReco::~PixelCPETemplateReco ( )

Definition at line 97 of file PixelCPETemplateReco.cc.

98 {
99  // &&& delete template store?
100 }

Member Function Documentation

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

Implements PixelCPEBase.

Definition at line 102 of file PixelCPETemplateReco.cc.

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

Implements PixelCPEBase.

Definition at line 463 of file PixelCPETemplateReco.cc.

References edm::hlt::Exception, f, PixelCPETemplateReco::ClusterParamTemplate::ierr, RectangularPixelTopology::isItEdgePixelInX(), RectangularPixelTopology::isItEdgePixelInY(), LogDebug, GeomDetEnumerators::PixelBarrel, GeomDetEnumerators::PixelEndcap, mathSSE::sqrt(), PixelCPETemplateReco::ClusterParamTemplate::templSigmaX_, PixelCPETemplateReco::ClusterParamTemplate::templSigmaY_, PixelCPEBase::DetParam::thePart, PixelCPEBase::DetParam::thePitchX, PixelCPEBase::DetParam::thePitchY, PixelCPEBase::DetParam::theRecTopol, and PixelCPEBase::theVerboseLevel.

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

Implements PixelCPEBase.

Definition at line 116 of file PixelCPETemplateReco.cc.

References PixelCPEBase::DetParam::bz, gather_cfg::cout, PixelCPEBase::DetParam::detTemplateId, PixelCPEBase::DoLorentz_, edm::hlt::Exception, GeomDet::geographicalId(), SiPixelTemplateDBObject::getTemplateID(), i, PixelCPETemplateReco::ClusterParamTemplate::ierr, RectangularPixelTopology::isItBigPixelInX(), RectangularPixelTopology::isItBigPixelInY(), PixelCPEBase::LoadTemplatesFromDB_, Topology::localPosition(), PixelTopology::localX(), PixelTopology::localY(), LogDebug, PixelCPEBase::DetParam::lorentzShiftInCmX, PixelCPEBase::DetParam::lorentzShiftInCmY, SiPixelTemplate::lorxbias(), SiPixelTemplate::lorybias(), GeomDetEnumerators::PixelBarrel, GeomDetEnumerators::PixelEndcap, SiPixelTemplateReco::PixelTempReco2D(), SiPixelTemplateSplit::PixelTempSplit(), SiPixelTemplate2D::pushfile(), speed_, mathSSE::sqrt(), PixelCPEBase::templateDBobject_, PixelCPETemplateReco::ClusterParamTemplate::templProbQ_, PixelCPETemplateReco::ClusterParamTemplate::templProbX_, PixelCPETemplateReco::ClusterParamTemplate::templProbY_, PixelCPETemplateReco::ClusterParamTemplate::templQbin_, PixelCPETemplateReco::ClusterParamTemplate::templSigmaX_, PixelCPETemplateReco::ClusterParamTemplate::templSigmaY_, PixelCPETemplateReco::ClusterParamTemplate::templXrec_, PixelCPETemplateReco::ClusterParamTemplate::templYrec_, PixelCPEBase::DetParam::theDet, PixelCPEBase::DetParam::thePart, thePixelTemp_, PixelCPEBase::DetParam::theRecTopol, PixelCPEBase::DetParam::theTopol, create_public_lumi_plots::tmp_x, create_public_lumi_plots::tmp_y, unlikely, UseClusterSplitter_, PV3DBase< T, PVType, FrameType >::x(), and PV3DBase< T, PVType, FrameType >::y().

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

Member Data Documentation

int PixelCPETemplateReco::speed_
private

Definition at line 78 of file PixelCPETemplateReco.h.

Referenced by localPosition(), and PixelCPETemplateReco().

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

Definition at line 76 of file PixelCPETemplateReco.h.

Referenced by localPosition(), and PixelCPETemplateReco().

bool PixelCPETemplateReco::UseClusterSplitter_
private

Definition at line 80 of file PixelCPETemplateReco.h.

Referenced by localPosition(), and PixelCPETemplateReco().