GlueX Simulation Richard Jones Parallelism in Experimental Nuclear Physics Workshop January 6-7, 2011 Christopher Newport University Newport News, VA
Jan 11, 2016
GlueX Simulation
Richard JonesParallelism in Experimental Nuclear Physics WorkshopJanuary 6-7, 2011Christopher Newport UniversityNewport News, VA
Richard Jones Parallelism in Experimental Nuclear Physics Workshop, Jan. 6-7, 2011, Newport News, VA
2
Outline
simulation tools browsing the hits browsing the geometry getting under the hood
Richard Jones Parallelism in Experimental Nuclear Physics Workshop, Jan. 6-7, 2011, Newport News, VA
3
Simulation tools
event generator
hdgeant
mcsmear
event analyser
prescription log
log
histos
log
prescription
parameters
parameters
Richard Jones Parallelism in Experimental Nuclear Physics Workshop, Jan. 6-7, 2011, Newport News, VA
4
running hdgeant very simple interface: $ hdgeant$ hdgeant reads prescription, parameters from: ./control.incontrol.in
+ many more parameters: see distribution control.in
C a very simple control.in exampleINFILE 'rhop.hddm‘OUTFILE 'hdgeant.out'TRIG 1000
Richard Jones Parallelism in Experimental Nuclear Physics Workshop, Jan. 6-7, 2011, Newport News, VA
5
running hdgeantc This is the control file for the GEANT simulation. Parameters definedc in this file control the kind and extent of simulation that is performed.c The full list of options is given in section BASE-40 of the GEANT manual.cc In addition, some new cards have been defined to set up the input sourcec for the simulation. Three kinds of simulation runs are available, selectedc by which of the following three "cards" are present below.c 1. Input from Monte Carlo generator (card INFILE)c 2. Built-in coherent bremsstrahlung source (card BEAM)c 3. Built-in single-track event generator (card KINE)c The order of the list is significant, that is if INFILE is present then thec BEAM and KINE cards are ignored, otherwise if BEAM is present then KINE isc ignored. For example, the 3-card sequence:c INFILE 'phi-1680.hddm'c SKIP 25c TRIG 100c instructs HDGeant to open ./phi-1680.hddm, skip the first 25 events and thenc process the following 100 input events and stop. If the end of the file isc reached before the event count specified in card TRIG is exhausted then thec processing will stop at the end of file.cINFILE 'rhop.hddm'TRIG 1000
c The BEAM card configures the built-in coherent bremsstralung photonc beam generator in HDGeant. If the INFILE card is not present and BEAMc is specified, the internal coherent bremsstralung generator is the primaryc source of events for the simulation. If INFILE is specified, the primaryc event source is the external Monte Carlo generator that produced the file,c but the BEAM card may still be present, and it is needed if beam-relatedc backgrounds are being superimposed on top of the primary event signals,c as requested with the BGRATE card (see below). The beam card acceptsc the following three parameters.c Emax - end-point energy of the electron beam (GeV)c Epeak - energy of the primary coherent peak edge (GeV)c Emin - minimum energy of the coherent bremsstrahlung beam (GeV)c Omitting the final parameter Emin results in the default value being used.BEAM 12. 9.
c Commenting out the following line will disable simulated hits output.OUTFILE 'hdgeant.hddm'
c The following are used to automatically invoke the mcsmear programc to do the final stage digitization of hits after the simulationc stage is complete. This simply invokes the mcsmear program passingc it any optional arguments supplied here and then optionally deletesc the OUTFILE specified above leaving only the smeared file. This stagec can be invoked by hand afterwards, but having it done automaticallyc here allows hdgeant and mcsmear to function as though it were a singlec program. The specific keys are as follows.cc POSTSMEAR - set this 1 to auto-invoke the mcsmear program and 0 to notc DELETEUNSMEARED - set this to 1 to delete the OUTFILE after running mcsmearc MCSMEAROPTS - String to specify additional arguments to pass to mcsmearPOSTSMEAR 0DELETEUNSMEARED 0c MCSMEAROPTS '-t1000 -d0'
c The following card enables single-track generation (for testing).c For a single-particle gun, set the momentum (GeV/c), directionc theta,phi (degrees) and vertex position (cm), and for the particlec type insert the Geant particle type code plus 100 (eg. 101=gamma,c 103=electron, 107=pi0, 108=pi+, 109=pi-, 114=proton). If you usec the particle code but do not add 100 then theta,phi are ignoredc and the particle direction is generated randomly over 4pi sr.c For a listing of the Geant particle types, see the following URL.c http://wwwasdoc.web.cern.ch/wwwasdoc/geant_html3/node72.htmlc The meaning of the arguments to KINE are as follows.c - particle = GEANT particle type of primary track + 100c - momentum = initial track momentum, central value (GeV/c)c - theta = initial track polar angle, central value (degrees)c - phi = initial track azimuthal angle, central value (degrees)c - delta_momentum = spread in initial track momentum, full width (GeV/c)c - delta_theta = spread in initial track polar angle, full width (degrees)c - delta_phi = spread in initial track azimuthal angle, full width (degrees)cc If you do explicitly specify the momentum/angle (by adding 100 asc described above, you may also choose to distibute tracks evenly inc log(P) or log(theta) by setting the appropriate PLOG and TLOG flagsc to a non-zero value.c PLOG 1c TLOG 1cc particle momentum theta phi delta_momentum delta_theta delta_phiKINE 101 9.0 10. 0. 0. 3. 360.
c The SCAP card determines the vertex position for the particle gun. Itc supports the following three arguments, all of which default to 0.cc vertex_x vertex_y vertex_zSCAP 0. 0. 65.
Richard Jones Parallelism in Experimental Nuclear Physics Workshop, Jan. 6-7, 2011, Newport News, VA
6
running hdgeant 2 (3) running modes: batch or interactive (+ motif)
$ hdgeant$ hdgeant++ (“m” = motif)
Richard Jones Parallelism in Experimental Nuclear Physics Workshop, Jan. 6-7, 2011, Newport News, VA
7
running mcsmear can be run automatically by hdgeant (POSTSMEAR) custom parameters specified on command line
Usage: mcsmear [options] file.hddm
Read the given, Geant-produced HDDM file as input and smearthe truth values for "hit" data before writing out to aseparate file. The truth values for the thrown particles arenot changed. Noise hits can also be added using the -n option.Note that all smearing is done using Gaussians, with thesigmas configurable with the options below.
Richard Jones Parallelism in Experimental Nuclear Physics Workshop, Jan. 6-7, 2011, Newport News, VA
8
running mcsmear can be run automatically by hdgeant (POSTSMEAR) custom parameters specified on command line
Options: -N Add random background hits to CDC and FDC -s Don't smear real hits (default is to smear) -u# Sigma CDC anode drift time in ns (def:2.72727ns) (NOTE: this is only used if -y is also specified!) -y Do NOT apply drift distance dependence error to CDC (default is to apply) -t# CDC time window for background hits in ns [1000ns] -U# Sigma FDC anode drift time in ns [3.63636ns] -C# Sigma FDC cathode strips in microns [3.63636e-09ns] -t# FDC time window for background hits in ns [1000ns] . . . -h Print this usage statement.
Richard Jones Parallelism in Experimental Nuclear Physics Workshop, Jan. 6-7, 2011, Newport News, VA
9
running mcsmear can be run automatically by hdgeant (POSTSMEAR) custom parameters specified on command line
Example:
mcsmear -u3.5 -t500 hdgeant.hddm
This will produce a file named hdgeant_nsmeared.hddm that includes the hit information from the input file hdgeant.hddm but with the FDC and CDC hits smeared out. The CDC hits will have their drift times smeared via a gaussian with a 3.5ns width while the FDC will be smeared using the default values. In addition, background hits will be added, the exact number of of which are determined by the time windows specified for the CDC and FDC. In this examplem the CDC time window was explicitly set to 500 ns.
Richard Jones Parallelism in Experimental Nuclear Physics Workshop, Jan. 6-7, 2011, Newport News, VA
10
Browsing the hits uses browsable xml-style “hddm” format to see what is in file xy.hddm, just do $ more xy.hddm$ more xy.hddm
gryphn> more out.hddm<HDDM class="s" version="1.0" xmlns="http://www.gluex.org/hddm"> <physicsEvent eventNo="int" maxOccurs="unbounded" runNo="int"> <reaction maxOccurs="unbounded" minOccurs="0" type="int" weight="float"> <beam minOccurs="0" type="Particle_t"> <momentum E="float" px="float" py="float" pz="float" /> <properties charge="int" mass="float" /> </beam> <target minOccurs="0" type="Particle_t"> <momentum E="float" px="float" py="float" pz="float" /> <properties charge="int" mass="float" /> </target> <vertex maxOccurs="unbounded"> <product decayVertex="int" id="int" maxOccurs="unbounded" mech="int" parentid="int" pdgtype="int" type="Particle_t"> <momentum E="float" px="float" py="float" pz="float" /> <properties charge="int" mass="float" />
Richard Jones Parallelism in Experimental Nuclear Physics Workshop, Jan. 6-7, 2011, Newport News, VA
11
Browsing the hits to see contents of file xy.hddm, do $ hddm-xml xy.hddm$ hddm-xml xy.hddm
gryphn> hddm-xml out.hddm <?xml version="1.0" encoding="UTF-8"?><HDDM class="s" version="1.0" xmlns="http://www.gluex.org/hddm"> <physicsEvent eventNo="58" runNo="1"> <reaction type="0" weight="0"> <vertex> <product decayVertex="0" id="1" mech="0" parentid="0" pdgtype="0" type="gamma"> <momentum E="9.1194" px="-0.000276329" py="-0.000385855" pz="9.1194" /> </product> <origin t="-7.55523e-08" vx="-0.223289" vy="-0.226387" vz="-2200" /> </vertex> </reaction> <hitView version="2.0"> <tagger> <microChannel E="9.1344" column="112" row="0"> <taggerHit t="0" />
Richard Jones Parallelism in Experimental Nuclear Physics Workshop, Jan. 6-7, 2011, Newport News, VA
12
Browsing the geometry 2 ways: read plain xml or hdgeant++ graphical viewer
hierarchicalstructure
documentationin comments
readable namesfor structuralelements
Richard Jones Parallelism in Experimental Nuclear Physics Workshop, Jan. 6-7, 2011, Newport News, VA
13
Browsing the geometry 2 ways: read plain xml or hdgeant++ graphical viewer
gryphn> hdgeant++ *************************************************** * * * G E A N T 3 . 2 1 * * * * C E R N * * * * 15/3/94 Geneva CH * * * ***************************************************
*** Using default PAWLOGON file "/home/jonesrt/.pawlogon.kumac"
GEANT > usage dxcut * GEANT/DRAWING/DXCUT NAME CUTTHE CUTPHI CUTVAL [ THETA PHI U0 V0 SU SV ]
GEANT > dxcut site 90 0 65
Richard Jones Parallelism in Experimental Nuclear Physics Workshop, Jan. 6-7, 2011, Newport News, VA
14
Browsing the geometry GEANT > help dxcut* GEANT/DRAWING/DXCUT NAME CUTTHE CUTPHI CUTVAL [ THETA PHI U0 V0 SU SV ]
NAME C 'Volume name' CUTTHE R 'Theta angle of the line normal to cut plane' R=0.:360. CUTPHI R 'Phi angle of the line normal to cut plane' R=0.:360. CUTVAL R 'Cut plane distance from the origin along the axis' THETA R 'Viewing angle theta (for 3D projection)' R=0.:360. PHI R 'Viewing angle phi (for 3D projection)' R=0.:360. U0 R 'U-coord. (horizontal) of volume origin' V0 R 'V-coord. (vertical) of volume origin' SU R 'Scale factor for U-coord.' SV R 'Scale factor for V-coord.'
CALL GDRAWX(name,cutthe,cutphi,cutval,theta,phi,u0,v0,su,sv)
The cut plane is normal to the line given by the cut angles cutthe and cutphi and placed at the distance cutval from the origin. The resulting picture is seen from the viewing angles theta,phi. If optional parameters are missing, the current values in /GCDRAW/ are taken.
Richard Jones Parallelism in Experimental Nuclear Physics Workshop, Jan. 6-7, 2011, Newport News, VA
15
Browsing the geometry
GEANT > usage dxcut * GEANT/DRAWING/DXCUT NAME CUTTHE CUTPHI CUTVAL [ THETA PHI U0 V0 SU SV ]GEANT > dxcut site 90 0 1GEANT >
Richard Jones Parallelism in Experimental Nuclear Physics Workshop, Jan. 6-7, 2011, Newport News, VA
16
Browsing the geometry
GEANT > usage dxcut * GEANT/DRAWING/DXCUT NAME CUTTHE CUTPHI CUTVAL [ THETA PHI U0 V0 SU SV ]GEANT > dxcut site 90 0 1GEANT > wc#setview 10 10 .01 .01GEANT > wc#angles 30 150GEANT > wc#dxcut site 90 0 1GEANT >
Richard Jones Parallelism in Experimental Nuclear Physics Workshop, Jan. 6-7, 2011, Newport News, VA
17
Browsing the geometry
GEANT > usage dxcut * GEANT/DRAWING/DXCUT NAME CUTTHE CUTPHI CUTVAL [ THETA PHI U0 V0 SU SV ]GEANT > dxcut site 90 0 1GEANT > wc#setview 10 10 .01 .01GEANT > wc#angles 30 150GEANT > wc#dxcut site 90 0 1GEANT > wc#pick o 1 points have been hit wc origin reset to (1,-0.61207,68.9271)GEANT >
Richard Jones Parallelism in Experimental Nuclear Physics Workshop, Jan. 6-7, 2011, Newport News, VA
18
Browsing the geometryGEANT > usage dxcut * GEANT/DRAWING/DXCUT NAME CUTTHE CUTPHI CUTVAL [ THETA PHI U0 V0 SU SV ]GEANT > dxcut site 90 0 1GEANT > wc#setview 10 10 .01 .01GEANT > wc#angles 30 150GEANT > wc#dxcut site 90 0 1GEANT > wc#pick o 1 points have been hit wc origin reset to (1,-0.61207,68.9271)GEANT > wc#setview 10 10 .3 .3GEANT > wc#dxcut site 90 0 1GEANT > wc#pick mGEANT > wc#pick
1 points have been hitpoint 1: 1.0000005 -0.14630273 71.088165 LIH2 LiqHydrogen /SITE 1/HALL 1/TARG 1/TGTV 1/LIH2 1/ inhomogeneous field (0.023536, -0.0034433, -18.454) kGGEANT >
Richard Jones Parallelism in Experimental Nuclear Physics Workshop, Jan. 6-7, 2011, Newport News, VA
19
Getting under the hood a place to start: gustep.F
instrument gustep() to snoop on the simulation lots of examples in the code enclose your customizations in #ifdef / #endif blocks
SUBROUTINE GUSTEP************************************************************************** ** User routine called at the end of each tracking step ** MEC is the mechanism origin of the step ** INWVOL is different from 0 when the track has reached ** a volume boundary ** ISTOP is different from 0 if the track has stopped ** *************************************************************************
Richard Jones Parallelism in Experimental Nuclear Physics Workshop, Jan. 6-7, 2011, Newport News, VA
20
Getting under the hood example: CERENKOV_PID_NTUPLE
near the top, add a block to define variables to be saved place them in the desired order in a named common block define a string like below to document the common block
#if defined CERENKOV_PID_NTUPLE integer evno,part real xvtx(3),xdet(3),pdet(3) common /ckovNtuple/evno,xvtx,xdet,pdet,part save /ckovNtuple/ character*80 ntckovdef parameter (ntckovdef='ev:I,xv(3):R,xt(3):R,p(3):R,part:I,vid:I') integer ntckov parameter (ntckov=10)#endif
Richard Jones Parallelism in Experimental Nuclear Physics Workshop, Jan. 6-7, 2011, Newport News, VA
21
Getting under the hood example: CERENKOV_PID_NTUPLE
down in the body, add the code to define, fill the ntuple
#if defined CERENKOV_PID_NTUPLE if (.not.HEXIST(ntckov)) then call HBNT(ntckov,'cerenkov counter hits','') call HBNAME(ntckov,'hits',evno,ntckovdef) endif if (NSTEP.eq.0) then xvtx(1) = VECT(1) xvtx(2) = VECT(2) xvtx(3) = VECT(3) elseif (INWVOL.eq.1) then if (cnames(NLEVEL).eq.'CGAS') then xdet(1) = VECT(1) xdet(2) = VECT(2) . . . call HFNT(ntckov) endif endif#endif
Richard Jones Parallelism in Experimental Nuclear Physics Workshop, Jan. 6-7, 2011, Newport News, VA
22
Getting under the hood example: CERENKOV_PID_NTUPLE
run the simulation in interactive mode: $ hdgeant++$ hdgeant++
simulate a few events: GEANT> trig 10 GEANT> trig 10
browse the ntuple for results: GEANT> n/pl 10.ev GEANT> n/pl 10.ev
if satisfied, run a longer simulation
output ntuple appears in new file geant.hbookgeant.hbook
Richard Jones Parallelism in Experimental Nuclear Physics Workshop, Jan. 6-7, 2011, Newport News, VA
23
Now for the real tutorial…
The goals of this session are1. generate events with the genr8 program
2. generate events with the bggen program (pythia)
3. run hdgeant (+mcsmear) to simulate events