CMS 3D CMS Logo

SimpleNavigableLayer.cc

Go to the documentation of this file.
00001 #include "RecoTracker/TkNavigation/interface/SimpleNavigableLayer.h"
00002 
00003 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00004 
00005 #include "DataFormats/GeometrySurface/interface/BoundCylinder.h"
00006 #include "DataFormats/GeometrySurface/interface/BoundDisk.h"
00007 #include "TrackingTools/PatternTools/interface/TransverseImpactPointExtrapolator.h"
00008 
00009 using namespace std;
00010 
00011 bool SimpleNavigableLayer::wellInside( const FreeTrajectoryState& fts,
00012                                        PropagationDirection dir,
00013                                        const BarrelDetLayer* bl,
00014                                        DLC& result) const
00015 {
00016   //TSOS propState = propagator(dir).propagate( fts, bl->specificSurface());
00017   TSOS propState ;
00018 
00019   if (bl==detLayer()){
00020     //self propagating. step one: go close to the center
00021     GlobalPoint initialPoint = fts.position();
00022     TransverseImpactPointExtrapolator middle;
00023     GlobalPoint center(0,0,0);
00024     propState = middle.extrapolate(fts, center, propagator(dir));
00025     if ( !propState.isValid()) return false;
00026 
00027     FreeTrajectoryState & dest = *propState.freeState();
00028     GlobalPoint middlePoint = dest.position();
00029     const double toCloseToEachOther=1e-4;
00030     if ( (middlePoint-initialPoint).mag() < toCloseToEachOther){
00031       LogDebug("SimpleNavigableLayer")<<"initial state and PCA are identical. Things are bound to fail. Do not add the link.";
00032       return false;
00033     }
00034 
00035     std::string dirS;
00036     if (dir==alongMomentum) dirS = "alongMomentum";
00037     else if (dir==oppositeToMomentum) dirS = "oppositeToMomentum";
00038     else dirS = "anyDirection";
00039 
00040     LogDebug("SimpleNavigableLayer")<<"self propagating("<< dir <<") from:\n"
00041                                     <<fts<<"\n"
00042                                     <<dest<<"\n"
00043                                     <<" and the direction is: "<<dir<<" = "<<dirS;
00044     
00045     //second propagation to go on the other side of the barrel
00046     propState = propagator(dir).propagate( dest, bl->specificSurface());
00047     if ( !propState.isValid()) return false;
00048 
00049     FreeTrajectoryState & dest2 = *propState.freeState();
00050     GlobalPoint finalPoint = dest2.position();
00051     LogDebug("SimpleNavigableLayer")<<"second propagation("<< dir <<") to: \n"
00052                                     <<dest2;
00053     double finalDot = (middlePoint - initialPoint).basicVector().dot((finalPoint-middlePoint).basicVector());
00054     if (finalDot<0){ // check that before and after are in different side.
00055       LogDebug("SimpleNavigableLayer")<<"switch side back: ABORT.";
00056       return false;
00057     }
00058   }else{
00059     propState= propagator(dir).propagate( fts, bl->specificSurface());
00060   }
00061 
00062   if ( !propState.isValid()) return false;
00063  
00064   //if requested check that the layer is crossed on the right side
00065   if (theCheckCrossingSide){
00066     bool backTobackTransverse = (fts.position().x()*propState.globalPosition().x() + fts.position().y()*propState.globalPosition().y())<0;
00067     bool backToback = propState.globalPosition().basicVector().dot(fts.position().basicVector())<0;
00068 
00069     if (backTobackTransverse || backToback ){
00070       LogTrace("TkNavigation") << "Crossing over prevented!\nStaring from (x,y,z,r) (" 
00071                                << fts.position().x()<<","<< fts.position().y()<<","<< fts.position().z()<<","<<fts.position().perp()
00072                                << ") going to TSOS (x,y,z,r)" 
00073                                << propState.globalPosition().x()<<","<< propState.globalPosition().y()<<","<< propState.globalPosition().z()<<","<<propState.globalPosition().perp()<<")";
00074       return false;
00075     
00076     /*
00077     //we have to check the crossing side only if we are going to something smaller
00078     if (fts.position().perp()>bl->specificSurface().radius() || 
00079     fabs(fts.position().z())>bl->surface().bounds().length()/2. ){
00080     if (propState.globalPosition().basicVector().dot(fts.position().basicVector())<0){
00081     LogTrace("TkNavigation") << "Crossing over prevented!\nStaring from (x,y,z,r) (" 
00082     << fts.position().x()<<","<< fts.position().y()<<","<< fts.position().z()<<","<<fts.position().perp()
00083     << ") going to TSOS (x,y,z,r)" 
00084     << propState.globalPosition().x()<<","<< propState.globalPosition().y()<<","<< propState.globalPosition().z()<<","<<propState.globalPosition().perp()<<")";; 
00085     return false;
00086     }
00087     }   
00088     */
00089     }}
00090 
00091   const Bounds& bounds( bl->specificSurface().bounds());
00092   float length = bounds.length() / 2.f;
00093 
00094   // take into account the thickness of the layer
00095   float deltaZ = bounds.thickness()/2. / 
00096     fabs( tan( propState.globalDirection().theta()));
00097 
00098   // take into account the error on the predicted state
00099   const float nSigma = theEpsilon;  // temporary reuse of epsilon
00100   if (propState.hasError()) {
00101     deltaZ += nSigma * sqrt( fts.cartesianError().position().czz());
00102   }
00103 
00104   // cout << "SimpleNavigableLayer BarrelDetLayer deltaZ = " << deltaZ << endl;
00105 
00106   float zpos = propState.globalPosition().z();
00107   if ( fabs( zpos) < length + deltaZ) result.push_back( bl);
00108 
00109   if ( fabs( zpos) < length - deltaZ) return true;
00110   else return false;
00111 }
00112 
00113 bool SimpleNavigableLayer::wellInside( const FreeTrajectoryState& fts,
00114                                        PropagationDirection dir,
00115                                        const ForwardDetLayer* fl,
00116                                        DLC& result) const
00117 {
00118   TSOS propState = propagator(dir).propagate( fts, fl->specificSurface());
00119   if ( !propState.isValid()) return false;
00120 
00121   if (fl==detLayer()){
00122     LogDebug("SimpleNavigableLayer")<<"self propagating from:\n"
00123                                     <<fts<<"\n to \n"
00124                                     <<*propState.freeState();
00125   }
00126 
00127   //if requested avoids crossing over the tracker 
00128   if (theCheckCrossingSide){
00129     bool backTobackTransverse = (fts.position().x()*propState.globalPosition().x() + fts.position().y()*propState.globalPosition().y())<0;
00130     bool backToback = propState.globalPosition().basicVector().dot(fts.position().basicVector())<0;
00131 
00132     if (backTobackTransverse || backToback ){
00133       LogTrace("TkNavigation") << "Crossing over prevented!\nStaring from (x,y,z,r) (" 
00134                                << fts.position().x()<<","<< fts.position().y()<<","<< fts.position().z()<<","<<fts.position().perp()
00135                                << ") going to TSOS (x,y,z,r)" 
00136                                << propState.globalPosition().x()<<","<< propState.globalPosition().y()<<","<< propState.globalPosition().z()<<","<<propState.globalPosition().perp()<<")";; 
00137       return false;
00138     
00139   //    if (fts.position().z()*propState.globalPosition().z() < 0) return false;
00140     }}
00141 
00142 
00143   float rpos = propState.globalPosition().perp();
00144   float innerR = fl->specificSurface().innerRadius();
00145   float outerR = fl->specificSurface().outerRadius();
00146  
00147   // take into account the thickness of the layer
00148   float deltaR = fl->surface().bounds().thickness()/2. *
00149     fabs( tan( propState.localDirection().theta()));
00150 
00151   // take into account the error on the predicted state
00152   const float nSigma = theEpsilon;
00153   if (propState.hasError()) {
00154     LocalError err = propState.localError().positionError();
00155     // ignore correlation for the moment...
00156     deltaR += nSigma * sqrt(err.xx() + err.yy());
00157   }
00158 
00159   // cout << "SimpleNavigableLayer BarrelDetLayer deltaR = " << deltaR << endl;
00160 
00161   if ( innerR-deltaR < rpos && rpos < outerR+deltaR) result.push_back( fl);
00162   
00163   if ( innerR+deltaR < rpos && rpos < outerR-deltaR) return true;
00164   else return false;
00165 }
00166 
00167 bool SimpleNavigableLayer::wellInside( const FreeTrajectoryState& fts,
00168                                        PropagationDirection dir,
00169                                        const DLC& layers,
00170                                        DLC& result) const
00171 {
00172 
00173   // cout << "Entering SimpleNavigableLayer::wellInside" << endl;
00174 
00175   for (DLC::const_iterator i = layers.begin(); i != layers.end(); i++) {
00176     const BarrelDetLayer* bl = dynamic_cast<const BarrelDetLayer*>(*i);
00177     if ( bl != 0) {
00178       if (wellInside( fts, dir, bl, result)) return true;
00179     }
00180     else {
00181       const ForwardDetLayer* fl = dynamic_cast<const ForwardDetLayer*>(*i);
00182       if ( fl == 0) edm::LogError("TkNavigation") << "dynamic_cast<const ForwardDetLayer*> failed" ;
00183       if (wellInside( fts, dir, fl, result)) return true;
00184     }
00185   }
00186   return false;
00187 }
00188 
00189 bool SimpleNavigableLayer::wellInside( const FreeTrajectoryState& fts,
00190                                        PropagationDirection dir,
00191                                        ConstBDLI begin, ConstBDLI end,
00192                                        DLC& result) const
00193 {
00194   for ( ConstBDLI i = begin; i < end; i++) {
00195     if (wellInside( fts, dir, *i, result)) return true;
00196   }
00197   return false;
00198 }
00199 
00200 bool SimpleNavigableLayer::wellInside( const FreeTrajectoryState& fts,
00201                                        PropagationDirection dir,
00202                                        ConstFDLI begin, ConstFDLI end,
00203                                        DLC& result) const
00204 {
00205   for ( ConstFDLI i = begin; i < end; i++) {
00206     if (wellInside( fts, dir, *i, result)) return true;
00207   }
00208   return false;
00209 }
00210 
00211 Propagator& SimpleNavigableLayer::propagator( PropagationDirection dir) const
00212 {
00213 #ifndef CMS_NO_MUTABLE
00214   thePropagator.setPropagationDirection(dir);
00215   return thePropagator;
00216 #else
00217   SimpleNavigableLayer* mthis = const_cast<SimpleNavigableLayer*>(this);
00218   mthis->thePropagator.setPropagationDirection(dir);
00219   return mthis->thePropagator;
00220 #endif
00221 }
00222 
00223 void SimpleNavigableLayer::pushResult( DLC& result, const BDLC& tmp) const 
00224 {
00225   for ( ConstBDLI i = tmp.begin(); i != tmp.end(); i++) {
00226     result.push_back(*i);
00227   }
00228 }
00229 
00230 void SimpleNavigableLayer::pushResult( DLC& result, const FDLC& tmp) const 
00231 {
00232   for ( ConstFDLI i = tmp.begin(); i != tmp.end(); i++) {
00233     result.push_back(*i);
00234   }
00235 }
00236 

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