Back to home page

EIC code displayed by LXR

 
 

    


Warning, /tutorial-simulations-using-ddsim-and-geant4/_episodes/02-physics-event-simulations.md is written in an unsupported language. File is not indexed.

0001 ---
0002 title: "Running physics simulations with `ddsim`"
0003 teaching: 30
0004 exercises: 20
0005 questions:
0006 - "How can I simulate events from physics event generators?"
0007 objectives:
0008 - "`ddsim` can simulate HepMC3 events in DD4hep geometries."
0009 - "`npsim` can be used as an alternative for simulations with optical photons."
0010 keypoints:
0011 - "`ddsim` or `npsim` are both able to simulate physics events."
0012 ---
0013 We now move on to running simulations on HepMC3 event input files from (in this case) Pythia8.
0014 
0015 # Using centrally produced input files  
0016 
0017 The large input files for simulation campaigns are stored on S3, but the `eic-shell` environment contains the Minio cient `mc` to access them. We first need to set up our access credentials, though:
0018 ```console
0019 mc config host add S3 https://eics3.sdcc.bnl.gov:9000 $S3_ACCESS_KEY $S3_SECRET_KEY
0020 mc ls S3/eictest/EPIC/Tutorials/pythia8NCDIS_10x100_minQ2=1_beamEffects_xAngle=-0.025_hiDiv.hepmc
0021 ```
0022 
0023 > Note: The values for `$S3_ACCESS_KEY` and `$S3_SECRET_KEY` will be provided in the tutorial, but are not provided here.
0024 {: .callout}
0025 
0026 You will notice that the input file is large (GBs). For this tutorial we only need the first few thousand lines:
0027 ```console
0028 mc head -n 20000 S3/eictest/EPIC/Tutorials/pythia8NCDIS_10x100_minQ2=1_beamEffects_xAngle=-0.025_hiDiv.hepmc > pythia8NCDIS_10x100.hepmc
0029 ```
0030 
0031 We can now specify this HepMC3 input file as input to `ddsim`:
0032 ```console
0033 ddsim --compactFile $DETECTOR_PATH/$DETECTOR_CONFIG.xml --numberOfEvents 10 --inputFiles pythia8NCDIS_10x100.hepmc --outputFile pythia8NCDIS_10x100.edm4hep.root
0034 ```
0035 
0036 Instead of downloading files, we can also request events on-demand from the publicly accessible EIC XRootD server, but in this case we must use the `hepmc3.tree.root` input file extension:
0037 ```console
0038 ddsim --compactFile $DETECTOR_PATH/$DETECTOR_CONFIG.xml --numberOfEvents 10 --inputFiles root://dtn-eic.jlab.org//work/eic2/EPIC/Tutorials/pythia8NCDIS_10x100_minQ2=1_beamEffects_xAngle=-0.025_hiDiv.hepmc3.tree.root --outputFile pythia8NCDIS_10x100.edm4hep.root
0039 ```
0040 > Note: Many files on S3 under the `S3/eictest/EPIC` location are mirrored on XRootD under the `root://dtn-eic.jlab.org//work/eic2/EPIC` location. Note the use of the double slash in this URI!
0041 {: .callout}
0042 
0043 # Creating your own input files
0044 
0045 Rather than relying on the centrally produced events, we can also create events ourselves. This gives us flexibility to run on and off certain event generator effects.
0046 
0047 ## Head-on versus rotated collision frames: the "afterburner"
0048 
0049 In this exercise, we will use Pythia8 to generate DIS neutral current interactions, but we could use other event generators as well. However, we have to pay attention to the reference frames in which interactions are generated. Most event generators are set up to generate events in the head-on collision frame of reference. This is not the reference frame in which beams collide at the EIC: the beams have a crossing angle of -0.025 mrad. In addition, there are beam energy smearing effects that cause the beam energies to deviated from the 'exact' values indicated in the settings: a 10 GeV electron beam contains in reality electrons with energies distributed around 10 GeV. To correct for crossing angle and beam energy smearing, we can modify the event generator or we can apply an "afterburner" which rotates and boosts events from the head-on fram into the correct frame. The afterburner is beyond the scope of this episode, but can be found at [https://github.com/eic/afterburner](https://github.com/eic/afterburner).
0050 
0051 ## Using Pythia8 with crossing angle and beam energy corrections
0052 
0053 Rather than relying on the afterburner, we have modified Pythia8 to include the required corrections directly upon event generation. The steering code and input files can be found at [https://github.com/eic/eicSimuBeamEffects](https://github.com/eic/eicSimuBeamEffects), so we start with using git to obtain this code.
0054 
0055 ```console
0056 git clone https://github.com/eic/eicSimuBeamEffects
0057 ```
0058 
0059 We can compile the code inside the `eic-shell` environment (which includes the Pythia8 event generator libraries that are used by this simulation):
0060 ```console
0061 cd eicSimuBeamEffects/Pythia8
0062 make
0063 ```
0064 After compilation, we can use the executable `runBeamShapeHepMC.exe` to generate events, but we need to provide some arguments:
0065 ```console
0066 $ ./runBeamShapeHepMC.exe
0067 Wrong number of arguments
0068 program.exe steer configuration hadronE leptonE xangle out.hist.root out.hepmc
0069 ```
0070 
0071 The various steering files in `steerFiles` contain various beam conitions. Here we will use the 10 GeV electron on 100 GeV proton conditions in the high beam divergence setting (`hiDiv`), or the steering file `dis_eicBeam_hiDiv_10x100`. The `hiDiv` setting requires the `configuration` flag value `1` (as explained in the `README.md` file).
0072 ```console
0073 ./runBeamShapeHepMC.exe steerFiles/dis_eicBeam_hiDiv_10x100 1 100 10 -0.025 \ 
0074   pythia8NCDIS_10x100_minQ2=1_beamEffects_xAngle=-0.025_hiDiv.hist.root \
0075   pythia8NCDIS_10x100_minQ2=1_beamEffects_xAngle=-0.025_hiDiv.hepmc
0076 ```
0077 
0078 We can now run the output files through the `ddsim` simulation as before.
0079 
0080 # NPSim as an alternative to `ddsim`
0081 
0082 Since some of the options that we pass to `ddsim` can only be provided through a steering file (such as python functions), or are otherwise cumbersome to provide on the command line, we provide `npsim` as a layer on top of `ddsim` that has these options pre-configured. This is as if you would take your steering file options and contribute them back to a central location for others to use them.
0083 
0084 `npsim` can be easily interpreted (since it has sections that look exactly like the steering file). We can look at its python source code, located at `/usr/local/bin/npsim.py` in the `eic-shell` environment.
0085 
0086 Currently `npsim` has the following additional options:
0087 - Cerenkov and optical photon physics are added through a python setup function,
0088 - an optical photon filter is created and added to the DRICH,
0089 - a modified tracking detector action which absorbs optical photon,
0090 - the minimal energy deposition in the tracker is set to zero.
0091 
0092 You can run `npsim` exactly as you would run `ddsim`.
0093 
0094 > Exercise:
0095 > - Rerun the previous Pythia8 simulation with `npsim`, and notice any difference in running time. Because of the addition of optical photon physics, the simulation will run more slowly.
0096 > - Open the output file and verify that more hits (from optical photons with PDG code -22) are stored in the hits branches for the relevant RICH detector.
0097 {: .challenge}
0098