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

The primary generator. More...

#include <A01PrimaryGenerator.h>

Inheritance diagram for A01PrimaryGenerator:

Public Member Functions

 A01PrimaryGenerator (TVirtualMCStack *stack)
 
 A01PrimaryGenerator (const A01PrimaryGenerator &origin, TVirtualMCStack *stack)
 
 A01PrimaryGenerator ()
 
virtual ~A01PrimaryGenerator ()
 
virtual void GeneratePrimaries ()
 
void SetNofPrimaries (Int_t nofPrimaries)
 
void SetMomentum (Double_t val)
 
void SetSigmaMomentum (Double_t val)
 
void SetSigmaAngle (Double_t val)
 
void SetRandomize (Bool_t val)
 
Double_t GetMomentum () const
 
Double_t GetSigmaMomentum () const
 
Double_t GetSigmaAngle () const
 
Bool_t GetRandomize () const
 

Private Attributes

TVirtualMCStackfStack
 VMC stack.
 
Int_t fNofPrimaries
 Number of primary particles.
 
Int_t fDefaultParticle
 Default particle PDG.
 
Double_t fMomentum
 Default particle momentum.
 
Double_t fSigmaMomentum
 The sigma of particle momentum.
 
Double_t fSigmaAngle
 The sigma of particle direction.
 
Bool_t fRandomizePrimary
 Option to randomize primary particle type.
 

Detailed Description

The primary generator.

Date
12/05/2012
Author
I. Hrivnacova; IPN, Orsay

Definition at line 33 of file A01PrimaryGenerator.h.

Constructor & Destructor Documentation

◆ A01PrimaryGenerator() [1/3]

A01PrimaryGenerator::A01PrimaryGenerator ( TVirtualMCStack * stack)

Standard constructor

Parameters
stackThe VMC stack

Definition at line 35 of file A01PrimaryGenerator.cxx.

36 : TObject(),
37 fStack(stack),
39 fDefaultParticle(kMuonPlus),
40 fMomentum(1.), // 1 GeV
41 fSigmaMomentum(50.e-03), // 50 MeV;
42 fSigmaAngle(2.), // 2 deg
44{
45 /// Standard constructor
46 /// \param stack The VMC stack
47}
TVirtualMCStack * fStack
VMC stack.
Int_t fNofPrimaries
Number of primary particles.
Double_t fMomentum
Default particle momentum.
Double_t fSigmaAngle
The sigma of particle direction.
Double_t fSigmaMomentum
The sigma of particle momentum.
Bool_t fRandomizePrimary
Option to randomize primary particle type.
Int_t fDefaultParticle
Default particle PDG.

◆ A01PrimaryGenerator() [2/3]

A01PrimaryGenerator::A01PrimaryGenerator ( const A01PrimaryGenerator & 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 50 of file A01PrimaryGenerator.cxx.

52 : TObject(origin),
53 fStack(stack),
56 fMomentum(origin.fMomentum),
60{
61 /// Copy constructor (for clonig on worker thread in MT mode).
62 /// \param origin The source object (on master).
63 /// \param stack The VMC stack
64}

◆ A01PrimaryGenerator() [3/3]

A01PrimaryGenerator::A01PrimaryGenerator ( )

Default constructor

Definition at line 67 of file A01PrimaryGenerator.cxx.

68 : TObject(),
69 fStack(0),
71 fDefaultParticle(kMuonPlus),
72 fMomentum(1.), // 1 GeV
73 fSigmaMomentum(50.e-03), // 50 MeV;
74 fSigmaAngle(2.), // 2 deg
76{
77 /// Default constructor
78}

◆ ~A01PrimaryGenerator()

A01PrimaryGenerator::~A01PrimaryGenerator ( )
virtual

Destructor

Definition at line 81 of file A01PrimaryGenerator.cxx.

82{
83 /// Destructor
84}

Member Function Documentation

◆ GeneratePrimaries()

void A01PrimaryGenerator::GeneratePrimaries ( )
virtual

Fill the user stack (derived from TVirtualMCStack) with primary particles. All primaries in one event have the same properties.

Definition at line 91 of file A01PrimaryGenerator.cxx.

92{
93 /// Fill the user stack (derived from TVirtualMCStack) with primary particles.
94 /// All primaries in one event have the same properties.
95
96 // Track ID (filled by stack)
97 Int_t ntr;
98
99 // Option: to be tracked
100 Int_t toBeDone = 1;
101
102 Int_t pdg = fDefaultParticle;
103 if (fRandomizePrimary) {
104 // Int_t i = (Int_t)(2.*gMC->GetRandom()->Rndm());
105 // Int_t i = (Int_t)(2.*0.3);
106 static Int_t counter = 0;
107 Int_t i = (counter++) % 5;
108 switch (i) {
109 case 0:
110 pdg = kPositron;
111 break;
112 case 1:
113 pdg = kMuonPlus;
114 break;
115 case 2:
116 pdg = kPiPlus;
117 break;
118 case 3:
119 pdg = kKPlus;
120 break;
121 case 4:
122 pdg = kProton;
123 break;
124 default:
125 pdg = kPositron;
126 break;
127 }
128 }
129
130 // Polarization
131 Double_t polx = 0.;
132 Double_t poly = 0.;
133 Double_t polz = 0.;
134
135 // Position
136 Double_t vx = 0;
137 Double_t vy = 0.;
138 Double_t vz = -800.0; //- 8.*m;
139 Double_t tof = 0.;
140
141 // Particle momentum
142 TDatabasePDG* databasePDG = TDatabasePDG::Instance();
143 TParticlePDG* particlePDG = databasePDG->GetParticle(pdg);
144 Double_t mass = particlePDG->Mass();
145 // Double_t pp = fMomentum + (gMC->GetRandom()->Rndm()-0.5)*fSigmaMomentum;
146 Double_t pp = fMomentum + (0.3 - 0.5) * fSigmaMomentum;
147 Double_t e = TMath::Sqrt(pp * pp + mass * mass);
148
149 // Double_t angle = (gMC->GetRandom()->Rndm()-0.5)*fSigmaAngle;
150 Double_t angle = (0.3 - 0.5) * fSigmaAngle;
151 Double_t px, py, pz;
152 px = pp * TMath::Sin(angle * TMath::DegToRad());
153 py = 0.;
154 pz = pp * TMath::Cos(angle * TMath::DegToRad());
155
156 for (Int_t i = 0; i < fNofPrimaries; i++) {
157 // Add particle to stack
158 fStack->PushTrack(toBeDone, -1, pdg, px, py, pz, e, vx, vy, vz, tof, polx,
159 poly, polz, kPPrimary, ntr, 1., 0);
160 }
161}

◆ SetNofPrimaries()

void A01PrimaryGenerator::SetNofPrimaries ( Int_t nofPrimaries)
inline

Set the number of particles to be generated

Parameters
nofPrimariesThe number of particles to be generated

Definition at line 78 of file A01PrimaryGenerator.h.

79{
80 fNofPrimaries = nofPrimaries;
81}

◆ SetMomentum()

void A01PrimaryGenerator::SetMomentum ( Double_t val)
inline

Definition at line 47 of file A01PrimaryGenerator.h.

47{ fMomentum = val; }

◆ SetSigmaMomentum()

void A01PrimaryGenerator::SetSigmaMomentum ( Double_t val)
inline

Definition at line 48 of file A01PrimaryGenerator.h.

48{ fSigmaMomentum = val; }

◆ SetSigmaAngle()

void A01PrimaryGenerator::SetSigmaAngle ( Double_t val)
inline

Definition at line 49 of file A01PrimaryGenerator.h.

49{ fSigmaAngle = val; }

◆ SetRandomize()

void A01PrimaryGenerator::SetRandomize ( Bool_t val)
inline

Definition at line 50 of file A01PrimaryGenerator.h.

50{ fRandomizePrimary = val; }

◆ GetMomentum()

Double_t A01PrimaryGenerator::GetMomentum ( ) const
inline

Definition at line 53 of file A01PrimaryGenerator.h.

53{ return fMomentum; }

◆ GetSigmaMomentum()

Double_t A01PrimaryGenerator::GetSigmaMomentum ( ) const
inline

Definition at line 54 of file A01PrimaryGenerator.h.

54{ return fSigmaMomentum; }

◆ GetSigmaAngle()

Double_t A01PrimaryGenerator::GetSigmaAngle ( ) const
inline

Definition at line 55 of file A01PrimaryGenerator.h.

55{ return fSigmaAngle; }

◆ GetRandomize()

Bool_t A01PrimaryGenerator::GetRandomize ( ) const
inline

Definition at line 56 of file A01PrimaryGenerator.h.

56{ return fRandomizePrimary; }

Member Data Documentation

◆ fStack

TVirtualMCStack* A01PrimaryGenerator::fStack
private

VMC stack.

Definition at line 63 of file A01PrimaryGenerator.h.

◆ fNofPrimaries

Int_t A01PrimaryGenerator::fNofPrimaries
private

Number of primary particles.

Definition at line 64 of file A01PrimaryGenerator.h.

◆ fDefaultParticle

Int_t A01PrimaryGenerator::fDefaultParticle
private

Default particle PDG.

Definition at line 65 of file A01PrimaryGenerator.h.

◆ fMomentum

Double_t A01PrimaryGenerator::fMomentum
private

Default particle momentum.

Definition at line 66 of file A01PrimaryGenerator.h.

◆ fSigmaMomentum

Double_t A01PrimaryGenerator::fSigmaMomentum
private

The sigma of particle momentum.

Definition at line 67 of file A01PrimaryGenerator.h.

◆ fSigmaAngle

Double_t A01PrimaryGenerator::fSigmaAngle
private

The sigma of particle direction.

Definition at line 68 of file A01PrimaryGenerator.h.

◆ fRandomizePrimary

Bool_t A01PrimaryGenerator::fRandomizePrimary
private

Option to randomize primary particle type.

Definition at line 69 of file A01PrimaryGenerator.h.


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