Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:31:27

0001 #ifndef DetLayers_NavigationSchool_H
0002 #define DetLayers_NavigationSchool_H
0003 
0004 #include <vector>
0005 
0006 #include "NavigableLayer.h"
0007 #include "DetLayer.h"
0008 
0009 #include <iostream>
0010 #include <typeinfo>
0011 
0012 /** A base class for NavigationSchools.
0013  *  The links between layers are computed or loaded from 
0014  *  persistent store by a NavigationSchool.
0015  *  The result is a container of NavigableLayers.
0016  */
0017 
0018 class NavigationSchool {
0019 public:
0020   NavigationSchool() : theAllDetLayersInSystem(nullptr) {
0021     //    std::cout << "NVSH: C "<< this << std::endl;
0022   }
0023 
0024   virtual ~NavigationSchool() {}
0025 
0026   typedef std::vector<NavigableLayer*> StateType;
0027 
0028   virtual StateType navigableLayers() = 0;
0029 
0030   /// Return the next (closest) layer(s) that can be reached in the specified
0031   /// NavigationDirection
0032   template <typename... Args>
0033   std::vector<const DetLayer*> nextLayers(const DetLayer& detLayer, Args&&... args) const {
0034     assert(detLayer.seqNum() >= 0);
0035     auto nl = theAllNavigableLayer[detLayer.seqNum()];
0036     return nl ? nl->nextLayers(std::forward<Args>(args)...) : std::vector<const DetLayer*>();
0037   }
0038 
0039   /// Returns all layers compatible
0040   template <typename... Args>
0041   std::vector<const DetLayer*> compatibleLayers(const DetLayer& detLayer, Args&&... args) const {
0042     auto nl = theAllNavigableLayer[detLayer.seqNum()];
0043     return nl ? nl->compatibleLayers(std::forward<Args>(args)...) : std::vector<const DetLayer*>();
0044   }
0045 
0046 protected:
0047   void setState(const StateType& state) {
0048     //  std::cout << "NVSH: set "<< this << ' ' << typeid(*this).name()
0049     //        << ' ' << state.size() << ' ' << theAllNavigableLayer.size() << std::endl;
0050 
0051     for (auto nl : state) {
0052       if (!nl)
0053         continue;
0054       theAllNavigableLayer[nl->detLayer()->seqNum()] = nl;
0055       nl->setSchool(this);
0056     }
0057   }
0058 
0059   // index correspond to seqNum of DetLayers
0060   StateType theAllNavigableLayer;
0061 
0062   // will be obsoleted together with NAvigationSetter
0063 public:
0064   const std::vector<const DetLayer*>& allLayersInSystem() const { return *theAllDetLayersInSystem; }
0065 
0066 protected:
0067   const std::vector<const DetLayer*>* theAllDetLayersInSystem;
0068 };
0069 
0070 #endif  // NavigationSchool_H