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