Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 11:58:32

0001 /****************************************************************************
0002 * Authors: 
0003 *  Jan Kašpar (jan.kaspar@gmail.com) 
0004 ****************************************************************************/
0005 
0006 #ifndef CalibPPS_AlignmentRelative_AlignmentGeometry_h
0007 #define CalibPPS_AlignmentRelative_AlignmentGeometry_h
0008 
0009 #include "FWCore/Utilities/interface/Exception.h"
0010 
0011 #include <map>
0012 #include <set>
0013 #include <string>
0014 
0015 //----------------------------------------------------------------------------------------------------
0016 
0017 /**
0018  *\brief A structure to hold relevant geometrical information about one detector/sensor.
0019  **/
0020 struct DetGeometry {
0021   double z;  ///< z postion at detector centre; mm
0022 
0023   double sx, sy;  ///< detector nominal shift = detector center in global coordinates; in mm
0024 
0025   struct DirectionData {
0026     double dx, dy, dz;  ///< x, y and z components of the direction unit vector in global coordinates
0027     double s;           ///< projection of (sx, sy) to (dx, dy)
0028   };
0029 
0030   std::map<unsigned int, DirectionData> directionData;
0031 
0032   bool isU;  ///< only relevant for strips: true for U detectors, false for V detectors
0033              ///< global U, V frame is used - that matches with u, v frame of the 1200 detector
0034 
0035   DetGeometry(double _z = 0., double _sx = 0., double _sy = 0., bool _isU = false)
0036       : z(_z), sx(_sx), sy(_sy), isU(_isU) {}
0037 
0038   void setDirection(unsigned int idx, double dx, double dy, double dz) {
0039     directionData[idx] = {dx, dy, dz, dx * sx + dy * sy};
0040   }
0041 
0042   const DirectionData& getDirectionData(unsigned int idx) const {
0043     auto it = directionData.find(idx);
0044     if (it == directionData.end())
0045       throw cms::Exception("PPS") << "direction index " << idx << " not in the mapping.";
0046 
0047     return it->second;
0048   }
0049 };
0050 
0051 //----------------------------------------------------------------------------------------------------
0052 
0053 /**
0054  * A collection of geometrical information.
0055  **/
0056 class AlignmentGeometry {
0057 protected:
0058   std::map<unsigned int, DetGeometry> sensorGeometry;
0059 
0060 public:
0061   /// a characteristic z in mm
0062   double z0;
0063 
0064   /// puts an element to the map
0065   void insert(unsigned int id, const DetGeometry& g);
0066 
0067   /// retrieves sensor geometry
0068   const DetGeometry& get(unsigned int id) const;
0069 
0070   const std::map<unsigned int, DetGeometry>& getSensorMap() const { return sensorGeometry; }
0071 
0072   /// returns the number of detectors in the collection
0073   unsigned int getNumberOfDetectors() const { return sensorGeometry.size(); }
0074 
0075   /// check whether the sensor Id is valid (present in the map)
0076   bool isValidSensorId(unsigned int id) const { return (sensorGeometry.find(id) != sensorGeometry.end()); }
0077 
0078   /// Prints the geometry.
0079   void print() const;
0080 };
0081 
0082 #endif