CMS 3D CMS Logo

PixelCPEBase.h
Go to the documentation of this file.
1 #ifndef RecoLocalTracker_SiPixelRecHits_PixelCPEBase_H
2 #define RecoLocalTracker_SiPixelRecHits_PixelCPEBase_H 1
3 
4 //-----------------------------------------------------------------------------
5 // \class PixelCPEBase
6 // \description Base class for pixel CPE's, with all the common code.
7 // Perform the position and error evaluation of pixel hits using
8 // the Det angle to estimate the track impact angle.
9 // Move geomCorrection to the concrete class. d.k. 06/06.
10 // change to use Lorentz angle from DB Lotte Wilke, Jan. 31st, 2008
11 // Change to use Generic error & Template calibration from DB - D.Fehling 11/08
12 //-----------------------------------------------------------------------------
13 
14 #include <utility>
15 #include <vector>
16 #include "TMath.h"
17 
20 
27 
28 //--- For the configuration:
30 
31 
35 
37 
38 // new errors
40 // old errors
41 //#include "CondFormats/SiPixelObjects/interface/SiPixelCPEGenericErrorParm.h"
42 
44 
45 #include <unordered_map>
46 
47 #include <iostream>
48 #ifdef EDM_ML_DEBUG
49 #include <atomic>
50 #endif
51 
53 class MagneticField;
55 {
56 public:
57  struct DetParam
58  {
59  DetParam() {}
61  // gavril : replace RectangularPixelTopology with PixelTopology
64 
67  float theThickness;
68  float thePitchX;
69  float thePitchY;
70 
71  float bz; // local Bz
72  float bx; // local Bx
74  float widthLAFractionX; // Width-LA to Offset-LA in X
75  float widthLAFractionY; // same in Y
76  float lorentzShiftInCmX; // a FULL shift, in cm
77  float lorentzShiftInCmY; // a FULL shift, in cm
78  int detTemplateId; // det if for templates & generic errors
79  int detTemplateId2D; // det if for 2D templates
80  };
81 
82  struct ClusterParam
83  {
84  ClusterParam(const SiPixelCluster & cl) : theCluster(&cl) {}
85 
86  virtual ~ClusterParam() = default;
87 
89 
90  //--- Cluster-level quantities (filled in computeAnglesFrom....)
91  float cotalpha;
92  float cotbeta;
93 
94  // G.Giurgiu (05/14/08) track local coordinates
95  // filled in computeAnglesFrom....
96  float trk_lp_x;
97  float trk_lp_y;
98 
99  // ggiurgiu@jhu.edu (12/01/2010) : Needed for calling topology methods
100  // with track angles to handle surface deformations (bows/kinks)
101  // filled in computeAnglesFrom.... (btw redundant with the 4 above)
103 
104  //--- Probability (protected by hasFilledProb_)
108  int qBin_ ; // always filled by qbin
109 
110  bool isOnEdge_ ; // filled in setTheClu
111  bool hasBadPixels_ = false; // (never used in current code)
112  bool spansTwoROCs_ ; // filled in setTheClu
113  bool hasFilledProb_ =false;
114  // ggiurgiu@jhu.edu (10/18/2008)
115  bool with_track_angle; // filled in computeAnglesFrom....
116  bool filled_from_2d = false; //
117 
118  // More detailed edge information (for CPE ClusterRepair, and elsewhere...)
119  int edgeTypeX_ = 0; // 0: not on edge, 1: low end on edge, 2: high end
120  int edgeTypeY_ = 0; // 0: not on edge, 1: low end on edge, 2: high end
121  };
122 
123 public:
124  PixelCPEBase(edm::ParameterSet const& conf, const MagneticField * mag, const TrackerGeometry& geom, const TrackerTopology& ttopo,
125  const SiPixelLorentzAngle * lorentzAngle,
126  const SiPixelGenErrorDBObject * genErrorDBObject,
127  const SiPixelTemplateDBObject * templateDBobject,
128  const SiPixelLorentzAngle * lorentzAngleWidth,
129  int flag=0 // flag=0 for generic, =1 for templates
130  ); // NEW
131 
132  //--------------------------------------------------------------------------
133  // Allow the magnetic field to be set/updated later.
134  //--------------------------------------------------------------------------
135  //inline void setMagField(const MagneticField *mag) const { magfield_ = mag; } // Not used, AH
136 
137 
138  //--------------------------------------------------------------------------
139  // Obtain the angles from the position of the DetUnit.
140  //--------------------------------------------------------------------------
141 
143  const GeomDetUnit & det ) const override
144  {
145 #ifdef EDM_ML_DEBUG
146  nRecHitsTotal_++ ;
147  //std::cout<<" in PixelCPEBase:localParameters(all) - "<<nRecHitsTotal_<<std::endl; //dk
148 #endif
149 
150  DetParam const & theDetParam = detParam(det);
151  ClusterParam * theClusterParam = createClusterParam(cl);
152  setTheClu( theDetParam, *theClusterParam );
153  computeAnglesFromDetPosition(theDetParam, *theClusterParam);
154 
155  // localPosition( cl, det ) must be called before localError( cl, det ) !!!
156  LocalPoint lp = localPosition(theDetParam, *theClusterParam);
157  LocalError le = localError(theDetParam, *theClusterParam);
158  SiPixelRecHitQuality::QualWordType rqw = rawQualityWord(*theClusterParam);
159  auto tuple = std::make_tuple(lp, le , rqw);
160  delete theClusterParam;
161 
162  //std::cout<<" in PixelCPEBase:localParameters(all) - "<<lp.x()<<" "<<lp.y()<<std::endl; //dk
163  return tuple;
164  }
165 
166  //--------------------------------------------------------------------------
167  // In principle we could use the track too to obtain alpha and beta.
168  //--------------------------------------------------------------------------
170  const GeomDetUnit & det,
171  const LocalTrajectoryParameters & ltp ) const override
172  {
173 #ifdef EDM_ML_DEBUG
174  nRecHitsTotal_++ ;
175  //std::cout<<" in PixelCPEBase:localParameters(on track) - "<<nRecHitsTotal_<<std::endl; //dk
176 #endif
177 
178  DetParam const & theDetParam = detParam(det);
179  ClusterParam * theClusterParam = createClusterParam(cl);
180  setTheClu( theDetParam, *theClusterParam );
181  computeAnglesFromTrajectory(theDetParam, *theClusterParam, ltp);
182 
183  // localPosition( cl, det ) must be called before localError( cl, det ) !!!
184  LocalPoint lp = localPosition(theDetParam, *theClusterParam);
185  LocalError le = localError(theDetParam, *theClusterParam);
186  SiPixelRecHitQuality::QualWordType rqw = rawQualityWord(*theClusterParam);
187  auto tuple = std::make_tuple(lp, le , rqw);
188  delete theClusterParam;
189 
190  //std::cout<<" in PixelCPEBase:localParameters(on track) - "<<lp.x()<<" "<<lp.y()<<std::endl; //dk
191  return tuple;
192  }
193 
194 
195 
196 private:
197  virtual ClusterParam * createClusterParam(const SiPixelCluster & cl) const = 0;
198 
199  //--------------------------------------------------------------------------
200  // This is where the action happens.
201  //--------------------------------------------------------------------------
202  virtual LocalPoint localPosition(DetParam const & theDetParam, ClusterParam & theClusterParam) const = 0;
203  virtual LocalError localError (DetParam const & theDetParam, ClusterParam & theClusterParam) const = 0;
204 
205  void fillDetParams();
206 
207  //-----------------------------------------------------------------------------
212  //-----------------------------------------------------------------------------
214 
215 protected:
216  //--- All methods and data members are protected to facilitate (for now)
217  //--- access from derived classes.
218 
220 
221  //---------------------------------------------------------------------------
222  // Data members
223  //---------------------------------------------------------------------------
224 
225  //--- Counters
226 #ifdef EDM_ML_DEBUG
227  mutable std::atomic<int> nRecHitsTotal_ ; //for debugging only
228  mutable std::atomic<int> nRecHitsUsedEdge_ ; //for debugging only
229 #endif
230 
231  // Added new members
232  float lAOffset_; // la used to calculate the offset from configuration (for testing)
233  float lAWidthBPix_; // la used to calculate the cluster width from conf.
234  float lAWidthFPix_; // la used to calculate the cluster width from conf.
235  //bool useLAAlignmentOffsets_; // lorentz angle offsets detrmined by alignment
236  bool useLAOffsetFromConfig_; // lorentz angle used to calculate the offset
237  bool useLAWidthFromConfig_; // lorentz angle used to calculate the cluster width
238  bool useLAWidthFromDB_; // lorentz angle used to calculate the cluster width
239 
240  //--- Global quantities
241  int theVerboseLevel; // algorithm's verbosity
242  int theFlag_; // flag to recognice if we are in generic or templates
243 
244  const MagneticField * magfield_; // magnetic field
245  const TrackerGeometry & geom_; // geometry
246  const TrackerTopology & ttopo_; // Tracker Topology
247 
249  const SiPixelLorentzAngle * lorentzAngleWidth_; // for the charge width (generic)
250 
252  //const SiPixelCPEGenericErrorParm * genErrorParm_; // OLD
253 
255  bool alpha2Order; // switch on/off E.B effect.
256 
259 
260  //---------------------------------------------------------------------------
261  // Geometrical services to subclasses.
262  //---------------------------------------------------------------------------
263 protected:
264  void computeAnglesFromDetPosition( DetParam const & theDetParam, ClusterParam & theClusterParam ) const;
265 
266  void computeAnglesFromTrajectory ( DetParam const & theDetParam, ClusterParam & theClusterParam,
267  const LocalTrajectoryParameters & ltp) const;
268 
269  void setTheClu( DetParam const &, ClusterParam & theClusterParam ) const ;
270 
271  LocalVector driftDirection (DetParam & theDetParam, GlobalVector bfield ) const ;
272  LocalVector driftDirection (DetParam & theDetParam, LocalVector bfield ) const ;
273  void computeLorentzShifts(DetParam &) const ;
274 
275 
276  //---------------------------------------------------------------------------
277  // Cluster-level services.
278  //---------------------------------------------------------------------------
279 
280  DetParam const & detParam(const GeomDetUnit & det) const;
281 
282  using DetParams=std::vector<DetParam>;
283 
285 
286 };
287 
288 #endif
289 
290 
Local3DPoint theOrigin
Definition: PixelCPEBase.h:66
const SiPixelLorentzAngle * lorentzAngleWidth_
Definition: PixelCPEBase.h:249
ReturnType getParameters(const SiPixelCluster &cl, const GeomDetUnit &det) const override
Definition: PixelCPEBase.h:142
T mag() const
The vector magnitude. Equivalent to sqrt(vec.mag2())
const SiPixelCluster * theCluster
Definition: PixelCPEBase.h:88
ClusterParam(const SiPixelCluster &cl)
Definition: PixelCPEBase.h:84
DetParams m_DetParams
Definition: PixelCPEBase.h:284
void fillDetParams()
const PixelGeomDetUnit * theDet
Definition: PixelCPEBase.h:60
GeomDetType::SubDetector thePart
Definition: PixelCPEBase.h:65
const RectangularPixelTopology * theRecTopol
Definition: PixelCPEBase.h:63
bool useLAWidthFromDB_
Definition: PixelCPEBase.h:238
float lAWidthBPix_
Definition: PixelCPEBase.h:233
bool useLAWidthFromConfig_
Definition: PixelCPEBase.h:237
const PixelTopology * theTopol
Definition: PixelCPEBase.h:62
bool LoadTemplatesFromDB_
Definition: PixelCPEBase.h:258
void computeAnglesFromTrajectory(DetParam const &theDetParam, ClusterParam &theClusterParam, const LocalTrajectoryParameters &ltp) const
virtual ClusterParam * createClusterParam(const SiPixelCluster &cl) const =0
void computeLorentzShifts(DetParam &) const
const SiPixelTemplateDBObject * templateDBobject_
Definition: PixelCPEBase.h:254
const MagneticField * magfield_
Definition: PixelCPEBase.h:244
void computeAnglesFromDetPosition(DetParam const &theDetParam, ClusterParam &theClusterParam) const
SiPixelRecHitQuality::QualWordType rawQualityWord(ClusterParam &theClusterParam) const
Topology::LocalTrackPred loc_trk_pred
Definition: PixelCPEBase.h:102
std::vector< DetParam > DetParams
Definition: PixelCPEBase.h:282
const TrackerTopology & ttopo_
Definition: PixelCPEBase.h:246
const SiPixelLorentzAngle * lorentzAngle_
Definition: PixelCPEBase.h:248
const SiPixelGenErrorDBObject * genErrorDBObject_
Definition: PixelCPEBase.h:251
void setTheClu(DetParam const &, ClusterParam &theClusterParam) const
bool useLAOffsetFromConfig_
Definition: PixelCPEBase.h:236
GloballyPositioned< double > Frame
Definition: PixelCPEBase.h:219
Pixel cluster – collection of neighboring pixels above threshold.
const TrackerGeometry & geom_
Definition: PixelCPEBase.h:245
PixelCPEBase(edm::ParameterSet const &conf, const MagneticField *mag, const TrackerGeometry &geom, const TrackerTopology &ttopo, const SiPixelLorentzAngle *lorentzAngle, const SiPixelGenErrorDBObject *genErrorDBObject, const SiPixelTemplateDBObject *templateDBobject, const SiPixelLorentzAngle *lorentzAngleWidth, int flag=0)
Definition: PixelCPEBase.cc:32
LocalVector driftDirection
Definition: PixelCPEBase.h:73
ReturnType getParameters(const SiPixelCluster &cl, const GeomDetUnit &det, const LocalTrajectoryParameters &ltp) const override
Definition: PixelCPEBase.h:169
std::tuple< LocalPoint, LocalError, SiPixelRecHitQuality::QualWordType > ReturnType
virtual LocalError localError(DetParam const &theDetParam, ClusterParam &theClusterParam) const =0
virtual LocalPoint localPosition(DetParam const &theDetParam, ClusterParam &theClusterParam) const =0
float lAWidthFPix_
Definition: PixelCPEBase.h:234
DetParam const & detParam(const GeomDetUnit &det) const