ATLAS Offline Software
CLHEPHelpers.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 //-----------------------------------------------------------------------------
6 //
7 // author: Lukasz Janyst <ljanyst@cern.ch>
8 // file: CLHEPHelpers.h
9 //
10 //-----------------------------------------------------------------------------
11 
12 #ifndef CLHEP_HELPERS_H
13 #define CLHEP_HELPERS_H
14 
15 #include "CLHEP/Geometry/Transform3D.h"
16 #include "CLHEP/Matrix/Vector.h"
17 
18 #include <vector>
19 
20 namespace {
21 
22 class SetTransform3D : public HepGeom::Transform3D
23 {
24 public:
25  void setTransform (double XX, double XY, double XZ, double DX,
26  double YX, double YY, double YZ, double DY,
27  double ZX, double ZY, double ZZ, double DZ)
28  {
29  HepGeom::Transform3D::setTransform (XX, XY, XZ, DX,
30  YX, YY, YZ, DY,
31  ZX, ZY, ZZ, DZ);
32  }
33 };
34 
35 }
36 
38 {
39  public:
40 
42  template <class T>
43  static void hepTransform3DToVector( const HepGeom::Transform3D &trans,
44  T &vec )
45  {
46  vec.reserve(12);
47  vec.push_back( trans.xx() );
48  vec.push_back( trans.xy() );
49  vec.push_back( trans.xz() );
50  vec.push_back( trans.dx() );
51 
52  vec.push_back( trans.yx() );
53  vec.push_back( trans.yy() );
54  vec.push_back( trans.yz() );
55  vec.push_back( trans.dy() );
56 
57  vec.push_back( trans.zx() );
58  vec.push_back( trans.zy() );
59  vec.push_back( trans.zz() );
60  vec.push_back( trans.dz() );
61  }
62 
64  template <class T>
65  static void vectorToHepTransform3D( const T &vec,
66  HepGeom::Transform3D &trans )
67  {
68  static_cast<SetTransform3D&> (trans).setTransform (
69  vec[0], // xx
70  vec[1], // xy
71  vec[2], // xz
72  vec[3], // dx
73  vec[4], // yx
74  vec[5], // yy
75  vec[6], // yz
76  vec[7], // dy
77  vec[8], // zx
78  vec[9], // zy
79  vec[10], // zz
80  vec[11] ); // dz
81  }
82 
84  template <class T>
85  static void basicVector3DToVector( const T &bvec,
86  std :: vector<double> &vec )
87  {
88  vec.reserve(3);
89  vec.push_back( bvec.x() );
90  vec.push_back( bvec.y() );
91  vec.push_back( bvec.z() );
92  }
93 
94  template <class T>
95  static void vectorToBasicVector3D( const std :: vector<double> &vec,
96  T &bvec )
97  {
98  bvec.setX( vec[0] );
99  bvec.setY( vec[1] );
100  bvec.setZ( vec[2] );
101  }
102 
103  //---------------------------------------------------------------------
104  // Convert CLHEP::HepVector to std vector<double> and vice versa
105  //---------------------------------------------------------------------
106  static void hepVectorToVector( const CLHEP::HepVector &hvec,
107  std :: vector<double> &vec )
108  {
109  vec.reserve(hvec.num_row());
110  for( int i = 0; i < hvec.num_row(); i++ )
111  vec.push_back( hvec[i] );
112  }
113 
114  static void vectorToHepVector( const std :: vector<double> &vec,
115  CLHEP::HepVector &hvec )
116  {
117  for( unsigned i = 0; i < vec.size(); i++ )
118  hvec[i] = vec[i];
119  }
120 };
121 
122 #endif // CLHEP_HELPERS_H
CLHEPHelpers::vectorToHepVector
static void vectorToHepVector(const std ::vector< double > &vec, CLHEP::HepVector &hvec)
Definition: CLHEPHelpers.h:114
CLHEPHelpers::vectorToHepTransform3D
static void vectorToHepTransform3D(const T &vec, HepGeom::Transform3D &trans)
Convert std :: vector<double> to HepGeom::Transform3D.
Definition: CLHEPHelpers.h:65
vec
std::vector< size_t > vec
Definition: CombinationsGeneratorTest.cxx:12
CLHEPHelpers::basicVector3DToVector
static void basicVector3DToVector(const T &bvec, std ::vector< double > &vec)
Convert HepGeom::BasicVector3D<double> to std :: vector<double> and vice versa.
Definition: CLHEPHelpers.h:85
CLHEPHelpers
Definition: CLHEPHelpers.h:38
CLHEPHelpers::vectorToBasicVector3D
static void vectorToBasicVector3D(const std ::vector< double > &vec, T &bvec)
Definition: CLHEPHelpers.h:95
lumiFormat.i
int i
Definition: lumiFormat.py:85
Amg::Transform3D
Eigen::Affine3d Transform3D
Definition: GeoPrimitives.h:46
CLHEPHelpers::hepTransform3DToVector
static void hepTransform3DToVector(const HepGeom::Transform3D &trans, T &vec)
Convert HepGeom::Transform3D to std :: vector<double>
Definition: CLHEPHelpers.h:43
CLHEPHelpers::hepVectorToVector
static void hepVectorToVector(const CLHEP::HepVector &hvec, std ::vector< double > &vec)
Definition: CLHEPHelpers.h:106
TSU::T
unsigned long long T
Definition: L1TopoDataTypes.h:35