Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 12:49:16

0001 /****************************************************************************
0002 *
0003 * Authors:
0004 *  Jan Kašpar (jan.kaspar@gmail.com)
0005 *
0006 ****************************************************************************/
0007 
0008 #ifndef Geometry_VeryForwardGeometryBuilder_CTPPSGeometry
0009 #define Geometry_VeryForwardGeometryBuilder_CTPPSGeometry
0010 
0011 #include "DataFormats/CTPPSDetId/interface/CTPPSDetId.h"
0012 
0013 #include "Geometry/VeryForwardGeometryBuilder/interface/DetGeomDesc.h"
0014 #include "Geometry/VeryForwardGeometryBuilder/interface/CTPPSDDDNames.h"
0015 
0016 #include <map>
0017 #include <set>
0018 
0019 /**
0020  * \brief The manager class for TOTEM RP geometry.
0021  *
0022  * This is kind of "public relation class" for the tree structure of DetGeomDesc. It provides convenient interface to
0023  * answer frequently asked questions about the geometry of TOTEM Roman Pots. These questions are of type:\n
0024  *  - What is the geometry (shift, roatation, material, etc.) of detector with id xxx?\n
0025  *  - If RP ID is xxx, which are the sensorss inside this pot?\n
0026  *  - If hit position in local detector coordinate system is xxx, what is the hit position in global c.s.?\n
0027  * etc. (see the comments in definition bellow)
0028  **/
0029 
0030 class CTPPSGeometry {
0031 public:
0032   typedef std::map<unsigned int, const DetGeomDesc*> mapType;
0033   typedef std::map<int, const DetGeomDesc*> RPDeviceMapType;
0034   typedef std::map<unsigned int, std::set<unsigned int> > mapSetType;
0035 
0036   using Vector = DetGeomDesc::Translation;
0037 
0038   /// build up from DetGeomDesc
0039   CTPPSGeometry(const DetGeomDesc* gd, unsigned int verbosity) { build(gd, verbosity); }
0040 
0041   /// build up from DetGeomDesc structure
0042   void build(const DetGeomDesc*, unsigned int verbosity);
0043 
0044   //----- setters and getters
0045 
0046   ///\brief adds an item to the map (detector ID --> DetGeomDesc)
0047   /// performs necessary checks
0048   /// \return true if successful, false if the sensor is already present
0049   bool addSensor(unsigned int, const DetGeomDesc*&);
0050 
0051   ///\brief adds a RP box to a map
0052   /// \return true if successful, false if the RP is already present
0053   bool addRP(unsigned int id, const DetGeomDesc*&);
0054 
0055   ///\brief returns geometry of a detector
0056   /// performs necessary checks, returns NULL if fails
0057   const DetGeomDesc* sensor(unsigned int id) const;
0058   const DetGeomDesc* sensorNoThrow(unsigned int id) const noexcept;
0059 
0060   /// returns geometry of a RP box
0061   const DetGeomDesc* rp(unsigned int id) const;
0062   const DetGeomDesc* rpNoThrow(unsigned int id) const noexcept;
0063 
0064   //----- objects iterators
0065 
0066   /// begin iterator over sensors
0067   mapType::const_iterator beginSensor() const { return sensors_map_.begin(); }
0068   /// end iterator over sensors
0069   mapType::const_iterator endSensor() const { return sensors_map_.end(); }
0070 
0071   /// begin iterator over RPs
0072   RPDeviceMapType::const_iterator beginRP() const { return rps_map_.begin(); }
0073   /// end iterator over RPs
0074   RPDeviceMapType::const_iterator endRP() const { return rps_map_.end(); }
0075 
0076   //----- translators
0077 
0078   /// coordinate transformations between local<-->global reference frames
0079   /// dimensions in mm
0080   /// sensor id expected
0081   Vector localToGlobal(const DetGeomDesc*, const Vector&) const;
0082   Vector globalToLocal(const DetGeomDesc*, const Vector&) const;
0083   Vector localToGlobal(unsigned int, const Vector&) const;
0084   Vector globalToLocal(unsigned int, const Vector&) const;
0085 
0086   /// direction transformations between local and global reference frames
0087   /// \param id sensor id
0088   Vector localToGlobalDirection(unsigned int id, const Vector&) const;
0089   /// direction transformations between global and local reference frames
0090   /// \param id sensor id
0091   Vector globalToLocalDirection(unsigned int id, const Vector&) const;
0092 
0093   /// returns translation (position) of a detector
0094   /// \param id sensor id
0095   Vector sensorTranslation(unsigned int id) const;
0096 
0097   /// returns position of a RP box
0098   /// \param id RP id
0099   Vector rpTranslation(unsigned int id) const;
0100 
0101   /// after checks returns set of station ids corresponding to the given arm id
0102   const std::set<unsigned int>& stationsInArm(unsigned int) const;
0103 
0104   /// after checks returns set of RP ids corresponding to the given station id
0105   const std::set<unsigned int>& rpsInStation(unsigned int) const;
0106 
0107   /// after checks returns set of sensor ids corresponding to the given RP id
0108   const std::set<unsigned int>& sensorsInRP(unsigned int) const;
0109 
0110 protected:
0111   /// map: sensor id --> DetGeomDesc
0112   mapType sensors_map_;
0113 
0114   /// map: rp id --> DetGeomDesc
0115   RPDeviceMapType rps_map_;
0116 
0117   ///\brief map: parent ID -> set of subelements
0118   /// E.g. \a stations_in_arm_ is map of arm ID -> set of stations (in that arm)
0119   mapSetType stations_in_arm_, rps_in_station_, dets_in_rp_;
0120 };
0121 
0122 #endif