VMC Examples
Version 6.6
Loading...
Searching...
No Matches
examples
TR
src
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
27
ClassImp(
VMC::TR::PrimaryGenerator
)
28
/// \endcond
29
30
namespace
VMC
31
{
32
namespace
TR
33
{
34
35
//_____________________________________________________________________________
36
PrimaryGenerator::PrimaryGenerator
(
TVirtualMCStack
* stack)
37
:
TObject
(), fStack(stack), fNofPrimaries(1)
38
39
{
40
/// Standard constructor
41
/// \param stack The VMC stack
42
}
43
44
//_____________________________________________________________________________
45
PrimaryGenerator::PrimaryGenerator
(
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
//_____________________________________________________________________________
61
PrimaryGenerator::~PrimaryGenerator
()
62
{
63
/// Destructor
64
}
65
66
//
67
// private methods
68
//
69
70
//_____________________________________________________________________________
71
void
PrimaryGenerator::GenerateOnePrimary
()
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
//_____________________________________________________________________________
114
void
PrimaryGenerator::GeneratePrimaries
()
115
{
116
/// Fill the user stack (derived from TVirtualMCStack) with primary
117
/// particles.
118
119
for
(Int_t i = 0; i <
fNofPrimaries
; i++) {
120
GenerateOnePrimary
();
121
}
122
}
123
124
}
// namespace TR
125
}
TObject
TVirtualMCStack
VMC::TR::PrimaryGenerator
The primary generator.
Definition
PrimaryGenerator.h:36
VMC::TR::PrimaryGenerator::fStack
TVirtualMCStack * fStack
VMC stack.
Definition
PrimaryGenerator.h:53
VMC::TR::PrimaryGenerator::~PrimaryGenerator
virtual ~PrimaryGenerator()
Definition
PrimaryGenerator.cxx:61
VMC::TR::PrimaryGenerator::GeneratePrimaries
virtual void GeneratePrimaries()
Definition
PrimaryGenerator.cxx:114
VMC::TR::PrimaryGenerator::PrimaryGenerator
PrimaryGenerator()
Definition
PrimaryGenerator.cxx:55
VMC::TR::PrimaryGenerator::GenerateOnePrimary
void GenerateOnePrimary()
Definition
PrimaryGenerator.cxx:71
VMC::TR::PrimaryGenerator::fNofPrimaries
Int_t fNofPrimaries
Number of primary particles.
Definition
PrimaryGenerator.h:54
VMC
Definition
FastSimulation.h:26
Generated on Thu Nov 28 2024 11:31:18 for VMC Examples by
1.12.0