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
00155
00156 inline unsigned int clusterProbComputationFlag() const
00157 {
00158 return clusterProbComputationFlag_ ;
00159 }
00160
00161
00162
00167
00168 SiPixelRecHitQuality::QualWordType rawQualityWord() const;
00169
00170
00171 protected:
00172
00173
00174
00175 typedef GloballyPositioned<double> Frame;
00176
00177
00178
00179
00180
00181 mutable const PixelGeomDetUnit * theDet;
00182
00183
00184
00185 mutable const PixelTopology * theTopol;
00186
00187
00188 mutable GeomDetType::SubDetector thePart;
00189
00190 mutable float theThickness;
00191 mutable float thePitchX;
00192 mutable float thePitchY;
00193
00194
00195 mutable float theNumOfRow;
00196 mutable float theNumOfCol;
00197 mutable float theDetZ;
00198 mutable float theDetR;
00199 mutable float theLShiftX;
00200 mutable float theLShiftY;
00201 mutable float theSign;
00202
00203
00204 mutable float alpha_;
00205 mutable float beta_;
00206
00207
00208 mutable float cotalpha_;
00209 mutable float cotbeta_;
00210
00211
00212 mutable float trk_lp_x;
00213 mutable float trk_lp_y;
00214
00215
00216 mutable int nRecHitsTotal_ ;
00217 mutable int nRecHitsUsedEdge_ ;
00218
00219
00220 mutable bool with_track_angle;
00221
00222
00223 mutable float probabilityX_ ;
00224 mutable float probabilityY_ ;
00225 mutable float probabilityQ_ ;
00226 mutable float qBin_ ;
00227 mutable bool isOnEdge_ ;
00228 mutable bool hasBadPixels_ ;
00229 mutable bool spansTwoROCs_ ;
00230 mutable bool hasFilledProb_ ;
00231
00232
00233
00234
00235
00236
00237
00238 unsigned int clusterProbComputationFlag_ ;
00239
00240
00241
00242
00243
00244
00245
00246 mutable LocalVector driftDirection_;
00247 mutable double lorentzShiftX_;
00248 mutable double lorentzShiftY_;
00249 mutable double lorentzShiftInCmX_;
00250 mutable double lorentzShiftInCmY_;
00251
00252
00253
00254
00255 int theVerboseLevel;
00256
00257 mutable const MagneticField * magfield_;
00258
00259 mutable const SiPixelLorentzAngle * lorentzAngle_;
00260
00261 mutable const SiPixelCPEGenericErrorParm * genErrorParm_;
00262
00263 mutable const SiPixelTemplateDBObject * templateDBobject_;
00264
00265 bool alpha2Order;
00266
00267
00268
00269
00270 mutable Topology::LocalTrackPred loc_trk_pred_;
00271
00272 mutable LocalTrajectoryParameters loc_traj_param_;
00273
00274
00275
00276
00277 void setTheDet( const GeomDetUnit & det, const SiPixelCluster & cluster ) const ;
00278
00279 MeasurementPoint measurementPosition( const SiPixelCluster&,
00280 const GeomDetUnit & det) const ;
00281 MeasurementError measurementError ( const SiPixelCluster&,
00282 const GeomDetUnit & det) const ;
00283
00284
00285
00286
00287
00288
00289
00290 void computeAnglesFromDetPosition(const SiPixelCluster & cl,
00291 const GeomDetUnit & det ) const;
00292 void computeAnglesFromTrajectory (const SiPixelCluster & cl,
00293 const GeomDetUnit & det,
00294 const LocalTrajectoryParameters & ltp) const;
00295 LocalVector driftDirection ( GlobalVector bfield ) const ;
00296 LocalVector driftDirectionCorrect( GlobalVector bfield ) const ;
00297 void computeLorentzShifts() const ;
00298
00299 bool isFlipped() const;
00300
00301
00302
00303
00304
00305
00306 void xCharge(const std::vector<SiPixelCluster::Pixel>&,
00307 const int&, const int&, float& q1, float& q2) const;
00308 void yCharge(const std::vector<SiPixelCluster::Pixel>&,
00309 const int&, const int&, float& q1, float& q2) const;
00310
00311
00312
00313
00314
00315
00316
00317
00318
00319
00320
00321
00322
00323
00324
00325
00326
00327
00328
00329
00330
00331 virtual float lorentzShiftX() const;
00332 virtual float lorentzShiftY() const;
00333
00334
00335 virtual float xpos( const SiPixelCluster& ) const = 0;
00336 virtual float ypos( const SiPixelCluster& ) const = 0;
00337
00338
00339
00340 public:
00341 struct Param
00342 {
00343 Param() : topology(0), drift(0.0, 0.0, 0.0) {}
00344
00345
00346
00347 PixelTopology const * topology;
00348
00349 LocalVector drift;
00350 };
00351
00352 private:
00353 typedef __gnu_cxx::hash_map< unsigned int, Param> Params;
00354
00355 Params m_Params;
00356
00357
00358
00359 };
00360
00361 #endif
00362
00363