Changeset 1449 for trunk/WuerzburgSoft/Thomas/mphys/MParticle.cc
- Timestamp:
- 07/29/02 09:10:23 (22 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/WuerzburgSoft/Thomas/mphys/MParticle.cc
r1448 r1449 9 9 #include <TRandom.h> 10 10 #include <TMatrixD.h> 11 #include <TRotation.h> 11 12 12 13 ClassImp(MParticle); … … 39 40 const Double_t r = x[0] /pc*ly*1e3; // [m] 40 41 41 const Double_t R = 1./(1 -r*H0/c/2); // [1]42 const Double_t R = 1./(1.-r*H0/c/2); // [1] 42 43 43 44 return R*R - 1; … … 67 68 const Double_t pc = 1./3.258; // [pc/ly] 68 69 69 const Double_t R = c/H0 * 2 * (1 - 1./sqrt(z1)); // [m]70 const Double_t R = c/H0 * 2 * (1. - 1./sqrt(z1)); // [m] 70 71 71 72 return R * pc/ly/1e3; // [kpc] … … 85 86 if (!isloaded) 86 87 { 87 Double_t c = 299792458; // [m/s]88 Double_t e = 1.602176462e-19; // [C]89 Double_t h = 1e-9/e*6.62606876e-34; // [GeVs]90 Double_t hc = h*c; // [GeVm]88 Double_t c = 299792458; // [m/s] 89 Double_t e = 1.602176462e-19; // [C] 90 Double_t h = 1e-9/e*6.62606876e-34; // [GeVs] 91 Double_t hc = h*c; // [GeVm] 91 92 Double_t konst = 4.*TMath::Pi() * 2. / (hc*hc*hc); 92 93 … … 123 124 } 124 125 126 static TAxis &axez = *hist2->GetXaxis(); 127 static TAxis &axee = *hist2->GetYaxis(); 128 125 129 // 126 130 // y = (y1-y0)/(x1-x0) * (x-x0) + y0 … … 129 133 Double_t E = x[0]; 130 134 131 Int_t i = hist2->GetXaxis()->FindFixBin(z);132 Int_t j = hist2->GetYaxis()->FindFixBin(E);133 134 Double_t z1 = hist2->GetXaxis()->GetBinLowEdge(i+1);135 Double_t z0 = hist2->GetXaxis()->GetBinLowEdge(i);136 137 Double_t E1 = hist2->GetYaxis()->GetBinLowEdge(j+1);138 Double_t E0 = hist2->GetYaxis()->GetBinLowEdge(j);135 Int_t i = axez.FindFixBin(z); 136 Int_t j = axee.FindFixBin(E); 137 138 Double_t z1 = axez.GetBinLowEdge(i+1); 139 Double_t z0 = axez.GetBinLowEdge(i); 140 141 Double_t E1 = axee.GetBinLowEdge(j+1); 142 Double_t E0 = axee.GetBinLowEdge(j); 139 143 140 144 Double_t n00 = hist2->GetBinContent(i, j); … … 207 211 void MParticle::InitRandom() 208 212 { 209 static TRandom rnd(0); 210 fPhi = rnd.Uniform(TMath::Pi()*2); 211 fPsi = rnd.Uniform(TMath::Pi()*2); 213 fPhi = gRandom->Uniform(TMath::Pi()*2); 214 fPsi = gRandom->Uniform(TMath::Pi()*2); 212 215 } 213 216 214 217 void MParticle::SetNewDirection(Double_t theta, Double_t phi) 215 218 { 216 TMatrixD B(3, 3); 217 218 B(0, 0) = cos(fTheta)*cos(fPsi); 219 B(1, 0) = cos(fTheta)*sin(fPsi); 220 B(2, 0) = -sin(fTheta); 221 222 B(0, 1) = -sin(fPsi); 223 B(1, 1) = cos(fPsi); 219 static TMatrixD B(3, 3); 220 221 const Double_t ct = cos(fTheta); 222 const Double_t st = sin(fTheta); 223 const Double_t cp = cos(fPsi); 224 const Double_t sp = sin(fPsi); 225 226 /* 227 TRotation B( ct*cp, ct*sp, -st, 228 -sp, cp, 0, 229 st*cp, st*sp, ct); 230 */ 231 232 // first row 233 B(0, 0) = ct*cp; 234 B(1, 0) = ct*sp; 235 B(2, 0) = -st; 236 237 // second row 238 B(0, 1) = -sp; 239 B(1, 1) = cp; 224 240 B(2, 1) = 0; 225 241 226 B(0, 2) = sin(fTheta)*cos(fPsi); 227 B(1, 2) = sin(fTheta)*sin(fPsi); 228 B(2, 2) = cos(fTheta); 229 230 // ------------------------------ 231 232 TVectorD r(3); 233 234 r(0) = sin(theta)*cos(phi); 235 r(1) = sin(theta)*sin(phi); 242 // third row 243 B(0, 2) = st*cp; 244 B(1, 2) = st*sp; 245 B(2, 2) = ct; 246 247 // ------------------------------ 248 249 static TVectorD r(3); 250 251 const Double_t sint = sin(theta); 252 253 /* 254 TVector3 r(sint*cos(phi), sint*sin(phi), cos(theta)); 255 */ 256 257 r(0) = sint*cos(phi); 258 r(1) = sint*sin(phi); 236 259 r(2) = cos(theta); 237 260 … … 253 276 Bool_t rc=kTRUE; 254 277 255 TVectorD x(3); 256 257 x(0) = sin(fTheta)*cos(fPsi); 258 x(1) = sin(fTheta)*sin(fPsi); 259 x(2) = cos(fTheta); 260 261 // ------------------------------ 262 263 const Double_t R = RofZ(&fZ); 264 265 const Double_t dx = R - dr*x(2); 266 278 const Double_t st = sin(fTheta); 279 280 TVector3 d(st*cos(fPsi), st*sin(fPsi), cos(fTheta)); 281 282 // ------------------------------ 283 284 const Double_t R = RofZ(&fZ); 285 const Double_t dx = R - dr*d.z(); 267 286 if (dx < 0) 268 287 { 269 dr = R/ x(2); // R>0 --> x(2)>0288 dr = R/d.z(); // R>0 --> x(2)>0 270 289 rc = kFALSE; 271 290 } 272 else 273 fX += dr*(1.-x(2)); 274 275 x *= dr; 276 277 // ------------------------------ 278 279 TVectorD r(3); 280 281 r(0) = fR*cos(fPhi); 282 r(1) = fR*sin(fPhi); 283 r(2) = R; 284 285 // ------------------------------ 286 287 r -= x; 291 292 fX += dr*(1.-d(2)); 293 d *= dr; 294 295 // ------------------------------ 296 297 TVector3 r(fR*cos(fPhi), fR*sin(fPhi), R); 298 299 r -= d; 300 301 // ------------------------------ 288 302 289 303 if (fR!=0) 290 fPhi = atan2(r(1), r(0)); 291 292 fR = sqrt(r(0)*r(0)+r(1)*r(1)); 304 fPhi = atan2(r.y(), r.x()); 305 fR = sqrt(r.x()*r.x()+r.y()*r.y()); 293 306 fZ = ZofR(&r(2)); 294 307 … … 298 311 Bool_t MParticle::SetNewPosition() 299 312 { 300 static TRandom rand(0); 301 Double_t r = rand.Exp(GetInteractionLength()); 313 Double_t r = gRandom->Exp(GetInteractionLength()); 302 314 return SetNewPosition(r); 303 315 }
Note:
See TracChangeset
for help on using the changeset viewer.