CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
CosmicNavigationSchool.cc
Go to the documentation of this file.
4 
10 
16 
18 
19 #include <functional>
20 #include <algorithm>
21 #include <map>
22 #include <cmath>
23 
24 using namespace std;
25 
27  noPXB=conf.getParameter<bool>("noPXB");
28  noPXF=conf.getParameter<bool>("noPXF");
29  noTIB=conf.getParameter<bool>("noTIB");
30  noTID=conf.getParameter<bool>("noTID");
31  noTOB=conf.getParameter<bool>("noTOB");
32  noTEC=conf.getParameter<bool>("noTEC");
33  self = conf.getParameter<bool>("selfSearch");
34  allSelf = conf.getParameter<bool>("allSelf");
35 }
36 
38  const MagneticField* field)
39 {
40  build(theInputTracker, field, CosmicNavigationSchoolConfiguration());
41 }
42 
44  const MagneticField* field,
46 {
47  LogTrace("CosmicNavigationSchool") << "*********Running CosmicNavigationSchool***********" ;
48  theBarrelLength = 0;theField = field; theTracker = theInputTracker;
49 
50  theAllDetLayersInSystem=&theInputTracker->allLayers();
51 
52  // Get barrel layers
53  vector<BarrelDetLayer*> blc = theTracker->barrelLayers();
54  for ( vector<BarrelDetLayer*>::iterator i = blc.begin(); i != blc.end(); i++) {
55  if (conf.noPXB && (*i)->subDetector() == GeomDetEnumerators::PixelBarrel) continue;
56  if (conf.noTOB && (*i)->subDetector() == GeomDetEnumerators::TOB) continue;
57  if (conf.noTIB && (*i)->subDetector() == GeomDetEnumerators::TIB) continue;
58  theBarrelLayers.push_back( (*i) );
59  }
60 
61  // get forward layers
62  vector<ForwardDetLayer*> flc = theTracker->forwardLayers();
63  for ( vector<ForwardDetLayer*>::iterator i = flc.begin(); i != flc.end(); i++) {
64  if (conf.noPXF && (*i)->subDetector() == GeomDetEnumerators::PixelEndcap) continue;
65  if (conf.noTEC && (*i)->subDetector() == GeomDetEnumerators::TEC) continue;
66  if (conf.noTID && (*i)->subDetector() == GeomDetEnumerators::TID) continue;
67  theForwardLayers.push_back( (*i) );
68  }
69 
70  FDLI middle = find_if( theForwardLayers.begin(), theForwardLayers.end(),
71  not1(DetBelowZ(0)));
72  theLeftLayers = FDLC( theForwardLayers.begin(), middle);
73  theRightLayers = FDLC( middle, theForwardLayers.end());
74 
75  SymmetricLayerFinder symFinder( theForwardLayers);
76 
77  // only work on positive Z side; negative by mirror symmetry later
78  linkBarrelLayers( symFinder);
79  linkForwardLayers( symFinder);
80  establishInverseRelations( symFinder );
81 
82  if (conf.self){
83 
84  // set the self search by hand
85  NavigationSetter setter(*this);
86 
87  //add TOB1->TOB1 inward link
88  const std::vector< BarrelDetLayer * > & tobL = theInputTracker->tobLayers();
89  if (tobL.size()>=1){
90  if (conf.allSelf){
91  LogDebug("CosmicNavigationSchool")<<" adding all TOB self search.";
92  for (std::vector< BarrelDetLayer * >::const_iterator lIt = tobL.begin(); lIt!=tobL.end(); ++lIt)
93  dynamic_cast<SimpleNavigableLayer*>((*lIt)->navigableLayer())->theSelfSearch = true;
94  }else{
95  SimpleNavigableLayer* navigableLayer = dynamic_cast<SimpleNavigableLayer*>(tobL.front()->navigableLayer());
96  LogDebug("CosmicNavigationSchool")<<" adding TOB1 to TOB1.";
97  navigableLayer->theSelfSearch = true;
98  }
99  }
100  const std::vector< BarrelDetLayer * > & tibL = theInputTracker->tibLayers();
101  if (tibL.size()>=1){
102  if (conf.allSelf){
103  LogDebug("CosmicNavigationSchool")<<" adding all TIB self search.";
104  for (std::vector< BarrelDetLayer * >::const_iterator lIt = tibL.begin(); lIt!=tibL.end(); ++lIt)
105  dynamic_cast<SimpleNavigableLayer*>((*lIt)->navigableLayer())->theSelfSearch = true;
106  }else{
107  SimpleNavigableLayer* navigableLayer = dynamic_cast<SimpleNavigableLayer*>(tibL.front()->navigableLayer());
108  LogDebug("CosmicNavigationSchool")<<" adding tib1 to tib1.";
109  navigableLayer->theSelfSearch = true;
110  }
111  }
112  const std::vector< BarrelDetLayer * > & pxbL = theInputTracker->pixelBarrelLayers();
113  if (pxbL.size()>=1){
114  if (conf.allSelf){
115  LogDebug("CosmicNavigationSchool")<<" adding all PXB self search.";
116  for (std::vector< BarrelDetLayer * >::const_iterator lIt = pxbL.begin(); lIt!=pxbL.end(); ++lIt)
117  dynamic_cast<SimpleNavigableLayer*>((*lIt)->navigableLayer())->theSelfSearch = true;
118  }else{
119  SimpleNavigableLayer* navigableLayer = dynamic_cast<SimpleNavigableLayer*>(pxbL.front()->navigableLayer());
120  LogDebug("CosmicNavigationSchool")<<" adding pxb1 to pxb1.";
121  navigableLayer->theSelfSearch = true;
122  }
123  }
124  }
125 }
126 
129 {
130  //identical to the SimpleNavigationSchool one, but it allows crossing over the tracker
131  //is some non-standard link is needed, it should probably be added here
132 
133  // Link barrel layers outwards
134  for ( BDLI i = theBarrelLayers.begin(); i != theBarrelLayers.end(); i++) {
135  BDLC reachableBL;
136  FDLC leftFL;
137  FDLC rightFL;
138 
139  // always add next barrel layer first
140  if ( i+1 != theBarrelLayers.end()) reachableBL.push_back(*(i+1));
141 
142  // Add closest reachable forward layer (except for last BarrelLayer)
143  if (i != theBarrelLayers.end() - 1) {
144  linkNextForwardLayer( *i, rightFL);
145  }
146 
147  // Add next BarrelLayer with length larger than the current BL
148  if ( i+2 < theBarrelLayers.end()) {
149  linkNextLargerLayer( i, theBarrelLayers.end(), reachableBL);
150  }
151 
152  theBarrelNLC.push_back( new
153  SimpleBarrelNavigableLayer( *i, reachableBL,
154  symFinder.mirror(rightFL),
155  rightFL,theField, 5.,false));
156  }
157 }
158 
159 
161 
162  //again: standard part is identical to SimpleNavigationSchool one.
163  //After the standard link, special outsideIn links are added
164 
165  NavigationSetter setter(*this);
166 
167  // find for each layer which are the barrel and forward
168  // layers that point to it
169  typedef map<const DetLayer*, vector<BarrelDetLayer*>, less<const DetLayer*> > BarrelMapType;
170  typedef map<const DetLayer*, vector<ForwardDetLayer*>, less<const DetLayer*> > ForwardMapType;
171 
172 
173  BarrelMapType reachedBarrelLayersMap;
174  ForwardMapType reachedForwardLayersMap;
175 
176 
177  for ( BDLI bli = theBarrelLayers.begin();
178  bli!=theBarrelLayers.end(); bli++) {
179  DLC reachedLC = (**bli).nextLayers( insideOut);
180  for ( DLI i = reachedLC.begin(); i != reachedLC.end(); i++) {
181  reachedBarrelLayersMap[*i].push_back( *bli);
182  }
183  }
184 
185  for ( FDLI fli = theForwardLayers.begin();
186  fli!=theForwardLayers.end(); fli++) {
187  DLC reachedLC = (**fli).nextLayers( insideOut);
188  for ( DLI i = reachedLC.begin(); i != reachedLC.end(); i++) {
189  reachedForwardLayersMap[*i].push_back( *fli);
190  }
191  }
192 
193 
194  vector<DetLayer*> lc = theTracker->allLayers();
195  for ( vector<DetLayer*>::iterator i = lc.begin(); i != lc.end(); i++) {
196  SimpleNavigableLayer* navigableLayer = dynamic_cast<SimpleNavigableLayer*>((**i).navigableLayer());
197  if (navigableLayer)
198  navigableLayer->setInwardLinks( reachedBarrelLayersMap[*i],reachedForwardLayersMap[*i] );
199  }
200  //buildAdditionalBarrelLinks();
201  buildAdditionalForwardLinks(symFinder);
202 
203 }
204 
205 
207  for ( vector<BarrelDetLayer*>::iterator i = theBarrelLayers.begin(); i != theBarrelLayers.end(); i++) {
208  SimpleNavigableLayer* navigableLayer =
209  dynamic_cast<SimpleNavigableLayer*>((**i).navigableLayer());
210  if (i+1 != theBarrelLayers.end() )navigableLayer->setAdditionalLink(*(i+1), outsideIn);
211  }
212 }
213 
214 
216  //the first layer of FPIX should not check the crossing side (since there are no inner layers to be tryed first)
217  SimpleNavigableLayer* firstR = dynamic_cast<SimpleNavigableLayer*>(theRightLayers.front()->navigableLayer());
218  SimpleNavigableLayer* firstL = dynamic_cast<SimpleNavigableLayer*>(theLeftLayers.front()->navigableLayer());
219  firstR->setCheckCrossingSide(false);
220  firstL->setCheckCrossingSide(false);
221 
222  for ( vector<ForwardDetLayer*>::iterator i = theRightLayers.begin(); i != theRightLayers.end(); i++){
223  //look for first bigger barrel layer and link to it outsideIn
224  SimpleForwardNavigableLayer* nfl = dynamic_cast<SimpleForwardNavigableLayer*>((*i)->navigableLayer());
225  SimpleForwardNavigableLayer* mnfl = dynamic_cast<SimpleForwardNavigableLayer*>(symFinder.mirror(*i)->navigableLayer());
226  for (vector<BarrelDetLayer*>::iterator j = theBarrelLayers.begin(); j != theBarrelLayers.end(); j++){
227  if ((*i)->specificSurface().outerRadius() < (*j)->specificSurface().radius() &&
228  fabs((*i)->specificSurface().position().z()) < (*j)->surface().bounds().length()/2.){
229  nfl ->setAdditionalLink(*j, outsideIn);
230  mnfl->setAdditionalLink(*j, outsideIn);
231  break;
232  }
233  }
234  }
235 }
236 
#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:45
void linkBarrelLayers(SymmetricLayerFinder &symFinder)
virtual void setAdditionalLink(DetLayer *, NavigationDirection direction=insideOut)
virtual void setInwardLinks(const BDLC &, const FDLC &, TkLayerLess sorter=TkLayerLess(outsideIn))=0
std::vector< ForwardDetLayer * > FDLC
std::vector< const DetLayer * > DLC
int j
Definition: DBlmapReader.cc:9
#define LogTrace(id)
virtual void establishInverseRelations()
tuple conf
Definition: dbtoconf.py:185
std::vector< DetLayer * > const & allLayers() const
virtual void setAdditionalLink(DetLayer *, NavigationDirection direction=insideOut)=0
void build(const GeometricSearchTracker *theTracker, const MagneticField *field, const CosmicNavigationSchoolConfiguration conf)
void setCheckCrossingSide(bool docheck)
std::vector< BarrelDetLayer * > const & tibLayers() const
std::vector< BarrelDetLayer * > BDLC
void buildAdditionalForwardLinks(SymmetricLayerFinder &symFinder)
std::vector< BarrelDetLayer * > const & tobLayers() const
std::vector< BarrelDetLayer * > const & pixelBarrelLayers() const
ForwardDetLayer * mirror(const ForwardDetLayer *layer)