Lelaps and GODL

41
Lelaps and GODL Lelaps and GODL Fast Detector Simulation Using Lelaps Fast Detector Simulation Using Lelaps Detector descriptions in GODL Detector descriptions in GODL

description

Lelaps and GODL. Fast Detector Simulation Using Lelaps Detector descriptions in GODL. Overview. Introduction Lelaps CEPack tool kit Usage Performance GODL geometry description Future. Introduction. - PowerPoint PPT Presentation

Transcript of Lelaps and GODL

Page 1: Lelaps and GODL

Lelaps and GODLLelaps and GODL

Fast Detector Simulation Using LelapsFast Detector Simulation Using LelapsDetector descriptions in GODLDetector descriptions in GODL

Page 2: Lelaps and GODL

7/28/20047/28/2004 W.G.J. Langeveld - SLACW.G.J. Langeveld - SLAC 22

OverviewOverview

IntroductionIntroduction LelapsLelaps

CEPack tool kitCEPack tool kit UsageUsage PerformancePerformance

GODL geometry descriptionGODL geometry description FutureFuture

Page 3: Lelaps and GODL

7/28/20047/28/2004 W.G.J. Langeveld - SLACW.G.J. Langeveld - SLAC 33

IntroductionIntroduction

Lelaps is a fast detector simulation that swims particles through detectors Lelaps is a fast detector simulation that swims particles through detectors with magnetic fields, accounting for multiple scattering and energy loss.with magnetic fields, accounting for multiple scattering and energy loss.

It produces parameterized showers in EM and hadronic calorimeters.It produces parameterized showers in EM and hadronic calorimeters. It converts gammas.It converts gammas. It supports decays of certain short-lived particles (“V” decays).It supports decays of certain short-lived particles (“V” decays). It does all this very fast.It does all this very fast.

Lelaps consists of a set of C++ class libraries and a main program, which Lelaps consists of a set of C++ class libraries and a main program, which itself is called lelaps.itself is called lelaps.

The main class library is called CEPack, the actual simulation toolkit.The main class library is called CEPack, the actual simulation toolkit. Built-in support for LDMar01, SDJan03 and SDMar04.Built-in support for LDMar01, SDJan03 and SDMar04. Also reads detector geometries in GODL format.Also reads detector geometries in GODL format. Reads StdHep (uses lStdHep class) generator files and produces SIO or Reads StdHep (uses lStdHep class) generator files and produces SIO or

LCIO output files.LCIO output files.

Page 4: Lelaps and GODL

7/28/20047/28/2004 W.G.J. Langeveld - SLACW.G.J. Langeveld - SLAC 44

Geometry in CEPack: LDGeometry in CEPack: LD

Most objects in the LD Most objects in the LD are cylinders.are cylinders.

There are some conical There are some conical masks (not drawn).masks (not drawn).

TPC and barrel muon TPC and barrel muon detector each contain a detector each contain a CENode with a set of CENode with a set of concentric cylinder concentric cylinder surfaces.surfaces.

Muon endcaps use a Muon endcaps use a CENode with a set of CENode with a set of cylindrical slices.cylindrical slices.

Calorimeters use subid Calorimeters use subid calculation for their calculation for their segmentation.segmentation.

Page 5: Lelaps and GODL

7/28/20047/28/2004 W.G.J. Langeveld - SLACW.G.J. Langeveld - SLAC 55

Materials in CEPackMaterials in CEPack

All elements built in with default pressure/temperature/density.All elements built in with default pressure/temperature/density. Any compound can be specified by chemical formula and density or Any compound can be specified by chemical formula and density or

(for gasses) temperature and pressure.(for gasses) temperature and pressure. Mixtures can be created by mixing elements and compounds (by Mixtures can be created by mixing elements and compounds (by

volume or by weight).volume or by weight). All needed quantities are calculated automaticallyAll needed quantities are calculated automatically

Constants needed for multiple scattering and energy lossConstants needed for multiple scattering and energy loss Radiation lengths (Tsai, PDG)Radiation lengths (Tsai, PDG) Interaction lengths (from a fit to element data)Interaction lengths (from a fit to element data) Other constants needed for shower parametrizationOther constants needed for shower parametrization

Page 6: Lelaps and GODL

7/28/20047/28/2004 W.G.J. Langeveld - SLACW.G.J. Langeveld - SLAC 66

MatpropMatprop

Lelaps distribution comes with a little program called Lelaps distribution comes with a little program called matprop:matprop: matprop U # for elements (gasses at NTP)matprop U # for elements (gasses at NTP) matprop SiO2/2.32 # for solids (and liquids) specifymatprop SiO2/2.32 # for solids (and liquids) specify

# density (g/cc)# density (g/cc) matprop CO2/1/298.15 # for gasses specify pressure (atm)matprop CO2/1/298.15 # for gasses specify pressure (atm)

# and temperature (K)# and temperature (K) matprop O2/STP # for gasses at STP (0 C, 1 atm)matprop O2/STP # for gasses at STP (0 C, 1 atm) matprop Ar/NTP # for gasses at NTP (25 C, 1 atm)matprop Ar/NTP # for gasses at NTP (25 C, 1 atm) matprop H2// # for gasses at NTPmatprop H2// # for gasses at NTP

For a mixture (e.g. Air at 20 C) use (-g to indicate gas):For a mixture (e.g. Air at 20 C) use (-g to indicate gas): matprop -g O2/1/293.15 20.946 N2/1/293.15 78.084matprop -g O2/1/293.15 20.946 N2/1/293.15 78.084

Ar/1/293.15 0.934Ar/1/293.15 0.934 Just type Just type matpropmatprop to get a list of options to get a list of options Prints out lots of material propertiesPrints out lots of material properties Matprop is available onnline: Matprop is available onnline: http://http://

www.slac.stanford.edu/comp/physics/matprop.htmlwww.slac.stanford.edu/comp/physics/matprop.html

Page 7: Lelaps and GODL

7/28/20047/28/2004 W.G.J. Langeveld - SLACW.G.J. Langeveld - SLAC 77

Multiple Scattering and dE/dxMultiple Scattering and dE/dx

Multiple scattering is performed using the algorithm of Lynch and Multiple scattering is performed using the algorithm of Lynch and Dahl.Dahl. Gerald R. Lynch and Orin I. Dahl, Nucl. Instr. And Meth. B58 (1991) 6.Gerald R. Lynch and Orin I. Dahl, Nucl. Instr. And Meth. B58 (1991) 6.

Material is “saved up” along the track until there is enough.Material is “saved up” along the track until there is enough.

dE/dx is calculated using the methods by Sternheimer and Peierls.dE/dx is calculated using the methods by Sternheimer and Peierls. R.M. Sternheimer and R.F. Peierls, Phys. Rev. B3 (1971) 3681.R.M. Sternheimer and R.F. Peierls, Phys. Rev. B3 (1971) 3681.

All constants precalculated by the material classes.All constants precalculated by the material classes.

Page 8: Lelaps and GODL

7/28/20047/28/2004 W.G.J. Langeveld - SLACW.G.J. Langeveld - SLAC 88

Shower ParameterizationShower Parameterization

Electromagnetic showers are parameterized using the algorithms of Electromagnetic showers are parameterized using the algorithms of Grindhammer and Peters.Grindhammer and Peters. G. Grindhammer and S. Peters, arXiv:hep-ex/0001020v1 (2000)G. Grindhammer and S. Peters, arXiv:hep-ex/0001020v1 (2000)

(Paper is a 1993 conference contribution, submitted by request to the archive in (Paper is a 1993 conference contribution, submitted by request to the archive in 2000).2000).

CEPack simulation of CEPack simulation of BaBar EM calorimeter BaBar EM calorimeter in Moose (courtesy of in Moose (courtesy of Dominique Mangeol). Dominique Mangeol). See also the BaBar See also the BaBar web site (computing – web site (computing – simulation – fast simulation – fast simulation).simulation).

Page 9: Lelaps and GODL

7/28/20047/28/2004 W.G.J. Langeveld - SLACW.G.J. Langeveld - SLAC 99

Shower ParameterizationShower Parameterization

Hadronic showers are parameterized using code that is similar to Hadronic showers are parameterized using code that is similar to the code for electromagnetic showers, with some modifications.the code for electromagnetic showers, with some modifications. R.K. Bock, T. Hansl-Kozanecka and T.P. Shah, Nucl. Instr. And Meth. R.K. Bock, T. Hansl-Kozanecka and T.P. Shah, Nucl. Instr. And Meth.

186 (1981) 533.186 (1981) 533. Parameterized shower simulation was compared to Geant4.Parameterized shower simulation was compared to Geant4.

““Parameterized Shower Simulation in Lelaps: A Comparison with Parameterized Shower Simulation in Lelaps: A Comparison with GEANT4”, Daniel Birt, Amy Nicholson, Willy Langeveld, Dennis Wright, GEANT4”, Daniel Birt, Amy Nicholson, Willy Langeveld, Dennis Wright, SLAC-TN-03-005, Aug 2003.SLAC-TN-03-005, Aug 2003.

In general pretty good agreement for EM showers. Hadronic In general pretty good agreement for EM showers. Hadronic showers agree pretty well longitudinally, but not as well radially.showers agree pretty well longitudinally, but not as well radially. Hadronic shower parameterization has been tweaked since then.Hadronic shower parameterization has been tweaked since then.

Page 10: Lelaps and GODL

7/28/20047/28/2004 W.G.J. Langeveld - SLACW.G.J. Langeveld - SLAC 1010

EM Shower Parameterization and Geant4EM Shower Parameterization and Geant4

Comparison of Comparison of CEPack longitudinal CEPack longitudinal profile (green) of a 10 profile (green) of a 10 GeV electron in an GeV electron in an EM calorimeter with EM calorimeter with Geant4 (orange).Geant4 (orange).

Page 11: Lelaps and GODL

7/28/20047/28/2004 W.G.J. Langeveld - SLACW.G.J. Langeveld - SLAC 1111

Decays and Gamma ConversionsDecays and Gamma Conversions

Supported unstable particles are pi0, K0-short (K0-long treated as Supported unstable particles are pi0, K0-short (K0-long treated as stable), Lambda, Sigma+/-/0, Xi-,0 and Omega- . Only decay stable), Lambda, Sigma+/-/0, Xi-,0 and Omega- . Only decay modes > 2% supported (“V” decays)modes > 2% supported (“V” decays)

Page 12: Lelaps and GODL

7/28/20047/28/2004 W.G.J. Langeveld - SLACW.G.J. Langeveld - SLAC 1212

Wired picture of the Wired picture of the decay chain:decay chain:

ΩΩ → → ΞΞ00 ππ--

ΞΞ00 → → ΛΛ ππ00

Λ Λ → p → p ππ--

ππ00 → → γ γγ γ as simulated by Lelaps as simulated by Lelaps for the LCD LD model.for the LCD LD model.

DecaysDecays

Page 13: Lelaps and GODL

7/28/20047/28/2004 W.G.J. Langeveld - SLACW.G.J. Langeveld - SLAC 1313

Wired picture of a Wired picture of a gamma conversion as gamma conversion as simulated by Lelaps for simulated by Lelaps for the LCD LD model.the LCD LD model.

ConversionsConversions

Page 14: Lelaps and GODL

7/28/20047/28/2004 W.G.J. Langeveld - SLACW.G.J. Langeveld - SLAC 1414

Lelaps (LDMar01)Lelaps (LDMar01)

Page 15: Lelaps and GODL

7/28/20047/28/2004 W.G.J. Langeveld - SLACW.G.J. Langeveld - SLAC 1515

Lelaps (SDJan03)Lelaps (SDJan03)

Page 16: Lelaps and GODL

7/28/20047/28/2004 W.G.J. Langeveld - SLACW.G.J. Langeveld - SLAC 1616

Lelaps: UsageLelaps: Usage

Most common usage: Most common usage: lelaps –o foo.sio –E bar1.stdhep bar2.stdhep …lelaps –o foo.sio –E bar1.stdhep bar2.stdhep …

reads one or more StdHep files and produces SIO output file.reads one or more StdHep files and produces SIO output file. Defaults to SDJan03. Use Defaults to SDJan03. Use –L LDMar04–L LDMar04 for LD, etc. for LD, etc.

Also has built-in simple particle “gun”:Also has built-in simple particle “gun”: lelaps –o foo.slcio –i 11 –m 10 –n 4 –N 1000lelaps –o foo.slcio –i 11 –m 10 –n 4 –N 1000

generates 1000 events with 4 electrons/event with 10 GeV eachgenerates 1000 events with 4 electrons/event with 10 GeV eachrandom in 4random in 4ππ and produces LCIO output file. and produces LCIO output file.

Options for generation in x,y plane (2Options for generation in x,y plane (2ππ) or along x, y, z directions) or along x, y, z directions Options for turning off energy loss, multiple scattering and/or Options for turning off energy loss, multiple scattering and/or

showering in calorimetersshowering in calorimeters Options for turning off decays and/or conversions and tracking their Options for turning off decays and/or conversions and tracking their

secondaries secondaries

Page 17: Lelaps and GODL

7/28/20047/28/2004 W.G.J. Langeveld - SLACW.G.J. Langeveld - SLAC 1717

PerformancePerformance

Tracking alone: 3 - 4 “typical” events/s (at 1 GHz) for LD, 2 events/s Tracking alone: 3 - 4 “typical” events/s (at 1 GHz) for LD, 2 events/s for SD.for SD.

Adding parameterized showering costs 15% (SD) to 30% (LD).Adding parameterized showering costs 15% (SD) to 30% (LD). Adding decays and conversions adds 20%.Adding decays and conversions adds 20%. LCIO output file (14 MB, compressed) adds another 40%.LCIO output file (14 MB, compressed) adds another 40%.

SIO output takes much longer (factor 2 to 4 depending heavily on SIO output takes much longer (factor 2 to 4 depending heavily on calorimeter segmentation). Could be optimized.calorimeter segmentation). Could be optimized.

Using a GODL detector description file adds some 20-30% because Using a GODL detector description file adds some 20-30% because of ID calculation.of ID calculation.

Page 18: Lelaps and GODL

7/28/20047/28/2004 W.G.J. Langeveld - SLACW.G.J. Langeveld - SLAC 1818

GODL – General Object Description LanguageGODL – General Object Description LanguageLangugae Features - Variables and ArraysLangugae Features - Variables and Arrays

GODL is an extensible typeless programming language.GODL is an extensible typeless programming language. Type determined by assignment:Type determined by assignment:

a = 2.4; # reala = 2.4; # realb = 2; # integerb = 2; # integerc = “text”; # stringc = “text”; # stringd = true; # booleand = true; # boolean

It has variables and operations that can be performed on them:It has variables and operations that can be performed on them:a += 1;a += 1;b = a * 12;b = a * 12;d = c + “ more text”;d = c + “ more text”;e = false;e = false;b = e != true;b = e != true;

Array-like constructs:Array-like constructs:i = 5; foo.i = 12;i = 5; foo.i = 12; # Same as # Same as foo.5 = 12;foo.5 = 12;

Page 19: Lelaps and GODL

7/28/20047/28/2004 W.G.J. Langeveld - SLACW.G.J. Langeveld - SLAC 1919

GODL – Language FeaturesGODL – Language FeaturesOperatorsOperators

Set of operators (some cannot be used in some contexts):Set of operators (some cannot be used in some contexts): + - * / = += -= *= /= == < > <= >= != ! && ||+ - * / = += -= *= /= == < > <= >= != ! && ||

Reference operator @Reference operator @a = 12;a = 12;b = @a; print(b, “\n”);b = @a; print(b, “\n”);

@a->(12)@a->(12)

Useful for referencing objects multiple times without recreating themUseful for referencing objects multiple times without recreating them

Page 20: Lelaps and GODL

7/28/20047/28/2004 W.G.J. Langeveld - SLACW.G.J. Langeveld - SLAC 2020

GODL – Language FeaturesGODL – Language FeaturesBuilt-in FunctionsBuilt-in Functions

It knows about the usual set of math functions:It knows about the usual set of math functions: exp, log, sqrt, pow, cos, sin, tan, acos, asin, atan, exp, log, sqrt, pow, cos, sin, tan, acos, asin, atan,

atan2, cosh, sinh, tanh, acosh, asinh, atanh, log10, atan2, cosh, sinh, tanh, acosh, asinh, atanh, log10, abs, fabs, ceil, floor, modabs, fabs, ceil, floor, mod

In addition:In addition: listlist

a = list(a, b, c, d); # Creates unnamed lista = list(a, b, c, d); # Creates unnamed list printprint

print(a, “\n”);print(a, “\n”);print(a, “\n”, b, “\n”);print(a, “\n”, b, “\n”);

argc, argvargc, argv When arguments are providedWhen arguments are provided

unitunit See laterSee later

Page 21: Lelaps and GODL

7/28/20047/28/2004 W.G.J. Langeveld - SLACW.G.J. Langeveld - SLAC 2121

GODL – Language FeaturesGODL – Language FeaturesControl ConstructsControl Constructs

It has a limited set of control constructs:It has a limited set of control constructs: C-style for and while loops:C-style for and while loops:

for (i = 0; i < 25; i += 1) {for (i = 0; i < 25; i += 1) { … …}}while (true) {while (true) { … … if (something) break;if (something) break;}}

C-style if statements (no “else” yet)C-style if statements (no “else” yet)if (a < b) {if (a < b) { … …}}

Page 22: Lelaps and GODL

7/28/20047/28/2004 W.G.J. Langeveld - SLACW.G.J. Langeveld - SLAC 2222

GODL – Language FeaturesGODL – Language FeaturesList ObjectsList Objects

Variables can be list objects:Variables can be list objects:a = foo(a, b, c, d);a = foo(a, b, c, d);

Lists can contain objects of any type, including other lists.Lists can contain objects of any type, including other lists. To add objects to a list:To add objects to a list:

a += e;a += e;a += f;a += f;

Note that this is not necessarily the same as:Note that this is not necessarily the same as:a += e + f;a += e + f;

which would first add f to e and then the result to a. If e and f are list which would first add f to e and then the result to a. If e and f are list objects, this adds to “a” a single list “e” which in turn contains “f”.objects, this adds to “a” a single list “e” which in turn contains “f”.

Page 23: Lelaps and GODL

7/28/20047/28/2004 W.G.J. Langeveld - SLACW.G.J. Langeveld - SLAC 2323

GODL – Language FeaturesGODL – Language FeaturesUnitsUnits

Variables can have units, and units are enforced across operations Variables can have units, and units are enforced across operations and in arguments to functions and list objects:and in arguments to functions and list objects:

m = _meter; # _meter m = _meter; # _meter is a built-in unitis a built-in unitunit(“m”); # Declare as unitunit(“m”); # Declare as unita = 2 m;a = 2 m;b = 12 * a;b = 12 * a;area = a * b;area = a * b;area += 5; # area += 5; # Error:Error: incorrect unitsincorrect unitsd = cos(area); # d = cos(area); # Error:Error: cos() only takes anglescos() only takes angles

Page 24: Lelaps and GODL

7/28/20047/28/2004 W.G.J. Langeveld - SLACW.G.J. Langeveld - SLAC 2424

GODL – Language FeaturesGODL – Language FeaturesUnitsUnits

Available units (like CLHEP):Available units (like CLHEP): Basic units: _meter, _second, _joule, _coulomb, _kelvin, _mole, Basic units: _meter, _second, _joule, _coulomb, _kelvin, _mole,

_candela, _radian, _steradian _candela, _radian, _steradian Derived units: _angstrom, _parsec, _barn, _degree, _hertz, _becquerel, Derived units: _angstrom, _parsec, _barn, _degree, _hertz, _becquerel,

_curie, _electronvolt, _gram, _watt, _newton, _pascal, _bar, _curie, _electronvolt, _gram, _watt, _newton, _pascal, _bar, _atmosphere, _ampere, _volt, _ohm, _farad, _weber, _tesla, _gauss, _atmosphere, _ampere, _volt, _ohm, _farad, _weber, _tesla, _gauss, _henry, _gray, _lumen, _lux_henry, _gray, _lumen, _lux

Create new units:Create new units:m = _meter; g = _gram; # m = _meter; g = _gram; # For convenienceFor convenienceunit(“m”, “g”) # unit(“m”, “g”) # Declare as unitsDeclare as units

gcc = g/cm3; # gcc = g/cm3; # New unit of densityNew unit of density unit(“gcc”); # unit(“gcc”); # DeclareDeclare

Automatically converts SI prefixes and powers:Automatically converts SI prefixes and powers:a = 1 cm2; # = 0.0001 _meter squareda = 1 cm2; # = 0.0001 _meter squared

Page 25: Lelaps and GODL

7/28/20047/28/2004 W.G.J. Langeveld - SLACW.G.J. Langeveld - SLAC 2525

GODL – Language FeaturesGODL – Language FeaturesMiscellaneousMiscellaneous

Built-in constants:Built-in constants: _pi (3.14…) has units of rad_pi (3.14…) has units of rad _e_SI (electron charge 1.6...10_e_SI (electron charge 1.6...10-19-19 C), _e (2.71…) dimensionless C), _e (2.71…) dimensionless

Debugging functions:Debugging functions: verbose: verbose: prints a lot of debugging information to stdoutprints a lot of debugging information to stdout __printvars: __printvars: prints a list of all variables to stdoutprints a list of all variables to stdout

Control variables for Control variables for print()print() function: function: printlevel_:printlevel_: (default 1) controls how much information to print (default 1) controls how much information to print

(mostly for for object lists).(mostly for for object lists). precision_:precision_: controls how many digits are displayed for floating point controls how many digits are displayed for floating point

numbers.numbers. fieldwidth_:fieldwidth_: controls how much space a printed number takes up. controls how much space a printed number takes up.

Page 26: Lelaps and GODL

7/28/20047/28/2004 W.G.J. Langeveld - SLACW.G.J. Langeveld - SLAC 2626

GODL – Built-in List ObjectsGODL – Built-in List ObjectsMaterialsMaterials

Materials are declared using the element, material or mixture list Materials are declared using the element, material or mixture list objects (use the @ operator to pass by reference):objects (use the @ operator to pass by reference):Si = element("Si");Si = element("Si");vacuum = material("vacuum");vacuum = material("vacuum");O2 = material(formula("O2"),O2 = material(formula("O2"), pressure(1.0 atm),pressure(1.0 atm), temperature(293.15 K));temperature(293.15 K));Tyvek = material(name("Tyvek"),Tyvek = material(name("Tyvek"), formula("CH2CH2"),formula("CH2CH2"), density(0.935 g/cm3));density(0.935 g/cm3));Air = mixture(part(@O2, 20.946),Air = mixture(part(@O2, 20.946), part(@N2, 78.084),part(@N2, 78.084), part(@Ar, 0.934),part(@Ar, 0.934), by("volume"));by("volume"));

Page 27: Lelaps and GODL

7/28/20047/28/2004 W.G.J. Langeveld - SLACW.G.J. Langeveld - SLAC 2727

GODL – Built-in List ObjectsGODL – Built-in List ObjectsVolumes and PlacementsVolumes and Placements

First define a World Volume:First define a World Volume:World = cylinder(radius(700.0 cm), length(14.0 m), @vacuum);World = cylinder(radius(700.0 cm), length(14.0 m), @vacuum);

Define another volume:Define another volume:em_ec_irad = 21.0 cm; em_ec_orad = 125.0 cm;em_ec_irad = 21.0 cm; em_ec_orad = 125.0 cm;em_b_irad = em_ec_orad + 2.0 cm; em_thickness = 15 cm;em_b_irad = em_ec_orad + 2.0 cm; em_thickness = 15 cm;em_b_orad = em_b_irad + em_thickness; em_nlayers = 30;em_b_orad = em_b_irad + em_thickness; em_nlayers = 30;em_sampfrac = 0.02664; em_b_length = 368.0 cm;em_sampfrac = 0.02664; em_b_length = 368.0 cm;

EM_Barrel = cylinder(name("EM Barrel"),EM_Barrel = cylinder(name("EM Barrel"), innerRadius(em_b_irad),innerRadius(em_b_irad), outerRadius(em_b_orad),outerRadius(em_b_orad), length(em_b_length), @SiW,length(em_b_length), @SiW, type("emcal"), nLayers(em_nlayers),type("emcal"), nLayers(em_nlayers), samplingFraction(em_sampfrac));samplingFraction(em_sampfrac));

Add to World using placement:Add to World using placement:World += placement(@EM_Barrel);World += placement(@EM_Barrel);

Page 28: Lelaps and GODL

7/28/20047/28/2004 W.G.J. Langeveld - SLACW.G.J. Langeveld - SLAC 2828

GODL – Built-in List ObjectsGODL – Built-in List ObjectsVolumes and PlacementsVolumes and Placements

Use loops to do repetitive tasks and if statements for conditionals:Use loops to do repetitive tasks and if statements for conditionals:Vertex_Barrel = cylinder(name("Vertex Barrel"),Vertex_Barrel = cylinder(name("Vertex Barrel"),

innerRadius(v_irad), outerRadius(v_orad),innerRadius(v_irad), outerRadius(v_orad), length(v_lenmax));length(v_lenmax));

for (i = 1; i <= v_nlayers; i += 1) {for (i = 1; i <= v_nlayers; i += 1) { vlen = v_leninner;vlen = v_leninner; if (i > 1) vlen = v_lenmax;if (i > 1) vlen = v_lenmax; Vertex_Barrel.i = cylinder(name("Vertex Barrel " + i),Vertex_Barrel.i = cylinder(name("Vertex Barrel " + i), innerRadius(v_spacing * i),innerRadius(v_spacing * i), outerRadius(v_spacing * i + v_thickness),outerRadius(v_spacing * i + v_thickness), length(vlen), @Si,length(vlen), @Si, type("tracker"));type("tracker")); Vertex_Barrel += placement(@Vertex_Barrel.i); # Notice hierarchyVertex_Barrel += placement(@Vertex_Barrel.i); # Notice hierarchy}}

World += placement(@Vertex_Barrel);World += placement(@Vertex_Barrel);

Page 29: Lelaps and GODL

7/28/20047/28/2004 W.G.J. Langeveld - SLACW.G.J. Langeveld - SLAC 2929

GODL – Built-in List ObjectsGODL – Built-in List ObjectsLevels of DetailLevels of Detail

Specify levels of detail with “level” tag:Specify levels of detail with “level” tag:Had_Endcap = cylinder(name("Had Endcap"), level(1),Had_Endcap = cylinder(name("Had Endcap"), level(1), innerRadius(had_ec_irad),innerRadius(had_ec_irad),

outerRadius(had_ec_orad),outerRadius(had_ec_orad), length(had_thickness), @StainlessPoly,length(had_thickness), @StainlessPoly, type("hadcal"), nslices(had_nlayers),type("hadcal"), nslices(had_nlayers), samplingFraction(had_sampfrac));samplingFraction(had_sampfrac));

Had_Endcap += placement(@something, …, Had_Endcap += placement(@something, …, level(max(0))level(max(0)), …);, …); Had_Endcap += placement(@something_else, …, Had_Endcap += placement(@something_else, …, level(min(1))level(min(1)), …);, …);

World += placement(@Had_Endcap, translate(0, 0, 0.5 * (had_b_length –World += placement(@Had_Endcap, translate(0, 0, 0.5 * (had_b_length – had_thickness)));had_thickness)));World += placement(@Had_Endcap, rotate(axis(“y”), angle(180 degrees)),World += placement(@Had_Endcap, rotate(axis(“y”), angle(180 degrees)),

translate(0, 0, -0.5 * (had_b_length – had_thickness)));translate(0, 0, -0.5 * (had_b_length – had_thickness)));

Page 30: Lelaps and GODL

7/28/20047/28/2004 W.G.J. Langeveld - SLACW.G.J. Langeveld - SLAC 3030

GODL – Built-in List ObjectsGODL – Built-in List ObjectsLevels of DetailLevels of Detail

Level syntax:Level syntax: Create object Create object when:when: Used for:Used for:

<not specified><not specified> alwaysalwaysFundamental objectsFundamental objectsthat are always presentthat are always present

level(min(2))level(min(2)) level >= 2level >= 2Detailed objects that should notDetailed objects that should notbe simulated at lower levelsbe simulated at lower levels

level(max(4))level(max(4)) level <= 4level <= 4Fundamental objects that areFundamental objects that arereplaced with other objects atreplaced with other objects athigher levelshigher levels

level(min(2), max(4))level(min(2), max(4))level(range(2, 4))level(range(2, 4))level(mask(0x1C))level(mask(0x1C))

2 <= level <= 42 <= level <= 4Combinations: objects relevantCombinations: objects relevantonly in a certain level rangeonly in a certain level range

Page 31: Lelaps and GODL

7/28/20047/28/2004 W.G.J. Langeveld - SLACW.G.J. Langeveld - SLAC 3131

GODL – Built-in List ObjectsGODL – Built-in List ObjectsID CalculationID Calculation

ID calculation (such as CalorimeterID and TrackerID) is generally ID calculation (such as CalorimeterID and TrackerID) is generally used for two purposes:used for two purposes: To specify segmentation of a detector: hits with the same ID are To specify segmentation of a detector: hits with the same ID are

combined to a single energy deposition.combined to a single energy deposition. To specify an abbreviated version of the location of an energy deposition.To specify an abbreviated version of the location of an energy deposition.

Problem: how can we change the amount or method of segmentation Problem: how can we change the amount or method of segmentation without changing the C++ source code of the simulator?without changing the C++ source code of the simulator?

One solution: Specify the segmentation method in the geometry file One solution: Specify the segmentation method in the geometry file and “interpret” it inside the simulator.and “interpret” it inside the simulator.

GODL API provides a simple, fast, interpreter to do that.GODL API provides a simple, fast, interpreter to do that. In fact, it “compiles” the segmentation specification into byte-code, and In fact, it “compiles” the segmentation specification into byte-code, and

runs the byte code for each hit.runs the byte code for each hit.

Page 32: Lelaps and GODL

7/28/20047/28/2004 W.G.J. Langeveld - SLACW.G.J. Langeveld - SLAC 3232

GODL – Built-in List ObjectsGODL – Built-in List ObjectsID CalculationID Calculation

Example: Tracker ID. For the Vertex detector barrel we would use: Example: Tracker ID. For the Vertex detector barrel we would use: Vertex_Barrel.i = cylinder(name("VXD"),Vertex_Barrel.i = cylinder(name("VXD"), innerRadius(1.2 cm * i),innerRadius(1.2 cm * i), outerRadius(1.2 cm * i + outerRadius(1.2 cm * i + 0.01 cm),0.01 cm), length(vlen), @Si,length(vlen), @Si, type("tracker"),type("tracker"), idCode(code(tb_code), idCode(code(tb_code), data("system", 1),data("system", 1), data("id", i - 1))data("id", i - 1))););

The ID calculation in idCode is specified as a string in a “code” list The ID calculation in idCode is specified as a string in a “code” list object. The algorithm for the vertex and barrel trackers is:object. The algorithm for the vertex and barrel trackers is:

tb_code = tb_code = "x: fp0 y: fp1 z: fp2 layer: d3 id z H "x: fp0 y: fp1 z: fp2 layer: d3 id z H 0x40000000 mul or system 28 bitshift or stop"0x40000000 mul or system 28 bitshift or stop"

Page 33: Lelaps and GODL

7/28/20047/28/2004 W.G.J. Langeveld - SLACW.G.J. Langeveld - SLAC 3333

GODL – Built-in List ObjectsGODL – Built-in List ObjectsID CalculationID Calculation

For the tracker end cap it is:For the tracker end cap it is:""x: fp0 y: fp1 z: fp2 layer: d3 id 0x80000000 or z H x: fp0 y: fp1 z: fp2 layer: d3 id 0x80000000 or z H 0x40000000 mul or system 28 bitshift or stop"0x40000000 mul or system 28 bitshift or stop";;

The “The “x: fp0x: fp0” part means that the API routine that evaluates the ” part means that the API routine that evaluates the byte code associated with the above expects x to be given in the byte code associated with the above expects x to be given in the first floating point “register”. Similarly, “layer” is provided as an first floating point “register”. Similarly, “layer” is provided as an integer in the fourth register.integer in the fourth register.

Reverse polish PostScript-like language with some limitations and Reverse polish PostScript-like language with some limitations and some extras:some extras: Some named variables must be provided by the simulator as standard Some named variables must be provided by the simulator as standard

arguments (arguments (x, y, z, layerx, y, z, layer)) Some named variables are provided using “data” object lists in the Some named variables are provided using “data” object lists in the

specification.specification. HH is the Heaviside step function: 1 if argument positive, 0 otherwise. is the Heaviside step function: 1 if argument positive, 0 otherwise.

Page 34: Lelaps and GODL

7/28/20047/28/2004 W.G.J. Langeveld - SLACW.G.J. Langeveld - SLAC 3434

GODL – Built-in List ObjectsGODL – Built-in List ObjectsID CalculationID Calculation

Slightly more work for the calorimeters. For the end caps we have:Slightly more work for the calorimeters. For the end caps we have:cal_code_ec = "x x mul y y mul add sqrt z atan2 cal_code_ec = "x x mul y y mul add sqrt z atan2 theta_seg mul pi div “ + standard_code;theta_seg mul pi div “ + standard_code;

For the barrel we have:For the barrel we have:cal_code_b = "x x mul y y mul add sqrt z atan2 cos cal_code_b = "x x mul y y mul add sqrt z atan2 cos 1.0 add theta_seg mul 2.0 div “ + standard_code;1.0 add theta_seg mul 2.0 div “ + standard_code;

where standard_code is: where standard_code is: standardl_code = “truncate 11 bitshift y x atan2m standardl_code = “truncate 11 bitshift y x atan2m phi_seg mul 0.5 mul _pi div truncate or layer 21 phi_seg mul 0.5 mul _pi div truncate or layer 21 bitshift or system 28 bitshift or stop";bitshift or system 28 bitshift or stop";

We have to add standard argument specifications to this:We have to add standard argument specifications to this:cal_code_ec = cal_code_ec = "x: fp0 y: fp1 z: fp2 layer: d3 ""x: fp0 y: fp1 z: fp2 layer: d3 "++

cal_code_ec;cal_code_ec;

Page 35: Lelaps and GODL

7/28/20047/28/2004 W.G.J. Langeveld - SLACW.G.J. Langeveld - SLAC 3535

GODL APIGODL API The GODL API consists of four classes: GODLParser, MCode, MStack and The GODL API consists of four classes: GODLParser, MCode, MStack and

MVar.MVar. There are (currently) 11 virtual functions that the API implementer must There are (currently) 11 virtual functions that the API implementer must

write. Example:write. Example:virtual int constructCylinder(virtual int constructCylinder(

const char *nameForFutureReference,const char *nameForFutureReference,const char *objectName,const char *objectName,

double innerRadius,// length units: meterdouble innerRadius,// length units: meter double outerRadius,double outerRadius, double length,double length, const char *materialRefName,const char *materialRefName, const char *type,const char *type, int nLayers,int nLayers, int nSlices,int nSlices, double samplingFraction,double samplingFraction, const MStack &IDCode)const MStack &IDCode)

Page 36: Lelaps and GODL

7/28/20047/28/2004 W.G.J. Langeveld - SLACW.G.J. Langeveld - SLAC 3636

GODL APIGODL API

Other functions:Other functions: constructCone(...);constructCone(...); addField(...);addField(...); addPlacement(...);addPlacement(...); constructPlacement(...);constructPlacement(...); rotate(...);rotate(...); translate(...);translate(...); constructElement(...);constructElement(...); constructCompound(...);constructCompound(...); constructMixture(...);constructMixture(...); addMixture(...);addMixture(...);

API reads .godl file and calls “construct” routines to construct objects and API reads .godl file and calls “construct” routines to construct objects and placements. It then calls rotate and translate on the placements and placements. It then calls rotate and translate on the placements and addMixtures to add materials to the mixtures. Finally it calls addPlacement addMixtures to add materials to the mixtures. Finally it calls addPlacement to instantiate an actual placement of an object. to instantiate an actual placement of an object.

Page 37: Lelaps and GODL

7/28/20047/28/2004 W.G.J. Langeveld - SLACW.G.J. Langeveld - SLAC 3737

GODL - StatusGODL - Status

Parser/evaluator is essentially complete.Parser/evaluator is essentially complete. API layer to access the volume list exists.API layer to access the volume list exists. Completely implemented in Lelaps V03-23-26.Completely implemented in Lelaps V03-23-26. Includes levels of detail and ID calculation.Includes levels of detail and ID calculation. SDMar04.godl file exists.SDMar04.godl file exists. SDJan03.godl with two different levels of detail exists.SDJan03.godl with two different levels of detail exists. GODL-to-HepRep converter exists. The HepReps it produces need GODL-to-HepRep converter exists. The HepReps it produces need

recently updated Wired 4.recently updated Wired 4.

Page 38: Lelaps and GODL

7/28/20047/28/2004 W.G.J. Langeveld - SLACW.G.J. Langeveld - SLAC 3838

FutureFuture

Lelaps and CEPack interfaces are not yet frozen!Lelaps and CEPack interfaces are not yet frozen! New features planned for CEPackNew features planned for CEPack

Combinatorial geometryCombinatorial geometry Shower continuation into next volumeShower continuation into next volume

New features planned for GODL:New features planned for GODL: Add a number of standard geometrical shapesAdd a number of standard geometrical shapes Add support for combinatorial geometryAdd support for combinatorial geometry

Old features need to be tested more thoroughlyOld features need to be tested more thoroughly More tuning of hadronic showersMore tuning of hadronic showers

Page 39: Lelaps and GODL

7/28/20047/28/2004 W.G.J. Langeveld - SLACW.G.J. Langeveld - SLAC 3939

About the name LelapsAbout the name Lelaps

Lelaps (“storm wind”) was a dog with such speed Lelaps (“storm wind”) was a dog with such speed that, once set upon a chase, he could not fail to that, once set upon a chase, he could not fail to catch his prey. Having forged him from bronze, catch his prey. Having forged him from bronze, Hephaestus gave him to Zeus, who in turn gave him Hephaestus gave him to Zeus, who in turn gave him to Athena, the goddess of the hunt. Athena gave to Athena, the goddess of the hunt. Athena gave Lelaps as a wedding present to Procris, daughter of Lelaps as a wedding present to Procris, daughter of Thespius, and the new bride of famous hunter Thespius, and the new bride of famous hunter Cephalus.Cephalus.A time came when a fox created havoc for the A time came when a fox created havoc for the shepherds in Thebes. The fox had the divine shepherds in Thebes. The fox had the divine property that its speed was so great that it could not property that its speed was so great that it could not be caught. Procris sent Lelaps to catch the fox. But be caught. Procris sent Lelaps to catch the fox. But because both were divine creatures, a stalemate because both were divine creatures, a stalemate ensued, upon which Zeus turned both into stone. ensued, upon which Zeus turned both into stone. Feeling remorse, Zeus elevated Lelaps to the skies, Feeling remorse, Zeus elevated Lelaps to the skies, where he now shines as the constellation Canis where he now shines as the constellation Canis Major, with Sirius as the main star.Major, with Sirius as the main star.

Page 40: Lelaps and GODL

7/28/20047/28/2004 W.G.J. Langeveld - SLACW.G.J. Langeveld - SLAC 4040

Introduction: LelapsIntroduction: Lelaps

……but clearly, Lelaps (the program) is not a dog!but clearly, Lelaps (the program) is not a dog!

Page 41: Lelaps and GODL

7/28/20047/28/2004 W.G.J. Langeveld - SLACW.G.J. Langeveld - SLAC 4141

The EndThe End