test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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  //float theDetR;
71  //float theDetZ;
72  //float theNumOfRow; //Not used, AH
73  //float theNumOfCol; //Not used, AH
74  //float theSign; //Not used, AH
75 
76  float bz; // local Bz
78  float widthLAFractionX; // Width-LA to Offset-LA in X
79  float widthLAFractionY; // same in Y
80  float lorentzShiftInCmX; // a FULL shift, in cm
81  float lorentzShiftInCmY; // a FULL shift, in cm
82  int detTemplateId; // det if for templates & generic errors
83  };
84 
85  struct ClusterParam
86  {
87  ClusterParam(const SiPixelCluster & cl) : theCluster(&cl), loc_trk_pred(0.0,0.0,0.0,0.0),
88  probabilityX_(0.0), probabilityY_(0.0), probabilityQ_(0.0), qBin_(0.0),
91 
92  //--- Cluster-level quantities (may need more)
93  float cotalpha;
94  float cotbeta;
95  //bool zneg; // Not used, AH
96 
97  // G.Giurgiu (05/14/08) track local coordinates
98  float trk_lp_x;
99  float trk_lp_y;
100 
101  // ggiurgiu@jhu.edu (12/01/2010) : Needed for calling topology methods
102  // with track angles to handle surface deformations (bows/kinks)
104  //LocalTrajectoryParameters loc_traj_param; // Not used, AH
105 
106  // ggiurgiu@jhu.edu (10/18/2008)
108 
109  //--- Probability
110  float probabilityX_ ;
111  float probabilityY_ ;
112  float probabilityQ_ ;
113  float qBin_ ;
114  bool isOnEdge_ ;
118  };
119 
120 public:
121  PixelCPEBase(edm::ParameterSet const& conf, const MagneticField * mag, const TrackerGeometry& geom, const TrackerTopology& ttopo,
122  const SiPixelLorentzAngle * lorentzAngle,
123  const SiPixelGenErrorDBObject * genErrorDBObject,
124  const SiPixelTemplateDBObject * templateDBobject,
125  const SiPixelLorentzAngle * lorentzAngleWidth,
126  int flag=0 // flag=0 for generic, =1 for templates
127  ); // NEW
128 
129  //--------------------------------------------------------------------------
130  // Allow the magnetic field to be set/updated later.
131  //--------------------------------------------------------------------------
132  //inline void setMagField(const MagneticField *mag) const { magfield_ = mag; } // Not used, AH
133 
134 
135  //--------------------------------------------------------------------------
136  // Obtain the angles from the position of the DetUnit.
137  //--------------------------------------------------------------------------
138 
140  const GeomDetUnit & det ) const
141  {
142 #ifdef EDM_ML_DEBUG
143  nRecHitsTotal_++ ;
144  //std::cout<<" in PixelCPEBase:localParameters(all) - "<<nRecHitsTotal_<<std::endl; //dk
145 #endif
146 
147  DetParam const & theDetParam = detParam(det);
148  ClusterParam * theClusterParam = createClusterParam(cl);
149  setTheClu( theDetParam, *theClusterParam );
150  computeAnglesFromDetPosition(theDetParam, *theClusterParam);
151 
152  // localPosition( cl, det ) must be called before localError( cl, det ) !!!
153  LocalPoint lp = localPosition(theDetParam, *theClusterParam);
154  LocalError le = localError(theDetParam, *theClusterParam);
155  SiPixelRecHitQuality::QualWordType rqw = rawQualityWord(*theClusterParam);
156  auto tuple = std::make_tuple(lp, le , rqw);
157  delete theClusterParam;
158 
159  //std::cout<<" in PixelCPEBase:localParameters(all) - "<<lp.x()<<" "<<lp.y()<<std::endl; //dk
160  return tuple;
161  }
162 
163  //--------------------------------------------------------------------------
164  // In principle we could use the track too to obtain alpha and beta.
165  //--------------------------------------------------------------------------
167  const GeomDetUnit & det,
168  const LocalTrajectoryParameters & ltp ) const
169  {
170 #ifdef EDM_ML_DEBUG
171  nRecHitsTotal_++ ;
172  //std::cout<<" in PixelCPEBase:localParameters(on track) - "<<nRecHitsTotal_<<std::endl; //dk
173 #endif
174 
175  DetParam const & theDetParam = detParam(det);
176  ClusterParam * theClusterParam = createClusterParam(cl);
177  setTheClu( theDetParam, *theClusterParam );
178  computeAnglesFromTrajectory(theDetParam, *theClusterParam, ltp);
179 
180  // localPosition( cl, det ) must be called before localError( cl, det ) !!!
181  LocalPoint lp = localPosition(theDetParam, *theClusterParam);
182  LocalError le = localError(theDetParam, *theClusterParam);
183  SiPixelRecHitQuality::QualWordType rqw = rawQualityWord(*theClusterParam);
184  auto tuple = std::make_tuple(lp, le , rqw);
185  delete theClusterParam;
186 
187  //std::cout<<" in PixelCPEBase:localParameters(on track) - "<<lp.x()<<" "<<lp.y()<<std::endl; //dk
188  return tuple;
189  }
190 
191 
192 
193 private:
194  virtual ClusterParam * createClusterParam(const SiPixelCluster & cl) const = 0;
195 
196  //--------------------------------------------------------------------------
197  // This is where the action happens.
198  //--------------------------------------------------------------------------
199  virtual LocalPoint localPosition(DetParam const & theDetParam, ClusterParam & theClusterParam) const = 0;
200  virtual LocalError localError (DetParam const & theDetParam, ClusterParam & theClusterParam) const = 0;
201 
202  void fillDetParams();
203 
204  //-----------------------------------------------------------------------------
209  //-----------------------------------------------------------------------------
210  SiPixelRecHitQuality::QualWordType rawQualityWord(ClusterParam & theClusterParam) const;
211 
212  protected:
213  //--- All methods and data members are protected to facilitate (for now)
214  //--- access from derived classes.
215 
217 
218  //---------------------------------------------------------------------------
219  // Data members
220  //---------------------------------------------------------------------------
221 
222  //--- Counters
223 #ifdef EDM_ML_DEBUG
224  mutable std::atomic<int> nRecHitsTotal_ ; //for debugging only
225  mutable std::atomic<int> nRecHitsUsedEdge_ ; //for debugging only
226 #endif
227 
228  // Added new members
229  float lAOffset_; // la used to calculate the offset from configuration (for testing)
230  float lAWidthBPix_; // la used to calculate the cluster width from conf.
231  float lAWidthFPix_; // la used to calculate the cluster width from conf.
232  //bool useLAAlignmentOffsets_; // lorentz angle offsets detrmined by alignment
233  bool useLAOffsetFromConfig_; // lorentz angle used to calculate the offset
234  bool useLAWidthFromConfig_; // lorentz angle used to calculate the cluster width
235  bool useLAWidthFromDB_; // lorentz angle used to calculate the cluster width
236 
237  //--- Global quantities
238  int theVerboseLevel; // algorithm's verbosity
239  int theFlag_; // flag to recognice if we are in generic or templates
240 
241  const MagneticField * magfield_; // magnetic field
242  const TrackerGeometry & geom_; // geometry
243  const TrackerTopology & ttopo_; // Tracker Topology
244 
246  const SiPixelLorentzAngle * lorentzAngleWidth_; // for the charge width (generic)
247 
249  //const SiPixelCPEGenericErrorParm * genErrorParm_; // OLD
250 
252  bool alpha2Order; // switch on/off E.B effect.
253 
256 
257  //---------------------------------------------------------------------------
258  // Geometrical services to subclasses.
259  //---------------------------------------------------------------------------
260 private:
261  void computeAnglesFromDetPosition( DetParam const & theDetParam, ClusterParam & theClusterParam ) const;
262 
263  void computeAnglesFromTrajectory ( DetParam const & theDetParam, ClusterParam & theClusterParam,
264  const LocalTrajectoryParameters & ltp) const;
265 
266  void setTheClu( DetParam const &, ClusterParam & theClusterParam ) const ;
267 
268  LocalVector driftDirection (DetParam & theDetParam, GlobalVector bfield ) const ;
269  LocalVector driftDirection (DetParam & theDetParam, LocalVector bfield ) const ;
270  void computeLorentzShifts(DetParam &) const ;
271 
272  bool isFlipped(DetParam const & theDetParam) const; // is the det flipped or not?
273 
274  //---------------------------------------------------------------------------
275  // Cluster-level services.
276  //---------------------------------------------------------------------------
277 
278  DetParam const & detParam(const GeomDetUnit & det) const;
279 
280  using DetParams=std::vector<DetParam>;
281 
283 
284 };
285 
286 #endif
287 
288 
Local3DPoint theOrigin
Definition: PixelCPEBase.h:66
const SiPixelLorentzAngle * lorentzAngleWidth_
Definition: PixelCPEBase.h:246
LocalVector driftDirection(DetParam &theDetParam, GlobalVector bfield) const
T mag() const
The vector magnitude. Equivalent to sqrt(vec.mag2())
const SiPixelCluster * theCluster
Definition: PixelCPEBase.h:90
ClusterParam(const SiPixelCluster &cl)
Definition: PixelCPEBase.h:87
bool isFlipped(DetParam const &theDetParam) const
DetParams m_DetParams
Definition: PixelCPEBase.h:282
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:235
float lAWidthBPix_
Definition: PixelCPEBase.h:230
bool useLAWidthFromConfig_
Definition: PixelCPEBase.h:234
virtual ClusterParam * createClusterParam(const SiPixelCluster &cl) const =0
const PixelTopology * theTopol
Definition: PixelCPEBase.h:62
bool LoadTemplatesFromDB_
Definition: PixelCPEBase.h:255
void computeAnglesFromTrajectory(DetParam const &theDetParam, ClusterParam &theClusterParam, const LocalTrajectoryParameters &ltp) const
virtual LocalPoint localPosition(DetParam const &theDetParam, ClusterParam &theClusterParam) const =0
void computeLorentzShifts(DetParam &) const
const SiPixelTemplateDBObject * templateDBobject_
Definition: PixelCPEBase.h:251
const MagneticField * magfield_
Definition: PixelCPEBase.h:241
void computeAnglesFromDetPosition(DetParam const &theDetParam, ClusterParam &theClusterParam) const
SiPixelRecHitQuality::QualWordType rawQualityWord(ClusterParam &theClusterParam) const
Topology::LocalTrackPred loc_trk_pred
Definition: PixelCPEBase.h:103
std::vector< DetParam > DetParams
Definition: PixelCPEBase.h:280
const TrackerTopology & ttopo_
Definition: PixelCPEBase.h:243
const SiPixelLorentzAngle * lorentzAngle_
Definition: PixelCPEBase.h:245
const SiPixelGenErrorDBObject * genErrorDBObject_
Definition: PixelCPEBase.h:248
void setTheClu(DetParam const &, ClusterParam &theClusterParam) const
ReturnType getParameters(const SiPixelCluster &cl, const GeomDetUnit &det, const LocalTrajectoryParameters &ltp) const
Definition: PixelCPEBase.h:166
bool useLAOffsetFromConfig_
Definition: PixelCPEBase.h:233
GloballyPositioned< double > Frame
Definition: PixelCPEBase.h:216
Pixel cluster – collection of neighboring pixels above threshold.
const TrackerGeometry & geom_
Definition: PixelCPEBase.h:242
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
virtual LocalError localError(DetParam const &theDetParam, ClusterParam &theClusterParam) const =0
LocalVector driftDirection
Definition: PixelCPEBase.h:77
volatile std::atomic< bool > shutdown_flag false
std::tuple< LocalPoint, LocalError, SiPixelRecHitQuality::QualWordType > ReturnType
ReturnType getParameters(const SiPixelCluster &cl, const GeomDetUnit &det) const
Definition: PixelCPEBase.h:139
float lAWidthFPix_
Definition: PixelCPEBase.h:231
DetParam const & detParam(const GeomDetUnit &det) const