CMS 3D CMS Logo

SimpleForwardNavigableLayer.cc

Go to the documentation of this file.
00001 #include "RecoTracker/TkNavigation/interface/SimpleForwardNavigableLayer.h"
00002 
00003 #include "TrackingTools/DetLayers/interface/BarrelDetLayer.h"
00004 #include "TrackingTools/DetLayers/interface/ForwardDetLayer.h"
00005 #include "TrackingTools/DetLayers/interface/DetLayerException.h"
00006 
00007 #include "DataFormats/GeometrySurface/interface/BoundCylinder.h"
00008 #include "DataFormats/GeometrySurface/interface/BoundDisk.h"
00009 
00010 #include "RecoTracker/TkNavigation/interface/TkLayerLess.h"
00011 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00012 
00013 
00014 using namespace std;
00015 
00016 SimpleForwardNavigableLayer::
00017 SimpleForwardNavigableLayer( ForwardDetLayer* detLayer,
00018                              const BDLC& outerBL, 
00019                              const FDLC& outerFL, 
00020                              const MagneticField* field,
00021                              float epsilon,
00022                              bool checkCrossingSide) :
00023   SimpleNavigableLayer(field,epsilon,checkCrossingSide),
00024   areAllReachableLayersSet(false),
00025   theDetLayer(detLayer), 
00026   theOuterBarrelLayers(outerBL),
00027   theInnerBarrelLayers(0),
00028   theOuterForwardLayers(outerFL),
00029   theInnerForwardLayers(0),
00030   theOuterLayers(0), 
00031   theInnerLayers(0)
00032 {
00033   
00034   // put barrel and forward layers together
00035   theOuterLayers.reserve(outerBL.size() + outerFL.size());
00036   for ( ConstBDLI bl = outerBL.begin(); bl != outerBL.end(); bl++ ) 
00037     theOuterLayers.push_back(*bl);
00038   for ( ConstFDLI fl = outerFL.begin(); fl != outerFL.end(); fl++ ) 
00039     theOuterLayers.push_back(*fl);
00040 
00041   // sort the outer layers 
00042   sort(theOuterLayers.begin(), theOuterLayers.end(), TkLayerLess());
00043   sort(theOuterForwardLayers.begin(), theOuterForwardLayers.end(), TkLayerLess());
00044   sort(theOuterBarrelLayers.begin(), theOuterBarrelLayers.end(), TkLayerLess());
00045 
00046 }
00047 
00048 SimpleForwardNavigableLayer::
00049 SimpleForwardNavigableLayer( ForwardDetLayer* detLayer,
00050                              const BDLC& outerBL, 
00051                              const BDLC& allOuterBL,
00052                              const BDLC& innerBL,
00053                              const BDLC& allInnerBL,
00054                              const FDLC& outerFL, 
00055                              const FDLC& allOuterFL,
00056                              const FDLC& innerFL,
00057                              const FDLC& allInnerFL,
00058                              const MagneticField* field,
00059                              float epsilon,
00060                              bool checkCrossingSide) :
00061   SimpleNavigableLayer(field,epsilon,checkCrossingSide),
00062   areAllReachableLayersSet(true),
00063   theDetLayer(detLayer), 
00064   theOuterBarrelLayers(outerBL),
00065   theAllOuterBarrelLayers(allOuterBL),
00066   theInnerBarrelLayers(innerBL),
00067   theAllInnerBarrelLayers(allInnerBL),
00068   theOuterForwardLayers(outerFL),
00069   theAllOuterForwardLayers(allOuterFL),
00070   theInnerForwardLayers(innerFL),
00071   theAllInnerForwardLayers(allInnerFL),
00072   theOuterLayers(0), 
00073   theInnerLayers(0),
00074   theAllOuterLayers(0),
00075   theAllInnerLayers(0)
00076 {
00077   
00078   // put barrel and forward layers together
00079   theOuterLayers.reserve(outerBL.size() + outerFL.size());
00080   for ( ConstBDLI bl = outerBL.begin(); bl != outerBL.end(); bl++ ) 
00081     theOuterLayers.push_back(*bl);
00082   for ( ConstFDLI fl = outerFL.begin(); fl != outerFL.end(); fl++ ) 
00083     theOuterLayers.push_back(*fl);
00084 
00085   theAllOuterLayers.reserve(allOuterBL.size() + allOuterFL.size());
00086   for ( ConstBDLI bl = allOuterBL.begin(); bl != allOuterBL.end(); bl++ )
00087     theAllOuterLayers.push_back(*bl);
00088   for ( ConstFDLI fl = allOuterFL.begin(); fl != allOuterFL.end(); fl++ )
00089     theAllOuterLayers.push_back(*fl);
00090 
00091   theInnerLayers.reserve(innerBL.size() + innerFL.size());
00092   for ( ConstBDLI bl = innerBL.begin(); bl != innerBL.end(); bl++ )
00093     theInnerLayers.push_back(*bl);
00094   for ( ConstFDLI fl = innerFL.begin(); fl != innerFL.end(); fl++ )
00095     theInnerLayers.push_back(*fl);
00096 
00097   theAllInnerLayers.reserve(allInnerBL.size() + allInnerFL.size());
00098   for ( ConstBDLI bl = allInnerBL.begin(); bl != allInnerBL.end(); bl++ )
00099     theAllInnerLayers.push_back(*bl);
00100   for ( ConstFDLI fl = allInnerFL.begin(); fl != allInnerFL.end(); fl++ )
00101     theAllInnerLayers.push_back(*fl);
00102 
00103 
00104   // sort the outer layers 
00105   sort(theOuterLayers.begin(), theOuterLayers.end(), TkLayerLess());
00106   sort(theInnerLayers.begin(), theInnerLayers.end(),TkLayerLess(outsideIn));
00107   sort(theOuterBarrelLayers.begin(), theOuterBarrelLayers.end(), TkLayerLess());
00108   sort(theInnerBarrelLayers.begin(), theInnerBarrelLayers.end(),TkLayerLess(outsideIn));
00109   sort(theOuterForwardLayers.begin(), theOuterForwardLayers.end(), TkLayerLess());
00110   sort(theInnerForwardLayers.begin(), theInnerForwardLayers.end(),TkLayerLess(outsideIn));
00111 
00112   sort(theAllOuterLayers.begin(), theAllOuterLayers.end(), TkLayerLess());
00113   sort(theAllInnerLayers.begin(), theAllInnerLayers.end(),TkLayerLess(outsideIn));
00114 
00115 }
00116 
00117 
00118 
00119 vector<const DetLayer*> 
00120 SimpleForwardNavigableLayer::nextLayers( NavigationDirection dir) const
00121 {
00122   vector<const DetLayer*> result;
00123   
00124   // the order is the one in which layers
00125   // should be checked for a reasonable trajectory
00126 
00127   if ( dir == insideOut ) {
00128     return theOuterLayers;
00129   }
00130   else {
00131     return theInnerLayers;
00132   }
00133 
00134   return result;
00135 }
00136 
00137 vector<const DetLayer*> 
00138 SimpleForwardNavigableLayer::nextLayers( const FreeTrajectoryState& fts, 
00139                                          PropagationDirection dir) const 
00140 {
00141   // This method contains the sequence in which the layers are tested.
00142   // The iteration stops as soon as a layer contains the propagated state
00143   // within epsilon
00144 
00145   vector<const DetLayer*> result;
00146 
00147   FreeTrajectoryState ftsWithoutErrors = (fts.hasError()) ?
00148     FreeTrajectoryState(fts.parameters()) : fts;
00149 
00150   //establish whether the tracks is crossing the tracker from outer layers to inner ones 
00151   //or from inner to outer
00152   //bool isInOutTrack  = (fts.position().basicVector().dot(fts.momentum().basicVector())>0) ? 1 : 0;
00153   float zpos = fts.position().z();
00154   bool isInOutTrackFWD = fts.momentum().z()*zpos>0;
00155   GlobalVector transversePosition(fts.position().x(), fts.position().y(), 0);
00156   bool isInOutTrackBarrel  = (transversePosition.dot(fts.momentum())>0) ? 1 : 0;        
00157 
00158   //establish whether inner or outer layers are crossed after propagation, according
00159   //to BOTH propagationDirection AND track momentum
00160   bool dirOppositeXORisInOutTrackBarrel = ( !(dir == oppositeToMomentum) && isInOutTrackBarrel) || ( (dir == oppositeToMomentum) && !isInOutTrackBarrel);
00161   bool dirOppositeXORisInOutTrackFWD = ( !(dir == oppositeToMomentum) && isInOutTrackFWD) || ( (dir == oppositeToMomentum) && !isInOutTrackFWD);
00162   //bool dirOppositeXORisInOutTrack = ( !(dir == oppositeToMomentum) && isInOutTrack) || ( (dir == oppositeToMomentum) && !isInOutTrack);
00163 
00164   if ( dirOppositeXORisInOutTrackFWD && dirOppositeXORisInOutTrackBarrel ) { //standard tracks
00165 
00166     //wellInside(ftsWithoutErrors, dir, theOuterForwardLayers.begin(), theOuterForwardLayers.end(), result);
00167     wellInside(ftsWithoutErrors, dir, theOuterLayers, result);
00168 
00169   }
00170   else if (!dirOppositeXORisInOutTrackFWD && !dirOppositeXORisInOutTrackBarrel){ // !dirOppositeXORisInOutTrack
00171 
00172     //wellInside(ftsWithoutErrors, dir, theInnerForwardLayers.begin(), theInnerForwardLayers.end(), result);
00173     wellInside(ftsWithoutErrors, dir, theInnerLayers, result);
00174 
00175   } else if (!dirOppositeXORisInOutTrackFWD && dirOppositeXORisInOutTrackBarrel ) {
00176     wellInside(ftsWithoutErrors, dir, theInnerForwardLayers.begin(), theInnerForwardLayers.end(), result);
00177     wellInside(ftsWithoutErrors, dir, theOuterBarrelLayers.begin(), theOuterBarrelLayers.end(), result);                
00178 
00179   } else {
00180     wellInside(ftsWithoutErrors, dir, theInnerBarrelLayers.begin(), theInnerBarrelLayers.end(), result);        
00181     wellInside(ftsWithoutErrors, dir, theOuterForwardLayers.begin(), theOuterForwardLayers.end(), result);
00182 
00183   }
00184 /*
00185   if ( dirOppositeXORisInOutTrackBarrel ) {
00186 
00187     wellInside(ftsWithoutErrors, dir, theOuterBarrelLayers.begin(), theOuterBarrelLayers.end(), result);
00188 
00189   }
00190   else { // !dirOppositeXORisInOutTrack
00191 
00192     wellInside(ftsWithoutErrors, dir, theInnerBarrelLayers.begin(),theInnerBarrelLayers.end(), result);
00193 
00194   }
00195 */
00196 
00197   return result;
00198 }
00199 
00200 
00201 vector<const DetLayer*> 
00202 SimpleForwardNavigableLayer::compatibleLayers( NavigationDirection dir) const
00203 {
00204   if( !areAllReachableLayersSet ){
00205     edm::LogError("TkNavigation") << "ERROR: compatibleLayers() method used without all reachableLayers are set" ;
00206     throw DetLayerException("compatibleLayers() method used without all reachableLayers are set"); 
00207   }
00208 
00209   vector<const DetLayer*> result;
00210 
00211   if ( dir == insideOut ) {
00212     return theAllOuterLayers;
00213   }
00214   else {
00215     return theAllInnerLayers;
00216   }
00217   return result;
00218 
00219 }
00220 
00221 vector<const DetLayer*> 
00222 SimpleForwardNavigableLayer::compatibleLayers( const FreeTrajectoryState& fts, 
00223                                                PropagationDirection dir) const
00224 {
00225   if( !areAllReachableLayersSet ){
00226     edm::LogError("TkNavigation") << "ERROR: compatibleLayers() method used without all reachableLayers are set" ;
00227     throw DetLayerException("compatibleLayers() method used without all reachableLayers are set"); 
00228   }
00229 
00230   vector<const DetLayer*> result;
00231   FreeTrajectoryState ftsWithoutErrors = (fts.hasError()) ?
00232     FreeTrajectoryState(fts.parameters()) : fts;
00233 
00234   //establish whether the tracks is crossing the tracker from outer layers to inner ones 
00235   //or from inner to outer.
00236   //bool isInOutTrack  = (fts.position().basicVector().dot(fts.momentum().basicVector())>0) ? 1 : 0;
00237 /*  float zpos = fts.position().z();
00238   bool isInOutTrack = fts.momentum().z()*zpos>0;
00239   
00240   //establish whether inner or outer layers are crossed after propagation, according
00241   //to BOTH propagationDirection AND track momentum
00242   bool dirOppositeXORisInOutTrack = ( !(dir == oppositeToMomentum) && isInOutTrack) || ((dir == oppositeToMomentum) && !isInOutTrack);
00243 
00244   if ( dirOppositeXORisInOutTrack ) {
00245     wellInside(ftsWithoutErrors, dir, theAllOuterLayers, result);
00246   }
00247   else { // !dirOppositeXORisInOutTrack
00248     wellInside(ftsWithoutErrors, dir, theAllInnerLayers, result);
00249   }
00250 */
00251 
00252   float zpos = fts.position().z();
00253   bool isInOutTrackFWD = fts.momentum().z()*zpos>0;
00254   GlobalVector transversePosition(fts.position().x(), fts.position().y(), 0);
00255   bool isInOutTrackBarrel  = (transversePosition.dot(fts.momentum())>0) ? 1 : 0;
00256 
00257   //establish whether inner or outer layers are crossed after propagation, according
00258   //to BOTH propagationDirection AND track momentum
00259   bool dirOppositeXORisInOutTrackBarrel = ( !(dir == oppositeToMomentum) && isInOutTrackBarrel) || ( (dir == oppositeToMomentum) && !isInOutTrackBarrel);
00260   bool dirOppositeXORisInOutTrackFWD = ( !(dir == oppositeToMomentum) && isInOutTrackFWD) || ( (dir == oppositeToMomentum) && !isInOutTrackFWD);
00261   //bool dirOppositeXORisInOutTrack = ( !(dir == oppositeToMomentum) && isInOutTrack) || ( (dir == oppositeToMomentum) && !isInOutTrack);
00262 
00263   if ( dirOppositeXORisInOutTrackFWD && dirOppositeXORisInOutTrackBarrel ) { //standard tracks
00264 
00265     //wellInside(ftsWithoutErrors, dir, theOuterForwardLayers.begin(), theOuterForwardLayers.end(), result);
00266     wellInside(ftsWithoutErrors, dir, theAllOuterLayers, result);
00267 
00268   }
00269   else if (!dirOppositeXORisInOutTrackFWD && !dirOppositeXORisInOutTrackBarrel){ // !dirOppositeXORisInOutTrack
00270   
00271     //wellInside(ftsWithoutErrors, dir, theInnerForwardLayers.begin(), theInnerForwardLayers.end(), result);
00272     wellInside(ftsWithoutErrors, dir, theAllInnerLayers, result);
00273   
00274   } else if (!dirOppositeXORisInOutTrackFWD && dirOppositeXORisInOutTrackBarrel ) {
00275         
00276     wellInside(ftsWithoutErrors, dir, theAllInnerForwardLayers.begin(), theAllInnerForwardLayers.end(), result);
00277     wellInside(ftsWithoutErrors, dir, theAllOuterBarrelLayers.begin(), theAllOuterBarrelLayers.end(), result);
00278   
00279   } else { 
00280   
00281     wellInside(ftsWithoutErrors, dir, theAllInnerBarrelLayers.begin(), theAllInnerBarrelLayers.end(), result);
00282     wellInside(ftsWithoutErrors, dir, theAllOuterForwardLayers.begin(), theAllOuterForwardLayers.end(), result);
00283 
00284   }
00285   return result;
00286 }
00287 
00288 
00289 DetLayer* SimpleForwardNavigableLayer::detLayer() const { return theDetLayer; }
00290 
00291 void SimpleForwardNavigableLayer::setDetLayer( DetLayer* dl) {
00292   cerr << "Warning: SimpleForwardNavigableLayer::setDetLayer called."
00293        << endl << "This should never happen!" << endl;
00294 }
00295 
00296 void SimpleForwardNavigableLayer::setInwardLinks(const BDLC& innerBL, 
00297                                                  const FDLC& innerFL,
00298                                                  TkLayerLess sorter) {
00299 
00300   theInnerBarrelLayers  = innerBL;
00301   theInnerForwardLayers = innerFL;
00302 
00303   theInnerLayers.clear();
00304   theInnerLayers.reserve(innerBL.size() + innerFL.size());
00305   for ( ConstBDLI bl = innerBL.begin(); bl != innerBL.end(); bl++ )
00306     theInnerLayers.push_back(*bl);
00307   for ( ConstFDLI fl = innerFL.begin(); fl != innerFL.end(); fl++ )
00308     theInnerLayers.push_back(*fl);
00309 
00310   // sort the inner layers
00311   sort(theInnerLayers.begin(), theInnerLayers.end(),sorter);
00312   sort(theInnerForwardLayers.begin(), theInnerForwardLayers.end(),sorter);
00313   sort(theInnerBarrelLayers.begin(), theInnerBarrelLayers.end(), sorter);
00314 
00315 }
00316 
00317 void SimpleForwardNavigableLayer::setAdditionalLink(DetLayer* additional, NavigationDirection direction){
00318   ForwardDetLayer* fadditional = dynamic_cast<ForwardDetLayer*>(additional);
00319   BarrelDetLayer*  badditional = dynamic_cast<BarrelDetLayer*>(additional);
00320   if (badditional){
00321         if (direction==insideOut){
00322                 theOuterBarrelLayers.push_back(badditional);
00323                 theAllOuterBarrelLayers.push_back(badditional);
00324                 theOuterLayers.push_back(badditional);
00325                 theAllOuterLayers.push_back(badditional);
00326                 return;
00327         }
00328         theInnerBarrelLayers.push_back(badditional);
00329         theAllInnerBarrelLayers.push_back(badditional);
00330         theInnerLayers.push_back(badditional);
00331         theAllInnerLayers.push_back(badditional);
00332         return;
00333   } else if (fadditional){
00334         if (direction==insideOut){
00335                 theOuterForwardLayers.push_back(fadditional);
00336                 theAllOuterForwardLayers.push_back(fadditional);        
00337                 theOuterLayers.push_back(badditional);
00338                 theAllOuterLayers.push_back(badditional);
00339                 return;
00340         }
00341         theInnerForwardLayers.push_back(fadditional);
00342         theAllInnerForwardLayers.push_back(fadditional);
00343         theInnerLayers.push_back(badditional);
00344         theAllInnerLayers.push_back(badditional);
00345         return;
00346   }
00347   edm::LogError("TkNavigation") << "trying to add neither a ForwardDetLayer nor a BarrelDetLayer";
00348   return;
00349 } 

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