00001 #ifndef RecoLocalTracker_SiPixelRecHits_PixelCPEBase_H
00002 #define RecoLocalTracker_SiPixelRecHits_PixelCPEBase_H 1
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013 #include <utility>
00014 #include <vector>
00015 #include "TMath.h"
00016
00017 #include "RecoLocalTracker/ClusterParameterEstimator/interface/PixelClusterParameterEstimator.h"
00018 #include "RecoLocalTracker/SiPixelRecHits/interface/EtaCorrection.h"
00019
00020 #include "Geometry/CommonDetUnit/interface/GeomDetType.h"
00021 #include "Geometry/TrackerGeometryBuilder/interface/PixelGeomDetUnit.h"
00022 #include "Geometry/TrackerTopology/interface/RectangularPixelTopology.h"
00023
00024
00025 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00026
00027
00028 #ifdef TP_OLD
00029 #include "Geometry/CommonDetAlgo/interface/MeasurementPoint.h"
00030 #include "Geometry/CommonDetAlgo/interface/MeasurementError.h"
00031 #include "Geometry/Surface/interface/GloballyPositioned.h"
00032 #else // new location
00033 #include "DataFormats/GeometryCommonDetAlgo/interface/MeasurementPoint.h"
00034 #include "DataFormats/GeometryCommonDetAlgo/interface/MeasurementError.h"
00035 #include "DataFormats/GeometrySurface/interface/GloballyPositioned.h"
00036 #endif
00037
00038 #include "CondFormats/SiPixelObjects/interface/SiPixelLorentzAngle.h"
00039 #include <ext/hash_map>
00040
00041 class MagneticField;
00042 class SiPixelCPEParmErrors;
00043 class PixelCPEBase : public PixelClusterParameterEstimator {
00044 public:
00045
00046 PixelCPEBase(edm::ParameterSet const& conf, const MagneticField * mag = 0, const SiPixelLorentzAngle * lorentzAngle = 0);
00047
00048
00049
00050
00051
00052 inline LocalValues localParameters( const SiPixelCluster & cl,
00053 const GeomDetUnit & det ) const
00054 {
00055 nRecHitsTotal_++ ;
00056 setTheDet( det );
00057 computeAnglesFromDetPosition(cl, det);
00058 return std::make_pair( localPosition(cl,det), localError(cl,det) );
00059 }
00060
00061
00062
00063
00064 inline LocalValues localParameters( const SiPixelCluster & cl,
00065 const GeomDetUnit & det,
00066 const LocalTrajectoryParameters & ltp) const
00067 {
00068 nRecHitsTotal_++ ;
00069 setTheDet( det );
00070 computeAnglesFromTrajectory(cl, det, ltp);
00071 return std::make_pair( localPosition(cl,det), localError(cl,det) );
00072 }
00073
00074
00075
00076
00077 inline LocalValues localParameters( const SiPixelCluster & cl,
00078 const GeomDetUnit & det,
00079 float alpha, float beta) const
00080 {
00081 nRecHitsTotal_++ ;
00082 alpha_ = alpha;
00083 beta_ = beta;
00084 double HalfPi = 0.5*TMath::Pi();
00085 cotalpha_ = tan(HalfPi - alpha_);
00086 cotbeta_ = tan(HalfPi - beta_ );
00087 setTheDet( det );
00088 return std::make_pair( localPosition(cl,det), localError(cl,det) );
00089 }
00090
00091
00092
00093
00094
00095 inline void setMagField(const MagneticField *mag) const { magfield_ = mag; }
00096
00097
00098
00099
00100 inline void setDBAccess(const SiPixelCPEParmErrors *parmErrors) const { parmErrors_ = parmErrors; }
00101
00102
00103
00104
00105 virtual LocalPoint localPosition(const SiPixelCluster& cl, const GeomDetUnit & det) const;
00106 virtual LocalError localError (const SiPixelCluster& cl, const GeomDetUnit & det) const = 0;
00107
00108
00109
00110
00111
00112 inline float cotAlphaFromCluster() const { return cotAlphaFromCluster_; }
00113 inline float cotBetaFromCluster() const { return cotBetaFromCluster_; }
00114 inline float probabilityX() const { return probabilityX_; }
00115 inline float probabilityY() const { return probabilityY_; }
00116 inline float qBin() const { return qBin_ ; }
00117
00118 protected:
00119
00120
00121
00122 typedef GloballyPositioned<double> Frame;
00123
00124
00125
00126
00127
00128 mutable const PixelGeomDetUnit * theDet;
00129 mutable const RectangularPixelTopology * theTopol;
00130 mutable GeomDetType::SubDetector thePart;
00131 mutable EtaCorrection theEtaFunc;
00132 mutable float theThickness;
00133 mutable float thePitchX;
00134 mutable float thePitchY;
00135 mutable float theOffsetX;
00136 mutable float theOffsetY;
00137 mutable float theNumOfRow;
00138 mutable float theNumOfCol;
00139 mutable float theDetZ;
00140 mutable float theDetR;
00141 mutable float theLShiftX;
00142 mutable float theLShiftY;
00143 mutable float theSign;
00144
00145
00146 mutable float alpha_;
00147 mutable float beta_;
00148
00149
00150 mutable float cotalpha_;
00151 mutable float cotbeta_;
00152
00153
00154 mutable float trk_lp_x;
00155 mutable float trk_lp_y;
00156
00157
00158
00159
00160
00161
00162
00163
00164
00165
00166 mutable float cotAlphaFromCluster_;
00167 mutable float cotBetaFromCluster_;
00168
00169
00170 mutable float probabilityX_ ;
00171 mutable float probabilityY_ ;
00172 mutable float qBin_ ;
00173
00174
00175
00176
00177
00178
00179
00180 mutable LocalVector driftDirection_;
00181 mutable double lorentzShiftX_;
00182 mutable double lorentzShiftY_;
00183 mutable double lorentzShiftInCmX_;
00184 mutable double lorentzShiftInCmY_;
00185
00186
00187 mutable int nRecHitsTotal_ ;
00188 mutable int nRecHitsUsedEdge_ ;
00189
00190
00191
00192
00193 int theVerboseLevel;
00194
00195 mutable const MagneticField * magfield_;
00196
00197 mutable const SiPixelCPEParmErrors * parmErrors_;
00198
00199 mutable const SiPixelLorentzAngle * lorentzAngle_;
00200
00201 bool alpha2Order;
00202
00203
00204
00205
00206
00207 void setTheDet( const GeomDetUnit & det ) const ;
00208
00209 MeasurementPoint measurementPosition( const SiPixelCluster&,
00210 const GeomDetUnit & det) const ;
00211 MeasurementError measurementError ( const SiPixelCluster&,
00212 const GeomDetUnit & det) const ;
00213
00214
00215
00216
00217
00218
00219
00220 void computeAnglesFromDetPosition(const SiPixelCluster & cl,
00221 const GeomDetUnit & det ) const;
00222 void computeAnglesFromTrajectory (const SiPixelCluster & cl,
00223 const GeomDetUnit & det,
00224 const LocalTrajectoryParameters & ltp) const;
00225 LocalVector driftDirection ( GlobalVector bfield ) const ;
00226 LocalVector driftDirectionCorrect( GlobalVector bfield ) const ;
00227 void computeLorentzShifts() const ;
00228
00229 bool isFlipped() const;
00230
00231
00232
00233
00234
00235
00236 void xCharge(const std::vector<SiPixelCluster::Pixel>&,
00237 const int&, const int&, float& q1, float& q2) const;
00238 void yCharge(const std::vector<SiPixelCluster::Pixel>&,
00239 const int&, const int&, float& q1, float& q2) const;
00240
00241
00242
00243
00244
00245
00246
00247
00248
00249
00250
00251
00252
00253
00254
00255
00256
00257
00258
00259
00260
00261 virtual float lorentzShiftX() const;
00262 virtual float lorentzShiftY() const;
00263
00264
00265 virtual float xpos( const SiPixelCluster& ) const = 0;
00266 virtual float ypos( const SiPixelCluster& ) const = 0;
00267
00268
00269
00270 public:
00271 struct Param
00272 {
00273 Param() : topology(0), drift(0.0, 0.0, 0.0) {}
00274 RectangularPixelTopology const * topology;
00275 LocalVector drift;
00276 };
00277
00278 private:
00279 typedef __gnu_cxx::hash_map< unsigned int, Param> Params;
00280
00281 Params m_Params;
00282
00283
00284
00285 };
00286
00287 #endif
00288
00289