GramsSimSensitivity is for gamma-ray sensitivity calculations for the upcoming GRAMS (Gamma Ray and Anti-Matter Survey) experiment. The actual physics simulations of the gamma-rays propagating through the detector is performed by GramsSim. This repository is a wrapper around GramsSim which provides syncrhonization between all of the various condor jobs and scripts of the sensitivity calculation.
While this code is designed to run on the Nevis condor batch farm, it should be possible with some tweaking to run on similar condor farms (the preamble written to the various .cmd files needs to be modified to accomplish this; see the condor script generator for details)
After cloning the repositiory with the command:
git clone https://github.com/mshettyFE/GramsSimSensitivity.git
cd into GramsSimSensitivity
- If you are at Nevis:
- You can set up your enviornment by running:
conda activate /nevis/riverside/share/ms6556/conda/envs/GramsDev
- You can set up your enviornment by running:
- If you are not at Nevis:
- You first need to install conda (see here)
- Run the following commands to download the requisite packages for GramsSim and GramsSimSensitivity
env_name="grams-dev"
conda $env create -f environment.yml
Once everything is done, run the following to activate the enviornment:
conda $env activate
- In order to build GramsSim from source, as well as prepare the
GramsWorkdirectory (which is the folder that gets transferred to the condor batch farms), runconfig.sh:
./config.sh # In GramSimSensitivity directory
- Run
./compile.shin root directory of repository. What this does create abuilddirectory, cd into it, run cmake+make, set up a directory structure, transfer over the files, and then finally, clean up temporary files. - (Side note: this process of building a project in a different directory that the source is called "out of source" building, and is a common paradigm for building with cmake. GramsSim also does this)
- Your final directory structure should look like the following, with GramsSimSensitivity and $WorkDirName on the same level:
.
├── GramSimSensitivity
├── ...
└── $WorkDirName
├── ...
- If you make any changes to the GramsSimSensitivity files, you need to re-run
compile.shso that the changes get mirrored in the build directory!!! - All of the scripts mentioned in Workflow should be run in the $WorkDirName directory.
The overall workflow of the sensitivity calculation is as follows:
- Calculate the effective area of the detector for a given energy and geometry
- Calculate the detector response to a point source of a given energy
- As part of this step, generate a "local" background to the source via the ARM (Angular Resolution Measure) at the given energy
- Calculate the detector response to some isotropic background
- The background follows some power law flux distribution, which is compared to some reference distribution for scaling purposes
- Calculate the differential point source sensitivity at that particular energy
In order to coordinate between the condor job scripts across each subtask, the following script is utilized along with a .toml file.
The script generates .cmd, .sh and .tar.gz files which are needed to specify a condor job for a particular subtasks. The script also ensures that arguments between jobs are compatible with each other (assuming that .toml file doesn't change in the interim time). Arguments are as follows:
- config: The path to the .toml config file
- --Job: What Sub task you want to run: EffectiveArea, Source and Background
- --JobType: What output data you want. "Cones" corresponds to the MC-truth level information for each scatter series, as well as Compton Cone data. "SkyMap" corresponds to the 2D skymap associated with all the Compton cones, as well as the number of cones which fall within the "local background"
- -b: Is used to run the script without any safety prompts. Normally, the script will check if you have the potential to overwrite previously generated root files upon running your condor job and warn you about this possibility. The -b flag just assumes you are aware of this risk and will generate condor jobs anyways.
- The default Config file can be found here.
- See the the full spec for more information on the .toml format
- Feel free to modify as needed. A TOML validator can be found here.
- After running a sucessful job, you can copy the clean up script to the condor output directory and run it to clean up the temporary files.
- For all of these, make sure that you are in the working directory and NOT GramsSimSensitivity. Also, make sure to modify the variables in Configs.toml to your liking PRIOR to running any tasks (changing Configs.toml mid-analysis might create inconsistencies).
- NOTE: Of particular importance is getting the
outputvariable under[General]to point to the correct location. At Nevis, this should point to somedatapartition. In general though, this should point to some directory OTHER than the GramsSimSensitivity or Work directory.
- NOTE: Of particular importance is getting the
Running an effective area calculation consists of the following:
- cd-ing into the
EffAreadirectory - Run the following command:
python3 GenCondorJobs.py Configs.toml --Job EffectiveArea --JobType Cones - Run
condor_submiton the .cmd files that gets generated- You can check the status of the job with
condor_q
- You can check the status of the job with
- Once the batch job is done, run
python3 CalcEffArea.py Configs.toml
To generate the source, do the following:
- cd-ing into the
Sourcedirectory - Run
python3 GenMask.py Configs.toml - Run
python3 GenCondorJobs.py Configs.toml --Job Source --JobType Cones - Run
condor_submiton the .cmd files that gets generated - Once that job is done, run
python3 GenCondorJobs.py Configs.toml --Job Source --JobType SkyMap - Run
condor_submiton the .cmd files that gets generated
To generate the background, do the following:
- cd-ing into the
Backgrounddirectory - Run
python3 GenCondorJobs.py Configs.toml --Job Background --JobType Cones - Run
condor_submiton the .cmd file that gets generated - Once that job is done, run
python3 GenCondorJobs.py Configs.toml --Job Background --JobType SkyMap - Run
condor_submiton the .cmd files that gets generated
- Assuming that you ran all the other scripts, just run the following in the
Sensitivityfolder to calculate the sensitivity:
python CalculateSensitivity.py Configs.toml