Go to the documentation of this file.00001 #include "RecoTracker/TkNavigation/interface/CfgNavigationSchool.h"
00002
00003 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00004 #include "TrackingTools/DetLayers/interface/NavigationSetter.h"
00005 #include "RecoTracker/TkNavigation/interface/SimpleBarrelNavigableLayer.h"
00006 #include "RecoTracker/TkNavigation/interface/SimpleForwardNavigableLayer.h"
00007 #include "RecoTracker/TkNavigation/interface/SimpleNavigableLayer.h"
00008 #include "TrackingTools/DetLayers/src/DetBelowZ.h"
00009
00010 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00011
00012 CfgNavigationSchool::CfgNavigationSchool(const edm::ParameterSet & cfg,
00013 const GeometricSearchTracker* theInputTracker,
00014 const MagneticField* field){
00015
00016 theTracker=theInputTracker;
00017 theField=field;
00018 theAllDetLayersInSystem=&theInputTracker->allLayers();
00019
00020 std::vector<BarrelDetLayer*> blc = theTracker->barrelLayers();
00021 for ( std::vector<BarrelDetLayer*>::iterator i = blc.begin(); i != blc.end(); i++)
00022 theBarrelLayers.push_back( (*i) );
00023
00024 std::vector<ForwardDetLayer*> flc = theTracker->forwardLayers();
00025 for ( std::vector<ForwardDetLayer*>::iterator i = flc.begin(); i != flc.end(); i++)
00026 theForwardLayers.push_back( (*i) );
00027
00028 std::vector< std::string > names;
00029 cfg.getParameterSetNames(names);
00030
00031 bool inverseRelationShip = true;
00032 for (unsigned int iN=0;iN!=names.size();++iN){
00033 edm::ParameterSet pset=cfg.getParameter<edm::ParameterSet>(names[iN]);
00034 std::vector<std::string> OUT = pset.getParameter<std::vector<std::string> >("OUT");
00035
00036 if ( pset.exists("IN") ) inverseRelationShip = false;
00037
00038 BDLC reachableBL;
00039 FDLC reachableFL;
00040
00041
00042 for (unsigned int iOut=0;iOut!=OUT.size();++iOut)
00043 addLayer(OUT[iOut], reachableBL, reachableFL);
00044
00045 makeFwdLinks(names[iN],reachableBL,reachableFL);
00046 }
00047
00048
00049 NavigationSetter setter(*this);
00050
00051 if( inverseRelationShip ){
00052 establishInverseRelations();
00053 }else{
00054
00055 for (unsigned int iN=0;iN!=names.size();++iN){
00056 edm::ParameterSet pset=cfg.getParameter<edm::ParameterSet>(names[iN]);
00057 std::vector<std::string> IN = pset.getParameter<std::vector<std::string> >("IN");
00058
00059 BDLC reachableBL;
00060 FDLC reachableFL;
00061
00062
00063 for (unsigned int iIn=0;iIn!=IN.size();++iIn)
00064 addLayer(IN[iIn], reachableBL, reachableFL);
00065
00066 makeBwdLinks(names[iN],reachableBL,reachableFL);
00067 }
00068 }
00069 }
00070
00071 void CfgNavigationSchool::makeFwdLinks(std::string & lname, BDLC & reachableBL, FDLC & reachableFL){
00072 DetLayer * l = layer(lname);
00073 if (l->location() == GeomDetEnumerators::barrel){
00074
00075
00076 FDLI middle = find_if( reachableFL.begin(), reachableFL.end(),
00077 not1(DetBelowZ(0)));
00078 FDLC leftFL(reachableFL.begin(), middle);
00079 FDLC rightFL(middle, reachableFL.end());
00080
00081 BarrelDetLayer * bl = dynamic_cast<BarrelDetLayer *>(l);
00082 theBarrelNLC.push_back( new SimpleBarrelNavigableLayer(bl,
00083 reachableBL,
00084 rightFL,leftFL,
00085 theField,
00086 5.));
00087 }
00088 else{
00089 ForwardDetLayer * fwdL = dynamic_cast<ForwardDetLayer *>(l);
00090 theForwardNLC.push_back( new SimpleForwardNavigableLayer(fwdL,
00091 reachableBL,
00092 reachableFL,
00093 theField,
00094 5.));
00095 }
00096 }
00097
00098 void CfgNavigationSchool::makeBwdLinks(std::string & lname, BDLC & reachableBL, FDLC & reachableFL){
00099 DetLayer * l = layer(lname);
00100 SimpleNavigableLayer * nl = dynamic_cast<SimpleNavigableLayer*>(l->navigableLayer());
00101 if (nl) nl->setInwardLinks(reachableBL,reachableFL);
00102 else
00103 edm::LogError("CfgNavigationSchool")<<"a layer is not casting to SimpleNavigableLayer.";
00104 }
00105
00106
00107 void CfgNavigationSchool::addLayer(std::string & lname, BDLC & reachableBL, FDLC & reachableFL){
00108 DetLayer * l = layer(lname);
00109 if (l->location() == GeomDetEnumerators::barrel)
00110 reachableBL.push_back(dynamic_cast<BarrelDetLayer*>(l));
00111 else
00112 reachableFL .push_back(dynamic_cast<ForwardDetLayer*>(l));
00113 }
00114
00115
00116 DetLayer * CfgNavigationSchool::layer(std::string & lname){
00117 std::string part = lname.substr(0,3);
00118 unsigned int idLayer = atoi(lname.substr(3,1).c_str())-1;
00119 bool isFwd = (lname.find("pos")!=std::string::npos);
00120 LogDebug("CfgNavigationSchool")<<"part: "<<part<<"\n idLayer: "<<idLayer<<" is: "<<(isFwd?"isFwd":"isBwd");
00121 if (part == "TOB") return theTracker->tobLayers()[idLayer];
00122 else if (part == "TIB") return theTracker->tibLayers()[idLayer];
00123 else if (part == "TID") return (isFwd?theTracker->posTidLayers()[idLayer]:theTracker->negTidLayers()[idLayer]);
00124 else if (part == "TEC") return (isFwd?theTracker->posTecLayers()[idLayer]:theTracker->negTecLayers()[idLayer]);
00125 else if (part == "PXB") return theTracker->pixelBarrelLayers()[idLayer];
00126 else if (part == "PXF") return (isFwd?theTracker->posPixelForwardLayers()[idLayer]:theTracker->negPixelForwardLayers()[idLayer]);
00127
00128 edm::LogError("CfgNavigationSchool")<<"layer specification: "<<lname<<" not understood. returning a null pointer.";
00129 return 0;
00130
00131 }