AgML Example: The Beam Beam Counters

Under:
  1. <Document  file="StarVMC/Geometry/BbcmGeo/BbcmGeo.xml">
  2. <!--
  3.  Every AgML document begins with a Document tag, which takes a single "file"
  4.  attribute as its arguement.
  5.  
  6.  -->
  7.  
  8.  
  9. <Module name="BbcmGeo" comment=" is the Beam Beam Counter Modules GEOmetry "  >
  10. <!--
  11.  The Module tag declares an AgML module.  The name should consist of a four
  12.  letter acronym, followed by the word "geo" and possibly a version number.
  13.  
  14.  e.g. BbcmGeo, EcalGeo6, TpceGeo3a, etc...
  15.  
  16.  A mandatory comment attribute provides a short description of which detector
  17.  is implemented by the module.
  18.  
  19.  -->
  20.  
  21.   <Created date="15 march 2002"   />
  22.   <Author  name="Yiqun Wang"      />
  23.   <!-- The Created and Author tags accept a free-form date and author, for the
  24.       purposes of documentation. -->
  25.  
  26.  
  27.   <CDE>AGECOM,GCONST,GCUNIT</CDE>
  28.   <!-- The CDE tag provides some backwards compatability features with starsim.
  29.       AGECOM,GCCONST and GCUNIT are fine for most modules. -->
  30.        
  31.   <Content>BBCM,BBCA,THXM,SHXT,BPOL,CLAD</Content>
  32.   <!-- The Content tag should declare the names of all volumes which are
  33.       declared in the detector module.  A comma-separated list.  -->
  34.        
  35.   <Structure name="BBCG"  >
  36.     <var name="version"  />
  37.     <var name="onoff(3)" />
  38.     <var name="zdis(2)"  />
  39.   </Structure>
  40.   <!-- The structure tag declares an AgML structure.  It is similar to a c-
  41.       struct, but has some important differences which will be illustrated
  42.       later.  The members of a Structure are declared using the var tag.  By
  43.       default, the type of a var will be a float.
  44.  
  45.       Arrays are declared by enclosing the dimensions of the array in
  46.       parentheses.  Only 1D and 2D arrayes are supported.  e.g.
  47.  
  48.       <var name="x(3)"     />   allowed
  49.       <var name="y(3,3)"   />   allowed
  50.       <var name="z(4,4,4)" />   not allowed
  51.  
  52.       Types may be declared explicitly using the type parameter as below.  
  53.       Valid types are int, float and char.  char variables should be limited
  54.       to four-character strings for backwards compatability with starsim.  
  55.       Arrays of chars are allowed, in which case you may treat the variable
  56.       as a string of length Nx4, where N is the dimension of the array.
  57.  
  58.       -->
  59.        
  60.   <Structure name="HEXG">
  61.     <var name="type"    type="float"  />
  62.     <var name="irad"    type="float"  />
  63.     <var name="clad"    type="float"  />
  64.     <var name="thick"   type="float"  />
  65.     <var name="zoffset" type="float"  />
  66.     <var name="xoffset" type="float"  />
  67.     <var name="yoffset" type="float"  />
  68.   </Structure>
  69.        
  70.   <varlist type="float">
  71.      actr,srad,lrad,ztotal,x0,y0,theta0,phi0,xtrip,ytrip,rtrip,thetrip,rsing,thesing
  72.   </varlist>
  73.   <!-- The varlist tag allows you to declare a list of variables of a stated type.
  74.       The variables will be in scope for all volumes declared in the module.
  75.  
  76.       Variables may be initialized using the syntax
  77.            var1/value1/ , var2/value2/, var3, var4/value4/ ...
  78.  
  79.       Arrays of 1 or 2 dimensions may also be declared.  The Assign tag may
  80.       be used to assign values to the arrays:
  81.  
  82.       <Assign var="ARRAY" value="{1,2,3,4}" />
  83.       -->
  84.        
  85.   <varlist type="int">I_trip/0/,J_sing/0/</varlist>
  86.        
  87.   <Fill  name="BBCG"    comment="BBC geometry">
  88.     <var name="Version" value="1.0"              comment=" Geometry version "  />
  89.     <var name="Onoff"   value="{3,3,3}"          comment=" 0 off, 1 west on, 2 east on, 3 both on: for BBC,Small tiles,Large tiles "  />
  90.     <var name="zdis"    value="{374.24,-374.24}" comment=" z-coord from center in STAR (715/2+6*2.54+1=373.8) "  />
  91.   </Fill>
  92.   <!-- The members of a structure are filled inside of a Fill block.  The Fill
  93.       tag specifies the name of the structure being filled, and accepts a
  94.       mandatory comment for documentation purposes.
  95.  
  96.       The var tag is used to fill the members of the structure.  In this
  97.       context, it accepts three arguements:  The name of the structure member,
  98.       the value which should be filled, and a mandatory comment for
  99.       documentation purposes.
  100.      
  101.       The names of variables, structures and structure members are case-
  102.       insensitive.
  103.  
  104.       1D Arrays are filled using a comma separated list of values contained in
  105.       curly brackets...
  106.  
  107.       e.g. value="{1,2,3,4,5}"
  108.  
  109.       2D Arrays are filled using a comma and semi-colon separated list of values
  110.  
  111.       e.g. value="{11,12,13,14,15;        This fills an array dimensioned
  112.                    21,22,23,24,25;        as A(3,5)
  113.                    31,32,33,34,35;}"
  114.  
  115.       -->
  116.        
  117.  
  118.   <Fill name="HEXG" comment="hexagon tile geometry"  >
  119.     <var name="Type"    value="1"     comment="1 for small hex tile, 2 for large tile "  />
  120.     <var name="irad"    value="4.174" comment="inscribing circle radius =9.64/2*sin(60)=4.174 "  />
  121.     <var name="clad"    value="0.1"   comment="cladding thickness "  />
  122.     <var name="thick"   value="1.0"   comment="thickness of tile "  />
  123.     <var name="zoffset" value="1.5"   comment="z-offset from center of BBCW (1), or BBCE (2) "  />
  124.     <var name="xoffset" value="0.0"   comment="x-offset center from beam for BBCW (1), or BBCE (2) "  />
  125.     <var name="yoffset" value="0.0"   comment="y-offset center from beam for BBCW (1), or BBCE (2) "  />
  126.   </Fill>
  127.        
  128.   <Fill name="HEXG" comment="hexagon tile geometry"  >
  129.     <var name="Type"    value="2"      comment="1 for small hex tile, 2 for large tile "  />
  130.     <var name="irad"    value="16.697" comment="inscribing circle radius (4x that of small one) "  />
  131.     <var name="clad"    value="0.1"    comment="cladding of tile "  />
  132.     <var name="thick"   value="1.0"    comment="thickness of tile "  />
  133.     <var name="zoffset" value="-1.5"   comment="z-offset from center of BBCW (1), or BBCE (2) "  />
  134.     <var name="xoffset" value="0.0"    comment="x-offset center from beam for BBCW (1), or BBCE (2) "  />
  135.     <var name="yoffset" value="0.0"    comment="y-offset center from beam for BBCW (1), or BBCE (2) "  />
  136.   </Fill>
  137.        
  138.   <Use struct="BBCG"/>
  139.   <!-- An important difference between AgML structures and c-structs is that
  140.       only one instance of an AgML structure is allowed in a geometry module,
  141.       and there is no need for the user to create it... it is automatically
  142.       generated.  The Fill blocks store multiple versions of this structure
  143.       in an external name space.  In order to access the different versions
  144.       of a structure, the Use tag is invoked.
  145.      
  146.       Use takes one mandatory attribute: the name of the structure to use.  
  147.       By default, the first set of values declared in the Fill block will
  148.       be loaded, as above.
  149.  
  150.       The Use tag may also be used to select the version of the structure
  151.       which is loaded.
  152.  
  153.       Example:
  154.          <Use struct="hexg" select="type" value="2" />
  155.  
  156.       The above example loads the second version of the HEXG structure
  157.       declared above.
  158.      
  159.       NOTE: The behavior of a structure is not well defined before the
  160.             Use operator is applied.
  161.      
  162.       -->
  163.  
  164.  
  165.   <Print level="1" fmt="'BBCMGEO version ', F4.2"  >
  166.     bbcg_version  
  167.   </Print>
  168.   <!-- The Print statement takes a print "level" and a format descriptor "fmt".  The
  169.       format descriptor follows the Fortran formatting convention
  170.  
  171.       (n.b. Print statements have not been implemented in ROOT export
  172.             as they utilize fortran format descriptors)
  173.    -->
  174.      
  175.                
  176.   <!-- small kludge x10000 because ROOT will cast these to (int) before computing properties -->
  177.   <Mixture name="ALKAP" dens="1.432"  >
  178.     <Component name="C5" a="12" z="6"  w="5      *10000"  />
  179.     <Component name="H4" a="1"  z="1"  w="4      *10000"  />
  180.     <Component name="O2" a="16" z="8"  w="2      *10000"  />
  181.     <Component name="Al" a="27" z="13" w="0.2302 *10000"  />
  182.   </Mixture>
  183.   <!-- Mixtures and Materials may be declared within the module... this one is not
  184.       a good example, as there is a workaround being used to avoid some issues
  185.       with ROOT vs GEANT compatability. -->
  186.  
  187.  
  188.   <Use struct="HEXG" select="type" value="1 "  />
  189.      srad   = hexg_irad*6.0;
  190.      ztotal = hexg_thick+2*abs(hexg_zoffset);
  191.  
  192.   <Use struct="HEXG" select="type" value="2 "  />
  193.      lrad   = hexg_irad*6.0;
  194.      ztotal = ztotal+hexg_thick+2*abs(hexg_zoffset);  <!-- hexg_zoffset is negative for Large (type=2) -->
  195.  
  196.   <!-- AgML has limited support for expressions, in the sense that anyhing which
  197.       is not an XML tag is passed (with minimal parsing) directly to the c++
  198.       or mortran compiler.  A few things are notable in the above lines.
  199.  
  200.       (1) Lines may be optionally terminated by a ";", but...
  201.       (2) There is no mechanism to break long lines across multiple lines.
  202.       (3) The members of a structure are accessed using an "_", i.e.
  203.  
  204.           hexg_irad above refers to the IRAD member of the HEXG structure
  205.           loaded by the Use tag.
  206.  
  207.       (4) Several intrinsic functions are available: abs, cos, sin, etc...
  208.       -->
  209.  
  210.   <Create block="BBCM"  />
  211.   <!-- The Create operator creates the volume specified in the  "block"
  212.       parameter.  When the Create operator is invoked, execution branches
  213.       to the block of code for the specified volume.   In this case, the
  214.       Volume named BBCM below. -->
  215.  
  216.   <If expr="bbcg_OnOff(1)==1|bbcg_OnOff(1)==3">  
  217.  
  218.     <Placement block="BBCM" in="CAVE"
  219.               x="0"
  220.               y="0"
  221.               z="bbcg_zdis(1)"/>
  222.     <!-- After the volume has been Created, it is positioned within another
  223.         volume in the STAR detector.  The mother volume may be specified
  224.         explicitly with the "in" attribute.
  225.  
  226.         The position of the volume is specified using x, y and z attributes.
  227.  
  228.         An additional attribute, konly, is used to indicate whether or
  229.         not the volume is expected to overlap another volume at the same
  230.         level in the geometry tree.  konly="ONLY" indicates no overlap and
  231.         is the default value.  konly="MANY" indicates overlap is possible.
  232.  
  233.         For more info on ONLY vs MANY, consult the geant 3 manual.        
  234.         -->
  235.  
  236.   </If>
  237.        
  238.   <If expr="bbcg_OnOff(1)==2|bbcg_OnOff(1)==3"  >
  239.     <Placement block="BBCM" in="CAVE"
  240.               x="0"
  241.               y="0"
  242.               z="bbcg_zdis(2)">
  243.       <Rotation alphay="180"  />
  244.     </Placement>            
  245.     <!-- Rotations are specified as additional tags contained withn a
  246.         Placement block of code.  The translation of the volume will
  247.         be performed first, followed by any rotations, evaluated in
  248.         the order given. -->
  249.  
  250.  
  251.   </If>
  252.        
  253.   <Print level="1" fmt="'BBCMGEO finished'"></Print>
  254.        
  255.  
  256. <!--
  257.  
  258.  Volumes are the basic building blocks in AgML.  The represent the un-
  259.  positioned elements of a detector setup.  They are characterized by
  260.  a material, medium, a set of attributes, and a shape.
  261.  
  262.  -->
  263.  
  264.  
  265.  
  266. <!--                      === V o l u m e  B B C M ===                      -->
  267. <Volume name="BBCM" comment="is one BBC East or West module">
  268.  
  269.   <Material  name="Air" />
  270.   <Medium    name="standard"  />
  271.   <Attribute for="BBCM" seen="0" colo="7"  />
  272.   <!-- The material, medium and attributes should be specified first.  If
  273.       ommitted, the volume will inherit the properties of the volume which
  274.       created it.
  275.  
  276.       NOTE: Be careful when you reorganize a detector module.  If you change
  277.             where a volume is created, you potentially change the properties
  278.          which that volume inherits.
  279.  
  280.   -->
  281.  
  282.   <Shape type="tube"
  283.      rmin="0"
  284.      rmax="lrad"
  285.      dz="ztotal/2" />
  286.   <!-- After specifying the material, medium and/or attributes of a volume,
  287.       the shape is specified.  The Shape is the only property of a volume
  288.       which *must* be declared.  Further, it must be declared *after* the
  289.       material, medium and attributes.
  290.  
  291.       Shapes may be any one of the basic 16 shapes in geant 3.  A future
  292.       release will add extrusions and composite shares to AgMl.
  293.  
  294.       The actual volume (geant3, geant4, TGeo, etc...) will be created at
  295.       this point.
  296.       -->
  297.          
  298.   <Use struct="HEXG" select="type" value="1 "  />
  299.  
  300.   <If expr="bbcg_OnOff(2)==1|bbcg_OnOff(2)==3"  >
  301.     <Create    block="BBCA"  />
  302.     <Placement block="BBCA" in="BBCM"
  303.            x="hexg_xoffset"
  304.            y="hexg_yoffset"
  305.            z="hexg_zoffset"/>    
  306.   </If>
  307.    
  308.   <Use struct="HEXG" select="type" value="2 "  />
  309.  
  310.   <If expr="bbcg_OnOff(3)==1|bbcg_OnOff(3)==3"  >
  311.  
  312.     <Create block="BBCA"/>
  313.     <Placement block="BBCA" in="BBCM"
  314.            x="hexg_xoffset"
  315.            y="hexg_yoffset"
  316.            z="hexg_zoffset"/>
  317.      
  318.   </If>
  319.    
  320. </Volume>
  321.  
  322. <!--                      === V o l u m e  B B C A ===                      -->
  323. <Volume name="BBCA" comment="is one BBC Annulus module"  >
  324.   <Material name="Air"  />
  325.   <Medium name="standard"  />
  326.   <Attribute for="BBCA" seen="0" colo="3"  />
  327.   <Shape type="tube" dz="hexg_thick/2" rmin="hexg_irad" rmax="hexg_irad*6.0"  />
  328.  
  329.   x0=hexg_irad*tan(pi/6.0)
  330.   y0=hexg_irad*3.0
  331.   rtrip = sqrt(x0*x0+y0*y0)
  332.   theta0 = atan(y0/x0)
  333.  
  334.   <Do var="I_trip" from="0" to="5"  >
  335.    
  336.     phi0 = I_trip*60
  337.     thetrip = theta0+I_trip*pi/3.0
  338.     xtrip = rtrip*cos(thetrip)
  339.     ytrip = rtrip*sin(thetrip)
  340.      
  341.     <Create block="THXM"  />
  342.     <Placement in="BBCA" y="ytrip" x="xtrip" z="0" konly="'MANY'" block="THXM"  >
  343.       <Rotation thetaz="0" thetax="90" phiz="0" phiy="90+phi0" phix="phi0"  />
  344.     </Placement>
  345.      
  346.      
  347.   </Do>
  348.    
  349.    
  350. </Volume>
  351.  
  352. <!--                      === V o l u m e  T H X M ===                      -->
  353. <Volume name="THXM" comment="is on Triple HeXagonal Module"  >
  354.   <Material name="Air"  />
  355.   <Medium name="standard"  />
  356.   <Attribute for="THXM" seen="0" colo="2"  />
  357.   <Shape type="tube" dz="hexg_thick/2" rmin="0" rmax="hexg_irad*2.0/sin(pi/3.0)"  />
  358.  
  359.   <Do var="J_sing" from="0" to="2"  >
  360.    
  361.     rsing=hexg_irad/sin(pi/3.0)
  362.     thesing=J_sing*pi*2.0/3.0
  363.     <Create block="SHXT"  />
  364.     <Placement y="rsing*sin(thesing)" x="rsing*cos(thesing)" z="0" block="SHXT" in="THXM"  >
  365.     </Placement>
  366.    
  367.    
  368.   </Do>
  369.  
  370. </Volume>
  371.  
  372.  
  373. <!--                      === V o l u m e  S H X T ===                      -->
  374. <Volume name="SHXT" comment="is one Single HeXagonal Tile"  >
  375.   <Material name="Air"  />
  376.   <Medium name="standard"  />
  377.   <Attribute for="SHXT" seen="1" colo="6"  />
  378.   <Shape type="PGON" phi1="0" rmn="{0,0}" rmx="{hexg_irad,hexg_irad}" nz="2" npdiv="6" dphi="360" zi="{-hexg_thick/2,hexg_thick/2}"  />
  379.  
  380.   actr = hexg_irad-hexg_clad
  381.  
  382.   <Create block="CLAD"  />
  383.   <Placement y="0" x="0" z="0" block="CLAD" in="SHXT"  >
  384.   </Placement>
  385.  
  386.   <Create block="BPOL"  />
  387.   <Placement y="0" x="0" z="0" block="BPOL" in="SHXT"  >
  388.   </Placement>
  389.  
  390.  
  391. </Volume>
  392.  
  393.  
  394. <!--                      === V o l u m e  C L A D ===                      -->
  395. <Volume name="CLAD" comment="is one CLADding of BPOL active region"  >
  396.   <Material name="ALKAP"  />
  397.   <Attribute for="CLAD" seen="1" colo="3"  />
  398.   <Shape type="PGON" phi1="0" rmn="{actr,actr}" rmx="{hexg_irad,hexg_irad}" nz="2" npdiv="6" dphi="360" zi="{-hexg_thick/2,hexg_thick/2}"  />
  399.  
  400. </Volume>
  401.  
  402.  
  403. <!--                      === V o l u m e  B P O L ===                      -->
  404. <Volume name="BPOL" comment="is one Bbc POLystyren active scintillator layer"  >
  405.  
  406.   <Material name="POLYSTYREN"  />
  407.   <!-- Reference the predefined material polystyrene -->
  408.  
  409.   <Material name="Cpolystyren" isvol="1"  />
  410.   <!-- By specifying isvol="1", polystyrene is copied into a new material
  411.       named Cpolystyrene.  A new material is introduced here in order to
  412.       force the creation of a new medium, which we change with parameters
  413.       below. -->
  414.  
  415.   <Attribute for="BPOL" seen="1" colo="4"  />
  416.   <Shape type="PGON" phi1="0" rmn="{0,0}" rmx="{actr,actr}" nz="2" npdiv="6" dphi="360" zi="{-hexg_thick/2,hexg_thick/2}"  />
  417.  
  418.   <Par name="CUTGAM" value="0.00008"  />
  419.   <Par name="CUTELE" value="0.001"  />
  420.   <Par name="BCUTE"  value="0.0001"  />
  421.   <Par name="CUTNEU" value="0.001"  />
  422.   <Par name="CUTHAD" value="0.001"  />
  423.   <Par name="CUTMUO" value="0.001"  />
  424.   <Par name="BIRK1"  value="1.000"  />
  425.   <Par name="BIRK2"  value="0.013"  />
  426.   <Par name="BIRK3"  value="9.6E-6"  />
  427.   <!--
  428.    Parameters are the Geant3 paramters which may be set via a call to
  429.    GSTPar.
  430.    -->
  431.  
  432.   <Instrument block="BPOL">
  433.     <Hit meas="tof"  nbits="16" opts="C" min="0" max="1.0E-6" />
  434.     <Hit meas="birk" nbits="0"  opts="C" min="0" max="10"     />
  435.   </Instrument>
  436.   <!-- The instrument block indicates what information should be saved
  437.       for this volume, and how the information should be packed. -->
  438.  
  439. </Volume>
  440.  
  441.  
  442. </Module>
  443. </Document>
  444.  
  445.