CMS 3D CMS Logo

PixelCPEParmError.cc

Go to the documentation of this file.
00001 // change to use Lorentz angle from DB Lotte Wilke, Jan. 31st, 2008
00002 
00003 //#include "Utilities/Configuration/interface/Architecture.h"
00004 
00005 #include "Geometry/TrackerGeometryBuilder/interface/PixelGeomDetUnit.h"
00006 #include "Geometry/TrackerTopology/interface/RectangularPixelTopology.h"
00007 
00008 #include "RecoLocalTracker/SiPixelRecHits/interface/PixelCPEParmError.h"
00009 
00010 // MessageLogger
00011 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00012 
00013 // Magnetic field
00014 #include "MagneticField/Engine/interface/MagneticField.h"
00015 
00016 #include <iostream>
00017 
00018 //#define TDEBUG
00019 using namespace std;
00020 
00021 const float PI = 3.141593;
00022 const float degsPerRad = 57.29578;
00023 
00024 
00025 //-----------------------------------------------------------------------------
00026 //  A fairly boring constructor.  All quantities are DetUnit-dependent, and
00027 //  will be initialized in setTheDet().
00028 //-----------------------------------------------------------------------------
00029 PixelCPEParmError::PixelCPEParmError(edm::ParameterSet const & conf, 
00030                                      const MagneticField *mag, const SiPixelLorentzAngle * lorentzAngle) 
00031   : PixelCPEBase(conf,mag,lorentzAngle)
00032 {
00033   pixelErrorParametrization_ = new PixelErrorParametrization(conf);
00034 }
00035 
00036 //-----------------------------------------------------------------------------
00037 //  Clean up.
00038 //-----------------------------------------------------------------------------
00039 PixelCPEParmError::~PixelCPEParmError()
00040 {
00041   delete pixelErrorParametrization_ ;
00042 }
00043 
00044 
00045 //------------------------------------------------------------------
00046 //  Public methods mandated by the base class.
00047 //------------------------------------------------------------------
00048 
00049 //------------------------------------------------------------------
00050 //  localError() calls measurementError() after computing size and 
00051 //  edge (flag) along x and y.
00052 //------------------------------------------------------------------
00053 LocalError  
00054 PixelCPEParmError::localError( const SiPixelCluster& cluster, const GeomDetUnit & det)const 
00055 {
00056   setTheDet( det );
00057 
00058   //--- Default is the maximum error used for edge clusters.
00059   float xerr = thePitchX / sqrt(12.);
00060   float yerr = thePitchY / sqrt(12.);
00061 
00062   //--- Are we near either of the edges?
00063   // Use edge methods from the Toplogy class
00064   int maxPixelCol = cluster.maxPixelCol();
00065   int maxPixelRow = cluster.maxPixelRow();
00066   int minPixelCol = cluster.minPixelCol();
00067   int minPixelRow = cluster.minPixelRow();       
00068   // edge method moved to topologu class
00069   bool edgex = (theTopol->isItEdgePixelInX(minPixelRow)) ||
00070     (theTopol->isItEdgePixelInX(maxPixelRow));
00071   bool edgey = (theTopol->isItEdgePixelInY(minPixelCol)) ||
00072     (theTopol->isItEdgePixelInY(maxPixelCol));
00073   
00074   // Gavril: check if this rechit contains big pixels, 03/27/07
00075   bool bigInX = theTopol->containsBigPixelInX(minPixelRow, maxPixelRow);
00076   bool bigInY = theTopol->containsBigPixelInY(minPixelCol, maxPixelCol);
00077 
00078   if (edgex && edgey) {
00079     //--- Both axes on the edge, no point in calling PixelErrorParameterization,
00080     //--- just return the max errors on both.
00081     // return LocalError(xerr*xerr, 0,yerr*yerr);
00082   } else {
00083     pair<float,float> errPair = 
00084       pixelErrorParametrization_->getError(thePart, 
00085                                            cluster.sizeX(), cluster.sizeY(), 
00086                                            alpha_         , beta_,
00087                                            bigInX         , bigInY); // Gavril: add big pixel flags, 03/27/07
00088     if (!edgex) xerr = errPair.first;
00089     if (!edgey) yerr = errPair.second;
00090   }       
00091 
00092   if (theVerboseLevel > 9) {
00093     LogDebug("PixelCPEParmError") <<
00094       "Sizex = " << cluster.sizeX() << " Sizey = " << cluster.sizeY() << 
00095       " Edgex = " << edgex          << " Edgey = " << edgey << 
00096       " ErrX = " << xerr            << " ErrY  = " << yerr;
00097   }
00098   return LocalError(xerr*xerr, 0,yerr*yerr);
00099 }
00100 
00101 //------------------------------------------------------------------
00102 //  Helper methods (protected)
00103 //------------------------------------------------------------------
00104 
00105 //-----------------------------------------------------------------------------
00106 //  Calculates the *corrected* position of the cluster.
00107 //  &&& Probably generic enough for the base class.
00108 // Use the same as for nagles from dets case but with eta correction
00109 //-----------------------------------------------------------------------------
00110 float 
00111 PixelCPEParmError::xpos(const SiPixelCluster& cluster) const {
00112   int size = cluster.sizeX();
00113                                                                                
00114   if (size == 1) {
00115     float baryc = cluster.x();
00116     // the middle of only one pixel is equivalent to the baryc.
00117     // transform baryc to local
00118     return theTopol->localX(baryc);
00119   }
00120   
00121   //calculate center
00122   int imin = cluster.minPixelRow();
00123   int imax = cluster.maxPixelRow();
00124   //float min = float(imin) + 0.5; // center of the edge
00125   //float max = float(imax) + 0.5; // center of the edge
00126   float minEdge = theTopol->localX(float(imin+1)); // left inner edge
00127   float maxEdge = theTopol->localX(float(imax));   // right inner edge
00128   float center = (minEdge + maxEdge)/2.; // center of inner part
00129   float wInner = maxEdge-minEdge; // width of the inner part
00130   
00131   // get the charge in the edge pixels
00132   const vector<SiPixelCluster::Pixel>& pixelsVec = cluster.pixels();
00133   float q1 = 0.;
00134   float q2 = 0.;
00135   xCharge(pixelsVec, imin, imax, q1, q2); // get q1 and q2
00136   
00137   // Estimate the charge width from track angle
00138   float width = chargeWidthX() * thePitchX; // chargewidth still in pitch units
00139   
00140   // Check the valid chargewidth 
00141   float effWidth = fabs(width) - wInner;
00142 
00143   // Check the residual width
00144   if( (effWidth>(2*thePitchX)) || (effWidth<0.) ) { // for illiegal wifth
00145     effWidth=thePitchX; // make it equal to pitch
00146   }
00147   
00148   // For X (with track angles) use the MSI formula.
00149   // position msI
00150   float pos = center + (q2-q1)/(2.*(q1+q2)) * effWidth;
00151   
00152 
00153   // Delete the eta correction, it did not bring much d.k.3/07
00154   //if (alpha_ < 1.53) {
00155   //float etashift=0;
00156   //float charatio = q1/(q1+q2);
00157   //etashift = theEtaFunc.xEtaShift(size,thePitchX,charatio,alpha_);
00158   //pos = pos - etashift;
00159   //}
00160 
00161   return pos;
00162 }
00163 
00164 //-----------------------------------------------------------------------------
00165 //  Calculates the *corrected* position of the cluster.
00166 //  &&& Probably generic enough for the base class.
00167 //-----------------------------------------------------------------------------
00168 float 
00169 PixelCPEParmError::ypos(const SiPixelCluster& cluster) const
00170 {
00171  
00172   int size = cluster.sizeY();
00173   
00174   if (size == 1) {
00175     float baryc = cluster.y();
00176     // the middle of only one pixel is equivalent to the baryc.
00177     // transform baryc to local
00178     return theTopol->localY(baryc);
00179   }
00180   
00181   //calculate center
00182   int imin = cluster.minPixelCol();
00183   int imax = cluster.maxPixelCol();
00184   //float min = float(imin) + 0.5; // center of the edge
00185   //float max = float(imax) + 0.5; // center of the edge
00186   float minEdge = theTopol->localY(float(imin+1)); // left inner edge
00187   float maxEdge = theTopol->localY(float(imax));   // right inner edge
00188   float center = (minEdge + maxEdge)/2.; // center of inner part in LC
00189   float wInner = maxEdge-minEdge; // width of the inner part in LC
00190     
00191   // get the charge in the edge pixels
00192   const vector<SiPixelCluster::Pixel>& pixelsVec = cluster.pixels();
00193   float q1 = 0.;
00194   float q2 = 0.;
00195   yCharge(pixelsVec, imin, imax, q1, q2);
00196     
00197   // Estimate the charge width using the track angle
00198   float width = (chargeWidthY()) * thePitchY;
00199   float effWidth = fabs(width) - wInner;
00200 
00201   // Check the validty of the width
00202   if(effWidth>2*thePitchY) { //  width too large
00203     float edgeLength = 2*thePitchY; // take care of big pixels
00204     if(RectangularPixelTopology::isItBigPixelInY(imin) )
00205       edgeLength += thePitchY;
00206     if(RectangularPixelTopology::isItBigPixelInY(imax) )
00207       edgeLength += thePitchY;
00208 
00209     if(effWidth>edgeLength) effWidth=edgeLength/2.;
00210 
00211   } else if(effWidth<0.) { // width too small
00212     effWidth=thePitchY; //
00213   }
00214 
00215   // For y with track angles use msI method
00216   float pos = center + (q2-q1)/(2.*(q1+q2)) * effWidth;
00217   
00218   // Delete the eta correction. It did not bring much
00219   // eta function for shallow tracks
00220   //float charatio = q1/(q1+q2);
00221   //float etashift = theEtaFunc.yEtaShift(size,thePitchY,charatio,beta_);
00222   //pos = pos - etashift;
00223 
00224   return pos;
00225 }
00226 
00227 
00228 //-----------------------------------------------------------------------------
00229 //
00230 //-----------------------------------------------------------------------------
00231 float 
00232 PixelCPEParmError::chargeWidthX() const
00233 { 
00234 // &&& Commented out: the version from FromDetPosition:
00235 //   float chargeW = 0;
00236 //   float lorentzWidth = 2 * theLShift;
00237 //   if (thePart == GeomDetEnumerators::PixelBarrel) {
00238 //     // Redefine the charge width to include the offset
00239 //     chargeW = lorentzWidth - theSign * geomCorrection() * theOffsetX;
00240 //   } else { // forward
00241 //     chargeW = fabs(lorentzWidth) + 
00242 //       theThickness * fabs(theDetR/theDetZ) / thePitchX;
00243 //   }
00244 //   return chargeW;
00245 
00246   float geomWidthX = theThickness * tan(PI/2 - alpha_)/thePitchX;
00247   if (thePart == GeomDetEnumerators::PixelBarrel){
00248     return (geomWidthX) + (2 * theLShiftX);
00249   } else {
00250     return fabs(geomWidthX) + (2 * fabs(theLShiftX)); 
00251   }
00252 }
00253 
00254 
00255 //-----------------------------------------------------------------------------
00256 //
00257 //-----------------------------------------------------------------------------
00258 float 
00259 PixelCPEParmError::chargeWidthY() const
00260 {
00261 // &&& Commented out: the version from FromDetPosition:
00262 //   float chargeW = 0;  
00263 //   if (thePart == GeomDetEnumerators::PixelBarrel) {
00264 //     chargeW = theThickness * fabs(theDetZ/theDetR) / thePitchY;
00265 //     chargeW -= (geomCorrection() * theOffsetY);
00266 //   } else { //forward
00267 //     // Width comes from geometry only, fixed by the tilt angle
00268 //    chargeW = theThickness * tan(20./degsPerRad) / thePitchY; 
00269 //   }
00270 //   return chargeW;
00271 
00272   float geomWidthY = theThickness * tan(PI/2 - beta_)/thePitchY;
00273   if (thePart == GeomDetEnumerators::PixelBarrel) {
00274     return geomWidthY;
00275   } else {
00276     return fabs(geomWidthY);
00277   }
00278 }
00279 
00280 
00281 
00282 
00283 

Generated on Tue Jun 9 17:43:59 2009 for CMSSW by  doxygen 1.5.4