g eneralized o bject d escription l anguage a new way to describe geometric and other objects
TRANSCRIPT
GGeneralized eneralized OObject bject DDescription escription LLanguageanguage
A new way to describe geometric and other objectsA new way to describe geometric and other objects
1/11/20051/11/2005 W.G.J. Langeveld - SLACW.G.J. Langeveld - SLAC 22
OverviewOverview
IntroductionIntroduction Requirements, or at least features that “would be nice”Requirements, or at least features that “would be nice”
GODL – Basic language featuresGODL – Basic language features Variables, arrays and operatorsVariables, arrays and operators Built-in functions and control constructsBuilt-in functions and control constructs List objectsList objects UnitsUnits
GODL – Built-in list objectsGODL – Built-in list objects Materials, volumes and placementsMaterials, volumes and placements Levels of detailLevels of detail ID calculationID calculation
StatusStatus GODL API, implementation in Lelaps and GODL HepRep writerGODL API, implementation in Lelaps and GODL HepRep writer GODL and LCIOGODL and LCIO Future plansFuture plans
1/11/20051/11/2005 W.G.J. Langeveld - SLACW.G.J. Langeveld - SLAC 33
IntroductionIntroduction
1/11/20051/11/2005 W.G.J. Langeveld - SLACW.G.J. Langeveld - SLAC 44
Introduction: Requirements and “Would be Nice”sIntroduction: Requirements and “Would be Nice”s
A Geometry file format ideally should satisfy the following:A Geometry file format ideally should satisfy the following: Should be as self-descriptive as possibleShould be as self-descriptive as possible
E.g. should contain the algorithm to derive cell ids from x, y, z, rho, theta, phiE.g. should contain the algorithm to derive cell ids from x, y, z, rho, theta, phi Should allow hierarchies of volumes inside volumesShould allow hierarchies of volumes inside volumes Should allow combinatorial geometryShould allow combinatorial geometry Should know about levels of detailShould know about levels of detail
One wants to simulate different things in fast and full simulationsOne wants to simulate different things in fast and full simulations Should allow one to avoid duplication of related numbersShould allow one to avoid duplication of related numbers Should know about simple mathematicsShould know about simple mathematics
cos, sin, sqrt, …cos, sin, sqrt, … Should know about units and enforce consistencyShould know about units and enforce consistency Simple things should be simple, difficult things should be possibleSimple things should be simple, difficult things should be possible Should be supported by Geant4, Lelaps, JAS, Wired.Should be supported by Geant4, Lelaps, JAS, Wired.
Should have an easy-to-use APIShould have an easy-to-use API ……
1/11/20051/11/2005 W.G.J. Langeveld - SLACW.G.J. Langeveld - SLAC 55
Introduction: The GoalIntroduction: The Goal
The main goal is a self-descriptive geometry file format that allows The main goal is a self-descriptive geometry file format that allows one to specify the entire detector, read it into a simulator, produce one to specify the entire detector, read it into a simulator, produce an output file that then can be read into an analysis code and an output file that then can be read into an analysis code and analyzed, all without ever changing either the source code of the analyzed, all without ever changing either the source code of the simulator or the source code of the analysis program.simulator or the source code of the analysis program.
1/11/20051/11/2005 W.G.J. Langeveld - SLACW.G.J. Langeveld - SLAC 66
GODL – Basic Language FeaturesGODL – Basic Language Features
1/11/20051/11/2005 W.G.J. Langeveld - SLACW.G.J. Langeveld - SLAC 77
GODL – Language FeaturesGODL – Language FeaturesVariables and ArraysVariables 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;
1/11/20051/11/2005 W.G.J. Langeveld - SLACW.G.J. Langeveld - SLAC 88
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
1/11/20051/11/2005 W.G.J. Langeveld - SLACW.G.J. Langeveld - SLAC 99
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
1/11/20051/11/2005 W.G.J. Langeveld - SLACW.G.J. Langeveld - SLAC 1010
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) {
… …
}}
1/11/20051/11/2005 W.G.J. Langeveld - SLACW.G.J. Langeveld - SLAC 1111
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”.
1/11/20051/11/2005 W.G.J. Langeveld - SLACW.G.J. Langeveld - SLAC 1212
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 unit
unit(“m”); # Declare as unitunit(“m”); # Declare as unit
a = 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 units
d = cos(area); # d = cos(area); # Error:Error: cos() only takes anglescos() only takes angles
1/11/20051/11/2005 W.G.J. Langeveld - SLACW.G.J. Langeveld - SLAC 1313
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
1/11/20051/11/2005 W.G.J. Langeveld - SLACW.G.J. Langeveld - SLAC 1414
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.
1/11/20051/11/2005 W.G.J. Langeveld - SLACW.G.J. Langeveld - SLAC 1515
GODL – Built-in List ObjectsGODL – Built-in List Objects
1/11/20051/11/2005 W.G.J. Langeveld - SLACW.G.J. Langeveld - SLAC 1616
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"));
1/11/20051/11/2005 W.G.J. Langeveld - SLACW.G.J. Langeveld - SLAC 1717
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);
1/11/20051/11/2005 W.G.J. Langeveld - SLACW.G.J. Langeveld - SLAC 1818
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);
1/11/20051/11/2005 W.G.J. Langeveld - SLACW.G.J. Langeveld - SLAC 1919
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)));
1/11/20051/11/2005 W.G.J. Langeveld - SLACW.G.J. Langeveld - SLAC 2020
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 objects
that are always presentthat are always present
level(min(2))level(min(2)) level >= 2level >= 2Detailed objects that should notDetailed objects that should not
be simulated at lower levelsbe simulated at lower levels
level(max(4))level(max(4)) level <= 4level <= 4
Fundamental objects that areFundamental objects that are
replaced with other objects atreplaced with other objects at
higher 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 relevant
only in a certain level rangeonly in a certain level range
1/11/20051/11/2005 W.G.J. Langeveld - SLACW.G.J. Langeveld - SLAC 2121
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 To specify an abbreviated version of the location of an energy
deposition.deposition. Problem: how can we change the amount or method of Problem: how can we change the amount or method of
segmentation without changing the C++ source code of the segmentation without changing the C++ source code of the simulator?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.
1/11/20051/11/2005 W.G.J. Langeveld - SLACW.G.J. Langeveld - SLAC 2222
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"
1/11/20051/11/2005 W.G.J. Langeveld - SLACW.G.J. Langeveld - SLAC 2323
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.
1/11/20051/11/2005 W.G.J. Langeveld - SLACW.G.J. Langeveld - SLAC 2424
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;
1/11/20051/11/2005 W.G.J. Langeveld - SLACW.G.J. Langeveld - SLAC 2525
GODL – StatusGODL – Status
1/11/20051/11/2005 W.G.J. Langeveld - SLACW.G.J. Langeveld - SLAC 2626
GODL - StatusGODL - Status
Parser/evaluator is essentially complete.Parser/evaluator is essentially complete. ~6000 lines C++, half of which came from previous projects.~6000 lines C++, half of which came from previous projects. API layer to access the volume list exists.API layer to access the volume list exists. Completely implemented in Lelaps V03-21-26. Includes levels of detail Completely implemented in Lelaps V03-21-26. Includes levels of detail
and ID calculation.and ID calculation. A working SDMar04.godl file exists.A working SDMar04.godl file exists. A version of SDMar03.godl with two different levels of detail almost A version of SDMar03.godl with two different levels of detail almost
exists.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.
1/11/20051/11/2005 W.G.J. Langeveld - SLACW.G.J. Langeveld - SLAC 2727
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)
1/11/20051/11/2005 W.G.J. Langeveld - SLACW.G.J. Langeveld - SLAC 2828
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.
1/11/20051/11/2005 W.G.J. Langeveld - SLACW.G.J. Langeveld - SLAC 2929
GODL APIGODL API
To use this inside a simulator:To use this inside a simulator:FILE *fp = fopen(detector, "r");FILE *fp = fopen(detector, "r");
LelapsGODLParser lgodl;LelapsGODLParser lgodl;
int reason = lgodl.evaluate(fp);int reason = lgodl.evaluate(fp);
if (reason) lgodl.printError(); ...if (reason) lgodl.printError(); ...
reason = lgodl.construct(level, fp);reason = lgodl.construct(level, fp);
if (reason) lgodl.printError(); ...if (reason) lgodl.printError(); ...
fclose(fp);fclose(fp);
if (reason) exit(0);if (reason) exit(0);
world = lgodl.get("World"); // non-API function added byworld = lgodl.get("World"); // non-API function added by
field = lgodl.get("Field"); // by implementer!field = lgodl.get("Field"); // by implementer!
1/11/20051/11/2005 W.G.J. Langeveld - SLACW.G.J. Langeveld - SLAC 3030
GODL APIGODL API For ID calculation must store the MStack that is handed during object For ID calculation must store the MStack that is handed during object
construction.construction. When hits are produced procedure for segmentation and hit scoring is When hits are produced procedure for segmentation and hit scoring is
simple:simple:MCode mc;MCode mc;MStack input, output;MStack input, output;input.push_back(MVar(h.p.getx()));input.push_back(MVar(h.p.getx()));input.push_back(MVar(h.p.gety()));input.push_back(MVar(h.p.gety()));input.push_back(MVar(h.p.getz()));input.push_back(MVar(h.p.getz()));input.push_back(MVar((int) subid));input.push_back(MVar((int) subid));
if (mc.execute(input, output, h.node->getcode())) {if (mc.execute(input, output, h.node->getcode())) { towerid = output[0].getInt();towerid = output[0].getInt(); if (h.node->getflags() == CEN_TRACKER) {if (h.node->getflags() == CEN_TRACKER) { lcdio->addSimTrackerHit(h.node->getName(), towerid, x,lcdio->addSimTrackerHit(h.node->getName(), towerid, x, y, z, e, t);y, z, e, t); }} else {else { lcdio->addSimCalorimeterHit(h.node->getName(), towerid,lcdio->addSimCalorimeterHit(h.node->getName(), towerid, 0, x, y, z, e, t);0, x, y, z, e, t); }}}}
1/11/20051/11/2005 W.G.J. Langeveld - SLACW.G.J. Langeveld - SLAC 3131
GODL and LCIOGODL and LCIO Must register trackers and calorimeters. LCDIO class (in Lelaps) provides Must register trackers and calorimeters. LCDIO class (in Lelaps) provides
easy way to do this:easy way to do this:void registerDet(CENode *world)void registerDet(CENode *world){{ if (world == 0) return;if (world == 0) return; for (int i = 0; i < world->size(); i++) {for (int i = 0; i < world->size(); i++) { CENode *ce = world->node(i);CENode *ce = world->node(i); if (ce->size() == 0) {if (ce->size() == 0) { if (ce->getflags() == CEN_TRACKER) {if (ce->getflags() == CEN_TRACKER) { lcdio->registerTracker(ce->getName());lcdio->registerTracker(ce->getName()); }} else if (ce->getflags() & CEN_DO_EM_SHOWER) {else if (ce->getflags() & CEN_DO_EM_SHOWER) { lcdio->registerCalorimeter(ce->getName());lcdio->registerCalorimeter(ce->getName()); }} }} else {else { registerDet(ce);registerDet(ce); }} }} return;return;}}
1/11/20051/11/2005 W.G.J. Langeveld - SLACW.G.J. Langeveld - SLAC 3232
GODL and LCIOGODL and LCIO
The goal is a self-descriptive geometry file format that allows one to The goal is a self-descriptive geometry file format that allows one to specify the entire detector, read it into a simulator, produce an specify the entire detector, read it into a simulator, produce an output file that then can be read into an analysis code and analyzed, output file that then can be read into an analysis code and analyzed, all without ever changing either the source code of the simulator or all without ever changing either the source code of the simulator or the source code of the analysis program.the source code of the analysis program.
GODL thus far makes it possible to make standard simulator GODL thus far makes it possible to make standard simulator executables, but more needs to be done to make standard analysis executables, but more needs to be done to make standard analysis executables, probably including modification of the LCIO standard.executables, probably including modification of the LCIO standard.
1/11/20051/11/2005 W.G.J. Langeveld - SLACW.G.J. Langeveld - SLAC 3333
GODL and LCIOGODL and LCIO
In the current scheme, there are various obstacles:In the current scheme, there are various obstacles: Assumptions are made in the analysis code (and Wired) based on Assumptions are made in the analysis code (and Wired) based on
names (e.g. “SDJan03”, but also detector names such as “VXD” and names (e.g. “SDJan03”, but also detector names such as “VXD” and “TrackerEndCap”).“TrackerEndCap”).
TrackerID’s and CalorimeterID’s are completely hardcoded in the TrackerID’s and CalorimeterID’s are completely hardcoded in the analysis code. A certain segmentation and bit encoding is assumed.analysis code. A certain segmentation and bit encoding is assumed.
Things that are “special”:Things that are “special”: Detector type identification (“tracker” versus “calorimeter”)Detector type identification (“tracker” versus “calorimeter”) In Lelaps: EM vs. hadron calorimeterIn Lelaps: EM vs. hadron calorimeter The concept of layersThe concept of layers System ID, overlap with system nameSystem ID, overlap with system name ““Theta” and “phi” segmentation (what about “x” and “y”? How do you Theta” and “phi” segmentation (what about “x” and “y”? How do you
know which?know which?
1/11/20051/11/2005 W.G.J. Langeveld - SLACW.G.J. Langeveld - SLAC 3434
GODL and LCIOGODL and LCIO
Things that currently aren’t in LCIO:Things that currently aren’t in LCIO: Maximum number of Layers or SlicesMaximum number of Layers or Slices Amounts of theta and phi segmentationAmounts of theta and phi segmentation Type of segmentation used (theta/phi, cos(theta)/phi, x/y, ...)Type of segmentation used (theta/phi, cos(theta)/phi, x/y, ...) Meaning of system ID (what if you want to add another type?)Meaning of system ID (what if you want to add another type?) What if I wanted to add a cerenkov counter? What name to use? What if I wanted to add a cerenkov counter? What name to use?
Tempting to “borrow”, say, “TrackerEndCap” to at least get hits Tempting to “borrow”, say, “TrackerEndCap” to at least get hits produced in the outputproduced in the output
Detector description (aside from “SDJan03”)Detector description (aside from “SDJan03”) It isn’t clear that one can remove all obstacles, but one can try to It isn’t clear that one can remove all obstacles, but one can try to
find solutionsfind solutions Perhaps .godl file (or whatever we use in the end) should be put inside Perhaps .godl file (or whatever we use in the end) should be put inside
run header – would fix Wired display problem, e.g.run header – would fix Wired display problem, e.g. Inverse of ID calculation could be provided and stored.Inverse of ID calculation could be provided and stored. ......
1/11/20051/11/2005 W.G.J. Langeveld - SLACW.G.J. Langeveld - SLAC 3535
GODL – StatusGODL – StatusFutureFuture
Left to do (not necessarily in this order):Left to do (not necessarily in this order): Add missing geometrical shapesAdd missing geometrical shapes Finalize combinatorial geometryFinalize combinatorial geometry Write implementations for Geant4Write implementations for Geant4 Translate parser/API into Java, add to JAS, WiredTranslate parser/API into Java, add to JAS, Wired
1/11/20051/11/2005 W.G.J. Langeveld - SLACW.G.J. Langeveld - SLAC 3636
GODL – StatusGODL – StatusCombinatorial GeometryCombinatorial Geometry
Currently envisioned to be done using union() and intersection() constructs Currently envisioned to be done using union() and intersection() constructs and not():and not():Lum_Endcap = cone(name("Lum Endcap"),Lum_Endcap = cone(name("Lum Endcap"), innerTopRadius(l_e_itoprad),innerTopRadius(l_e_itoprad), outerTopRadius(l_e_otoprad),outerTopRadius(l_e_otoprad), innerBottomRadius(l_e_ibotrad),innerBottomRadius(l_e_ibotrad), outerBottomRadius(l_e_obotrad),outerBottomRadius(l_e_obotrad), length(l_e_length), @WSiG10Air);length(l_e_length), @WSiG10Air);
Beampipe1 = cylinder(name("Beampipe 1"),Beampipe1 = cylinder(name("Beampipe 1"), radius(1.0 cm), length(lb_length));radius(1.0 cm), length(lb_length));Beampipe2 = cylinder(…, radius(2.0 cm), …);Beampipe2 = cylinder(…, radius(2.0 cm), …);
Lum_Cal = intersection(placement(@Lum_Endcap),Lum_Cal = intersection(placement(@Lum_Endcap), placement(not(@Beampipe1), …)),placement(not(@Beampipe1), …)), placement(not(@Beampipe2), …));placement(not(@Beampipe2), …));
World += placement(@Lum_Cal, translate(0, 0, l_e_zoff));World += placement(@Lum_Cal, translate(0, 0, l_e_zoff));World += placement(@Lum_Cal, rotate(axis(“x”), angle(180 degrees)),World += placement(@Lum_Cal, rotate(axis(“x”), angle(180 degrees)), translate(0, 0, -l_e_zoff)); translate(0, 0, -l_e_zoff));
1/11/20051/11/2005 W.G.J. Langeveld - SLACW.G.J. Langeveld - SLAC 3737
The EndThe End