VMC Examples Version 6.6
Loading...
Searching...
No Matches
PrimaryGenerator.cxx
Go to the documentation of this file.
1//------------------------------------------------
2// The Virtual Monte Carlo examples
3// Copyright (C) 2007 - 2015 Ivana Hrivnacova
4// All rights reserved.
5//
6// For the licensing terms see geant4_vmc/LICENSE.
7// Contact: root-vmc@cern.ch
8//-------------------------------------------------
9
10/// \file TR/src/PrimaryGenerator.cxx
11/// \brief Implementation of the PrimaryGenerator class
12///
13/// Geant4 TestEm10 adapted to Virtual Monte Carlo.
14///
15/// \date 18/12/2015
16/// \author I. Hrivnacova; IPN, Orsay
17
18#include "PrimaryGenerator.h"
19
20#include <TDatabasePDG.h>
21#include <TPDGCode.h>
22#include <TParticlePDG.h>
23#include <TVirtualMC.h>
24#include <TVirtualMCStack.h>
25
26/// \cond CLASSIMP
28 /// \endcond
29
30 namespace VMC
31{
32 namespace TR
33 {
34
35 //_____________________________________________________________________________
37 : TObject(), fStack(stack), fNofPrimaries(1)
38
39 {
40 /// Standard constructor
41 /// \param stack The VMC stack
42 }
43
44 //_____________________________________________________________________________
46 const PrimaryGenerator& origin, TVirtualMCStack* stack)
47 : TObject(origin), fStack(stack), fNofPrimaries(origin.fNofPrimaries)
48 {
49 /// Copy constructor (for clonig on worker thread in MT mode).
50 /// \param origin The source object (on master).
51 /// \param stack The VMC stack
52 }
53
54 //_____________________________________________________________________________
55 PrimaryGenerator::PrimaryGenerator() : TObject(), fStack(0), fNofPrimaries(0)
56 {
57 /// Default constructor
58 }
59
60 //_____________________________________________________________________________
62 {
63 /// Destructor
64 }
65
66 //
67 // private methods
68 //
69
70 //_____________________________________________________________________________
72 {
73 /// Add one primary particle (kElectron) to the user stack
74 /// (derived from TVirtualMCStack).
75
76 // Track ID (filled by stack)
77 Int_t ntr;
78
79 // Option: to be tracked
80 Int_t toBeDone = 1;
81
82 // PDG
83 Int_t pdg = kElectron;
84 // Int_t pdg = kRootino;
85
86 // Polarization
87 Double_t polx = 0.;
88 Double_t poly = 0.;
89 Double_t polz = 0.;
90
91 // Position
92 Double_t vx = 0.;
93 Double_t vy = 0.;
94 Double_t vz = 0.;
95 Double_t tof = 0.;
96
97 // Energy (in GeV)
98 Double_t kinEnergy = 2.;
99 Double_t mass = 0.51099906 * 1e-03;
100 Double_t e = mass + kinEnergy;
101
102 // Particle momentum
103 Double_t px, py, pz;
104 px = 0.;
105 py = 0.;
106 pz = sqrt(e * e - mass * mass);
107
108 // Add particle to stack
109 fStack->PushTrack(toBeDone, -1, pdg, px, py, pz, e, vx, vy, vz, tof, polx,
110 poly, polz, kPPrimary, ntr, 1., 0);
111 }
112
113 //_____________________________________________________________________________
115 {
116 /// Fill the user stack (derived from TVirtualMCStack) with primary
117 /// particles.
118
119 for (Int_t i = 0; i < fNofPrimaries; i++) {
121 }
122 }
123
124 } // namespace TR
125}
The primary generator.
TVirtualMCStack * fStack
VMC stack.
Int_t fNofPrimaries
Number of primary particles.