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