1 | // |
---|
2 | // ******************************************************************** |
---|
3 | // * License and Disclaimer * |
---|
4 | // * * |
---|
5 | // * The Geant4 software is copyright of the Copyright Holders of * |
---|
6 | // * the Geant4 Collaboration. It is provided under the terms and * |
---|
7 | // * conditions of the Geant4 Software License, included in the file * |
---|
8 | // * LICENSE and available at http://cern.ch/geant4/license . These * |
---|
9 | // * include a list of copyright holders. * |
---|
10 | // * * |
---|
11 | // * Neither the authors of this software system, nor their employing * |
---|
12 | // * institutes,nor the agencies providing financial support for this * |
---|
13 | // * work make any representation or warranty, express or implied, * |
---|
14 | // * regarding this software system or assume any liability for its * |
---|
15 | // * use. Please see the license in the file LICENSE and URL above * |
---|
16 | // * for the full disclaimer and the limitation of liability. * |
---|
17 | // * * |
---|
18 | // * This code implementation is the result of the scientific and * |
---|
19 | // * technical work of the GEANT4 collaboration. * |
---|
20 | // * By using, copying, modifying or distributing the software (or * |
---|
21 | // * any work based on the software) you agree to acknowledge its * |
---|
22 | // * use in resulting scientific publications, and indicate your * |
---|
23 | // * acceptance of all terms of the Geant4 Software license. * |
---|
24 | // ******************************************************************** |
---|
25 | // |
---|
26 | // $Id: FCALPrimaryGeneratorAction.cc,v 1.9 2006/07/21 08:19:33 gcosmo Exp $ |
---|
27 | // GEANT4 tag $Name: $ |
---|
28 | // |
---|
29 | // |
---|
30 | |
---|
31 | //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... |
---|
32 | //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... |
---|
33 | |
---|
34 | #include "FCALPrimaryGeneratorAction.hh" |
---|
35 | |
---|
36 | |
---|
37 | #include "G4Event.hh" |
---|
38 | #include "G4ParticleGun.hh" |
---|
39 | #include "G4ParticleTable.hh" |
---|
40 | #include "G4ParticleDefinition.hh" |
---|
41 | #include "Randomize.hh" |
---|
42 | |
---|
43 | #include <fstream> |
---|
44 | #include <cstdlib> |
---|
45 | //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... |
---|
46 | |
---|
47 | FCALPrimaryGeneratorAction::FCALPrimaryGeneratorAction() |
---|
48 | { |
---|
49 | X = new G4double[5001]; |
---|
50 | Y = new G4double[5001]; |
---|
51 | Z = new G4double[5001]; |
---|
52 | Cos_X = new G4double[5001]; |
---|
53 | Cos_Y = new G4double[5001]; |
---|
54 | Cos_Z = new G4double[5001]; |
---|
55 | |
---|
56 | |
---|
57 | G4int Nparticles = 1; |
---|
58 | particleGun = new G4ParticleGun(Nparticles); |
---|
59 | |
---|
60 | // default Particle |
---|
61 | G4String particleName; |
---|
62 | G4ParticleTable* particleTable = G4ParticleTable::GetParticleTable(); |
---|
63 | G4ParticleDefinition* particle = particleTable->FindParticle(particleName="e+"); |
---|
64 | particleGun->SetParticleDefinition(particle); |
---|
65 | |
---|
66 | |
---|
67 | // default Energy |
---|
68 | particleGun->SetParticleEnergy(80*GeV); |
---|
69 | |
---|
70 | // Read Kinematics from file |
---|
71 | G4int InEvent = 0; |
---|
72 | G4String file_name = "data-tracks/tracks-80GeV.dat"; |
---|
73 | std::ifstream Traks_file(file_name); |
---|
74 | if(!Traks_file) G4cerr << "WARNING: Failed to open file " << file_name << G4endl; |
---|
75 | Traks_file.seekg(0); |
---|
76 | |
---|
77 | while(!(Traks_file.eof())) { |
---|
78 | InEvent++; |
---|
79 | Traks_file >> Ievent >> X[InEvent] >> Y[InEvent] >> Z[InEvent] |
---|
80 | >> Cos_X[InEvent] >> Cos_Y[InEvent] >> Cos_Z[InEvent]; |
---|
81 | }; |
---|
82 | |
---|
83 | Nevent = 2500; |
---|
84 | } |
---|
85 | |
---|
86 | |
---|
87 | //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... |
---|
88 | |
---|
89 | FCALPrimaryGeneratorAction::~FCALPrimaryGeneratorAction() |
---|
90 | { |
---|
91 | delete particleGun; |
---|
92 | delete [] X; |
---|
93 | delete [] Y; |
---|
94 | delete [] Z; |
---|
95 | delete [] Cos_X; |
---|
96 | delete [] Cos_Y; |
---|
97 | delete [] Cos_Z; |
---|
98 | |
---|
99 | } |
---|
100 | |
---|
101 | //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... |
---|
102 | |
---|
103 | void FCALPrimaryGeneratorAction::GeneratePrimaries(G4Event* anEvent) |
---|
104 | { |
---|
105 | //this function is called at the begining of event |
---|
106 | |
---|
107 | Nevent++; |
---|
108 | |
---|
109 | particleGun->SetParticlePosition(G4ThreeVector(X[Nevent]*cm,Y[Nevent]*cm,Z[Nevent]*cm)); |
---|
110 | particleGun->SetParticleMomentumDirection(G4ThreeVector(-Cos_X[Nevent],Cos_Y[Nevent],-Cos_Z[Nevent])); |
---|
111 | |
---|
112 | |
---|
113 | particleGun->GeneratePrimaryVertex(anEvent); |
---|
114 | |
---|
115 | G4cout << "--------------------------------------------" << G4endl; |
---|
116 | G4cout << " Event, X,Y,Z Generated Vertex : " << G4endl; |
---|
117 | G4cout << Nevent << " " << X[Nevent] << " " << Y[Nevent] << " " << Z[Nevent]<< G4endl; |
---|
118 | G4cout << "--------------------------------------------" << G4endl; |
---|
119 | |
---|
120 | |
---|
121 | } |
---|
122 | |
---|
123 | //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... |
---|
124 | |
---|
125 | |
---|