Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
Proyecto de Maestria Yessica
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Yessica Dominguez
Proyecto de Maestria Yessica
Commits
5390bc54
Commit
5390bc54
authored
2 years ago
by
Yessica Dominguez
Browse files
Options
Downloads
Patches
Plain Diff
Upload New File
parent
ad0c307a
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
CODE/PrimaryGeneratorAction.cc
+104
-0
104 additions, 0 deletions
CODE/PrimaryGeneratorAction.cc
with
104 additions
and
0 deletions
CODE/PrimaryGeneratorAction.cc
0 → 100644
+
104
−
0
View file @
5390bc54
// Geant4 Libraries
//
#include
"Randomize.hh"
#include
"G4Event.hh"
#include
"G4ParticleGun.hh"
#include
"G4ParticleTable.hh"
#include
"G4ParticleDefinition.hh"
#include
"G4SystemOfUnits.hh"
// Local Libraries
//
#include
"PrimaryGeneratorAction.hh"
#include
"PrimaryGeneratorMessenger.hh"
#include
"G4LogicalVolumeStore.hh"
#include
"G4LogicalVolume.hh"
#include
"G4RunManager.hh"
PrimaryGeneratorAction
::
PrimaryGeneratorAction
()
:
G4VUserPrimaryGeneratorAction
(),
enerPart
(
1.
*
GeV
),
fParticleGun
(
0
),
parPosDir
()
{
//G4cout << "...PrimaryGeneratorAction..." << G4endl;
G4int
n_particle
=
1
;
fParticleGun
=
new
G4ParticleGun
(
n_particle
);
//create a messenger for this class
fGunMessenger
=
new
PrimaryGeneratorMessenger
(
this
);
}
PrimaryGeneratorAction
::~
PrimaryGeneratorAction
()
{
delete
fParticleGun
;
delete
fGunMessenger
;
}
void
PrimaryGeneratorAction
::
GeneratePrimaries
(
G4Event
*
anEvent
)
{
//To include CORSIKA FLUX
parPosDir
.
primaryPosition
();
parPosDir
.
primaryMomento
();
G4ThreeVector
position
=
parPosDir
.
particlePosition
;
G4ThreeVector
direction
=
parPosDir
.
particleDirection
;
G4String
parid
=
parPosDir
.
parId
;
G4ParticleTable
*
particleTable
=
G4ParticleTable
::
GetParticleTable
();
G4ParticleDefinition
*
particle
=
particleTable
->
FindParticle
(
parid
);
fParticleGun
->
SetParticleDefinition
(
particle
);
fParticleGun
->
SetParticlePosition
(
position
);
fParticleGun
->
SetParticleMomentumDirection
(
direction
);
fParticleGun
->
GeneratePrimaryVertex
(
anEvent
);
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void
PrimaryGeneratorAction
::
SetOptPhotonPolar
()
{
G4double
angle
=
G4UniformRand
()
*
360.0
*
deg
;
SetOptPhotonPolar
(
angle
);
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void
PrimaryGeneratorAction
::
SetOptPhotonPolar
(
G4double
angle
)
{
if
(
fParticleGun
->
GetParticleDefinition
()
->
GetParticleName
()
!=
"opticalphoton"
)
{
/*G4cout << "--> warning from PrimaryGeneratorAction::SetOptPhotonPolar() :"
"the particleGun is not an opticalphoton" << G4endl;*/
return
;
}
G4ThreeVector
normal
(
1.
,
0.
,
0.
);
G4ThreeVector
kphoton
=
fParticleGun
->
GetParticleMomentumDirection
();
G4ThreeVector
product
=
normal
.
cross
(
kphoton
);
G4double
modul2
=
product
*
product
;
G4ThreeVector
e_perpend
(
0.
,
0.
,
1.
);
if
(
modul2
>
0.
)
e_perpend
=
(
1.
/
std
::
sqrt
(
modul2
))
*
product
;
G4ThreeVector
e_paralle
=
e_perpend
.
cross
(
kphoton
);
G4ThreeVector
polar
=
std
::
cos
(
angle
)
*
e_paralle
+
std
::
sin
(
angle
)
*
e_perpend
;
fParticleGun
->
SetParticlePolarization
(
polar
);
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment