Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-03-25 23:59:16

0001 #ifndef Alignment_CommonAlignment_AlignableObjectId_h
0002 #define Alignment_CommonAlignment_AlignableObjectId_h
0003 
0004 #include <string>
0005 #include "Alignment/CommonAlignment/interface/StructureType.h"
0006 
0007 class TrackerGeometry;
0008 class DTGeometry;
0009 class CSCGeometry;
0010 class GEMGeometry;
0011 
0012 /// Allows conversion between type and name, and vice-versa
0013 class AlignableObjectId {
0014 public:
0015   struct entry;
0016   enum class Geometry { RunI, PhaseI, PhaseII, General, Unspecified };
0017 
0018   AlignableObjectId(Geometry);
0019   AlignableObjectId(const TrackerGeometry*, const DTGeometry*, const CSCGeometry*, const GEMGeometry*);
0020   AlignableObjectId(const AlignableObjectId&) = default;
0021   AlignableObjectId& operator=(const AlignableObjectId&) = default;
0022   AlignableObjectId(AlignableObjectId&&) = default;
0023   AlignableObjectId& operator=(AlignableObjectId&&) = default;
0024   virtual ~AlignableObjectId() = default;
0025 
0026   /// retrieve the geometry information
0027   Geometry geometry() const { return geometry_; }
0028 
0029   /// Convert name to type
0030   align::StructureType nameToType(const std::string& name) const;
0031 
0032   /// Convert type to name
0033   std::string typeToName(align::StructureType type) const;
0034   const char* idToString(align::StructureType type) const;
0035   align::StructureType stringToId(const char*) const;
0036   align::StructureType stringToId(const std::string& s) const { return stringToId(s.c_str()); }
0037 
0038   static Geometry commonGeometry(Geometry, Geometry);
0039   static AlignableObjectId commonObjectIdProvider(const AlignableObjectId&, const AlignableObjectId&);
0040   template <typename TRACKER, typename MUON>
0041   static AlignableObjectId commonObjectIdProvider(const TRACKER*, const MUON*);
0042   template <typename TRACKER>
0043   static AlignableObjectId commonObjectIdProvider(const TRACKER*, std::nullptr_t);
0044 
0045 private:
0046   static Geometry trackerGeometry(const TrackerGeometry*);
0047   static Geometry muonGeometry(const DTGeometry*, const CSCGeometry*, const GEMGeometry*);
0048 
0049   const entry* entries_{nullptr};
0050   Geometry geometry_{Geometry::Unspecified};
0051 };
0052 
0053 template <typename TRACKER, typename MUON>
0054 AlignableObjectId AlignableObjectId ::commonObjectIdProvider(const TRACKER* tracker, const MUON* muon) {
0055   auto trackerGeometry = (tracker ? tracker->objectIdProvider().geometry() : AlignableObjectId::Geometry::General);
0056   auto muonGeometry = (muon ? muon->objectIdProvider().geometry() : AlignableObjectId::Geometry::General);
0057   return AlignableObjectId::commonGeometry(trackerGeometry, muonGeometry);
0058 }
0059 
0060 template <typename T>
0061 AlignableObjectId AlignableObjectId ::commonObjectIdProvider(const T* tracker, std::nullptr_t) {
0062   auto trackerGeometry = (tracker ? tracker->objectIdProvider().geometry() : AlignableObjectId::Geometry::General);
0063   return AlignableObjectId::commonGeometry(trackerGeometry, AlignableObjectId::Geometry::General);
0064 }
0065 
0066 #endif