AgML Library Status and Tuneup, II

Known Issues:

1. EEMC -- version in StarDb/VmcGeometry differs from pams/geometry.  The SMD iron/air fix was not applied.  Comparisons below will compare pams/geometry to StarVMC/Geometry instead.

2. TPCE -- first version tpcegeo.g currently is not converted to AgML, due to dependence on complicated support codes (custon stepping and digitization routines).

3. In tpcegeo3a.g, mixture G10 uses "O" twice.  Label is important in AgML library and duplication causes problems.  This is now fixed but will show up below.

Also in btofgeo1-7, calbgeo - calbgeo2,ecalgeo,fpdmgeo1-3,ftpcgeo*,mutdgeo4,phmdgeo,scongeo,sisdgeo*,supogeo,svttgeo*,

tpcegeo*,vpddgeo*.  Fix tomorrow.


Similar --> G5 in sisdgeo modules.


4. TPCE -- TPAD vs TPA1 ... AgML does not distinguish new volumes based on medium changes... therefore TPA1 is missing in AgML, and TPAD will show up as an issue.  One should compare TPGV (gas volume) instead.

Geometry y2011 : y2011

1. MUTD --  Big problems here.. probably code has been updated since it was converted to AgML... (Bill was working on a complete revision of mutdgeo4.g).

2. BTOF -- The issue with BUND/BCOV/BWAT are correlated.  BWAT is missing in AgSTAR geometry due to mistakes in the AgSTAR description of the detector... which are present in past revisions as well.  Not clear why as I remember we went through a round of fixes with the TOF guys.  i.e. revision 1.8.   These were then backed out, and we introduced btofgeo7 to apply this fix.  The fix is indeed applied, *but* the BWAT volume still has an issue.  

Block BWAT  is  TPC cooling water
      Attribute BWAT   seen=0   colo=3
      Component H2     A=1   Z=1   W=2
      Component O      A=16  Z=8   W=1
      Mixture   Water  Dens=1.0     
      Shape     TUBE   Rmin=0  Rmax=0 

The SHAPE command above sets rmax=0, which overrides the value set in the CREATE operator.  Once again users get confused because there are multiple ways to pass values into the BLOCKs.
The AgML export code looks like this --
     {  AgShape shape = AgShape("Tube");
        /// Shape Tube rmin=0 rmax=0
        shape     .Inherit( AgBlock::previous() );
        create     .SetParameters(shape);
        _same_shape &= _stacker->SearchVolume( shape, _attribute );
        _shape = shape;
        if (_same_shape) goto END_OF_BWAT;
        _stacker -> Build(this);

This differs from the behavior of the AgSTAR library... the paramters specified by the SHAPE operator should take precedence over those provided on the CREATE command.
DEFER this fix for now, as I don't want to make multiple changes to the infrastructure at once.

3.FTPC -- FSEN in FGAS.  Only 2 of 10 sensitive layers are placed.  Placement is wrong.  The correct placement spans from z=-46cm to +46cm.  AgML positions volumes from -4.25 cm to +4.25 cm... so there is some overall scale factor which we are getting wrong.

The problem is that the IFLAGA and IFLAGB variables are not initialized.  Solution:  Swap data statement for assign statement after variable declarations.

 4. TOIG -- in TPCE.  It looks like Nitrogen gas is declared incorrectly... looks like geant3 differs a bit on what the radiation length should be as compared to what is tabulated in PDG.    Note that the density is defined a little bit off of what I would expect as well... and also, remember that the TPC is overpressured a bit... so nowhere do we have the densities exactly as they should be.

TSGT may be the G10 issue in the TPC, but maybe some other issues indicated by the difference in shape of the distributions.

Difference in TSAS may be explained by the TSGT issue.

5. PHMD still has serveral problems which I'm finding difficult to trace.

Geometry y2011 after applying fixes to FSEN, G10 definition, N gas definition, and precendence in shape parameters: y2011

BTOF, FTPC issues resolved.  TOIG resolved.  MUTD, PHMD, TSGT issues remain.

1. TSGT -- This issue is an issue with naming convention.  The TSGT volume has multiple instances in AgSTAR, but only a single instance in AgML.  Reason?  Well, the Z, RMIN, RMAX all change... so not at all sure why AgML fails to generate a new volume here.

2. MUTD -- This appears to be a problem in Geometry.cxx... was not passing in the MUTD configuration flag, and thus the sub volumes of the MUTD were not being constructed.

In mutdgeo4.g, it appears there may be an error:

0195 |  if (NINT(MTDG_blconfig(iphi))>0) then
0196 |          !
0197 |          ! BEMC PMT box................
0198 |          if (NINT(MTDG_blconfig(iphi))==5) then
0199 |                  Create and Position MTLB _
0200 |                               x=MTDD_BackLegR+MTDD_BemcElectBoxdX _
0201 |                               y=0 z=0
0202 |          elseif (NINT(MTDG_blconfig(iphi))==3) then
0203 |                  Create and Position MTSB _
0204 |                          x=MTDD_BackLegR+MTDD_BemcElectBoxdX _
0205 |                               y=0 z=0
0206 |          endif
0207 |          !
0208 |  endif
line 195, 198, 202, ... possibly others... accesses an array using IPHI as a key.  But IPHI is only initialized in the case of MTDG_config=5.  
For the y2011 geometry, we use config=4 and the value of IPHI may not be readily predicted (though it would not surprise me to learn that it 
is zero...)  Nonetheless, seems like Bill intended to use kphi in this context rather than iphi to denote which tray is being placed.  Also, 
this would not necessarily be caught in starsim as array boundary problems are supressed, but most certainly are problems in c++.


After final round of fixes: y2011 RADIAL AZIMUTHAL

Largest remaining issue is the PMD.