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:
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 public:
56  struct DetParam {
57  DetParam() {}
59  // gavril : replace RectangularPixelTopology with PixelTopology
62 
65  float theThickness;
66  float thePitchX;
67  float thePitchY;
68 
69  float bz; // local Bz
70  float bx; // local Bx
72  float widthLAFractionX; // Width-LA to Offset-LA in X
73  float widthLAFractionY; // same in Y
74  float lorentzShiftInCmX; // a FULL shift, in cm
75  float lorentzShiftInCmY; // a FULL shift, in cm
76  int detTemplateId; // det if for templates & generic errors
77  int detTemplateId2D; // det if for 2D templates
78  };
79 
80  struct ClusterParam {
82 
83  virtual ~ClusterParam() = default;
84 
86 
87  //--- Cluster-level quantities (filled in computeAnglesFrom....)
88  float cotalpha;
89  float cotbeta;
90 
91  // G.Giurgiu (05/14/08) track local coordinates
92  // filled in computeAnglesFrom....
93  float trk_lp_x;
94  float trk_lp_y;
95 
96  // ggiurgiu@jhu.edu (12/01/2010) : Needed for calling topology methods
97  // with track angles to handle surface deformations (bows/kinks)
98  // filled in computeAnglesFrom.... (btw redundant with the 4 above)
100 
101  //--- Probability (protected by hasFilledProb_)
105  int qBin_; // always filled by qbin
106 
107  bool isOnEdge_; // filled in setTheClu
108  bool hasBadPixels_ = false; // (never used in current code)
109  bool spansTwoROCs_; // filled in setTheClu
110  bool hasFilledProb_ = false;
111  // ggiurgiu@jhu.edu (10/18/2008)
112  bool with_track_angle; // filled in computeAnglesFrom....
113  bool filled_from_2d = false; //
114 
115  // More detailed edge information (for CPE ClusterRepair, and elsewhere...)
116  int edgeTypeX_ = 0; // 0: not on edge, 1: low end on edge, 2: high end
117  int edgeTypeY_ = 0; // 0: not on edge, 1: low end on edge, 2: high end
118  };
119 
120 public:
121  PixelCPEBase(edm::ParameterSet const& conf,
122  const MagneticField* mag,
123  const TrackerGeometry& geom,
124  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 
133 
134  //--------------------------------------------------------------------------
135  // Allow the magnetic field to be set/updated later.
136  //--------------------------------------------------------------------------
137  //inline void setMagField(const MagneticField *mag) const { magfield_ = mag; } // Not used, AH
138 
139  //--------------------------------------------------------------------------
140  // Obtain the angles from the position of the DetUnit.
141  //--------------------------------------------------------------------------
142 
143  inline ReturnType getParameters(const SiPixelCluster& cl, const GeomDetUnit& det) const override {
144 #ifdef EDM_ML_DEBUG
145  nRecHitsTotal_++;
146  //std::cout<<" in PixelCPEBase:localParameters(all) - "<<nRecHitsTotal_<<std::endl; //dk
147 #endif
148 
149  DetParam const& theDetParam = detParam(det);
150  std::unique_ptr<ClusterParam> theClusterParam = createClusterParam(cl);
151  setTheClu(theDetParam, *theClusterParam);
152  computeAnglesFromDetPosition(theDetParam, *theClusterParam);
153 
154  // localPosition( cl, det ) must be called before localError( cl, det ) !!!
155  LocalPoint lp = localPosition(theDetParam, *theClusterParam);
156  LocalError le = localError(theDetParam, *theClusterParam);
157  SiPixelRecHitQuality::QualWordType rqw = rawQualityWord(*theClusterParam);
158  auto tuple = std::make_tuple(lp, le, rqw);
159 
160  //std::cout<<" in PixelCPEBase:localParameters(all) - "<<lp.x()<<" "<<lp.y()<<std::endl; //dk
161  return tuple;
162  }
163 
164  //--------------------------------------------------------------------------
165  // In principle we could use the track too to obtain alpha and beta.
166  //--------------------------------------------------------------------------
168  const GeomDetUnit& det,
169  const LocalTrajectoryParameters& ltp) const override {
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  std::unique_ptr<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 
186  //std::cout<<" in PixelCPEBase:localParameters(on track) - "<<lp.x()<<" "<<lp.y()<<std::endl; //dk
187  return tuple;
188  }
189 
190 private:
191  virtual std::unique_ptr<ClusterParam> createClusterParam(const SiPixelCluster& cl) const = 0;
192 
193  //--------------------------------------------------------------------------
194  // This is where the action happens.
195  //--------------------------------------------------------------------------
196  virtual LocalPoint localPosition(DetParam const& theDetParam, ClusterParam& theClusterParam) const = 0;
197  virtual LocalError localError(DetParam const& theDetParam, ClusterParam& theClusterParam) const = 0;
198 
199  void fillDetParams();
200 
201  //-----------------------------------------------------------------------------
206  //-----------------------------------------------------------------------------
207  SiPixelRecHitQuality::QualWordType rawQualityWord(ClusterParam& theClusterParam) const;
208 
209 protected:
210  //--- All methods and data members are protected to facilitate (for now)
211  //--- access from derived classes.
212 
214 
215  //---------------------------------------------------------------------------
216  // Data members
217  //---------------------------------------------------------------------------
218 
219  //--- Counters
220 #ifdef EDM_ML_DEBUG
221  mutable std::atomic<int> nRecHitsTotal_; //for debugging only
222  mutable std::atomic<int> nRecHitsUsedEdge_; //for debugging only
223 #endif
224 
225  // Added new members
226  float lAOffset_; // la used to calculate the offset from configuration (for testing)
227  float lAWidthBPix_; // la used to calculate the cluster width from conf.
228  float lAWidthFPix_; // la used to calculate the cluster width from conf.
229  //bool useLAAlignmentOffsets_; // lorentz angle offsets detrmined by alignment
230  bool useLAOffsetFromConfig_; // lorentz angle used to calculate the offset
231  bool useLAWidthFromConfig_; // lorentz angle used to calculate the cluster width
232  bool useLAWidthFromDB_; // lorentz angle used to calculate the cluster width
233 
234  //--- Global quantities
235  int theVerboseLevel; // algorithm's verbosity
236  int theFlag_; // flag to recognice if we are in generic or templates
237 
238  const MagneticField* magfield_; // magnetic field
239  const TrackerGeometry& geom_; // geometry
240  const TrackerTopology& ttopo_; // Tracker Topology
241 
243  const SiPixelLorentzAngle* lorentzAngleWidth_; // for the charge width (generic)
244 
246  //const SiPixelCPEGenericErrorParm * genErrorParm_; // OLD
247 
249  bool alpha2Order; // switch on/off E.B effect.
250 
253 
254  //---------------------------------------------------------------------------
255  // Geometrical services to subclasses.
256  //---------------------------------------------------------------------------
257 protected:
258  void computeAnglesFromDetPosition(DetParam const& theDetParam, ClusterParam& theClusterParam) const;
259 
260  void computeAnglesFromTrajectory(DetParam const& theDetParam,
261  ClusterParam& theClusterParam,
262  const LocalTrajectoryParameters& ltp) const;
263 
264  void setTheClu(DetParam const&, ClusterParam& theClusterParam) const;
265 
266  LocalVector driftDirection(DetParam& theDetParam, GlobalVector bfield) const;
267  LocalVector driftDirection(DetParam& theDetParam, LocalVector bfield) const;
268  void computeLorentzShifts(DetParam&) const;
269 
270  //---------------------------------------------------------------------------
271  // Cluster-level services.
272  //---------------------------------------------------------------------------
273 
274  DetParam const& detParam(const GeomDetUnit& det) const;
275 
276  using DetParams = std::vector<DetParam>;
277 
279 };
280 
281 #endif
Vector3DBase< float, LocalTag >
GloballyPositioned
Definition: GloballyPositioned.h:18
ConfigurationDescriptions.h
GeomDetEnumerators::SubDetector
SubDetector
Definition: GeomDetEnumerators.h:10
PixelClusterParameterEstimator
Definition: PixelClusterParameterEstimator.h:15
PixelCPEBase::getParameters
ReturnType getParameters(const SiPixelCluster &cl, const GeomDetUnit &det) const override
Definition: PixelCPEBase.h:143
PixelCPEBase::ClusterParam
Definition: PixelCPEBase.h:80
PixelCPEBase::useLAOffsetFromConfig_
bool useLAOffsetFromConfig_
Definition: PixelCPEBase.h:230
PixelCPEBase::DetParam::bz
float bz
Definition: PixelCPEBase.h:69
PixelCPEBase::DetParam::bx
float bx
Definition: PixelCPEBase.h:70
PixelCPEBase::DetParam::theTopol
const PixelTopology * theTopol
Definition: PixelCPEBase.h:60
SiPixelRecHitQuality.h
PixelCPEBase::DetParam::lorentzShiftInCmY
float lorentzShiftInCmY
Definition: PixelCPEBase.h:75
PixelCPEBase::DetParam::thePitchX
float thePitchX
Definition: PixelCPEBase.h:66
PixelCPEBase::DetParam::widthLAFractionX
float widthLAFractionX
Definition: PixelCPEBase.h:72
PixelCPEBase::Frame
GloballyPositioned< double > Frame
Definition: PixelCPEBase.h:213
PixelCPEBase::templateDBobject_
const SiPixelTemplateDBObject * templateDBobject_
Definition: PixelCPEBase.h:248
PixelCPEBase::ClusterParam::ClusterParam
ClusterParam(const SiPixelCluster &cl)
Definition: PixelCPEBase.h:81
TrackerGeometry.h
GeomDet
Definition: GeomDet.h:27
PixelTopology.h
PixelCPEBase::DetParam::theRecTopol
const RectangularPixelTopology * theRecTopol
Definition: PixelCPEBase.h:61
PixelCPEBase::DetParam::theThickness
float theThickness
Definition: PixelCPEBase.h:65
TrackerTopology
Definition: TrackerTopology.h:16
PixelCPEBase::genErrorDBObject_
const SiPixelGenErrorDBObject * genErrorDBObject_
Definition: PixelCPEBase.h:245
PixelCPEBase::ttopo_
const TrackerTopology & ttopo_
Definition: PixelCPEBase.h:240
PixelClusterParameterEstimator.h
PixelCPEBase::DetParam::widthLAFractionY
float widthLAFractionY
Definition: PixelCPEBase.h:73
edm::ParameterSetDescription
Definition: ParameterSetDescription.h:52
MeasurementError.h
PixelCPEBase::useLAWidthFromDB_
bool useLAWidthFromDB_
Definition: PixelCPEBase.h:232
PixelCPEBase::DetParam::thePitchY
float thePitchY
Definition: PixelCPEBase.h:67
GeomDetType.h
PixelCPEBase::createClusterParam
virtual std::unique_ptr< ClusterParam > createClusterParam(const SiPixelCluster &cl) const =0
PixelCPEBase::driftDirection
LocalVector driftDirection(DetParam &theDetParam, GlobalVector bfield) const
Definition: PixelCPEBase.cc:336
PixelCPEBase::geom_
const TrackerGeometry & geom_
Definition: PixelCPEBase.h:239
PixelCPEBase::theFlag_
int theFlag_
Definition: PixelCPEBase.h:236
SiPixelCluster
Pixel cluster – collection of neighboring pixels above threshold.
Definition: SiPixelCluster.h:27
PixelCPEBase::alpha2Order
bool alpha2Order
Definition: PixelCPEBase.h:249
PixelCPEBase::detParam
DetParam const & detParam(const GeomDetUnit &det) const
Definition: PixelCPEBase.cc:320
PixelCPEBase::ClusterParam::hasFilledProb_
bool hasFilledProb_
Definition: PixelCPEBase.h:110
PixelCPEBase::DetParam::theDet
const PixelGeomDetUnit * theDet
Definition: PixelCPEBase.h:58
PixelCPEBase::ClusterParam::theCluster
const SiPixelCluster * theCluster
Definition: PixelCPEBase.h:85
PixelCPEBase::computeAnglesFromTrajectory
void computeAnglesFromTrajectory(DetParam const &theDetParam, ClusterParam &theClusterParam, const LocalTrajectoryParameters &ltp) const
Definition: PixelCPEBase.cc:255
LocalTrajectoryParameters
Definition: LocalTrajectoryParameters.h:25
GetRecoTauVFromDQM_MC_cff.cl
cl
Definition: GetRecoTauVFromDQM_MC_cff.py:38
TrackerTopology.h
PixelCPEBase::localError
virtual LocalError localError(DetParam const &theDetParam, ClusterParam &theClusterParam) const =0
RectangularPixelTopology
Definition: RectangularPixelTopology.h:39
PixelCPEBase::m_DetParams
DetParams m_DetParams
Definition: PixelCPEBase.h:278
SiPixelRecHitQuality::QualWordType
unsigned int QualWordType
Definition: SiPixelRecHitQuality.h:10
PixelGeomDetUnit
Definition: PixelGeomDetUnit.h:15
GloballyPositioned.h
SiPixelLorentzAngle
Definition: SiPixelLorentzAngle.h:11
Topology::LocalTrackPred
Definition: Topology.h:56
relativeConstraints.geom
geom
Definition: relativeConstraints.py:72
PixelCPEBase::useLAWidthFromConfig_
bool useLAWidthFromConfig_
Definition: PixelCPEBase.h:231
Point3DBase< float, LocalTag >
PixelTopology
Definition: PixelTopology.h:10
PixelCPEBase::DetParam::detTemplateId2D
int detTemplateId2D
Definition: PixelCPEBase.h:77
PixelCPEBase::ClusterParam::filled_from_2d
bool filled_from_2d
Definition: PixelCPEBase.h:113
PixelCPEBase::ClusterParam::spansTwoROCs_
bool spansTwoROCs_
Definition: PixelCPEBase.h:109
PixelCPEBase::DetParams
std::vector< DetParam > DetParams
Definition: PixelCPEBase.h:276
PixelCPEBase::ClusterParam::hasBadPixels_
bool hasBadPixels_
Definition: PixelCPEBase.h:108
edm::ParameterSet
Definition: ParameterSet.h:36
SiPixelTemplateDBObject.h
PixelCPEBase::setTheClu
void setTheClu(DetParam const &, ClusterParam &theClusterParam) const
Definition: PixelCPEBase.cc:212
LocalError
Definition: LocalError.h:12
PixelCPEBase::lorentzAngle_
const SiPixelLorentzAngle * lorentzAngle_
Definition: PixelCPEBase.h:242
PixelCPEBase::lAWidthFPix_
float lAWidthFPix_
Definition: PixelCPEBase.h:228
SiPixelTemplateDBObject
Definition: SiPixelTemplateDBObject.h:16
PixelCPEBase::ClusterParam::probabilityY_
float probabilityY_
Definition: PixelCPEBase.h:103
PixelCPEBase::theVerboseLevel
int theVerboseLevel
Definition: PixelCPEBase.h:235
PixelCPEBase::DoLorentz_
bool DoLorentz_
Definition: PixelCPEBase.h:251
PixelCPEBase::DetParam::DetParam
DetParam()
Definition: PixelCPEBase.h:57
MeasurementPoint.h
PixelCPEBase::PixelCPEBase
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:30
PixelCPEBase::lorentzAngleWidth_
const SiPixelLorentzAngle * lorentzAngleWidth_
Definition: PixelCPEBase.h:243
PixelCPEBase::LoadTemplatesFromDB_
bool LoadTemplatesFromDB_
Definition: PixelCPEBase.h:252
PixelCPEBase::DetParam::detTemplateId
int detTemplateId
Definition: PixelCPEBase.h:76
PixelCPEBase::DetParam::thePart
GeomDetType::SubDetector thePart
Definition: PixelCPEBase.h:63
PixelCPEBase::DetParam::lorentzShiftInCmX
float lorentzShiftInCmX
Definition: PixelCPEBase.h:74
PixelCPEBase::ClusterParam::edgeTypeY_
int edgeTypeY_
Definition: PixelCPEBase.h:117
PixelCPEBase::computeAnglesFromDetPosition
void computeAnglesFromDetPosition(DetParam const &theDetParam, ClusterParam &theClusterParam) const
Definition: PixelCPEBase.cc:289
PixelCPEBase::localPosition
virtual LocalPoint localPosition(DetParam const &theDetParam, ClusterParam &theClusterParam) const =0
mag
T mag() const
The vector magnitude. Equivalent to sqrt(vec.mag2())
Definition: Basic3DVectorLD.h:127
PixelCPEBase::DetParam
Definition: PixelCPEBase.h:56
PixelCPEBase::ClusterParam::probabilityX_
float probabilityX_
Definition: PixelCPEBase.h:102
SiPixelGenErrorDBObject.h
PixelCPEBase::ClusterParam::probabilityQ_
float probabilityQ_
Definition: PixelCPEBase.h:104
PixelCPEBase::ClusterParam::isOnEdge_
bool isOnEdge_
Definition: PixelCPEBase.h:107
PixelCPEBase::DetParam::theOrigin
Local3DPoint theOrigin
Definition: PixelCPEBase.h:64
PixelCPEBase::DetParam::driftDirection
LocalVector driftDirection
Definition: PixelCPEBase.h:71
PixelCPEBase
Definition: PixelCPEBase.h:54
PixelGeomDetUnit.h
PixelCPEBase::computeLorentzShifts
void computeLorentzShifts(DetParam &) const
Definition: PixelCPEBase.cc:421
PixelCPEBase::ClusterParam::loc_trk_pred
Topology::LocalTrackPred loc_trk_pred
Definition: PixelCPEBase.h:99
SiPixelLorentzAngle.h
PixelCPEBase::fillPSetDescription
static void fillPSetDescription(edm::ParameterSetDescription &desc)
Definition: PixelCPEBase.cc:465
PixelCPEBase::ClusterParam::trk_lp_x
float trk_lp_x
Definition: PixelCPEBase.h:93
PixelCPEBase::rawQualityWord
SiPixelRecHitQuality::QualWordType rawQualityWord(ClusterParam &theClusterParam) const
Definition: PixelCPEBase.cc:439
PixelCPEBase::ClusterParam::cotbeta
float cotbeta
Definition: PixelCPEBase.h:89
SiPixelGenErrorDBObject
Definition: SiPixelGenErrorDBObject.h:16
PixelCPEBase::lAWidthBPix_
float lAWidthBPix_
Definition: PixelCPEBase.h:227
ParameterSet.h
PixelCPEBase::fillDetParams
void fillDetParams()
Definition: PixelCPEBase.cc:120
PixelCPEBase::ClusterParam::cotalpha
float cotalpha
Definition: PixelCPEBase.h:88
PixelCPEBase::getParameters
ReturnType getParameters(const SiPixelCluster &cl, const GeomDetUnit &det, const LocalTrajectoryParameters &ltp) const override
Definition: PixelCPEBase.h:167
PixelCPEBase::ClusterParam::trk_lp_y
float trk_lp_y
Definition: PixelCPEBase.h:94
MagneticField
Definition: MagneticField.h:19
Topology.h
PixelCPEBase::ClusterParam::with_track_angle
bool with_track_angle
Definition: PixelCPEBase.h:112
PixelCPEBase::ClusterParam::edgeTypeX_
int edgeTypeX_
Definition: PixelCPEBase.h:116
PixelCPEBase::magfield_
const MagneticField * magfield_
Definition: PixelCPEBase.h:238
PixelCPEBase::ClusterParam::~ClusterParam
virtual ~ClusterParam()=default
RemoveAddSevLevel.flag
flag
Definition: RemoveAddSevLevel.py:116
PixelCPEBase::lAOffset_
float lAOffset_
Definition: PixelCPEBase.h:226
PixelClusterParameterEstimator::ReturnType
std::tuple< LocalPoint, LocalError, SiPixelRecHitQuality::QualWordType > ReturnType
Definition: PixelClusterParameterEstimator.h:22
TrackerGeometry
Definition: TrackerGeometry.h:14
PixelCPEBase::ClusterParam::qBin_
int qBin_
Definition: PixelCPEBase.h:105