VMC Examples Version 6.6
Loading...
Searching...
No Matches
Ex06PrimaryGenerator Class Reference

The primary generator. More...

#include <Ex06PrimaryGenerator.h>

Inheritance diagram for Ex06PrimaryGenerator:

Public Member Functions

 Ex06PrimaryGenerator (TVirtualMCStack *stack)
 
 Ex06PrimaryGenerator (const Ex06PrimaryGenerator &origin, TVirtualMCStack *stack)
 
 Ex06PrimaryGenerator ()
 
virtual ~Ex06PrimaryGenerator ()
 
void GeneratePrimaries ()
 
void SetParticle (Int_t pdg)
 
void SetKinEnergy (Double_t kinEnergy)
 
void SetDirection (Double_t dirX, Double_t dirY, Double_t dirZ)
 
void SetOptPhotonPolar (Double_t angle)
 
void SetNofPrimaries (Int_t nofPrimaries)
 

Private Member Functions

void GeneratePrimary ()
 

Private Attributes

TVirtualMCStackfStack
 VMC stack.
 
Int_t fPdg
 Particle PDG encoding.
 
Double_t fKinEnergy
 Particle kinetic energy.
 
Double_t fDirX
 Particle direction - x component.
 
Double_t fDirY
 Particle direction - y component.
 
Double_t fDirZ
 Particle direction - z component.
 
Double_t fPolAngle
 Particle polarization angle.
 
Int_t fNofPrimaries
 Number of primary particles.
 

Detailed Description

The primary generator.

Date
16/05/2005
Author
I. Hrivnacova; IPN, Orsay

Definition at line 33 of file Ex06PrimaryGenerator.h.

Constructor & Destructor Documentation

◆ Ex06PrimaryGenerator() [1/3]

Ex06PrimaryGenerator::Ex06PrimaryGenerator ( TVirtualMCStack * stack)

Standard constructor

Parameters
stackThe VMC stack

Definition at line 35 of file Ex06PrimaryGenerator.cxx.

36 : TObject(),
37 fStack(stack),
38 fPdg(kPositron),
39 fKinEnergy(500.e-06),
40 fDirX(1.),
41 fDirY(0.),
42 fDirZ(0.),
43 fPolAngle(0.),
45{
46 /// Standard constructor
47 /// \param stack The VMC stack
48}
Double_t fDirY
Particle direction - y component.
Double_t fDirZ
Particle direction - z component.
TVirtualMCStack * fStack
VMC stack.
Double_t fPolAngle
Particle polarization angle.
Int_t fNofPrimaries
Number of primary particles.
Int_t fPdg
Particle PDG encoding.
Double_t fKinEnergy
Particle kinetic energy.
Double_t fDirX
Particle direction - x component.

◆ Ex06PrimaryGenerator() [2/3]

Ex06PrimaryGenerator::Ex06PrimaryGenerator ( const Ex06PrimaryGenerator & origin,
TVirtualMCStack * stack )

Copy constructor (for clonig on worker thread in MT mode).

Parameters
originThe source object (on master).
stackThe VMC stack

Definition at line 51 of file Ex06PrimaryGenerator.cxx.

53 : TObject(origin),
54 fStack(stack),
55 fPdg(origin.fPdg),
56 fKinEnergy(origin.fKinEnergy),
57 fDirX(origin.fDirX),
58 fDirY(origin.fDirY),
59 fDirZ(origin.fDirZ),
60 fPolAngle(origin.fPolAngle),
62{
63 /// Copy constructor (for clonig on worker thread in MT mode).
64 /// \param origin The source object (on master).
65 /// \param stack The VMC stack
66}

◆ Ex06PrimaryGenerator() [3/3]

Ex06PrimaryGenerator::Ex06PrimaryGenerator ( )

Default constructor

Definition at line 69 of file Ex06PrimaryGenerator.cxx.

70 : TObject(),
71 fStack(0),
72 fPdg(0),
73 fKinEnergy(0.),
74 fDirX(0.),
75 fDirY(0.),
76 fDirZ(0.),
77 fPolAngle(0.),
79{
80 /// Default constructor
81}

◆ ~Ex06PrimaryGenerator()

Ex06PrimaryGenerator::~Ex06PrimaryGenerator ( )
virtual

Destructor

Definition at line 84 of file Ex06PrimaryGenerator.cxx.

85{
86 /// Destructor
87}

Member Function Documentation

◆ GeneratePrimaries()

void Ex06PrimaryGenerator::GeneratePrimaries ( )

Fill the user stack (derived from TVirtualMCStack) with primary particle

Definition at line 158 of file Ex06PrimaryGenerator.cxx.

159{
160 /// Fill the user stack (derived from TVirtualMCStack) with primary particle
161
162 for (Int_t i = 0; i < fNofPrimaries; i++) GeneratePrimary();
163}

◆ SetParticle()

void Ex06PrimaryGenerator::SetParticle ( Int_t pdg)
inline

Set particle type

Parameters
pdgThe new particle PDG encoding

Definition at line 73 of file Ex06PrimaryGenerator.h.

73{ fPdg = pdg; }

◆ SetKinEnergy()

void Ex06PrimaryGenerator::SetKinEnergy ( Double_t kinEnergy)
inline

Set kinetic energy

Parameters
kinEnergyThe new particle kinetic energy (in GeV)

Definition at line 77 of file Ex06PrimaryGenerator.h.

78{
79 fKinEnergy = kinEnergy;
80}

◆ SetDirection()

void Ex06PrimaryGenerator::SetDirection ( Double_t dirX,
Double_t dirY,
Double_t dirZ )

Set normalized direction

Parameters
dirXThe new direction - x component
dirYThe new direction - y component
dirZThe new direction - z component

Definition at line 166 of file Ex06PrimaryGenerator.cxx.

168{
169 /// Set normalized direction
170 /// \param dirX The new direction - x component
171 /// \param dirY The new direction - y component
172 /// \param dirZ The new direction - z component
173
174 Double_t norm = TMath::Sqrt(dirX * dirX + dirY * dirY + dirZ * dirZ);
175
176 fDirX = dirX / norm;
177 fDirY = dirY / norm;
178 fDirZ = dirZ / norm;
179}

◆ SetOptPhotonPolar()

void Ex06PrimaryGenerator::SetOptPhotonPolar ( Double_t angle)
inline

Set photon polarization

Parameters
angleThe new polarization angle (in degrees)

Definition at line 84 of file Ex06PrimaryGenerator.h.

85{
86 fPolAngle = angle;
87}

◆ SetNofPrimaries()

void Ex06PrimaryGenerator::SetNofPrimaries ( Int_t nofPrimaries)
inline

Set the number of particles to be generated

Parameters
nofPrimariesThe number of particles to be generated

Definition at line 91 of file Ex06PrimaryGenerator.h.

92{
93 fNofPrimaries = nofPrimaries;
94}

◆ GeneratePrimary()

void Ex06PrimaryGenerator::GeneratePrimary ( )
private

Add one primary particle to the user stack (derived from TVirtualMCStack).

Definition at line 95 of file Ex06PrimaryGenerator.cxx.

96{
97 /// Add one primary particle to the user stack
98 /// (derived from TVirtualMCStack).
99
100 // Track ID (filled by stack)
101 Int_t ntr;
102
103 // Option: to be tracked
104 Int_t toBeDone = 1;
105
106 // Particle type
107 Int_t pdg = fPdg;
108 TParticlePDG* particlePDG = TDatabasePDG::Instance()->GetParticle(fPdg);
109
110 // Position
111 Double_t vx = 0.;
112 Double_t vy = 0.;
113 Double_t vz = 0.;
114 Double_t tof = 0.;
115
116 // Energy (in GeV)
117 Double_t kinEnergy = fKinEnergy;
118 Double_t mass = particlePDG->Mass();
119 // Double_t mass = 0.51099906*1e-03;
120 Double_t e = mass + kinEnergy;
121
122 // Particle momentum
123 Double_t p0, px, py, pz;
124 p0 = sqrt(e * e - mass * mass);
125 px = p0 * fDirX;
126 py = p0 * fDirY;
127 pz = p0 * fDirZ;
128
129 // Polarization
130 TVector3 polar;
131 if (fPdg == 50000050) {
132 TVector3 normal(1., 0., 0.);
133 TVector3 kphoton = TVector3(fDirX, fDirY, fDirZ);
134 TVector3 product = normal.Cross(kphoton);
135 Double_t modul2 = product * product;
136
137 TVector3 e_perpend(0., 0., 1.);
138 if (modul2 > 0.) e_perpend = (1. / sqrt(modul2)) * product;
139 TVector3 e_paralle = e_perpend.Cross(kphoton);
140
141 polar = TMath::Cos(fPolAngle * TMath::DegToRad()) * e_paralle +
142 TMath::Sin(fPolAngle * TMath::DegToRad()) * e_perpend;
143 }
144 // else
145 // Warning("GeneratePrimary",
146 // "The primary particle is not an opticalphoton");
147
148 // Add particle to stack
149 fStack->PushTrack(toBeDone, -1, pdg, px, py, pz, e, vx, vy, vz, tof,
150 polar.X(), polar.Y(), polar.Z(), kPPrimary, ntr, 1., 0);
151}

Member Data Documentation

◆ fStack

TVirtualMCStack* Ex06PrimaryGenerator::fStack
private

VMC stack.

Definition at line 57 of file Ex06PrimaryGenerator.h.

◆ fPdg

Int_t Ex06PrimaryGenerator::fPdg
private

Particle PDG encoding.

Definition at line 58 of file Ex06PrimaryGenerator.h.

◆ fKinEnergy

Double_t Ex06PrimaryGenerator::fKinEnergy
private

Particle kinetic energy.

Definition at line 59 of file Ex06PrimaryGenerator.h.

◆ fDirX

Double_t Ex06PrimaryGenerator::fDirX
private

Particle direction - x component.

Definition at line 60 of file Ex06PrimaryGenerator.h.

◆ fDirY

Double_t Ex06PrimaryGenerator::fDirY
private

Particle direction - y component.

Definition at line 61 of file Ex06PrimaryGenerator.h.

◆ fDirZ

Double_t Ex06PrimaryGenerator::fDirZ
private

Particle direction - z component.

Definition at line 62 of file Ex06PrimaryGenerator.h.

◆ fPolAngle

Double_t Ex06PrimaryGenerator::fPolAngle
private

Particle polarization angle.

Definition at line 63 of file Ex06PrimaryGenerator.h.

◆ fNofPrimaries

Int_t Ex06PrimaryGenerator::fNofPrimaries
private

Number of primary particles.

Definition at line 64 of file Ex06PrimaryGenerator.h.


The documentation for this class was generated from the following files: