source: trunk/source/processes/hadronic/models/binary_cascade/test/G4AbsorberTest.cc@ 1200

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

nvx fichiers dans CVS

File size: 3.9 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 "globals.hh"
24#include "G4Absorber.hh"
25#include "G4Fancy3DNucleus.hh"
26#include "G4KineticTrackVectorSTL.hh"
27#include "G4ThreeVector.hh"
28#include "G4LorentzVector.hh"
29#include "Randomize.hh"
30#include "G4PionPlus.hh"
31#include "G4LeptonConstructor.hh"
32
33
34G4V3DNucleus * the3DNucleus;
35G4KineticTrackVectorSTL theTargetList;
36
37void BuildTargetList();
38G4ThreeVector GetSpherePoint(G4double r);
39
40int main(int argc, char ** argv)
41{
42 G4LeptonConstructor leptons;
43 leptons.ConstructParticle();
44
45 G4int A, Z;
46 G4int nEvents;
47 if(argc != 4)
48 {
49 cout << "Input A and Z: ";
50 cin >> A >> Z;
51 cout << "Input number of events: ";
52 cin >> nEvents;
53 }
54 else
55 {
56 A = atoi(argv[1]);
57 Z = atoi(argv[2]);
58 nEvents = atoi(argv[3]);
59 }
60
61// create the nucleus
62 the3DNucleus = new G4Fancy3DNucleus;
63 the3DNucleus->Init(A, Z);
64// create theTargetList
65 BuildTargetList();
66// create the pion
67 G4ParticleDefinition * pion = G4PionPlus::PionPlus();
68 G4ThreeVector pos = GetSpherePoint(the3DNucleus->GetOuterRadius());
69 G4double p = 100*MeV;
70 G4double mass = pion->GetPDGMass();
71 G4LorentzVector mom(0, 0, p, sqrt(p*p+mass*mass));
72 G4KineticTrack kt(pion, 0., pos, mom);
73// create the absorber
74 G4double theCutOnP = 150*MeV;
75 G4Absorber absorber(theCutOnP);
76
77 absorber.FindAbsorbers(kt, theTargetList);
78 for(G4int i = 0; i < nEvents; ++i)
79 {
80 absorber.FindProducts(kt);
81 }
82
83 return 0;
84}
85
86
87void BuildTargetList()
88{
89 if(!the3DNucleus->StartLoop())
90 {
91 G4cerr << "G4HadronKineticModel::BuildTargetList(): StartLoop() error!"
92 << G4endl;
93 return;
94 }
95 G4Nucleon * nucleon;
96 G4ParticleDefinition * definition;
97 G4ThreeVector pos;
98 G4LorentzVector mom;
99 while((nucleon = the3DNucleus->GetNextNucleon()) != NULL)
100 {
101 definition = nucleon->GetDefinition();
102 pos = nucleon->GetPosition();
103 mom = nucleon->GetMomentum();
104 G4KineticTrack * kt = new G4KineticTrack(definition, 0., pos, mom);
105 theTargetList.push_back(kt);
106 }
107}
108
109
110G4ThreeVector GetSpherePoint(G4double r)
111{
112// Get the entry point of the projectile, distribuited uniformly
113// on the projection of the surface in the plane ortogonal to the direction
114// of the motion.
115 G4double b = r*G4UniformRand(); // impact parameter
116 G4double phi = G4UniformRand()*2*pi;
117 G4double x = b*cos(phi);
118 G4double y = b*sin(phi);
119 G4double z = -sqrt(r*r-b*b);
120 z *= 1.001; // Get position a little bit out of the sphere...
121 G4ThreeVector point;
122 point.setX(x);
123 point.setY(y);
124 point.setZ(z);
125 return point;
126}
Note: See TracBrowser for help on using the repository browser.