/[PAMELA software]/PamVMC/src/PamVMCPrimaryGenerator.cxx~
ViewVC logotype

Contents of /PamVMC/src/PamVMCPrimaryGenerator.cxx~

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.5 - (show annotations) (download)
Fri Jun 12 18:39:32 2009 UTC (16 years, 6 months ago) by pam-rm2
Branch: MAIN
Changes since 1.1: +0 -0 lines
- Introduced user-defined names of output files and random seeds number.
Users can do it use options of PamVMCApplication constructor:
PamVMCApplication(const char* name,  const char *title, const char*
filename="pamtest", Int_t seed=0).
The Random object that I use is TRandom3 object which has astronomical
large period (in case of default initialization 0). All random generators
in the code use this object by calling of gRandom singleton which keeps
it.

- Corrected TOF digitization routine. No problems with TDC hits due to
hadronic interactions anymore.

- Some small changes was done to compile code under Root 5.23. +
geant4_vmc v. 2.6 without any warnings

- Some classes of PamG4RunConfiguartion was changed for geant4_vmc v.
2.6.Some obsolete classes was deleted as soon as developers implemented
regions.

- Navigation was changed from "geomRootToGeant4" to "geomRoot", because on
VMC web page written that as soon as Geant4 has no option ONLY/MANY
translation of overlapped geometry to Geant4 through VGM could be wrong.
I'd like to stay with Root navigation:
http://root.cern.ch/root/vmc/Geant4VMC.html. This should be default
option.

- New Tracker digitization routine written by Sergio was implemented

- PamVMC again became compatible with geant4_vmc v.2.5 and ROOT 5.20.
 The problem was that ROOT developers introduced in TVirtualMC class a new
method SetMagField and new base class:TVirtualMagField from which
user-defined classes shoukd be derived

1 // $Id: PamVMCPrimaryGenerator.cxx,v 1.0 2006/06/03
2 //
3
4 #include <TVirtualMC.h>
5 #include <TVirtualMCStack.h>
6 #include <TPDGCode.h>
7 #include <TDatabasePDG.h>
8 #include <TParticlePDG.h>
9 #include <TVector3.h>
10 #include <TMath.h>
11
12 #include "PamVMCPrimaryGenerator.h"
13
14 ClassImp(PamVMCPrimaryGenerator)
15
16 PamVMCPrimaryGenerator::PamVMCPrimaryGenerator(TVirtualMCStack* stack)
17 : TObject(),
18 fStack(stack),
19 fPdg(kProton),
20 fKinEnergy(100.0),//100 GeV
21 fDirX(0.),
22 fDirY(0.),
23 fDirZ(-1.),
24 fPolAngle(0.),
25 fNofPrimaries(1)
26 {
27 // Standard constructor
28
29 }
30
31 PamVMCPrimaryGenerator::PamVMCPrimaryGenerator()
32 : TObject(),
33 fStack(0),
34 fPdg(0),
35 fKinEnergy(0.),
36 fDirX(0.),
37 fDirY(0.),
38 fDirZ(0.),
39 fPolAngle(0.),
40 fNofPrimaries(0)
41 {
42 // Default constructor
43 }
44
45 PamVMCPrimaryGenerator::~PamVMCPrimaryGenerator()
46 {
47 // Destructor
48 }
49
50 // private methods
51
52 #include <Riostream.h>
53
54 void PamVMCPrimaryGenerator::GeneratePrimary()
55 {
56 // Add one primary particle to the user stack (derived from TVirtualMCStack).
57
58 // Track ID (filled by stack)
59 Int_t ntr;
60
61 // Option: to be tracked
62 Int_t toBeDone = 1;
63
64 // Particle type
65 Int_t pdg = fPdg;
66 TParticlePDG* particlePDG = TDatabasePDG::Instance()->GetParticle(fPdg);
67
68 // Position
69 Double_t vx = 0.;
70 Double_t vy = 0.;
71 Double_t vz = 80.;
72 Double_t tof = 0.;
73
74 // Energy (in GeV)
75 Double_t kinEnergy = fKinEnergy;
76 Double_t mass = particlePDG->Mass();
77 Double_t e = mass + kinEnergy;
78
79 // Particle momentum
80 Double_t p0, px, py, pz;
81 p0 = sqrt(e*e - mass*mass);
82 px = p0 * fDirX;
83 py = p0 * fDirY;
84 pz = p0 * fDirZ;
85
86 // Polarization
87 TVector3 polar;
88 // if ( fPdg == 50000050 ) {
89 // TVector3 normal (1., 0., 0.);
90 // TVector3 kphoton = TVector3(fDirX, fDirY, fDirZ);
91 // TVector3 product = normal.Cross(kphoton);
92 // Double_t modul2 = product*product;
93
94 // TVector3 e_perpend (0., 0., 1.);
95 // if (modul2 > 0.) e_perpend = (1./sqrt(modul2))*product;
96 // TVector3 e_paralle = e_perpend.Cross(kphoton);
97
98 /// polar = TMath::Cos(fPolAngle*TMath::DegToRad())*e_paralle
99 // + TMath::Sin(fPolAngle*TMath::DegToRad())*e_perpend;
100 // }
101 //else
102 // Warning("GeneratePrimary",
103 // "The primary particle is not an opticalphoton");
104
105 // Add particle to stack
106 fStack->PushTrack(toBeDone, -1, pdg, px, py, pz, e, vx, vy, vz, tof,
107 polar.X(), polar.Y(), polar.Z(),
108 kPPrimary, ntr, 1., 0);
109 }
110
111 // public methods
112
113 void PamVMCPrimaryGenerator::GeneratePrimaries()
114 {
115 // Fill the user stack (derived from TVirtualMCStack) with primary particle
116
117 for (Int_t i=0; i<fNofPrimaries; i++) GeneratePrimary();
118 }
119
120 void PamVMCPrimaryGenerator::SetDirection(
121 Double_t dirX, Double_t dirY, Double_t dirZ)
122 {
123 // Set normalized direction
124
125 Double_t norm = TMath::Sqrt(dirX*dirX + dirY*dirY + dirZ*dirZ);
126
127 fDirX = dirX/norm;
128 fDirY = dirY/norm;
129 fDirZ = dirZ/norm;
130 }
131
132

  ViewVC Help
Powered by ViewVC 1.1.23