Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Riccardo Longo
JZCaPA
Commits
72c4ad76
Commit
72c4ad76
authored
Jan 22, 2022
by
Chad Lantz
Browse files
Added TestBeam2021PrimaryGenerator skeloten to be implemented by Hongbo
parent
8a8dc802
Changes
4
Hide whitespace changes
Inline
Side-by-side
MonteCarlo/include/PrimaryGeneratorAction.hh
View file @
72c4ad76
...
...
@@ -33,6 +33,7 @@
#include "G4VUserPrimaryGeneratorAction.hh"
#include "PrimaryGeneratorMessenger.hh"
#include "TestBeam2021PrimaryGenerator.hh"
#include "G4ParticleGun.hh"
#include "G4IonTable.hh"
#include "globals.hh"
...
...
@@ -85,6 +86,7 @@ class PrimaryGeneratorAction : public G4VUserPrimaryGeneratorAction
private:
G4GeneralParticleSource
*
fParticleGun
;
PrimaryGeneratorMessenger
*
fGeneratorMessenger
;
TestBeam2021PrimaryGenerator
*
fTestBeam2021PrimaryGenerator
;
G4String
fBeamType
;
G4String
fGenInputFile
;
...
...
MonteCarlo/include/TestBeam2021PrimaryGenerator.hh
0 → 100644
View file @
72c4ad76
//
// ********************************************************************
// * License and Disclaimer *
// * *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
/// \file TestBeam2021PrimaryGenerator.hh
/// \brief Definition of the TestBeam2021PrimaryGenerator class
//
//
//
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
#ifndef TestBeam2021PrimaryGenerator_h
#define TestBeam2021PrimaryGenerator_h 1
#include "G4VPrimaryGenerator.hh"
#include "DetectorConstruction.hh"
class
G4Event
;
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
class
TestBeam2021PrimaryGenerator
:
public
G4VPrimaryGenerator
{
public:
TestBeam2021PrimaryGenerator
();
~
TestBeam2021PrimaryGenerator
();
public:
virtual
void
GeneratePrimaryVertex
(
G4Event
*
);
Alignment
m_alignment
;
};
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
#endif
MonteCarlo/src/PrimaryGeneratorAction.cc
View file @
72c4ad76
...
...
@@ -41,7 +41,7 @@
#General beam parameters
- <b>/beam/type</b>
- Set the beam environment. Options are LHC, FNAL
or SPS
- Set the beam environment. Options are LHC, FNAL
, SPS, or TB2021
- <b>/beam/pos</b>
- Set the origin of the beam particles
...
...
@@ -162,6 +162,7 @@ PrimaryGeneratorAction::PrimaryGeneratorAction()
fGeneratorMessenger
=
new
PrimaryGeneratorMessenger
(
this
);
fParticleGun
=
new
G4GeneralParticleSource
();
m_analysisManager
=
AnalysisManager
::
getInstance
();
fTestBeam2021PrimaryGenerator
=
new
TestBeam2021PrimaryGenerator
();
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
...
...
@@ -170,6 +171,7 @@ PrimaryGeneratorAction::~PrimaryGeneratorAction()
{
delete
fGeneratorMessenger
;
delete
fParticleGun
;
delete
fTestBeam2021PrimaryGenerator
;
if
(
INPUT_INITIALIZED
){
eventGenFile
->
Close
();
...
...
@@ -195,6 +197,8 @@ void PrimaryGeneratorAction::GeneratePrimaries(G4Event* anEvent){
GenerateSPSEvent
(
anEvent
);
else
if
(
fBeamType
==
"fnal"
)
GenerateFNALEvent
(
anEvent
);
else
if
(
fBeamType
==
"tb2021"
)
fTestBeam2021PrimaryGenerator
->
GeneratePrimaryVertex
(
anEvent
);
else
{
G4cerr
<<
"
\n
Invalid beam type selection. Aborting event
\n
"
<<
G4endl
;
anEvent
->
SetEventAborted
();
...
...
MonteCarlo/src/TestBeam2021PrimaryGenerator.cc
0 → 100644
View file @
72c4ad76
//
// ********************************************************************
// * License and Disclaimer *
// * *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
/// \file TestBeam2021PrimaryGenerator.cc
/// \brief Implementation of the TestBeam2021PrimaryGenerator1 class
//
//
//
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
#include "TestBeam2021PrimaryGenerator.hh"
#include "G4Event.hh"
#include "G4RunManager.hh"
#include "G4ParticleTable.hh"
#include "G4ParticleDefinition.hh"
#include "G4PrimaryParticle.hh"
#include "G4PrimaryVertex.hh"
#include "G4PhysicalConstants.hh"
#include "G4SystemOfUnits.hh"
#include "Randomize.hh"
#include "G4String.hh"
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
TestBeam2021PrimaryGenerator
::
TestBeam2021PrimaryGenerator
()
:
G4VPrimaryGenerator
()
{
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
TestBeam2021PrimaryGenerator
::~
TestBeam2021PrimaryGenerator
()
{
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void
TestBeam2021PrimaryGenerator
::
GeneratePrimaryVertex
(
G4Event
*
event
)
{
//Get the alignment from DetectorConstruction
DetectorConstruction
*
dC
=
(
DetectorConstruction
*
)
G4RunManager
::
GetRunManager
()
->
GetUserDetectorConstruction
();
if
(
event
->
GetEventID
()
==
0
){
G4String
_inFile
=
(
std
::
string
)
std
::
getenv
(
"JZCaPA"
)
+
"/Utils/Survey_2021.xml"
;
dC
->
LoadAlignmentFile
(
_inFile
.
c_str
()
);
m_alignment
=
dC
->
GetAlignment
();
}
G4cout
<<
"This doesn't do anything yet"
<<
G4endl
;
// // Define the position of the particle
// G4double x = yourRandomDistributionX; //x position
// G4double y = yourRandomDistributionY; //y position
// G4ThreeVector position(x,y,0); //Insert x and y into a vector. Beam will be at zero
// G4double time = 0*s; //Time is always zero for us
// //
// G4PrimaryVertex* vertex = new G4PrimaryVertex(position, time); //Insert the position and time into a primary vertex
//
//
// // A note for Hongbo:
// // I think for now we can use the particle type as defined by the .xml file
// // but for future work it might be good for us to simulate an impure beam.
// // What I've written below should work fine. You just need to worry about x and y above
//
// G4ParticleDefinition* particleDefinition
// = G4ParticleTable::GetParticleTable()->FindParticle(alignment.beam_type.c_str()); //get the particle definition for this beam
// G4PrimaryParticle* particle = new G4PrimaryParticle(particleDefinition); //create a particle with the given definition
// particle->SetMomentumDirection(G4ThreeVector(0,0,1)); //set the momentum to be purely in Z
// particle->SetKineticEnergy(alignment.beam_energy); //get the beam energy from the alignment file
// vertex->SetPrimary(particle); //add the particle to the vertex created above
//
// event->AddPrimaryVertex(vertex); //add the vertex to this event for geant to simulate
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment