The trick around this is to modify the PYTHIA libraries themselves. In particular we want to modify the PYEVNT subroutine which is run during the generation of each PYTHIA event. Begin by
- Checking out a copy of the pythia libraries from cvs
- Create a back up of pyevnt.F in case anything goes wrong
- Open up pyevnt.F in your favorite text editor
- Rename SUBROUTINE PYEVNT to SUBROUTINE PYEVNT_ORG
- Now create your own subroutine, SUBROUTINE PYEVNT
- Copy the variable declarations and commonblocks from the original PYEVNT
The body of this new subroutine will in general go as the following
while(conditions have not been met)
Call the original PYEVNT
Call any necessary auxillery subroutines
Loop over particles
if(not desired characteristic a) continue
if(not desired characteristic b) continue
...
if(not desired characteristic i) continue
Calculate relevant kinematic variables
Check conditions
Call PYLIST
Note that to avoid too many nested if loops we abort when the first test fails.
For example, consider an analysis requiring a high energy electron in the endcap. The usual PYTHIA settings allow one to require a high energy electron, but there is no way to restrict its location in the detector. So in the above pseudocode becomes
while(no high pT electron in the endcap)
Call the original PYEVNT
Loop over particles
if(not electron) continue
Calculate pT
Calculate eta
if(pT < 15) continue
if(eta < 1) continue
if(eta > 2) continue
return
Call PYLIST
while(no high pT jet in the endcap)
Call the original PYEVNT
Loop over the jets at the end of the PYTHIA record
if(not stable) continue
if(charge not equal +/- 1) continue
if(not hadron or meson) continue
Calculate pT
Calculate eta
if(pT < 15) continue
if(eta < 1) continue
if(eta > 2) continue
return
Call PYLIST
gexec $STAR_LIB/libpythia_6410.so
must be replaced by
gexec /star/u/username/path_to_directory/.slxx_gccxxxx/lib/name_of_new_pythia_library.so
Examples of modified pyevnt.F files for both the electron example and the jet example are attached, as is a kumac for use with the jet example.