This is a modified version of G4MC. In this version the magnetic fields are given according to SNAKE package, fringe fields are also added, apertures are updated (from SIMC), several new volumes are added to simulate a more realistic acceptances. For APEX mode simulations, septum magnet and it's vaccum chambers are also defined.
Magnetic Fields:
Only dipole central field is using fortran code (dipolert2.f) which is a part of the SNAKE package. For the other fields (quads central and fringe fields, dipole fringe field) SNAKE functions are translated to cpp-language and implemented in the G4-codes (a few years ago I found this way more effective, but didn't manage to translate the last part - dipole central field). In the current version the fields are given as global field (by HRSEMField.cc). In old versions the fields were localized in volumes (see HRSEMFieldSetup.cc). This way was not very productive when I added fringe fields and tryed to run simulations with different step sizes, and also monitor the field values on each of the track steps.
Generator:
The initial particle generation is done by "HRSPrimaryGeneratorAction.cc". It uses geant macro input files, while for APEX full simulation, I used root files as input to generate e- e+ pairs... We can modify the particles generation with different ways - depends on what process (particles) you want to generate
Detector:
There are two modes to construct the detector.
- HRS standard mode - where we have vacuum, Q1-quad, Q2 quad, Dipole, Q3-quad
- APEX mode - where we have displaced targets (by about dz=-100 cm), septum magnet with it's vacuum chambers and then the standard HRS spectrometers (Q1, Q2, Dipole, Q3). Switching the septum "ON" in Detector.ini, the APEX mode is built automatically. With "SeptumOn=0" the standard HRS can be used.
- The Sieve slits are defined for APEX mode, but it needs one line modification to place it in the HRS standard mode place. the following parameters (from Detector.ini) are used the most
SetupLSieveSlit=1;
SetupRSieveSlit=0;
sieve_thickness=0.5;
Rad_tail_foil_postn=-104.8;
#if fringe fileds are not needed FringeField=0
FringeField=1;
SeptumOn=1;
SeptumNew=1;
SeptumFieldScale=1.0;
Q1Sos=1;
LFocalPlaneAngle=-45.0
LHRSAngle=12.5;
RHRSAngle=347.5;
The central momentums are defined in HRSUsage.ini
BeamEnergy LHRSMomentum RHRSMomentum BeamTiltedAngle #name list
2200 1500 1500 0.0 #value list
These are the only numbers I changed in HRSUsage.ini
The rest I inherited from old versions and haven't changed (probably most of them are not useful anymore, because of removed modules).
The simulation step size is defined in DetectorConstruction.cc double LarmStepLimit=2.000 * mm;
Simulation Analyses:
I don't use sensitive detectors in my analyses, instead of that I directly analyze track G4Steps (see HRSSteppingAction.cc). I use ASCII output files to write the required information during the simulations. The outputs easily can be changed to root trees, but ASCII files are better when you run several hundreds of parallel jobs and they all write information into the same file simultaneously.
There are a bunch of planes (defined in DetectorConstruction and used in SteppingAction to follow the particles) that I defined and record the track coordinates on these planes. Like "Q1Front", "vdc1Plane", "RSvSlBack" and "LSvSlBack" right and left Sieve back planes I haven't deleted them - may be useful.
How to run:
- Set up geant:
A locally installed geant4 version should be ok.
On ifarm (@JLab)
setenv JLAB_ROOT /site/12gev_phys
source $JLAB_ROOT/softenv.csh 2.0
- Download the package to your local directory
git clone https://github.com/kvardan/APEX_G4MC
- Build:
cd APEX_G4MC
mkdir build
cd build
cmake ..
make
4.Run: After above steps an exacutable "G4MC" will appear in build/ directory
ln -s `pwd`/G4MC ../test/no_sieve_central_target/files_in/G4MC
cd ../test/no_sieve_central_target/run
chmod 744 run_0003.sh
./run_0003.sh
Sometimes it is useful to see the detector visually
You can go to files_in/ directory and type:
./G4MC -i -x 1