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 
15 // #include "TrackingTools/DetLayers/interface/NavigationSetter.h"
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  theAllNavigableLayer.resize(theInputTracker->allLayers().size(),nullptr);
50 
51 
52 
53 
54  // Get barrel layers
55  vector<BarrelDetLayer const*> const& blc = theTracker->barrelLayers();
56  for ( auto i = blc.begin(); i != blc.end(); i++) {
57  if (conf.noPXB && (*i)->subDetector() == GeomDetEnumerators::PixelBarrel) continue;
58  if (conf.noTOB && (*i)->subDetector() == GeomDetEnumerators::TOB) continue;
59  if (conf.noTIB && (*i)->subDetector() == GeomDetEnumerators::TIB) continue;
60  theBarrelLayers.push_back( (*i) );
61  }
62 
63  // get forward layers
64  vector<ForwardDetLayer const*> const& flc = theTracker->forwardLayers();
65  for ( auto i = flc.begin(); i != flc.end(); i++) {
66  if (conf.noPXF && (*i)->subDetector() == GeomDetEnumerators::PixelEndcap) continue;
67  if (conf.noTEC && (*i)->subDetector() == GeomDetEnumerators::TEC) continue;
68  if (conf.noTID && (*i)->subDetector() == GeomDetEnumerators::TID) continue;
69  theForwardLayers.push_back( (*i) );
70  }
71 
72  FDLI middle = find_if( theForwardLayers.begin(), theForwardLayers.end(),
73  not1(DetBelowZ(0)));
74  theLeftLayers = FDLC( theForwardLayers.begin(), middle);
75  theRightLayers = FDLC( middle, theForwardLayers.end());
76 
77  SymmetricLayerFinder symFinder( theForwardLayers);
78 
79  // only work on positive Z side; negative by mirror symmetry later
80  linkBarrelLayers( symFinder);
81  linkForwardLayers( symFinder);
82  establishInverseRelations( symFinder );
83 
84  if (conf.self){
85 
86  // set the self search by hand
87  // NavigationSetter setter(*this);
88 
89  //add TOB1->TOB1 inward link
90  const std::vector< const BarrelDetLayer * > & tobL = theInputTracker->tobLayers();
91  if (tobL.size()>=1){
92  if (conf.allSelf){
93  LogDebug("CosmicNavigationSchool")<<" adding all TOB self search.";
94  for (auto lIt = tobL.begin(); lIt!=tobL.end(); ++lIt)
95  dynamic_cast<SimpleNavigableLayer*>(theAllNavigableLayer[(*lIt)->seqNum()])->theSelfSearch = true;
96  }else{
97  SimpleNavigableLayer* navigableLayer =
98  dynamic_cast<SimpleNavigableLayer*>(theAllNavigableLayer[tobL.front()->seqNum()]);
99  LogDebug("CosmicNavigationSchool")<<" adding TOB1 to TOB1.";
100  navigableLayer->theSelfSearch = true;
101  }
102  }
103  const std::vector< const BarrelDetLayer * > & tibL = theInputTracker->tibLayers();
104  if (tibL.size()>=1){
105  if (conf.allSelf){
106  LogDebug("CosmicNavigationSchool")<<" adding all TIB self search.";
107  for (auto lIt = tibL.begin(); lIt!=tibL.end(); ++lIt)
108  dynamic_cast<SimpleNavigableLayer*>(theAllNavigableLayer[(*lIt)->seqNum()])->theSelfSearch = true;
109  }else{
110  SimpleNavigableLayer* navigableLayer =
111  dynamic_cast<SimpleNavigableLayer*>(theAllNavigableLayer[tibL.front()->seqNum()]);
112  LogDebug("CosmicNavigationSchool")<<" adding tib1 to tib1.";
113  navigableLayer->theSelfSearch = true;
114  }
115  }
116  const std::vector< const BarrelDetLayer * > & pxbL = theInputTracker->pixelBarrelLayers();
117  if (pxbL.size()>=1){
118  if (conf.allSelf){
119  LogDebug("CosmicNavigationSchool")<<" adding all PXB self search.";
120  for (auto lIt = pxbL.begin(); lIt!=pxbL.end(); ++lIt)
121  dynamic_cast<SimpleNavigableLayer*>(theAllNavigableLayer[(*lIt)->seqNum()])->theSelfSearch = true;
122  }else{
123  SimpleNavigableLayer* navigableLayer =
124  dynamic_cast<SimpleNavigableLayer*>(theAllNavigableLayer[pxbL.front()->seqNum()]);
125  LogDebug("CosmicNavigationSchool")<<" adding pxb1 to pxb1.";
126  navigableLayer->theSelfSearch = true;
127  }
128  }
129  }
130 }
131 
134 {
135  //identical to the SimpleNavigationSchool one, but it allows crossing over the tracker
136  //is some non-standard link is needed, it should probably be added here
137 
138  // Link barrel layers outwards
139  for ( BDLI i = theBarrelLayers.begin(); i != theBarrelLayers.end(); i++) {
140  BDLC reachableBL;
141  FDLC leftFL;
142  FDLC rightFL;
143 
144  // always add next barrel layer first
145  if ( i+1 != theBarrelLayers.end()) reachableBL.push_back(*(i+1));
146 
147  // Add closest reachable forward layer (except for last BarrelLayer)
148  if (i != theBarrelLayers.end() - 1) {
149  linkNextForwardLayer( *i, rightFL);
150  }
151 
152  // Add next BarrelLayer with length larger than the current BL
153  if ( i+2 < theBarrelLayers.end()) {
154  linkNextLargerLayer( i, theBarrelLayers.end(), reachableBL);
155  }
156 
157  theBarrelNLC.push_back( new
158  SimpleBarrelNavigableLayer( *i, reachableBL,
159  symFinder.mirror(rightFL),
160  rightFL,theField, 5.,false));
161  }
162 }
163 
164 
165 // identical to SimpleNavigationSchool but for the last additional stuff
167 
168  //again: standard part is identical to SimpleNavigationSchool one.
169  //After the standard link, special outsideIn links are added
170 
171  // NavigationSetter setter(*this);
172 
173  setState(navigableLayers());
174 
175 
176  // find for each layer which are the barrel and forward
177  // layers that point to it
178  typedef map<const DetLayer*, vector<const BarrelDetLayer*>, less<const DetLayer*> > BarrelMapType;
179  typedef map<const DetLayer*, vector<const ForwardDetLayer*>, less<const DetLayer*> > ForwardMapType;
180 
181 
182  BarrelMapType reachedBarrelLayersMap;
183  ForwardMapType reachedForwardLayersMap;
184 
185  for ( auto bli : theBarrelLayers) {
186  auto reachedLC = nextLayers(*bli, insideOut);
187  for ( auto i : reachedLC) {
188  reachedBarrelLayersMap[i].push_back(bli);
189  }
190  }
191 
192  for ( auto fli : theForwardLayers) {
193  auto reachedLC = nextLayers(*fli, insideOut);
194  for ( auto i : reachedLC) {
195  reachedForwardLayersMap[i].push_back(fli);
196  }
197  }
198 
199  for(auto nl : theAllNavigableLayer) {
200  if (!nl) continue;
201  auto navigableLayer = static_cast<SimpleNavigableLayer*>(nl);
202  auto dl = nl->detLayer();
203  navigableLayer->setInwardLinks( reachedBarrelLayersMap[dl],reachedForwardLayersMap[dl] );
204  }
205 
206  //buildAdditionalBarrelLinks();
207  buildAdditionalForwardLinks(symFinder);
208 
209 }
210 
211 
213  for (auto i = theBarrelLayers.begin(); i != theBarrelLayers.end(); i++) {
214  SimpleNavigableLayer* navigableLayer =
215  dynamic_cast<SimpleNavigableLayer*>(theAllNavigableLayer[(*i)->seqNum()]);
216  if (i+1 != theBarrelLayers.end() )navigableLayer->setAdditionalLink(*(i+1), outsideIn);
217  }
218 }
219 
220 
222  //the first layer of FPIX should not check the crossing side (since there are no inner layers to be tryed first)
223  SimpleNavigableLayer* firstR =
224  dynamic_cast<SimpleNavigableLayer*>(theAllNavigableLayer[theRightLayers.front()->seqNum()]);
225  SimpleNavigableLayer* firstL =
226  dynamic_cast<SimpleNavigableLayer*>(theAllNavigableLayer[theLeftLayers.front()->seqNum()]);
227  firstR->setCheckCrossingSide(false);
228  firstL->setCheckCrossingSide(false);
229 
230  for (auto i : theRightLayers){
231  //look for first bigger barrel layer and link to it outsideIn
233  dynamic_cast<SimpleForwardNavigableLayer*>(theAllNavigableLayer[(i)->seqNum()]);
235  dynamic_cast<SimpleForwardNavigableLayer*>(theAllNavigableLayer[symFinder.mirror(i)->seqNum()]);
236  for (auto j : theBarrelLayers) {
237  if ((i)->specificSurface().outerRadius() < (j)->specificSurface().radius() &&
238  fabs((i)->specificSurface().position().z()) < (j)->surface().bounds().length()/2.){
239  nfl ->setAdditionalLink(j, outsideIn);
240  mnfl->setAdditionalLink(j, outsideIn);
241  break;
242  }
243  }
244  }
245 }
246 
#define LogDebug(id)
T getParameter(std::string const &) const
int i
Definition: DBlmapReader.cc:9
void linkBarrelLayers(SymmetricLayerFinder &symFinder)
std::vector< DetLayer const * > const & allLayers() const
std::vector< const BarrelDetLayer * > BDLC
virtual DetLayer const * detLayer() const =0
std::vector< BarrelDetLayer const * > const & tobLayers() const
float float float z
const ForwardDetLayer * mirror(const ForwardDetLayer *layer)
int seqNum() const
Definition: DetLayer.h:36
int j
Definition: DBlmapReader.cc:9
std::vector< BarrelDetLayer const * > const & pixelBarrelLayers() const
#define LogTrace(id)
virtual void establishInverseRelations()
tuple conf
Definition: dbtoconf.py:185
std::vector< const ForwardDetLayer * > FDLC
std::vector< BarrelDetLayer const * > const & tibLayers() const
void build(const GeometricSearchTracker *theTracker, const MagneticField *field, const CosmicNavigationSchoolConfiguration conf)
virtual void setAdditionalLink(const DetLayer *, NavigationDirection direction=insideOut)=0
void setCheckCrossingSide(bool docheck)
static int position[264][3]
Definition: ReadPGInfo.cc:509
virtual void setAdditionalLink(const DetLayer *, NavigationDirection direction=insideOut) override
void buildAdditionalForwardLinks(SymmetricLayerFinder &symFinder)