CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
CfgNavigationSchool.cc
Go to the documentation of this file.
2 
9 
11 
13  const GeometricSearchTracker* theInputTracker,
14  const MagneticField* field){
15  //some genericinitialisation
16  theTracker=theInputTracker;
18  theAllDetLayersInSystem=&theInputTracker->allLayers();
19  // Get barrel layers
20  std::vector<BarrelDetLayer*> blc = theTracker->barrelLayers();
21  for ( std::vector<BarrelDetLayer*>::iterator i = blc.begin(); i != blc.end(); i++)
22  theBarrelLayers.push_back( (*i) );
23  // get forward layers
24  std::vector<ForwardDetLayer*> flc = theTracker->forwardLayers();
25  for ( std::vector<ForwardDetLayer*>::iterator i = flc.begin(); i != flc.end(); i++)
26  theForwardLayers.push_back( (*i) );
27 
28  std::vector< std::string > names;
29  cfg.getParameterSetNames(names);
30 
31  bool inverseRelationShip = true;
32  for (unsigned int iN=0;iN!=names.size();++iN){
34  std::vector<std::string> OUT = pset.getParameter<std::vector<std::string> >("OUT");
35  //will not do automatic inverse relation is any IN is specified
36  if ( pset.exists("IN") ) inverseRelationShip = false;
37 
38  BDLC reachableBL;
39  FDLC reachableFL;
40 
41  //create the OUT links
42  for (unsigned int iOut=0;iOut!=OUT.size();++iOut)
43  addLayer(OUT[iOut], reachableBL, reachableFL);
44 
45  makeFwdLinks(names[iN],reachableBL,reachableFL);
46  }
47 
48  //set the navigation to be able to access the NavigableLayer from the DetLayer itself
49  NavigationSetter setter(*this);
50 
51  if( inverseRelationShip ){
53  }else{
54  //set it by hand in the configuration
55  for (unsigned int iN=0;iN!=names.size();++iN){
57  std::vector<std::string> IN = pset.getParameter<std::vector<std::string> >("IN");
58 
59  BDLC reachableBL;
60  FDLC reachableFL;
61 
62  //create the IN links
63  for (unsigned int iIn=0;iIn!=IN.size();++iIn)
64  addLayer(IN[iIn], reachableBL, reachableFL);
65 
66  makeBwdLinks(names[iN],reachableBL,reachableFL);
67  }
68  }
69 }
70 
71 void CfgNavigationSchool::makeFwdLinks(std::string & lname, BDLC & reachableBL, FDLC & reachableFL){
72  DetLayer * l = layer(lname);
74  //split the FL into left and right.
75 
76  FDLI middle = find_if( reachableFL.begin(), reachableFL.end(),
77  not1(DetBelowZ(0)));
78  FDLC leftFL(reachableFL.begin(), middle);
79  FDLC rightFL(middle, reachableFL.end());
80 
81  BarrelDetLayer * bl = dynamic_cast<BarrelDetLayer *>(l);
82  theBarrelNLC.push_back( new SimpleBarrelNavigableLayer(bl,
83  reachableBL,
84  rightFL,leftFL,
85  theField,
86  5.));
87  }
88  else{
89  ForwardDetLayer * fwdL = dynamic_cast<ForwardDetLayer *>(l);
90  theForwardNLC.push_back( new SimpleForwardNavigableLayer(fwdL,
91  reachableBL,
92  reachableFL,
93  theField,
94  5.));
95  }
96 }
97 
98 void CfgNavigationSchool::makeBwdLinks(std::string & lname, BDLC & reachableBL, FDLC & reachableFL){
99  DetLayer * l = layer(lname);
100  SimpleNavigableLayer * nl = dynamic_cast<SimpleNavigableLayer*>(l->navigableLayer());
101  if (nl) nl->setInwardLinks(reachableBL,reachableFL);
102  else
103  edm::LogError("CfgNavigationSchool")<<"a layer is not casting to SimpleNavigableLayer.";
104 }
105 
106 
107 void CfgNavigationSchool::addLayer(std::string & lname, BDLC & reachableBL, FDLC & reachableFL){
108  DetLayer * l = layer(lname);
110  reachableBL.push_back(dynamic_cast<BarrelDetLayer*>(l));
111  else
112  reachableFL .push_back(dynamic_cast<ForwardDetLayer*>(l));
113 }
114 
115 
117  std::string part = lname.substr(0,3);
118  unsigned int idLayer = atoi(lname.substr(3,1).c_str())-1;
119  bool isFwd = (lname.find("pos")!=std::string::npos);
120  LogDebug("CfgNavigationSchool")<<"part: "<<part<<"\n idLayer: "<<idLayer<<" is: "<<(isFwd?"isFwd":"isBwd");
121  if (part == "TOB") return theTracker->tobLayers()[idLayer];
122  else if (part == "TIB") return theTracker->tibLayers()[idLayer];
123  else if (part == "TID") return (isFwd?theTracker->posTidLayers()[idLayer]:theTracker->negTidLayers()[idLayer]);
124  else if (part == "TEC") return (isFwd?theTracker->posTecLayers()[idLayer]:theTracker->negTecLayers()[idLayer]);
125  else if (part == "PXB") return theTracker->pixelBarrelLayers()[idLayer];
126  else if (part == "PXF") return (isFwd?theTracker->posPixelForwardLayers()[idLayer]:theTracker->negPixelForwardLayers()[idLayer]);
127 
128  edm::LogError("CfgNavigationSchool")<<"layer specification: "<<lname<<" not understood. returning a null pointer.";
129  return 0;//and crash
130 
131 }
#define LogDebug(id)
T getParameter(std::string const &) const
int i
Definition: DBlmapReader.cc:9
NavigableLayer * navigableLayer() const
Return the NavigableLayer associated with this DetLayer.
Definition: DetLayer.h:51
static const HistoName names[]
virtual Location location() const =0
Which part of the detector (barrel, endcap)
bool exists(std::string const &parameterName) const
checks if a parameter exists
std::vector< ForwardDetLayer * > const & posTecLayers() const
const GeometricSearchTracker * theTracker
virtual void setInwardLinks(const BDLC &, const FDLC &, TkLayerLess sorter=TkLayerLess(outsideIn))=0
void makeBwdLinks(std::string &lname, BDLC &reachableBL, FDLC &reachableFL)
tuple field
Definition: statics.py:62
std::vector< BarrelDetLayer * > const & barrelLayers() const
std::vector< ForwardDetLayer * > const & negTecLayers() const
std::vector< ForwardDetLayer * > FDLC
std::vector< ForwardDetLayer * > const & posPixelForwardLayers() const
virtual void establishInverseRelations()
std::vector< DetLayer * > const & allLayers() const
const MagneticField * theField
void addLayer(std::string &lname, BDLC &reachableBL, FDLC &reachableFL)
part
Definition: HCALResponse.h:20
DetLayer * layer(std::string &lname)
std::vector< BarrelDetLayer * > const & tibLayers() const
std::vector< ForwardDetLayer * > const & posTidLayers() const
void makeFwdLinks(std::string &lname, BDLC &reachableBL, FDLC &reachableFL)
std::vector< ForwardDetLayer * > const & negTidLayers() const
std::vector< BarrelDetLayer * > BDLC
const std::vector< DetLayer * > * theAllDetLayersInSystem
size_t getParameterSetNames(std::vector< std::string > &output, bool trackiness=true) const
std::vector< ForwardDetLayer * > const & forwardLayers() const
std::vector< BarrelDetLayer * > const & tobLayers() const
std::vector< BarrelDetLayer * > const & pixelBarrelLayers() const
std::vector< ForwardDetLayer * > const & negPixelForwardLayers() const