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 - "**`npsim` should be used in almost all regular use cases for ePIC simulations**" 
0013 ---
0014 We now move on to running simulations on HepMC3 event input files from (in this case) Pythia8.
0015 
0016 # Using centrally produced input files  
0017 
0018 The large input files for simulation campaigns are stored on xrootd, but the `eic-shell` environment allows us to access them. We can connect to the server and take a look at the file:
0019 ```console
0020 xrdfs root://dtn-eic.jlab.org
0021 ls /volatile/eic/EPIC/Tutorials/pythia8NCDIS_10x100_minQ2=1_beamEffects_xAngle=-0.025_hiDiv.hepmc
0022 exit
0023 ```
0024 
0025 This input file is large (GBs). For this tutorial we only need the first few thousand lines. We can do this for the first 20000 lines using the following command:
0026 ```console
0027 xrdfs root://dtn-eic.jlab.org cat /volatile/eic/EPIC/Tutorials/pythia8NCDIS_10x100_minQ2=1_beamEffects_xAngle=-0.025_hiDiv.hepmc | head -n 20000 > pythia8NCDIS_10x100.hepmc
0028 ```
0029 
0030 We can now specify this HepMC3 input file as input to `ddsim`:
0031 ```console
0032 ddsim --compactFile $DETECTOR_PATH/$DETECTOR_CONFIG.xml --numberOfEvents 10 --inputFiles pythia8NCDIS_10x100.hepmc --outputFile pythia8NCDIS_10x100.edm4hep.root
0033 ```
0034 
0035 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:
0036 ```console
0037 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
0038 ```
0039 
0040 # Creating your own input files
0041 
0042 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.
0043 
0044 ## Head-on versus rotated collision frames: the "afterburner"
0045 
0046 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).
0047 
0048 ## Using Pythia8 with crossing angle and beam energy corrections
0049 
0050 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.
0051 
0052 ```console
0053 git clone https://github.com/eic/eicSimuBeamEffects
0054 ```
0055 
0056 We can compile the code inside the `eic-shell` environment (which includes the Pythia8 event generator libraries that are used by this simulation):
0057 ```console
0058 cd eicSimuBeamEffects/Pythia8
0059 make
0060 ```
0061 After compilation, we can use the executable `runBeamShapeHepMC.exe` to generate events, but we need to provide some arguments:
0062 ```console
0063 $ ./runBeamShapeHepMC.exe
0064 Wrong number of arguments
0065 program.exe steer configuration hadronE leptonE xangle out.hist.root out.hepmc
0066 ```
0067 
0068 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).
0069 ```console
0070 ./runBeamShapeHepMC.exe steerFiles/dis_eicBeam_hiDiv_10x100 1 100 10 -0.025 \ 
0071   pythia8NCDIS_10x100_minQ2=1_beamEffects_xAngle=-0.025_hiDiv.hist.root \
0072   pythia8NCDIS_10x100_minQ2=1_beamEffects_xAngle=-0.025_hiDiv.hepmc
0073 ```
0074 
0075 We can now run the output files through the `ddsim` simulation as before.
0076 
0077 # NPSim as an alternative to `ddsim`
0078 
0079 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.
0080 
0081 `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 `/opt/local/bin/npsim.py` in the `eic-shell` environment.
0082 
0083 Currently `npsim` has the following additional options:
0084 - Cerenkov and optical photon physics are added through a python setup function,
0085 - an optical photon filter is created and added to the DRICH,
0086 - a modified tracking detector action which absorbs optical photon,
0087 - the minimal energy deposition in the tracker is set to zero.
0088 
0089 You can run `npsim` exactly as you would run `ddsim`.
0090 
0091 > Exercise:
0092 > - 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.
0093 > - 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.
0094 {: .challenge}
0095 
0096 > For most full physics analyses, the use of `npsim` is strongly preferred. The performance of some detector systems, including Cherenkov detectors as mentioned above, will be very different if `ddsim` is used. Similarly, trackers and calorimeters may appear to perform very differently. For some specialist use cases, `ddsim` may be preferred. If you are unsure whether such cases apply, use `npsim` when running your simulations.
0097 {: .callout}
0098