CMS 3D CMS Logo

PixelForwardLayer.cc

Go to the documentation of this file.
00001 #include "RecoTracker/TkDetLayers/interface/PixelForwardLayer.h"
00002 
00003 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00004 
00005 #include "DataFormats/GeometrySurface/interface/BoundingBox.h"
00006 #include "DataFormats/GeometrySurface/interface/SimpleDiskBounds.h"
00007 
00008 #include "TrackingTools/DetLayers/interface/simple_stat.h"
00009 #include "TrackingTools/DetLayers/interface/PhiLess.h"
00010 #include "TrackingTools/GeomPropagators/interface/HelixArbitraryPlaneCrossing2Order.h"
00011 #include "TrackingTools/GeomPropagators/interface/HelixArbitraryPlaneCrossing.h"
00012 #include "TrackingTools/PatternTools/interface/MeasurementEstimator.h"
00013 
00014 
00015 #include "RecoTracker/TkDetLayers/interface/LayerCrossingSide.h"
00016 #include "RecoTracker/TkDetLayers/interface/DetGroupMerger.h"
00017 #include "RecoTracker/TkDetLayers/interface/CompatibleDetToGroupAdder.h"
00018 
00019 using namespace std;
00020 
00021 typedef GeometricSearchDet::DetWithState DetWithState;
00022 
00023 PixelForwardLayer::PixelForwardLayer(vector<const PixelBlade*>& blades):
00024   theComps(blades.begin(),blades.end())
00025 {
00026   for(vector<const GeometricSearchDet*>::const_iterator it=theComps.begin();
00027       it!=theComps.end();it++){  
00028     theBasicComps.insert(theBasicComps.end(),   
00029                          (**it).basicComponents().begin(),
00030                          (**it).basicComponents().end());
00031   }
00032 
00033   //They should be already phi-ordered. TO BE CHECKED!!
00034   //sort( theBlades.begin(), theBlades.end(), PhiLess());
00035   setSurface( computeSurface() );
00036   
00037   //Is a "periodic" binFinderInPhi enough?. TO BE CHECKED!!
00038   theBinFinder = BinFinderType( theComps.front()->surface().position().phi(),
00039                                 theComps.size());
00040 
00041   //--------- DEBUG INFO --------------
00042   LogDebug("TkDetLayers") << "DEBUG INFO for PixelForwardLayer" << "\n"
00043                           << "PixelForwardLayer.surfcace.phi(): " 
00044                           << this->surface().position().phi() << "\n"
00045                           << "PixelForwardLayer.surfcace.z(): " 
00046                           << this->surface().position().z() << "\n"
00047                           << "PixelForwardLayer.surfcace.innerR(): " 
00048                           << this->specificSurface().innerRadius() << "\n"
00049                           << "PixelForwardLayer.surfcace.outerR(): " 
00050                           << this->specificSurface().outerRadius() ;
00051 
00052   for(vector<const GeometricSearchDet*>::const_iterator it=theComps.begin(); 
00053       it!=theComps.end(); it++){
00054     LogDebug("TkDetLayers") << "blades phi,z,r: " 
00055                             << (*it)->surface().position().phi() << " , "
00056                             << (*it)->surface().position().z() <<   " , "
00057                             << (*it)->surface().position().perp();
00058   }
00059   //-----------------------------------
00060 
00061     
00062 }
00063 
00064 PixelForwardLayer::~PixelForwardLayer(){
00065   vector<const GeometricSearchDet*>::const_iterator i;
00066   for (i=theComps.begin(); i!=theComps.end(); i++) {
00067     delete *i;
00068   }
00069 } 
00070 
00071 void
00072 PixelForwardLayer::groupedCompatibleDetsV( const TrajectoryStateOnSurface& tsos,
00073                                           const Propagator& prop,
00074                                            const MeasurementEstimator& est,
00075                                            std::vector<DetGroup> & result) const {
00076   vector<DetGroup> closestResult;
00077   SubTurbineCrossings  crossings; 
00078 
00079   crossings = computeCrossings( tsos, prop.propagationDirection());
00080   if (!crossings.isValid){
00081     //edm::LogInfo("TkDetLayers") << "computeCrossings returns invalid in PixelForwardLayer::groupedCompatibleDets:";
00082     return;
00083   }
00084 
00085   typedef CompatibleDetToGroupAdder Adder;
00086   Adder::add( *theComps[theBinFinder.binIndex(crossings.closestIndex)], 
00087              tsos, prop, est, closestResult);
00088 
00089   if(closestResult.empty()){
00090     Adder::add( *theComps[theBinFinder.binIndex(crossings.nextIndex)], 
00091                tsos, prop, est, result);
00092     return;
00093   }      
00094 
00095   DetGroupElement closestGel( closestResult.front().front());
00096   float window = computeWindowSize( closestGel.det(), closestGel.trajectoryState(), est);
00097 
00098   //float detWidth = closestGel.det()->surface().bounds().width();
00099   //if (crossings.nextDistance < detWidth + window) {
00100   vector<DetGroup> nextResult;
00101   if (Adder::add( *theComps[theBinFinder.binIndex(crossings.nextIndex)], 
00102                   tsos, prop, est, nextResult)) {
00103     int crossingSide = LayerCrossingSide().endcapSide( tsos, prop);
00104     int theHelicity = computeHelicity(theComps[theBinFinder.binIndex(crossings.closestIndex)],
00105                                         theComps[theBinFinder.binIndex(crossings.nextIndex)] );
00106     DetGroupMerger::orderAndMergeTwoLevels( closestResult, nextResult, result, 
00107                                             theHelicity, crossingSide);
00108   }
00109   else {
00110     result.swap(closestResult);
00111   }
00112   
00113   /*
00114   }
00115   else {
00116     result.swap(closestResult);
00117   }
00118   */
00119 
00120   // --- THIS lines may speed up the reconstruction. But it reduces slightly the efficiency.
00121   // only loop over neighbors (other than closest and next) if window is BIG  
00122   //if (window > 0.5*detWidth) {
00123   searchNeighbors( tsos, prop, est, crossings, window, result);
00124   //} 
00125 }
00126 
00127 
00128 
00129 void 
00130 PixelForwardLayer::searchNeighbors( const TrajectoryStateOnSurface& tsos,
00131                                     const Propagator& prop,
00132                                     const MeasurementEstimator& est,
00133                                     const SubTurbineCrossings& crossings,
00134                                     float window, 
00135                                     vector<DetGroup>& result) const
00136 {
00137   typedef CompatibleDetToGroupAdder Adder;
00138   int crossingSide = LayerCrossingSide().endcapSide( tsos, prop);
00139   typedef DetGroupMerger Merger;
00140 
00141   int negStart = min( crossings.closestIndex, crossings.nextIndex) - 1;
00142   int posStart = max( crossings.closestIndex, crossings.nextIndex) + 1;
00143 
00144   int quarter = theComps.size()/4;
00145  
00146   vector<DetGroup> tmp;
00147   vector<DetGroup> newResult;
00148   for (int idet=negStart; idet >= negStart - quarter+1; idet--) {
00149     tmp.clear();
00150     newResult.clear();
00151     const GeometricSearchDet* neighbor = theComps[theBinFinder.binIndex(idet)];
00152     // if (!overlap( gCrossingPos, *neighbor, window)) break; // mybe not needed?
00153     // maybe also add shallow crossing angle test here???
00154     if (!Adder::add( *neighbor, tsos, prop, est, tmp)) break;
00155     int theHelicity = computeHelicity(theComps[theBinFinder.binIndex(idet)],
00156                                       theComps[theBinFinder.binIndex(idet+1)] );
00157     Merger::orderAndMergeTwoLevels( tmp, result, newResult, theHelicity, crossingSide);
00158     result.swap(newResult);
00159   }
00160   for (int idet=posStart; idet < posStart + quarter-1; idet++) {
00161     tmp.clear();
00162     newResult.clear();
00163     const GeometricSearchDet* neighbor = theComps[theBinFinder.binIndex(idet)];
00164     // if (!overlap( gCrossingPos, *neighbor, window)) break; // mybe not needed?
00165     // maybe also add shallow crossing angle test here???
00166     if (!Adder::add( *neighbor, tsos, prop, est, tmp)) break;
00167     int theHelicity = computeHelicity(theComps[theBinFinder.binIndex(idet-1)],
00168                                       theComps[theBinFinder.binIndex(idet)] );
00169     Merger::orderAndMergeTwoLevels( result, tmp, newResult, theHelicity, crossingSide);
00170     result.swap(newResult);
00171   }
00172 }
00173 
00174 int 
00175 PixelForwardLayer::computeHelicity(const GeometricSearchDet* firstBlade,const GeometricSearchDet* secondBlade) const
00176 {  
00177   if( fabs(firstBlade->position().z()) < fabs(secondBlade->position().z()) ) return 0;
00178   return 1;
00179 }
00180 
00181 PixelForwardLayer::SubTurbineCrossings 
00182 PixelForwardLayer::computeCrossings( const TrajectoryStateOnSurface& startingState,
00183                                      PropagationDirection propDir) const
00184 {  
00185   typedef MeasurementEstimator::Local2DVector Local2DVector;
00186 
00187   HelixPlaneCrossing::PositionType startPos( startingState.globalPosition());
00188   HelixPlaneCrossing::DirectionType startDir( startingState.globalMomentum());
00189   float rho( startingState.transverseCurvature());
00190 
00191   HelixArbitraryPlaneCrossing turbineCrossing( startPos, startDir, rho,
00192                                                propDir);
00193 
00194   pair<bool,double> thePath = turbineCrossing.pathLength( specificSurface() );
00195   
00196   if (!thePath.first) {
00197     //edm::LogInfo("TkDetLayers") << "ERROR in PixelForwardLayer: disk not crossed by track" ;
00198     return SubTurbineCrossings();
00199   }
00200 
00201   HelixPlaneCrossing::PositionType  turbinePoint( turbineCrossing.position(thePath.second));
00202   HelixPlaneCrossing::DirectionType turbineDir( turbineCrossing.direction(thePath.second));
00203   int closestIndex = theBinFinder.binIndex(turbinePoint.phi());
00204 
00205   const BoundPlane& closestPlane( static_cast<const BoundPlane&>( 
00206     theComps[closestIndex]->surface()));
00207 
00208 
00209   HelixArbitraryPlaneCrossing2Order theBladeCrossing(turbinePoint, turbineDir, rho);
00210 
00211   pair<bool,double> theClosestBladePath = theBladeCrossing.pathLength( closestPlane );
00212   LocalPoint closestPos = closestPlane.toLocal(GlobalPoint(theBladeCrossing.position(theClosestBladePath.second)) );
00213     
00214   float closestDist = closestPos.x(); // use fact that local X perp to global Y
00215 
00216   //int next = turbinePoint.phi() - closestPlane.position().phi() > 0 ? closest+1 : closest-1;
00217   int nextIndex = PhiLess()( closestPlane.position().phi(), turbinePoint.phi()) ? 
00218     closestIndex+1 : closestIndex-1;
00219 
00220   const BoundPlane& nextPlane( static_cast<const BoundPlane&>( 
00221     theComps[ theBinFinder.binIndex(nextIndex)]->surface()));
00222 
00223   pair<bool,double> theNextBladePath    = theBladeCrossing.pathLength( nextPlane );
00224   LocalPoint nextPos = nextPlane.toLocal(GlobalPoint(theBladeCrossing.position(theNextBladePath.second)) );
00225 
00226   float nextDist = nextPos.x();
00227 
00228   if (fabs(closestDist) < fabs(nextDist)) {
00229     return SubTurbineCrossings( closestIndex, nextIndex, nextDist);
00230   }
00231   else {
00232     return SubTurbineCrossings( nextIndex, closestIndex, closestDist);
00233   }
00234 }
00235 
00236 float 
00237 PixelForwardLayer::computeWindowSize( const GeomDet* det, 
00238                                       const TrajectoryStateOnSurface& tsos, 
00239                                       const MeasurementEstimator& est) const
00240 {
00241   return est.maximalLocalDisplacement(tsos, det->surface()).x();
00242 }
00243 
00244 

Generated on Tue Jun 9 17:45:47 2009 for CMSSW by  doxygen 1.5.4