00001
00002
00003
00004
00005 #include "Geometry/TrackerGeometryBuilder/interface/PixelGeomDetUnit.h"
00006 #include "Geometry/TrackerTopology/interface/RectangularPixelTopology.h"
00007
00008 #include "RecoLocalTracker/SiPixelRecHits/interface/PixelCPEInitial.h"
00009
00010
00011 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00012
00013 #include "MagneticField/Engine/interface/MagneticField.h"
00014
00015 #include <iostream>
00016
00017
00018 using namespace std;
00019
00020 const float PI = 3.141593;
00021 const float degsPerRad = 57.29578;
00022
00023
00024
00025
00026
00027 PixelCPEInitial::PixelCPEInitial(edm::ParameterSet const & conf, const MagneticField *mag, const SiPixelLorentzAngle * lorentzAngle)
00028 : PixelCPEBase(conf,mag,lorentzAngle)
00029 {
00030 }
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041 LocalError
00042 PixelCPEInitial::localError( const SiPixelCluster& cluster, const GeomDetUnit & det)const
00043 {
00044 setTheDet( det );
00045 int sizex = cluster.sizeX();
00046 int sizey = cluster.sizeY();
00047
00048
00049
00050 int maxPixelCol = cluster.maxPixelCol();
00051 int maxPixelRow = cluster.maxPixelRow();
00052 int minPixelCol = cluster.minPixelCol();
00053 int minPixelRow = cluster.minPixelRow();
00054
00055 bool edgex = (theTopol->isItEdgePixelInX(minPixelRow)) ||
00056 (theTopol->isItEdgePixelInX(maxPixelRow));
00057 bool edgey = (theTopol->isItEdgePixelInY(minPixelCol)) ||
00058 (theTopol->isItEdgePixelInY(maxPixelCol));
00059
00060
00061 if (theVerboseLevel > 9) {
00062 LogDebug("PixelCPEInitial") <<
00063 "Sizex = " << sizex <<
00064 " Sizey = " << sizey <<
00065 " Edgex = " << edgex <<
00066 " Edgey = " << edgey ;
00067 }
00068
00069
00070 return LocalError( err2X(edgex, sizex), 0, err2Y(edgey, sizey) );
00071 }
00072
00073
00074
00075
00076
00077
00078
00079
00080 float
00081 PixelCPEInitial::err2X(bool& edgex, int& sizex) const
00082 {
00083
00084
00085
00086 float xerr = thePitchX/3.464;
00087
00088
00089
00090
00091 if (!edgex){
00092
00093 if (thePart == GeomDetEnumerators::PixelBarrel) {
00094 if ( sizex == 1) xerr = 0.00115;
00095 else if ( sizex == 2) xerr = 0.0012;
00096 else if ( sizex == 3) xerr = 0.00088;
00097 else xerr = 0.0103;
00098 } else {
00099 if ( sizex == 1) {
00100 xerr = 0.0020;
00101 } else if ( sizex == 2) {
00102 xerr = 0.0020;
00103
00104 } else {
00105 xerr = 0.0020;
00106
00107 }
00108 }
00109
00110
00111
00112
00113
00114
00115
00116
00117
00118
00119
00120
00121 }
00122 return xerr*xerr;
00123 }
00124
00125
00126
00127
00128 float
00129 PixelCPEInitial::err2Y(bool& edgey, int& sizey) const
00130 {
00131
00132
00133
00134 float yerr = thePitchY/3.464;
00135 if (!edgey){
00136 if (thePart == GeomDetEnumerators::PixelBarrel) {
00137 if ( sizey == 1) {
00138 yerr = 0.00375;
00139 } else if ( sizey == 2) {
00140 yerr = 0.0023;
00141 } else if ( sizey == 3) {
00142 yerr = 0.0025;
00143 } else if ( sizey == 4) {
00144 yerr = 0.0025;
00145 } else if ( sizey == 5) {
00146 yerr = 0.0023;
00147 } else if ( sizey == 6) {
00148 yerr = 0.0023;
00149 } else if ( sizey == 7) {
00150 yerr = 0.0021;
00151 } else if ( sizey == 8) {
00152 yerr = 0.0021;
00153 } else if ( sizey == 9) {
00154 yerr = 0.0024;
00155 } else if ( sizey >= 10) {
00156 yerr = 0.0021;
00157 }
00158 } else {
00159 if ( sizey == 1) yerr = 0.0021;
00160 else if ( sizey >= 2) yerr = 0.00075;
00161 }
00162 }
00163 return yerr*yerr;
00164 }
00165
00166
00167
00168
00169
00170 float
00171 PixelCPEInitial::xpos(const SiPixelCluster& cluster) const {
00172
00173 int size = cluster.sizeX();
00174
00175 if (size == 1) {
00176 float baryc = cluster.x();
00177
00178
00179 return theTopol->localX(baryc);
00180 }
00181
00182
00183 int imin = cluster.minPixelRow();
00184 int imax = cluster.maxPixelRow();
00185 float min = float(imin) + 0.5;
00186 float max = float(imax) + 0.5;
00187 float minEdge = theTopol->localX(float(imin+1));
00188 float maxEdge = theTopol->localX(float(imax));
00189 float center = (minEdge + maxEdge)/2.;
00190 float wInner = maxEdge-minEdge;
00191
00192
00193 const vector<SiPixelCluster::Pixel>& pixelsVec = cluster.pixels();
00194 float q1 = 0.;
00195 float q2 = 0.;
00196 xCharge(pixelsVec, imin, imax, q1, q2);
00197
00198
00199 float tmp = (max+min)/2.;
00200 float width = (chargeWidthX() + geomCorrectionX(tmp)) * thePitchX;
00201
00202
00203 float effWidth = fabs(width) - wInner;
00204
00205
00206 if( (effWidth>(2*thePitchX)) || (effWidth<0.) ) {
00207 effWidth=thePitchX;
00208 }
00209
00210
00211
00212 float pos = center + (q2-q1)/(2.*(q1+q2)) * effWidth;
00213
00214 return pos;
00215
00216 }
00217
00218
00219
00220 float
00221 PixelCPEInitial::ypos(const SiPixelCluster& cluster) const {
00222
00223 int size = cluster.sizeY();
00224
00225 if (size == 1) {
00226 float baryc = cluster.y();
00227
00228
00229 return theTopol->localY(baryc);
00230 }
00231
00232
00233 int imin = cluster.minPixelCol();
00234 int imax = cluster.maxPixelCol();
00235
00236
00237 float minEdge = theTopol->localY(float(imin+1));
00238 float maxEdge = theTopol->localY(float(imax));
00239 float center = (minEdge + maxEdge)/2.;
00240
00241
00242
00243 const vector<SiPixelCluster::Pixel>& pixelsVec = cluster.pixels();
00244 float q1 = 0.;
00245 float q2 = 0.;
00246 yCharge(pixelsVec, imin, imax, q1, q2);
00247
00248 float pitch1 = thePitchY;
00249 float pitch2 = thePitchY;
00250 if(RectangularPixelTopology::isItBigPixelInY(imin) )
00251 pitch1= 2.*thePitchY;
00252 if(RectangularPixelTopology::isItBigPixelInY(imax) )
00253 pitch2= 2.*thePitchY;
00254
00255
00256 float pos = center + (q2-q1)/(2.*(q1+q2)) * (pitch1+pitch2)/2.;
00257 return pos;
00258
00259 }
00260
00261
00262
00263
00264
00265 float PixelCPEInitial::chargeWidthX() const {
00266 float chargeW = 0;
00267 float lorentzWidth = 2 * theLShiftX;
00268 if (thePart == GeomDetEnumerators::PixelBarrel) {
00269 chargeW = lorentzWidth;
00270 } else {
00271 chargeW = fabs(lorentzWidth) +
00272 theThickness * fabs(theDetR/theDetZ) / thePitchX;
00273 }
00274 return chargeW;
00275 }
00276
00277
00278
00279
00280 float PixelCPEInitial::chargeWidthY() const {
00281 float chargeW = 0;
00282 float lorentzWidth = 2 * theLShiftY;
00283 if (thePart == GeomDetEnumerators::PixelBarrel) {
00284
00285 chargeW = theThickness * fabs(theDetZ/theDetR) / thePitchY;
00286 } else {
00287
00288 if ( alpha2Order) {
00289 chargeW = -fabs(lorentzWidth)+ theThickness * tan(20./degsPerRad) / thePitchY;
00290 }else {
00291 chargeW = theThickness * tan(20./degsPerRad) / thePitchY;
00292 }
00293 }
00294 return chargeW;
00295 }
00296
00297
00298
00299
00300
00301
00302
00303
00304
00305 float PixelCPEInitial::geomCorrectionX(float xcenter) const {
00306 if (thePart == GeomDetEnumerators::PixelEndcap) return 0;
00307 else {
00308 float tmp = theSign * (theThickness / theDetR) * (xcenter-theOffsetX);
00309 return tmp;
00310 }
00311 }
00312
00313
00314 float PixelCPEInitial::geomCorrectionY(float ycenter) const {
00315 if (thePart == GeomDetEnumerators::PixelEndcap) return 0;
00316 else {
00317 float tmp = (ycenter - theOffsetY) * theThickness / theDetR;
00318 if(theDetZ>0.) tmp = -tmp;
00319 return tmp;
00320 }
00321 }
00322
00323
00324