79 if(generatorName==
"tester")
81 G4ParticleTable* particleTable = G4ParticleTable::GetParticleTable();
82 G4ParticleDefinition* particle
83 = particleTable->FindParticle(particleName);
84 particleGun->SetParticleDefinition(particle);
85 particleGun->SetParticlePosition(G4ThreeVector(posX,posY,posZ));
88 for(G4int i=0; i<nParticle; i++)
90 G4double pMag = pMomentum;
92 if(deltaP>0.)pMag = pMomentum - deltaP*(1.0 - 2.0*G4UniformRand());
95 G4double costheta = minCos +(maxCos - minCos)*G4UniformRand();
97 G4double phi = phiStart+(phiEnd-phiStart)*G4UniformRand();
99 G4double sintheta = sqrt(1.-costheta*costheta);
101 G4ParticleMomentum aMomentum;
102 aMomentum[0] = pMag*sintheta*
cos(phi);
103 aMomentum[1] = pMag*sintheta*
sin(phi);
104 aMomentum[2] = pMag*costheta;
106 particleGun->SetParticleMomentum(aMomentum);
107 particleGun->GeneratePrimaryVertex(anEvent);
110 else if(generatorName==
"cosmic")
112 G4cout<<
"generatorName: "<<generatorName<<G4endl;
113 G4ParticleTable* particleTable = G4ParticleTable::GetParticleTable();
114 G4ParticleDefinition* particle
115 = particleTable->FindParticle(particleName);
116 G4cout<<
"particleName: "<<particleName<<G4endl;
118 particleGun->SetParticleDefinition(particle);
119 particleGun->SetParticlePosition(G4ThreeVector(posX,posY,posZ));
131 G4double pMag = h1->GetRandom()*GeV;
132 G4cout<<
"pMag: "<<pMag<<G4endl;
138 G4double theta =(Double_t)h2->GetRandom();
139 G4cout<<
"theta: "<<theta<<G4endl;
140 G4double costheta =
cos(theta);
146 G4double phi = (Double_t)h3->GetRandom();
147 G4cout<<
"phi: "<<phi<<G4endl;
159 G4double sintheta = sqrt(1.-costheta*costheta);
161 G4ParticleMomentum aMomentum;
162 aMomentum[0] = pMag*sintheta*
cos(phi);
163 aMomentum[1] = pMag*sintheta*
sin(phi);
164 aMomentum[2] = pMag*costheta;
166 particleGun->SetParticleMomentum(aMomentum);
167 particleGun->GeneratePrimaryVertex(anEvent);
170 else if(generatorName==
"genbes")
172 G4cout<<
"genbes called"<<G4endl;
176 HEPEvt=
new G4HEPEvtInterface(genbesName);
178 HEPEvt->GeneratePrimaryVertex(anEvent);