geant4-B1-example  1.0
 All Classes Files Functions Variables Pages
B1PrimaryGeneratorAction.hh
Go to the documentation of this file.
1 /// @file B1PrimaryGeneratorAction.hh
2 /// @brief Definition of the B1PrimaryGeneratorAction class
3 
4 #ifndef B1PrimaryGeneratorAction_h
5 #define B1PrimaryGeneratorAction_h 1
6 
7 #include "G4VUserPrimaryGeneratorAction.hh"
8 #include "G4ParticleGun.hh"
9 #include "globals.hh"
10 
11 class G4ParticleGun;
12 class G4Event;
13 class G4Box;
14 
15 /*!
16  @brief to set up the beam.
17 
18  + B1PrimaryGeneratorAction(): set up moving direction, energy for a gamma particle
19  + ~B1PrimaryGeneratorAction(): delete fParticleGun
20  + GeneratePrimaries(): setup the position (via random) for our gamma, and generate
21  primary vertex.
22  + GetParticleGun(): return our gamma beam.
23 
24  in this case: 6MeV gamma, moving toward (0,0,1) direction, <br>
25  and 0.8*width and 0.8*height as the area that the gamma will hit
26 */
27 class B1PrimaryGeneratorAction : public G4VUserPrimaryGeneratorAction // a must
28 {
29  public:
30 
31  B1PrimaryGeneratorAction(); // constructor
32 
33  virtual ~B1PrimaryGeneratorAction(); // destructor
34 
35 
36  // method from the base class ( G4VUserPrimaryGeneratorAction class )
37  // here we replace it according to our need.
38  // ie. 80% of the area.
39  virtual void GeneratePrimaries(G4Event*);
40 
41 
42  // GetParticleGun method is to access particle gun
43  // return type is G4ParticleGun*
44  const G4ParticleGun* GetParticleGun() const { return fParticleGun; }
45 
46 
47 
48 
49  private:
50  G4ParticleGun* fParticleGun;
51  G4Box* fEnvelopeBox;
52 };
53 
54 
55 #endif
virtual void GeneratePrimaries(G4Event *)
setup the gamma's location to get the width and height of the 'Envelope' phyisclogic volume...
B1PrimaryGeneratorAction()
set up our gamma beamIt is 6MeV gamma, moving toward (0,0,1) direction. gamma's location will be se...
const G4ParticleGun * GetParticleGun() const
virtual ~B1PrimaryGeneratorAction()
we must delete the fParticleGun when the B1PrimaryGeneratorAction obj is deleted. ...