Show
Ignore:
Timestamp:
08/26/10 14:43:05 (21 months ago)
Author:
farhi
Message:

Monitor_nD: added support for OFF geometry

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/nlib/monitors/Monitor_nD.comp

    r2883 r2914  
    196196* restore_neutron: [0|1] If set, the monitor does not influence the neutron state. 
    197197*                        Equivalent to setting the 'parallel' option. 
     198* geometry:   [str] Name of an OFF file to specify a complex geometry detector 
    198199* 
    199200* OUTPUT PARAMETERS: 
     
    208209******************************************************************************/ 
    209210DEFINE COMPONENT Monitor_nD 
    210 DEFINITION PARAMETERS (string options=0, string filename=0, user1=FLT_MAX, user2=FLT_MAX, user3=FLT_MAX, username1=0, username2=0,username3=0) 
     211DEFINITION PARAMETERS (string options=0, string filename=0,string geometry=0,  
     212  user1=FLT_MAX, user2=FLT_MAX, user3=FLT_MAX, username1=0, username2=0,username3=0) 
    211213SETTING PARAMETERS (xwidth=0, yheight=0, zdepth=0, xmin=0, xmax=0, ymin=0, ymax=0, zmin=0, zmax=0, bins=0, min=-1e40, max=1e40, restore_neutron=0, radius=0) 
    212214/* these are protected C variables */ 
     
    216218SHARE 
    217219%{ 
    218 %include "monitor_nd-lib" 
     220  %include "monitor_nd-lib" 
     221  %include "interoff-lib" 
    219222%} 
    220223 
     
    224227  MonitornD_Variables_type Vars; 
    225228  MCDETECTOR detector; 
     229  off_struct offdata; 
    226230%} 
    227231 
    228232INITIALIZE 
    229233%{ 
    230   char tmp[256]; 
     234  char tmp[CHAR_BUF_LENGTH]; 
    231235  strcpy(Vars.compcurname, NAME_CURRENT_COMP); 
    232236  if (options != NULL) 
    233     strncpy(Vars.option, options, 1024); 
     237    strncpy(Vars.option, options, CHAR_BUF_LENGTH); 
    234238  else { 
    235239    strcpy(Vars.option, "x y"); 
     
    258262  } 
    259263   
     264  if (geometry && strlen(geometry)) 
     265    if (!off_init(  geometry, xwidth, yheight, zdepth, 0, &offdata )) { 
     266      printf("Monitor_nD: %s could not initiate the OFF geometry. \n" 
     267             "            Defaulting to normal Monitor dimensions.\n", NAME_CURRENT_COMP); 
     268      strcpy(geometry, ""); 
     269    } 
     270   
    260271  if (!radius && !xwidth && !yheight && !zdepth && !xmin && !xmax && !ymin && !ymax && !strstr(Vars.option, "previous")) 
    261     exit(printf("Monitor_nD: %s has no dimension specified. Aborting (radius, xwidth, yheight, zdepth,previous).\n", NAME_CURRENT_COMP)); 
     272    exit(printf("Monitor_nD: %s has no dimension specified. Aborting (radius, xwidth, yheight, zdepth, previous).\n", NAME_CURRENT_COMP)); 
    262273 
    263274  Monitor_nD_Init(&DEFS, &Vars, xwidth, yheight, zdepth, xmin,xmax,ymin,ymax,zmin,zmax); 
     
    295306    STORE_NEUTRON(INDEX_CURRENT_COMP, x, y, z, vx, vy, vz, t, sx, sy, sz, p); 
    296307  */ 
    297  
    298   if (abs(Vars.Flag_Shape) == DEFS.SHAPE_SQUARE) /* square xy */ 
     308   
     309  if (geometry && strlen(geometry)) 
     310  { 
     311    Coords n0, n1, n={0,0,0}; 
     312    /* determine intersections with object */ 
     313    intersect = off_intersect(&t0, &t1, &n0, &n1, 
     314       x,y,z, vx, vy, vz, offdata ); 
     315  } 
     316  else if (abs(Vars.Flag_Shape) == DEFS.SHAPE_SQUARE) /* square xy */ 
    299317  { 
    300318    PROP_Z0; 
     
    325343  if (intersect) 
    326344  { 
    327     if ((abs(Vars.Flag_Shape) == DEFS.SHAPE_SPHERE) || (abs(Vars.Flag_Shape) == DEFS.SHAPE_CYLIND) || (abs(Vars.Flag_Shape) == DEFS.SHAPE_BOX) || (abs(Vars.Flag_Shape) == DEFS.SHAPE_BANANA)) 
     345    if ((abs(Vars.Flag_Shape) == DEFS.SHAPE_SPHERE) || (abs(Vars.Flag_Shape) == DEFS.SHAPE_CYLIND)  
     346     || (abs(Vars.Flag_Shape) == DEFS.SHAPE_BOX) || (abs(Vars.Flag_Shape) == DEFS.SHAPE_BANANA) 
     347     || (geometry && strlen(geometry)) ) 
    328348    { 
    329349      if (t0 < 0 && t1 > 0)