Take a look at: https://www.cs.rice.edu/~vo9/deeplearning/2019/slides/Rivanna.pdf

Here are the updated instruction of generating Monte Carlo for SpinQuest simulations and analysis

            The jobscript.sh should look like this:

#!/bin/bash

dir_macros=$(dirname $(readlink -f $BASH_SOURCE))
jobname=$1
njobs=$2
nevents=$3
echo "njobs=$njobs"
echo "nevents=$nevents"
work=/scratch/$USER/MC/$jobname
mkdir -p $work
chmod -R 01755 $work
cd $dir_macros

for (( id=1; id<=$njobs; id++ ))
do
mkdir -p $work/$id/
chmod -R 01755 $work/$id
cd $work/$id/
cp $dir_macros/*.C .
cp $dir_macros/*.cfg .
cp $dir_macros/*.txt .
cp $dir_macros/*.slurm .
sed -i "s/1234/$nevents/" Fun4Sim.C
echo "submitting job number = $id"
  sbatch grid.slurm

   Which will submit the job according to the grid.slurm script:

#!/bin/sh
#SBATCH --ntasks=1
#SBATCH --ntasks-per-node=1
#SBATCH --time=6:00:00
#SBATCH --output=slurm.out
#SBATCH --error=slurm.err
#SBATCH --partition=standard
#SBATCH -A spinquest
export DISPLAY=:0.0
root -l Fun4Sim.C
root -l filter.C



Additional Information about changing the Setup

The script that you need to change for any particular configuration is the Fun4Sim.C

Most of this configuration file you will not need to change, but depending on what you want to do here are some pointers

Choice of the Generators: 

This is how you would select what physics generator you want to use (for normal DY or J/Psi use pythia):

  const bool gen_pythia8  = true;
const bool gen_cosmic   = false;
const bool gen_gun      = false;
const bool gen_particle = false;
const bool read_hepmc   = false;
const bool gen_e906legacy = false;

gen_pythia8:

   1. If you want to use Pythia8, you can load the config file using this function. pythia8->set_config_file("phpythia8_DY.cfg") or pythia8->set_config_file("phpythia8_Jpsi.cfg"); depending on your
work.

Generating Single or Multi muons from using the multi particle gun

For making a single  or multiple muons you can use multi particle gun. The portion of the script below can be found on the SimChainDev module. Set the gen_particle true if you would like to generate single muons from multi particle guns. Some user function are available on the doxygen page.

if(gen_particle) {

    PHG4SimpleEventGenerator *genp = new PHG4SimpleEventGenerator("MUP");

  //genp->set_seed(123);
  genp->add_particles("mu+", nmu);  // mu+,e+,proton,pi+,Upsilon
  if (legacyVtxGen) genp->enableLegacyVtxGen();
  else{
  genp->set_vertex_distribution_function(PHG4SimpleEventGenerator::Uniform,
      PHG4SimpleEventGenerator::Uniform,
      PHG4SimpleEventGenerator::Uniform);
  genp->set_vertex_distribution_mean(0.0, 0.0, -300);
  genp->set_vertex_distribution_width(100.0, 100.0, 400.0);
genp->set_vertex_size_function(PHG4SimpleEventGenerator::Uniform); [For Gaussian distributions use "Gaus"]
    genp->set_vertex_size_parameters(0.0, 0.0);

    }

Here you can change the muon to mu+ or mu-, or change the or change the vertex interaction volume, for example this one creates a cylinder 1m radius around the beamline from 700 cm upstream of the dump to 100 cm inside the dump.


To save the accepted tracks/Dimuons: 

If you would like to save only accepted single muon or dimuon, you can use SQGeomAcc.

  /// Save only events that are in the geometric acceptance.
  SQGeomAcc* geom_acc = new SQGeomAcc();
  geom_acc->SetMuonMode(SQGeomAcc::PAIR); // PAIR, PAIR_TBBT, SINGLE, SINGLE_T, etc.
  geom_acc->SetPlaneMode(SQGeomAcc::HODO_CHAM); // HODO, CHAM or HODO_CHAM
  geom_acc->SetNumOfH1EdgeElementsExcluded(4); // Exclude 4 elements at H1 edges
  se->registerSubsystem(geom_acc);


Fun4Sim.C scripts