Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 11:56:05

0001 //   $Revision: 1.15 $
0002 //   $Date: 2009/02/28 21:06:53 $
0003 //   (last update by $Author: flucke $)
0004 
0005 #ifndef Alignment_CommonAlignment_AlignableNavigator_h
0006 #define Alignment_CommonAlignment_AlignableNavigator_h
0007 
0008 #include <map>
0009 #include <vector>
0010 
0011 #include "TrackingTools/TransientTrackingRecHit/interface/TransientTrackingRecHit.h"
0012 
0013 #include "Alignment/CommonAlignment/interface/AlignableDetOrUnitPtr.h"
0014 #include "Alignment/CommonAlignment/interface/Utilities.h"
0015 
0016 class Alignable;
0017 class AlignableDet;
0018 class AlignableExtras;
0019 class GeomDet;
0020 
0021 /// A class to navigate from a DetId to the corresponding AlignableDetOrUnitPtr.
0022 /// A map is created at construction time from all
0023 /// sub-structures of the constructor's argument(s) that are AlignableDet or AlignableDetUnit.
0024 
0025 class AlignableNavigator {
0026 public:
0027   /// Constructor from one or two Alignables
0028   explicit AlignableNavigator(Alignable* tracker, Alignable* muon = nullptr);
0029 
0030   /// Constructor from one or two Alignables
0031   explicit AlignableNavigator(AlignableExtras* extras, Alignable* tracker, Alignable* muon = nullptr);
0032 
0033   /// Constructor from list of Alignbable
0034   explicit AlignableNavigator(const align::Alignables&);
0035 
0036   typedef std::map<DetId, AlignableDetOrUnitPtr> MapType;
0037   typedef MapType::value_type PairType;
0038 
0039   /// Returns AlignableDetOrUnitPtr corresponding to given DetId
0040   AlignableDetOrUnitPtr alignableFromDetId(const DetId& detid);
0041 
0042   /// Returns AlignableDetOrUnitPtr corresponding to given GeomDet
0043   AlignableDetOrUnitPtr alignableFromGeomDet(const GeomDet* geomDet);
0044 
0045   /// Returns vector AlignableDetOrUnitPtr for given vector of Hits.
0046   std::vector<AlignableDetOrUnitPtr> alignablesFromHits(const std::vector<const TransientTrackingRecHit*>& hitvec);
0047 
0048   /// Returns vector of AlignableDetOrUnitPtr for given vector of Hits.
0049   std::vector<AlignableDetOrUnitPtr> alignablesFromHits(const TransientTrackingRecHit::ConstRecHitContainer& hitVec);
0050 
0051   /// return all AlignableDetOrUnitPtrs
0052   std::vector<AlignableDetOrUnitPtr> alignableDetOrUnits();
0053 
0054   /// Returns number of elements in map
0055   int size(void) { return theMap.size(); }
0056 
0057   /// Given a DetId, returns true if DetIds with this detector and subdetector id are in the map (not necessarily the exact DetId)
0058   bool detAndSubdetInMap(const DetId& detid) const;
0059 
0060 private:
0061   /// Add recursively DetId-AlignableDetOrUnitPtr pairs to map.
0062   /// Returns number of Alignables with DetId!=0 which are (illegaly) neither AlignableDet
0063   /// nor AlignableDetUnit and are thus not added to the map.
0064   unsigned int recursiveGetId(Alignable* alignable);
0065 
0066   MapType theMap;
0067   std::vector<std::pair<int, int> > theDetAndSubdet;
0068 };
0069 
0070 #endif