CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_6_1_2_SLHC2_patch1/src/SLHCUpgradeSimulations/L1TrackTrigger/src/WindowFinder.cc

Go to the documentation of this file.
00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 #include "SLHCUpgradeSimulations/L1TrackTrigger/interface/WindowFinder.h"
00010 #include <iostream>
00011 
00018 
00019 WindowFinder::WindowFinder( const StackedTrackerGeometry *aGeometry,
00020                                          double aPtScalingFactor,
00021                                          double aIPwidth,
00022                                          double aRowResolution,
00023                                          double aColResolution )
00024   : mGeometry( aGeometry ),
00025     mPtScalingFactor( aPtScalingFactor ),
00026     mIPwidth( aIPwidth ),
00027     mRowResolution( aRowResolution ),
00028     mColResolution( aColResolution ),
00029     mMinrow(0), mMaxrow(0), mMincol(0), mMaxcol(0),
00030     mLastId(0), mlastInnerRow(-1), mlastInnerCol(-1){}
00031 
00033 WindowFinder::~WindowFinder(){}
00034 
00036 void WindowFinder::dumphit( const StackedTrackerDetId & anId,
00037                                          unsigned int hitIdentifier,
00038                                          const double & aInnerRow,
00039                                          const double & aInnerColumn )
00040 {
00041   const PixelGeomDetUnit* detunit = reinterpret_cast< const PixelGeomDetUnit* > (mGeometry -> idToDetUnit( anId, hitIdentifier ));
00042 
00044   MeasurementPoint mp( aInnerRow + (0.5*mRowResolution), aInnerColumn + (0.5*mColResolution) );
00045   LocalPoint LP  = detunit->topology().localPosition( mp );
00046   GlobalPoint GP = detunit->surface().toGlobal( LP );
00047   std::cout << (hitIdentifier?"INNER":"OUTER") << " -> eta = " << GP.eta() << std::endl;
00048 }
00049 
00051 StackedTrackerWindow WindowFinder::getWindow( const StackedTrackerDetId & anId,
00052                                                                         const double & aInnerRow,
00053                                                                         const double & aInnerColumn )
00054 {
00056   if ( (anId == mLastId) && (mlastInnerRow == aInnerRow) && (mlastInnerCol == aInnerColumn) )
00057   {
00058     StackedTrackerWindow thisWindow = StackedTrackerWindow( mMinrow, mMaxrow, mMincol, mMaxcol );
00059     return thisWindow;
00060   }
00061 
00062   mlastInnerRow = aInnerRow;
00063   mlastInnerCol = aInnerColumn;
00064 
00065   if (anId != mLastId)
00066   {
00067     mLastId = anId;
00068     mInnerDet = const_cast< PixelGeomDetUnit* >(reinterpret_cast< const PixelGeomDetUnit* > (mGeometry->idToDetUnit( anId, 0 )));
00069     mOuterDet = const_cast< PixelGeomDetUnit* >(reinterpret_cast< const PixelGeomDetUnit* > (mGeometry->idToDetUnit( anId, 1 )));
00070 
00071     mHalfPixelLength = mInnerDet->specificTopology().pitch().second * mColResolution * 0.5;
00072     mSeparation = mInnerDet->surface().localZ( mOuterDet->position() );
00073     if ( mSeparation < 0 )
00074       mSeparation = -mSeparation;
00075 
00076     mInnerDetRadius  = mInnerDet->position().perp();
00077     mInnerDetPhi     = mInnerDet->position().phi();
00078   }
00079 
00082   MeasurementPoint MP_INNER( aInnerRow + (0.5*mRowResolution), aInnerColumn + (0.5*mColResolution) );
00083 
00085   LocalPoint       LP_INNER = mInnerDet->topology().localPosition( MP_INNER );
00086 
00088   GlobalPoint      GP_INNER = mInnerDet->surface().toGlobal( LP_INNER );
00089 
00091   double           PHI = asin( mPtScalingFactor * GP_INNER.perp() );
00092 
00094   double           PixelAngle = acos( sin( mInnerDetPhi - GP_INNER.phi() ) * mInnerDetRadius / LP_INNER.x() );
00095 
00097   double           deltaXminus = ( mSeparation * tan( PixelAngle - PHI ));  
00098   double           deltaXplus  = ( mSeparation * tan( PixelAngle + PHI ));  
00099 
00101   double           PIXEL_Z_PLUS  = GP_INNER.z()+mHalfPixelLength;
00102   double           PIXEL_Z_MINUS = GP_INNER.z()-mHalfPixelLength;
00103 
00105   double           IP_Z_PLUS  =  mIPwidth;
00106   double           IP_Z_MINUS = -mIPwidth;
00107 
00109   double                R_SEPARATION =  mSeparation / cos( PixelAngle );
00110   if (R_SEPARATION < 0)
00111     R_SEPARATION = -R_SEPARATION;
00112 
00114   double           deltaZminus = (PIXEL_Z_MINUS-IP_Z_PLUS) * R_SEPARATION / GP_INNER.perp();  
00115   double           deltaZplus  = (PIXEL_Z_PLUS-IP_Z_MINUS) * R_SEPARATION / GP_INNER.perp();    
00116 
00118   LocalPoint LP_OUTER_PLUS( LP_INNER.x()-deltaXplus , LP_INNER.y()-mHalfPixelLength-deltaZplus , -mSeparation );
00119   LocalPoint LP_OUTER_MINUS( LP_INNER.x()-deltaXminus , LP_INNER.y()+mHalfPixelLength-deltaZminus , -mSeparation );
00120 
00122   GlobalPoint GP_OUTER_PLUS = mInnerDet ->surface().toGlobal(LP_OUTER_PLUS);
00123   GlobalPoint GP_OUTER_MINUS = mInnerDet ->surface().toGlobal(LP_OUTER_MINUS);
00124 
00126   LocalPoint LP_OUTER_PLUS_2 = mOuterDet ->surface().toLocal(GP_OUTER_PLUS);
00127   LocalPoint LP_OUTER_MINUS_2 = mOuterDet ->surface().toLocal(GP_OUTER_MINUS);
00128 
00130   std::pair<float,float> PLUS = mOuterDet -> specificTopology().pixel(LP_OUTER_PLUS_2);
00131   std::pair<float,float> MINUS = mOuterDet -> specificTopology().pixel(LP_OUTER_MINUS_2);
00132 
00134   mMinrow = mRowResolution * floor( PLUS.first / mRowResolution ); 
00135   mMincol = mColResolution * floor( PLUS.second / mColResolution );
00136   mMaxrow = mRowResolution * floor( MINUS.first / mRowResolution );
00137   mMaxcol = mColResolution * floor( MINUS.second / mColResolution ); 
00138 
00139   if (mMinrow>mMaxrow)
00140     std::swap(mMinrow,mMaxrow);
00141   if (mMincol>mMaxcol)
00142     std::swap(mMincol,mMaxcol);
00143 
00145   StackedTrackerWindow theWindow = StackedTrackerWindow( mMinrow, mMaxrow, mMincol, mMaxcol );
00146   return theWindow;
00147 }
00148