# musrSim simulation # ### Contents ### This is the C++ source code for the musrSim simulation software which is intended to be a general tool to design and simulate µSR spectrometer with very high accuracy. To compile and run musrSim, the user must have a recent Geant4 (tested with v11.0.3 and v11.2.0) and Root installed (tested with v6-22-06 and v6-30-02, but the version should not be critical). * The code is specifically tuned to simulate muon spin spectrometers. * The code is maintained by the Laboratory for Muon Spin Spectroscopy at PSI. ### Supported platforms ### * Linux and any other decent OS that can run Root and GEANT4. ### Installation ### Compile and install Geant4, we recommend the use of the following cmake flags cmake -DCMAKE_INSTALL_PREFIX=/path/to/G4installation /path/to/G4source -DGEANT4_USE_QT=ON -DGEANT4_INSTALL_DATA=ON -DGEANT4_USE_OPENGL_X11=ON We also recommend that you use (view3dscene)[https://castle-engine.io/view3dscene.php] as a VRML viewer. Following the installation of Gean4, set the correct environment variables. This can be done easily by editing `/path/to/G4installation/bin/geant4.sh` to uncomment the lines defining Geant4 data location: export G4NEUTRONHPDATA=$GEANT4_DATA_DIR/G4NDL4.7 export G4LEDATA=$GEANT4_DATA_DIR/G4EMLOW8.5 export G4LEVELGAMMADATA=$GEANT4_DATA_DIR/PhotonEvaporation5.7 export G4RADIOACTIVEDATA=$GEANT4_DATA_DIR/RadioactiveDecay5.6 export G4PARTICLEXSDATA=$GEANT4_DATA_DIR/G4PARTICLEXS4.0 export G4PIIDATA=$GEANT4_DATA_DIR/G4PII1.3 export G4REALSURFACEDATA=$GEANT4_DATA_DIR/RealSurface2.2 export G4SAIDXSDATA=$GEANT4_DATA_DIR/G4SAIDDATA2.0 export G4ABLADATA=$GEANT4_DATA_DIR/G4ABLA3.3 export G4INCLDATA=$GEANT4_DATA_DIR/G4INCL1.2 export G4ENSDFSTATEDATA=$GEANT4_DATA_DIR/G4ENSDFSTATE2.3 Then run the following to setup the correct variables . /path/to/G4installation/bin/geant4.sh You will probably need to do that everytime you want to run the simulation or add the line above to your `.bashrc`. Clone the musrSim repository git clone https://zaher-salman@bitbucket.org/zaher-salman/musrsim.git then (see below for RedHat or other old systems) cd musrsim mkdir build cd build cmake ../ make -j8 make install This will install the `musrSim` binary in `/usr/local/bin`, but it can be moved to any other directory in your `PATH`. ### Running the simulations ### Prepare a file, `finlename.mac`, with your beamline and spectrometer design following the instruction in the [musrSim manual](https://bitbucket.org/zaher-salman/musrsim/src/master/doc/musrSim.pdf). Create a folder `data` and then run the simulation musrSim filename.mac ### RedHat and old systems ### For compilation on RedHat systems: * Make sure that the `gcc-toolset-13` package is installed * Use the follwoing compilation command: `scl enable gcc-toolset-13 'make -j8'` * Use `CMakeLists_rhel8.txt`: `cp CMakeLists_rhel8.txt CMakeLists.txt` * If you have Root 6.30 use `FindROOT_6.30.cmake`: `cp FindROOT_6.30.cmake FindROOT.cmake` ### Contact ### Zaher Salman