The Particle GUN

 

The ParticleGun is a very simple application using the G4Gun machinery to shoot single particles into the CMS detector. The generation is followed by simulation (OSCAR), digitization, DST creation and a Root tree maker (ORCA). The ParticleKillerGun is a special case where, in the simulation, all particles leaving the tracking volume are killed, i. e., truncated. This is realized by loading a special shared library into OSCAR.

 

Getting Started

In the following we assume that you have set up your environment correctly so that you can work within the cms framework. To do this execute the following lines:

source /afs/fnal.gov/files/code/cms/setup/cshrc uaf
setenv SCRAM_ARCH `scramv1 arch`
Note that the string scramv1 arch is bracketed with the so-called back-quote character - the one in the upper left corner of a standard keyboard.

At this point, we can attend to some preliminaries. This involves checking out some perl scripts and building some libraries, all of which are used later. To get the scripts and build the library which kills the particle once it goes beyond the tracking volume do the following:

cd /uscms_data/d1/$LOGNAME
# Connect up to the lpc CVS repository 
setenv CVSROOT :pserver:anonymous@cdcvs.fnal.gov:/cvs/lpc
# Get the needed scripts
cvs co ParticleGun
# Get the source code for the ParticleKiller library
scram project OSCAR OSCAR_3_6_5
cd OSCAR_3_6_5/src
cvs co OscarApplication
cd OscarApplication/ParticleKiller/src
scram b shared
There should be a flurry of activity after which you should find a file named libParticleKiller.so in the OSCAR_3_6_5/lib/$SCRAM_ARCH/ directory.

We will also need to compile the ExRootAnalysis and ExRootAnalysisReader packages that will allow us to generate and then read the Root tree to do some analysis of the output.

cd /uscms_data/d1/$LOGNAME
scram project ORCA ORCA_8_7_3
cd ORCA_8_7_3/src
eval `scram runtime -csh`
rehash
cmscvsroot ORCA
cvs co -r Tutorial_872 Examples/ExRootAnalysis
cvs co -r Tutorial_872 Examples/ExRootAnalysisReader
cd Examples/ExRootAnalysisReader
scram b shared
eval `scram runtime -csh`
rehash
Again, there should be a flurry of activity after which you should find a file named libExRootAnalysisReader.so in the ORCA_8_7_3/lib/$SCRAM_ARCH/ directory.

N. B. There is another important detail that we should point out here.

Going into the ORCA_8_7_3 directory tree and executing the eval `scram runtime -csh` command, has a subtle but important side effect. Each ORCA release has an internally defined configuration which includes the specification of an accompanying release of Root. For our purposes here, that means that setting up ORCA automatically sets up a compatible Root. You can verify that for yourself by issuing the command which root.exe at this point.

 

Generating the Batch Job Scripts

Next, you need to run the perl scripts you checked out earlier to generate the batch scripts that you will need to run the particle gun jobs.

cd /uscms_data/d1/$LOGNAME
cd ParticleGun
./setup_gun.pl [-h                     |
                -s <OSCAR version>     |
                -r <ORCA Version>      |
                -p <path>              |
                -e <email>             |
                -c <copy command>      |
                -d <destination path>]
Where:
      -h : This help message
      -s : OSCAR version         default: OSCAR_3_6_5
      -r : ORCA version          default: ORCA_8_7_3
      -p : path to top directory default: /uscms_data/d1/$LOGNAME 
      -e : email address         default: $LOGNAME@FNAL.GOV
      -c : copy command          default: /bin/cp
      -d : path to output data   default: /uscms_data/d1/$LOGNAME/particlegun

As you can see setup_gun.pl is a perl script that requires 6 input parameters to tailor the produced scripts to your environment.

This command will create 12 scripts that fall into three groups as follows:

  1. Utility scripts for specific tasks. We will mention these as needed.

  2. Scripts that Condor executes on your behalf in batch mode

  3. Scripts that you submit to the Condor batch system.

The setup_tut.csh script is especially useful immediately since it defines some additional environment variables that make it easier to navigate between directories. These are

 

Running the OSCAR/ORCA Jobs

To submit a job to the batch system issue a command like this:

cd $SCRIPTS
./setup_tut.csh
./ParticleGun_condor.csh 10 1000 50 211 50. 60. 0. 6.283185307 -1.5 1.5
or
cd $SCRIPTS
./setup_tut.csh
./ParticleKillerGun_condor.csh 10 1000 50 211 50. 60. 0. 6.283185307 -1.5 1.5
The first of these runs the ParticleGun jobs, submitting in turn an OSCAR job, an ORCA job to generate the Digis and finally another ORCA job to produce a DST. The second submits the same three jobs (in the same order) and differs only in that it uses the ParticleKillerGun library to terminate track following at the beginning of the EM calorimeter.

Either script will take 10 arguments. They are

  1. The number of processes being requested.
  2. The ID number of the first process.
  3. The number of events required per process.
  4. The ID number of the particle to shoot. Currently the choice is limited to
  5. PTmin      Default value is  10.0
  6. PTmax      Default value is 10.0
  7. PHImin    Default value is    0.0
  8. PHImax    Default value is 2*pi
  9. ETAmin   Default value is  -2.5
  10. ETAmax   Default value is   2.5
Arguments 5 through 10 can be defaulted. In that case they will take on the values shown.

When the ParticleGun (or ParticleKillerGun) job finishes, you should find directories named OSCAR, Digis and DST under $PNFS_PATH if they weren't already there. Each will also have a subdirectory, whose name is determined by your choice of which particle to shoot, according to the following list:

 

Writing A Root Tree

The next step is to write a Root file containing a TTree object that you can subject to whatever level of analysis you need. In principal, this can be done using either the output of the Digis step or the output of the DST step. For reasons that are not yet understood, using the output of the DST step does not work at present so we will fall back to using the output of the Digis step. That is accomplished as follows:

cd $SCRIPTS
./setup_tut.csh
./ExRootDigis_condor.csh 10 1000 50 211
Note that this script requires only four arguments. These are the same as the first four of the 10 you gave to the ParticleGun run. In the same way as the earlier run, this will product a subdirectory of $PNFS_PATH and that subdirectory will be named ExRootDigis. Again, that directory will have a subdirectory with the name of the particle you chose to shoot. Again as before, that directory will contain a set of subdirectories, each corresponding to one of the (in this example) 10 processes you chose to run. Those 10 subdirectories will be named 1000, 1001, ... 1009 since you said that the starting process number was 1000. Each of those directories will contain one Root file, corresponding to the output of one of your 10 processes.

For analysis, it is convenient to gather all of these Root files into one place. There is a script named gather.sh in $SCRIPTS to do that. It requires that you supply one argument, the name of the particle as given in the list above. Beyond that, gather.sh figures out how many processes you chose to run and what ID numbers were used.

The gather.sh script creates a directory structure that is symmetric with the others under $PNFS_PATH. Thus, $PNFS_PATH acquires a subdirectory named ExRootAnalysis. It in turn acquires a subdirectory named after the particle you chose to shoot, and finally, the Root files are all collected there.

 

Analyzing the Resulting Root Tree

In what follows, we will assume that all the data files were generated shooting pi+ so that the operative particle name is pip. To do some simple analysis,

cd $ANALYSIS/pip
cp $SCRIPTS/*.C .
root.exe -l
.x pl_pttr.C++
.q

Nore that it was not necessary to mention the ExRootAnalysisReader library here. All of that is imbedded in the rootlogin.C file that Root always looks at on startup. Putting it there makes sure that the required libraries are always (and automatically) put in the library path list and that you don't have to remember to mention it.

The Root macro pl_pttr.C defines a TChain that includes all of the *.root files in the current directory and, using the ExRootAnalysisReader library you built earlier, makes a pass over that TChain, accumulating a set of histograms and displaying them on the screen. It also writes them out to a file named a1.root.

To have another look at those histograms without having to make another pass over the TChain object,

root.exe -l a1.root
.x plotem.C
In either case, the plot should look like the one below.

 

 

Last updated: Nov. 17, 2005.
This document is maintained by Hans Wenzel (wenzel@fnal.gov) and John Marraffino (marafino@fnal.gov)