source: trunk/source/processes/hadronic/models/binary_cascade/test/G4ScattererStubTest.cc@ 1201

Last change on this file since 1201 was 1199, checked in by garnier, 16 years ago

nvx fichiers dans CVS

File size: 3.3 KB
Line 
1//
2// ********************************************************************
3// * DISCLAIMER *
4// * *
5// * The following disclaimer summarizes all the specific disclaimers *
6// * of contributors to this software. The specific disclaimers,which *
7// * govern, are listed with their locations in: *
8// * http://cern.ch/geant4/license *
9// * *
10// * Neither the authors of this software system, nor their employing *
11// * institutes,nor the agencies providing financial support for this *
12// * work make any representation or warranty, express or implied, *
13// * regarding this software system or assume any liability for its *
14// * use. *
15// * *
16// * This code implementation is the intellectual property of the *
17// * GEANT4 collaboration. *
18// * By copying, distributing or modifying the Program (or any work *
19// * based on the Program) you indicate your acceptance of this *
20// * statement, and all its terms. *
21// ********************************************************************
22//
23#include "G4ScattererStub.hh"
24#include "G4Proton.hh"
25#include "G4Neutron.hh"
26
27
28int main(int argc, char ** argv)
29{
30 G4int nEvents;
31 if(argc == 2)
32 nEvents = atoi(argv[1]);
33 else
34 {
35 cout << "Input number of events: ";
36 cin >> nEvents;
37 }
38
39 G4ScattererStub scatterer;
40
41 G4ParticleDefinition * proton = G4Proton::Proton();
42 G4ParticleDefinition * neutron = G4Neutron::Neutron();
43 G4double pmass = proton->GetPDGMass();
44 G4double nmass = neutron->GetPDGMass();
45
46 G4ThreeVector pos(0,0,0);
47
48 for(G4int i = 0; i < nEvents; ++i)
49 {
50 G4double p = 1000*MeV*G4UniformRand();
51 G4double theta = 2.0*G4UniformRand()-1.0;
52 theta = acos(theta);
53 G4double phi = G4UniformRand()*2*pi;
54 G4ThreeVector direction(sin(theta)*cos(phi),
55 sin(theta)*sin(phi), cos(theta));
56 G4LorentzVector mom1(p*direction, sqrt(p*p+pmass*pmass));
57 p = 1000*MeV*G4UniformRand();
58 theta = 2.0*G4UniformRand()-1.0;
59 theta = acos(theta);
60 phi = G4UniformRand()*2*pi;
61 G4ThreeVector direction2(sin(theta)*cos(phi), sin(theta)*sin(phi), cos(theta));
62 G4LorentzVector mom2(p*direction2, sqrt(p*p+nmass*nmass));
63
64 G4KineticTrack kt1(proton, 0.0, pos, mom1);
65 G4KineticTrack kt2(proton, 0.0, pos, mom2);
66
67 G4KineticTrackVectorSTL * products = scatterer.Scatter(kt1, kt2);
68 G4KineticTrackVectorSTL::iterator i = products->begin();
69 G4LorentzVector fmom1 = (*i)->Get4Momentum();
70 ++i;
71 G4LorentzVector fmom2 = (*i)->Get4Momentum();
72 G4LorentzVector diff = fmom1+fmom2-mom1-mom2;
73 G4LorentzVector diff1 = fmom1-mom1;
74 G4LorentzVector diff2 = fmom2-mom2;
75 cout << diff1.x() << " " << diff1.y() << " " << diff1.z() << " "
76 << diff1.t() << " "
77 << diff2.x() << " " << diff2.y() << " " << diff2.z() << " "
78 << diff2.t() << " "
79 << diff.x() << " " << diff.y() << " " << diff.z() << " "
80 << diff.t() << " "
81 << fmom1.m() << " " << fmom2.m() << endl;
82 }
83
84
85 return 0;
86}
87
88
89
90
Note: See TracBrowser for help on using the repository browser.