Detector Simulation

Existing Samples

Based on Beamline Simulation

Without noise particles, 64GeV secondary beam, 20 spills with 1M secondary beam particle per spill, B = -0.9T:


With noise particles, 64GeV secondary beam, 20 spills with 1M secondary beam particles per spill, B = -0.9T:



There are files with ~10k particles each in /nova/ana/users/tlackey/testbeam/simfiles. Files with the name <particle>-<momentum>-S19-01-16_SingleGen.root are the output of SingleGen simulation up through ReadoutSim. Files with the name <particle>-<momentum>-S19-01-16_Reco.root have had the majority of reco modules run on them. If you see any issues (i.e. proton file actually has pions instead, missing reco modules, etc.) please let Teresa know. NOTE: All these files were generated with a geometry that did not account for the ~half-cell stagger between planes. New geometry has been created, but I am holding off on recreating all samples until we have numbers from the surveyors and can finalize the geometry.
The SingleGen parameters used to generate these files are below.

 PDG:          [{11,13,211,2212}]       # Particle data group particle code
 P0:           [{0.25,0.5,0.75,1,1.25,1.5,1.75,2}] # Central momentum in GeV
 SigmaP:       [0.2]      # Variation in momentum in GeV (Min for flat, Sigma for gaus option)
 SigmaP2:      [4.0]      # Variation in momentum in GeV (Max for flat option)
 PDist:        [1]        # How to vary momentum (0=uniform, 1=gaussian, 2=genielike)
 X0:           [0.0] # Min central position in cm
 Y0:           [0.0] # Min central position in cm
 Z0:           [0.0] # central position in cm
 T0:           [250000.0] # central time in ns
 SigmaX:       [20.0]   # variation in x in cm (Min for flat, Sigma for gaus option)
 SigmaY:       [20.0]   # variation in y in cm (Min for flat, Sigma for gaus option)
 SigmaZ:       [10.0]      # variation in z in cm (Min for flat, Sigma for gaus option)
 SigmaT:       [10000.0]  # variation in time in ns (Min for flat, Sigma for gaus option)
 SigmaX2:      [200.0]    # variation in x in cm (Max for flat option)
 SigmaY2:      [200.0]    # variation in y in cm (Max for flat option)
 SigmaZ2:      [1275.0]   # variation in z in cm (Max for flat option)
 SigmaT2:      [14005.0]  # variation in time in ns (Max for flat option)
 PosDist:      [1]        # How to vary positions (0=uniform, 1=gaussian, 2=genielike)
 CosZ0:        [1.0] # Central value of cosine theta wrt z-axis
 SigmaCosZ:    [0.25]     # Variation in cosine theta (Min for flat, Sigma for gaus option)
 SigmaCosZ2:   [1.0]      # Variation in cosine theta (Max for flat option)
 CosZDist:     [1]        # How to vary cosine theta (0=uniform, 1=gaussian, 2=genielike)
 PhiXY0:       [0.0] # Central angle in xy plane (degrees)
 SigmaPhiXY:   [-180]     # Variation in phi (degrees) (Min for flat, Sigma for gaus option)
 SigmaPhiXY2:  [180]      # Variation in phi (degrees) (Max for flat option)
 PhiDist:      [0]        # How to vary phi (0=uniform, 1=gaussian, 2=genielike)

See Instructions for Running SingleGen and Reco for more details.


In progress.


 fcl: lackey_testbeam_cry_20181211
 daq: lackey_artdaq_S18-12-10_testbeam_cry_v1
 pclist: lackey_pclist_dev18-12-18_testbeam_cry_v1
 pcliststop: lackey_pcliststop_dev18-12-18_testbeam_cry_v1

Running SingleGen and CRY

Detector simulation can be run through ReadoutSim for both SingleGen and CRY. See DocDB-33782.
Slide 7 has details on what changes need to be made to your fcl to run ReadoutSim for both FEB versions. Any fcl you run for Test Beam (evd.fcl, etc.) will need the following added:

services.RunHistory.DetGainTag: "" 

We now have parameter tables for Test Beam in some of the offline packages, so you can run TestBeam simulation with the following lines in your fcl:

services.Geometry: @local::tb_geo
services.Geometry.ForceUseFCLOnly: true
services.Geometry.GDML: "Geometry/gdml/testbeam-2x2-2block-xtru-vacuum-stagger.gdml" 

Until these parameters are tuned for Test Beam, the simulation result is not guaranteed to be correct.
More details about specific fcl parameters can be found here: Test Beam Detector fcl parameters.

Running MC Using Beamline Simulation Output

In novasoft, EventGenerator/ can be used to generate custom events in a detector. The input is in the form of a text file, listing all the events and particle information for each event. The format is described in EventGenerator/ with examples.

The following script is used to convert the G4beamline output to a text file that the TextFileGen needs:

Here is an example to run it:
python -f /nova/app/users/junting/testbeam/beam/data/g4bl.b_-0.9T.proton.64000.merge_tree.root.job_1_1000.20m.edep.root

The root file above is the output of the beamline simulation described in Beamline Simulation. By default, noises particles are included, and one can use -e option to exclude them. It produces a text file in the same directory as the input root file:

The filename follows the scheme of "text_gen. + file name of the beamline simulation output + .txt". Once the text file input is prepared, this fcl file can be used to run MC jobs:

Without configuring it, the job looks for a file named default.txt as input, for which one can simply create a link:
ln -s text_gen.g4bl.b_-0.9T.proton.64000.merge_tree.root.job_1_1000.20m.edep.root.txt default.txt

Once default.txt is there, one can run:
nova -c job/prodtextgen.testbeam.fcl -n 984

to produce MC samples. Note that "-n 984" in the command above specifies the number of events to be generated. Currently without it the job finishes but does not close the output file properly.

Analyze MC Event

After the MC files are generated, one can run the event display with

nova -c evd.fcl -s mc_event_file.root

To analyze the events, one should write a custom anayzer. An example can be found here:
Copy the files: GNUmakefile, TestBeamAna.fcl,, testbeamanajob.fcl to a directory: "TestBeam"
Check out the RunHistory package with

addpkg_svn -h RunHistory

but copy:
cp /nova/app/users/junting/testbeam/RunHistory/RunHistory.cxx RunHistory/

to your RunHistory directory. This is a hack since we don’t have RunHistory yet.
$SRT_PUBLIC_CONTEXT/SRT_NOVA/scripts/novasoft_build -t

gmake TestBeam.all

Example for running:
nova -c testbeamanajob.fcl -s /nova/app/users/junting/testbeam/det/data/text_gen.g4bl.b_-0.9T.proton.64000.MergedAtstart_linebeam.trigger.root.job_1_10000.200m.shielding_5.full.root