> For the complete documentation index, see [llms.txt](https://esciencecu-twiki.sc.chula.ac.th/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://esciencecu-twiki.sc.chula.ac.th/slurm/slurm-examples/slurm-cmssw.md).

# CMSSW

Here, an example on how to use CMSSW with the Slurm. We will simulate minimum bias events with CMS Phase-2 detector.

`cmssw_template.slurm`

```bash
#!/bin/tcsh
#
#SBATCH --qos=cu_htc
#SBATCH --partition=cpu
#SBATCH --job-name=cmssw
#SBATCH --output=Log_CMSSW_INPUT1.txt
#SBATCH --nodes=1
#SBATCH --ntasks=1
#SBATCH --time=08:00:00
#SBATCH --cpus-per-task=8
#SBATCH --mem-per-cpu=2G

module purge

#To handle ENV and PATHs
source /work/app/share_env/hepsw.csh
setenv MYCODEDIR /work/home/srimanob/Phase2SW/11_3_Production/CMSSW_11_3_0/src
setenv MYPROJOUTPUT /work/project/cms/srimanob/11_3_0/MinBias
echo "MYCODEDIR = "$MYCODEDIR
echo "TMPDIR = "$TMPDIR

#To run CMSSW program
cd $TMPDIR
cmsrel CMSSW_11_3_0
cd CMSSW_11_3_0/src
eval `scram runtime -csh`
cmsDriver.py MinBias_14TeV_pythia8_TuneCP5_cfi  --mc --conditions auto:phase2_realistic_T21 -n 100 --era Phase2C11M9 --eventcontent RAWSIM -s GEN,SIM --datatier GEN-SIM --beamspot HLLHC14TeV --geometr
y Extended2026D76 --python MinBias_14TeV_pythia8_TuneCP5_2026D76_GenSimHLBeamSpot14.py --nThreads 8 --no_exec --fileout file:minbias.root --customise_commands "from IOMC.RandomEngine.RandomServiceHelp
er import RandomNumberServiceHelper ; randSvc = RandomNumberServiceHelper(process.RandomNumberGeneratorService) ; randSvc.populate() \n process.source.firstLuminosityBlock = cms.untracked.uint32(INPUT
1)"
cmsRun MinBias_14TeV_pythia8_TuneCP5_2026D76_GenSimHLBeamSpot14.py
cp -rf minbias.root $MYPROJOUTPUT/minbias_INPUT1.root
```

Submission script, to submit many jobs with the same driver.

```bash
#!/bin/tcsh

set lhe = 10
while ( $lhe < 18 )
    sed s/INPUT1/$lhe/g cmssw_template.slurm >! cmssw-$lhe.slurm
    sbatch cmssw-$lhe.slurm
    sleep 2s
    rm -rf cmssw-$lhe.slurm
    @ lhe++
end

exit
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://esciencecu-twiki.sc.chula.ac.th/slurm/slurm-examples/slurm-cmssw.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
