00001 #include "TrackingTools/DetLayers/interface/NavigationSetter.h" 00002 #include "TrackingTools/DetLayers/interface/NavigationSchool.h" 00003 #include "TrackingTools/DetLayers/interface/NavigableLayer.h" 00004 #include "TrackingTools/DetLayers/interface/DetLayer.h" 00005 #include "FWCore/MessageLogger/interface/MessageLogger.h" 00006 00007 NavigationSetter::NavigationSetter( const NavigationSchool& school) 00008 : theNav(school) 00009 { 00010 //save the current state from all layer in the system which is being set: allow to set it back 00011 saveState(); 00012 00013 //remove any links from the detlayer in the system: allow partial navigation (BeamHalo) 00014 cleanState(); 00015 00016 //set the current navigation 00017 setState(school.navigableLayers()); 00018 } 00019 00020 NavigationSetter::~NavigationSetter() 00021 { 00022 //remove any link from the detlyaer in the system which has been set 00023 cleanState(); 00024 /* 00025 LogDebug("NavigationSetter")<<"NavigationSchool settings are totally reset in the destructor of NavigationSetter.\n" 00026 <<"this is the designed behavior. If you do not get track reconstruction, please refer to\n" 00027 <<"https://twiki.cern.ch/twiki/bin/view/CMS/NavigationSchool \n" 00028 <<"to properly use the NavigationSetter."; 00029 */ 00030 00031 //restore the previous layer DetLayer settings within the system which has been set. 00032 setState( theSavedState); 00033 } 00034 00035 00036 void NavigationSetter::saveState() { 00037 //remember all navigable layers from all layer in the system. 00038 std::vector<DetLayer*>::const_iterator i = theNav.allLayersInSystem().begin(); 00039 std::vector<DetLayer*>::const_iterator end = theNav.allLayersInSystem().end(); 00040 for (; i != end; ++i){ 00041 if (*i !=0) theSavedState.push_back( (*i)->navigableLayer()); 00042 } 00043 } 00044 00045 void NavigationSetter::cleanState(){ 00046 //set no navigable layer to all detlayers in the system 00047 std::vector<DetLayer*>::const_iterator i = theNav.allLayersInSystem().begin(); 00048 std::vector<DetLayer*>::const_iterator end = theNav.allLayersInSystem().end(); 00049 for (; i != end; ++i){ 00050 if (*i !=0) (*i)->setNavigableLayer(0); 00051 } 00052 } 00053 00054 void NavigationSetter::setState( const StateType& newState) { 00055 //set DetLayer->NavigableLayer link from navigable layer in given state 00056 StateType::const_iterator i = newState.begin(); 00057 StateType::const_iterator end = newState.end(); 00058 for (; i != end; i++) { 00059 if ( *i != 0) (**i).detLayer()->setNavigableLayer(*i); 00060 } 00061 } 00062