Public Member Functions | Private Member Functions | Private Attributes | List of all members
geo::CoordinateTransformation Class Reference

#include "/cvmfs/nova-development.opensciencegrid.org/novasoft/releases/N20-10-26/GeometryObjects/CoordinateTransformation.h"

Public Member Functions

 CoordinateTransformation ()
 
 CoordinateTransformation (uint32_t detector_id, uint32_t beam_type)
 
 ~CoordinateTransformation ()
 
bool setDetectorAndBeam (uint32_t detector_id, uint32_t beam_type)
 Try to set the detector and beam. More...
 
bool transformBeamToDetectorCoordinates (double *input_beam_coords, double *output_detector_coords) const
 
bool transformDetectorToBeamCoordinates (double *input_detector_coords, double *output_beam_coords) const
 
bool print ()
 Print Matrices. More...
 

Private Member Functions

bool init ()
 Initializing matrices. More...
 
bool setCoordinateParameters (uint32_t detector_id, uint32_t beam_type)
 

Private Attributes

uint32_t _detectorID
 Current Detector ID. More...
 
uint32_t _beamType
 Current Beam Type. More...
 
boost::numeric::ublas::matrix< double > _rotationMatrix
 Rotational matrix. More...
 
boost::numeric::ublas::matrix< double > _rotationMatrixInverse
 Rotational matrix inverse. More...
 
boost::numeric::ublas::vector< double > _simpleTranslation
 coordinates of the detector zero in the beam coordinates More...
 
double _alpha
 Angle between NuMI beamline and the earth's surface. More...
 
double _beta
 Angle between NuMi beamline and the detector looking from top. More...
 

Detailed Description

Definition at line 52 of file CoordinateTransformation.h.

Constructor & Destructor Documentation

geo::CoordinateTransformation::CoordinateTransformation ( )

Definition at line 24 of file CoordinateTransformation.cxx.

24  :
25  _detectorID(0),
26  _beamType(0),
27  _rotationMatrix(3,3),
30  {
31  }
boost::numeric::ublas::matrix< double > _rotationMatrixInverse
Rotational matrix inverse.
boost::numeric::ublas::matrix< double > _rotationMatrix
Rotational matrix.
uint32_t _beamType
Current Beam Type.
boost::numeric::ublas::vector< double > _simpleTranslation
coordinates of the detector zero in the beam coordinates
uint32_t _detectorID
Current Detector ID.
geo::CoordinateTransformation::CoordinateTransformation ( uint32_t  detector_id,
uint32_t  beam_type 
)

Definition at line 34 of file CoordinateTransformation.cxx.

References _beamType, _detectorID, and setDetectorAndBeam().

34  :
35  _detectorID(detector_id),
37  _rotationMatrix(3,3),
40  {
42  }
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.
boost::numeric::ublas::matrix< double > _rotationMatrix
Rotational matrix.
uint32_t _beamType
Current Beam Type.
boost::numeric::ublas::vector< double > _simpleTranslation
coordinates of the detector zero in the beam coordinates
uint32_t _detectorID
Current Detector ID.
geo::CoordinateTransformation::~CoordinateTransformation ( )

Definition at line 66 of file CoordinateTransformation.cxx.

References LOG_DEBUG.

66  {
67  LOG_DEBUG("CoordinateTransformation")
68  << "~CoordinateTransformation\n";
69  }
#define LOG_DEBUG(stream)
Definition: Messenger.h:149

Member Function Documentation

bool geo::CoordinateTransformation::init ( )
private

Initializing matrices.

Definition at line 73 of file CoordinateTransformation.cxx.

References _alpha, _beta, _rotationMatrix, _rotationMatrixInverse, std::cos(), std::sin(), and transformBeamToDetectorCoordinates().

Referenced by demo.App::__init__(), testem0.App::__init__(), Lesson1.App::__init__(), ExN03.App::__init__(), and setCoordinateParameters().

73  {
74 
75  double ca = cos(_alpha);
76  double sa = sin(_alpha);
77  double cb = cos(_beta);
78  double sb = sin(_beta);
79 
80  _rotationMatrix(0, 0) = cb;
81  _rotationMatrix(0, 1) = -sb*sa;
82  _rotationMatrix(0, 2) = sb*ca;
83 
84  _rotationMatrix(1, 0) = 0.0;
85  _rotationMatrix(1, 1) = ca;
86  _rotationMatrix(1, 2) = sa;
87 
88  _rotationMatrix(2, 0) = -sb;
89  _rotationMatrix(2, 1) = -cb*sa;
90  _rotationMatrix(2, 2) = cb*ca;
91 
92 
93  _rotationMatrixInverse(0, 0) = cb;
94  _rotationMatrixInverse(0, 1) = 0.0;
95  _rotationMatrixInverse(0, 2) = -sb;
96 
97  _rotationMatrixInverse(1, 0) = -sa*sb;
98  _rotationMatrixInverse(1, 1) = ca;
99  _rotationMatrixInverse(1, 2) = -sa*cb;
100 
101  _rotationMatrixInverse(2, 0) = ca*sb;
102  _rotationMatrixInverse(2, 1) = sa;
103  _rotationMatrixInverse(2, 2) = ca*cb;
104 
105  return true;
106  }
boost::numeric::ublas::matrix< double > _rotationMatrixInverse
Rotational matrix inverse.
double _alpha
Angle between NuMI beamline and the earth&#39;s surface.
boost::numeric::ublas::matrix< double > _rotationMatrix
Rotational matrix.
T sin(T number)
Definition: d0nt_math.hpp:132
double _beta
Angle between NuMi beamline and the detector looking from top.
T cos(T number)
Definition: d0nt_math.hpp:78
bool geo::CoordinateTransformation::print ( )

Print Matrices.

Now calculating the angle at which point S sees the front surface of the detector

First figuring out the detector UZ in beam coordinates

Unit vector of detector's Uz in beam coordinates

Distance from point S to detector zero

Now need to normalize it

cosine of the angle at which point-S sees the front surface of the detector

Definition at line 155 of file CoordinateTransformation.cxx.

References _beamType, _detectorID, _rotationMatrix, _rotationMatrixInverse, _simpleTranslation, om::cout, MECModelEnuComparisons::i, LOG_DEBUG, geo::pointS_Z, printf(), std::sqrt(), and transformDetectorToBeamCoordinates().

Referenced by geo::CoordinateTransformationTest::printCoordinateTransformations().

155  {
156 
157  std::cout << "Coordinate system transformations for "
158  << "Beam Type = " << _beamType << " "
159  << "Detector = " << _detectorID << ":\n";
160 
161  std::cout << "Translation:\n";
162  printf(" |%0.10E|\n", _simpleTranslation[0]);
163  printf("S = |%0.10E|\n", _simpleTranslation[1]);
164  printf(" |%0.10E|\n", _simpleTranslation[2]);
165 
166 
167 
168  std::cout << "Beam->Detector\n";
169  printf("|x_det| | %0.10E %0.10E %0.10E | | x_beam - %0.10E |\n", _rotationMatrixInverse(0,0), _rotationMatrixInverse(0,1), _rotationMatrixInverse(0,2) , _simpleTranslation[0]);
170  printf("|y_det| = | %0.10E %0.10E %0.10E | * | y_beam - %0.10E |\n", _rotationMatrixInverse(1,0), _rotationMatrixInverse(1,1), _rotationMatrixInverse(1,2) , _simpleTranslation[1]);
171  printf("|z_det| | %0.10E %0.10E %0.10E | | z_beam - %0.10E |\n", _rotationMatrixInverse(2,0), _rotationMatrixInverse(2,1), _rotationMatrixInverse(2,2) , _simpleTranslation[2]);
172 
173 
174  std::cout << "\n";
175  std::cout << "Detector->Beam\n";
176  printf("|x_beam| | %0.10E | | %0.10E %0.10E %0.10E | | x_det |\n", _simpleTranslation[0], _rotationMatrix(0,0), _rotationMatrix(0,1), _rotationMatrix(0,2));
177  printf("|y_beam| = | %0.10E | + | %0.10E %0.10E %0.10E | * | y_det |\n", _simpleTranslation[1], _rotationMatrix(1,0), _rotationMatrix(1,1), _rotationMatrix(1,2));
178  printf("|z_beam| | %0.10E | | %0.10E %0.10E %0.10E | | z_det |\n", _simpleTranslation[2], _rotationMatrix(2,0), _rotationMatrix(2,1), _rotationMatrix(2,2));
179 
180  /// Now calculating the angle at which point S sees the front surface of the detector
181 
182  /// First figuring out the detector UZ in beam coordinates
183  double p0_det[3] = {0,0,0};
184  double p0_beam[3];
185  transformDetectorToBeamCoordinates(p0_det, p0_beam);
186 
187  double p1_det[3] = {0,0,1};
188  double p1_beam[3];
189  transformDetectorToBeamCoordinates(p1_det, p1_beam);
190 
191  /// Unit vector of detector's Uz in beam coordinates
192  double dr_detector_uz[3] = {
193  p1_beam[0] - p0_beam[0],
194  p1_beam[1] - p0_beam[1],
195  p1_beam[2] - p0_beam[2]
196  };
197 
198 
199  /// Distance from point S to detector zero
200  double dr_from_pointS_to_detector_zero[3] = {
203  _simpleTranslation[2] - pointS_Z
204  };
205 
206  /// Now need to normalize it
207  {
208  double drmod_from_pointS_to_detector_zero = sqrt(
209  dr_from_pointS_to_detector_zero[0]*dr_from_pointS_to_detector_zero[0]
210  + dr_from_pointS_to_detector_zero[1]*dr_from_pointS_to_detector_zero[1]
211  + dr_from_pointS_to_detector_zero[2]*dr_from_pointS_to_detector_zero[2]
212  );
213  for(int i=0; i<3; i++)
214  dr_from_pointS_to_detector_zero[i] /= drmod_from_pointS_to_detector_zero;
215  }// end of normalization
216 
217  /// cosine of the angle at which point-S sees the front surface of the detector
218  double cos_detector_front_surface = dr_detector_uz[0] * dr_from_pointS_to_detector_zero[0]
219  + dr_detector_uz[1] * dr_from_pointS_to_detector_zero[1]
220  + dr_detector_uz[2] * dr_from_pointS_to_detector_zero[2];
221 
222  LOG_DEBUG("CoordinateTransformation")
223  << "Cosine of the angle at which point S sees the front surface of the detector: "
224  << cos_detector_front_surface
225  << "\n";
226 
227  return true;
228  }
#define LOG_DEBUG(stream)
Definition: Messenger.h:149
boost::numeric::ublas::matrix< double > _rotationMatrixInverse
Rotational matrix inverse.
T sqrt(T number)
Definition: d0nt_math.hpp:156
bool transformDetectorToBeamCoordinates(double *input_detector_coords, double *output_beam_coords) const
printf("%d Experimental points found\n", nlines)
boost::numeric::ublas::matrix< double > _rotationMatrix
Rotational matrix.
uint32_t _beamType
Current Beam Type.
OStream cout
Definition: OStream.cxx:6
boost::numeric::ublas::vector< double > _simpleTranslation
coordinates of the detector zero in the beam coordinates
uint32_t _detectorID
Current Detector ID.
const double pointS_Z
bool geo::CoordinateTransformation::setCoordinateParameters ( uint32_t  detector_id,
uint32_t  beam_type 
)
private

Setting the coordinate parameters If returns tru, everything is set fine If false, then some configuration was not supported and the parameters were not set

See if we support this beam type

See if we support this detector type

From NOvA-doc-5485

From NOvA-doc-5485

From NOvA-doc-5485

Definition at line 232 of file CoordinateTransformation.cxx.

References _alpha, _beta, _simpleTranslation, geo::BEAMTYPE_NUMI, init(), novadaq::cnv::kFARDET, CLHEP::km, novadaq::cnv::kNDOS, novadaq::cnv::kNEARDET, LOG_DEBUG, CLHEP::m, geo::NOvAneardetNuMiAngle, and geo::NuMiBeamLineAngle.

Referenced by setDetectorAndBeam().

233  {
234 
235 
236  /// See if we support this beam type
237  if(beam_type != BEAMTYPE_NUMI) {
238  LOG_DEBUG("CoordinateTransformation")
239  << "From CoordinateTransformation::setCoordinateParameters. "
240  << "Beam type " << beam_type << " is not supported.\n";
241  return false;
242  }// end of checking the beam configuration
243 
244 
245  /// See if we support this detector type
246  if (detector_id == novadaq::cnv::kNEARDET) {
247  /// From NOvA-doc-5485
248  _simpleTranslation[0] = 11.414 * CLHEP::m;
249  _simpleTranslation[1] = -3.456 * CLHEP::m;
250  _simpleTranslation[2] = 994.665 * CLHEP::m;
251 
254  }
255  else if (detector_id == novadaq::cnv::kFARDET) {
256  /// From NOvA-doc-5485
257  _simpleTranslation[0] = 11.037 * CLHEP::km;
258  _simpleTranslation[1] = -4.1626 * CLHEP::km;
259  _simpleTranslation[2] = 810.42 * CLHEP::km;
260 
263  }
264  else if (detector_id == novadaq::cnv::kNDOS) {
265  /// From NOvA-doc-5485
266  _simpleTranslation[0] = -0.29 * CLHEP::m;
267  _simpleTranslation[1] = 92.21 * CLHEP::m;
268  _simpleTranslation[2] = 841.76* CLHEP::m;
269 
271  _beta = 0.0;
272  }
273 
274  else {
275  LOG_DEBUG("CoordinateTransformation")
276  << "From geo::CoordinateTransformation::setCoordinateParameters. "
277  << "Detector ID " << detector_id << " is not supported.\n";
278  return false;
279  }// end of checking the detector configuration
280 
281  return init();
282  }
#define LOG_DEBUG(stream)
Definition: Messenger.h:149
beam_type
Definition: Constants.h:26
double _alpha
Angle between NuMI beamline and the earth&#39;s surface.
bool init()
Initializing matrices.
Far Detector at Ash River, MN.
Prototype Near Detector on the surface at FNAL.
Near Detector in the NuMI cavern.
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
static constexpr double km
const double NOvAneardetNuMiAngle
Angle between NuMi beamline and the NOvA near detectors.
const double NuMiBeamLineAngle
bool geo::CoordinateTransformation::setDetectorAndBeam ( uint32_t  detector_id,
uint32_t  beam_type 
)

Try to set the detector and beam.

Trying to set the detector parameters If unsuccessfull, set the detector and beam ID to zero

Have to reset the detector ID and beam type

Definition at line 46 of file CoordinateTransformation.cxx.

References _beamType, _detectorID, and setCoordinateParameters().

Referenced by CoordinateTransformation(), and geo::GeometryBase::setDetectorID().

46  {
47 
48  /// Trying to set the detector parameters
49  /// If unsuccessfull, set the detector and beam ID to zero
50  if(!setCoordinateParameters(detector_id, beam_type)){
51  _detectorID = 0;
52  _beamType = 0;
53  return false;
54  }// end of setting the detector parameters
55 
56 
57  /// Have to reset the detector ID and beam type
58  _detectorID = detector_id;
60 
61  return true;
62  }
beam_type
Definition: Constants.h:26
bool setCoordinateParameters(uint32_t detector_id, uint32_t beam_type)
uint32_t _beamType
Current Beam Type.
uint32_t _detectorID
Current Detector ID.
bool geo::CoordinateTransformation::transformBeamToDetectorCoordinates ( double *  input_beam_coords,
double *  output_detector_coords 
) const

Transformation of Beam coordinates to NOvA detector coordinates detector_id is as defined in DAQChannelMap IMPORTANT! Input coordinates must be CLHEP-dimensional. For example if x is in cm, make it x = x * CLHEP::cm IMPORTANT! Output coordinates are also CLHEP-dimensional. Fox example to get x in meters, do length_x = output_detector_coords[0] / CLHEP::m

Check if the beam type and detector id are set

Calculate the beam coordinates x`` = M^{-1} * (x-x0)

Definition at line 110 of file CoordinateTransformation.cxx.

References _beamType, _detectorID, _rotationMatrixInverse, _simpleTranslation, MECModelEnuComparisons::i, calib::j, sum, and transformDetectorToBeamCoordinates().

Referenced by mcchk::NeutrinoAna::AnalyzeNeutrinoInteraction(), and init().

111  {
112 
113 
114  /// Check if the beam type and detector id are set
115  if(!_beamType || !_detectorID) return false;
116 
117  /// Calculate the beam coordinates
118  /// x`` = M^{-1} * (x-x0)
119  for(int i = 0; i < 3; i++){
120  double sum = 0.0;
121  for(int j = 0; j < 3; j++)
122  sum += _rotationMatrixInverse(i,j)*(input_beam_coords[j] - _simpleTranslation[j]);
123 
124  output_detector_coords[i] = sum;
125  }// end of loop over coordinates
126 
127  return true;
128  }// end of transformBeamToDetectorCoordinates
boost::numeric::ublas::matrix< double > _rotationMatrixInverse
Rotational matrix inverse.
const double j
Definition: BetheBloch.cxx:29
uint32_t _beamType
Current Beam Type.
boost::numeric::ublas::vector< double > _simpleTranslation
coordinates of the detector zero in the beam coordinates
Double_t sum
Definition: plot.C:31
uint32_t _detectorID
Current Detector ID.
bool geo::CoordinateTransformation::transformDetectorToBeamCoordinates ( double *  input_detector_coords,
double *  output_beam_coords 
) const

Transformation of NOvA Detector coordinates to Beam coordinates detector_id is as defined in DAQChannelMap IMPORTANT! Input coordinates must be CLHEP-dimensional. For example if x is in cm, make it x = x * CLHEP::cm IMPORTANT! Output coordinates are also CLHEP-dimensional. Fox example to get x in meters, do length_x = output_detector_coords[0] / CLHEP::m

Check if the beam type and detector id are set

Calculate the detector coordinates x = x0 + M * x''

Definition at line 132 of file CoordinateTransformation.cxx.

References _beamType, _detectorID, _rotationMatrix, _simpleTranslation, MECModelEnuComparisons::i, calib::j, and sum.

Referenced by geo::Geometry::getDirectionInBeamCoordinates(), print(), and transformBeamToDetectorCoordinates().

133  {
134 
135 
136  /// Check if the beam type and detector id are set
137  if(!_beamType || !_detectorID) return false;
138 
139 
140  /// Calculate the detector coordinates
141  /// x = x0 + M * x''
142  for(int i = 0; i < 3; i++) {
143  double sum = 0.0;
144  for(int j = 0; j < 3; j++)
145  sum += _rotationMatrix(i,j)*input_detector_coords[j];
146 
147  output_beam_coords[i] = _simpleTranslation[i] + sum;
148  }// end of loop over coordinates
149 
150  return true;
151  }// end of transformDetectorToBeamCoordinates
boost::numeric::ublas::matrix< double > _rotationMatrix
Rotational matrix.
const double j
Definition: BetheBloch.cxx:29
uint32_t _beamType
Current Beam Type.
boost::numeric::ublas::vector< double > _simpleTranslation
coordinates of the detector zero in the beam coordinates
Double_t sum
Definition: plot.C:31
uint32_t _detectorID
Current Detector ID.

Member Data Documentation

double geo::CoordinateTransformation::_alpha
private

Angle between NuMI beamline and the earth's surface.

Definition at line 107 of file CoordinateTransformation.h.

Referenced by init(), and setCoordinateParameters().

uint32_t geo::CoordinateTransformation::_beamType
private
double geo::CoordinateTransformation::_beta
private

Angle between NuMi beamline and the detector looking from top.

Definition at line 108 of file CoordinateTransformation.h.

Referenced by init(), and setCoordinateParameters().

uint32_t geo::CoordinateTransformation::_detectorID
private
boost::numeric::ublas::matrix<double> geo::CoordinateTransformation::_rotationMatrix
private

Rotational matrix.

Definition at line 99 of file CoordinateTransformation.h.

Referenced by init(), print(), and transformDetectorToBeamCoordinates().

boost::numeric::ublas::matrix<double> geo::CoordinateTransformation::_rotationMatrixInverse
private

Rotational matrix inverse.

Definition at line 100 of file CoordinateTransformation.h.

Referenced by init(), print(), and transformBeamToDetectorCoordinates().

boost::numeric::ublas::vector<double> geo::CoordinateTransformation::_simpleTranslation
private

coordinates of the detector zero in the beam coordinates

Definition at line 103 of file CoordinateTransformation.h.

Referenced by print(), setCoordinateParameters(), transformBeamToDetectorCoordinates(), and transformDetectorToBeamCoordinates().


The documentation for this class was generated from the following files: