comparison gcc/testsuite/g++.dg/other/pr60675.C @ 131:84e7813d76e9

gcc-8.2
author mir3636
date Thu, 25 Oct 2018 07:37:49 +0900
parents
children
comparison
equal deleted inserted replaced
111:04ced10e8804 131:84e7813d76e9
1 /* { dg-do compile { target c++11 } } */
2 /* { dg-require-effective-target tls } */
3 /* { dg-require-effective-target fpic } */
4 /* { dg-options "-w -O2 -fPIC" } */
5 namespace CLHEP {
6 static const double meter = 1000.*10;
7 static const double meter2 = meter*meter;
8 static const double megaelectronvolt = 1. ;
9 static const double gigaelectronvolt = 1.e+3;
10 static const double GeV = gigaelectronvolt;
11 static const double megavolt = megaelectronvolt;
12 static const double volt = 1.e-6*megavolt;
13 static const double tesla = volt*1.e+9/meter2;
14 }
15 using CLHEP::GeV;
16 using CLHEP::tesla;
17 namespace std {
18 typedef long int ptrdiff_t;
19 }
20 extern "C" {
21 extern double cos (double __x) throw ();
22 extern double sin (double __x) throw ();
23 extern double sqrt (double __x) throw ();
24 }
25 namespace std __attribute__ ((__visibility__ ("default"))) {
26 using ::cos;
27 using ::sin;
28 using ::sqrt;
29 template<class _CharT> struct char_traits;
30 template<typename _CharT, typename _Traits = char_traits<_CharT> > struct basic_ostream;
31 typedef basic_ostream<char> ostream;
32 template<typename _Iterator> struct iterator_traits { };
33 template<typename _Tp> struct iterator_traits<_Tp*> {
34 typedef ptrdiff_t difference_type;
35 typedef _Tp& reference;
36 };
37 }
38 namespace __gnu_cxx __attribute__ ((__visibility__ ("default"))) {
39 using std::iterator_traits;
40 template<typename _Iterator, typename _Container> struct __normal_iterator {
41 _Iterator _M_current;
42 typedef iterator_traits<_Iterator> __traits_type;
43 typedef typename __traits_type::difference_type difference_type;
44 typedef typename __traits_type::reference reference;
45 explicit __normal_iterator(const _Iterator& __i) : _M_current(__i) { }
46 reference operator*() const {
47 return *_M_current;
48 }
49 __normal_iterator operator+(difference_type __n) const {
50 return __normal_iterator(_M_current + __n);
51 }
52 };
53 template<typename _Tp> struct new_allocator {
54 };
55 }
56 namespace std __attribute__ ((__visibility__ ("default"))) {
57 template<typename _Tp> struct allocator: public __gnu_cxx::new_allocator<_Tp> {
58 };
59 struct ios_base { };
60 template<typename _CharT, typename _Traits> struct basic_ios : public ios_base { };
61 template<typename _CharT, typename _Traits> struct basic_ostream : virtual public basic_ios<_CharT, _Traits> {
62 typedef basic_ostream<_CharT, _Traits> __ostream_type;
63 __ostream_type& operator<<(__ostream_type& (*__pf)(__ostream_type&)) { }
64 __ostream_type& operator<<(const void* __p) {
65 return _M_insert(__p);
66 }
67 template<typename _ValueT> __ostream_type& _M_insert(_ValueT __v);
68 };
69 template<typename _CharT, typename _Traits> inline basic_ostream<_CharT, _Traits>& endl(basic_ostream<_CharT, _Traits>& __os) {
70 }
71 }
72 typedef double G4double;
73 typedef int G4int;
74 extern __thread std::ostream *G4cout_p;
75 struct G4Field;
76 struct G4FieldManager {
77 inline G4Field* GetDetectorField() ;
78 };
79 namespace CLHEP {
80 struct Hep3Vector {
81 Hep3Vector(double x, double y, double z);
82 inline ~Hep3Vector();
83 inline double x() const;
84 inline double y() const;
85 inline double z() const;
86 inline double mag() const;
87 inline Hep3Vector cross(const Hep3Vector &) const;
88 double dx;
89 double dy;
90 double dz;
91 };
92 Hep3Vector operator / (const Hep3Vector &, double a);
93 inline double Hep3Vector::x() const {
94 return dx;
95 }
96 inline double Hep3Vector::y() const {
97 return dy;
98 }
99 inline double Hep3Vector::z() const {
100 return dz;
101 }
102 inline Hep3Vector operator + (const Hep3Vector & a, const Hep3Vector & b) { }
103 inline Hep3Vector operator * (const Hep3Vector & p, double a) { }
104 inline double operator * (const Hep3Vector & a, const Hep3Vector & b) { }
105 inline Hep3Vector::Hep3Vector(double x1, double y1, double z1) : dx(x1), dy(y1), dz(z1) {
106 }
107 inline Hep3Vector::~Hep3Vector() { }
108 inline Hep3Vector Hep3Vector::cross(const Hep3Vector & p) const {
109 return Hep3Vector(dy*p.dz-p.dy*dz, dz*p.dx-p.dz*dx, dx*p.dy-p.dx*dy);
110 }
111 }
112 typedef CLHEP::Hep3Vector G4ThreeVector;
113 namespace std __attribute__ ((__visibility__ ("default"))) {
114 template<typename _Tp, typename _Alloc = std::allocator<_Tp> > struct vector
115 {
116 typedef _Tp *pointer;
117 typedef __gnu_cxx::__normal_iterator<pointer, vector> iterator;
118 iterator begin() { }
119 };
120 }
121 struct G4TransportationManager {
122 static G4TransportationManager* GetTransportationManager();
123 inline G4FieldManager* GetFieldManager() const;
124 };
125 struct G4ErrorMatrix {
126 G4ErrorMatrix(G4int p, G4int q, G4int i);
127 virtual ~G4ErrorMatrix();
128 struct G4ErrorMatrix_row {
129 inline G4ErrorMatrix_row(G4ErrorMatrix&,G4int);
130 G4double & operator[](G4int);
131 G4ErrorMatrix& _a;
132 G4int _r;
133 };
134 inline G4ErrorMatrix_row operator[] (G4int);
135 std::vector<G4double > m;
136 G4int nrow, ncol;
137 };
138 inline G4ErrorMatrix::G4ErrorMatrix_row G4ErrorMatrix::operator[] (G4int r) {
139 G4ErrorMatrix_row b(*this,r);
140 return b;
141 }
142 inline G4double &G4ErrorMatrix::G4ErrorMatrix_row::operator[](G4int c) {
143 return *(_a.m.begin()+_r*_a.ncol+c);
144 }
145 inline G4ErrorMatrix:: G4ErrorMatrix_row::G4ErrorMatrix_row(G4ErrorMatrix&a, G4int r) : _a(a) {
146 _r = r;
147 };
148 struct G4DynamicParticle {
149 G4double GetCharge() const;
150 };
151 struct G4Step;
152 struct G4Track {
153 const G4DynamicParticle* GetDynamicParticle() const;
154 const G4ThreeVector& GetPosition() const;
155 G4ThreeVector GetMomentum() const;
156 const G4Step* GetStep() const;
157 };
158 struct G4StepPoint {
159 const G4ThreeVector& GetPosition() const;
160 G4ThreeVector GetMomentum() const;
161 };
162 struct G4Step {
163 G4StepPoint* GetPreStepPoint() const;
164 G4double GetStepLength() const;
165 };
166 namespace HepGeom {
167 template<class T> struct BasicVector3D {
168 T v_[3];
169 BasicVector3D(T x1, T y1, T z1) { }
170 operator T * () {
171 return v_;
172 }
173 T x() const {
174 return v_[0];
175 }
176 T y() const {
177 return v_[1];
178 }
179 T z() const {
180 return v_[2];
181 }
182 T perp2() const { }
183 T perp() const {
184 return std::sqrt(perp2());
185 }
186 T mag2() const { }
187 T mag() const {
188 return std::sqrt(mag2());
189 }
190 T theta() const { }
191 };
192 inline BasicVector3D<double> operator-(const BasicVector3D<double> & a,const BasicVector3D<double> & b) { }
193 inline BasicVector3D<double> operator*(const BasicVector3D<double> & v, double a) { }
194 template<class T> struct Point3D : public BasicVector3D<T> {
195 explicit Point3D(const double * a) : BasicVector3D<double>(a[0],a[1],a[2]) { }
196 Point3D(const CLHEP::Hep3Vector & v) : BasicVector3D<double>(v.dx,v.dy,v.dz) { }
197 };
198 }
199 typedef HepGeom::Point3D<G4double> G4Point3D;
200 namespace HepGeom {
201 template<class T> struct Vector3D : public BasicVector3D<T> {
202 Vector3D(const BasicVector3D<double> & v) : BasicVector3D<double>(v) { }
203 Vector3D(const CLHEP::Hep3Vector & v) : BasicVector3D<double>(v.dx,v.dy,v.dz) { }
204 operator CLHEP::Hep3Vector () const { }
205 };
206 }
207 typedef HepGeom::Vector3D<G4double> G4Vector3D;
208 struct G4ErrorFreeTrajState
209 {
210 virtual G4int PropagateError( const G4Track* aTrack );
211 G4int PropagateErrorMSC( const G4Track* aTrack );
212 };
213 G4int G4ErrorFreeTrajState::PropagateError( const G4Track* aTrack ) {
214 G4double stepLengthCm = aTrack->GetStep()->GetStepLength()/10.;
215 G4Point3D vposPost = aTrack->GetPosition()/10.;
216 G4Vector3D vpPost = aTrack->GetMomentum()/GeV;
217 G4Point3D vposPre = aTrack->GetStep()->GetPreStepPoint()->GetPosition()/10.;
218 G4Vector3D vpPre = aTrack->GetStep()->GetPreStepPoint()->GetMomentum()/GeV;
219 G4double pPre = vpPre.mag();
220 G4double pPost = vpPost.mag();
221 G4double pInvPre = 1./pPre;
222 G4double pInvPost = 1./pPost;
223 G4double deltaPInv = pInvPost - pInvPre;
224 G4Vector3D vpPreNorm = vpPre * pInvPre;
225 G4Vector3D vpPostNorm = vpPost * pInvPost;
226 (*G4cout_p) << "G4EP: vpPreNorm " << vpPreNorm << " vpPostNorm " << vpPostNorm << std::endl;
227 G4double sinpPre = std::sin( vpPreNorm.theta() );
228 G4double sinpPostInv = 1./std::sin( vpPreNorm.theta() );
229 G4ErrorMatrix transf(5, 5, 0 );
230 G4double charge = aTrack->GetDynamicParticle()->GetCharge();
231 G4double h1[3], h2[3];
232 G4Field* field
233 = G4TransportationManager::GetTransportationManager()->GetFieldManager()->GetDetectorField()
234 ;
235 if( charge != 0. && field )
236 {
237 G4ThreeVector HPre = G4ThreeVector( h1[0], h1[1], h1[2] ) / tesla *10.;
238 G4ThreeVector HPost= G4ThreeVector( h2[0], h2[1], h2[2] ) / tesla *10.;
239 {
240 G4double pInvAver = 1./(pInvPre + pInvPost );
241 G4double CFACT8 = 2.997925E-4;
242 G4ThreeVector vHAverNorm( (HPre*pInvPre + HPost*pInvPost ) * pInvAver * charge * CFACT8 );
243 G4double HAver = vHAverNorm.mag();
244 G4double pAver = (pPre+pPost)*0.5;
245 G4double QAver = -HAver/pAver;
246 G4double thetaAver = QAver * stepLengthCm;
247 G4double sinThetaAver = std::sin(thetaAver);
248 G4double cosThetaAver = std::cos(thetaAver);
249 G4double gamma = vHAverNorm * vpPostNorm;
250 G4ThreeVector AN2 = vHAverNorm.cross( vpPostNorm );
251 G4double AU = 1./vpPreNorm.perp();
252 G4ThreeVector vUPre( -AU*vpPreNorm.y(), AU*vpPreNorm.x(), 0. );
253 G4ThreeVector vVPre( -vpPreNorm.z()*vUPre.y(), vpPreNorm.z()*vUPre.x(), vpPreNorm.x()*vUPre.y() - vpPreNorm.y()*vUPre.x() );
254 AU = 1./vpPostNorm.perp();
255 G4ThreeVector vUPost( -AU*vpPostNorm.y(), AU*vpPostNorm.x(), 0. );
256 G4ThreeVector vVPost( -vpPostNorm.z()*vUPost.y(), vpPostNorm.z()*vUPost.x(), vpPostNorm.x()*vUPost.y() - vpPostNorm.y()*vUPost.x() );
257 G4Point3D deltaPos( vposPre - vposPost );
258 G4double QP = QAver * pAver;
259 G4double ANV = -( vHAverNorm.x()*vUPost.x() + vHAverNorm.y()*vUPost.y() );
260 G4double ANU = ( vHAverNorm.x()*vVPost.x() + vHAverNorm.y()*vVPost.y() + vHAverNorm.z()*vVPost.z() );
261 G4double OMcosThetaAver = 1. - cosThetaAver;
262 G4double TMSINT = thetaAver - sinThetaAver;
263 G4ThreeVector vHUPre( -vHAverNorm.z() * vUPre.y(), vHAverNorm.z() * vUPre.x(), vHAverNorm.x() * vUPre.y() - vHAverNorm.y() * vUPre.x() );
264 G4ThreeVector vHVPre( vHAverNorm.y() * vVPre.z() - vHAverNorm.z() * vVPre.y(), vHAverNorm.z() * vVPre.x() - vHAverNorm.x() * vVPre.z(), vHAverNorm.x() * vVPre.y() - vHAverNorm.y() * vVPre.x() );
265 transf[0][1] = -deltaPInv/thetaAver* ( TMSINT*gamma*(vHAverNorm.x()*vVPre.x()+vHAverNorm.y()*vVPre.y()+vHAverNorm.z()*vVPre.z()) + sinThetaAver*(vVPre.x()*vpPostNorm.x()+vVPre.y()*vpPostNorm.y()+vVPre.z()*vpPostNorm.z()) + OMcosThetaAver*(vHVPre.x()*vpPostNorm.x()+vHVPre.y()*vpPostNorm.y()+vHVPre.z()*vpPostNorm.z()) );
266 transf[0][2] = -sinpPre*deltaPInv/thetaAver* ( TMSINT*gamma*(vHAverNorm.x()*vUPre.x()+vHAverNorm.y()*vUPre.y() ) + sinThetaAver*(vUPre.x()*vpPostNorm.x()+vUPre.y()*vpPostNorm.y() ) + OMcosThetaAver*(vHUPre.x()*vpPostNorm.x()+vHUPre.y()*vpPostNorm.y()+vHUPre.z()*vpPostNorm.z()) );
267 transf[0][3] = -deltaPInv/stepLengthCm*(vUPre.x()*vpPostNorm.x()+vUPre.y()*vpPostNorm.y() );
268 transf[1][1] = cosThetaAver*(vVPre.x()*vVPost.x()+vVPre.y()*vVPost.y()+vVPre.z()*vVPost.z()) + sinThetaAver*(vHVPre.x()*vVPost.x()+vHVPre.y()*vVPost.y()+vHVPre.z()*vVPost.z()) + OMcosThetaAver*(vHAverNorm.x()*vVPre.x()+vHAverNorm.y()*vVPre.y()+vHAverNorm.z()*vVPre.z())* (vHAverNorm.x()*vVPost.x()+vHAverNorm.y()*vVPost.y()+vHAverNorm.z()*vVPost.z()) + ANV*( -sinThetaAver*(vVPre.x()*vpPostNorm.x()+vVPre.y()*vpPostNorm.y()+vVPre.z()*vpPostNorm.z()) + OMcosThetaAver*(vVPre.x()*AN2.x()+vVPre.y()*AN2.y()+vVPre.z()*AN2.z()) - TMSINT*gamma*(vHAverNorm.x()*vVPre.x()+vHAverNorm.y()*vVPre.y()+vHAverNorm.z()*vVPre.z()) );
269 transf[1][2] = cosThetaAver*(vUPre.x()*vVPost.x()+vUPre.y()*vVPost.y() ) + sinThetaAver*(vHUPre.x()*vVPost.x()+vHUPre.y()*vVPost.y()+vHUPre.z()*vVPost.z()) + OMcosThetaAver*(vHAverNorm.x()*vUPre.x()+vHAverNorm.y()*vUPre.y() )* (vHAverNorm.x()*vVPost.x()+vHAverNorm.y()*vVPost.y()+vHAverNorm.z()*vVPost.z()) + ANV*( -sinThetaAver*(vUPre.x()*vpPostNorm.x()+vUPre.y()*vpPostNorm.y() ) + OMcosThetaAver*(vUPre.x()*AN2.x()+vUPre.y()*AN2.y() ) - TMSINT*gamma*(vHAverNorm.x()*vUPre.x()+vHAverNorm.y()*vUPre.y() ) );
270 transf[2][0] = -QP*ANU*(vpPostNorm.x()*deltaPos.x()+vpPostNorm.y()*deltaPos.y()+vpPostNorm.z()*deltaPos.z())*sinpPostInv *(1.+deltaPInv*pAver);
271 transf[2][3] = -QAver*ANU*(vUPre.x()*vpPostNorm.x()+vUPre.y()*vpPostNorm.y() )*sinpPostInv;
272 transf[3][4] = (vVPre.x()*vUPost.x()+vVPre.y()*vUPost.y() );
273 transf[4][0] = pAver*(vVPost.x()*deltaPos.x()+vVPost.y()*deltaPos.y()+vVPost.z()*deltaPos.z()) *(1.+deltaPInv*pAver);
274 transf[4][1] = ( sinThetaAver*(vVPre.x()*vVPost.x()+vVPre.y()*vVPost.y()+vVPre.z()*vVPost.z()) + OMcosThetaAver*(vHVPre.x()*vVPost.x()+vHVPre.y()*vVPost.y()+vHVPre.z()*vVPost.z()) + TMSINT*(vHAverNorm.x()*vVPost.x()+vHAverNorm.y()*vVPost.y()+vHAverNorm.z()*vVPost.z())* (vHAverNorm.x()*vVPre.x()+vHAverNorm.y()*vVPre.y()+vHAverNorm.z()*vVPre.z()) )/QAver;
275 transf[4][2] = ( sinThetaAver*(vUPre.x()*vVPost.x()+vUPre.y()*vVPost.y() ) + OMcosThetaAver*(vHUPre.x()*vVPost.x()+vHUPre.y()*vVPost.y()+vHUPre.z()*vVPost.z()) + TMSINT*(vHAverNorm.x()*vVPost.x()+vHAverNorm.y()*vVPost.y()+vHAverNorm.z()*vVPost.z())* (vHAverNorm.x()*vUPre.x()+vHAverNorm.y()*vUPre.y() ) )*sinpPre/QAver;
276 }
277 }
278 PropagateErrorMSC( aTrack );
279 }