CoordinateTransformation.h
Go to the documentation of this file.
1 /*
2  * File: CoordinateTransformation.h
3  * Author: denis
4  *
5  * This class handles transformation from the beam coordinates
6  * to the NOvA detector coordinates and back.
7  * Also has some supplementary functions.
8  *
9  * Currently support only NEAR, FAR detectors AND NuMI beamline
10  *
11  * Created on April 10, 2011, 10:21 PM
12  */
13 
14 #ifndef _COORDIATETRANSFORMATION_H
15 #define _COORDIATETRANSFORMATION_H
16 #include <CLHEP/Units/SystemOfUnits.h> // to define m, cm, degrees, radians, GeV, etc.
17 
18 #include "DAQChannelMap/DAQChannelMapConstants.h" // to get the Detector ID enum
19 
20 // Standard boost linear algebra library - matrix and vector.
21 // include array_wrapper.hpp as it appears to be missing from the
22 // other boost include files listed here but is needed by them
23 #include <boost/serialization/array_wrapper.hpp>
24 #pragma GCC diagnostic push
25 #ifndef DARWINBUILD
26 #pragma GCC diagnostic ignored "-Wmisleading-indentation"
27 #endif
28 #include <boost/numeric/ublas/matrix.hpp>
29 #include <boost/numeric/ublas/vector.hpp>
30 #pragma GCC diagnostic pop
31 
32 namespace geo {
33 
34  /// Z position of the point S (mean hadron decay) in beam coordinates.
35  /// Taken from NOvA-doc-5485.
36  const double pointS_Z = 184.25 * CLHEP::m;
37 
38  /// Angle between NuMI beamline and the earth's surface.
39  /// Equals to 3.3 degrees
40  const double NuMiBeamLineAngle = 0.057715289 * CLHEP::radian;
41 
42  /// Angle between NuMi beamline and the NOvA near detectors
43  const double NOvAneardetNuMiAngle = 0.0145766 * CLHEP::radian; // From NOvA-doc-5485
44 
45  /// Beam type. BOONE or NuMI
46  enum BeamType {
49  };
50 
51 
53 
54  public:
56  CoordinateTransformation(uint32_t detector_id, uint32_t beam_type);
57 
59 
60 
61  /// Try to set the detector and beam
62  bool setDetectorAndBeam(uint32_t detector_id, uint32_t beam_type);
63 
64  /// Transformation of Beam coordinates to NOvA detector coordinates
65  /// detector_id is as defined in DAQChannelMap
66  /// IMPORTANT! Input coordinates must be CLHEP-dimensional.
67  /// For example if x is in cm, make it x = x * CLHEP::cm
68  /// IMPORTANT! Output coordinates are also CLHEP-dimensional.
69  /// Fox example to get x in meters, do length_x = output_detector_coords[0] / CLHEP::m
70  bool transformBeamToDetectorCoordinates(double* input_beam_coords,
71  double* output_detector_coords) const;
72 
73  /// Transformation of NOvA Detector coordinates to Beam coordinates
74  /// detector_id is as defined in DAQChannelMap
75  /// IMPORTANT! Input coordinates must be CLHEP-dimensional.
76  /// For example if x is in cm, make it x = x * CLHEP::cm
77  /// IMPORTANT! Output coordinates are also CLHEP-dimensional.
78  /// Fox example to get x in meters, do length_x = output_detector_coords[0] / CLHEP::m
79  bool transformDetectorToBeamCoordinates(double* input_detector_coords,
80  double* output_beam_coords) const;
81 
82 
83  /// Print Matrices
84  bool print();
85 
86  private:
87  /// Initializing matrices
88  bool init();
89 
90  /// Setting the coordinate parameters
91  /// If returns tru, everything is set fine
92  /// If false, then some configuration was not supported and the parameters were not set
93  bool setCoordinateParameters(uint32_t detector_id, uint32_t beam_type);
94 
95  private:
96  uint32_t _detectorID; ///< Current Detector ID
97  uint32_t _beamType; ///< Current Beam Type
98 
99  boost::numeric::ublas::matrix <double> _rotationMatrix; ///< Rotational matrix
100  boost::numeric::ublas::matrix <double> _rotationMatrixInverse; ///< Rotational matrix inverse
101 
102  /// coordinates of the detector zero in the beam coordinates
103  boost::numeric::ublas::vector <double> _simpleTranslation;
104 
105 
106 
107  double _alpha; ///<Angle between NuMI beamline and the earth's surface.
108  double _beta; ///<Angle between NuMi beamline and the detector looking from top
109 
110 
111  };// end of class CoordinateTransformation
112 
113 }// end of namespace geo
114 
115 #endif /* _COORDINATETRANSFORMATION_H */
116 
boost::numeric::ublas::matrix< double > _rotationMatrixInverse
Rotational matrix inverse.
beam_type
Definition: Constants.h:26
bool setDetectorAndBeam(uint32_t detector_id, uint32_t beam_type)
Try to set the detector and beam.
double _alpha
Angle between NuMI beamline and the earth&#39;s surface.
bool transformBeamToDetectorCoordinates(double *input_beam_coords, double *output_detector_coords) const
bool init()
Initializing matrices.
bool transformDetectorToBeamCoordinates(double *input_detector_coords, double *output_beam_coords) const
bool setCoordinateParameters(uint32_t detector_id, uint32_t beam_type)
BeamType
Beam type. BOONE or NuMI.
boost::numeric::ublas::matrix< double > _rotationMatrix
Rotational matrix.
static constexpr double radian
uint32_t _beamType
Current Beam Type.
static constexpr double m
double _beta
Angle between NuMi beamline and the detector looking from top.
boost::numeric::ublas::vector< double > _simpleTranslation
coordinates of the detector zero in the beam coordinates
Helper for AttenCurve.
Definition: Path.h:10
const double NOvAneardetNuMiAngle
Angle between NuMi beamline and the NOvA near detectors.
uint32_t _detectorID
Current Detector ID.
const double pointS_Z
const double NuMiBeamLineAngle