CMS 3D CMS Logo

CosmicNavigationSchool.cc
Go to the documentation of this file.
2 
4 
6 
7 #include <vector>
8 
9 //class FakeDetLayer;
10 
11 
16 public:
18  const MagneticField* field);
20 
22  public:
25  bool noPXB;
26  bool noPXF;
27  bool noTOB;
28  bool noTIB;
29  bool noTEC;
30  bool noTID;
31 
32  bool self;
33  bool allSelf;
34  };
35 
36  void build(const GeometricSearchTracker* theTracker,
37  const MagneticField* field,
39 
40 protected:
42 private:
43 
44  //FakeDetLayer* theFakeDetLayer;
45  void linkBarrelLayers( SymmetricLayerFinder& symFinder) override;
46  //void linkForwardLayers( SymmetricLayerFinder& symFinder);
48  void establishInverseRelations( SymmetricLayerFinder& symFinder );
49  void buildAdditionalBarrelLinks();
50  void buildAdditionalForwardLinks(SymmetricLayerFinder& symFinder);
51 };
52 
53 
55 
58 #include "SimpleNavigableLayer.h"
59 #include "SymmetricLayerFinder.h"
60 
65 
66 #include <functional>
67 #include <algorithm>
68 #include <map>
69 #include <cmath>
70 
71 using namespace std;
72 
74  noPXB=conf.getParameter<bool>("noPXB");
75  noPXF=conf.getParameter<bool>("noPXF");
76  noTIB=conf.getParameter<bool>("noTIB");
77  noTID=conf.getParameter<bool>("noTID");
78  noTOB=conf.getParameter<bool>("noTOB");
79  noTEC=conf.getParameter<bool>("noTEC");
80  self = conf.getParameter<bool>("selfSearch");
81  allSelf = conf.getParameter<bool>("allSelf");
82 }
83 
85  const MagneticField* field)
86 {
87  build(theInputTracker, field, CosmicNavigationSchoolConfiguration());
88 }
89 
91  const MagneticField* field,
93 {
94  LogTrace("CosmicNavigationSchool") << "*********Running CosmicNavigationSchool***********" ;
95  theBarrelLength = 0;theField = field; theTracker = theInputTracker;
96 
97  theAllDetLayersInSystem=&theInputTracker->allLayers();
98  theAllNavigableLayer.resize(theInputTracker->allLayers().size(),nullptr);
99 
100 
101 
102 
103  // Get barrel layers
104  vector<BarrelDetLayer const*> const& blc = theTracker->barrelLayers();
105  for ( auto i = blc.begin(); i != blc.end(); i++) {
106  if (conf.noPXB && GeomDetEnumerators::isTrackerPixel((*i)->subDetector())) continue;
107  if (conf.noTOB && (*i)->subDetector() == GeomDetEnumerators::TOB) continue;
108  if (conf.noTIB && (*i)->subDetector() == GeomDetEnumerators::TIB) continue;
109  theBarrelLayers.push_back( (*i) );
110  }
111 
112  // get forward layers
113  vector<ForwardDetLayer const*> const& flc = theTracker->forwardLayers();
114  for ( auto i = flc.begin(); i != flc.end(); i++) {
115  if (conf.noPXF && GeomDetEnumerators::isTrackerPixel((*i)->subDetector())) continue;
116  if (conf.noTEC && (*i)->subDetector() == GeomDetEnumerators::TEC) continue;
117  if (conf.noTID && (*i)->subDetector() == GeomDetEnumerators::TID) continue;
118  theForwardLayers.push_back( (*i) );
119  }
120 
121  FDLI middle = find_if( theForwardLayers.begin(), theForwardLayers.end(),
122  not1(DetBelowZ(0)));
123  theLeftLayers = FDLC( theForwardLayers.begin(), middle);
124  theRightLayers = FDLC( middle, theForwardLayers.end());
125 
126  SymmetricLayerFinder symFinder( theForwardLayers);
127 
128  // only work on positive Z side; negative by mirror symmetry later
129  linkBarrelLayers( symFinder);
130  linkForwardLayers( symFinder);
131  establishInverseRelations( symFinder );
132 
133  if (conf.self){
134 
135  // set the self search by hand
136  // NavigationSetter setter(*this);
137 
138  //add TOB1->TOB1 inward link
139  const std::vector< const BarrelDetLayer * > & tobL = theInputTracker->tobLayers();
140  if (!tobL.empty()){
141  if (conf.allSelf){
142  LogDebug("CosmicNavigationSchool")<<" adding all TOB self search.";
143  for (auto lIt = tobL.begin(); lIt!=tobL.end(); ++lIt)
144  dynamic_cast<SimpleNavigableLayer*>(theAllNavigableLayer[(*lIt)->seqNum()])->theSelfSearch = true;
145  }else{
146  SimpleNavigableLayer* navigableLayer =
147  dynamic_cast<SimpleNavigableLayer*>(theAllNavigableLayer[tobL.front()->seqNum()]);
148  LogDebug("CosmicNavigationSchool")<<" adding TOB1 to TOB1.";
149  navigableLayer->theSelfSearch = true;
150  }
151  }
152  const std::vector< const BarrelDetLayer * > & tibL = theInputTracker->tibLayers();
153  if (!tibL.empty()){
154  if (conf.allSelf){
155  LogDebug("CosmicNavigationSchool")<<" adding all TIB self search.";
156  for (auto lIt = tibL.begin(); lIt!=tibL.end(); ++lIt)
157  dynamic_cast<SimpleNavigableLayer*>(theAllNavigableLayer[(*lIt)->seqNum()])->theSelfSearch = true;
158  }else{
159  SimpleNavigableLayer* navigableLayer =
160  dynamic_cast<SimpleNavigableLayer*>(theAllNavigableLayer[tibL.front()->seqNum()]);
161  LogDebug("CosmicNavigationSchool")<<" adding tib1 to tib1.";
162  navigableLayer->theSelfSearch = true;
163  }
164  }
165  const std::vector< const BarrelDetLayer * > & pxbL = theInputTracker->pixelBarrelLayers();
166  if (!pxbL.empty()){
167  if (conf.allSelf){
168  LogDebug("CosmicNavigationSchool")<<" adding all PXB self search.";
169  for (auto lIt = pxbL.begin(); lIt!=pxbL.end(); ++lIt)
170  dynamic_cast<SimpleNavigableLayer*>(theAllNavigableLayer[(*lIt)->seqNum()])->theSelfSearch = true;
171  }else{
172  SimpleNavigableLayer* navigableLayer =
173  dynamic_cast<SimpleNavigableLayer*>(theAllNavigableLayer[pxbL.front()->seqNum()]);
174  LogDebug("CosmicNavigationSchool")<<" adding pxb1 to pxb1.";
175  navigableLayer->theSelfSearch = true;
176  }
177  }
178  }
179 }
180 
183 {
184  //identical to the SimpleNavigationSchool one, but it allows crossing over the tracker
185  //is some non-standard link is needed, it should probably be added here
186 
187  // Link barrel layers outwards
188  for ( BDLI i = theBarrelLayers.begin(); i != theBarrelLayers.end(); i++) {
189  BDLC reachableBL;
190  FDLC leftFL;
191  FDLC rightFL;
192 
193  // always add next barrel layer first
194  if ( i+1 != theBarrelLayers.end()) reachableBL.push_back(*(i+1));
195 
196  // Add closest reachable forward layer (except for last BarrelLayer)
197  if (i != theBarrelLayers.end() - 1) {
198  linkNextForwardLayer( *i, rightFL);
199  }
200 
201  // Add next BarrelLayer with length larger than the current BL
202  if ( i+2 < theBarrelLayers.end()) {
203  linkNextLargerLayer( i, theBarrelLayers.end(), reachableBL);
204  }
205 
206  theBarrelNLC.push_back( new
207  SimpleBarrelNavigableLayer( *i, reachableBL,
208  symFinder.mirror(rightFL),
209  rightFL,theField, 5.,false));
210  }
211 }
212 
213 // identical to SimpleNavigationSchool but for the last additional stuff
215 
216  //again: standard part is identical to SimpleNavigationSchool one.
217  //After the standard link, special outsideIn links are added
218 
219  // NavigationSetter setter(*this);
220 
221  setState(navigableLayers());
222 
223 
224  // find for each layer which are the barrel and forward
225  // layers that point to it
226  typedef map<const DetLayer*, vector<const BarrelDetLayer*>, less<const DetLayer*> > BarrelMapType;
227  typedef map<const DetLayer*, vector<const ForwardDetLayer*>, less<const DetLayer*> > ForwardMapType;
228 
229 
230  BarrelMapType reachedBarrelLayersMap;
231  ForwardMapType reachedForwardLayersMap;
232 
233  for ( auto bli : theBarrelLayers) {
234  auto reachedLC = nextLayers(*bli, insideOut);
235  for ( auto i : reachedLC) {
236  reachedBarrelLayersMap[i].push_back(bli);
237  }
238  }
239 
240  for ( auto fli : theForwardLayers) {
241  auto reachedLC = nextLayers(*fli, insideOut);
242  for ( auto i : reachedLC) {
243  reachedForwardLayersMap[i].push_back(fli);
244  }
245  }
246 
247  for(auto nl : theAllNavigableLayer) {
248  if (!nl) continue;
249  auto navigableLayer = static_cast<SimpleNavigableLayer*>(nl);
250  auto dl = nl->detLayer();
251  navigableLayer->setInwardLinks( reachedBarrelLayersMap[dl],reachedForwardLayersMap[dl] );
252  }
253 
254  //buildAdditionalBarrelLinks();
255  buildAdditionalForwardLinks(symFinder);
256 
257 }
258 
259 
261  for (auto i = theBarrelLayers.begin(); i != theBarrelLayers.end(); i++) {
262  SimpleNavigableLayer* navigableLayer =
263  dynamic_cast<SimpleNavigableLayer*>(theAllNavigableLayer[(*i)->seqNum()]);
264  if (i+1 != theBarrelLayers.end() )navigableLayer->setAdditionalLink(*(i+1), outsideIn);
265  }
266 }
267 
268 
270  //the first layer of FPIX should not check the crossing side (since there are no inner layers to be tryed first)
271  SimpleNavigableLayer* firstR =
272  dynamic_cast<SimpleNavigableLayer*>(theAllNavigableLayer[theRightLayers.front()->seqNum()]);
273  SimpleNavigableLayer* firstL =
274  dynamic_cast<SimpleNavigableLayer*>(theAllNavigableLayer[theLeftLayers.front()->seqNum()]);
275  firstR->setCheckCrossingSide(false);
276  firstL->setCheckCrossingSide(false);
277 
278  for (auto i : theRightLayers){
279  //look for first bigger barrel layer and link to it outsideIn
281  dynamic_cast<SimpleForwardNavigableLayer*>(theAllNavigableLayer[(i)->seqNum()]);
283  dynamic_cast<SimpleForwardNavigableLayer*>(theAllNavigableLayer[symFinder.mirror(i)->seqNum()]);
284  for (auto j : theBarrelLayers) {
285  if ((i)->specificSurface().outerRadius() < (j)->specificSurface().radius() &&
286  fabs((i)->specificSurface().position().z()) < (j)->surface().bounds().length()/2.){
287  nfl ->setAdditionalLink(j, outsideIn);
288  mnfl->setAdditionalLink(j, outsideIn);
289  break;
290  }
291  }
292  }
293 }
294 
297 
298 
299 #include "NavigationSchoolFactory.h"
302 
303 
304 
305 
307 
308 #include <vector>
309 
310 //class FakeDetLayer;
311 
312 
317 public:
319  const MagneticField* field,
321 
322  ~SkippingLayerCosmicNavigationSchool() override{cleanMemory();};
323 };
324 
325 
327  const MagneticField* field,
329 {
330  build(theInputTracker, field, conf);
331 }
332 
333 
334 
335 
337 
338 #include <memory>
339 
340 // user include files
343 
345 
346 #include "NavigationSchoolFactory.h"
348 
349 //
350 // class decleration
351 //
353  public:
355  theNavigationPSet = iConfig;
356  theNavigationSchoolName = theNavigationPSet.getParameter<std::string>("ComponentName");
357  //the following line is needed to tell the framework what
358  // data is being produced
359  setWhatProduced(this, theNavigationSchoolName);
360  }
361 
363 
364  using ReturnType = std::unique_ptr<NavigationSchool>;
365 
366  ReturnType produce(const NavigationSchoolRecord&);
367 
368  // ----------member data ---------------------------
371 };
372 
375 
376  std::unique_ptr<NavigationSchool> theNavigationSchool ;
377 
378  // get the field
380  iRecord.getRecord<IdealMagneticFieldRecord>().get(field);
381 
382  //get the geometricsearch tracker geometry
383  edm::ESHandle<GeometricSearchTracker> geometricSearchTracker;
384  iRecord.getRecord<TrackerRecoGeometryRecord>().get(geometricSearchTracker);
385 
387  theNavigationSchool.reset(new SkippingLayerCosmicNavigationSchool(geometricSearchTracker.product(), field.product(), layerConfig) );
388 
389  return theNavigationSchool;
390 }
391 
394 
396 
397 
#define LogDebug(id)
T getParameter(std::string const &) const
#define dso_hidden
void linkBarrelLayers(SymmetricLayerFinder &symFinder) override
std::unique_ptr< NavigationSchool > ReturnType
std::vector< DetLayer const * > const & allLayers() const
std::vector< const BarrelDetLayer * > BDLC
SkippingLayerCosmicNavigationSchool(const GeometricSearchTracker *theTracker, const MagneticField *field, const CosmicNavigationSchoolConfiguration conf)
std::vector< BarrelDetLayer const * > const & tobLayers() const
const ForwardDetLayer * mirror(const ForwardDetLayer *layer)
int seqNum() const
Definition: DetLayer.h:36
SkippingLayerCosmicNavigationSchoolESProducer(const edm::ParameterSet &iConfig)
std::vector< BarrelDetLayer const * > const & pixelBarrelLayers() const
#define LogTrace(id)
virtual void establishInverseRelations()
std::vector< const ForwardDetLayer * > FDLC
std::vector< BarrelDetLayer const * > const & tibLayers() const
#define DEFINE_FWK_EVENTSETUP_MODULE(type)
Definition: ModuleFactory.h:60
void build(const GeometricSearchTracker *theTracker, const MagneticField *field, const CosmicNavigationSchoolConfiguration conf)
virtual void setAdditionalLink(const DetLayer *, NavigationDirection direction=insideOut)=0
void setCheckCrossingSide(bool docheck)
virtual DetLayer const * detLayer() const =0
static int position[264][3]
Definition: ReadPGInfo.cc:509
#define DEFINE_EDM_PLUGIN(factory, type, name)
ReturnType produce(const NavigationSchoolRecord &)
void setAdditionalLink(const DetLayer *, NavigationDirection direction=insideOut) override
T const * product() const
Definition: ESHandle.h:84
void buildAdditionalForwardLinks(SymmetricLayerFinder &symFinder)
bool isTrackerPixel(GeomDetEnumerators::SubDetector m)