/* Automatically generated file. Do not edit. * Format: ANSI C source code * Creator: McStas * Instrument: RITA-II.instr (RITA_II) * Date: Fri Aug 14 12:20:46 2026 * File: ./RITA-II.c * CFLAGS= @NCRYSTALFLAGS@ */ #ifndef WIN32 # ifndef OPENACC # define _GNU_SOURCE # endif # define _POSIX_C_SOURCE 200809L #endif /* In case of cl.exe on Windows, supppress warnings about #pragma acc */ #ifdef _MSC_EXTENSIONS #pragma warning(disable: 4068) #endif #define MCCODE_STRING " 3.99.99, git" #define FLAVOR "mcstas" #define FLAVOR_UPPER "MCSTAS" #define MC_USE_DEFAULT_MAIN #define MC_TRACE_ENABLED #include #include typedef double MCNUM; typedef struct {MCNUM x, y, z;} Coords; typedef MCNUM Rotation[3][3]; #define MCCODE_BASE_TYPES /* available random number generators */ #define _RNG_ALG_MT 1 #define _RNG_ALG_KISS 2 /* selection of random number generator */ #ifndef RNG_ALG # define RNG_ALG _RNG_ALG_KISS #endif #if RNG_ALG == _RNG_ALG_MT // MT #define randstate_t uint32_t #elif RNG_ALG == _RNG_ALG_KISS // KISS #define randstate_t uint64_t #endif #ifndef MC_NUSERVAR #define MC_NUSERVAR 10 #endif /* Particle JUMP control logic */ struct particle_logic_struct { int dummy; }; struct _struct_particle { double x,y,z; /* position [m] */ double vx,vy,vz; /* velocity [m/s] */ double sx,sy,sz; /* spin [0-1] */ int mcgravitation; /* gravity-state */ void *mcMagnet; /* precession-state */ int allow_backprop; /* allow backprop */ /* Generic Temporaries: */ /* May be used internally by components e.g. for special */ /* return-values from functions used in trace, thusreturned via */ /* particle struct. (Example: Wolter Conics from McStas, silicon slabs.) */ double _mctmp_a; /* temp a */ double _mctmp_b; /* temp b */ double _mctmp_c; /* temp c */ randstate_t randstate[7]; double t, p; /* time, event weight */ long long _uid; /* Unique event ID */ long _index; /* component index where to send this event */ long _absorbed; /* flag set to TRUE when this event is to be removed/ignored */ long _scattered; /* flag set to TRUE when this event has interacted with the last component instance */ long _restore; /* set to true if neutron event must be restored */ long flag_nocoordschange; /* set to true if particle is jumping */ struct particle_logic_struct _logic; // user variables and comp-injections: double Mono_order; int AnaBlade; int BinX; int BinY; int ncol_54; int nrow_54; }; typedef struct _struct_particle _class_particle; _class_particle _particle_global_randnbuse_var; _class_particle* _particle = &_particle_global_randnbuse_var; #pragma acc routine _class_particle mcgenstate(void); #pragma acc routine _class_particle mcsetstate(double x, double y, double z, double vx, double vy, double vz, double t, double sx, double sy, double sz, double p, int mcgravitation, void *mcMagnet, int mcallowbackprop); #pragma acc routine _class_particle mcgetstate(_class_particle mcneutron, double *x, double *y, double *z, double *vx, double *vy, double *vz, double *t, double *sx, double *sy, double *sz, double *p); extern int mcgravitation; /* flag to enable gravitation */ #pragma acc declare create ( mcgravitation ) _class_particle mcgenstate(void) { _class_particle particle = mcsetstate(0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, mcgravitation, NULL, 0); return(particle); } /*Generated user variable handlers:*/ #pragma acc routine double particle_getvar(_class_particle *p, char *name, int *suc); #ifdef OPENACC #pragma acc routine int str_comp(char *str1, char *str2); #endif double particle_getvar(_class_particle *p, char *name, int *suc){ #ifndef OPENACC #define str_comp strcmp #endif int s=1; double rval=0; if(!str_comp("x",name)){rval=p->x;s=0;} if(!str_comp("y",name)){rval=p->y;s=0;} if(!str_comp("z",name)){rval=p->z;s=0;} if(!str_comp("vx",name)){rval=p->vx;s=0;} if(!str_comp("vy",name)){rval=p->vy;s=0;} if(!str_comp("vz",name)){rval=p->vz;s=0;} if(!str_comp("sx",name)){rval=p->sx;s=0;} if(!str_comp("sy",name)){rval=p->sy;s=0;} if(!str_comp("sz",name)){rval=p->sz;s=0;} if(!str_comp("t",name)){rval=p->t;s=0;} if(!str_comp("p",name)){rval=p->p;s=0;} if(!str_comp("_mctmp_a",name)){rval=p->_mctmp_a;s=0;} if(!str_comp("_mctmp_b",name)){rval=p->_mctmp_b;s=0;} if(!str_comp("_mctmp_c",name)){rval=p->_mctmp_c;s=0;} if(!str_comp("Mono_order",name)){rval=*( (double *)(&(p->Mono_order)) );s=0;} if(!str_comp("AnaBlade",name)){rval=*( (double *)(&(p->AnaBlade)) );s=0;} if(!str_comp("BinX",name)){rval=*( (double *)(&(p->BinX)) );s=0;} if(!str_comp("BinY",name)){rval=*( (double *)(&(p->BinY)) );s=0;} if(!str_comp("ncol_54",name)){rval=*( (double *)(&(p->ncol_54)) );s=0;} if(!str_comp("nrow_54",name)){rval=*( (double *)(&(p->nrow_54)) );s=0;} if (suc!=0x0) {*suc=s;} return rval; } #pragma acc routine void* particle_getvar_void(_class_particle *p, char *name, int *suc); #ifdef OPENACC #pragma acc routine int str_comp(char *str1, char *str2); #endif void* particle_getvar_void(_class_particle *p, char *name, int *suc){ #ifndef OPENACC #define str_comp strcmp #endif int s=1; void* rval=0; if(!str_comp("x",name)) {rval=(void*)&(p->x); s=0;} if(!str_comp("y",name)) {rval=(void*)&(p->y); s=0;} if(!str_comp("z",name)) {rval=(void*)&(p->z); s=0;} if(!str_comp("vx",name)){rval=(void*)&(p->vx);s=0;} if(!str_comp("vy",name)){rval=(void*)&(p->vy);s=0;} if(!str_comp("vz",name)){rval=(void*)&(p->vz);s=0;} if(!str_comp("sx",name)){rval=(void*)&(p->sx);s=0;} if(!str_comp("sy",name)){rval=(void*)&(p->sy);s=0;} if(!str_comp("sz",name)){rval=(void*)&(p->sz);s=0;} if(!str_comp("t",name)) {rval=(void*)&(p->t); s=0;} if(!str_comp("p",name)) {rval=(void*)&(p->p); s=0;} if(!str_comp("Mono_order",name)){rval=(void*)&(p->Mono_order);s=0;} if(!str_comp("AnaBlade",name)){rval=(void*)&(p->AnaBlade);s=0;} if(!str_comp("BinX",name)){rval=(void*)&(p->BinX);s=0;} if(!str_comp("BinY",name)){rval=(void*)&(p->BinY);s=0;} if(!str_comp("ncol_54",name)){rval=(void*)&(p->ncol_54);s=0;} if(!str_comp("nrow_54",name)){rval=(void*)&(p->nrow_54);s=0;} if (suc!=0x0) {*suc=s;} return rval; } #pragma acc routine int particle_setvar_void(_class_particle *, char *, void*); int particle_setvar_void(_class_particle *p, char *name, void* value){ #ifndef OPENACC #define str_comp strcmp #endif int rval=1; if(!str_comp("x",name)) {memcpy(&(p->x), value, sizeof(double)); rval=0;} if(!str_comp("y",name)) {memcpy(&(p->y), value, sizeof(double)); rval=0;} if(!str_comp("z",name)) {memcpy(&(p->z), value, sizeof(double)); rval=0;} if(!str_comp("vx",name)){memcpy(&(p->vx), value, sizeof(double)); rval=0;} if(!str_comp("vy",name)){memcpy(&(p->vy), value, sizeof(double)); rval=0;} if(!str_comp("vz",name)){memcpy(&(p->vz), value, sizeof(double)); rval=0;} if(!str_comp("sx",name)){memcpy(&(p->sx), value, sizeof(double)); rval=0;} if(!str_comp("sy",name)){memcpy(&(p->sy), value, sizeof(double)); rval=0;} if(!str_comp("sz",name)){memcpy(&(p->sz), value, sizeof(double)); rval=0;} if(!str_comp("p",name)) {memcpy(&(p->p), value, sizeof(double)); rval=0;} if(!str_comp("t",name)) {memcpy(&(p->t), value, sizeof(double)); rval=0;} if(!str_comp("Mono_order",name)){memcpy(&(p->Mono_order), value, sizeof(double )); rval=0;} if(!str_comp("AnaBlade",name)){memcpy(&(p->AnaBlade), value, sizeof(int )); rval=0;} if(!str_comp("BinX",name)){memcpy(&(p->BinX), value, sizeof(int )); rval=0;} if(!str_comp("BinY",name)){memcpy(&(p->BinY), value, sizeof(int )); rval=0;} if(!str_comp("ncol_54",name)){memcpy(&(p->ncol_54), value, sizeof(int )); rval=0;} if(!str_comp("nrow_54",name)){memcpy(&(p->nrow_54), value, sizeof(int )); rval=0;} return rval; } #pragma acc routine int particle_setvar_void_array(_class_particle *, char *, void*, int); int particle_setvar_void_array(_class_particle *p, char *name, void* value, int elements){ #ifndef OPENACC #define str_comp strcmp #endif int rval=1; return rval; } #pragma acc routine void particle_restore(_class_particle *p, _class_particle *p0); void particle_restore(_class_particle *p, _class_particle *p0) { p->x = p0->x; p->y = p0->y; p->z = p0->z; p->vx = p0->vx; p->vy = p0->vy; p->vz = p0->vz; p->sx = p0->sx; p->sy = p0->sy; p->sz = p0->sz; p->t = p0->t; p->p = p0->p; p->_absorbed=0; p->_restore=0; } #pragma acc routine double particle_getuservar_byid(_class_particle *p, int id, int *suc){ int s=1; double rval=0; switch(id){ case 0: { rval=*( (double *)(&(p->Mono_order)) );s=0;break;} case 1: { rval=*( (double *)(&(p->AnaBlade)) );s=0;break;} case 2: { rval=*( (double *)(&(p->BinX)) );s=0;break;} case 3: { rval=*( (double *)(&(p->BinY)) );s=0;break;} case 4: { rval=*( (double *)(&(p->ncol_54)) );s=0;break;} case 5: { rval=*( (double *)(&(p->nrow_54)) );s=0;break;} } if (suc!=0x0) {*suc=s;} return rval; } #pragma acc routine void particle_uservar_init(_class_particle *p){ p->Mono_order=0; p->AnaBlade=0; p->BinX=0; p->BinY=0; p->ncol_54=0; p->nrow_54=0; } #define MC_EMBEDDED_RUNTIME /* embedding file "mccode-r.h" */ /******************************************************************************* * * McCode, neutron/xray ray-tracing package * Copyright (C) 1997-2009, All rights reserved * Risoe National Laboratory, Roskilde, Denmark * Institut Laue Langevin, Grenoble, France * * Runtime: share/mccode-r.h * * %Identification * Written by: KN * Date: Aug 29, 1997 * Release: mcstas 3.99.99 * Version: $Revision$ * * Runtime system header for McStas/McXtrace. * * In order to use this library as an external library, the following variables * and macros must be declared (see details in the code) * * struct mcinputtable_struct mcinputtable[]; * int numipar; * metadata_table_t metadata_table[]; * int num_metadata; * char instrument_name[], instrument_source[]; * int traceenabled, defaultmain; * extern MCNUM mccomp_storein[]; * extern MCNUM mcAbsorbProp[]; * extern MCNUM mcScattered; * #define MCCODE_STRING "the McStas/McXtrace version" * * Usage: Automatically embbeded in the c code. * * $Id$ * *******************************************************************************/ #ifndef MCCODE_R_H #define MCCODE_R_H "$Revision$" #include #include #include #include #include #include #include #ifndef _MSC_EXTENSIONS #include #endif #include #include #include #ifdef OPENACC #include #ifndef GCCOFFLOAD #include #else #include #endif #pragma acc routine int noprintf(); #pragma acc routine size_t str_len(const char *s); #else #include #endif /* In case of gcc / clang, ensure to use the built-in isnan/isinf functions */ #if defined(__GNUC__) || defined(__clang__) # ifdef isnan # undef isnan # endif # ifdef isinf # undef isinf # endif # define isnan(x) __builtin_isnan(x) # define isinf(x) __builtin_isinf(x) #endif #ifdef _MSC_EXTENSIONS #ifndef _TIMES_H #define _TIMES_H #if defined(WIN32) || defined(_WIN32) #include #include #include int gettimeofday(struct timeval* t,void* timezone); #define __need_clock_t #include /* Structure describing CPU time used by a process and its children. */ struct tms { clock_t tms_utime; /* User CPU time. */ clock_t tms_stime; /* System CPU time. */ clock_t tms_cutime; /* User CPU time of dead children. */ clock_t tms_cstime; /* System CPU time of dead children. */ }; /* Store the CPU time used by this process and all its dead children (and their dead children) in BUFFER. Return the elapsed real time, or (clock_t) -1 for errors. All times are in CLK_TCKths of a second. */ clock_t times (struct tms *__buffer); typedef long long suseconds_t ; int gettimeofday(struct timeval* t,void* timezone) { struct _timeb timebuffer; _ftime( &timebuffer ); t->tv_sec=timebuffer.time; t->tv_usec=1000*timebuffer.millitm; return 0; } clock_t times (struct tms *__buffer) { __buffer->tms_utime = clock(); __buffer->tms_stime = 0; __buffer->tms_cstime = 0; __buffer->tms_cutime = 0; return __buffer->tms_utime; } #endif #endif #endif /* If the runtime is embedded in the simulation program, some definitions can be made static. */ #ifdef MC_EMBEDDED_RUNTIME # define mcstatic #else # define mcstatic #endif #ifdef __dest_os # if (__dest_os == __mac_os) # define MAC # endif #endif #ifdef __FreeBSD__ # define NEED_STAT_H #endif #if defined(__APPLE__) && defined(__GNUC__) # define NEED_STAT_H #endif #if defined(WIN32) || defined(_WIN32) # define NEED_STAT_H # define NEED_TYPES_H #endif #ifdef NEED_STAT_H # include #endif #ifdef NEED_TYPES_H # include #endif #ifndef MC_PATHSEP_C #if defined(WIN32) || defined(_WIN32) # define MC_PATHSEP_C '\\' # define MC_PATHSEP_S "\\" # else /* !WIN32 */ # define MC_PATHSEP_C '/' # define MC_PATHSEP_S "/" # endif /* !WIN32 */ #endif /* MC_PATHSEP_C */ #if defined(WIN32) || defined(_WIN32) #if defined _MSC_VER #include #elif defined __GNUC__ #include #include #include #endif #define mkdir(a,b) mkdir(a) #define getpid() _getpid() #endif /* the version string is replaced when building distribution with mkdist */ #ifndef MCCODE_STRING # define MCCODE_STRING " 3.99.99, git" #endif #ifndef MCCODE_DATE # define MCCODE_DATE "git" #endif #ifndef MCCODE_VERSION # define MCCODE_VERSION "3.99.99" #endif #ifndef __MCCODE_VERSION__ #define __MCCODE_VERSION__ 399099L #endif #ifndef MCCODE_NAME # define MCCODE_NAME "mcstas" #endif #ifndef MCCODE_PARTICLE # define MCCODE_PARTICLE "neutron" #endif #ifndef MCCODE_PARTICLE_CODE # define MCCODE_PARTICLE_CODE 2112 #endif #ifndef MCCODE_LIBENV # define MCCODE_LIBENV "MCSTAS" #endif #ifndef FLAVOR_UPPER # define FLAVOR_UPPER MCCODE_NAME #endif #ifdef MC_PORTABLE # ifndef NOSIGNALS # define NOSIGNALS 1 # endif #endif #ifdef MAC # ifndef NOSIGNALS # define NOSIGNALS 1 # endif #endif #if (USE_MPI == 0) # undef USE_MPI #endif #ifdef USE_MPI /* default is to disable signals with MPI, as MPICH uses them to communicate */ # ifndef NOSIGNALS # define NOSIGNALS 1 # endif #endif #ifdef OPENACC /* default is to disable signals with PGI/OpenACC */ # ifndef NOSIGNALS # define NOSIGNALS 1 # endif #endif #ifndef OPENACC # ifndef USE_OFF /* default is to enable OFF when not using PGI/OpenACC */ # define USE_OFF # endif # ifndef CPUFUNNEL /* allow to enable FUNNEL-mode on CPU */ # ifdef FUNNEL /* by default disable FUNNEL-mode when not using PGI/OpenACC */ # undef FUNNEL # endif # endif #endif #if (NOSIGNALS == 0) # undef NOSIGNALS #endif /** Header information for metadata-r.c ----------------------------------------------------------------------------- */ struct metadata_table_struct { /* stores metadata strings from components */ char * source; // component name which provided the metadata char * name; // the name of the metadata char * type; // the MIME type of the metadata (free form, valid identifier) char * value; // the metadata string contents }; typedef struct metadata_table_struct metadata_table_t; char * metadata_table_key_component(char* key); char * metadata_table_key_literal(char * key); int metadata_table_defined(int, metadata_table_t *, char *); char * metadata_table_name(int, metadata_table_t *, char *); char * metadata_table_type(int, metadata_table_t *, char *); char * metadata_table_literal(int, metadata_table_t *, char *); void metadata_table_print_all_keys(int no, metadata_table_t * tab); int metadata_table_print_all_components(int no, metadata_table_t * tab); int metadata_table_print_component_keys(int no, metadata_table_t * tab, char * key); /* -------------------------------------------------------------------------- Header information for metadata-r.c --- */ /* Note: the enum instr_formal_types definition MUST be kept synchronized with the one in mccode.h and with the instr_formal_type_names array in cogen.c. */ enum instr_formal_types { instr_type_int, instr_type_string, instr_type_char, instr_type_vector, instr_type_double }; struct mcinputtable_struct { /* defines instrument parameters */ char *name; /* name of parameter */ void *par; /* pointer to instrument parameter (variable) */ enum instr_formal_types type; char *val; /* default value */ char *unit; /* expected unit for parameter; informational only */ }; #ifndef MCCODE_BASE_TYPES typedef double MCNUM; typedef struct {MCNUM x, y, z;} Coords; typedef MCNUM Rotation[3][3]; #endif /* the following variables are defined in the McStas generated C code but should be defined externally in case of independent library usage */ #ifndef DANSE extern struct mcinputtable_struct mcinputtable[]; /* list of instrument parameters */ extern int numipar; /* number of instrument parameters */ extern metadata_table_t metadata_table[]; /* list of component-defined string metadata */ extern int num_metadata; /* number of component-defined string metadata */ extern char instrument_name[], instrument_source[]; /* instrument name and filename */ extern char *instrument_exe; /* executable path = argv[0] or NULL */ extern char instrument_code[]; /* contains the initial 'instr' file */ #ifndef MC_ANCIENT_COMPATIBILITY extern int traceenabled, defaultmain; #endif #endif /* Useful macros ============================================================ */ /* SECTION: Dynamic Arrays */ typedef int* IArray1d; IArray1d create_iarr1d(int n); void destroy_iarr1d(IArray1d a); typedef int** IArray2d; IArray2d create_iarr2d(int nx, int ny); void destroy_iarr2d(IArray2d a); typedef int*** IArray3d; IArray3d create_iarr3d(int nx, int ny, int nz); void destroy_iarr3d(IArray3d a); typedef double* DArray1d; DArray1d create_darr1d(int n); void destroy_darr1d(DArray1d a); typedef double** DArray2d; DArray2d create_darr2d(int nx, int ny); void destroy_darr2d(DArray2d a); typedef double*** DArray3d; DArray3d create_darr3d(int nx, int ny, int nz); void destroy_darr3d(DArray3d a); /* MPI stuff */ #ifdef USE_MPI #include "mpi.h" #ifdef OMPI_MPI_H /* openmpi does not use signals: we may install our sighandler */ #ifndef OPENACC /* ... but only if we are not also running on GPU */ #undef NOSIGNALS #endif #endif /* * MPI_MASTER(i): * execution of i only on master node */ #define MPI_MASTER(statement) { \ if(mpi_node_rank == mpi_node_root)\ { statement; } \ } #ifndef MPI_REDUCE_BLOCKSIZE #define MPI_REDUCE_BLOCKSIZE 100000 #endif int mc_MPI_Sum(double* buf, long count); int mc_MPI_Send(void *sbuf, long count, MPI_Datatype dtype, int dest); int mc_MPI_Recv(void *rbuf, long count, MPI_Datatype dtype, int source); /* MPI_Finalize exits gracefully and should be preferred to MPI_Abort */ #define exit(code) do { \ MPI_Finalize(); \ exit(code); \ } while(0) #else /* !USE_MPI */ #define MPI_MASTER(instr) instr #endif /* USE_MPI */ #ifdef USE_MPI static int mpi_node_count; #endif #ifdef USE_THREADS /* user want threads */ #error Threading (USE_THREADS) support has been removed for very poor efficiency. Use MPI/SSH grid instead. #endif void mcset_ncount(unsigned long long count); /* wrapper to get mcncount */ #pragma acc routine unsigned long long int mcget_ncount(void); /* wrapper to set mcncount */ unsigned long long mcget_run_num(void); /* wrapper to get mcrun_num=0:mcncount-1 */ /* Following part is only embedded when not redundant with mccode.h ========= */ #ifndef MCCODE_H #ifndef NOSIGNALS #include char *mcsig_message; #define SIG_MESSAGE(msg) mcsig_message=(char *)(msg); #else #define SIG_MESSAGE(...) #endif /* !NOSIGNALS */ /* Useful macros and constants ============================================== */ #ifndef FLT_MAX #define FLT_MAX 3.40282347E+38F /* max decimal value of a "float" */ #endif #ifndef MIN #define MIN(a, b) (((a) < (b)) ? (a) : (b)) #endif #ifndef MAX #define MAX(a, b) (((a) > (b)) ? (a) : (b)) #endif #ifndef SQR #define SQR(x) ( (x) * (x) ) #endif #ifndef SIGN #define SIGN(x) (((x)>0.0)?(1):(-1)) #endif # ifndef M_E # define M_E 2.71828182845904523536 // e # endif # ifndef M_LOG2E # define M_LOG2E 1.44269504088896340736 // log2(e) # endif # ifndef M_LOG10E # define M_LOG10E 0.434294481903251827651 // log10(e) # endif # ifndef M_LN2 # define M_LN2 0.693147180559945309417 // ln(2) # endif # ifndef M_LN10 # define M_LN10 2.30258509299404568402 // ln(10) # endif # ifndef M_PI # define M_PI 3.14159265358979323846 // pi # endif # ifndef PI # define PI M_PI // pi - also used in some places # endif # ifndef M_PI_2 # define M_PI_2 1.57079632679489661923 // pi/2 # endif # ifndef M_PI_4 # define M_PI_4 0.785398163397448309616 // pi/4 # endif # ifndef M_1_PI # define M_1_PI 0.318309886183790671538 // 1/pi # endif # ifndef M_2_PI # define M_2_PI 0.636619772367581343076 // 2/pi # endif # ifndef M_2_SQRTPI # define M_2_SQRTPI 1.12837916709551257390 // 2/sqrt(pi) # endif # ifndef M_SQRT2 # define M_SQRT2 1.41421356237309504880 // sqrt(2) # endif # ifndef M_SQRT1_2 # define M_SQRT1_2 0.707106781186547524401 // 1/sqrt(2) # endif #define RAD2MIN ((180*60)/PI) #define MIN2RAD (PI/(180*60)) #define DEG2RAD (PI/180) #define RAD2DEG (180/PI) #define FWHM2RMS 0.424660900144 /* Convert between full-width-half-max and */ #define RMS2FWHM 2.35482004503 /* root-mean-square (standard deviation) */ #define HBAR 1.05457168e-34 /* [Js] h bar Planck constant CODATA 2002 */ #define MNEUTRON 1.67492728e-27 /* [kg] mass of neutron CODATA 2002 */ #define GRAVITY 9.81 /* [m/s^2] gravitational acceleration */ #define NA 6.02214179e23 /* [#atoms/g .mole] Avogadro's number*/ #define UNSET nan("0x6E6F74736574") int nans_match(double, double); int is_unset(double); int is_valid(double); int is_set(double); int all_unset(int n, ...); int all_set(int n, ...); int any_unset(int n, ...); int any_set(int n, ...); /* wrapper to get absolute and relative position of comp */ /* mccomp_posa and mccomp_posr are defined in McStas generated C code */ #define POS_A_COMP_INDEX(index) (instrument->_position_absolute[index]) #define POS_R_COMP_INDEX(index) (instrument->_position_relative[index]) /* setting parameters based COMP_GETPAR (returned as pointer) */ /* compname must be given as a string, type and par are symbols. */ #define COMP_GETPAR3(type, compname, par) \ &( ((_class_ ## type ##_parameters *) _getvar_parameters(compname))->par ) /* the body of this function depends on component instances, and is cogen'd */ void* _getvar_parameters(char* compname); int _getcomp_index(char* compname); /* Note: The two-stage approach to COMP_GETPAR is NOT redundant; without it, * after #define C sample, COMP_GETPAR(C,x) would refer to component C, not to * component sample. Such are the joys of ANSI C. * Anyway the usage of COMP_GETPAR requires that we use sometimes bare names... * NOTE: This can ONLY be used in instrument descriptions, not components. */ #define COMP_GETPAR2(comp, par) (_ ## comp ## _var._parameters.par) #define COMP_GETPAR(comp, par) COMP_GETPAR2(comp,par) #define INSTRUMENT_GETPAR(par) (_instrument_var._parameters.par) /* Current component name, index, position and orientation */ /* These macros work because, using class-based functions, "comp" is usually * the local variable of the active/current component. */ #define INDEX_CURRENT_COMP (_comp->_index) #define NAME_CURRENT_COMP (_comp->_name) #define TYPE_CURRENT_COMP (_comp->_type) #define POS_A_CURRENT_COMP (_comp->_position_absolute) #define POS_R_CURRENT_COMP (_comp->_position_relative) #define ROT_A_CURRENT_COMP (_comp->_rotation_absolute) #define ROT_R_CURRENT_COMP (_comp->_rotation_relative) #define NAME_INSTRUMENT (instrument->_name) /* MCDISPLAY/trace and debugging message sent to stdout */ #ifdef MC_TRACE_ENABLED #define DEBUG #endif #ifdef DEBUG #define DEBUG_INSTR() if(!mcdotrace); else { printf("INSTRUMENT:\n"); printf("Instrument '%s' (%s)\n", instrument_name, instrument_source); } #define DEBUG_COMPONENT(name,c,t) if(!mcdotrace); else {\ printf("COMPONENT: \"%s\"\n" \ "POS: %g, %g, %g, %g, %g, %g, %g, %g, %g, %g, %g, %g\n", \ name, c.x, c.y, c.z, t[0][0], t[0][1], t[0][2], \ t[1][0], t[1][1], t[1][2], t[2][0], t[2][1], t[2][2]); \ fflush(stdout);\ printf("Component %30s AT (%g,%g,%g)\n", name, c.x, c.y, c.z);\ fflush(stdout);} #define DEBUG_INSTR_END() if(!mcdotrace); else printf("INSTRUMENT END:\n"); #define DEBUG_ENTER() if(!mcdotrace); else printf("ENTER:\n"); #define DEBUG_COMP(c) if(!mcdotrace); else printf("COMP: \"%s\"\n", c); #define DEBUG_LEAVE() if(!mcdotrace); else printf("LEAVE:\n"); #define DEBUG_ABSORB() if(!mcdotrace); else printf("ABSORB:\n"); #else #define DEBUG_INSTR() #define DEBUG_COMPONENT(name,c,t) #define DEBUG_INSTR_END() #define DEBUG_ENTER() #define DEBUG_COMP(c) #define DEBUG_LEAVE() #define DEBUG_ABSORB() #endif // mcDEBUG_STATE and mcDEBUG_SCATTER are defined by mcstas-r.h and mcxtrace-r.h #ifdef TEST #define test_printf printf #else #define test_printf while(0) printf #endif /* send MCDISPLAY message to stdout to show gemoetry */ void mcdis_magnify(char *what); void mcdis_line(double x1, double y1, double z1, double x2, double y2, double z2); void mcdis_dashed_line(double x1, double y1, double z1, double x2, double y2, double z2, int n); void mcdis_multiline(int count, ...); void mcdis_rectangle(char* plane, double x, double y, double z, double width, double height); void mcdis_box(double x, double y, double z, double width, double height, double length, double thickness, double nx, double ny, double nz); void mcdis_circle(char *plane, double x, double y, double z, double r); void mcdis_Circle(double x, double y, double z, double r, double nx, double ny, double nz); void mcdis_cylinder( double x, double y, double z, double r, double height, double thickness, double nx, double ny, double nz); void mcdis_cone( double x, double y, double z, double r, double height, double nx, double ny, double nz); void mcdis_sphere(double x, double y, double z, double r); /* random number generation. ================================================ */ #if RNG_ALG == _RNG_ALG_MT // MT (currently not functional for GPU) # define MC_RAND_MAX ((uint32_t)0xffffffffUL) # define RANDSTATE_LEN 1 # define srandom(seed) mt_srandom_empty() # define random() mt_random() # define _random() mt_random() #elif RNG_ALG == _RNG_ALG_KISS // KISS # ifndef UINT64_MAX # define UINT64_MAX ((uint64_t)0xffffffffffffffffULL) # endif # define MC_RAND_MAX UINT64_MAX # define RANDSTATE_LEN 7 # define srandom(seed) kiss_srandom(_particle->randstate, seed) # define random() kiss_random(_particle->randstate) # define _random() kiss_random(state) #endif #pragma acc routine double _randnorm2(randstate_t* state); // Component writer interface #define randnorm() _randnorm2(_particle->randstate) // NOTE: can't use _randnorm on GPU #define rand01() _rand01(_particle->randstate) #define randpm1() _randpm1(_particle->randstate) #define rand0max(p1) _rand0max(p1, _particle->randstate) #define randminmax(p1, p2) _randminmax(p1, p2, _particle->randstate) #define randtriangle() _randtriangle(_particle->randstate) // Mersenne Twister rng uint32_t mt_random(void); void mt_srandom (uint32_t x); void mt_srandom_empty(); // KISS rng #pragma acc routine uint64_t *kiss_srandom(uint64_t state[7], uint64_t seed); #pragma acc routine uint64_t kiss_random(uint64_t state[7]); // Scrambler / hash function #pragma acc routine seq randstate_t _hash(randstate_t x); // internal RNG (transforms) interface #pragma acc routine double _rand01(randstate_t* state); #pragma acc routine double _randpm1(randstate_t* state); #pragma acc routine double _rand0max(double max, randstate_t* state); #pragma acc routine double _randminmax(double min, double max, randstate_t* state); #pragma acc routine double _randtriangle(randstate_t* state); // version which pass randstate_t* as opague void* #pragma acc routine double _rand01_opague(void* state); #ifdef USE_OPENCL #include "opencl-lib.h" #include "opencl-lib.c" #endif #ifndef DANSE int init(void); int raytrace(_class_particle*); int save(FILE *); int finally(void); int display(void); #endif /* GPU related algorithms =================================================== */ /* * Divide-and-conquer strategy for parallel sort absorbed last. */ #ifdef FUNNEL long sort_absorb_last(_class_particle* particles, _class_particle* pbuffer, long len, long buffer_len, long flag_split, long* multiplier); #endif long sort_absorb_last_serial(_class_particle* particles, long len); /* simple vector algebra ==================================================== */ #define vec_prod(x, y, z, x1, y1, z1, x2, y2, z2) \ vec_prod_func(&x, &y, &z, x1, y1, z1, x2, y2, z2) #pragma acc routine seq mcstatic void vec_prod_func(double *x, double *y, double *z, double x1, double y1, double z1, double x2, double y2, double z2); #pragma acc routine seq mcstatic double scalar_prod( double x1, double y1, double z1, double x2, double y2, double z2); #pragma acc routine seq mcstatic void norm_func(double *x, double *y, double *z); #define NORM(x,y,z) norm_func(&x, &y, &z) #pragma acc routine seq void normal_vec(double *nx, double *ny, double *nz, double x, double y, double z); /** * Rotate the vector vx,vy,vz psi radians around the vector ax,ay,az * and put the result in x,y,z. */ #define rotate(x, y, z, vx, vy, vz, phi, ax, ay, az) \ do { \ double mcrt_tmpx = (ax), mcrt_tmpy = (ay), mcrt_tmpz = (az); \ double mcrt_vp, mcrt_vpx, mcrt_vpy, mcrt_vpz; \ double mcrt_vnx, mcrt_vny, mcrt_vnz, mcrt_vn1x, mcrt_vn1y, mcrt_vn1z; \ double mcrt_bx, mcrt_by, mcrt_bz; \ double mcrt_cos, mcrt_sin; \ NORM(mcrt_tmpx, mcrt_tmpy, mcrt_tmpz); \ mcrt_vp = scalar_prod((vx), (vy), (vz), mcrt_tmpx, mcrt_tmpy, mcrt_tmpz); \ mcrt_vpx = mcrt_vp*mcrt_tmpx; \ mcrt_vpy = mcrt_vp*mcrt_tmpy; \ mcrt_vpz = mcrt_vp*mcrt_tmpz; \ mcrt_vnx = (vx) - mcrt_vpx; \ mcrt_vny = (vy) - mcrt_vpy; \ mcrt_vnz = (vz) - mcrt_vpz; \ vec_prod(mcrt_bx, mcrt_by, mcrt_bz, \ mcrt_tmpx, mcrt_tmpy, mcrt_tmpz, mcrt_vnx, mcrt_vny, mcrt_vnz); \ mcrt_cos = cos((phi)); mcrt_sin = sin((phi)); \ mcrt_vn1x = mcrt_vnx*mcrt_cos + mcrt_bx*mcrt_sin; \ mcrt_vn1y = mcrt_vny*mcrt_cos + mcrt_by*mcrt_sin; \ mcrt_vn1z = mcrt_vnz*mcrt_cos + mcrt_bz*mcrt_sin; \ (x) = mcrt_vpx + mcrt_vn1x; \ (y) = mcrt_vpy + mcrt_vn1y; \ (z) = mcrt_vpz + mcrt_vn1z; \ } while(0) /** * Mirror (xyz) in the plane given by the point (rx,ry,rz) and normal (nx,ny,nz) * * TODO: This define is seemingly never used... */ #define mirror(x,y,z,rx,ry,rz,nx,ny,nz) \ do { \ double mcrt_tmpx= (nx), mcrt_tmpy = (ny), mcrt_tmpz = (nz); \ double mcrt_tmpt; \ NORM(mcrt_tmpx, mcrt_tmpy, mcrt_tmpz); \ mcrt_tmpt=scalar_prod((rx),(ry),(rz),mcrt_tmpx,mcrt_tmpy,mcrt_tmpz); \ (x) = rx -2 * mcrt_tmpt*mcrt_rmpx; \ (y) = ry -2 * mcrt_tmpt*mcrt_rmpy; \ (z) = rz -2 * mcrt_tmpt*mcrt_rmpz; \ } while (0) #pragma acc routine Coords coords_set(MCNUM x, MCNUM y, MCNUM z); #pragma acc routine Coords coords_get(Coords a, MCNUM *x, MCNUM *y, MCNUM *z); #pragma acc routine Coords coords_add(Coords a, Coords b); #pragma acc routine Coords coords_sub(Coords a, Coords b); #pragma acc routine Coords coords_neg(Coords a); #pragma acc routine Coords coords_scale(Coords b, double scale); #pragma acc routine double coords_sp(Coords a, Coords b); #pragma acc routine Coords coords_xp(Coords b, Coords c); #pragma acc routine double coords_len(Coords a); #pragma acc routine seq void coords_print(Coords a); #pragma acc routine seq mcstatic void coords_norm(Coords* c); #pragma acc routine seq void rot_set_rotation(Rotation t, double phx, double phy, double phz); #pragma acc routine seq int rot_test_identity(Rotation t); #pragma acc routine seq void rot_mul(Rotation t1, Rotation t2, Rotation t3); #pragma acc routine seq void rot_copy(Rotation dest, Rotation src); #pragma acc routine seq void rot_transpose(Rotation src, Rotation dst); #pragma acc routine seq Coords rot_apply(Rotation t, Coords a); #pragma acc routine seq void mccoordschange(Coords a, Rotation t, _class_particle *particle); #pragma acc routine seq void mccoordschange_polarisation(Rotation t, double *sx, double *sy, double *sz); double mcestimate_error(double N, double p1, double p2); void mcreadparams(void); /* this is now in mcstas-r.h and mcxtrace-r.h as the number of state parameters is no longer equal */ _class_particle mcgenstate(void); // trajectory/shape intersection routines #pragma acc routine seq int inside_rectangle(double, double, double, double); #pragma acc routine seq int box_intersect(double *dt_in, double *dt_out, double x, double y, double z, double vx, double vy, double vz, double dx, double dy, double dz); #pragma acc routine seq int cylinder_intersect(double *t0, double *t1, double x, double y, double z, double vx, double vy, double vz, double r, double h); #pragma acc routine seq int sphere_intersect(double *t0, double *t1, double x, double y, double z, double vx, double vy, double vz, double r); // second order equation roots #pragma acc routine seq int solve_2nd_order(double *t1, double *t2, double A, double B, double C); // random vector generation to shape // defines silently introducing _particle as the last argument #define randvec_target_circle(xo, yo, zo, solid_angle, xi, yi, zi, radius) \ _randvec_target_circle(xo, yo, zo, solid_angle, xi, yi, zi, radius, _particle) #define randvec_target_rect_angular(xo, yo, zo, solid_angle, xi, yi, zi, height, width, A) \ _randvec_target_rect_angular(xo, yo, zo, solid_angle, xi, yi, zi, height, width, A, _particle) #define randvec_target_rect_real(xo, yo, zo, solid_angle, xi, yi, zi, height, width, A, lx, ly, lz, order) \ _randvec_target_rect_real(xo, yo, zo, solid_angle, xi, yi, zi, height, width, A, lx, ly, lz, order, _particle) // defines forwarding to "inner" functions #define randvec_target_sphere randvec_target_circle #define randvec_target_rect(p0,p1,p2,p3,p4,p5,p6,p7,p8,p9) \ randvec_target_rect_real(p0,p1,p2,p3,p4,p5,p6,p7,p8,p9,0,0,0,1) // headers for randvec #pragma acc routine seq void _randvec_target_circle(double *xo, double *yo, double *zo, double *solid_angle, double xi, double yi, double zi, double radius, _class_particle* _particle); #pragma acc routine seq void _randvec_target_rect_angular(double *xo, double *yo, double *zo, double *solid_angle, double xi, double yi, double zi, double height, double width, Rotation A, _class_particle* _particle); #pragma acc routine seq void _randvec_target_rect_real(double *xo, double *yo, double *zo, double *solid_angle, double xi, double yi, double zi, double height, double width, Rotation A, double lx, double ly, double lz, int order, _class_particle* _particle); // this is the main() int mccode_main(int argc, char *argv[]); #endif /* !MCCODE_H */ #ifndef MCCODE_R_IO_H #define MCCODE_R_IO_H "$Revision$" #if (USE_NEXUS == 0) #undef USE_NEXUS #endif #ifndef CHAR_BUF_LENGTH #define CHAR_BUF_LENGTH 1024 #endif /* I/O section part ========================================================= */ /* ========================================================================== */ /* MCCODE_R_IO_C */ /* ========================================================================== */ /* main DETECTOR structure which stores most information to write to data files */ struct mcdetector_struct { char filename[CHAR_BUF_LENGTH]; /* file name of monitor */ double Position[3]; /* position of detector component*/ char position[CHAR_BUF_LENGTH]; /* position of detector component (string)*/ Rotation Rotation; /* position of detector component*/ char options[CHAR_BUF_LENGTH]; /* Monitor_nD style list-mode'options' (string)*/ char component[CHAR_BUF_LENGTH]; /* component instance name */ char nexuscomp[CHAR_BUF_LENGTH]; /* component naming in NeXus/HDF case */ char instrument[CHAR_BUF_LENGTH]; /* instrument name */ char type[CHAR_BUF_LENGTH]; /* data type, e.g. 0d, 1d, 2d, 3d */ char user[CHAR_BUF_LENGTH]; /* user name, e.g. HOME */ char date[CHAR_BUF_LENGTH]; /* date of simulation end/write time */ char title[CHAR_BUF_LENGTH]; /* title of detector */ char xlabel[CHAR_BUF_LENGTH]; /* X axis label */ char ylabel[CHAR_BUF_LENGTH]; /* Y axis label */ char zlabel[CHAR_BUF_LENGTH]; /* Z axis label */ char xvar[CHAR_BUF_LENGTH]; /* X variable name */ char yvar[CHAR_BUF_LENGTH]; /* Y variable name */ char zvar[CHAR_BUF_LENGTH]; /* Z variable name */ char ncount[CHAR_BUF_LENGTH]; /* number of events initially generated */ char limits[CHAR_BUF_LENGTH]; /* X Y Z limits, e.g. [xmin xmax ymin ymax zmin zmax] */ char variables[CHAR_BUF_LENGTH]; /* variables written into data block */ char statistics[CHAR_BUF_LENGTH]; /* center, mean and half width along axis */ char signal[CHAR_BUF_LENGTH]; /* min max and mean of signal (data block) */ char values[CHAR_BUF_LENGTH]; /* integrated values e.g. [I I_err N] */ double xmin,xmax; /* min max of axes */ double ymin,ymax; double zmin,zmax; double intensity; /* integrated values for data block */ double error; double events; double min; /* statistics for data block */ double max; double mean; double centerX; /* statistics for axes */ double halfwidthX; double centerY; double halfwidthY; int rank; /* dimensionaly of monitor, e.g. 0 1 2 3 */ char istransposed; /* flag to transpose matrix for some formats */ long m,n,p; /* dimensions of data block and along axes */ long date_l; /* same as date, but in sec since 1970 */ double *p0, *p1, *p2; /* pointers to saved data, NULL when freed */ char format[CHAR_BUF_LENGTH]; /* format for file generation */ }; typedef struct mcdetector_struct MCDETECTOR; static char *dirname = NULL; /* name of output directory */ static char *siminfo_name = "mccode"; /* default output sim file name */ char *mcformat = NULL; /* NULL (default) or a specific format */ /* file I/O definitions and function prototypes */ #ifndef MC_EMBEDDED_RUNTIME /* the mcstatic variables (from mccode-r.c) */ extern FILE * siminfo_file; /* handle to the output siminfo file */ extern int mcgravitation; /* flag to enable gravitation */ extern int mcdotrace; /* flag to print MCDISPLAY messages */ #else mcstatic FILE *siminfo_file = NULL; #endif /* I/O function prototypes ================================================== */ // from msysgit: https://code.google.com/p/msysgit/source/browse/compat/strcasestr.c char *strcasestr(const char *haystack, const char *needle); /* output functions */ MCDETECTOR mcdetector_out_0D(char *t, double p0, double p1, double p2, char *c, Coords pos, Rotation rot, int index); MCDETECTOR mcdetector_out_1D(char *t, char *xl, char *yl, char *xvar, double x1, double x2, long n, double *p0, double *p1, double *p2, char *f, char *c, Coords pos, Rotation rot, int index); MCDETECTOR mcdetector_out_2D(char *t, char *xl, char *yl, double x1, double x2, double y1, double y2, long m, long n, double *p0, double *p1, double *p2, char *f, char *c, Coords pos, Rotation rot, int index); MCDETECTOR mcdetector_out_list(char *t, char *xl, char *yl, long m, long n, double *p1, char *f, char *c, Coords posa, Rotation rot,char* options, int index); /* wrappers to output functions, that automatically set NAME and POSITION */ #define DETECTOR_OUT(p0,p1,p2) mcdetector_out_0D(NAME_CURRENT_COMP,p0,p1,p2,NAME_CURRENT_COMP,POS_A_CURRENT_COMP,ROT_A_CURRENT_COMP,INDEX_CURRENT_COMP) #define DETECTOR_OUT_0D(t,p0,p1,p2) mcdetector_out_0D(t,p0,p1,p2,NAME_CURRENT_COMP,POS_A_CURRENT_COMP,ROT_A_CURRENT_COMP,INDEX_CURRENT_COMP) #define DETECTOR_OUT_1D(t,xl,yl,xvar,x1,x2,n,p0,p1,p2,f) \ mcdetector_out_1D(t,xl,yl,xvar,x1,x2,n,p0,p1,p2,f,NAME_CURRENT_COMP,POS_A_CURRENT_COMP,ROT_A_CURRENT_COMP,INDEX_CURRENT_COMP) #define DETECTOR_OUT_2D(t,xl,yl,x1,x2,y1,y2,m,n,p0,p1,p2,f) \ mcdetector_out_2D(t,xl,yl,x1,x2,y1,y2,m,n,p0,p1,p2,f,NAME_CURRENT_COMP,POS_A_CURRENT_COMP,ROT_A_CURRENT_COMP,INDEX_CURRENT_COMP) #ifdef USE_NEXUS #include "napi.h" NXhandle nxhandle; #endif #endif /* ndef MCCODE_R_IO_H */ #endif /* MCCODE_R_H */ /* End of file "mccode-r.h". */ /* embedding file "mcstas-r.h" */ /******************************************************************************* * * McStas, neutron ray-tracing package * Copyright (C) 1997-2009, All rights reserved * Risoe National Laboratory, Roskilde, Denmark * Institut Laue Langevin, Grenoble, France * * Runtime: share/mcstas-r.h * * %Identification * Written by: KN * Date: Aug 29, 1997 * Release: McStas X.Y * Version: $Revision$ * * Runtime system header for McStas. * * In order to use this library as an external library, the following variables * and macros must be declared (see details in the code) * * struct mcinputtable_struct mcinputtable[]; * int mcnumipar; * char instrument_name[], instrument_source[]; * int traceenabled, defaultmain; * extern MCNUM mccomp_storein[]; * extern MCNUM instrument.counter_AbsorbProp[]; * extern MCNUM mcScattered; * #define MCCODE_STRING "the McStas version" * * Usage: Automatically embbeded in the c code. * * $Id$ * *******************************************************************************/ #ifndef MCSTAS_R_H #define MCSTAS_R_H "$Revision$" /* Following part is only embedded when not redundent with mcstas.h */ #ifndef MCCODE_H #define AA2MS 629.622368 /* Convert k[1/AA] to v[m/s] */ #define MS2AA 1.58825361e-3 /* Convert v[m/s] to k[1/AA] */ #define K2V AA2MS #define V2K MS2AA #define Q2V AA2MS #define V2Q MS2AA #define SE2V 437.393377 /* Convert sqrt(E)[meV] to v[m/s] */ #define VS2E 5.22703725e-6 /* Convert (v[m/s])**2 to E[meV] */ #define SCATTER0 do {DEBUG_SCATTER(); SCATTERED++;} while(0) #define SCATTER SCATTER0 void SCATTER_func(_class_particle *_particle); /* provides function to SCATTER from within libaries */ #define JUMPTOCOMP(comp) mcneutron->_index = INDEX_COMP(comp); #define MAGNET_ON \ do { \ mcMagnet = 1; \ } while(0) #define MAGNET_OFF \ do { \ mcMagnet = 0; \ } while(0) #define ALLOW_BACKPROP \ do { \ allow_backprop = 1; \ } while(0) #define DISALLOW_BACKPROP \ do { \ allow_backprop = 0; \ } while(0) #define PROP_MAGNET(dt) \ do { \ } while (0) /* change coordinates from local system to magnet system */ /* Rotation rotLM, rotTemp; \ Coords posLM = coords_sub(POS_A_CURRENT_COMP, mcMagnetPos); \ rot_transpose(ROT_A_CURRENT_COMP, rotTemp); \ rot_mul(rotTemp, mcMagnetRot, rotLM); \ mcMagnetPrecession(x, y, z, t, vx, vy, vz, \ &sx, &sy, &sz, dt, posLM, rotLM); \ } while(0) */ #define mcPROP_DT(dt) \ do { \ if (mcMagnet && dt > 0) PROP_MAGNET(dt);\ x += vx*(dt); \ y += vy*(dt); \ z += vz*(dt); \ t += (dt); \ if (isnan(p) || isinf(p)) { ABSORB; }\ } while(0) /* ADD: E. Farhi, Aug 6th, 2001 PROP_GRAV_DT propagation with acceleration */ #define PROP_GRAV_DT(dt, Ax, Ay, Az) \ do { \ if(dt < 0 && allow_backprop == 0) { ABSORB; }\ if (mcMagnet) /*printf("Spin precession gravity\n")*/; \ x += vx*(dt) + (Ax)*(dt)*(dt)/2; \ y += vy*(dt) + (Ay)*(dt)*(dt)/2; \ z += vz*(dt) + (Az)*(dt)*(dt)/2; \ vx += (Ax)*(dt); \ vy += (Ay)*(dt); \ vz += (Az)*(dt); \ t += (dt); \ DISALLOW_BACKPROP;\ } while(0) #define PROP_DT(dt) \ do { \ if(dt < 0 && allow_backprop == 0) { RESTORE=1; ABSORB; }; \ if (mcgravitation) { Coords mcLocG; double mc_gx, mc_gy, mc_gz; \ mcLocG = rot_apply(ROT_A_CURRENT_COMP, coords_set(0,-GRAVITY,0)); \ coords_get(mcLocG, &mc_gx, &mc_gy, &mc_gz); \ PROP_GRAV_DT(dt, mc_gx, mc_gy, mc_gz); } \ else mcPROP_DT(dt); \ DISALLOW_BACKPROP;\ } while(0) #define PROP_Z0 \ do { \ if (mcgravitation) { Coords mcLocG; int mc_ret; \ double mc_dt, mc_gx, mc_gy, mc_gz; \ mcLocG = rot_apply(ROT_A_CURRENT_COMP, coords_set(0,-GRAVITY,0)); \ coords_get(mcLocG, &mc_gx, &mc_gy, &mc_gz); \ mc_ret = solve_2nd_order(&mc_dt, NULL, -mc_gz/2, -vz, -z); \ if (mc_ret) {PROP_GRAV_DT(mc_dt, mc_gx, mc_gy, mc_gz); z=0;}\ else if (allow_backprop == 0 && mc_dt < 0) { ABSORB; }; } \ else mcPROP_Z0; \ DISALLOW_BACKPROP;\ } while(0) #define mcPROP_Z0 \ do { \ double mc_dt; \ if(vz == 0) { ABSORB; }; \ mc_dt = -z/vz; \ if(mc_dt < 0 && allow_backprop == 0) { ABSORB; }; \ mcPROP_DT(mc_dt); \ z = 0; \ DISALLOW_BACKPROP;\ } while(0) #define PROP_X0 \ do { \ if (mcgravitation) { Coords mcLocG; int mc_ret; \ double mc_dt, mc_gx, mc_gy, mc_gz; \ mcLocG = rot_apply(ROT_A_CURRENT_COMP, coords_set(0,-GRAVITY,0)); \ coords_get(mcLocG, &mc_gx, &mc_gy, &mc_gz); \ mc_ret = solve_2nd_order(&mc_dt, NULL, -mc_gx/2, -vx, -x); \ if (mc_ret) {PROP_GRAV_DT(mc_dt, mc_gx, mc_gy, mc_gz); x=0;}\ else if (allow_backprop == 0 && mc_dt < 0) { ABSORB; }; } \ else mcPROP_X0; \ DISALLOW_BACKPROP;\ } while(0) #define mcPROP_X0 \ do { \ double mc_dt; \ if(vx == 0) { ABSORB; }; \ mc_dt = -x/vx; \ if(mc_dt < 0 && allow_backprop == 0) { ABSORB; }; \ mcPROP_DT(mc_dt); \ x = 0; \ DISALLOW_BACKPROP;\ } while(0) #define PROP_Y0 \ do { \ if (mcgravitation) { Coords mcLocG; int mc_ret; \ double mc_dt, mc_gx, mc_gy, mc_gz; \ mcLocG = rot_apply(ROT_A_CURRENT_COMP, coords_set(0,-GRAVITY,0)); \ coords_get(mcLocG, &mc_gx, &mc_gy, &mc_gz); \ mc_ret = solve_2nd_order(&mc_dt, NULL, -mc_gy/2, -vy, -y); \ if (mc_ret) {PROP_GRAV_DT(mc_dt, mc_gx, mc_gy, mc_gz); y=0;}\ else if (allow_backprop == 0 && mc_dt < 0) { ABSORB; }; } \ else mcPROP_Y0; \ DISALLOW_BACKPROP;\ } while(0) #define mcPROP_Y0 \ do { \ double mc_dt; \ if(vy == 0) { ABSORB; }; \ mc_dt = -y/vy; \ if(mc_dt < 0 && allow_backprop == 0) { ABSORB; }; \ mcPROP_DT(mc_dt); \ y = 0; \ DISALLOW_BACKPROP; \ } while(0) #ifdef DEBUG #define DEBUG_STATE() if(!mcdotrace); else \ printf("STATE: %g, %g, %g, %g, %g, %g, %g, %g, %g, %g, %g\n", \ x,y,z,vx,vy,vz,t,sx,sy,sz,p); #define DEBUG_SCATTER() if(!mcdotrace); else \ printf("SCATTER: %g, %g, %g, %g, %g, %g, %g, %g, %g, %g, %g\n", \ x,y,z,vx,vy,vz,t,sx,sy,sz,p); #else #define DEBUG_STATE() #define DEBUG_SCATTER() #endif #endif /* !MCCODE_H */ #endif /* MCSTAS_R_H */ /* End of file "mcstas-r.h". */ /* embedding file "mccode-r.c" */ /******************************************************************************* * * McCode, neutron/xray ray-tracing package * Copyright (C) 1997-2009, All rights reserved * Risoe National Laboratory, Roskilde, Denmark * Institut Laue Langevin, Grenoble, France * * Runtime: share/mccode-r.c * * %Identification * Written by: KN * Date: Aug 29, 1997 * Release: McStas X.Y/McXtrace X.Y * Version: $Revision$ * * Runtime system for McStas and McXtrace. * Embedded within instrument in runtime mode. * Contains SECTIONS: * MPI handling (sum, send, recv) * format definitions * I/O * mcdisplay support * random numbers * coordinates handling * vectors math (solve 2nd order, normals, randvec...) * parameter handling * signal and main handlers * * Usage: Automatically embbeded in the c code whenever required. * * $Id$ * *******************************************************************************/ /******************************************************************************* * The I/O format definitions and functions *******************************************************************************/ /** Include header files to avoid implicit declarations (not allowed on LLVM) */ #include #include #ifndef _MSC_EXTENSIONS #include #else /* McCode includes its own 'dirent' for use with MSVC on Windows */ #include #define popen _popen #define pclose _pclose #endif #include // UNIX specific headers (non-Windows) #if defined(__unix__) || defined(__APPLE__) #include #include #endif #ifndef DANSE #ifdef MC_ANCIENT_COMPATIBILITY int traceenabled = 0; int defaultmain = 0; #endif /* else defined directly in the McCode generated C code */ static long mcseed = 0; /* seed for random generator */ #pragma acc declare create ( mcseed ) static long mcstartdate = 0; /* start simulation time */ static int mcdisable_output_files = 0; /* --no-output-files */ mcstatic int mcgravitation = 0; /* use gravitation flag, for PROP macros */ mcstatic int mcusedefaults = 0; /* assume default value for all parameters */ mcstatic int mcappend = 0; /* flag to allow append mode on datasets/directories */ mcstatic int mcdotrace = 0; /* flag for --trace and messages for DISPLAY */ mcstatic int mcnexus_embed_idf = 0; /* flag to embed xml-formatted IDF file for Mantid */ #pragma acc declare create ( mcdotrace ) int mcallowbackprop = 0; /* flag to enable negative/backprop */ /* OpenACC-related segmentation parameters: */ int vecsize = 128; int numgangs = 7813; long gpu_innerloop = 2147483647; /* Monitor_nD list/buffer-size default */ /* Starting value may be defined using -DND_BUFFER=N */ /* Can further be controlled dynamically using --bufsiz input */ long MONND_BUFSIZ = 10000000; #ifdef ND_BUFFER MONND_BUFSIZ = ND_BUFFER; #endif /* Number of particle histories to simulate. */ #ifdef NEUTRONICS mcstatic unsigned long long int mcncount = 1; mcstatic unsigned long long int mcrun_num = 0; #else #ifdef MCDEFAULT_NCOUNT mcstatic unsigned long long int mcncount = MCDEFAULT_NCOUNT; #else mcstatic unsigned long long int mcncount = 1000000; #endif #pragma acc declare create ( mcncount ) mcstatic unsigned long long int mcrun_num = 0; #pragma acc declare create ( mcrun_num ) #endif /* NEUTRONICS */ #else #include "mcstas-globals.h" #endif /* !DANSE */ #ifndef NX_COMPRESSION #define NX_COMPRESSION NX_COMP_NONE #endif /* String nullification on GPU and other replacements */ #ifdef OPENACC int noprintf() { return 0; } int str_comp(char *str1, char *str2) { while (*str1 && *str1 == *str2) { str1++; str2++; } return (*str1 - *str2); } size_t str_len(const char *s) { size_t len = 0; if(s != NULL) { while(*s != '\0') { ++len; ++s; } } return len; } #endif /* SECTION: Predefine (component) parameters ================================= */ int nans_match(double a, double b){ return (*(uint64_t*)&a == *(uint64_t*)&b); } int is_unset(double x){ return nans_match(x, UNSET); } int is_set(double x){ return !nans_match(x, UNSET); } int is_valid(double x){ return !isnan(x)||is_unset(x); } int all_unset(int n, ...){ va_list ptr; va_start(ptr, n); int ret=1; for (int i=0; i count-1) length=count-offset; else length=MPI_REDUCE_BLOCKSIZE; if (MPI_Allreduce((double*)(sbuf+offset), (double*)(rbuf+offset), length, MPI_DOUBLE, MPI_SUM, MPI_COMM_WORLD) != MPI_SUCCESS) return MPI_ERR_COUNT; offset += length; } for (i=0; i count-1) length=count-offset; else length=MPI_REDUCE_BLOCKSIZE; if (MPI_Send((void*)((char*)sbuf+offset*dsize), length, dtype, dest, tag++, MPI_COMM_WORLD) != MPI_SUCCESS) return MPI_ERR_COUNT; offset += length; } return MPI_SUCCESS; } /* mc_MPI_Send */ /******************************************************************************* * mc_MPI_Recv: Receives arrays from MPI nodes by blocks to avoid buffer limit * the buffer must have been allocated previously. *******************************************************************************/ int mc_MPI_Recv(void *sbuf, long count, MPI_Datatype dtype, int source) { int dsize; long offset=0; int tag=1; int length=MPI_REDUCE_BLOCKSIZE; /* defined in mccode-r.h */ if (!sbuf || count <= 0) return(MPI_SUCCESS); /* nothing to recv */ MPI_Type_size(dtype, &dsize); while (offset < count) { if (offset+length > count-1) length=count-offset; else length=MPI_REDUCE_BLOCKSIZE; if (MPI_Recv((void*)((char*)sbuf+offset*dsize), length, dtype, source, tag++, MPI_COMM_WORLD, MPI_STATUS_IGNORE) != MPI_SUCCESS) return MPI_ERR_COUNT; offset += length; } return MPI_SUCCESS; } /* mc_MPI_Recv */ #endif /* USE_MPI */ /* SECTION: parameters handling ============================================= */ /* Instrument input parameter type handling. */ /******************************************************************************* * mcparm_double: extract double value from 's' into 'vptr' *******************************************************************************/ static int mcparm_double(char *s, void *vptr) { char *p; double *v = (double *)vptr; if (!s) { *v = 0; return(1); } *v = strtod(s, &p); if(*s == '\0' || (p != NULL && *p != '\0') || errno == ERANGE) return 0; /* Failed */ else return 1; /* Success */ } /******************************************************************************* * mcparminfo_double: display parameter type double *******************************************************************************/ static char * mcparminfo_double(char *parmname) { return "double"; } /******************************************************************************* * mcparmerror_double: display error message when failed extract double *******************************************************************************/ static void mcparmerror_double(char *parm, char *val) { fprintf(stderr, "Error: Invalid value '%s' for floating point parameter %s (mcparmerror_double)\n", val, parm); } /******************************************************************************* * mcparmprinter_double: convert double to string *******************************************************************************/ static void mcparmprinter_double(char *f, void *vptr) { double *v = (double *)vptr; sprintf(f, "%g", *v); } /******************************************************************************* * mcparm_int: extract int value from 's' into 'vptr' *******************************************************************************/ static int mcparm_int(char *s, void *vptr) { char *p; int *v = (int *)vptr; long x; if (!s) { *v = 0; return(1); } *v = 0; x = strtol(s, &p, 10); if(x < INT_MIN || x > INT_MAX) return 0; /* Under/overflow */ *v = x; if(*s == '\0' || (p != NULL && *p != '\0') || errno == ERANGE) return 0; /* Failed */ else return 1; /* Success */ } /******************************************************************************* * mcparminfo_int: display parameter type int *******************************************************************************/ static char * mcparminfo_int(char *parmname) { return "int"; } /******************************************************************************* * mcparmerror_int: display error message when failed extract int *******************************************************************************/ static void mcparmerror_int(char *parm, char *val) { fprintf(stderr, "Error: Invalid value '%s' for integer parameter %s (mcparmerror_int)\n", val, parm); } /******************************************************************************* * mcparmprinter_int: convert int to string *******************************************************************************/ static void mcparmprinter_int(char *f, void *vptr) { int *v = (int *)vptr; sprintf(f, "%d", *v); } /******************************************************************************* * mcparm_string: extract char* value from 's' into 'vptr' (copy) *******************************************************************************/ static int mcparm_string(char *s, void *vptr) { char **v = (char **)vptr; if (!s) { *v = NULL; return(1); } *v = (char *)malloc(strlen(s) + 1); if(*v == NULL) { exit(-fprintf(stderr, "Error: Out of memory %li (mcparm_string).\n", (long)strlen(s) + 1)); } strcpy(*v, s); return 1; /* Success */ } /******************************************************************************* * mcparminfo_string: display parameter type string *******************************************************************************/ static char * mcparminfo_string(char *parmname) { return "string"; } /******************************************************************************* * mcparmerror_string: display error message when failed extract string *******************************************************************************/ static void mcparmerror_string(char *parm, char *val) { fprintf(stderr, "Error: Invalid value '%s' for string parameter %s (mcparmerror_string)\n", val, parm); } /******************************************************************************* * mcparmprinter_string: convert string to string (including esc chars) *******************************************************************************/ static void mcparmprinter_string(char *f, void *vptr) { char **v = (char **)vptr; char *p; if (!*v) { *f='\0'; return; } strcpy(f, ""); for(p = *v; *p != '\0'; p++) { switch(*p) { case '\n': strcat(f, "\\n"); break; case '\r': strcat(f, "\\r"); break; case '"': strcat(f, "\\\""); break; case '\\': strcat(f, "\\\\"); break; default: strncat(f, p, 1); } } /* strcat(f, "\""); */ } /* mcparmprinter_string */ /* now we may define the parameter structure, using previous functions */ static struct { int (*getparm)(char *, void *); char * (*parminfo)(char *); void (*error)(char *, char *); void (*printer)(char *, void *); } mcinputtypes[] = { { mcparm_int, mcparminfo_int, mcparmerror_int, mcparmprinter_int }, { mcparm_string, mcparminfo_string, mcparmerror_string, mcparmprinter_string }, { mcparm_string, mcparminfo_string, mcparmerror_string, mcparmprinter_string }, { mcparm_double, mcparminfo_double, mcparmerror_double, mcparmprinter_double }, { mcparm_double, mcparminfo_double, mcparmerror_double, mcparmprinter_double } }; /******************************************************************************* * mcestimate_error: compute sigma from N,p,p2 in Gaussian large numbers approx *******************************************************************************/ double mcestimate_error(double N, double p1, double p2) { double pmean, n1; if(N <= 1) return p1; pmean = p1 / N; n1 = N - 1; /* Note: underflow may cause p2 to become zero; the fabs() below guards against this. */ return sqrt((N/n1)*fabs(p2 - pmean*pmean)); } double (*mcestimate_error_p) (double V2, double psum, double p2sum)=mcestimate_error; /* ========================================================================== */ /* MCCODE_R_IO_C */ /* ========================================================================== */ #ifndef MCCODE_R_IO_C #define MCCODE_R_IO_C "$Revision$" /* SECTION: file i/o handling ================================================ */ #ifndef HAVE_STRCASESTR // from msysgit: https://code.google.com/p/msysgit/source/browse/compat/strcasestr.c char *strcasestr(const char *haystack, const char *needle) { int nlen = strlen(needle); int hlen = strlen(haystack) - nlen + 1; int i; for (i = 0; i < hlen; i++) { int j; for (j = 0; j < nlen; j++) { unsigned char c1 = haystack[i+j]; unsigned char c2 = needle[j]; if (toupper(c1) != toupper(c2)) goto next; } return (char *) haystack + i; next: ; } return NULL; } #endif #ifndef HAVE_STRCASECMP int strcasecmp( const char *s1, const char *s2 ) { int c1, c2; do { c1 = tolower( (unsigned char) *s1++ ); c2 = tolower( (unsigned char) *s2++ ); } while (c1 == c2 && c1 != 0); return c2 > c1 ? -1 : c1 > c2; } #endif #ifndef STRACPY /* this is a replacement to strncpy, but ensures that the copy ends with NULL */ /* http://stracpy.blogspot.fr/2011/04/stracpy-strncpy-replacement.html */ #define STRACPY char *stracpy(char *destination, const char *source, size_t amount) { if (!destination || !source || !amount) return(NULL); while(amount--) if((*destination++ = *source++) == '\0') break; *destination = '\0'; return destination; } #endif /******************************************************************************* * mcfull_file: allocates a full file name=dirname+file. Catenate extension if missing. *******************************************************************************/ char *mcfull_file(char *name, char *ext) { int dirlen=0; char *mem =NULL; dirlen = dirname ? strlen(dirname) : 0; mem = (char*)malloc(dirlen + strlen(name) + CHAR_BUF_LENGTH); if(!mem) { exit(-fprintf(stderr, "Error: Out of memory %li (mcfull_file)\n", (long)(dirlen + strlen(name) + 256))); } strcpy(mem, ""); /* prepend directory name to path if name does not contain a path */ if (dirlen > 0 && !strchr(name, MC_PATHSEP_C)) { strcat(mem, dirname); strcat(mem, MC_PATHSEP_S); } /* dirlen */ strcat(mem, name); if (!strchr(name, '.') && ext && strlen(ext)) { /* add extension if not in file name already */ strcat(mem, "."); strcat(mem, ext); } return(mem); } /* mcfull_file */ /******************************************************************************* * mcnew_file: opens a new file within dirname if non NULL * the file is opened in "a" (append, create if does not exist) * the extension 'ext' is added if the file name does not include one. * the last argument is set to 0 if file did not exist, else to 1. *******************************************************************************/ FILE *mcnew_file(char *name, char *ext, int *exists) { char *mem; FILE *file=NULL; if (!name || strlen(name) == 0 || mcdisable_output_files) return(NULL); mem = mcfull_file(name, ext); /* create dirname/name.ext */ /* check for existence */ file = fopen(mem, "r"); /* for reading -> fails if does not exist */ if (file) { fclose(file); *exists=1; } else *exists=0; /* open the file for writing/appending */ #ifdef USE_NEXUS if (mcformat && strcasestr(mcformat, "NeXus")) { /* NXhandle nxhandle is defined in the .h with USE_NEXUS */ NXaccess mode = (*exists ? NXACC_CREATE5 | NXACC_RDWR : NXACC_CREATE5); if (NXopen(mem, mode, &nxhandle) != NX_OK) file = NULL; else file = (FILE*)&nxhandle; /* to make it non NULL */ } else #endif file = fopen(mem, "a+"); if(!file) fprintf(stderr, "Warning: could not open output file '%s' for %s (mcnew_file)\n", mem, *exists ? "append" : "create"); free(mem); return file; } /* mcnew_file */ /******************************************************************************* * mcdetector_statistics: compute detector statistics, error bars, [x I I_err N] 1D * RETURN: updated detector structure * Used by: detector_import *******************************************************************************/ MCDETECTOR mcdetector_statistics( MCDETECTOR detector) { if (!detector.p1 || !detector.m) return(detector); /* compute statistics and update MCDETECTOR structure ===================== */ double sum_z = 0, min_z = 0, max_z = 0; double fmon_x =0, smon_x = 0, fmon_y =0, smon_y=0, mean_z=0; double Nsum=0, P2sum=0; double sum_xz = 0, sum_yz = 0, sum_x = 0, sum_y = 0, sum_x2z = 0, sum_y2z = 0; int i,j; char hasnan=0, hasinf=0; char israw = ((char*)strcasestr(detector.format,"raw") != NULL); double *this_p1=NULL; /* new 1D McCode array [x I E N]. Freed after writing data */ /* if McCode/PGPLOT and rank==1 we create a new m*4 data block=[x I E N] */ if (detector.rank == 1 && strcasestr(detector.format,"McCode")) { this_p1 = (double *)calloc(detector.m*detector.n*detector.p*4, sizeof(double)); if (!this_p1) exit(-fprintf(stderr, "Error: Out of memory creating %zi 1D " MCCODE_STRING " data set for file '%s' (detector_import)\n", detector.m*detector.n*detector.p*4*sizeof(double*), detector.filename)); } max_z = min_z = detector.p1[0]; /* compute sum and moments (not for lists) */ if (!strcasestr(detector.format,"list") && detector.m) for(j = 0; j < detector.n*detector.p; j++) { for(i = 0; i < detector.m; i++) { double x,y,z; double N, E; long index= !detector.istransposed ? i*detector.n*detector.p + j : i+j*detector.m; char hasnaninf=0; if (detector.m) x = detector.xmin + (i + 0.5)/detector.m*(detector.xmax - detector.xmin); else x = 0; if (detector.n && detector.p) y = detector.ymin + (j + 0.5)/detector.n/detector.p*(detector.ymax - detector.ymin); else y = 0; z = detector.p1[index]; N = detector.p0 ? detector.p0[index] : 1; E = detector.p2 ? detector.p2[index] : 0; if (detector.p2 && !israw) detector.p2[index] = (*mcestimate_error_p)(detector.p0[index],detector.p1[index],detector.p2[index]); /* set sigma */ if (detector.rank == 1 && this_p1 && strcasestr(detector.format,"McCode")) { /* fill-in 1D McCode array [x I E N] */ this_p1[index*4] = x; this_p1[index*4+1] = z; this_p1[index*4+2] = detector.p2 ? detector.p2[index] : 0; this_p1[index*4+3] = N; } if (isnan(z) || isnan(E) || isnan(N)) hasnaninf=hasnan=1; if (isinf(z) || isinf(E) || isinf(N)) hasnaninf=hasinf=1; /* compute stats integrals */ if (!hasnaninf) { sum_xz += x*z; sum_yz += y*z; sum_x += x; sum_y += y; sum_z += z; sum_x2z += x*x*z; sum_y2z += y*y*z; if (z > max_z) max_z = z; if (z < min_z) min_z = z; Nsum += N; P2sum += E; } } } /* for j */ /* compute 1st and 2nd moments. For lists, sum_z=0 so this is skipped. */ if (sum_z && detector.n*detector.m*detector.p) { fmon_x = sum_xz/sum_z; fmon_y = sum_yz/sum_z; smon_x = sum_x2z/sum_z-fmon_x*fmon_x; smon_x = smon_x > 0 ? sqrt(smon_x) : 0; smon_y = sum_y2z/sum_z-fmon_y*fmon_y; smon_y = smon_y > 0 ? sqrt(smon_y) : 0; mean_z = sum_z/detector.n/detector.m/detector.p; } /* store statistics into detector */ detector.intensity = sum_z; detector.error = Nsum ? (*mcestimate_error_p)(Nsum, sum_z, P2sum) : 0; detector.events = Nsum; detector.min = min_z; detector.max = max_z; detector.mean = mean_z; detector.centerX = fmon_x; detector.halfwidthX= smon_x; detector.centerY = fmon_y; detector.halfwidthY= smon_y; /* if McCode/PGPLOT and rank==1 replace p1 with new m*4 1D McCode and clear others */ if (detector.rank == 1 && this_p1 && strcasestr(detector.format,"McCode")) { detector.p1 = this_p1; detector.n = detector.m; detector.m = 4; detector.p0 = detector.p2 = NULL; detector.istransposed = 1; } if (detector.n*detector.m*detector.p > 1) snprintf(detector.signal, CHAR_BUF_LENGTH, "Min=%g; Max=%g; Mean=%g;", detector.min, detector.max, detector.mean); else strcpy(detector.signal, "None"); snprintf(detector.values, CHAR_BUF_LENGTH, "%g %g %g", detector.intensity, detector.error, detector.events); switch (detector.rank) { case 1: snprintf(detector.statistics, CHAR_BUF_LENGTH, "X0=%g; dX=%g;", detector.centerX, detector.halfwidthX); break; case 2: case 3: snprintf(detector.statistics, CHAR_BUF_LENGTH, "X0=%g; dX=%g; Y0=%g; dY=%g;", detector.centerX, detector.halfwidthX, detector.centerY, detector.halfwidthY); break; default: strcpy(detector.statistics, "None"); } if (hasnan) printf("WARNING: Nan detected in component/file %s %s\n", detector.component, strlen(detector.filename) ? detector.filename : ""); if (hasinf) printf("WARNING: Inf detected in component/file %s %s\n", detector.component, strlen(detector.filename) ? detector.filename : ""); return(detector); } /* mcdetector_statistics */ /******************************************************************************* * detector_import: build detector structure, merge non-lists from MPI * compute basic stat, write "Detector:" line * RETURN: detector structure. Invalid data if detector.p1 == NULL * Invalid detector sets m=0 and filename="" * Simulation data sets m=0 and filename=siminfo_name * This function is equivalent to the old 'mcdetector_out', returning a structure *******************************************************************************/ MCDETECTOR detector_import( char *format, char *component, char *title, long m, long n, long p, char *xlabel, char *ylabel, char *zlabel, char *xvar, char *yvar, char *zvar, double x1, double x2, double y1, double y2, double z1, double z2, char *filename, double *p0, double *p1, double *p2, Coords position, Rotation rotation, int index) { time_t t; /* for detector.date */ long date_l; /* date as a long number */ char istransposed=0; char c[CHAR_BUF_LENGTH]; /* temp var for signal label */ MCDETECTOR detector; /* build MCDETECTOR structure ============================================= */ /* make sure we do not have NULL for char fields */ /* these also apply to simfile */ strncpy (detector.filename, filename ? filename : "", CHAR_BUF_LENGTH); strncpy (detector.format, format ? format : "McCode" , CHAR_BUF_LENGTH); /* add extension if missing */ if (strlen(detector.filename) && !strchr(detector.filename, '.')) { /* add extension if not in file name already */ strcat(detector.filename, ".dat"); } strncpy (detector.component, component ? component : MCCODE_STRING " component", CHAR_BUF_LENGTH); #ifdef USE_NEXUS char pref[5]; if (index-1 < 10) { sprintf(pref,"000"); } else if (index-1 < 100) { sprintf(pref,"00"); } else if (index-1 < 1000) { sprintf(pref,"0"); } else if (index-1 < 10000) { sprintf(pref,""); } else { fprintf(stderr,"Error, no support for > 10000 comps at the moment!\n"); exit(-1); } sprintf(detector.nexuscomp,"%s%d_%s",pref,index-1,detector.component); #endif snprintf(detector.instrument, CHAR_BUF_LENGTH, "%s (%s)", instrument_name, instrument_source); snprintf(detector.user, CHAR_BUF_LENGTH, "%s on %s", getenv("USER") ? getenv("USER") : MCCODE_NAME, getenv("HOST") ? getenv("HOST") : "localhost"); time(&t); /* get current write time */ date_l = (long)t; /* same but as a long */ snprintf(detector.date, CHAR_BUF_LENGTH, "%s", ctime(&t)); if (strlen(detector.date)) detector.date[strlen(detector.date)-1] = '\0'; /* remove last \n in date */ detector.date_l = date_l; if (!mcget_run_num() || mcget_run_num() >= mcget_ncount()) snprintf(detector.ncount, CHAR_BUF_LENGTH, "%llu", mcget_ncount() #ifdef USE_MPI *mpi_node_count #endif ); else snprintf(detector.ncount, CHAR_BUF_LENGTH, "%g/%g", (double)mcget_run_num(), (double)mcget_ncount()); detector.p0 = p0; detector.p1 = p1; detector.p2 = p2; /* handle transposition (not for NeXus) */ if (!strcasestr(detector.format, "NeXus")) { if (m<0 || n<0 || p<0) istransposed = !istransposed; if (strcasestr(detector.format, "transpose")) istransposed = !istransposed; if (istransposed) { /* do the swap once for all */ long i=m; m=n; n=i; } } m=labs(m); n=labs(n); p=labs(p); /* make sure dimensions are positive */ detector.istransposed = istransposed; /* determine detector rank (dimensionality) */ if (!m || !n || !p || !p1) detector.rank = 4; /* invalid: exit with m=0 filename="" */ else if (m*n*p == 1) detector.rank = 0; /* 0D */ else if (n == 1 || m == 1) detector.rank = 1; /* 1D */ else if (p == 1) detector.rank = 2; /* 2D */ else detector.rank = 3; /* 3D */ /* from rank, set type */ switch (detector.rank) { case 0: strcpy(detector.type, "array_0d"); m=n=p=1; break; case 1: snprintf(detector.type, CHAR_BUF_LENGTH, "array_1d(%ld)", m*n*p); m *= n*p; n=p=1; break; case 2: if(!strcasestr(detector.format,"list")) { snprintf(detector.type, CHAR_BUF_LENGTH, "array_2d(%ld, %ld)", m, n*p); n *= p; p=1; } else { snprintf(detector.type, CHAR_BUF_LENGTH, "list(%ld, %ld)", m, n*p); n *= p; p=1; } break; case 3: snprintf(detector.type, CHAR_BUF_LENGTH, "array_3d(%ld, %ld, %ld)", m, n, p); break; default: m=0; strcpy(detector.type, ""); strcpy(detector.filename, "");/* invalid */ } detector.m = m; detector.n = n; detector.p = p; /* these only apply to detector files ===================================== */ detector.Position[0]=position.x; detector.Position[1]=position.y; detector.Position[2]=position.z; rot_copy(detector.Rotation,rotation); snprintf(detector.position, CHAR_BUF_LENGTH, "%g %g %g", position.x, position.y, position.z); /* may also store actual detector orientation in the future */ strncpy(detector.title, title && strlen(title) ? title : component, CHAR_BUF_LENGTH); strncpy(detector.xlabel, xlabel && strlen(xlabel) ? xlabel : "X", CHAR_BUF_LENGTH); /* axis labels */ strncpy(detector.ylabel, ylabel && strlen(ylabel) ? ylabel : "Y", CHAR_BUF_LENGTH); strncpy(detector.zlabel, zlabel && strlen(zlabel) ? zlabel : "Z", CHAR_BUF_LENGTH); strncpy(detector.xvar, xvar && strlen(xvar) ? xvar : "x", CHAR_BUF_LENGTH); /* axis variables */ strncpy(detector.yvar, yvar && strlen(yvar) ? yvar : detector.xvar, CHAR_BUF_LENGTH); strncpy(detector.zvar, zvar && strlen(zvar) ? zvar : detector.yvar, CHAR_BUF_LENGTH); /* set "variables" as e.g. "I I_err N" */ strcpy(c, "I "); if (strlen(detector.zvar)) strncpy(c, detector.zvar,32); else if (strlen(detector.yvar)) strncpy(c, detector.yvar,32); else if (strlen(detector.xvar)) strncpy(c, detector.xvar,32); if (detector.rank == 1) snprintf(detector.variables, CHAR_BUF_LENGTH, "%s %s %s_err N", detector.xvar, c, c); else snprintf(detector.variables, CHAR_BUF_LENGTH, "%s %s_err N", c, c); /* limits */ detector.xmin = x1; detector.xmax = x2; detector.ymin = y1; detector.ymax = y2; detector.zmin = z1; detector.zmax = z2; if (abs(detector.rank) == 1) snprintf(detector.limits, CHAR_BUF_LENGTH, "%g %g", x1, x2); else if (detector.rank == 2) snprintf(detector.limits, CHAR_BUF_LENGTH, "%g %g %g %g", x1, x2, y1, y2); else snprintf(detector.limits, CHAR_BUF_LENGTH, "%g %g %g %g %g %g", x1, x2, y1, y2, z1, z2); /* if MPI and nodes_nb > 1: reduce data sets when using MPI =============== */ #ifdef USE_MPI if (!strcasestr(detector.format,"list") && mpi_node_count > 1 && m) { /* we save additive data: reduce everything into mpi_node_root */ if (p0) mc_MPI_Sum(p0, m*n*p); if (p1) mc_MPI_Sum(p1, m*n*p); if (p2) mc_MPI_Sum(p2, m*n*p); if (!p0) { /* additive signal must be then divided by the number of nodes */ int i; for (i=0; i CHAR_BUF_LENGTH) break; snprintf(ThisParam, CHAR_BUF_LENGTH, " %s(%s)", mcinputtable[i].name, (*mcinputtypes[mcinputtable[i].type].parminfo) (mcinputtable[i].name)); if (strlen(Parameters) + strlen(ThisParam) + 1 >= CHAR_BUF_LENGTH) break; strcat(Parameters, ThisParam); } /* output data ============================================================ */ if (f != stdout) fprintf(f, "%sFile: %s%c%s\n", pre, dirname, MC_PATHSEP_C, siminfo_name); else fprintf(f, "%sCreator: %s\n", pre, MCCODE_STRING); fprintf(f, "%sSource: %s\n", pre, instrument_source); fprintf(f, "%sParameters: %s\n", pre, Parameters); fprintf(f, "%sTrace_enabled: %s\n", pre, traceenabled ? "yes" : "no"); fprintf(f, "%sDefault_main: %s\n", pre, defaultmain ? "yes" : "no"); #ifdef MC_EMBEDDED_RUNTIME fprintf(f, "%sEmbedded_runtime: %s\n", pre, "yes"); #else fprintf(f, "%sEmbedded_runtime: %s\n", pre, "no"); #endif fflush(f); } /* mcinfo_out */ /******************************************************************************* * mcruninfo_out: output simulation tags/info (both in SIM and data files) * Used in: siminfo_init (ascii case), mcdetector_out_xD_ascii *******************************************************************************/ static void mcruninfo_out(char *pre, FILE *f) { int i; char Parameters[CHAR_BUF_LENGTH]; if (!f || mcdisable_output_files) return; fprintf(f, "%sFormat: %s%s\n", pre, mcformat && strlen(mcformat) ? mcformat : MCCODE_NAME, mcformat && strcasestr(mcformat,"McCode") ? " with text headers" : ""); fprintf(f, "%sURL: %s\n", pre, "http://www.mccode.org"); fprintf(f, "%sCreator: %s\n", pre, MCCODE_STRING); fprintf(f, "%sInstrument: %s\n", pre, instrument_source); fprintf(f, "%sNcount: %llu\n", pre, mcget_ncount()); fprintf(f, "%sTrace: %s\n", pre, mcdotrace ? "yes" : "no"); fprintf(f, "%sGravitation: %s\n", pre, mcgravitation ? "yes" : "no"); snprintf(Parameters, CHAR_BUF_LENGTH, "%ld", mcseed); fprintf(f, "%sSeed: %s\n", pre, Parameters); fprintf(f, "%sDirectory: %s\n", pre, dirname ? dirname : "."); #ifdef USE_MPI if (mpi_node_count > 1) fprintf(f, "%sNodes: %i\n", pre, mpi_node_count); #endif // TODO Consider replacing this by a a call to `mcparameterinfo_out(pre+"Param: ", f)` /* output parameter string ================================================ */ for(i = 0; i < numipar; i++) { if (mcinputtable[i].par){ /* Parameters with a default value */ if(mcinputtable[i].val && strlen(mcinputtable[i].val)){ (*mcinputtypes[mcinputtable[i].type].printer)(Parameters, mcinputtable[i].par); fprintf(f, "%sParam: %s=%s\n", pre, mcinputtable[i].name, Parameters); /* ... and those without */ }else{ fprintf(f, "%sParam: %s=NULL\n", pre, mcinputtable[i].name); } } } fflush(f); } /* mcruninfo_out */ /******************************************************************************* * @brief Print parameter information to the specified file * @param pre any beginning-of-line padding * @param f the output file */ static void mcparameterinfo_out(char * pre, FILE *f){ if (!f || mcdisable_output_files) return; unsigned int nchar = 4; for (int i=0; i < numipar; ++i){ if (mcinputtable[i].par && mcinputtable[i].val && strlen(mcinputtable[i].val) > nchar) nchar = strlen(mcinputtable[i].val); } char * buffer = calloc(nchar+1, sizeof(char)); if (!buffer) { exit(1); } for (int i=0; i < numipar; ++i) { if (mcinputtable[i].par) { char * name = mcinputtable[i].name; if (mcinputtable[i].val && strlen(mcinputtable[i].val)) { mcinputtypes[mcinputtable[i].type].printer(buffer, mcinputtable[i].par); } else { strcpy(buffer, "NULL"); } if (strlen(mcinputtable[i].unit)){ //fprintf(f, "%s%s %s (\"%s\") = %s\n", pre, mcinputtypes[mcinputtable[i].type].parminfo(name), name, mcinputtable[i].unit, buffer); fprintf(f, "%s%s %s/\"%s\" = %s\n", pre, mcinputtypes[mcinputtable[i].type].parminfo(name), name, mcinputtable[i].unit, buffer); } else { fprintf(f, "%s%s %s = %s\n", pre, mcinputtypes[mcinputtable[i].type].parminfo(name), name, buffer); } } } free(buffer); } /******************************************************************************* * siminfo_out: wrapper to fprintf(siminfo_file) *******************************************************************************/ void siminfo_out(char *format, ...) { va_list ap; if(siminfo_file && !mcdisable_output_files) { va_start(ap, format); vfprintf(siminfo_file, format, ap); va_end(ap); } } /* siminfo_out */ /******************************************************************************* * mcdatainfo_out: output detector header * mcdatainfo_out(prefix, file_handle, detector) writes info to data file *******************************************************************************/ static void mcdatainfo_out(char *pre, FILE *f, MCDETECTOR detector) { if (!f || !detector.m || mcdisable_output_files) return; /* output data ============================================================ */ fprintf(f, "%sDate: %s (%li)\n", pre, detector.date, detector.date_l); fprintf(f, "%stype: %s\n", pre, detector.type); fprintf(f, "%sSource: %s\n", pre, detector.instrument); fprintf(f, "%scomponent: %s\n", pre, detector.component); fprintf(f, "%sposition: %s\n", pre, detector.position); fprintf(f, "%stitle: %s\n", pre, detector.title); fprintf(f, !mcget_run_num() || mcget_run_num() >= mcget_ncount() ? "%sNcount: %s\n" : "%sratio: %s\n", pre, detector.ncount); if (strlen(detector.filename)) { fprintf(f, "%sfilename: %s\n", pre, detector.filename); } fprintf(f, "%sstatistics: %s\n", pre, detector.statistics); fprintf(f, "%ssignal: %s\n", pre, detector.signal); fprintf(f, "%svalues: %s\n", pre, detector.values); if (detector.rank >= 1) { fprintf(f, "%sxvar: %s\n", pre, detector.xvar); fprintf(f, "%syvar: %s\n", pre, detector.yvar); fprintf(f, "%sxlabel: %s\n", pre, detector.xlabel); fprintf(f, "%sylabel: %s\n", pre, detector.ylabel); if (detector.rank > 1) { fprintf(f, "%szvar: %s\n", pre, detector.zvar); fprintf(f, "%szlabel: %s\n", pre, detector.zlabel); } } fprintf(f, abs(detector.rank)==1 ? "%sxlimits: %s\n" : "%sxylimits: %s\n", pre, detector.limits); fprintf(f, "%svariables: %s\n", pre, strcasestr(detector.format, "list") ? detector.ylabel : detector.variables); fflush(f); } /* mcdatainfo_out */ /* mcdetector_out_array_ascii: output a single array to a file * m: columns * n: rows * p: array * f: file handle (already opened) */ static void mcdetector_out_array_ascii(long m, long n, double *p, FILE *f, char istransposed) { if(f) { int i,j; for(j = 0; j < n; j++) { for(i = 0; i < m; i++) { fprintf(f, "%.10g ", p[!istransposed ? i*n + j : j*m+i]); } fprintf(f,"\n"); } } } /* mcdetector_out_array_ascii */ /******************************************************************************* * mcdetector_out_0D_ascii: called by mcdetector_out_0D for ascii output *******************************************************************************/ MCDETECTOR mcdetector_out_0D_ascii(MCDETECTOR detector) { int exists=0; FILE *outfile = NULL; /* Write data set information to simulation description file. */ MPI_MASTER( siminfo_out("\nbegin data\n"); // detector.component mcdatainfo_out(" ", siminfo_file, detector); siminfo_out("end data\n"); /* Don't write if filename is NULL: mcnew_file handles this (return NULL) */ outfile = mcnew_file(detector.component, "dat", &exists); if(outfile) { /* write data file header and entry in simulation description file */ mcruninfo_out( "# ", outfile); mcdatainfo_out("# ", outfile, detector); /* write I I_err N */ fprintf(outfile, "%g %g %g\n", detector.intensity, detector.error, detector.events); fclose(outfile); } ); /* MPI_MASTER */ return(detector); } /* mcdetector_out_0D_ascii */ /******************************************************************************* * mcdetector_out_1D_ascii: called by mcdetector_out_1D for ascii output *******************************************************************************/ MCDETECTOR mcdetector_out_1D_ascii(MCDETECTOR detector) { int exists=0; FILE *outfile = NULL; MPI_MASTER( /* Write data set information to simulation description file. */ siminfo_out("\nbegin data\n"); // detector.filename mcdatainfo_out(" ", siminfo_file, detector); siminfo_out("end data\n"); /* Loop over array elements, writing to file. */ /* Don't write if filename is NULL: mcnew_file handles this (return NULL) */ outfile = mcnew_file(detector.filename, "dat", &exists); if(outfile) { /* write data file header and entry in simulation description file */ mcruninfo_out( "# ", outfile); mcdatainfo_out("# ", outfile, detector); /* output the 1D array columns */ mcdetector_out_array_ascii(detector.m, detector.n, detector.p1, outfile, detector.istransposed); fclose(outfile); } ); /* MPI_MASTER */ return(detector); } /* mcdetector_out_1D_ascii */ /******************************************************************************* * mcdetector_out_2D_ascii: called by mcdetector_out_2D for ascii output *******************************************************************************/ MCDETECTOR mcdetector_out_2D_ascii(MCDETECTOR detector) { int exists=0; FILE *outfile = NULL; MPI_MASTER( /* Loop over array elements, writing to file. */ /* Don't write if filename is NULL: mcnew_file handles this (return NULL) */ outfile = mcnew_file(detector.filename, "dat", &exists); if(outfile) { /* write header only if file has just been created (not appending) */ if (!exists) { /* Write data set information to simulation description file. */ siminfo_out("\nbegin data\n"); // detector.filename mcdatainfo_out(" ", siminfo_file, detector); siminfo_out("end data\n"); mcruninfo_out( "# ", outfile); mcdatainfo_out("# ", outfile, detector); } /* Add # Data entry for any write to the file (e.g. via -USR2, see GitHub issue #2174 ) */ fprintf(outfile, "# Data [%s/%s] %s:\n", detector.component, detector.filename, detector.zvar); mcdetector_out_array_ascii(detector.m, detector.n*detector.p, detector.p1, outfile, detector.istransposed); if (detector.p2) { fprintf(outfile, "# Errors [%s/%s] %s_err:\n", detector.component, detector.filename, detector.zvar); mcdetector_out_array_ascii(detector.m, detector.n*detector.p, detector.p2, outfile, detector.istransposed); } if (detector.p0) { fprintf(outfile, "# Events [%s/%s] N:\n", detector.component, detector.filename); mcdetector_out_array_ascii(detector.m, detector.n*detector.p, detector.p0, outfile, detector.istransposed); } fclose(outfile); if (!exists) { if (strcasestr(detector.format, "list")) printf("Events: \"%s\"\n", strlen(detector.filename) ? detector.filename : detector.component); } } /* if outfile */ ); /* MPI_MASTER */ #ifdef USE_MPI if (strcasestr(detector.format, "list") && mpi_node_count > 1) { int node_i=0; /* loop along MPI nodes to write sequentially */ for(node_i=0; node_i strlen(original)) n = strlen(original); else original += strlen(original)-n; strncpy(valid, original, n); for (i=0; i < n; i++) { if ( (valid[i] > 122) || (valid[i] < 32) || (strchr("!\"#$%&'()*+,-.:;<=>?@[\\]^`/ \n\r\t", valid[i]) != NULL) ) { if (i) valid[i] = '_'; else valid[i] = 'm'; } } valid[i] = '\0'; return(valid); } /* strcpy_valid */ /* end ascii output section ================================================= */ #ifdef USE_NEXUS /* ========================================================================== */ /* NeXus output */ /* ========================================================================== */ #define nxprintf(...) nxstr('d', __VA_ARGS__) #define nxprintattr(...) nxstr('a', __VA_ARGS__) /******************************************************************************* * nxstr: output a tag=value data set (char) in NeXus/current group * when 'format' is larger that 1024 chars it is used as value for the 'tag' * else the value is assembled with format and following arguments. * type='d' -> data set * 'a' -> attribute for current data set *******************************************************************************/ static int nxstr(char type, NXhandle *f, char *tag, char *format, ...) { va_list ap; char value[CHAR_BUF_LENGTH]; int i; int ret=NX_OK; if (!tag || !format || !strlen(tag) || !strlen(format)) return(NX_OK); /* assemble the value string */ if (strlen(format) < CHAR_BUF_LENGTH) { va_start(ap, format); ret = vsnprintf(value, CHAR_BUF_LENGTH, format, ap); va_end(ap); i = strlen(value); } else { i = strlen(format); } if (type == 'd') { /* open/put/close data set */ if (NXmakedata (f, tag, NX_CHAR, 1, &i) != NX_OK) return(NX_ERROR); NXopendata (f, tag); if (strlen(format) < CHAR_BUF_LENGTH) ret = NXputdata (f, value); else ret = NXputdata (f, format); NXclosedata(f); } else { if (strlen(format) < CHAR_BUF_LENGTH) ret = NXputattr (f, tag, value, strlen(value), NX_CHAR); else ret = NXputattr (f, tag, format, strlen(format), NX_CHAR); } return(ret); } /* nxstr */ /******************************************************************************* * mcinfo_readfile: read a full file into a string buffer which is allocated * Think to free the buffer after use. * Used in: mcinfo_out_nexus (nexus) *******************************************************************************/ char *mcinfo_readfile(char *filename) { FILE *f = fopen(filename, "rb"); if (!f) return(NULL); fseek(f, 0, SEEK_END); long fsize = ftell(f); rewind(f); char *string = malloc(fsize + 1); if (string) { int n = fread(string, fsize, 1, f); fclose(f); string[fsize] = 0; } return(string); } /******************************************************************************* * mcinfo_out: output instrument/simulation groups in NeXus file * Used in: siminfo_init (nexus) *******************************************************************************/ static void mcinfo_out_nexus(NXhandle f) { FILE *fid; /* for intrument source code/C/IDF */ char *buffer=NULL; time_t t =time(NULL); /* for date */ char entry0[CHAR_BUF_LENGTH]; int count=0; char name[CHAR_BUF_LENGTH]; char class[CHAR_BUF_LENGTH]; if (!f || mcdisable_output_files) return; /* write NeXus NXroot attributes */ /* automatically added: file_name, HDF5_Version, file_time, NeXus_version */ nxprintattr(f, "creator", "%s generated with " MCCODE_STRING, instrument_name); /* count the number of existing NXentry and create the next one */ NXgetgroupinfo(f, &count, name, class); sprintf(entry0, "entry%i", count+1); /* create the main NXentry (mandatory in NeXus) */ if (NXmakegroup(f, entry0, "NXentry") == NX_OK) if (NXopengroup(f, entry0, "NXentry") == NX_OK) { nxprintf(nxhandle, "program_name", MCCODE_STRING); nxprintf(f, "start_time", ctime(&t)); nxprintf(f, "title", "%s%s%s simulation generated by instrument %s", dirname && strlen(dirname) ? dirname : ".", MC_PATHSEP_S, siminfo_name, instrument_name); nxprintattr(f, "program_name", MCCODE_STRING); nxprintattr(f, "instrument", instrument_name); nxprintattr(f, "simulation", "%s%s%s", dirname && strlen(dirname) ? dirname : ".", MC_PATHSEP_S, siminfo_name); /* write NeXus instrument group */ if (NXmakegroup(f, "instrument", "NXinstrument") == NX_OK) if (NXopengroup(f, "instrument", "NXinstrument") == NX_OK) { int i; char *string=NULL; /* write NeXus parameters(types) data =================================== */ string = (char*)malloc(CHAR_BUF_LENGTH); if (string) { strcpy(string, ""); for(i = 0; i < numipar; i++) { char ThisParam[CHAR_BUF_LENGTH]; snprintf(ThisParam, CHAR_BUF_LENGTH, " %s(%s)", mcinputtable[i].name, (*mcinputtypes[mcinputtable[i].type].parminfo) (mcinputtable[i].name)); if (strlen(string) + strlen(ThisParam) < CHAR_BUF_LENGTH) strcat(string, ThisParam); } nxprintattr(f, "Parameters", string); free(string); } nxprintattr(f, "name", instrument_name); nxprintf (f, "name", instrument_name); nxprintattr(f, "Source", instrument_source); nxprintattr(f, "Trace_enabled", traceenabled ? "yes" : "no"); nxprintattr(f, "Default_main", defaultmain ? "yes" : "no"); #ifdef MC_EMBEDDED_RUNTIME nxprintattr(f, "Embedded_runtime", "yes"); #else nxprintattr(f, "Embedded_runtime", "no"); #endif /* add instrument source code when available */ buffer = mcinfo_readfile(instrument_source); if (buffer && strlen(buffer)) { long length=strlen(buffer); nxprintf (f, "description", buffer); NXopendata(f,"description"); nxprintattr(f, "file_name", instrument_source); nxprintattr(f, "file_size", "%li", length); nxprintattr(f, "MCCODE_STRING", MCCODE_STRING); NXclosedata(f); nxprintf (f,"instrument_source", "%s " MCCODE_NAME " " MCCODE_PARTICLE " Monte Carlo simulation", instrument_name); free(buffer); } else nxprintf (f, "description", "File %s not found (instrument description %s is missing)", instrument_source, instrument_name); if (mcnexus_embed_idf) { /* add Mantid/IDF.xml when available */ char *IDFfile=NULL; IDFfile = (char*)malloc(CHAR_BUF_LENGTH); sprintf(IDFfile,"%s%s",instrument_source,".xml"); buffer = mcinfo_readfile(IDFfile); if (buffer && strlen(buffer)) { NXmakegroup (nxhandle, "instrument_xml", "NXnote"); NXopengroup (nxhandle, "instrument_xml", "NXnote"); nxprintf(f, "data", buffer); nxprintf(f, "description", "IDF.xml file found with instrument %s", instrument_source); nxprintf(f, "type", "text/xml"); NXclosegroup(f); /* instrument_xml */ free(buffer); } free(IDFfile); } /* Add "components" entry */ if (NXmakegroup(f, "components", "NXdata") == NX_OK) { NXopengroup(f, "components", "NXdata"); nxprintattr(f, "description", "Component list for instrument %s", instrument_name); NXclosegroup(f); /* components */ } else { printf("Failed to create NeXus component hierarchy\n"); } NXclosegroup(f); /* instrument */ } /* NXinstrument */ /* write NeXus simulation group */ if (NXmakegroup(f, "simulation", "NXnote") == NX_OK) if (NXopengroup(f, "simulation", "NXnote") == NX_OK) { nxprintattr(f, "name", "%s%s%s", dirname && strlen(dirname) ? dirname : ".", MC_PATHSEP_S, siminfo_name); nxprintf (f, "name", "%s", siminfo_name); nxprintattr(f, "Format", mcformat && strlen(mcformat) ? mcformat : MCCODE_NAME); nxprintattr(f, "URL", "http://www.mccode.org"); nxprintattr(f, "program", MCCODE_STRING); nxprintattr(f, "Instrument",instrument_source); nxprintattr(f, "Trace", mcdotrace ? "yes" : "no"); nxprintattr(f, "Gravitation",mcgravitation ? "yes" : "no"); nxprintattr(f, "Seed", "%li", mcseed); nxprintattr(f, "Directory", dirname); #ifdef USE_MPI if (mpi_node_count > 1) nxprintf(f, "Nodes", "%i", mpi_node_count); #endif /* output parameter string ================================================ */ if (NXmakegroup(f, "Param", "NXparameters") == NX_OK) { NXopengroup(f,"Param", "NXparameters"); int i; char string[CHAR_BUF_LENGTH]; for(i = 0; i < numipar; i++) { if (mcget_run_num() || (mcinputtable[i].val && strlen(mcinputtable[i].val))) { if (mcinputtable[i].par == NULL) strncpy(string, (mcinputtable[i].val ? mcinputtable[i].val : ""), CHAR_BUF_LENGTH); else (*mcinputtypes[mcinputtable[i].type].printer)(string, mcinputtable[i].par); nxprintf(f, mcinputtable[i].name, "%s", string); nxprintattr(f, mcinputtable[i].name, string); } } NXclosegroup(f); /* Param */ } /* NXparameters */ NXclosegroup(f); /* simulation */ } /* NXsimulation */ /* create a group to hold all links for all monitors */ NXmakegroup(f, "data", "NXdetector"); /* leave the NXentry opened (closed at exit) */ } /* NXentry */ } /* mcinfo_out_nexus */ /******************************************************************************* * mccomp_placement_type_nexus: * Places * - absolute (3x1) position * - absolute (3x3) rotation * - type / class of component instance into attributes under * entry/instrument/compname * requires: NXentry to be opened *******************************************************************************/ static void mccomp_placement_type_nexus(NXhandle nxhandle, char* component, Coords position, Rotation rotation, char* comptype) { /* open NeXus instrument group */ #ifdef USE_NEXUS if(nxhandle) { if (NXopengroup(nxhandle, "instrument", "NXinstrument") == NX_OK) { if (NXopengroup(nxhandle, "components", "NXdata") == NX_OK) { if (NXmakegroup(nxhandle, component, "NXdata") == NX_OK) { if (NXopengroup(nxhandle, component, "NXdata") == NX_OK) { int64_t pdims[3]; pdims[0]=3; pdims[1]=0; pdims[2]=0; if (NXcompmakedata64(nxhandle, "Position", NX_FLOAT64, 1, pdims, NX_COMPRESSION, pdims) == NX_OK) { if (NXopendata(nxhandle, "Position") == NX_OK) { double pos[3]; coords_get(position, &pos[0], &pos[1], &pos[2]); if (NXputdata (nxhandle, pos) == NX_OK) { NXclosedata(nxhandle); } else { fprintf(stderr, "COULD NOT PUT Position field for component %s\n",component); } } else { fprintf(stderr, "Warning: could not open Position field for component %s\n",component); } } int64_t rdims[3]; rdims[0]=3; rdims[1]=3; rdims[2]=0; if (NXcompmakedata64(nxhandle, "Rotation", NX_FLOAT64, 2, rdims, NX_COMPRESSION, rdims) == NX_OK) { if (NXopendata(nxhandle, "Rotation") == NX_OK) { if (NXputdata (nxhandle, rotation) == NX_OK) { NXclosedata(nxhandle); } else { fprintf(stderr, "COULD NOT PUT Rotation field for component %s\n",component); } } else { fprintf(stderr, "Warning: could not open Rotation field for component %s\n",component); } } nxprintf(nxhandle, "Component_type", comptype); NXclosegroup(nxhandle); // component } else { printf("FAILED to open comp data group %s\n",component); } } else { printf("FAILED to create comp data group %s\n",component); } NXclosegroup(nxhandle); // components } else { printf("Failed to open NeXus component hierarchy\n"); } NXclosegroup(nxhandle); // instrument } else { printf("Failed to open NeXus instrument hierarchy\n"); } } else { fprintf(stderr,"NO NEXUS FILE\n"); } #endif } /* mccomp_placement_nexus */ /******************************************************************************* * mccomp_param_nexus: * Output parameter/value pair for component instance into * the attribute * entry/instrument/compname/parameter * requires: NXentry to be opened *******************************************************************************/ static void mccomp_param_nexus(NXhandle nxhandle, char* component, char* parameter, char* defval, char* value, char* type) { /* open NeXus instrument group */ #ifdef USE_NEXUS if(nxhandle) { if (NXopengroup(nxhandle, "instrument", "NXinstrument") == NX_OK) { if (NXopengroup(nxhandle, "components", "NXdata") == NX_OK) { if (NXopengroup(nxhandle, component, "NXdata") == NX_OK) { NXMDisableErrorReporting(); /* inactivate NeXus error messages, as creation may fail */ NXmakegroup(nxhandle, "parameters", "NXdata"); NXMEnableErrorReporting(); /* re-enable NeXus error messages */ if (NXopengroup(nxhandle, "parameters", "NXdata") == NX_OK) { NXmakegroup(nxhandle, parameter, "NXnote"); if (NXopengroup(nxhandle, parameter, "NXnote") == NX_OK) { nxprintattr(nxhandle, "type", type); nxprintattr(nxhandle, "default", defval); nxprintattr(nxhandle, "value", value); NXclosegroup(nxhandle); // parameter } else { printf("FAILED to open parameters %s data group \n",parameter); } NXclosegroup(nxhandle); // "parameters" } else { printf("FAILED to open comp/parameters data group \n"); } NXclosegroup(nxhandle); // component } else { printf("FAILED to open comp data group %s\n",component); } NXclosegroup(nxhandle); // components } else { printf("Failed to open NeXus component hierarchy\n"); } NXclosegroup(nxhandle); // instrument } else { printf("Failed to open NeXus instrument hierarchy\n"); } } else { fprintf(stderr,"NO NEXUS FILE\n"); } #endif } /* mccomp_param_nexus */ /******************************************************************************* * mcdatainfo_out_nexus: output detector header * mcdatainfo_out_nexus(detector) create group and write info to NeXus data file * open data:NXdetector then filename:NXdata and write headers/attributes * requires: NXentry to be opened *******************************************************************************/ static void mcdatainfo_out_nexus(NXhandle f, MCDETECTOR detector) { char data_name[CHAR_BUF_LENGTH]; if (!f || !detector.m || mcdisable_output_files) return; strcpy_valid(data_name, strlen(detector.filename) ? detector.filename : detector.component); /* the NXdetector group has been created in mcinfo_out_nexus (siminfo_init) */ if (NXopengroup(f, "instrument", "NXinstrument") == NX_OK) { if (NXopengroup(f, "components", "NXdata") == NX_OK) { NXMDisableErrorReporting(); /* inactivate NeXus error messages, as creation may fail */ NXmakegroup(f, detector.nexuscomp, "NXdata"); if (NXopengroup(f, detector.nexuscomp, "NXdata") == NX_OK) { NXmakegroup(f, "output", "NXdetector"); if (NXopengroup(f, "output", "NXdetector") == NX_OK) { if (NXmakegroup(f, data_name, "NXdata") == NX_OK) { if (NXopengroup(f, data_name, "NXdata") == NX_OK) { /* output metadata (as attributes) ======================================== */ nxprintattr(f, "Date", detector.date); nxprintattr(f, "type", detector.type); nxprintattr(f, "Source", detector.instrument); nxprintattr(f, "component", detector.component); nxprintattr(f, "position", detector.position); nxprintattr(f, "title", detector.title); nxprintattr(f, !mcget_run_num() || mcget_run_num() >= mcget_ncount() ? "Ncount" : "ratio", detector.ncount); if (strlen(detector.filename)) { nxprintattr(f, "filename", detector.filename); } nxprintattr(f, "statistics", detector.statistics); nxprintattr(f, "signal", detector.signal); nxprintattr(f, "values", detector.values); if (detector.rank >= 1) { nxprintattr(f, "xvar", detector.xvar); nxprintattr(f, "yvar", detector.yvar); nxprintattr(f, "xlabel", detector.xlabel); nxprintattr(f, "ylabel", detector.ylabel); if (detector.rank > 1) { nxprintattr(f, "zvar", detector.zvar); nxprintattr(f, "zlabel", detector.zlabel); } } nxprintattr(f, abs(detector.rank)==1 ? "xlimits" : "xylimits", detector.limits); nxprintattr(f, "variables", strcasestr(detector.format, "list") ? detector.ylabel : detector.variables); NXclosegroup(f); // data_name } } } NXclosegroup(f); // output NXclosegroup(f); // detector.nexuscomp } NXclosegroup(f); // components } NXMEnableErrorReporting(); /* re-enable NeXus error messages */ NXclosegroup(f); // instrument } /* NXdetector (instrument) */ } /* mcdatainfo_out_nexus */ /******************************************************************************* * mcdetector_out_axis_nexus: write detector axis into current NXdata * requires: NXdata to be opened *******************************************************************************/ int mcdetector_out_axis_nexus(NXhandle f, char *label, char *var, int rank, long length, double min, double max) { if (!f || length <= 1 || mcdisable_output_files || max == min) return(NX_OK); else { double *axis; axis=malloc(sizeof(double)*length); if (!axis ) { printf("Fatal memory error allocating NeXus axis of length %li, exiting!\n", length); return(NX_ERROR); } char *valid; valid=malloc(sizeof(char)*CHAR_BUF_LENGTH); if (!valid ) { printf("Fatal memory error allocating label axis of length %i, exiting!\n", CHAR_BUF_LENGTH); free(axis); return(NX_ERROR); } int dim=(int)length; int i; int nprimary=1; /* create an axis from [min:max] */ for(i = 0; i < length; i++) axis[i] = min+(max-min)*(i+0.5)/length; /* create the data set */ strcpy_valid(valid, label); NXcompmakedata(f, valid, NX_FLOAT64, 1, &dim, NX_COMPRESSION, &dim); /* open it */ if (NXopendata(f, valid) != NX_OK) { fprintf(stderr, "Warning: could not open axis rank %i '%s' (NeXus)\n", rank, valid); free(axis); free(valid); return(NX_ERROR); } /* put the axis and its attributes */ NXputdata (f, axis); nxprintattr(f, "long_name", label); nxprintattr(f, "short_name", var); NXputattr (f, "axis", &rank, 1, NX_INT32); nxprintattr(f, "units", var); NXputattr (f, "primary", &nprimary, 1, NX_INT32); NXclosedata(f); free(axis); free(valid); return(NX_OK); } } /* mcdetector_out_axis_nexus */ /******************************************************************************* * mcdetector_out_array_nexus: write detector array into current NXdata (1D,2D) * requires: NXdata to be opened *******************************************************************************/ int mcdetector_out_array_nexus(NXhandle f, char *part, double *data, MCDETECTOR detector) { int64_t dims[3]={detector.m,detector.n,detector.p}; /* number of elements to write */ int64_t fulldims[3]={detector.m,detector.n,detector.p}; int signal=1; int exists=0; int64_t current_dims[3]={0,0,0}; int ret=NX_OK; if (!f || !data || !detector.m || mcdisable_output_files) return(NX_OK); /* when this is a list, we set 1st dimension to NX_UNLIMITED for creation */ if (strcasestr(detector.format, "list")) fulldims[0] = NX_UNLIMITED; /* create the data set in NXdata group */ NXMDisableErrorReporting(); /* inactivate NeXus error messages, as creation may fail */ ret = NXcompmakedata64(f, part, NX_FLOAT64, detector.rank, fulldims, NX_COMPRESSION, dims); if (ret != NX_OK) { /* failed: data set already exists */ int datatype=0; int rank=0; exists=1; /* inquire current size of data set (nb of events stored) */ NXopendata(f, part); NXgetinfo64(f, &rank, current_dims, &datatype); NXclosedata(f); } NXMEnableErrorReporting(); /* re-enable NeXus error messages */ /* open the data set */ if (NXopendata(f, part) == NX_ERROR) { fprintf(stderr, "Warning: could not open DataSet %s '%s' (NeXus)\n", part, detector.title); return(NX_ERROR); } if (strcasestr(detector.format, "list")) { current_dims[1] = current_dims[2] = 0; /* set starting location for writing slab */ NXputslab64(f, data, current_dims, dims); if (!exists) printf("Events: \"%s\"\n", strlen(detector.filename) ? detector.filename : detector.component); else printf("Append: \"%s\"\n", strlen(detector.filename) ? detector.filename : detector.component); } else { NXputdata (f, data); } if (strstr(part,"data") || strstr(part, "events")) { NXputattr(f, "signal", &signal, 1, NX_INT32); nxprintattr(f, "short_name", strlen(detector.filename) ? detector.filename : detector.component); } nxprintattr(f, "long_name", "%s '%s'", part, detector.title); NXclosedata(f); return(NX_OK); } /* mcdetector_out_array_nexus */ /******************************************************************************* * mcdetector_out_data_nexus: write detector axes+data into current NXdata * The data:NXdetector is opened, then filename:NXdata * requires: NXentry to be opened *******************************************************************************/ int mcdetector_out_data_nexus(NXhandle f, MCDETECTOR detector) { char data_name[CHAR_BUF_LENGTH]; if (!f || !detector.m || mcdisable_output_files) return(NX_OK); strcpy_valid(data_name, strlen(detector.filename) ? detector.filename : detector.component); NXlink pLink; /* the NXdetector group has been created in mcinfo_out_nexus (siminfo_init) */ if (NXopengroup(f, "instrument", "NXinstrument") == NX_OK) { if (NXopengroup(f, "components", "NXdata") == NX_OK) { if (NXopengroup(f, detector.nexuscomp, "NXdata") == NX_OK) { if (NXopengroup(f, "output", "NXdetector") == NX_OK) { /* the NXdata group has been created in mcdatainfo_out_nexus */ if (NXopengroup(f, data_name, "NXdata") == NX_OK) { MPI_MASTER( nxprintattr(f, "options", strlen(detector.options) ? detector.options : "None"); ); /* write axes, for histogram data sets, not for lists */ if (!strcasestr(detector.format, "list")) { mcdetector_out_axis_nexus(f, detector.xlabel, detector.xvar, 1, detector.m, detector.xmin, detector.xmax); mcdetector_out_axis_nexus(f, detector.ylabel, detector.yvar, 2, detector.n, detector.ymin, detector.ymax); mcdetector_out_axis_nexus(f, detector.zlabel, detector.zvar, 3, detector.p, detector.zmin, detector.zmax); } else { MPI_MASTER( nxprintattr(f, "dataset columns", strlen(detector.ylabel) ? detector.ylabel : "None"); ); } /* write the actual data (appended if already exists) */ if (!strcasestr(detector.format, "list") && !strcasestr(detector.format, "pixels")) { mcdetector_out_array_nexus(f, "data", detector.p1, detector); mcdetector_out_array_nexus(f, "errors", detector.p2, detector); mcdetector_out_array_nexus(f, "ncount", detector.p0, detector); } else if (strcasestr(detector.format, "pixels")) { mcdetector_out_array_nexus( f, "pixels", detector.p1, detector); } else { mcdetector_out_array_nexus( f, "events", detector.p1, detector); } NXclosegroup(f); NXopengroup(f, data_name, "NXdata"); NXgetgroupID(nxhandle, &pLink); NXclosegroup(f); } /* NXdata data_name*/ NXclosegroup(f); } /* NXdetector output */ NXclosegroup(f); } /* NXdata detector.nexuscomp */ NXclosegroup(f); } /* NXdata components */ NXclosegroup(f); } /* NXdata instrument */ if (!strcasestr(detector.format, "pixels")) { if (NXopengroup(f, "data", "NXdetector") == NX_OK) { NXmakelink(nxhandle, &pLink); NXclosegroup(f); } } return(NX_OK); } /* mcdetector_out_array_nexus */ #ifdef USE_MPI /******************************************************************************* * mcdetector_out_list_slaves: slaves send their list data to master which writes * requires: NXentry to be opened * WARNING: this method has a flaw: it requires all nodes to flush the lists * the same number of times. In case one node is just below the buffer size * when finishing (e.g. monitor_nd), it may not trigger save but others may. * Then the number of recv/send is not constant along nodes, and simulation stalls. *******************************************************************************/ MCDETECTOR mcdetector_out_list_slaves(MCDETECTOR detector) { int node_i=0; MPI_MASTER( printf("\n** MPI master gathering slave node list data ** \n"); ); if (mpi_node_rank != mpi_node_root) { /* MPI slave: slaves send their data to master: 2 MPI_Send calls */ /* m, n, p must be sent first, since all slaves do not have the same number of events */ int mnp[3]={detector.m,detector.n,detector.p}; if (mc_MPI_Send(mnp, 3, MPI_INT, mpi_node_root)!= MPI_SUCCESS) fprintf(stderr, "Warning: proc %i to master: MPI_Send mnp list error (mcdetector_out_list_slaves)\n", mpi_node_rank); if (!detector.p1 || mc_MPI_Send(detector.p1, mnp[0]*mnp[1]*mnp[2], MPI_DOUBLE, mpi_node_root) != MPI_SUCCESS) fprintf(stderr, "Warning: proc %i to master: MPI_Send p1 list error: mnp=%i (mcdetector_out_list_slaves)\n", mpi_node_rank, abs(mnp[0]*mnp[1]*mnp[2])); /* slaves are done: sent mnp and p1 */ } /* end slaves */ /* MPI master: receive data from slaves sequentially: 2 MPI_Recv calls */ if (mpi_node_rank == mpi_node_root) { for(node_i=0; node_i 1) { mcdetector_out_list_slaves(detector); } #endif /* USE_MPI */ return(detector); } /* mcdetector_out_2D_nexus */ MCDETECTOR mcdetector_out_3D_nexus(MCDETECTOR detector) { printf("Received detector from %s\n",detector.component); MPI_MASTER( mcdatainfo_out_nexus(nxhandle, detector); mcdetector_out_data_nexus(nxhandle, detector); ); return(detector); } /* mcdetector_out_3D_nexus */ #endif /* USE_NEXUS*/ /* ========================================================================== */ /* Main input functions */ /* DETECTOR_OUT_xD function calls -> ascii or NeXus */ /* ========================================================================== */ /******************************************************************************* * siminfo_init: open SIM and write header *******************************************************************************/ FILE *siminfo_init(FILE *f) { int exists=0; /* check format */ if (!mcformat || !strlen(mcformat) || !strcasecmp(mcformat, "MCSTAS") || !strcasecmp(mcformat, "MCXTRACE") || !strcasecmp(mcformat, "PGPLOT") || !strcasecmp(mcformat, "GNUPLOT") || !strcasecmp(mcformat, "MCCODE") || !strcasecmp(mcformat, "MATLAB")) { mcformat="McCode"; #ifdef USE_NEXUS } else if (strcasestr(mcformat, "NeXus")) { /* Do nothing */ #endif } else { fprintf(stderr, "Warning: You have requested the output format %s which is unsupported by this binary. Resetting to standard %s format.\n",mcformat ,"McCode"); mcformat="McCode"; } /* open the SIM file if not defined yet */ if (siminfo_file || mcdisable_output_files) return (siminfo_file); #ifdef USE_NEXUS /* only master writes NeXus header: calls NXopen(nxhandle) */ if (mcformat && strcasestr(mcformat, "NeXus")) { MPI_MASTER( siminfo_file = mcnew_file(siminfo_name, "h5", &exists); if(!siminfo_file) fprintf(stderr, "Warning: could not open simulation description file '%s'\n", siminfo_name); else mcinfo_out_nexus(nxhandle); ); return(siminfo_file); /* points to nxhandle */ } #endif /* write main description file (only MASTER) */ MPI_MASTER( siminfo_file = mcnew_file(siminfo_name, "sim", &exists); if(!siminfo_file) fprintf(stderr, "Warning: could not open simulation description file '%s'\n", siminfo_name); else { /* write SIM header */ time_t t=time(NULL); siminfo_out("%s simulation description file for %s.\n", MCCODE_NAME, instrument_name); siminfo_out("Date: %s", ctime(&t)); /* includes \n */ siminfo_out("Program: %s\n\n", MCCODE_STRING); siminfo_out("begin instrument: %s\n", instrument_name); mcinfo_out( " ", siminfo_file); siminfo_out("end instrument\n"); siminfo_out("\nbegin simulation: %s\n", dirname); mcruninfo_out(" ", siminfo_file); siminfo_out("end simulation\n"); } ); /* MPI_MASTER */ return (siminfo_file); } /* siminfo_init */ /******************************************************************************* * siminfo_close: close SIM *******************************************************************************/ void siminfo_close() { #ifdef USE_MPI if(mpi_node_rank == mpi_node_root) { #endif if(siminfo_file && !mcdisable_output_files) { #ifdef USE_NEXUS if (mcformat && strcasestr(mcformat, "NeXus")) { time_t t=time(NULL); nxprintf(nxhandle, "end_time", ctime(&t)); nxprintf(nxhandle, "duration", "%li", (long)t-mcstartdate); NXclosegroup(nxhandle); /* NXentry */ NXclose(&nxhandle); } else { #endif fclose(siminfo_file); #ifdef USE_NEXUS } #endif #ifdef USE_MPI } #endif siminfo_file = NULL; } } /* siminfo_close */ /******************************************************************************* * mcdetector_out_0D: wrapper for 0D (single value). * Output single detector/monitor data (p0, p1, p2). * Title is t, component name is c. *******************************************************************************/ MCDETECTOR mcdetector_out_0D(char *t, double p0, double p1, double p2, char *c, Coords posa, Rotation rota, int index) { /* import and perform basic detector analysis (and handle MPI reduce) */ MCDETECTOR detector = detector_import(mcformat, c, (t ? t : MCCODE_STRING " data"), 1, 1, 1, "I", "", "", "I", "", "", 0, 0, 0, 0, 0, 0, c, &p0, &p1, &p2, posa, rota, index); /* write Detector: line */ #ifdef USE_NEXUS if (strcasestr(detector.format, "NeXus")) return(mcdetector_out_0D_nexus(detector)); else #endif return(mcdetector_out_0D_ascii(detector)); } /* mcdetector_out_0D */ /******************************************************************************* * mcdetector_out_1D: wrapper for 1D. * Output 1d detector data (p0, p1, p2) for n bins linearly * distributed across the range x1..x2 (x1 is lower limit of first * bin, x2 is upper limit of last bin). Title is t, axis labels are xl * and yl. File name is f, component name is c. * * t: title * xl: x-label * yl: y-label * xvar: measured variable length * x1: x axus min * x2: x axis max * n: 1d data vector lenght * p0: pntr to start of data block#0 * p1: pntr to start of data block#1 * p2: pntr to start of data block#2 * f: filename * * Not included in the macro, and here forwarded to detector_import: * c: ? * posa: ? *******************************************************************************/ MCDETECTOR mcdetector_out_1D(char *t, char *xl, char *yl, char *xvar, double x1, double x2, long n, double *p0, double *p1, double *p2, char *f, char *c, Coords posa, Rotation rota, int index) { /* import and perform basic detector analysis (and handle MPI_Reduce) */ // detector_import calls mcdetector_statistics, which will return different // MCDETECTOR versions for 1-D data based on the value of mcformat. // MCDETECTOR detector = detector_import(mcformat, c, (t ? t : MCCODE_STRING " 1D data"), n, 1, 1, xl, yl, (n > 1 ? "Signal per bin" : " Signal"), xvar, "(I,I_err)", "I", x1, x2, 0, 0, 0, 0, f, p0, p1, p2, posa, rota, index); /* write Detector: line */ if (!detector.p1 || !detector.m) return(detector); #ifdef USE_NEXUS if (strcasestr(detector.format, "NeXus")) detector = mcdetector_out_1D_nexus(detector); else #endif detector = mcdetector_out_1D_ascii(detector); if (detector.p1 != p1 && detector.p1) { // mcdetector_statistics allocated memory but it hasn't been freed. free(detector.p1); // plus undo the other damage done there: detector.p0 = p0; // was set to NULL detector.p1 = p1; // was set to this_p1 detector.p2 = p2; // was set to NULL detector.m = detector.n; // (e.g., labs(n)) detector.n = 1; // not (n x n) detector.istransposed = n < 0 ? 1 : 0; } return detector; } /* mcdetector_out_1D */ /******************************************************************************* * mcdetector_out_2D: wrapper for 2D. * Special case for list: master creates file first, then slaves append their * blocks without header- * * t: title * xl: x-label * yl: y-label * x1: x axus min * x2: x axis max * y1: y axis min * y2: y axis max * m: dim 1 (x) size * n: dim 2 (y) size * p0: pntr to start of data block#0 * p1: pntr to start of data block#1 * p2: pntr to start of data block#2 * f: filename * * Not included in the macro, and here forwarded to detector_import: * c: ? * posa: ? * rota: ? *******************************************************************************/ MCDETECTOR mcdetector_out_2D(char *t, char *xl, char *yl, double x1, double x2, double y1, double y2, long m, long n, double *p0, double *p1, double *p2, char *f, char *c, Coords posa, Rotation rota, int index) { char xvar[CHAR_BUF_LENGTH]; char yvar[CHAR_BUF_LENGTH]; /* create short axes labels */ if (xl && strlen(xl)) { strncpy(xvar, xl, CHAR_BUF_LENGTH); xvar[2]='\0'; } else strcpy(xvar, "x"); if (yl && strlen(yl)) { strncpy(yvar, yl, CHAR_BUF_LENGTH); yvar[2]='\0'; } else strcpy(yvar, "y"); MCDETECTOR detector; /* import and perform basic detector analysis (and handle MPI_Reduce) */ if (labs(m) == 1) {/* n>1 on Y, m==1 on X: 1D, no X axis*/ detector = detector_import(mcformat, c, (t ? t : MCCODE_STRING " 1D data"), n, 1, 1, yl, "", "Signal per bin", yvar, "(I,Ierr)", "I", y1, y2, x1, x2, 0, 0, f, p0, p1, p2, posa, rota, index); /* write Detector: line */ } else if (labs(n)==1) {/* m>1 on X, n==1 on Y: 1D, no Y axis*/ detector = detector_import(mcformat, c, (t ? t : MCCODE_STRING " 1D data"), m, 1, 1, xl, "", "Signal per bin", xvar, "(I,Ierr)", "I", x1, x2, y1, y2, 0, 0, f, p0, p1, p2, posa, rota, index); /* write Detector: line */ }else { detector = detector_import(mcformat, c, (t ? t : MCCODE_STRING " 2D data"), m, n, 1, xl, yl, "Signal per bin", xvar, yvar, "I", x1, x2, y1, y2, 0, 0, f, p0, p1, p2, posa, rota, index); /* write Detector: line */ } if (!detector.p1 || !detector.m) return(detector); #ifdef USE_NEXUS if (strcasestr(detector.format, "NeXus")) return(mcdetector_out_2D_nexus(detector)); else #endif return(mcdetector_out_2D_ascii(detector)); } /* mcdetector_out_2D */ /******************************************************************************* * mcdetector_out_2D_list: List mode 2D including forwarding "options" from * Monitor_nD * * Special case for list: master creates file first, then slaves append their * blocks without header- * * t: title * xl: x-label * yl: y-label * x1: x axus min * x2: x axis max * y1: y axis min * y2: y axis max * m: dim 1 (x) size * n: dim 2 (y) size * p0: pntr to start of data block#0 * p1: pntr to start of data block#1 * p2: pntr to start of data block#2 * f: filename * * Not included in the macro, and here forwarded to detector_import: * c: ? * posa: ? * rota: ? *******************************************************************************/ MCDETECTOR mcdetector_out_2D_list(char *t, char *xl, char *yl, double x1, double x2, double y1, double y2, long m, long n, double *p0, double *p1, double *p2, char *f, char *c, Coords posa, Rotation rota, char* options, int index) { char xvar[CHAR_BUF_LENGTH]; char yvar[CHAR_BUF_LENGTH]; /* create short axes labels */ if (xl && strlen(xl)) { strncpy(xvar, xl, CHAR_BUF_LENGTH); xvar[2]='\0'; } else strcpy(xvar, "x"); if (yl && strlen(yl)) { strncpy(yvar, yl, CHAR_BUF_LENGTH); yvar[2]='\0'; } else strcpy(yvar, "y"); MCDETECTOR detector; /* import and perform basic detector analysis (and handle MPI_Reduce) */ if (labs(m) == 1) {/* n>1 on Y, m==1 on X: 1D, no X axis*/ detector = detector_import(mcformat, c, (t ? t : MCCODE_STRING " 1D data"), n, 1, 1, yl, "", "Signal per bin", yvar, "(I,Ierr)", "I", y1, y2, x1, x2, 0, 0, f, p0, p1, p2, posa, rota, index); /* write Detector: line */ } else if (labs(n)==1) {/* m>1 on X, n==1 on Y: 1D, no Y axis*/ detector = detector_import(mcformat, c, (t ? t : MCCODE_STRING " 1D data"), m, 1, 1, xl, "", "Signal per bin", xvar, "(I,Ierr)", "I", x1, x2, y1, y2, 0, 0, f, p0, p1, p2, posa, rota, index); /* write Detector: line */ }else { detector = detector_import(mcformat, c, (t ? t : MCCODE_STRING " 2D data"), m, n, 1, xl, yl, "Signal per bin", xvar, yvar, "I", x1, x2, y1, y2, 0, 0, f, p0, p1, p2, posa, rota, index); /* write Detector: line */ } MPI_MASTER( if (strlen(options)) { strcpy(detector.options,options); } else { strcpy(detector.options,"None"); } ); if (!detector.p1 || !detector.m) return(detector); #ifdef USE_NEXUS if (strcasestr(detector.format, "NeXus")) return(mcdetector_out_2D_nexus(detector)); else #endif return(mcdetector_out_2D_ascii(detector)); } /* mcdetector_out_2D_list */ /******************************************************************************* * mcdetector_out_list: wrapper for list output (calls out_2D with mcformat+"list"). * m=number of events, n=size of each event *******************************************************************************/ MCDETECTOR mcdetector_out_list(char *t, char *xl, char *yl, long m, long n, double *p1, char *f, char *c, Coords posa, Rotation rota, char* options, int index) { char format_new[CHAR_BUF_LENGTH]; char *format_org; MCDETECTOR detector; format_org = mcformat; strcpy(format_new, mcformat); strcat(format_new, " list"); mcformat = format_new; detector = mcdetector_out_2D_list(t, xl, yl, 1,labs(m),1,labs(n), m,n, NULL, p1, NULL, f, c, posa,rota,options, index); mcformat = format_org; return(detector); } /******************************************************************************* * mcuse_dir: set data/sim storage directory and create it, * or exit with error if exists ******************************************************************************/ static void mcuse_dir(char *dir) { if (!dir || !strlen(dir)) return; #ifdef MC_PORTABLE fprintf(stderr, "Error: " "Directory output cannot be used with portable simulation (mcuse_dir)\n"); exit(1); #else /* !MC_PORTABLE */ /* handle file://directory URL type */ if (strncmp(dir, "file://", strlen("file://"))) dirname = dir; else dirname = dir+strlen("file://"); #ifdef USE_MPI if(mpi_node_rank == mpi_node_root) { #endif int exists=0; DIR* handle = opendir(dirname); if (handle) { /* Directory exists. */ closedir(handle); exists=1; } if(mkdir(dirname, 0777)) { #ifndef DANSE if(!mcappend) { fprintf(stderr, "Error: unable to create directory '%s' (mcuse_dir)\n", dir); fprintf(stderr, "(Maybe the directory already exists?)\n"); #endif #ifdef USE_MPI MPI_Abort(MPI_COMM_WORLD, -1); #endif exit(-1); } } #ifdef USE_MPI } #endif /* remove trailing PATHSEP (if any) */ while (strlen(dirname) && dirname[strlen(dirname) - 1] == MC_PATHSEP_C) dirname[strlen(dirname) - 1]='\0'; #endif /* !MC_PORTABLE */ } /* mcuse_dir */ /******************************************************************************* * mcinfo: display instrument simulation info to stdout and exit *******************************************************************************/ static void mcinfo(void) { fprintf(stdout, "begin instrument: %s\n", instrument_name); mcinfo_out(" ", stdout); fprintf(stdout, "end instrument\n"); fprintf(stdout, "begin simulation: %s\n", dirname ? dirname : "."); mcruninfo_out(" ", stdout); fprintf(stdout, "end simulation\n"); exit(0); /* includes MPI_Finalize in MPI mode */ } /* mcinfo */ /******************************************************************************* * mcparameterinfo: display instrument parameter info to stdout and exit *******************************************************************************/ static void mcparameterinfo(void) { mcparameterinfo_out(" ", stdout); exit(0); /* includes MPI_Finalize in MPI mode */ } /* mcparameterinfo */ #endif /* ndef MCCODE_R_IO_C */ /* end of the I/O section =================================================== */ /******************************************************************************* * mcset_ncount: set total number of rays to generate *******************************************************************************/ void mcset_ncount(unsigned long long int count) { mcncount = count; } /* mcget_ncount: get total number of rays to generate */ unsigned long long int mcget_ncount(void) { return mcncount; } /* mcget_run_num: get curent number of rays */ /* Within the TRACE scope we are now using _particle->uid directly */ unsigned long long int mcget_run_num() // shuld be (_class_particle* _particle) somehow { /* This function only remains for the few cases outside TRACE where we need to know the number of simulated particles */ return mcrun_num; } /* mcsetn_arg: get ncount from a string argument */ static void mcsetn_arg(char *arg) { mcset_ncount((long long int) strtod(arg, NULL)); } /* mcsetseed: set the random generator seed from a string argument */ static void mcsetseed(char *arg) { mcseed = atol(arg); if(!mcseed) { // srandom(mcseed); //} else { fprintf(stderr, "Error: seed must not be zero (mcsetseed)\n"); exit(1); } } /* Following part is only embedded when not redundent with mccode-r.h ========= */ #ifndef MCCODE_H /* SECTION: MCDISPLAY support. =============================================== */ /******************************************************************************* * Just output MCDISPLAY keywords to be caught by an external plotter client. *******************************************************************************/ void mcdis_magnify(char *what){ // Do nothing here, better use interactive zoom from the tools } void mcdis_line(double x1, double y1, double z1, double x2, double y2, double z2){ printf("MCDISPLAY: multiline(2,%g,%g,%g,%g,%g,%g)\n", x1,y1,z1,x2,y2,z2); } void mcdis_dashed_line(double x1, double y1, double z1, double x2, double y2, double z2, int n){ int i; const double dx = (x2-x1)/(2*n+1); const double dy = (y2-y1)/(2*n+1); const double dz = (z2-z1)/(2*n+1); for(i = 0; i < n+1; i++) mcdis_line(x1 + 2*i*dx, y1 + 2*i*dy, z1 + 2*i*dz, x1 + (2*i+1)*dx, y1 + (2*i+1)*dy, z1 + (2*i+1)*dz); } void mcdis_multiline(int count, ...){ va_list ap; double x,y,z; printf("MCDISPLAY: multiline(%d", count); va_start(ap, count); while(count--) { x = va_arg(ap, double); y = va_arg(ap, double); z = va_arg(ap, double); printf(",%g,%g,%g", x, y, z); } va_end(ap); printf(")\n"); } void mcdis_rectangle(char* plane, double x, double y, double z, double width, double height){ /* draws a rectangle in the plane */ /* x is ALWAYS width and y is ALWAYS height */ if (strcmp("xy", plane)==0) { mcdis_multiline(5, x - width/2, y - height/2, z, x + width/2, y - height/2, z, x + width/2, y + height/2, z, x - width/2, y + height/2, z, x - width/2, y - height/2, z); } else if (strcmp("xz", plane)==0) { mcdis_multiline(5, x - width/2, y, z - height/2, x + width/2, y, z - height/2, x + width/2, y, z + height/2, x - width/2, y, z + height/2, x - width/2, y, z - height/2); } else if (strcmp("yz", plane)==0) { mcdis_multiline(5, x, y - height/2, z - width/2, x, y - height/2, z + width/2, x, y + height/2, z + width/2, x, y + height/2, z - width/2, x, y - height/2, z - width/2); } else { fprintf(stderr, "Error: Definition of plane %s unknown\n", plane); exit(1); } } void mcdis_circle(char *plane, double x, double y, double z, double r){ printf("MCDISPLAY: mcdiscircle('%s',%g,%g,%g,%g)\n", plane, x, y, z, r); } void mcdis_new_circle(double x, double y, double z, double r, double nx, double ny, double nz){ printf("MCDISPLAY: mcdisnew_circle(%g,%g,%g,%g,%g,%g,%g)\n", x, y, z, r, nx, ny, nz); } /* Draws a circle with center (x,y,z), radius (r), and in the plane * with normal (nx,ny,nz)*/ void mcdis_Circle(double x, double y, double z, double r, double nx, double ny, double nz){ int i; if(nx==0 && ny && nz==0){ for (i=0;i<24; i++){ mcdis_line(x+r*sin(i*2*PI/24),y,z+r*cos(i*2*PI/24), x+r*sin((i+1)*2*PI/24),y,z+r*cos((i+1)*2*PI/24)); } }else{ double mx,my,mz; /*generate perpendicular vector using (nx,ny,nz) and (0,1,0)*/ vec_prod(mx,my,mz, 0,1,0, nx,ny,nz); NORM(mx,my,mz); /*draw circle*/ for (i=0;i<24; i++){ double ux,uy,uz; double wx,wy,wz; rotate(ux,uy,uz, mx,my,mz, i*2*PI/24, nx,ny,nz); rotate(wx,wy,wz, mx,my,mz, (i+1)*2*PI/24, nx,ny,nz); mcdis_line(x+ux*r,y+uy*r,z+uz*r, x+wx*r,y+wy*r,z+wz*r); } } } /* OLD IMPLEMENTATION draws a box with center at (x, y, z) and width (deltax), height (deltay), length (deltaz) */ void mcdis_legacy_box(double x, double y, double z, double width, double height, double length){ mcdis_rectangle("xy", x, y, z-length/2, width, height); mcdis_rectangle("xy", x, y, z+length/2, width, height); mcdis_line(x-width/2, y-height/2, z-length/2, x-width/2, y-height/2, z+length/2); mcdis_line(x-width/2, y+height/2, z-length/2, x-width/2, y+height/2, z+length/2); mcdis_line(x+width/2, y-height/2, z-length/2, x+width/2, y-height/2, z+length/2); mcdis_line(x+width/2, y+height/2, z-length/2, x+width/2, y+height/2, z+length/2); } /* NEW 3D IMPLEMENTATION OF BOX SUPPORTS HOLLOW ALSO draws a box with center at (x, y, z) and width (deltax), height (deltay), length (deltaz) */ void mcdis_box(double x, double y, double z, double width, double height, double length, double thickness, double nx, double ny, double nz){ if (mcdotrace==2) { printf("MCDISPLAY: mcdisbox(%g,%g,%g,%g,%g,%g,%g,%g,%g,%g)\n", x, y, z, width, height, length, thickness, nx, ny, nz); } else { mcdis_legacy_box(x, y, z, width, height, length); if (thickness) mcdis_legacy_box(x, y, z, width-thickness, height-thickness, length); } } /* OLD IMPLEMENTATION Draws a cylinder with center at (x,y,z) with extent (r,height). * The cylinder axis is along the vector nx,ny,nz. */ void mcdis_legacy_cylinder( double x, double y, double z, double r, double height, int N, double nx, double ny, double nz){ int i; /*no lines make little sense - so trigger the default*/ if(N<=0) N=5; NORM(nx,ny,nz); double h_2=height/2.0; mcdis_Circle(x+nx*h_2,y+ny*h_2,z+nz*h_2,r,nx,ny,nz); mcdis_Circle(x-nx*h_2,y-ny*h_2,z-nz*h_2,r,nx,ny,nz); double mx,my,mz; /*generate perpendicular vector using (nx,ny,nz) and (0,1,0)*/ if(nx==0 && ny && nz==0){ mx=my=0;mz=1; }else{ vec_prod(mx,my,mz, 0,1,0, nx,ny,nz); NORM(mx,my,mz); } /*draw circle*/ for (i=0; i<24; i++){ double ux,uy,uz; rotate(ux,uy,uz, mx,my,mz, i*2*PI/24, nx,ny,nz); mcdis_line(x+nx*h_2+ux*r, y+ny*h_2+uy*r, z+nz*h_2+uz*r, x-nx*h_2+ux*r, y-ny*h_2+uy*r, z-nz*h_2+uz*r); } } /* NEW 3D IMPLEMENTATION ALSO SUPPORTING HOLLOW Draws a cylinder with center at (x,y,z) with extent (r,height). * The cylinder axis is along the vector nx,ny,nz.*/ void mcdis_cylinder( double x, double y, double z, double r, double height, double thickness, double nx, double ny, double nz){ if (mcdotrace==2) { printf("MCDISPLAY: mcdiscylinder(%g, %g, %g, %g, %g, %g, %g, %g, %g)\n", x, y, z, r, height, thickness, nx, ny, nz); } else { mcdis_legacy_cylinder(x, y, z, r, height, 12, nx, ny, nz); } } /* Draws a cone with center at (x,y,z) with extent (r,height). * The cone axis is along the vector nx,ny,nz.*/ void mcdis_cone( double x, double y, double z, double r, double height, double nx, double ny, double nz){ if (mcdotrace==2) { printf("MCDISPLAY: mcdiscone(%g, %g, %g, %g, %g, %g, %g, %g)\n", x, y, z, r, height, nx, ny, nz); } else { mcdis_Circle(x, y, z, r, nx, ny, nz); mcdis_Circle(x+0.25*height*nx, y+0.25*height*ny, z+0.25*height*nz, 0.75*r, nx, ny, nz); mcdis_Circle(x+0.5*height*nx, y+0.5*height*ny, z+0.5*height*nz, 0.5*r, nx, ny, nz); mcdis_Circle(x+0.75*height*nx, y+0.75*height*ny, z+0.75*height*nz, 0.25*r, nx, ny, nz); mcdis_line(x, y, z, x+height*nx, y+height*ny, z+height*nz); } } /* Draws a disc with center at (x,y,z) with extent (r). * The disc axis is along the vector nx,ny,nz.*/ void mcdis_disc( double x, double y, double z, double r, double nx, double ny, double nz){ printf("MCDISPLAY: mcdisdisc(%g, %g, %g, %g, %g, %g, %g)\n", x, y, z, r, nx, ny, nz); } /* Draws a annulus with center at (x,y,z) with extent (outer_radius) and remove inner_radius. * The annulus axis is along the vector nx,ny,nz.*/ void mcdis_annulus( double x, double y, double z, double outer_radius, double inner_radius, double nx, double ny, double nz){ printf("MCDISPLAY: mcdisannulus(%g, %g, %g, %g, %g, %g, %g, %g)\n", x, y, z, outer_radius, inner_radius, nx, ny, nz); } /* draws a sphere with center at (x,y,z) with extent (r)*/ void mcdis_sphere(double x, double y, double z, double r){ if (mcdotrace==2) { printf("MCDISPLAY: mcdissphere(%g,%g,%g,%g)\n", x, y, z, r); } else { double nx,ny,nz; int i; int N=12; nx=0;ny=0;nz=1; mcdis_Circle(x,y,z,r,nx,ny,nz); for (i=1;i 3) { /* Split in triangles - as many as polygon rank */ faceSize=count; vtxSize=count+1; } else { faceSize=1; vtxSize=count; } for (int i = 0; i < faceSize;) { int num_indices = 3; estimated_size += FACE_OVERHEAD_BASE + num_indices * FACE_INDEX_OVERHEAD; i += num_indices + 1; } char *json_string = malloc(estimated_size); if (json_string == NULL) { fprintf(stderr, "Memory allocation failed.\n"); return; } char *ptr = json_string; ptr += sprintf(ptr, "{ \"vertices\": ["); if (count==3) { // Single, basic triangle ptr += sprintf(ptr, "[%g, %g, %g], [%g, %g, %g], [%g, %g, %g]", x[0], y[0], z[0], x[1], y[1], z[1], x[2], y[2], z[2]); } else { for (int i = 0; i < vtxSize-1; i++) { ptr += sprintf(ptr, "[%g, %g, %g]", x[i], y[i], z[i]); if (i < vtxSize - 2) { ptr += sprintf(ptr, ", "); } else { ptr += sprintf(ptr, ", [%g, %g, %g]", x0, y0, z0); } } } ptr += sprintf(ptr, "], \"faces\": ["); if (count==3) { // Single, basic triangle, 1 face... ptr += sprintf(ptr, "{ \"face\": ["); ptr += sprintf(ptr, "0, 1, 2"); ptr += sprintf(ptr, "]}"); } else { for (int i = 0; i < faceSize; i++) { int num = 3; ptr += sprintf(ptr, "{ \"face\": ["); if (i < faceSize - 1) { ptr += sprintf(ptr, "%d, %d, %d",i,i+1,count); } else { ptr += sprintf(ptr, "%d, %d, %d",i,count,0); } ptr += sprintf(ptr, "]}"); if (i < faceSize-1) { ptr += sprintf(ptr, ", "); } } } ptr += sprintf(ptr, "]}"); mcdis_polyhedron(json_string); free(json_string); } free(x);free(y);free(z); } /* END NEW POLYGON IMPLEMENTATION*/ /* void polygon(double x1, double y1, double z1, double x2, double y2, double z2){ printf("MCDISPLAY: polygon(2,%g,%g,%g,%g,%g,%g)\n", x1,y1,z1,x2,y2,z2); } */ /* SECTION: coordinates handling ============================================ */ /******************************************************************************* * Since we use a lot of geometric calculations using Cartesian coordinates, * we collect some useful routines here. However, it is also permissible to * work directly on the underlying struct coords whenever that is most * convenient (that is, the type Coords is not abstract). * * Coordinates are also used to store rotation angles around x/y/z axis. * * Since coordinates are used much like a basic type (such as double), the * structure itself is passed and returned, rather than a pointer. * * At compile-time, the values of the coordinates may be unknown (for example * a motor position). Hence coordinates are general expressions and not simple * numbers. For this we used the type Coords_exp which has three CExp * fields. For runtime (or calculations possible at compile time), we use * Coords which contains three double fields. *******************************************************************************/ /* coords_set: Assign coordinates. */ Coords coords_set(MCNUM x, MCNUM y, MCNUM z) { Coords a; a.x = x; a.y = y; a.z = z; return a; } /* coords_get: get coordinates. Required when 'x','y','z' are #defined as ray pars */ Coords coords_get(Coords a, MCNUM *x, MCNUM *y, MCNUM *z) { *x = a.x; *y = a.y; *z = a.z; return a; } /* coords_add: Add two coordinates. */ Coords coords_add(Coords a, Coords b) { Coords c; c.x = a.x + b.x; c.y = a.y + b.y; c.z = a.z + b.z; if (fabs(c.z) < 1e-14) c.z=0.0; return c; } /* coords_sub: Subtract two coordinates. */ Coords coords_sub(Coords a, Coords b) { Coords c; c.x = a.x - b.x; c.y = a.y - b.y; c.z = a.z - b.z; if (fabs(c.z) < 1e-14) c.z=0.0; return c; } /* coords_neg: Negate coordinates. */ Coords coords_neg(Coords a) { Coords b; b.x = -a.x; b.y = -a.y; b.z = -a.z; return b; } /* coords_scale: Scale a vector. */ Coords coords_scale(Coords b, double scale) { Coords a; a.x = b.x*scale; a.y = b.y*scale; a.z = b.z*scale; return a; } /* coords_sp: Scalar product: a . b */ double coords_sp(Coords a, Coords b) { double value; value = a.x*b.x + a.y*b.y + a.z*b.z; return value; } /* coords_xp: Cross product: a = b x c. */ Coords coords_xp(Coords b, Coords c) { Coords a; a.x = b.y*c.z - c.y*b.z; a.y = b.z*c.x - c.z*b.x; a.z = b.x*c.y - c.x*b.y; return a; } /* coords_len: Gives length of coords set. */ double coords_len(Coords a) { return sqrt(a.x*a.x + a.y*a.y + a.z*a.z); } /* coords_mirror: Mirror a in plane (through the origin) defined by normal n*/ Coords coords_mirror(Coords a, Coords n) { double t = scalar_prod(n.x, n.y, n.z, n.x, n.y, n.z); Coords b; if (t!=1) { t = sqrt(t); n.x /= t; n.y /= t; n.z /= t; } t=scalar_prod(a.x, a.y, a.z, n.x, n.y, n.z); b.x = a.x-2*t*n.x; b.y = a.y-2*t*n.y; b.z = a.z-2*t*n.z; return b; } /* coords_print: Print out vector values. */ void coords_print(Coords a) { #ifndef OPENACC fprintf(stdout, "(%f, %f, %f)\n", a.x, a.y, a.z); #endif return; } mcstatic void coords_norm(Coords* c) { double temp = coords_sp(*c,*c); // Skip if we will end dividing by zero if (temp == 0) return; temp = sqrt(temp); c->x /= temp; c->y /= temp; c->z /= temp; } /* coords_test_zero: check if zero vector*/ int coords_test_zero(Coords a){ return ( a.x==0 && a.y==0 && a.z==0 ); } /******************************************************************************* * The Rotation type implements a rotation transformation of a coordinate * system in the form of a double[3][3] matrix. * * Contrary to the Coords type in coords.c, rotations are passed by * reference. Functions that yield new rotations do so by writing to an * explicit result parameter; rotations are not returned from functions. The * reason for this is that arrays cannot by returned from functions (though * structures can; thus an alternative would have been to wrap the * double[3][3] array up in a struct). Such are the ways of C programming. * * A rotation represents the tranformation of the coordinates of a vector when * changing between coordinate systems that are rotated with respect to each * other. For example, suppose that coordinate system Q is rotated 45 degrees * around the Z axis with respect to coordinate system P. Let T be the * rotation transformation representing a 45 degree rotation around Z. Then to * get the coordinates of a vector r in system Q, apply T to the coordinates * of r in P. If r=(1,0,0) in P, it will be (sqrt(1/2),-sqrt(1/2),0) in * Q. Thus we should be careful when interpreting the sign of rotation angles: * they represent the rotation of the coordinate systems, not of the * coordinates (which has opposite sign). *******************************************************************************/ /******************************************************************************* * rot_set_rotation: Get transformation for rotation first phx around x axis, * then phy around y, then phz around z. *******************************************************************************/ void rot_set_rotation(Rotation t, double phx, double phy, double phz) { if ((phx == 0) && (phy == 0) && (phz == 0)) { t[0][0] = 1.0; t[0][1] = 0.0; t[0][2] = 0.0; t[1][0] = 0.0; t[1][1] = 1.0; t[1][2] = 0.0; t[2][0] = 0.0; t[2][1] = 0.0; t[2][2] = 1.0; } else { double cx = cos(phx); double sx = sin(phx); double cy = cos(phy); double sy = sin(phy); double cz = cos(phz); double sz = sin(phz); t[0][0] = cy*cz; t[0][1] = sx*sy*cz + cx*sz; t[0][2] = sx*sz - cx*sy*cz; t[1][0] = -cy*sz; t[1][1] = cx*cz - sx*sy*sz; t[1][2] = sx*cz + cx*sy*sz; t[2][0] = sy; t[2][1] = -sx*cy; t[2][2] = cx*cy; } } /******************************************************************************* * rot_test_identity: Test if rotation is identity *******************************************************************************/ int rot_test_identity(Rotation t) { return (t[0][0] + t[1][1] + t[2][2] == 3); } /******************************************************************************* * rot_mul: Matrix multiplication of transformations (this corresponds to * combining transformations). After rot_mul(T1, T2, T3), doing T3 is * equal to doing first T2, then T1. * Note that T3 must not alias (use the same array as) T1 or T2. *******************************************************************************/ void rot_mul(Rotation t1, Rotation t2, Rotation t3) { if (rot_test_identity(t1)) { rot_copy(t3, t2); } else if (rot_test_identity(t2)) { rot_copy(t3, t1); } else { int i,j; for(i = 0; i < 3; i++) for(j = 0; j < 3; j++) t3[i][j] = t1[i][0]*t2[0][j] + t1[i][1]*t2[1][j] + t1[i][2]*t2[2][j]; } } /******************************************************************************* * rot_copy: Copy a rotation transformation (arrays cannot be assigned in C). *******************************************************************************/ void rot_copy(Rotation dest, Rotation src) { int i,j; for(i = 0; i < 3; i++) for(j = 0; j < 3; j++) dest[i][j] = src[i][j]; } /******************************************************************************* * rot_transpose: Matrix transposition, which is inversion for Rotation matrices *******************************************************************************/ void rot_transpose(Rotation src, Rotation dst) { dst[0][0] = src[0][0]; dst[0][1] = src[1][0]; dst[0][2] = src[2][0]; dst[1][0] = src[0][1]; dst[1][1] = src[1][1]; dst[1][2] = src[2][1]; dst[2][0] = src[0][2]; dst[2][1] = src[1][2]; dst[2][2] = src[2][2]; } /******************************************************************************* * rot_apply: returns t*a *******************************************************************************/ Coords rot_apply(Rotation t, Coords a) { Coords b; if (rot_test_identity(t)) { return a; } else { b.x = t[0][0]*a.x + t[0][1]*a.y + t[0][2]*a.z; b.y = t[1][0]*a.x + t[1][1]*a.y + t[1][2]*a.z; b.z = t[2][0]*a.x + t[2][1]*a.y + t[2][2]*a.z; return b; } } /** * Pretty-printing of rotation matrices. */ void rot_print(Rotation rot) { printf("[ %4.2f %4.2f %4.2f ]\n", rot[0][0], rot[0][1], rot[0][2]); printf("[ %4.2f %4.2f %4.2f ]\n", rot[1][0], rot[1][1], rot[1][2]); printf("[ %4.2f %4.2f %4.2f ]\n\n", rot[2][0], rot[2][1], rot[2][2]); } /** * Vector product: used by vec_prod (mccode-r.h). Use coords_xp for Coords. */ void vec_prod_func(double *x, double *y, double *z, double x1, double y1, double z1, double x2, double y2, double z2) { *x = (y1)*(z2) - (y2)*(z1); *y = (z1)*(x2) - (z2)*(x1); *z = (x1)*(y2) - (x2)*(y1); } /** * Scalar product: use coords_sp for Coords. */ double scalar_prod( double x1, double y1, double z1, double x2, double y2, double z2) { return ((x1 * x2) + (y1 * y2) + (z1 * z2)); } mcstatic void norm_func(double *x, double *y, double *z) { double temp = (*x * *x) + (*y * *y) + (*z * *z); if (temp != 0) { temp = sqrt(temp); *x /= temp; *y /= temp; *z /= temp; } } /* SECTION: GPU algorithms ================================================== */ /* * Divide-and-conquer strategy for parallelizing this task: Sort absorbed * particles last. * * particles: the particle array, required to checking _absorbed * pbuffer: same-size particle buffer array required for parallel sort * len: sorting area-of-interest size (e.g. from previous calls) * buffer_len: total array size * flag_split: if set, multiply live particles into absorbed slots, up to buffer_len * multiplier: output arg, becomes the SPLIT multiplier if flag_split is set */ #ifdef FUNNEL long sort_absorb_last(_class_particle* particles, _class_particle* pbuffer, long len, long buffer_len, long flag_split, long* multiplier) { #define SAL_THREADS 1024 // num parallel sections if (len_absorbed)); // return (no SPLIT) if (flag_split != 1) return accumlen; // SPLIT - repeat the non-absorbed block N-1 times, where len % accumlen = N + R int mult = buffer_len / accumlen; // TODO: possibly use a new arg, bufferlen, rather than len // not enough space for full-block split, return if (mult <= 1) return accumlen; // copy non-absorbed block #pragma acc parallel loop present(particles[0:buffer_len]) for (long tidx = 0; tidx < accumlen; tidx++) { // tidx: thread index randstate_t randstate[7]; _class_particle sourcebuffer; _class_particle targetbuffer; // assign reduced weight to all particles particles[tidx].p=particles[tidx].p/mult; #pragma acc loop seq for (long bidx = 1; bidx < mult; bidx++) { // bidx: block index // preserve absorbed particle (for randstate) sourcebuffer = particles[bidx*accumlen + tidx]; // buffer full particle struct targetbuffer = particles[tidx]; // reassign previous randstate targetbuffer.randstate[0] = sourcebuffer.randstate[0]; targetbuffer.randstate[1] = sourcebuffer.randstate[1]; targetbuffer.randstate[2] = sourcebuffer.randstate[2]; targetbuffer.randstate[3] = sourcebuffer.randstate[3]; targetbuffer.randstate[4] = sourcebuffer.randstate[4]; targetbuffer.randstate[5] = sourcebuffer.randstate[5]; targetbuffer.randstate[6] = sourcebuffer.randstate[6]; // apply particles[bidx*accumlen + tidx] = targetbuffer; } } // set out split multiplier value *multiplier = mult; // return expanded array size return accumlen * mult; } #endif /* * Fallback serial version of the one above. */ long sort_absorb_last_serial(_class_particle* particles, long len) { long i = 0; long j = len - 1; _class_particle pbuffer; // bubble while (i < j) { while (!particles[i]._absorbed && ix; b.y = particle->y; b.z = particle->z; c = rot_apply(t, b); b = coords_add(c, a); particle->x = b.x; particle->y = b.y; particle->z = b.z; #if MCCODE_PARTICLE_CODE == 2112 if (particle->vz != 0.0 || particle->vx != 0.0 || particle->vy != 0.0) mccoordschange_polarisation(t, &(particle->vx), &(particle->vy), &(particle->vz)); if (particle->sz != 0.0 || particle->sx != 0.0 || particle->sy != 0.0) mccoordschange_polarisation(t, &(particle->sx), &(particle->sy), &(particle->sz)); #elif MCCODE_PARTICLE_CODE == 22 if (particle->kz != 0.0 || particle->kx != 0.0 || particle->ky != 0.0) mccoordschange_polarisation(t, &(particle->kx), &(particle->ky), &(particle->kz)); if (particle->Ez != 0.0 || particle->Ex != 0.0 || particle->Ey != 0.0) mccoordschange_polarisation(t, &(particle->Ex), &(particle->Ey), &(particle->Ez)); #endif } /******************************************************************************* * mccoordschange_polarisation: applies rotation to vector (sx sy sz) *******************************************************************************/ void mccoordschange_polarisation(Rotation t, double *sx, double *sy, double *sz) { Coords b, c; b.x = *sx; b.y = *sy; b.z = *sz; c = rot_apply(t, b); *sx = c.x; *sy = c.y; *sz = c.z; } /* SECTION: vector math ==================================================== */ /* normal_vec_func: Compute normal vector to (x,y,z). */ void normal_vec(double *nx, double *ny, double *nz, double x, double y, double z) { double ax = fabs(x); double ay = fabs(y); double az = fabs(z); double l; if(x == 0 && y == 0 && z == 0) { *nx = 0; *ny = 0; *nz = 0; return; } if(ax < ay) { if(ax < az) { /* Use X axis */ l = sqrt(z*z + y*y); *nx = 0; *ny = z/l; *nz = -y/l; return; } } else { if(ay < az) { /* Use Y axis */ l = sqrt(z*z + x*x); *nx = z/l; *ny = 0; *nz = -x/l; return; } } /* Use Z axis */ l = sqrt(y*y + x*x); *nx = y/l; *ny = -x/l; *nz = 0; } /* normal_vec */ /******************************************************************************* * solve_2nd_order: second order equation solve: A*t^2 + B*t + C = 0 * solve_2nd_order(&t1, NULL, A,B,C) * returns 0 if no solution was found, or set 't1' to the smallest positive * solution. * solve_2nd_order(&t1, &t2, A,B,C) * same as with &t2=NULL, but also returns the second solution. * EXAMPLE usage for intersection of a trajectory with a plane in gravitation * field (gx,gy,gz): * The neutron starts at point r=(x,y,z) with velocityv=(vx vy vz). The plane * has a normal vector n=(nx,ny,nz) and contains the point W=(wx,wy,wz). * The problem consists in solving the 2nd order equation: * 1/2.n.g.t^2 + n.v.t + n.(r-W) = 0 * so that A = 0.5 n.g; B = n.v; C = n.(r-W); * Without acceleration, t=-n.(r-W)/n.v ******************************************************************************/ int solve_2nd_order_old(double *t1, double *t2, double A, double B, double C) { int ret=0; if (!t1) return 0; *t1 = 0; if (t2) *t2=0; if (fabs(A) < 1E-10) /* approximate to linear equation: A ~ 0 */ { if (B) { *t1 = -C/B; ret=1; if (t2) *t2=*t1; } /* else no intersection: A=B=0 ret=0 */ } else { double D; D = B*B - 4*A*C; if (D >= 0) /* Delta > 0: two solutions */ { double sD, dt1, dt2; sD = sqrt(D); dt1 = (-B + sD)/2/A; dt2 = (-B - sD)/2/A; /* we identify very small values with zero */ if (fabs(dt1) < 1e-10) dt1=0.0; if (fabs(dt2) < 1e-10) dt2=0.0; /* now we choose the smallest positive solution */ if (dt1<=0.0 && dt2>0.0) ret=2; /* dt2 positive */ else if (dt2<=0.0 && dt1>0.0) ret=1; /* dt1 positive */ else if (dt1> 0.0 && dt2>0.0) { if (dt1 < dt2) ret=1; else ret=2; } /* all positive: min(dt1,dt2) */ /* else two solutions are negative. ret=-1 */ if (ret==1) { *t1 = dt1; if (t2) *t2=dt2; } else { *t1 = dt2; if (t2) *t2=dt1; } ret=2; /* found 2 solutions and t1 is the positive one */ } /* else Delta <0: no intersection. ret=0 */ } return(ret); } /* solve_2nd_order */ int solve_2nd_order(double *t0, double *t1, double A, double B, double C){ int retval=0; double sign=copysign(1.0,B); double dt0,dt1; dt0=0; dt1=0; if(t1){ *t1=0;} /*protect against rounding errors by locally equating DBL_EPSILON with 0*/ if (fabs(A)=0){ dt0=(-B - sign*sqrt(B*B-4*A*C))/(2*A); dt1=C/(A*dt0); retval=2; }else{ /*no real roots*/ retval=0; } } /*sort the solutions*/ if (retval==1){ /*put both solutions in t0 and t1*/ *t0=dt0; if(t1) *t1=dt1; }else{ /*we have two solutions*/ /*swap if both are positive and t1 smaller than t0 or t1 the only positive*/ int swap=0; if(dt1>0 && ( dt1) * * If height or width is zero, choose random direction in full 4PI, no target. * * Traditionally, this routine had the name randvec_target_rect - this is now a * a define (see mcstas-r.h) pointing here. If you use the old rouine, you are NOT * taking the local emmission coordinate into account. *******************************************************************************/ void _randvec_target_rect_real(double *xo, double *yo, double *zo, double *solid_angle, double xi, double yi, double zi, double width, double height, Rotation A, double lx, double ly, double lz, int order, _class_particle* _particle) { double dx, dy, dist, dist_p, nx, ny, nz, mx, my, mz, n_norm, m_norm; double cos_theta; Coords tmp; Rotation Ainverse; rot_transpose(A, Ainverse); if(height == 0.0 || width == 0.0) { randvec_target_circle(xo, yo, zo, solid_angle, xi, yi, zi, 0); return; } else { /* Now choose point uniformly on rectangle within width x height */ dx = width*randpm1()/2.0; dy = height*randpm1()/2.0; /* Determine distance to target plane*/ dist = sqrt(xi*xi + yi*yi + zi*zi); /* Go to global coordinate system */ tmp = coords_set(xi, yi, zi); tmp = rot_apply(Ainverse, tmp); coords_get(tmp, &xi, &yi, &zi); /* Determine vector normal to trajectory axis (z) and gravity [0 1 0] */ vec_prod(nx, ny, nz, xi, yi, zi, 0, 1, 0); /* This now defines the x-axis, normalize: */ n_norm=sqrt(nx*nx + ny*ny + nz*nz); nx = nx/n_norm; ny = ny/n_norm; nz = nz/n_norm; /* Now, determine our y-axis (vertical in many cases...) */ vec_prod(mx, my, mz, xi, yi, zi, nx, ny, nz); m_norm=sqrt(mx*mx + my*my + mz*mz); mx = mx/m_norm; my = my/m_norm; mz = mz/m_norm; /* Our output, random vector can now be defined by linear combination: */ *xo = xi + dx * nx + dy * mx; *yo = yi + dx * ny + dy * my; *zo = zi + dx * nz + dy * mz; /* Go back to local coordinate system */ tmp = coords_set(*xo, *yo, *zo); tmp = rot_apply(A, tmp); coords_get(tmp, &*xo, &*yo, &*zo); /* Go back to local coordinate system */ tmp = coords_set(xi, yi, zi); tmp = rot_apply(A, tmp); coords_get(tmp, &xi, &yi, &zi); if (solid_angle) { /* Calculate vector from local point to remote random point */ lx = *xo - lx; ly = *yo - ly; lz = *zo - lz; dist_p = sqrt(lx*lx + ly*ly + lz*lz); /* Adjust the 'solid angle' */ /* 1/r^2 to the chosen point times cos(\theta) between the normal */ /* vector of the target rectangle and direction vector of the chosen point. */ cos_theta = (xi * lx + yi * ly + zi * lz) / (dist * dist_p); *solid_angle = width * height / (dist_p * dist_p); int counter; for (counter = 0; counter < order; counter++) { *solid_angle = *solid_angle * cos_theta; } } } } /* randvec_target_rect_real */ /* SECTION: random numbers ================================================== How to add a new RNG: - Use an rng with a manegable state vector, e.g. of lengt 4 or 7. The state will sit on the particle struct as a "randstate_t state[RANDSTATE_LEN]" - If the rng has a long state (as MT), set an empty "srandom" and initialize it explicitly using the appropriate define (RNG_ALG) - Add a seed and a random function (the transforms will be reused) - Write the proper defines in mccode-r.h, e.g. randstate_t and RANDSTATE_LEN, srandom and random. - Compile using -DRNG_ALG= ============================================================================= */ /* "Mersenne Twister", by Makoto Matsumoto and Takuji Nishimura. */ /* See http://www.math.keio.ac.jp/~matumoto/emt.html for original source. */ /* A C-program for MT19937, with initialization improved 2002/1/26. Coded by Takuji Nishimura and Makoto Matsumoto. Before using, initialize the state by using mt_srandom(seed) or init_by_array(init_key, key_length). Copyright (C) 1997 - 2002, Makoto Matsumoto and Takuji Nishimura, All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 3. The names of its contributors may not be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. Any feedback is very welcome. http://www.math.keio.ac.jp/matumoto/emt.html email: matumoto@math.keio.ac.jp */ #include #include // for uint32_t #include // for size_t /* Period parameters */ #define N 624 #define M 397 #define MATRIX_A 0x9908b0dfU /* constant vector a */ #define UPPER_MASK 0x80000000U /* most significant w-r bits */ #define LOWER_MASK 0x7fffffffU /* least significant r bits */ static uint32_t mt[N]; /* the array for the state vector */ static int mti = N + 1; /* mti==N+1 means mt[N] is not initialized */ // Required for compatibility with common RNG interface (e.g., kiss/mt polymorphism) void mt_srandom_empty(void) {} // Initializes mt[N] with a seed void mt_srandom(uint32_t seed) { mt[0] = seed; for (mti = 1; mti < N; mti++) { mt[mti] = 1812433253U * (mt[mti-1] ^ (mt[mti-1] >> 30)) + mti; /* See Knuth TAOCP Vol2. 3rd Ed. P.106 for multiplier. */ /* In the previous versions, MSBs of the seed affect */ /* only MSBs of the array mt[]. */ /* 2002/01/09 modified by Makoto Matsumoto */ mt[mti] &= 0xffffffffU; /* for >32 bit machines */ } } /* Initialize by an array with array-length. Init_key is the array for initializing keys. key_length is its length. */ void init_by_array(uint32_t init_key[], size_t key_length) { size_t i = 1, j = 0, k; mt_srandom(19650218U); k = (N > key_length ? N : key_length); for (; k; k--) { mt[i] = (mt[i] ^ ((mt[i-1] ^ (mt[i-1] >> 30)) * 1664525U)) + init_key[j] + (uint32_t)j; mt[i] &= 0xffffffffU; i++; j++; if (i >= N) { mt[0] = mt[N - 1]; i = 1; } if (j >= key_length) j = 0; } for (k = N - 1; k; k--) { mt[i] = (mt[i] ^ ((mt[i-1] ^ (mt[i-1] >> 30)) * 1566083941U)) - (uint32_t)i; mt[i] &= 0xffffffffU; i++; if (i >= N) { mt[0] = mt[N - 1]; i = 1; } } mt[0] = 0x80000000U; /* MSB is 1; ensuring non-zero initial array */ } // Generates a random number on [0, 0xffffffff]-interval uint32_t mt_random(void) { uint32_t y; static const uint32_t mag01[2] = { 0x0U, MATRIX_A }; /* mag01[x] = x * MATRIX_A for x=0,1 */ if (mti >= N) { /* generate N words at one time */ int kk; if (mti == N + 1) /* if mt_srandom() has not been called, */ mt_srandom(5489U); /* a default initial seed is used */ for (kk = 0; kk < N - M; kk++) { y = (mt[kk] & UPPER_MASK) | (mt[kk + 1] & LOWER_MASK); mt[kk] = mt[kk + M] ^ (y >> 1) ^ mag01[y & 0x1U]; } for (; kk < N - 1; kk++) { y = (mt[kk] & UPPER_MASK) | (mt[kk + 1] & LOWER_MASK); mt[kk] = mt[kk + (M - N)] ^ (y >> 1) ^ mag01[y & 0x1U]; } y = (mt[N - 1] & UPPER_MASK) | (mt[0] & LOWER_MASK); mt[N - 1] = mt[M - 1] ^ (y >> 1) ^ mag01[y & 0x1U]; mti = 0; } y = mt[mti++]; /* Tempering */ y ^= (y >> 11); y ^= (y << 7) & 0x9d2c5680U; y ^= (y << 15) & 0xefc60000U; y ^= (y >> 18); return y; } #undef N #undef M #undef MATRIX_A #undef UPPER_MASK #undef LOWER_MASK /* End of "Mersenne Twister". */ /* KISS From: http://www.helsbreth.org/random/rng_kiss.html Scott Nelson 1999 Based on Marsaglia's KISS or (KISS+SWB) KISS - Keep it Simple Stupid PRNG the idea is to use simple, fast, individually promising generators to get a composite that will be fast, easy to code have a very long period and pass all the tests put to it. The three components of KISS are x(n)=a*x(n-1)+1 mod 2^32 y(n)=y(n-1)(I+L^13)(I+R^17)(I+L^5), z(n)=2*z(n-1)+z(n-2) +carry mod 2^32 The y's are a shift register sequence on 32bit binary vectors period 2^32-1; The z's are a simple multiply-with-carry sequence with period 2^63+2^32-1. The period of KISS is thus 2^32*(2^32-1)*(2^63+2^32-1) > 2^127 In 2025 adapted for consistent 64-bit behavior across platforms. */ /* the KISS state is stored as a vector of 7 uint64_t */ /* 0 1 2 3 4 5 6 */ /* [ x, y, z, w, carry, k, m ] */ uint64_t *kiss_srandom(uint64_t state[7], uint64_t seed) { if (seed == 0) seed = 1ull; state[0] = seed | 1ull; // x state[1] = seed | 2ull; // y state[2] = seed | 4ull; // z state[3] = seed | 8ull; // w state[4] = 0ull; // carry state[5] = 0ull; // k state[6] = 0ull; // m return state; } uint64_t kiss_random(uint64_t state[7]) { // Linear congruential generator state[0] = state[0] * 69069ull + 1ull; // Xorshift state[1] ^= state[1] << 13ull; state[1] ^= state[1] >> 17ull; state[1] ^= state[1] << 5ull; // Multiply-with-carry state[5] = (state[2] >> 2ull) + (state[3] >> 3ull) + (state[4] >> 2ull); state[6] = state[3] + state[3] + state[2] + state[4]; state[2] = state[3]; state[3] = state[6]; state[4] = state[5] >> 62ull; // Top bit of carry (adjusted for 64-bit) return state[0] + state[1] + state[3]; } /* end of "KISS" rng */ /* FAST KISS in another implementation (Hundt) */ ////////////////////////////////////////////////////////////////////////////// // fast keep it simple stupid generator ////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////// // Thomas Mueller hash for initialization of rngs // http://stackoverflow.com/questions/664014/ // what-integer-hash-function-are-good-that-accepts-an-integer-hash-key ////////////////////////////////////////////////////////////////////////////// randstate_t _hash(randstate_t x) { x = ((x >> 16) ^ x) * (randstate_t)0x45d9f3b; x = ((x >> 16) ^ x) * (randstate_t)0x45d9f3b; x = ((x >> 16) ^ x); return x; } // SECTION: random number transforms ========================================== // generate a random number from normal law double _randnorm(randstate_t* state) { static double v1, v2, s; /* removing static breaks comparison with McStas <= 2.5 */ static int phase = 0; double X, u1, u2; if(phase == 0) { do { u1 = _rand01(state); u2 = _rand01(state); v1 = 2*u1 - 1; v2 = 2*u2 - 1; s = v1*v1 + v2*v2; } while(s >= 1 || s == 0); X = v1*sqrt(-2*log(s)/s); } else { X = v2*sqrt(-2*log(s)/s); } phase = 1 - phase; return X; } // another one double _randnorm2(randstate_t* state) { double x, y, r; do { x = 2.0 * _rand01(state) - 1.0; y = 2.0 * _rand01(state) - 1.0; r = x*x + y*y; } while (r == 0.0 || r >= 1.0); return x * sqrt((-2.0 * log(r)) / r); } // Generate a random number from -1 to 1 with triangle distribution double _randtriangle(randstate_t* state) { double randnum = _rand01(state); if (randnum>0.5) return(1-sqrt(2*(randnum-0.5))); else return(sqrt(2*randnum)-1); } double _rand01(randstate_t* state) { double randnum; randnum = (double) _random(); // TODO: can we mult instead of div? randnum /= (double) MC_RAND_MAX + 1; return randnum; } double _rand01_opague(void* opague_state) { randstate_t* state = (randstate_t*)opague_state; // Following lines exactly like in _rand01 just above (repeated to // avoid another layer of indirection): double randnum; randnum = (double) _random(); // TODO: can we mult instead of div? randnum /= (double) MC_RAND_MAX + 1; return randnum; } // Return a random number between 1 and -1 double _randpm1(randstate_t* state) { double randnum; randnum = (double) _random(); randnum /= ((double) MC_RAND_MAX + 1) / 2; randnum -= 1; return randnum; } // Return a random number between 0 and max. double _rand0max(double max, randstate_t* state) { double randnum; randnum = (double) _random(); randnum /= ((double) MC_RAND_MAX + 1) / max; return randnum; } // Return a random number between min and max. double _randminmax(double min, double max, randstate_t* state) { return _rand0max(max - min, state) + max; } /* SECTION: main and signal handlers ======================================== */ /******************************************************************************* * mchelp: displays instrument executable help with possible options *******************************************************************************/ static void mchelp(char *pgmname) { int i; fprintf(stderr, "%s (%s) instrument simulation, generated with " MCCODE_STRING " (" MCCODE_DATE ")\n", instrument_name, instrument_source); fprintf(stderr, "Usage: %s [options] [parm=value ...]\n", pgmname); fprintf(stderr, "Options are:\n" " -s SEED --seed=SEED Set random seed (must be != 0)\n" " -n COUNT --ncount=COUNT Set number of particles to simulate.\n" " -d DIR --dir=DIR Put all data files in directory DIR.\n" " -a --append Append data files to those in directory DIR.\n" " -t --trace Enable trace of " MCCODE_PARTICLE "s through instrument.\n" " (Use -t=2 or --trace=2 for modernised mcdisplay rendering)\n" " -g --gravitation Enable gravitation for all trajectories.\n" " --no-output-files Do not write any data files.\n" " -h --help Show this help message.\n" " -i --info Detailed instrument information.\n" " --list-parameters Print the instrument parameters to standard out\n" " -y --yes Assume default values for all parameters with a default\n" " --meta-list Print names of components which defined metadata\n" " --meta-defined COMP[:NAME] Print component defined metadata names, or (0,1) if NAME provided\n" " --meta-type COMP:NAME Print metadata format type specified in definition\n" " --meta-data COMP:NAME Print the metadata text\n" " --source Show the instrument code which was compiled.\n" #ifdef OPENACC "\n" " --vecsize OpenACC vector-size (default: 128)\n" " --numgangs Number of OpenACC gangs (default: 7813)\n" " --gpu_innerloop Maximum rays to process pr. OpenACC \n" " kernel run (default: 2147483647)\n" "\n" #endif "\n" " --bufsiz Monitor_nD list/buffer-size (default: 1000000)\n" " --format=FORMAT Output data files using FORMAT=" FLAVOR_UPPER #ifdef USE_NEXUS " NEXUS\n" " --IDF Embed an xml-formatted IDF instrument definition\n" " in the NeXus file (if existent in .)\n\n" #else "\n\n" #endif ); #ifdef USE_MPI fprintf(stderr, "This instrument has been compiled with MPI support.\n Use 'mpirun %s [options] [parm=value ...]'.\n", pgmname); #endif #ifdef OPENACC fprintf(stderr, "This instrument has been compiled with NVIDIA GPU support through OpenACC.\n Running on systems without such devices will lead to segfaults.\nFurter, fprintf, sprintf and printf have been removed from any component TRACE.\n"); #endif if(numipar > 0) { fprintf(stderr, "Instrument parameters are:\n"); for(i = 0; i < numipar; i++) if (mcinputtable[i].val && strlen(mcinputtable[i].val)) fprintf(stderr, " %-16s(%s) [default='%s']\n", mcinputtable[i].name, (*mcinputtypes[mcinputtable[i].type].parminfo)(mcinputtable[i].name), mcinputtable[i].val); else fprintf(stderr, " %-16s(%s)\n", mcinputtable[i].name, (*mcinputtypes[mcinputtable[i].type].parminfo)(mcinputtable[i].name)); } #ifndef NOSIGNALS fprintf(stderr, "Known signals are: " #ifdef SIGUSR1 "USR1 (status) " #endif #ifdef SIGUSR2 "USR2 (save) " #endif #ifdef SIGBREAK "BREAK (save) " #endif #ifdef SIGTERM "TERM (save and exit)" #endif "\n"); #endif /* !NOSIGNALS */ } /* mchelp */ /* mcshowhelp: show help and exit with 0 */ static void mcshowhelp(char *pgmname) { mchelp(pgmname); exit(0); } /* mcusage: display usage when error in input arguments and exit with 1 */ static void mcusage(char *pgmname) { fprintf(stderr, "Error: incorrect command line arguments\n"); mchelp(pgmname); exit(1); } /* mcenabletrace: enable trace/mcdisplay or error if requires recompile */ static void mcenabletrace(int mode) { if(traceenabled) { mcdotrace = mode; #pragma acc update device ( mcdotrace ) } else { if (mode>0) { fprintf(stderr, "Error: trace not enabled (mcenabletrace)\n" "Please re-run the " MCCODE_NAME " compiler " "with the --trace option, or rerun the\n" "C compiler with the MC_TRACE_ENABLED macro defined.\n"); exit(1); } } } /******************************************************************************* * mcreadparams: request parameters from the prompt (or use default) *******************************************************************************/ void mcreadparams(void) { int i,j,status; static char buf[CHAR_BUF_LENGTH]; char *p; int len; MPI_MASTER(printf("Instrument parameters for %s (%s)\n", instrument_name, instrument_source)); for(i = 0; mcinputtable[i].name != 0; i++) { do { MPI_MASTER( if (mcinputtable[i].val && strlen(mcinputtable[i].val)) printf("Set value of instrument parameter %s (%s) [default='%s']:\n", mcinputtable[i].name, (*mcinputtypes[mcinputtable[i].type].parminfo) (mcinputtable[i].name), mcinputtable[i].val); else printf("Set value of instrument parameter %s (%s):\n", mcinputtable[i].name, (*mcinputtypes[mcinputtable[i].type].parminfo) (mcinputtable[i].name)); fflush(stdout); ); #ifdef USE_MPI if(mpi_node_rank == mpi_node_root) { p = fgets(buf, CHAR_BUF_LENGTH, stdin); if(p == NULL) { fprintf(stderr, "Error: empty input for paramater %s (mcreadparams)\n", mcinputtable[i].name); exit(1); } } else p = buf; MPI_Bcast(buf, CHAR_BUF_LENGTH, MPI_CHAR, mpi_node_root, MPI_COMM_WORLD); #else /* !USE_MPI */ p = fgets(buf, CHAR_BUF_LENGTH, stdin); if(p == NULL) { fprintf(stderr, "Error: empty input for paramater %s (mcreadparams)\n", mcinputtable[i].name); exit(1); } #endif /* USE_MPI */ len = strlen(buf); if (!len || (len == 1 && (buf[0] == '\n' || buf[0] == '\r'))) { if (mcinputtable[i].val && strlen(mcinputtable[i].val)) { strncpy(buf, mcinputtable[i].val, CHAR_BUF_LENGTH); /* use default value */ len = strlen(buf); } } for(j = 0; j < 2; j++) { if(len > 0 && (buf[len - 1] == '\n' || buf[len - 1] == '\r')) { len--; buf[len] = '\0'; } } status = (*mcinputtypes[mcinputtable[i].type].getparm) (buf, mcinputtable[i].par); if(!status) { (*mcinputtypes[mcinputtable[i].type].error)(mcinputtable[i].name, buf); if (!mcinputtable[i].val || strlen(mcinputtable[i].val)) { fprintf(stderr, " Change %s default value in instrument definition.\n", mcinputtable[i].name); exit(1); } } } while(!status); } } /* mcreadparams */ /******************************************************************************* * mcparseoptions: parse command line arguments (options, parameters) *******************************************************************************/ void mcparseoptions(int argc, char *argv[]) { int i, j; char *p; int paramset = 0, *paramsetarray; char *usedir=NULL; /* Add one to numipar to avoid allocating zero size memory block. */ paramsetarray = (int*)malloc((numipar + 1)*sizeof(*paramsetarray)); if(paramsetarray == NULL) { fprintf(stderr, "Error: insufficient memory (mcparseoptions)\n"); exit(1); } for(j = 0; j < numipar; j++) { paramsetarray[j] = 0; if (mcinputtable[j].val != NULL && strlen(mcinputtable[j].val)) { int status; char buf[CHAR_BUF_LENGTH]; strncpy(buf, mcinputtable[j].val, CHAR_BUF_LENGTH); status = (*mcinputtypes[mcinputtable[j].type].getparm) (buf, mcinputtable[j].par); if(!status) fprintf(stderr, "Invalid '%s' default value %s in instrument definition (mcparseoptions)\n", mcinputtable[j].name, buf); else paramsetarray[j] = 1; } else { (*mcinputtypes[mcinputtable[j].type].getparm) (NULL, mcinputtable[j].par); paramsetarray[j] = 0; } } for(i = 1; i < argc; i++) { if(!strcmp("-s", argv[i]) && (i + 1) < argc) mcsetseed(argv[++i]); else if(!strncmp("-s", argv[i], 2)) mcsetseed(&argv[i][2]); else if(!strcmp("--seed", argv[i]) && (i + 1) < argc) mcsetseed(argv[++i]); else if(!strncmp("--seed=", argv[i], 7)) mcsetseed(&argv[i][7]); else if(!strcmp("-n", argv[i]) && (i + 1) < argc) mcsetn_arg(argv[++i]); else if(!strncmp("-n", argv[i], 2)) mcsetn_arg(&argv[i][2]); else if(!strcmp("--ncount", argv[i]) && (i + 1) < argc) mcsetn_arg(argv[++i]); else if(!strncmp("--ncount=", argv[i], 9)) mcsetn_arg(&argv[i][9]); else if(!strcmp("-d", argv[i]) && (i + 1) < argc) usedir=argv[++i]; /* will create directory after parsing all arguments (end of this function) */ else if(!strncmp("-d", argv[i], 2)) usedir=&argv[i][2]; else if(!strcmp("--dir", argv[i]) && (i + 1) < argc) usedir=argv[++i]; else if(!strncmp("-a", argv[i], 2)) mcappend = 1; else if(!strcmp("--append", argv[i])) mcappend = 1; else if(!strncmp("--dir=", argv[i], 6)) usedir=&argv[i][6]; else if(!strcmp("-h", argv[i])) mcshowhelp(argv[0]); else if(!strcmp("--help", argv[i]) || !strcmp("--version", argv[i])) mcshowhelp(argv[0]); else if(!strcmp("-i", argv[i])) { mcformat=FLAVOR_UPPER; mcinfo(); } else if(!strcmp("--info", argv[i])) mcinfo(); else if (!strcmp("--list-parameters", argv[i])) mcparameterinfo(); else if (!strcmp("--meta-list", argv[i]) && ((i+1) >= argc || argv[i+1][0] == '-')){ //printf("Components with metadata defined:\n"); exit(metadata_table_print_all_components(num_metadata, metadata_table) == 0); } else if (!strcmp("--meta-defined", argv[i]) && (i+1) < argc){ exit(metadata_table_print_component_keys(num_metadata, metadata_table, argv[i+1]) == 0); } else if (!strcmp("--meta-type", argv[i]) && (i+1) < argc){ char * literal_type = metadata_table_type(num_metadata, metadata_table, argv[i+1]); if (literal_type == NULL) exit(1); printf("%s\n", literal_type); exit(0); } else if (!strcmp("--meta-data", argv[i]) && (i+1) < argc){ char * literal = metadata_table_literal(num_metadata, metadata_table, argv[i+1]); if (literal == NULL) exit(1); printf("%s\n", literal); exit(0); } else if(!strncmp("--trace=", argv[i], 8)) { mcenabletrace(atoi(&argv[i][8])); } else if(!strncmp("-t=", argv[i], 3) || !strcmp("--verbose", argv[i])) { mcenabletrace(atoi(&argv[i][3])); } else if(!strcmp("-t", argv[i])) mcenabletrace(1); else if(!strcmp("--trace", argv[i]) || !strcmp("--verbose", argv[i])) mcenabletrace(1); else if(!strcmp("--gravitation", argv[i])) mcgravitation = 1; else if(!strcmp("-g", argv[i])) mcgravitation = 1; else if(!strcmp("--yes", argv[i])) mcusedefaults = 1; else if(!strcmp("-y", argv[i])) mcusedefaults = 1; else if(!strncmp("--format=", argv[i], 9)) { mcformat=&argv[i][9]; } else if(!strcmp("--format", argv[i]) && (i + 1) < argc) { mcformat=argv[++i]; } #ifdef USE_NEXUS else if(!strcmp("--IDF", argv[i])) { mcnexus_embed_idf = 1; } #endif else if(!strncmp("--vecsize=", argv[i], 10)) { vecsize=atoi(&argv[i][10]); } else if(!strcmp("--vecsize", argv[i]) && (i + 1) < argc) { vecsize=atoi(argv[++i]); } else if(!strncmp("--bufsiz=", argv[i], 9)) { MONND_BUFSIZ=atoi(&argv[i][9]); } else if(!strcmp("--bufsiz", argv[i]) && (i + 1) < argc) { MONND_BUFSIZ=atoi(argv[++i]); } else if(!strncmp("--numgangs=", argv[i], 11)) { numgangs=atoi(&argv[i][11]); } else if(!strcmp("--numgangs", argv[i]) && (i + 1) < argc) { numgangs=atoi(argv[++i]); } else if(!strncmp("--gpu_innerloop=", argv[i], 16)) { gpu_innerloop=(long)strtod(&argv[i][16], NULL); } else if(!strcmp("--gpu_innerloop", argv[i]) && (i + 1) < argc) { gpu_innerloop=(long)strtod(argv[++i], NULL); } else if(!strcmp("--no-output-files", argv[i])) mcdisable_output_files = 1; else if(!strcmp("--source", argv[i])) { printf("/* Source code %s from %s: */\n" "/******************************************************************************/\n" "%s\n" "/******************************************************************************/\n" "/* End of source code %s from %s */\n", instrument_name, instrument_source, instrument_code, instrument_name, instrument_source); exit(1); } else if(argv[i][0] != '-' && (p = strchr(argv[i], '=')) != NULL) { *p++ = '\0'; for(j = 0; j < numipar; j++) if(!strcmp(mcinputtable[j].name, argv[i])) { int status; status = (*mcinputtypes[mcinputtable[j].type].getparm)(p, mcinputtable[j].par); if(!status || !strlen(p)) { (*mcinputtypes[mcinputtable[j].type].error) (mcinputtable[j].name, p); exit(1); } paramsetarray[j] = 1; paramset = 1; break; } if(j == numipar) { /* Unrecognized parameter name */ fprintf(stderr, "Error: unrecognized parameter %s (mcparseoptions)\n", argv[i]); exit(1); } } else if(argv[i][0] == '-') { fprintf(stderr, "Error: unrecognized option argument %s (mcparseoptions). Ignored.\n", argv[i++]); } else { fprintf(stderr, "Error: unrecognized argument %s (mcparseoptions). Aborting.\n", argv[i]); mcusage(argv[0]); } } if (mcusedefaults) { MPI_MASTER( printf("Using all default parameter values\n"); ); for(j = 0; j < numipar; j++) { int status; if(mcinputtable[j].val && strlen(mcinputtable[j].val)){ status = (*mcinputtypes[mcinputtable[j].type].getparm)(mcinputtable[j].val, mcinputtable[j].par); paramsetarray[j] = 1; paramset = 1; } } } if(!paramset) mcreadparams(); /* Prompt for parameters if not specified. */ else { for(j = 0; j < numipar; j++) if(!paramsetarray[j]) { fprintf(stderr, "Error: Instrument parameter %s left unset (mcparseoptions)\n", mcinputtable[j].name); exit(1); } } free(paramsetarray); #ifdef USE_MPI if (mcdotrace) mpi_node_count=1; /* disable threading when in trace mode */ #endif if (usedir && strlen(usedir) && !mcdisable_output_files) mcuse_dir(usedir); } /* mcparseoptions */ #ifndef NOSIGNALS /******************************************************************************* * sighandler: signal handler that makes simulation stop, and save results *******************************************************************************/ void sighandler(int sig) { /* MOD: E. Farhi, Sep 20th 2001: give more info */ time_t t1, t0; #define SIG_SAVE 0 #define SIG_TERM 1 #define SIG_STAT 2 #define SIG_ABRT 3 printf("\n# " MCCODE_STRING ": [pid %i] Signal %i detected", getpid(), sig); #ifdef USE_MPI printf(" [proc %i]", mpi_node_rank); #endif #if defined(SIGUSR1) && defined(SIGUSR2) && defined(SIGKILL) if (!strcmp(mcsig_message, "sighandler") && (sig != SIGUSR1) && (sig != SIGUSR2)) { printf("\n# Fatal : unrecoverable loop ! Suicide (naughty boy).\n"); kill(0, SIGKILL); /* kill myself if error occurs within sighandler: loops */ } #endif switch (sig) { #ifdef SIGINT case SIGINT : printf(" SIGINT (interrupt from terminal, Ctrl-C)"); sig = SIG_TERM; break; #endif #ifdef SIGILL case SIGILL : printf(" SIGILL (Illegal instruction)"); sig = SIG_ABRT; break; #endif #ifdef SIGFPE case SIGFPE : printf(" SIGFPE (Math Error)"); sig = SIG_ABRT; break; #endif #ifdef SIGSEGV case SIGSEGV : printf(" SIGSEGV (Mem Error)"); sig = SIG_ABRT; break; #endif #ifdef SIGTERM case SIGTERM : printf(" SIGTERM (Termination)"); sig = SIG_TERM; break; #endif #ifdef SIGABRT case SIGABRT : printf(" SIGABRT (Abort)"); sig = SIG_ABRT; break; #endif #ifdef SIGQUIT case SIGQUIT : printf(" SIGQUIT (Quit from terminal)"); sig = SIG_TERM; break; #endif #ifdef SIGTRAP case SIGTRAP : printf(" SIGTRAP (Trace trap)"); sig = SIG_ABRT; break; #endif #ifdef SIGPIPE case SIGPIPE : printf(" SIGPIPE (Broken pipe)"); sig = SIG_ABRT; break; #endif #ifdef SIGUSR1 case SIGUSR1 : printf(" SIGUSR1 (Display info)"); sig = SIG_STAT; break; #endif #ifdef SIGUSR2 case SIGUSR2 : printf(" SIGUSR2 (Save simulation)"); sig = SIG_SAVE; break; #endif #ifdef SIGHUP case SIGHUP : printf(" SIGHUP (Hangup/update)"); sig = SIG_SAVE; break; #endif #ifdef SIGBUS case SIGBUS : printf(" SIGBUS (Bus error)"); sig = SIG_ABRT; break; #endif #ifdef SIGURG case SIGURG : printf(" SIGURG (Urgent socket condition)"); sig = SIG_ABRT; break; #endif #ifdef SIGBREAK case SIGBREAK: printf(" SIGBREAK (Break signal, Ctrl-Break)"); sig = SIG_SAVE; break; #endif default : printf(" (look at signal list for signification)"); sig = SIG_ABRT; break; } printf("\n"); printf("# Simulation: %s (%s) \n", instrument_name, instrument_source); printf("# Breakpoint: %s ", mcsig_message); if (strstr(mcsig_message, "Save") && (sig == SIG_SAVE)) sig = SIG_STAT; SIG_MESSAGE("sighandler"); if (mcget_ncount() == 0) printf("(0 %%)\n" ); else { printf("%.2f %% (%10.1f/%10.1f)\n", 100.0*mcget_run_num()/mcget_ncount(), 1.0*mcget_run_num(), 1.0*mcget_ncount()); } t0 = (time_t)mcstartdate; t1 = time(NULL); printf("# Date: %s", ctime(&t1)); printf("# Started: %s", ctime(&t0)); if (sig == SIG_STAT) { printf("# " MCCODE_STRING ": Resuming simulation (continue)\n"); fflush(stdout); return; } else if (sig == SIG_SAVE) { printf("# " MCCODE_STRING ": Saving data and resume simulation (continue)\n"); save(NULL); fflush(stdout); return; } else if (sig == SIG_TERM) { printf("# " MCCODE_STRING ": Finishing simulation (save results and exit)\n"); finally(); exit(0); } else { fflush(stdout); perror("# Last I/O Error"); printf("# " MCCODE_STRING ": Simulation stop (abort).\n"); // This portion of the signal handling only works on UNIX #if defined(__unix__) || defined(__APPLE__) signal(sig, SIG_DFL); /* force to use default sighandler now */ kill(getpid(), sig); /* and trigger it with the current signal */ #endif exit(-1); } #undef SIG_SAVE #undef SIG_TERM #undef SIG_STAT #undef SIG_ABRT } /* sighandler */ #endif /* !NOSIGNALS */ #ifdef NEUTRONICS /*Main neutronics function steers the McStas calls, initializes parameters etc */ /* Only called in case NEUTRONICS = TRUE */ void neutronics_main_(float *inx, float *iny, float *inz, float *invx, float *invy, float *invz, float *intime, float *insx, float *insy, float *insz, float *inw, float *outx, float *outy, float *outz, float *outvx, float *outvy, float *outvz, float *outtime, float *outsx, float *outsy, float *outsz, float *outwgt) { extern double mcnx, mcny, mcnz, mcnvx, mcnvy, mcnvz; extern double mcnt, mcnsx, mcnsy, mcnsz, mcnp; /* External code governs iteration - McStas is iterated once per call to neutronics_main. I.e. below counter must be initiancated for each call to neutronics_main*/ mcrun_num=0; time_t t; t = (time_t)mcstartdate; mcstartdate = t; /* set start date before parsing options and creating sim file */ init(); /* *** parse options *** */ SIG_MESSAGE("[" __FILE__ "] main START"); mcformat=getenv(FLAVOR_UPPER "_FORMAT") ? getenv(FLAVOR_UPPER "_FORMAT") : FLAVOR_UPPER; /* Set neutron state based on input from neutronics code */ mcsetstate(*inx,*iny,*inz,*invx,*invy,*invz,*intime,*insx,*insy,*insz,*inw); /* main neutron event loop - runs only one iteration */ //mcstas_raytrace(&mcncount); /* prior to McStas 1.12 */ mcallowbackprop = 1; //avoid absorbtion from negative dt int argc=1; char *argv[0]; int dummy = mccode_main(argc, argv); *outx = mcnx; *outy = mcny; *outz = mcnz; *outvx = mcnvx; *outvy = mcnvy; *outvz = mcnvz; *outtime = mcnt; *outsx = mcnsx; *outsy = mcnsy; *outsz = mcnsz; *outwgt = mcnp; return; } /* neutronics_main */ #endif /*NEUTRONICS*/ #endif /* !MCCODE_H */ /* End of file "mccode-r.c". */ /* End of file "mccode-r.c". */ /* embedding file "mcstas-r.c" */ /******************************************************************************* * * McStas, neutron ray-tracing package * Copyright (C) 1997-2009, All rights reserved * Risoe National Laboratory, Roskilde, Denmark * Institut Laue Langevin, Grenoble, France * * Runtime: share/mcstas-r.c * * %Identification * Written by: KN * Date: Aug 29, 1997 * Release: McStas X.Y * Version: $Revision$ * * Runtime system for McStas. * Embedded within instrument in runtime mode. * * Usage: Automatically embbeded in the c code whenever required. * * $Id$ * *******************************************************************************/ #ifndef MCSTAS_R_H #include "mcstas-r.h" #endif #ifdef DANSE #include "mcstas-globals.h" #endif /******************************************************************************* * The I/O format definitions and functions *******************************************************************************/ /*the magnet stack*/ #ifdef MC_POL_COMPAT void (*mcMagnetPrecession) (double, double, double, double, double, double, double, double*, double*, double*, double, Coords, Rotation)=NULL; Coords mcMagnetPos; Rotation mcMagnetRot; double* mcMagnetData = NULL; /* mcMagneticField(x, y, z, t, Bx, By, Bz) */ int (*mcMagneticField) (double, double, double, double, double*, double*, double*, void *) = NULL; #endif #ifndef MCSTAS_H /******************************************************************************* * mcsetstate: transfer parameters into global McStas variables *******************************************************************************/ _class_particle mcsetstate(double x, double y, double z, double vx, double vy, double vz, double t, double sx, double sy, double sz, double p, int mcgravitation, void *mcMagnet, int mcallowbackprop) { _class_particle mcneutron; mcneutron.x = x; mcneutron.y = y; mcneutron.z = z; mcneutron.vx = vx; mcneutron.vy = vy; mcneutron.vz = vz; mcneutron.t = t; mcneutron.sx = sx; mcneutron.sy = sy; mcneutron.sz = sz; mcneutron.p = p; mcneutron.mcgravitation = mcgravitation; mcneutron.mcMagnet = mcMagnet; mcneutron.allow_backprop = mcallowbackprop; mcneutron._uid = 0; mcneutron._index = 1; mcneutron._absorbed = 0; mcneutron._restore = 0; mcneutron._scattered = 0; mcneutron.flag_nocoordschange = 0; /* init tmp-vars - FIXME are they used? */ mcneutron._mctmp_a = mcneutron._mctmp_b = mcneutron._mctmp_c = 0; // what about mcneutron._logic ? mcneutron._logic.dummy=1; // init uservars via cogen'd-function particle_uservar_init(&mcneutron); return(mcneutron); } /* mcsetstate */ /******************************************************************************* * mcgetstate: get neutron parameters from particle structure *******************************************************************************/ _class_particle mcgetstate(_class_particle mcneutron, double *x, double *y, double *z, double *vx, double *vy, double *vz, double *t, double *sx, double *sy, double *sz, double *p) { *x = mcneutron.x; *y = mcneutron.y; *z = mcneutron.z; *vx = mcneutron.vx; *vy = mcneutron.vy; *vz = mcneutron.vz; *t = mcneutron.t; *sx = mcneutron.sx; *sy = mcneutron.sy; *sz = mcneutron.sz; *p = mcneutron.p; return(mcneutron); } /* mcgetstate */ /******************************************************************************* * SCATTER_func: provides function to SCATTER from within libaries *******************************************************************************/ void SCATTER_func(_class_particle *_particle) { if(mcdotrace) { printf("SCATTER: %g, %g, %g, %g, %g, %g, %g, %g, %g, %g, %g\n", _particle->x,_particle->y,_particle->z, _particle->vx,_particle->vy,_particle->vz, _particle->t, _particle->sx,_particle->sy,_particle->sz, _particle->p); } if (!_particle->_absorbed) _particle->_scattered++; } /* SCATTER_func */ /******************************************************************************* * mcgenstate: set default neutron parameters *******************************************************************************/ // Moved to generated code /* #pragma acc routine seq */ /* _class_particle mcgenstate(void) */ /* { */ /* return(mcsetstate(0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, mcgravitation, mcMagnet, mcallowbackprop)); */ /* } */ /******************************************************************************* * mccoordschanges: old style rotation routine rot -> (x y z) ,(vx vy vz),(sx,sy,sz) *******************************************************************************/ void mccoordschanges(Coords a, Rotation t, double *x, double *y, double *z, double *vx, double *vy, double *vz, double *sx, double *sy, double *sz) { Coords b, c; b.x = *x; b.y = *y; b.z = *z; c = rot_apply(t, b); b = coords_add(c, a); *x = b.x; *y = b.y; *z = b.z; if ( (vz && vy && vx) && (*vz != 0.0 || *vx != 0.0 || *vy != 0.0) ) mccoordschange_polarisation(t, vx, vy, vz); if ( (sz && sy && sx) && (*sz != 0.0 || *sx != 0.0 || *sy != 0.0) ) mccoordschange_polarisation(t, sx, sy, sz); } /* intersection routines ==================================================== */ /******************************************************************************* * inside_rectangle: Check if (x,y) is inside rectangle (xwidth, yheight) * return 0 if outside and 1 if inside *******************************************************************************/ int inside_rectangle(double x, double y, double xwidth, double yheight) { if (x>-xwidth/2 && x-yheight/2 && y -dy/2 && y_in < dy/2 && z_in > -dz/2 && z_in < dz/2) t[0] = tt; else t[0] = 0; tt = (dx/2 - x)/vx; y_in = y + tt*vy; z_in = z + tt*vz; if( y_in > -dy/2 && y_in < dy/2 && z_in > -dz/2 && z_in < dz/2) t[1] = tt; else t[1] = 0; } else t[0] = t[1] = 0; if(vy != 0) { tt = -(dy/2 + y)/vy; x_in = x + tt*vx; z_in = z + tt*vz; if( x_in > -dx/2 && x_in < dx/2 && z_in > -dz/2 && z_in < dz/2) t[2] = tt; else t[2] = 0; tt = (dy/2 - y)/vy; x_in = x + tt*vx; z_in = z + tt*vz; if( x_in > -dx/2 && x_in < dx/2 && z_in > -dz/2 && z_in < dz/2) t[3] = tt; else t[3] = 0; } else t[2] = t[3] = 0; if(vz != 0) { tt = -(dz/2 + z)/vz; x_in = x + tt*vx; y_in = y + tt*vy; if( x_in > -dx/2 && x_in < dx/2 && y_in > -dy/2 && y_in < dy/2) t[4] = tt; else t[4] = 0; tt = (dz/2 - z)/vz; x_in = x + tt*vx; y_in = y + tt*vy; if( x_in > -dx/2 && x_in < dx/2 && y_in > -dy/2 && y_in < dy/2) t[5] = tt; else t[5] = 0; } else t[4] = t[5] = 0; /* The intersection is evaluated and *dt_in and *dt_out are assigned */ a = b = s = 0; count = 0; for( i = 0; i < 6; i = i + 1 ) if( t[i] == 0 ) s = s+1; else if( count == 0 ) { a = t[i]; count = 1; } else { b = t[i]; count = 2; } if ( a == 0 && b == 0 ) return 0; else if( a < b ) { *dt_in = a; *dt_out = b; return 1; } else { *dt_in = b; *dt_out = a; return 1; } } /* box_intersect */ /******************************************************************************* * cylinder_intersect: compute intersection with a cylinder * returns 0 when no intersection is found * or 2/4/8/16 bits depending on intersection, * and resulting times t0 and t1 * Written by: EM,NB,ABA 4.2.98 *******************************************************************************/ int cylinder_intersect(double *t0, double *t1, double x, double y, double z, double vx, double vy, double vz, double r, double h) { double D, t_in, t_out, y_in, y_out; int ret=1; D = (2*vx*x + 2*vz*z)*(2*vx*x + 2*vz*z) - 4*(vx*vx + vz*vz)*(x*x + z*z - r*r); if (D>=0) { if (vz*vz + vx*vx) { t_in = (-(2*vz*z + 2*vx*x) - sqrt(D))/(2*(vz*vz + vx*vx)); t_out = (-(2*vz*z + 2*vx*x) + sqrt(D))/(2*(vz*vz + vx*vx)); } else if (vy) { /* trajectory parallel to cylinder axis */ t_in = (-h/2-y)/vy; t_out = (h/2-y)/vy; if (t_in>t_out){ double tmp=t_in; t_in=t_out;t_out=tmp; } } else return 0; y_in = vy*t_in + y; y_out =vy*t_out + y; if ( (y_in > h/2 && y_out > h/2) || (y_in < -h/2 && y_out < -h/2) ) return 0; else { if (y_in > h/2) { t_in = ((h/2)-y)/vy; ret += 2; } else if (y_in < -h/2) { t_in = ((-h/2)-y)/vy; ret += 4; } if (y_out > h/2) { t_out = ((h/2)-y)/vy; ret += 8; } else if (y_out < -h/2) { t_out = ((-h/2)-y)/vy; ret += 16; } } *t0 = t_in; *t1 = t_out; return ret; } else { *t0 = *t1 = 0; return 0; } } /* cylinder_intersect */ /******************************************************************************* * sphere_intersect: Calculate intersection between a line and a sphere. * returns 0 when no intersection is found * or 1 in case of intersection with resulting times t0 and t1 *******************************************************************************/ int sphere_intersect(double *t0, double *t1, double x, double y, double z, double vx, double vy, double vz, double r) { double A, B, C, D, v; v = sqrt(vx*vx + vy*vy + vz*vz); A = v*v; B = 2*(x*vx + y*vy + z*vz); C = x*x + y*y + z*z - r*r; D = B*B - 4*A*C; if(D < 0) return 0; D = sqrt(D); *t0 = (-B - D) / (2*A); *t1 = (-B + D) / (2*A); return 1; } /* sphere_intersect */ /******************************************************************************* * plane_intersect: Calculate intersection between a plane and a line. * returns 0 when no intersection is found (i.e. line is parallel to the plane) * returns 1 or -1 when intersection time is positive and negative respectively *******************************************************************************/ int plane_intersect(double *t, double x, double y, double z, double vx, double vy, double vz, double nx, double ny, double nz, double wx, double wy, double wz) { double s; if (fabs(s=scalar_prod(nx,ny,nz,vx,vy,vz)) #include #include #ifndef _MSC_EXTENSIONS #include #else # include # define strcasecmp _stricmp # define strncasecmp _strnicmp #endif typedef struct struct_table { char filename[1024]; long filesize; char *header; /* text header, e.g. comments */ double *data; /* vector { x[0], y[0], ... x[n-1], y[n-1]... } */ double min_x; /* min value of first column */ double max_x; /* max value of first column */ double step_x; /* minimal step value of first column */ long rows; /* number of rows in matrix block */ long columns; /* number of columns in matrix block */ long begin; /* start fseek index of block */ long end; /* stop fseek index of block */ long block_number; /* block index. 0 is catenation of all */ long array_length; /* number of elements in the t_Table array */ char monotonic; /* true when 1st column/vector data is monotonic */ char constantstep; /* true when 1st column/vector data has constant step */ char method[32]; /* interpolation method: nearest, linear */ char quiet; /*output level for messages to the console 0: print all messages, 1:only print some/including errors, 2: never print anything.*/ } t_Table; /*maximum number of rows to rebin a table = 1M*/ enum { mcread_table_rebin_maxsize = 1000000 }; typedef struct t_Read_table_file_item { int ref_count; t_Table *table_ref; } t_Read_table_file_item; typedef enum enum_Read_table_file_actions {STORE,FIND,GC} t_Read_table_file_actions; /* read_table-lib function prototypes */ /* ========================================================================= */ /* 'public' functions */ long Table_Read (t_Table *Table, char *File, long block_number); long Table_Read_Offset (t_Table *Table, char *File, long block_number, long *offset, long max_lines); long Table_Read_Offset_Binary(t_Table *Table, char *File, char *Type, long *Offset, long Rows, long Columns); long Table_Rebin(t_Table *Table); /* rebin table with regular 1st column and interpolate all columns 2:end */ long Table_Info (t_Table Table); #pragma acc routine double Table_Index(t_Table Table, long i, long j); /* get indexed value */ #pragma acc routine double Table_Value(t_Table Table, double X, long j); /* search X in 1st column and return interpolated value in j-column */ t_Table *Table_Read_Array(char *File, long *blocks); void Table_Free_Array(t_Table *Table); long Table_Info_Array(t_Table *Table); int Table_SetElement(t_Table *Table, long i, long j, double value); long Table_Init(t_Table *Table, long rows, long columns); /* create a Table */ #pragma acc routine double Table_Value2d(t_Table Table, double X, double Y); /* same as Table_Index with non-integer indices and 2d interpolation */ MCDETECTOR Table_Write(t_Table Table, char*file, char*xl, char*yl, double x1, double x2, double y1, double y2); /* write Table to disk */ void * Table_File_List_Handler(t_Read_table_file_actions action, void *item, void *item_modifier); t_Table *Table_File_List_find(char *name, int block, int offset); int Table_File_List_gc(t_Table *tab); void *Table_File_List_store(t_Table *tab); #define Table_ParseHeader(header, ...) \ Table_ParseHeader_backend(header,__VA_ARGS__,NULL); char **Table_ParseHeader_backend(char *header, ...); FILE *Open_File(char *name, const char *Mode, char *path); /* private functions */ void Table_Free(t_Table *Table); long Table_Read_Handle(t_Table *Table, FILE *fid, long block_number, long max_lines, char *name); static void Table_Stat(t_Table *Table); #pragma acc routine double Table_Interp1d(double x, double x1, double y1, double x2, double y2); #pragma acc routine double Table_Interp1d_nearest(double x, double x1, double y1, double x2, double y2); #pragma acc routine double Table_Interp2d(double x, double y, double x1, double y1, double x2, double y2, double z11, double z12, double z21, double z22); #endif /* end of read_table-lib.h */ /******************************************************************************* * * McStas, neutron ray-tracing package * Copyright (C) 1997-2009, All rights reserved * Risoe National Laboratory, Roskilde, Denmark * Institut Laue Langevin, Grenoble, France * * Library: share/read_table-lib.c * * %Identification * Written by: EF * Date: Aug 28, 2002 * Origin: ILL * Release: McStas CVS_090504 * Version: $Revision$ * * This file is to be imported by components that may read data from table files * It handles some shared functions. Embedded within instrument in runtime mode. * * Usage: within SHARE * %include "read_table-lib" * *******************************************************************************/ #ifndef READ_TABLE_LIB_H #include "read_table-lib.h" #endif #ifndef READ_TABLE_LIB_C #define READ_TABLE_LIB_C "$Revision$" /******************************************************************************* * void *Table_File_List_Handler(action, item, item_modifier) * ACTION: handle file entries in the read_table-lib file list. If a file is read - it is supposed to be * stored in a list such that we can avoid reading the same file many times. * input action: FIND, STORE, GC. check if file exists in the list, store an item in the list, or check if it can be garbage collected. * input item: depends on the action. * FIND) item is a filename, and item_modifier is the block number * STORE) item is the Table to store - item_modifier is ignored * GC) item is the Table to check. If it has a ref_count >1 then this is simply decremented. * return depends on the action * FIND) return a reference to a table+ref_count item if found - NULL otherwise. I.e. NULL means the file has not been read before and must be read again. * STORE) return NULL always * GC) return NULL if no garbage collection is needed, return an adress to the t_Table which should be garbage collected. 0x1 is returned if * the item is not found in the list *******************************************************************************/ void * Table_File_List_Handler(t_Read_table_file_actions action, void *item, void *item_modifier){ /* logic here is Read_Table should include a call to FIND. If found the return value should just be used as * if the table had been read from disk. If not found then read the table and STORE. * Table_Free should include a call to GC. If this returns non-NULL then we should proceed with freeing the memory * associated with the table item - otherwise only decrement the reference counter since there are more references * that may need it.*/ static t_Read_table_file_item read_table_file_list[1024]; static int read_table_file_count=0; t_Read_table_file_item *tr; switch(action){ case FIND: /*interpret data item as a filename, if it is found return a pointer to the table and increment refcount. * if not found return the item itself*/ tr=read_table_file_list; while ( tr->table_ref!=NULL ){ int i=*((int*) item_modifier); int j=*( ((int*) item_modifier)+1); if ( !strcmp(tr->table_ref->filename,(char *) item) && tr->table_ref->block_number==i && tr->table_ref->begin==j ){ tr->ref_count++; return (void *) tr; } tr++; } return NULL; case STORE: /*find an available slot and store references to table there*/ tr=&(read_table_file_list[read_table_file_count++]); tr->table_ref = ((t_Table *) item); tr->ref_count++; return NULL; case GC: /* Should this item be garbage collected (freed) - if so scratch the entry and return the address of the item - * else decrement ref_count and return NULL. * A non-NULL return expects the item to actually be freed afterwards.*/ tr=read_table_file_list; while ( tr->table_ref!=NULL ){ if ( tr->table_ref->data ==((t_Table *)item)->data && tr->table_ref->block_number == ((t_Table *)item)->block_number){ /*matching item found*/ if (tr->ref_count>1){ /*the item is found and no garbage collection needed*/ tr->ref_count--; return NULL; }else{ /* The item is found and the reference counter is 1. * This means we should garbage collect. Move remaining list items up one slot, * and return the table for garbage collection by caller*/ while (tr->table_ref!=NULL){ *tr=*(tr+1); tr++; } read_table_file_count--; return (t_Table *) item; } } tr++; } /* item not found, and so should be garbage collected. This could be the case if freeing a * Table that has been constructed from code - not read from file. Return 0x1 to flag it for * collection.*/ return (void *) 0x1 ; } /* If we arrive here, nothing worked, return NULL */ return NULL; } /* Access functions to the handler*/ /******************************************** * t_Table *Table_File_List_find(char *name, int block, int offset) * input name: filename to search for in the file list * input block: data block in the file as each file may contain more than 1 data block. * return a ref. to a table if it is found (you may use this pointer and skip reading the file), NULL otherwise (i.e. go ahead and read the file) *********************************************/ t_Table *Table_File_List_find(char *name, int block, int offset){ int vars[2]={block,offset}; t_Read_table_file_item *item = Table_File_List_Handler(FIND,name, vars); if (item == NULL){ return NULL; }else{ return item->table_ref; } } /******************************************** * int Table_File_List_gc(t_Table *tab) * input tab: the table to check for references. * return 0: no garbage collection needed * 1: Table's data and header (at least) should be freed. *********************************************/ int Table_File_List_gc(t_Table *tab){ void *rval=Table_File_List_Handler(GC,tab,0); if (rval==NULL) return 0; else return 1; } /***************************************************************************** * void *Table_File_List_store(t_Table *tab) * input tab: pointer to table to store. * return None. *******************************************************************************/ void *Table_File_List_store(t_Table *tab){ return Table_File_List_Handler(STORE,tab,0); } /******************************************************************************* * FILE *Open_File(char *name, char *Mode, char *path) * ACTION: search for a file and open it. Optionally return the opened path. * input name: file name from which table should be extracted * mode: "r", "w", "a" or any valid fopen mode * path: NULL or a pointer to at least 1024 allocated chars * return initialized file handle or NULL in case of error *******************************************************************************/ FILE *Open_File(char *File, const char *Mode, char *Path) { char path[1024]; FILE *hfile = NULL; if (!File || File[0]=='\0') return(NULL); if (!strcmp(File,"NULL") || !strcmp(File,"0")) return(NULL); /* search in current or full path */ strncpy(path, File, 1024); hfile = fopen(path, Mode); if(!hfile) { char dir[1024]; if (!hfile && instrument_source[0] != '\0' && strlen(instrument_source)) /* search in instrument source location */ { char *path_pos = NULL; /* extract path: searches for last file separator */ path_pos = strrchr(instrument_source, MC_PATHSEP_C); /* last PATHSEP */ if (path_pos) { long path_length = path_pos +1 - instrument_source; /* from start to path+sep */ if (path_length) { strncpy(dir, instrument_source, path_length); dir[path_length] = '\0'; snprintf(path, 1024, "%s%c%s", dir, MC_PATHSEP_C, File); hfile = fopen(path, Mode); } } } if (!hfile && instrument_exe[0] != '\0' && strlen(instrument_exe)) /* search in PWD instrument executable location */ { char *path_pos = NULL; /* extract path: searches for last file separator */ path_pos = strrchr(instrument_exe, MC_PATHSEP_C); /* last PATHSEP */ if (path_pos) { long path_length = path_pos +1 - instrument_exe; /* from start to path+sep */ if (path_length) { strncpy(dir, instrument_exe, path_length); dir[path_length] = '\0'; snprintf(path, 1024, "%s%c%s", dir, MC_PATHSEP_C, File); hfile = fopen(path, Mode); } } } if (!hfile) /* search in HOME or . */ { strcpy(dir, getenv("HOME") ? getenv("HOME") : "."); snprintf(path, 1024, "%s%c%s", dir, MC_PATHSEP_C, File); hfile = fopen(path, Mode); } if (!hfile) /* search in MCSTAS/data */ { strcpy(dir, getenv(FLAVOR_UPPER) ? getenv(FLAVOR_UPPER) : MCSTAS); snprintf(path, 1024, "%s%c%s%c%s", dir, MC_PATHSEP_C, "data", MC_PATHSEP_C, File); hfile = fopen(path, Mode); } if (!hfile) /* search in MVCSTAS/contrib */ { strcpy(dir, getenv(FLAVOR_UPPER) ? getenv(FLAVOR_UPPER) : MCSTAS); snprintf(path, 1024, "%s%c%s%c%s", dir, MC_PATHSEP_C, "contrib", MC_PATHSEP_C, File); hfile = fopen(path, Mode); } if(!hfile) { // fprintf(stderr, "Warning: Could not open input file '%s' (Open_File)\n", File); return (NULL); } } if (Path) strncpy(Path, path, 1024); return(hfile); } /* end Open_File */ /******************************************************************************* * long Read_Table(t_Table *Table, char *name, int block_number) * ACTION: read a single Table from a text file * input Table: pointer to a t_Table structure * name: file name from which table should be extracted * block_number: if the file does contain more than one * data block, then indicates which one to get (from index 1) * a 0 value means append/catenate all * return initialized single Table t_Table structure containing data, header, ... * number of read elements (-1: error, 0:header only) * The routine stores any line starting with '#', '%' and ';' into the header * File is opened, read and closed * Other lines are interpreted as numerical data, and stored. * Data block should be a rectangular matrix or vector. * Data block may be rebinned with Table_Rebin (also sort in ascending order) *******************************************************************************/ long Table_Read(t_Table *Table, char *File, long block_number) { /* reads all or a single data block from 'file' and returns a Table structure */ return(Table_Read_Offset(Table, File, block_number, NULL, 0)); } /* end Table_Read */ /******************************************************************************* * long Table_Read_Offset(t_Table *Table, char *name, int block_number, long *offset * long max_rows) * ACTION: read a single Table from a text file, starting at offset * Same as Table_Read(..) except: * input offset: pointer to an offset (*offset should be 0 at start) * max_rows: max number of data rows to read from file (0 means all) * return initialized single Table t_Table structure containing data, header, ... * number of read elements (-1: error, 0:header only) * updated *offset position (where end of reading occured) *******************************************************************************/ long Table_Read_Offset(t_Table *Table, char *File, long block_number, long *offset, long max_rows) { /* reads all/a data block in 'file' and returns a Table structure */ FILE *hfile; long nelements=0; long begin=0; long filesize=0; char name[1024]; char path[1024]; struct stat stfile; /*Need to be able to store the pointer*/ if (!Table) return(-1); /*TK: Valgrind flags it as usage of uninitialised variable: */ Table->quiet = 0; //if (offset && *offset) snprintf(name, 1024, "%s@%li", File, *offset); //else strncpy(name, File, 1024); if(offset && *offset){ begin=*offset; } /* Check if the table has already been read from file. * If so just reuse the table, if not (this is flagged by returning NULL * set up a new table and read the data into it */ t_Table *tab_p= Table_File_List_find(name,block_number,begin); if ( tab_p!=NULL ){ /*table was found in the Table_File_List*/ *Table=*tab_p; MPI_MASTER( if(Table->quiet<1) printf("Reusing input file '%s' (Table_Read_Offset)\n", name); ); return Table->rows*Table->columns; } /* open the file */ hfile = Open_File(File, "r", path); if (!hfile) return(-1); else { MPI_MASTER( if(Table->quiet<1) printf("Opening input file '%s' (Table_Read_Offset)\n", path); ); } /* read file state */ stat(path,&stfile); filesize = stfile.st_size; if (offset && *offset) fseek(hfile, *offset, SEEK_SET); begin = ftell(hfile); Table_Init(Table, 0, 0); /* read file content and set the Table */ nelements = Table_Read_Handle(Table, hfile, block_number, max_rows, name); Table->begin = begin; Table->end = ftell(hfile); Table->filesize = (filesize>0 ? filesize : 0); Table_Stat(Table); Table_File_List_store(Table); if (offset) *offset=Table->end; fclose(hfile); return(nelements); } /* end Table_Read_Offset */ /******************************************************************************* * long Table_Read_Offset_Binary(t_Table *Table, char *File, char *type, * long *offset, long rows, long columns) * ACTION: read a single Table from a binary file, starting at offset * Same as Table_Read_Offset(..) except that it handles binary files. * input type: may be "float"/NULL or "double" * offset: pointer to an offset (*offset should be 0 at start) * rows : number of rows (0 means read all) * columns: number of columns * return initialized single Table t_Table structure containing data, header, ... * number of read elements (-1: error, 0:header only) * updated *offset position (where end of reading occured) *******************************************************************************/ long Table_Read_Offset_Binary(t_Table *Table, char *File, char *type, long *offset, long rows, long columns) { /* reads all/a data block in binary 'file' and returns a Table structure */ long nelements, sizeofelement; long filesize; FILE *hfile; char path[1024]; struct stat stfile; double *data = NULL; double *datatmp = NULL; long i; long begin; if (!Table) return(-1); Table_Init(Table, 0, 0); /* open the file */ hfile = Open_File(File, "r", path); if (!hfile) return(-1); else { MPI_MASTER( if(Table->quiet<1) printf("Opening input file '%s' (Table_Read, Binary)\n", path); ); } /* read file state */ stat(File,&stfile); filesize = stfile.st_size; Table->filesize=filesize; /* read file content */ if (type && !strcmp(type,"double")) sizeofelement = sizeof(double); else sizeofelement = sizeof(float); if (offset && *offset) fseek(hfile, *offset, SEEK_SET); begin = ftell(hfile); if (rows && filesize > sizeofelement*columns*rows) nelements = columns*rows; else nelements = (long)(filesize/sizeofelement); if (!nelements || filesize <= *offset) return(0); data = (double*)malloc(nelements*sizeofelement); if (!data) { if(!(Table->quiet>1)) fprintf(stderr,"Error: allocating %ld elements for %s file '%s'. Too big (Table_Read_Offset_Binary).\n", nelements, type, File); exit(-1); } nelements = fread(data, sizeofelement, nelements, hfile); if (!data || !nelements) { if(!(Table->quiet>1)) fprintf(stderr,"Error: reading %ld elements from %s file '%s' (Table_Read_Offset_Binary)\n", nelements, type, File); exit(-1); } Table->begin = begin; Table->end = ftell(hfile); if (offset) *offset=Table->end; fclose(hfile); datatmp = (double*)realloc(data, (double)nelements*sizeofelement); if (!datatmp) { free(data); fprintf(stderr,"Error: reallocating %ld elements for %s file '%s'. Too big (Table_Read_Offset_Binary).\n", nelements, type, File); exit(-1); } else { data = datatmp; } /* copy file data into Table */ if (type && !strcmp(type,"double")) Table->data = data; else { float *s; double *dataf; s = (float*)data; dataf = (double*)malloc(sizeof(double)*nelements); if (!dataf) { fprintf(stderr, "Could not allocate data block of size %ld\n", nelements); exit(-1); } for (i=0; idata = dataf; } strncpy(Table->filename, File, 1024); Table->rows = nelements/columns; Table->columns = columns; Table->array_length = 1; Table->block_number = 1; Table_Stat(Table); return(nelements); } /* end Table_Read_Offset_Binary */ /******************************************************************************* * long Table_Read_Handle(t_Table *Table, FILE *fid, int block_number, long max_rows, char *name) * ACTION: read a single Table from a text file handle (private) * input Table:pointer to a t_Table structure * fid: pointer to FILE handle * block_number: if the file does contain more than one * data block, then indicates which one to get (from index 1) * a 0 value means append/catenate all * max_rows: if non 0, only reads that number of lines * return initialized single Table t_Table structure containing data, header, ... * modified Table t_Table structure containing data, header, ... * number of read elements (-1: error, 0:header only) * The routine stores any line starting with '#', '%' and ';' into the header * Other lines are interpreted as numerical data, and stored. * Data block should be a rectangular matrix or vector. * Data block may be rebined with Table_Rebin (also sort in ascending order) *******************************************************************************/ long Table_Read_Handle(t_Table *Table, FILE *hfile, long block_number, long max_rows, char *name) { /* reads all/a data block from 'file' handle and returns a Table structure */ double *Data = NULL; double *Datatmp = NULL; char *Header = NULL; char *Headertmp = NULL; long malloc_size = CHAR_BUF_LENGTH; long malloc_size_h = 4096; long Rows = 0, Columns = 0; long count_in_array = 0; long count_in_header = 0; long count_invalid = 0; long block_Current_index = 0; char flag_End_row_loop = 0; if (!Table) return(-1); Table_Init(Table, 0, 0); if (name && name[0]!='\0') strncpy(Table->filename, name, 1024); if(!hfile) { fprintf(stderr, "Error: File handle is NULL (Table_Read_Handle).\n"); return (-1); } Header = (char*) calloc(malloc_size_h, sizeof(char)); Data = (double*)calloc(malloc_size, sizeof(double)); if ((Header == NULL) || (Data == NULL)) { fprintf(stderr, "Error: Could not allocate Table and Header (Table_Read_Handle).\n"); return (-1); } int flag_In_array = 0; do { /* while (!flag_End_row_loop) */ char *line=malloc(1024*CHAR_BUF_LENGTH*sizeof(char)); long back_pos=0; /* ftell start of line */ if (!line) { fprintf(stderr,"Could not allocate line buffer\n"); exit(-1); } back_pos = ftell(hfile); if (fgets(line, 1024*CHAR_BUF_LENGTH, hfile) != NULL) { /* analyse line */ /* first skip blank and tabulation characters */ int i = strspn(line, " \t"); /* handle comments: stored in header */ if (NULL != strchr("#%;/", line[i])) { /* line is a comment */ count_in_header += strlen(line); if (count_in_header >= malloc_size_h) { /* if succeed and in array : add (and realloc if necessary) */ malloc_size_h = count_in_header+4096; char *Headertmp = (char*)realloc(Header, malloc_size_h*sizeof(char)); if(!Headertmp) { free(Header); fprintf(stderr, "Error: Could not reallocate Header (Table_Read_Handle).\n"); free(Header); return (-1); } else { Header = Headertmp; } } strncat(Header, line, 4096); flag_In_array=0; /* exit line and file if passed desired block */ if (block_number > 0 && block_number == block_Current_index) { flag_End_row_loop = 1; } /* Continue with next line */ continue; } if (strstr(line, "***")) { count_invalid++; /* Continue with next line */ continue; } /* get the number of columns splitting line with strtok */ char *lexeme; char flag_End_Line = 0; long block_Num_Columns = 0; const char seps[] = " ,;\t\n\r"; lexeme = strtok(line, seps); while (!flag_End_Line) { if ((lexeme != NULL) && (lexeme[0] != '\0')) { /* reading line: the token is not empty */ double X; int count=1; /* test if we have 'NaN','Inf' */ if (!strncasecmp(lexeme,"NaN",3)) X = 0; else if (!strncasecmp(lexeme,"Inf",3) || !strncasecmp(lexeme,"+Inf",4)) X = FLT_MAX; else if (!strncasecmp(lexeme,"-Inf",4)) X = -FLT_MAX; else count = sscanf(lexeme,"%lg",&X); if (count == 1) { /* reading line: the token is a number in the line */ if (!flag_In_array) { /* reading num: not already in a block: starts a new data block */ block_Current_index++; flag_In_array = 1; block_Num_Columns= 0; if (block_number > 0) { /* initialise a new data block */ Rows = 0; count_in_array = 0; } /* else append */ } /* reading num: all blocks or selected block */ if (flag_In_array && (block_number == 0 || block_number == block_Current_index)) { /* starting block: already the desired number of rows ? */ if (block_Num_Columns == 0 && max_rows > 0 && Rows >= max_rows) { flag_End_Line = 1; flag_End_row_loop = 1; flag_In_array = 0; /* reposition to begining of line (ignore line) */ fseek(hfile, back_pos, SEEK_SET); } else { /* store into data array */ if (count_in_array >= malloc_size) { /* realloc data buffer if necessary */ malloc_size = count_in_array*1.5; Datatmp = (double*) realloc(Data, malloc_size*sizeof(double)); if (Datatmp == NULL) { fprintf(stderr, "Error: Can not re-allocate memory %zi (Table_Read_Handle).\n", malloc_size*sizeof(double)); free(Data); return (-1); } else { Data=Datatmp; } } if (0 == block_Num_Columns) Rows++; Data[count_in_array] = X; count_in_array++; block_Num_Columns++; } } /* reading num: end if flag_In_array */ } /* end reading num: end if sscanf lexeme -> numerical */ else { /* reading line: the token is not numerical in that line. end block */ if (block_Current_index == block_number) { flag_End_Line = 1; flag_End_row_loop = 1; } else { flag_In_array = 0; flag_End_Line = 1; } } } else { /* no more tokens in line */ flag_End_Line = 1; if (block_Num_Columns > 0) Columns = block_Num_Columns; } // parse next token lexeme = strtok(NULL, seps); } /* while (!flag_End_Line) */ } /* end: if fgets */ else flag_End_row_loop = 1; /* else fgets : end of file */ free(line); } while (!flag_End_row_loop); /* end while flag_End_row_loop */ Table->block_number = block_number; Table->array_length = 1; // shrink header to actual size (plus terminating 0-byte) if (count_in_header) { Headertmp = (char*)realloc(Header, count_in_header*sizeof(char) + 1); if(!Headertmp) { fprintf(stderr, "Error: Could not shrink Header (Table_Read_Handle).\n"); free(Header); return (-1); } else { Header = Headertmp; } } Table->header = Header; if (count_in_array*Rows*Columns == 0) { Table->rows = 0; Table->columns = 0; free(Data); return (0); } if (Rows * Columns != count_in_array) { fprintf(stderr, "Warning: Read_Table :%s %s Data has %li values that should be %li x %li\n", (Table->filename[0] != '\0' ? Table->filename : ""), (!block_number ? " catenated" : ""), count_in_array, Rows, Columns); Columns = count_in_array; Rows = 1; } if (count_invalid) { fprintf(stderr,"Warning: Read_Table :%s %s Data has %li invalid lines (*****). Ignored.\n", (Table->filename[0] != '\0' ? Table->filename : ""), (!block_number ? " catenated" : ""), count_invalid); } Datatmp = (double*)realloc(Data, count_in_array*sizeof(double)); if(!Datatmp) { fprintf(stderr, "Error: Could reallocate Data block to %li doubles (Table_Read_Handle).\n", count_in_array); free(Data); return (-1); } else { Data = Datatmp; } Table->data = Data; Table->rows = Rows; Table->columns = Columns; return (count_in_array); } /* end Table_Read_Handle */ /******************************************************************************* * long Table_Rebin(t_Table *Table) * ACTION: rebin a single Table, sorting 1st column in ascending order * input Table: single table containing data. * The data block is reallocated in this process * return updated Table with increasing, evenly spaced first column (index 0) * number of data elements (-1: error, 0:empty data) *******************************************************************************/ long Table_Rebin(t_Table *Table) { double new_step=0; long i; /* performs linear interpolation on X axis (0-th column) */ if (!Table) return(-1); if (!Table->data || Table->rows*Table->columns == 0 || !Table->step_x) return(0); Table_Stat(Table); /* recompute statitstics and minimal step */ new_step = Table->step_x; /* minimal step in 1st column */ if (!(Table->constantstep)) /* not already evenly spaced */ { long Length_Table; double *New_Table; Length_Table = ceil(fabs(Table->max_x - Table->min_x)/new_step)+1; /*return early if the rebinned table will become too large*/ if (Length_Table > mcread_table_rebin_maxsize){ fprintf(stderr,"WARNING: (Table_Rebin): Rebinning table from %s would exceed 1M rows. Skipping.\n", Table->filename); return(Table->rows*Table->columns); } New_Table = (double*)malloc(Length_Table*Table->columns*sizeof(double)); if (!New_Table) { fprintf(stderr,"Could not allocate New_Table of size %ld x %ld\n", Length_Table, Table->columns); exit(-1); } for (i=0; i < Length_Table; i++) { long j; double X; X = Table->min_x + i*new_step; New_Table[i*Table->columns] = X; for (j=1; j < Table->columns; j++) New_Table[i*Table->columns+j] = Table_Value(*Table, X, j); } /* end for i */ Table->rows = Length_Table; Table->step_x = new_step; Table->max_x = Table->min_x + (Length_Table-1)*new_step; /*max might not be the same anymore * Use Length_Table -1 since the first and laset rows are the limits of the defined interval.*/ free(Table->data); Table->data = New_Table; Table->constantstep=1; } /* end else (!constantstep) */ return (Table->rows*Table->columns); } /* end Table_Rebin */ /******************************************************************************* * double Table_Index(t_Table Table, long i, long j) * ACTION: read an element [i,j] of a single Table * input Table: table containing data * i : index of row (0:Rows-1) * j : index of column (0:Columns-1) * return Value = data[i][j] * Returns Value from the i-th row, j-th column of Table * Tests are performed on indexes i,j to avoid errors *******************************************************************************/ #ifndef MIN #define MIN(a, b) (((a) < (b)) ? (a) : (b)) #endif #ifndef MAX #define MAX(a, b) (((a) > (b)) ? (a) : (b)) #endif double Table_Index(t_Table Table, long i, long j) { long AbsIndex; if (Table.rows == 1 || Table.columns == 1) { /* vector */ j = MIN(MAX(0, i+j), Table.columns*Table.rows - 1); i = 0; } else { /* matrix */ i = MIN(MAX(0, i), Table.rows - 1); j = MIN(MAX(0, j), Table.columns - 1); } /* handle vectors specifically */ AbsIndex = i*(Table.columns)+j; if (Table.data != NULL) return (Table.data[AbsIndex]); else return 0; } /* end Table_Index */ /******************************************************************************* * void Table_SetElement(t_Table *Table, long i, long j, double value) * ACTION: set an element [i,j] of a single Table * input Table: table containing data * i : index of row (0:Rows-1) * j : index of column (0:Columns-1) * value = data[i][j] * Returns 0 in case of error * Tests are performed on indexes i,j to avoid errors *******************************************************************************/ int Table_SetElement(t_Table *Table, long i, long j, double value) { long AbsIndex; if (Table->rows == 1 || Table->columns == 1) { /* vector */ j = MIN(MAX(0, i+j), Table->columns*Table->rows - 1); i=0; } else { /* matrix */ i = MIN(MAX(0, i), Table->rows - 1); j = MIN(MAX(0, j), Table->columns - 1); } AbsIndex = i*(Table->columns)+j; if (Table->data != NULL) { Table->data[AbsIndex] = value; return 1; } return 0; } /* end Table_SetElement */ /******************************************************************************* * double Table_Value(t_Table Table, double X, long j) * ACTION: read column [j] of a single Table at row which 1st column is X * input Table: table containing data. * X : data value in the first column (index 0) * j : index of column from which is extracted the Value (0:Columns-1) * return Value = data[index for X][j] with linear interpolation * Returns Value from the j-th column of Table corresponding to the * X value for the 1st column (index 0) * Tests are performed (within Table_Index) on indexes i,j to avoid errors * NOTE: data should rather be monotonic, and evenly sampled. *******************************************************************************/ double Table_Value(t_Table Table, double X, long j) { long Index = -1; double X1=0, Y1=0, X2=0, Y2=0; double ret=0; if (X > Table.max_x) return Table_Index(Table,Table.rows-1 ,j); if (X < Table.min_x) return Table_Index(Table,0 ,j); // Use constant-time lookup when possible if(Table.constantstep) { Index = (long)floor( (X - Table.min_x) / (Table.max_x - Table.min_x) * (Table.rows-1)); X1 = Table_Index(Table,Index-1,0); X2 = Table_Index(Table,Index ,0); } // Use binary search on large, monotonic tables else if(Table.monotonic && Table.rows > 100) { long left = Table.min_x; long right = Table.max_x; while (!((X1 <= X) && (X < X2)) && (right - left > 1)) { Index = (left + right) / 2; X1 = Table_Index(Table, Index-1, 0); X2 = Table_Index(Table, Index, 0); if (X < X1) { right = Index; } else { left = Index; } } } // Fall back to linear search, if no-one else has set X1, X2 correctly if (!((X1 <= X) && (X < X2))) { /* look for index surrounding X in the table -> Index */ for (Index=1; Index <= Table.rows-1; Index++) { X1 = Table_Index(Table, Index-1,0); X2 = Table_Index(Table, Index ,0); if ((X1 <= X) && (X < X2)) break; } /* end for Index */ } Y1 = Table_Index(Table,Index-1, j); Y2 = Table_Index(Table,Index , j); #ifdef OPENACC #define strcmp(a,b) str_comp(a,b) #endif if (!strcmp(Table.method,"linear")) { ret = Table_Interp1d(X, X1,Y1, X2,Y2); } else if (!strcmp(Table.method,"nearest")) { ret = Table_Interp1d_nearest(X, X1,Y1, X2,Y2); } #ifdef OPENACC #ifdef strcmp #undef strcmp #endif #endif return ret; } /* end Table_Value */ /******************************************************************************* * double Table_Value2d(t_Table Table, double X, double Y) * ACTION: read element [X,Y] of a matrix Table * input Table: table containing data. * X : row index, may be non integer * Y : column index, may be non integer * return Value = data[index X][index Y] with bi-linear interpolation * Returns Value for the indices [X,Y] * Tests are performed (within Table_Index) on indexes i,j to avoid errors * NOTE: data should rather be monotonic, and evenly sampled. *******************************************************************************/ double Table_Value2d(t_Table Table, double X, double Y) { long x1,x2,y1,y2; double z11,z12,z21,z22; double ret=0; x1 = (long)floor(X); y1 = (long)floor(Y); if (x1 > Table.rows-1 || x1 < 0) { x2 = x1; } else { x2 = x1 + 1; } if (y1 > Table.columns-1 || y1 < 0) { y2 = y1; } else { y2 = y1 + 1; } z11 = Table_Index(Table, x1, y1); if (y2 != y1) z12=Table_Index(Table, x1, y2); else z12 = z11; if (x2 != x1) z21=Table_Index(Table, x2, y1); else z21 = z11; if (y2 != y1) z22=Table_Index(Table, x2, y2); else z22 = z21; #ifdef OPENACC #define strcmp(a,b) str_comp(a,b) #endif if (!strcmp(Table.method,"linear")) ret = Table_Interp2d(X,Y, x1,y1,x2,y2, z11,z12,z21,z22); #ifdef OPENACC #ifdef strcmp #undef strcmp #endif #endif else { if (fabs(X-x1) < fabs(X-x2)) { if (fabs(Y-y1) < fabs(Y-y2)) ret = z11; else ret = z12; } else { if (fabs(Y-y1) < fabs(Y-y2)) ret = z21; else ret = z22; } } return ret; } /* end Table_Value2d */ /******************************************************************************* * void Table_Free(t_Table *Table) * ACTION: free a single Table. First Call Table_File_list_gc. If this returns * non-zero it means there are more refernces to the table, and so the table * should not bee freed. * return: empty Table *******************************************************************************/ void Table_Free(t_Table *Table) { if( !Table_File_List_gc(Table) ){ return; } if (!Table) return; if (Table->data != NULL) free(Table->data); if (Table->header != NULL) free(Table->header); Table->data = NULL; Table->header = NULL; } /* end Table_Free */ /****************************************************************************** * void Table_Info(t_Table Table) * ACTION: print informations about a single Table *******************************************************************************/ long Table_Info(t_Table Table) { char buffer[256]; long ret=0; if (!Table.block_number) strcpy(buffer, "catenated"); else sprintf(buffer, "block %li", Table.block_number); printf("Table from file '%s' (%s)", Table.filename[0] != '\0' ? Table.filename : "", buffer); if ((Table.data != NULL) && (Table.rows*Table.columns)) { printf(" is %li x %li ", Table.rows, Table.columns); if (Table.rows*Table.columns > 1) printf("(x=%g:%g)", Table.min_x, Table.max_x); else printf("(x=%g) ", Table.min_x); ret = Table.rows*Table.columns; if (Table.monotonic) printf(", monotonic"); if (Table.constantstep) printf(", constant step"); printf(". interpolation: %s\n", Table.method); } else printf(" is empty.\n"); if (Table.header && strlen(Table.header)) { char *header; int i; header = malloc(80); if (!header) return(ret); for (i=0; i<80; header[i++]=0); strncpy(header, Table.header, 75); if (strlen(Table.header) > 75) { strcat( header, " ..."); } for (i=0; iheader = NULL; Table->filename[0]= '\0'; Table->filesize= 0; Table->min_x = 0; Table->max_x = 0; Table->step_x = 0; Table->block_number = 0; Table->array_length = 0; Table->monotonic = 0; Table->constantstep = 0; Table->begin = 0; Table->end = 0; strcpy(Table->method,"linear"); if (rows*columns >= 1) { data = (double*)malloc(rows*columns*sizeof(double)); if (data) for (i=0; i < rows*columns; data[i++]=0); else { if(Table->quiet<2) fprintf(stderr,"Error: allocating %ld double elements." "Too big (Table_Init).\n", rows*columns); rows = columns = 0; } } Table->rows = (rows >= 1 ? rows : 0); Table->columns = (columns >= 1 ? columns : 0); Table->data = data; return(Table->rows*Table->columns); } /* end Table_Init */ /****************************************************************************** * long Table_Write(t_Table Table, char *file, x1,x2, y1,y2) * ACTION: write a Table to disk (ascii). * when x1=x2=0 or y1=y2=0, the table default limits are used. * return: 0=all is fine, non-0: error *******************************************************************************/ MCDETECTOR Table_Write(t_Table Table, char *file, char *xl, char *yl, double x1, double x2, double y1, double y2) { MCDETECTOR detector; if ((Table.data == NULL) && (Table.rows*Table.columns)) { detector.m = 0; detector.xmin = 0; detector.xmax = 0; detector.ymin = 0; detector.ymax = 0; detector.zmin = 0; detector.zmax = 0; detector.intensity = 0; detector.error = 0; detector.events = 0; detector.min = 0; detector.max = 0; detector.mean = 0; detector.centerX = 0; detector.halfwidthX = 0; detector.centerY = 0; detector.halfwidthY = 0; detector.rank = 0; detector.istransposed = 0; detector.n = 0; detector.p = 0; detector.date_l = 0; detector.p0 = NULL; detector.p1 = NULL; detector.p2 = NULL; return(detector); /* Table is empty - nothing to do */ } if (!x1 && !x2) { x1 = Table.min_x; x2 = Table.max_x; } if (!y1 && !y2) { y1 = 1; y2 = Table.columns; } /* transfer content of the Table into a 2D detector */ Coords coords = { 0, 0, 0}; Rotation rot; rot_set_rotation(rot, 0, 0, 0); if (Table.rows == 1 || Table.columns == 1) { detector = mcdetector_out_1D(Table.filename, xl ? xl : "", yl ? yl : "", "x", x1, x2, Table.rows * Table.columns, NULL, Table.data, NULL, file, file, coords, rot,9999); } else { detector = mcdetector_out_2D(Table.filename, xl ? xl : "", yl ? yl : "", x1, x2, y1, y2, Table.rows, Table.columns, NULL, Table.data, NULL, file, file, coords, rot,9999); } return(detector); } /****************************************************************************** * void Table_Stat(t_Table *Table) * ACTION: computes min/max/mean step of 1st column for a single table (private) * return: updated Table *******************************************************************************/ static void Table_Stat(t_Table *Table) { long i; double max_x, min_x; double row=1; char monotonic=1; char constantstep=1; double step=0; long n; if (!Table) return; if (!Table->rows || !Table->columns) return; if (Table->rows == 1) row=0; // single row max_x = -FLT_MAX; min_x = FLT_MAX; n = (row ? Table->rows : Table->columns); /* get min and max of first column/vector */ for (i=0; i < n; i++) { double X; X = (row ? Table_Index(*Table,i ,0) : Table_Index(*Table,0, i)); if (X < min_x) min_x = X; if (X > max_x) max_x = X; } /* for */ /* test for monotonicity and constant step if the table is an XY or single vector */ if (n > 1) { /* mean step */ step = (max_x - min_x)/(n-1); /* now test if table is monotonic on first column, and get minimal step size */ for (i=0; i < n-1; i++) { double X, diff;; X = (row ? Table_Index(*Table,i ,0) : Table_Index(*Table,0, i)); diff = (row ? Table_Index(*Table,i+1,0) : Table_Index(*Table,0, i+1)) - X; if (diff && fabs(diff) < fabs(step)) step = diff; /* change sign ? */ if ((max_x - min_x)*diff < 0 && monotonic) monotonic = 0; } /* end for */ /* now test if steps are constant within READ_TABLE_STEPTOL */ if(!step){ /*means there's a disconitnuity -> not constantstep*/ constantstep=0; }else if (monotonic) { for (i=0; i < n-1; i++) { double X, diff; X = (row ? Table_Index(*Table,i ,0) : Table_Index(*Table,0, i)); diff = (row ? Table_Index(*Table,i+1,0) : Table_Index(*Table,0, i+1)) - X; if ( fabs(step)*(1+READ_TABLE_STEPTOL) < fabs(diff) || fabs(diff) < fabs(step)*(1-READ_TABLE_STEPTOL) ) { constantstep = 0; break; } } } } Table->step_x= step; Table->max_x = max_x; Table->min_x = min_x; Table->monotonic = monotonic; Table->constantstep = constantstep; } /* end Table_Stat */ /****************************************************************************** * t_Table *Table_Read_Array(char *File, long *blocks) * ACTION: read as many data blocks as available, iteratively from file * return: initialized t_Table array, last element is an empty Table. * the number of extracted blocks in non NULL pointer *blocks *******************************************************************************/ t_Table *Table_Read_Array(char *File, long *blocks) { t_Table *Table_Array = NULL; t_Table *Table_Arraytmp = NULL; long offset=0; long block_number=0; long allocated=256; long nelements=1; /* first allocate an initial empty t_Table array */ Table_Array = (t_Table *)malloc(allocated*sizeof(t_Table)); if (!Table_Array) { fprintf(stderr, "Error: Can not allocate memory %zi (Table_Read_Array).\n", allocated*sizeof(t_Table)); *blocks = 0; return (NULL); } while (nelements > 0) { t_Table Table; /* if ok, set t_Table block number else exit loop */ block_number++; Table.block_number = block_number; /* access file at offset and get following block. Block number is from the set offset * hence the hardcoded 1 - i.e. the next block counted from offset.*/ nelements = Table_Read_Offset(&Table, File, 1, &offset,0); /*if the block is empty - don't store it*/ if (nelements>0){ /* if t_Table array is not long enough, expand and realocate */ if (block_number >= allocated-1) { allocated += 256; Table_Arraytmp = (t_Table *)realloc(Table_Array, allocated*sizeof(t_Table)); if (!Table_Arraytmp) { fprintf(stderr, "Error: Can not re-allocate memory %zi (Table_Read_Array).\n", allocated*sizeof(t_Table)); free(Table_Array); *blocks = 0; return (NULL); } else { Table_Array = Table_Arraytmp; } } /* store it into t_Table array */ //snprintf(Table.filename, 1024, "%s#%li", File, block_number-1); Table_Array[block_number-1] = Table; } /* continues until we find an empty block */ } /* send back number of extracted blocks */ if (blocks) *blocks = block_number-1; /* now store total number of elements in Table array */ for (offset=0; offset < block_number; Table_Array[offset++].array_length = block_number-1); return(Table_Array); } /* end Table_Read_Array */ /******************************************************************************* * void Table_Free_Array(t_Table *Table) * ACTION: free a Table array *******************************************************************************/ void Table_Free_Array(t_Table *Table) { long index; if (!Table) return; for (index=0;index < Table[0].array_length; index++){ Table_Free(&Table[index]); } free(Table); } /* end Table_Free_Array */ /****************************************************************************** * long Table_Info_Array(t_Table *Table) * ACTION: print informations about a Table array * return: number of elements in the Table array *******************************************************************************/ long Table_Info_Array(t_Table *Table) { long index=0; if (!Table) return(-1); while (index < Table[index].array_length && (Table[index].data || Table[index].header) && (Table[index].rows*Table[index].columns) ) { Table_Info(Table[index]); index++; } printf("This Table array contains %li elements\n", index); return(index); } /* end Table_Info_Array */ /****************************************************************************** * char **Table_ParseHeader(char *header, symbol1, symbol2, ..., NULL) * ACTION: search for char* symbols in header and return their value or NULL * the search is not case sensitive. * Last argument MUST be NULL * return: array of char* with line following each symbol, or NULL if not found *******************************************************************************/ #ifndef MyNL_ARGMAX #define MyNL_ARGMAX 50 #endif char **Table_ParseHeader_backend(char *header, ...){ va_list ap; char exit_flag=0; int counter =0; char **ret =NULL; if (!header || header[0]=='\0') return(NULL); ret = (char**)calloc(MyNL_ARGMAX, sizeof(char*)); if (!ret) { printf("Table_ParseHeader: Cannot allocate %i values array for Parser (Table_ParseHeader).\n", MyNL_ARGMAX); return(NULL); } for (counter=0; counter < MyNL_ARGMAX; ret[counter++] = NULL); counter=0; va_start(ap, header); while(!exit_flag && counter < MyNL_ARGMAX-1) { char *arg_char=NULL; char *pos =NULL; /* get variable argument value as a char */ arg_char = va_arg(ap, char *); if (!arg_char || arg_char[0]=='\0'){ exit_flag = 1; break; } /* search for the symbol in the header */ pos = (char*)strcasestr(header, arg_char); if (pos) { char *eol_pos; eol_pos = strchr(pos+strlen(arg_char), '\n'); if (!eol_pos) eol_pos = strchr(pos+strlen(arg_char), '\r'); if (!eol_pos) eol_pos = pos+strlen(pos)-1; ret[counter] = (char*)malloc(eol_pos - pos); if (!ret[counter]) { printf("Table_ParseHeader: Cannot allocate value[%i] array for Parser searching for %s (Table_ParseHeader).\n", counter, arg_char); exit_flag = 1; break; } strncpy(ret[counter], pos+strlen(arg_char), eol_pos - pos - strlen(arg_char)); ret[counter][eol_pos - pos - strlen(arg_char)]='\0'; } counter++; } va_end(ap); return(ret); } /* Table_ParseHeader */ /****************************************************************************** * double Table_Interp1d(x, x1, y1, x2, y2) * ACTION: interpolates linearly at x between y1=f(x1) and y2=f(x2) * return: y=f(x) value *******************************************************************************/ double Table_Interp1d(double x, double x1, double y1, double x2, double y2) { double slope; if (x2 == x1) return (y1+y2)/2; if (y1 == y2) return y1; slope = (y2 - y1)/(x2 - x1); return y1+slope*(x - x1); } /* Table_Interp1d */ /****************************************************************************** * double Table_Interp1d_nearest(x, x1, y1, x2, y2) * ACTION: table lookup with nearest method at x between y1=f(x1) and y2=f(x2) * return: y=f(x) value *******************************************************************************/ double Table_Interp1d_nearest(double x, double x1, double y1, double x2, double y2) { if (fabs(x-x1) < fabs(x-x2)) return (y1); else return(y2); } /* Table_Interp1d_nearest */ /****************************************************************************** * double Table_Interp2d(x,y, x1,y1, x2,y2, z11,z12,z21,z22) * ACTION: interpolates bi-linearly at (x,y) between z1=f(x1,y1) and z2=f(x2,y2) * return: z=f(x,y) value * x,y | x1 x2 * ---------------- * y1 | z11 z21 * y2 | z12 z22 *******************************************************************************/ double Table_Interp2d(double x, double y, double x1, double y1, double x2, double y2, double z11, double z12, double z21, double z22) { double ratio_x, ratio_y; if (x2 == x1) return Table_Interp1d(y, y1,z11, y2,z12); if (y1 == y2) return Table_Interp1d(x, x1,z11, x2,z21); ratio_y = (y - y1)/(y2 - y1); ratio_x = (x - x1)/(x2 - x1); return (1-ratio_x)*(1-ratio_y)*z11 + ratio_x*(1-ratio_y)*z21 + ratio_x*ratio_y*z22 + (1-ratio_x)*ratio_y*z12; } /* Table_Interp2d */ /* end of read_table-lib.c */ #endif // READ_TABLE_LIB_C #ifndef SOURCE_GEN_DEF #define SOURCE_GEN_DEF /******************************************************************************* * str_dup_numeric: makes a clean copy of a string and allocate as numeric *******************************************************************************/ char* str_dup_numeric (char* orig) { long i; char* valid; if (!orig || !strlen (orig)) return (NULL); for (i = 0; i < strlen (orig); i++) { if ((orig[i] > 122) || (orig[i] < 32) || (strchr ("!\"#$%&'()*,:;<=>?@[\\]^`/ ", orig[i]) != NULL)) { orig[i] = ' '; } } orig[i] = '\0'; /* now skip spaces */ for (i = 0; i < strlen (orig); i++) { if (*orig == ' ') orig++; else break; } return (orig); } /* str_dup_numeric */ #endif /* Shared user declarations for all components types 'Slit'. */ void slit_print_if (int condition, char* level, char* message, char* component) { if (condition) fprintf (stderr, "Slit: %s: %s: %s\n", component, level, message); } void slit_error_if (int condition, char* message, char* component) { slit_print_if (condition, "Error", message, component); if (condition) exit (-1); } void slit_warning_if (int condition, char* message, char* component) { slit_print_if (condition, "Warning", message, component); } /* Shared user declarations for all components types 'Guide'. */ /***************************************************************************** * * McStas, neutron ray-tracing package * Copyright 1997-2006, All rights reserved * Risoe National Laboratory, Roskilde, Denmark * Institut Laue Langevin, Grenoble, France * * Library: share/ref-lib.h * * %Identification * Written by: Peter Christiansen * Date: August, 2006 * Origin: RISOE * Release: McStas 1.10 * Version: $Revision$ * * Add StdDoubleReflecFunc, ExtendedReflecFunc * Date: October, 2022 * Locale: ESS * Release: McStas 2.7x, 3.1x * * Commonly used reflection functions are declared in this file which * are used by some guide and mirror components. * * Depends on read_table-lib * * Usage: within SHARE * %include "ref-lib" * ****************************************************************************/ #ifndef REF_LIB_H #define REF_LIB_H "$Revision$" void StdReflecFunc(double, double*, double*); void TableReflecFunc(double, t_Table*, double*); void StdDoubleReflecFunc(double, double*, double*); void ExtendedReflecFunc(double, double*, double*); #endif /* end of ref-lib.h */ /**************************************************************************** * * McStas, neutron ray-tracing package * Copyright 1997-2006, All rights reserved * Risoe National Laboratory, Roskilde, Denmark * Institut Laue Langevin, Grenoble, France * * Library: share/ref-lib.c * * %Identification * Written by: Peter Christiansen * Date: August, 2006 * Origin: RISOE * Release: McStas 1.10 * Version: $Revision$ * * Add StdDoubleReflecFunc, ExtendedReflecFunc * Date: October, 2022 * Locale: ESS * Release: McStas 2.7.x, 3.x * * Commonly used reflection functions are declared in this file which * are used by some guide and mirror components. * * Variable names have prefix 'mc_ref_' for 'McStas Reflection' * to avoid conflicts * * Usage: within SHARE * %include "ref-lib" * ****************************************************************************/ #ifndef REF_LIB_H #include "ref-lib.h" #endif #ifndef READ_TABLE_LIB_H #include "read_table-lib.h" #include "read_table-lib.c" #endif /**************************************************************************** * void StdReflecFunc(double q, double *par, double *r) * * The McStas standard analytic parametrization of the reflectivity. * The parameters are: * R0: [1] Low-angle reflectivity * Qc: [AA-1] Critical scattering vector * alpha: [AA] Slope of reflectivity * m: [1] m-value of material. Zero means completely absorbing. * W: [AA-1] Width of supermirror cut-off *****************************************************************************/ #pragma acc routine seq void StdReflecFunc(double mc_pol_q, double *mc_pol_par, double *mc_pol_r) { double R0 = mc_pol_par[0]; double Qc = mc_pol_par[1]; double alpha = mc_pol_par[2]; double m = mc_pol_par[3]; double W = mc_pol_par[4]; double beta = 0; mc_pol_q = fabs(mc_pol_q); double arg; double m_corr; /* Simpler parametrization from Henrik Jacobsen uses these values that depend on m only. double m_value=m*0.9853+0.1978; double W=-0.0002*m_value+0.0022; double alpha=0.2304*m_value+5.0944; double beta=-7.6251*m_value+68.1137; If W and alpha are set to 0, use Henrik's approach for estimating these parameters and apply the formulation: arg = R0*0.5*(1-tanh(arg))*(1-alpha*(q-Qc)+beta*(q-Qc)*(q-Qc)); */ if (W==0 && alpha==0) { m = m * 0.9853 + 0.1978; m_corr = m * 0.9853 - 0.7875; W = -0.0002 * m_corr + 0.0022; alpha = 0.2304 * m_corr + 5.0944; beta = -7.6251 * m_corr + 68.1137; if (m==3) { alpha = m_corr; beta = 0; } arg = (mc_pol_q - m*Qc)/W; // <--- here m, not m_corr!! } arg = W > 0 ? (mc_pol_q - m*Qc)/W : 11; if (arg > 10 || m <= 0 || Qc <=0 || R0 <= 0) { *mc_pol_r = 0; return; } if (m < 1) { Qc *= m; m=1; } if(mc_pol_q <= Qc) { *mc_pol_r = R0; return; } *mc_pol_r = R0*0.5*(1 - tanh(arg))*(1 - alpha*(mc_pol_q - Qc) + beta*(mc_pol_q - Qc)*(mc_pol_q - Qc)); return; } /**************************************************************************** * void TableReflecFunc(double q, t_Table *par, double *r) { * * Looks up the reflectivity in a table using the routines in read_table-lib. *****************************************************************************/ #pragma acc routine seq void TableReflecFunc(double mc_pol_q, t_Table *mc_pol_par, double *mc_pol_r) { *mc_pol_r = Table_Value(*mc_pol_par, mc_pol_q, 1); if(*mc_pol_r>1) *mc_pol_r = 1; return; } /**************************************************************************** * void StdDoubleReflecFunc(double q, double *par, double *r) * * The McStas standard analytic parametrization of the reflectivity for * double-side coated supermirror. * The parameters are: * R0: [1] Low-angle reflectivity * Qc: [AA-1] Critical scattering vector * alpha: [AA] Slope of reflectivity * m: [1] m-value of material. Zero means completely absorbing. * W: [AA-1] Width of supermirror cut-off *****************************************************************************/ void StdDoubleReflecFunc(double mc_pol_q, double *mc_pol_par, double *mc_pol_r) { double R0 = mc_pol_par[0]; double Qc = mc_pol_par[1]; double alpha = mc_pol_par[2]; double m = mc_pol_par[3]; double W = mc_pol_par[4]; double beta = 0; mc_pol_q = fabs(mc_pol_q); double arg; /* Simpler parametrization from Henrik Jacobsen uses these values that depend on m only. double m_value=m*0.9853+0.1978; double W=-0.0002*m_value+0.0022; double alpha=0.2304*m_value+5.0944; double beta=-7.6251*m_value+68.1137; If W and alpha are set to 0, use Henrik's approach for estimating these parameters and apply the formulation: arg = R0*0.5*(1-tanh(arg))*(1-alpha*(q-Qc)+beta*(q-Qc)*(q-Qc)); */ if (W==0 && alpha==0) { m=m*0.9853+0.1978; W=-0.0002*m+0.0022; alpha=0.2304*m+5.0944; beta=-7.6251*m+68.1137; if (m<=3) { alpha=m; beta=0; } } arg = W > 0 ? (mc_pol_q - m*Qc)/W : 11; if (arg > 10 || m <= 0 || Qc <=0 || R0 <= 0) { *mc_pol_r = 0; return; } if (m < 1) { Qc *= m; m=1; } /* Reflectivity R0 = single-side coated supermirror reflectivity double-side coated supermirror reflectivity = 1- (1-R0)^2 */ if(mc_pol_q <= Qc) { *mc_pol_r = 1- (1-R0)*(1-R0); return; } R0 = R0*0.5*(1 - tanh(arg))*(1 - alpha*(mc_pol_q - Qc) + beta*(mc_pol_q - Qc)*(mc_pol_q - Qc)); *mc_pol_r = 1- (1-R0)*(1-R0); return; } void ExtendedReflecFunc(double mc_pol_q, double *mc_pol_par, double *mc_pol_r) { double R0 = mc_pol_par[0]; double Qc = mc_pol_par[1]; double alpha = mc_pol_par[2]; double m = mc_pol_par[3]; double W = mc_pol_par[4]; double beta = mc_pol_par[5]; mc_pol_q = fabs(mc_pol_q); double arg; /* Simpler parametrization from Henrik Jacobsen uses these values that depend on m only. double m_value=m*0.9853+0.1978; double W=-0.0002*m_value+0.0022; double alpha=0.2304*m_value+5.0944; double beta=-7.6251*m_value+68.1137; If W and alpha are set to 0, use Henrik's approach for estimating these parameters and apply the formulation: arg = R0*0.5*(1-tanh(arg))*(1-alpha*(q-Qc)+beta*(q-Qc)*(q-Qc)); */ if (W==0 && alpha==0) { m=m*0.9853+0.1978; W=-0.0002*m+0.0022; alpha=0.2304*m+5.0944; beta=-7.6251*m+68.1137; if (m<=3) { alpha=m; beta=0; } } arg = W > 0 ? (mc_pol_q - m*Qc)/W : 11; if (arg > 10 || m <= 0 || Qc <=0 || R0 <= 0) { *mc_pol_r = 0; return; } if (m < 1) { Qc *= m; m=1; } if(mc_pol_q <= Qc) { *mc_pol_r = R0; return; } *mc_pol_r = R0*0.5*(1 - tanh(arg))*(1 - alpha*(mc_pol_q - Qc) + beta*(mc_pol_q - Qc)*(mc_pol_q - Qc)); return; } /* end of ref-lib.c */ /* Shared user declarations for all components types 'Monochromator_curved'. */ #pragma acc routine double GAUSS_monocurved (double x, double mean, double rms) { return (exp (-((x) - (mean)) * ((x) - (mean)) / (2 * (rms) * (rms))) / (sqrt (2 * PI) * (rms))); } /* Shared user declarations for all components types 'Filter_gen'. */ #ifndef FILTER_GEN #define FILTER_GEN $Revision$ #define UNKNOWN_TABLE 0 #define ENERGY_TABLE 1 #define WAVEVECTOR_TABLE 2 #define WAVELENGTH_TABLE 3 #define FLUX_ADAPT_SET 0 #define FLUX_ADAPT_MULT 1 #define FLUX_ADAPT_ADD 2 char FilterGen_Mode (char* str, char* Mode, char* Type, double* verbose) { long i; char* c; if (!str || !strlen (str)) return (0); c = malloc (strlen (str)); if (!c) { fprintf (stderr, "Filter_Gen: malloc error in FilterGen_Mode. Exit!\n"); exit (-1); } for (i = 0; i < strlen (str); i++) c[i] = tolower (str[i]); /* setup options */ if (strstr (str, " k ") || strstr (str, " q ") || strstr (str, "wavevector")) *Type = WAVEVECTOR_TABLE; if (strstr (str, "omega") || strstr (str, " e ") || strstr (str, "energy")) *Type = ENERGY_TABLE; if (strstr (str, "lambda") || strstr (str, "wavelength") || strstr (str, " L ")) *Type = WAVELENGTH_TABLE; if (strstr (str, "set")) *Mode = FLUX_ADAPT_SET; if (strstr (str, "add")) *Mode = FLUX_ADAPT_ADD; if (strstr (str, "multiply")) *Mode = FLUX_ADAPT_MULT; if (strstr (str, "verbose")) *verbose = 1; return (*Mode); } #endif /* Shared user declarations for all components types 'Monitor_nD'. */ /******************************************************************************* * * McStas, neutron ray-tracing package * Copyright 1997-2002, All rights reserved * Risoe National Laboratory, Roskilde, Denmark * Institut Laue Langevin, Grenoble, France * * Library: share/monitor_nd-lib.h * * %Identification * Written by: EF * Date: Aug 28, 2002 * Origin: ILL * Modified by: TW, Nov 2020: introduced user doubles * Release: McStas 1.6 * Version: $Revision$ * * This file is to be imported by the monitor_nd related components * It handles some shared functions. * * Usage: within SHARE * %include "monitor_nd-lib" * *******************************************************************************/ #ifndef MONITOR_ND_LIB_H #define MONITOR_ND_LIB_H "$Revision$" #define MONnD_COORD_NMAX 30 /* max number of variables to record */ typedef struct MonitornD_Defines { int COORD_NONE ; int COORD_X ; int COORD_Y ; int COORD_Z ; int COORD_RADIUS; int COORD_VX ; int COORD_VY ; int COORD_VZ ; int COORD_V ; int COORD_T ; int COORD_P ; int COORD_SX ; int COORD_SY ; int COORD_SZ ; int COORD_KX ; int COORD_KY ; int COORD_KZ ; int COORD_K ; int COORD_ENERGY; int COORD_LAMBDA; int COORD_KXY ; int COORD_KYZ ; int COORD_KXZ ; int COORD_VXY ; int COORD_VYZ ; int COORD_VXZ ; int COORD_HDIV ; int COORD_VDIV ; int COORD_ANGLE ; int COORD_NCOUNT; int COORD_THETA ; int COORD_PHI ; int COORD_USER0 ; int COORD_USER1 ; int COORD_USER2 ; int COORD_USER3 ; int COORD_USER4 ; int COORD_USER5 ; int COORD_USER6 ; int COORD_USER7 ; int COORD_USER8 ; int COORD_USER9 ; int COORD_USERDOUBLE0 ; int COORD_USERDOUBLE1 ; int COORD_USERDOUBLE2 ; int COORD_USERDOUBLE3 ; int COORD_USERDOUBLE4 ; int COORD_USERDOUBLE5 ; int COORD_USERDOUBLE6 ; int COORD_USERDOUBLE7 ; int COORD_USERDOUBLE8 ; int COORD_USERDOUBLE9 ; int COORD_USERDOUBLE10 ; int COORD_USERDOUBLE11 ; int COORD_USERDOUBLE12 ; int COORD_USERDOUBLE13 ; int COORD_USERDOUBLE14 ; int COORD_USERDOUBLE15 ; int COORD_XY ; int COORD_XZ ; int COORD_YZ ; int COORD_PIXELID; /* token modifiers */ int COORD_VAR ; /* next token should be a variable or normal option */ int COORD_MIN ; /* next token is a min value */ int COORD_MAX ; /* next token is a max value */ int COORD_DIM ; /* next token is a bin value */ int COORD_FIL ; /* next token is a filename */ int COORD_EVNT ; /* next token is a buffer size value */ int COORD_3HE ; /* next token is a 3He pressure value */ int COORD_LOG ; /* next variable will be in log scale */ int COORD_ABS ; /* next variable will be in abs scale */ int COORD_SIGNAL; /* next variable will be the signal var */ int COORD_AUTO ; /* set auto limits */ char TOKEN_DEL[32]; /* token separators */ char SHAPE_SQUARE; /* shape of the monitor */ char SHAPE_DISK ; char SHAPE_SPHERE; char SHAPE_CYLIND; char SHAPE_BANANA; /* cylinder without top/bottom, on restricted angular area */ char SHAPE_BOX ; char SHAPE_PREVIOUS; char SHAPE_OFF; } MonitornD_Defines_type; typedef struct MonitornD_Variables { double area; double Sphere_Radius ; double Cylinder_Height ; char Flag_With_Borders ; /* 2 means xy borders too */ char Flag_List ; /* 1 store 1 buffer, 2 is list all, 3 list all+append */ char Flag_nexusbins ; /* Only relevant in NeXus mode. -1 fully disable, 0 store BINS arrays if list mode, 1 store always */ char Flag_Multiple ; /* 1 when n1D, 0 for 2D */ char Flag_Verbose ; int Flag_Shape ; char Flag_Auto_Limits ; /* get limits from first Buffer */ char Flag_Absorb ; /* monitor is also a slit */ char Flag_per_cm2 ; /* flux is per cm2 */ char Flag_log ; /* log10 of the flux */ char Flag_parallel ; /* set neutron state back after detection (parallel components) */ char Flag_Binary_List ; char Flag_capture ; /* lambda monitor with lambda/lambda(2200m/s = 1.7985 Angs) weightening */ int Flag_signal ; /* 0:monitor p, else monitor a mean value */ int Flag_mantid ; /* 0:normal monitor, else do mantid-event specifics */ int Flag_OFF ; /* Flag to indicate external geometry from OFF file */ long long OFF_polyidx; /* When intersection is done externally by off_intersect, this gives the polygon number, i.e. pixel index */ unsigned long Coord_Number ; /* total number of variables to monitor, plus intensity (0) */ unsigned long Coord_NumberNoPixel; /* same but without counting PixelID */ unsigned long Buffer_Block ; /* Buffer size for list or auto limits */ long long Neutron_Counter ; /* event counter, simulation total counts is mcget_ncount() */ unsigned long Buffer_Counter ; /* index in Buffer size (for realloc) */ unsigned long Buffer_Size ; int Coord_Type[MONnD_COORD_NMAX]; /* type of variable */ char Coord_Label[MONnD_COORD_NMAX][30]; /* label of variable */ char Coord_Var[MONnD_COORD_NMAX][30]; /* short id of variable */ long Coord_Bin[MONnD_COORD_NMAX]; /* bins of variable array */ long Coord_BinProd[MONnD_COORD_NMAX]; /* product of bins of variable array */ double Coord_Min[MONnD_COORD_NMAX]; double Coord_Max[MONnD_COORD_NMAX]; char Monitor_Label[MONnD_COORD_NMAX*30];/* Label for monitor */ char Mon_File[128]; /* output file name */ /* these don't seem to be used anymore as they are superseded by _particle double cx, cy, cz; double cvx, cvy, cvz; double ckx, cky, ckz; double csx, csy, csz; double cEx, cEy, cEz; double cs1, cs2, ct, cphi, cp; */ double He3_pressure; char Flag_UsePreMonitor ; /* use a previously stored neutron parameter set */ char UserName0[128]; char UserName1[128]; char UserName2[128]; char UserName3[128]; char UserName4[128]; char UserName5[128]; char UserName6[128]; char UserName7[128]; char UserName8[128]; char UserName9[128]; char UserVariable0[128]; char UserVariable1[128]; char UserVariable2[128]; char UserVariable3[128]; char UserVariable4[128]; char UserVariable5[128]; char UserVariable6[128]; char UserVariable7[128]; char UserVariable8[128]; char UserVariable9[128]; double UserDoubles[16]; char option[CHAR_BUF_LENGTH]; long long int Nsum; double psum, p2sum; double **Mon2D_N; double **Mon2D_p; double **Mon2D_p2; double *Mon2D_Buffer; unsigned long PixelID; double mxmin,mxmax,mymin,mymax,mzmin,mzmax; double mean_dx, mean_dy, min_x, min_y, max_x, max_y, mean_p; char compcurname[128]; Coords compcurpos; Rotation compcurrot; int compcurindex; } MonitornD_Variables_type; /* monitor_nd-lib function prototypes */ /* ========================================================================= */ void Monitor_nD_Init(MonitornD_Defines_type *, MonitornD_Variables_type *, MCNUM, MCNUM, MCNUM, MCNUM, MCNUM, MCNUM, MCNUM, MCNUM, MCNUM, int, int); #pragma acc routine int Monitor_nD_Trace(MonitornD_Defines_type *, MonitornD_Variables_type *, _class_particle* _particle); MCDETECTOR Monitor_nD_Save(MonitornD_Defines_type *, MonitornD_Variables_type *); void Monitor_nD_Finally(MonitornD_Defines_type *, MonitornD_Variables_type *); void Monitor_nD_McDisplay(MonitornD_Defines_type *, MonitornD_Variables_type *); #endif /* end of monitor_nd-lib.h */ /******************************************************************************* * * McStas, neutron ray-tracing package * Copyright 1997-2002, All rights reserved * Risoe National Laboratory, Roskilde, Denmark * Institut Laue Langevin, Grenoble, France * * Library: share/monitor_nd-lib.c * * %Identification * Written by: EF * Date: Aug 28, 2002 * Origin: ILL * Modified by: TW, Nov 2020: introduced user doubles * Release: McStas 1.6 * Version: $Revision$ * * This file is to be imported by the monitor_nd related components * It handles some shared functions. Embedded within instrument in runtime mode. * * Usage: within SHARE * %include "monitor_nd-lib" * *******************************************************************************/ #ifndef MONITOR_ND_LIB_H #error McStas : please import this library with %include "monitor_nd-lib" #endif /* ========================================================================= */ /* Monitor_nD_Init: this routine is used to parse options */ /* ========================================================================= */ void Monitor_nD_Init(MonitornD_Defines_type *DEFS, MonitornD_Variables_type *Vars, MCNUM xwidth, MCNUM yheight, MCNUM zdepth, MCNUM xmin, MCNUM xmax, MCNUM ymin, MCNUM ymax, MCNUM zmin, MCNUM zmax, int offflag, int nexusbins) { long carg = 1; char *option_copy, *token; char Flag_New_token = 1; char Flag_End = 1; char Flag_All = 0; char Flag_No = 0; char Flag_abs = 0; int Flag_auto = 0; /* -1: all, 1: the current variable */ int Set_Vars_Coord_Type; char Set_Vars_Coord_Label[64]; char Set_Vars_Coord_Var[64]; char Short_Label[MONnD_COORD_NMAX][64]; int Set_Coord_Mode; long i=0, j=0; double lmin, lmax, XY=0; long t; int N_spatial_dims=0; t = (long)time(NULL); /* initialize DEFS */ /* Variables to monitor */ DEFS->COORD_NONE =0; DEFS->COORD_X =1; DEFS->COORD_Y =2; DEFS->COORD_Z =3; DEFS->COORD_RADIUS =19; DEFS->COORD_VX =4; DEFS->COORD_VY =5; DEFS->COORD_VZ =6; DEFS->COORD_V =16; DEFS->COORD_T =7; DEFS->COORD_P =8; DEFS->COORD_SX =9; DEFS->COORD_SY =10; DEFS->COORD_SZ =11; DEFS->COORD_KX =12; DEFS->COORD_KY =13; DEFS->COORD_KZ =14; DEFS->COORD_K =15; DEFS->COORD_ENERGY =17; DEFS->COORD_LAMBDA =18; DEFS->COORD_HDIV =20; DEFS->COORD_VDIV =21; DEFS->COORD_ANGLE =22; DEFS->COORD_NCOUNT =23; DEFS->COORD_THETA =24; DEFS->COORD_PHI =25; DEFS->COORD_USER0 =55; DEFS->COORD_USER1 =26; DEFS->COORD_USER2 =27; DEFS->COORD_USER3 =28; DEFS->COORD_USER4 =56; DEFS->COORD_USER5 =57; DEFS->COORD_USER6 =58; DEFS->COORD_USER7 =59; DEFS->COORD_USER8 =60; DEFS->COORD_USER9 =61; DEFS->COORD_USERDOUBLE0=39; DEFS->COORD_USERDOUBLE1=40; DEFS->COORD_USERDOUBLE2=41; DEFS->COORD_USERDOUBLE3=42; DEFS->COORD_USERDOUBLE4=43; DEFS->COORD_USERDOUBLE5=44; DEFS->COORD_USERDOUBLE6=45; DEFS->COORD_USERDOUBLE7=46; DEFS->COORD_USERDOUBLE8=47; DEFS->COORD_USERDOUBLE9=48; DEFS->COORD_USERDOUBLE10=49; DEFS->COORD_USERDOUBLE11=50; DEFS->COORD_USERDOUBLE12=51; DEFS->COORD_USERDOUBLE13=52; DEFS->COORD_USERDOUBLE14=53; DEFS->COORD_USERDOUBLE15=54; DEFS->COORD_XY =37; DEFS->COORD_YZ =31; DEFS->COORD_XZ =32; DEFS->COORD_VXY =30; DEFS->COORD_VYZ =34; DEFS->COORD_VXZ =36; DEFS->COORD_KXY =29; DEFS->COORD_KYZ =33; DEFS->COORD_KXZ =35; DEFS->COORD_PIXELID=38; /* token modifiers */ DEFS->COORD_VAR =0; /* next token should be a variable or normal option */ DEFS->COORD_MIN =1; /* next token is a min value */ DEFS->COORD_MAX =2; /* next token is a max value */ DEFS->COORD_DIM =3; /* next token is a bin value */ DEFS->COORD_FIL =4; /* next token is a filename */ DEFS->COORD_EVNT =5; /* next token is a buffer size value */ DEFS->COORD_3HE =6; /* next token is a 3He pressure value */ DEFS->COORD_LOG =64; /* next variable will be in log scale */ DEFS->COORD_ABS =128; /* next variable will be in abs scale */ DEFS->COORD_SIGNAL =256; /* next variable will be the signal var */ DEFS->COORD_AUTO =512; /* set auto limits */ strcpy(DEFS->TOKEN_DEL, " =,;[](){}:"); /* token separators */ DEFS->SHAPE_SQUARE =0; /* shape of the monitor */ DEFS->SHAPE_DISK =1; DEFS->SHAPE_SPHERE =2; DEFS->SHAPE_CYLIND =3; DEFS->SHAPE_BANANA =4; DEFS->SHAPE_BOX =5; DEFS->SHAPE_PREVIOUS=6; DEFS->SHAPE_OFF=7; Vars->Sphere_Radius = 0; Vars->Cylinder_Height = 0; Vars->Flag_With_Borders = 0; /* 2 means xy borders too */ Vars->Flag_List = 0; /* 1=store 1 buffer, 2=list all, 3=re-use buffer */ Vars->Flag_nexusbins = 0; /* NeXus only: -1=disable, 0=enable for list mode, 1=enable for all monitors */ /* (Actual control of variable happens in comp INIT) */ Vars->Flag_Multiple = 0; /* 1 when n1D, 0 for 2D */ Vars->Flag_Verbose = 0; Vars->Flag_Shape = DEFS->SHAPE_SQUARE; Vars->Flag_Auto_Limits = 0; /* get limits from first Buffer */ Vars->Flag_Absorb = 0; /* monitor is also a slit */ Vars->Flag_per_cm2 = 0; /* flux is per cm2 */ Vars->Flag_log = 0; /* log10 of the flux */ Vars->Flag_parallel = 0; /* set neutron state back after detection (parallel components) */ Vars->Flag_Binary_List = 0; /* save list as a binary file (smaller) */ Vars->Coord_Number = 0; /* total number of variables to monitor, plus intensity (0) */ Vars->Coord_NumberNoPixel=0; /* same but without counting PixelID */ Vars->Buffer_Block = MONND_BUFSIZ; /* Buffer size for list or auto limits */ Vars->Neutron_Counter = 0; /* event counter, simulation total counts is mcget_ncount() */ Vars->Buffer_Counter = 0; /* index in Buffer size (for realloc) */ Vars->Buffer_Size = 0; Vars->He3_pressure = 0; Vars->Flag_capture = 0; Vars->Flag_signal = DEFS->COORD_P; Vars->Flag_mantid = 0; Vars->Flag_OFF = offflag; Vars->OFF_polyidx = -1; Vars->mean_dx=Vars->mean_dy=0; Vars->min_x = Vars->max_x =0; Vars->min_y = Vars->max_y =0; Set_Vars_Coord_Type = DEFS->COORD_NONE; Set_Coord_Mode = DEFS->COORD_VAR; /* handle size parameters */ /* normal use is with xwidth, yheight, zdepth */ /* if xmin,xmax,ymin,ymax,zmin,zmax are non 0, use them */ if (fabs(xmin-xmax) == 0) { Vars->mxmin = -fabs(xwidth)/2; Vars->mxmax = fabs(xwidth)/2; } else { if (xmin < xmax) {Vars->mxmin = xmin; Vars->mxmax = xmax;} else {Vars->mxmin = xmax; Vars->mxmax = xmin;} } if (fabs(ymin-ymax) == 0) { Vars->mymin = -fabs(yheight)/2; Vars->mymax = fabs(yheight)/2; } else { if (ymin < ymax) {Vars->mymin = ymin; Vars->mymax = ymax;} else {Vars->mymin = ymax; Vars->mymax = ymin;} } if (fabs(zmin-zmax) == 0) { Vars->mzmin = -fabs(zdepth)/2; Vars->mzmax = fabs(zdepth)/2; } else { if (zmin < zmax) {Vars->mzmin = zmin; Vars->mzmax = zmax; } else {Vars->mzmin = zmax; Vars->mzmax = zmin; } } if (fabs(Vars->mzmax-Vars->mzmin) == 0) Vars->Flag_Shape = DEFS->SHAPE_SQUARE; else Vars->Flag_Shape = DEFS->SHAPE_BOX; if (Vars->Flag_OFF) { N_spatial_dims++; Vars->Flag_Shape = DEFS->SHAPE_OFF; } /* parse option string */ option_copy = (char*)malloc(strlen(Vars->option)+1); if (option_copy == NULL) { fprintf(stderr,"Monitor_nD: %s cannot allocate 'options' copy (%li). Fatal.\n", Vars->compcurname, (long)strlen(Vars->option)); exit(-1); } if (strlen(Vars->option)) { Flag_End = 0; strcpy(option_copy, Vars->option); } if (strstr(Vars->option, "cm2") || strstr(Vars->option, "cm^2")) Vars->Flag_per_cm2 = 1; if (strstr(Vars->option, "binary") || strstr(Vars->option, "float")) Vars->Flag_Binary_List = 1; if (strstr(Vars->option, "double")) Vars->Flag_Binary_List = 2; strcpy(Vars->Coord_Label[0],"Intensity"); strncpy(Vars->Coord_Var[0],"p",30); Vars->Coord_Type[0] = DEFS->COORD_P; Vars->Coord_Bin[0] = 1; Vars->Coord_Min[0] = 0; Vars->Coord_Max[0] = FLT_MAX; /* default file name is comp_name+dateID */ sprintf(Vars->Mon_File, "%s_%li", Vars->compcurname, t); carg = 1; while((Flag_End == 0) && (carg < 128)) { if (Flag_New_token) /* retain previous token or get a new one */ { if (carg == 1) token=(char *)strtok(option_copy,DEFS->TOKEN_DEL); else token=(char *)strtok(NULL,DEFS->TOKEN_DEL); if (token == NULL) Flag_End=1; } Flag_New_token = 1; if ((token != NULL) && (strlen(token) != 0)) { char iskeyword=0; /* left at 0 when variables are processed, 1 for modifiers */ int old_Mode; /* change token to lower case */ for (i=0; iCOORD_MAX) /* max=%i */ { if (!Flag_All) Vars->Coord_Max[Vars->Coord_Number] = atof(token); else for (i = 0; i <= Vars->Coord_Number; Vars->Coord_Max[i++] = atof(token)); Set_Coord_Mode = DEFS->COORD_VAR; Flag_All = 0; } if (Set_Coord_Mode == DEFS->COORD_MIN) /* min=%i */ { if (!Flag_All) Vars->Coord_Min[Vars->Coord_Number] = atof(token); else for (i = 0; i <= Vars->Coord_Number; Vars->Coord_Min[i++] = atof(token)); Set_Coord_Mode = DEFS->COORD_MAX; } if (Set_Coord_Mode == DEFS->COORD_DIM) /* bins=%i */ { if (!Flag_All) Vars->Coord_Bin[Vars->Coord_Number] = atoi(token); else for (i = 0; i <= Vars->Coord_Number; Vars->Coord_Bin[i++] = atoi(token)); Set_Coord_Mode = DEFS->COORD_VAR; Flag_All = 0; } if (Set_Coord_Mode == DEFS->COORD_FIL) /* file=%s */ { if (!Flag_No) strncpy(Vars->Mon_File,token,128); else { strcpy(Vars->Mon_File,""); Vars->Coord_Number = 0; Flag_End = 1;} Set_Coord_Mode = DEFS->COORD_VAR; } if (Set_Coord_Mode == DEFS->COORD_EVNT) /* list=%i */ { if (!strcmp(token, "all") || Flag_All) Vars->Flag_List = 2; else { i = (long)ceil(atof(token)); if (i) Vars->Buffer_Block = i; Vars->Flag_List = 1; } Set_Coord_Mode = DEFS->COORD_VAR; Flag_All = 0; } if (Set_Coord_Mode == DEFS->COORD_3HE) /* pressure=%g */ { Vars->He3_pressure = atof(token); Set_Coord_Mode = DEFS->COORD_VAR; Flag_All = 0; } /* now look for general option keywords */ if (!strcmp(token, "borders")) {Vars->Flag_With_Borders = 1; iskeyword=1; } if (!strcmp(token, "verbose")) {Vars->Flag_Verbose = 1; iskeyword=1; } if (!strcmp(token, "log")) {Vars->Flag_log = 1; iskeyword=1; } if (!strcmp(token, "abs")) {Flag_abs = 1; iskeyword=1; } if (!strcmp(token, "multiple")) {Vars->Flag_Multiple = 1; iskeyword=1; } if (!strcmp(token, "list") || !strcmp(token, "events")) { Vars->Flag_List = 1; Set_Coord_Mode = DEFS->COORD_EVNT; } if (!strcmp(token, "limits") || !strcmp(token, "min")) Set_Coord_Mode = DEFS->COORD_MIN; if (!strcmp(token, "slit") || !strcmp(token, "absorb")) { Vars->Flag_Absorb = 1; iskeyword=1; } if (!strcmp(token, "max")) Set_Coord_Mode = DEFS->COORD_MAX; if (!strcmp(token, "bins") || !strcmp(token, "dim")) Set_Coord_Mode = DEFS->COORD_DIM; if (!strcmp(token, "file") || !strcmp(token, "filename")) { Set_Coord_Mode = DEFS->COORD_FIL; if (Flag_No) { strcpy(Vars->Mon_File,""); Vars->Coord_Number = 0; Flag_End = 1; } } if (!strcmp(token, "inactivate")) { Flag_End = 1; Vars->Coord_Number = 0; iskeyword=1; } if (!strcmp(token, "all")) { Flag_All = 1; iskeyword=1; } if (!strcmp(token, "sphere")) { Vars->Flag_Shape = DEFS->SHAPE_SPHERE; iskeyword=1; } if (!strcmp(token, "cylinder")) { Vars->Flag_Shape = DEFS->SHAPE_CYLIND; iskeyword=1; } if (!strcmp(token, "banana")) { Vars->Flag_Shape = DEFS->SHAPE_BANANA; iskeyword=1; } if (!strcmp(token, "square")) { Vars->Flag_Shape = DEFS->SHAPE_SQUARE; iskeyword=1; } if (!strcmp(token, "disk")) { Vars->Flag_Shape = DEFS->SHAPE_DISK; iskeyword=1; } if (!strcmp(token, "box")) { Vars->Flag_Shape = DEFS->SHAPE_BOX; iskeyword=1; } if (!strcmp(token, "previous")) { Vars->Flag_Shape = DEFS->SHAPE_PREVIOUS; iskeyword=1; } if (!strcmp(token, "parallel")){ Vars->Flag_parallel = 1; iskeyword=1; } if (!strcmp(token, "capture")) { Vars->Flag_capture = 1; iskeyword=1; } if (!strcmp(token, "auto")) { #ifndef OPENACC if (Flag_auto != -1) { Vars->Flag_Auto_Limits = 1; if (Flag_All) Flag_auto = -1; else Flag_auto = 1; iskeyword=1; Flag_All=0; } #endif } if (!strcmp(token, "premonitor")) { Vars->Flag_UsePreMonitor = 1; iskeyword=1; } if (!strcmp(token, "3He_pressure") || !strcmp(token, "pressure")) { Vars->He3_pressure = 3; iskeyword=1; } if (!strcmp(token, "no") || !strcmp(token, "not")) { Flag_No = 1; iskeyword=1; } if (!strcmp(token, "signal")) Set_Coord_Mode = DEFS->COORD_SIGNAL; if (!strcmp(token, "mantid")) { Vars->Flag_mantid = 1; iskeyword=1; } /* Mode has changed: this was a keyword or value ? */ if (Set_Coord_Mode != old_Mode) iskeyword=1; /* now look for variable names to monitor */ Set_Vars_Coord_Type = DEFS->COORD_NONE; lmin = 0; lmax = 0; if (!strcmp(token, "x")) { Set_Vars_Coord_Type = DEFS->COORD_X; strcpy(Set_Vars_Coord_Label,"x [m]"); strcpy(Set_Vars_Coord_Var,"x"); lmin = Vars->mxmin; lmax = Vars->mxmax; Vars->Coord_Min[Vars->Coord_Number+1] = Vars->mxmin; Vars->Coord_Max[Vars->Coord_Number+1] = Vars->mxmax; N_spatial_dims++;} if (!strcmp(token, "y")) { Set_Vars_Coord_Type = DEFS->COORD_Y; strcpy(Set_Vars_Coord_Label,"y [m]"); strcpy(Set_Vars_Coord_Var,"y"); lmin = Vars->mymin; lmax = Vars->mymax; Vars->Coord_Min[Vars->Coord_Number+1] = Vars->mymin; Vars->Coord_Max[Vars->Coord_Number+1] = Vars->mymax; N_spatial_dims++;} if (!strcmp(token, "z")) { Set_Vars_Coord_Type = DEFS->COORD_Z; strcpy(Set_Vars_Coord_Label,"z [m]"); strcpy(Set_Vars_Coord_Var,"z"); lmin = Vars->mzmin; lmax = Vars->mzmax; N_spatial_dims++;} if (!strcmp(token, "k") || !strcmp(token, "wavevector")) { Set_Vars_Coord_Type = DEFS->COORD_K; strcpy(Set_Vars_Coord_Label,"|k| [Angs-1]"); strcpy(Set_Vars_Coord_Var,"k"); lmin = 0; lmax = 10; } if (!strcmp(token, "v")) { Set_Vars_Coord_Type = DEFS->COORD_V; strcpy(Set_Vars_Coord_Label,"Velocity [m/s]"); strcpy(Set_Vars_Coord_Var,"v"); lmin = 0; lmax = 10000; } if (!strcmp(token, "t") || !strcmp(token, "time") || !strcmp(token, "tof")) { Set_Vars_Coord_Type = DEFS->COORD_T; strcpy(Set_Vars_Coord_Label,"TOF [s]"); strcpy(Set_Vars_Coord_Var,"t"); lmin = 0; lmax = 1.0; } if ((!strcmp(token, "p") || !strcmp(token, "i") || !strcmp(token, "intensity") || !strcmp(token, "flux"))) { Set_Vars_Coord_Type = DEFS->COORD_P; strcpy(Set_Vars_Coord_Label,"Intensity"); strncat(Set_Vars_Coord_Label, " [n/s", 30); if (Vars->Flag_per_cm2) strncat(Set_Vars_Coord_Label, "/cm2", 30); if (XY > 1 && Vars->Coord_Number) strncat(Set_Vars_Coord_Label, "/bin", 30); strncat(Set_Vars_Coord_Label, "]", 30); strcpy(Set_Vars_Coord_Var,"I"); lmin = 0; lmax = FLT_MAX; if (Flag_auto>0) Flag_auto=0; } if (!strcmp(token, "vx")) { Set_Vars_Coord_Type = DEFS->COORD_VX; strcpy(Set_Vars_Coord_Label,"vx [m/s]"); strcpy(Set_Vars_Coord_Var,"vx"); lmin = -1000; lmax = 1000; } if (!strcmp(token, "vy")) { Set_Vars_Coord_Type = DEFS->COORD_VY; strcpy(Set_Vars_Coord_Label,"vy [m/s]"); strcpy(Set_Vars_Coord_Var,"vy"); lmin = -1000; lmax = 1000; } if (!strcmp(token, "vz")) { Set_Vars_Coord_Type = DEFS->COORD_VZ; strcpy(Set_Vars_Coord_Label,"vz [m/s]"); strcpy(Set_Vars_Coord_Var,"vz"); lmin = -10000; lmax = 10000; } if (!strcmp(token, "kx")) { Set_Vars_Coord_Type = DEFS->COORD_KX; strcpy(Set_Vars_Coord_Label,"kx [Angs-1]"); strcpy(Set_Vars_Coord_Var,"kx"); lmin = -1; lmax = 1; } if (!strcmp(token, "ky")) { Set_Vars_Coord_Type = DEFS->COORD_KY; strcpy(Set_Vars_Coord_Label,"ky [Angs-1]"); strcpy(Set_Vars_Coord_Var,"ky"); lmin = -1; lmax = 1; } if (!strcmp(token, "kz")) { Set_Vars_Coord_Type = DEFS->COORD_KZ; strcpy(Set_Vars_Coord_Label,"kz [Angs-1]"); strcpy(Set_Vars_Coord_Var,"kz"); lmin = -10; lmax = 10; } if (!strcmp(token, "sx")) { Set_Vars_Coord_Type = DEFS->COORD_SX; strcpy(Set_Vars_Coord_Label,"sx [1]"); strcpy(Set_Vars_Coord_Var,"sx"); lmin = -1; lmax = 1; } if (!strcmp(token, "sy")) { Set_Vars_Coord_Type = DEFS->COORD_SY; strcpy(Set_Vars_Coord_Label,"sy [1]"); strcpy(Set_Vars_Coord_Var,"sy"); lmin = -1; lmax = 1; } if (!strcmp(token, "sz")) { Set_Vars_Coord_Type = DEFS->COORD_SZ; strcpy(Set_Vars_Coord_Label,"sz [1]"); strcpy(Set_Vars_Coord_Var,"sz"); lmin = -1; lmax = 1; } if (!strcmp(token, "energy") || !strcmp(token, "omega") || !strcmp(token, "e")) { Set_Vars_Coord_Type = DEFS->COORD_ENERGY; strcpy(Set_Vars_Coord_Label,"Energy [meV]"); strcpy(Set_Vars_Coord_Var,"E"); lmin = 0; lmax = 100; } if (!strcmp(token, "lambda") || !strcmp(token, "wavelength") || !strcmp(token, "l")) { Set_Vars_Coord_Type = DEFS->COORD_LAMBDA; strcpy(Set_Vars_Coord_Label,"Wavelength [Angs]"); strcpy(Set_Vars_Coord_Var,"L"); lmin = 0; lmax = 100; } if (!strcmp(token, "radius") || !strcmp(token, "r")) { Set_Vars_Coord_Type = DEFS->COORD_RADIUS; strcpy(Set_Vars_Coord_Label,"Radius [m]"); strcpy(Set_Vars_Coord_Var,"xy"); lmin = 0; lmax = xmax; } if (!strcmp(token, "xy")) { Set_Vars_Coord_Type = DEFS->COORD_XY; strcpy(Set_Vars_Coord_Label,"Radius (xy) [m]"); strcpy(Set_Vars_Coord_Var,"xy"); lmin = 0; lmax = xmax; N_spatial_dims+=1;} if (!strcmp(token, "yz")) { Set_Vars_Coord_Type = DEFS->COORD_YZ; strcpy(Set_Vars_Coord_Label,"Radius (yz) [m]"); strcpy(Set_Vars_Coord_Var,"yz"); lmin = 0; lmax = xmax; N_spatial_dims+=1;} if (!strcmp(token, "xz")) { Set_Vars_Coord_Type = DEFS->COORD_XZ; strcpy(Set_Vars_Coord_Label,"Radius (xz) [m]"); strcpy(Set_Vars_Coord_Var,"xz"); lmin = 0; lmax = xmax; N_spatial_dims+=1;} if (!strcmp(token, "vxy")) { Set_Vars_Coord_Type = DEFS->COORD_VXY; strcpy(Set_Vars_Coord_Label,"Radial Velocity (xy) [m]"); strcpy(Set_Vars_Coord_Var,"Vxy"); lmin = 0; lmax = 2000; } if (!strcmp(token, "kxy")) { Set_Vars_Coord_Type = DEFS->COORD_KXY; strcpy(Set_Vars_Coord_Label,"Radial Wavevector (xy) [Angs-1]"); strcpy(Set_Vars_Coord_Var,"Kxy"); lmin = 0; lmax = 2; } if (!strcmp(token, "vyz")) { Set_Vars_Coord_Type = DEFS->COORD_VYZ; strcpy(Set_Vars_Coord_Label,"Radial Velocity (yz) [m]"); strcpy(Set_Vars_Coord_Var,"Vyz"); lmin = 0; lmax = 2000; } if (!strcmp(token, "kyz")) { Set_Vars_Coord_Type = DEFS->COORD_KYZ; strcpy(Set_Vars_Coord_Label,"Radial Wavevector (yz) [Angs-1]"); strcpy(Set_Vars_Coord_Var,"Kyz"); lmin = 0; lmax = 2; } if (!strcmp(token, "vxz")) { Set_Vars_Coord_Type = DEFS->COORD_VXZ; strcpy(Set_Vars_Coord_Label,"Radial Velocity (xz) [m]"); strcpy(Set_Vars_Coord_Var,"Vxz"); lmin = 0; lmax = 2000; } if (!strcmp(token, "kxz")) { Set_Vars_Coord_Type = DEFS->COORD_KXZ; strcpy(Set_Vars_Coord_Label,"Radial Wavevector (xz) [Angs-1]"); strcpy(Set_Vars_Coord_Var,"Kxz"); lmin = 0; lmax = 2; } if (!strcmp(token, "angle") || !strcmp(token, "a")) { Set_Vars_Coord_Type = DEFS->COORD_ANGLE; strcpy(Set_Vars_Coord_Label,"Angle [deg]"); strcpy(Set_Vars_Coord_Var,"A"); lmin = -50; lmax = 50; N_spatial_dims++;} if (!strcmp(token, "hdiv")|| !strcmp(token, "divergence") || !strcmp(token, "xdiv") || !strcmp(token, "hd") || !strcmp(token, "dx")) { Set_Vars_Coord_Type = DEFS->COORD_HDIV; strcpy(Set_Vars_Coord_Label,"Hor. Divergence [deg]"); strcpy(Set_Vars_Coord_Var,"hd"); lmin = -5; lmax = 5; N_spatial_dims++;} if (!strcmp(token, "vdiv") || !strcmp(token, "ydiv") || !strcmp(token, "vd") || !strcmp(token, "dy")) { Set_Vars_Coord_Type = DEFS->COORD_VDIV; strcpy(Set_Vars_Coord_Label,"Vert. Divergence [deg]"); strcpy(Set_Vars_Coord_Var,"vd"); lmin = -5; lmax = 5; N_spatial_dims++;} if (!strcmp(token, "theta") || !strcmp(token, "longitude") || !strcmp(token, "th")) { Set_Vars_Coord_Type = DEFS->COORD_THETA; strcpy(Set_Vars_Coord_Label,"Longitude [deg]"); strcpy(Set_Vars_Coord_Var,"th"); lmin = -180; lmax = 180; N_spatial_dims++;} if (!strcmp(token, "phi") || !strcmp(token, "latitude") || !strcmp(token, "ph")) { Set_Vars_Coord_Type = DEFS->COORD_PHI; strcpy(Set_Vars_Coord_Label,"Latitude [deg]"); strcpy(Set_Vars_Coord_Var,"ph"); lmin = -90; lmax = 90; N_spatial_dims++;} if (!strcmp(token, "ncounts") || !strcmp(token, "n") || !strcmp(token, "neutron")) { Set_Vars_Coord_Type = DEFS->COORD_NCOUNT; strcpy(Set_Vars_Coord_Label,"Neutron ID [1]"); strcpy(Set_Vars_Coord_Var,"n"); lmin = 0; lmax = mcget_ncount(); if (Flag_auto>0) Flag_auto=0; } if (!strcmp(token, "id") || !strcmp(token, "pixel")) { Set_Vars_Coord_Type = DEFS->COORD_PIXELID; strcpy(Set_Vars_Coord_Label,"Pixel ID [1]"); strcpy(Set_Vars_Coord_Var,"id"); lmin = 0; lmax = FLT_MAX; if (Flag_auto>0) Flag_auto=0; Vars->Flag_List = 1; } if (!strcmp(token, "user0") || !strcmp(token, "u0")) { Set_Vars_Coord_Type = DEFS->COORD_USER0; strncpy(Set_Vars_Coord_Label,Vars->UserName0,30); strcpy(Set_Vars_Coord_Var,"U0"); lmin = -1e10; lmax = 1e10; } if (!strcmp(token, "user") || !strcmp(token, "user1") || !strcmp(token, "u1")) { Set_Vars_Coord_Type = DEFS->COORD_USER1; strncpy(Set_Vars_Coord_Label,Vars->UserName1,30); strcpy(Set_Vars_Coord_Var,"U1"); lmin = -1e10; lmax = 1e10; } if (!strcmp(token, "user2") || !strcmp(token, "u2")) { Set_Vars_Coord_Type = DEFS->COORD_USER2; strncpy(Set_Vars_Coord_Label,Vars->UserName2,30); strcpy(Set_Vars_Coord_Var,"U2"); lmin = -1e10; lmax = 1e10; } if (!strcmp(token, "user3") || !strcmp(token, "u3")) { Set_Vars_Coord_Type = DEFS->COORD_USER3; strncpy(Set_Vars_Coord_Label,Vars->UserName3,30); strcpy(Set_Vars_Coord_Var,"U3"); lmin = -1e10; lmax = 1e10; } if (!strcmp(token, "user4") || !strcmp(token, "u4")) { Set_Vars_Coord_Type = DEFS->COORD_USER4; strncpy(Set_Vars_Coord_Label,Vars->UserName4,30); strcpy(Set_Vars_Coord_Var,"U4"); lmin = -1e10; lmax = 1e10; } if (!strcmp(token, "user5") || !strcmp(token, "u5")) { Set_Vars_Coord_Type = DEFS->COORD_USER5; strncpy(Set_Vars_Coord_Label,Vars->UserName5,30); strcpy(Set_Vars_Coord_Var,"U5"); lmin = -1e10; lmax = 1e10; } if (!strcmp(token, "user6") || !strcmp(token, "u6")) { Set_Vars_Coord_Type = DEFS->COORD_USER6; strncpy(Set_Vars_Coord_Label,Vars->UserName6,30); strcpy(Set_Vars_Coord_Var,"U6"); lmin = -1e10; lmax = 1e10; } if (!strcmp(token, "user7") || !strcmp(token, "u7")) { Set_Vars_Coord_Type = DEFS->COORD_USER7; strncpy(Set_Vars_Coord_Label,Vars->UserName7,30); strcpy(Set_Vars_Coord_Var,"U7"); lmin = -1e10; lmax = 1e10; } if (!strcmp(token, "user8") || !strcmp(token, "u8")) { Set_Vars_Coord_Type = DEFS->COORD_USER8; strncpy(Set_Vars_Coord_Label,Vars->UserName8,30); strcpy(Set_Vars_Coord_Var,"U8"); lmin = -1e10; lmax = 1e10; } if (!strcmp(token, "user9") || !strcmp(token, "u9")) { Set_Vars_Coord_Type = DEFS->COORD_USER9; strncpy(Set_Vars_Coord_Label,Vars->UserName9,30); strcpy(Set_Vars_Coord_Var,"U9"); lmin = -1e10; lmax = 1e10; } if (!strcmp(token, "userdouble0") || !strcmp(token, "ud0")) { Set_Vars_Coord_Type = DEFS->COORD_USERDOUBLE0; strcpy(Set_Vars_Coord_Label,"ud0 [1]"); strcpy(Set_Vars_Coord_Var,"ud0"); lmin = -1e10; lmax = 1e10; } if (!strcmp(token, "userdouble1") || !strcmp(token, "ud1")) { Set_Vars_Coord_Type = DEFS->COORD_USERDOUBLE1; strcpy(Set_Vars_Coord_Label,"ud1 [1]"); strcpy(Set_Vars_Coord_Var,"ud1"); lmin = -1e10; lmax = 1e10; } if (!strcmp(token, "userdouble2") || !strcmp(token, "ud2")) { Set_Vars_Coord_Type = DEFS->COORD_USERDOUBLE2; strcpy(Set_Vars_Coord_Label,"ud2 [1]"); strcpy(Set_Vars_Coord_Var,"ud2"); lmin = -1e10; lmax = 1e10; } if (!strcmp(token, "userdouble3") || !strcmp(token, "ud3")) { Set_Vars_Coord_Type = DEFS->COORD_USERDOUBLE3; strcpy(Set_Vars_Coord_Label,"ud3 [1]"); strcpy(Set_Vars_Coord_Var,"ud3"); lmin = -1e10; lmax = 1e10; } if (!strcmp(token, "userdouble4") || !strcmp(token, "ud4")) { Set_Vars_Coord_Type = DEFS->COORD_USERDOUBLE4; strcpy(Set_Vars_Coord_Label,"ud4 [1]"); strcpy(Set_Vars_Coord_Var,"ud4"); lmin = -1e10; lmax = 1e10; } if (!strcmp(token, "userdouble5") || !strcmp(token, "ud5")) { Set_Vars_Coord_Type = DEFS->COORD_USERDOUBLE5; strcpy(Set_Vars_Coord_Label,"ud5 [1]"); strcpy(Set_Vars_Coord_Var,"ud5"); lmin = -1e10; lmax = 1e10; } if (!strcmp(token, "userdouble6") || !strcmp(token, "ud6")) { Set_Vars_Coord_Type = DEFS->COORD_USERDOUBLE6; strcpy(Set_Vars_Coord_Label,"ud6 [1]"); strcpy(Set_Vars_Coord_Var,"ud6"); lmin = -1e10; lmax = 1e10; } if (!strcmp(token, "userdouble7") || !strcmp(token, "ud7")) { Set_Vars_Coord_Type = DEFS->COORD_USERDOUBLE7; strcpy(Set_Vars_Coord_Label,"ud7 [1]"); strcpy(Set_Vars_Coord_Var,"ud7"); lmin = -1e10; lmax = 1e10; } if (!strcmp(token, "userdouble8") || !strcmp(token, "ud8")) { Set_Vars_Coord_Type = DEFS->COORD_USERDOUBLE8; strcpy(Set_Vars_Coord_Label,"ud8 [1]"); strcpy(Set_Vars_Coord_Var,"ud8"); lmin = -1e10; lmax = 1e10; } if (!strcmp(token, "userdouble9") || !strcmp(token, "ud9")) { Set_Vars_Coord_Type = DEFS->COORD_USERDOUBLE9; strcpy(Set_Vars_Coord_Label,"ud9 [1]"); strcpy(Set_Vars_Coord_Var,"ud9"); lmin = -1e10; lmax = 1e10; } if (!strcmp(token, "userdouble10") || !strcmp(token, "ud10")) { Set_Vars_Coord_Type = DEFS->COORD_USERDOUBLE10; strcpy(Set_Vars_Coord_Label,"ud10 [1]"); strcpy(Set_Vars_Coord_Var,"ud10"); lmin = -1e10; lmax = 1e10; } if (!strcmp(token, "userdouble11") || !strcmp(token, "ud11")) { Set_Vars_Coord_Type = DEFS->COORD_USERDOUBLE11; strcpy(Set_Vars_Coord_Label,"ud11 [1]"); strcpy(Set_Vars_Coord_Var,"ud11"); lmin = -1e10; lmax = 1e10; } if (!strcmp(token, "userdouble12") || !strcmp(token, "ud12")) { Set_Vars_Coord_Type = DEFS->COORD_USERDOUBLE12; strcpy(Set_Vars_Coord_Label,"ud12 [1]"); strcpy(Set_Vars_Coord_Var,"ud12"); lmin = -1e10; lmax = 1e10; } if (!strcmp(token, "userdouble13") || !strcmp(token, "ud13")) { Set_Vars_Coord_Type = DEFS->COORD_USERDOUBLE13; strcpy(Set_Vars_Coord_Label,"ud13 [1]"); strcpy(Set_Vars_Coord_Var,"ud13"); lmin = -1e10; lmax = 1e10; } if (!strcmp(token, "userdouble14") || !strcmp(token, "ud14")) { Set_Vars_Coord_Type = DEFS->COORD_USERDOUBLE14; strcpy(Set_Vars_Coord_Label,"ud14 [1]"); strcpy(Set_Vars_Coord_Var,"ud14"); lmin = -1e10; lmax = 1e10; } if (!strcmp(token, "userdouble15") || !strcmp(token, "ud15")) { Set_Vars_Coord_Type = DEFS->COORD_USERDOUBLE15; strcpy(Set_Vars_Coord_Label,"ud15 [1]"); strcpy(Set_Vars_Coord_Var,"ud15"); lmin = -1e10; lmax = 1e10; } /* now stores variable keywords detected, if any */ if (Set_Vars_Coord_Type != DEFS->COORD_NONE) { int Coord_Number = Vars->Coord_Number; if (Vars->Flag_log) { Set_Vars_Coord_Type |= DEFS->COORD_LOG; Vars->Flag_log = 0; } if (Flag_abs) { Set_Vars_Coord_Type |= DEFS->COORD_ABS; Flag_abs = 0; } if (Flag_auto != 0) { Set_Vars_Coord_Type |= DEFS->COORD_AUTO; if (Flag_auto > 0) Flag_auto = 0; } if (Set_Coord_Mode == DEFS->COORD_SIGNAL) { Coord_Number = 0; Vars->Flag_signal = Set_Vars_Coord_Type; } else { if (Coord_Number < MONnD_COORD_NMAX) { Coord_Number++; Vars->Coord_Number = Coord_Number; if (Set_Vars_Coord_Type != DEFS->COORD_PIXELID) Vars->Coord_NumberNoPixel++; } else if (Vars->Flag_Verbose) printf("Monitor_nD: %s reached max number of variables (%i).\n", Vars->compcurname, MONnD_COORD_NMAX); } Vars->Coord_Type[Coord_Number] = Set_Vars_Coord_Type; strncpy(Vars->Coord_Label[Coord_Number], Set_Vars_Coord_Label,30); strncpy(Vars->Coord_Var[Coord_Number], Set_Vars_Coord_Var,30); if (lmin > lmax) { XY = lmin; lmin=lmax; lmax = XY; } Vars->Coord_Min[Coord_Number] = lmin; Vars->Coord_Max[Coord_Number] = lmax; if (Set_Vars_Coord_Type == DEFS->COORD_NCOUNT || Set_Vars_Coord_Type == DEFS->COORD_PIXELID || Set_Vars_Coord_Type == DEFS->COORD_SIGNAL) Vars->Coord_Bin[Coord_Number] = 1; else Vars->Coord_Bin[Coord_Number] = 20; Set_Coord_Mode = DEFS->COORD_VAR; Flag_All = 0; Flag_No = 0; } else { /* no variable name could be read from options */ if (!iskeyword) { if (strcmp(token, "cm2") && strcmp(token, "incoming") && strcmp(token, "outgoing") && strcmp(token, "cm2") && strcmp(token, "cm^2") && strcmp(token, "float") && strcmp(token, "double") && strcmp(token, "binary") && strcmp(token, "steradian") && Vars->Flag_Verbose) printf("Monitor_nD: %s: unknown '%s' keyword in 'options'. Ignoring.\n", Vars->compcurname, token); } } carg++; } /* end if token */ } /* end while carg */ /* Handle nexusbins information */ /* Case 1, list mode and not disabled i.e. >-1 */ if (Vars->Flag_List && nexusbins>-1) Vars->Flag_nexusbins=1; /* Case 2, NOT list mode and enabled i.e. ==1 */ if (!Vars->Flag_List && nexusbins==1) Vars->Flag_nexusbins=1; free(option_copy); if (carg == 128) printf("Monitor_nD: %s reached max number of tokens (%i). Skipping.\n", Vars->compcurname, 128); if ((Vars->Flag_Shape == DEFS->SHAPE_BOX) && (fabs(Vars->mzmax - Vars->mzmin) == 0)) Vars->Flag_Shape = DEFS->SHAPE_SQUARE; if (Vars->Flag_log == 1) Vars->Coord_Type[0] |= DEFS->COORD_LOG; if (Vars->Coord_Number == 0) { Vars->Flag_Auto_Limits=0; Vars->Flag_Multiple=0; Vars->Flag_List=0; } /* now setting Monitor Name from variable labels */ strcpy(Vars->Monitor_Label,""); XY = 1; /* will contain total bin number */ for (i = 0; i <= Vars->Coord_Number; i++) { if (Flag_auto != 0) Vars->Coord_Type[i] |= DEFS->COORD_AUTO; Set_Vars_Coord_Type = (Vars->Coord_Type[i] & (DEFS->COORD_LOG-1)); if ((Set_Vars_Coord_Type == DEFS->COORD_X) || (Set_Vars_Coord_Type == DEFS->COORD_Y) || (Set_Vars_Coord_Type == DEFS->COORD_Z)) strcpy(Short_Label[i],"Position"); else if ((Set_Vars_Coord_Type == DEFS->COORD_THETA) || (Set_Vars_Coord_Type == DEFS->COORD_PHI) || (Set_Vars_Coord_Type == DEFS->COORD_ANGLE)) strcpy(Short_Label[i],"Angle"); else if ((Set_Vars_Coord_Type == DEFS->COORD_XY) || (Set_Vars_Coord_Type == DEFS->COORD_XZ) || (Set_Vars_Coord_Type == DEFS->COORD_YZ) || (Set_Vars_Coord_Type == DEFS->COORD_RADIUS)) strcpy(Short_Label[i],"Radius"); else if ((Set_Vars_Coord_Type == DEFS->COORD_VX) || (Set_Vars_Coord_Type == DEFS->COORD_VY) || (Set_Vars_Coord_Type == DEFS->COORD_VZ) || (Set_Vars_Coord_Type == DEFS->COORD_V) || (Set_Vars_Coord_Type == DEFS->COORD_VXY) || (Set_Vars_Coord_Type == DEFS->COORD_VYZ) || (Set_Vars_Coord_Type == DEFS->COORD_VXZ)) strcpy(Short_Label[i],"Velocity"); else if ((Set_Vars_Coord_Type == DEFS->COORD_KX) || (Set_Vars_Coord_Type == DEFS->COORD_KY) || (Set_Vars_Coord_Type == DEFS->COORD_KZ) || (Set_Vars_Coord_Type == DEFS->COORD_KXY) || (Set_Vars_Coord_Type == DEFS->COORD_KYZ) || (Set_Vars_Coord_Type == DEFS->COORD_KXZ) || (Set_Vars_Coord_Type == DEFS->COORD_K)) strcpy(Short_Label[i],"Wavevector"); else if ((Set_Vars_Coord_Type == DEFS->COORD_SX) || (Set_Vars_Coord_Type == DEFS->COORD_SY) || (Set_Vars_Coord_Type == DEFS->COORD_SZ)) strcpy(Short_Label[i],"Spin"); else if ((Set_Vars_Coord_Type == DEFS->COORD_HDIV) || (Set_Vars_Coord_Type == DEFS->COORD_VDIV)) strcpy(Short_Label[i],"Divergence"); else if (Set_Vars_Coord_Type == DEFS->COORD_ENERGY) strcpy(Short_Label[i],"Energy"); else if (Set_Vars_Coord_Type == DEFS->COORD_LAMBDA) strcpy(Short_Label[i],"Wavelength"); else if (Set_Vars_Coord_Type == DEFS->COORD_NCOUNT) strcpy(Short_Label[i],"Neutron_ID"); else if (Set_Vars_Coord_Type == DEFS->COORD_PIXELID) strcpy(Short_Label[i],"Pixel_ID"); else if (Set_Vars_Coord_Type == DEFS->COORD_T) strcpy(Short_Label[i],"Time_Of_Flight"); else if (Set_Vars_Coord_Type == DEFS->COORD_P) strcpy(Short_Label[i],"Intensity"); else if (Set_Vars_Coord_Type == DEFS->COORD_USER0) strncpy(Short_Label[i],Vars->UserName0,30); else if (Set_Vars_Coord_Type == DEFS->COORD_USER1) strncpy(Short_Label[i],Vars->UserName1,30); else if (Set_Vars_Coord_Type == DEFS->COORD_USER2) strncpy(Short_Label[i],Vars->UserName2,30); else if (Set_Vars_Coord_Type == DEFS->COORD_USER3) strncpy(Short_Label[i],Vars->UserName3,30); else if (Set_Vars_Coord_Type == DEFS->COORD_USER4) strncpy(Short_Label[i],Vars->UserName4,30); else if (Set_Vars_Coord_Type == DEFS->COORD_USER5) strncpy(Short_Label[i],Vars->UserName5,30); else if (Set_Vars_Coord_Type == DEFS->COORD_USER6) strncpy(Short_Label[i],Vars->UserName6,30); else if (Set_Vars_Coord_Type == DEFS->COORD_USER7) strncpy(Short_Label[i],Vars->UserName7,30); else if (Set_Vars_Coord_Type == DEFS->COORD_USER8) strncpy(Short_Label[i],Vars->UserName8,30); else if (Set_Vars_Coord_Type == DEFS->COORD_USER9) strncpy(Short_Label[i],Vars->UserName9,30); else strcpy(Short_Label[i],"Unknown"); if (Vars->Coord_Type[i] & DEFS->COORD_ABS) { strcat(Vars->Coord_Label[i]," (abs)"); } if (Vars->Coord_Type[i] & DEFS->COORD_LOG) { strcat(Vars->Coord_Label[i]," (log)"); } strcat(Vars->Monitor_Label, " "); strcat(Vars->Monitor_Label, Short_Label[i]); XY *= Vars->Coord_Bin[i]; } /* end for Short_Label */ if ((Vars->Coord_Type[0] & (DEFS->COORD_LOG-1)) == DEFS->COORD_P) { strncat(Vars->Coord_Label[0], " [n/s", 30); if (Vars->Flag_per_cm2) strncat(Vars->Coord_Label[0], "/cm2", 30); if (XY > 1 && Vars->Coord_Number) strncat(Vars->Coord_Label[0], "/bin", 30); strncat(Vars->Coord_Label[0], "]", 30); } /* update label 'signal per bin' if more than 1 bin */ if (XY > 1 && Vars->Coord_Number) { if (Vars->Flag_capture) printf("Monitor_nD: %s: Using capture flux weightening on %ld bins.\n" "WARNING Use binned data with caution, and prefer monitor integral value (I,Ierr).\n", Vars->compcurname, (long)XY); } strcat(Vars->Monitor_Label, " Monitor"); if (Vars->Flag_Shape == DEFS->SHAPE_SQUARE) strcat(Vars->Monitor_Label, " (Square)"); if (Vars->Flag_Shape == DEFS->SHAPE_DISK) strcat(Vars->Monitor_Label, " (Disk)"); if (Vars->Flag_Shape == DEFS->SHAPE_SPHERE) strcat(Vars->Monitor_Label, " (Sphere)"); if (Vars->Flag_Shape == DEFS->SHAPE_CYLIND) strcat(Vars->Monitor_Label, " (Cylinder)"); if (Vars->Flag_Shape == DEFS->SHAPE_BANANA) strcat(Vars->Monitor_Label, " (Banana)"); if (Vars->Flag_Shape == DEFS->SHAPE_BOX) strcat(Vars->Monitor_Label, " (Box)"); if (Vars->Flag_Shape == DEFS->SHAPE_PREVIOUS) strcat(Vars->Monitor_Label, " (on PREVIOUS)"); if (Vars->Flag_Shape == DEFS->SHAPE_OFF) strcat(Vars->Monitor_Label, " (OFF geometry)"); if ((Vars->Flag_Shape == DEFS->SHAPE_CYLIND) || (Vars->Flag_Shape == DEFS->SHAPE_BANANA) || (Vars->Flag_Shape == DEFS->SHAPE_SPHERE) || (Vars->Flag_Shape == DEFS->SHAPE_BOX)) { if (strstr(Vars->option, "incoming")) { Vars->Flag_Shape = abs(Vars->Flag_Shape); strcat(Vars->Monitor_Label, " [in]"); } else /* if strstr(Vars->option, "outgoing")) */ { Vars->Flag_Shape = -abs(Vars->Flag_Shape); strcat(Vars->Monitor_Label, " [out]"); } } if (Vars->Flag_UsePreMonitor == 1) { strcat(Vars->Monitor_Label, " at "); strncat(Vars->Monitor_Label, Vars->UserName1,30); } if (Vars->Flag_log == 1) strcat(Vars->Monitor_Label, " [log] "); /* now allocate memory to store variables in TRACE */ /* Vars->Coord_Number 0 : intensity or signal * Vars->Coord_Number 1:n : detector variables */ if ((Vars->Coord_NumberNoPixel != 2) && !Vars->Flag_Multiple && !Vars->Flag_List) { Vars->Flag_Multiple = 1; /* default is n1D */ if (Vars->Coord_Number != Vars->Coord_NumberNoPixel) Vars->Flag_List = 1; } /* list and auto limits case : Vars->Flag_List or Vars->Flag_Auto_Limits * -> Buffer to flush and suppress after Vars->Flag_Auto_Limits */ if ((Vars->Flag_Auto_Limits || Vars->Flag_List) && Vars->Coord_Number) { /* Dim : (Vars->Coord_Number+1)*Vars->Buffer_Block matrix (for p, dp) */ Vars->Mon2D_Buffer = (double *)malloc((Vars->Coord_Number+1)*Vars->Buffer_Block*sizeof(double)); if (Vars->Mon2D_Buffer == NULL) { printf("Monitor_nD: %s cannot allocate Vars->Mon2D_Buffer (%zi). No list and auto limits.\n", Vars->compcurname, Vars->Buffer_Block*(Vars->Coord_Number+1)*sizeof(double)); Vars->Flag_List = 0; Vars->Flag_Auto_Limits = 0; } else { for (i=0; i < (Vars->Coord_Number+1)*Vars->Buffer_Block; Vars->Mon2D_Buffer[i++] = (double)0); } Vars->Buffer_Size = Vars->Buffer_Block; } /* 1D and n1D case : Vars->Flag_Multiple */ if (Vars->Flag_Multiple && Vars->Coord_NumberNoPixel) { /* Dim : Vars->Coord_Number*Vars->Coord_Bin[i] vectors */ Vars->Mon2D_N = (double **)malloc((Vars->Coord_Number)*sizeof(double *)); Vars->Mon2D_p = (double **)malloc((Vars->Coord_Number)*sizeof(double *)); Vars->Mon2D_p2 = (double **)malloc((Vars->Coord_Number)*sizeof(double *)); if ((Vars->Mon2D_N == NULL) || (Vars->Mon2D_p == NULL) || (Vars->Mon2D_p2 == NULL)) { fprintf(stderr,"Monitor_nD: %s n1D cannot allocate Vars->Mon2D_N/p/p2 (%zi). Fatal.\n", Vars->compcurname, (Vars->Coord_Number)*sizeof(double *)); exit(-1); } for (i= 1; i <= Vars->Coord_Number; i++) { Vars->Mon2D_N[i-1] = (double *)malloc(Vars->Coord_Bin[i]*sizeof(double)); Vars->Mon2D_p[i-1] = (double *)malloc(Vars->Coord_Bin[i]*sizeof(double)); Vars->Mon2D_p2[i-1] = (double *)malloc(Vars->Coord_Bin[i]*sizeof(double)); if ((Vars->Mon2D_N == NULL) || (Vars->Mon2D_p == NULL) || (Vars->Mon2D_p2 == NULL)) { fprintf(stderr,"Monitor_nD: %s n1D cannot allocate %s Vars->Mon2D_N/p/p2[%li] (%zi). Fatal.\n", Vars->compcurname, Vars->Coord_Var[i], i, (Vars->Coord_Bin[i])*sizeof(double *)); exit(-1); } else { for (j=0; j < Vars->Coord_Bin[i]; j++ ) { Vars->Mon2D_N[i-1][j] = (double)0; Vars->Mon2D_p[i-1][j] = (double)0; Vars->Mon2D_p2[i-1][j] = (double)0; } } } } else /* 2D case : Vars->Coord_Number==2 and !Vars->Flag_Multiple and !Vars->Flag_List */ if ((Vars->Coord_NumberNoPixel == 2) && !Vars->Flag_Multiple) { /* Dim : Vars->Coord_Bin[1]*Vars->Coord_Bin[2] matrix */ Vars->Mon2D_N = (double **)malloc((Vars->Coord_Bin[1])*sizeof(double *)); Vars->Mon2D_p = (double **)malloc((Vars->Coord_Bin[1])*sizeof(double *)); Vars->Mon2D_p2 = (double **)malloc((Vars->Coord_Bin[1])*sizeof(double *)); if ((Vars->Mon2D_N == NULL) || (Vars->Mon2D_p == NULL) || (Vars->Mon2D_p2 == NULL)) { fprintf(stderr,"Monitor_nD: %s 2D cannot allocate %s Vars->Mon2D_N/p/p2 (%zi). Fatal.\n", Vars->compcurname, Vars->Coord_Var[1], (Vars->Coord_Bin[1])*sizeof(double *)); exit(-1); } for (i= 0; i < Vars->Coord_Bin[1]; i++) { Vars->Mon2D_N[i] = (double *)malloc(Vars->Coord_Bin[2]*sizeof(double)); Vars->Mon2D_p[i] = (double *)malloc(Vars->Coord_Bin[2]*sizeof(double)); Vars->Mon2D_p2[i] = (double *)malloc(Vars->Coord_Bin[2]*sizeof(double)); if ((Vars->Mon2D_N == NULL) || (Vars->Mon2D_p == NULL) || (Vars->Mon2D_p2 == NULL)) { fprintf(stderr,"Monitor_nD: %s 2D cannot allocate %s Vars->Mon2D_N/p/p2[%li] (%zi). Fatal.\n", Vars->compcurname, Vars->Coord_Var[1], i, (Vars->Coord_Bin[2])*sizeof(double *)); exit(-1); } else { for (j=0; j < Vars->Coord_Bin[2]; j++ ) { Vars->Mon2D_N[i][j] = (double)0; Vars->Mon2D_p[i][j] = (double)0; Vars->Mon2D_p2[i][j] = (double)0; } } } } else { Vars->Mon2D_N = Vars->Mon2D_p = Vars->Mon2D_p2 = NULL; } /* no Mon2D allocated for * (Vars->Coord_Number != 2) && !Vars->Flag_Multiple && Vars->Flag_List */ Vars->psum = 0; Vars->p2sum = 0; Vars->Nsum = 0; Vars->area = fabs(Vars->mxmax - Vars->mxmin)*fabs(Vars->mymax - Vars->mymin)*1E4; /* in cm**2 for square and box shapes */ Vars->Sphere_Radius = fabs(Vars->mxmax - Vars->mxmin)/2; if ((abs(Vars->Flag_Shape) == DEFS->SHAPE_DISK) || (abs(Vars->Flag_Shape) == DEFS->SHAPE_SPHERE)) { Vars->area = PI*Vars->Sphere_Radius*Vars->Sphere_Radius*1E4; /* disk shapes */ } if (Vars->area == 0 && abs(Vars->Flag_Shape) != DEFS->SHAPE_PREVIOUS ) { if (abs(Vars->Flag_Shape) != DEFS->SHAPE_OFF) { Vars->Coord_Number = 0; } } if (Vars->Coord_Number == 0 && Vars->Flag_Verbose) printf("Monitor_nD: %s is inactivated (0D)\n", Vars->compcurname); Vars->Cylinder_Height = fabs(Vars->mymax - Vars->mymin); if (Vars->Flag_Verbose) { printf("Monitor_nD: %s is a %s.\n", Vars->compcurname, Vars->Monitor_Label); printf("Monitor_nD: version %s with options=%s\n", MONITOR_ND_LIB_H, Vars->option); } /* compute the product of bin dimensions for PixelID */ Vars->Coord_BinProd[0]=1; for (i = 1; i <= Vars->Coord_Number; i++) { Vars->Coord_BinProd[i]=Vars->Coord_Bin[i]*Vars->Coord_BinProd[i-1]; } #ifdef USE_NEXUS #ifdef USE_MPI if(mpi_node_rank == mpi_node_root) { #endif if(nxhandle) { /* This section of code writes detector shape information to entryN/instrument/components/'name'/geometry in the NeXus file */ char nexuscomp[CHAR_BUF_LENGTH]; char pref[5]; if (Vars->compcurindex-1 < 10) { sprintf(pref,"000"); } else if (Vars->compcurindex-1 < 100) { sprintf(pref,"00"); } else if (Vars->compcurindex-1 < 1000) { sprintf(pref,"0"); } else if (Vars->compcurindex-1 < 10000) { sprintf(pref,""); } else { fprintf(stderr,"Error, no support for > 10000 comps at the moment!\n"); exit(-1); } sprintf(nexuscomp,"%s%d_%s",pref,Vars->compcurindex-1,Vars->compcurname); if (NXopengroup(nxhandle, "instrument", "NXinstrument") == NX_OK) { if (NXopengroup(nxhandle, "components", "NXdata") == NX_OK) { if (NXopengroup(nxhandle, nexuscomp, "NXdata") == NX_OK) { if (NXmakegroup(nxhandle, "Geometry", "NXdata") == NX_OK) { if (NXopengroup(nxhandle, "Geometry", "NXdata") == NX_OK) { char tmp[CHAR_BUF_LENGTH]; sprintf(tmp,"%g",Vars->Sphere_Radius); nxprintattr(nxhandle, "radius", tmp); sprintf(tmp,"%g",Vars->Cylinder_Height); nxprintattr(nxhandle, "height", tmp); sprintf(tmp,"%g",Vars->mxmin); nxprintattr(nxhandle, "xmin", tmp); sprintf(tmp,"%g",Vars->mxmax); nxprintattr(nxhandle, "xmax", tmp); sprintf(tmp,"%g",Vars->mymin); nxprintattr(nxhandle, "ymin", tmp); sprintf(tmp,"%g",Vars->mymax); nxprintattr(nxhandle, "ymax", tmp); sprintf(tmp,"%g",Vars->mzmin); nxprintattr(nxhandle, "zmin", tmp); sprintf(tmp,"%g",Vars->mzmax); nxprintattr(nxhandle, "zmax", tmp); sprintf(tmp,"%g",Vars->mzmin); nxprintattr(nxhandle, "zmin", tmp); sprintf(tmp,"%g",Vars->mzmax); nxprintattr(nxhandle, "zmax", tmp); sprintf(tmp,"%i",Vars->Flag_Shape); nxprintattr(nxhandle, "Shape identifier", tmp); sprintf(tmp,"%s",Vars->Monitor_Label); nxprintattr(nxhandle, "Shape string", tmp); sprintf(tmp,"%s",Vars->option); nxprintattr(nxhandle, "Option string", tmp); NXclosegroup(nxhandle); // Geometry } else { printf("Failed to open component NeXus component Geometry group\n"); } } else { printf("Failed to create component NeXus component Geometry group\n"); } NXclosegroup(nxhandle); // component } NXclosegroup(nxhandle); // components } else { printf("Failed to open NeXus component hierarchy\n"); } NXclosegroup(nxhandle); // instrument } if (Vars->Flag_nexusbins) { /* Below code communicates geometry-oriented "BINS" for the detector. */ char metadata[CHAR_BUF_LENGTH]; char metadatatmp[CHAR_BUF_LENGTH]; // Vars for 1D, >3D, OFF long numbins; long minbins = 0; long maxbins = 0; char binlabel[CHAR_BUF_LENGTH]; char binvar[CHAR_BUF_LENGTH]; sprintf(binlabel,"none"); sprintf(binvar,"none"); // Find index of pixel column int id_index; for (id_index=0;id_index<30;id_index++) { if (strcmp(Vars->Coord_Var[id_index], "id") == 0) break; } if (id_index == 30) id_index = Vars->Coord_Number-1; // Revert to earlier behavior is id not found long pix=Vars->Coord_Min[id_index]; MCDETECTOR detector; /* Init - perhaps better with an init-function in mccode-r? */ detector.m = 0; detector.xmin = 0; detector.xmax = 0; detector.ymin = 0; detector.ymax = 0; detector.zmin = 0; detector.zmax = 0; detector.intensity = 0; detector.error = 0; detector.events = 0; detector.min = 0; detector.max = 0; detector.mean = 0; detector.centerX = 0; detector.halfwidthX = 0; detector.centerY = 0; detector.halfwidthY = 0; detector.rank = 0; detector.istransposed = 0; detector.n = 0; detector.p = 0; detector.date_l = 0; detector.p0 = NULL; detector.p1 = NULL; detector.p2 = NULL; sprintf(detector.ncount,"%s",""); sprintf(detector.xvar,"%s",""); sprintf(detector.xlabel,"%s",""); sprintf(detector.yvar,"%s",""); sprintf(detector.ylabel,"%s",""); sprintf(detector.zvar,"%s",""); sprintf(detector.zvar,"%s",""); sprintf(detector.statistics,"%s","None"); sprintf(detector.variables,"%s","None"); sprintf(detector.signal,"%s","Pixel index"); sprintf(detector.filename,"BINS"); sprintf(detector.component,"%s",Vars->compcurname); sprintf(detector.nexuscomp,"%s%d_%s",pref,Vars->compcurindex-1,detector.component); sprintf(detector.format,"pixels"); if(!Vars->Flag_OFF) { sprintf(metadata,"id=%ld + %ld pixels: ",(long)Vars->Coord_Min[id_index],(long)Vars->Coord_BinProd[Vars->Coord_Number]); for (i=1; iCoord_Label[i],Vars->Coord_Bin[i]); sprintf(metadata,"%s",metadatatmp); } sprintf(metadatatmp,"%s %s (%ld bins)",metadata,Vars->Coord_Label[i],Vars->Coord_Bin[i]); sprintf(metadata,"%s",metadatatmp); numbins = Vars->Coord_BinProd[Vars->Coord_Number]; if (N_spatial_dims==1) { minbins=Vars->Coord_Min[1]; maxbins=Vars->Coord_Max[1]; sprintf(binlabel,"%s",Vars->Coord_Label[1]); sprintf(binvar,"%s",Vars->Coord_Var[1]); } else if (N_spatial_dims>3) { minbins=1; maxbins=Vars->Coord_BinProd[Vars->Coord_Number]; sprintf(binlabel,"More than 3 dimensions"); sprintf(binvar,"wrapped_variables_4plus_dims"); N_spatial_dims=1; } sprintf(detector.xlabel,"%s",binlabel); sprintf(detector.xvar,"%s",binvar); detector.xmin=minbins; detector.xmax=maxbins; } else { numbins = Vars->Flag_OFF; minbins=1; maxbins=Vars->Flag_OFF; sprintf(binlabel,"OFF pixel index"); sprintf(binvar,"OFF"); N_spatial_dims=1; sprintf(detector.xlabel,"%s",binlabel); sprintf(detector.xvar,"%s",binvar); detector.xmin=minbins; detector.xmax=maxbins; } long k,l,m; if (N_spatial_dims==1) { // 1D case or ND detector.m=numbins; detector.n=1; detector.p=1; detector.rank=1; detector.p0=(double *)calloc(numbins, sizeof(double)); detector.p1=(double *)calloc(numbins, sizeof(double)); detector.p2=(double *)calloc(numbins, sizeof(double)); if (Vars->Flag_Verbose) printf("1D case %ld \n",Vars->Coord_Bin[1]); for (k=0; kFlag_Verbose) printf("Assigning pixel no [%ld] = %ld\n",k,pix); detector.p1[k]=pix; pix++; } mcdetector_out_1D_nexus(detector); free(detector.p0); free(detector.p1); free(detector.p2); } else if (N_spatial_dims==2) { // 2D case detector.m=Vars->Coord_Bin[1]; detector.n=Vars->Coord_Bin[2]; detector.p=1; detector.rank=2; sprintf(detector.xlabel,"%s",Vars->Coord_Label[1]); sprintf(detector.xvar,"%s",Vars->Coord_Var[1]); detector.xmin=Vars->Coord_Min[1]; detector.xmax=Vars->Coord_Max[1]; sprintf(detector.ylabel,"%s",Vars->Coord_Label[2]); sprintf(detector.yvar,"%s",Vars->Coord_Var[2]); detector.ymin=Vars->Coord_Min[2]; detector.ymax=Vars->Coord_Max[2]; detector.p0=(double *)calloc(Vars->Coord_BinProd[Vars->Coord_Number], sizeof(double)); detector.p1=(double *)calloc(Vars->Coord_BinProd[Vars->Coord_Number], sizeof(double)); detector.p2=(double *)calloc(Vars->Coord_BinProd[Vars->Coord_Number], sizeof(double)); if (Vars->Flag_Verbose) printf("2D case %ld x %ld \n",Vars->Coord_Bin[1],Vars->Coord_Bin[2]); for (k=0; kCoord_Bin[1]; k++) { for (l=0; lCoord_Bin[2]; l++) { if (Vars->Flag_Verbose) printf("Assigning pixel no [%ld,%ld] = %ld\n",l,k,pix); detector.p1[k*Vars->Coord_Bin[2]+l]=pix; pix++; } } mcdetector_out_2D_nexus(detector); free(detector.p0); free(detector.p1); free(detector.p2); } else if (N_spatial_dims==3) { // 3D case detector.m=Vars->Coord_Bin[1]; detector.n=Vars->Coord_Bin[2]; detector.p=Vars->Coord_Bin[3];; detector.rank=3; sprintf(detector.xlabel,"%s",Vars->Coord_Label[1]); sprintf(detector.xvar,"%s",Vars->Coord_Var[1]); detector.xmin=Vars->Coord_Min[1]; detector.xmax=Vars->Coord_Max[1]; sprintf(detector.ylabel,"%s",Vars->Coord_Label[2]); sprintf(detector.yvar,"%s",Vars->Coord_Var[2]); detector.ymin=Vars->Coord_Min[2]; detector.ymax=Vars->Coord_Max[2]; sprintf(detector.zlabel,"%s",Vars->Coord_Label[3]); sprintf(detector.zvar,"%s",Vars->Coord_Var[3]); detector.zmin=Vars->Coord_Min[3]; detector.zmax=Vars->Coord_Max[3]; detector.p0=(double *)calloc(Vars->Coord_BinProd[Vars->Coord_Number], sizeof(double)); detector.p1=(double *)calloc(Vars->Coord_BinProd[Vars->Coord_Number], sizeof(double)); detector.p2=(double *)calloc(Vars->Coord_BinProd[Vars->Coord_Number], sizeof(double)); if (Vars->Flag_Verbose) printf("3D case %ld x %ld x %ld \n",Vars->Coord_Bin[1],Vars->Coord_Bin[2],Vars->Coord_Bin[3]); for (k=0; kCoord_Bin[1]; k++) { for (l=0; lCoord_Bin[2]; l++) { for (m=0; mCoord_Bin[3]; m++) { if (Vars->Flag_Verbose) printf("Assigning pixel no [%ld,%ld,%ld] = %ld\n",m,l,k,pix); detector.p1[k*Vars->Coord_Bin[2]*Vars->Coord_Bin[3] + l*Vars->Coord_Bin[3] + m]=pix; pix++; } } } mcdetector_out_3D_nexus(detector); free(detector.p0); free(detector.p1); free(detector.p2); } } // Flag_nexusbins active } // nxhandle available #ifdef USE_MPI } // Master only #endif #endif // USE_NEXUS } /* end Monitor_nD_Init */ /* ========================================================================= */ /* Monitor_nD_Trace: this routine is used to monitor one propagating neutron */ /* return values: 0=neutron was absorbed, -1=neutron was outside bounds, 1=neutron was measured*/ /* ========================================================================= */ int Monitor_nD_Trace(MonitornD_Defines_type *DEFS, MonitornD_Variables_type *Vars, _class_particle* _particle) { double XY=0, pp=0; long i =0, j =0; double Coord[MONnD_COORD_NMAX]; long Coord_Index[MONnD_COORD_NMAX]; char While_End =0; long While_Buffer=0; char Set_Vars_Coord_Type = DEFS->COORD_NONE; /* the logic below depends mainly on: Flag_List: 1=store 1 buffer, 2=list all, 3=re-use buffer Flag_Auto_Limits: 0 (no auto limits/list), 1 (store events into Buffer), 2 (re-emit store events) */ /* Vars->Flag_Auto_Limits=1: buffer full, we read the Buffer, and determine min and max bounds */ if ((Vars->Buffer_Counter >= Vars->Buffer_Block) && (Vars->Flag_Auto_Limits == 1) && (Vars->Coord_Number > 0)) { /* auto limits case : get limits in Buffer for each variable */ /* Dim : (Vars->Coord_Number+1)*Vars->Buffer_Block matrix (for p, dp) */ if (Vars->Flag_Verbose) printf("Monitor_nD: %s getting %li Auto Limits from List (%li events) in TRACE.\n", Vars->compcurname, Vars->Coord_Number, Vars->Buffer_Counter); for (i = 1; i <= Vars->Coord_Number; i++) { if (Vars->Coord_Type[i] & DEFS->COORD_AUTO) { Vars->Coord_Min[i] = FLT_MAX; Vars->Coord_Max[i] = -FLT_MAX; for (j = 0; j < Vars->Buffer_Counter; j++) { XY = Vars->Mon2D_Buffer[i+j*(Vars->Coord_Number+1)]; /* scanning variables in Buffer */ if (XY < Vars->Coord_Min[i]) Vars->Coord_Min[i] = XY; if (XY > Vars->Coord_Max[i]) Vars->Coord_Max[i] = XY; } if (Vars->Flag_Verbose) printf(" %s: min=%g max=%g\n", Vars->Coord_Var[i], Vars->Coord_Min[i], Vars->Coord_Max[i]); } } Vars->Flag_Auto_Limits = 2; /* pass to 2nd auto limits step (read Buffer and generate new events to store in histograms) */ } /* end if Flag_Auto_Limits == 1 */ #ifndef OPENACC /* manage realloc for 'list all' if Buffer size exceeded: flush Buffer to file */ if ((Vars->Buffer_Counter >= Vars->Buffer_Block) && (Vars->Flag_List >= 2)) { if (Vars->Buffer_Size >= 1000000 || Vars->Flag_List == 3) { /* save current (possibly append) and re-use Buffer */ Monitor_nD_Save(DEFS, Vars); Vars->Flag_List = 3; Vars->Buffer_Block = Vars->Buffer_Size; Vars->Buffer_Counter = 0; Vars->Neutron_Counter = 0; } else { Vars->Mon2D_Buffer = (double *)realloc(Vars->Mon2D_Buffer, (Vars->Coord_Number+1)*(2*Vars->Buffer_Block)*sizeof(double)); if (Vars->Mon2D_Buffer == NULL) { printf("Monitor_nD: %s cannot reallocate Vars->Mon2D_Buffer[%li] (%zi). Skipping.\n", Vars->compcurname, i, (long int)(2*Vars->Buffer_Block)*sizeof(double)); Vars->Flag_List = 1; } else { Vars->Buffer_Block = 2*Vars->Buffer_Block; Vars->Buffer_Size = Vars->Buffer_Block; } } } /* end if Buffer realloc */ #endif char outsidebounds=0; while (!While_End) { /* we generate Coord[] and Coord_index[] from Buffer (auto limits) or passing neutron */ if ((Vars->Flag_Auto_Limits == 2) && (Vars->Coord_Number > 0)) { /* Vars->Flag_Auto_Limits == 2: read back from Buffer (Buffer is filled or auto limits have been computed) */ if (While_Buffer < Vars->Buffer_Block) { /* first while loop (While_Buffer) */ /* auto limits case : scan Buffer within limits and store in Mon2D */ Coord[0] = pp = Vars->Mon2D_Buffer[While_Buffer*(Vars->Coord_Number+1)]; for (i = 1; i <= Vars->Coord_Number; i++) { /* scanning variables in Buffer */ if (Vars->Coord_Bin[i] <= 1) continue; XY = (Vars->Coord_Max[i]-Vars->Coord_Min[i]); Coord[i] = Vars->Mon2D_Buffer[i+While_Buffer*(Vars->Coord_Number+1)]; if (XY > 0) Coord_Index[i] = floor((Coord[i]-Vars->Coord_Min[i])*Vars->Coord_Bin[i]/XY); else Coord_Index[i] = 0; if (Vars->Flag_With_Borders) { if (Coord_Index[i] < 0) Coord_Index[i] = 0; if (Coord_Index[i] >= Vars->Coord_Bin[i]) Coord_Index[i] = Vars->Coord_Bin[i] - 1; } } /* end for */ /* update the PixelID, we compute it from the previous variables index */ if (Vars->Coord_NumberNoPixel < Vars->Coord_Number) /* there is a Pixel variable */ for (i = 1; i <= Vars->Coord_Number; i++) { char Set_Vars_Coord_Type = (Vars->Coord_Type[i] & (DEFS->COORD_LOG-1)); if (Set_Vars_Coord_Type == DEFS->COORD_PIXELID) { char flag_outside=0; Coord_Index[i] = Coord[i] = 0; for (j= 1; j < i; j++) { /* not for 1D variables with Bin=1 such as PixelID, NCOUNT, Intensity */ if (Vars->Coord_Bin[j] == 1) continue; if (0 > Coord_Index[j] || Coord_Index[j] >= Vars->Coord_Bin[j]) { flag_outside=1; Coord[i] = 0; break; } Coord[i] += Coord_Index[j]*Vars->Coord_BinProd[j-1]; } if (!flag_outside) { Vars->Mon2D_Buffer[i+While_Buffer*(Vars->Coord_Number+1)] = Coord[i]; } } /* end if PixelID */ } While_Buffer++; } /* end if in Buffer */ else /* (While_Buffer >= Vars->Buffer_Block) && (Vars->Flag_Auto_Limits == 2) */ { Vars->Flag_Auto_Limits = 0; if (!Vars->Flag_List) /* free Buffer not needed anymore (no list to output) */ { /* Dim : (Vars->Coord_Number+1)*Vars->Buffer_Block matrix (for p, p2) */ free(Vars->Mon2D_Buffer); Vars->Mon2D_Buffer = NULL; } if (Vars->Flag_Verbose) printf("Monitor_nD: %s flushed %li Auto Limits from List (%li) in TRACE.\n", Vars->compcurname, Vars->Coord_Number, Vars->Buffer_Counter); } } /* if Vars->Flag_Auto_Limits == 2 */ if (Vars->Flag_Auto_Limits != 2 || !Vars->Coord_Number) /* Vars->Flag_Auto_Limits == 0 (no auto limits/list) or 1 (store events into Buffer) */ { /* automatically compute area and steradian solid angle when in AUTO mode */ /* compute the steradian solid angle incoming on the monitor */ double v; double tmp; v=sqrt(_particle->vx*_particle->vx + _particle->vy*_particle->vy + _particle->vz*_particle->vz); tmp=_particle->x; if (Vars->min_x > _particle->x){ #pragma acc atomic write Vars->min_x = tmp; } if (Vars->max_x < _particle->x){ #pragma acc atomic write Vars->max_x = tmp; } tmp=_particle->y; if (Vars->min_y > _particle->y){ #pragma acc atomic write Vars->min_y = tmp; } if (Vars->max_y < _particle->y){ tmp=_particle->y; #pragma acc atomic write Vars->max_y = tmp; } #pragma acc atomic Vars->mean_p = Vars->mean_p + _particle->p; if (v) { tmp=_particle->p*fabs(_particle->vx/v); #pragma acc atomic Vars->mean_dx = Vars->mean_dx + tmp; //_particle->p*fabs(_particle->vx/v); tmp=_particle->p*fabs(_particle->vy/v); #pragma acc atomic Vars->mean_dy = Vars->mean_dy + tmp; //_particle->p*fabs(_particle->vy/v); } for (i = 0; i <= Vars->Coord_Number; i++) { /* handle current neutron : last while */ XY = 0; Set_Vars_Coord_Type = (Vars->Coord_Type[i] & (DEFS->COORD_LOG-1)); /* get values for variables to monitor */ if (Set_Vars_Coord_Type == DEFS->COORD_X) XY = _particle->x; else if (Set_Vars_Coord_Type == DEFS->COORD_Y) XY = _particle->y; else if (Set_Vars_Coord_Type == DEFS->COORD_Z) XY = _particle->z; else if (Set_Vars_Coord_Type == DEFS->COORD_VX) XY = _particle->vx; else if (Set_Vars_Coord_Type == DEFS->COORD_VY) XY = _particle->vy; else if (Set_Vars_Coord_Type == DEFS->COORD_VZ) XY = _particle->vz; else if (Set_Vars_Coord_Type == DEFS->COORD_KX) XY = V2K*_particle->vx; else if (Set_Vars_Coord_Type == DEFS->COORD_KY) XY = V2K*_particle->vy; else if (Set_Vars_Coord_Type == DEFS->COORD_KZ) XY = V2K*_particle->vz; else if (Set_Vars_Coord_Type == DEFS->COORD_SX) XY = _particle->sx; else if (Set_Vars_Coord_Type == DEFS->COORD_SY) XY = _particle->sy; else if (Set_Vars_Coord_Type == DEFS->COORD_SZ) XY = _particle->sz; else if (Set_Vars_Coord_Type == DEFS->COORD_T) XY = _particle->t; else if (Set_Vars_Coord_Type == DEFS->COORD_P) XY = _particle->p; else if (Set_Vars_Coord_Type == DEFS->COORD_USERDOUBLE0) XY = Vars->UserDoubles[0]; else if (Set_Vars_Coord_Type == DEFS->COORD_USERDOUBLE1) XY = Vars->UserDoubles[1]; else if (Set_Vars_Coord_Type == DEFS->COORD_USERDOUBLE2) XY = Vars->UserDoubles[2]; else if (Set_Vars_Coord_Type == DEFS->COORD_USERDOUBLE3) XY = Vars->UserDoubles[3]; else if (Set_Vars_Coord_Type == DEFS->COORD_USERDOUBLE4) XY = Vars->UserDoubles[4]; else if (Set_Vars_Coord_Type == DEFS->COORD_USERDOUBLE5) XY = Vars->UserDoubles[5]; else if (Set_Vars_Coord_Type == DEFS->COORD_USERDOUBLE6) XY = Vars->UserDoubles[6]; else if (Set_Vars_Coord_Type == DEFS->COORD_USERDOUBLE7) XY = Vars->UserDoubles[7]; else if (Set_Vars_Coord_Type == DEFS->COORD_USERDOUBLE8) XY = Vars->UserDoubles[8]; else if (Set_Vars_Coord_Type == DEFS->COORD_USERDOUBLE9) XY = Vars->UserDoubles[9]; else if (Set_Vars_Coord_Type == DEFS->COORD_USERDOUBLE10) XY = Vars->UserDoubles[10]; else if (Set_Vars_Coord_Type == DEFS->COORD_USERDOUBLE11) XY = Vars->UserDoubles[11]; else if (Set_Vars_Coord_Type == DEFS->COORD_USERDOUBLE12) XY = Vars->UserDoubles[12]; else if (Set_Vars_Coord_Type == DEFS->COORD_USERDOUBLE13) XY = Vars->UserDoubles[13]; else if (Set_Vars_Coord_Type == DEFS->COORD_USERDOUBLE14) XY = Vars->UserDoubles[14]; else if (Set_Vars_Coord_Type == DEFS->COORD_USERDOUBLE15) XY = Vars->UserDoubles[15]; else if (Set_Vars_Coord_Type == DEFS->COORD_HDIV) XY = RAD2DEG*atan2(_particle->vx,_particle->vz); else if (Set_Vars_Coord_Type == DEFS->COORD_VDIV) XY = RAD2DEG*atan2(_particle->vy,_particle->vz); else if (Set_Vars_Coord_Type == DEFS->COORD_V) XY = sqrt(_particle->vx*_particle->vx+_particle->vy*_particle->vy+_particle->vz*_particle->vz); else if (Set_Vars_Coord_Type == DEFS->COORD_RADIUS) XY = sqrt(_particle->x*_particle->x+_particle->y*_particle->y+_particle->z*_particle->z); else if (Set_Vars_Coord_Type == DEFS->COORD_XY) XY = sqrt(_particle->x*_particle->x+_particle->y*_particle->y)*(_particle->x > 0 ? 1 : -1); else if (Set_Vars_Coord_Type == DEFS->COORD_YZ) XY = sqrt(_particle->y*_particle->y+_particle->z*_particle->z); else if (Set_Vars_Coord_Type == DEFS->COORD_XZ) XY = sqrt(_particle->x*_particle->x+_particle->z*_particle->z); else if (Set_Vars_Coord_Type == DEFS->COORD_VXY) XY = sqrt(_particle->vx*_particle->vx+_particle->vy*_particle->vy); else if (Set_Vars_Coord_Type == DEFS->COORD_VXZ) XY = sqrt(_particle->vx*_particle->vx+_particle->vz*_particle->vz); else if (Set_Vars_Coord_Type == DEFS->COORD_VYZ) XY = sqrt(_particle->vy*_particle->vy+_particle->vz*_particle->vz); else if (Set_Vars_Coord_Type == DEFS->COORD_K) { XY = sqrt(_particle->vx*_particle->vx+_particle->vy*_particle->vy+_particle->vz*_particle->vz); XY *= V2K; } else if (Set_Vars_Coord_Type == DEFS->COORD_KXY) { XY = sqrt(_particle->vx*_particle->vx+_particle->vy*_particle->vy); XY *= V2K; } else if (Set_Vars_Coord_Type == DEFS->COORD_KXZ) { XY = sqrt(_particle->vx*_particle->vx+_particle->vz*_particle->vz); XY *= V2K; } else if (Set_Vars_Coord_Type == DEFS->COORD_KYZ) { XY = sqrt(_particle->vy*_particle->vy+_particle->vz*_particle->vz); XY *= V2K; } else if (Set_Vars_Coord_Type == DEFS->COORD_ENERGY) { XY = _particle->vx*_particle->vx+_particle->vy*_particle->vy+_particle->vz*_particle->vz; XY *= VS2E; } else if (Set_Vars_Coord_Type == DEFS->COORD_LAMBDA) { XY = sqrt(_particle->vx*_particle->vx+_particle->vy*_particle->vy+_particle->vz*_particle->vz); XY *= V2K; if (XY != 0) XY = 2*PI/XY; } else if (Set_Vars_Coord_Type == DEFS->COORD_NCOUNT) XY = _particle->_uid; else if (Set_Vars_Coord_Type == DEFS->COORD_ANGLE) { XY = sqrt(_particle->vx*_particle->vx+_particle->vy*_particle->vy); if (_particle->vz != 0) XY = RAD2DEG*atan2(XY,_particle->vz)*(_particle->x > 0 ? 1 : -1); else XY = 0; } else if (Set_Vars_Coord_Type == DEFS->COORD_THETA) { if (_particle->z != 0) XY = RAD2DEG*atan2(_particle->x,_particle->z); } else if (Set_Vars_Coord_Type == DEFS->COORD_PHI) { double rr=sqrt(_particle->x*_particle->x+ _particle->y*_particle->y + _particle->z*_particle->z); if (rr != 0) XY = RAD2DEG*asin(_particle->y/rr); } else if (Set_Vars_Coord_Type == DEFS->COORD_USER0) {int fail; XY = particle_getvar(_particle,Vars->UserVariable0,&fail); if(fail) XY=0; } else if (Set_Vars_Coord_Type == DEFS->COORD_USER1) {int fail; XY = particle_getvar(_particle,Vars->UserVariable1,&fail); if(fail) XY=0; } else if (Set_Vars_Coord_Type == DEFS->COORD_USER2) {int fail; XY = particle_getvar(_particle,Vars->UserVariable2,&fail); if(fail) XY=0; } else if (Set_Vars_Coord_Type == DEFS->COORD_USER3) {int fail; XY = particle_getvar(_particle,Vars->UserVariable3,&fail); if(fail) XY=0; } else if (Set_Vars_Coord_Type == DEFS->COORD_USER4) {int fail; XY = particle_getvar(_particle,Vars->UserVariable4,&fail); if(fail) XY=0; } else if (Set_Vars_Coord_Type == DEFS->COORD_USER5) {int fail; XY = particle_getvar(_particle,Vars->UserVariable5,&fail); if(fail) XY=0; } else if (Set_Vars_Coord_Type == DEFS->COORD_USER6) {int fail; XY = particle_getvar(_particle,Vars->UserVariable6,&fail); if(fail) XY=0; } else if (Set_Vars_Coord_Type == DEFS->COORD_USER7) {int fail; XY = particle_getvar(_particle,Vars->UserVariable7,&fail); if(fail) XY=0; } else if (Set_Vars_Coord_Type == DEFS->COORD_USER8) {int fail; XY = particle_getvar(_particle,Vars->UserVariable8,&fail); if(fail) XY=0; } else if (Set_Vars_Coord_Type == DEFS->COORD_USER9) {int fail; XY = particle_getvar(_particle,Vars->UserVariable9,&fail); if(fail) XY=0; } else if (Set_Vars_Coord_Type == DEFS->COORD_PIXELID && !Vars->Flag_Auto_Limits) { /* compute the PixelID from previous coordinates the PixelID is the product of Coord_Index[i] in the detector geometry pixelID = sum( Coord_Index[j]*prod(Vars->Coord_Bin[1:(j-1)]) ) this does not apply when we store events in the buffer as Coord_Index is not set. Then the pixelID will be re-computed during SAVE. */ char flag_outside=0; for (j= 1; j < i; j++) { /* not for 1D variables with Bin=1 such as PixelID, NCOUNT, Intensity */ if (Vars->Coord_Bin[j] <= 1) continue; if (0 > Coord_Index[j] || Coord_Index[j] >= Vars->Coord_Bin[j]) { flag_outside=1; XY=0; break; } XY += Coord_Index[j]*Vars->Coord_BinProd[j-1]; } if (Vars->Flag_mantid && Vars->Flag_OFF && Vars->OFF_polyidx >=0) XY=Vars->OFF_polyidx; if (!flag_outside) XY += Vars->Coord_Min[i]; } /* handle 'abs' and 'log' keywords */ if (Vars->Coord_Type[i] & DEFS->COORD_ABS) XY=fabs(XY); if (Vars->Coord_Type[i] & DEFS->COORD_LOG) /* compute log of variable if requested */ { if (XY > 0) XY = log(XY)/log(10); else XY = -100; } Coord[i] = XY; Coord_Index[i] = 0; if (i == 0) { pp = XY; Coord_Index[i] = 0; } else { /* check bounds for variables which have no automatic limits */ if ((!Vars->Flag_Auto_Limits || !(Vars->Coord_Type[i] & DEFS->COORD_AUTO)) && Vars->Coord_Bin[i]>1) { /* compute index in histograms for each variable to monitor */ XY = (Vars->Coord_Max[i]-Vars->Coord_Min[i]); if (XY > 0) Coord_Index[i] = floor((Coord[i]-Vars->Coord_Min[i])*Vars->Coord_Bin[i]/XY); if (Vars->Flag_With_Borders) { if (Coord_Index[i] >= Vars->Coord_Bin[i]) Coord_Index[i] = Vars->Coord_Bin[i] - 1; if (Coord_Index[i] < 0) Coord_Index[i] = 0; } //if (0 > Coord_Index[i] || Coord_Index[i] >= Vars->Coord_Bin[i]) // outsidebounds=1; } /* else will get Index later from Buffer when Flag_Auto_Limits == 2 */ } } /* end for i */ While_End = 1; }/* end else if Vars->Flag_Auto_Limits == 2 */ /* ====================================================================== */ /* store n1d/2d neutron from Buffer (Auto_Limits == 2) or current neutron in while */ if (Vars->Flag_Auto_Limits != 1) /* not when storing auto limits Buffer */ { /* apply per cm2 */ if (Vars->Flag_per_cm2 && Vars->area != 0) pp /= Vars->area; /* 2D case : Vars->Coord_Number==2 and !Vars->Flag_Multiple and !Vars->Flag_List */ if ( Vars->Coord_NumberNoPixel == 2 && !Vars->Flag_Multiple) { /* Dim : Vars->Coord_Bin[1]*Vars->Coord_Bin[2] matrix */ i = Coord_Index[1]; j = Coord_Index[2]; if (i >= 0 && i < Vars->Coord_Bin[1] && j >= 0 && j < Vars->Coord_Bin[2]) { if (Vars->Mon2D_N) { double p2 = pp*pp; #pragma acc atomic Vars->Mon2D_N[i][j] = Vars->Mon2D_N[i][j]+1; #pragma acc atomic Vars->Mon2D_p[i][j] = Vars->Mon2D_p[i][j]+pp; #pragma acc atomic Vars->Mon2D_p2[i][j] = Vars->Mon2D_p2[i][j] + p2; } } else { outsidebounds=1; } } else { /* 1D and n1D case : Vars->Flag_Multiple */ /* Dim : Vars->Coord_Number*Vars->Coord_Bin[i] vectors (intensity is not included) */ for (i= 1; i <= Vars->Coord_Number; i++) { j = Coord_Index[i]; if (j >= 0 && j < Vars->Coord_Bin[i]) { if (Vars->Flag_Multiple && Vars->Mon2D_N) { if (Vars->Mon2D_N) { double p2 = pp*pp; #pragma acc atomic Vars->Mon2D_N[i-1][j] = Vars->Mon2D_N[i-1][j]+1; #pragma acc atomic Vars->Mon2D_p[i-1][j] = Vars->Mon2D_p[i-1][j]+pp; #pragma acc atomic Vars->Mon2D_p2[i-1][j] = Vars->Mon2D_p2[i-1][j] + p2; } } } else { outsidebounds=1; break; } } } } /* end (Vars->Flag_Auto_Limits != 1) */ if (Vars->Flag_Auto_Limits != 2 && !outsidebounds) /* not when reading auto limits Buffer */ { /* now store Coord into Buffer (no index needed) if necessary (list or auto limits) */ if ((Vars->Buffer_Counter < Vars->Buffer_Block) && ((Vars->Flag_List) || (Vars->Flag_Auto_Limits == 1))) { for (i = 0; i <= Vars->Coord_Number; i++) { // This is is where the list is appended. How to make this "atomic"? #pragma acc atomic write Vars->Mon2D_Buffer[i + Vars->Buffer_Counter*(Vars->Coord_Number+1)] = Coord[i]; } #pragma acc atomic update Vars->Buffer_Counter = Vars->Buffer_Counter + 1; if (Vars->Flag_Verbose && (Vars->Buffer_Counter >= Vars->Buffer_Block) && (Vars->Flag_List == 1)) printf("Monitor_nD: %s %li neutrons stored in List.\n", Vars->compcurname, Vars->Buffer_Counter); } } /* end (Vars->Flag_Auto_Limits != 2) */ } /* end while */ #pragma acc atomic Vars->Nsum = Vars->Nsum + 1; #pragma acc atomic Vars->psum = Vars->psum + pp; #pragma acc atomic Vars->p2sum = Vars->p2sum + pp*pp; /*determine return value: 1:neutron was in bounds and measured, -1: outside bounds, 0: outside bounds, should be absorbed.*/ if(outsidebounds){ if(Vars->Flag_Absorb){ return 0; }else{ return -1; } } else { /* For the OPENACC list buffer an atomic capture/update of the updated Neutron_counter - updated below under list mode Only need to be updated when inside bounds. */ #pragma acc atomic update Vars->Neutron_Counter++; } return 1; } /* end Monitor_nD_Trace */ /* ========================================================================= */ /* Monitor_nD_Save: this routine is used to save data files */ /* ========================================================================= */ MCDETECTOR Monitor_nD_Save(MonitornD_Defines_type *DEFS, MonitornD_Variables_type *Vars) { char *fname; long i,j; double *p0m = NULL; double *p1m = NULL; double *p2m = NULL; char Coord_X_Label[CHAR_BUF_LENGTH]; double min1d, max1d; double min2d, max2d; char While_End = 0; long While_Buffer = 0; double XY=0, pp=0; double Coord[MONnD_COORD_NMAX]; long Coord_Index[MONnD_COORD_NMAX]; char label[CHAR_BUF_LENGTH]; MCDETECTOR detector; strcpy(detector.options,Vars->option); if (Vars->Flag_Verbose && Vars->Flag_per_cm2) { printf("Monitor_nD: %s: active flat detector area is %g [cm^2], total area is %g [cm^2]\n", Vars->compcurname, (Vars->max_x-Vars->min_x) *(Vars->max_y-Vars->min_y)*1E4, Vars->area); printf("Monitor_nD: %s: beam solid angle is %g [st] (%g x %g [deg^2])\n", Vars->compcurname, 2*fabs(2*atan2(Vars->mean_dx,Vars->mean_p) *sin(2*atan2(Vars->mean_dy,Vars->mean_p)/2)), atan2(Vars->mean_dx,Vars->mean_p)*RAD2DEG, atan2(Vars->mean_dy,Vars->mean_p)*RAD2DEG); } /* check Buffer flush when end of simulation reached */ if ((Vars->Buffer_Counter <= Vars->Buffer_Block) && Vars->Flag_Auto_Limits && Vars->Mon2D_Buffer && Vars->Buffer_Counter) { /* Get Auto Limits */ if (Vars->Flag_Verbose) printf("Monitor_nD: %s getting %li Auto Limits from List (%li events).\n", Vars->compcurname, Vars->Coord_Number, Vars->Buffer_Counter); for (i = 1; i <= Vars->Coord_Number; i++) { if ((Vars->Coord_Type[i] & DEFS->COORD_AUTO) && Vars->Coord_Bin[i] > 1) { Vars->Coord_Min[i] = FLT_MAX; Vars->Coord_Max[i] = -FLT_MAX; for (j = 0; j < Vars->Buffer_Counter; j++) { XY = Vars->Mon2D_Buffer[i+j*(Vars->Coord_Number+1)]; /* scanning variables in Buffer */ if (XY < Vars->Coord_Min[i]) Vars->Coord_Min[i] = XY; if (XY > Vars->Coord_Max[i]) Vars->Coord_Max[i] = XY; } if (Vars->Flag_Verbose) printf(" %s: min=%g max=%g in %li bins\n", Vars->Coord_Var[i], Vars->Coord_Min[i], Vars->Coord_Max[i], Vars->Coord_Bin[i]); } } Vars->Flag_Auto_Limits = 2; /* pass to 2nd auto limits step */ Vars->Buffer_Block = Vars->Buffer_Counter; while (!While_End) { /* we generate Coord[] and Coord_index[] from Buffer (auto limits) */ /* simulation ended before Buffer was filled. Limits have to be computed, and stored events must be sent into histograms */ if (While_Buffer < Vars->Buffer_Block) { /* first while loops (While_Buffer) */ Coord[0] = Vars->Mon2D_Buffer[While_Buffer*(Vars->Coord_Number+1)]; /* auto limits case : scan Buffer within limits and store in Mon2D */ for (i = 1; i <= Vars->Coord_Number; i++) { /* scanning variables in Buffer */ if (Vars->Coord_Bin[i] <= 1) Coord_Index[i] = 0; else { XY = (Vars->Coord_Max[i]-Vars->Coord_Min[i]); Coord[i] = Vars->Mon2D_Buffer[i+While_Buffer*(Vars->Coord_Number+1)]; if (XY > 0) Coord_Index[i] = floor((Coord[i]-Vars->Coord_Min[i])*Vars->Coord_Bin[i]/XY); else Coord_Index[i] = 0; if (Vars->Flag_With_Borders) { if (Coord_Index[i] < 0) Coord_Index[i] = 0; if (Coord_Index[i] >= Vars->Coord_Bin[i]) Coord_Index[i] = Vars->Coord_Bin[i] - 1; } } } /* end for */ /* update the PixelID, we compute it from the previous variables index */ for (i = 1; i <= Vars->Coord_Number; i++) { char Set_Vars_Coord_Type = (Vars->Coord_Type[i] & (DEFS->COORD_LOG-1)); if (Set_Vars_Coord_Type == DEFS->COORD_PIXELID) { char outsidebounds=0; Coord_Index[i] = Coord[i] = 0; for (j= 1; j < i; j++) { /* not for 1D variables with Bin=1 such as PixelID, NCOUNT, Intensity */ if (Vars->Coord_Bin[j] == 1) continue; if (0 > Coord_Index[j] || Coord_Index[j] >= Vars->Coord_Bin[j]) { outsidebounds=1; Coord[i] = 0; break; } Coord[i] += Coord_Index[j]*Vars->Coord_BinProd[j-1]; } if (!outsidebounds) { Vars->Mon2D_Buffer[i+While_Buffer*(Vars->Coord_Number+1)] = Coord[i]; } } /* end if PixelID */ } While_Buffer++; } /* end if in Buffer */ else /* (While_Buffer >= Vars->Buffer_Block) && (Vars->Flag_Auto_Limits == 2) */ { Vars->Flag_Auto_Limits = 0; While_End = 1; if (Vars->Flag_Verbose) printf("Monitor_nD: %s flushed %li Auto Limits from List (%li).\n", Vars->compcurname, Vars->Coord_Number, Vars->Buffer_Counter); } /* store n1d/2d section from Buffer */ pp = Coord[0]; /* apply per cm2 or per st */ if (Vars->Flag_per_cm2 && Vars->area != 0) pp /= Vars->area; /* 2D case : Vars->Coord_Number==2 and !Vars->Flag_Multiple and !Vars->Flag_List */ if (!Vars->Flag_Multiple && Vars->Coord_NumberNoPixel == 2) { /* Dim : Vars->Coord_Bin[1]*Vars->Coord_Bin[2] matrix */ i = Coord_Index[1]; j = Coord_Index[2]; if (i >= 0 && i < Vars->Coord_Bin[1] && j >= 0 && j < Vars->Coord_Bin[2]) { if (Vars->Mon2D_N) { Vars->Mon2D_N[i][j]++; Vars->Mon2D_p[i][j] += pp; Vars->Mon2D_p2[i][j] += pp*pp; } } else if (Vars->Flag_Absorb) pp=0; } else /* 1D and n1D case : Vars->Flag_Multiple */ { /* Dim : Vars->Coord_Number*Vars->Coord_Bin[i] vectors (intensity is not included) */ for (i= 1; i <= Vars->Coord_Number; i++) { j = Coord_Index[i]; if (j >= 0 && j < Vars->Coord_Bin[i]) { if (Vars->Flag_Multiple && Vars->Mon2D_N) { Vars->Mon2D_N[i-1][j]++; Vars->Mon2D_p[i-1][j] += pp; Vars->Mon2D_p2[i-1][j] += pp*pp; } } else if (Vars->Flag_Absorb) { pp=0; break; } } } /* end store 2D/1D */ } /* end while */ } /* end Force Get Limits */ /* write output files (sent to file as p[i*n + j] vectors) */ if (Vars->Coord_Number == 0) { double Nsum; double psum, p2sum; Nsum = Vars->Nsum; psum = Vars->psum; p2sum= Vars->p2sum; if (Vars->Flag_signal != DEFS->COORD_P && Nsum > 0) { psum /=Nsum; p2sum /= Nsum*Nsum; } /* DETECTOR_OUT_0D(Vars->Monitor_Label, Vars->Nsum, Vars->psum, Vars->p2sum); */ detector = mcdetector_out_0D(Vars->Monitor_Label, Nsum, psum, p2sum, Vars->compcurname, Vars->compcurpos, Vars->compcurrot,Vars->compcurindex); } else if (strlen(Vars->Mon_File) > 0) { fname = (char*)malloc(strlen(Vars->Mon_File)+10*Vars->Coord_Number); if (Vars->Flag_List && Vars->Mon2D_Buffer) /* List: DETECTOR_OUT_2D */ { if (Vars->Flag_List >= 2) Vars->Buffer_Size = Vars->Neutron_Counter; if (Vars->Buffer_Size >= Vars->Neutron_Counter) Vars->Buffer_Size = Vars->Neutron_Counter; strcpy(fname,Vars->Mon_File); if (strchr(Vars->Mon_File,'.') == NULL) strcat(fname, "_list"); strcpy(Coord_X_Label,""); for (i= 0; i <= Vars->Coord_Number; i++) { strcat(Coord_X_Label, Vars->Coord_Var[i]); strcat(Coord_X_Label, " "); if (strchr(Vars->Mon_File,'.') == NULL) { strcat(fname, "."); strcat(fname, Vars->Coord_Var[i]); } } if (Vars->Flag_Verbose) printf("Monitor_nD: %s write monitor file %s List (%lix%li).\n", Vars->compcurname, fname,(long int)Vars->Neutron_Counter,Vars->Coord_Number); /* handle the type of list output */ strcpy(label, Vars->Monitor_Label); detector = mcdetector_out_list( label, "List of neutron events", Coord_X_Label, -Vars->Buffer_Size, Vars->Coord_Number+1, Vars->Mon2D_Buffer, fname, Vars->compcurname, Vars->compcurpos, Vars->compcurrot, Vars->option,Vars->compcurindex); } if (Vars->Flag_Multiple) /* n1D: DETECTOR_OUT_1D */ { for (i= 0; i < Vars->Coord_Number; i++) { strcpy(fname,Vars->Mon_File); if (strchr(Vars->Mon_File,'.') == NULL) { strcat(fname, "."); strcat(fname, Vars->Coord_Var[i+1]); } sprintf(Coord_X_Label, "%s monitor", Vars->Coord_Label[i+1]); strcpy(label, Coord_X_Label); if (Vars->Coord_Bin[i+1] > 0) { /* 1D monitor */ if (Vars->Flag_Verbose) printf("Monitor_nD: %s write monitor file %s 1D (%li).\n", Vars->compcurname, fname, Vars->Coord_Bin[i+1]); min1d = Vars->Coord_Min[i+1]; max1d = Vars->Coord_Max[i+1]; if (min1d == max1d) max1d = min1d+1e-6; p1m = (double *)malloc(Vars->Coord_Bin[i+1]*sizeof(double)); p2m = (double *)malloc(Vars->Coord_Bin[i+1]*sizeof(double)); if (p2m == NULL) /* use Raw Buffer line output */ { if (Vars->Flag_Verbose) printf("Monitor_nD: %s cannot allocate memory for output. Using raw data.\n", Vars->compcurname); if (p1m != NULL) free(p1m); detector = mcdetector_out_1D( label, Vars->Coord_Label[i+1], Vars->Coord_Label[0], Vars->Coord_Var[i+1], min1d, max1d, Vars->Coord_Bin[i+1], Vars->Mon2D_N[i],Vars->Mon2D_p[i],Vars->Mon2D_p2[i], fname, Vars->compcurname, Vars->compcurpos, Vars->compcurrot,Vars->compcurindex); } /* if (p2m == NULL) */ else { if (Vars->Flag_log != 0) { XY = FLT_MAX; for (j=0; j < Vars->Coord_Bin[i+1]; j++) /* search min of signal */ if ((XY > Vars->Mon2D_p[i][j]) && (Vars->Mon2D_p[i][j] > 0)) XY = Vars->Mon2D_p[i][j]; if (XY <= 0) XY = -log(FLT_MAX)/log(10); else XY = log(XY)/log(10)-1; } /* if */ for (j=0; j < Vars->Coord_Bin[i+1]; j++) { p1m[j] = Vars->Mon2D_p[i][j]; p2m[j] = Vars->Mon2D_p2[i][j]; if (Vars->Flag_signal != DEFS->COORD_P && Vars->Mon2D_N[i][j] > 0) { /* normalize mean signal to the number of events */ p1m[j] /= Vars->Mon2D_N[i][j]; p2m[j] /= Vars->Mon2D_N[i][j]*Vars->Mon2D_N[i][j]; } if (Vars->Flag_log != 0) { if ((p1m[j] > 0) && (p2m[j] > 0)) { p2m[j] /= p1m[j]*p1m[j]; p1m[j] = log(p1m[j])/log(10); } else { p1m[j] = XY; p2m[j] = 0; } } } /* for */ detector = mcdetector_out_1D( label, Vars->Coord_Label[i+1], Vars->Coord_Label[0], Vars->Coord_Var[i+1], min1d, max1d, Vars->Coord_Bin[i+1], Vars->Mon2D_N[i],p1m,p2m, fname, Vars->compcurname, Vars->compcurpos, Vars->compcurrot,Vars->compcurindex); } /* else */ /* comment out 'free memory' lines to avoid loosing arrays if 'detector' structure is used by other instrument parts if (p1m != NULL) free(p1m); p1m=NULL; if (p2m != NULL) free(p2m); p2m=NULL; */ } else { /* 0d monitor */ detector = mcdetector_out_0D(label, Vars->Mon2D_p[i][0], Vars->Mon2D_p2[i][0], Vars->Mon2D_N[i][0], Vars->compcurname, Vars->compcurpos, Vars->compcurrot,Vars->compcurindex); } } /* for */ } /* if 1D */ else if (Vars->Coord_NumberNoPixel == 2) /* 2D: DETECTOR_OUT_2D */ { strcpy(fname,Vars->Mon_File); p0m = (double *)malloc(Vars->Coord_Bin[1]*Vars->Coord_Bin[2]*sizeof(double)); p1m = (double *)malloc(Vars->Coord_Bin[1]*Vars->Coord_Bin[2]*sizeof(double)); p2m = (double *)malloc(Vars->Coord_Bin[1]*Vars->Coord_Bin[2]*sizeof(double)); if (p2m == NULL) { if (Vars->Flag_Verbose) printf("Monitor_nD: %s cannot allocate memory for 2D array (%zi). Skipping.\n", Vars->compcurname, 3*Vars->Coord_Bin[1]*Vars->Coord_Bin[2]*sizeof(double)); /* comment out 'free memory' lines to avoid loosing arrays if 'detector' structure is used by other instrument parts if (p0m != NULL) free(p0m); if (p1m != NULL) free(p1m); */ } else { if (Vars->Flag_log != 0) { XY = FLT_MAX; for (i= 0; i < Vars->Coord_Bin[1]; i++) for (j= 0; j < Vars->Coord_Bin[2]; j++) /* search min of signal */ if ((XY > Vars->Mon2D_p[i][j]) && (Vars->Mon2D_p[i][j]>0)) XY = Vars->Mon2D_p[i][j]; if (XY <= 0) XY = -log(FLT_MAX)/log(10); else XY = log(XY)/log(10)-1; } for (i= 0; i < Vars->Coord_Bin[1]; i++) { for (j= 0; j < Vars->Coord_Bin[2]; j++) { long index; index = j + i*Vars->Coord_Bin[2]; p0m[index] = Vars->Mon2D_N[i][j]; p1m[index] = Vars->Mon2D_p[i][j]; p2m[index] = Vars->Mon2D_p2[i][j]; if (Vars->Flag_signal != DEFS->COORD_P && p0m[index] > 0) { p1m[index] /= p0m[index]; p2m[index] /= p0m[index]*p0m[index]; } if (Vars->Flag_log != 0) { if ((p1m[index] > 0) && (p2m[index] > 0)) { p2m[index] /= (p1m[index]*p1m[index]); p1m[index] = log(p1m[index])/log(10); } else { p1m[index] = XY; p2m[index] = 0; } } } } if (strchr(Vars->Mon_File,'.') == NULL) { strcat(fname, "."); strcat(fname, Vars->Coord_Var[1]); strcat(fname, "_"); strcat(fname, Vars->Coord_Var[2]); } if (Vars->Flag_Verbose) printf("Monitor_nD: %s write monitor file %s 2D (%lix%li).\n", Vars->compcurname, fname, Vars->Coord_Bin[1], Vars->Coord_Bin[2]); min1d = Vars->Coord_Min[1]; max1d = Vars->Coord_Max[1]; if (min1d == max1d) max1d = min1d+1e-6; min2d = Vars->Coord_Min[2]; max2d = Vars->Coord_Max[2]; if (min2d == max2d) max2d = min2d+1e-6; strcpy(label, Vars->Monitor_Label); if (Vars->Coord_Bin[1]*Vars->Coord_Bin[2] > 1 && Vars->Flag_signal == DEFS->COORD_P) strcat(label, " per bin"); if (Vars->Flag_List) { detector = mcdetector_out_2D_list( label, Vars->Coord_Label[1], Vars->Coord_Label[2], min1d, max1d, min2d, max2d, Vars->Coord_Bin[1], Vars->Coord_Bin[2], p0m,p1m,p2m, fname, Vars->compcurname, Vars->compcurpos, Vars->compcurrot,Vars->option,Vars->compcurindex); } else { detector = mcdetector_out_2D( label, Vars->Coord_Label[1], Vars->Coord_Label[2], min1d, max1d, min2d, max2d, Vars->Coord_Bin[1], Vars->Coord_Bin[2], p0m,p1m,p2m, fname, Vars->compcurname, Vars->compcurpos, Vars->compcurrot,Vars->compcurindex); } /* comment out 'free memory' lines to avoid loosing arrays if 'detector' structure is used by other instrument parts if (p0m != NULL) free(p0m); if (p1m != NULL) free(p1m); if (p2m != NULL) free(p2m); */ } } free(fname); } return(detector); } /* end Monitor_nD_Save */ /* ========================================================================= */ /* Monitor_nD_Finally: this routine is used to free memory */ /* ========================================================================= */ void Monitor_nD_Finally(MonitornD_Defines_type *DEFS, MonitornD_Variables_type *Vars) { int i; /* Now Free memory Mon2D.. */ if ((Vars->Flag_Auto_Limits || Vars->Flag_List) && Vars->Coord_Number) { /* Dim : (Vars->Coord_Number+1)*Vars->Buffer_Block matrix (for p, dp) */ if (Vars->Mon2D_Buffer != NULL) free(Vars->Mon2D_Buffer); } /* 1D and n1D case : Vars->Flag_Multiple */ if (Vars->Flag_Multiple && Vars->Coord_Number) { /* Dim : Vars->Coord_Number*Vars->Coord_Bin[i] vectors */ for (i= 0; i < Vars->Coord_Number; i++) { free(Vars->Mon2D_N[i]); free(Vars->Mon2D_p[i]); free(Vars->Mon2D_p2[i]); } free(Vars->Mon2D_N); free(Vars->Mon2D_p); free(Vars->Mon2D_p2); } /* 2D case : Vars->Coord_Number==2 and !Vars->Flag_Multiple and !Vars->Flag_List */ if ((Vars->Coord_NumberNoPixel == 2) && !Vars->Flag_Multiple) { /* Dim : Vars->Coord_Bin[1]*Vars->Coord_Bin[2] matrix */ for (i= 0; i < Vars->Coord_Bin[1]; i++) { free(Vars->Mon2D_N[i]); free(Vars->Mon2D_p[i]); free(Vars->Mon2D_p2[i]); } free(Vars->Mon2D_N); free(Vars->Mon2D_p); free(Vars->Mon2D_p2); } } /* end Monitor_nD_Finally */ /* ========================================================================= */ /* Monitor_nD_McDisplay: this routine is used to display component */ /* ========================================================================= */ void Monitor_nD_McDisplay(MonitornD_Defines_type *DEFS, MonitornD_Variables_type *Vars) { double radius, h; double xmin; double xmax; double ymin; double ymax; double zmin; double zmax; int i; double hdiv_min=-180, hdiv_max=180, vdiv_min=-90, vdiv_max=90; char restricted = 0; radius = Vars->Sphere_Radius; h = Vars->Cylinder_Height; xmin = Vars->mxmin; xmax = Vars->mxmax; ymin = Vars->mymin; ymax = Vars->mymax; zmin = Vars->mzmin; zmax = Vars->mzmax; /* determine if there are angular limits set at start (no auto) in coord_types * cylinder/banana: look for hdiv * sphere: look for angle, radius (->atan2(val,radius)), hdiv, vdiv * this activates a 'restricted' flag, to draw a region as blades on cylinder/sphere */ for (i= 0; i <= Vars->Coord_Number; i++) { int Set_Vars_Coord_Type; Set_Vars_Coord_Type = (Vars->Coord_Type[i] & (DEFS->COORD_LOG-1)); if (Set_Vars_Coord_Type == DEFS->COORD_HDIV || Set_Vars_Coord_Type == DEFS->COORD_THETA) { hdiv_min = Vars->Coord_Min[i]; hdiv_max = Vars->Coord_Max[i]; restricted = 1; } else if (Set_Vars_Coord_Type == DEFS->COORD_VDIV || Set_Vars_Coord_Type == DEFS->COORD_PHI) { vdiv_min = Vars->Coord_Min[i]; vdiv_max = Vars->Coord_Max[i];restricted = 1; } else if (Set_Vars_Coord_Type == DEFS->COORD_ANGLE) { hdiv_min = vdiv_min = Vars->Coord_Min[i]; hdiv_max = vdiv_max = Vars->Coord_Max[i]; restricted = 1; } else if (Set_Vars_Coord_Type == DEFS->COORD_RADIUS) { double angle; angle = RAD2DEG*atan2(Vars->Coord_Max[i], radius); hdiv_min = vdiv_min = angle; hdiv_max = vdiv_max = angle; restricted = 1; } else if (Set_Vars_Coord_Type == DEFS->COORD_Y && abs(Vars->Flag_Shape) == DEFS->SHAPE_SPHERE) { vdiv_min = atan2(ymin,radius)*RAD2DEG; vdiv_max = atan2(ymax,radius)*RAD2DEG; restricted = 1; } } /* full sphere */ if ((!restricted && (abs(Vars->Flag_Shape) == DEFS->SHAPE_SPHERE)) || abs(Vars->Flag_Shape) == DEFS->SHAPE_PREVIOUS) { mcdis_magnify(""); mcdis_circle("xy",0,0,0,radius); mcdis_circle("xz",0,0,0,radius); mcdis_circle("yz",0,0,0,radius); } /* banana/cylinder/sphere portion */ else if (restricted && ((abs(Vars->Flag_Shape) == DEFS->SHAPE_CYLIND) || (abs(Vars->Flag_Shape) == DEFS->SHAPE_BANANA) || (abs(Vars->Flag_Shape) == DEFS->SHAPE_SPHERE))) { int NH=24, NV=24; int ih, iv; double width, height; int issphere; issphere = (abs(Vars->Flag_Shape) == DEFS->SHAPE_SPHERE); width = (hdiv_max-hdiv_min)/NH; if (!issphere) { NV=1; /* cylinder has vertical axis */ } height= (vdiv_max-vdiv_min)/NV; /* check width and height of elements (sphere) to make sure the nb of plates remains limited */ if (width < 10 && NH > 1) { width = 10; NH=(hdiv_max-hdiv_min)/width; width=(hdiv_max-hdiv_min)/NH; } if (height < 10 && NV > 1) { height = 10; NV=(vdiv_max-vdiv_min)/height; height= (vdiv_max-vdiv_min)/NV; } mcdis_magnify("xyz"); for(ih = 0; ih < NH; ih++) for(iv = 0; iv < NV; iv++) { double theta0, phi0, theta1, phi1; /* angles in spherical coordinates */ double x0,y0,z0,x1,y1,z1,x2,y2,z2,x3,y3,z3; /* vertices at plate edges */ phi0 = (hdiv_min+ width*ih-90)*DEG2RAD; /* in xz plane */ phi1 = (hdiv_min+ width*(ih+1)-90)*DEG2RAD; if (issphere) { theta0= (vdiv_min+height* iv + 90) *DEG2RAD; /* in vertical plane */ theta1= (vdiv_min+height*(iv+1) + 90)*DEG2RAD; y0 = -radius*cos(theta0); /* z with Z vertical */ y1 = -radius*cos(theta1); if (y0 < ymin) y0=ymin; if (y0 > ymax) y0=ymax; if (y1 < ymin) y1=ymin; if (y1 > ymax) y1=ymax; } else { y0 = ymin; y1 = ymax; theta0=theta1=90*DEG2RAD; } x0 = radius*sin(theta0)*cos(phi0); /* x with Z vertical */ z0 =-radius*sin(theta0)*sin(phi0); /* y with Z vertical */ x1 = radius*sin(theta1)*cos(phi0); z1 =-radius*sin(theta1)*sin(phi0); x2 = radius*sin(theta1)*cos(phi1); z2 =-radius*sin(theta1)*sin(phi1); x3 = radius*sin(theta0)*cos(phi1); z3 =-radius*sin(theta0)*sin(phi1); y2 = y1; y3 = y0; mcdis_multiline(5, x0,y0,z0, x1,y1,z1, x2,y2,z2, x3,y3,z3, x0,y0,z0); } if (Vars->Flag_mantid) { /* First define the base pixel type */ double dt, dy; dt = (Vars->Coord_Max[1]-Vars->Coord_Min[1])/Vars->Coord_Bin[1]; dy = (Vars->Coord_Max[2]-Vars->Coord_Min[2])/Vars->Coord_Bin[2]; printf("MANTID_BANANA_DET: %g, %g, %g, %g, %g, %li, %li, %llu\n", radius, Vars->Coord_Min[1],Vars->Coord_Max[1], Vars->Coord_Min[2],Vars->Coord_Max[2], Vars->Coord_Bin[1], Vars->Coord_Bin[2], (long long unsigned)Vars->Coord_Min[4]); } } /* disk (circle) */ else if (abs(Vars->Flag_Shape) == DEFS->SHAPE_DISK) { mcdis_magnify(""); mcdis_circle("xy",0,0,0,radius); } /* rectangle (square) */ else if (abs(Vars->Flag_Shape) == DEFS->SHAPE_SQUARE) { mcdis_magnify("xy"); mcdis_multiline(5, (double)xmin, (double)ymin, 0.0, (double)xmax, (double)ymin, 0.0, (double)xmax, (double)ymax, 0.0, (double)xmin, (double)ymax, 0.0, (double)xmin, (double)ymin, 0.0); if (Vars->Flag_mantid) { /* First define the base pixel type */ double dx, dy; dx = (Vars->Coord_Max[1]-Vars->Coord_Min[1])/Vars->Coord_Bin[1]; dy = (Vars->Coord_Max[2]-Vars->Coord_Min[2])/Vars->Coord_Bin[2]; printf("MANTID_RECTANGULAR_DET: %g, %g, %g, %g, %li, %li, %llu\n", Vars->Coord_Min[1],Vars->Coord_Max[1], Vars->Coord_Min[2],Vars->Coord_Max[2], Vars->Coord_Bin[1], Vars->Coord_Bin[2], (long long unsigned)Vars->Coord_Min[4]); } } /* full cylinder/banana */ else if (!restricted && ((abs(Vars->Flag_Shape) == DEFS->SHAPE_CYLIND) || (abs(Vars->Flag_Shape) == DEFS->SHAPE_BANANA))) { mcdis_magnify("xyz"); mcdis_circle("xz", 0, h/2.0, 0, radius); mcdis_circle("xz", 0, -h/2.0, 0, radius); mcdis_line(-radius, -h/2.0, 0, -radius, +h/2.0, 0); mcdis_line(+radius, -h/2.0, 0, +radius, +h/2.0, 0); mcdis_line(0, -h/2.0, -radius, 0, +h/2.0, -radius); mcdis_line(0, -h/2.0, +radius, 0, +h/2.0, +radius); } else /* box */ if (abs(Vars->Flag_Shape) == DEFS->SHAPE_BOX) { mcdis_magnify("xyz"); mcdis_multiline(5, xmin, ymin, zmin, xmax, ymin, zmin, xmax, ymax, zmin, xmin, ymax, zmin, xmin, ymin, zmin); mcdis_multiline(5, xmin, ymin, zmax, xmax, ymin, zmax, xmax, ymax, zmax, xmin, ymax, zmax, xmin, ymin, zmax); mcdis_line(xmin, ymin, zmin, xmin, ymin, zmax); mcdis_line(xmax, ymin, zmin, xmax, ymin, zmax); mcdis_line(xmin, ymax, zmin, xmin, ymax, zmax); mcdis_line(xmax, ymax, zmin, xmax, ymax, zmax); } } /* end Monitor_nD_McDisplay */ /* end of monitor_nd-lib.c */ /******************************************************************************* * * McStas, neutron ray-tracing package * Copyright (C) 1997-2008, All rights reserved * Risoe National Laboratory, Roskilde, Denmark * Institut Laue Langevin, Grenoble, France * * Runtime: share/interoff.h * * %Identification * Written by: Reynald Arnerin * Date: Jun 12, 2008 * Release: * Version: * * Object File Format intersection header for McStas. Requires the qsort function. * * Such files may be obtained with e.g. * qhull < points.xyz Qx Qv Tv o > points.off * where points.xyz has format: * 3 * * * ... * The resulting file should have its first line being changed from '3' into 'OFF'. * It can then be displayed with geomview. * A similar, but somewhat older solution is to use 'powercrust' with e.g. * powercrust -i points.xyz * which will generate a 'pc.off' file to be renamed as suited. * *******************************************************************************/ #ifndef INTEROFF_LIB_H #define INTEROFF_LIB_H "$Revision$" #ifndef OFF_EPSILON #define OFF_EPSILON 1e-13 #endif #ifndef OFF_INTERSECT_MAX #ifdef OPENACC #define OFF_INTERSECT_MAX 100 #else #define OFF_INTERSECT_MAX 1024 #endif #endif //#include #define N_VERTEX_DISPLAYED 200000 typedef struct intersection { MCNUM time; //time of the intersection Coords v; //intersection point Coords normal; //normal vector of the surface intersected short in_out; //1 if the ray enters the volume, -1 otherwise short edge; //1 if the intersection is on the boundary of the polygon, and error is possible unsigned long index; // index of the face } intersection; typedef struct polygon { MCNUM* p; //vertices of the polygon in adjacent order, this way : x1 | y1 | z1 | x2 | y2 | z2 ... int npol; //number of vertices #pragma acc shape(p[0:npol]) init_needed(npol) Coords normal; double D; } polygon; typedef struct off_struct { long vtxSize; long polySize; long faceSize; Coords* vtxArray; #pragma acc shape(vtxArray[0:vtxSize]) init_needed(vtxSize) Coords* normalArray; #pragma acc shape(vtxArray[0:faceSize]) init_needed(faceSize) unsigned long* faceArray; #pragma acc shape(vtxArray[0:faceSize][0:polySize]) init_needed(faceSize,polySize) double* DArray; #pragma acc shape(vtxArray[0:polySize]) init_needed(polySize) char *filename; int mantidflag; long mantidoffset; intersection intersects[OFF_INTERSECT_MAX]; // After a call to off_intersect_all contains the list of intersections. int nextintersect; // 'Next' intersection (first t>0) solution after call to off_intersect_all int numintersect; // Number of intersections after call to off_intersect_all } off_struct; /******************************************************************************* * long off_init( char *offfile, double xwidth, double yheight, double zdepth, off_struct* data) * ACTION: read an OFF file, optionally center object and rescale, initialize OFF data structure * INPUT: 'offfile' OFF file to read * 'xwidth,yheight,zdepth' if given as non-zero, apply bounding box. * Specifying only one of these will also use the same ratio on all axes * 'notcenter' center the object to the (0,0,0) position in local frame when set to zero * RETURN: number of polyhedra and 'data' OFF structure *******************************************************************************/ long off_init( char *offfile, double xwidth, double yheight, double zdepth, int notcenter, off_struct* data); /******************************************************************************* * int off_intersect_all(double* t0, double* t3, Coords *n0, Coords *n3, double x, double y, double z, double vx, double vy, double vz, double ax, double ay, double az, off_struct *data ) * ACTION: computes intersection of neutron trajectory with an object. * INPUT: x,y,z and vx,vy,vz are the position and velocity of the neutron * ax, ay, az are the local acceleration vector * data points to the OFF data structure * RETURN: the number of polyhedral which trajectory intersects * t0 and t3 are the smallest incoming and outgoing intersection times * n0 and n3 are the corresponding normal vectors to the surface * data is the full OFF structure, including a list intersection type *******************************************************************************/ #pragma acc routine int off_intersect_all(double* t0, double* t3, Coords *n0, Coords *n3, double x, double y, double z, double vx, double vy, double vz, double ax, double ay, double az, off_struct *data ); /******************************************************************************* * int off_intersect(double* t0, double* t3, Coords *n0, Coords *n3, double x, double y, double z, double vx, double vy, double vz, double ax, double ay, double az, off_struct data ) * ACTION: computes intersection of neutron trajectory with an object. * INPUT: x,y,z and vx,vy,vz are the position and velocity of the neutron * ax, ay, az are the local acceleration vector * data points to the OFF data structure * RETURN: the number of polyhedral which trajectory intersects * t0 and t3 are the smallest incoming and outgoing intersection times * n0 and n3 are the corresponding normal vectors to the surface *******************************************************************************/ #pragma acc routine int off_intersect(double* t0, double* t3, Coords *n0, Coords *n3, double x, double y, double z, double vx, double vy, double vz, double ax, double ay, double az, off_struct data ); /***************************************************************************** * int off_intersectx(double* l0, double* l3, Coords *n0, Coords *n3, double x, double y, double z, double kx, double ky, double kz, off_struct data ) * ACTION: computes intersection of an xray trajectory with an object. * INPUT: x,y,z and kx,ky,kz, are spatial coordinates and wavevector of the x-ray * respectively. data points to the OFF data structure. * RETURN: the number of polyhedral the trajectory intersects * l0 and l3 are the smallest incoming and outgoing intersection lengths * n0 and n3 are the corresponding normal vectors to the surface *******************************************************************************/ #pragma acc routine int off_x_intersect(double *l0,double *l3, Coords *n0, Coords *n3, double x, double y, double z, double kx, double ky, double kz, off_struct data ); /******************************************************************************* * void off_display(off_struct data) * ACTION: display up to N_VERTEX_DISPLAYED points from the object *******************************************************************************/ void off_display(off_struct); /******************************************************************************* void p_to_quadratic(double eq[], Coords acc, Coords pos, Coords vel, double* teq) * ACTION: define the quadratic for the intersection of a parabola with a plane * INPUT: 'eq' plane equation * 'acc' acceleration vector * 'vel' velocity of the particle * 'pos' position of the particle * equation of plane A * x + B * y + C * z - D = 0 * eq[0] = (C*az)/2+(B*ay)/2+(A*ax)/2 * eq[1] = C*vz+B*vy+A*vx * eq[2] = C*z0+B*y0+A*x0-D * RETURN: equation of parabola: teq(0) * t^2 + teq(1) * t + teq(2) *******************************************************************************/ void p_to_quadratic(Coords norm, MCNUM d, Coords acc, Coords pos, Coords vel, double* teq); /******************************************************************************* int quadraticSolve(double eq[], double* x1, double* x2); * ACTION: solves the quadratic for the roots x1 and x2 * eq[0] * t^2 + eq[1] * t + eq[2] = 0 * INPUT: 'eq' the coefficients of the parabola * RETURN: roots x1 and x2 and the number of solutions *******************************************************************************/ int quadraticSolve(double* eq, double* x1, double* x2); #endif /* end of interoff-lib.h */ /******************************************************************************* * * McStas, neutron ray-tracing package * Copyright (C) 1997-2008, All rights reserved * Risoe National Laboratory, Roskilde, Denmark * Institut Laue Langevin, Grenoble, France * * Runtime: share/interoff-lib.c * * %Identification * Written by: Reynald Arnerin * Date: Jun 12, 2008 * Origin: ILL * Release: $Revision$ * Version: McStas X.Y * * Object File Format intersection library for McStas. Requires the qsort function. * * Such files may be obtained with e.g. * qhull < points.xyz Qx Qv Tv o > points.off * where points.xyz has format (it supports comments): * 3 * * * ... * The resulting file should have its first line being changed from '3' into 'OFF'. * It can then be displayed with geomview. * A similar, but somewhat older solution is to use 'powercrust' with e.g. * powercrust -i points.xyz * which will generate a 'pc.off' file to be renamed as suited. * *******************************************************************************/ #ifndef INTEROFF_LIB_H #include "interoff-lib.h" #endif #ifndef INTEROFF_LIB_C #define INTEROFF_LIB_C "$Revision$" #ifdef OPENACC // If on GPU map fprintf to printf #define fprintf(stderr,...) printf(__VA_ARGS__) #endif #pragma acc routine double off_F(double x, double y,double z,double A,double B,double C,double D) { return ( A*x + B*y + C*z + D ); } #pragma acc routine char off_sign(double a) { if (a<0) return(-1); else if (a==0) return(0); else return(1); } // off_normal ****************************************************************** //gives the normal vector of p #pragma acc routine void off_normal(Coords* n, polygon p) { //using Newell method int i=0,j=0; n->x=0;n->y=0;n->z=0; for (i = 0, j = p.npol-1; i < p.npol; j = i++) { MCNUM x1=p.p[3*i], y1=p.p[3*i+1], z1=p.p[3*i+2]; MCNUM x2=p.p[3*j], y2=p.p[3*j+1], z2=p.p[3*j+2]; // n is the cross product of v1*v2 n->x += (y1 - y2) * (z1 + z2); n->y += (z1 - z2) * (x1 + x2); n->z += (x1 - x2) * (y1 + y2); } } /* off_normal */ // off_pnpoly ****************************************************************** //based on http://www.ecse.rpi.edu/Homepages/wrf/Research/Short_Notes/pnpoly.html //return 0 if the vertex is out // 1 if it is in // -1 if on the boundary #pragma acc routine int off_pnpoly(polygon p, Coords v) { int i=0, c = 0; MCNUM minx=FLT_MAX,maxx=-FLT_MAX,miny=FLT_MAX,maxy=-FLT_MAX,minz=FLT_MAX,maxz=-FLT_MAX; MCNUM areax=0,areay=0,areaz=0; int pol2dx=0,pol2dy=1; //2d restriction of the poly MCNUM x=v.x,y=v.y; /*areax: projected area with x-scratched = |v1_yz x v2_yz|, where v1=(x1-x0,0,z1-z0) & v2=(x2-x0,0,z2-z0).*/ /* In principle, if polygon is triangle area should be scaled by 1/2, but this is irrelevant for finding the maximum area.*/ /* Similarly for y and z scratched.*/ areax=coords_len(coords_xp( coords_set(0,p.p[3*1+1]-p.p[0+1],p.p[3*1+2]-p.p[0+2]), coords_set(0,p.p[3*2+1]-p.p[0+1],p.p[3*2+2]-p.p[0+2]))); areay=coords_len(coords_xp( coords_set(p.p[3*1+0]-p.p[0+0],0,p.p[3*1+2]-p.p[0+2]), coords_set(p.p[3*2+0]-p.p[0+0],0,p.p[3*2+2]-p.p[0+2]))); areaz=coords_len(coords_xp( coords_set(p.p[3*1+0]-p.p[0+0],p.p[3*1+1]-p.p[0+1],0), coords_set(p.p[3*2+0]-p.p[0+0],p.p[3*2+1]-p.p[0+1],0))); if(areaztime = inter->edge = inter->in_out=0; inter->v = inter->normal = coords_set(0,0,1); if (fabs(ndir) < OFF_EPSILON) // ray is parallel to polygon plane { if (nw0 == 0) // ray lies in polygon plane (infinite number of solution) return 0; else return 0; // ray disjoint from plane (no solution) } // get intersect point of ray with polygon plane inter->time = nw0 / ndir; //parametric value the point on line (a,b) inter->v = coords_set(a.x + inter->time * dir.x,// intersect point of ray and plane a.y + inter->time * dir.y, a.z + inter->time * dir.z); int res=off_pnpoly(p,inter->v); inter->edge=(res==-1); if (ndir<0) inter->in_out=1; //the negative dot product means we enter the surface else inter->in_out=-1; inter->normal=p.normal; return res; //true if the intersection point lies inside the poly } /* off_intersectPoly */ // off_getBlocksIndex ********************************************************** /*reads the indexes at the beginning of the off file as this : line 1 OFF line 2 nbVertex nbFaces nbEdges */ FILE *off_getBlocksIndex(char* filename, long* vtxSize, long* polySize ) { FILE* f = Open_File(filename,"r", NULL); /* from read_table-lib: FILE *Open_File(char *name, char *Mode, char *path) */ if (!f) return (f); char line[CHAR_BUF_LENGTH]; char *ret=0; *vtxSize = *polySize = 0; /* **************** start to read the file header */ /* OFF file: 'OFF' or '3' */ ret=fgets(line,CHAR_BUF_LENGTH , f);// line 1 = "OFF" if (ret == NULL) { fprintf(stderr, "Error: Can not read 1st line in file %s (interoff/off_getBlocksIndex)\n", filename); exit(1); } if (strlen(line)>5) { fprintf(stderr,"Error: First line in %s is too long (=%lu). Possibly the line is not terminated by '\\n'.\n" " The first line is required to be exactly 'OFF', '3' or 'ply'.\n", filename,(long unsigned)strlen(line)); fclose(f); return(NULL); } if (strncmp(line,"OFF",3) && strncmp(line,"3",1) && strncmp(line,"ply",1)) { fprintf(stderr, "Error: %s is probably not an OFF, NOFF or PLY file (interoff/off_getBlocksIndex).\n" " Requires first line to be 'OFF', '3' or 'ply'.\n",filename); fclose(f); return(NULL); } if (!strncmp(line,"OFF",3) || !strncmp(line,"3",1)) { do /* OFF file: skip # comments which may be there */ { ret=fgets(line,CHAR_BUF_LENGTH , f); if (ret == NULL) { fprintf(stderr, "Error: Can not read line in file %s (interoff/off_getBlocksIndex)\n", filename); exit(1); } } while (line[0]=='#'); //line = nblines of vertex,faces and edges arrays sscanf(line,"%lu %lu",vtxSize,polySize); } else { do /* PLY file: read all lines until find 'end_header' and locate 'element faces' and 'element vertex' */ { ret=fgets(line,CHAR_BUF_LENGTH , f); if (ret == NULL) { fprintf(stderr, "Error: Can not read line in file %s (interoff/off_getBlocksIndex)\n", filename); exit(1); } if (!strncmp(line,"element face",12)) sscanf(line,"element face %lu",polySize); else if (!strncmp(line,"element vertex",14)) sscanf(line,"element vertex %lu",vtxSize); else if (!strncmp(line,"format binary",13)) exit(fprintf(stderr, "Error: Can not read binary PLY file %s, only 'format ascii' (interoff/off_getBlocksIndex)\n%s\n", filename, line)); } while (strncmp(line,"end_header",10)); } /* The FILE is left opened ready to read 'vtxSize' vertices (vtxSize *3 numbers) and then polySize polygons (rows) */ return(f); } /* off_getBlocksIndex */ // off_init_planes ************************************************************* //gives the equations of 2 perpandicular planes of [ab] #pragma acc routine void off_init_planes(Coords a, Coords b, MCNUM* A1, MCNUM* C1, MCNUM* D1, MCNUM *A2, MCNUM* B2, MCNUM* C2, MCNUM* D2) { //direction vector of [a b] Coords dir={b.x-a.x, b.y-a.y, b.z-a.z}; //the plane parallel to the 'y' is computed with the normal vector of the projection of [ab] on plane 'xz' *A1= dir.z; *C1=-dir.x; if(*A1!=0 || *C1!=0) *D1=-(a.x)*(*A1)-(a.z)*(*C1); else { //the plane does not support the vector, take the one parallel to 'z'' *A1=1; //B1=dir.x=0 *D1=-(a.x); } //the plane parallel to the 'x' is computed with the normal vector of the projection of [ab] on plane 'yz' *B2= dir.z; *C2=-dir.y; *A2= 0; if (*B2==0 && *C2==0) { //the plane does not support the vector, take the one parallel to 'z' *B2=1; //B1=dir.x=0 *D2=-(a.y); } else { if (dir.z==0) { //the planes are the same, take the one parallel to 'z' *A2= dir.y; *B2=-dir.x; *D2=-(a.x)*(*A2)-(a.y)*(*B2); } else *D2=-(a.y)**B2-(a.z)**C2; } } /* off_init_planes */ // off_clip_3D_mod ************************************************************* #pragma acc routine int off_clip_3D_mod(intersection* t, Coords a, Coords b, Coords* vtxArray, unsigned long vtxSize, unsigned long* faceArray, unsigned long faceSize, Coords* normalArray) { MCNUM A1=0, C1=0, D1=0, A2=0, B2=0, C2=0, D2=0; //perpendicular plane equations to [a,b] off_init_planes(a, b, &A1, &C1, &D1, &A2, &B2, &C2, &D2); int t_size=0; MCNUM popol[3*4]; /*3 dimensions and max 4 vertices to form a polygon*/ unsigned long i=0,indPoly=0; //exploring the polygons : i=indPoly=0; while (iOFF_INTERSECT_MAX) { fprintf(stderr, "Warning: number of intersection exceeded (%d) (interoff-lib/off_clip_3D_mod)\n", OFF_INTERSECT_MAX); return (t_size); } #endif //both planes intersect the polygon, let's find the intersection point //our polygon : int k; for (k=0; k t[0].time) { t[0]=x; } } else { /* Case 2, positive time */ intersection xtmp; if (x.time < t[3].time) { t[3]=x; if (t[3].time < t[2].time) { xtmp = t[2]; t[2] = t[3]; t[3] = xtmp; } if (t[2].time < t[1].time) { xtmp = t[1]; t[1] = t[2]; t[2] = xtmp; } } } #endif } } /* if (jCHAR_BUF_LENGTH) { fprintf(stderr, "Warning: number of intersection exceeded (%d) (interoff-lib/off_clip_3D_mod)\n", CHAR_BUF_LENGTH); return (t_size); } //both planes intersect the polygon, let's find the intersection point //our polygon : int k; for (k=0; k= 1) { double time = 1.0e36; if (x1 < time && x1 > 0.0) { time = x1; } if (nsol == 2 && x2 < time && x2 > 0.0) { time = x2; } if (time != 1.0e36) { intersection inters; double t2 = time * time * 0.5; double tx = pos.x + time * vel.x; if (acc.x != 0.0) { tx = tx + t2 * acc.x; } double ty = pos.y + time * vel.y; if (acc.y != 0.0) { ty = ty + t2 * acc.y; } double tz = pos.z + time * vel.z; if (acc.z != 0.0) { tz = tz + t2 * acc.z; } inters.v = coords_set(tx, ty, tz); Coords tvel = coords_set(vel.x + time * acc.x, vel.y + time * acc.y, vel.z + time * acc.z); inters.time = time; inters.normal = pol.normal; inters.index = indPoly; int res=off_pnpoly(pol,inters.v); if (res != 0) { inters.edge=(res==-1); MCNUM ndir = scalar_prod(pol.normal.x,pol.normal.y,pol.normal.z,tvel.x,tvel.y,tvel.z); if (ndir<0) { inters.in_out=1; //the negative dot product means we enter the surface } else { inters.in_out=-1; } #ifdef OFF_LEGACY t[t_size++]=inters; #else /* Check against our 4 existing times, starting from [-FLT_MAX, FLT_MAX, FLT_MAX, FLT_MAX] */ /* Case 1, negative time? */ if (t_size < 4) t_size++; if (inters.time < 0) { if (inters.time > t[0].time) { t[0]=inters; } } else { /* Case 2, positive time */ intersection xtmp; if (inters.time < t[3].time) { t[3]=inters; if (t[3].time < t[2].time) { xtmp = t[2]; t[2] = t[3]; t[3] = xtmp; } if (t[2].time < t[1].time) { xtmp = t[1]; t[1] = t[2]; t[2] = xtmp; } } } #endif } } } i += pol.npol; indPoly++; } /* while itime - pb->time); } /* off_compare */ // off_cleanDouble ************************************************************* //given an array of intersections throw those which appear several times //returns 1 if there is a possibility of error #pragma acc routine int off_cleanDouble(intersection* t, int* t_size) { int i=1; intersection prev=t[0]; while (i<*t_size) { int j=i; //for each intersection with the same time while (j<*t_size && fabs(prev.time-t[j].time)maxx) maxx=vtxArray[i].x; if (vtxArray[i].ymaxy) maxy=vtxArray[i].y; if (vtxArray[i].zmaxz) maxz=vtxArray[i].z; i++; // inquire next vertex } // resizing and repositioning params double centerx=0, centery=0, centerz=0; if (!notcenter) { centerx=(minx+maxx)*0.5; centery=(miny+maxy)*0.5; centerz=(minz+maxz)*0.5; } double rangex=-minx+maxx, rangey=-miny+maxy, rangez=-minz+maxz; double ratiox=1,ratioy=1,ratioz=1; if (xwidth && rangex) { ratiox=xwidth/rangex; ratioy=ratiox; ratioz=ratiox; } if (yheight && rangey) { ratioy=yheight/rangey; if(!xwidth) ratiox=ratioy; ratioz=ratioy; } if (zdepth && rangez) { ratioz=zdepth/rangez; if(!xwidth) ratiox=ratioz; if(!yheight) ratioy=ratioz; } rangex *= ratiox; rangey *= ratioy; rangez *= ratioz; //center and resize the object for (i=0; i polySize*10) { fprintf(stderr, "Error: %li exceeded allocated polygon array[%li] in file %s (interoff/off_init)\n", faceSize, polySize*10, offfile); } faceArray[faceSize++] = nbVertex; // length of the polygon/face // then read the vertex ID's for (j=0; jvtxArray = vtxArray; data->normalArray= normalArray; data->DArray = DArray; data->faceArray = faceArray; data->vtxSize = vtxSize; data->polySize = polySize; data->faceSize = faceSize; data->filename = offfile; #ifdef OPENACC acc_attach((void *)&vtxArray); acc_attach((void *)&normalArray); acc_attach((void *)&faceArray); #endif return(polySize); } /* off_init */ #pragma acc routine int Min_int(int x, int y) { return (xintersects, pos, vel, acc, data->vtxArray, data->vtxSize, data->faceArray, data->faceSize, data->normalArray, data->DArray ); } else { /////////////////////////////////// // non-grav Coords A={x, y, z}; Coords B={x+vx, y+vy, z+vz}; t_size=off_clip_3D_mod(data->intersects, A, B, data->vtxArray, data->vtxSize, data->faceArray, data->faceSize, data->normalArray ); } #ifndef OPENACC qsort(data->intersects, t_size, sizeof(intersection), off_compare); #else #ifdef USE_OFF gpusort(data->intersects, t_size); #endif #endif off_cleanDouble(data->intersects, &t_size); off_cleanInOut(data->intersects, &t_size); /*find intersections "closest" to 0 (favouring positive ones)*/ if(t_size>0){ int i=0; if(t_size>1) { for (i=1; i < t_size-1; i++){ if (data->intersects[i-1].time > 0 && data->intersects[i].time > 0) break; } data->nextintersect=i-1; data->numintersect=t_size; if (t0) *t0 = data->intersects[i-1].time; if (n0) *n0 = data->intersects[i-1].normal; if (t3) *t3 = data->intersects[i].time; if (n3) *n3 = data->intersects[i].normal; } else { if (t0) *t0 = data->intersects[0].time; if (n0) *n0 = data->intersects[0].normal; } /* should also return t[0].index and t[i].index as polygon ID */ data->nextintersect=(data->intersects[data->nextintersect]).index; return t_size; } #else intersection intersect4[4]; intersect4[0].time=-FLT_MAX; intersect4[1].time=FLT_MAX; intersect4[2].time=FLT_MAX; intersect4[3].time=FLT_MAX; if(mcgravitation) { Coords pos={ x, y, z}; Coords vel={vx, vy, vz}; Coords acc={ax, ay, az}; t_size=off_clip_3D_mod_grav(intersect4, pos, vel, acc, data->vtxArray, data->vtxSize, data->faceArray, data->faceSize, data->normalArray, data->DArray); } else { /////////////////////////////////// // non-grav Coords A={x, y, z}; Coords B={x+vx, y+vy, z+vz}; t_size=off_clip_3D_mod(intersect4, A, B, data->vtxArray, data->vtxSize, data->faceArray, data->faceSize, data->normalArray ); } if(t_size>0){ int i=0; if (intersect4[0].time == -FLT_MAX) i=1; data->numintersect=t_size; if (t0) *t0 = intersect4[i].time; if (n0) *n0 = intersect4[i].normal; if (t3) *t3 = intersect4[i+1].time; if (n3) *n3 = intersect4[i+1].normal; if (intersect4[1].time == FLT_MAX) { if (t3) *t3 = 0.0; } /* should also return t[0].index and t[i].index as polygon ID */ data->nextintersect=(int)intersect4[i].index; return t_size; } #endif return 0; } /* off_intersect */ /******************************************************************************* * int off_intersect(double* t0, double* t3, Coords *n0, Coords *n3, double x, double y, double z, double vx, double vy, double vz, off_struct data ) * ACTION: computes intersection of neutron trajectory with an object. * INPUT: x,y,z and vx,vy,vz are the position and velocity of the neutron * data points to the OFF data structure * RETURN: the number of polyhedral which trajectory intersects * t0 and t3 are the smallest incoming and outgoing intersection times * n0 and n3 are the corresponding normal vectors to the surface *******************************************************************************/ int off_intersect(double* t0, double* t3, Coords *n0, Coords *n3, double x, double y, double z, double vx, double vy, double vz, double ax, double ay, double az, off_struct data ) { return off_intersect_all(t0, t3, n0, n3, x, y, z, vx, vy, vz, ax, ay, az, &data ); } /* off_intersect */ /***************************************************************************** * int off_x_intersect(double* l0, double* l3, Coords *n0, Coords *n3, double x, double y, double z, double kx, double ky, double kz, off_struct data ) * ACTION: computes intersection of an xray trajectory with an object. * INPUT: x,y,z and kx,ky,kz, are spatial coordinates and wavevector of the x-ray * respectively. data points to the OFF data structure. * RETURN: the number of polyhedral the trajectory intersects * l0 and l3 are the smallest incoming and outgoing intersection lengths * n0 and n3 are the corresponding normal vectors to the surface *******************************************************************************/ int off_x_intersect(double *l0,double *l3, Coords *n0, Coords *n3, double x, double y, double z, double kx, double ky, double kz, off_struct data ) { /*This function simply reformats and calls off_intersect (as for neutrons) *by normalizing the wavevector - this will yield the intersection lengths *in m*/ double jx,jy,jz,invk; int n; invk=1/sqrt(scalar_prod(kx,ky,kz,kx,ky,kz)); jx=kx*invk;jy=ky*invk;jz=kz*invk; n=off_intersect(l0,l3,n0,n3,x,y,z,jx,jy,jz,0.0,0.0,0.0,data); return n; } /******************************************************************************* * void off_display(off_struct data) * ACTION: display up to N_VERTEX_DISPLAYED polygons from the object *******************************************************************************/ void off_display(off_struct data) { if(mcdotrace==2){ // Estimate size of the JSON string const int VERTEX_OVERHEAD = 30; const int FACE_OVERHEAD_BASE = 20; const int FACE_INDEX_OVERHEAD = 15; int estimated_size = 256; // Base size estimated_size += data.vtxSize * VERTEX_OVERHEAD; for (int i = 0; i < data.faceSize;) { int num_indices = data.faceArray[i]; estimated_size += FACE_OVERHEAD_BASE + num_indices * FACE_INDEX_OVERHEAD; i += num_indices + 1; } char *json_string = malloc(estimated_size); if (json_string == NULL) { fprintf(stderr, "Memory allocation failed.\n"); return; } char *ptr = json_string; ptr += sprintf(ptr, "{ \"vertices\": ["); for (int i = 0; i < data.vtxSize; i++) { ptr += sprintf(ptr, "[%g, %g, %g]", data.vtxArray[i].x, data.vtxArray[i].y, data.vtxArray[i].z); if (i < data.vtxSize - 1) { ptr += sprintf(ptr, ", "); } } ptr += sprintf(ptr, "], \"faces\": ["); for (int i = 0; i < data.faceSize;) { int num = data.faceArray[i]; ptr += sprintf(ptr, "{ \"face\": ["); for (int j = 1; j <= num; j++) { ptr += sprintf(ptr, "%lu", data.faceArray[i + j]); if (j < num) { ptr += sprintf(ptr, ", "); } } ptr += sprintf(ptr, "]}"); i += num + 1; if(i 1 || drawthis) { mcdis_line(x1,y1,z1,x2,y2,z2); } x1 = x2; y1 = y2; z1 = z2; } if (ratio > 1 || drawthis) { mcdis_line(x1,y1,z1,x0,y0,z0); } if (data.mantidflag) { printf("MANTID_PIXEL: %s\n", pixelinfo); pixel++; } i += nbVertex; } } } /* off_display */ /* end of interoff-lib.c */ #endif // INTEROFF_LIB_C /* Shared user declarations for all components types 'Incoherent'. */ struct StructVarsInc { double sigma_a; /* Absorption cross section per atom (barns) */ double sigma_i; /* Incoherent scattering cross section per atom (barns) */ double rho; /* Density of atoms (AA-3) */ double my_s; double my_a_v; int shape; /* 0 cylinder, 1 box, 2 sphere, 3 OFF file */ double aw, ah; /* rectangular angular dimensions */ double xw, yh; /* rectangular metrical dimensions */ double tx, ty, tz; /* target coords */ }; /* Shared user declarations for all components types 'PowderN'. */ /* used for reading data table from file */ /* Declare structures and functions only once in each instrument. */ #ifndef POWDERN_DECL #define POWDERN_DECL struct line_data { double F2; /* Value of structure factor */ double q; /* Qvector */ int j; /* Multiplicity */ double DWfactor; /* Debye-Waller factor */ double w; /* Intrinsic line width */ }; struct line_info_struct { struct line_data* list; /* Reflection array */ int count; /* Number of reflections */ double Dd; double DWfactor; double V_0; double rho; double at_weight; double at_nb; double sigma_a; double sigma_i; char compname[256]; double flag_barns; int shape; /* 0 cylinder, 1 box, 2 sphere, 3 OFF file */ int column_order[9]; /* column signification */ int flag_warning; double dq; /* wavevector transfer [Angs-1] */ double Epsilon; /* global strain in ppm */ double XsectionFactor; double my_s_v2_sum; double my_a_v; double my_inc; double lfree; // store mean free path for the last event; double *w_v, *q_v, *my_s_v2; double radius_i, xwidth_i, yheight_i, zdepth_i; double v; /* last velocity (cached) */ double Nq; int nb_reuses, nb_refl, nb_refl_count; double v_min, v_max; double xs_Nq[CHAR_BUF_LENGTH]; double xs_sum[CHAR_BUF_LENGTH]; double neutron_passed; long xs_compute, xs_reuse, xs_calls; }; // PN_list_compare ***************************************************************** int PN_list_compare (const void* a, const void* b) { const struct line_data* pa = a; const struct line_data* pb = b; /* Sort by q */ if (pa->q < pb->q) return -1; if (pa->q > pb->q) return 1; /* In case of tie, sort by F2 also */ if (pa->F2 < pb->F2) return -1; if (pa->F2 > pb->F2) return 1; /* In case of tie, sort by j also */ if (pa->j < pb->j) return -1; if (pa->j > pb->j) return 1; return 0; } /* PN_list_compare */ #ifndef CIF2HKL #define CIF2HKL // hkl_filename = cif2hkl(file, options) // used to convert CIF/CFL/INS file into F2(hkl) // the CIF2HKL env var can point to a cif2hkl executable // else the McCode binary is attempted, then the system. char* cif2hkl (char* infile, char* options) { char cmd[1024]; int ret = 0; int found = 0; char* OUTFILE; char* inpath; // get filename extension char* ext = strrchr (infile, '.'); if (!ext || ext == infile) return infile; else ext++; // return input when no extension or not a CIF/FullProf/ShelX file if (strcasecmp (ext, "cif") && strcasecmp (ext, "pcr") && strcasecmp (ext, "cfl") && strcasecmp (ext, "shx") && strcasecmp (ext, "ins") && strcasecmp (ext, "res")) return infile; OUTFILE = malloc (1024); if (!OUTFILE) { free (OUTFILE); return infile; } inpath = malloc (1024); if (!inpath) { free (OUTFILE); free (inpath); return infile; } // get input file path from read-table:Open_File FILE* f_infile = Open_File (infile, "r", inpath); if (!f_infile) { free (OUTFILE); free (inpath); free (f_infile); return infile; } fclose (f_infile); strncpy (OUTFILE, tmpnam (NULL), 1024); // create an output temporary file name // try in order the CIF2HKL env var, then the system cif2hkl, then the McCode one if (!found && getenv ("CIF2HKL")) { snprintf (cmd, 1024, "%s -o %s %s %s", getenv ("CIF2HKL"), OUTFILE, options, inpath); ret = system (cmd); if (ret != -1 && ret != 127) found = 1; } if (!found) { // try with cif2hkl command from the system PATH snprintf (cmd, 1024, "%s -o %s %s %s", "cif2hkl", OUTFILE, options, infile); ret = system (cmd); if (ret != -1 && ret != 127) found = 1; } if (!found) { // As a last resort, attempt with cif2hkl from $MCSTAS/bin snprintf (cmd, 1024, "%s%c%s%c%s -o %s %s %s", getenv (FLAVOR_UPPER) ? getenv (FLAVOR_UPPER) : MCSTAS, MC_PATHSEP_C, "bin", MC_PATHSEP_C, "cif2hkl", OUTFILE, options, inpath); ret = system (cmd); } // ret = -1: child process could not be created // ret = 127: shell could not be executed in the child process if (ret == -1 || ret == 127) { free (OUTFILE); return (NULL); } // test if the result file has been created FILE* file = fopen (OUTFILE, "r"); if (!file) { free (OUTFILE); return (NULL); } MPI_MASTER (printf ("%s: INFO: Converting %s into F2(HKL) list %s\n", __FILE__, inpath, OUTFILE); printf ("%s\n", cmd);); fflush (NULL); fclose (file); return (OUTFILE); } // cif2hkl #endif #ifndef WIN32 #include "NCrystal/ncrystal.h" #else #include "NCrystal\\ncrystal.h" #endif double ncrystalpowdern_determine_sigma_inc (ncrystal_info_t ncobj) { // Digging out sigma_inc via the NCrystal C API is not as easy as it // should be yet, so for now we do it the hard way. unsigned ncomps = ncrystal_info_ncomponents (ncobj); double sum = 0.0; for (unsigned icomp = 0; icomp < ncomps; ++icomp) { // Get component fraction and atomdata: double fraction; unsigned atomdataidx; // unused ncrystal_info_getcomponent (ncobj, icomp, &atomdataidx, &fraction); ncrystal_atomdata_t atomdata = ncrystal_create_component_atomdata (ncobj, icomp); // Get incoherent xsect from atomdata: const char* displaylabel; const char* description; double mass, incxs, cohsl_fm, absxs; unsigned nsubcomponents, zval, aval; ncrystal_atomdata_getfields (atomdata, &displaylabel, &description, &mass, &incxs, &cohsl_fm, &absxs, &nsubcomponents, &zval, &aval); ncrystal_unref (&atomdata); sum += incxs * fraction; } return sum; } int read_line_data_ncrystal (const char* cfgstr, struct line_info_struct* info) { ncrystal_info_t ncobj = ncrystal_create_info (cfgstr); if (ncrystal_info_nphases (ncobj) != 0) { exit (fprintf (stderr, "PowderN: %s: Error: Only single phase NCrystal " "materials are currently supported by PowderN\n", info->compname)); } const double numberdensity = ncrystal_info_getnumberdensity (ncobj); const int nhkl = ncrystal_info_nhkl (ncobj); if (nhkl == 0) { printf ("PowderN: %s: WARNING: NCrystal material " "does not contain reflections\n", info->compname); } else { MPI_MASTER (printf ("PowderN: %s: Loading %d reflections from %s\n", info->compname, nhkl, cfgstr);); } unsigned spacegroup, n_atoms; double lattice_a, lattice_b, lattice_c, alpha, beta, gamma, cell_volume; int has_structure = ncrystal_info_getstructure (ncobj, &spacegroup, &lattice_a, &lattice_b, &lattice_c, &alpha, &beta, &gamma, &cell_volume, &n_atoms); if (!has_structure) { exit (fprintf (stderr, "PowderN: %s: Error: NCrystal material " "does not contain crystal structure\n", info->compname)); } // Note we use V_0=n_atoms/numdens and not V_0 = cell_volume. This way, it // supports density scaling that the user might have performed with the // NCrystal cfg-string parameters (e.g. "...;density=0.6x"). info->V_0 = n_atoms / numberdensity; info->at_nb = n_atoms; info->flag_barns = 1; /* allocate line_data array */ struct line_data* list = NULL; list = (struct line_data*)malloc (nhkl * sizeof (struct line_data)); if (!list) { exit (fprintf (stderr, "PowderN: %s: Error: Could not allocate line array\n", info->compname)); } info->sigma_a = ncrystal_info_getxsectabsorption (ncobj); info->sigma_i = ncrystalpowdern_determine_sigma_inc (ncobj); const double w = (info->Dd >= 0.0 ? info->Dd : 0.0); const double Epsilon = ((info->Epsilon && fabs (info->Epsilon) < 1e6) ? info->Epsilon * 1e-6 : 0.0); for (int idx = 0; idx < nhkl; ++idx) { int h, k, l, mult; double dsp, fsq; ncrystal_info_gethkl (ncobj, idx, &h, &k, &l, &mult, &dsp, &fsq); list[idx].j = mult; double q = (2.0 * PI) / dsp; if (Epsilon) q -= Epsilon * q; list[idx].q = q; list[idx].DWfactor = 1.0; list[idx].w = w; list[idx].F2 = fsq; } ncrystal_unref (&ncobj); info->list = list; info->count = nhkl; return nhkl; } int read_line_data (char* SC_file, struct line_info_struct* info) { struct line_data* list = NULL; int size = 0; t_Table sTable; /* sample data table structure from SC_file */ int i = 0; int mult_count = 0; char flag = 0; double q_count = 0, j_count = 0, F2_count = 0; char** parsing; int list_count = 0; char* filename = NULL; if (!SC_file) { // Should not be possible, was checked by calling code in INITIALIZE. fprintf (stderr, "PowderN: logic error (SC_file is NULL)!\n"); exit (-1); } filename = cif2hkl (SC_file, "--mode NUC"); if (filename != SC_file) info->flag_barns = 1; // cif2hkl returns barns long retval = Table_Read (&sTable, filename, 1); /* read 1st block data from SC_file into sTable*/ if (retval < 0) { fprintf (stderr, "PowderN: Could not open file %s - exiting!\n", SC_file); exit (-1); } /* parsing of header */ parsing = Table_ParseHeader (sTable.header, "Vc", "V_0", "sigma_abs", "sigma_a ", "sigma_inc", "sigma_i ", "column_j", "column_d", "column_F2", "column_DW", "column_Dd", "column_inv2d", "column_1/2d", "column_sintheta/lambda", "column_q", /* 14 */ "DW", "Debye_Waller", "delta_d_d/d", "column_F ", "V_rho", "density", "weight", "nb_atoms", "multiplicity", /* 23 */ "column_ppm", "column_strain", "ncmat2hklversion", "ncrystal_cfgstr", NULL); int ncmat2hklversion = -1; int has_ncrystal_cfgstr = 0; if (parsing) { if (parsing[0] && !info->V_0) info->V_0 = atof (parsing[0]); if (parsing[1] && !info->V_0) info->V_0 = atof (parsing[1]); if (parsing[2] && !info->sigma_a) info->sigma_a = atof (parsing[2]); if (parsing[3] && !info->sigma_a) info->sigma_a = atof (parsing[3]); if (parsing[4] && !info->sigma_i) info->sigma_i = atof (parsing[4]); if (parsing[5] && !info->sigma_i) info->sigma_i = atof (parsing[5]); if (parsing[6]) info->column_order[0] = atoi (parsing[6]); if (parsing[7]) info->column_order[1] = atoi (parsing[7]); if (parsing[8]) info->column_order[2] = atoi (parsing[8]); if (parsing[9]) info->column_order[3] = atoi (parsing[9]); if (parsing[10]) info->column_order[4] = atoi (parsing[10]); if (parsing[11]) info->column_order[5] = atoi (parsing[11]); if (parsing[12]) info->column_order[5] = atoi (parsing[12]); if (parsing[13]) info->column_order[5] = atoi (parsing[13]); if (parsing[14]) info->column_order[6] = atoi (parsing[14]); if (parsing[15] && info->DWfactor <= 0) info->DWfactor = atof (parsing[15]); if (parsing[16] && info->DWfactor <= 0) info->DWfactor = atof (parsing[16]); if (parsing[17] && info->Dd < 0) info->Dd = atof (parsing[17]); if (parsing[18]) info->column_order[7] = atoi (parsing[18]); if (parsing[19] && !info->V_0) info->V_0 = 1 / atof (parsing[19]); if (parsing[20] && !info->rho) info->rho = atof (parsing[20]); if (parsing[21] && !info->at_weight) info->at_weight = atof (parsing[21]); if (parsing[22] && info->at_nb <= 1) info->at_nb = atof (parsing[22]); if (parsing[23] && info->at_nb <= 1) info->at_nb = atof (parsing[23]); if (parsing[24]) info->column_order[8] = atoi (parsing[24]); if (parsing[25]) info->column_order[8] = atoi (parsing[25]); if (parsing[26]) ncmat2hklversion = atoi (parsing[26]); if (parsing[27]) has_ncrystal_cfgstr = 1; for (i = 0; i <= 27; i++) if (parsing[i]) free (parsing[i]); free (parsing); } // First round of laz/lau files from ncrystal_ncmat2hkl had an n_atoms factor // wrong in sigma_a/sigma_i. Luckily we can detect such files. const int is_buggy_ncmat2hkl_laz = (has_ncrystal_cfgstr && ncmat2hklversion < 2); if (is_buggy_ncmat2hkl_laz) { info->sigma_a /= info->at_nb; info->sigma_i /= info->at_nb; } if (!sTable.rows) exit (fprintf (stderr, "PowderN: %s: Error: The number of rows in %s " "should be at least %d\n", info->compname, SC_file, 1)); else size = sTable.rows; MPI_MASTER (Table_Info (sTable); printf ("PowderN: %s: Reading %d rows from %s\n", info->compname, size, SC_file);); if (filename == SC_file) { // only when not from cif2hkl if (info->column_order[0] == 4 && info->flag_barns != 0) MPI_MASTER (printf ("PowderN: %s: Powder file probably of type Crystallographica/Fullprof (lau)\n" "WARNING: but F2 unit is set to barns=1 (barns). Intensity might be 100 times too high.\n", info->compname);); if (info->column_order[0] == 17 && info->flag_barns == 0) MPI_MASTER (printf ("PowderN: %s: Powder file probably of type Lazy Pulver (laz)\n" "WARNING: but F2 unit is set to barns=0 (fm^2). Intensity might be 100 times too low.\n", info->compname);); } /* allocate line_data array */ list = (struct line_data*)malloc (size * sizeof (struct line_data)); if (!list) { exit (fprintf (stderr, "PowderN: %s: Error: Could not allocate line array\n", info->compname)); } for (i = 0; i < size; i++) { /* printf("Reading in line %i\n",i);*/ double j = 0, d = 0, w = 0, q = 0, DWfactor = 0, F2 = 0, Epsilon = 0; int index; if (info->Dd >= 0) w = info->Dd; if (info->DWfactor > 0) DWfactor = info->DWfactor; if (info->Epsilon) Epsilon = info->Epsilon * 1e-6; /* get data from table using columns {j d F2 DW Dd inv2d q F} */ /* column indexes start at 1, thus need to substract 1 */ if (info->column_order[0] > 0) j = Table_Index (sTable, i, info->column_order[0] - 1); if (info->column_order[1] > 0) d = Table_Index (sTable, i, info->column_order[1] - 1); if (info->column_order[2] > 0) F2 = Table_Index (sTable, i, info->column_order[2] - 1); if (info->column_order[3] > 0) DWfactor = Table_Index (sTable, i, info->column_order[3] - 1); if (info->column_order[4] > 0) w = Table_Index (sTable, i, info->column_order[4] - 1); if (info->column_order[5] > 0 && !(info->column_order[1] > 0)) // Only use if d not read already { d = Table_Index (sTable, i, info->column_order[5] - 1); d = (d > 0 ? 1 / d / 2 : 0); } if (info->column_order[6] > 0 && !(info->column_order[1] > 0)) // Only use if d not read already { q = Table_Index (sTable, i, info->column_order[6] - 1); d = (q > 0 ? 2 * PI / q : 0); } if (info->column_order[7] > 0 && !F2) { F2 = Table_Index (sTable, i, info->column_order[7] - 1); F2 *= F2; } if (info->column_order[8] > 0 && !Epsilon) { Epsilon = Table_Index (sTable, i, info->column_order[8] - 1) * 1e-6; } /* assign and check values */ j = (j > 0 ? j : 0); q = (d > 0 ? 2 * PI / d : 0); /* this is q */ if (Epsilon && fabs (Epsilon) < 1e6) { q -= Epsilon * q; /* dq/q = -delta_d_d/d = -Epsilon */ } DWfactor = (DWfactor > 0 ? DWfactor : 1); w = (w > 0 ? w : 0); /* this is q and d relative spreading */ F2 = (F2 >= 0 ? F2 : 0); if (j == 0 || q == 0) { MPI_MASTER (printf ("PowderN: %s: line %i has invalid definition\n" " (mult=0 or q=0 or d=0)\n", info->compname, i);); continue; } list[list_count].j = j; list[list_count].q = q; list[list_count].DWfactor = DWfactor; list[list_count].w = w; list[list_count].F2 = F2; /* adjust multiplicity if j-column + multiple d-spacing lines */ /* if d = previous d, increase line duplication index */ if (!q_count) q_count = q; if (!j_count) j_count = j; if (!F2_count) F2_count = F2; if (fabs (q_count - q) < 0.0001 * fabs (q) && fabs (F2_count - F2) < 0.0001 * fabs (F2) && j_count == j) { mult_count++; flag = 0; } else flag = 1; if (i == size - 1) flag = 1; /* else if d != previous d : just passed equivalent lines */ if (flag) { if (i == size - 1) list_count++; /* if duplication index == previous multiplicity */ /* set back multiplicity of previous lines to 1 */ if ((mult_count && list_count > 0) && (mult_count == list[list_count - 1].j || ((list_count < size) && (i == size - 1) && (mult_count == list[list_count].j)))) { MPI_MASTER (printf ("PowderN: %s: Set multiplicity to 1 for lines [%i:%i]\n" " (d-spacing %g is duplicated %i times)\n", info->compname, list_count - mult_count, list_count - 1, list[list_count - 1].q, mult_count);); for (index = list_count - mult_count; index < list_count; list[index++].j = 1) ; mult_count = 1; q_count = q; j_count = j; F2_count = F2; } if (i == size - 1) list_count--; flag = 0; } list_count++; } /* end for */ Table_Free (&sTable); /* sort the list with increasing q */ qsort (list, list_count, sizeof (struct line_data), PN_list_compare); MPI_MASTER (printf ("PowderN: %s: Read %i reflections from file '%s'\n", info->compname, list_count, SC_file);); // remove temporary F2(hkl) file when giving CFL/CIF/ShelX file if (filename != SC_file) unlink (filename); info->list = list; info->count = list_count; return (list_count); } /* read_line_data */ /* computes the number of possible reflections (return value), and the total xsection 'sum' */ /* this routine looks for a pre-computed value in the Nq and sum cache tables */ /* when found, the earch starts from the corresponding lower element in the table */ #pragma acc routine seq int calc_xsect (double v, double* qv, double* my_sv2, int count, double* sum, struct line_info_struct* line_info) { int Nq = 0, line = 0, line0 = 0; *sum = 0; /* check if a line_info element has been recorded already - not on OpenACC */ #ifndef OPENACC if (v >= line_info->v_min && v <= line_info->v_max && line_info->neutron_passed >= CHAR_BUF_LENGTH) { line = (int)floor (v - line_info->v_min) * CHAR_BUF_LENGTH / (line_info->v_max - line_info->v_min); Nq = line_info->xs_Nq[line]; *sum = line_info->xs_sum[line]; if (!Nq && *sum == 0) { /* not yet set: we compute the sum up to the corresponding speed in the table cache */ double line_v = line_info->v_min + line * (line_info->v_max - line_info->v_min) / CHAR_BUF_LENGTH; for (line0 = 0; line0 < count; line0++) { if (qv[line0] <= 2 * line_v) { /* q < 2*kf: restrict structural range */ *sum += my_sv2[line0]; if (Nq < line0 + 1) Nq = line0 + 1; /* determine maximum line index which can scatter */ } else break; } line_info->xs_Nq[line] = Nq; line_info->xs_sum[line] = *sum; line_info->xs_compute++; } else line_info->xs_reuse++; line0 = Nq; } line_info->xs_calls++; #endif for (line = line0; line < count; line++) { if (qv[line] <= 2 * v) { /* q < 2*kf: restrict structural range */ *sum += my_sv2[line]; if (Nq < line + 1) Nq = line + 1; /* determine maximum line index which can scatter */ } else break; } return (Nq); } /* calc_xsect */ #endif /* !POWDERN_DECL */ /* Shared user declarations for all components types 'Single_crystal'. */ /* used for reading data table from file */ #ifndef OPENACC ////////////////////////////////////////////////////////////////////////////// //OpenCL lilbrary file for McStas // // global variables assigned to the OpenCL mechanism // only initialised once //Created by Jinyan LIU //Date july 2014 ////////////////////////////////////////////////////////////////////////////// #ifdef USE_OPENCL #ifndef OPENCL_LIB_H #define OPENCL_LIB_H #include <> // this structure holds the full GPU context initialised from a Kernel source file // to get if use: s = oclInitKernel(filename, 1); #define MAX_GPU_COUNT 8 struct opencl_context { cl_context GPUContext; // OpenCL context cl_command_queue CommandQueue[MAX_GPU_COUNT]; // OpenCL command queue cl_kernel Kernel; }; struct opencl_context oclInitKernel(char *filename, cl_uint nDevice); // Mersenne OCL implementation #define MT_RNG_COUNT 4096 #define MT_MM 397 #define MT_NN 624 #define MT_WMASK 0xFFFFFFFFU #define MT_UMASK 0x80000000U #define MT_LMASK 0x7fffffffU #define MT_SHIFT0 12 #define MT_SHIFTB 7 #define MT_SHIFTC 15 #define MT_SHIFT1 18 #define DCMT_SEED 4172 //////////////////////////////////////////////////////////////////////////////// //OpenCL Global Variable //////////////////////////////////////////////////////////////////////////////// struct opencl_context oclContext_mt; unsigned int **oclContext_mt_buffer=NULL; // buffer holding a list of random numbers, on the CPU cl_mem *oclContext_mt_buffer_GPU=NULL; // buffer holding a list of random numbers, on the GPU/OpenCL int oclContext_mt_counter = -2; // index of random number read from buffer void mt_srandom_opencl(unsigned long s); unsigned int mt_random_opencl(void); #endif #endif ////////////////////////////////////////////////////////////////////////////// //OpenCL lilbrary file for McStas // // global variables assigned to the OpenCL mechanism // only initialised once //Created by Jinyan LIU //Date july 2014 ////////////////////////////////////////////////////////////////////////////// #ifdef USE_OPENCL #ifndef OPENCL_LIB_C #define OPENCL_LIB_C ////////////////////////////////////////////////////////////////////////////// //! fileparts: return the name of the file between '/' and '.' //! //! @return the name of the file if succeeded, 0 otherwise //! @param name filename maybe with '/' , '\' or '.' //! ////////////////////////////////////////////////////////////////////////////// #if defined(WIN32) || defined(_WIN32) || defined(_WIN64) #define PATHSEP_C '\\' #define PATHSEP_S "\\" #else /* !WIN32 */ #define PATHSEP_C '/' #define PATHSEP_S "/" #endif /* !WIN32 */ char* fileparts(char *name) { char *Name=NULL; if (name && strlen(name)) { char *dot_pos = NULL; char *path_pos = NULL; char *end_pos = NULL; char *name_pos = NULL; size_t name_length= 0; end_pos = name+strlen(name); /* end of file name */ /* extract path: searches for last file separator */ path_pos= strrchr(name, PATHSEP_C); /* last PATHSEP */ if (!path_pos) { path_pos =name; name_pos =name; } else { name_pos = path_pos+1; /* from start to path+sep */ } /* extract ext: now looks for the 'dot' */ dot_pos = strrchr(name_pos, '.'); /* last dot */ if (dot_pos <= name_pos) dot_pos = end_pos; /* extract Name (without extension) */ name_length = dot_pos - name_pos; /* from path to dot */ if (name_length) { Name = (char*)malloc(name_length); if (Name) strncpy(Name, name_pos, name_length); Name[name_length]='\0'; } } /* if (name) */ return (Name); } /* fileparts */ ////////////////////////////////////////////////////////////////////////////// //! oclLoadProgSource: Loads a Program file and prepends the cPreamble to the code. //! //! @return the source string if succeeded, 0 otherwise //! @param cFilename program filename //! @param cPreamble code that is prepended to the loaded file, typically a set of #defines or a header //! @param szFinalLength returned length of the code string ////////////////////////////////////////////////////////////////////////////// char* oclLoadProgSource(const char* cFilename, const char* cPreamble, size_t* szFinalLength) { // locals FILE* pFileStream = NULL; size_t szSourceLength; // open the OpenCL source code file #ifdef _WIN32 // Windows version if(fopen_s(&pFileStream, cFilename, "rb") != 0) { return NULL; } #else // Linux version pFileStream = fopen(cFilename, "rb"); if(pFileStream == 0) { return NULL; } #endif size_t szPreambleLength = strlen(cPreamble); // get the length of the source code fseek(pFileStream, 0, SEEK_END); szSourceLength = ftell(pFileStream); fseek(pFileStream, 0, SEEK_SET); // allocate a buffer for the source code string and read it in char* cSourceString = (char *)malloc(szSourceLength + szPreambleLength + 1); memcpy(cSourceString, cPreamble, szPreambleLength); if (fread((cSourceString) + szPreambleLength, szSourceLength, 1, pFileStream) != 1) { fclose(pFileStream); free(cSourceString); return NULL; } // close the file and return the total length of the combined (preamble + source) string fclose(pFileStream); if(szFinalLength != 0) { *szFinalLength = szSourceLength + szPreambleLength; } cSourceString[szSourceLength + szPreambleLength] = '\0'; return cSourceString; } /* end oclLoadProgSource */ ////////////////////////////////////////////////////////////////////////////// //! oclGetPlatformID: Gets the platform ID for NVIDIA if available, otherwise default //! //! @return the id //! @param clSelectedPlatformID OpenCL plateform ID ////////////////////////////////////////////////////////////////////////////// cl_int oclGetPlatformID(cl_platform_id* clSelectedPlatformID) { char chBuffer[1024]; cl_uint num_platforms,i; cl_platform_id* clPlatformIDs; cl_int ciErrNum; *clSelectedPlatformID = NULL; // Get OpenCL platform count ciErrNum = clGetPlatformIDs (0, NULL, &num_platforms); if (ciErrNum != CL_SUCCESS) { printf(" Error %i in clGetPlatformIDs Call !!!\n\n", ciErrNum); return -1000; } else { if(num_platforms == 0) { printf("No OpenCL platform found!\n\n"); return -2000; } else { // if there's a platform or more, make space for ID's if ((clPlatformIDs = (cl_platform_id*)malloc(num_platforms * sizeof(cl_platform_id))) == NULL) { printf("Failed to allocate memory for cl_platform ID's!\n\n"); return -3000; } // get platform info for each platform and trap the NVIDIA platform if found ciErrNum = clGetPlatformIDs (num_platforms, clPlatformIDs, NULL); printf("We found %i CL platforms, selecting the first of them:\n",num_platforms); ciErrNum = clGetPlatformInfo (clPlatformIDs[0], CL_PLATFORM_NAME, 1024, &chBuffer, NULL); if(ciErrNum == CL_SUCCESS) { printf("Platform: %s\n",chBuffer); *clSelectedPlatformID = clPlatformIDs[0]; } free(clPlatformIDs); } } return CL_SUCCESS; } /* end oclGetPlatformID */ ////////////////////////////////////////////////////////////////////////////// //! oclInit: initialize 'nDevice' GPU's //! //! @return error code or CL_SUCCESS //! @param nDevice nb of devices requested OpenCL // // This function should initialize cxGPUContext and cqCommandQueue ////////////////////////////////////////////////////////////////////////////// struct opencl_context oclInitKernel(char *filename, cl_uint nDevice) { cl_program cpProgram; // OpenCL program cl_platform_id cpPlatform; cl_device_id* cdDevices; // OpenCL device list cl_int ciErr1, ciErr2; // Error code var char *basename = NULL; const int nPerRng = 5860; // # of recurrence steps, must be even if do Box-Muller transformation const int nRand = MT_RNG_COUNT * nPerRng; // Output size cl_uint i; struct opencl_context oclContext; oclContext.GPUContext = NULL; oclContext.Kernel = NULL; ciErr1 = oclGetPlatformID(&cpPlatform); if(ciErr1 != CL_SUCCESS) return(oclContext); ciErr1 = clGetDeviceIDs(NULL, CL_DEVICE_TYPE_GPU, 0, NULL, &nDevice); cdDevices = (cl_device_id *)malloc(nDevice * sizeof(cl_device_id) ); ciErr1 =clGetDeviceIDs(NULL, CL_DEVICE_TYPE_GPU, nDevice, cdDevices, NULL); oclContext.GPUContext = clCreateContext(0, nDevice, cdDevices, NULL, NULL, &ciErr1); if(ciErr1 != CL_SUCCESS) return(oclContext); for (i = 0; i < nDevice; i++) { oclContext.CommandQueue[i] = clCreateCommandQueue(oclContext.GPUContext, cdDevices[i], 0, &ciErr1); } if (!oclContext.GPUContext) return (oclContext); /* load mersenne twister kernel source from disk */ size_t szKernelLength; // Byte size of kernel code char *cKernel = oclLoadProgSource(filename, "// My comment\n", &szKernelLength); if(cKernel == NULL) { printf("%s:%u: OpenCL error: Failed to open the OpenCL program source file %s\n", __FILE__, __LINE__, filename); return(oclContext); } cpProgram = clCreateProgramWithSource(oclContext.GPUContext, 1, (const char **)&cKernel, &szKernelLength, &ciErr1); if(ciErr1 != CL_SUCCESS) return(oclContext); if (cpProgram== NULL) { printf("%s:%u: OpenCL error: Failed to create %s OpenCL program\n", __FILE__, __LINE__, filename); return(oclContext); } ciErr1 |= clBuildProgram(cpProgram, 0, NULL, "-cl-fast-relaxed-math", NULL, NULL); if (ciErr1 !=CL_SUCCESS){ printf("%s:%u: OpenCL error: Failed to build %s kernel\n", __FILE__, __LINE__, filename); for (i=0; i < nDevice; i++) { // Determine the size of the log size_t len; clGetProgramBuildInfo(cpProgram, cdDevices[i], CL_PROGRAM_BUILD_LOG, 0, NULL, &len); // Allocate memory for the log char *build_log = (char*)malloc(len); // Get the log ciErr1 |= clGetProgramBuildInfo(cpProgram, cdDevices[i], CL_PROGRAM_BUILD_LOG, len, build_log, NULL); // Print the log printf("-------Build log-----------\n"); printf("\nBuildInfo:%s\n", build_log); free(build_log); clFinish(oclContext.CommandQueue[i]); } return(oclContext); } basename = fileparts(filename); oclContext.Kernel = clCreateKernel(cpProgram, basename, &ciErr1); free(basename); if (oclContext.Kernel == NULL || ciErr1 !=CL_SUCCESS) { printf("%s:%u: OpenCL error: Failed to create %s kernel\n", __FILE__, __LINE__, filename); return(oclContext); } for (i = 0; i < nDevice; i++) { clFinish(oclContext.CommandQueue[i]); } clReleaseProgram(cpProgram); free(cKernel); free(cdDevices); return oclContext; } /* ========================================================================== */ /* OpenCL implementation of random MersenneTwister generator */ /* ========================================================================== */ unsigned int **mt_random_opencl_fill_buffer(cl_uint nDevice, struct opencl_context oclContext) { cl_int ciErr1=0, ciErr2=0; // Error code var size_t globalWorkSize[1] = {MT_RNG_COUNT}; // 1D var for Total # of work items size_t localWorkSize[1] = {128}; // 1D var for # of work items in the work group const int nPerRng =5860; // # of recurrence steps, must be even if do Box-Muller transformation const int nRand = MT_RNG_COUNT * nPerRng; // Output size char allocate_memory=0; cl_uint iDevice,i; printf("Filling buffer\n"); /* this section launches the kernel to fill the buffer (when counter = -1) */ // Using GPU(s)... if (oclContext.Kernel == NULL || oclContext.GPUContext==NULL) return(NULL); // Initialization: load MT parameters and init host buffers if (!oclContext_mt_buffer) { // first call to this function: allocate memory allocate_memory = 1; oclContext_mt_buffer = (unsigned int**)malloc(nDevice*sizeof(unsigned int*)); if (!oclContext_mt_buffer) return NULL; for (iDevice = 0; iDevice < nDevice; oclContext_mt_buffer[iDevice++]=NULL); } // Allocate memory if (allocate_memory) for (iDevice = 0; iDevice < nDevice; iDevice++) { if (!oclContext_mt_buffer[iDevice]) oclContext_mt_buffer[iDevice] = (unsigned int*)malloc(sizeof(unsigned int)*nRand); // Host buffers for GPU output if (!oclContext_mt_buffer[iDevice]) return(NULL); } if (allocate_memory && !oclContext_mt_buffer_GPU) { oclContext_mt_buffer_GPU = (cl_mem*)malloc(nDevice*sizeof(cl_mem)); if (!oclContext_mt_buffer_GPU) return NULL; for (iDevice = 0; iDevice < nDevice; oclContext_mt_buffer_GPU[iDevice++]=NULL); } if (allocate_memory) for (iDevice = 0; iDevice < nDevice; iDevice++) { if (!oclContext_mt_buffer_GPU[iDevice]) { oclContext_mt_buffer_GPU[iDevice] = clCreateBuffer(oclContext.GPUContext, CL_MEM_READ_WRITE, sizeof(cl_uint)*nRand, NULL, &ciErr2); if (ciErr2 !=CL_SUCCESS) return(NULL); } } /* for */ for (iDevice = 0; iDevice < nDevice; iDevice++) { clFinish(oclContext.CommandQueue[iDevice]); } for (iDevice = 0; iDevice < nDevice; iDevice++) { time_t t; int seed=(int)time(&t); if (allocate_memory) { ciErr1 |= clSetKernelArg(oclContext.Kernel, 0, sizeof(cl_mem), (void*)&oclContext_mt_buffer_GPU[iDevice]); if (ciErr1 !=CL_SUCCESS) return(NULL); ciErr1 |= clSetKernelArg(oclContext.Kernel, 1, sizeof(int), (void*)&nPerRng); if (ciErr1 !=CL_SUCCESS) return(NULL); } // Each call to fill buffer must use a different seed ciErr1 |= clSetKernelArg(oclContext.Kernel, 2, sizeof(int), (void*)&seed); if (ciErr1 !=CL_SUCCESS) return(NULL); // call the Kernel with the queue ciErr1 |= clEnqueueNDRangeKernel(oclContext.CommandQueue[iDevice], oclContext.Kernel, 1, NULL, globalWorkSize, localWorkSize, 0, NULL, NULL); if (ciErr1 !=CL_SUCCESS) return (NULL); } for (iDevice = 0; iDevice < nDevice; iDevice++) { clFinish(oclContext.CommandQueue[iDevice]); } // Read back results for (iDevice = 0; iDevice < nDevice; iDevice++) { ciErr1 = clEnqueueReadBuffer(oclContext.CommandQueue[iDevice], oclContext_mt_buffer_GPU[iDevice], CL_TRUE, 0, sizeof(cl_uint) * nRand, oclContext_mt_buffer[iDevice], 0, NULL, NULL); if (ciErr1 !=CL_SUCCESS) return(NULL); } return (unsigned int**) oclContext_mt_buffer; } /* end mt_random_opencl_fill_buffer */ // main Mersenne random call --------------------------------------------------- void mt_srandom_opencl(unsigned long s) { fprintf(stderr, "%s: The GPU implementation does not support manual seed setting. Using seed=clock().\n", __FILE__); } unsigned int mt_random_opencl(void) // Should be called by others { unsigned int nDevice = 1; // Use 1st opencl Device, > 0 const int nPerRng = 5860; // # of recurrence steps, must be even if do Box-Muller transformation const int nRand = MT_RNG_COUNT * nPerRng; // Output size if (oclContext_mt_counter >= nRand) { printf("%s:%i: INFO: reached max (oclContext_mt_counter=%i)\n", __FILE__, __LINE__, oclContext_mt_counter); fflush(NULL); oclContext_mt_counter = -1; } if (oclContext_mt_counter <= -2) { /* the first time we create the OCL kernel and the buffer */ oclContext_mt = oclInitKernel("MersenneTwister.cl", nDevice); oclContext_mt_counter = -1; } // in case the OpenCL context has noot been initialized, default to serial MT if (oclContext_mt.Kernel == NULL) { return(mt_random()); } if (oclContext_mt_counter <= -1 /*|| oclContext_mt_counter >= nRand*/ ) { /* when the buffer is just created or fully read, we re-fill the buffer */ if (mt_random_opencl_fill_buffer(nDevice, oclContext_mt) == NULL) { fprintf(stderr, "%s: Could not find the OpenCL MT buffer. Using serial MT.\n", __FILE__); return(mt_random()); } oclContext_mt_counter = 0; } /* return the value of the random number read from the buffer */ printf("Rng returned %u as %u\n",oclContext_mt_counter++,oclContext_mt_buffer[nDevice-1][oclContext_mt_counter++]); return (oclContext_mt_buffer[nDevice-1][oclContext_mt_counter++]); } /* mt_random_opencl */ #endif #endif #endif /* Declare structures and functions only once in each instrument. */ #ifndef SINGLE_CRYSTAL_DECL #define SINGLE_CRYSTAL_DECL #ifndef Mosaic_AB_Undefined #define Mosaic_AB_Undefined {0,0, 0,0,0, 0,0,0} #endif #ifndef MCSX_REFL_SLIST_SIZE #define MCSX_REFL_SLIST_SIZE 128 #endif struct hkl_data { int h, k, l; /* Indices for this reflection */ double F2; /* Value of structure factor */ double tau_x, tau_y, tau_z; /* Coordinates in reciprocal space */ double tau; /* Length of (tau_x, tau_y, tau_z) */ double u1x, u1y, u1z; /* First axis of local coordinate system */ double u2x, u2y, u2z; /* Second axis of local coordinate system */ double u3x, u3y, u3z; /* Third axis of local coordinate system */ double sig123; /* The product sig1*sig2*sig3 = volume of spot */ double m1, m2, m3; /* Diagonal matrix representation of Gauss */ double cutoff; /* Cutoff value for Gaussian tails */ }; struct tau_data { int index; /* Index into reflection table */ double refl; double xsect; /* The following vectors are in local koordinates. */ double rho_x, rho_y, rho_z; /* The vector ki - tau */ double rho; /* Length of rho vector */ double ox, oy, oz; /* Origin of Ewald sphere tangent plane */ double b1x, b1y, b1z; /* Spanning vectors of Ewald sphere tangent */ double b2x, b2y, b2z; double l11, l12, l22; /* Cholesky decomposition L of 2D Gauss */ double y0x, y0y; /* 2D Gauss center in tangent plane */ }; struct hkl_info_struct { int count; /* Number of reflections */ double m_delta_d_d; /* Delta-d/d FWHM */ double m_ax, m_ay, m_az; /* First unit cell axis (direct space, AA) */ double m_bx, m_by, m_bz; /* Second unit cell axis */ double m_cx, m_cy, m_cz; /* Third unit cell axis */ double asx, asy, asz; /* First reciprocal lattice axis (1/AA) */ double bsx, bsy, bsz; /* Second reciprocal lattice axis */ double csx, csy, csz; /* Third reciprocal lattice axis */ double m_a, m_b, m_c; /* length of lattice parameter lengths */ double m_aa, m_bb, m_cc; /* lattice angles */ double sigma_a, sigma_i; /* abs and inc X sect */ double rho; /* density */ double at_weight; /* atomic weight */ double at_nb; /* nb of atoms in a cell */ double V0; /* Unit cell volume (AA**3) */ int column_order[5]; /* column signification [h,k,l,F,F2] */ int recip; /* Flag to indicate if recip or direct cell axes given */ int shape; /* 0:cylinder, 1:box, 2:sphere 3:any shape*/ int flag_warning; /* number of warnings */ int flag_barns; /* 1: F2 in barns, 0: in fm^2 */ char type; /* type of last event: t=transmit,c=coherent or i=incoherent */ int h, k, l; /* last coherent scattering momentum transfer indices */ int tau_count; /* Number of reflections within cutoff */ double coh_refl, coh_xsect; /* cross section computed with last tau_list */ double kix, kiy, kiz; /* last incoming neutron ki */ int nb_reuses, nb_refl, nb_refl_count; int max_tau_count; }; #pragma acc routine int SX_list_compare (void const* a, void const* b) { struct hkl_data const* pa = a; struct hkl_data const* pb = b; /* Sort by tau */ if (pa->tau < pb->tau) return -1; if (pa->tau > pb->tau) return 1; /* Sort by tau_x */ if (pa->tau_x < pb->tau_x) return -1; if (pa->tau_x > pb->tau_x) return 1; /* Sort by tau_y */ if (pa->tau_y < pb->tau_y) return -1; if (pa->tau_y > pb->tau_y) return 1; /* Sort by tau_z */ if (pa->tau_z < pb->tau_z) return -1; if (pa->tau_z > pb->tau_z) return 1; /* In case of tie, sort by F2 also */ if (pa->F2 < pb->F2) return -1; if (pa->F2 > pb->F2) return 1; return 0; } /* SX_list_compare */ #ifndef CIF2HKL #define CIF2HKL // hkl_filename = cif2hkl(file, options) // used to convert CIF/CFL/INS file into F2(hkl) // the CIF2HKL env var can point to a cif2hkl executable // else the McCode binary is attempted, then the system. char* cif2hkl (char* infile, char* options) { char cmd[1024]; int ret = 0; int found = 0; char* OUTFILE; char* inpath; // get filename extension const char* ext = strrchr (infile, '.'); if (!ext || ext == infile) return infile; else ext++; // return input when no extension or not a CIF/FullProf/ShelX file if (strcasecmp (ext, "cif") && strcasecmp (ext, "pcr") && strcasecmp (ext, "cfl") && strcasecmp (ext, "shx") && strcasecmp (ext, "ins") && strcasecmp (ext, "res")) return infile; OUTFILE = malloc (1024); if (!OUTFILE) { free (OUTFILE); return infile; } inpath = malloc (1024); if (!inpath) { free (OUTFILE); free (inpath); return infile; } // get input file path from read-table:Open_File FILE* f_infile = Open_File (infile, "r", inpath); if (!f_infile) { free (OUTFILE); free (inpath); free (f_infile); return infile; } fclose (f_infile); strncpy (OUTFILE, tmpnam (NULL), 1024); // create an output temporary file name // try in order the CIF2HKL env var, then the system cif2hkl, then the McCode one if (!found && getenv ("CIF2HKL")) { snprintf (cmd, 1024, "%s -o %s %s %s", getenv ("CIF2HKL"), OUTFILE, options, inpath); ret = system (cmd); if (ret != -1 && ret != 127) found = 1; } if (!found) { // try with cif2hkl command from the system PATH snprintf (cmd, 1024, "%s -o %s %s %s", "cif2hkl", OUTFILE, options, inpath); ret = system (cmd); if (ret != -1 && ret != 127) found = 1; } if (!found) { // As a last resort, attempt with cif2hkl from $MCSTAS/bin snprintf (cmd, 1024, "%s%c%s%c%s -o %s %s %s", getenv (FLAVOR_UPPER) ? getenv (FLAVOR_UPPER) : MCSTAS, MC_PATHSEP_C, "bin", MC_PATHSEP_C, "cif2hkl", OUTFILE, options, inpath); ret = system (cmd); } // ret = -1: child process could not be created // ret = 127: shell could not be executed in the child process if (ret == -1 || ret == 127) { free (OUTFILE); return (NULL); } // test if the result file has been created FILE* file = fopen (OUTFILE, "r"); if (!file) { free (OUTFILE); return (NULL); } MPI_MASTER (printf ("%s: INFO: Converting %s into F2(HKL) list %s\n", __FILE__, infile, OUTFILE); printf ("%s\n", cmd);); fflush (NULL); fclose (file); return (OUTFILE); } // cif2hkl #endif /* ------------------------------------------------------------------------ */ int read_hkl_data (char* SC_file, struct hkl_info_struct* info, struct hkl_data** hkl_list, double SC_mosaic, double SC_mosaic_a, double SC_mosaic_b, double SC_mosaic_c, double* SC_mosaic_AB) { struct hkl_data* list = NULL; int size = 0; t_Table sTable; /* sample data table structure from SC_file */ int i = 0; double tmp_x, tmp_y, tmp_z; char** parsing; char flag = 0; double nb_atoms = 1; char* filename = NULL; if (!SC_file || !strlen (SC_file) || !strcmp (SC_file, "NULL") || !strcmp (SC_file, "0")) { info->count = 0; flag = 1; } if (!flag) { filename = cif2hkl (SC_file, "--xtal --mode NUC"); if (filename != SC_file) info->flag_barns = 1; // cif2hkl returns barns Table_Read (&sTable, filename, 1); /* read 1st block data from SC_file into sTable*/ if (sTable.columns < 4) { fprintf (stderr, "Single_crystal: Error: The number of columns in %s should be at least %d for [h,k,l,F2]\n", SC_file, 4); return (0); } if (!sTable.rows) { fprintf (stderr, "Single_crystal: Error: The number of rows in %s should be at least %d\n", SC_file, 1); return (0); } else size = sTable.rows; /* parsing of header */ parsing = Table_ParseHeader (sTable.header, "sigma_abs", "sigma_a ", "sigma_inc", "sigma_i ", "column_h", "column_k", "column_l", "column_F ", "column_F2", "Delta_d/d", "lattice_a ", "lattice_b ", "lattice_c ", "lattice_aa", "lattice_bb", "lattice_cc", "nb_atoms", "multiplicity", NULL); if (parsing) { if (parsing[0] && !info->sigma_a) info->sigma_a = atof (parsing[0]); if (parsing[1] && !info->sigma_a) info->sigma_a = atof (parsing[1]); if (parsing[2] && !info->sigma_i) info->sigma_i = atof (parsing[2]); if (parsing[3] && !info->sigma_i) info->sigma_i = atof (parsing[3]); if (parsing[4]) info->column_order[0] = atoi (parsing[4]); if (parsing[5]) info->column_order[1] = atoi (parsing[5]); if (parsing[6]) info->column_order[2] = atoi (parsing[6]); if (parsing[7]) info->column_order[3] = atoi (parsing[7]); if (parsing[8]) info->column_order[4] = atoi (parsing[8]); if (parsing[9] && info->m_delta_d_d < 0) info->m_delta_d_d = atof (parsing[9]); if (parsing[10] && !info->m_a) info->m_a = atof (parsing[10]); if (parsing[11] && !info->m_b) info->m_b = atof (parsing[11]); if (parsing[12] && !info->m_c) info->m_c = atof (parsing[12]); if (parsing[13] && !info->m_aa) info->m_aa = atof (parsing[13]); if (parsing[14] && !info->m_bb) info->m_bb = atof (parsing[14]); if (parsing[15] && !info->m_cc) info->m_cc = atof (parsing[15]); if (parsing[16]) nb_atoms = atof (parsing[16]); if (parsing[17]) nb_atoms = atof (parsing[17]); for (i = 0; i <= 17; i++) if (parsing[i]) free (parsing[i]); free (parsing); } } if (nb_atoms > 1) { info->sigma_a *= nb_atoms; info->sigma_i *= nb_atoms; } /* special cases for the structure definition */ if (info->m_ax || info->m_ay || info->m_az) { info->m_a = 0; info->m_aa = 0; } /* means we specify by hand the vectors */ if (info->m_bx || info->m_by || info->m_bz) { info->m_b = 0; info->m_bb = 0; } if (info->m_cx || info->m_cy || info->m_cz) { info->m_c = 0; info->m_cc = 0; }; /* compute the norm from vector a if missing */ if (info->m_ax || info->m_ay || info->m_az) { double as = sqrt (info->m_ax * info->m_ax + info->m_ay * info->m_ay + info->m_az * info->m_az); if (!info->m_bx && !info->m_by && !info->m_bz) info->m_a = info->m_b = as; if (!info->m_cx && !info->m_cy && !info->m_cz) info->m_a = info->m_c = as; } if (info->m_a && !info->m_b) info->m_b = info->m_a; if (info->m_b && !info->m_c) info->m_c = info->m_b; /* compute the lattive angles if not set from data file. Not used when in vector mode. */ if (info->m_a && !info->m_aa) info->m_aa = 90; if (info->m_aa && !info->m_bb) info->m_bb = info->m_aa; if (info->m_bb && !info->m_cc) info->m_cc = info->m_bb; /* parameters consistency checks */ if (!info->m_ax && !info->m_ay && !info->m_az && !info->m_a) { fprintf (stderr, "Single_crystal: Error: Wrong a lattice vector definition\n"); return (0); } if (!info->m_bx && !info->m_by && !info->m_bz && !info->m_b) { fprintf (stderr, "Single_crystal: Error: Wrong b lattice vector definition\n"); return (0); } if (!info->m_cx && !info->m_cy && !info->m_cz && !info->m_c) { fprintf (stderr, "Single_crystal: Error: Wrong c lattice vector definition\n"); return (0); } if (info->m_aa && info->m_bb && info->m_cc && info->recip) { fprintf (stderr, "Single_crystal: Error: Selecting reciprocal cell and angles is unmeaningful\n"); return (0); } /* when lengths a,b,c + angles are given (instead of vectors a,b,c) */ if (info->m_aa && info->m_bb && info->m_cc) { MPI_MASTER (printf ("Mode: lengths and angles\n");); double as, bs, cs; if (info->m_a) as = info->m_a; else as = sqrt (info->m_ax * info->m_ax + info->m_ay * info->m_ay + info->m_az * info->m_az); if (info->m_b) bs = info->m_b; else bs = sqrt (info->m_bx * info->m_bx + info->m_by * info->m_by + info->m_bz * info->m_bz); if (info->m_c) cs = info->m_c; else cs = sqrt (info->m_cx * info->m_cx + info->m_cy * info->m_cy + info->m_cz * info->m_cz); info->m_bz = as; info->m_by = 0; info->m_bx = 0; info->m_az = bs * cos (info->m_cc * DEG2RAD); info->m_ay = bs * sin (info->m_cc * DEG2RAD); info->m_ax = 0; info->m_cz = cs * cos (info->m_bb * DEG2RAD); info->m_cy = cs * (cos (info->m_aa * DEG2RAD) - cos (info->m_cc * DEG2RAD) * cos (info->m_bb * DEG2RAD)) / sin (info->m_cc * DEG2RAD); info->m_cx = sqrt (cs * cs - info->m_cz * info->m_cz - info->m_cy * info->m_cy); MPI_MASTER ( printf ("Single_crystal: %s structure a=%g b=%g c=%g aa=%g bb=%g cc=%g ", (flag ? "INC" : SC_file), as, bs, cs, info->m_aa, info->m_bb, info->m_cc);); } else { if (!info->recip) { MPI_MASTER (printf ("Mode: Direct mode lattice\n"); printf ("Single_crystal: %s structure a=[%g,%g,%g] b=[%g,%g,%g] c=[%g,%g,%g] ", (flag ? "INC" : SC_file), info->m_ax, info->m_ay, info->m_az, info->m_bx, info->m_by, info->m_bz, info->m_cx, info->m_cy, info->m_cz);); } else { MPI_MASTER (printf ("Mode: Reciprocal mode lattice\n"); printf ("Single_crystal: %s structure a*=[%g,%g,%g] b*=[%g,%g,%g] c*=[%g,%g,%g] ", (flag ? "INC" : SC_file), info->m_ax, info->m_ay, info->m_az, info->m_bx, info->m_by, info->m_bz, info->m_cx, info->m_cy, info->m_cz);); } } /* Compute reciprocal or direct lattice vectors. */ if (!info->recip) { vec_prod (tmp_x, tmp_y, tmp_z, info->m_bx, info->m_by, info->m_bz, info->m_cx, info->m_cy, info->m_cz); info->V0 = fabs (scalar_prod (info->m_ax, info->m_ay, info->m_az, tmp_x, tmp_y, tmp_z)); MPI_MASTER (printf ("V0=%g\n", info->V0);); info->asx = 2 * PI / info->V0 * tmp_x; info->asy = 2 * PI / info->V0 * tmp_y; info->asz = 2 * PI / info->V0 * tmp_z; vec_prod (tmp_x, tmp_y, tmp_z, info->m_cx, info->m_cy, info->m_cz, info->m_ax, info->m_ay, info->m_az); info->bsx = 2 * PI / info->V0 * tmp_x; info->bsy = 2 * PI / info->V0 * tmp_y; info->bsz = 2 * PI / info->V0 * tmp_z; vec_prod (tmp_x, tmp_y, tmp_z, info->m_ax, info->m_ay, info->m_az, info->m_bx, info->m_by, info->m_bz); info->csx = 2 * PI / info->V0 * tmp_x; info->csy = 2 * PI / info->V0 * tmp_y; info->csz = 2 * PI / info->V0 * tmp_z; } else { info->asx = info->m_ax; info->asy = info->m_ay; info->asz = info->m_az; info->bsx = info->m_bx; info->bsy = info->m_by; info->bsz = info->m_bz; info->csx = info->m_cx; info->csy = info->m_cy; info->csz = info->m_cz; vec_prod (tmp_x, tmp_y, tmp_z, info->bsx / (2 * PI), info->bsy / (2 * PI), info->bsz / (2 * PI), info->csx / (2 * PI), info->csy / (2 * PI), info->csz / (2 * PI)); info->V0 = 1 / fabs (scalar_prod (info->asx / (2 * PI), info->asy / (2 * PI), info->asz / (2 * PI), tmp_x, tmp_y, tmp_z)); MPI_MASTER (printf ("V0=%g\n", info->V0);); /*compute the direct cell parameters, ofr completeness*/ info->m_ax = tmp_x * info->V0; info->m_ay = tmp_y * info->V0; info->m_az = tmp_z * info->V0; vec_prod (tmp_x, tmp_y, tmp_z, info->csx / (2 * PI), info->csy / (2 * PI), info->csz / (2 * PI), info->asx / (2 * PI), info->asy / (2 * PI), info->asz / (2 * PI)); info->m_bx = tmp_x * info->V0; info->m_by = tmp_y * info->V0; info->m_bz = tmp_z * info->V0; vec_prod (tmp_x, tmp_y, tmp_z, info->asx / (2 * PI), info->asy / (2 * PI), info->asz / (2 * PI), info->bsx / (2 * PI), info->bsy / (2 * PI), info->bsz / (2 * PI)); info->m_cx = tmp_x * info->V0; info->m_cy = tmp_y * info->V0; info->m_cz = tmp_z * info->V0; } if (flag) return (-1); if (!info->column_order[0] || !info->column_order[1] || !info->column_order[2]) { fprintf (stderr, "Single_crystal: Error: Wrong h,k,l column definition\n"); return (0); } if (!info->column_order[3] && !info->column_order[4]) { fprintf (stderr, "Single_crystal: Error: Wrong F,F2 column definition\n"); return (0); } /* allocate hkl_data array */ list = (struct hkl_data*)malloc (size * sizeof (struct hkl_data)); if (!list) { fprintf (stderr, "Single_crystal: Error allocating reflection list\n"); return (0); } for (i = 0; i < size; i++) { double h = 0, k = 0, l = 0, F2 = 0; double b1[3], b2[3]; double sig1, sig2, sig3; /* get data from table */ h = Table_Index (sTable, i, info->column_order[0] - 1); k = Table_Index (sTable, i, info->column_order[1] - 1); l = Table_Index (sTable, i, info->column_order[2] - 1); if (info->column_order[3]) { F2 = Table_Index (sTable, i, info->column_order[3] - 1); F2 *= F2; } else if (info->column_order[4]) F2 = Table_Index (sTable, i, info->column_order[4] - 1); list[i].h = h; list[i].k = k; list[i].l = l; list[i].F2 = F2; /* Precompute some values */ list[i].tau_x = h * info->asx + k * info->bsx + l * info->csx; list[i].tau_y = h * info->asy + k * info->bsy + l * info->csy; list[i].tau_z = h * info->asz + k * info->bsz + l * info->csz; list[i].tau = sqrt (list[i].tau_x * list[i].tau_x + list[i].tau_y * list[i].tau_y + list[i].tau_z * list[i].tau_z); list[i].u1x = list[i].tau_x / list[i].tau; list[i].u1y = list[i].tau_y / list[i].tau; list[i].u1z = list[i].tau_z / list[i].tau; sig1 = FWHM2RMS * info->m_delta_d_d * list[i].tau; /* Find two arbitrary axes perpendicular to tau and each other. */ normal_vec (&b1[0], &b1[1], &b1[2], list[i].u1x, list[i].u1y, list[i].u1z); vec_prod (b2[0], b2[1], b2[2], list[i].u1x, list[i].u1y, list[i].u1z, b1[0], b1[1], b1[2]); /* Find the two mosaic axes perpendicular to tau. */ if (SC_mosaic > 0) { /* Use isotropic mosaic. */ list[i].u2x = b1[0]; list[i].u2y = b1[1]; list[i].u2z = b1[2]; sig2 = FWHM2RMS * list[i].tau * MIN2RAD * SC_mosaic; list[i].u3x = b2[0]; list[i].u3y = b2[1]; list[i].u3z = b2[2]; sig3 = FWHM2RMS * list[i].tau * MIN2RAD * SC_mosaic; } else if (SC_mosaic_a > 0 && SC_mosaic_b > 0 && SC_mosaic_c > 0) { /* Use anisotropic mosaic. */ fprintf (stderr, "Single_crystal: Warning: you are using an experimental feature:\n" " anistropic mosaicity. Please examine your data carefully.\n"); /* compute the jacobian of (tau_v,tau_n) from rotations around the unit cell vectors. */ struct hkl_data* l = &(list[i]); double xia_x, xia_y, xia_z, xib_x, xib_y, xib_z, xic_x, xic_y, xic_z; /*input parameters are in arc minutes*/ double sig_fi_a = SC_mosaic_a * MIN2RAD; double sig_fi_b = SC_mosaic_b * MIN2RAD; double sig_fi_c = SC_mosaic_c * MIN2RAD; if (info->m_a == 0) info->m_a = sqrt (scalar_prod (info->m_ax, info->m_ay, info->m_az, info->m_ax, info->m_ay, info->m_az)); if (info->m_b == 0) info->m_b = sqrt (scalar_prod (info->m_bx, info->m_by, info->m_bz, info->m_bx, info->m_by, info->m_bz)); if (info->m_c == 0) info->m_c = sqrt (scalar_prod (info->m_cx, info->m_cy, info->m_cz, info->m_cx, info->m_cy, info->m_cz)); l->u2x = b1[0]; l->u2y = b1[1]; l->u2z = b1[2]; l->u3x = b2[0]; l->u3y = b2[1]; l->u3z = b2[2]; xia_x = l->tau_x - (M_2_PI * h / info->m_a) * info->asx; xia_y = l->tau_y - (M_2_PI * h / info->m_a) * info->asy; xia_z = l->tau_z - (M_2_PI * h / info->m_a) * info->asz; xib_x = l->tau_x - (M_2_PI * h / info->m_b) * info->bsx; xib_y = l->tau_y - (M_2_PI * h / info->m_b) * info->bsy; xib_z = l->tau_z - (M_2_PI * h / info->m_b) * info->bsz; xic_x = l->tau_x - (M_2_PI * h / info->m_c) * info->csx; xic_y = l->tau_y - (M_2_PI * h / info->m_c) * info->csy; xic_z = l->tau_z - (M_2_PI * h / info->m_c) * info->csz; double xia = sqrt (xia_x * xia_x + xia_y * xia_y + xia_z * xia_z); double xib = sqrt (xib_x * xib_x + xib_y * xib_y + xib_z * xib_z); double xic = sqrt (xic_x * xic_x + xic_y * xic_y + xic_z * xic_z); vec_prod (tmp_x, tmp_y, tmp_z, l->tau_x, l->tau_y, l->tau_z, l->u2x, l->u2y, l->u2z); double J_n_fia = xia / info->m_a / l->tau * scalar_prod (info->asx, info->asy, info->asz, tmp_x, tmp_y, tmp_z); vec_prod (tmp_x, tmp_y, tmp_z, l->tau_x, l->tau_y, l->tau_z, l->u2x, l->u2y, l->u2z); double J_n_fib = xib / info->m_b / l->tau * scalar_prod (info->bsx, info->bsy, info->bsz, tmp_x, tmp_y, tmp_z); vec_prod (tmp_x, tmp_y, tmp_z, l->tau_x, l->tau_y, l->tau_z, l->u2x, l->u2y, l->u2z); double J_n_fic = xic / info->m_c / l->tau * scalar_prod (info->csx, info->csy, info->csz, tmp_x, tmp_y, tmp_z); vec_prod (tmp_x, tmp_y, tmp_z, l->tau_x, l->tau_y, l->tau_z, l->u3x, l->u3y, l->u3z); double J_v_fia = xia / info->m_a / l->tau * scalar_prod (info->asx, info->asy, info->asz, tmp_x, tmp_y, tmp_z); vec_prod (tmp_x, tmp_y, tmp_z, l->tau_x, l->tau_y, l->tau_z, l->u3x, l->u3y, l->u3z); double J_v_fib = xib / info->m_b / l->tau * scalar_prod (info->bsx, info->bsy, info->bsz, tmp_x, tmp_y, tmp_z); vec_prod (tmp_x, tmp_y, tmp_z, l->tau_x, l->tau_y, l->tau_z, l->u3x, l->u3y, l->u3z); double J_v_fic = xic / info->m_c / l->tau * scalar_prod (info->csx, info->csy, info->csz, tmp_x, tmp_y, tmp_z); /*with the jacobian we can compute the sigmas in terms of the orthogonal vectors u2 and u3*/ sig2 = sig_fi_a * fabs (J_v_fia) + sig_fi_b * fabs (J_v_fib) + sig_fi_c * fabs (J_v_fic); sig3 = sig_fi_a * fabs (J_n_fia) + sig_fi_b * fabs (J_n_fib) + sig_fi_c * fabs (J_n_fic); } else if (SC_mosaic_AB[0] != 0 && SC_mosaic_AB[1] != 0) { if ((SC_mosaic_AB[2] == 0 && SC_mosaic_AB[3] == 0 && SC_mosaic_AB[4] == 0) || (SC_mosaic_AB[5] == 0 && SC_mosaic_AB[6] == 0 && SC_mosaic_AB[7] == 0)) { fprintf (stderr, "Single_crystal: Error: in-plane mosaics are specified but one (or both)\n" " in-plane reciprocal vector is the zero vector\n"); return (0); } fprintf (stderr, "Single_crystal: Warning: you are using an experimental feature: \n" " \"in-plane\" anistropic mosaicity. Please examine your data carefully.\n"); /*for given reflection in list - compute linear comb of tau_a and tau_b*/ /*check for not in plane - f.i. check if (tau_a X tau_b).tau_i)==0*/ struct hkl_data* l = &(list[i]); double det, c1, c2, sig_tau_c; double em_x, em_y, em_z, tmp_x, tmp_y, tmp_z; double tau_a[3], tau_b[3]; /*convert Miller indices to taus*/ if (info->m_a == 0) info->m_a = sqrt (scalar_prod (info->m_ax, info->m_ay, info->m_az, info->m_ax, info->m_ay, info->m_az)); if (info->m_b == 0) info->m_b = sqrt (scalar_prod (info->m_bx, info->m_by, info->m_bz, info->m_bx, info->m_by, info->m_bz)); if (info->m_c == 0) info->m_c = sqrt (scalar_prod (info->m_cx, info->m_cy, info->m_cz, info->m_cx, info->m_cy, info->m_cz)); tau_a[0] = M_2_PI * ((SC_mosaic_AB[2] / info->m_a) * info->asx + (SC_mosaic_AB[3] / info->m_b) * info->bsx + (SC_mosaic_AB[4] / info->m_c) * info->csx); tau_a[1] = M_2_PI * ((SC_mosaic_AB[2] / info->m_a) * info->asy + (SC_mosaic_AB[3] / info->m_b) * info->bsy + (SC_mosaic_AB[4] / info->m_c) * info->csy); tau_a[2] = M_2_PI * ((SC_mosaic_AB[2] / info->m_a) * info->asz + (SC_mosaic_AB[3] / info->m_b) * info->bsz + (SC_mosaic_AB[4] / info->m_c) * info->csz); tau_b[0] = M_2_PI * ((SC_mosaic_AB[5] / info->m_a) * info->asx + (SC_mosaic_AB[6] / info->m_b) * info->bsx + (SC_mosaic_AB[7] / info->m_c) * info->csx); tau_b[1] = M_2_PI * ((SC_mosaic_AB[5] / info->m_a) * info->asy + (SC_mosaic_AB[6] / info->m_b) * info->bsy + (SC_mosaic_AB[7] / info->m_c) * info->csy); tau_b[2] = M_2_PI * ((SC_mosaic_AB[5] / info->m_a) * info->asz + (SC_mosaic_AB[6] / info->m_b) * info->bsz + (SC_mosaic_AB[7] / info->m_c) * info->csz); /*check determinants to see how we should compute the linear combination of a and b (to match c)*/ c1 = c2 = 0; if ((det = tau_a[0] * tau_b[1] - tau_a[1] * tau_b[0]) != 0) { c1 = (l->tau_x * tau_b[1] - l->tau_y * tau_b[0]) / det; c2 = (tau_a[0] * l->tau_y - tau_a[1] * l->tau_x) / det; } else if ((det = tau_a[1] * tau_b[2] - tau_a[2] * tau_b[1]) != 0) { c1 = (l->tau_y * tau_b[2] - l->tau_z * tau_b[1]) / det; c2 = (tau_a[1] * l->tau_z - tau_a[2] * l->tau_y) / det; } else if ((det = tau_a[0] * tau_b[2] - tau_a[2] * tau_b[0]) != 0) { c1 = (l->tau_x * tau_b[2] - l->tau_z * tau_b[0]) / det; c2 = (tau_a[0] * l->tau_z - tau_a[2] * l->tau_x) / det; } if ((c1 == 0) && (c2 == 0)) { fprintf (stderr, "Single_crystal: Warning: reflection tau[%i]=(%g %g %g) " "has no component in defined mosaic plane\n", i, l->tau_x, l->tau_y, l->tau_z); } /*compute linear combination => sig_tau_i = | c1*sig_tau_a + c2*sig_tau_b | - also add in the minute to radian scaling factor*/; sig_tau_c = MIN2RAD * sqrt (c1 * SC_mosaic_AB[0] * c1 * SC_mosaic_AB[0] + c2 * SC_mosaic_AB[1] * c2 * SC_mosaic_AB[1]); l->u2x = b1[0]; l->u2y = b1[1]; l->u2z = b1[2]; l->u3x = b2[0]; l->u3y = b2[1]; l->u3z = b2[2]; /*so now let's compute the rotation around planenormal tau_a X tau_b*/ /*g_bar (unit normal of rotation plane) = tau_a X tau_b / norm(tau_a X tau_b)*/ vec_prod (tmp_x, tmp_y, tmp_z, tau_a[0], tau_a[1], tau_a[2], tau_b[0], tau_b[1], tau_b[2]); vec_prod (em_x, em_y, em_z, l->tau_x, l->tau_y, l->tau_z, tmp_x, tmp_y, tmp_z); NORM (em_x, em_y, em_z); sig2 = l->tau * sig_tau_c * fabs (scalar_prod (em_x, em_y, em_z, l->u2x, l->u2y, l->u2z)); sig3 = l->tau * sig_tau_c * fabs (scalar_prod (em_x, em_y, em_z, l->u3x, l->u3y, l->u3z)); /*protect against collapsing gaussians. These seem to be sensible values.*/ if (sig2 < 1e-5) sig2 = 1e-5; if (sig3 < 1e-5) sig3 = 1e-5; } else { fprintf (stderr, "Single_crystal: Error: EITHER mosaic OR (mosaic_a, mosaic_b, mosaic_c)\n" " must be given and be >0.\n"); return (0); } list[i].sig123 = sig1 * sig2 * sig3; list[i].m1 = 1 / (2 * sig1 * sig1); list[i].m2 = 1 / (2 * sig2 * sig2); list[i].m3 = 1 / (2 * sig3 * sig3); /* Set Gauss cutoff to 5 times the maximal sigma. */ if (sig1 > sig2) if (sig1 > sig3) list[i].cutoff = 5 * sig1; else list[i].cutoff = 5 * sig3; else if (sig2 > sig3) list[i].cutoff = 5 * sig2; else list[i].cutoff = 5 * sig3; } Table_Free (&sTable); /* sort the list with increasing tau */ qsort (list, i, sizeof (struct hkl_data), SX_list_compare); *hkl_list = list; info->count = i; // remove temporary F2(hkl) file when giving CFL/CIF/ShelX file if (filename != SC_file) unlink (filename); return (info->count); } /* read_hkl_data */ /* ------------------------------------------------------------------------ */ /* hkl_search search the HKL reflections which are on the Ewald sphere input: L,T,count,V0: constants for all calls kix,kiy,kiz: may be different for each call this function returns: tau_count (return), coh_refl, coh_xsect, T (updated elements in the array up to [j]) */ #pragma acc routine int hkl_search (struct hkl_data* L, void* TT, int count, double V0, double kix, double kiy, double kiz, double tau_max, double* coh_refl, double* coh_xsect) { double rho, rho_x, rho_y, rho_z; double diff; int i, j; double ox, oy, oz; double b1x, b1y, b1z, b2x, b2y, b2z, kx, ky, kz, nx, ny, nz; double n11, n22, n12, det_N, inv_n11, inv_n22, inv_n12, l11, l22, l12, det_L; double Bt_D_O_x, Bt_D_O_y, y0x, y0y, alpha; double ki = sqrt (kix * kix + kiy * kiy + kiz * kiz); int jglobal = -1; double coherent_refl, coherent_xsect; struct tau_data* T = (struct tau_data*)TT; // coherent_refl = *coh_refl; // coherent_xsect = *coh_xsect; coherent_refl = 0; coherent_xsect = 0; /* Common factor in coherent cross-section */ double xsect_factor = pow (2 * PI, 5.0 / 2.0) / (V0 * ki * ki); j = 0; for (i = 0; i < count; i++) { /* Assuming reflections are sorted, stop search when max tau exceeded. */ if (L[i].tau > tau_max) break; /* Check if this reciprocal lattice point is close enough to the Ewald sphere to make scattering possible. */ rho_x = kix - L[i].tau_x; rho_y = kiy - L[i].tau_y; rho_z = kiz - L[i].tau_z; rho = sqrt (rho_x * rho_x + rho_y * rho_y + rho_z * rho_z); diff = fabs (rho - ki); /* Check if scattering is possible (cutoff of Gaussian tails). */ if (diff <= L[i].cutoff) { /* Store reflection. */ T[j].index = i; /* Get ki vector in local coordinates. */ kx = kix * L[i].u1x + kiy * L[i].u1y + kiz * L[i].u1z; ky = kix * L[i].u2x + kiy * L[i].u2y + kiz * L[i].u2z; kz = kix * L[i].u3x + kiy * L[i].u3y + kiz * L[i].u3z; T[j].rho_x = kx - L[i].tau; T[j].rho_y = ky; T[j].rho_z = kz; T[j].rho = rho; /* Compute the tangent plane of the Ewald sphere. */ nx = T[j].rho_x / T[j].rho; ny = T[j].rho_y / T[j].rho; nz = T[j].rho_z / T[j].rho; ox = (ki - T[j].rho) * nx; oy = (ki - T[j].rho) * ny; oz = (ki - T[j].rho) * nz; T[j].ox = ox; T[j].oy = oy; T[j].oz = oz; /* Compute unit vectors b1 and b2 that span the tangent plane. */ normal_vec (&b1x, &b1y, &b1z, nx, ny, nz); vec_prod (b2x, b2y, b2z, nx, ny, nz, b1x, b1y, b1z); T[j].b1x = b1x; T[j].b1y = b1y; T[j].b1z = b1z; T[j].b2x = b2x; T[j].b2y = b2y; T[j].b2z = b2z; /* Compute the 2D projection of the 3D Gauss of the reflection. */ /* The symmetric 2x2 matrix N describing the 2D gauss. */ n11 = L[i].m1 * b1x * b1x + L[i].m2 * b1y * b1y + L[i].m3 * b1z * b1z; n12 = L[i].m1 * b1x * b2x + L[i].m2 * b1y * b2y + L[i].m3 * b1z * b2z; n22 = L[i].m1 * b2x * b2x + L[i].m2 * b2y * b2y + L[i].m3 * b2z * b2z; /* The (symmetric) inverse matrix of N. */ det_N = n11 * n22 - n12 * n12; inv_n11 = n22 / det_N; inv_n12 = -n12 / det_N; inv_n22 = n11 / det_N; /* The Cholesky decomposition of 1/2*inv_n (lower triangular L). */ l11 = sqrt (inv_n11 / 2); l12 = inv_n12 / (2 * l11); l22 = sqrt (inv_n22 / 2 - l12 * l12); T[j].l11 = l11; T[j].l12 = l12; T[j].l22 = l22; det_L = l11 * l22; /* The product B^T D o. */ Bt_D_O_x = b1x * L[i].m1 * ox + b1y * L[i].m2 * oy + b1z * L[i].m3 * oz; Bt_D_O_y = b2x * L[i].m1 * ox + b2y * L[i].m2 * oy + b2z * L[i].m3 * oz; /* Center of 2D Gauss in plane coordinates. */ y0x = -(Bt_D_O_x * inv_n11 + Bt_D_O_y * inv_n12); y0y = -(Bt_D_O_x * inv_n12 + Bt_D_O_y * inv_n22); T[j].y0x = y0x; T[j].y0y = y0y; /* Factor alpha for the distance of the 2D Gauss from the origin. */ alpha = L[i].m1 * ox * ox + L[i].m2 * oy * oy + L[i].m3 * oz * oz - (y0x * y0x * n11 + y0y * y0y * n22 + 2 * y0x * y0y * n12); T[j].refl = xsect_factor * det_L * exp (-alpha) / L[i].sig123; /* intensity of that Bragg */ *coh_refl += T[j].refl; /* total scatterable intensity*/ T[j].xsect = T[j].refl * L[i].F2; *coh_xsect += T[j].xsect; j++; } /*protect against tau shortlist buffer overrrun*/ if (j == MCSX_REFL_SLIST_SIZE) { break; } } /* end for */ return (j); // this is 'tau_count', i.e. number of reachable reflections } /* end hkl_search */ #pragma acc routine int hkl_select (struct tau_data* T, int tau_count, double coh_refl, double* sum, _class_particle* _particle) { int j; double r = rand0max (coh_refl); *sum = 0; for (j = 0; j < tau_count; j++) { *sum += T[j].refl; if (*sum > r) break; } return j; } /* Functions for "reorientation", powder and PG modes */ /* Powder, forward */ #pragma acc routine void randrotate (double* nx, double* ny, double* nz, double a, double b, double c) { double x1, y1, z1, x2, y2, z2; rotate (x1, y1, z1, *nx, *ny, *nz, a, 1, 0, 0); /* <1> = rot(,a) */ rotate (x2, y2, z2, x1, y1, z1, b, 0, 1, 0); /* <2> = rot(<1>,b) */ rotate (*nx, *ny, *nz, x2, y2, z2, c, 0, 0, 1); /* = rot(<2>,c) */ } /* Powder, back */ #pragma acc routine void randderotate (double* nx, double* ny, double* nz, double a, double b, double c) { double x1, y1, z1, x2, y2, z2; rotate (x1, y1, z1, *nx, *ny, *nz, -c, 0, 0, 1); rotate (x2, y2, z2, x1, y1, z1, -b, 0, 1, 0); rotate (*nx, *ny, *nz, x2, y2, z2, -a, 1, 0, 0); } /* PG, forward */ #pragma acc routine void PGrotate (double* nx, double* ny, double* nz, double a, double csx, double csy, double csz) { /* Currently assumes c-axis along 'x', ought to be generalized... */ double nvx, nvy, nvz; rotate (nvx, nvy, nvz, *nx, *ny, *nz, a, csx, csy, csz); *nx = nvx; *ny = nvy; *nz = nvz; } /* PG, back */ #pragma acc routine void PGderotate (double* nx, double* ny, double* nz, double a, double csx, double csy, double csz) { /* Currently assumes c-axis along 'x', ought to be generalized... */ double nvx, nvy, nvz; rotate (nvx, nvy, nvz, *nx, *ny, *nz, -a, csx, csy, csz); *nx = nvx; *ny = nvy; *nz = nvz; } #pragma acc routine /* rotate vector counterclockwise */ void vec_rotate_2d (double* x, double* y, double angle) { double c, s; double newx, newy; c = cos (angle); s = sin (angle); newx = *x * c - *y * s; newy = *x * s + *y * c; *x = newx; *y = newy; } #ifdef USE_OPENCL struct opencl_context oclContext_SX; cl_mem d_T = NULL, d_tau_count = NULL, d_coh_refl = NULL, d_coh_xsect = NULL; // OpenCL device buffers cl_mem d_L = NULL; #endif #endif /* !SINGLE_CRYSTAL_DECL */ /* Shared user declarations for all components types 'Phonon_simple'. */ #ifndef PHONON_SIMPLE #define PHONON_SIMPLE $Revision$ #define T2E (1/11.605) /* Kelvin to meV */ struct phonon_params { double a_; // d spacing of the cubic lattice double c_; // Speed of sound in the material double gap_; // optional spin gap double ah; // Half of a int e_steps_high_; int e_steps_low_; }; struct neutron_params { // Statically allocate vectors that are always 3 double vf; // Final velocity size double vi; // Initial velocity size double vv_x; // vv is the unit vector of the final velocity vector double vv_y; double vv_z; double vi_x; // vi is the initial velocity vector double vi_y; double vi_z; }; #pragma acc routine double nbose (double omega, double T) /* Other name ?? */ { double nb; nb = (omega > 0) ? 1 + 1 / (exp (omega / (T * T2E)) - 1) : 1 / (exp (-omega / (T * T2E)) - 1); return nb; } #undef T2E /* Routine types from Numerical Recipies book */ #define UNUSED (-1.11e30) #define MAXRIDD 60 void fatalerror_cpu (char* s) { fprintf (stderr, "%s \n", s); exit (1); } #pragma acc routine void fatalerror (char* s) { #ifndef OPENACC fatalerror_cpu (s); #endif } #pragma acc routine double omega_q (struct neutron_params* neutron, struct phonon_params* phonon) { /* dispersion in units of meV */ double vi, vf, vv_x, vv_y, vv_z, vi_x, vi_y, vi_z; double q, qx, qy, qz, Jq, res_phonon, res_neutron; double ah, a, c; double gap; vf = neutron->vf; vi = neutron->vi; vv_x = neutron->vv_x; vv_y = neutron->vv_y; vv_z = neutron->vv_z; vi_x = neutron->vi_x; vi_y = neutron->vi_y; vi_z = neutron->vi_z; a = phonon->a_; c = phonon->c_; gap = phonon->gap_; ah = phonon->ah; qx = V2K * (vi_x - vf * vv_x); qy = V2K * (vi_y - vf * vv_y); qz = V2K * (vi_z - vf * vv_z); q = sqrt (qx * qx + qy * qy + qz * qz); Jq = 2 * (cos (ah * (qx + qy)) + cos (ah * (qx - qy)) + cos (ah * (qx + qz)) + cos (ah * (qx - qz)) + cos (ah * (qy + qz)) + cos (ah * (qy - qz))); if (gap > 0) { res_phonon = sqrt (gap * gap + (12 - Jq) * (c * c) / (a * a)); } else { res_phonon = c / a * sqrt (12 - Jq); } res_neutron = fabs (VS2E * (vi * vi - vf * vf)); return (res_phonon - res_neutron); } double zridd (double (*func) (struct neutron_params*, struct phonon_params*), double x1, double x2, struct neutron_params* neutron, struct phonon_params* phonon, double xacc) { int j; double ans, fh, fl, fm, fnew, s, xh, xl, xm, xnew; neutron->vf = x1; fl = func (neutron, phonon); neutron->vf = x2; fh = func (neutron, phonon); if (fl * fh >= 0) { if (fl == 0) return x1; if (fh == 0) return x2; return UNUSED; } else { xl = x1; xh = x2; ans = UNUSED; for (j = 1; j < MAXRIDD; j++) { xm = 0.5 * (xl + xh); neutron->vf = xm; fm = func (neutron, phonon); s = sqrt (fm * fm - fl * fh); if (s == 0.0) return ans; xnew = xm + (xm - xl) * ((fl >= fh ? 1.0 : -1.0) * fm / s); if (fabs (xnew - ans) <= xacc) return ans; ans = xnew; neutron->vf = ans; fnew = func (neutron, phonon); if (fnew == 0.0) return ans; if (fabs (fm) * SIGN (fnew) != fm) { xl = xm; fl = fm; xh = ans; fh = fnew; } else if (fabs (fl) * SIGN (fnew) != fl) { xh = ans; fh = fnew; } else if (fabs (fh) * SIGN (fnew) != fh) { xl = ans; fl = fnew; } else fatalerror ("never get here in zridd"); if (fabs (xh - xl) <= xacc) return ans; } fatalerror ("zridd exceeded maximum iterations"); } return 0.0; /* Never get here */ } #pragma acc routine double zridd_gpu (double x1, double x2, struct neutron_params* neutron, struct phonon_params* phonon, double xacc) { int j; double ans, fh, fl, fm, fnew, s, xh, xl, xm, xnew; neutron->vf = x1; fl = omega_q (neutron, phonon); neutron->vf = x2; fh = omega_q (neutron, phonon); if (fl * fh >= 0) { if (fl == 0) return x1; if (fh == 0) return x2; return UNUSED; } else { xl = x1; xh = x2; ans = UNUSED; for (j = 1; j < MAXRIDD; j++) { xm = 0.5 * (xl + xh); neutron->vf = xm; fm = omega_q (neutron, phonon); s = sqrt (fm * fm - fl * fh); if (s == 0.0) return ans; xnew = xm + (xm - xl) * ((fl >= fh ? 1.0 : -1.0) * fm / s); if (fabs (xnew - ans) <= xacc) return ans; ans = xnew; neutron->vf = ans; fnew = omega_q (neutron, phonon); if (fnew == 0.0) return ans; if (fabs (fm) * SIGN (fnew) != fm) { xl = xm; fl = fm; xh = ans; fh = fnew; } else if (fabs (fl) * SIGN (fnew) != fl) { xh = ans; fh = fnew; } else if (fabs (fh) * SIGN (fnew) != fh) { xl = ans; fl = fnew; } else fatalerror ("never get here in zridd"); if (fabs (xh - xl) <= xacc) return ans; } fatalerror ("zridd exceeded maximum iterations"); } return 0.0; /* Never get here */ } #define ROOTACC 1e-8 void findroots (double brack_low, double brack_mid, double brack_high, double* list, int* index, double (*f) (struct neutron_params*, struct phonon_params*), struct neutron_params* neutron, struct phonon_params* phonon) { double root; // Energy gain and energy loss spaces are not equally big. We check uniformly // So we use two different ranges double range_low = brack_mid - brack_low; double range_high = brack_high - brack_mid; // First in energy loss for the neutron for (int i = 0; i < phonon->e_steps_low_; i++) { root = zridd (f, brack_low + range_low * i / phonon->e_steps_low_, brack_low + range_low * (i + 1) / phonon->e_steps_low_, neutron, phonon, ROOTACC); if (root != UNUSED) { list[(*index)++] = root; } } // Then in energy gain for the neutron for (int i = 0; i < phonon->e_steps_high_; i++) { root = zridd (f, brack_mid + range_high * i / phonon->e_steps_high_, brack_mid + range_high * (i + 1) / phonon->e_steps_high_, neutron, phonon, ROOTACC); if (root != UNUSED) { list[(*index)++] = root; } } } #pragma acc routine void findroots_gpu (double brack_low, double brack_mid, double brack_high, double* list, int* index, struct neutron_params* neutron, struct phonon_params* phonon) { double root; // Energy gain and energy loss spaces are not equally big. We check uniformly // So we use two different ranges double range_low = brack_mid - brack_low; double range_high = brack_high - brack_mid; // First in energy loss for the neutron for (int i = 0; i < phonon->e_steps_low_; i++) { root = zridd_gpu (brack_low + range_low * i / phonon->e_steps_low_, brack_low + range_low * (i + 1) / phonon->e_steps_low_, neutron, phonon, ROOTACC); if (root != UNUSED) { list[(*index)++] = root; } } // Then in energy gain for the neutron for (int i = 0; i < phonon->e_steps_high_; i++) { root = zridd_gpu (brack_mid + range_high * i / phonon->e_steps_high_, brack_mid + range_high * (i + 1) / phonon->e_steps_high_, neutron, phonon, ROOTACC); if (root != UNUSED) { list[(*index)++] = root; } } } #undef UNUSED #undef MAXRIDD #endif /* Shared user declarations for all components types 'Monochromator_flat'. */ #ifndef GAUSS /* Define these arrays only once for all instances. */ /* Values for Gauss quadrature. Taken from Brice Carnahan, H. A. Luther and James O Wilkes, "Applied numerical methods", Wiley, 1969, page 103. This reference is available from the Copenhagen UB2 library */ double Gauss_X[] = { -0.987992518020485, -0.937273392400706, -0.848206583410427, -0.724417731360170, -0.570972172608539, -0.394151347077563, -0.201194093997435, 0, 0.201194093997435, 0.394151347077563, 0.570972172608539, 0.724417731360170, 0.848206583410427, 0.937273392400706, 0.987992518020485 }; double Gauss_W[] = { 0.030753241996117, 0.070366047488108, 0.107159220467172, 0.139570677926154, 0.166269205816994, 0.186161000115562, 0.198431485327111, 0.202578241925561, 0.198431485327111, 0.186161000115562, 0.166269205816994, 0.139570677926154, 0.107159220467172, 0.070366047488108, 0.030753241996117 }; #pragma acc declare create ( Gauss_X ) #pragma acc declare create ( Gauss_W ) #define GAUSS(x,mean,rms) \ (exp(-((x)-(mean))*((x)-(mean))/(2*(rms)*(rms)))/(sqrt(2*PI)*(rms))) #endif /* ************************************************************************** */ /* End of SHARE user declarations for all components */ /* ************************************************************************** */ /* ********************** component definition declarations. **************** */ /* component armSource=Progress_bar() [1] DECLARE */ /* Parameter definition for component type 'Progress_bar' */ struct _struct_Progress_bar_parameters { /* Component type 'Progress_bar' setting parameters */ char profile[16384]; MCNUM percent; MCNUM flag_save; MCNUM minutes; /* Component type 'Progress_bar' private parameters */ double IntermediateCnts; time_t StartTime; time_t EndTime; time_t CurrentTime; char infostring[64]; }; /* _struct_Progress_bar_parameters */ typedef struct _struct_Progress_bar_parameters _class_Progress_bar_parameters; /* Parameters for component type 'Progress_bar' */ struct _struct_Progress_bar { char _name[256]; /* e.g. armSource */ char _type[256]; /* Progress_bar */ long _index; /* e.g. 2 index in TRACE list */ Coords _position_absolute; Coords _position_relative; /* wrt PREVIOUS */ Rotation _rotation_absolute; Rotation _rotation_relative; /* wrt PREVIOUS */ int _rotation_is_identity; int _position_relative_is_zero; _class_Progress_bar_parameters _parameters; }; typedef struct _struct_Progress_bar _class_Progress_bar; _class_Progress_bar _armSource_var; #pragma acc declare create ( _armSource_var ) /* component source=Source_gen4() [2] DECLARE */ /* Parameter definition for component type 'Source_gen4' */ struct _struct_Source_gen4_parameters { /* Component type 'Source_gen4' setting parameters */ char flux_file[16384]; char xdiv_file[16384]; char ydiv_file[16384]; MCNUM radius; MCNUM dist; MCNUM xw; MCNUM yh; MCNUM E0; MCNUM dE; MCNUM Lambda0; MCNUM dLambda; MCNUM I1; MCNUM h; MCNUM w; MCNUM gaussian; MCNUM verbose; MCNUM T1; MCNUM flux_file_perAA; MCNUM flux_file_log; MCNUM Lmin; MCNUM Lmax; MCNUM Emin; MCNUM Emax; MCNUM T2; MCNUM I2; MCNUM T3; MCNUM I3; MCNUM length; MCNUM phi_init; MCNUM theta_init; MCNUM HEtailA; MCNUM HEtailL0; /* Component type 'Source_gen4' private parameters */ t_Table pTable; t_Table pTable_x; t_Table pTable_y; double p_in; double lambda0; double lambda02; double lambda0b; double lambda02b; double lambda0c; double lambda02c; double L2P; double L2Pb; double L2Pc; double pTable_xmin; double pTable_ymin; double pTable_xmax; double pTable_ymax; double pTable_xsum; double pTable_ysum; double pTable_dxmin; double pTable_dxmax; double pTable_dymin; double pTable_dymax; }; /* _struct_Source_gen4_parameters */ typedef struct _struct_Source_gen4_parameters _class_Source_gen4_parameters; /* Parameters for component type 'Source_gen4' */ struct _struct_Source_gen4 { char _name[256]; /* e.g. source */ char _type[256]; /* Source_gen4 */ long _index; /* e.g. 2 index in TRACE list */ Coords _position_absolute; Coords _position_relative; /* wrt PREVIOUS */ Rotation _rotation_absolute; Rotation _rotation_relative; /* wrt PREVIOUS */ int _rotation_is_identity; int _position_relative_is_zero; _class_Source_gen4_parameters _parameters; }; typedef struct _struct_Source_gen4 _class_Source_gen4; _class_Source_gen4 _source_var; #pragma acc declare create ( _source_var ) /* component slitGuideBegin=Slit() [3] DECLARE */ /* Parameter definition for component type 'Slit' */ struct _struct_Slit_parameters { /* Component type 'Slit' setting parameters */ MCNUM xmin; MCNUM xmax; MCNUM ymin; MCNUM ymax; MCNUM radius; MCNUM xwidth; MCNUM yheight; /* Component type 'Slit' private parameters */ char isradial; }; /* _struct_Slit_parameters */ typedef struct _struct_Slit_parameters _class_Slit_parameters; /* Parameters for component type 'Slit' */ struct _struct_Slit { char _name[256]; /* e.g. slitGuideBegin */ char _type[256]; /* Slit */ long _index; /* e.g. 2 index in TRACE list */ Coords _position_absolute; Coords _position_relative; /* wrt PREVIOUS */ Rotation _rotation_absolute; Rotation _rotation_relative; /* wrt PREVIOUS */ int _rotation_is_identity; int _position_relative_is_zero; _class_Slit_parameters _parameters; }; typedef struct _struct_Slit _class_Slit; _class_Slit _slitGuideBegin_var; #pragma acc declare create ( _slitGuideBegin_var ) /* component lmon_guide_start=L_monitor() [4] DECLARE */ /* Parameter definition for component type 'L_monitor' */ struct _struct_L_monitor_parameters { /* Component type 'L_monitor' setting parameters */ int nL; char filename[16384]; int nowritefile; MCNUM xmin; MCNUM xmax; MCNUM ymin; MCNUM ymax; MCNUM xwidth; MCNUM yheight; MCNUM Lmin; MCNUM Lmax; int restore_neutron; /* Component type 'L_monitor' private parameters */ DArray1d L_N; DArray1d L_p; DArray1d L_p2; }; /* _struct_L_monitor_parameters */ typedef struct _struct_L_monitor_parameters _class_L_monitor_parameters; /* Parameters for component type 'L_monitor' */ struct _struct_L_monitor { char _name[256]; /* e.g. lmon_guide_start */ char _type[256]; /* L_monitor */ long _index; /* e.g. 2 index in TRACE list */ Coords _position_absolute; Coords _position_relative; /* wrt PREVIOUS */ Rotation _rotation_absolute; Rotation _rotation_relative; /* wrt PREVIOUS */ int _rotation_is_identity; int _position_relative_is_zero; _class_L_monitor_parameters _parameters; }; typedef struct _struct_L_monitor _class_L_monitor; _class_L_monitor _lmon_guide_start_var; #pragma acc declare create ( _lmon_guide_start_var ) /* component guideStraight=Guide() [5] DECLARE */ /* Parameter definition for component type 'Guide' */ struct _struct_Guide_parameters { /* Component type 'Guide' setting parameters */ char reflect[16384]; MCNUM w1; MCNUM h1; MCNUM w2; MCNUM h2; MCNUM l; MCNUM R0; MCNUM Qc; MCNUM alpha; MCNUM m; MCNUM W; /* Component type 'Guide' private parameters */ t_Table pTable; int table_present; }; /* _struct_Guide_parameters */ typedef struct _struct_Guide_parameters _class_Guide_parameters; /* Parameters for component type 'Guide' */ struct _struct_Guide { char _name[256]; /* e.g. guideStraight */ char _type[256]; /* Guide */ long _index; /* e.g. 2 index in TRACE list */ Coords _position_absolute; Coords _position_relative; /* wrt PREVIOUS */ Rotation _rotation_absolute; Rotation _rotation_relative; /* wrt PREVIOUS */ int _rotation_is_identity; int _position_relative_is_zero; _class_Guide_parameters _parameters; }; typedef struct _struct_Guide _class_Guide; _class_Guide _guideStraight_var; #pragma acc declare create ( _guideStraight_var ) _class_Guide _guideCurved1_var; #pragma acc declare create ( _guideCurved1_var ) _class_Guide _guideCurved2_var; #pragma acc declare create ( _guideCurved2_var ) _class_Guide _guideCurved3_var; #pragma acc declare create ( _guideCurved3_var ) _class_Guide _guideCurved4_var; #pragma acc declare create ( _guideCurved4_var ) _class_Guide _guideCurved5_var; #pragma acc declare create ( _guideCurved5_var ) _class_Guide _guideCurved6_var; #pragma acc declare create ( _guideCurved6_var ) _class_Guide _guideCurved7_var; #pragma acc declare create ( _guideCurved7_var ) _class_Guide _guideCurved8_var; #pragma acc declare create ( _guideCurved8_var ) _class_Guide _guideCurved9_var; #pragma acc declare create ( _guideCurved9_var ) _class_Guide _guideCurved10_var; #pragma acc declare create ( _guideCurved10_var ) _class_Guide _guideCurved11_var; #pragma acc declare create ( _guideCurved11_var ) _class_Guide _guideCurved12_var; #pragma acc declare create ( _guideCurved12_var ) _class_Guide _guideCurved13_var; #pragma acc declare create ( _guideCurved13_var ) _class_Guide _guideCurved14_var; #pragma acc declare create ( _guideCurved14_var ) _class_Guide _guideCurved15_var; #pragma acc declare create ( _guideCurved15_var ) _class_Guide _guideCurved16_var; #pragma acc declare create ( _guideCurved16_var ) _class_Guide _guideCurved17_var; #pragma acc declare create ( _guideCurved17_var ) _class_Guide _guideCurved18_var; #pragma acc declare create ( _guideCurved18_var ) _class_Guide _guideCurved19_var; #pragma acc declare create ( _guideCurved19_var ) _class_Guide _guideCurved20_var; #pragma acc declare create ( _guideCurved20_var ) _class_Guide _guideCurved21_var; #pragma acc declare create ( _guideCurved21_var ) _class_Guide _guideCurved22_var; #pragma acc declare create ( _guideCurved22_var ) _class_Guide _guideCurved23_var; #pragma acc declare create ( _guideCurved23_var ) _class_Guide _guideCurved24_var; #pragma acc declare create ( _guideCurved24_var ) _class_Guide _guideCurved25_var; #pragma acc declare create ( _guideCurved25_var ) _class_Guide _guideCurved26_var; #pragma acc declare create ( _guideCurved26_var ) _class_Guide _guideCurved27_var; #pragma acc declare create ( _guideCurved27_var ) _class_Guide _guideCurved28_var; #pragma acc declare create ( _guideCurved28_var ) _class_Guide _guideCurved29_var; #pragma acc declare create ( _guideCurved29_var ) _class_Guide _guideCurved30_var; #pragma acc declare create ( _guideCurved30_var ) _class_Guide _guideCurved31_var; #pragma acc declare create ( _guideCurved31_var ) _class_Guide _guideCurved32_var; #pragma acc declare create ( _guideCurved32_var ) _class_Guide _guideCurved33_var; #pragma acc declare create ( _guideCurved33_var ) _class_Guide _guideCurved34_var; #pragma acc declare create ( _guideCurved34_var ) _class_Guide _guideCurved35_var; #pragma acc declare create ( _guideCurved35_var ) _class_Guide _guideCurved36_var; #pragma acc declare create ( _guideCurved36_var ) _class_Guide _guideCurved37_var; #pragma acc declare create ( _guideCurved37_var ) _class_Guide _guideCurved38_var; #pragma acc declare create ( _guideCurved38_var ) _class_Guide _guideCurved39_var; #pragma acc declare create ( _guideCurved39_var ) _class_Guide _guideCurved40_var; #pragma acc declare create ( _guideCurved40_var ) _class_Guide _bunker_var; #pragma acc declare create ( _bunker_var ) _class_Guide _guide3_var; #pragma acc declare create ( _guide3_var ) _class_Slit _slitGuideEnd_var; #pragma acc declare create ( _slitGuideEnd_var ) /* component psd_guide_end=PSD_monitor() [49] DECLARE */ /* Parameter definition for component type 'PSD_monitor' */ struct _struct_PSD_monitor_parameters { /* Component type 'PSD_monitor' setting parameters */ int nx; int ny; char filename[16384]; MCNUM xmin; MCNUM xmax; MCNUM ymin; MCNUM ymax; MCNUM xwidth; MCNUM yheight; int restore_neutron; int nowritefile; /* Component type 'PSD_monitor' private parameters */ DArray2d PSD_N; DArray2d PSD_p; DArray2d PSD_p2; }; /* _struct_PSD_monitor_parameters */ typedef struct _struct_PSD_monitor_parameters _class_PSD_monitor_parameters; /* Parameters for component type 'PSD_monitor' */ struct _struct_PSD_monitor { char _name[256]; /* e.g. psd_guide_end */ char _type[256]; /* PSD_monitor */ long _index; /* e.g. 2 index in TRACE list */ Coords _position_absolute; Coords _position_relative; /* wrt PREVIOUS */ Rotation _rotation_absolute; Rotation _rotation_relative; /* wrt PREVIOUS */ int _rotation_is_identity; int _position_relative_is_zero; _class_PSD_monitor_parameters _parameters; }; typedef struct _struct_PSD_monitor _class_PSD_monitor; _class_PSD_monitor _psd_guide_end_var; #pragma acc declare create ( _psd_guide_end_var ) /* component emon_guide_end=E_monitor() [50] DECLARE */ /* Parameter definition for component type 'E_monitor' */ struct _struct_E_monitor_parameters { /* Component type 'E_monitor' setting parameters */ int nE; char filename[16384]; MCNUM xmin; MCNUM xmax; MCNUM ymin; MCNUM ymax; int nowritefile; MCNUM xwidth; MCNUM yheight; MCNUM Emin; MCNUM Emax; int restore_neutron; /* Component type 'E_monitor' private parameters */ DArray1d E_N; DArray1d E_p; DArray1d E_p2; double S_p; double S_pE; double S_pE2; }; /* _struct_E_monitor_parameters */ typedef struct _struct_E_monitor_parameters _class_E_monitor_parameters; /* Parameters for component type 'E_monitor' */ struct _struct_E_monitor { char _name[256]; /* e.g. emon_guide_end */ char _type[256]; /* E_monitor */ long _index; /* e.g. 2 index in TRACE list */ Coords _position_absolute; Coords _position_relative; /* wrt PREVIOUS */ Rotation _rotation_absolute; Rotation _rotation_relative; /* wrt PREVIOUS */ int _rotation_is_identity; int _position_relative_is_zero; _class_E_monitor_parameters _parameters; }; typedef struct _struct_E_monitor _class_E_monitor; _class_E_monitor _emon_guide_end_var; #pragma acc declare create ( _emon_guide_end_var ) _class_L_monitor _lmon_guide_end_var; #pragma acc declare create ( _lmon_guide_end_var ) /* component divmon_guide_end=Divergence_monitor() [52] DECLARE */ /* Parameter definition for component type 'Divergence_monitor' */ struct _struct_Divergence_monitor_parameters { /* Component type 'Divergence_monitor' setting parameters */ int nh; int nv; char filename[16384]; MCNUM xmin; MCNUM xmax; MCNUM ymin; MCNUM ymax; int nowritefile; MCNUM xwidth; MCNUM yheight; MCNUM maxdiv_h; MCNUM maxdiv_v; int restore_neutron; MCNUM nx; MCNUM ny; MCNUM nz; /* Component type 'Divergence_monitor' private parameters */ DArray2d Div_N; DArray2d Div_p; DArray2d Div_p2; }; /* _struct_Divergence_monitor_parameters */ typedef struct _struct_Divergence_monitor_parameters _class_Divergence_monitor_parameters; /* Parameters for component type 'Divergence_monitor' */ struct _struct_Divergence_monitor { char _name[256]; /* e.g. divmon_guide_end */ char _type[256]; /* Divergence_monitor */ long _index; /* e.g. 2 index in TRACE list */ Coords _position_absolute; Coords _position_relative; /* wrt PREVIOUS */ Rotation _rotation_absolute; Rotation _rotation_relative; /* wrt PREVIOUS */ int _rotation_is_identity; int _position_relative_is_zero; _class_Divergence_monitor_parameters _parameters; }; typedef struct _struct_Divergence_monitor _class_Divergence_monitor; _class_Divergence_monitor _divmon_guide_end_var; #pragma acc declare create ( _divmon_guide_end_var ) /* component focus_mono=Arm() [53] DECLARE */ /* Parameter definition for component type 'Arm' */ struct _struct_Arm_parameters { char Arm_has_no_parameters; }; /* _struct_Arm_parameters */ typedef struct _struct_Arm_parameters _class_Arm_parameters; /* Parameters for component type 'Arm' */ struct _struct_Arm { char _name[256]; /* e.g. focus_mono */ char _type[256]; /* Arm */ long _index; /* e.g. 2 index in TRACE list */ Coords _position_absolute; Coords _position_relative; /* wrt PREVIOUS */ Rotation _rotation_absolute; Rotation _rotation_relative; /* wrt PREVIOUS */ int _rotation_is_identity; int _position_relative_is_zero; _class_Arm_parameters _parameters; }; typedef struct _struct_Arm _class_Arm; _class_Arm _focus_mono_var; #pragma acc declare create ( _focus_mono_var ) /* component monochromator_curved=Monochromator_curved() [54] DECLARE */ /* Parameter definition for component type 'Monochromator_curved' */ struct _struct_Monochromator_curved_parameters { /* Component type 'Monochromator_curved' setting parameters */ char reflect[16384]; char transmit[16384]; MCNUM zwidth; MCNUM yheight; MCNUM gap; int NH; int NV; MCNUM mosaich; MCNUM mosaicv; MCNUM r0; MCNUM t0; MCNUM Q; MCNUM RV; MCNUM RH; MCNUM DM; MCNUM mosaic; MCNUM width; MCNUM height; MCNUM verbose; MCNUM order; /* Component type 'Monochromator_curved' private parameters */ double mos_rms_y; double mos_rms_z; double mos_rms_max; double mono_Q; double SlabWidth; double SlabHeight; t_Table rTable; t_Table tTable; int rTableFlag; int tTableFlag; double* tiltH; double* tiltV; char ncol_var[128]; char nrow_var[128]; }; /* _struct_Monochromator_curved_parameters */ typedef struct _struct_Monochromator_curved_parameters _class_Monochromator_curved_parameters; /* Parameters for component type 'Monochromator_curved' */ struct _struct_Monochromator_curved { char _name[256]; /* e.g. monochromator_curved */ char _type[256]; /* Monochromator_curved */ long _index; /* e.g. 2 index in TRACE list */ Coords _position_absolute; Coords _position_relative; /* wrt PREVIOUS */ Rotation _rotation_absolute; Rotation _rotation_relative; /* wrt PREVIOUS */ int _rotation_is_identity; int _position_relative_is_zero; _class_Monochromator_curved_parameters _parameters; }; typedef struct _struct_Monochromator_curved _class_Monochromator_curved; _class_Monochromator_curved _monochromator_curved_var; #pragma acc declare create ( _monochromator_curved_var ) _class_Arm _a2_var; #pragma acc declare create ( _a2_var ) _class_Slit _slitShutter_var; #pragma acc declare create ( _slitShutter_var ) /* component MSCollimator=Collimator_linear() [57] DECLARE */ /* Parameter definition for component type 'Collimator_linear' */ struct _struct_Collimator_linear_parameters { /* Component type 'Collimator_linear' setting parameters */ MCNUM xmin; MCNUM xmax; MCNUM ymin; MCNUM ymax; MCNUM xwidth; MCNUM yheight; MCNUM length; MCNUM divergence; MCNUM transmission; MCNUM divergenceV; /* Component type 'Collimator_linear' private parameters */ double slope; double slopeV; }; /* _struct_Collimator_linear_parameters */ typedef struct _struct_Collimator_linear_parameters _class_Collimator_linear_parameters; /* Parameters for component type 'Collimator_linear' */ struct _struct_Collimator_linear { char _name[256]; /* e.g. MSCollimator */ char _type[256]; /* Collimator_linear */ long _index; /* e.g. 2 index in TRACE list */ Coords _position_absolute; Coords _position_relative; /* wrt PREVIOUS */ Rotation _rotation_absolute; Rotation _rotation_relative; /* wrt PREVIOUS */ int _rotation_is_identity; int _position_relative_is_zero; _class_Collimator_linear_parameters _parameters; }; typedef struct _struct_Collimator_linear _class_Collimator_linear; _class_Collimator_linear _MSCollimator_var; #pragma acc declare create ( _MSCollimator_var ) /* component infilter=Filter_gen() [58] DECLARE */ /* Parameter definition for component type 'Filter_gen' */ struct _struct_Filter_gen_parameters { /* Component type 'Filter_gen' setting parameters */ char filename[16384]; char options[16384]; MCNUM xmin; MCNUM xmax; MCNUM ymin; MCNUM ymax; MCNUM xwidth; MCNUM yheight; MCNUM thickness; MCNUM scaling; MCNUM verbose; /* Component type 'Filter_gen' private parameters */ char Mode_Table; char Type_Table; t_Table pTable; }; /* _struct_Filter_gen_parameters */ typedef struct _struct_Filter_gen_parameters _class_Filter_gen_parameters; /* Parameters for component type 'Filter_gen' */ struct _struct_Filter_gen { char _name[256]; /* e.g. infilter */ char _type[256]; /* Filter_gen */ long _index; /* e.g. 2 index in TRACE list */ Coords _position_absolute; Coords _position_relative; /* wrt PREVIOUS */ Rotation _rotation_absolute; Rotation _rotation_relative; /* wrt PREVIOUS */ int _rotation_is_identity; int _position_relative_is_zero; _class_Filter_gen_parameters _parameters; }; typedef struct _struct_Filter_gen _class_Filter_gen; _class_Filter_gen _infilter_var; #pragma acc declare create ( _infilter_var ) _class_PSD_monitor _psd_virt_var; #pragma acc declare create ( _psd_virt_var ) _class_L_monitor _lmon_virt_var; #pragma acc declare create ( _lmon_virt_var ) _class_Arm _aa2_var; #pragma acc declare create ( _aa2_var ) /* component OrderMon=Monitor_nD() [62] DECLARE */ /* Parameter definition for component type 'Monitor_nD' */ struct _struct_Monitor_nD_parameters { /* Component type 'Monitor_nD' setting parameters */ char user0[16384]; char user1[16384]; char user2[16384]; char user3[16384]; char user4[16384]; char user5[16384]; char user6[16384]; char user7[16384]; char user8[16384]; char user9[16384]; MCNUM xwidth; MCNUM yheight; MCNUM zdepth; MCNUM xmin; MCNUM xmax; MCNUM ymin; MCNUM ymax; MCNUM zmin; MCNUM zmax; int bins; MCNUM min; MCNUM max; int restore_neutron; MCNUM radius; char options[16384]; char filename[16384]; char geometry[16384]; int nowritefile; int nexus_bins; char username0[16384]; char username1[16384]; char username2[16384]; char username3[16384]; char username4[16384]; char username5[16384]; char username6[16384]; char username7[16384]; char username8[16384]; char username9[16384]; /* Component type 'Monitor_nD' private parameters */ MonitornD_Defines_type DEFS; MonitornD_Variables_type Vars; MCDETECTOR detector; off_struct offdata; }; /* _struct_Monitor_nD_parameters */ typedef struct _struct_Monitor_nD_parameters _class_Monitor_nD_parameters; /* Parameters for component type 'Monitor_nD' */ struct _struct_Monitor_nD { char _name[256]; /* e.g. OrderMon */ char _type[256]; /* Monitor_nD */ long _index; /* e.g. 2 index in TRACE list */ Coords _position_absolute; Coords _position_relative; /* wrt PREVIOUS */ Rotation _rotation_absolute; Rotation _rotation_relative; /* wrt PREVIOUS */ int _rotation_is_identity; int _position_relative_is_zero; _class_Monitor_nD_parameters _parameters; }; typedef struct _struct_Monitor_nD _class_Monitor_nD; _class_Monitor_nD _OrderMon_var; #pragma acc declare create ( _OrderMon_var ) /* component kMoni=PSD_monitor_psf_eff() [63] DECLARE */ /* Parameter definition for component type 'PSD_monitor_psf_eff' */ struct _struct_PSD_monitor_psf_eff_parameters { /* Component type 'PSD_monitor_psf_eff' setting parameters */ int nx; int ny; char filename[16384]; MCNUM xmin; MCNUM xmax; MCNUM ymin; MCNUM ymax; int nowritefile; MCNUM xwidth; MCNUM yheight; MCNUM psf; MCNUM k0; MCNUM eff; int restore_neutron; /* Component type 'PSD_monitor_psf_eff' private parameters */ DArray2d PSD_N; DArray2d PSD_p; DArray2d PSD_p2; double weight; }; /* _struct_PSD_monitor_psf_eff_parameters */ typedef struct _struct_PSD_monitor_psf_eff_parameters _class_PSD_monitor_psf_eff_parameters; /* Parameters for component type 'PSD_monitor_psf_eff' */ struct _struct_PSD_monitor_psf_eff { char _name[256]; /* e.g. kMoni */ char _type[256]; /* PSD_monitor_psf_eff */ long _index; /* e.g. 2 index in TRACE list */ Coords _position_absolute; Coords _position_relative; /* wrt PREVIOUS */ Rotation _rotation_absolute; Rotation _rotation_relative; /* wrt PREVIOUS */ int _rotation_is_identity; int _position_relative_is_zero; _class_PSD_monitor_psf_eff_parameters _parameters; }; typedef struct _struct_PSD_monitor_psf_eff _class_PSD_monitor_psf_eff; _class_PSD_monitor_psf_eff _kMoni_var; #pragma acc declare create ( _kMoni_var ) _class_PSD_monitor_psf_eff _kMoni1st_var; #pragma acc declare create ( _kMoni1st_var ) _class_PSD_monitor_psf_eff _kMoni2nd_var; #pragma acc declare create ( _kMoni2nd_var ) _class_PSD_monitor_psf_eff _kMoni3rd_var; #pragma acc declare create ( _kMoni3rd_var ) _class_Slit _slitMonochromator_var; #pragma acc declare create ( _slitMonochromator_var ) /* component Perspex=Incoherent() [68] DECLARE */ /* Parameter definition for component type 'Incoherent' */ struct _struct_Incoherent_parameters { /* Component type 'Incoherent' setting parameters */ char geometry[16384]; MCNUM radius; MCNUM xwidth; MCNUM yheight; MCNUM zdepth; MCNUM thickness; MCNUM target_x; MCNUM target_y; MCNUM target_z; MCNUM focus_r; MCNUM focus_xw; MCNUM focus_yh; MCNUM focus_aw; MCNUM focus_ah; int target_index; MCNUM pack; MCNUM p_interact; MCNUM f_QE; MCNUM gamma; MCNUM Etrans; MCNUM deltaE; MCNUM sigma_abs; MCNUM sigma_inc; MCNUM Vc; MCNUM concentric; MCNUM order; /* Component type 'Incoherent' private parameters */ struct StructVarsInc VarsInc; off_struct offdata; }; /* _struct_Incoherent_parameters */ typedef struct _struct_Incoherent_parameters _class_Incoherent_parameters; /* Parameters for component type 'Incoherent' */ struct _struct_Incoherent { char _name[256]; /* e.g. Perspex */ char _type[256]; /* Incoherent */ long _index; /* e.g. 2 index in TRACE list */ Coords _position_absolute; Coords _position_relative; /* wrt PREVIOUS */ Rotation _rotation_absolute; Rotation _rotation_relative; /* wrt PREVIOUS */ int _rotation_is_identity; int _position_relative_is_zero; _class_Incoherent_parameters _parameters; }; typedef struct _struct_Incoherent _class_Incoherent; _class_Incoherent _Perspex_var; #pragma acc declare create ( _Perspex_var ) _class_PSD_monitor _psd_samplepos_1cm2_var; #pragma acc declare create ( _psd_samplepos_1cm2_var ) _class_E_monitor _emon_samplepos_1cm2_var; #pragma acc declare create ( _emon_samplepos_1cm2_var ) _class_Divergence_monitor _divmon_samplepos_1cm2_var; #pragma acc declare create ( _divmon_samplepos_1cm2_var ) _class_PSD_monitor _psd_samplepos_large_var; #pragma acc declare create ( _psd_samplepos_large_var ) _class_Arm _a3_var; #pragma acc declare create ( _a3_var ) _class_Arm _aa3_var; #pragma acc declare create ( _aa3_var ) _class_Incoherent _incohSample_var; #pragma acc declare create ( _incohSample_var ) /* component powderSample=PowderN() [76] DECLARE */ /* Parameter definition for component type 'PowderN' */ struct _struct_PowderN_parameters { /* Component type 'PowderN' setting parameters */ char reflections[16384]; char geometry[16384]; MCNUM format[9]; MCNUM radius; MCNUM yheight; MCNUM xwidth; MCNUM zdepth; MCNUM thickness; MCNUM pack; MCNUM Vc; MCNUM sigma_abs; MCNUM sigma_inc; MCNUM delta_d_d; MCNUM p_inc; MCNUM p_transmit; MCNUM DW; MCNUM nb_atoms; MCNUM d_omega; MCNUM d_phi; MCNUM tth_sign; MCNUM p_interact; MCNUM concentric; MCNUM density; MCNUM weight; MCNUM barns; MCNUM Strain; MCNUM focus_flip; int target_index; int order; /* Component type 'PowderN' private parameters */ struct line_info_struct line_info; double* columns; off_struct offdata; double tgt_x; double tgt_y; double tgt_z; }; /* _struct_PowderN_parameters */ typedef struct _struct_PowderN_parameters _class_PowderN_parameters; /* Parameters for component type 'PowderN' */ struct _struct_PowderN { char _name[256]; /* e.g. powderSample */ char _type[256]; /* PowderN */ long _index; /* e.g. 2 index in TRACE list */ Coords _position_absolute; Coords _position_relative; /* wrt PREVIOUS */ Rotation _rotation_absolute; Rotation _rotation_relative; /* wrt PREVIOUS */ int _rotation_is_identity; int _position_relative_is_zero; _class_PowderN_parameters _parameters; }; typedef struct _struct_PowderN _class_PowderN; _class_PowderN _powderSample_var; #pragma acc declare create ( _powderSample_var ) /* component crystalSample=Single_crystal() [77] DECLARE */ /* Parameter definition for component type 'Single_crystal' */ struct _struct_Single_crystal_parameters { /* Component type 'Single_crystal' setting parameters */ char reflections[16384]; char geometry[16384]; MCNUM mosaic_AB[8]; MCNUM xwidth; MCNUM yheight; MCNUM zdepth; MCNUM radius; MCNUM delta_d_d; MCNUM mosaic; MCNUM mosaic_a; MCNUM mosaic_b; MCNUM mosaic_c; MCNUM recip_cell; MCNUM barns; MCNUM ax; MCNUM ay; MCNUM az; MCNUM bx; MCNUM by; MCNUM bz; MCNUM cx; MCNUM cy; MCNUM cz; MCNUM p_transmit; MCNUM sigma_abs; MCNUM sigma_inc; MCNUM aa; MCNUM bb; MCNUM cc; MCNUM order; MCNUM extra_order; MCNUM RX; MCNUM RY; MCNUM powder; MCNUM PG; MCNUM deltak; /* Component type 'Single_crystal' private parameters */ struct hkl_info_struct hkl_info; off_struct offdata; struct hkl_data* hkl_list; struct tau_data tau_list[MCSX_REFL_SLIST_SIZE]; }; /* _struct_Single_crystal_parameters */ typedef struct _struct_Single_crystal_parameters _class_Single_crystal_parameters; /* Parameters for component type 'Single_crystal' */ struct _struct_Single_crystal { char _name[256]; /* e.g. crystalSample */ char _type[256]; /* Single_crystal */ long _index; /* e.g. 2 index in TRACE list */ Coords _position_absolute; Coords _position_relative; /* wrt PREVIOUS */ Rotation _rotation_absolute; Rotation _rotation_relative; /* wrt PREVIOUS */ int _rotation_is_identity; int _position_relative_is_zero; _class_Single_crystal_parameters _parameters; }; typedef struct _struct_Single_crystal _class_Single_crystal; _class_Single_crystal _crystalSample_var; #pragma acc declare create ( _crystalSample_var ) /* component phononSample=Phonon_simple() [78] DECLARE */ /* Parameter definition for component type 'Phonon_simple' */ struct _struct_Phonon_simple_parameters { /* Component type 'Phonon_simple' setting parameters */ MCNUM radius; MCNUM yheight; MCNUM sigma_abs; MCNUM sigma_inc; MCNUM a; MCNUM b; MCNUM M; MCNUM c; MCNUM DW; MCNUM T; MCNUM target_x; MCNUM target_y; MCNUM target_z; int target_index; MCNUM focus_r; MCNUM focus_xw; MCNUM focus_yh; MCNUM focus_aw; MCNUM focus_ah; MCNUM gap; int e_steps_low; int e_steps_high; /* Component type 'Phonon_simple' private parameters */ double V_rho; double V_my_s; double V_my_a_v; double DV; struct phonon_params phonon; }; /* _struct_Phonon_simple_parameters */ typedef struct _struct_Phonon_simple_parameters _class_Phonon_simple_parameters; /* Parameters for component type 'Phonon_simple' */ struct _struct_Phonon_simple { char _name[256]; /* e.g. phononSample */ char _type[256]; /* Phonon_simple */ long _index; /* e.g. 2 index in TRACE list */ Coords _position_absolute; Coords _position_relative; /* wrt PREVIOUS */ Rotation _rotation_absolute; Rotation _rotation_relative; /* wrt PREVIOUS */ int _rotation_is_identity; int _position_relative_is_zero; _class_Phonon_simple_parameters _parameters; }; typedef struct _struct_Phonon_simple _class_Phonon_simple; _class_Phonon_simple _phononSample_var; #pragma acc declare create ( _phononSample_var ) /* component psd_4pi=PSD_monitor_4PI() [79] DECLARE */ /* Parameter definition for component type 'PSD_monitor_4PI' */ struct _struct_PSD_monitor_4PI_parameters { /* Component type 'PSD_monitor_4PI' setting parameters */ int nx; int ny; char filename[16384]; int nowritefile; MCNUM radius; int restore_neutron; /* Component type 'PSD_monitor_4PI' private parameters */ DArray2d PSD_N; DArray2d PSD_p; DArray2d PSD_p2; }; /* _struct_PSD_monitor_4PI_parameters */ typedef struct _struct_PSD_monitor_4PI_parameters _class_PSD_monitor_4PI_parameters; /* Parameters for component type 'PSD_monitor_4PI' */ struct _struct_PSD_monitor_4PI { char _name[256]; /* e.g. psd_4pi */ char _type[256]; /* PSD_monitor_4PI */ long _index; /* e.g. 2 index in TRACE list */ Coords _position_absolute; Coords _position_relative; /* wrt PREVIOUS */ Rotation _rotation_absolute; Rotation _rotation_relative; /* wrt PREVIOUS */ int _rotation_is_identity; int _position_relative_is_zero; _class_PSD_monitor_4PI_parameters _parameters; }; typedef struct _struct_PSD_monitor_4PI _class_PSD_monitor_4PI; _class_PSD_monitor_4PI _psd_4pi_var; #pragma acc declare create ( _psd_4pi_var ) _class_Arm _a4_var; #pragma acc declare create ( _a4_var ) _class_Slit _slitSample_var; #pragma acc declare create ( _slitSample_var ) /* component filter_coll=Exact_radial_coll() [82] DECLARE */ /* Parameter definition for component type 'Exact_radial_coll' */ struct _struct_Exact_radial_coll_parameters { /* Component type 'Exact_radial_coll' setting parameters */ MCNUM theta_min; MCNUM theta_max; MCNUM nslit; MCNUM radius; MCNUM length; MCNUM h_in; MCNUM h_out; MCNUM d; MCNUM verbose; /* Component type 'Exact_radial_coll' private parameters */ double alpha_in; double alpha_out; double beta_in; double beta_out; double theta; double out_radius; double iw; double ow; double divergence; }; /* _struct_Exact_radial_coll_parameters */ typedef struct _struct_Exact_radial_coll_parameters _class_Exact_radial_coll_parameters; /* Parameters for component type 'Exact_radial_coll' */ struct _struct_Exact_radial_coll { char _name[256]; /* e.g. filter_coll */ char _type[256]; /* Exact_radial_coll */ long _index; /* e.g. 2 index in TRACE list */ Coords _position_absolute; Coords _position_relative; /* wrt PREVIOUS */ Rotation _rotation_absolute; Rotation _rotation_relative; /* wrt PREVIOUS */ int _rotation_is_identity; int _position_relative_is_zero; _class_Exact_radial_coll_parameters _parameters; }; typedef struct _struct_Exact_radial_coll _class_Exact_radial_coll; _class_Exact_radial_coll _filter_coll_var; #pragma acc declare create ( _filter_coll_var ) _class_Filter_gen _filter_var; #pragma acc declare create ( _filter_var ) _class_Slit _ana_slit1_var; #pragma acc declare create ( _ana_slit1_var ) _class_Slit _ana_slit2_var; #pragma acc declare create ( _ana_slit2_var ) _class_E_monitor _emon_before_ana_var; #pragma acc declare create ( _emon_before_ana_var ) _class_PSD_monitor _psd_before_ana_var; #pragma acc declare create ( _psd_before_ana_var ) _class_Divergence_monitor _divmon_before_ana_var; #pragma acc declare create ( _divmon_before_ana_var ) _class_Arm _focus_ana_var; #pragma acc declare create ( _focus_ana_var ) /* component an1l=Monochromator_flat() [90] DECLARE */ /* Parameter definition for component type 'Monochromator_flat' */ struct _struct_Monochromator_flat_parameters { /* Component type 'Monochromator_flat' setting parameters */ MCNUM zmin; MCNUM zmax; MCNUM ymin; MCNUM ymax; MCNUM zwidth; MCNUM yheight; MCNUM mosaich; MCNUM mosaicv; MCNUM r0; MCNUM Q; MCNUM DM; /* Component type 'Monochromator_flat' private parameters */ double mos_rms_y; double mos_rms_z; double mos_rms_max; double mono_Q; }; /* _struct_Monochromator_flat_parameters */ typedef struct _struct_Monochromator_flat_parameters _class_Monochromator_flat_parameters; /* Parameters for component type 'Monochromator_flat' */ struct _struct_Monochromator_flat { char _name[256]; /* e.g. an1l */ char _type[256]; /* Monochromator_flat */ long _index; /* e.g. 2 index in TRACE list */ Coords _position_absolute; Coords _position_relative; /* wrt PREVIOUS */ Rotation _rotation_absolute; Rotation _rotation_relative; /* wrt PREVIOUS */ int _rotation_is_identity; int _position_relative_is_zero; _class_Monochromator_flat_parameters _parameters; }; typedef struct _struct_Monochromator_flat _class_Monochromator_flat; _class_Monochromator_flat _an1l_var; #pragma acc declare create ( _an1l_var ) _class_Monochromator_flat _an1u_var; #pragma acc declare create ( _an1u_var ) _class_Monochromator_flat _an2l_var; #pragma acc declare create ( _an2l_var ) _class_Monochromator_flat _an2u_var; #pragma acc declare create ( _an2u_var ) _class_Monochromator_flat _an3l_var; #pragma acc declare create ( _an3l_var ) _class_Monochromator_flat _an3u_var; #pragma acc declare create ( _an3u_var ) _class_Monochromator_flat _an4l_var; #pragma acc declare create ( _an4l_var ) _class_Monochromator_flat _an4u_var; #pragma acc declare create ( _an4u_var ) _class_Monochromator_flat _an5l_var; #pragma acc declare create ( _an5l_var ) _class_Monochromator_flat _an5u_var; #pragma acc declare create ( _an5u_var ) _class_Monochromator_flat _an6l_var; #pragma acc declare create ( _an6l_var ) _class_Monochromator_flat _an6u_var; #pragma acc declare create ( _an6u_var ) _class_Monochromator_flat _an7l_var; #pragma acc declare create ( _an7l_var ) _class_Monochromator_flat _an7u_var; #pragma acc declare create ( _an7u_var ) _class_Monochromator_flat _an8l_var; #pragma acc declare create ( _an8l_var ) _class_Monochromator_flat _an8u_var; #pragma acc declare create ( _an8u_var ) _class_Monochromator_flat _an9l_var; #pragma acc declare create ( _an9l_var ) _class_Monochromator_flat _an9u_var; #pragma acc declare create ( _an9u_var ) _class_Arm _a6_var; #pragma acc declare create ( _a6_var ) _class_E_monitor _emon_before_coarse_var; #pragma acc declare create ( _emon_before_coarse_var ) _class_PSD_monitor _psd_before_coarse_var; #pragma acc declare create ( _psd_before_coarse_var ) _class_Arm _ArmR1_var; #pragma acc declare create ( _ArmR1_var ) /* component BladeR1=Absorber() [112] DECLARE */ /* Parameter definition for component type 'Absorber' */ struct _struct_Absorber_parameters { /* Component type 'Absorber' setting parameters */ MCNUM xmin; MCNUM xmax; MCNUM ymin; MCNUM ymax; MCNUM zmin; MCNUM zmax; /* Component type 'Absorber' private parameters */ double xw; double yh; double zt; double xm; double ym; double zm; }; /* _struct_Absorber_parameters */ typedef struct _struct_Absorber_parameters _class_Absorber_parameters; /* Parameters for component type 'Absorber' */ struct _struct_Absorber { char _name[256]; /* e.g. BladeR1 */ char _type[256]; /* Absorber */ long _index; /* e.g. 2 index in TRACE list */ Coords _position_absolute; Coords _position_relative; /* wrt PREVIOUS */ Rotation _rotation_absolute; Rotation _rotation_relative; /* wrt PREVIOUS */ int _rotation_is_identity; int _position_relative_is_zero; _class_Absorber_parameters _parameters; }; typedef struct _struct_Absorber _class_Absorber; _class_Absorber _BladeR1_var; #pragma acc declare create ( _BladeR1_var ) _class_Arm _ArmR2_var; #pragma acc declare create ( _ArmR2_var ) _class_Absorber _BladeR2_var; #pragma acc declare create ( _BladeR2_var ) _class_Arm _ArmR3_var; #pragma acc declare create ( _ArmR3_var ) _class_Absorber _BladeR3_var; #pragma acc declare create ( _BladeR3_var ) _class_Arm _ArmR4_var; #pragma acc declare create ( _ArmR4_var ) _class_Absorber _BladeR4_var; #pragma acc declare create ( _BladeR4_var ) _class_Arm _ArmR5_var; #pragma acc declare create ( _ArmR5_var ) _class_Absorber _BladeR5_var; #pragma acc declare create ( _BladeR5_var ) _class_Arm _ArmL1_var; #pragma acc declare create ( _ArmL1_var ) _class_Absorber _BladeL1_var; #pragma acc declare create ( _BladeL1_var ) _class_Arm _ArmL2_var; #pragma acc declare create ( _ArmL2_var ) _class_Absorber _BladeL2_var; #pragma acc declare create ( _BladeL2_var ) _class_Arm _ArmL3_var; #pragma acc declare create ( _ArmL3_var ) _class_Absorber _BladeL3_var; #pragma acc declare create ( _BladeL3_var ) _class_Arm _ArmL4_var; #pragma acc declare create ( _ArmL4_var ) _class_Absorber _BladeL4_var; #pragma acc declare create ( _BladeL4_var ) _class_Arm _ArmL5_var; #pragma acc declare create ( _ArmL5_var ) _class_Absorber _BladeL5_var; #pragma acc declare create ( _BladeL5_var ) _class_PSD_monitor_psf_eff _psd_detector_var; #pragma acc declare create ( _psd_detector_var ) _class_E_monitor _emon_detector_var; #pragma acc declare create ( _emon_detector_var ) _class_PSD_monitor_psf_eff _psd_window1_var; #pragma acc declare create ( _psd_window1_var ) _class_E_monitor _emon_window1_var; #pragma acc declare create ( _emon_window1_var ) _class_PSD_monitor_psf_eff _psd_window2_var; #pragma acc declare create ( _psd_window2_var ) _class_E_monitor _emon_window2_var; #pragma acc declare create ( _emon_window2_var ) _class_PSD_monitor_psf_eff _psd_window3_var; #pragma acc declare create ( _psd_window3_var ) _class_E_monitor _emon_window3_var; #pragma acc declare create ( _emon_window3_var ) _class_PSD_monitor_psf_eff _psd_window4_var; #pragma acc declare create ( _psd_window4_var ) _class_E_monitor _emon_window4_var; #pragma acc declare create ( _emon_window4_var ) _class_PSD_monitor_psf_eff _psd_window5_var; #pragma acc declare create ( _psd_window5_var ) _class_E_monitor _emon_window5_var; #pragma acc declare create ( _emon_window5_var ) _class_PSD_monitor_psf_eff _psd_window6_var; #pragma acc declare create ( _psd_window6_var ) _class_E_monitor _emon_window6_var; #pragma acc declare create ( _emon_window6_var ) _class_PSD_monitor_psf_eff _psd_window7_var; #pragma acc declare create ( _psd_window7_var ) _class_E_monitor _emon_window7_var; #pragma acc declare create ( _emon_window7_var ) _class_PSD_monitor_psf_eff _psd_window8_var; #pragma acc declare create ( _psd_window8_var ) _class_E_monitor _emon_window8_var; #pragma acc declare create ( _emon_window8_var ) _class_PSD_monitor_psf_eff _psd_window9_var; #pragma acc declare create ( _psd_window9_var ) _class_E_monitor _emon_window9_var; #pragma acc declare create ( _emon_window9_var ) int mcNUMCOMP = 150; /* User declarations from instrument definition. Can define functions. */ /* The following is from RITA2front, Kim Lefmann / Linda Udby */ /* Static values... */ double l0,lmin,lmax; double emini,emaxi; double eminf,emaxf; double nefchan; double neichan; double lI,KI,KF; /* Internal variable for SPLIT repetitions */ int SPLITREP; int SPLITMREP; int SPLITAREP; #pragma acc declare create (SPLITREP,SPLITMREP,SPLITAREP) /* Guide element parameters*/ double angleGuideCurved; double R = 0.88; double R0 = 0.995; double Qc = 0.0217; double W = 0; double M= 2.15; double ALPHA; /* Monochromator material parameters */ double mono_q = 1.87325; double mono_r0 = 0.8; double DM; /*d-spacing monochromator*/ double mono_mosaic_h; double mono_mosaic_v; /* Monochromator curvature parmeters */ //double u,v; double dms; /* Target vector for focusing */ double tx,tz; /* Target vector for focusing */ double sintm,sinta; double rv; /* Mono focusing parameter */ /* Monochromator geometrical parameters */ /* Size of monochromator blades are hard-coded in the component*/ double mono_d = 0.026; /* Distance between mono blades. From drawings */ double dmc; /* Distance monochromator to front of collimator. Was 0.32 from Stine */ double rmh = 0.58; /* Radius of monohousing. Measured 2008/11/05 */ double lc = 0.198; /*Length of monocollimator. Measured 2008/11/05*/ /* RITA Monitor efficiency 1.7e-5 */ double EFF = 1.7e-5; /* Sample parameters */ double d_sample_slit = 0.35; /* Measured 2008/11/05, was 25 cm from Stine */ double d_sample_filter = 0.51; /*To centre of filter. Measured 2008/11/05, was to filter front 25 cm from Stine */ double dsa = 1.195; /* distance sample-analyzer (m). Was 1.256 from Stine */ double dsb ; /*distance sample to blade, depends on analyser rack postion*/ double dmv = 1.00; /* distance monochromator to virtual out */ //double dvs = 0.67; /* distance virtual in to sample. dmv+dvs=1.67=rmh+1.09. Ma15 setting */ double dvs = 0.54; /* distance virtual in to sample. dmv+dvs=1.54 */ double is_incoh;/* Random number pr. neutron event for incoherent V scattering */ /* Filenames for the sample comps: */ char *PowderFile; char *SingleXFile; /* Analyser material parameters*/ double ana_mosaic_h; double ana_mosaic_v; double ana_q = 1.87325; double ana_r0 = 0.8; double DA; /* d-spacing analyser*/ /*Analyser geometrical parameters */ double ana_d = 0.025; /* Width of analyser blades. From drawings */ double ana_h = 0.15; /* Height of analyser blades. From drawings */ double dad = 0.338; /* distance analyzer to detector front (m) */ double dadw = 0.3595; //= 0.3595; /* distance analyzer to detector wire (m) */ double wan = 0.024; /* width of analyzer blades , by ruler (m) */ double RR; // = 0.3008; /* ratio of dadw and dsa*/ //double DA4; /*angle between blades*/ double A5; /* scattering angle for flat analyser*/ /* Declarations for 'Coarse Collimator' at the PSD detector surface */ int EntrySlit; int ExitSlit; double BladeThickness = 0.007;// detector coll after 2006, from drawings double WindowSize = 0.025; double BladeLength = 0.179;// detector coll after 2006, from drawings double BladeHeight = 0.272;// detector coll after 2006, from drawings //double BladeThickness = 0.002;// detector coll before 2006 //double BladeLength = 0.180;// detector coll before 2006 //double BladeHeight = 0.250;// detector coll before 2006 double FirstWindowSizeL; double FirstWindowSizeR; double deltaL; int coarse; /* Detector parameters */ //double det_width = 0.2735;/* was 0.3 from Stine*/ double det_width = 0.275; double det_height =0.5; double PSF = 0.0074/2.35;// FWHM=0.0074m, measured by C. Bahl NIMB 246, 452. /* Electronic Window positions in the PSD */ int XwinMin[10]; int YwinMin[10]; int XwinMax[10]; int YwinMax[10]; #pragma acc declare create (XwinMin,YwinMin,XwinMax,YwinMax) /* BEGIN declaring stuff for the HKL calculator adapted from templateTAS */ struct sample_struct { double as, bs, cs; // Lattice parameters double aa, bb, cc; // Lattice angles double ax, ay, az; // First scattering plane vector double bx, by, bz; // Second scattering plane vector } sample; struct machine_hkl_struct { double dm, da; // Mono and ana d-spacings double sm, ss, sa; // Mono, sample, ana angle signs double ki, kf, ei, ef; // Initial and Final wavevectors and energies double qh, qk, ql, en; // Momentum transfer and energy transfer in sample } machine_hkl; struct machine_real_struct { double a1,a2,a3,a4,a5,a6; double da4,aa5; double c1,c2,c3,c4,c5,c6,c7,c8,c9; double rmh, rmv, rah, rav; double qm, qs, qt[3]; char message[256]; } machine_real; struct machine_real_struct qhkl2angles( struct sample_struct sample, struct machine_hkl_struct machine_hkl, struct machine_real_struct machine_real) { /* code from TASMAD/t_rlp.F:SETRLP */ double qhkl[3]; double alpha[3]; double a[3]; double aspv[3][2]; double cosa[3], sina[3]; double cosb[3], sinb[3]; double b[3], c[3], s[4][4]; double vv[3][3], bb[3][3]; double arg, cc; int i,j,k,l,m,n; char liquid_case=1; /* transfered parameters to local arrays */ qhkl[0] = machine_hkl.qh; /* HKL target */ qhkl[1] = machine_hkl.qk; qhkl[2] = machine_hkl.ql; alpha[0] = sample.aa; /* cell angles */ alpha[1] = sample.bb; alpha[2] = sample.cc; a[0] = sample.as; /* cell parameters */ a[1] = sample.bs; a[2] = sample.cs; aspv[0][0]= sample.ax; /* cell axis A */ aspv[1][0]= sample.ay; aspv[2][0]= sample.az; aspv[0][1]= sample.bx; /* cell axis B */ aspv[1][1]= sample.by; aspv[2][1]= sample.bz; /* default return values */ strcpy(machine_real.message, ""); machine_real.a3 = machine_real.a4 = 0; machine_real.a1 = machine_real.a5 = 0; /* if using HKL positioning in crystal (QM = 0) */ if (machine_real.qm <= 0) { liquid_case = 0; /* compute reciprocal cell */ for (i=0; i< 3; i++) if (a[i] <=0) sprintf(machine_real.message, "Lattice parameters a[%i]=%g", i, a[i]); else { a[i] /= 2*PI; alpha[i]*= DEG2RAD; cosa[i] = cos(alpha[i]); sina[i] = sin(alpha[i]); } cc = cosa[0]*cosa[0]+cosa[1]*cosa[1]+cosa[2]*cosa[2]; /* nprm */ cc = 1 + 2*cosa[0]*cosa[1]*cosa[2] - cc; if (cc <= 0) sprintf(machine_real.message, "Lattice angles (AA,BB,CC) cc=%g", cc); else cc = sqrt(cc); if (strlen(machine_real.message)) return machine_real; /* compute bb */ j=1; k=2; for (i=0; i<3; i++) { b[i] = sina[i]/(a[i]*cc); cosb[i] = (cosa[j]*cosa[k] - cosa[i])/(sina[j]*sina[k]); sinb[i] = sqrt(1 - cosb[i]*cosb[i]); j=k; k=i; } bb[0][0] = b[0]; bb[1][0] = 0; bb[2][0] = 0; bb[0][1] = b[1]*cosb[2]; bb[1][1] = b[1]*sinb[2]; bb[2][1] = 0; bb[0][2] = b[2]*cosb[1]; bb[1][2] =-b[2]*sinb[1]*cosa[0]; bb[2][2] = 1/a[2]; /* compute vv */ for (k=0; k< 3; k++) for (i=0; i< 3; i++) vv[k][i] = 0; for (k=0; k< 2; k++) for (i=0; i< 3; i++) for (j=0; j< 3; j++) vv[k][i] += bb[i][j]*aspv[j][k]; for (m=2; m>=1; m--) for (n=0; n<3; n++) { i = (int)fmod(m+1,3); j= (int)fmod(m+2,3); k = (int)fmod(n+1,3); l= (int)fmod(n+2,3); vv[m][n]=vv[i][k]*vv[j][l]-vv[i][l]*vv[j][k]; } for (i=0; i< 3; i++) { /* compute norm(vv) */ c[i]=0; for (j=0; j< 3; j++) c[i] += vv[i][j]*vv[i][j]; if (c[i]>0) c[i] = sqrt(c[i]); else { sprintf(machine_real.message, "Vectors A and B, c[%i]=%g", i, c[i]); return machine_real; } } for (i=0; i< 3; i++) /* normalize vv */ for (j=0; j< 3; j++) vv[j][i] /= c[j]; for (i=0; i< 3; i++) /* compute S */ for (j=0; j< 3; j++) { s[i][j] = 0; for (k=0; k< 3; k++) s[i][j] += vv[i][k]*bb[k][j]; } s[3][3]=1; for (i=0; i< 3; i++) s[3][i]=s[i][3]=0; /* compute q modulus and transverse component */ machine_real.qs = 0; for (i=0; i< 3; i++) { machine_real.qt[i] = 0; for (j=0; j< 3; j++) machine_real.qt[i] += qhkl[j]*s[i][j]; machine_real.qs += machine_real.qt[i]*machine_real.qt[i]; } if (machine_real.qs > 0) machine_real.qm = sqrt(machine_real.qs); else sprintf(machine_real.message, "Q modulus too small QM^2=%g", machine_real.qs); } else { machine_real.qs = machine_real.qm*machine_real.qm; } /* end if qm <= 0 ********************************************* */ /* positioning of monochromator and analyser */ arg = PI/machine_hkl.dm/machine_hkl.ki; if (fabs(arg) > 1) sprintf(machine_real.message, "Monochromator can not reach this KI. arg=%g", arg); else { if (machine_hkl.dm <= 0 || machine_hkl.ki <= 0) strcpy(machine_real.message, "Monochromator DM=0 or KI=0."); else machine_real.a1 = asin(arg)*RAD2DEG; machine_real.a1 *= machine_hkl.sm; } machine_real.a2=2*machine_real.a1; arg = PI/machine_hkl.da/machine_hkl.kf; if (fabs(arg) > 1) sprintf(machine_real.message, "Analyzer can not reach this KF. arg=%g",arg); else { if (machine_hkl.da <= 0 || machine_hkl.kf <= 0) strcpy(machine_real.message, "Analyzer DA=0 or KF=0."); else machine_real.a5 = asin(arg)*RAD2DEG; machine_real.a5 *= machine_hkl.sa; } machine_real.a6=2*machine_real.a5; if (strlen(machine_real.message)) return machine_real; /* code from TASMAD/t_conv.F:SAM_CASE */ arg = (machine_hkl.ki*machine_hkl.ki + machine_hkl.kf*machine_hkl.kf - machine_real.qs) / (2*machine_hkl.ki*machine_hkl.kf); if (fabs(arg) < 1.0) machine_real.a4 = RAD2DEG*acos(arg); else sprintf(machine_real.message, "Q modulus too big. Can not close triangle. arg=%g", arg); machine_real.a4 *= machine_hkl.ss; if (!liquid_case) { /* compute a3 in crystals */ machine_real.a3 = -atan2(machine_real.qt[1],machine_real.qt[0]) -acos( (machine_hkl.kf*machine_hkl.kf-machine_real.qs-machine_hkl.ki*machine_hkl.ki) /(-2*machine_real.qm*machine_hkl.ki) ); machine_real.a3 *= RAD2DEG*(machine_real.a4 > 0 ? 1 : -1 ); //machine_real.a3 = machine_real.a3 -90;// Add by PW & LU } /* Analyser angles */ /* Angle of the analyser rack aa5 */ RR = dadw/dsa; machine_real.aa5 = -RAD2DEG*(acos((sin(DEG2RAD*machine_real.a6)-(cos(DEG2RAD*machine_real.a6)+RR)*sqrt(RR*RR+2*RR*cos(DEG2RAD*machine_real.a6)))/(1+RR*RR+2*RR*cos(DEG2RAD*machine_real.a6)))); // From Bahl et al. , NIMB 226 (2004) /*printf("(RITA Analyzer Rack Angle: AA5=%.4g[deg])\n", machine_real.aa5);*/ /*A4 angle between blades */ dsb = sqrt(dsa*dsa + ana_d*ana_d - 2*dsa*ana_d*cos(DEG2RAD*machine_real.aa5)); machine_real.da4 = RAD2DEG*asin(ana_d*sin(DEG2RAD*fabs(machine_real.aa5))/dsb); //machine_real.da4 = RAD2DEG*atan(ana_d*cos(DEG2RAD*machine_real.aa5)/dsa); printf("(RITA Analyzer Angle between blades: DA4=%.4g[deg])\n", machine_real.da4); /*Blade angle rotation */ machine_real.c1= -machine_real.aa5+machine_real.a5-(1-5)*machine_real.da4; machine_real.c2= -machine_real.aa5+machine_real.a5-(2-5)*machine_real.da4; machine_real.c3= -machine_real.aa5+machine_real.a5-(3-5)*machine_real.da4; machine_real.c4= -machine_real.aa5+machine_real.a5-(4-5)*machine_real.da4; machine_real.c5= -machine_real.aa5+machine_real.a5-(5-5)*machine_real.da4; machine_real.c6= -machine_real.aa5+machine_real.a5-(6-5)*machine_real.da4; machine_real.c7= -machine_real.aa5+machine_real.a5-(7-5)*machine_real.da4; machine_real.c8= -machine_real.aa5+machine_real.a5-(8-5)*machine_real.da4; machine_real.c9= -machine_real.aa5+machine_real.a5-(9-5)*machine_real.da4; return machine_real; } /* END declaring stuff for the HKL calculator adapted from templateTAS */ #undef compcurname #undef compcurtype #undef compcurindex /* end of instrument 'RITA_II' and components DECLARE */ /* ***************************************************************************** * instrument 'RITA_II' and components INITIALISE ***************************************************************************** */ double index_getdistance(int first_index, int second_index) /* Calculate the distance two components from their indexes*/ { return coords_len(coords_sub(POS_A_COMP_INDEX(first_index), POS_A_COMP_INDEX(second_index))); } double getdistance(char* first_component, char* second_component) /* Calculate the distance between two named components */ { int first_index = _getcomp_index(first_component); int second_index = _getcomp_index(second_component); return index_getdistance(first_index, second_index); } double checked_setpos_getdistance(int current_index, char* first_component, char* second_component) /* Calculate the distance between two named components at *_setpos() time, with component index checking */ { int first_index = _getcomp_index(first_component); int second_index = _getcomp_index(second_component); if (first_index >= current_index || second_index >= current_index) { printf("setpos_getdistance can only be used with the names of components before the current one!\n"); return 0; } return index_getdistance(first_index, second_index); } #define setpos_getdistance(first, second) checked_setpos_getdistance(current_setpos_index, first, second) /* component armSource=Progress_bar() SETTING, POSITION/ROTATION */ int _armSource_setpos(void) { /* sets initial component parameters, position and rotation */ SIG_MESSAGE("[_armSource_setpos] component armSource=Progress_bar() SETTING [Progress_bar:0]"); stracpy(_armSource_var._name, "armSource", 16384); stracpy(_armSource_var._type, "Progress_bar", 16384); _armSource_var._index=1; int current_setpos_index = 1; if("NULL" && strlen("NULL")) stracpy(_armSource_var._parameters.profile, "NULL" ? "NULL" : "", 16384); else _armSource_var._parameters.profile[0]='\0'; _armSource_var._parameters.percent = 10; _armSource_var._parameters.flag_save = 0; _armSource_var._parameters.minutes = 0; /* component armSource=Progress_bar() AT ROTATED */ { Coords tc1, tc2; tc1 = coords_set(0,0,0); tc2 = coords_set(0,0,0); Rotation tr1; rot_set_rotation(tr1,0,0,0); rot_set_rotation(_armSource_var._rotation_absolute, (0.0)*DEG2RAD, (0.0)*DEG2RAD, (0.0)*DEG2RAD); rot_copy(_armSource_var._rotation_relative, _armSource_var._rotation_absolute); _armSource_var._rotation_is_identity = rot_test_identity(_armSource_var._rotation_relative); _armSource_var._position_absolute = coords_set( 0, 0, 0); tc1 = coords_neg(_armSource_var._position_absolute); _armSource_var._position_relative = rot_apply(_armSource_var._rotation_absolute, tc1); } /* armSource=Progress_bar() AT ROTATED */ DEBUG_COMPONENT("armSource", _armSource_var._position_absolute, _armSource_var._rotation_absolute); instrument->_position_absolute[1] = _armSource_var._position_absolute; instrument->_position_relative[1] = _armSource_var._position_relative; _armSource_var._position_relative_is_zero = coords_test_zero(_armSource_var._position_relative); instrument->counter_N[1] = instrument->counter_P[1] = instrument->counter_P2[1] = 0; instrument->counter_AbsorbProp[1]= 0; #ifdef USE_NEXUS if(nxhandle) { if ((!mcdotrace) && mcformat && strcasestr(mcformat, "NeXus")) { MPI_MASTER( mccomp_placement_type_nexus(nxhandle,"0000_armSource", _armSource_var._position_absolute, _armSource_var._rotation_absolute, "Progress_bar"); mccomp_param_nexus(nxhandle,"0000_armSource", "profile", "NULL", "NULL", "char*"); mccomp_param_nexus(nxhandle,"0000_armSource", "percent", "10", "10","MCNUM"); mccomp_param_nexus(nxhandle,"0000_armSource", "flag_save", "0", "0","MCNUM"); mccomp_param_nexus(nxhandle,"0000_armSource", "minutes", "0", "0","MCNUM"); ); } } else { // fprintf(stderr,"NO NEXUS FILE"); } #endif return(0); } /* _armSource_setpos */ /* component source=Source_gen4() SETTING, POSITION/ROTATION */ int _source_setpos(void) { /* sets initial component parameters, position and rotation */ SIG_MESSAGE("[_source_setpos] component source=Source_gen4() SETTING [Source_gen4:0]"); stracpy(_source_var._name, "source", 16384); stracpy(_source_var._type, "Source_gen4", 16384); _source_var._index=2; int current_setpos_index = 2; _source_var._parameters.flux_file[0]='\0'; _source_var._parameters.xdiv_file[0]='\0'; _source_var._parameters.ydiv_file[0]='\0'; _source_var._parameters.radius = 0.0; _source_var._parameters.dist = 1.465; _source_var._parameters.xw = 0.03; _source_var._parameters.yh = 0.12; _source_var._parameters.E0 = 0; _source_var._parameters.dE = 0; _source_var._parameters.Lambda0 = 0; _source_var._parameters.dLambda = 0; _source_var._parameters.I1 = _instrument_var._parameters.ITAR * ( 1.27e13 / 4 / PI ); _source_var._parameters.h = 0.135; _source_var._parameters.w = 0.08; _source_var._parameters.gaussian = 0; _source_var._parameters.verbose = 0; _source_var._parameters.T1 = 301.287; _source_var._parameters.flux_file_perAA = 0; _source_var._parameters.flux_file_log = 0; _source_var._parameters.Lmin = lmin; _source_var._parameters.Lmax = lmax; _source_var._parameters.Emin = 0; _source_var._parameters.Emax = 0; _source_var._parameters.T2 = 105.655; _source_var._parameters.I2 = _instrument_var._parameters.ITAR * ( 3.818e12 / 4 / PI ); _source_var._parameters.T3 = 25.379; _source_var._parameters.I3 = _instrument_var._parameters.ITAR * ( 2.331e12 / 4 / PI ); _source_var._parameters.length = 0; _source_var._parameters.phi_init = 0; _source_var._parameters.theta_init = 0; _source_var._parameters.HEtailA = _instrument_var._parameters.ITAR * 8.306e11 / 4 / PI; _source_var._parameters.HEtailL0 = -0.398; /* component source=Source_gen4() AT ROTATED */ { Coords tc1, tc2; tc1 = coords_set(0,0,0); tc2 = coords_set(0,0,0); Rotation tr1; rot_set_rotation(tr1,0,0,0); rot_set_rotation(tr1, (0)*DEG2RAD, (0)*DEG2RAD, (0)*DEG2RAD); rot_mul(tr1, _armSource_var._rotation_absolute, _source_var._rotation_absolute); rot_transpose(_armSource_var._rotation_absolute, tr1); rot_mul(_source_var._rotation_absolute, tr1, _source_var._rotation_relative); _source_var._rotation_is_identity = rot_test_identity(_source_var._rotation_relative); tc1 = coords_set( 0, 0, 0); rot_transpose(_armSource_var._rotation_absolute, tr1); tc2 = rot_apply(tr1, tc1); _source_var._position_absolute = coords_add(_armSource_var._position_absolute, tc2); tc1 = coords_sub(_armSource_var._position_absolute, _source_var._position_absolute); _source_var._position_relative = rot_apply(_source_var._rotation_absolute, tc1); } /* source=Source_gen4() AT ROTATED */ DEBUG_COMPONENT("source", _source_var._position_absolute, _source_var._rotation_absolute); instrument->_position_absolute[2] = _source_var._position_absolute; instrument->_position_relative[2] = _source_var._position_relative; _source_var._position_relative_is_zero = coords_test_zero(_source_var._position_relative); instrument->counter_N[2] = instrument->counter_P[2] = instrument->counter_P2[2] = 0; instrument->counter_AbsorbProp[2]= 0; #ifdef USE_NEXUS if(nxhandle) { if ((!mcdotrace) && mcformat && strcasestr(mcformat, "NeXus")) { MPI_MASTER( mccomp_placement_type_nexus(nxhandle,"0001_source", _source_var._position_absolute, _source_var._rotation_absolute, "Source_gen4"); mccomp_param_nexus(nxhandle,"0001_source", "flux_file", 0, 0, "char*"); mccomp_param_nexus(nxhandle,"0001_source", "xdiv_file", 0, 0, "char*"); mccomp_param_nexus(nxhandle,"0001_source", "ydiv_file", 0, 0, "char*"); mccomp_param_nexus(nxhandle,"0001_source", "radius", "0.0", "0.0","MCNUM"); mccomp_param_nexus(nxhandle,"0001_source", "dist", "0", "1.465","MCNUM"); mccomp_param_nexus(nxhandle,"0001_source", "xw", "0", "0.03","MCNUM"); mccomp_param_nexus(nxhandle,"0001_source", "yh", "0", "0.12","MCNUM"); mccomp_param_nexus(nxhandle,"0001_source", "E0", "0", "0","MCNUM"); mccomp_param_nexus(nxhandle,"0001_source", "dE", "0", "0","MCNUM"); mccomp_param_nexus(nxhandle,"0001_source", "Lambda0", "0", "0","MCNUM"); mccomp_param_nexus(nxhandle,"0001_source", "dLambda", "0", "0","MCNUM"); mccomp_param_nexus(nxhandle,"0001_source", "I1", "0", "_instrument_var._parameters.ITAR * ( 1.27e13 / 4 / PI )","MCNUM"); mccomp_param_nexus(nxhandle,"0001_source", "h", "0", "0.135","MCNUM"); mccomp_param_nexus(nxhandle,"0001_source", "w", "0", "0.08","MCNUM"); mccomp_param_nexus(nxhandle,"0001_source", "gaussian", "0", "0","MCNUM"); mccomp_param_nexus(nxhandle,"0001_source", "verbose", "0", "0","MCNUM"); mccomp_param_nexus(nxhandle,"0001_source", "T1", "0", "301.287","MCNUM"); mccomp_param_nexus(nxhandle,"0001_source", "flux_file_perAA", "0", "0","MCNUM"); mccomp_param_nexus(nxhandle,"0001_source", "flux_file_log", "0", "0","MCNUM"); mccomp_param_nexus(nxhandle,"0001_source", "Lmin", "0", "lmin","MCNUM"); mccomp_param_nexus(nxhandle,"0001_source", "Lmax", "0", "lmax","MCNUM"); mccomp_param_nexus(nxhandle,"0001_source", "Emin", "0", "0","MCNUM"); mccomp_param_nexus(nxhandle,"0001_source", "Emax", "0", "0","MCNUM"); mccomp_param_nexus(nxhandle,"0001_source", "T2", "0", "105.655","MCNUM"); mccomp_param_nexus(nxhandle,"0001_source", "I2", "0", "_instrument_var._parameters.ITAR * ( 3.818e12 / 4 / PI )","MCNUM"); mccomp_param_nexus(nxhandle,"0001_source", "T3", "0", "25.379","MCNUM"); mccomp_param_nexus(nxhandle,"0001_source", "I3", "0", "_instrument_var._parameters.ITAR * ( 2.331e12 / 4 / PI )","MCNUM"); mccomp_param_nexus(nxhandle,"0001_source", "length", "0", "0","MCNUM"); mccomp_param_nexus(nxhandle,"0001_source", "phi_init", "0", "0","MCNUM"); mccomp_param_nexus(nxhandle,"0001_source", "theta_init", "0", "0","MCNUM"); mccomp_param_nexus(nxhandle,"0001_source", "HEtailA", "0", "_instrument_var._parameters.ITAR * 8.306e11 / 4 / PI","MCNUM"); mccomp_param_nexus(nxhandle,"0001_source", "HEtailL0", "0", "-0.398","MCNUM"); ); } } else { // fprintf(stderr,"NO NEXUS FILE"); } #endif return(0); } /* _source_setpos */ /* component slitGuideBegin=Slit() SETTING, POSITION/ROTATION */ int _slitGuideBegin_setpos(void) { /* sets initial component parameters, position and rotation */ SIG_MESSAGE("[_slitGuideBegin_setpos] component slitGuideBegin=Slit() SETTING [Slit:0]"); stracpy(_slitGuideBegin_var._name, "slitGuideBegin", 16384); stracpy(_slitGuideBegin_var._type, "Slit", 16384); _slitGuideBegin_var._index=3; int current_setpos_index = 3; _slitGuideBegin_var._parameters.xmin = -0.015; _slitGuideBegin_var._parameters.xmax = 0.015; _slitGuideBegin_var._parameters.ymin = -0.06; _slitGuideBegin_var._parameters.ymax = 0.06; _slitGuideBegin_var._parameters.radius = UNSET; _slitGuideBegin_var._parameters.xwidth = UNSET; _slitGuideBegin_var._parameters.yheight = UNSET; /* component slitGuideBegin=Slit() AT ROTATED */ { Coords tc1, tc2; tc1 = coords_set(0,0,0); tc2 = coords_set(0,0,0); Rotation tr1; rot_set_rotation(tr1,0,0,0); rot_set_rotation(tr1, (0.0)*DEG2RAD, (0.0)*DEG2RAD, (0.0)*DEG2RAD); rot_mul(tr1, _armSource_var._rotation_absolute, _slitGuideBegin_var._rotation_absolute); rot_transpose(_source_var._rotation_absolute, tr1); rot_mul(_slitGuideBegin_var._rotation_absolute, tr1, _slitGuideBegin_var._rotation_relative); _slitGuideBegin_var._rotation_is_identity = rot_test_identity(_slitGuideBegin_var._rotation_relative); tc1 = coords_set( 0, 0, 1.464999); rot_transpose(_armSource_var._rotation_absolute, tr1); tc2 = rot_apply(tr1, tc1); _slitGuideBegin_var._position_absolute = coords_add(_armSource_var._position_absolute, tc2); tc1 = coords_sub(_source_var._position_absolute, _slitGuideBegin_var._position_absolute); _slitGuideBegin_var._position_relative = rot_apply(_slitGuideBegin_var._rotation_absolute, tc1); } /* slitGuideBegin=Slit() AT ROTATED */ DEBUG_COMPONENT("slitGuideBegin", _slitGuideBegin_var._position_absolute, _slitGuideBegin_var._rotation_absolute); instrument->_position_absolute[3] = _slitGuideBegin_var._position_absolute; instrument->_position_relative[3] = _slitGuideBegin_var._position_relative; _slitGuideBegin_var._position_relative_is_zero = coords_test_zero(_slitGuideBegin_var._position_relative); instrument->counter_N[3] = instrument->counter_P[3] = instrument->counter_P2[3] = 0; instrument->counter_AbsorbProp[3]= 0; #ifdef USE_NEXUS if(nxhandle) { if ((!mcdotrace) && mcformat && strcasestr(mcformat, "NeXus")) { MPI_MASTER( mccomp_placement_type_nexus(nxhandle,"0002_slitGuideBegin", _slitGuideBegin_var._position_absolute, _slitGuideBegin_var._rotation_absolute, "Slit"); mccomp_param_nexus(nxhandle,"0002_slitGuideBegin", "xmin", "UNSET", "-0.015","MCNUM"); mccomp_param_nexus(nxhandle,"0002_slitGuideBegin", "xmax", "UNSET", "0.015","MCNUM"); mccomp_param_nexus(nxhandle,"0002_slitGuideBegin", "ymin", "UNSET", "-0.06","MCNUM"); mccomp_param_nexus(nxhandle,"0002_slitGuideBegin", "ymax", "UNSET", "0.06","MCNUM"); mccomp_param_nexus(nxhandle,"0002_slitGuideBegin", "radius", "UNSET", "UNSET","MCNUM"); mccomp_param_nexus(nxhandle,"0002_slitGuideBegin", "xwidth", "UNSET", "UNSET","MCNUM"); mccomp_param_nexus(nxhandle,"0002_slitGuideBegin", "yheight", "UNSET", "UNSET","MCNUM"); ); } } else { // fprintf(stderr,"NO NEXUS FILE"); } #endif return(0); } /* _slitGuideBegin_setpos */ /* component lmon_guide_start=L_monitor() SETTING, POSITION/ROTATION */ int _lmon_guide_start_setpos(void) { /* sets initial component parameters, position and rotation */ SIG_MESSAGE("[_lmon_guide_start_setpos] component lmon_guide_start=L_monitor() SETTING [L_monitor:0]"); stracpy(_lmon_guide_start_var._name, "lmon_guide_start", 16384); stracpy(_lmon_guide_start_var._type, "L_monitor", 16384); _lmon_guide_start_var._index=4; int current_setpos_index = 4; _lmon_guide_start_var._parameters.nL = 100; if("lmon_guide_start.dat" && strlen("lmon_guide_start.dat")) stracpy(_lmon_guide_start_var._parameters.filename, "lmon_guide_start.dat" ? "lmon_guide_start.dat" : "", 16384); else _lmon_guide_start_var._parameters.filename[0]='\0'; _lmon_guide_start_var._parameters.nowritefile = 0; _lmon_guide_start_var._parameters.xmin = -0.02; _lmon_guide_start_var._parameters.xmax = 0.02; _lmon_guide_start_var._parameters.ymin = -0.075; _lmon_guide_start_var._parameters.ymax = 0.075; _lmon_guide_start_var._parameters.xwidth = 0; _lmon_guide_start_var._parameters.yheight = 0; _lmon_guide_start_var._parameters.Lmin = lmin; _lmon_guide_start_var._parameters.Lmax = lmax; _lmon_guide_start_var._parameters.restore_neutron = 1; /* component lmon_guide_start=L_monitor() AT ROTATED */ { Coords tc1, tc2; tc1 = coords_set(0,0,0); tc2 = coords_set(0,0,0); Rotation tr1; rot_set_rotation(tr1,0,0,0); rot_set_rotation(tr1, (0.0)*DEG2RAD, (0.0)*DEG2RAD, (0.0)*DEG2RAD); rot_mul(tr1, _armSource_var._rotation_absolute, _lmon_guide_start_var._rotation_absolute); rot_transpose(_slitGuideBegin_var._rotation_absolute, tr1); rot_mul(_lmon_guide_start_var._rotation_absolute, tr1, _lmon_guide_start_var._rotation_relative); _lmon_guide_start_var._rotation_is_identity = rot_test_identity(_lmon_guide_start_var._rotation_relative); tc1 = coords_set( 0, 0, 1.4649992); rot_transpose(_armSource_var._rotation_absolute, tr1); tc2 = rot_apply(tr1, tc1); _lmon_guide_start_var._position_absolute = coords_add(_armSource_var._position_absolute, tc2); tc1 = coords_sub(_slitGuideBegin_var._position_absolute, _lmon_guide_start_var._position_absolute); _lmon_guide_start_var._position_relative = rot_apply(_lmon_guide_start_var._rotation_absolute, tc1); } /* lmon_guide_start=L_monitor() AT ROTATED */ DEBUG_COMPONENT("lmon_guide_start", _lmon_guide_start_var._position_absolute, _lmon_guide_start_var._rotation_absolute); instrument->_position_absolute[4] = _lmon_guide_start_var._position_absolute; instrument->_position_relative[4] = _lmon_guide_start_var._position_relative; _lmon_guide_start_var._position_relative_is_zero = coords_test_zero(_lmon_guide_start_var._position_relative); instrument->counter_N[4] = instrument->counter_P[4] = instrument->counter_P2[4] = 0; instrument->counter_AbsorbProp[4]= 0; #ifdef USE_NEXUS if(nxhandle) { if ((!mcdotrace) && mcformat && strcasestr(mcformat, "NeXus")) { MPI_MASTER( mccomp_placement_type_nexus(nxhandle,"0003_lmon_guide_start", _lmon_guide_start_var._position_absolute, _lmon_guide_start_var._rotation_absolute, "L_monitor"); mccomp_param_nexus(nxhandle,"0003_lmon_guide_start", "nL", "20", "100","int"); mccomp_param_nexus(nxhandle,"0003_lmon_guide_start", "filename", 0, "lmon_guide_start.dat", "char*"); mccomp_param_nexus(nxhandle,"0003_lmon_guide_start", "nowritefile", "0", "0","int"); mccomp_param_nexus(nxhandle,"0003_lmon_guide_start", "xmin", "-0.05", "-0.02","MCNUM"); mccomp_param_nexus(nxhandle,"0003_lmon_guide_start", "xmax", "0.05", "0.02","MCNUM"); mccomp_param_nexus(nxhandle,"0003_lmon_guide_start", "ymin", "-0.05", "-0.075","MCNUM"); mccomp_param_nexus(nxhandle,"0003_lmon_guide_start", "ymax", "0.05", "0.075","MCNUM"); mccomp_param_nexus(nxhandle,"0003_lmon_guide_start", "xwidth", "0", "0","MCNUM"); mccomp_param_nexus(nxhandle,"0003_lmon_guide_start", "yheight", "0", "0","MCNUM"); mccomp_param_nexus(nxhandle,"0003_lmon_guide_start", "Lmin", "NONE", "lmin","MCNUM"); mccomp_param_nexus(nxhandle,"0003_lmon_guide_start", "Lmax", "NONE", "lmax","MCNUM"); mccomp_param_nexus(nxhandle,"0003_lmon_guide_start", "restore_neutron", "0", "1","int"); ); } } else { // fprintf(stderr,"NO NEXUS FILE"); } #endif return(0); } /* _lmon_guide_start_setpos */ /* component guideStraight=Guide() SETTING, POSITION/ROTATION */ int _guideStraight_setpos(void) { /* sets initial component parameters, position and rotation */ SIG_MESSAGE("[_guideStraight_setpos] component guideStraight=Guide() SETTING [Guide:0]"); stracpy(_guideStraight_var._name, "guideStraight", 16384); stracpy(_guideStraight_var._type, "Guide", 16384); _guideStraight_var._index=5; int current_setpos_index = 5; _guideStraight_var._parameters.reflect[0]='\0'; _guideStraight_var._parameters.w1 = 0.03; _guideStraight_var._parameters.h1 = 0.12; _guideStraight_var._parameters.w2 = 0.03; _guideStraight_var._parameters.h2 = 0.12; _guideStraight_var._parameters.l = 4.628; _guideStraight_var._parameters.R0 = R0; _guideStraight_var._parameters.Qc = Qc; _guideStraight_var._parameters.alpha = ALPHA; _guideStraight_var._parameters.m = M; _guideStraight_var._parameters.W = W; /* component guideStraight=Guide() AT ROTATED */ { Coords tc1, tc2; tc1 = coords_set(0,0,0); tc2 = coords_set(0,0,0); Rotation tr1; rot_set_rotation(tr1,0,0,0); rot_set_rotation(tr1, (0.0)*DEG2RAD, (0.0)*DEG2RAD, (0.0)*DEG2RAD); rot_mul(tr1, _armSource_var._rotation_absolute, _guideStraight_var._rotation_absolute); rot_transpose(_lmon_guide_start_var._rotation_absolute, tr1); rot_mul(_guideStraight_var._rotation_absolute, tr1, _guideStraight_var._rotation_relative); _guideStraight_var._rotation_is_identity = rot_test_identity(_guideStraight_var._rotation_relative); tc1 = coords_set( 0, 0, 1.465); rot_transpose(_armSource_var._rotation_absolute, tr1); tc2 = rot_apply(tr1, tc1); _guideStraight_var._position_absolute = coords_add(_armSource_var._position_absolute, tc2); tc1 = coords_sub(_lmon_guide_start_var._position_absolute, _guideStraight_var._position_absolute); _guideStraight_var._position_relative = rot_apply(_guideStraight_var._rotation_absolute, tc1); } /* guideStraight=Guide() AT ROTATED */ DEBUG_COMPONENT("guideStraight", _guideStraight_var._position_absolute, _guideStraight_var._rotation_absolute); instrument->_position_absolute[5] = _guideStraight_var._position_absolute; instrument->_position_relative[5] = _guideStraight_var._position_relative; _guideStraight_var._position_relative_is_zero = coords_test_zero(_guideStraight_var._position_relative); instrument->counter_N[5] = instrument->counter_P[5] = instrument->counter_P2[5] = 0; instrument->counter_AbsorbProp[5]= 0; #ifdef USE_NEXUS if(nxhandle) { if ((!mcdotrace) && mcformat && strcasestr(mcformat, "NeXus")) { MPI_MASTER( mccomp_placement_type_nexus(nxhandle,"0004_guideStraight", _guideStraight_var._position_absolute, _guideStraight_var._rotation_absolute, "Guide"); mccomp_param_nexus(nxhandle,"0004_guideStraight", "reflect", 0, 0, "char*"); mccomp_param_nexus(nxhandle,"0004_guideStraight", "w1", "NONE", "0.03","MCNUM"); mccomp_param_nexus(nxhandle,"0004_guideStraight", "h1", "NONE", "0.12","MCNUM"); mccomp_param_nexus(nxhandle,"0004_guideStraight", "w2", "0", "0.03","MCNUM"); mccomp_param_nexus(nxhandle,"0004_guideStraight", "h2", "0", "0.12","MCNUM"); mccomp_param_nexus(nxhandle,"0004_guideStraight", "l", "NONE", "4.628","MCNUM"); mccomp_param_nexus(nxhandle,"0004_guideStraight", "R0", "0.99", "R0","MCNUM"); mccomp_param_nexus(nxhandle,"0004_guideStraight", "Qc", "0.0219", "Qc","MCNUM"); mccomp_param_nexus(nxhandle,"0004_guideStraight", "alpha", "6.07", "ALPHA","MCNUM"); mccomp_param_nexus(nxhandle,"0004_guideStraight", "m", "2", "M","MCNUM"); mccomp_param_nexus(nxhandle,"0004_guideStraight", "W", "0.003", "W","MCNUM"); ); } } else { // fprintf(stderr,"NO NEXUS FILE"); } #endif return(0); } /* _guideStraight_setpos */ /* component guideCurved1=Guide() SETTING, POSITION/ROTATION */ int _guideCurved1_setpos(void) { /* sets initial component parameters, position and rotation */ SIG_MESSAGE("[_guideCurved1_setpos] component guideCurved1=Guide() SETTING [Guide:0]"); stracpy(_guideCurved1_var._name, "guideCurved1", 16384); stracpy(_guideCurved1_var._type, "Guide", 16384); _guideCurved1_var._index=6; int current_setpos_index = 6; _guideCurved1_var._parameters.reflect[0]='\0'; _guideCurved1_var._parameters.w1 = 0.03; _guideCurved1_var._parameters.h1 = 0.12; _guideCurved1_var._parameters.w2 = 0.03; _guideCurved1_var._parameters.h2 = 0.12; _guideCurved1_var._parameters.l = 0.499995; _guideCurved1_var._parameters.R0 = R0; _guideCurved1_var._parameters.Qc = Qc; _guideCurved1_var._parameters.alpha = ALPHA; _guideCurved1_var._parameters.m = M; _guideCurved1_var._parameters.W = W; /* component guideCurved1=Guide() AT ROTATED */ { Coords tc1, tc2; tc1 = coords_set(0,0,0); tc2 = coords_set(0,0,0); Rotation tr1; rot_set_rotation(tr1,0,0,0); rot_set_rotation(tr1, (0)*DEG2RAD, (angleGuideCurved)*DEG2RAD, (0)*DEG2RAD); rot_mul(tr1, _guideStraight_var._rotation_absolute, _guideCurved1_var._rotation_absolute); rot_transpose(_guideStraight_var._rotation_absolute, tr1); rot_mul(_guideCurved1_var._rotation_absolute, tr1, _guideCurved1_var._rotation_relative); _guideCurved1_var._rotation_is_identity = rot_test_identity(_guideCurved1_var._rotation_relative); tc1 = coords_set( 0, 0, 4.663); rot_transpose(_guideStraight_var._rotation_absolute, tr1); tc2 = rot_apply(tr1, tc1); _guideCurved1_var._position_absolute = coords_add(_guideStraight_var._position_absolute, tc2); tc1 = coords_sub(_guideStraight_var._position_absolute, _guideCurved1_var._position_absolute); _guideCurved1_var._position_relative = rot_apply(_guideCurved1_var._rotation_absolute, tc1); } /* guideCurved1=Guide() AT ROTATED */ DEBUG_COMPONENT("guideCurved1", _guideCurved1_var._position_absolute, _guideCurved1_var._rotation_absolute); instrument->_position_absolute[6] = _guideCurved1_var._position_absolute; instrument->_position_relative[6] = _guideCurved1_var._position_relative; _guideCurved1_var._position_relative_is_zero = coords_test_zero(_guideCurved1_var._position_relative); instrument->counter_N[6] = instrument->counter_P[6] = instrument->counter_P2[6] = 0; instrument->counter_AbsorbProp[6]= 0; #ifdef USE_NEXUS if(nxhandle) { if ((!mcdotrace) && mcformat && strcasestr(mcformat, "NeXus")) { MPI_MASTER( mccomp_placement_type_nexus(nxhandle,"0005_guideCurved1", _guideCurved1_var._position_absolute, _guideCurved1_var._rotation_absolute, "Guide"); mccomp_param_nexus(nxhandle,"0005_guideCurved1", "reflect", 0, 0, "char*"); mccomp_param_nexus(nxhandle,"0005_guideCurved1", "w1", "NONE", "0.03","MCNUM"); mccomp_param_nexus(nxhandle,"0005_guideCurved1", "h1", "NONE", "0.12","MCNUM"); mccomp_param_nexus(nxhandle,"0005_guideCurved1", "w2", "0", "0.03","MCNUM"); mccomp_param_nexus(nxhandle,"0005_guideCurved1", "h2", "0", "0.12","MCNUM"); mccomp_param_nexus(nxhandle,"0005_guideCurved1", "l", "NONE", "0.499995","MCNUM"); mccomp_param_nexus(nxhandle,"0005_guideCurved1", "R0", "0.99", "R0","MCNUM"); mccomp_param_nexus(nxhandle,"0005_guideCurved1", "Qc", "0.0219", "Qc","MCNUM"); mccomp_param_nexus(nxhandle,"0005_guideCurved1", "alpha", "6.07", "ALPHA","MCNUM"); mccomp_param_nexus(nxhandle,"0005_guideCurved1", "m", "2", "M","MCNUM"); mccomp_param_nexus(nxhandle,"0005_guideCurved1", "W", "0.003", "W","MCNUM"); ); } } else { // fprintf(stderr,"NO NEXUS FILE"); } #endif return(0); } /* _guideCurved1_setpos */ /* component guideCurved2=Guide() SETTING, POSITION/ROTATION */ int _guideCurved2_setpos(void) { /* sets initial component parameters, position and rotation */ SIG_MESSAGE("[_guideCurved2_setpos] component guideCurved2=Guide() SETTING [Guide:0]"); stracpy(_guideCurved2_var._name, "guideCurved2", 16384); stracpy(_guideCurved2_var._type, "Guide", 16384); _guideCurved2_var._index=7; int current_setpos_index = 7; _guideCurved2_var._parameters.reflect[0]='\0'; _guideCurved2_var._parameters.w1 = 0.03; _guideCurved2_var._parameters.h1 = 0.12; _guideCurved2_var._parameters.w2 = 0.03; _guideCurved2_var._parameters.h2 = 0.12; _guideCurved2_var._parameters.l = 0.499995; _guideCurved2_var._parameters.R0 = R0; _guideCurved2_var._parameters.Qc = Qc; _guideCurved2_var._parameters.alpha = ALPHA; _guideCurved2_var._parameters.m = M; _guideCurved2_var._parameters.W = W; /* component guideCurved2=Guide() AT ROTATED */ { Coords tc1, tc2; tc1 = coords_set(0,0,0); tc2 = coords_set(0,0,0); Rotation tr1; rot_set_rotation(tr1,0,0,0); rot_set_rotation(tr1, (0)*DEG2RAD, (angleGuideCurved)*DEG2RAD, (0)*DEG2RAD); rot_mul(tr1, _guideCurved1_var._rotation_absolute, _guideCurved2_var._rotation_absolute); rot_transpose(_guideCurved1_var._rotation_absolute, tr1); rot_mul(_guideCurved2_var._rotation_absolute, tr1, _guideCurved2_var._rotation_relative); _guideCurved2_var._rotation_is_identity = rot_test_identity(_guideCurved2_var._rotation_relative); tc1 = coords_set( 0, 0, 0.5); rot_transpose(_guideCurved1_var._rotation_absolute, tr1); tc2 = rot_apply(tr1, tc1); _guideCurved2_var._position_absolute = coords_add(_guideCurved1_var._position_absolute, tc2); tc1 = coords_sub(_guideCurved1_var._position_absolute, _guideCurved2_var._position_absolute); _guideCurved2_var._position_relative = rot_apply(_guideCurved2_var._rotation_absolute, tc1); } /* guideCurved2=Guide() AT ROTATED */ DEBUG_COMPONENT("guideCurved2", _guideCurved2_var._position_absolute, _guideCurved2_var._rotation_absolute); instrument->_position_absolute[7] = _guideCurved2_var._position_absolute; instrument->_position_relative[7] = _guideCurved2_var._position_relative; _guideCurved2_var._position_relative_is_zero = coords_test_zero(_guideCurved2_var._position_relative); instrument->counter_N[7] = instrument->counter_P[7] = instrument->counter_P2[7] = 0; instrument->counter_AbsorbProp[7]= 0; #ifdef USE_NEXUS if(nxhandle) { if ((!mcdotrace) && mcformat && strcasestr(mcformat, "NeXus")) { MPI_MASTER( mccomp_placement_type_nexus(nxhandle,"0006_guideCurved2", _guideCurved2_var._position_absolute, _guideCurved2_var._rotation_absolute, "Guide"); mccomp_param_nexus(nxhandle,"0006_guideCurved2", "reflect", 0, 0, "char*"); mccomp_param_nexus(nxhandle,"0006_guideCurved2", "w1", "NONE", "0.03","MCNUM"); mccomp_param_nexus(nxhandle,"0006_guideCurved2", "h1", "NONE", "0.12","MCNUM"); mccomp_param_nexus(nxhandle,"0006_guideCurved2", "w2", "0", "0.03","MCNUM"); mccomp_param_nexus(nxhandle,"0006_guideCurved2", "h2", "0", "0.12","MCNUM"); mccomp_param_nexus(nxhandle,"0006_guideCurved2", "l", "NONE", "0.499995","MCNUM"); mccomp_param_nexus(nxhandle,"0006_guideCurved2", "R0", "0.99", "R0","MCNUM"); mccomp_param_nexus(nxhandle,"0006_guideCurved2", "Qc", "0.0219", "Qc","MCNUM"); mccomp_param_nexus(nxhandle,"0006_guideCurved2", "alpha", "6.07", "ALPHA","MCNUM"); mccomp_param_nexus(nxhandle,"0006_guideCurved2", "m", "2", "M","MCNUM"); mccomp_param_nexus(nxhandle,"0006_guideCurved2", "W", "0.003", "W","MCNUM"); ); } } else { // fprintf(stderr,"NO NEXUS FILE"); } #endif return(0); } /* _guideCurved2_setpos */ /* component guideCurved3=Guide() SETTING, POSITION/ROTATION */ int _guideCurved3_setpos(void) { /* sets initial component parameters, position and rotation */ SIG_MESSAGE("[_guideCurved3_setpos] component guideCurved3=Guide() SETTING [Guide:0]"); stracpy(_guideCurved3_var._name, "guideCurved3", 16384); stracpy(_guideCurved3_var._type, "Guide", 16384); _guideCurved3_var._index=8; int current_setpos_index = 8; _guideCurved3_var._parameters.reflect[0]='\0'; _guideCurved3_var._parameters.w1 = 0.03; _guideCurved3_var._parameters.h1 = 0.12; _guideCurved3_var._parameters.w2 = 0.03; _guideCurved3_var._parameters.h2 = 0.12; _guideCurved3_var._parameters.l = 0.499995; _guideCurved3_var._parameters.R0 = R0; _guideCurved3_var._parameters.Qc = Qc; _guideCurved3_var._parameters.alpha = ALPHA; _guideCurved3_var._parameters.m = M; _guideCurved3_var._parameters.W = W; /* component guideCurved3=Guide() AT ROTATED */ { Coords tc1, tc2; tc1 = coords_set(0,0,0); tc2 = coords_set(0,0,0); Rotation tr1; rot_set_rotation(tr1,0,0,0); rot_set_rotation(tr1, (0)*DEG2RAD, (angleGuideCurved)*DEG2RAD, (0)*DEG2RAD); rot_mul(tr1, _guideCurved2_var._rotation_absolute, _guideCurved3_var._rotation_absolute); rot_transpose(_guideCurved2_var._rotation_absolute, tr1); rot_mul(_guideCurved3_var._rotation_absolute, tr1, _guideCurved3_var._rotation_relative); _guideCurved3_var._rotation_is_identity = rot_test_identity(_guideCurved3_var._rotation_relative); tc1 = coords_set( 0, 0, 0.5); rot_transpose(_guideCurved2_var._rotation_absolute, tr1); tc2 = rot_apply(tr1, tc1); _guideCurved3_var._position_absolute = coords_add(_guideCurved2_var._position_absolute, tc2); tc1 = coords_sub(_guideCurved2_var._position_absolute, _guideCurved3_var._position_absolute); _guideCurved3_var._position_relative = rot_apply(_guideCurved3_var._rotation_absolute, tc1); } /* guideCurved3=Guide() AT ROTATED */ DEBUG_COMPONENT("guideCurved3", _guideCurved3_var._position_absolute, _guideCurved3_var._rotation_absolute); instrument->_position_absolute[8] = _guideCurved3_var._position_absolute; instrument->_position_relative[8] = _guideCurved3_var._position_relative; _guideCurved3_var._position_relative_is_zero = coords_test_zero(_guideCurved3_var._position_relative); instrument->counter_N[8] = instrument->counter_P[8] = instrument->counter_P2[8] = 0; instrument->counter_AbsorbProp[8]= 0; #ifdef USE_NEXUS if(nxhandle) { if ((!mcdotrace) && mcformat && strcasestr(mcformat, "NeXus")) { MPI_MASTER( mccomp_placement_type_nexus(nxhandle,"0007_guideCurved3", _guideCurved3_var._position_absolute, _guideCurved3_var._rotation_absolute, "Guide"); mccomp_param_nexus(nxhandle,"0007_guideCurved3", "reflect", 0, 0, "char*"); mccomp_param_nexus(nxhandle,"0007_guideCurved3", "w1", "NONE", "0.03","MCNUM"); mccomp_param_nexus(nxhandle,"0007_guideCurved3", "h1", "NONE", "0.12","MCNUM"); mccomp_param_nexus(nxhandle,"0007_guideCurved3", "w2", "0", "0.03","MCNUM"); mccomp_param_nexus(nxhandle,"0007_guideCurved3", "h2", "0", "0.12","MCNUM"); mccomp_param_nexus(nxhandle,"0007_guideCurved3", "l", "NONE", "0.499995","MCNUM"); mccomp_param_nexus(nxhandle,"0007_guideCurved3", "R0", "0.99", "R0","MCNUM"); mccomp_param_nexus(nxhandle,"0007_guideCurved3", "Qc", "0.0219", "Qc","MCNUM"); mccomp_param_nexus(nxhandle,"0007_guideCurved3", "alpha", "6.07", "ALPHA","MCNUM"); mccomp_param_nexus(nxhandle,"0007_guideCurved3", "m", "2", "M","MCNUM"); mccomp_param_nexus(nxhandle,"0007_guideCurved3", "W", "0.003", "W","MCNUM"); ); } } else { // fprintf(stderr,"NO NEXUS FILE"); } #endif return(0); } /* _guideCurved3_setpos */ /* component guideCurved4=Guide() SETTING, POSITION/ROTATION */ int _guideCurved4_setpos(void) { /* sets initial component parameters, position and rotation */ SIG_MESSAGE("[_guideCurved4_setpos] component guideCurved4=Guide() SETTING [Guide:0]"); stracpy(_guideCurved4_var._name, "guideCurved4", 16384); stracpy(_guideCurved4_var._type, "Guide", 16384); _guideCurved4_var._index=9; int current_setpos_index = 9; _guideCurved4_var._parameters.reflect[0]='\0'; _guideCurved4_var._parameters.w1 = 0.03; _guideCurved4_var._parameters.h1 = 0.12; _guideCurved4_var._parameters.w2 = 0.03; _guideCurved4_var._parameters.h2 = 0.12; _guideCurved4_var._parameters.l = 0.499995; _guideCurved4_var._parameters.R0 = R0; _guideCurved4_var._parameters.Qc = Qc; _guideCurved4_var._parameters.alpha = ALPHA; _guideCurved4_var._parameters.m = M; _guideCurved4_var._parameters.W = W; /* component guideCurved4=Guide() AT ROTATED */ { Coords tc1, tc2; tc1 = coords_set(0,0,0); tc2 = coords_set(0,0,0); Rotation tr1; rot_set_rotation(tr1,0,0,0); rot_set_rotation(tr1, (0)*DEG2RAD, (angleGuideCurved)*DEG2RAD, (0)*DEG2RAD); rot_mul(tr1, _guideCurved3_var._rotation_absolute, _guideCurved4_var._rotation_absolute); rot_transpose(_guideCurved3_var._rotation_absolute, tr1); rot_mul(_guideCurved4_var._rotation_absolute, tr1, _guideCurved4_var._rotation_relative); _guideCurved4_var._rotation_is_identity = rot_test_identity(_guideCurved4_var._rotation_relative); tc1 = coords_set( 0, 0, 0.5); rot_transpose(_guideCurved3_var._rotation_absolute, tr1); tc2 = rot_apply(tr1, tc1); _guideCurved4_var._position_absolute = coords_add(_guideCurved3_var._position_absolute, tc2); tc1 = coords_sub(_guideCurved3_var._position_absolute, _guideCurved4_var._position_absolute); _guideCurved4_var._position_relative = rot_apply(_guideCurved4_var._rotation_absolute, tc1); } /* guideCurved4=Guide() AT ROTATED */ DEBUG_COMPONENT("guideCurved4", _guideCurved4_var._position_absolute, _guideCurved4_var._rotation_absolute); instrument->_position_absolute[9] = _guideCurved4_var._position_absolute; instrument->_position_relative[9] = _guideCurved4_var._position_relative; _guideCurved4_var._position_relative_is_zero = coords_test_zero(_guideCurved4_var._position_relative); instrument->counter_N[9] = instrument->counter_P[9] = instrument->counter_P2[9] = 0; instrument->counter_AbsorbProp[9]= 0; #ifdef USE_NEXUS if(nxhandle) { if ((!mcdotrace) && mcformat && strcasestr(mcformat, "NeXus")) { MPI_MASTER( mccomp_placement_type_nexus(nxhandle,"0008_guideCurved4", _guideCurved4_var._position_absolute, _guideCurved4_var._rotation_absolute, "Guide"); mccomp_param_nexus(nxhandle,"0008_guideCurved4", "reflect", 0, 0, "char*"); mccomp_param_nexus(nxhandle,"0008_guideCurved4", "w1", "NONE", "0.03","MCNUM"); mccomp_param_nexus(nxhandle,"0008_guideCurved4", "h1", "NONE", "0.12","MCNUM"); mccomp_param_nexus(nxhandle,"0008_guideCurved4", "w2", "0", "0.03","MCNUM"); mccomp_param_nexus(nxhandle,"0008_guideCurved4", "h2", "0", "0.12","MCNUM"); mccomp_param_nexus(nxhandle,"0008_guideCurved4", "l", "NONE", "0.499995","MCNUM"); mccomp_param_nexus(nxhandle,"0008_guideCurved4", "R0", "0.99", "R0","MCNUM"); mccomp_param_nexus(nxhandle,"0008_guideCurved4", "Qc", "0.0219", "Qc","MCNUM"); mccomp_param_nexus(nxhandle,"0008_guideCurved4", "alpha", "6.07", "ALPHA","MCNUM"); mccomp_param_nexus(nxhandle,"0008_guideCurved4", "m", "2", "M","MCNUM"); mccomp_param_nexus(nxhandle,"0008_guideCurved4", "W", "0.003", "W","MCNUM"); ); } } else { // fprintf(stderr,"NO NEXUS FILE"); } #endif return(0); } /* _guideCurved4_setpos */ /* component guideCurved5=Guide() SETTING, POSITION/ROTATION */ int _guideCurved5_setpos(void) { /* sets initial component parameters, position and rotation */ SIG_MESSAGE("[_guideCurved5_setpos] component guideCurved5=Guide() SETTING [Guide:0]"); stracpy(_guideCurved5_var._name, "guideCurved5", 16384); stracpy(_guideCurved5_var._type, "Guide", 16384); _guideCurved5_var._index=10; int current_setpos_index = 10; _guideCurved5_var._parameters.reflect[0]='\0'; _guideCurved5_var._parameters.w1 = 0.03; _guideCurved5_var._parameters.h1 = 0.12; _guideCurved5_var._parameters.w2 = 0.03; _guideCurved5_var._parameters.h2 = 0.12; _guideCurved5_var._parameters.l = 0.499995; _guideCurved5_var._parameters.R0 = R0; _guideCurved5_var._parameters.Qc = Qc; _guideCurved5_var._parameters.alpha = ALPHA; _guideCurved5_var._parameters.m = M; _guideCurved5_var._parameters.W = W; /* component guideCurved5=Guide() AT ROTATED */ { Coords tc1, tc2; tc1 = coords_set(0,0,0); tc2 = coords_set(0,0,0); Rotation tr1; rot_set_rotation(tr1,0,0,0); rot_set_rotation(tr1, (0)*DEG2RAD, (angleGuideCurved)*DEG2RAD, (0)*DEG2RAD); rot_mul(tr1, _guideCurved4_var._rotation_absolute, _guideCurved5_var._rotation_absolute); rot_transpose(_guideCurved4_var._rotation_absolute, tr1); rot_mul(_guideCurved5_var._rotation_absolute, tr1, _guideCurved5_var._rotation_relative); _guideCurved5_var._rotation_is_identity = rot_test_identity(_guideCurved5_var._rotation_relative); tc1 = coords_set( 0, 0, 0.5); rot_transpose(_guideCurved4_var._rotation_absolute, tr1); tc2 = rot_apply(tr1, tc1); _guideCurved5_var._position_absolute = coords_add(_guideCurved4_var._position_absolute, tc2); tc1 = coords_sub(_guideCurved4_var._position_absolute, _guideCurved5_var._position_absolute); _guideCurved5_var._position_relative = rot_apply(_guideCurved5_var._rotation_absolute, tc1); } /* guideCurved5=Guide() AT ROTATED */ DEBUG_COMPONENT("guideCurved5", _guideCurved5_var._position_absolute, _guideCurved5_var._rotation_absolute); instrument->_position_absolute[10] = _guideCurved5_var._position_absolute; instrument->_position_relative[10] = _guideCurved5_var._position_relative; _guideCurved5_var._position_relative_is_zero = coords_test_zero(_guideCurved5_var._position_relative); instrument->counter_N[10] = instrument->counter_P[10] = instrument->counter_P2[10] = 0; instrument->counter_AbsorbProp[10]= 0; #ifdef USE_NEXUS if(nxhandle) { if ((!mcdotrace) && mcformat && strcasestr(mcformat, "NeXus")) { MPI_MASTER( mccomp_placement_type_nexus(nxhandle,"0009_guideCurved5", _guideCurved5_var._position_absolute, _guideCurved5_var._rotation_absolute, "Guide"); mccomp_param_nexus(nxhandle,"0009_guideCurved5", "reflect", 0, 0, "char*"); mccomp_param_nexus(nxhandle,"0009_guideCurved5", "w1", "NONE", "0.03","MCNUM"); mccomp_param_nexus(nxhandle,"0009_guideCurved5", "h1", "NONE", "0.12","MCNUM"); mccomp_param_nexus(nxhandle,"0009_guideCurved5", "w2", "0", "0.03","MCNUM"); mccomp_param_nexus(nxhandle,"0009_guideCurved5", "h2", "0", "0.12","MCNUM"); mccomp_param_nexus(nxhandle,"0009_guideCurved5", "l", "NONE", "0.499995","MCNUM"); mccomp_param_nexus(nxhandle,"0009_guideCurved5", "R0", "0.99", "R0","MCNUM"); mccomp_param_nexus(nxhandle,"0009_guideCurved5", "Qc", "0.0219", "Qc","MCNUM"); mccomp_param_nexus(nxhandle,"0009_guideCurved5", "alpha", "6.07", "ALPHA","MCNUM"); mccomp_param_nexus(nxhandle,"0009_guideCurved5", "m", "2", "M","MCNUM"); mccomp_param_nexus(nxhandle,"0009_guideCurved5", "W", "0.003", "W","MCNUM"); ); } } else { // fprintf(stderr,"NO NEXUS FILE"); } #endif return(0); } /* _guideCurved5_setpos */ /* component guideCurved6=Guide() SETTING, POSITION/ROTATION */ int _guideCurved6_setpos(void) { /* sets initial component parameters, position and rotation */ SIG_MESSAGE("[_guideCurved6_setpos] component guideCurved6=Guide() SETTING [Guide:0]"); stracpy(_guideCurved6_var._name, "guideCurved6", 16384); stracpy(_guideCurved6_var._type, "Guide", 16384); _guideCurved6_var._index=11; int current_setpos_index = 11; _guideCurved6_var._parameters.reflect[0]='\0'; _guideCurved6_var._parameters.w1 = 0.03; _guideCurved6_var._parameters.h1 = 0.12; _guideCurved6_var._parameters.w2 = 0.03; _guideCurved6_var._parameters.h2 = 0.12; _guideCurved6_var._parameters.l = 0.499995; _guideCurved6_var._parameters.R0 = R0; _guideCurved6_var._parameters.Qc = Qc; _guideCurved6_var._parameters.alpha = ALPHA; _guideCurved6_var._parameters.m = M; _guideCurved6_var._parameters.W = W; /* component guideCurved6=Guide() AT ROTATED */ { Coords tc1, tc2; tc1 = coords_set(0,0,0); tc2 = coords_set(0,0,0); Rotation tr1; rot_set_rotation(tr1,0,0,0); rot_set_rotation(tr1, (0)*DEG2RAD, (angleGuideCurved)*DEG2RAD, (0)*DEG2RAD); rot_mul(tr1, _guideCurved5_var._rotation_absolute, _guideCurved6_var._rotation_absolute); rot_transpose(_guideCurved5_var._rotation_absolute, tr1); rot_mul(_guideCurved6_var._rotation_absolute, tr1, _guideCurved6_var._rotation_relative); _guideCurved6_var._rotation_is_identity = rot_test_identity(_guideCurved6_var._rotation_relative); tc1 = coords_set( 0, 0, 0.5); rot_transpose(_guideCurved5_var._rotation_absolute, tr1); tc2 = rot_apply(tr1, tc1); _guideCurved6_var._position_absolute = coords_add(_guideCurved5_var._position_absolute, tc2); tc1 = coords_sub(_guideCurved5_var._position_absolute, _guideCurved6_var._position_absolute); _guideCurved6_var._position_relative = rot_apply(_guideCurved6_var._rotation_absolute, tc1); } /* guideCurved6=Guide() AT ROTATED */ DEBUG_COMPONENT("guideCurved6", _guideCurved6_var._position_absolute, _guideCurved6_var._rotation_absolute); instrument->_position_absolute[11] = _guideCurved6_var._position_absolute; instrument->_position_relative[11] = _guideCurved6_var._position_relative; _guideCurved6_var._position_relative_is_zero = coords_test_zero(_guideCurved6_var._position_relative); instrument->counter_N[11] = instrument->counter_P[11] = instrument->counter_P2[11] = 0; instrument->counter_AbsorbProp[11]= 0; #ifdef USE_NEXUS if(nxhandle) { if ((!mcdotrace) && mcformat && strcasestr(mcformat, "NeXus")) { MPI_MASTER( mccomp_placement_type_nexus(nxhandle,"0010_guideCurved6", _guideCurved6_var._position_absolute, _guideCurved6_var._rotation_absolute, "Guide"); mccomp_param_nexus(nxhandle,"0010_guideCurved6", "reflect", 0, 0, "char*"); mccomp_param_nexus(nxhandle,"0010_guideCurved6", "w1", "NONE", "0.03","MCNUM"); mccomp_param_nexus(nxhandle,"0010_guideCurved6", "h1", "NONE", "0.12","MCNUM"); mccomp_param_nexus(nxhandle,"0010_guideCurved6", "w2", "0", "0.03","MCNUM"); mccomp_param_nexus(nxhandle,"0010_guideCurved6", "h2", "0", "0.12","MCNUM"); mccomp_param_nexus(nxhandle,"0010_guideCurved6", "l", "NONE", "0.499995","MCNUM"); mccomp_param_nexus(nxhandle,"0010_guideCurved6", "R0", "0.99", "R0","MCNUM"); mccomp_param_nexus(nxhandle,"0010_guideCurved6", "Qc", "0.0219", "Qc","MCNUM"); mccomp_param_nexus(nxhandle,"0010_guideCurved6", "alpha", "6.07", "ALPHA","MCNUM"); mccomp_param_nexus(nxhandle,"0010_guideCurved6", "m", "2", "M","MCNUM"); mccomp_param_nexus(nxhandle,"0010_guideCurved6", "W", "0.003", "W","MCNUM"); ); } } else { // fprintf(stderr,"NO NEXUS FILE"); } #endif return(0); } /* _guideCurved6_setpos */ /* component guideCurved7=Guide() SETTING, POSITION/ROTATION */ int _guideCurved7_setpos(void) { /* sets initial component parameters, position and rotation */ SIG_MESSAGE("[_guideCurved7_setpos] component guideCurved7=Guide() SETTING [Guide:0]"); stracpy(_guideCurved7_var._name, "guideCurved7", 16384); stracpy(_guideCurved7_var._type, "Guide", 16384); _guideCurved7_var._index=12; int current_setpos_index = 12; _guideCurved7_var._parameters.reflect[0]='\0'; _guideCurved7_var._parameters.w1 = 0.03; _guideCurved7_var._parameters.h1 = 0.12; _guideCurved7_var._parameters.w2 = 0.03; _guideCurved7_var._parameters.h2 = 0.12; _guideCurved7_var._parameters.l = 0.499995; _guideCurved7_var._parameters.R0 = R0; _guideCurved7_var._parameters.Qc = Qc; _guideCurved7_var._parameters.alpha = ALPHA; _guideCurved7_var._parameters.m = M; _guideCurved7_var._parameters.W = W; /* component guideCurved7=Guide() AT ROTATED */ { Coords tc1, tc2; tc1 = coords_set(0,0,0); tc2 = coords_set(0,0,0); Rotation tr1; rot_set_rotation(tr1,0,0,0); rot_set_rotation(tr1, (0)*DEG2RAD, (angleGuideCurved)*DEG2RAD, (0)*DEG2RAD); rot_mul(tr1, _guideCurved6_var._rotation_absolute, _guideCurved7_var._rotation_absolute); rot_transpose(_guideCurved6_var._rotation_absolute, tr1); rot_mul(_guideCurved7_var._rotation_absolute, tr1, _guideCurved7_var._rotation_relative); _guideCurved7_var._rotation_is_identity = rot_test_identity(_guideCurved7_var._rotation_relative); tc1 = coords_set( 0, 0, 0.5); rot_transpose(_guideCurved6_var._rotation_absolute, tr1); tc2 = rot_apply(tr1, tc1); _guideCurved7_var._position_absolute = coords_add(_guideCurved6_var._position_absolute, tc2); tc1 = coords_sub(_guideCurved6_var._position_absolute, _guideCurved7_var._position_absolute); _guideCurved7_var._position_relative = rot_apply(_guideCurved7_var._rotation_absolute, tc1); } /* guideCurved7=Guide() AT ROTATED */ DEBUG_COMPONENT("guideCurved7", _guideCurved7_var._position_absolute, _guideCurved7_var._rotation_absolute); instrument->_position_absolute[12] = _guideCurved7_var._position_absolute; instrument->_position_relative[12] = _guideCurved7_var._position_relative; _guideCurved7_var._position_relative_is_zero = coords_test_zero(_guideCurved7_var._position_relative); instrument->counter_N[12] = instrument->counter_P[12] = instrument->counter_P2[12] = 0; instrument->counter_AbsorbProp[12]= 0; #ifdef USE_NEXUS if(nxhandle) { if ((!mcdotrace) && mcformat && strcasestr(mcformat, "NeXus")) { MPI_MASTER( mccomp_placement_type_nexus(nxhandle,"0011_guideCurved7", _guideCurved7_var._position_absolute, _guideCurved7_var._rotation_absolute, "Guide"); mccomp_param_nexus(nxhandle,"0011_guideCurved7", "reflect", 0, 0, "char*"); mccomp_param_nexus(nxhandle,"0011_guideCurved7", "w1", "NONE", "0.03","MCNUM"); mccomp_param_nexus(nxhandle,"0011_guideCurved7", "h1", "NONE", "0.12","MCNUM"); mccomp_param_nexus(nxhandle,"0011_guideCurved7", "w2", "0", "0.03","MCNUM"); mccomp_param_nexus(nxhandle,"0011_guideCurved7", "h2", "0", "0.12","MCNUM"); mccomp_param_nexus(nxhandle,"0011_guideCurved7", "l", "NONE", "0.499995","MCNUM"); mccomp_param_nexus(nxhandle,"0011_guideCurved7", "R0", "0.99", "R0","MCNUM"); mccomp_param_nexus(nxhandle,"0011_guideCurved7", "Qc", "0.0219", "Qc","MCNUM"); mccomp_param_nexus(nxhandle,"0011_guideCurved7", "alpha", "6.07", "ALPHA","MCNUM"); mccomp_param_nexus(nxhandle,"0011_guideCurved7", "m", "2", "M","MCNUM"); mccomp_param_nexus(nxhandle,"0011_guideCurved7", "W", "0.003", "W","MCNUM"); ); } } else { // fprintf(stderr,"NO NEXUS FILE"); } #endif return(0); } /* _guideCurved7_setpos */ /* component guideCurved8=Guide() SETTING, POSITION/ROTATION */ int _guideCurved8_setpos(void) { /* sets initial component parameters, position and rotation */ SIG_MESSAGE("[_guideCurved8_setpos] component guideCurved8=Guide() SETTING [Guide:0]"); stracpy(_guideCurved8_var._name, "guideCurved8", 16384); stracpy(_guideCurved8_var._type, "Guide", 16384); _guideCurved8_var._index=13; int current_setpos_index = 13; _guideCurved8_var._parameters.reflect[0]='\0'; _guideCurved8_var._parameters.w1 = 0.03; _guideCurved8_var._parameters.h1 = 0.12; _guideCurved8_var._parameters.w2 = 0.03; _guideCurved8_var._parameters.h2 = 0.12; _guideCurved8_var._parameters.l = 0.499995; _guideCurved8_var._parameters.R0 = R0; _guideCurved8_var._parameters.Qc = Qc; _guideCurved8_var._parameters.alpha = ALPHA; _guideCurved8_var._parameters.m = M; _guideCurved8_var._parameters.W = W; /* component guideCurved8=Guide() AT ROTATED */ { Coords tc1, tc2; tc1 = coords_set(0,0,0); tc2 = coords_set(0,0,0); Rotation tr1; rot_set_rotation(tr1,0,0,0); rot_set_rotation(tr1, (0)*DEG2RAD, (angleGuideCurved)*DEG2RAD, (0)*DEG2RAD); rot_mul(tr1, _guideCurved7_var._rotation_absolute, _guideCurved8_var._rotation_absolute); rot_transpose(_guideCurved7_var._rotation_absolute, tr1); rot_mul(_guideCurved8_var._rotation_absolute, tr1, _guideCurved8_var._rotation_relative); _guideCurved8_var._rotation_is_identity = rot_test_identity(_guideCurved8_var._rotation_relative); tc1 = coords_set( 0, 0, 0.5); rot_transpose(_guideCurved7_var._rotation_absolute, tr1); tc2 = rot_apply(tr1, tc1); _guideCurved8_var._position_absolute = coords_add(_guideCurved7_var._position_absolute, tc2); tc1 = coords_sub(_guideCurved7_var._position_absolute, _guideCurved8_var._position_absolute); _guideCurved8_var._position_relative = rot_apply(_guideCurved8_var._rotation_absolute, tc1); } /* guideCurved8=Guide() AT ROTATED */ DEBUG_COMPONENT("guideCurved8", _guideCurved8_var._position_absolute, _guideCurved8_var._rotation_absolute); instrument->_position_absolute[13] = _guideCurved8_var._position_absolute; instrument->_position_relative[13] = _guideCurved8_var._position_relative; _guideCurved8_var._position_relative_is_zero = coords_test_zero(_guideCurved8_var._position_relative); instrument->counter_N[13] = instrument->counter_P[13] = instrument->counter_P2[13] = 0; instrument->counter_AbsorbProp[13]= 0; #ifdef USE_NEXUS if(nxhandle) { if ((!mcdotrace) && mcformat && strcasestr(mcformat, "NeXus")) { MPI_MASTER( mccomp_placement_type_nexus(nxhandle,"0012_guideCurved8", _guideCurved8_var._position_absolute, _guideCurved8_var._rotation_absolute, "Guide"); mccomp_param_nexus(nxhandle,"0012_guideCurved8", "reflect", 0, 0, "char*"); mccomp_param_nexus(nxhandle,"0012_guideCurved8", "w1", "NONE", "0.03","MCNUM"); mccomp_param_nexus(nxhandle,"0012_guideCurved8", "h1", "NONE", "0.12","MCNUM"); mccomp_param_nexus(nxhandle,"0012_guideCurved8", "w2", "0", "0.03","MCNUM"); mccomp_param_nexus(nxhandle,"0012_guideCurved8", "h2", "0", "0.12","MCNUM"); mccomp_param_nexus(nxhandle,"0012_guideCurved8", "l", "NONE", "0.499995","MCNUM"); mccomp_param_nexus(nxhandle,"0012_guideCurved8", "R0", "0.99", "R0","MCNUM"); mccomp_param_nexus(nxhandle,"0012_guideCurved8", "Qc", "0.0219", "Qc","MCNUM"); mccomp_param_nexus(nxhandle,"0012_guideCurved8", "alpha", "6.07", "ALPHA","MCNUM"); mccomp_param_nexus(nxhandle,"0012_guideCurved8", "m", "2", "M","MCNUM"); mccomp_param_nexus(nxhandle,"0012_guideCurved8", "W", "0.003", "W","MCNUM"); ); } } else { // fprintf(stderr,"NO NEXUS FILE"); } #endif return(0); } /* _guideCurved8_setpos */ /* component guideCurved9=Guide() SETTING, POSITION/ROTATION */ int _guideCurved9_setpos(void) { /* sets initial component parameters, position and rotation */ SIG_MESSAGE("[_guideCurved9_setpos] component guideCurved9=Guide() SETTING [Guide:0]"); stracpy(_guideCurved9_var._name, "guideCurved9", 16384); stracpy(_guideCurved9_var._type, "Guide", 16384); _guideCurved9_var._index=14; int current_setpos_index = 14; _guideCurved9_var._parameters.reflect[0]='\0'; _guideCurved9_var._parameters.w1 = 0.03; _guideCurved9_var._parameters.h1 = 0.12; _guideCurved9_var._parameters.w2 = 0.03; _guideCurved9_var._parameters.h2 = 0.12; _guideCurved9_var._parameters.l = 0.499995; _guideCurved9_var._parameters.R0 = R0; _guideCurved9_var._parameters.Qc = Qc; _guideCurved9_var._parameters.alpha = ALPHA; _guideCurved9_var._parameters.m = M; _guideCurved9_var._parameters.W = W; /* component guideCurved9=Guide() AT ROTATED */ { Coords tc1, tc2; tc1 = coords_set(0,0,0); tc2 = coords_set(0,0,0); Rotation tr1; rot_set_rotation(tr1,0,0,0); rot_set_rotation(tr1, (0)*DEG2RAD, (angleGuideCurved)*DEG2RAD, (0)*DEG2RAD); rot_mul(tr1, _guideCurved8_var._rotation_absolute, _guideCurved9_var._rotation_absolute); rot_transpose(_guideCurved8_var._rotation_absolute, tr1); rot_mul(_guideCurved9_var._rotation_absolute, tr1, _guideCurved9_var._rotation_relative); _guideCurved9_var._rotation_is_identity = rot_test_identity(_guideCurved9_var._rotation_relative); tc1 = coords_set( 0, 0, 0.5); rot_transpose(_guideCurved8_var._rotation_absolute, tr1); tc2 = rot_apply(tr1, tc1); _guideCurved9_var._position_absolute = coords_add(_guideCurved8_var._position_absolute, tc2); tc1 = coords_sub(_guideCurved8_var._position_absolute, _guideCurved9_var._position_absolute); _guideCurved9_var._position_relative = rot_apply(_guideCurved9_var._rotation_absolute, tc1); } /* guideCurved9=Guide() AT ROTATED */ DEBUG_COMPONENT("guideCurved9", _guideCurved9_var._position_absolute, _guideCurved9_var._rotation_absolute); instrument->_position_absolute[14] = _guideCurved9_var._position_absolute; instrument->_position_relative[14] = _guideCurved9_var._position_relative; _guideCurved9_var._position_relative_is_zero = coords_test_zero(_guideCurved9_var._position_relative); instrument->counter_N[14] = instrument->counter_P[14] = instrument->counter_P2[14] = 0; instrument->counter_AbsorbProp[14]= 0; #ifdef USE_NEXUS if(nxhandle) { if ((!mcdotrace) && mcformat && strcasestr(mcformat, "NeXus")) { MPI_MASTER( mccomp_placement_type_nexus(nxhandle,"0013_guideCurved9", _guideCurved9_var._position_absolute, _guideCurved9_var._rotation_absolute, "Guide"); mccomp_param_nexus(nxhandle,"0013_guideCurved9", "reflect", 0, 0, "char*"); mccomp_param_nexus(nxhandle,"0013_guideCurved9", "w1", "NONE", "0.03","MCNUM"); mccomp_param_nexus(nxhandle,"0013_guideCurved9", "h1", "NONE", "0.12","MCNUM"); mccomp_param_nexus(nxhandle,"0013_guideCurved9", "w2", "0", "0.03","MCNUM"); mccomp_param_nexus(nxhandle,"0013_guideCurved9", "h2", "0", "0.12","MCNUM"); mccomp_param_nexus(nxhandle,"0013_guideCurved9", "l", "NONE", "0.499995","MCNUM"); mccomp_param_nexus(nxhandle,"0013_guideCurved9", "R0", "0.99", "R0","MCNUM"); mccomp_param_nexus(nxhandle,"0013_guideCurved9", "Qc", "0.0219", "Qc","MCNUM"); mccomp_param_nexus(nxhandle,"0013_guideCurved9", "alpha", "6.07", "ALPHA","MCNUM"); mccomp_param_nexus(nxhandle,"0013_guideCurved9", "m", "2", "M","MCNUM"); mccomp_param_nexus(nxhandle,"0013_guideCurved9", "W", "0.003", "W","MCNUM"); ); } } else { // fprintf(stderr,"NO NEXUS FILE"); } #endif return(0); } /* _guideCurved9_setpos */ /* component guideCurved10=Guide() SETTING, POSITION/ROTATION */ int _guideCurved10_setpos(void) { /* sets initial component parameters, position and rotation */ SIG_MESSAGE("[_guideCurved10_setpos] component guideCurved10=Guide() SETTING [Guide:0]"); stracpy(_guideCurved10_var._name, "guideCurved10", 16384); stracpy(_guideCurved10_var._type, "Guide", 16384); _guideCurved10_var._index=15; int current_setpos_index = 15; _guideCurved10_var._parameters.reflect[0]='\0'; _guideCurved10_var._parameters.w1 = 0.03; _guideCurved10_var._parameters.h1 = 0.12; _guideCurved10_var._parameters.w2 = 0.03; _guideCurved10_var._parameters.h2 = 0.12; _guideCurved10_var._parameters.l = 0.499995; _guideCurved10_var._parameters.R0 = R0; _guideCurved10_var._parameters.Qc = Qc; _guideCurved10_var._parameters.alpha = ALPHA; _guideCurved10_var._parameters.m = M; _guideCurved10_var._parameters.W = W; /* component guideCurved10=Guide() AT ROTATED */ { Coords tc1, tc2; tc1 = coords_set(0,0,0); tc2 = coords_set(0,0,0); Rotation tr1; rot_set_rotation(tr1,0,0,0); rot_set_rotation(tr1, (0)*DEG2RAD, (angleGuideCurved)*DEG2RAD, (0)*DEG2RAD); rot_mul(tr1, _guideCurved9_var._rotation_absolute, _guideCurved10_var._rotation_absolute); rot_transpose(_guideCurved9_var._rotation_absolute, tr1); rot_mul(_guideCurved10_var._rotation_absolute, tr1, _guideCurved10_var._rotation_relative); _guideCurved10_var._rotation_is_identity = rot_test_identity(_guideCurved10_var._rotation_relative); tc1 = coords_set( 0, 0, 0.5); rot_transpose(_guideCurved9_var._rotation_absolute, tr1); tc2 = rot_apply(tr1, tc1); _guideCurved10_var._position_absolute = coords_add(_guideCurved9_var._position_absolute, tc2); tc1 = coords_sub(_guideCurved9_var._position_absolute, _guideCurved10_var._position_absolute); _guideCurved10_var._position_relative = rot_apply(_guideCurved10_var._rotation_absolute, tc1); } /* guideCurved10=Guide() AT ROTATED */ DEBUG_COMPONENT("guideCurved10", _guideCurved10_var._position_absolute, _guideCurved10_var._rotation_absolute); instrument->_position_absolute[15] = _guideCurved10_var._position_absolute; instrument->_position_relative[15] = _guideCurved10_var._position_relative; _guideCurved10_var._position_relative_is_zero = coords_test_zero(_guideCurved10_var._position_relative); instrument->counter_N[15] = instrument->counter_P[15] = instrument->counter_P2[15] = 0; instrument->counter_AbsorbProp[15]= 0; #ifdef USE_NEXUS if(nxhandle) { if ((!mcdotrace) && mcformat && strcasestr(mcformat, "NeXus")) { MPI_MASTER( mccomp_placement_type_nexus(nxhandle,"0014_guideCurved10", _guideCurved10_var._position_absolute, _guideCurved10_var._rotation_absolute, "Guide"); mccomp_param_nexus(nxhandle,"0014_guideCurved10", "reflect", 0, 0, "char*"); mccomp_param_nexus(nxhandle,"0014_guideCurved10", "w1", "NONE", "0.03","MCNUM"); mccomp_param_nexus(nxhandle,"0014_guideCurved10", "h1", "NONE", "0.12","MCNUM"); mccomp_param_nexus(nxhandle,"0014_guideCurved10", "w2", "0", "0.03","MCNUM"); mccomp_param_nexus(nxhandle,"0014_guideCurved10", "h2", "0", "0.12","MCNUM"); mccomp_param_nexus(nxhandle,"0014_guideCurved10", "l", "NONE", "0.499995","MCNUM"); mccomp_param_nexus(nxhandle,"0014_guideCurved10", "R0", "0.99", "R0","MCNUM"); mccomp_param_nexus(nxhandle,"0014_guideCurved10", "Qc", "0.0219", "Qc","MCNUM"); mccomp_param_nexus(nxhandle,"0014_guideCurved10", "alpha", "6.07", "ALPHA","MCNUM"); mccomp_param_nexus(nxhandle,"0014_guideCurved10", "m", "2", "M","MCNUM"); mccomp_param_nexus(nxhandle,"0014_guideCurved10", "W", "0.003", "W","MCNUM"); ); } } else { // fprintf(stderr,"NO NEXUS FILE"); } #endif return(0); } /* _guideCurved10_setpos */ /* component guideCurved11=Guide() SETTING, POSITION/ROTATION */ int _guideCurved11_setpos(void) { /* sets initial component parameters, position and rotation */ SIG_MESSAGE("[_guideCurved11_setpos] component guideCurved11=Guide() SETTING [Guide:0]"); stracpy(_guideCurved11_var._name, "guideCurved11", 16384); stracpy(_guideCurved11_var._type, "Guide", 16384); _guideCurved11_var._index=16; int current_setpos_index = 16; _guideCurved11_var._parameters.reflect[0]='\0'; _guideCurved11_var._parameters.w1 = 0.03; _guideCurved11_var._parameters.h1 = 0.12; _guideCurved11_var._parameters.w2 = 0.03; _guideCurved11_var._parameters.h2 = 0.12; _guideCurved11_var._parameters.l = 0.499995; _guideCurved11_var._parameters.R0 = R0; _guideCurved11_var._parameters.Qc = Qc; _guideCurved11_var._parameters.alpha = ALPHA; _guideCurved11_var._parameters.m = M; _guideCurved11_var._parameters.W = W; /* component guideCurved11=Guide() AT ROTATED */ { Coords tc1, tc2; tc1 = coords_set(0,0,0); tc2 = coords_set(0,0,0); Rotation tr1; rot_set_rotation(tr1,0,0,0); rot_set_rotation(tr1, (0)*DEG2RAD, (angleGuideCurved)*DEG2RAD, (0)*DEG2RAD); rot_mul(tr1, _guideCurved10_var._rotation_absolute, _guideCurved11_var._rotation_absolute); rot_transpose(_guideCurved10_var._rotation_absolute, tr1); rot_mul(_guideCurved11_var._rotation_absolute, tr1, _guideCurved11_var._rotation_relative); _guideCurved11_var._rotation_is_identity = rot_test_identity(_guideCurved11_var._rotation_relative); tc1 = coords_set( 0, 0, 0.5); rot_transpose(_guideCurved10_var._rotation_absolute, tr1); tc2 = rot_apply(tr1, tc1); _guideCurved11_var._position_absolute = coords_add(_guideCurved10_var._position_absolute, tc2); tc1 = coords_sub(_guideCurved10_var._position_absolute, _guideCurved11_var._position_absolute); _guideCurved11_var._position_relative = rot_apply(_guideCurved11_var._rotation_absolute, tc1); } /* guideCurved11=Guide() AT ROTATED */ DEBUG_COMPONENT("guideCurved11", _guideCurved11_var._position_absolute, _guideCurved11_var._rotation_absolute); instrument->_position_absolute[16] = _guideCurved11_var._position_absolute; instrument->_position_relative[16] = _guideCurved11_var._position_relative; _guideCurved11_var._position_relative_is_zero = coords_test_zero(_guideCurved11_var._position_relative); instrument->counter_N[16] = instrument->counter_P[16] = instrument->counter_P2[16] = 0; instrument->counter_AbsorbProp[16]= 0; #ifdef USE_NEXUS if(nxhandle) { if ((!mcdotrace) && mcformat && strcasestr(mcformat, "NeXus")) { MPI_MASTER( mccomp_placement_type_nexus(nxhandle,"0015_guideCurved11", _guideCurved11_var._position_absolute, _guideCurved11_var._rotation_absolute, "Guide"); mccomp_param_nexus(nxhandle,"0015_guideCurved11", "reflect", 0, 0, "char*"); mccomp_param_nexus(nxhandle,"0015_guideCurved11", "w1", "NONE", "0.03","MCNUM"); mccomp_param_nexus(nxhandle,"0015_guideCurved11", "h1", "NONE", "0.12","MCNUM"); mccomp_param_nexus(nxhandle,"0015_guideCurved11", "w2", "0", "0.03","MCNUM"); mccomp_param_nexus(nxhandle,"0015_guideCurved11", "h2", "0", "0.12","MCNUM"); mccomp_param_nexus(nxhandle,"0015_guideCurved11", "l", "NONE", "0.499995","MCNUM"); mccomp_param_nexus(nxhandle,"0015_guideCurved11", "R0", "0.99", "R0","MCNUM"); mccomp_param_nexus(nxhandle,"0015_guideCurved11", "Qc", "0.0219", "Qc","MCNUM"); mccomp_param_nexus(nxhandle,"0015_guideCurved11", "alpha", "6.07", "ALPHA","MCNUM"); mccomp_param_nexus(nxhandle,"0015_guideCurved11", "m", "2", "M","MCNUM"); mccomp_param_nexus(nxhandle,"0015_guideCurved11", "W", "0.003", "W","MCNUM"); ); } } else { // fprintf(stderr,"NO NEXUS FILE"); } #endif return(0); } /* _guideCurved11_setpos */ /* component guideCurved12=Guide() SETTING, POSITION/ROTATION */ int _guideCurved12_setpos(void) { /* sets initial component parameters, position and rotation */ SIG_MESSAGE("[_guideCurved12_setpos] component guideCurved12=Guide() SETTING [Guide:0]"); stracpy(_guideCurved12_var._name, "guideCurved12", 16384); stracpy(_guideCurved12_var._type, "Guide", 16384); _guideCurved12_var._index=17; int current_setpos_index = 17; _guideCurved12_var._parameters.reflect[0]='\0'; _guideCurved12_var._parameters.w1 = 0.03; _guideCurved12_var._parameters.h1 = 0.12; _guideCurved12_var._parameters.w2 = 0.03; _guideCurved12_var._parameters.h2 = 0.12; _guideCurved12_var._parameters.l = 0.499995; _guideCurved12_var._parameters.R0 = R0; _guideCurved12_var._parameters.Qc = Qc; _guideCurved12_var._parameters.alpha = ALPHA; _guideCurved12_var._parameters.m = M; _guideCurved12_var._parameters.W = W; /* component guideCurved12=Guide() AT ROTATED */ { Coords tc1, tc2; tc1 = coords_set(0,0,0); tc2 = coords_set(0,0,0); Rotation tr1; rot_set_rotation(tr1,0,0,0); rot_set_rotation(tr1, (0)*DEG2RAD, (angleGuideCurved)*DEG2RAD, (0)*DEG2RAD); rot_mul(tr1, _guideCurved11_var._rotation_absolute, _guideCurved12_var._rotation_absolute); rot_transpose(_guideCurved11_var._rotation_absolute, tr1); rot_mul(_guideCurved12_var._rotation_absolute, tr1, _guideCurved12_var._rotation_relative); _guideCurved12_var._rotation_is_identity = rot_test_identity(_guideCurved12_var._rotation_relative); tc1 = coords_set( 0, 0, 0.5); rot_transpose(_guideCurved11_var._rotation_absolute, tr1); tc2 = rot_apply(tr1, tc1); _guideCurved12_var._position_absolute = coords_add(_guideCurved11_var._position_absolute, tc2); tc1 = coords_sub(_guideCurved11_var._position_absolute, _guideCurved12_var._position_absolute); _guideCurved12_var._position_relative = rot_apply(_guideCurved12_var._rotation_absolute, tc1); } /* guideCurved12=Guide() AT ROTATED */ DEBUG_COMPONENT("guideCurved12", _guideCurved12_var._position_absolute, _guideCurved12_var._rotation_absolute); instrument->_position_absolute[17] = _guideCurved12_var._position_absolute; instrument->_position_relative[17] = _guideCurved12_var._position_relative; _guideCurved12_var._position_relative_is_zero = coords_test_zero(_guideCurved12_var._position_relative); instrument->counter_N[17] = instrument->counter_P[17] = instrument->counter_P2[17] = 0; instrument->counter_AbsorbProp[17]= 0; #ifdef USE_NEXUS if(nxhandle) { if ((!mcdotrace) && mcformat && strcasestr(mcformat, "NeXus")) { MPI_MASTER( mccomp_placement_type_nexus(nxhandle,"0016_guideCurved12", _guideCurved12_var._position_absolute, _guideCurved12_var._rotation_absolute, "Guide"); mccomp_param_nexus(nxhandle,"0016_guideCurved12", "reflect", 0, 0, "char*"); mccomp_param_nexus(nxhandle,"0016_guideCurved12", "w1", "NONE", "0.03","MCNUM"); mccomp_param_nexus(nxhandle,"0016_guideCurved12", "h1", "NONE", "0.12","MCNUM"); mccomp_param_nexus(nxhandle,"0016_guideCurved12", "w2", "0", "0.03","MCNUM"); mccomp_param_nexus(nxhandle,"0016_guideCurved12", "h2", "0", "0.12","MCNUM"); mccomp_param_nexus(nxhandle,"0016_guideCurved12", "l", "NONE", "0.499995","MCNUM"); mccomp_param_nexus(nxhandle,"0016_guideCurved12", "R0", "0.99", "R0","MCNUM"); mccomp_param_nexus(nxhandle,"0016_guideCurved12", "Qc", "0.0219", "Qc","MCNUM"); mccomp_param_nexus(nxhandle,"0016_guideCurved12", "alpha", "6.07", "ALPHA","MCNUM"); mccomp_param_nexus(nxhandle,"0016_guideCurved12", "m", "2", "M","MCNUM"); mccomp_param_nexus(nxhandle,"0016_guideCurved12", "W", "0.003", "W","MCNUM"); ); } } else { // fprintf(stderr,"NO NEXUS FILE"); } #endif return(0); } /* _guideCurved12_setpos */ /* component guideCurved13=Guide() SETTING, POSITION/ROTATION */ int _guideCurved13_setpos(void) { /* sets initial component parameters, position and rotation */ SIG_MESSAGE("[_guideCurved13_setpos] component guideCurved13=Guide() SETTING [Guide:0]"); stracpy(_guideCurved13_var._name, "guideCurved13", 16384); stracpy(_guideCurved13_var._type, "Guide", 16384); _guideCurved13_var._index=18; int current_setpos_index = 18; _guideCurved13_var._parameters.reflect[0]='\0'; _guideCurved13_var._parameters.w1 = 0.03; _guideCurved13_var._parameters.h1 = 0.12; _guideCurved13_var._parameters.w2 = 0.03; _guideCurved13_var._parameters.h2 = 0.12; _guideCurved13_var._parameters.l = 0.499995; _guideCurved13_var._parameters.R0 = R0; _guideCurved13_var._parameters.Qc = Qc; _guideCurved13_var._parameters.alpha = ALPHA; _guideCurved13_var._parameters.m = M; _guideCurved13_var._parameters.W = W; /* component guideCurved13=Guide() AT ROTATED */ { Coords tc1, tc2; tc1 = coords_set(0,0,0); tc2 = coords_set(0,0,0); Rotation tr1; rot_set_rotation(tr1,0,0,0); rot_set_rotation(tr1, (0)*DEG2RAD, (angleGuideCurved)*DEG2RAD, (0)*DEG2RAD); rot_mul(tr1, _guideCurved12_var._rotation_absolute, _guideCurved13_var._rotation_absolute); rot_transpose(_guideCurved12_var._rotation_absolute, tr1); rot_mul(_guideCurved13_var._rotation_absolute, tr1, _guideCurved13_var._rotation_relative); _guideCurved13_var._rotation_is_identity = rot_test_identity(_guideCurved13_var._rotation_relative); tc1 = coords_set( 0, 0, 0.5); rot_transpose(_guideCurved12_var._rotation_absolute, tr1); tc2 = rot_apply(tr1, tc1); _guideCurved13_var._position_absolute = coords_add(_guideCurved12_var._position_absolute, tc2); tc1 = coords_sub(_guideCurved12_var._position_absolute, _guideCurved13_var._position_absolute); _guideCurved13_var._position_relative = rot_apply(_guideCurved13_var._rotation_absolute, tc1); } /* guideCurved13=Guide() AT ROTATED */ DEBUG_COMPONENT("guideCurved13", _guideCurved13_var._position_absolute, _guideCurved13_var._rotation_absolute); instrument->_position_absolute[18] = _guideCurved13_var._position_absolute; instrument->_position_relative[18] = _guideCurved13_var._position_relative; _guideCurved13_var._position_relative_is_zero = coords_test_zero(_guideCurved13_var._position_relative); instrument->counter_N[18] = instrument->counter_P[18] = instrument->counter_P2[18] = 0; instrument->counter_AbsorbProp[18]= 0; #ifdef USE_NEXUS if(nxhandle) { if ((!mcdotrace) && mcformat && strcasestr(mcformat, "NeXus")) { MPI_MASTER( mccomp_placement_type_nexus(nxhandle,"0017_guideCurved13", _guideCurved13_var._position_absolute, _guideCurved13_var._rotation_absolute, "Guide"); mccomp_param_nexus(nxhandle,"0017_guideCurved13", "reflect", 0, 0, "char*"); mccomp_param_nexus(nxhandle,"0017_guideCurved13", "w1", "NONE", "0.03","MCNUM"); mccomp_param_nexus(nxhandle,"0017_guideCurved13", "h1", "NONE", "0.12","MCNUM"); mccomp_param_nexus(nxhandle,"0017_guideCurved13", "w2", "0", "0.03","MCNUM"); mccomp_param_nexus(nxhandle,"0017_guideCurved13", "h2", "0", "0.12","MCNUM"); mccomp_param_nexus(nxhandle,"0017_guideCurved13", "l", "NONE", "0.499995","MCNUM"); mccomp_param_nexus(nxhandle,"0017_guideCurved13", "R0", "0.99", "R0","MCNUM"); mccomp_param_nexus(nxhandle,"0017_guideCurved13", "Qc", "0.0219", "Qc","MCNUM"); mccomp_param_nexus(nxhandle,"0017_guideCurved13", "alpha", "6.07", "ALPHA","MCNUM"); mccomp_param_nexus(nxhandle,"0017_guideCurved13", "m", "2", "M","MCNUM"); mccomp_param_nexus(nxhandle,"0017_guideCurved13", "W", "0.003", "W","MCNUM"); ); } } else { // fprintf(stderr,"NO NEXUS FILE"); } #endif return(0); } /* _guideCurved13_setpos */ /* component guideCurved14=Guide() SETTING, POSITION/ROTATION */ int _guideCurved14_setpos(void) { /* sets initial component parameters, position and rotation */ SIG_MESSAGE("[_guideCurved14_setpos] component guideCurved14=Guide() SETTING [Guide:0]"); stracpy(_guideCurved14_var._name, "guideCurved14", 16384); stracpy(_guideCurved14_var._type, "Guide", 16384); _guideCurved14_var._index=19; int current_setpos_index = 19; _guideCurved14_var._parameters.reflect[0]='\0'; _guideCurved14_var._parameters.w1 = 0.03; _guideCurved14_var._parameters.h1 = 0.12; _guideCurved14_var._parameters.w2 = 0.03; _guideCurved14_var._parameters.h2 = 0.12; _guideCurved14_var._parameters.l = 0.499995; _guideCurved14_var._parameters.R0 = R0; _guideCurved14_var._parameters.Qc = Qc; _guideCurved14_var._parameters.alpha = ALPHA; _guideCurved14_var._parameters.m = M; _guideCurved14_var._parameters.W = W; /* component guideCurved14=Guide() AT ROTATED */ { Coords tc1, tc2; tc1 = coords_set(0,0,0); tc2 = coords_set(0,0,0); Rotation tr1; rot_set_rotation(tr1,0,0,0); rot_set_rotation(tr1, (0)*DEG2RAD, (angleGuideCurved)*DEG2RAD, (0)*DEG2RAD); rot_mul(tr1, _guideCurved13_var._rotation_absolute, _guideCurved14_var._rotation_absolute); rot_transpose(_guideCurved13_var._rotation_absolute, tr1); rot_mul(_guideCurved14_var._rotation_absolute, tr1, _guideCurved14_var._rotation_relative); _guideCurved14_var._rotation_is_identity = rot_test_identity(_guideCurved14_var._rotation_relative); tc1 = coords_set( 0, 0, 0.5); rot_transpose(_guideCurved13_var._rotation_absolute, tr1); tc2 = rot_apply(tr1, tc1); _guideCurved14_var._position_absolute = coords_add(_guideCurved13_var._position_absolute, tc2); tc1 = coords_sub(_guideCurved13_var._position_absolute, _guideCurved14_var._position_absolute); _guideCurved14_var._position_relative = rot_apply(_guideCurved14_var._rotation_absolute, tc1); } /* guideCurved14=Guide() AT ROTATED */ DEBUG_COMPONENT("guideCurved14", _guideCurved14_var._position_absolute, _guideCurved14_var._rotation_absolute); instrument->_position_absolute[19] = _guideCurved14_var._position_absolute; instrument->_position_relative[19] = _guideCurved14_var._position_relative; _guideCurved14_var._position_relative_is_zero = coords_test_zero(_guideCurved14_var._position_relative); instrument->counter_N[19] = instrument->counter_P[19] = instrument->counter_P2[19] = 0; instrument->counter_AbsorbProp[19]= 0; #ifdef USE_NEXUS if(nxhandle) { if ((!mcdotrace) && mcformat && strcasestr(mcformat, "NeXus")) { MPI_MASTER( mccomp_placement_type_nexus(nxhandle,"0018_guideCurved14", _guideCurved14_var._position_absolute, _guideCurved14_var._rotation_absolute, "Guide"); mccomp_param_nexus(nxhandle,"0018_guideCurved14", "reflect", 0, 0, "char*"); mccomp_param_nexus(nxhandle,"0018_guideCurved14", "w1", "NONE", "0.03","MCNUM"); mccomp_param_nexus(nxhandle,"0018_guideCurved14", "h1", "NONE", "0.12","MCNUM"); mccomp_param_nexus(nxhandle,"0018_guideCurved14", "w2", "0", "0.03","MCNUM"); mccomp_param_nexus(nxhandle,"0018_guideCurved14", "h2", "0", "0.12","MCNUM"); mccomp_param_nexus(nxhandle,"0018_guideCurved14", "l", "NONE", "0.499995","MCNUM"); mccomp_param_nexus(nxhandle,"0018_guideCurved14", "R0", "0.99", "R0","MCNUM"); mccomp_param_nexus(nxhandle,"0018_guideCurved14", "Qc", "0.0219", "Qc","MCNUM"); mccomp_param_nexus(nxhandle,"0018_guideCurved14", "alpha", "6.07", "ALPHA","MCNUM"); mccomp_param_nexus(nxhandle,"0018_guideCurved14", "m", "2", "M","MCNUM"); mccomp_param_nexus(nxhandle,"0018_guideCurved14", "W", "0.003", "W","MCNUM"); ); } } else { // fprintf(stderr,"NO NEXUS FILE"); } #endif return(0); } /* _guideCurved14_setpos */ /* component guideCurved15=Guide() SETTING, POSITION/ROTATION */ int _guideCurved15_setpos(void) { /* sets initial component parameters, position and rotation */ SIG_MESSAGE("[_guideCurved15_setpos] component guideCurved15=Guide() SETTING [Guide:0]"); stracpy(_guideCurved15_var._name, "guideCurved15", 16384); stracpy(_guideCurved15_var._type, "Guide", 16384); _guideCurved15_var._index=20; int current_setpos_index = 20; _guideCurved15_var._parameters.reflect[0]='\0'; _guideCurved15_var._parameters.w1 = 0.03; _guideCurved15_var._parameters.h1 = 0.12; _guideCurved15_var._parameters.w2 = 0.03; _guideCurved15_var._parameters.h2 = 0.12; _guideCurved15_var._parameters.l = 0.499995; _guideCurved15_var._parameters.R0 = R0; _guideCurved15_var._parameters.Qc = Qc; _guideCurved15_var._parameters.alpha = ALPHA; _guideCurved15_var._parameters.m = M; _guideCurved15_var._parameters.W = W; /* component guideCurved15=Guide() AT ROTATED */ { Coords tc1, tc2; tc1 = coords_set(0,0,0); tc2 = coords_set(0,0,0); Rotation tr1; rot_set_rotation(tr1,0,0,0); rot_set_rotation(tr1, (0)*DEG2RAD, (angleGuideCurved)*DEG2RAD, (0)*DEG2RAD); rot_mul(tr1, _guideCurved14_var._rotation_absolute, _guideCurved15_var._rotation_absolute); rot_transpose(_guideCurved14_var._rotation_absolute, tr1); rot_mul(_guideCurved15_var._rotation_absolute, tr1, _guideCurved15_var._rotation_relative); _guideCurved15_var._rotation_is_identity = rot_test_identity(_guideCurved15_var._rotation_relative); tc1 = coords_set( 0, 0, 0.5); rot_transpose(_guideCurved14_var._rotation_absolute, tr1); tc2 = rot_apply(tr1, tc1); _guideCurved15_var._position_absolute = coords_add(_guideCurved14_var._position_absolute, tc2); tc1 = coords_sub(_guideCurved14_var._position_absolute, _guideCurved15_var._position_absolute); _guideCurved15_var._position_relative = rot_apply(_guideCurved15_var._rotation_absolute, tc1); } /* guideCurved15=Guide() AT ROTATED */ DEBUG_COMPONENT("guideCurved15", _guideCurved15_var._position_absolute, _guideCurved15_var._rotation_absolute); instrument->_position_absolute[20] = _guideCurved15_var._position_absolute; instrument->_position_relative[20] = _guideCurved15_var._position_relative; _guideCurved15_var._position_relative_is_zero = coords_test_zero(_guideCurved15_var._position_relative); instrument->counter_N[20] = instrument->counter_P[20] = instrument->counter_P2[20] = 0; instrument->counter_AbsorbProp[20]= 0; #ifdef USE_NEXUS if(nxhandle) { if ((!mcdotrace) && mcformat && strcasestr(mcformat, "NeXus")) { MPI_MASTER( mccomp_placement_type_nexus(nxhandle,"0019_guideCurved15", _guideCurved15_var._position_absolute, _guideCurved15_var._rotation_absolute, "Guide"); mccomp_param_nexus(nxhandle,"0019_guideCurved15", "reflect", 0, 0, "char*"); mccomp_param_nexus(nxhandle,"0019_guideCurved15", "w1", "NONE", "0.03","MCNUM"); mccomp_param_nexus(nxhandle,"0019_guideCurved15", "h1", "NONE", "0.12","MCNUM"); mccomp_param_nexus(nxhandle,"0019_guideCurved15", "w2", "0", "0.03","MCNUM"); mccomp_param_nexus(nxhandle,"0019_guideCurved15", "h2", "0", "0.12","MCNUM"); mccomp_param_nexus(nxhandle,"0019_guideCurved15", "l", "NONE", "0.499995","MCNUM"); mccomp_param_nexus(nxhandle,"0019_guideCurved15", "R0", "0.99", "R0","MCNUM"); mccomp_param_nexus(nxhandle,"0019_guideCurved15", "Qc", "0.0219", "Qc","MCNUM"); mccomp_param_nexus(nxhandle,"0019_guideCurved15", "alpha", "6.07", "ALPHA","MCNUM"); mccomp_param_nexus(nxhandle,"0019_guideCurved15", "m", "2", "M","MCNUM"); mccomp_param_nexus(nxhandle,"0019_guideCurved15", "W", "0.003", "W","MCNUM"); ); } } else { // fprintf(stderr,"NO NEXUS FILE"); } #endif return(0); } /* _guideCurved15_setpos */ /* component guideCurved16=Guide() SETTING, POSITION/ROTATION */ int _guideCurved16_setpos(void) { /* sets initial component parameters, position and rotation */ SIG_MESSAGE("[_guideCurved16_setpos] component guideCurved16=Guide() SETTING [Guide:0]"); stracpy(_guideCurved16_var._name, "guideCurved16", 16384); stracpy(_guideCurved16_var._type, "Guide", 16384); _guideCurved16_var._index=21; int current_setpos_index = 21; _guideCurved16_var._parameters.reflect[0]='\0'; _guideCurved16_var._parameters.w1 = 0.03; _guideCurved16_var._parameters.h1 = 0.12; _guideCurved16_var._parameters.w2 = 0.03; _guideCurved16_var._parameters.h2 = 0.12; _guideCurved16_var._parameters.l = 0.499995; _guideCurved16_var._parameters.R0 = R0; _guideCurved16_var._parameters.Qc = Qc; _guideCurved16_var._parameters.alpha = ALPHA; _guideCurved16_var._parameters.m = M; _guideCurved16_var._parameters.W = W; /* component guideCurved16=Guide() AT ROTATED */ { Coords tc1, tc2; tc1 = coords_set(0,0,0); tc2 = coords_set(0,0,0); Rotation tr1; rot_set_rotation(tr1,0,0,0); rot_set_rotation(tr1, (0)*DEG2RAD, (angleGuideCurved)*DEG2RAD, (0)*DEG2RAD); rot_mul(tr1, _guideCurved15_var._rotation_absolute, _guideCurved16_var._rotation_absolute); rot_transpose(_guideCurved15_var._rotation_absolute, tr1); rot_mul(_guideCurved16_var._rotation_absolute, tr1, _guideCurved16_var._rotation_relative); _guideCurved16_var._rotation_is_identity = rot_test_identity(_guideCurved16_var._rotation_relative); tc1 = coords_set( 0, 0, 0.5); rot_transpose(_guideCurved15_var._rotation_absolute, tr1); tc2 = rot_apply(tr1, tc1); _guideCurved16_var._position_absolute = coords_add(_guideCurved15_var._position_absolute, tc2); tc1 = coords_sub(_guideCurved15_var._position_absolute, _guideCurved16_var._position_absolute); _guideCurved16_var._position_relative = rot_apply(_guideCurved16_var._rotation_absolute, tc1); } /* guideCurved16=Guide() AT ROTATED */ DEBUG_COMPONENT("guideCurved16", _guideCurved16_var._position_absolute, _guideCurved16_var._rotation_absolute); instrument->_position_absolute[21] = _guideCurved16_var._position_absolute; instrument->_position_relative[21] = _guideCurved16_var._position_relative; _guideCurved16_var._position_relative_is_zero = coords_test_zero(_guideCurved16_var._position_relative); instrument->counter_N[21] = instrument->counter_P[21] = instrument->counter_P2[21] = 0; instrument->counter_AbsorbProp[21]= 0; #ifdef USE_NEXUS if(nxhandle) { if ((!mcdotrace) && mcformat && strcasestr(mcformat, "NeXus")) { MPI_MASTER( mccomp_placement_type_nexus(nxhandle,"0020_guideCurved16", _guideCurved16_var._position_absolute, _guideCurved16_var._rotation_absolute, "Guide"); mccomp_param_nexus(nxhandle,"0020_guideCurved16", "reflect", 0, 0, "char*"); mccomp_param_nexus(nxhandle,"0020_guideCurved16", "w1", "NONE", "0.03","MCNUM"); mccomp_param_nexus(nxhandle,"0020_guideCurved16", "h1", "NONE", "0.12","MCNUM"); mccomp_param_nexus(nxhandle,"0020_guideCurved16", "w2", "0", "0.03","MCNUM"); mccomp_param_nexus(nxhandle,"0020_guideCurved16", "h2", "0", "0.12","MCNUM"); mccomp_param_nexus(nxhandle,"0020_guideCurved16", "l", "NONE", "0.499995","MCNUM"); mccomp_param_nexus(nxhandle,"0020_guideCurved16", "R0", "0.99", "R0","MCNUM"); mccomp_param_nexus(nxhandle,"0020_guideCurved16", "Qc", "0.0219", "Qc","MCNUM"); mccomp_param_nexus(nxhandle,"0020_guideCurved16", "alpha", "6.07", "ALPHA","MCNUM"); mccomp_param_nexus(nxhandle,"0020_guideCurved16", "m", "2", "M","MCNUM"); mccomp_param_nexus(nxhandle,"0020_guideCurved16", "W", "0.003", "W","MCNUM"); ); } } else { // fprintf(stderr,"NO NEXUS FILE"); } #endif return(0); } /* _guideCurved16_setpos */ /* component guideCurved17=Guide() SETTING, POSITION/ROTATION */ int _guideCurved17_setpos(void) { /* sets initial component parameters, position and rotation */ SIG_MESSAGE("[_guideCurved17_setpos] component guideCurved17=Guide() SETTING [Guide:0]"); stracpy(_guideCurved17_var._name, "guideCurved17", 16384); stracpy(_guideCurved17_var._type, "Guide", 16384); _guideCurved17_var._index=22; int current_setpos_index = 22; _guideCurved17_var._parameters.reflect[0]='\0'; _guideCurved17_var._parameters.w1 = 0.03; _guideCurved17_var._parameters.h1 = 0.12; _guideCurved17_var._parameters.w2 = 0.03; _guideCurved17_var._parameters.h2 = 0.12; _guideCurved17_var._parameters.l = 0.499995; _guideCurved17_var._parameters.R0 = R0; _guideCurved17_var._parameters.Qc = Qc; _guideCurved17_var._parameters.alpha = ALPHA; _guideCurved17_var._parameters.m = M; _guideCurved17_var._parameters.W = W; /* component guideCurved17=Guide() AT ROTATED */ { Coords tc1, tc2; tc1 = coords_set(0,0,0); tc2 = coords_set(0,0,0); Rotation tr1; rot_set_rotation(tr1,0,0,0); rot_set_rotation(tr1, (0)*DEG2RAD, (angleGuideCurved)*DEG2RAD, (0)*DEG2RAD); rot_mul(tr1, _guideCurved16_var._rotation_absolute, _guideCurved17_var._rotation_absolute); rot_transpose(_guideCurved16_var._rotation_absolute, tr1); rot_mul(_guideCurved17_var._rotation_absolute, tr1, _guideCurved17_var._rotation_relative); _guideCurved17_var._rotation_is_identity = rot_test_identity(_guideCurved17_var._rotation_relative); tc1 = coords_set( 0, 0, 0.5); rot_transpose(_guideCurved16_var._rotation_absolute, tr1); tc2 = rot_apply(tr1, tc1); _guideCurved17_var._position_absolute = coords_add(_guideCurved16_var._position_absolute, tc2); tc1 = coords_sub(_guideCurved16_var._position_absolute, _guideCurved17_var._position_absolute); _guideCurved17_var._position_relative = rot_apply(_guideCurved17_var._rotation_absolute, tc1); } /* guideCurved17=Guide() AT ROTATED */ DEBUG_COMPONENT("guideCurved17", _guideCurved17_var._position_absolute, _guideCurved17_var._rotation_absolute); instrument->_position_absolute[22] = _guideCurved17_var._position_absolute; instrument->_position_relative[22] = _guideCurved17_var._position_relative; _guideCurved17_var._position_relative_is_zero = coords_test_zero(_guideCurved17_var._position_relative); instrument->counter_N[22] = instrument->counter_P[22] = instrument->counter_P2[22] = 0; instrument->counter_AbsorbProp[22]= 0; #ifdef USE_NEXUS if(nxhandle) { if ((!mcdotrace) && mcformat && strcasestr(mcformat, "NeXus")) { MPI_MASTER( mccomp_placement_type_nexus(nxhandle,"0021_guideCurved17", _guideCurved17_var._position_absolute, _guideCurved17_var._rotation_absolute, "Guide"); mccomp_param_nexus(nxhandle,"0021_guideCurved17", "reflect", 0, 0, "char*"); mccomp_param_nexus(nxhandle,"0021_guideCurved17", "w1", "NONE", "0.03","MCNUM"); mccomp_param_nexus(nxhandle,"0021_guideCurved17", "h1", "NONE", "0.12","MCNUM"); mccomp_param_nexus(nxhandle,"0021_guideCurved17", "w2", "0", "0.03","MCNUM"); mccomp_param_nexus(nxhandle,"0021_guideCurved17", "h2", "0", "0.12","MCNUM"); mccomp_param_nexus(nxhandle,"0021_guideCurved17", "l", "NONE", "0.499995","MCNUM"); mccomp_param_nexus(nxhandle,"0021_guideCurved17", "R0", "0.99", "R0","MCNUM"); mccomp_param_nexus(nxhandle,"0021_guideCurved17", "Qc", "0.0219", "Qc","MCNUM"); mccomp_param_nexus(nxhandle,"0021_guideCurved17", "alpha", "6.07", "ALPHA","MCNUM"); mccomp_param_nexus(nxhandle,"0021_guideCurved17", "m", "2", "M","MCNUM"); mccomp_param_nexus(nxhandle,"0021_guideCurved17", "W", "0.003", "W","MCNUM"); ); } } else { // fprintf(stderr,"NO NEXUS FILE"); } #endif return(0); } /* _guideCurved17_setpos */ /* component guideCurved18=Guide() SETTING, POSITION/ROTATION */ int _guideCurved18_setpos(void) { /* sets initial component parameters, position and rotation */ SIG_MESSAGE("[_guideCurved18_setpos] component guideCurved18=Guide() SETTING [Guide:0]"); stracpy(_guideCurved18_var._name, "guideCurved18", 16384); stracpy(_guideCurved18_var._type, "Guide", 16384); _guideCurved18_var._index=23; int current_setpos_index = 23; _guideCurved18_var._parameters.reflect[0]='\0'; _guideCurved18_var._parameters.w1 = 0.03; _guideCurved18_var._parameters.h1 = 0.12; _guideCurved18_var._parameters.w2 = 0.03; _guideCurved18_var._parameters.h2 = 0.12; _guideCurved18_var._parameters.l = 0.499995; _guideCurved18_var._parameters.R0 = R0; _guideCurved18_var._parameters.Qc = Qc; _guideCurved18_var._parameters.alpha = ALPHA; _guideCurved18_var._parameters.m = M; _guideCurved18_var._parameters.W = W; /* component guideCurved18=Guide() AT ROTATED */ { Coords tc1, tc2; tc1 = coords_set(0,0,0); tc2 = coords_set(0,0,0); Rotation tr1; rot_set_rotation(tr1,0,0,0); rot_set_rotation(tr1, (0)*DEG2RAD, (angleGuideCurved)*DEG2RAD, (0)*DEG2RAD); rot_mul(tr1, _guideCurved17_var._rotation_absolute, _guideCurved18_var._rotation_absolute); rot_transpose(_guideCurved17_var._rotation_absolute, tr1); rot_mul(_guideCurved18_var._rotation_absolute, tr1, _guideCurved18_var._rotation_relative); _guideCurved18_var._rotation_is_identity = rot_test_identity(_guideCurved18_var._rotation_relative); tc1 = coords_set( 0, 0, 0.5); rot_transpose(_guideCurved17_var._rotation_absolute, tr1); tc2 = rot_apply(tr1, tc1); _guideCurved18_var._position_absolute = coords_add(_guideCurved17_var._position_absolute, tc2); tc1 = coords_sub(_guideCurved17_var._position_absolute, _guideCurved18_var._position_absolute); _guideCurved18_var._position_relative = rot_apply(_guideCurved18_var._rotation_absolute, tc1); } /* guideCurved18=Guide() AT ROTATED */ DEBUG_COMPONENT("guideCurved18", _guideCurved18_var._position_absolute, _guideCurved18_var._rotation_absolute); instrument->_position_absolute[23] = _guideCurved18_var._position_absolute; instrument->_position_relative[23] = _guideCurved18_var._position_relative; _guideCurved18_var._position_relative_is_zero = coords_test_zero(_guideCurved18_var._position_relative); instrument->counter_N[23] = instrument->counter_P[23] = instrument->counter_P2[23] = 0; instrument->counter_AbsorbProp[23]= 0; #ifdef USE_NEXUS if(nxhandle) { if ((!mcdotrace) && mcformat && strcasestr(mcformat, "NeXus")) { MPI_MASTER( mccomp_placement_type_nexus(nxhandle,"0022_guideCurved18", _guideCurved18_var._position_absolute, _guideCurved18_var._rotation_absolute, "Guide"); mccomp_param_nexus(nxhandle,"0022_guideCurved18", "reflect", 0, 0, "char*"); mccomp_param_nexus(nxhandle,"0022_guideCurved18", "w1", "NONE", "0.03","MCNUM"); mccomp_param_nexus(nxhandle,"0022_guideCurved18", "h1", "NONE", "0.12","MCNUM"); mccomp_param_nexus(nxhandle,"0022_guideCurved18", "w2", "0", "0.03","MCNUM"); mccomp_param_nexus(nxhandle,"0022_guideCurved18", "h2", "0", "0.12","MCNUM"); mccomp_param_nexus(nxhandle,"0022_guideCurved18", "l", "NONE", "0.499995","MCNUM"); mccomp_param_nexus(nxhandle,"0022_guideCurved18", "R0", "0.99", "R0","MCNUM"); mccomp_param_nexus(nxhandle,"0022_guideCurved18", "Qc", "0.0219", "Qc","MCNUM"); mccomp_param_nexus(nxhandle,"0022_guideCurved18", "alpha", "6.07", "ALPHA","MCNUM"); mccomp_param_nexus(nxhandle,"0022_guideCurved18", "m", "2", "M","MCNUM"); mccomp_param_nexus(nxhandle,"0022_guideCurved18", "W", "0.003", "W","MCNUM"); ); } } else { // fprintf(stderr,"NO NEXUS FILE"); } #endif return(0); } /* _guideCurved18_setpos */ /* component guideCurved19=Guide() SETTING, POSITION/ROTATION */ int _guideCurved19_setpos(void) { /* sets initial component parameters, position and rotation */ SIG_MESSAGE("[_guideCurved19_setpos] component guideCurved19=Guide() SETTING [Guide:0]"); stracpy(_guideCurved19_var._name, "guideCurved19", 16384); stracpy(_guideCurved19_var._type, "Guide", 16384); _guideCurved19_var._index=24; int current_setpos_index = 24; _guideCurved19_var._parameters.reflect[0]='\0'; _guideCurved19_var._parameters.w1 = 0.03; _guideCurved19_var._parameters.h1 = 0.12; _guideCurved19_var._parameters.w2 = 0.03; _guideCurved19_var._parameters.h2 = 0.12; _guideCurved19_var._parameters.l = 0.499995; _guideCurved19_var._parameters.R0 = R0; _guideCurved19_var._parameters.Qc = Qc; _guideCurved19_var._parameters.alpha = ALPHA; _guideCurved19_var._parameters.m = M; _guideCurved19_var._parameters.W = W; /* component guideCurved19=Guide() AT ROTATED */ { Coords tc1, tc2; tc1 = coords_set(0,0,0); tc2 = coords_set(0,0,0); Rotation tr1; rot_set_rotation(tr1,0,0,0); rot_set_rotation(tr1, (0)*DEG2RAD, (angleGuideCurved)*DEG2RAD, (0)*DEG2RAD); rot_mul(tr1, _guideCurved18_var._rotation_absolute, _guideCurved19_var._rotation_absolute); rot_transpose(_guideCurved18_var._rotation_absolute, tr1); rot_mul(_guideCurved19_var._rotation_absolute, tr1, _guideCurved19_var._rotation_relative); _guideCurved19_var._rotation_is_identity = rot_test_identity(_guideCurved19_var._rotation_relative); tc1 = coords_set( 0, 0, 0.5); rot_transpose(_guideCurved18_var._rotation_absolute, tr1); tc2 = rot_apply(tr1, tc1); _guideCurved19_var._position_absolute = coords_add(_guideCurved18_var._position_absolute, tc2); tc1 = coords_sub(_guideCurved18_var._position_absolute, _guideCurved19_var._position_absolute); _guideCurved19_var._position_relative = rot_apply(_guideCurved19_var._rotation_absolute, tc1); } /* guideCurved19=Guide() AT ROTATED */ DEBUG_COMPONENT("guideCurved19", _guideCurved19_var._position_absolute, _guideCurved19_var._rotation_absolute); instrument->_position_absolute[24] = _guideCurved19_var._position_absolute; instrument->_position_relative[24] = _guideCurved19_var._position_relative; _guideCurved19_var._position_relative_is_zero = coords_test_zero(_guideCurved19_var._position_relative); instrument->counter_N[24] = instrument->counter_P[24] = instrument->counter_P2[24] = 0; instrument->counter_AbsorbProp[24]= 0; #ifdef USE_NEXUS if(nxhandle) { if ((!mcdotrace) && mcformat && strcasestr(mcformat, "NeXus")) { MPI_MASTER( mccomp_placement_type_nexus(nxhandle,"0023_guideCurved19", _guideCurved19_var._position_absolute, _guideCurved19_var._rotation_absolute, "Guide"); mccomp_param_nexus(nxhandle,"0023_guideCurved19", "reflect", 0, 0, "char*"); mccomp_param_nexus(nxhandle,"0023_guideCurved19", "w1", "NONE", "0.03","MCNUM"); mccomp_param_nexus(nxhandle,"0023_guideCurved19", "h1", "NONE", "0.12","MCNUM"); mccomp_param_nexus(nxhandle,"0023_guideCurved19", "w2", "0", "0.03","MCNUM"); mccomp_param_nexus(nxhandle,"0023_guideCurved19", "h2", "0", "0.12","MCNUM"); mccomp_param_nexus(nxhandle,"0023_guideCurved19", "l", "NONE", "0.499995","MCNUM"); mccomp_param_nexus(nxhandle,"0023_guideCurved19", "R0", "0.99", "R0","MCNUM"); mccomp_param_nexus(nxhandle,"0023_guideCurved19", "Qc", "0.0219", "Qc","MCNUM"); mccomp_param_nexus(nxhandle,"0023_guideCurved19", "alpha", "6.07", "ALPHA","MCNUM"); mccomp_param_nexus(nxhandle,"0023_guideCurved19", "m", "2", "M","MCNUM"); mccomp_param_nexus(nxhandle,"0023_guideCurved19", "W", "0.003", "W","MCNUM"); ); } } else { // fprintf(stderr,"NO NEXUS FILE"); } #endif return(0); } /* _guideCurved19_setpos */ /* component guideCurved20=Guide() SETTING, POSITION/ROTATION */ int _guideCurved20_setpos(void) { /* sets initial component parameters, position and rotation */ SIG_MESSAGE("[_guideCurved20_setpos] component guideCurved20=Guide() SETTING [Guide:0]"); stracpy(_guideCurved20_var._name, "guideCurved20", 16384); stracpy(_guideCurved20_var._type, "Guide", 16384); _guideCurved20_var._index=25; int current_setpos_index = 25; _guideCurved20_var._parameters.reflect[0]='\0'; _guideCurved20_var._parameters.w1 = 0.03; _guideCurved20_var._parameters.h1 = 0.12; _guideCurved20_var._parameters.w2 = 0.03; _guideCurved20_var._parameters.h2 = 0.12; _guideCurved20_var._parameters.l = 0.499995; _guideCurved20_var._parameters.R0 = R0; _guideCurved20_var._parameters.Qc = Qc; _guideCurved20_var._parameters.alpha = ALPHA; _guideCurved20_var._parameters.m = M; _guideCurved20_var._parameters.W = W; /* component guideCurved20=Guide() AT ROTATED */ { Coords tc1, tc2; tc1 = coords_set(0,0,0); tc2 = coords_set(0,0,0); Rotation tr1; rot_set_rotation(tr1,0,0,0); rot_set_rotation(tr1, (0)*DEG2RAD, (angleGuideCurved)*DEG2RAD, (0)*DEG2RAD); rot_mul(tr1, _guideCurved19_var._rotation_absolute, _guideCurved20_var._rotation_absolute); rot_transpose(_guideCurved19_var._rotation_absolute, tr1); rot_mul(_guideCurved20_var._rotation_absolute, tr1, _guideCurved20_var._rotation_relative); _guideCurved20_var._rotation_is_identity = rot_test_identity(_guideCurved20_var._rotation_relative); tc1 = coords_set( 0, 0, 0.5); rot_transpose(_guideCurved19_var._rotation_absolute, tr1); tc2 = rot_apply(tr1, tc1); _guideCurved20_var._position_absolute = coords_add(_guideCurved19_var._position_absolute, tc2); tc1 = coords_sub(_guideCurved19_var._position_absolute, _guideCurved20_var._position_absolute); _guideCurved20_var._position_relative = rot_apply(_guideCurved20_var._rotation_absolute, tc1); } /* guideCurved20=Guide() AT ROTATED */ DEBUG_COMPONENT("guideCurved20", _guideCurved20_var._position_absolute, _guideCurved20_var._rotation_absolute); instrument->_position_absolute[25] = _guideCurved20_var._position_absolute; instrument->_position_relative[25] = _guideCurved20_var._position_relative; _guideCurved20_var._position_relative_is_zero = coords_test_zero(_guideCurved20_var._position_relative); instrument->counter_N[25] = instrument->counter_P[25] = instrument->counter_P2[25] = 0; instrument->counter_AbsorbProp[25]= 0; #ifdef USE_NEXUS if(nxhandle) { if ((!mcdotrace) && mcformat && strcasestr(mcformat, "NeXus")) { MPI_MASTER( mccomp_placement_type_nexus(nxhandle,"0024_guideCurved20", _guideCurved20_var._position_absolute, _guideCurved20_var._rotation_absolute, "Guide"); mccomp_param_nexus(nxhandle,"0024_guideCurved20", "reflect", 0, 0, "char*"); mccomp_param_nexus(nxhandle,"0024_guideCurved20", "w1", "NONE", "0.03","MCNUM"); mccomp_param_nexus(nxhandle,"0024_guideCurved20", "h1", "NONE", "0.12","MCNUM"); mccomp_param_nexus(nxhandle,"0024_guideCurved20", "w2", "0", "0.03","MCNUM"); mccomp_param_nexus(nxhandle,"0024_guideCurved20", "h2", "0", "0.12","MCNUM"); mccomp_param_nexus(nxhandle,"0024_guideCurved20", "l", "NONE", "0.499995","MCNUM"); mccomp_param_nexus(nxhandle,"0024_guideCurved20", "R0", "0.99", "R0","MCNUM"); mccomp_param_nexus(nxhandle,"0024_guideCurved20", "Qc", "0.0219", "Qc","MCNUM"); mccomp_param_nexus(nxhandle,"0024_guideCurved20", "alpha", "6.07", "ALPHA","MCNUM"); mccomp_param_nexus(nxhandle,"0024_guideCurved20", "m", "2", "M","MCNUM"); mccomp_param_nexus(nxhandle,"0024_guideCurved20", "W", "0.003", "W","MCNUM"); ); } } else { // fprintf(stderr,"NO NEXUS FILE"); } #endif return(0); } /* _guideCurved20_setpos */ /* component guideCurved21=Guide() SETTING, POSITION/ROTATION */ int _guideCurved21_setpos(void) { /* sets initial component parameters, position and rotation */ SIG_MESSAGE("[_guideCurved21_setpos] component guideCurved21=Guide() SETTING [Guide:0]"); stracpy(_guideCurved21_var._name, "guideCurved21", 16384); stracpy(_guideCurved21_var._type, "Guide", 16384); _guideCurved21_var._index=26; int current_setpos_index = 26; _guideCurved21_var._parameters.reflect[0]='\0'; _guideCurved21_var._parameters.w1 = 0.03; _guideCurved21_var._parameters.h1 = 0.12; _guideCurved21_var._parameters.w2 = 0.03; _guideCurved21_var._parameters.h2 = 0.12; _guideCurved21_var._parameters.l = 0.499995; _guideCurved21_var._parameters.R0 = R0; _guideCurved21_var._parameters.Qc = Qc; _guideCurved21_var._parameters.alpha = ALPHA; _guideCurved21_var._parameters.m = M; _guideCurved21_var._parameters.W = W; /* component guideCurved21=Guide() AT ROTATED */ { Coords tc1, tc2; tc1 = coords_set(0,0,0); tc2 = coords_set(0,0,0); Rotation tr1; rot_set_rotation(tr1,0,0,0); rot_set_rotation(tr1, (0)*DEG2RAD, (angleGuideCurved)*DEG2RAD, (0)*DEG2RAD); rot_mul(tr1, _guideCurved20_var._rotation_absolute, _guideCurved21_var._rotation_absolute); rot_transpose(_guideCurved20_var._rotation_absolute, tr1); rot_mul(_guideCurved21_var._rotation_absolute, tr1, _guideCurved21_var._rotation_relative); _guideCurved21_var._rotation_is_identity = rot_test_identity(_guideCurved21_var._rotation_relative); tc1 = coords_set( 0, 0, 0.5); rot_transpose(_guideCurved20_var._rotation_absolute, tr1); tc2 = rot_apply(tr1, tc1); _guideCurved21_var._position_absolute = coords_add(_guideCurved20_var._position_absolute, tc2); tc1 = coords_sub(_guideCurved20_var._position_absolute, _guideCurved21_var._position_absolute); _guideCurved21_var._position_relative = rot_apply(_guideCurved21_var._rotation_absolute, tc1); } /* guideCurved21=Guide() AT ROTATED */ DEBUG_COMPONENT("guideCurved21", _guideCurved21_var._position_absolute, _guideCurved21_var._rotation_absolute); instrument->_position_absolute[26] = _guideCurved21_var._position_absolute; instrument->_position_relative[26] = _guideCurved21_var._position_relative; _guideCurved21_var._position_relative_is_zero = coords_test_zero(_guideCurved21_var._position_relative); instrument->counter_N[26] = instrument->counter_P[26] = instrument->counter_P2[26] = 0; instrument->counter_AbsorbProp[26]= 0; #ifdef USE_NEXUS if(nxhandle) { if ((!mcdotrace) && mcformat && strcasestr(mcformat, "NeXus")) { MPI_MASTER( mccomp_placement_type_nexus(nxhandle,"0025_guideCurved21", _guideCurved21_var._position_absolute, _guideCurved21_var._rotation_absolute, "Guide"); mccomp_param_nexus(nxhandle,"0025_guideCurved21", "reflect", 0, 0, "char*"); mccomp_param_nexus(nxhandle,"0025_guideCurved21", "w1", "NONE", "0.03","MCNUM"); mccomp_param_nexus(nxhandle,"0025_guideCurved21", "h1", "NONE", "0.12","MCNUM"); mccomp_param_nexus(nxhandle,"0025_guideCurved21", "w2", "0", "0.03","MCNUM"); mccomp_param_nexus(nxhandle,"0025_guideCurved21", "h2", "0", "0.12","MCNUM"); mccomp_param_nexus(nxhandle,"0025_guideCurved21", "l", "NONE", "0.499995","MCNUM"); mccomp_param_nexus(nxhandle,"0025_guideCurved21", "R0", "0.99", "R0","MCNUM"); mccomp_param_nexus(nxhandle,"0025_guideCurved21", "Qc", "0.0219", "Qc","MCNUM"); mccomp_param_nexus(nxhandle,"0025_guideCurved21", "alpha", "6.07", "ALPHA","MCNUM"); mccomp_param_nexus(nxhandle,"0025_guideCurved21", "m", "2", "M","MCNUM"); mccomp_param_nexus(nxhandle,"0025_guideCurved21", "W", "0.003", "W","MCNUM"); ); } } else { // fprintf(stderr,"NO NEXUS FILE"); } #endif return(0); } /* _guideCurved21_setpos */ /* component guideCurved22=Guide() SETTING, POSITION/ROTATION */ int _guideCurved22_setpos(void) { /* sets initial component parameters, position and rotation */ SIG_MESSAGE("[_guideCurved22_setpos] component guideCurved22=Guide() SETTING [Guide:0]"); stracpy(_guideCurved22_var._name, "guideCurved22", 16384); stracpy(_guideCurved22_var._type, "Guide", 16384); _guideCurved22_var._index=27; int current_setpos_index = 27; _guideCurved22_var._parameters.reflect[0]='\0'; _guideCurved22_var._parameters.w1 = 0.03; _guideCurved22_var._parameters.h1 = 0.12; _guideCurved22_var._parameters.w2 = 0.03; _guideCurved22_var._parameters.h2 = 0.12; _guideCurved22_var._parameters.l = 0.499995; _guideCurved22_var._parameters.R0 = R0; _guideCurved22_var._parameters.Qc = Qc; _guideCurved22_var._parameters.alpha = ALPHA; _guideCurved22_var._parameters.m = M; _guideCurved22_var._parameters.W = W; /* component guideCurved22=Guide() AT ROTATED */ { Coords tc1, tc2; tc1 = coords_set(0,0,0); tc2 = coords_set(0,0,0); Rotation tr1; rot_set_rotation(tr1,0,0,0); rot_set_rotation(tr1, (0)*DEG2RAD, (angleGuideCurved)*DEG2RAD, (0)*DEG2RAD); rot_mul(tr1, _guideCurved21_var._rotation_absolute, _guideCurved22_var._rotation_absolute); rot_transpose(_guideCurved21_var._rotation_absolute, tr1); rot_mul(_guideCurved22_var._rotation_absolute, tr1, _guideCurved22_var._rotation_relative); _guideCurved22_var._rotation_is_identity = rot_test_identity(_guideCurved22_var._rotation_relative); tc1 = coords_set( 0, 0, 0.5); rot_transpose(_guideCurved21_var._rotation_absolute, tr1); tc2 = rot_apply(tr1, tc1); _guideCurved22_var._position_absolute = coords_add(_guideCurved21_var._position_absolute, tc2); tc1 = coords_sub(_guideCurved21_var._position_absolute, _guideCurved22_var._position_absolute); _guideCurved22_var._position_relative = rot_apply(_guideCurved22_var._rotation_absolute, tc1); } /* guideCurved22=Guide() AT ROTATED */ DEBUG_COMPONENT("guideCurved22", _guideCurved22_var._position_absolute, _guideCurved22_var._rotation_absolute); instrument->_position_absolute[27] = _guideCurved22_var._position_absolute; instrument->_position_relative[27] = _guideCurved22_var._position_relative; _guideCurved22_var._position_relative_is_zero = coords_test_zero(_guideCurved22_var._position_relative); instrument->counter_N[27] = instrument->counter_P[27] = instrument->counter_P2[27] = 0; instrument->counter_AbsorbProp[27]= 0; #ifdef USE_NEXUS if(nxhandle) { if ((!mcdotrace) && mcformat && strcasestr(mcformat, "NeXus")) { MPI_MASTER( mccomp_placement_type_nexus(nxhandle,"0026_guideCurved22", _guideCurved22_var._position_absolute, _guideCurved22_var._rotation_absolute, "Guide"); mccomp_param_nexus(nxhandle,"0026_guideCurved22", "reflect", 0, 0, "char*"); mccomp_param_nexus(nxhandle,"0026_guideCurved22", "w1", "NONE", "0.03","MCNUM"); mccomp_param_nexus(nxhandle,"0026_guideCurved22", "h1", "NONE", "0.12","MCNUM"); mccomp_param_nexus(nxhandle,"0026_guideCurved22", "w2", "0", "0.03","MCNUM"); mccomp_param_nexus(nxhandle,"0026_guideCurved22", "h2", "0", "0.12","MCNUM"); mccomp_param_nexus(nxhandle,"0026_guideCurved22", "l", "NONE", "0.499995","MCNUM"); mccomp_param_nexus(nxhandle,"0026_guideCurved22", "R0", "0.99", "R0","MCNUM"); mccomp_param_nexus(nxhandle,"0026_guideCurved22", "Qc", "0.0219", "Qc","MCNUM"); mccomp_param_nexus(nxhandle,"0026_guideCurved22", "alpha", "6.07", "ALPHA","MCNUM"); mccomp_param_nexus(nxhandle,"0026_guideCurved22", "m", "2", "M","MCNUM"); mccomp_param_nexus(nxhandle,"0026_guideCurved22", "W", "0.003", "W","MCNUM"); ); } } else { // fprintf(stderr,"NO NEXUS FILE"); } #endif return(0); } /* _guideCurved22_setpos */ /* component guideCurved23=Guide() SETTING, POSITION/ROTATION */ int _guideCurved23_setpos(void) { /* sets initial component parameters, position and rotation */ SIG_MESSAGE("[_guideCurved23_setpos] component guideCurved23=Guide() SETTING [Guide:0]"); stracpy(_guideCurved23_var._name, "guideCurved23", 16384); stracpy(_guideCurved23_var._type, "Guide", 16384); _guideCurved23_var._index=28; int current_setpos_index = 28; _guideCurved23_var._parameters.reflect[0]='\0'; _guideCurved23_var._parameters.w1 = 0.03; _guideCurved23_var._parameters.h1 = 0.12; _guideCurved23_var._parameters.w2 = 0.03; _guideCurved23_var._parameters.h2 = 0.12; _guideCurved23_var._parameters.l = 0.499995; _guideCurved23_var._parameters.R0 = R0; _guideCurved23_var._parameters.Qc = Qc; _guideCurved23_var._parameters.alpha = ALPHA; _guideCurved23_var._parameters.m = M; _guideCurved23_var._parameters.W = W; /* component guideCurved23=Guide() AT ROTATED */ { Coords tc1, tc2; tc1 = coords_set(0,0,0); tc2 = coords_set(0,0,0); Rotation tr1; rot_set_rotation(tr1,0,0,0); rot_set_rotation(tr1, (0)*DEG2RAD, (angleGuideCurved)*DEG2RAD, (0)*DEG2RAD); rot_mul(tr1, _guideCurved22_var._rotation_absolute, _guideCurved23_var._rotation_absolute); rot_transpose(_guideCurved22_var._rotation_absolute, tr1); rot_mul(_guideCurved23_var._rotation_absolute, tr1, _guideCurved23_var._rotation_relative); _guideCurved23_var._rotation_is_identity = rot_test_identity(_guideCurved23_var._rotation_relative); tc1 = coords_set( 0, 0, 0.5); rot_transpose(_guideCurved22_var._rotation_absolute, tr1); tc2 = rot_apply(tr1, tc1); _guideCurved23_var._position_absolute = coords_add(_guideCurved22_var._position_absolute, tc2); tc1 = coords_sub(_guideCurved22_var._position_absolute, _guideCurved23_var._position_absolute); _guideCurved23_var._position_relative = rot_apply(_guideCurved23_var._rotation_absolute, tc1); } /* guideCurved23=Guide() AT ROTATED */ DEBUG_COMPONENT("guideCurved23", _guideCurved23_var._position_absolute, _guideCurved23_var._rotation_absolute); instrument->_position_absolute[28] = _guideCurved23_var._position_absolute; instrument->_position_relative[28] = _guideCurved23_var._position_relative; _guideCurved23_var._position_relative_is_zero = coords_test_zero(_guideCurved23_var._position_relative); instrument->counter_N[28] = instrument->counter_P[28] = instrument->counter_P2[28] = 0; instrument->counter_AbsorbProp[28]= 0; #ifdef USE_NEXUS if(nxhandle) { if ((!mcdotrace) && mcformat && strcasestr(mcformat, "NeXus")) { MPI_MASTER( mccomp_placement_type_nexus(nxhandle,"0027_guideCurved23", _guideCurved23_var._position_absolute, _guideCurved23_var._rotation_absolute, "Guide"); mccomp_param_nexus(nxhandle,"0027_guideCurved23", "reflect", 0, 0, "char*"); mccomp_param_nexus(nxhandle,"0027_guideCurved23", "w1", "NONE", "0.03","MCNUM"); mccomp_param_nexus(nxhandle,"0027_guideCurved23", "h1", "NONE", "0.12","MCNUM"); mccomp_param_nexus(nxhandle,"0027_guideCurved23", "w2", "0", "0.03","MCNUM"); mccomp_param_nexus(nxhandle,"0027_guideCurved23", "h2", "0", "0.12","MCNUM"); mccomp_param_nexus(nxhandle,"0027_guideCurved23", "l", "NONE", "0.499995","MCNUM"); mccomp_param_nexus(nxhandle,"0027_guideCurved23", "R0", "0.99", "R0","MCNUM"); mccomp_param_nexus(nxhandle,"0027_guideCurved23", "Qc", "0.0219", "Qc","MCNUM"); mccomp_param_nexus(nxhandle,"0027_guideCurved23", "alpha", "6.07", "ALPHA","MCNUM"); mccomp_param_nexus(nxhandle,"0027_guideCurved23", "m", "2", "M","MCNUM"); mccomp_param_nexus(nxhandle,"0027_guideCurved23", "W", "0.003", "W","MCNUM"); ); } } else { // fprintf(stderr,"NO NEXUS FILE"); } #endif return(0); } /* _guideCurved23_setpos */ /* component guideCurved24=Guide() SETTING, POSITION/ROTATION */ int _guideCurved24_setpos(void) { /* sets initial component parameters, position and rotation */ SIG_MESSAGE("[_guideCurved24_setpos] component guideCurved24=Guide() SETTING [Guide:0]"); stracpy(_guideCurved24_var._name, "guideCurved24", 16384); stracpy(_guideCurved24_var._type, "Guide", 16384); _guideCurved24_var._index=29; int current_setpos_index = 29; _guideCurved24_var._parameters.reflect[0]='\0'; _guideCurved24_var._parameters.w1 = 0.03; _guideCurved24_var._parameters.h1 = 0.12; _guideCurved24_var._parameters.w2 = 0.03; _guideCurved24_var._parameters.h2 = 0.12; _guideCurved24_var._parameters.l = 0.499995; _guideCurved24_var._parameters.R0 = R0; _guideCurved24_var._parameters.Qc = Qc; _guideCurved24_var._parameters.alpha = ALPHA; _guideCurved24_var._parameters.m = M; _guideCurved24_var._parameters.W = W; /* component guideCurved24=Guide() AT ROTATED */ { Coords tc1, tc2; tc1 = coords_set(0,0,0); tc2 = coords_set(0,0,0); Rotation tr1; rot_set_rotation(tr1,0,0,0); rot_set_rotation(tr1, (0)*DEG2RAD, (angleGuideCurved)*DEG2RAD, (0)*DEG2RAD); rot_mul(tr1, _guideCurved23_var._rotation_absolute, _guideCurved24_var._rotation_absolute); rot_transpose(_guideCurved23_var._rotation_absolute, tr1); rot_mul(_guideCurved24_var._rotation_absolute, tr1, _guideCurved24_var._rotation_relative); _guideCurved24_var._rotation_is_identity = rot_test_identity(_guideCurved24_var._rotation_relative); tc1 = coords_set( 0, 0, 0.5); rot_transpose(_guideCurved23_var._rotation_absolute, tr1); tc2 = rot_apply(tr1, tc1); _guideCurved24_var._position_absolute = coords_add(_guideCurved23_var._position_absolute, tc2); tc1 = coords_sub(_guideCurved23_var._position_absolute, _guideCurved24_var._position_absolute); _guideCurved24_var._position_relative = rot_apply(_guideCurved24_var._rotation_absolute, tc1); } /* guideCurved24=Guide() AT ROTATED */ DEBUG_COMPONENT("guideCurved24", _guideCurved24_var._position_absolute, _guideCurved24_var._rotation_absolute); instrument->_position_absolute[29] = _guideCurved24_var._position_absolute; instrument->_position_relative[29] = _guideCurved24_var._position_relative; _guideCurved24_var._position_relative_is_zero = coords_test_zero(_guideCurved24_var._position_relative); instrument->counter_N[29] = instrument->counter_P[29] = instrument->counter_P2[29] = 0; instrument->counter_AbsorbProp[29]= 0; #ifdef USE_NEXUS if(nxhandle) { if ((!mcdotrace) && mcformat && strcasestr(mcformat, "NeXus")) { MPI_MASTER( mccomp_placement_type_nexus(nxhandle,"0028_guideCurved24", _guideCurved24_var._position_absolute, _guideCurved24_var._rotation_absolute, "Guide"); mccomp_param_nexus(nxhandle,"0028_guideCurved24", "reflect", 0, 0, "char*"); mccomp_param_nexus(nxhandle,"0028_guideCurved24", "w1", "NONE", "0.03","MCNUM"); mccomp_param_nexus(nxhandle,"0028_guideCurved24", "h1", "NONE", "0.12","MCNUM"); mccomp_param_nexus(nxhandle,"0028_guideCurved24", "w2", "0", "0.03","MCNUM"); mccomp_param_nexus(nxhandle,"0028_guideCurved24", "h2", "0", "0.12","MCNUM"); mccomp_param_nexus(nxhandle,"0028_guideCurved24", "l", "NONE", "0.499995","MCNUM"); mccomp_param_nexus(nxhandle,"0028_guideCurved24", "R0", "0.99", "R0","MCNUM"); mccomp_param_nexus(nxhandle,"0028_guideCurved24", "Qc", "0.0219", "Qc","MCNUM"); mccomp_param_nexus(nxhandle,"0028_guideCurved24", "alpha", "6.07", "ALPHA","MCNUM"); mccomp_param_nexus(nxhandle,"0028_guideCurved24", "m", "2", "M","MCNUM"); mccomp_param_nexus(nxhandle,"0028_guideCurved24", "W", "0.003", "W","MCNUM"); ); } } else { // fprintf(stderr,"NO NEXUS FILE"); } #endif return(0); } /* _guideCurved24_setpos */ /* component guideCurved25=Guide() SETTING, POSITION/ROTATION */ int _guideCurved25_setpos(void) { /* sets initial component parameters, position and rotation */ SIG_MESSAGE("[_guideCurved25_setpos] component guideCurved25=Guide() SETTING [Guide:0]"); stracpy(_guideCurved25_var._name, "guideCurved25", 16384); stracpy(_guideCurved25_var._type, "Guide", 16384); _guideCurved25_var._index=30; int current_setpos_index = 30; _guideCurved25_var._parameters.reflect[0]='\0'; _guideCurved25_var._parameters.w1 = 0.03; _guideCurved25_var._parameters.h1 = 0.12; _guideCurved25_var._parameters.w2 = 0.03; _guideCurved25_var._parameters.h2 = 0.12; _guideCurved25_var._parameters.l = 0.499995; _guideCurved25_var._parameters.R0 = R0; _guideCurved25_var._parameters.Qc = Qc; _guideCurved25_var._parameters.alpha = ALPHA; _guideCurved25_var._parameters.m = M; _guideCurved25_var._parameters.W = W; /* component guideCurved25=Guide() AT ROTATED */ { Coords tc1, tc2; tc1 = coords_set(0,0,0); tc2 = coords_set(0,0,0); Rotation tr1; rot_set_rotation(tr1,0,0,0); rot_set_rotation(tr1, (0)*DEG2RAD, (angleGuideCurved)*DEG2RAD, (0)*DEG2RAD); rot_mul(tr1, _guideCurved24_var._rotation_absolute, _guideCurved25_var._rotation_absolute); rot_transpose(_guideCurved24_var._rotation_absolute, tr1); rot_mul(_guideCurved25_var._rotation_absolute, tr1, _guideCurved25_var._rotation_relative); _guideCurved25_var._rotation_is_identity = rot_test_identity(_guideCurved25_var._rotation_relative); tc1 = coords_set( 0, 0, 0.5); rot_transpose(_guideCurved24_var._rotation_absolute, tr1); tc2 = rot_apply(tr1, tc1); _guideCurved25_var._position_absolute = coords_add(_guideCurved24_var._position_absolute, tc2); tc1 = coords_sub(_guideCurved24_var._position_absolute, _guideCurved25_var._position_absolute); _guideCurved25_var._position_relative = rot_apply(_guideCurved25_var._rotation_absolute, tc1); } /* guideCurved25=Guide() AT ROTATED */ DEBUG_COMPONENT("guideCurved25", _guideCurved25_var._position_absolute, _guideCurved25_var._rotation_absolute); instrument->_position_absolute[30] = _guideCurved25_var._position_absolute; instrument->_position_relative[30] = _guideCurved25_var._position_relative; _guideCurved25_var._position_relative_is_zero = coords_test_zero(_guideCurved25_var._position_relative); instrument->counter_N[30] = instrument->counter_P[30] = instrument->counter_P2[30] = 0; instrument->counter_AbsorbProp[30]= 0; #ifdef USE_NEXUS if(nxhandle) { if ((!mcdotrace) && mcformat && strcasestr(mcformat, "NeXus")) { MPI_MASTER( mccomp_placement_type_nexus(nxhandle,"0029_guideCurved25", _guideCurved25_var._position_absolute, _guideCurved25_var._rotation_absolute, "Guide"); mccomp_param_nexus(nxhandle,"0029_guideCurved25", "reflect", 0, 0, "char*"); mccomp_param_nexus(nxhandle,"0029_guideCurved25", "w1", "NONE", "0.03","MCNUM"); mccomp_param_nexus(nxhandle,"0029_guideCurved25", "h1", "NONE", "0.12","MCNUM"); mccomp_param_nexus(nxhandle,"0029_guideCurved25", "w2", "0", "0.03","MCNUM"); mccomp_param_nexus(nxhandle,"0029_guideCurved25", "h2", "0", "0.12","MCNUM"); mccomp_param_nexus(nxhandle,"0029_guideCurved25", "l", "NONE", "0.499995","MCNUM"); mccomp_param_nexus(nxhandle,"0029_guideCurved25", "R0", "0.99", "R0","MCNUM"); mccomp_param_nexus(nxhandle,"0029_guideCurved25", "Qc", "0.0219", "Qc","MCNUM"); mccomp_param_nexus(nxhandle,"0029_guideCurved25", "alpha", "6.07", "ALPHA","MCNUM"); mccomp_param_nexus(nxhandle,"0029_guideCurved25", "m", "2", "M","MCNUM"); mccomp_param_nexus(nxhandle,"0029_guideCurved25", "W", "0.003", "W","MCNUM"); ); } } else { // fprintf(stderr,"NO NEXUS FILE"); } #endif return(0); } /* _guideCurved25_setpos */ /* component guideCurved26=Guide() SETTING, POSITION/ROTATION */ int _guideCurved26_setpos(void) { /* sets initial component parameters, position and rotation */ SIG_MESSAGE("[_guideCurved26_setpos] component guideCurved26=Guide() SETTING [Guide:0]"); stracpy(_guideCurved26_var._name, "guideCurved26", 16384); stracpy(_guideCurved26_var._type, "Guide", 16384); _guideCurved26_var._index=31; int current_setpos_index = 31; _guideCurved26_var._parameters.reflect[0]='\0'; _guideCurved26_var._parameters.w1 = 0.03; _guideCurved26_var._parameters.h1 = 0.12; _guideCurved26_var._parameters.w2 = 0.03; _guideCurved26_var._parameters.h2 = 0.12; _guideCurved26_var._parameters.l = 0.499995; _guideCurved26_var._parameters.R0 = R0; _guideCurved26_var._parameters.Qc = Qc; _guideCurved26_var._parameters.alpha = ALPHA; _guideCurved26_var._parameters.m = M; _guideCurved26_var._parameters.W = W; /* component guideCurved26=Guide() AT ROTATED */ { Coords tc1, tc2; tc1 = coords_set(0,0,0); tc2 = coords_set(0,0,0); Rotation tr1; rot_set_rotation(tr1,0,0,0); rot_set_rotation(tr1, (0)*DEG2RAD, (angleGuideCurved)*DEG2RAD, (0)*DEG2RAD); rot_mul(tr1, _guideCurved25_var._rotation_absolute, _guideCurved26_var._rotation_absolute); rot_transpose(_guideCurved25_var._rotation_absolute, tr1); rot_mul(_guideCurved26_var._rotation_absolute, tr1, _guideCurved26_var._rotation_relative); _guideCurved26_var._rotation_is_identity = rot_test_identity(_guideCurved26_var._rotation_relative); tc1 = coords_set( 0, 0, 0.5); rot_transpose(_guideCurved25_var._rotation_absolute, tr1); tc2 = rot_apply(tr1, tc1); _guideCurved26_var._position_absolute = coords_add(_guideCurved25_var._position_absolute, tc2); tc1 = coords_sub(_guideCurved25_var._position_absolute, _guideCurved26_var._position_absolute); _guideCurved26_var._position_relative = rot_apply(_guideCurved26_var._rotation_absolute, tc1); } /* guideCurved26=Guide() AT ROTATED */ DEBUG_COMPONENT("guideCurved26", _guideCurved26_var._position_absolute, _guideCurved26_var._rotation_absolute); instrument->_position_absolute[31] = _guideCurved26_var._position_absolute; instrument->_position_relative[31] = _guideCurved26_var._position_relative; _guideCurved26_var._position_relative_is_zero = coords_test_zero(_guideCurved26_var._position_relative); instrument->counter_N[31] = instrument->counter_P[31] = instrument->counter_P2[31] = 0; instrument->counter_AbsorbProp[31]= 0; #ifdef USE_NEXUS if(nxhandle) { if ((!mcdotrace) && mcformat && strcasestr(mcformat, "NeXus")) { MPI_MASTER( mccomp_placement_type_nexus(nxhandle,"0030_guideCurved26", _guideCurved26_var._position_absolute, _guideCurved26_var._rotation_absolute, "Guide"); mccomp_param_nexus(nxhandle,"0030_guideCurved26", "reflect", 0, 0, "char*"); mccomp_param_nexus(nxhandle,"0030_guideCurved26", "w1", "NONE", "0.03","MCNUM"); mccomp_param_nexus(nxhandle,"0030_guideCurved26", "h1", "NONE", "0.12","MCNUM"); mccomp_param_nexus(nxhandle,"0030_guideCurved26", "w2", "0", "0.03","MCNUM"); mccomp_param_nexus(nxhandle,"0030_guideCurved26", "h2", "0", "0.12","MCNUM"); mccomp_param_nexus(nxhandle,"0030_guideCurved26", "l", "NONE", "0.499995","MCNUM"); mccomp_param_nexus(nxhandle,"0030_guideCurved26", "R0", "0.99", "R0","MCNUM"); mccomp_param_nexus(nxhandle,"0030_guideCurved26", "Qc", "0.0219", "Qc","MCNUM"); mccomp_param_nexus(nxhandle,"0030_guideCurved26", "alpha", "6.07", "ALPHA","MCNUM"); mccomp_param_nexus(nxhandle,"0030_guideCurved26", "m", "2", "M","MCNUM"); mccomp_param_nexus(nxhandle,"0030_guideCurved26", "W", "0.003", "W","MCNUM"); ); } } else { // fprintf(stderr,"NO NEXUS FILE"); } #endif return(0); } /* _guideCurved26_setpos */ /* component guideCurved27=Guide() SETTING, POSITION/ROTATION */ int _guideCurved27_setpos(void) { /* sets initial component parameters, position and rotation */ SIG_MESSAGE("[_guideCurved27_setpos] component guideCurved27=Guide() SETTING [Guide:0]"); stracpy(_guideCurved27_var._name, "guideCurved27", 16384); stracpy(_guideCurved27_var._type, "Guide", 16384); _guideCurved27_var._index=32; int current_setpos_index = 32; _guideCurved27_var._parameters.reflect[0]='\0'; _guideCurved27_var._parameters.w1 = 0.03; _guideCurved27_var._parameters.h1 = 0.12; _guideCurved27_var._parameters.w2 = 0.03; _guideCurved27_var._parameters.h2 = 0.12; _guideCurved27_var._parameters.l = 0.499995; _guideCurved27_var._parameters.R0 = R0; _guideCurved27_var._parameters.Qc = Qc; _guideCurved27_var._parameters.alpha = ALPHA; _guideCurved27_var._parameters.m = M; _guideCurved27_var._parameters.W = W; /* component guideCurved27=Guide() AT ROTATED */ { Coords tc1, tc2; tc1 = coords_set(0,0,0); tc2 = coords_set(0,0,0); Rotation tr1; rot_set_rotation(tr1,0,0,0); rot_set_rotation(tr1, (0)*DEG2RAD, (angleGuideCurved)*DEG2RAD, (0)*DEG2RAD); rot_mul(tr1, _guideCurved26_var._rotation_absolute, _guideCurved27_var._rotation_absolute); rot_transpose(_guideCurved26_var._rotation_absolute, tr1); rot_mul(_guideCurved27_var._rotation_absolute, tr1, _guideCurved27_var._rotation_relative); _guideCurved27_var._rotation_is_identity = rot_test_identity(_guideCurved27_var._rotation_relative); tc1 = coords_set( 0, 0, 0.5); rot_transpose(_guideCurved26_var._rotation_absolute, tr1); tc2 = rot_apply(tr1, tc1); _guideCurved27_var._position_absolute = coords_add(_guideCurved26_var._position_absolute, tc2); tc1 = coords_sub(_guideCurved26_var._position_absolute, _guideCurved27_var._position_absolute); _guideCurved27_var._position_relative = rot_apply(_guideCurved27_var._rotation_absolute, tc1); } /* guideCurved27=Guide() AT ROTATED */ DEBUG_COMPONENT("guideCurved27", _guideCurved27_var._position_absolute, _guideCurved27_var._rotation_absolute); instrument->_position_absolute[32] = _guideCurved27_var._position_absolute; instrument->_position_relative[32] = _guideCurved27_var._position_relative; _guideCurved27_var._position_relative_is_zero = coords_test_zero(_guideCurved27_var._position_relative); instrument->counter_N[32] = instrument->counter_P[32] = instrument->counter_P2[32] = 0; instrument->counter_AbsorbProp[32]= 0; #ifdef USE_NEXUS if(nxhandle) { if ((!mcdotrace) && mcformat && strcasestr(mcformat, "NeXus")) { MPI_MASTER( mccomp_placement_type_nexus(nxhandle,"0031_guideCurved27", _guideCurved27_var._position_absolute, _guideCurved27_var._rotation_absolute, "Guide"); mccomp_param_nexus(nxhandle,"0031_guideCurved27", "reflect", 0, 0, "char*"); mccomp_param_nexus(nxhandle,"0031_guideCurved27", "w1", "NONE", "0.03","MCNUM"); mccomp_param_nexus(nxhandle,"0031_guideCurved27", "h1", "NONE", "0.12","MCNUM"); mccomp_param_nexus(nxhandle,"0031_guideCurved27", "w2", "0", "0.03","MCNUM"); mccomp_param_nexus(nxhandle,"0031_guideCurved27", "h2", "0", "0.12","MCNUM"); mccomp_param_nexus(nxhandle,"0031_guideCurved27", "l", "NONE", "0.499995","MCNUM"); mccomp_param_nexus(nxhandle,"0031_guideCurved27", "R0", "0.99", "R0","MCNUM"); mccomp_param_nexus(nxhandle,"0031_guideCurved27", "Qc", "0.0219", "Qc","MCNUM"); mccomp_param_nexus(nxhandle,"0031_guideCurved27", "alpha", "6.07", "ALPHA","MCNUM"); mccomp_param_nexus(nxhandle,"0031_guideCurved27", "m", "2", "M","MCNUM"); mccomp_param_nexus(nxhandle,"0031_guideCurved27", "W", "0.003", "W","MCNUM"); ); } } else { // fprintf(stderr,"NO NEXUS FILE"); } #endif return(0); } /* _guideCurved27_setpos */ /* component guideCurved28=Guide() SETTING, POSITION/ROTATION */ int _guideCurved28_setpos(void) { /* sets initial component parameters, position and rotation */ SIG_MESSAGE("[_guideCurved28_setpos] component guideCurved28=Guide() SETTING [Guide:0]"); stracpy(_guideCurved28_var._name, "guideCurved28", 16384); stracpy(_guideCurved28_var._type, "Guide", 16384); _guideCurved28_var._index=33; int current_setpos_index = 33; _guideCurved28_var._parameters.reflect[0]='\0'; _guideCurved28_var._parameters.w1 = 0.03; _guideCurved28_var._parameters.h1 = 0.12; _guideCurved28_var._parameters.w2 = 0.03; _guideCurved28_var._parameters.h2 = 0.12; _guideCurved28_var._parameters.l = 0.499995; _guideCurved28_var._parameters.R0 = R0; _guideCurved28_var._parameters.Qc = Qc; _guideCurved28_var._parameters.alpha = ALPHA; _guideCurved28_var._parameters.m = M; _guideCurved28_var._parameters.W = W; /* component guideCurved28=Guide() AT ROTATED */ { Coords tc1, tc2; tc1 = coords_set(0,0,0); tc2 = coords_set(0,0,0); Rotation tr1; rot_set_rotation(tr1,0,0,0); rot_set_rotation(tr1, (0)*DEG2RAD, (angleGuideCurved)*DEG2RAD, (0)*DEG2RAD); rot_mul(tr1, _guideCurved27_var._rotation_absolute, _guideCurved28_var._rotation_absolute); rot_transpose(_guideCurved27_var._rotation_absolute, tr1); rot_mul(_guideCurved28_var._rotation_absolute, tr1, _guideCurved28_var._rotation_relative); _guideCurved28_var._rotation_is_identity = rot_test_identity(_guideCurved28_var._rotation_relative); tc1 = coords_set( 0, 0, 0.5); rot_transpose(_guideCurved27_var._rotation_absolute, tr1); tc2 = rot_apply(tr1, tc1); _guideCurved28_var._position_absolute = coords_add(_guideCurved27_var._position_absolute, tc2); tc1 = coords_sub(_guideCurved27_var._position_absolute, _guideCurved28_var._position_absolute); _guideCurved28_var._position_relative = rot_apply(_guideCurved28_var._rotation_absolute, tc1); } /* guideCurved28=Guide() AT ROTATED */ DEBUG_COMPONENT("guideCurved28", _guideCurved28_var._position_absolute, _guideCurved28_var._rotation_absolute); instrument->_position_absolute[33] = _guideCurved28_var._position_absolute; instrument->_position_relative[33] = _guideCurved28_var._position_relative; _guideCurved28_var._position_relative_is_zero = coords_test_zero(_guideCurved28_var._position_relative); instrument->counter_N[33] = instrument->counter_P[33] = instrument->counter_P2[33] = 0; instrument->counter_AbsorbProp[33]= 0; #ifdef USE_NEXUS if(nxhandle) { if ((!mcdotrace) && mcformat && strcasestr(mcformat, "NeXus")) { MPI_MASTER( mccomp_placement_type_nexus(nxhandle,"0032_guideCurved28", _guideCurved28_var._position_absolute, _guideCurved28_var._rotation_absolute, "Guide"); mccomp_param_nexus(nxhandle,"0032_guideCurved28", "reflect", 0, 0, "char*"); mccomp_param_nexus(nxhandle,"0032_guideCurved28", "w1", "NONE", "0.03","MCNUM"); mccomp_param_nexus(nxhandle,"0032_guideCurved28", "h1", "NONE", "0.12","MCNUM"); mccomp_param_nexus(nxhandle,"0032_guideCurved28", "w2", "0", "0.03","MCNUM"); mccomp_param_nexus(nxhandle,"0032_guideCurved28", "h2", "0", "0.12","MCNUM"); mccomp_param_nexus(nxhandle,"0032_guideCurved28", "l", "NONE", "0.499995","MCNUM"); mccomp_param_nexus(nxhandle,"0032_guideCurved28", "R0", "0.99", "R0","MCNUM"); mccomp_param_nexus(nxhandle,"0032_guideCurved28", "Qc", "0.0219", "Qc","MCNUM"); mccomp_param_nexus(nxhandle,"0032_guideCurved28", "alpha", "6.07", "ALPHA","MCNUM"); mccomp_param_nexus(nxhandle,"0032_guideCurved28", "m", "2", "M","MCNUM"); mccomp_param_nexus(nxhandle,"0032_guideCurved28", "W", "0.003", "W","MCNUM"); ); } } else { // fprintf(stderr,"NO NEXUS FILE"); } #endif return(0); } /* _guideCurved28_setpos */ /* component guideCurved29=Guide() SETTING, POSITION/ROTATION */ int _guideCurved29_setpos(void) { /* sets initial component parameters, position and rotation */ SIG_MESSAGE("[_guideCurved29_setpos] component guideCurved29=Guide() SETTING [Guide:0]"); stracpy(_guideCurved29_var._name, "guideCurved29", 16384); stracpy(_guideCurved29_var._type, "Guide", 16384); _guideCurved29_var._index=34; int current_setpos_index = 34; _guideCurved29_var._parameters.reflect[0]='\0'; _guideCurved29_var._parameters.w1 = 0.03; _guideCurved29_var._parameters.h1 = 0.12; _guideCurved29_var._parameters.w2 = 0.03; _guideCurved29_var._parameters.h2 = 0.12; _guideCurved29_var._parameters.l = 0.499995; _guideCurved29_var._parameters.R0 = R0; _guideCurved29_var._parameters.Qc = Qc; _guideCurved29_var._parameters.alpha = ALPHA; _guideCurved29_var._parameters.m = M; _guideCurved29_var._parameters.W = W; /* component guideCurved29=Guide() AT ROTATED */ { Coords tc1, tc2; tc1 = coords_set(0,0,0); tc2 = coords_set(0,0,0); Rotation tr1; rot_set_rotation(tr1,0,0,0); rot_set_rotation(tr1, (0)*DEG2RAD, (angleGuideCurved)*DEG2RAD, (0)*DEG2RAD); rot_mul(tr1, _guideCurved28_var._rotation_absolute, _guideCurved29_var._rotation_absolute); rot_transpose(_guideCurved28_var._rotation_absolute, tr1); rot_mul(_guideCurved29_var._rotation_absolute, tr1, _guideCurved29_var._rotation_relative); _guideCurved29_var._rotation_is_identity = rot_test_identity(_guideCurved29_var._rotation_relative); tc1 = coords_set( 0, 0, 0.5); rot_transpose(_guideCurved28_var._rotation_absolute, tr1); tc2 = rot_apply(tr1, tc1); _guideCurved29_var._position_absolute = coords_add(_guideCurved28_var._position_absolute, tc2); tc1 = coords_sub(_guideCurved28_var._position_absolute, _guideCurved29_var._position_absolute); _guideCurved29_var._position_relative = rot_apply(_guideCurved29_var._rotation_absolute, tc1); } /* guideCurved29=Guide() AT ROTATED */ DEBUG_COMPONENT("guideCurved29", _guideCurved29_var._position_absolute, _guideCurved29_var._rotation_absolute); instrument->_position_absolute[34] = _guideCurved29_var._position_absolute; instrument->_position_relative[34] = _guideCurved29_var._position_relative; _guideCurved29_var._position_relative_is_zero = coords_test_zero(_guideCurved29_var._position_relative); instrument->counter_N[34] = instrument->counter_P[34] = instrument->counter_P2[34] = 0; instrument->counter_AbsorbProp[34]= 0; #ifdef USE_NEXUS if(nxhandle) { if ((!mcdotrace) && mcformat && strcasestr(mcformat, "NeXus")) { MPI_MASTER( mccomp_placement_type_nexus(nxhandle,"0033_guideCurved29", _guideCurved29_var._position_absolute, _guideCurved29_var._rotation_absolute, "Guide"); mccomp_param_nexus(nxhandle,"0033_guideCurved29", "reflect", 0, 0, "char*"); mccomp_param_nexus(nxhandle,"0033_guideCurved29", "w1", "NONE", "0.03","MCNUM"); mccomp_param_nexus(nxhandle,"0033_guideCurved29", "h1", "NONE", "0.12","MCNUM"); mccomp_param_nexus(nxhandle,"0033_guideCurved29", "w2", "0", "0.03","MCNUM"); mccomp_param_nexus(nxhandle,"0033_guideCurved29", "h2", "0", "0.12","MCNUM"); mccomp_param_nexus(nxhandle,"0033_guideCurved29", "l", "NONE", "0.499995","MCNUM"); mccomp_param_nexus(nxhandle,"0033_guideCurved29", "R0", "0.99", "R0","MCNUM"); mccomp_param_nexus(nxhandle,"0033_guideCurved29", "Qc", "0.0219", "Qc","MCNUM"); mccomp_param_nexus(nxhandle,"0033_guideCurved29", "alpha", "6.07", "ALPHA","MCNUM"); mccomp_param_nexus(nxhandle,"0033_guideCurved29", "m", "2", "M","MCNUM"); mccomp_param_nexus(nxhandle,"0033_guideCurved29", "W", "0.003", "W","MCNUM"); ); } } else { // fprintf(stderr,"NO NEXUS FILE"); } #endif return(0); } /* _guideCurved29_setpos */ /* component guideCurved30=Guide() SETTING, POSITION/ROTATION */ int _guideCurved30_setpos(void) { /* sets initial component parameters, position and rotation */ SIG_MESSAGE("[_guideCurved30_setpos] component guideCurved30=Guide() SETTING [Guide:0]"); stracpy(_guideCurved30_var._name, "guideCurved30", 16384); stracpy(_guideCurved30_var._type, "Guide", 16384); _guideCurved30_var._index=35; int current_setpos_index = 35; _guideCurved30_var._parameters.reflect[0]='\0'; _guideCurved30_var._parameters.w1 = 0.03; _guideCurved30_var._parameters.h1 = 0.12; _guideCurved30_var._parameters.w2 = 0.03; _guideCurved30_var._parameters.h2 = 0.12; _guideCurved30_var._parameters.l = 0.499995; _guideCurved30_var._parameters.R0 = R0; _guideCurved30_var._parameters.Qc = Qc; _guideCurved30_var._parameters.alpha = ALPHA; _guideCurved30_var._parameters.m = M; _guideCurved30_var._parameters.W = W; /* component guideCurved30=Guide() AT ROTATED */ { Coords tc1, tc2; tc1 = coords_set(0,0,0); tc2 = coords_set(0,0,0); Rotation tr1; rot_set_rotation(tr1,0,0,0); rot_set_rotation(tr1, (0)*DEG2RAD, (angleGuideCurved)*DEG2RAD, (0)*DEG2RAD); rot_mul(tr1, _guideCurved29_var._rotation_absolute, _guideCurved30_var._rotation_absolute); rot_transpose(_guideCurved29_var._rotation_absolute, tr1); rot_mul(_guideCurved30_var._rotation_absolute, tr1, _guideCurved30_var._rotation_relative); _guideCurved30_var._rotation_is_identity = rot_test_identity(_guideCurved30_var._rotation_relative); tc1 = coords_set( 0, 0, 0.5); rot_transpose(_guideCurved29_var._rotation_absolute, tr1); tc2 = rot_apply(tr1, tc1); _guideCurved30_var._position_absolute = coords_add(_guideCurved29_var._position_absolute, tc2); tc1 = coords_sub(_guideCurved29_var._position_absolute, _guideCurved30_var._position_absolute); _guideCurved30_var._position_relative = rot_apply(_guideCurved30_var._rotation_absolute, tc1); } /* guideCurved30=Guide() AT ROTATED */ DEBUG_COMPONENT("guideCurved30", _guideCurved30_var._position_absolute, _guideCurved30_var._rotation_absolute); instrument->_position_absolute[35] = _guideCurved30_var._position_absolute; instrument->_position_relative[35] = _guideCurved30_var._position_relative; _guideCurved30_var._position_relative_is_zero = coords_test_zero(_guideCurved30_var._position_relative); instrument->counter_N[35] = instrument->counter_P[35] = instrument->counter_P2[35] = 0; instrument->counter_AbsorbProp[35]= 0; #ifdef USE_NEXUS if(nxhandle) { if ((!mcdotrace) && mcformat && strcasestr(mcformat, "NeXus")) { MPI_MASTER( mccomp_placement_type_nexus(nxhandle,"0034_guideCurved30", _guideCurved30_var._position_absolute, _guideCurved30_var._rotation_absolute, "Guide"); mccomp_param_nexus(nxhandle,"0034_guideCurved30", "reflect", 0, 0, "char*"); mccomp_param_nexus(nxhandle,"0034_guideCurved30", "w1", "NONE", "0.03","MCNUM"); mccomp_param_nexus(nxhandle,"0034_guideCurved30", "h1", "NONE", "0.12","MCNUM"); mccomp_param_nexus(nxhandle,"0034_guideCurved30", "w2", "0", "0.03","MCNUM"); mccomp_param_nexus(nxhandle,"0034_guideCurved30", "h2", "0", "0.12","MCNUM"); mccomp_param_nexus(nxhandle,"0034_guideCurved30", "l", "NONE", "0.499995","MCNUM"); mccomp_param_nexus(nxhandle,"0034_guideCurved30", "R0", "0.99", "R0","MCNUM"); mccomp_param_nexus(nxhandle,"0034_guideCurved30", "Qc", "0.0219", "Qc","MCNUM"); mccomp_param_nexus(nxhandle,"0034_guideCurved30", "alpha", "6.07", "ALPHA","MCNUM"); mccomp_param_nexus(nxhandle,"0034_guideCurved30", "m", "2", "M","MCNUM"); mccomp_param_nexus(nxhandle,"0034_guideCurved30", "W", "0.003", "W","MCNUM"); ); } } else { // fprintf(stderr,"NO NEXUS FILE"); } #endif return(0); } /* _guideCurved30_setpos */ /* component guideCurved31=Guide() SETTING, POSITION/ROTATION */ int _guideCurved31_setpos(void) { /* sets initial component parameters, position and rotation */ SIG_MESSAGE("[_guideCurved31_setpos] component guideCurved31=Guide() SETTING [Guide:0]"); stracpy(_guideCurved31_var._name, "guideCurved31", 16384); stracpy(_guideCurved31_var._type, "Guide", 16384); _guideCurved31_var._index=36; int current_setpos_index = 36; _guideCurved31_var._parameters.reflect[0]='\0'; _guideCurved31_var._parameters.w1 = 0.03; _guideCurved31_var._parameters.h1 = 0.12; _guideCurved31_var._parameters.w2 = 0.03; _guideCurved31_var._parameters.h2 = 0.12; _guideCurved31_var._parameters.l = 0.499995; _guideCurved31_var._parameters.R0 = R0; _guideCurved31_var._parameters.Qc = Qc; _guideCurved31_var._parameters.alpha = ALPHA; _guideCurved31_var._parameters.m = M; _guideCurved31_var._parameters.W = W; /* component guideCurved31=Guide() AT ROTATED */ { Coords tc1, tc2; tc1 = coords_set(0,0,0); tc2 = coords_set(0,0,0); Rotation tr1; rot_set_rotation(tr1,0,0,0); rot_set_rotation(tr1, (0)*DEG2RAD, (angleGuideCurved)*DEG2RAD, (0)*DEG2RAD); rot_mul(tr1, _guideCurved30_var._rotation_absolute, _guideCurved31_var._rotation_absolute); rot_transpose(_guideCurved30_var._rotation_absolute, tr1); rot_mul(_guideCurved31_var._rotation_absolute, tr1, _guideCurved31_var._rotation_relative); _guideCurved31_var._rotation_is_identity = rot_test_identity(_guideCurved31_var._rotation_relative); tc1 = coords_set( 0, 0, 0.5); rot_transpose(_guideCurved30_var._rotation_absolute, tr1); tc2 = rot_apply(tr1, tc1); _guideCurved31_var._position_absolute = coords_add(_guideCurved30_var._position_absolute, tc2); tc1 = coords_sub(_guideCurved30_var._position_absolute, _guideCurved31_var._position_absolute); _guideCurved31_var._position_relative = rot_apply(_guideCurved31_var._rotation_absolute, tc1); } /* guideCurved31=Guide() AT ROTATED */ DEBUG_COMPONENT("guideCurved31", _guideCurved31_var._position_absolute, _guideCurved31_var._rotation_absolute); instrument->_position_absolute[36] = _guideCurved31_var._position_absolute; instrument->_position_relative[36] = _guideCurved31_var._position_relative; _guideCurved31_var._position_relative_is_zero = coords_test_zero(_guideCurved31_var._position_relative); instrument->counter_N[36] = instrument->counter_P[36] = instrument->counter_P2[36] = 0; instrument->counter_AbsorbProp[36]= 0; #ifdef USE_NEXUS if(nxhandle) { if ((!mcdotrace) && mcformat && strcasestr(mcformat, "NeXus")) { MPI_MASTER( mccomp_placement_type_nexus(nxhandle,"0035_guideCurved31", _guideCurved31_var._position_absolute, _guideCurved31_var._rotation_absolute, "Guide"); mccomp_param_nexus(nxhandle,"0035_guideCurved31", "reflect", 0, 0, "char*"); mccomp_param_nexus(nxhandle,"0035_guideCurved31", "w1", "NONE", "0.03","MCNUM"); mccomp_param_nexus(nxhandle,"0035_guideCurved31", "h1", "NONE", "0.12","MCNUM"); mccomp_param_nexus(nxhandle,"0035_guideCurved31", "w2", "0", "0.03","MCNUM"); mccomp_param_nexus(nxhandle,"0035_guideCurved31", "h2", "0", "0.12","MCNUM"); mccomp_param_nexus(nxhandle,"0035_guideCurved31", "l", "NONE", "0.499995","MCNUM"); mccomp_param_nexus(nxhandle,"0035_guideCurved31", "R0", "0.99", "R0","MCNUM"); mccomp_param_nexus(nxhandle,"0035_guideCurved31", "Qc", "0.0219", "Qc","MCNUM"); mccomp_param_nexus(nxhandle,"0035_guideCurved31", "alpha", "6.07", "ALPHA","MCNUM"); mccomp_param_nexus(nxhandle,"0035_guideCurved31", "m", "2", "M","MCNUM"); mccomp_param_nexus(nxhandle,"0035_guideCurved31", "W", "0.003", "W","MCNUM"); ); } } else { // fprintf(stderr,"NO NEXUS FILE"); } #endif return(0); } /* _guideCurved31_setpos */ /* component guideCurved32=Guide() SETTING, POSITION/ROTATION */ int _guideCurved32_setpos(void) { /* sets initial component parameters, position and rotation */ SIG_MESSAGE("[_guideCurved32_setpos] component guideCurved32=Guide() SETTING [Guide:0]"); stracpy(_guideCurved32_var._name, "guideCurved32", 16384); stracpy(_guideCurved32_var._type, "Guide", 16384); _guideCurved32_var._index=37; int current_setpos_index = 37; _guideCurved32_var._parameters.reflect[0]='\0'; _guideCurved32_var._parameters.w1 = 0.03; _guideCurved32_var._parameters.h1 = 0.12; _guideCurved32_var._parameters.w2 = 0.03; _guideCurved32_var._parameters.h2 = 0.12; _guideCurved32_var._parameters.l = 0.499995; _guideCurved32_var._parameters.R0 = R0; _guideCurved32_var._parameters.Qc = Qc; _guideCurved32_var._parameters.alpha = ALPHA; _guideCurved32_var._parameters.m = M; _guideCurved32_var._parameters.W = W; /* component guideCurved32=Guide() AT ROTATED */ { Coords tc1, tc2; tc1 = coords_set(0,0,0); tc2 = coords_set(0,0,0); Rotation tr1; rot_set_rotation(tr1,0,0,0); rot_set_rotation(tr1, (0)*DEG2RAD, (angleGuideCurved)*DEG2RAD, (0)*DEG2RAD); rot_mul(tr1, _guideCurved31_var._rotation_absolute, _guideCurved32_var._rotation_absolute); rot_transpose(_guideCurved31_var._rotation_absolute, tr1); rot_mul(_guideCurved32_var._rotation_absolute, tr1, _guideCurved32_var._rotation_relative); _guideCurved32_var._rotation_is_identity = rot_test_identity(_guideCurved32_var._rotation_relative); tc1 = coords_set( 0, 0, 0.5); rot_transpose(_guideCurved31_var._rotation_absolute, tr1); tc2 = rot_apply(tr1, tc1); _guideCurved32_var._position_absolute = coords_add(_guideCurved31_var._position_absolute, tc2); tc1 = coords_sub(_guideCurved31_var._position_absolute, _guideCurved32_var._position_absolute); _guideCurved32_var._position_relative = rot_apply(_guideCurved32_var._rotation_absolute, tc1); } /* guideCurved32=Guide() AT ROTATED */ DEBUG_COMPONENT("guideCurved32", _guideCurved32_var._position_absolute, _guideCurved32_var._rotation_absolute); instrument->_position_absolute[37] = _guideCurved32_var._position_absolute; instrument->_position_relative[37] = _guideCurved32_var._position_relative; _guideCurved32_var._position_relative_is_zero = coords_test_zero(_guideCurved32_var._position_relative); instrument->counter_N[37] = instrument->counter_P[37] = instrument->counter_P2[37] = 0; instrument->counter_AbsorbProp[37]= 0; #ifdef USE_NEXUS if(nxhandle) { if ((!mcdotrace) && mcformat && strcasestr(mcformat, "NeXus")) { MPI_MASTER( mccomp_placement_type_nexus(nxhandle,"0036_guideCurved32", _guideCurved32_var._position_absolute, _guideCurved32_var._rotation_absolute, "Guide"); mccomp_param_nexus(nxhandle,"0036_guideCurved32", "reflect", 0, 0, "char*"); mccomp_param_nexus(nxhandle,"0036_guideCurved32", "w1", "NONE", "0.03","MCNUM"); mccomp_param_nexus(nxhandle,"0036_guideCurved32", "h1", "NONE", "0.12","MCNUM"); mccomp_param_nexus(nxhandle,"0036_guideCurved32", "w2", "0", "0.03","MCNUM"); mccomp_param_nexus(nxhandle,"0036_guideCurved32", "h2", "0", "0.12","MCNUM"); mccomp_param_nexus(nxhandle,"0036_guideCurved32", "l", "NONE", "0.499995","MCNUM"); mccomp_param_nexus(nxhandle,"0036_guideCurved32", "R0", "0.99", "R0","MCNUM"); mccomp_param_nexus(nxhandle,"0036_guideCurved32", "Qc", "0.0219", "Qc","MCNUM"); mccomp_param_nexus(nxhandle,"0036_guideCurved32", "alpha", "6.07", "ALPHA","MCNUM"); mccomp_param_nexus(nxhandle,"0036_guideCurved32", "m", "2", "M","MCNUM"); mccomp_param_nexus(nxhandle,"0036_guideCurved32", "W", "0.003", "W","MCNUM"); ); } } else { // fprintf(stderr,"NO NEXUS FILE"); } #endif return(0); } /* _guideCurved32_setpos */ /* component guideCurved33=Guide() SETTING, POSITION/ROTATION */ int _guideCurved33_setpos(void) { /* sets initial component parameters, position and rotation */ SIG_MESSAGE("[_guideCurved33_setpos] component guideCurved33=Guide() SETTING [Guide:0]"); stracpy(_guideCurved33_var._name, "guideCurved33", 16384); stracpy(_guideCurved33_var._type, "Guide", 16384); _guideCurved33_var._index=38; int current_setpos_index = 38; _guideCurved33_var._parameters.reflect[0]='\0'; _guideCurved33_var._parameters.w1 = 0.03; _guideCurved33_var._parameters.h1 = 0.12; _guideCurved33_var._parameters.w2 = 0.03; _guideCurved33_var._parameters.h2 = 0.12; _guideCurved33_var._parameters.l = 0.499995; _guideCurved33_var._parameters.R0 = R0; _guideCurved33_var._parameters.Qc = Qc; _guideCurved33_var._parameters.alpha = ALPHA; _guideCurved33_var._parameters.m = M; _guideCurved33_var._parameters.W = W; /* component guideCurved33=Guide() AT ROTATED */ { Coords tc1, tc2; tc1 = coords_set(0,0,0); tc2 = coords_set(0,0,0); Rotation tr1; rot_set_rotation(tr1,0,0,0); rot_set_rotation(tr1, (0)*DEG2RAD, (angleGuideCurved)*DEG2RAD, (0)*DEG2RAD); rot_mul(tr1, _guideCurved32_var._rotation_absolute, _guideCurved33_var._rotation_absolute); rot_transpose(_guideCurved32_var._rotation_absolute, tr1); rot_mul(_guideCurved33_var._rotation_absolute, tr1, _guideCurved33_var._rotation_relative); _guideCurved33_var._rotation_is_identity = rot_test_identity(_guideCurved33_var._rotation_relative); tc1 = coords_set( 0, 0, 0.5); rot_transpose(_guideCurved32_var._rotation_absolute, tr1); tc2 = rot_apply(tr1, tc1); _guideCurved33_var._position_absolute = coords_add(_guideCurved32_var._position_absolute, tc2); tc1 = coords_sub(_guideCurved32_var._position_absolute, _guideCurved33_var._position_absolute); _guideCurved33_var._position_relative = rot_apply(_guideCurved33_var._rotation_absolute, tc1); } /* guideCurved33=Guide() AT ROTATED */ DEBUG_COMPONENT("guideCurved33", _guideCurved33_var._position_absolute, _guideCurved33_var._rotation_absolute); instrument->_position_absolute[38] = _guideCurved33_var._position_absolute; instrument->_position_relative[38] = _guideCurved33_var._position_relative; _guideCurved33_var._position_relative_is_zero = coords_test_zero(_guideCurved33_var._position_relative); instrument->counter_N[38] = instrument->counter_P[38] = instrument->counter_P2[38] = 0; instrument->counter_AbsorbProp[38]= 0; #ifdef USE_NEXUS if(nxhandle) { if ((!mcdotrace) && mcformat && strcasestr(mcformat, "NeXus")) { MPI_MASTER( mccomp_placement_type_nexus(nxhandle,"0037_guideCurved33", _guideCurved33_var._position_absolute, _guideCurved33_var._rotation_absolute, "Guide"); mccomp_param_nexus(nxhandle,"0037_guideCurved33", "reflect", 0, 0, "char*"); mccomp_param_nexus(nxhandle,"0037_guideCurved33", "w1", "NONE", "0.03","MCNUM"); mccomp_param_nexus(nxhandle,"0037_guideCurved33", "h1", "NONE", "0.12","MCNUM"); mccomp_param_nexus(nxhandle,"0037_guideCurved33", "w2", "0", "0.03","MCNUM"); mccomp_param_nexus(nxhandle,"0037_guideCurved33", "h2", "0", "0.12","MCNUM"); mccomp_param_nexus(nxhandle,"0037_guideCurved33", "l", "NONE", "0.499995","MCNUM"); mccomp_param_nexus(nxhandle,"0037_guideCurved33", "R0", "0.99", "R0","MCNUM"); mccomp_param_nexus(nxhandle,"0037_guideCurved33", "Qc", "0.0219", "Qc","MCNUM"); mccomp_param_nexus(nxhandle,"0037_guideCurved33", "alpha", "6.07", "ALPHA","MCNUM"); mccomp_param_nexus(nxhandle,"0037_guideCurved33", "m", "2", "M","MCNUM"); mccomp_param_nexus(nxhandle,"0037_guideCurved33", "W", "0.003", "W","MCNUM"); ); } } else { // fprintf(stderr,"NO NEXUS FILE"); } #endif return(0); } /* _guideCurved33_setpos */ /* component guideCurved34=Guide() SETTING, POSITION/ROTATION */ int _guideCurved34_setpos(void) { /* sets initial component parameters, position and rotation */ SIG_MESSAGE("[_guideCurved34_setpos] component guideCurved34=Guide() SETTING [Guide:0]"); stracpy(_guideCurved34_var._name, "guideCurved34", 16384); stracpy(_guideCurved34_var._type, "Guide", 16384); _guideCurved34_var._index=39; int current_setpos_index = 39; _guideCurved34_var._parameters.reflect[0]='\0'; _guideCurved34_var._parameters.w1 = 0.03; _guideCurved34_var._parameters.h1 = 0.12; _guideCurved34_var._parameters.w2 = 0.03; _guideCurved34_var._parameters.h2 = 0.12; _guideCurved34_var._parameters.l = 0.499995; _guideCurved34_var._parameters.R0 = R0; _guideCurved34_var._parameters.Qc = Qc; _guideCurved34_var._parameters.alpha = ALPHA; _guideCurved34_var._parameters.m = M; _guideCurved34_var._parameters.W = W; /* component guideCurved34=Guide() AT ROTATED */ { Coords tc1, tc2; tc1 = coords_set(0,0,0); tc2 = coords_set(0,0,0); Rotation tr1; rot_set_rotation(tr1,0,0,0); rot_set_rotation(tr1, (0)*DEG2RAD, (angleGuideCurved)*DEG2RAD, (0)*DEG2RAD); rot_mul(tr1, _guideCurved33_var._rotation_absolute, _guideCurved34_var._rotation_absolute); rot_transpose(_guideCurved33_var._rotation_absolute, tr1); rot_mul(_guideCurved34_var._rotation_absolute, tr1, _guideCurved34_var._rotation_relative); _guideCurved34_var._rotation_is_identity = rot_test_identity(_guideCurved34_var._rotation_relative); tc1 = coords_set( 0, 0, 0.5); rot_transpose(_guideCurved33_var._rotation_absolute, tr1); tc2 = rot_apply(tr1, tc1); _guideCurved34_var._position_absolute = coords_add(_guideCurved33_var._position_absolute, tc2); tc1 = coords_sub(_guideCurved33_var._position_absolute, _guideCurved34_var._position_absolute); _guideCurved34_var._position_relative = rot_apply(_guideCurved34_var._rotation_absolute, tc1); } /* guideCurved34=Guide() AT ROTATED */ DEBUG_COMPONENT("guideCurved34", _guideCurved34_var._position_absolute, _guideCurved34_var._rotation_absolute); instrument->_position_absolute[39] = _guideCurved34_var._position_absolute; instrument->_position_relative[39] = _guideCurved34_var._position_relative; _guideCurved34_var._position_relative_is_zero = coords_test_zero(_guideCurved34_var._position_relative); instrument->counter_N[39] = instrument->counter_P[39] = instrument->counter_P2[39] = 0; instrument->counter_AbsorbProp[39]= 0; #ifdef USE_NEXUS if(nxhandle) { if ((!mcdotrace) && mcformat && strcasestr(mcformat, "NeXus")) { MPI_MASTER( mccomp_placement_type_nexus(nxhandle,"0038_guideCurved34", _guideCurved34_var._position_absolute, _guideCurved34_var._rotation_absolute, "Guide"); mccomp_param_nexus(nxhandle,"0038_guideCurved34", "reflect", 0, 0, "char*"); mccomp_param_nexus(nxhandle,"0038_guideCurved34", "w1", "NONE", "0.03","MCNUM"); mccomp_param_nexus(nxhandle,"0038_guideCurved34", "h1", "NONE", "0.12","MCNUM"); mccomp_param_nexus(nxhandle,"0038_guideCurved34", "w2", "0", "0.03","MCNUM"); mccomp_param_nexus(nxhandle,"0038_guideCurved34", "h2", "0", "0.12","MCNUM"); mccomp_param_nexus(nxhandle,"0038_guideCurved34", "l", "NONE", "0.499995","MCNUM"); mccomp_param_nexus(nxhandle,"0038_guideCurved34", "R0", "0.99", "R0","MCNUM"); mccomp_param_nexus(nxhandle,"0038_guideCurved34", "Qc", "0.0219", "Qc","MCNUM"); mccomp_param_nexus(nxhandle,"0038_guideCurved34", "alpha", "6.07", "ALPHA","MCNUM"); mccomp_param_nexus(nxhandle,"0038_guideCurved34", "m", "2", "M","MCNUM"); mccomp_param_nexus(nxhandle,"0038_guideCurved34", "W", "0.003", "W","MCNUM"); ); } } else { // fprintf(stderr,"NO NEXUS FILE"); } #endif return(0); } /* _guideCurved34_setpos */ /* component guideCurved35=Guide() SETTING, POSITION/ROTATION */ int _guideCurved35_setpos(void) { /* sets initial component parameters, position and rotation */ SIG_MESSAGE("[_guideCurved35_setpos] component guideCurved35=Guide() SETTING [Guide:0]"); stracpy(_guideCurved35_var._name, "guideCurved35", 16384); stracpy(_guideCurved35_var._type, "Guide", 16384); _guideCurved35_var._index=40; int current_setpos_index = 40; _guideCurved35_var._parameters.reflect[0]='\0'; _guideCurved35_var._parameters.w1 = 0.03; _guideCurved35_var._parameters.h1 = 0.12; _guideCurved35_var._parameters.w2 = 0.03; _guideCurved35_var._parameters.h2 = 0.12; _guideCurved35_var._parameters.l = 0.499995; _guideCurved35_var._parameters.R0 = R0; _guideCurved35_var._parameters.Qc = Qc; _guideCurved35_var._parameters.alpha = ALPHA; _guideCurved35_var._parameters.m = M; _guideCurved35_var._parameters.W = W; /* component guideCurved35=Guide() AT ROTATED */ { Coords tc1, tc2; tc1 = coords_set(0,0,0); tc2 = coords_set(0,0,0); Rotation tr1; rot_set_rotation(tr1,0,0,0); rot_set_rotation(tr1, (0)*DEG2RAD, (angleGuideCurved)*DEG2RAD, (0)*DEG2RAD); rot_mul(tr1, _guideCurved34_var._rotation_absolute, _guideCurved35_var._rotation_absolute); rot_transpose(_guideCurved34_var._rotation_absolute, tr1); rot_mul(_guideCurved35_var._rotation_absolute, tr1, _guideCurved35_var._rotation_relative); _guideCurved35_var._rotation_is_identity = rot_test_identity(_guideCurved35_var._rotation_relative); tc1 = coords_set( 0, 0, 0.5); rot_transpose(_guideCurved34_var._rotation_absolute, tr1); tc2 = rot_apply(tr1, tc1); _guideCurved35_var._position_absolute = coords_add(_guideCurved34_var._position_absolute, tc2); tc1 = coords_sub(_guideCurved34_var._position_absolute, _guideCurved35_var._position_absolute); _guideCurved35_var._position_relative = rot_apply(_guideCurved35_var._rotation_absolute, tc1); } /* guideCurved35=Guide() AT ROTATED */ DEBUG_COMPONENT("guideCurved35", _guideCurved35_var._position_absolute, _guideCurved35_var._rotation_absolute); instrument->_position_absolute[40] = _guideCurved35_var._position_absolute; instrument->_position_relative[40] = _guideCurved35_var._position_relative; _guideCurved35_var._position_relative_is_zero = coords_test_zero(_guideCurved35_var._position_relative); instrument->counter_N[40] = instrument->counter_P[40] = instrument->counter_P2[40] = 0; instrument->counter_AbsorbProp[40]= 0; #ifdef USE_NEXUS if(nxhandle) { if ((!mcdotrace) && mcformat && strcasestr(mcformat, "NeXus")) { MPI_MASTER( mccomp_placement_type_nexus(nxhandle,"0039_guideCurved35", _guideCurved35_var._position_absolute, _guideCurved35_var._rotation_absolute, "Guide"); mccomp_param_nexus(nxhandle,"0039_guideCurved35", "reflect", 0, 0, "char*"); mccomp_param_nexus(nxhandle,"0039_guideCurved35", "w1", "NONE", "0.03","MCNUM"); mccomp_param_nexus(nxhandle,"0039_guideCurved35", "h1", "NONE", "0.12","MCNUM"); mccomp_param_nexus(nxhandle,"0039_guideCurved35", "w2", "0", "0.03","MCNUM"); mccomp_param_nexus(nxhandle,"0039_guideCurved35", "h2", "0", "0.12","MCNUM"); mccomp_param_nexus(nxhandle,"0039_guideCurved35", "l", "NONE", "0.499995","MCNUM"); mccomp_param_nexus(nxhandle,"0039_guideCurved35", "R0", "0.99", "R0","MCNUM"); mccomp_param_nexus(nxhandle,"0039_guideCurved35", "Qc", "0.0219", "Qc","MCNUM"); mccomp_param_nexus(nxhandle,"0039_guideCurved35", "alpha", "6.07", "ALPHA","MCNUM"); mccomp_param_nexus(nxhandle,"0039_guideCurved35", "m", "2", "M","MCNUM"); mccomp_param_nexus(nxhandle,"0039_guideCurved35", "W", "0.003", "W","MCNUM"); ); } } else { // fprintf(stderr,"NO NEXUS FILE"); } #endif return(0); } /* _guideCurved35_setpos */ /* component guideCurved36=Guide() SETTING, POSITION/ROTATION */ int _guideCurved36_setpos(void) { /* sets initial component parameters, position and rotation */ SIG_MESSAGE("[_guideCurved36_setpos] component guideCurved36=Guide() SETTING [Guide:0]"); stracpy(_guideCurved36_var._name, "guideCurved36", 16384); stracpy(_guideCurved36_var._type, "Guide", 16384); _guideCurved36_var._index=41; int current_setpos_index = 41; _guideCurved36_var._parameters.reflect[0]='\0'; _guideCurved36_var._parameters.w1 = 0.03; _guideCurved36_var._parameters.h1 = 0.12; _guideCurved36_var._parameters.w2 = 0.03; _guideCurved36_var._parameters.h2 = 0.12; _guideCurved36_var._parameters.l = 0.499995; _guideCurved36_var._parameters.R0 = R0; _guideCurved36_var._parameters.Qc = Qc; _guideCurved36_var._parameters.alpha = ALPHA; _guideCurved36_var._parameters.m = M; _guideCurved36_var._parameters.W = W; /* component guideCurved36=Guide() AT ROTATED */ { Coords tc1, tc2; tc1 = coords_set(0,0,0); tc2 = coords_set(0,0,0); Rotation tr1; rot_set_rotation(tr1,0,0,0); rot_set_rotation(tr1, (0)*DEG2RAD, (angleGuideCurved)*DEG2RAD, (0)*DEG2RAD); rot_mul(tr1, _guideCurved35_var._rotation_absolute, _guideCurved36_var._rotation_absolute); rot_transpose(_guideCurved35_var._rotation_absolute, tr1); rot_mul(_guideCurved36_var._rotation_absolute, tr1, _guideCurved36_var._rotation_relative); _guideCurved36_var._rotation_is_identity = rot_test_identity(_guideCurved36_var._rotation_relative); tc1 = coords_set( 0, 0, 0.5); rot_transpose(_guideCurved35_var._rotation_absolute, tr1); tc2 = rot_apply(tr1, tc1); _guideCurved36_var._position_absolute = coords_add(_guideCurved35_var._position_absolute, tc2); tc1 = coords_sub(_guideCurved35_var._position_absolute, _guideCurved36_var._position_absolute); _guideCurved36_var._position_relative = rot_apply(_guideCurved36_var._rotation_absolute, tc1); } /* guideCurved36=Guide() AT ROTATED */ DEBUG_COMPONENT("guideCurved36", _guideCurved36_var._position_absolute, _guideCurved36_var._rotation_absolute); instrument->_position_absolute[41] = _guideCurved36_var._position_absolute; instrument->_position_relative[41] = _guideCurved36_var._position_relative; _guideCurved36_var._position_relative_is_zero = coords_test_zero(_guideCurved36_var._position_relative); instrument->counter_N[41] = instrument->counter_P[41] = instrument->counter_P2[41] = 0; instrument->counter_AbsorbProp[41]= 0; #ifdef USE_NEXUS if(nxhandle) { if ((!mcdotrace) && mcformat && strcasestr(mcformat, "NeXus")) { MPI_MASTER( mccomp_placement_type_nexus(nxhandle,"0040_guideCurved36", _guideCurved36_var._position_absolute, _guideCurved36_var._rotation_absolute, "Guide"); mccomp_param_nexus(nxhandle,"0040_guideCurved36", "reflect", 0, 0, "char*"); mccomp_param_nexus(nxhandle,"0040_guideCurved36", "w1", "NONE", "0.03","MCNUM"); mccomp_param_nexus(nxhandle,"0040_guideCurved36", "h1", "NONE", "0.12","MCNUM"); mccomp_param_nexus(nxhandle,"0040_guideCurved36", "w2", "0", "0.03","MCNUM"); mccomp_param_nexus(nxhandle,"0040_guideCurved36", "h2", "0", "0.12","MCNUM"); mccomp_param_nexus(nxhandle,"0040_guideCurved36", "l", "NONE", "0.499995","MCNUM"); mccomp_param_nexus(nxhandle,"0040_guideCurved36", "R0", "0.99", "R0","MCNUM"); mccomp_param_nexus(nxhandle,"0040_guideCurved36", "Qc", "0.0219", "Qc","MCNUM"); mccomp_param_nexus(nxhandle,"0040_guideCurved36", "alpha", "6.07", "ALPHA","MCNUM"); mccomp_param_nexus(nxhandle,"0040_guideCurved36", "m", "2", "M","MCNUM"); mccomp_param_nexus(nxhandle,"0040_guideCurved36", "W", "0.003", "W","MCNUM"); ); } } else { // fprintf(stderr,"NO NEXUS FILE"); } #endif return(0); } /* _guideCurved36_setpos */ /* component guideCurved37=Guide() SETTING, POSITION/ROTATION */ int _guideCurved37_setpos(void) { /* sets initial component parameters, position and rotation */ SIG_MESSAGE("[_guideCurved37_setpos] component guideCurved37=Guide() SETTING [Guide:0]"); stracpy(_guideCurved37_var._name, "guideCurved37", 16384); stracpy(_guideCurved37_var._type, "Guide", 16384); _guideCurved37_var._index=42; int current_setpos_index = 42; _guideCurved37_var._parameters.reflect[0]='\0'; _guideCurved37_var._parameters.w1 = 0.03; _guideCurved37_var._parameters.h1 = 0.12; _guideCurved37_var._parameters.w2 = 0.03; _guideCurved37_var._parameters.h2 = 0.12; _guideCurved37_var._parameters.l = 0.499995; _guideCurved37_var._parameters.R0 = R0; _guideCurved37_var._parameters.Qc = Qc; _guideCurved37_var._parameters.alpha = ALPHA; _guideCurved37_var._parameters.m = M; _guideCurved37_var._parameters.W = W; /* component guideCurved37=Guide() AT ROTATED */ { Coords tc1, tc2; tc1 = coords_set(0,0,0); tc2 = coords_set(0,0,0); Rotation tr1; rot_set_rotation(tr1,0,0,0); rot_set_rotation(tr1, (0)*DEG2RAD, (angleGuideCurved)*DEG2RAD, (0)*DEG2RAD); rot_mul(tr1, _guideCurved36_var._rotation_absolute, _guideCurved37_var._rotation_absolute); rot_transpose(_guideCurved36_var._rotation_absolute, tr1); rot_mul(_guideCurved37_var._rotation_absolute, tr1, _guideCurved37_var._rotation_relative); _guideCurved37_var._rotation_is_identity = rot_test_identity(_guideCurved37_var._rotation_relative); tc1 = coords_set( 0, 0, 0.5); rot_transpose(_guideCurved36_var._rotation_absolute, tr1); tc2 = rot_apply(tr1, tc1); _guideCurved37_var._position_absolute = coords_add(_guideCurved36_var._position_absolute, tc2); tc1 = coords_sub(_guideCurved36_var._position_absolute, _guideCurved37_var._position_absolute); _guideCurved37_var._position_relative = rot_apply(_guideCurved37_var._rotation_absolute, tc1); } /* guideCurved37=Guide() AT ROTATED */ DEBUG_COMPONENT("guideCurved37", _guideCurved37_var._position_absolute, _guideCurved37_var._rotation_absolute); instrument->_position_absolute[42] = _guideCurved37_var._position_absolute; instrument->_position_relative[42] = _guideCurved37_var._position_relative; _guideCurved37_var._position_relative_is_zero = coords_test_zero(_guideCurved37_var._position_relative); instrument->counter_N[42] = instrument->counter_P[42] = instrument->counter_P2[42] = 0; instrument->counter_AbsorbProp[42]= 0; #ifdef USE_NEXUS if(nxhandle) { if ((!mcdotrace) && mcformat && strcasestr(mcformat, "NeXus")) { MPI_MASTER( mccomp_placement_type_nexus(nxhandle,"0041_guideCurved37", _guideCurved37_var._position_absolute, _guideCurved37_var._rotation_absolute, "Guide"); mccomp_param_nexus(nxhandle,"0041_guideCurved37", "reflect", 0, 0, "char*"); mccomp_param_nexus(nxhandle,"0041_guideCurved37", "w1", "NONE", "0.03","MCNUM"); mccomp_param_nexus(nxhandle,"0041_guideCurved37", "h1", "NONE", "0.12","MCNUM"); mccomp_param_nexus(nxhandle,"0041_guideCurved37", "w2", "0", "0.03","MCNUM"); mccomp_param_nexus(nxhandle,"0041_guideCurved37", "h2", "0", "0.12","MCNUM"); mccomp_param_nexus(nxhandle,"0041_guideCurved37", "l", "NONE", "0.499995","MCNUM"); mccomp_param_nexus(nxhandle,"0041_guideCurved37", "R0", "0.99", "R0","MCNUM"); mccomp_param_nexus(nxhandle,"0041_guideCurved37", "Qc", "0.0219", "Qc","MCNUM"); mccomp_param_nexus(nxhandle,"0041_guideCurved37", "alpha", "6.07", "ALPHA","MCNUM"); mccomp_param_nexus(nxhandle,"0041_guideCurved37", "m", "2", "M","MCNUM"); mccomp_param_nexus(nxhandle,"0041_guideCurved37", "W", "0.003", "W","MCNUM"); ); } } else { // fprintf(stderr,"NO NEXUS FILE"); } #endif return(0); } /* _guideCurved37_setpos */ /* component guideCurved38=Guide() SETTING, POSITION/ROTATION */ int _guideCurved38_setpos(void) { /* sets initial component parameters, position and rotation */ SIG_MESSAGE("[_guideCurved38_setpos] component guideCurved38=Guide() SETTING [Guide:0]"); stracpy(_guideCurved38_var._name, "guideCurved38", 16384); stracpy(_guideCurved38_var._type, "Guide", 16384); _guideCurved38_var._index=43; int current_setpos_index = 43; _guideCurved38_var._parameters.reflect[0]='\0'; _guideCurved38_var._parameters.w1 = 0.03; _guideCurved38_var._parameters.h1 = 0.12; _guideCurved38_var._parameters.w2 = 0.03; _guideCurved38_var._parameters.h2 = 0.12; _guideCurved38_var._parameters.l = 0.499995; _guideCurved38_var._parameters.R0 = R0; _guideCurved38_var._parameters.Qc = Qc; _guideCurved38_var._parameters.alpha = ALPHA; _guideCurved38_var._parameters.m = M; _guideCurved38_var._parameters.W = W; /* component guideCurved38=Guide() AT ROTATED */ { Coords tc1, tc2; tc1 = coords_set(0,0,0); tc2 = coords_set(0,0,0); Rotation tr1; rot_set_rotation(tr1,0,0,0); rot_set_rotation(tr1, (0)*DEG2RAD, (angleGuideCurved)*DEG2RAD, (0)*DEG2RAD); rot_mul(tr1, _guideCurved37_var._rotation_absolute, _guideCurved38_var._rotation_absolute); rot_transpose(_guideCurved37_var._rotation_absolute, tr1); rot_mul(_guideCurved38_var._rotation_absolute, tr1, _guideCurved38_var._rotation_relative); _guideCurved38_var._rotation_is_identity = rot_test_identity(_guideCurved38_var._rotation_relative); tc1 = coords_set( 0, 0, 0.5); rot_transpose(_guideCurved37_var._rotation_absolute, tr1); tc2 = rot_apply(tr1, tc1); _guideCurved38_var._position_absolute = coords_add(_guideCurved37_var._position_absolute, tc2); tc1 = coords_sub(_guideCurved37_var._position_absolute, _guideCurved38_var._position_absolute); _guideCurved38_var._position_relative = rot_apply(_guideCurved38_var._rotation_absolute, tc1); } /* guideCurved38=Guide() AT ROTATED */ DEBUG_COMPONENT("guideCurved38", _guideCurved38_var._position_absolute, _guideCurved38_var._rotation_absolute); instrument->_position_absolute[43] = _guideCurved38_var._position_absolute; instrument->_position_relative[43] = _guideCurved38_var._position_relative; _guideCurved38_var._position_relative_is_zero = coords_test_zero(_guideCurved38_var._position_relative); instrument->counter_N[43] = instrument->counter_P[43] = instrument->counter_P2[43] = 0; instrument->counter_AbsorbProp[43]= 0; #ifdef USE_NEXUS if(nxhandle) { if ((!mcdotrace) && mcformat && strcasestr(mcformat, "NeXus")) { MPI_MASTER( mccomp_placement_type_nexus(nxhandle,"0042_guideCurved38", _guideCurved38_var._position_absolute, _guideCurved38_var._rotation_absolute, "Guide"); mccomp_param_nexus(nxhandle,"0042_guideCurved38", "reflect", 0, 0, "char*"); mccomp_param_nexus(nxhandle,"0042_guideCurved38", "w1", "NONE", "0.03","MCNUM"); mccomp_param_nexus(nxhandle,"0042_guideCurved38", "h1", "NONE", "0.12","MCNUM"); mccomp_param_nexus(nxhandle,"0042_guideCurved38", "w2", "0", "0.03","MCNUM"); mccomp_param_nexus(nxhandle,"0042_guideCurved38", "h2", "0", "0.12","MCNUM"); mccomp_param_nexus(nxhandle,"0042_guideCurved38", "l", "NONE", "0.499995","MCNUM"); mccomp_param_nexus(nxhandle,"0042_guideCurved38", "R0", "0.99", "R0","MCNUM"); mccomp_param_nexus(nxhandle,"0042_guideCurved38", "Qc", "0.0219", "Qc","MCNUM"); mccomp_param_nexus(nxhandle,"0042_guideCurved38", "alpha", "6.07", "ALPHA","MCNUM"); mccomp_param_nexus(nxhandle,"0042_guideCurved38", "m", "2", "M","MCNUM"); mccomp_param_nexus(nxhandle,"0042_guideCurved38", "W", "0.003", "W","MCNUM"); ); } } else { // fprintf(stderr,"NO NEXUS FILE"); } #endif return(0); } /* _guideCurved38_setpos */ /* component guideCurved39=Guide() SETTING, POSITION/ROTATION */ int _guideCurved39_setpos(void) { /* sets initial component parameters, position and rotation */ SIG_MESSAGE("[_guideCurved39_setpos] component guideCurved39=Guide() SETTING [Guide:0]"); stracpy(_guideCurved39_var._name, "guideCurved39", 16384); stracpy(_guideCurved39_var._type, "Guide", 16384); _guideCurved39_var._index=44; int current_setpos_index = 44; _guideCurved39_var._parameters.reflect[0]='\0'; _guideCurved39_var._parameters.w1 = 0.03; _guideCurved39_var._parameters.h1 = 0.12; _guideCurved39_var._parameters.w2 = 0.03; _guideCurved39_var._parameters.h2 = 0.12; _guideCurved39_var._parameters.l = 0.499995; _guideCurved39_var._parameters.R0 = R0; _guideCurved39_var._parameters.Qc = Qc; _guideCurved39_var._parameters.alpha = ALPHA; _guideCurved39_var._parameters.m = M; _guideCurved39_var._parameters.W = W; /* component guideCurved39=Guide() AT ROTATED */ { Coords tc1, tc2; tc1 = coords_set(0,0,0); tc2 = coords_set(0,0,0); Rotation tr1; rot_set_rotation(tr1,0,0,0); rot_set_rotation(tr1, (0)*DEG2RAD, (angleGuideCurved)*DEG2RAD, (0)*DEG2RAD); rot_mul(tr1, _guideCurved38_var._rotation_absolute, _guideCurved39_var._rotation_absolute); rot_transpose(_guideCurved38_var._rotation_absolute, tr1); rot_mul(_guideCurved39_var._rotation_absolute, tr1, _guideCurved39_var._rotation_relative); _guideCurved39_var._rotation_is_identity = rot_test_identity(_guideCurved39_var._rotation_relative); tc1 = coords_set( 0, 0, 0.5); rot_transpose(_guideCurved38_var._rotation_absolute, tr1); tc2 = rot_apply(tr1, tc1); _guideCurved39_var._position_absolute = coords_add(_guideCurved38_var._position_absolute, tc2); tc1 = coords_sub(_guideCurved38_var._position_absolute, _guideCurved39_var._position_absolute); _guideCurved39_var._position_relative = rot_apply(_guideCurved39_var._rotation_absolute, tc1); } /* guideCurved39=Guide() AT ROTATED */ DEBUG_COMPONENT("guideCurved39", _guideCurved39_var._position_absolute, _guideCurved39_var._rotation_absolute); instrument->_position_absolute[44] = _guideCurved39_var._position_absolute; instrument->_position_relative[44] = _guideCurved39_var._position_relative; _guideCurved39_var._position_relative_is_zero = coords_test_zero(_guideCurved39_var._position_relative); instrument->counter_N[44] = instrument->counter_P[44] = instrument->counter_P2[44] = 0; instrument->counter_AbsorbProp[44]= 0; #ifdef USE_NEXUS if(nxhandle) { if ((!mcdotrace) && mcformat && strcasestr(mcformat, "NeXus")) { MPI_MASTER( mccomp_placement_type_nexus(nxhandle,"0043_guideCurved39", _guideCurved39_var._position_absolute, _guideCurved39_var._rotation_absolute, "Guide"); mccomp_param_nexus(nxhandle,"0043_guideCurved39", "reflect", 0, 0, "char*"); mccomp_param_nexus(nxhandle,"0043_guideCurved39", "w1", "NONE", "0.03","MCNUM"); mccomp_param_nexus(nxhandle,"0043_guideCurved39", "h1", "NONE", "0.12","MCNUM"); mccomp_param_nexus(nxhandle,"0043_guideCurved39", "w2", "0", "0.03","MCNUM"); mccomp_param_nexus(nxhandle,"0043_guideCurved39", "h2", "0", "0.12","MCNUM"); mccomp_param_nexus(nxhandle,"0043_guideCurved39", "l", "NONE", "0.499995","MCNUM"); mccomp_param_nexus(nxhandle,"0043_guideCurved39", "R0", "0.99", "R0","MCNUM"); mccomp_param_nexus(nxhandle,"0043_guideCurved39", "Qc", "0.0219", "Qc","MCNUM"); mccomp_param_nexus(nxhandle,"0043_guideCurved39", "alpha", "6.07", "ALPHA","MCNUM"); mccomp_param_nexus(nxhandle,"0043_guideCurved39", "m", "2", "M","MCNUM"); mccomp_param_nexus(nxhandle,"0043_guideCurved39", "W", "0.003", "W","MCNUM"); ); } } else { // fprintf(stderr,"NO NEXUS FILE"); } #endif return(0); } /* _guideCurved39_setpos */ /* component guideCurved40=Guide() SETTING, POSITION/ROTATION */ int _guideCurved40_setpos(void) { /* sets initial component parameters, position and rotation */ SIG_MESSAGE("[_guideCurved40_setpos] component guideCurved40=Guide() SETTING [Guide:0]"); stracpy(_guideCurved40_var._name, "guideCurved40", 16384); stracpy(_guideCurved40_var._type, "Guide", 16384); _guideCurved40_var._index=45; int current_setpos_index = 45; _guideCurved40_var._parameters.reflect[0]='\0'; _guideCurved40_var._parameters.w1 = 0.03; _guideCurved40_var._parameters.h1 = 0.12; _guideCurved40_var._parameters.w2 = 0.03; _guideCurved40_var._parameters.h2 = 0.12; _guideCurved40_var._parameters.l = 0.499995; _guideCurved40_var._parameters.R0 = R0; _guideCurved40_var._parameters.Qc = Qc; _guideCurved40_var._parameters.alpha = ALPHA; _guideCurved40_var._parameters.m = M; _guideCurved40_var._parameters.W = W; /* component guideCurved40=Guide() AT ROTATED */ { Coords tc1, tc2; tc1 = coords_set(0,0,0); tc2 = coords_set(0,0,0); Rotation tr1; rot_set_rotation(tr1,0,0,0); rot_set_rotation(tr1, (0)*DEG2RAD, (angleGuideCurved)*DEG2RAD, (0)*DEG2RAD); rot_mul(tr1, _guideCurved39_var._rotation_absolute, _guideCurved40_var._rotation_absolute); rot_transpose(_guideCurved39_var._rotation_absolute, tr1); rot_mul(_guideCurved40_var._rotation_absolute, tr1, _guideCurved40_var._rotation_relative); _guideCurved40_var._rotation_is_identity = rot_test_identity(_guideCurved40_var._rotation_relative); tc1 = coords_set( 0, 0, 0.5); rot_transpose(_guideCurved39_var._rotation_absolute, tr1); tc2 = rot_apply(tr1, tc1); _guideCurved40_var._position_absolute = coords_add(_guideCurved39_var._position_absolute, tc2); tc1 = coords_sub(_guideCurved39_var._position_absolute, _guideCurved40_var._position_absolute); _guideCurved40_var._position_relative = rot_apply(_guideCurved40_var._rotation_absolute, tc1); } /* guideCurved40=Guide() AT ROTATED */ DEBUG_COMPONENT("guideCurved40", _guideCurved40_var._position_absolute, _guideCurved40_var._rotation_absolute); instrument->_position_absolute[45] = _guideCurved40_var._position_absolute; instrument->_position_relative[45] = _guideCurved40_var._position_relative; _guideCurved40_var._position_relative_is_zero = coords_test_zero(_guideCurved40_var._position_relative); instrument->counter_N[45] = instrument->counter_P[45] = instrument->counter_P2[45] = 0; instrument->counter_AbsorbProp[45]= 0; #ifdef USE_NEXUS if(nxhandle) { if ((!mcdotrace) && mcformat && strcasestr(mcformat, "NeXus")) { MPI_MASTER( mccomp_placement_type_nexus(nxhandle,"0044_guideCurved40", _guideCurved40_var._position_absolute, _guideCurved40_var._rotation_absolute, "Guide"); mccomp_param_nexus(nxhandle,"0044_guideCurved40", "reflect", 0, 0, "char*"); mccomp_param_nexus(nxhandle,"0044_guideCurved40", "w1", "NONE", "0.03","MCNUM"); mccomp_param_nexus(nxhandle,"0044_guideCurved40", "h1", "NONE", "0.12","MCNUM"); mccomp_param_nexus(nxhandle,"0044_guideCurved40", "w2", "0", "0.03","MCNUM"); mccomp_param_nexus(nxhandle,"0044_guideCurved40", "h2", "0", "0.12","MCNUM"); mccomp_param_nexus(nxhandle,"0044_guideCurved40", "l", "NONE", "0.499995","MCNUM"); mccomp_param_nexus(nxhandle,"0044_guideCurved40", "R0", "0.99", "R0","MCNUM"); mccomp_param_nexus(nxhandle,"0044_guideCurved40", "Qc", "0.0219", "Qc","MCNUM"); mccomp_param_nexus(nxhandle,"0044_guideCurved40", "alpha", "6.07", "ALPHA","MCNUM"); mccomp_param_nexus(nxhandle,"0044_guideCurved40", "m", "2", "M","MCNUM"); mccomp_param_nexus(nxhandle,"0044_guideCurved40", "W", "0.003", "W","MCNUM"); ); } } else { // fprintf(stderr,"NO NEXUS FILE"); } #endif return(0); } /* _guideCurved40_setpos */ /* component bunker=Guide() SETTING, POSITION/ROTATION */ int _bunker_setpos(void) { /* sets initial component parameters, position and rotation */ SIG_MESSAGE("[_bunker_setpos] component bunker=Guide() SETTING [Guide:0]"); stracpy(_bunker_var._name, "bunker", 16384); stracpy(_bunker_var._type, "Guide", 16384); _bunker_var._index=46; int current_setpos_index = 46; _bunker_var._parameters.reflect[0]='\0'; _bunker_var._parameters.w1 = 0.03; _bunker_var._parameters.h1 = 0.12; _bunker_var._parameters.w2 = 0.03; _bunker_var._parameters.h2 = 0.12; _bunker_var._parameters.l = 3.45; _bunker_var._parameters.R0 = R0; _bunker_var._parameters.Qc = Qc; _bunker_var._parameters.alpha = ALPHA; _bunker_var._parameters.m = M; _bunker_var._parameters.W = W; /* component bunker=Guide() AT ROTATED */ { Coords tc1, tc2; tc1 = coords_set(0,0,0); tc2 = coords_set(0,0,0); Rotation tr1; rot_set_rotation(tr1,0,0,0); rot_set_rotation(tr1, (0.0)*DEG2RAD, (0.0)*DEG2RAD, (0.0)*DEG2RAD); rot_mul(tr1, _guideCurved40_var._rotation_absolute, _bunker_var._rotation_absolute); rot_transpose(_guideCurved40_var._rotation_absolute, tr1); rot_mul(_bunker_var._rotation_absolute, tr1, _bunker_var._rotation_relative); _bunker_var._rotation_is_identity = rot_test_identity(_bunker_var._rotation_relative); tc1 = coords_set( 0, 0, 0.5); rot_transpose(_guideCurved40_var._rotation_absolute, tr1); tc2 = rot_apply(tr1, tc1); _bunker_var._position_absolute = coords_add(_guideCurved40_var._position_absolute, tc2); tc1 = coords_sub(_guideCurved40_var._position_absolute, _bunker_var._position_absolute); _bunker_var._position_relative = rot_apply(_bunker_var._rotation_absolute, tc1); } /* bunker=Guide() AT ROTATED */ DEBUG_COMPONENT("bunker", _bunker_var._position_absolute, _bunker_var._rotation_absolute); instrument->_position_absolute[46] = _bunker_var._position_absolute; instrument->_position_relative[46] = _bunker_var._position_relative; _bunker_var._position_relative_is_zero = coords_test_zero(_bunker_var._position_relative); instrument->counter_N[46] = instrument->counter_P[46] = instrument->counter_P2[46] = 0; instrument->counter_AbsorbProp[46]= 0; #ifdef USE_NEXUS if(nxhandle) { if ((!mcdotrace) && mcformat && strcasestr(mcformat, "NeXus")) { MPI_MASTER( mccomp_placement_type_nexus(nxhandle,"0045_bunker", _bunker_var._position_absolute, _bunker_var._rotation_absolute, "Guide"); mccomp_param_nexus(nxhandle,"0045_bunker", "reflect", 0, 0, "char*"); mccomp_param_nexus(nxhandle,"0045_bunker", "w1", "NONE", "0.03","MCNUM"); mccomp_param_nexus(nxhandle,"0045_bunker", "h1", "NONE", "0.12","MCNUM"); mccomp_param_nexus(nxhandle,"0045_bunker", "w2", "0", "0.03","MCNUM"); mccomp_param_nexus(nxhandle,"0045_bunker", "h2", "0", "0.12","MCNUM"); mccomp_param_nexus(nxhandle,"0045_bunker", "l", "NONE", "3.45","MCNUM"); mccomp_param_nexus(nxhandle,"0045_bunker", "R0", "0.99", "R0","MCNUM"); mccomp_param_nexus(nxhandle,"0045_bunker", "Qc", "0.0219", "Qc","MCNUM"); mccomp_param_nexus(nxhandle,"0045_bunker", "alpha", "6.07", "ALPHA","MCNUM"); mccomp_param_nexus(nxhandle,"0045_bunker", "m", "2", "M","MCNUM"); mccomp_param_nexus(nxhandle,"0045_bunker", "W", "0.003", "W","MCNUM"); ); } } else { // fprintf(stderr,"NO NEXUS FILE"); } #endif return(0); } /* _bunker_setpos */ /* component guide3=Guide() SETTING, POSITION/ROTATION */ int _guide3_setpos(void) { /* sets initial component parameters, position and rotation */ SIG_MESSAGE("[_guide3_setpos] component guide3=Guide() SETTING [Guide:0]"); stracpy(_guide3_var._name, "guide3", 16384); stracpy(_guide3_var._type, "Guide", 16384); _guide3_var._index=47; int current_setpos_index = 47; _guide3_var._parameters.reflect[0]='\0'; _guide3_var._parameters.w1 = 0.03; _guide3_var._parameters.h1 = 0.12; _guide3_var._parameters.w2 = 0.03; _guide3_var._parameters.h2 = 0.12; _guide3_var._parameters.l = 5.2; _guide3_var._parameters.R0 = R0; _guide3_var._parameters.Qc = Qc; _guide3_var._parameters.alpha = ALPHA; _guide3_var._parameters.m = M; _guide3_var._parameters.W = W; /* component guide3=Guide() AT ROTATED */ { Coords tc1, tc2; tc1 = coords_set(0,0,0); tc2 = coords_set(0,0,0); Rotation tr1; rot_set_rotation(tr1,0,0,0); rot_set_rotation(tr1, (0.0)*DEG2RAD, (0.0)*DEG2RAD, (0.0)*DEG2RAD); rot_mul(tr1, _bunker_var._rotation_absolute, _guide3_var._rotation_absolute); rot_transpose(_bunker_var._rotation_absolute, tr1); rot_mul(_guide3_var._rotation_absolute, tr1, _guide3_var._rotation_relative); _guide3_var._rotation_is_identity = rot_test_identity(_guide3_var._rotation_relative); tc1 = coords_set( 0, 0, 3.6); rot_transpose(_bunker_var._rotation_absolute, tr1); tc2 = rot_apply(tr1, tc1); _guide3_var._position_absolute = coords_add(_bunker_var._position_absolute, tc2); tc1 = coords_sub(_bunker_var._position_absolute, _guide3_var._position_absolute); _guide3_var._position_relative = rot_apply(_guide3_var._rotation_absolute, tc1); } /* guide3=Guide() AT ROTATED */ DEBUG_COMPONENT("guide3", _guide3_var._position_absolute, _guide3_var._rotation_absolute); instrument->_position_absolute[47] = _guide3_var._position_absolute; instrument->_position_relative[47] = _guide3_var._position_relative; _guide3_var._position_relative_is_zero = coords_test_zero(_guide3_var._position_relative); instrument->counter_N[47] = instrument->counter_P[47] = instrument->counter_P2[47] = 0; instrument->counter_AbsorbProp[47]= 0; #ifdef USE_NEXUS if(nxhandle) { if ((!mcdotrace) && mcformat && strcasestr(mcformat, "NeXus")) { MPI_MASTER( mccomp_placement_type_nexus(nxhandle,"0046_guide3", _guide3_var._position_absolute, _guide3_var._rotation_absolute, "Guide"); mccomp_param_nexus(nxhandle,"0046_guide3", "reflect", 0, 0, "char*"); mccomp_param_nexus(nxhandle,"0046_guide3", "w1", "NONE", "0.03","MCNUM"); mccomp_param_nexus(nxhandle,"0046_guide3", "h1", "NONE", "0.12","MCNUM"); mccomp_param_nexus(nxhandle,"0046_guide3", "w2", "0", "0.03","MCNUM"); mccomp_param_nexus(nxhandle,"0046_guide3", "h2", "0", "0.12","MCNUM"); mccomp_param_nexus(nxhandle,"0046_guide3", "l", "NONE", "5.2","MCNUM"); mccomp_param_nexus(nxhandle,"0046_guide3", "R0", "0.99", "R0","MCNUM"); mccomp_param_nexus(nxhandle,"0046_guide3", "Qc", "0.0219", "Qc","MCNUM"); mccomp_param_nexus(nxhandle,"0046_guide3", "alpha", "6.07", "ALPHA","MCNUM"); mccomp_param_nexus(nxhandle,"0046_guide3", "m", "2", "M","MCNUM"); mccomp_param_nexus(nxhandle,"0046_guide3", "W", "0.003", "W","MCNUM"); ); } } else { // fprintf(stderr,"NO NEXUS FILE"); } #endif return(0); } /* _guide3_setpos */ /* component slitGuideEnd=Slit() SETTING, POSITION/ROTATION */ int _slitGuideEnd_setpos(void) { /* sets initial component parameters, position and rotation */ SIG_MESSAGE("[_slitGuideEnd_setpos] component slitGuideEnd=Slit() SETTING [Slit:0]"); stracpy(_slitGuideEnd_var._name, "slitGuideEnd", 16384); stracpy(_slitGuideEnd_var._type, "Slit", 16384); _slitGuideEnd_var._index=48; int current_setpos_index = 48; _slitGuideEnd_var._parameters.xmin = -0.016; _slitGuideEnd_var._parameters.xmax = 0.016; _slitGuideEnd_var._parameters.ymin = -0.061; _slitGuideEnd_var._parameters.ymax = 0.061; _slitGuideEnd_var._parameters.radius = UNSET; _slitGuideEnd_var._parameters.xwidth = UNSET; _slitGuideEnd_var._parameters.yheight = UNSET; /* component slitGuideEnd=Slit() AT ROTATED */ { Coords tc1, tc2; tc1 = coords_set(0,0,0); tc2 = coords_set(0,0,0); Rotation tr1; rot_set_rotation(tr1,0,0,0); rot_set_rotation(tr1, (0.0)*DEG2RAD, (0.0)*DEG2RAD, (0.0)*DEG2RAD); rot_mul(tr1, _guide3_var._rotation_absolute, _slitGuideEnd_var._rotation_absolute); rot_transpose(_guide3_var._rotation_absolute, tr1); rot_mul(_slitGuideEnd_var._rotation_absolute, tr1, _slitGuideEnd_var._rotation_relative); _slitGuideEnd_var._rotation_is_identity = rot_test_identity(_slitGuideEnd_var._rotation_relative); tc1 = coords_set( 0, 0, 5.2001); rot_transpose(_guide3_var._rotation_absolute, tr1); tc2 = rot_apply(tr1, tc1); _slitGuideEnd_var._position_absolute = coords_add(_guide3_var._position_absolute, tc2); tc1 = coords_sub(_guide3_var._position_absolute, _slitGuideEnd_var._position_absolute); _slitGuideEnd_var._position_relative = rot_apply(_slitGuideEnd_var._rotation_absolute, tc1); } /* slitGuideEnd=Slit() AT ROTATED */ DEBUG_COMPONENT("slitGuideEnd", _slitGuideEnd_var._position_absolute, _slitGuideEnd_var._rotation_absolute); instrument->_position_absolute[48] = _slitGuideEnd_var._position_absolute; instrument->_position_relative[48] = _slitGuideEnd_var._position_relative; _slitGuideEnd_var._position_relative_is_zero = coords_test_zero(_slitGuideEnd_var._position_relative); instrument->counter_N[48] = instrument->counter_P[48] = instrument->counter_P2[48] = 0; instrument->counter_AbsorbProp[48]= 0; #ifdef USE_NEXUS if(nxhandle) { if ((!mcdotrace) && mcformat && strcasestr(mcformat, "NeXus")) { MPI_MASTER( mccomp_placement_type_nexus(nxhandle,"0047_slitGuideEnd", _slitGuideEnd_var._position_absolute, _slitGuideEnd_var._rotation_absolute, "Slit"); mccomp_param_nexus(nxhandle,"0047_slitGuideEnd", "xmin", "UNSET", "-0.016","MCNUM"); mccomp_param_nexus(nxhandle,"0047_slitGuideEnd", "xmax", "UNSET", "0.016","MCNUM"); mccomp_param_nexus(nxhandle,"0047_slitGuideEnd", "ymin", "UNSET", "-0.061","MCNUM"); mccomp_param_nexus(nxhandle,"0047_slitGuideEnd", "ymax", "UNSET", "0.061","MCNUM"); mccomp_param_nexus(nxhandle,"0047_slitGuideEnd", "radius", "UNSET", "UNSET","MCNUM"); mccomp_param_nexus(nxhandle,"0047_slitGuideEnd", "xwidth", "UNSET", "UNSET","MCNUM"); mccomp_param_nexus(nxhandle,"0047_slitGuideEnd", "yheight", "UNSET", "UNSET","MCNUM"); ); } } else { // fprintf(stderr,"NO NEXUS FILE"); } #endif return(0); } /* _slitGuideEnd_setpos */ /* component psd_guide_end=PSD_monitor() SETTING, POSITION/ROTATION */ int _psd_guide_end_setpos(void) { /* sets initial component parameters, position and rotation */ SIG_MESSAGE("[_psd_guide_end_setpos] component psd_guide_end=PSD_monitor() SETTING [PSD_monitor:0]"); stracpy(_psd_guide_end_var._name, "psd_guide_end", 16384); stracpy(_psd_guide_end_var._type, "PSD_monitor", 16384); _psd_guide_end_var._index=49; int current_setpos_index = 49; _psd_guide_end_var._parameters.nx = 64; _psd_guide_end_var._parameters.ny = 64; if("psd_guide_end.dat" && strlen("psd_guide_end.dat")) stracpy(_psd_guide_end_var._parameters.filename, "psd_guide_end.dat" ? "psd_guide_end.dat" : "", 16384); else _psd_guide_end_var._parameters.filename[0]='\0'; _psd_guide_end_var._parameters.xmin = -0.05; _psd_guide_end_var._parameters.xmax = 0.05; _psd_guide_end_var._parameters.ymin = -0.05; _psd_guide_end_var._parameters.ymax = 0.05; _psd_guide_end_var._parameters.xwidth = 0.04; _psd_guide_end_var._parameters.yheight = 0.15; _psd_guide_end_var._parameters.restore_neutron = 1; _psd_guide_end_var._parameters.nowritefile = 0; /* component psd_guide_end=PSD_monitor() AT ROTATED */ { Coords tc1, tc2; tc1 = coords_set(0,0,0); tc2 = coords_set(0,0,0); Rotation tr1; rot_set_rotation(tr1,0,0,0); rot_set_rotation(tr1, (0.0)*DEG2RAD, (0.0)*DEG2RAD, (0.0)*DEG2RAD); rot_mul(tr1, _slitGuideEnd_var._rotation_absolute, _psd_guide_end_var._rotation_absolute); rot_transpose(_slitGuideEnd_var._rotation_absolute, tr1); rot_mul(_psd_guide_end_var._rotation_absolute, tr1, _psd_guide_end_var._rotation_relative); _psd_guide_end_var._rotation_is_identity = rot_test_identity(_psd_guide_end_var._rotation_relative); tc1 = coords_set( 0, 0, 0.04); rot_transpose(_slitGuideEnd_var._rotation_absolute, tr1); tc2 = rot_apply(tr1, tc1); _psd_guide_end_var._position_absolute = coords_add(_slitGuideEnd_var._position_absolute, tc2); tc1 = coords_sub(_slitGuideEnd_var._position_absolute, _psd_guide_end_var._position_absolute); _psd_guide_end_var._position_relative = rot_apply(_psd_guide_end_var._rotation_absolute, tc1); } /* psd_guide_end=PSD_monitor() AT ROTATED */ DEBUG_COMPONENT("psd_guide_end", _psd_guide_end_var._position_absolute, _psd_guide_end_var._rotation_absolute); instrument->_position_absolute[49] = _psd_guide_end_var._position_absolute; instrument->_position_relative[49] = _psd_guide_end_var._position_relative; _psd_guide_end_var._position_relative_is_zero = coords_test_zero(_psd_guide_end_var._position_relative); instrument->counter_N[49] = instrument->counter_P[49] = instrument->counter_P2[49] = 0; instrument->counter_AbsorbProp[49]= 0; #ifdef USE_NEXUS if(nxhandle) { if ((!mcdotrace) && mcformat && strcasestr(mcformat, "NeXus")) { MPI_MASTER( mccomp_placement_type_nexus(nxhandle,"0048_psd_guide_end", _psd_guide_end_var._position_absolute, _psd_guide_end_var._rotation_absolute, "PSD_monitor"); mccomp_param_nexus(nxhandle,"0048_psd_guide_end", "nx", "90", "64","int"); mccomp_param_nexus(nxhandle,"0048_psd_guide_end", "ny", "90", "64","int"); mccomp_param_nexus(nxhandle,"0048_psd_guide_end", "filename", 0, "psd_guide_end.dat", "char*"); mccomp_param_nexus(nxhandle,"0048_psd_guide_end", "xmin", "-0.05", "-0.05","MCNUM"); mccomp_param_nexus(nxhandle,"0048_psd_guide_end", "xmax", "0.05", "0.05","MCNUM"); mccomp_param_nexus(nxhandle,"0048_psd_guide_end", "ymin", "-0.05", "-0.05","MCNUM"); mccomp_param_nexus(nxhandle,"0048_psd_guide_end", "ymax", "0.05", "0.05","MCNUM"); mccomp_param_nexus(nxhandle,"0048_psd_guide_end", "xwidth", "0", "0.04","MCNUM"); mccomp_param_nexus(nxhandle,"0048_psd_guide_end", "yheight", "0", "0.15","MCNUM"); mccomp_param_nexus(nxhandle,"0048_psd_guide_end", "restore_neutron", "0", "1","int"); mccomp_param_nexus(nxhandle,"0048_psd_guide_end", "nowritefile", "0", "0","int"); ); } } else { // fprintf(stderr,"NO NEXUS FILE"); } #endif return(0); } /* _psd_guide_end_setpos */ /* component emon_guide_end=E_monitor() SETTING, POSITION/ROTATION */ int _emon_guide_end_setpos(void) { /* sets initial component parameters, position and rotation */ SIG_MESSAGE("[_emon_guide_end_setpos] component emon_guide_end=E_monitor() SETTING [E_monitor:0]"); stracpy(_emon_guide_end_var._name, "emon_guide_end", 16384); stracpy(_emon_guide_end_var._type, "E_monitor", 16384); _emon_guide_end_var._index=50; int current_setpos_index = 50; _emon_guide_end_var._parameters.nE = 100; if("emon_guide_end.dat" && strlen("emon_guide_end.dat")) stracpy(_emon_guide_end_var._parameters.filename, "emon_guide_end.dat" ? "emon_guide_end.dat" : "", 16384); else _emon_guide_end_var._parameters.filename[0]='\0'; _emon_guide_end_var._parameters.xmin = -0.05; _emon_guide_end_var._parameters.xmax = 0.05; _emon_guide_end_var._parameters.ymin = -0.05; _emon_guide_end_var._parameters.ymax = 0.05; _emon_guide_end_var._parameters.nowritefile = 0; _emon_guide_end_var._parameters.xwidth = 0.04; _emon_guide_end_var._parameters.yheight = 0.15; _emon_guide_end_var._parameters.Emin = emini; _emon_guide_end_var._parameters.Emax = emaxi; _emon_guide_end_var._parameters.restore_neutron = 1; /* component emon_guide_end=E_monitor() AT ROTATED */ { Coords tc1, tc2; tc1 = coords_set(0,0,0); tc2 = coords_set(0,0,0); Rotation tr1; rot_set_rotation(tr1,0,0,0); rot_set_rotation(tr1, (0.0)*DEG2RAD, (0.0)*DEG2RAD, (0.0)*DEG2RAD); rot_mul(tr1, _slitGuideEnd_var._rotation_absolute, _emon_guide_end_var._rotation_absolute); rot_transpose(_psd_guide_end_var._rotation_absolute, tr1); rot_mul(_emon_guide_end_var._rotation_absolute, tr1, _emon_guide_end_var._rotation_relative); _emon_guide_end_var._rotation_is_identity = rot_test_identity(_emon_guide_end_var._rotation_relative); tc1 = coords_set( 0, 0, 0.05); rot_transpose(_slitGuideEnd_var._rotation_absolute, tr1); tc2 = rot_apply(tr1, tc1); _emon_guide_end_var._position_absolute = coords_add(_slitGuideEnd_var._position_absolute, tc2); tc1 = coords_sub(_psd_guide_end_var._position_absolute, _emon_guide_end_var._position_absolute); _emon_guide_end_var._position_relative = rot_apply(_emon_guide_end_var._rotation_absolute, tc1); } /* emon_guide_end=E_monitor() AT ROTATED */ DEBUG_COMPONENT("emon_guide_end", _emon_guide_end_var._position_absolute, _emon_guide_end_var._rotation_absolute); instrument->_position_absolute[50] = _emon_guide_end_var._position_absolute; instrument->_position_relative[50] = _emon_guide_end_var._position_relative; _emon_guide_end_var._position_relative_is_zero = coords_test_zero(_emon_guide_end_var._position_relative); instrument->counter_N[50] = instrument->counter_P[50] = instrument->counter_P2[50] = 0; instrument->counter_AbsorbProp[50]= 0; #ifdef USE_NEXUS if(nxhandle) { if ((!mcdotrace) && mcformat && strcasestr(mcformat, "NeXus")) { MPI_MASTER( mccomp_placement_type_nexus(nxhandle,"0049_emon_guide_end", _emon_guide_end_var._position_absolute, _emon_guide_end_var._rotation_absolute, "E_monitor"); mccomp_param_nexus(nxhandle,"0049_emon_guide_end", "nE", "20", "100","int"); mccomp_param_nexus(nxhandle,"0049_emon_guide_end", "filename", 0, "emon_guide_end.dat", "char*"); mccomp_param_nexus(nxhandle,"0049_emon_guide_end", "xmin", "-0.05", "-0.05","MCNUM"); mccomp_param_nexus(nxhandle,"0049_emon_guide_end", "xmax", "0.05", "0.05","MCNUM"); mccomp_param_nexus(nxhandle,"0049_emon_guide_end", "ymin", "-0.05", "-0.05","MCNUM"); mccomp_param_nexus(nxhandle,"0049_emon_guide_end", "ymax", "0.05", "0.05","MCNUM"); mccomp_param_nexus(nxhandle,"0049_emon_guide_end", "nowritefile", "0", "0","int"); mccomp_param_nexus(nxhandle,"0049_emon_guide_end", "xwidth", "0", "0.04","MCNUM"); mccomp_param_nexus(nxhandle,"0049_emon_guide_end", "yheight", "0", "0.15","MCNUM"); mccomp_param_nexus(nxhandle,"0049_emon_guide_end", "Emin", "NONE", "emini","MCNUM"); mccomp_param_nexus(nxhandle,"0049_emon_guide_end", "Emax", "NONE", "emaxi","MCNUM"); mccomp_param_nexus(nxhandle,"0049_emon_guide_end", "restore_neutron", "0", "1","int"); ); } } else { // fprintf(stderr,"NO NEXUS FILE"); } #endif return(0); } /* _emon_guide_end_setpos */ /* component lmon_guide_end=L_monitor() SETTING, POSITION/ROTATION */ int _lmon_guide_end_setpos(void) { /* sets initial component parameters, position and rotation */ SIG_MESSAGE("[_lmon_guide_end_setpos] component lmon_guide_end=L_monitor() SETTING [L_monitor:0]"); stracpy(_lmon_guide_end_var._name, "lmon_guide_end", 16384); stracpy(_lmon_guide_end_var._type, "L_monitor", 16384); _lmon_guide_end_var._index=51; int current_setpos_index = 51; _lmon_guide_end_var._parameters.nL = 100; if("lmon_guide_end.dat" && strlen("lmon_guide_end.dat")) stracpy(_lmon_guide_end_var._parameters.filename, "lmon_guide_end.dat" ? "lmon_guide_end.dat" : "", 16384); else _lmon_guide_end_var._parameters.filename[0]='\0'; _lmon_guide_end_var._parameters.nowritefile = 0; _lmon_guide_end_var._parameters.xmin = -0.05; _lmon_guide_end_var._parameters.xmax = 0.05; _lmon_guide_end_var._parameters.ymin = -0.05; _lmon_guide_end_var._parameters.ymax = 0.05; _lmon_guide_end_var._parameters.xwidth = 0.04; _lmon_guide_end_var._parameters.yheight = 0.15; _lmon_guide_end_var._parameters.Lmin = lmin; _lmon_guide_end_var._parameters.Lmax = lmax; _lmon_guide_end_var._parameters.restore_neutron = 1; /* component lmon_guide_end=L_monitor() AT ROTATED */ { Coords tc1, tc2; tc1 = coords_set(0,0,0); tc2 = coords_set(0,0,0); Rotation tr1; rot_set_rotation(tr1,0,0,0); rot_set_rotation(tr1, (0.0)*DEG2RAD, (0.0)*DEG2RAD, (0.0)*DEG2RAD); rot_mul(tr1, _slitGuideEnd_var._rotation_absolute, _lmon_guide_end_var._rotation_absolute); rot_transpose(_emon_guide_end_var._rotation_absolute, tr1); rot_mul(_lmon_guide_end_var._rotation_absolute, tr1, _lmon_guide_end_var._rotation_relative); _lmon_guide_end_var._rotation_is_identity = rot_test_identity(_lmon_guide_end_var._rotation_relative); tc1 = coords_set( 0, 0, 0.06); rot_transpose(_slitGuideEnd_var._rotation_absolute, tr1); tc2 = rot_apply(tr1, tc1); _lmon_guide_end_var._position_absolute = coords_add(_slitGuideEnd_var._position_absolute, tc2); tc1 = coords_sub(_emon_guide_end_var._position_absolute, _lmon_guide_end_var._position_absolute); _lmon_guide_end_var._position_relative = rot_apply(_lmon_guide_end_var._rotation_absolute, tc1); } /* lmon_guide_end=L_monitor() AT ROTATED */ DEBUG_COMPONENT("lmon_guide_end", _lmon_guide_end_var._position_absolute, _lmon_guide_end_var._rotation_absolute); instrument->_position_absolute[51] = _lmon_guide_end_var._position_absolute; instrument->_position_relative[51] = _lmon_guide_end_var._position_relative; _lmon_guide_end_var._position_relative_is_zero = coords_test_zero(_lmon_guide_end_var._position_relative); instrument->counter_N[51] = instrument->counter_P[51] = instrument->counter_P2[51] = 0; instrument->counter_AbsorbProp[51]= 0; #ifdef USE_NEXUS if(nxhandle) { if ((!mcdotrace) && mcformat && strcasestr(mcformat, "NeXus")) { MPI_MASTER( mccomp_placement_type_nexus(nxhandle,"0050_lmon_guide_end", _lmon_guide_end_var._position_absolute, _lmon_guide_end_var._rotation_absolute, "L_monitor"); mccomp_param_nexus(nxhandle,"0050_lmon_guide_end", "nL", "20", "100","int"); mccomp_param_nexus(nxhandle,"0050_lmon_guide_end", "filename", 0, "lmon_guide_end.dat", "char*"); mccomp_param_nexus(nxhandle,"0050_lmon_guide_end", "nowritefile", "0", "0","int"); mccomp_param_nexus(nxhandle,"0050_lmon_guide_end", "xmin", "-0.05", "-0.05","MCNUM"); mccomp_param_nexus(nxhandle,"0050_lmon_guide_end", "xmax", "0.05", "0.05","MCNUM"); mccomp_param_nexus(nxhandle,"0050_lmon_guide_end", "ymin", "-0.05", "-0.05","MCNUM"); mccomp_param_nexus(nxhandle,"0050_lmon_guide_end", "ymax", "0.05", "0.05","MCNUM"); mccomp_param_nexus(nxhandle,"0050_lmon_guide_end", "xwidth", "0", "0.04","MCNUM"); mccomp_param_nexus(nxhandle,"0050_lmon_guide_end", "yheight", "0", "0.15","MCNUM"); mccomp_param_nexus(nxhandle,"0050_lmon_guide_end", "Lmin", "NONE", "lmin","MCNUM"); mccomp_param_nexus(nxhandle,"0050_lmon_guide_end", "Lmax", "NONE", "lmax","MCNUM"); mccomp_param_nexus(nxhandle,"0050_lmon_guide_end", "restore_neutron", "0", "1","int"); ); } } else { // fprintf(stderr,"NO NEXUS FILE"); } #endif return(0); } /* _lmon_guide_end_setpos */ /* component divmon_guide_end=Divergence_monitor() SETTING, POSITION/ROTATION */ int _divmon_guide_end_setpos(void) { /* sets initial component parameters, position and rotation */ SIG_MESSAGE("[_divmon_guide_end_setpos] component divmon_guide_end=Divergence_monitor() SETTING [Divergence_monitor:0]"); stracpy(_divmon_guide_end_var._name, "divmon_guide_end", 16384); stracpy(_divmon_guide_end_var._type, "Divergence_monitor", 16384); _divmon_guide_end_var._index=52; int current_setpos_index = 52; _divmon_guide_end_var._parameters.nh = 128; _divmon_guide_end_var._parameters.nv = 128; if("divmon_guide_end.dat" && strlen("divmon_guide_end.dat")) stracpy(_divmon_guide_end_var._parameters.filename, "divmon_guide_end.dat" ? "divmon_guide_end.dat" : "", 16384); else _divmon_guide_end_var._parameters.filename[0]='\0'; _divmon_guide_end_var._parameters.xmin = -0.05; _divmon_guide_end_var._parameters.xmax = 0.05; _divmon_guide_end_var._parameters.ymin = -0.05; _divmon_guide_end_var._parameters.ymax = 0.05; _divmon_guide_end_var._parameters.nowritefile = 0; _divmon_guide_end_var._parameters.xwidth = 0.04; _divmon_guide_end_var._parameters.yheight = 0.15; _divmon_guide_end_var._parameters.maxdiv_h = 2; _divmon_guide_end_var._parameters.maxdiv_v = 2; _divmon_guide_end_var._parameters.restore_neutron = 1; _divmon_guide_end_var._parameters.nx = 0; _divmon_guide_end_var._parameters.ny = 0; _divmon_guide_end_var._parameters.nz = 1; /* component divmon_guide_end=Divergence_monitor() AT ROTATED */ { Coords tc1, tc2; tc1 = coords_set(0,0,0); tc2 = coords_set(0,0,0); Rotation tr1; rot_set_rotation(tr1,0,0,0); rot_set_rotation(tr1, (0.0)*DEG2RAD, (0.0)*DEG2RAD, (0.0)*DEG2RAD); rot_mul(tr1, _slitGuideEnd_var._rotation_absolute, _divmon_guide_end_var._rotation_absolute); rot_transpose(_lmon_guide_end_var._rotation_absolute, tr1); rot_mul(_divmon_guide_end_var._rotation_absolute, tr1, _divmon_guide_end_var._rotation_relative); _divmon_guide_end_var._rotation_is_identity = rot_test_identity(_divmon_guide_end_var._rotation_relative); tc1 = coords_set( 0, 0, 0.07); rot_transpose(_slitGuideEnd_var._rotation_absolute, tr1); tc2 = rot_apply(tr1, tc1); _divmon_guide_end_var._position_absolute = coords_add(_slitGuideEnd_var._position_absolute, tc2); tc1 = coords_sub(_lmon_guide_end_var._position_absolute, _divmon_guide_end_var._position_absolute); _divmon_guide_end_var._position_relative = rot_apply(_divmon_guide_end_var._rotation_absolute, tc1); } /* divmon_guide_end=Divergence_monitor() AT ROTATED */ DEBUG_COMPONENT("divmon_guide_end", _divmon_guide_end_var._position_absolute, _divmon_guide_end_var._rotation_absolute); instrument->_position_absolute[52] = _divmon_guide_end_var._position_absolute; instrument->_position_relative[52] = _divmon_guide_end_var._position_relative; _divmon_guide_end_var._position_relative_is_zero = coords_test_zero(_divmon_guide_end_var._position_relative); instrument->counter_N[52] = instrument->counter_P[52] = instrument->counter_P2[52] = 0; instrument->counter_AbsorbProp[52]= 0; #ifdef USE_NEXUS if(nxhandle) { if ((!mcdotrace) && mcformat && strcasestr(mcformat, "NeXus")) { MPI_MASTER( mccomp_placement_type_nexus(nxhandle,"0051_divmon_guide_end", _divmon_guide_end_var._position_absolute, _divmon_guide_end_var._rotation_absolute, "Divergence_monitor"); mccomp_param_nexus(nxhandle,"0051_divmon_guide_end", "nh", "20", "128","int"); mccomp_param_nexus(nxhandle,"0051_divmon_guide_end", "nv", "20", "128","int"); mccomp_param_nexus(nxhandle,"0051_divmon_guide_end", "filename", 0, "divmon_guide_end.dat", "char*"); mccomp_param_nexus(nxhandle,"0051_divmon_guide_end", "xmin", "-0.05", "-0.05","MCNUM"); mccomp_param_nexus(nxhandle,"0051_divmon_guide_end", "xmax", "0.05", "0.05","MCNUM"); mccomp_param_nexus(nxhandle,"0051_divmon_guide_end", "ymin", "-0.05", "-0.05","MCNUM"); mccomp_param_nexus(nxhandle,"0051_divmon_guide_end", "ymax", "0.05", "0.05","MCNUM"); mccomp_param_nexus(nxhandle,"0051_divmon_guide_end", "nowritefile", "0", "0","int"); mccomp_param_nexus(nxhandle,"0051_divmon_guide_end", "xwidth", "0", "0.04","MCNUM"); mccomp_param_nexus(nxhandle,"0051_divmon_guide_end", "yheight", "0", "0.15","MCNUM"); mccomp_param_nexus(nxhandle,"0051_divmon_guide_end", "maxdiv_h", "2", "2","MCNUM"); mccomp_param_nexus(nxhandle,"0051_divmon_guide_end", "maxdiv_v", "2", "2","MCNUM"); mccomp_param_nexus(nxhandle,"0051_divmon_guide_end", "restore_neutron", "0", "1","int"); mccomp_param_nexus(nxhandle,"0051_divmon_guide_end", "nx", "0", "0","MCNUM"); mccomp_param_nexus(nxhandle,"0051_divmon_guide_end", "ny", "0", "0","MCNUM"); mccomp_param_nexus(nxhandle,"0051_divmon_guide_end", "nz", "1", "1","MCNUM"); ); } } else { // fprintf(stderr,"NO NEXUS FILE"); } #endif return(0); } /* _divmon_guide_end_setpos */ /* component focus_mono=Arm() SETTING, POSITION/ROTATION */ int _focus_mono_setpos(void) { /* sets initial component parameters, position and rotation */ SIG_MESSAGE("[_focus_mono_setpos] component focus_mono=Arm() SETTING [Arm:0]"); stracpy(_focus_mono_var._name, "focus_mono", 16384); stracpy(_focus_mono_var._type, "Arm", 16384); _focus_mono_var._index=53; int current_setpos_index = 53; /* component focus_mono=Arm() AT ROTATED */ { Coords tc1, tc2; tc1 = coords_set(0,0,0); tc2 = coords_set(0,0,0); Rotation tr1; rot_set_rotation(tr1,0,0,0); rot_set_rotation(tr1, (0)*DEG2RAD, (machine_real . a1)*DEG2RAD, (0)*DEG2RAD); rot_mul(tr1, _slitGuideEnd_var._rotation_absolute, _focus_mono_var._rotation_absolute); rot_transpose(_divmon_guide_end_var._rotation_absolute, tr1); rot_mul(_focus_mono_var._rotation_absolute, tr1, _focus_mono_var._rotation_relative); _focus_mono_var._rotation_is_identity = rot_test_identity(_focus_mono_var._rotation_relative); tc1 = coords_set( 0, 0, 0.15); rot_transpose(_slitGuideEnd_var._rotation_absolute, tr1); tc2 = rot_apply(tr1, tc1); _focus_mono_var._position_absolute = coords_add(_slitGuideEnd_var._position_absolute, tc2); tc1 = coords_sub(_divmon_guide_end_var._position_absolute, _focus_mono_var._position_absolute); _focus_mono_var._position_relative = rot_apply(_focus_mono_var._rotation_absolute, tc1); } /* focus_mono=Arm() AT ROTATED */ DEBUG_COMPONENT("focus_mono", _focus_mono_var._position_absolute, _focus_mono_var._rotation_absolute); instrument->_position_absolute[53] = _focus_mono_var._position_absolute; instrument->_position_relative[53] = _focus_mono_var._position_relative; _focus_mono_var._position_relative_is_zero = coords_test_zero(_focus_mono_var._position_relative); instrument->counter_N[53] = instrument->counter_P[53] = instrument->counter_P2[53] = 0; instrument->counter_AbsorbProp[53]= 0; #ifdef USE_NEXUS if(nxhandle) { if ((!mcdotrace) && mcformat && strcasestr(mcformat, "NeXus")) { MPI_MASTER( mccomp_placement_type_nexus(nxhandle,"0052_focus_mono", _focus_mono_var._position_absolute, _focus_mono_var._rotation_absolute, "Arm"); ); } } else { // fprintf(stderr,"NO NEXUS FILE"); } #endif return(0); } /* _focus_mono_setpos */ /* component monochromator_curved=Monochromator_curved() SETTING, POSITION/ROTATION */ int _monochromator_curved_setpos(void) { /* sets initial component parameters, position and rotation */ SIG_MESSAGE("[_monochromator_curved_setpos] component monochromator_curved=Monochromator_curved() SETTING [Monochromator_curved:0]"); stracpy(_monochromator_curved_var._name, "monochromator_curved", 16384); stracpy(_monochromator_curved_var._type, "Monochromator_curved", 16384); _monochromator_curved_var._index=54; int current_setpos_index = 54; if("HOPG.rfl" && strlen("HOPG.rfl")) stracpy(_monochromator_curved_var._parameters.reflect, "HOPG.rfl" ? "HOPG.rfl" : "", 16384); else _monochromator_curved_var._parameters.reflect[0]='\0'; if("NULL" && strlen("NULL")) stracpy(_monochromator_curved_var._parameters.transmit, "NULL" ? "NULL" : "", 16384); else _monochromator_curved_var._parameters.transmit[0]='\0'; _monochromator_curved_var._parameters.zwidth = 0.15; _monochromator_curved_var._parameters.yheight = 0.025; _monochromator_curved_var._parameters.gap = 0.001; _monochromator_curved_var._parameters.NH = 1; _monochromator_curved_var._parameters.NV = 5; _monochromator_curved_var._parameters.mosaich = mono_mosaic_h; _monochromator_curved_var._parameters.mosaicv = mono_mosaic_v; _monochromator_curved_var._parameters.r0 = 1; _monochromator_curved_var._parameters.t0 = 1.0; _monochromator_curved_var._parameters.Q = 1.8734; _monochromator_curved_var._parameters.RV = rv; _monochromator_curved_var._parameters.RH = 0; _monochromator_curved_var._parameters.DM = 0; _monochromator_curved_var._parameters.mosaic = 0; _monochromator_curved_var._parameters.width = 0; _monochromator_curved_var._parameters.height = 0; _monochromator_curved_var._parameters.verbose = 0; _monochromator_curved_var._parameters.order = 0; /* component monochromator_curved=Monochromator_curved() AT ROTATED */ { Coords tc1, tc2; tc1 = coords_set(0,0,0); tc2 = coords_set(0,0,0); Rotation tr1; rot_set_rotation(tr1,0,0,0); rot_set_rotation(tr1, (0.0)*DEG2RAD, (0.0)*DEG2RAD, (0.0)*DEG2RAD); rot_mul(tr1, _focus_mono_var._rotation_absolute, _monochromator_curved_var._rotation_absolute); rot_transpose(_focus_mono_var._rotation_absolute, tr1); rot_mul(_monochromator_curved_var._rotation_absolute, tr1, _monochromator_curved_var._rotation_relative); _monochromator_curved_var._rotation_is_identity = rot_test_identity(_monochromator_curved_var._rotation_relative); tc1 = coords_set( 0, 0, 0); rot_transpose(_focus_mono_var._rotation_absolute, tr1); tc2 = rot_apply(tr1, tc1); _monochromator_curved_var._position_absolute = coords_add(_focus_mono_var._position_absolute, tc2); tc1 = coords_sub(_focus_mono_var._position_absolute, _monochromator_curved_var._position_absolute); _monochromator_curved_var._position_relative = rot_apply(_monochromator_curved_var._rotation_absolute, tc1); } /* monochromator_curved=Monochromator_curved() AT ROTATED */ DEBUG_COMPONENT("monochromator_curved", _monochromator_curved_var._position_absolute, _monochromator_curved_var._rotation_absolute); instrument->_position_absolute[54] = _monochromator_curved_var._position_absolute; instrument->_position_relative[54] = _monochromator_curved_var._position_relative; _monochromator_curved_var._position_relative_is_zero = coords_test_zero(_monochromator_curved_var._position_relative); instrument->counter_N[54] = instrument->counter_P[54] = instrument->counter_P2[54] = 0; instrument->counter_AbsorbProp[54]= 0; #ifdef USE_NEXUS if(nxhandle) { if ((!mcdotrace) && mcformat && strcasestr(mcformat, "NeXus")) { MPI_MASTER( mccomp_placement_type_nexus(nxhandle,"0053_monochromator_curved", _monochromator_curved_var._position_absolute, _monochromator_curved_var._rotation_absolute, "Monochromator_curved"); mccomp_param_nexus(nxhandle,"0053_monochromator_curved", "reflect", "NULL", "HOPG.rfl", "char*"); mccomp_param_nexus(nxhandle,"0053_monochromator_curved", "transmit", "NULL", "NULL", "char*"); mccomp_param_nexus(nxhandle,"0053_monochromator_curved", "zwidth", "0.01", "0.15","MCNUM"); mccomp_param_nexus(nxhandle,"0053_monochromator_curved", "yheight", "0.01", "0.025","MCNUM"); mccomp_param_nexus(nxhandle,"0053_monochromator_curved", "gap", "0.0005", "0.001","MCNUM"); mccomp_param_nexus(nxhandle,"0053_monochromator_curved", "NH", "11", "1","int"); mccomp_param_nexus(nxhandle,"0053_monochromator_curved", "NV", "11", "5","int"); mccomp_param_nexus(nxhandle,"0053_monochromator_curved", "mosaich", "30.0", "mono_mosaic_h","MCNUM"); mccomp_param_nexus(nxhandle,"0053_monochromator_curved", "mosaicv", "30.0", "mono_mosaic_v","MCNUM"); mccomp_param_nexus(nxhandle,"0053_monochromator_curved", "r0", "0.7", "1","MCNUM"); mccomp_param_nexus(nxhandle,"0053_monochromator_curved", "t0", "1.0", "1.0","MCNUM"); mccomp_param_nexus(nxhandle,"0053_monochromator_curved", "Q", "1.8734", "1.8734","MCNUM"); mccomp_param_nexus(nxhandle,"0053_monochromator_curved", "RV", "0", "rv","MCNUM"); mccomp_param_nexus(nxhandle,"0053_monochromator_curved", "RH", "0", "0","MCNUM"); mccomp_param_nexus(nxhandle,"0053_monochromator_curved", "DM", "0", "0","MCNUM"); mccomp_param_nexus(nxhandle,"0053_monochromator_curved", "mosaic", "0", "0","MCNUM"); mccomp_param_nexus(nxhandle,"0053_monochromator_curved", "width", "0", "0","MCNUM"); mccomp_param_nexus(nxhandle,"0053_monochromator_curved", "height", "0", "0","MCNUM"); mccomp_param_nexus(nxhandle,"0053_monochromator_curved", "verbose", "0", "0","MCNUM"); mccomp_param_nexus(nxhandle,"0053_monochromator_curved", "order", "0", "0","MCNUM"); ); } } else { // fprintf(stderr,"NO NEXUS FILE"); } #endif return(0); } /* _monochromator_curved_setpos */ /* component a2=Arm() SETTING, POSITION/ROTATION */ int _a2_setpos(void) { /* sets initial component parameters, position and rotation */ SIG_MESSAGE("[_a2_setpos] component a2=Arm() SETTING [Arm:0]"); stracpy(_a2_var._name, "a2", 16384); stracpy(_a2_var._type, "Arm", 16384); _a2_var._index=55; int current_setpos_index = 55; /* component a2=Arm() AT ROTATED */ { Coords tc1, tc2; tc1 = coords_set(0,0,0); tc2 = coords_set(0,0,0); Rotation tr1; rot_set_rotation(tr1,0,0,0); rot_set_rotation(tr1, (0)*DEG2RAD, (machine_real . a2)*DEG2RAD, (0)*DEG2RAD); rot_mul(tr1, _slitGuideEnd_var._rotation_absolute, _a2_var._rotation_absolute); rot_transpose(_monochromator_curved_var._rotation_absolute, tr1); rot_mul(_a2_var._rotation_absolute, tr1, _a2_var._rotation_relative); _a2_var._rotation_is_identity = rot_test_identity(_a2_var._rotation_relative); tc1 = coords_set( 0, 0, 0); rot_transpose(_focus_mono_var._rotation_absolute, tr1); tc2 = rot_apply(tr1, tc1); _a2_var._position_absolute = coords_add(_focus_mono_var._position_absolute, tc2); tc1 = coords_sub(_monochromator_curved_var._position_absolute, _a2_var._position_absolute); _a2_var._position_relative = rot_apply(_a2_var._rotation_absolute, tc1); } /* a2=Arm() AT ROTATED */ DEBUG_COMPONENT("a2", _a2_var._position_absolute, _a2_var._rotation_absolute); instrument->_position_absolute[55] = _a2_var._position_absolute; instrument->_position_relative[55] = _a2_var._position_relative; _a2_var._position_relative_is_zero = coords_test_zero(_a2_var._position_relative); instrument->counter_N[55] = instrument->counter_P[55] = instrument->counter_P2[55] = 0; instrument->counter_AbsorbProp[55]= 0; #ifdef USE_NEXUS if(nxhandle) { if ((!mcdotrace) && mcformat && strcasestr(mcformat, "NeXus")) { MPI_MASTER( mccomp_placement_type_nexus(nxhandle,"0054_a2", _a2_var._position_absolute, _a2_var._rotation_absolute, "Arm"); ); } } else { // fprintf(stderr,"NO NEXUS FILE"); } #endif return(0); } /* _a2_setpos */ /* component slitShutter=Slit() SETTING, POSITION/ROTATION */ int _slitShutter_setpos(void) { /* sets initial component parameters, position and rotation */ SIG_MESSAGE("[_slitShutter_setpos] component slitShutter=Slit() SETTING [Slit:0]"); stracpy(_slitShutter_var._name, "slitShutter", 16384); stracpy(_slitShutter_var._type, "Slit", 16384); _slitShutter_var._index=56; int current_setpos_index = 56; _slitShutter_var._parameters.xmin = -0.02; _slitShutter_var._parameters.xmax = 0.02; _slitShutter_var._parameters.ymin = -0.075; _slitShutter_var._parameters.ymax = 0.075; _slitShutter_var._parameters.radius = UNSET; _slitShutter_var._parameters.xwidth = UNSET; _slitShutter_var._parameters.yheight = UNSET; /* component slitShutter=Slit() AT ROTATED */ { Coords tc1, tc2; tc1 = coords_set(0,0,0); tc2 = coords_set(0,0,0); Rotation tr1; rot_set_rotation(tr1,0,0,0); rot_set_rotation(tr1, (0)*DEG2RAD, (0)*DEG2RAD, (0)*DEG2RAD); rot_mul(tr1, _a2_var._rotation_absolute, _slitShutter_var._rotation_absolute); rot_transpose(_monochromator_curved_var._rotation_absolute, tr1); rot_mul(_slitShutter_var._rotation_absolute, tr1, _slitShutter_var._rotation_relative); _slitShutter_var._rotation_is_identity = rot_test_identity(_slitShutter_var._rotation_relative); tc1 = coords_set( 0, 0, 0.2); rot_transpose(_a2_var._rotation_absolute, tr1); tc2 = rot_apply(tr1, tc1); _slitShutter_var._position_absolute = coords_add(_a2_var._position_absolute, tc2); tc1 = coords_sub(_monochromator_curved_var._position_absolute, _slitShutter_var._position_absolute); _slitShutter_var._position_relative = rot_apply(_slitShutter_var._rotation_absolute, tc1); } /* slitShutter=Slit() AT ROTATED */ DEBUG_COMPONENT("slitShutter", _slitShutter_var._position_absolute, _slitShutter_var._rotation_absolute); instrument->_position_absolute[56] = _slitShutter_var._position_absolute; instrument->_position_relative[56] = _slitShutter_var._position_relative; _slitShutter_var._position_relative_is_zero = coords_test_zero(_slitShutter_var._position_relative); instrument->counter_N[56] = instrument->counter_P[56] = instrument->counter_P2[56] = 0; instrument->counter_AbsorbProp[56]= 0; #ifdef USE_NEXUS if(nxhandle) { if ((!mcdotrace) && mcformat && strcasestr(mcformat, "NeXus")) { MPI_MASTER( mccomp_placement_type_nexus(nxhandle,"0055_slitShutter", _slitShutter_var._position_absolute, _slitShutter_var._rotation_absolute, "Slit"); mccomp_param_nexus(nxhandle,"0055_slitShutter", "xmin", "UNSET", "-0.02","MCNUM"); mccomp_param_nexus(nxhandle,"0055_slitShutter", "xmax", "UNSET", "0.02","MCNUM"); mccomp_param_nexus(nxhandle,"0055_slitShutter", "ymin", "UNSET", "-0.075","MCNUM"); mccomp_param_nexus(nxhandle,"0055_slitShutter", "ymax", "UNSET", "0.075","MCNUM"); mccomp_param_nexus(nxhandle,"0055_slitShutter", "radius", "UNSET", "UNSET","MCNUM"); mccomp_param_nexus(nxhandle,"0055_slitShutter", "xwidth", "UNSET", "UNSET","MCNUM"); mccomp_param_nexus(nxhandle,"0055_slitShutter", "yheight", "UNSET", "UNSET","MCNUM"); ); } } else { // fprintf(stderr,"NO NEXUS FILE"); } #endif return(0); } /* _slitShutter_setpos */ /* component MSCollimator=Collimator_linear() SETTING, POSITION/ROTATION */ int _MSCollimator_setpos(void) { /* sets initial component parameters, position and rotation */ SIG_MESSAGE("[_MSCollimator_setpos] component MSCollimator=Collimator_linear() SETTING [Collimator_linear:0]"); stracpy(_MSCollimator_var._name, "MSCollimator", 16384); stracpy(_MSCollimator_var._type, "Collimator_linear", 16384); _MSCollimator_var._index=57; int current_setpos_index = 57; _MSCollimator_var._parameters.xmin = -0.02; _MSCollimator_var._parameters.xmax = 0.02; _MSCollimator_var._parameters.ymin = -0.075; _MSCollimator_var._parameters.ymax = 0.075; _MSCollimator_var._parameters.xwidth = 0; _MSCollimator_var._parameters.yheight = 0; _MSCollimator_var._parameters.length = 0.20; _MSCollimator_var._parameters.divergence = _instrument_var._parameters.COLL_MS; _MSCollimator_var._parameters.transmission = 1; _MSCollimator_var._parameters.divergenceV = 0; /* component MSCollimator=Collimator_linear() AT ROTATED */ { Coords tc1, tc2; tc1 = coords_set(0,0,0); tc2 = coords_set(0,0,0); Rotation tr1; rot_set_rotation(tr1,0,0,0); rot_set_rotation(tr1, (0.0)*DEG2RAD, (0.0)*DEG2RAD, (0.0)*DEG2RAD); rot_mul(tr1, _a2_var._rotation_absolute, _MSCollimator_var._rotation_absolute); rot_transpose(_slitShutter_var._rotation_absolute, tr1); rot_mul(_MSCollimator_var._rotation_absolute, tr1, _MSCollimator_var._rotation_relative); _MSCollimator_var._rotation_is_identity = rot_test_identity(_MSCollimator_var._rotation_relative); tc1 = coords_set( 0, 0, dmc); rot_transpose(_a2_var._rotation_absolute, tr1); tc2 = rot_apply(tr1, tc1); _MSCollimator_var._position_absolute = coords_add(_a2_var._position_absolute, tc2); tc1 = coords_sub(_slitShutter_var._position_absolute, _MSCollimator_var._position_absolute); _MSCollimator_var._position_relative = rot_apply(_MSCollimator_var._rotation_absolute, tc1); } /* MSCollimator=Collimator_linear() AT ROTATED */ DEBUG_COMPONENT("MSCollimator", _MSCollimator_var._position_absolute, _MSCollimator_var._rotation_absolute); instrument->_position_absolute[57] = _MSCollimator_var._position_absolute; instrument->_position_relative[57] = _MSCollimator_var._position_relative; _MSCollimator_var._position_relative_is_zero = coords_test_zero(_MSCollimator_var._position_relative); instrument->counter_N[57] = instrument->counter_P[57] = instrument->counter_P2[57] = 0; instrument->counter_AbsorbProp[57]= 0; #ifdef USE_NEXUS if(nxhandle) { if ((!mcdotrace) && mcformat && strcasestr(mcformat, "NeXus")) { MPI_MASTER( mccomp_placement_type_nexus(nxhandle,"0056_MSCollimator", _MSCollimator_var._position_absolute, _MSCollimator_var._rotation_absolute, "Collimator_linear"); mccomp_param_nexus(nxhandle,"0056_MSCollimator", "xmin", "-0.02", "-0.02","MCNUM"); mccomp_param_nexus(nxhandle,"0056_MSCollimator", "xmax", "0.02", "0.02","MCNUM"); mccomp_param_nexus(nxhandle,"0056_MSCollimator", "ymin", "-0.05", "-0.075","MCNUM"); mccomp_param_nexus(nxhandle,"0056_MSCollimator", "ymax", "0.05", "0.075","MCNUM"); mccomp_param_nexus(nxhandle,"0056_MSCollimator", "xwidth", "0", "0","MCNUM"); mccomp_param_nexus(nxhandle,"0056_MSCollimator", "yheight", "0", "0","MCNUM"); mccomp_param_nexus(nxhandle,"0056_MSCollimator", "length", "0.3", "0.20","MCNUM"); mccomp_param_nexus(nxhandle,"0056_MSCollimator", "divergence", "40", "_instrument_var._parameters.COLL_MS","MCNUM"); mccomp_param_nexus(nxhandle,"0056_MSCollimator", "transmission", "1", "1","MCNUM"); mccomp_param_nexus(nxhandle,"0056_MSCollimator", "divergenceV", "0", "0","MCNUM"); ); } } else { // fprintf(stderr,"NO NEXUS FILE"); } #endif return(0); } /* _MSCollimator_setpos */ /* component infilter=Filter_gen() SETTING, POSITION/ROTATION */ int _infilter_setpos(void) { /* sets initial component parameters, position and rotation */ SIG_MESSAGE("[_infilter_setpos] component infilter=Filter_gen() SETTING [Filter_gen:0]"); stracpy(_infilter_var._name, "infilter", 16384); stracpy(_infilter_var._type, "Filter_gen", 16384); _infilter_var._index=58; int current_setpos_index = 58; if(_instrument_var._parameters.INFILTERFILE && strlen(_instrument_var._parameters.INFILTERFILE)) stracpy(_infilter_var._parameters.filename, _instrument_var._parameters.INFILTERFILE ? _instrument_var._parameters.INFILTERFILE : "", 16384); else _infilter_var._parameters.filename[0]='\0'; if("wavevector multiply" && strlen("wavevector multiply")) stracpy(_infilter_var._parameters.options, "wavevector multiply" ? "wavevector multiply" : "", 16384); else _infilter_var._parameters.options[0]='\0'; _infilter_var._parameters.xmin = -0.02; _infilter_var._parameters.xmax = 0.02; _infilter_var._parameters.ymin = -0.075; _infilter_var._parameters.ymax = 0.075; _infilter_var._parameters.xwidth = 0; _infilter_var._parameters.yheight = 0; _infilter_var._parameters.thickness = 1; _infilter_var._parameters.scaling = 1; _infilter_var._parameters.verbose = 0; /* component infilter=Filter_gen() AT ROTATED */ { Coords tc1, tc2; tc1 = coords_set(0,0,0); tc2 = coords_set(0,0,0); Rotation tr1; rot_set_rotation(tr1,0,0,0); rot_set_rotation(tr1, (0.0)*DEG2RAD, (0.0)*DEG2RAD, (0.0)*DEG2RAD); rot_mul(tr1, _MSCollimator_var._rotation_absolute, _infilter_var._rotation_absolute); rot_transpose(_MSCollimator_var._rotation_absolute, tr1); rot_mul(_infilter_var._rotation_absolute, tr1, _infilter_var._rotation_relative); _infilter_var._rotation_is_identity = rot_test_identity(_infilter_var._rotation_relative); tc1 = coords_set( 0, 0, 0.201); rot_transpose(_MSCollimator_var._rotation_absolute, tr1); tc2 = rot_apply(tr1, tc1); _infilter_var._position_absolute = coords_add(_MSCollimator_var._position_absolute, tc2); tc1 = coords_sub(_MSCollimator_var._position_absolute, _infilter_var._position_absolute); _infilter_var._position_relative = rot_apply(_infilter_var._rotation_absolute, tc1); } /* infilter=Filter_gen() AT ROTATED */ DEBUG_COMPONENT("infilter", _infilter_var._position_absolute, _infilter_var._rotation_absolute); instrument->_position_absolute[58] = _infilter_var._position_absolute; instrument->_position_relative[58] = _infilter_var._position_relative; _infilter_var._position_relative_is_zero = coords_test_zero(_infilter_var._position_relative); instrument->counter_N[58] = instrument->counter_P[58] = instrument->counter_P2[58] = 0; instrument->counter_AbsorbProp[58]= 0; #ifdef USE_NEXUS if(nxhandle) { if ((!mcdotrace) && mcformat && strcasestr(mcformat, "NeXus")) { MPI_MASTER( mccomp_placement_type_nexus(nxhandle,"0057_infilter", _infilter_var._position_absolute, _infilter_var._rotation_absolute, "Filter_gen"); mccomp_param_nexus(nxhandle,"0057_infilter", "filename", 0, _instrument_var._parameters.INFILTERFILE, "char*"); mccomp_param_nexus(nxhandle,"0057_infilter", "options", 0, "wavevector multiply", "char*"); mccomp_param_nexus(nxhandle,"0057_infilter", "xmin", "-0.05", "-0.02","MCNUM"); mccomp_param_nexus(nxhandle,"0057_infilter", "xmax", "0.05", "0.02","MCNUM"); mccomp_param_nexus(nxhandle,"0057_infilter", "ymin", "-0.05", "-0.075","MCNUM"); mccomp_param_nexus(nxhandle,"0057_infilter", "ymax", "0.05", "0.075","MCNUM"); mccomp_param_nexus(nxhandle,"0057_infilter", "xwidth", "0", "0","MCNUM"); mccomp_param_nexus(nxhandle,"0057_infilter", "yheight", "0", "0","MCNUM"); mccomp_param_nexus(nxhandle,"0057_infilter", "thickness", "1", "1","MCNUM"); mccomp_param_nexus(nxhandle,"0057_infilter", "scaling", "1", "1","MCNUM"); mccomp_param_nexus(nxhandle,"0057_infilter", "verbose", "0", "0","MCNUM"); ); } } else { // fprintf(stderr,"NO NEXUS FILE"); } #endif return(0); } /* _infilter_setpos */ /* component psd_virt=PSD_monitor() SETTING, POSITION/ROTATION */ int _psd_virt_setpos(void) { /* sets initial component parameters, position and rotation */ SIG_MESSAGE("[_psd_virt_setpos] component psd_virt=PSD_monitor() SETTING [PSD_monitor:0]"); stracpy(_psd_virt_var._name, "psd_virt", 16384); stracpy(_psd_virt_var._type, "PSD_monitor", 16384); _psd_virt_var._index=59; int current_setpos_index = 59; _psd_virt_var._parameters.nx = 128; _psd_virt_var._parameters.ny = 128; if("psd_virt.dat" && strlen("psd_virt.dat")) stracpy(_psd_virt_var._parameters.filename, "psd_virt.dat" ? "psd_virt.dat" : "", 16384); else _psd_virt_var._parameters.filename[0]='\0'; _psd_virt_var._parameters.xmin = -0.05; _psd_virt_var._parameters.xmax = 0.05; _psd_virt_var._parameters.ymin = -0.05; _psd_virt_var._parameters.ymax = 0.05; _psd_virt_var._parameters.xwidth = 0.10; _psd_virt_var._parameters.yheight = 0.10; _psd_virt_var._parameters.restore_neutron = 0; _psd_virt_var._parameters.nowritefile = 0; /* component psd_virt=PSD_monitor() AT ROTATED */ { Coords tc1, tc2; tc1 = coords_set(0,0,0); tc2 = coords_set(0,0,0); Rotation tr1; rot_set_rotation(tr1,0,0,0); rot_set_rotation(tr1, (0.0)*DEG2RAD, (0.0)*DEG2RAD, (0.0)*DEG2RAD); rot_mul(tr1, _a2_var._rotation_absolute, _psd_virt_var._rotation_absolute); rot_transpose(_infilter_var._rotation_absolute, tr1); rot_mul(_psd_virt_var._rotation_absolute, tr1, _psd_virt_var._rotation_relative); _psd_virt_var._rotation_is_identity = rot_test_identity(_psd_virt_var._rotation_relative); tc1 = coords_set( 0, 0, dmv -0.01); rot_transpose(_a2_var._rotation_absolute, tr1); tc2 = rot_apply(tr1, tc1); _psd_virt_var._position_absolute = coords_add(_a2_var._position_absolute, tc2); tc1 = coords_sub(_infilter_var._position_absolute, _psd_virt_var._position_absolute); _psd_virt_var._position_relative = rot_apply(_psd_virt_var._rotation_absolute, tc1); } /* psd_virt=PSD_monitor() AT ROTATED */ DEBUG_COMPONENT("psd_virt", _psd_virt_var._position_absolute, _psd_virt_var._rotation_absolute); instrument->_position_absolute[59] = _psd_virt_var._position_absolute; instrument->_position_relative[59] = _psd_virt_var._position_relative; _psd_virt_var._position_relative_is_zero = coords_test_zero(_psd_virt_var._position_relative); instrument->counter_N[59] = instrument->counter_P[59] = instrument->counter_P2[59] = 0; instrument->counter_AbsorbProp[59]= 0; #ifdef USE_NEXUS if(nxhandle) { if ((!mcdotrace) && mcformat && strcasestr(mcformat, "NeXus")) { MPI_MASTER( mccomp_placement_type_nexus(nxhandle,"0058_psd_virt", _psd_virt_var._position_absolute, _psd_virt_var._rotation_absolute, "PSD_monitor"); mccomp_param_nexus(nxhandle,"0058_psd_virt", "nx", "90", "128","int"); mccomp_param_nexus(nxhandle,"0058_psd_virt", "ny", "90", "128","int"); mccomp_param_nexus(nxhandle,"0058_psd_virt", "filename", 0, "psd_virt.dat", "char*"); mccomp_param_nexus(nxhandle,"0058_psd_virt", "xmin", "-0.05", "-0.05","MCNUM"); mccomp_param_nexus(nxhandle,"0058_psd_virt", "xmax", "0.05", "0.05","MCNUM"); mccomp_param_nexus(nxhandle,"0058_psd_virt", "ymin", "-0.05", "-0.05","MCNUM"); mccomp_param_nexus(nxhandle,"0058_psd_virt", "ymax", "0.05", "0.05","MCNUM"); mccomp_param_nexus(nxhandle,"0058_psd_virt", "xwidth", "0", "0.10","MCNUM"); mccomp_param_nexus(nxhandle,"0058_psd_virt", "yheight", "0", "0.10","MCNUM"); mccomp_param_nexus(nxhandle,"0058_psd_virt", "restore_neutron", "0", "0","int"); mccomp_param_nexus(nxhandle,"0058_psd_virt", "nowritefile", "0", "0","int"); ); } } else { // fprintf(stderr,"NO NEXUS FILE"); } #endif return(0); } /* _psd_virt_setpos */ /* component lmon_virt=L_monitor() SETTING, POSITION/ROTATION */ int _lmon_virt_setpos(void) { /* sets initial component parameters, position and rotation */ SIG_MESSAGE("[_lmon_virt_setpos] component lmon_virt=L_monitor() SETTING [L_monitor:0]"); stracpy(_lmon_virt_var._name, "lmon_virt", 16384); stracpy(_lmon_virt_var._type, "L_monitor", 16384); _lmon_virt_var._index=60; int current_setpos_index = 60; _lmon_virt_var._parameters.nL = 100; if("lmon_virt.dat" && strlen("lmon_virt.dat")) stracpy(_lmon_virt_var._parameters.filename, "lmon_virt.dat" ? "lmon_virt.dat" : "", 16384); else _lmon_virt_var._parameters.filename[0]='\0'; _lmon_virt_var._parameters.nowritefile = 0; _lmon_virt_var._parameters.xmin = -0.05; _lmon_virt_var._parameters.xmax = 0.05; _lmon_virt_var._parameters.ymin = -0.05; _lmon_virt_var._parameters.ymax = 0.05; _lmon_virt_var._parameters.xwidth = 0.06; _lmon_virt_var._parameters.yheight = 0.10; _lmon_virt_var._parameters.Lmin = lmin; _lmon_virt_var._parameters.Lmax = lmax; _lmon_virt_var._parameters.restore_neutron = 1; /* component lmon_virt=L_monitor() AT ROTATED */ { Coords tc1, tc2; tc1 = coords_set(0,0,0); tc2 = coords_set(0,0,0); Rotation tr1; rot_set_rotation(tr1,0,0,0); rot_set_rotation(tr1, (0.0)*DEG2RAD, (0.0)*DEG2RAD, (0.0)*DEG2RAD); rot_mul(tr1, _a2_var._rotation_absolute, _lmon_virt_var._rotation_absolute); rot_transpose(_psd_virt_var._rotation_absolute, tr1); rot_mul(_lmon_virt_var._rotation_absolute, tr1, _lmon_virt_var._rotation_relative); _lmon_virt_var._rotation_is_identity = rot_test_identity(_lmon_virt_var._rotation_relative); tc1 = coords_set( 0, 0, dmv); rot_transpose(_a2_var._rotation_absolute, tr1); tc2 = rot_apply(tr1, tc1); _lmon_virt_var._position_absolute = coords_add(_a2_var._position_absolute, tc2); tc1 = coords_sub(_psd_virt_var._position_absolute, _lmon_virt_var._position_absolute); _lmon_virt_var._position_relative = rot_apply(_lmon_virt_var._rotation_absolute, tc1); } /* lmon_virt=L_monitor() AT ROTATED */ DEBUG_COMPONENT("lmon_virt", _lmon_virt_var._position_absolute, _lmon_virt_var._rotation_absolute); instrument->_position_absolute[60] = _lmon_virt_var._position_absolute; instrument->_position_relative[60] = _lmon_virt_var._position_relative; _lmon_virt_var._position_relative_is_zero = coords_test_zero(_lmon_virt_var._position_relative); instrument->counter_N[60] = instrument->counter_P[60] = instrument->counter_P2[60] = 0; instrument->counter_AbsorbProp[60]= 0; #ifdef USE_NEXUS if(nxhandle) { if ((!mcdotrace) && mcformat && strcasestr(mcformat, "NeXus")) { MPI_MASTER( mccomp_placement_type_nexus(nxhandle,"0059_lmon_virt", _lmon_virt_var._position_absolute, _lmon_virt_var._rotation_absolute, "L_monitor"); mccomp_param_nexus(nxhandle,"0059_lmon_virt", "nL", "20", "100","int"); mccomp_param_nexus(nxhandle,"0059_lmon_virt", "filename", 0, "lmon_virt.dat", "char*"); mccomp_param_nexus(nxhandle,"0059_lmon_virt", "nowritefile", "0", "0","int"); mccomp_param_nexus(nxhandle,"0059_lmon_virt", "xmin", "-0.05", "-0.05","MCNUM"); mccomp_param_nexus(nxhandle,"0059_lmon_virt", "xmax", "0.05", "0.05","MCNUM"); mccomp_param_nexus(nxhandle,"0059_lmon_virt", "ymin", "-0.05", "-0.05","MCNUM"); mccomp_param_nexus(nxhandle,"0059_lmon_virt", "ymax", "0.05", "0.05","MCNUM"); mccomp_param_nexus(nxhandle,"0059_lmon_virt", "xwidth", "0", "0.06","MCNUM"); mccomp_param_nexus(nxhandle,"0059_lmon_virt", "yheight", "0", "0.10","MCNUM"); mccomp_param_nexus(nxhandle,"0059_lmon_virt", "Lmin", "NONE", "lmin","MCNUM"); mccomp_param_nexus(nxhandle,"0059_lmon_virt", "Lmax", "NONE", "lmax","MCNUM"); mccomp_param_nexus(nxhandle,"0059_lmon_virt", "restore_neutron", "0", "1","int"); ); } } else { // fprintf(stderr,"NO NEXUS FILE"); } #endif return(0); } /* _lmon_virt_setpos */ /* component aa2=Arm() SETTING, POSITION/ROTATION */ int _aa2_setpos(void) { /* sets initial component parameters, position and rotation */ SIG_MESSAGE("[_aa2_setpos] component aa2=Arm() SETTING [Arm:0]"); stracpy(_aa2_var._name, "aa2", 16384); stracpy(_aa2_var._type, "Arm", 16384); _aa2_var._index=61; int current_setpos_index = 61; /* component aa2=Arm() AT ROTATED */ { Coords tc1, tc2; tc1 = coords_set(0,0,0); tc2 = coords_set(0,0,0); Rotation tr1; rot_set_rotation(tr1,0,0,0); rot_set_rotation(tr1, (0.0)*DEG2RAD, (0.0)*DEG2RAD, (0.0)*DEG2RAD); rot_mul(tr1, _a2_var._rotation_absolute, _aa2_var._rotation_absolute); rot_transpose(_lmon_virt_var._rotation_absolute, tr1); rot_mul(_aa2_var._rotation_absolute, tr1, _aa2_var._rotation_relative); _aa2_var._rotation_is_identity = rot_test_identity(_aa2_var._rotation_relative); tc1 = coords_set( 0, 0, dmv); rot_transpose(_a2_var._rotation_absolute, tr1); tc2 = rot_apply(tr1, tc1); _aa2_var._position_absolute = coords_add(_a2_var._position_absolute, tc2); tc1 = coords_sub(_lmon_virt_var._position_absolute, _aa2_var._position_absolute); _aa2_var._position_relative = rot_apply(_aa2_var._rotation_absolute, tc1); } /* aa2=Arm() AT ROTATED */ DEBUG_COMPONENT("aa2", _aa2_var._position_absolute, _aa2_var._rotation_absolute); instrument->_position_absolute[61] = _aa2_var._position_absolute; instrument->_position_relative[61] = _aa2_var._position_relative; _aa2_var._position_relative_is_zero = coords_test_zero(_aa2_var._position_relative); instrument->counter_N[61] = instrument->counter_P[61] = instrument->counter_P2[61] = 0; instrument->counter_AbsorbProp[61]= 0; #ifdef USE_NEXUS if(nxhandle) { if ((!mcdotrace) && mcformat && strcasestr(mcformat, "NeXus")) { MPI_MASTER( mccomp_placement_type_nexus(nxhandle,"0060_aa2", _aa2_var._position_absolute, _aa2_var._rotation_absolute, "Arm"); ); } } else { // fprintf(stderr,"NO NEXUS FILE"); } #endif return(0); } /* _aa2_setpos */ /* component OrderMon=Monitor_nD() SETTING, POSITION/ROTATION */ int _OrderMon_setpos(void) { /* sets initial component parameters, position and rotation */ SIG_MESSAGE("[_OrderMon_setpos] component OrderMon=Monitor_nD() SETTING [Monitor_nD:0]"); stracpy(_OrderMon_var._name, "OrderMon", 16384); stracpy(_OrderMon_var._type, "Monitor_nD", 16384); _OrderMon_var._index=62; int current_setpos_index = 62; if("" && strlen("")) stracpy(_OrderMon_var._parameters.user0, "" ? "" : "", 16384); else _OrderMon_var._parameters.user0[0]='\0'; if("Mono_order" && strlen("Mono_order")) stracpy(_OrderMon_var._parameters.user1, "Mono_order" ? "Mono_order" : "", 16384); else _OrderMon_var._parameters.user1[0]='\0'; if("" && strlen("")) stracpy(_OrderMon_var._parameters.user2, "" ? "" : "", 16384); else _OrderMon_var._parameters.user2[0]='\0'; if("" && strlen("")) stracpy(_OrderMon_var._parameters.user3, "" ? "" : "", 16384); else _OrderMon_var._parameters.user3[0]='\0'; if("" && strlen("")) stracpy(_OrderMon_var._parameters.user4, "" ? "" : "", 16384); else _OrderMon_var._parameters.user4[0]='\0'; if("" && strlen("")) stracpy(_OrderMon_var._parameters.user5, "" ? "" : "", 16384); else _OrderMon_var._parameters.user5[0]='\0'; if("" && strlen("")) stracpy(_OrderMon_var._parameters.user6, "" ? "" : "", 16384); else _OrderMon_var._parameters.user6[0]='\0'; if("" && strlen("")) stracpy(_OrderMon_var._parameters.user7, "" ? "" : "", 16384); else _OrderMon_var._parameters.user7[0]='\0'; if("" && strlen("")) stracpy(_OrderMon_var._parameters.user8, "" ? "" : "", 16384); else _OrderMon_var._parameters.user8[0]='\0'; if("" && strlen("")) stracpy(_OrderMon_var._parameters.user9, "" ? "" : "", 16384); else _OrderMon_var._parameters.user9[0]='\0'; _OrderMon_var._parameters.xwidth = 0.04; _OrderMon_var._parameters.yheight = 0.08; _OrderMon_var._parameters.zdepth = 0; _OrderMon_var._parameters.xmin = 0; _OrderMon_var._parameters.xmax = 0; _OrderMon_var._parameters.ymin = 0; _OrderMon_var._parameters.ymax = 0; _OrderMon_var._parameters.zmin = 0; _OrderMon_var._parameters.zmax = 0; _OrderMon_var._parameters.bins = 0; _OrderMon_var._parameters.min = -1e40; _OrderMon_var._parameters.max = 1e40; _OrderMon_var._parameters.restore_neutron = 1; _OrderMon_var._parameters.radius = 0; if("user1 bins=5 limits=[0.5 5.5], user1 bins=5 limits=[0.5 5.5]" && strlen("user1 bins=5 limits=[0.5 5.5], user1 bins=5 limits=[0.5 5.5]")) stracpy(_OrderMon_var._parameters.options, "user1 bins=5 limits=[0.5 5.5], user1 bins=5 limits=[0.5 5.5]" ? "user1 bins=5 limits=[0.5 5.5], user1 bins=5 limits=[0.5 5.5]" : "", 16384); else _OrderMon_var._parameters.options[0]='\0'; if("OrderMonNtest.dat" && strlen("OrderMonNtest.dat")) stracpy(_OrderMon_var._parameters.filename, "OrderMonNtest.dat" ? "OrderMonNtest.dat" : "", 16384); else _OrderMon_var._parameters.filename[0]='\0'; if("NULL" && strlen("NULL")) stracpy(_OrderMon_var._parameters.geometry, "NULL" ? "NULL" : "", 16384); else _OrderMon_var._parameters.geometry[0]='\0'; _OrderMon_var._parameters.nowritefile = 0; _OrderMon_var._parameters.nexus_bins = 0; if("NULL" && strlen("NULL")) stracpy(_OrderMon_var._parameters.username0, "NULL" ? "NULL" : "", 16384); else _OrderMon_var._parameters.username0[0]='\0'; if("Intensity of multiples" && strlen("Intensity of multiples")) stracpy(_OrderMon_var._parameters.username1, "Intensity of multiples" ? "Intensity of multiples" : "", 16384); else _OrderMon_var._parameters.username1[0]='\0'; if("NULL" && strlen("NULL")) stracpy(_OrderMon_var._parameters.username2, "NULL" ? "NULL" : "", 16384); else _OrderMon_var._parameters.username2[0]='\0'; if("NULL" && strlen("NULL")) stracpy(_OrderMon_var._parameters.username3, "NULL" ? "NULL" : "", 16384); else _OrderMon_var._parameters.username3[0]='\0'; if("NULL" && strlen("NULL")) stracpy(_OrderMon_var._parameters.username4, "NULL" ? "NULL" : "", 16384); else _OrderMon_var._parameters.username4[0]='\0'; if("NULL" && strlen("NULL")) stracpy(_OrderMon_var._parameters.username5, "NULL" ? "NULL" : "", 16384); else _OrderMon_var._parameters.username5[0]='\0'; if("NULL" && strlen("NULL")) stracpy(_OrderMon_var._parameters.username6, "NULL" ? "NULL" : "", 16384); else _OrderMon_var._parameters.username6[0]='\0'; if("NULL" && strlen("NULL")) stracpy(_OrderMon_var._parameters.username7, "NULL" ? "NULL" : "", 16384); else _OrderMon_var._parameters.username7[0]='\0'; if("NULL" && strlen("NULL")) stracpy(_OrderMon_var._parameters.username8, "NULL" ? "NULL" : "", 16384); else _OrderMon_var._parameters.username8[0]='\0'; if("NULL" && strlen("NULL")) stracpy(_OrderMon_var._parameters.username9, "NULL" ? "NULL" : "", 16384); else _OrderMon_var._parameters.username9[0]='\0'; /* component OrderMon=Monitor_nD() AT ROTATED */ { Coords tc1, tc2; tc1 = coords_set(0,0,0); tc2 = coords_set(0,0,0); Rotation tr1; rot_set_rotation(tr1,0,0,0); rot_set_rotation(tr1, (0.0)*DEG2RAD, (0.0)*DEG2RAD, (0.0)*DEG2RAD); rot_mul(tr1, _aa2_var._rotation_absolute, _OrderMon_var._rotation_absolute); rot_transpose(_lmon_virt_var._rotation_absolute, tr1); rot_mul(_OrderMon_var._rotation_absolute, tr1, _OrderMon_var._rotation_relative); _OrderMon_var._rotation_is_identity = rot_test_identity(_OrderMon_var._rotation_relative); tc1 = coords_set( 0, 0, 0.170 -4e-3); rot_transpose(_aa2_var._rotation_absolute, tr1); tc2 = rot_apply(tr1, tc1); _OrderMon_var._position_absolute = coords_add(_aa2_var._position_absolute, tc2); tc1 = coords_sub(_lmon_virt_var._position_absolute, _OrderMon_var._position_absolute); _OrderMon_var._position_relative = rot_apply(_OrderMon_var._rotation_absolute, tc1); } /* OrderMon=Monitor_nD() AT ROTATED */ DEBUG_COMPONENT("OrderMon", _OrderMon_var._position_absolute, _OrderMon_var._rotation_absolute); instrument->_position_absolute[62] = _OrderMon_var._position_absolute; instrument->_position_relative[62] = _OrderMon_var._position_relative; _OrderMon_var._position_relative_is_zero = coords_test_zero(_OrderMon_var._position_relative); instrument->counter_N[62] = instrument->counter_P[62] = instrument->counter_P2[62] = 0; instrument->counter_AbsorbProp[62]= 0; #ifdef USE_NEXUS if(nxhandle) { if ((!mcdotrace) && mcformat && strcasestr(mcformat, "NeXus")) { MPI_MASTER( mccomp_placement_type_nexus(nxhandle,"0061_OrderMon", _OrderMon_var._position_absolute, _OrderMon_var._rotation_absolute, "Monitor_nD"); mccomp_param_nexus(nxhandle,"0061_OrderMon", "user0", "", "", "char*"); mccomp_param_nexus(nxhandle,"0061_OrderMon", "user1", "", "Mono_order", "char*"); mccomp_param_nexus(nxhandle,"0061_OrderMon", "user2", "", "", "char*"); mccomp_param_nexus(nxhandle,"0061_OrderMon", "user3", "", "", "char*"); mccomp_param_nexus(nxhandle,"0061_OrderMon", "user4", "", "", "char*"); mccomp_param_nexus(nxhandle,"0061_OrderMon", "user5", "", "", "char*"); mccomp_param_nexus(nxhandle,"0061_OrderMon", "user6", "", "", "char*"); mccomp_param_nexus(nxhandle,"0061_OrderMon", "user7", "", "", "char*"); mccomp_param_nexus(nxhandle,"0061_OrderMon", "user8", "", "", "char*"); mccomp_param_nexus(nxhandle,"0061_OrderMon", "user9", "", "", "char*"); mccomp_param_nexus(nxhandle,"0061_OrderMon", "xwidth", "0", "0.04","MCNUM"); mccomp_param_nexus(nxhandle,"0061_OrderMon", "yheight", "0", "0.08","MCNUM"); mccomp_param_nexus(nxhandle,"0061_OrderMon", "zdepth", "0", "0","MCNUM"); mccomp_param_nexus(nxhandle,"0061_OrderMon", "xmin", "0", "0","MCNUM"); mccomp_param_nexus(nxhandle,"0061_OrderMon", "xmax", "0", "0","MCNUM"); mccomp_param_nexus(nxhandle,"0061_OrderMon", "ymin", "0", "0","MCNUM"); mccomp_param_nexus(nxhandle,"0061_OrderMon", "ymax", "0", "0","MCNUM"); mccomp_param_nexus(nxhandle,"0061_OrderMon", "zmin", "0", "0","MCNUM"); mccomp_param_nexus(nxhandle,"0061_OrderMon", "zmax", "0", "0","MCNUM"); mccomp_param_nexus(nxhandle,"0061_OrderMon", "bins", "0", "0","int"); mccomp_param_nexus(nxhandle,"0061_OrderMon", "min", "-1e40", "-1e40","MCNUM"); mccomp_param_nexus(nxhandle,"0061_OrderMon", "max", "1e40", "1e40","MCNUM"); mccomp_param_nexus(nxhandle,"0061_OrderMon", "restore_neutron", "0", "1","int"); mccomp_param_nexus(nxhandle,"0061_OrderMon", "radius", "0", "0","MCNUM"); mccomp_param_nexus(nxhandle,"0061_OrderMon", "options", "NULL", "user1 bins=5 limits=[0.5 5.5], user1 bins=5 limits=[0.5 5.5]", "char*"); mccomp_param_nexus(nxhandle,"0061_OrderMon", "filename", "NULL", "OrderMonNtest.dat", "char*"); mccomp_param_nexus(nxhandle,"0061_OrderMon", "geometry", "NULL", "NULL", "char*"); mccomp_param_nexus(nxhandle,"0061_OrderMon", "nowritefile", "0", "0","int"); mccomp_param_nexus(nxhandle,"0061_OrderMon", "nexus_bins", "0", "0","int"); mccomp_param_nexus(nxhandle,"0061_OrderMon", "username0", "NULL", "NULL", "char*"); mccomp_param_nexus(nxhandle,"0061_OrderMon", "username1", "NULL", "Intensity of multiples", "char*"); mccomp_param_nexus(nxhandle,"0061_OrderMon", "username2", "NULL", "NULL", "char*"); mccomp_param_nexus(nxhandle,"0061_OrderMon", "username3", "NULL", "NULL", "char*"); mccomp_param_nexus(nxhandle,"0061_OrderMon", "username4", "NULL", "NULL", "char*"); mccomp_param_nexus(nxhandle,"0061_OrderMon", "username5", "NULL", "NULL", "char*"); mccomp_param_nexus(nxhandle,"0061_OrderMon", "username6", "NULL", "NULL", "char*"); mccomp_param_nexus(nxhandle,"0061_OrderMon", "username7", "NULL", "NULL", "char*"); mccomp_param_nexus(nxhandle,"0061_OrderMon", "username8", "NULL", "NULL", "char*"); mccomp_param_nexus(nxhandle,"0061_OrderMon", "username9", "NULL", "NULL", "char*"); ); } } else { // fprintf(stderr,"NO NEXUS FILE"); } #endif return(0); } /* _OrderMon_setpos */ /* component kMoni=PSD_monitor_psf_eff() SETTING, POSITION/ROTATION */ int _kMoni_setpos(void) { /* sets initial component parameters, position and rotation */ SIG_MESSAGE("[_kMoni_setpos] component kMoni=PSD_monitor_psf_eff() SETTING [PSD_monitor_psf_eff:0]"); stracpy(_kMoni_var._name, "kMoni", 16384); stracpy(_kMoni_var._type, "PSD_monitor_psf_eff", 16384); _kMoni_var._index=63; int current_setpos_index = 63; _kMoni_var._parameters.nx = 90; _kMoni_var._parameters.ny = 90; if("kMoni.dat" && strlen("kMoni.dat")) stracpy(_kMoni_var._parameters.filename, "kMoni.dat" ? "kMoni.dat" : "", 16384); else _kMoni_var._parameters.filename[0]='\0'; _kMoni_var._parameters.xmin = 0; _kMoni_var._parameters.xmax = 0; _kMoni_var._parameters.ymin = 0; _kMoni_var._parameters.ymax = 0; _kMoni_var._parameters.nowritefile = 0; _kMoni_var._parameters.xwidth = 0.04; _kMoni_var._parameters.yheight = 0.08; _kMoni_var._parameters.psf = 0; _kMoni_var._parameters.k0 = 1.553; _kMoni_var._parameters.eff = EFF; _kMoni_var._parameters.restore_neutron = 1; /* component kMoni=PSD_monitor_psf_eff() AT ROTATED */ { Coords tc1, tc2; tc1 = coords_set(0,0,0); tc2 = coords_set(0,0,0); Rotation tr1; rot_set_rotation(tr1,0,0,0); rot_set_rotation(tr1, (0.0)*DEG2RAD, (0.0)*DEG2RAD, (0.0)*DEG2RAD); rot_mul(tr1, _aa2_var._rotation_absolute, _kMoni_var._rotation_absolute); rot_transpose(_OrderMon_var._rotation_absolute, tr1); rot_mul(_kMoni_var._rotation_absolute, tr1, _kMoni_var._rotation_relative); _kMoni_var._rotation_is_identity = rot_test_identity(_kMoni_var._rotation_relative); tc1 = coords_set( 0, 0, 0.170 -3e-3); rot_transpose(_aa2_var._rotation_absolute, tr1); tc2 = rot_apply(tr1, tc1); _kMoni_var._position_absolute = coords_add(_aa2_var._position_absolute, tc2); tc1 = coords_sub(_OrderMon_var._position_absolute, _kMoni_var._position_absolute); _kMoni_var._position_relative = rot_apply(_kMoni_var._rotation_absolute, tc1); } /* kMoni=PSD_monitor_psf_eff() AT ROTATED */ DEBUG_COMPONENT("kMoni", _kMoni_var._position_absolute, _kMoni_var._rotation_absolute); instrument->_position_absolute[63] = _kMoni_var._position_absolute; instrument->_position_relative[63] = _kMoni_var._position_relative; _kMoni_var._position_relative_is_zero = coords_test_zero(_kMoni_var._position_relative); instrument->counter_N[63] = instrument->counter_P[63] = instrument->counter_P2[63] = 0; instrument->counter_AbsorbProp[63]= 0; #ifdef USE_NEXUS if(nxhandle) { if ((!mcdotrace) && mcformat && strcasestr(mcformat, "NeXus")) { MPI_MASTER( mccomp_placement_type_nexus(nxhandle,"0062_kMoni", _kMoni_var._position_absolute, _kMoni_var._rotation_absolute, "PSD_monitor_psf_eff"); mccomp_param_nexus(nxhandle,"0062_kMoni", "nx", "90", "90","int"); mccomp_param_nexus(nxhandle,"0062_kMoni", "ny", "90", "90","int"); mccomp_param_nexus(nxhandle,"0062_kMoni", "filename", 0, "kMoni.dat", "char*"); mccomp_param_nexus(nxhandle,"0062_kMoni", "xmin", "0", "0","MCNUM"); mccomp_param_nexus(nxhandle,"0062_kMoni", "xmax", "0", "0","MCNUM"); mccomp_param_nexus(nxhandle,"0062_kMoni", "ymin", "0", "0","MCNUM"); mccomp_param_nexus(nxhandle,"0062_kMoni", "ymax", "0", "0","MCNUM"); mccomp_param_nexus(nxhandle,"0062_kMoni", "nowritefile", "0", "0","int"); mccomp_param_nexus(nxhandle,"0062_kMoni", "xwidth", "0", "0.04","MCNUM"); mccomp_param_nexus(nxhandle,"0062_kMoni", "yheight", "0", "0.08","MCNUM"); mccomp_param_nexus(nxhandle,"0062_kMoni", "psf", "0", "0","MCNUM"); mccomp_param_nexus(nxhandle,"0062_kMoni", "k0", "1", "1.553","MCNUM"); mccomp_param_nexus(nxhandle,"0062_kMoni", "eff", "1", "EFF","MCNUM"); mccomp_param_nexus(nxhandle,"0062_kMoni", "restore_neutron", "0", "1","int"); ); } } else { // fprintf(stderr,"NO NEXUS FILE"); } #endif return(0); } /* _kMoni_setpos */ /* component kMoni1st=PSD_monitor_psf_eff() SETTING, POSITION/ROTATION */ int _kMoni1st_setpos(void) { /* sets initial component parameters, position and rotation */ SIG_MESSAGE("[_kMoni1st_setpos] component kMoni1st=PSD_monitor_psf_eff() SETTING [PSD_monitor_psf_eff:0]"); stracpy(_kMoni1st_var._name, "kMoni1st", 16384); stracpy(_kMoni1st_var._type, "PSD_monitor_psf_eff", 16384); _kMoni1st_var._index=64; int current_setpos_index = 64; _kMoni1st_var._parameters.nx = 90; _kMoni1st_var._parameters.ny = 90; if("kMoni1st.dat" && strlen("kMoni1st.dat")) stracpy(_kMoni1st_var._parameters.filename, "kMoni1st.dat" ? "kMoni1st.dat" : "", 16384); else _kMoni1st_var._parameters.filename[0]='\0'; _kMoni1st_var._parameters.xmin = 0; _kMoni1st_var._parameters.xmax = 0; _kMoni1st_var._parameters.ymin = 0; _kMoni1st_var._parameters.ymax = 0; _kMoni1st_var._parameters.nowritefile = 0; _kMoni1st_var._parameters.xwidth = 0.04; _kMoni1st_var._parameters.yheight = 0.08; _kMoni1st_var._parameters.psf = 0; _kMoni1st_var._parameters.k0 = 1.553; _kMoni1st_var._parameters.eff = EFF; _kMoni1st_var._parameters.restore_neutron = 1; /* component kMoni1st=PSD_monitor_psf_eff() AT ROTATED */ { Coords tc1, tc2; tc1 = coords_set(0,0,0); tc2 = coords_set(0,0,0); Rotation tr1; rot_set_rotation(tr1,0,0,0); rot_set_rotation(tr1, (0.0)*DEG2RAD, (0.0)*DEG2RAD, (0.0)*DEG2RAD); rot_mul(tr1, _aa2_var._rotation_absolute, _kMoni1st_var._rotation_absolute); rot_transpose(_kMoni_var._rotation_absolute, tr1); rot_mul(_kMoni1st_var._rotation_absolute, tr1, _kMoni1st_var._rotation_relative); _kMoni1st_var._rotation_is_identity = rot_test_identity(_kMoni1st_var._rotation_relative); tc1 = coords_set( 0, 0, 0.170 -2e-3); rot_transpose(_aa2_var._rotation_absolute, tr1); tc2 = rot_apply(tr1, tc1); _kMoni1st_var._position_absolute = coords_add(_aa2_var._position_absolute, tc2); tc1 = coords_sub(_kMoni_var._position_absolute, _kMoni1st_var._position_absolute); _kMoni1st_var._position_relative = rot_apply(_kMoni1st_var._rotation_absolute, tc1); } /* kMoni1st=PSD_monitor_psf_eff() AT ROTATED */ DEBUG_COMPONENT("kMoni1st", _kMoni1st_var._position_absolute, _kMoni1st_var._rotation_absolute); instrument->_position_absolute[64] = _kMoni1st_var._position_absolute; instrument->_position_relative[64] = _kMoni1st_var._position_relative; _kMoni1st_var._position_relative_is_zero = coords_test_zero(_kMoni1st_var._position_relative); instrument->counter_N[64] = instrument->counter_P[64] = instrument->counter_P2[64] = 0; instrument->counter_AbsorbProp[64]= 0; #ifdef USE_NEXUS if(nxhandle) { if ((!mcdotrace) && mcformat && strcasestr(mcformat, "NeXus")) { MPI_MASTER( mccomp_placement_type_nexus(nxhandle,"0063_kMoni1st", _kMoni1st_var._position_absolute, _kMoni1st_var._rotation_absolute, "PSD_monitor_psf_eff"); mccomp_param_nexus(nxhandle,"0063_kMoni1st", "nx", "90", "90","int"); mccomp_param_nexus(nxhandle,"0063_kMoni1st", "ny", "90", "90","int"); mccomp_param_nexus(nxhandle,"0063_kMoni1st", "filename", 0, "kMoni1st.dat", "char*"); mccomp_param_nexus(nxhandle,"0063_kMoni1st", "xmin", "0", "0","MCNUM"); mccomp_param_nexus(nxhandle,"0063_kMoni1st", "xmax", "0", "0","MCNUM"); mccomp_param_nexus(nxhandle,"0063_kMoni1st", "ymin", "0", "0","MCNUM"); mccomp_param_nexus(nxhandle,"0063_kMoni1st", "ymax", "0", "0","MCNUM"); mccomp_param_nexus(nxhandle,"0063_kMoni1st", "nowritefile", "0", "0","int"); mccomp_param_nexus(nxhandle,"0063_kMoni1st", "xwidth", "0", "0.04","MCNUM"); mccomp_param_nexus(nxhandle,"0063_kMoni1st", "yheight", "0", "0.08","MCNUM"); mccomp_param_nexus(nxhandle,"0063_kMoni1st", "psf", "0", "0","MCNUM"); mccomp_param_nexus(nxhandle,"0063_kMoni1st", "k0", "1", "1.553","MCNUM"); mccomp_param_nexus(nxhandle,"0063_kMoni1st", "eff", "1", "EFF","MCNUM"); mccomp_param_nexus(nxhandle,"0063_kMoni1st", "restore_neutron", "0", "1","int"); ); } } else { // fprintf(stderr,"NO NEXUS FILE"); } #endif return(0); } /* _kMoni1st_setpos */ /* component kMoni2nd=PSD_monitor_psf_eff() SETTING, POSITION/ROTATION */ int _kMoni2nd_setpos(void) { /* sets initial component parameters, position and rotation */ SIG_MESSAGE("[_kMoni2nd_setpos] component kMoni2nd=PSD_monitor_psf_eff() SETTING [PSD_monitor_psf_eff:0]"); stracpy(_kMoni2nd_var._name, "kMoni2nd", 16384); stracpy(_kMoni2nd_var._type, "PSD_monitor_psf_eff", 16384); _kMoni2nd_var._index=65; int current_setpos_index = 65; _kMoni2nd_var._parameters.nx = 90; _kMoni2nd_var._parameters.ny = 90; if("kMoni2nd.dat" && strlen("kMoni2nd.dat")) stracpy(_kMoni2nd_var._parameters.filename, "kMoni2nd.dat" ? "kMoni2nd.dat" : "", 16384); else _kMoni2nd_var._parameters.filename[0]='\0'; _kMoni2nd_var._parameters.xmin = 0; _kMoni2nd_var._parameters.xmax = 0; _kMoni2nd_var._parameters.ymin = 0; _kMoni2nd_var._parameters.ymax = 0; _kMoni2nd_var._parameters.nowritefile = 0; _kMoni2nd_var._parameters.xwidth = 0.04; _kMoni2nd_var._parameters.yheight = 0.08; _kMoni2nd_var._parameters.psf = 0; _kMoni2nd_var._parameters.k0 = 1.553; _kMoni2nd_var._parameters.eff = EFF; _kMoni2nd_var._parameters.restore_neutron = 1; /* component kMoni2nd=PSD_monitor_psf_eff() AT ROTATED */ { Coords tc1, tc2; tc1 = coords_set(0,0,0); tc2 = coords_set(0,0,0); Rotation tr1; rot_set_rotation(tr1,0,0,0); rot_set_rotation(tr1, (0.0)*DEG2RAD, (0.0)*DEG2RAD, (0.0)*DEG2RAD); rot_mul(tr1, _aa2_var._rotation_absolute, _kMoni2nd_var._rotation_absolute); rot_transpose(_kMoni1st_var._rotation_absolute, tr1); rot_mul(_kMoni2nd_var._rotation_absolute, tr1, _kMoni2nd_var._rotation_relative); _kMoni2nd_var._rotation_is_identity = rot_test_identity(_kMoni2nd_var._rotation_relative); tc1 = coords_set( 0, 0, 0.170 -1e-3); rot_transpose(_aa2_var._rotation_absolute, tr1); tc2 = rot_apply(tr1, tc1); _kMoni2nd_var._position_absolute = coords_add(_aa2_var._position_absolute, tc2); tc1 = coords_sub(_kMoni1st_var._position_absolute, _kMoni2nd_var._position_absolute); _kMoni2nd_var._position_relative = rot_apply(_kMoni2nd_var._rotation_absolute, tc1); } /* kMoni2nd=PSD_monitor_psf_eff() AT ROTATED */ DEBUG_COMPONENT("kMoni2nd", _kMoni2nd_var._position_absolute, _kMoni2nd_var._rotation_absolute); instrument->_position_absolute[65] = _kMoni2nd_var._position_absolute; instrument->_position_relative[65] = _kMoni2nd_var._position_relative; _kMoni2nd_var._position_relative_is_zero = coords_test_zero(_kMoni2nd_var._position_relative); instrument->counter_N[65] = instrument->counter_P[65] = instrument->counter_P2[65] = 0; instrument->counter_AbsorbProp[65]= 0; #ifdef USE_NEXUS if(nxhandle) { if ((!mcdotrace) && mcformat && strcasestr(mcformat, "NeXus")) { MPI_MASTER( mccomp_placement_type_nexus(nxhandle,"0064_kMoni2nd", _kMoni2nd_var._position_absolute, _kMoni2nd_var._rotation_absolute, "PSD_monitor_psf_eff"); mccomp_param_nexus(nxhandle,"0064_kMoni2nd", "nx", "90", "90","int"); mccomp_param_nexus(nxhandle,"0064_kMoni2nd", "ny", "90", "90","int"); mccomp_param_nexus(nxhandle,"0064_kMoni2nd", "filename", 0, "kMoni2nd.dat", "char*"); mccomp_param_nexus(nxhandle,"0064_kMoni2nd", "xmin", "0", "0","MCNUM"); mccomp_param_nexus(nxhandle,"0064_kMoni2nd", "xmax", "0", "0","MCNUM"); mccomp_param_nexus(nxhandle,"0064_kMoni2nd", "ymin", "0", "0","MCNUM"); mccomp_param_nexus(nxhandle,"0064_kMoni2nd", "ymax", "0", "0","MCNUM"); mccomp_param_nexus(nxhandle,"0064_kMoni2nd", "nowritefile", "0", "0","int"); mccomp_param_nexus(nxhandle,"0064_kMoni2nd", "xwidth", "0", "0.04","MCNUM"); mccomp_param_nexus(nxhandle,"0064_kMoni2nd", "yheight", "0", "0.08","MCNUM"); mccomp_param_nexus(nxhandle,"0064_kMoni2nd", "psf", "0", "0","MCNUM"); mccomp_param_nexus(nxhandle,"0064_kMoni2nd", "k0", "1", "1.553","MCNUM"); mccomp_param_nexus(nxhandle,"0064_kMoni2nd", "eff", "1", "EFF","MCNUM"); mccomp_param_nexus(nxhandle,"0064_kMoni2nd", "restore_neutron", "0", "1","int"); ); } } else { // fprintf(stderr,"NO NEXUS FILE"); } #endif return(0); } /* _kMoni2nd_setpos */ /* component kMoni3rd=PSD_monitor_psf_eff() SETTING, POSITION/ROTATION */ int _kMoni3rd_setpos(void) { /* sets initial component parameters, position and rotation */ SIG_MESSAGE("[_kMoni3rd_setpos] component kMoni3rd=PSD_monitor_psf_eff() SETTING [PSD_monitor_psf_eff:0]"); stracpy(_kMoni3rd_var._name, "kMoni3rd", 16384); stracpy(_kMoni3rd_var._type, "PSD_monitor_psf_eff", 16384); _kMoni3rd_var._index=66; int current_setpos_index = 66; _kMoni3rd_var._parameters.nx = 90; _kMoni3rd_var._parameters.ny = 90; if("kMoni3rd.dat" && strlen("kMoni3rd.dat")) stracpy(_kMoni3rd_var._parameters.filename, "kMoni3rd.dat" ? "kMoni3rd.dat" : "", 16384); else _kMoni3rd_var._parameters.filename[0]='\0'; _kMoni3rd_var._parameters.xmin = 0; _kMoni3rd_var._parameters.xmax = 0; _kMoni3rd_var._parameters.ymin = 0; _kMoni3rd_var._parameters.ymax = 0; _kMoni3rd_var._parameters.nowritefile = 0; _kMoni3rd_var._parameters.xwidth = 0.04; _kMoni3rd_var._parameters.yheight = 0.08; _kMoni3rd_var._parameters.psf = 0; _kMoni3rd_var._parameters.k0 = 1.553; _kMoni3rd_var._parameters.eff = EFF; _kMoni3rd_var._parameters.restore_neutron = 1; /* component kMoni3rd=PSD_monitor_psf_eff() AT ROTATED */ { Coords tc1, tc2; tc1 = coords_set(0,0,0); tc2 = coords_set(0,0,0); Rotation tr1; rot_set_rotation(tr1,0,0,0); rot_set_rotation(tr1, (0.0)*DEG2RAD, (0.0)*DEG2RAD, (0.0)*DEG2RAD); rot_mul(tr1, _aa2_var._rotation_absolute, _kMoni3rd_var._rotation_absolute); rot_transpose(_kMoni2nd_var._rotation_absolute, tr1); rot_mul(_kMoni3rd_var._rotation_absolute, tr1, _kMoni3rd_var._rotation_relative); _kMoni3rd_var._rotation_is_identity = rot_test_identity(_kMoni3rd_var._rotation_relative); tc1 = coords_set( 0, 0, 0.170); rot_transpose(_aa2_var._rotation_absolute, tr1); tc2 = rot_apply(tr1, tc1); _kMoni3rd_var._position_absolute = coords_add(_aa2_var._position_absolute, tc2); tc1 = coords_sub(_kMoni2nd_var._position_absolute, _kMoni3rd_var._position_absolute); _kMoni3rd_var._position_relative = rot_apply(_kMoni3rd_var._rotation_absolute, tc1); } /* kMoni3rd=PSD_monitor_psf_eff() AT ROTATED */ DEBUG_COMPONENT("kMoni3rd", _kMoni3rd_var._position_absolute, _kMoni3rd_var._rotation_absolute); instrument->_position_absolute[66] = _kMoni3rd_var._position_absolute; instrument->_position_relative[66] = _kMoni3rd_var._position_relative; _kMoni3rd_var._position_relative_is_zero = coords_test_zero(_kMoni3rd_var._position_relative); instrument->counter_N[66] = instrument->counter_P[66] = instrument->counter_P2[66] = 0; instrument->counter_AbsorbProp[66]= 0; #ifdef USE_NEXUS if(nxhandle) { if ((!mcdotrace) && mcformat && strcasestr(mcformat, "NeXus")) { MPI_MASTER( mccomp_placement_type_nexus(nxhandle,"0065_kMoni3rd", _kMoni3rd_var._position_absolute, _kMoni3rd_var._rotation_absolute, "PSD_monitor_psf_eff"); mccomp_param_nexus(nxhandle,"0065_kMoni3rd", "nx", "90", "90","int"); mccomp_param_nexus(nxhandle,"0065_kMoni3rd", "ny", "90", "90","int"); mccomp_param_nexus(nxhandle,"0065_kMoni3rd", "filename", 0, "kMoni3rd.dat", "char*"); mccomp_param_nexus(nxhandle,"0065_kMoni3rd", "xmin", "0", "0","MCNUM"); mccomp_param_nexus(nxhandle,"0065_kMoni3rd", "xmax", "0", "0","MCNUM"); mccomp_param_nexus(nxhandle,"0065_kMoni3rd", "ymin", "0", "0","MCNUM"); mccomp_param_nexus(nxhandle,"0065_kMoni3rd", "ymax", "0", "0","MCNUM"); mccomp_param_nexus(nxhandle,"0065_kMoni3rd", "nowritefile", "0", "0","int"); mccomp_param_nexus(nxhandle,"0065_kMoni3rd", "xwidth", "0", "0.04","MCNUM"); mccomp_param_nexus(nxhandle,"0065_kMoni3rd", "yheight", "0", "0.08","MCNUM"); mccomp_param_nexus(nxhandle,"0065_kMoni3rd", "psf", "0", "0","MCNUM"); mccomp_param_nexus(nxhandle,"0065_kMoni3rd", "k0", "1", "1.553","MCNUM"); mccomp_param_nexus(nxhandle,"0065_kMoni3rd", "eff", "1", "EFF","MCNUM"); mccomp_param_nexus(nxhandle,"0065_kMoni3rd", "restore_neutron", "0", "1","int"); ); } } else { // fprintf(stderr,"NO NEXUS FILE"); } #endif return(0); } /* _kMoni3rd_setpos */ /* component slitMonochromator=Slit() SETTING, POSITION/ROTATION */ int _slitMonochromator_setpos(void) { /* sets initial component parameters, position and rotation */ SIG_MESSAGE("[_slitMonochromator_setpos] component slitMonochromator=Slit() SETTING [Slit:0]"); stracpy(_slitMonochromator_var._name, "slitMonochromator", 16384); stracpy(_slitMonochromator_var._type, "Slit", 16384); _slitMonochromator_var._index=67; int current_setpos_index = 67; _slitMonochromator_var._parameters.xmin = - _instrument_var._parameters.MSL / 1000.0; _slitMonochromator_var._parameters.xmax = _instrument_var._parameters.MSR / 1000.0; _slitMonochromator_var._parameters.ymin = - _instrument_var._parameters.MSB / 1000.0; _slitMonochromator_var._parameters.ymax = _instrument_var._parameters.MST / 1000.0; _slitMonochromator_var._parameters.radius = UNSET; _slitMonochromator_var._parameters.xwidth = UNSET; _slitMonochromator_var._parameters.yheight = UNSET; /* component slitMonochromator=Slit() AT ROTATED */ { Coords tc1, tc2; tc1 = coords_set(0,0,0); tc2 = coords_set(0,0,0); Rotation tr1; rot_set_rotation(tr1,0,0,0); rot_set_rotation(tr1, (0.0)*DEG2RAD, (0.0)*DEG2RAD, (0.0)*DEG2RAD); rot_mul(tr1, _aa2_var._rotation_absolute, _slitMonochromator_var._rotation_absolute); rot_transpose(_kMoni3rd_var._rotation_absolute, tr1); rot_mul(_slitMonochromator_var._rotation_absolute, tr1, _slitMonochromator_var._rotation_relative); _slitMonochromator_var._rotation_is_identity = rot_test_identity(_slitMonochromator_var._rotation_relative); tc1 = coords_set( 0, 0, 0.285); rot_transpose(_aa2_var._rotation_absolute, tr1); tc2 = rot_apply(tr1, tc1); _slitMonochromator_var._position_absolute = coords_add(_aa2_var._position_absolute, tc2); tc1 = coords_sub(_kMoni3rd_var._position_absolute, _slitMonochromator_var._position_absolute); _slitMonochromator_var._position_relative = rot_apply(_slitMonochromator_var._rotation_absolute, tc1); } /* slitMonochromator=Slit() AT ROTATED */ DEBUG_COMPONENT("slitMonochromator", _slitMonochromator_var._position_absolute, _slitMonochromator_var._rotation_absolute); instrument->_position_absolute[67] = _slitMonochromator_var._position_absolute; instrument->_position_relative[67] = _slitMonochromator_var._position_relative; _slitMonochromator_var._position_relative_is_zero = coords_test_zero(_slitMonochromator_var._position_relative); instrument->counter_N[67] = instrument->counter_P[67] = instrument->counter_P2[67] = 0; instrument->counter_AbsorbProp[67]= 0; #ifdef USE_NEXUS if(nxhandle) { if ((!mcdotrace) && mcformat && strcasestr(mcformat, "NeXus")) { MPI_MASTER( mccomp_placement_type_nexus(nxhandle,"0066_slitMonochromator", _slitMonochromator_var._position_absolute, _slitMonochromator_var._rotation_absolute, "Slit"); mccomp_param_nexus(nxhandle,"0066_slitMonochromator", "xmin", "UNSET", "- _instrument_var._parameters.MSL / 1000.0","MCNUM"); mccomp_param_nexus(nxhandle,"0066_slitMonochromator", "xmax", "UNSET", "_instrument_var._parameters.MSR / 1000.0","MCNUM"); mccomp_param_nexus(nxhandle,"0066_slitMonochromator", "ymin", "UNSET", "- _instrument_var._parameters.MSB / 1000.0","MCNUM"); mccomp_param_nexus(nxhandle,"0066_slitMonochromator", "ymax", "UNSET", "_instrument_var._parameters.MST / 1000.0","MCNUM"); mccomp_param_nexus(nxhandle,"0066_slitMonochromator", "radius", "UNSET", "UNSET","MCNUM"); mccomp_param_nexus(nxhandle,"0066_slitMonochromator", "xwidth", "UNSET", "UNSET","MCNUM"); mccomp_param_nexus(nxhandle,"0066_slitMonochromator", "yheight", "UNSET", "UNSET","MCNUM"); ); } } else { // fprintf(stderr,"NO NEXUS FILE"); } #endif return(0); } /* _slitMonochromator_setpos */ /* component Perspex=Incoherent() SETTING, POSITION/ROTATION */ int _Perspex_setpos(void) { /* sets initial component parameters, position and rotation */ SIG_MESSAGE("[_Perspex_setpos] component Perspex=Incoherent() SETTING [Incoherent:0]"); stracpy(_Perspex_var._name, "Perspex", 16384); stracpy(_Perspex_var._type, "Incoherent", 16384); _Perspex_var._index=68; int current_setpos_index = 68; _Perspex_var._parameters.geometry[0]='\0'; _Perspex_var._parameters.radius = 0; _Perspex_var._parameters.xwidth = 0.1; _Perspex_var._parameters.yheight = 0.1; _Perspex_var._parameters.zdepth = _instrument_var._parameters.PTHICK; _Perspex_var._parameters.thickness = 0; _Perspex_var._parameters.target_x = 0; _Perspex_var._parameters.target_y = 0; _Perspex_var._parameters.target_z = 0; _Perspex_var._parameters.focus_r = 0; _Perspex_var._parameters.focus_xw = 0; _Perspex_var._parameters.focus_yh = 0; _Perspex_var._parameters.focus_aw = 0; _Perspex_var._parameters.focus_ah = 0; _Perspex_var._parameters.target_index = 0; _Perspex_var._parameters.pack = 1; _Perspex_var._parameters.p_interact = 1e-2; _Perspex_var._parameters.f_QE = 0; _Perspex_var._parameters.gamma = 0; _Perspex_var._parameters.Etrans = 0; _Perspex_var._parameters.deltaE = 0; _Perspex_var._parameters.sigma_abs = 0.019; _Perspex_var._parameters.sigma_inc = 4.7; _Perspex_var._parameters.Vc = 1; _Perspex_var._parameters.concentric = 0; _Perspex_var._parameters.order = 0; /* component Perspex=Incoherent() AT ROTATED */ { Coords tc1, tc2; tc1 = coords_set(0,0,0); tc2 = coords_set(0,0,0); Rotation tr1; rot_set_rotation(tr1,0,0,0); rot_set_rotation(tr1, (0.0)*DEG2RAD, (0.0)*DEG2RAD, (0.0)*DEG2RAD); rot_mul(tr1, _aa2_var._rotation_absolute, _Perspex_var._rotation_absolute); rot_transpose(_slitMonochromator_var._rotation_absolute, tr1); rot_mul(_Perspex_var._rotation_absolute, tr1, _Perspex_var._rotation_relative); _Perspex_var._rotation_is_identity = rot_test_identity(_Perspex_var._rotation_relative); tc1 = coords_set( 0, 0, 0.3); rot_transpose(_aa2_var._rotation_absolute, tr1); tc2 = rot_apply(tr1, tc1); _Perspex_var._position_absolute = coords_add(_aa2_var._position_absolute, tc2); tc1 = coords_sub(_slitMonochromator_var._position_absolute, _Perspex_var._position_absolute); _Perspex_var._position_relative = rot_apply(_Perspex_var._rotation_absolute, tc1); } /* Perspex=Incoherent() AT ROTATED */ DEBUG_COMPONENT("Perspex", _Perspex_var._position_absolute, _Perspex_var._rotation_absolute); instrument->_position_absolute[68] = _Perspex_var._position_absolute; instrument->_position_relative[68] = _Perspex_var._position_relative; _Perspex_var._position_relative_is_zero = coords_test_zero(_Perspex_var._position_relative); instrument->counter_N[68] = instrument->counter_P[68] = instrument->counter_P2[68] = 0; instrument->counter_AbsorbProp[68]= 0; #ifdef USE_NEXUS if(nxhandle) { if ((!mcdotrace) && mcformat && strcasestr(mcformat, "NeXus")) { MPI_MASTER( mccomp_placement_type_nexus(nxhandle,"0067_Perspex", _Perspex_var._position_absolute, _Perspex_var._rotation_absolute, "Incoherent"); mccomp_param_nexus(nxhandle,"0067_Perspex", "geometry", 0, 0, "char*"); mccomp_param_nexus(nxhandle,"0067_Perspex", "radius", "0", "0","MCNUM"); mccomp_param_nexus(nxhandle,"0067_Perspex", "xwidth", "0", "0.1","MCNUM"); mccomp_param_nexus(nxhandle,"0067_Perspex", "yheight", "0", "0.1","MCNUM"); mccomp_param_nexus(nxhandle,"0067_Perspex", "zdepth", "0", "_instrument_var._parameters.PTHICK","MCNUM"); mccomp_param_nexus(nxhandle,"0067_Perspex", "thickness", "0", "0","MCNUM"); mccomp_param_nexus(nxhandle,"0067_Perspex", "target_x", "0", "0","MCNUM"); mccomp_param_nexus(nxhandle,"0067_Perspex", "target_y", "0", "0","MCNUM"); mccomp_param_nexus(nxhandle,"0067_Perspex", "target_z", "0", "0","MCNUM"); mccomp_param_nexus(nxhandle,"0067_Perspex", "focus_r", "0", "0","MCNUM"); mccomp_param_nexus(nxhandle,"0067_Perspex", "focus_xw", "0", "0","MCNUM"); mccomp_param_nexus(nxhandle,"0067_Perspex", "focus_yh", "0", "0","MCNUM"); mccomp_param_nexus(nxhandle,"0067_Perspex", "focus_aw", "0", "0","MCNUM"); mccomp_param_nexus(nxhandle,"0067_Perspex", "focus_ah", "0", "0","MCNUM"); mccomp_param_nexus(nxhandle,"0067_Perspex", "target_index", "0", "0","int"); mccomp_param_nexus(nxhandle,"0067_Perspex", "pack", "1", "1","MCNUM"); mccomp_param_nexus(nxhandle,"0067_Perspex", "p_interact", "1", "1e-2","MCNUM"); mccomp_param_nexus(nxhandle,"0067_Perspex", "f_QE", "0", "0","MCNUM"); mccomp_param_nexus(nxhandle,"0067_Perspex", "gamma", "0", "0","MCNUM"); mccomp_param_nexus(nxhandle,"0067_Perspex", "Etrans", "0", "0","MCNUM"); mccomp_param_nexus(nxhandle,"0067_Perspex", "deltaE", "0", "0","MCNUM"); mccomp_param_nexus(nxhandle,"0067_Perspex", "sigma_abs", "5.08", "0.019","MCNUM"); mccomp_param_nexus(nxhandle,"0067_Perspex", "sigma_inc", "5.08", "4.7","MCNUM"); mccomp_param_nexus(nxhandle,"0067_Perspex", "Vc", "13.827", "1","MCNUM"); mccomp_param_nexus(nxhandle,"0067_Perspex", "concentric", "0", "0","MCNUM"); mccomp_param_nexus(nxhandle,"0067_Perspex", "order", "0", "0","MCNUM"); ); } } else { // fprintf(stderr,"NO NEXUS FILE"); } #endif return(0); } /* _Perspex_setpos */ /* component psd_samplepos_1cm2=PSD_monitor() SETTING, POSITION/ROTATION */ int _psd_samplepos_1cm2_setpos(void) { /* sets initial component parameters, position and rotation */ SIG_MESSAGE("[_psd_samplepos_1cm2_setpos] component psd_samplepos_1cm2=PSD_monitor() SETTING [PSD_monitor:0]"); stracpy(_psd_samplepos_1cm2_var._name, "psd_samplepos_1cm2", 16384); stracpy(_psd_samplepos_1cm2_var._type, "PSD_monitor", 16384); _psd_samplepos_1cm2_var._index=69; int current_setpos_index = 69; _psd_samplepos_1cm2_var._parameters.nx = 90; _psd_samplepos_1cm2_var._parameters.ny = 90; if("psd_samplepos_1cm2.dat" && strlen("psd_samplepos_1cm2.dat")) stracpy(_psd_samplepos_1cm2_var._parameters.filename, "psd_samplepos_1cm2.dat" ? "psd_samplepos_1cm2.dat" : "", 16384); else _psd_samplepos_1cm2_var._parameters.filename[0]='\0'; _psd_samplepos_1cm2_var._parameters.xmin = -0.05; _psd_samplepos_1cm2_var._parameters.xmax = 0.05; _psd_samplepos_1cm2_var._parameters.ymin = -0.05; _psd_samplepos_1cm2_var._parameters.ymax = 0.05; _psd_samplepos_1cm2_var._parameters.xwidth = 0.01; _psd_samplepos_1cm2_var._parameters.yheight = 0.01; _psd_samplepos_1cm2_var._parameters.restore_neutron = 1; _psd_samplepos_1cm2_var._parameters.nowritefile = 0; /* component psd_samplepos_1cm2=PSD_monitor() AT ROTATED */ { Coords tc1, tc2; tc1 = coords_set(0,0,0); tc2 = coords_set(0,0,0); Rotation tr1; rot_set_rotation(tr1,0,0,0); rot_set_rotation(tr1, (0.0)*DEG2RAD, (0.0)*DEG2RAD, (0.0)*DEG2RAD); rot_mul(tr1, _aa2_var._rotation_absolute, _psd_samplepos_1cm2_var._rotation_absolute); rot_transpose(_Perspex_var._rotation_absolute, tr1); rot_mul(_psd_samplepos_1cm2_var._rotation_absolute, tr1, _psd_samplepos_1cm2_var._rotation_relative); _psd_samplepos_1cm2_var._rotation_is_identity = rot_test_identity(_psd_samplepos_1cm2_var._rotation_relative); tc1 = coords_set( 0, 0, dvs); rot_transpose(_aa2_var._rotation_absolute, tr1); tc2 = rot_apply(tr1, tc1); _psd_samplepos_1cm2_var._position_absolute = coords_add(_aa2_var._position_absolute, tc2); tc1 = coords_sub(_Perspex_var._position_absolute, _psd_samplepos_1cm2_var._position_absolute); _psd_samplepos_1cm2_var._position_relative = rot_apply(_psd_samplepos_1cm2_var._rotation_absolute, tc1); } /* psd_samplepos_1cm2=PSD_monitor() AT ROTATED */ DEBUG_COMPONENT("psd_samplepos_1cm2", _psd_samplepos_1cm2_var._position_absolute, _psd_samplepos_1cm2_var._rotation_absolute); instrument->_position_absolute[69] = _psd_samplepos_1cm2_var._position_absolute; instrument->_position_relative[69] = _psd_samplepos_1cm2_var._position_relative; _psd_samplepos_1cm2_var._position_relative_is_zero = coords_test_zero(_psd_samplepos_1cm2_var._position_relative); instrument->counter_N[69] = instrument->counter_P[69] = instrument->counter_P2[69] = 0; instrument->counter_AbsorbProp[69]= 0; #ifdef USE_NEXUS if(nxhandle) { if ((!mcdotrace) && mcformat && strcasestr(mcformat, "NeXus")) { MPI_MASTER( mccomp_placement_type_nexus(nxhandle,"0068_psd_samplepos_1cm2", _psd_samplepos_1cm2_var._position_absolute, _psd_samplepos_1cm2_var._rotation_absolute, "PSD_monitor"); mccomp_param_nexus(nxhandle,"0068_psd_samplepos_1cm2", "nx", "90", "90","int"); mccomp_param_nexus(nxhandle,"0068_psd_samplepos_1cm2", "ny", "90", "90","int"); mccomp_param_nexus(nxhandle,"0068_psd_samplepos_1cm2", "filename", 0, "psd_samplepos_1cm2.dat", "char*"); mccomp_param_nexus(nxhandle,"0068_psd_samplepos_1cm2", "xmin", "-0.05", "-0.05","MCNUM"); mccomp_param_nexus(nxhandle,"0068_psd_samplepos_1cm2", "xmax", "0.05", "0.05","MCNUM"); mccomp_param_nexus(nxhandle,"0068_psd_samplepos_1cm2", "ymin", "-0.05", "-0.05","MCNUM"); mccomp_param_nexus(nxhandle,"0068_psd_samplepos_1cm2", "ymax", "0.05", "0.05","MCNUM"); mccomp_param_nexus(nxhandle,"0068_psd_samplepos_1cm2", "xwidth", "0", "0.01","MCNUM"); mccomp_param_nexus(nxhandle,"0068_psd_samplepos_1cm2", "yheight", "0", "0.01","MCNUM"); mccomp_param_nexus(nxhandle,"0068_psd_samplepos_1cm2", "restore_neutron", "0", "1","int"); mccomp_param_nexus(nxhandle,"0068_psd_samplepos_1cm2", "nowritefile", "0", "0","int"); ); } } else { // fprintf(stderr,"NO NEXUS FILE"); } #endif return(0); } /* _psd_samplepos_1cm2_setpos */ /* component emon_samplepos_1cm2=E_monitor() SETTING, POSITION/ROTATION */ int _emon_samplepos_1cm2_setpos(void) { /* sets initial component parameters, position and rotation */ SIG_MESSAGE("[_emon_samplepos_1cm2_setpos] component emon_samplepos_1cm2=E_monitor() SETTING [E_monitor:0]"); stracpy(_emon_samplepos_1cm2_var._name, "emon_samplepos_1cm2", 16384); stracpy(_emon_samplepos_1cm2_var._type, "E_monitor", 16384); _emon_samplepos_1cm2_var._index=70; int current_setpos_index = 70; _emon_samplepos_1cm2_var._parameters.nE = 100; if("emon_samplepos_1cm2.dat" && strlen("emon_samplepos_1cm2.dat")) stracpy(_emon_samplepos_1cm2_var._parameters.filename, "emon_samplepos_1cm2.dat" ? "emon_samplepos_1cm2.dat" : "", 16384); else _emon_samplepos_1cm2_var._parameters.filename[0]='\0'; _emon_samplepos_1cm2_var._parameters.xmin = -0.05; _emon_samplepos_1cm2_var._parameters.xmax = 0.05; _emon_samplepos_1cm2_var._parameters.ymin = -0.05; _emon_samplepos_1cm2_var._parameters.ymax = 0.05; _emon_samplepos_1cm2_var._parameters.nowritefile = 0; _emon_samplepos_1cm2_var._parameters.xwidth = 0.01; _emon_samplepos_1cm2_var._parameters.yheight = 0.01; _emon_samplepos_1cm2_var._parameters.Emin = emini; _emon_samplepos_1cm2_var._parameters.Emax = emaxi; _emon_samplepos_1cm2_var._parameters.restore_neutron = 1; /* component emon_samplepos_1cm2=E_monitor() AT ROTATED */ { Coords tc1, tc2; tc1 = coords_set(0,0,0); tc2 = coords_set(0,0,0); Rotation tr1; rot_set_rotation(tr1,0,0,0); rot_set_rotation(tr1, (0.0)*DEG2RAD, (0.0)*DEG2RAD, (0.0)*DEG2RAD); rot_mul(tr1, _aa2_var._rotation_absolute, _emon_samplepos_1cm2_var._rotation_absolute); rot_transpose(_psd_samplepos_1cm2_var._rotation_absolute, tr1); rot_mul(_emon_samplepos_1cm2_var._rotation_absolute, tr1, _emon_samplepos_1cm2_var._rotation_relative); _emon_samplepos_1cm2_var._rotation_is_identity = rot_test_identity(_emon_samplepos_1cm2_var._rotation_relative); tc1 = coords_set( 0, 0, dvs); rot_transpose(_aa2_var._rotation_absolute, tr1); tc2 = rot_apply(tr1, tc1); _emon_samplepos_1cm2_var._position_absolute = coords_add(_aa2_var._position_absolute, tc2); tc1 = coords_sub(_psd_samplepos_1cm2_var._position_absolute, _emon_samplepos_1cm2_var._position_absolute); _emon_samplepos_1cm2_var._position_relative = rot_apply(_emon_samplepos_1cm2_var._rotation_absolute, tc1); } /* emon_samplepos_1cm2=E_monitor() AT ROTATED */ DEBUG_COMPONENT("emon_samplepos_1cm2", _emon_samplepos_1cm2_var._position_absolute, _emon_samplepos_1cm2_var._rotation_absolute); instrument->_position_absolute[70] = _emon_samplepos_1cm2_var._position_absolute; instrument->_position_relative[70] = _emon_samplepos_1cm2_var._position_relative; _emon_samplepos_1cm2_var._position_relative_is_zero = coords_test_zero(_emon_samplepos_1cm2_var._position_relative); instrument->counter_N[70] = instrument->counter_P[70] = instrument->counter_P2[70] = 0; instrument->counter_AbsorbProp[70]= 0; #ifdef USE_NEXUS if(nxhandle) { if ((!mcdotrace) && mcformat && strcasestr(mcformat, "NeXus")) { MPI_MASTER( mccomp_placement_type_nexus(nxhandle,"0069_emon_samplepos_1cm2", _emon_samplepos_1cm2_var._position_absolute, _emon_samplepos_1cm2_var._rotation_absolute, "E_monitor"); mccomp_param_nexus(nxhandle,"0069_emon_samplepos_1cm2", "nE", "20", "100","int"); mccomp_param_nexus(nxhandle,"0069_emon_samplepos_1cm2", "filename", 0, "emon_samplepos_1cm2.dat", "char*"); mccomp_param_nexus(nxhandle,"0069_emon_samplepos_1cm2", "xmin", "-0.05", "-0.05","MCNUM"); mccomp_param_nexus(nxhandle,"0069_emon_samplepos_1cm2", "xmax", "0.05", "0.05","MCNUM"); mccomp_param_nexus(nxhandle,"0069_emon_samplepos_1cm2", "ymin", "-0.05", "-0.05","MCNUM"); mccomp_param_nexus(nxhandle,"0069_emon_samplepos_1cm2", "ymax", "0.05", "0.05","MCNUM"); mccomp_param_nexus(nxhandle,"0069_emon_samplepos_1cm2", "nowritefile", "0", "0","int"); mccomp_param_nexus(nxhandle,"0069_emon_samplepos_1cm2", "xwidth", "0", "0.01","MCNUM"); mccomp_param_nexus(nxhandle,"0069_emon_samplepos_1cm2", "yheight", "0", "0.01","MCNUM"); mccomp_param_nexus(nxhandle,"0069_emon_samplepos_1cm2", "Emin", "NONE", "emini","MCNUM"); mccomp_param_nexus(nxhandle,"0069_emon_samplepos_1cm2", "Emax", "NONE", "emaxi","MCNUM"); mccomp_param_nexus(nxhandle,"0069_emon_samplepos_1cm2", "restore_neutron", "0", "1","int"); ); } } else { // fprintf(stderr,"NO NEXUS FILE"); } #endif return(0); } /* _emon_samplepos_1cm2_setpos */ /* component divmon_samplepos_1cm2=Divergence_monitor() SETTING, POSITION/ROTATION */ int _divmon_samplepos_1cm2_setpos(void) { /* sets initial component parameters, position and rotation */ SIG_MESSAGE("[_divmon_samplepos_1cm2_setpos] component divmon_samplepos_1cm2=Divergence_monitor() SETTING [Divergence_monitor:0]"); stracpy(_divmon_samplepos_1cm2_var._name, "divmon_samplepos_1cm2", 16384); stracpy(_divmon_samplepos_1cm2_var._type, "Divergence_monitor", 16384); _divmon_samplepos_1cm2_var._index=71; int current_setpos_index = 71; _divmon_samplepos_1cm2_var._parameters.nh = 128; _divmon_samplepos_1cm2_var._parameters.nv = 128; if("divmon_samplepos_1cm2.dat" && strlen("divmon_samplepos_1cm2.dat")) stracpy(_divmon_samplepos_1cm2_var._parameters.filename, "divmon_samplepos_1cm2.dat" ? "divmon_samplepos_1cm2.dat" : "", 16384); else _divmon_samplepos_1cm2_var._parameters.filename[0]='\0'; _divmon_samplepos_1cm2_var._parameters.xmin = -0.05; _divmon_samplepos_1cm2_var._parameters.xmax = 0.05; _divmon_samplepos_1cm2_var._parameters.ymin = -0.05; _divmon_samplepos_1cm2_var._parameters.ymax = 0.05; _divmon_samplepos_1cm2_var._parameters.nowritefile = 0; _divmon_samplepos_1cm2_var._parameters.xwidth = 0.01; _divmon_samplepos_1cm2_var._parameters.yheight = 0.01; _divmon_samplepos_1cm2_var._parameters.maxdiv_h = 3; _divmon_samplepos_1cm2_var._parameters.maxdiv_v = 3; _divmon_samplepos_1cm2_var._parameters.restore_neutron = 1; _divmon_samplepos_1cm2_var._parameters.nx = 0; _divmon_samplepos_1cm2_var._parameters.ny = 0; _divmon_samplepos_1cm2_var._parameters.nz = 1; /* component divmon_samplepos_1cm2=Divergence_monitor() AT ROTATED */ { Coords tc1, tc2; tc1 = coords_set(0,0,0); tc2 = coords_set(0,0,0); Rotation tr1; rot_set_rotation(tr1,0,0,0); rot_set_rotation(tr1, (0.0)*DEG2RAD, (0.0)*DEG2RAD, (0.0)*DEG2RAD); rot_mul(tr1, _aa2_var._rotation_absolute, _divmon_samplepos_1cm2_var._rotation_absolute); rot_transpose(_emon_samplepos_1cm2_var._rotation_absolute, tr1); rot_mul(_divmon_samplepos_1cm2_var._rotation_absolute, tr1, _divmon_samplepos_1cm2_var._rotation_relative); _divmon_samplepos_1cm2_var._rotation_is_identity = rot_test_identity(_divmon_samplepos_1cm2_var._rotation_relative); tc1 = coords_set( 0, 0, dvs); rot_transpose(_aa2_var._rotation_absolute, tr1); tc2 = rot_apply(tr1, tc1); _divmon_samplepos_1cm2_var._position_absolute = coords_add(_aa2_var._position_absolute, tc2); tc1 = coords_sub(_emon_samplepos_1cm2_var._position_absolute, _divmon_samplepos_1cm2_var._position_absolute); _divmon_samplepos_1cm2_var._position_relative = rot_apply(_divmon_samplepos_1cm2_var._rotation_absolute, tc1); } /* divmon_samplepos_1cm2=Divergence_monitor() AT ROTATED */ DEBUG_COMPONENT("divmon_samplepos_1cm2", _divmon_samplepos_1cm2_var._position_absolute, _divmon_samplepos_1cm2_var._rotation_absolute); instrument->_position_absolute[71] = _divmon_samplepos_1cm2_var._position_absolute; instrument->_position_relative[71] = _divmon_samplepos_1cm2_var._position_relative; _divmon_samplepos_1cm2_var._position_relative_is_zero = coords_test_zero(_divmon_samplepos_1cm2_var._position_relative); instrument->counter_N[71] = instrument->counter_P[71] = instrument->counter_P2[71] = 0; instrument->counter_AbsorbProp[71]= 0; #ifdef USE_NEXUS if(nxhandle) { if ((!mcdotrace) && mcformat && strcasestr(mcformat, "NeXus")) { MPI_MASTER( mccomp_placement_type_nexus(nxhandle,"0070_divmon_samplepos_1cm2", _divmon_samplepos_1cm2_var._position_absolute, _divmon_samplepos_1cm2_var._rotation_absolute, "Divergence_monitor"); mccomp_param_nexus(nxhandle,"0070_divmon_samplepos_1cm2", "nh", "20", "128","int"); mccomp_param_nexus(nxhandle,"0070_divmon_samplepos_1cm2", "nv", "20", "128","int"); mccomp_param_nexus(nxhandle,"0070_divmon_samplepos_1cm2", "filename", 0, "divmon_samplepos_1cm2.dat", "char*"); mccomp_param_nexus(nxhandle,"0070_divmon_samplepos_1cm2", "xmin", "-0.05", "-0.05","MCNUM"); mccomp_param_nexus(nxhandle,"0070_divmon_samplepos_1cm2", "xmax", "0.05", "0.05","MCNUM"); mccomp_param_nexus(nxhandle,"0070_divmon_samplepos_1cm2", "ymin", "-0.05", "-0.05","MCNUM"); mccomp_param_nexus(nxhandle,"0070_divmon_samplepos_1cm2", "ymax", "0.05", "0.05","MCNUM"); mccomp_param_nexus(nxhandle,"0070_divmon_samplepos_1cm2", "nowritefile", "0", "0","int"); mccomp_param_nexus(nxhandle,"0070_divmon_samplepos_1cm2", "xwidth", "0", "0.01","MCNUM"); mccomp_param_nexus(nxhandle,"0070_divmon_samplepos_1cm2", "yheight", "0", "0.01","MCNUM"); mccomp_param_nexus(nxhandle,"0070_divmon_samplepos_1cm2", "maxdiv_h", "2", "3","MCNUM"); mccomp_param_nexus(nxhandle,"0070_divmon_samplepos_1cm2", "maxdiv_v", "2", "3","MCNUM"); mccomp_param_nexus(nxhandle,"0070_divmon_samplepos_1cm2", "restore_neutron", "0", "1","int"); mccomp_param_nexus(nxhandle,"0070_divmon_samplepos_1cm2", "nx", "0", "0","MCNUM"); mccomp_param_nexus(nxhandle,"0070_divmon_samplepos_1cm2", "ny", "0", "0","MCNUM"); mccomp_param_nexus(nxhandle,"0070_divmon_samplepos_1cm2", "nz", "1", "1","MCNUM"); ); } } else { // fprintf(stderr,"NO NEXUS FILE"); } #endif return(0); } /* _divmon_samplepos_1cm2_setpos */ /* component psd_samplepos_large=PSD_monitor() SETTING, POSITION/ROTATION */ int _psd_samplepos_large_setpos(void) { /* sets initial component parameters, position and rotation */ SIG_MESSAGE("[_psd_samplepos_large_setpos] component psd_samplepos_large=PSD_monitor() SETTING [PSD_monitor:0]"); stracpy(_psd_samplepos_large_var._name, "psd_samplepos_large", 16384); stracpy(_psd_samplepos_large_var._type, "PSD_monitor", 16384); _psd_samplepos_large_var._index=72; int current_setpos_index = 72; _psd_samplepos_large_var._parameters.nx = 90; _psd_samplepos_large_var._parameters.ny = 90; if("psd_samplepos_large.dat" && strlen("psd_samplepos_large.dat")) stracpy(_psd_samplepos_large_var._parameters.filename, "psd_samplepos_large.dat" ? "psd_samplepos_large.dat" : "", 16384); else _psd_samplepos_large_var._parameters.filename[0]='\0'; _psd_samplepos_large_var._parameters.xmin = -0.05; _psd_samplepos_large_var._parameters.xmax = 0.05; _psd_samplepos_large_var._parameters.ymin = -0.05; _psd_samplepos_large_var._parameters.ymax = 0.05; _psd_samplepos_large_var._parameters.xwidth = 0.06; _psd_samplepos_large_var._parameters.yheight = 0.06; _psd_samplepos_large_var._parameters.restore_neutron = 1; _psd_samplepos_large_var._parameters.nowritefile = 0; /* component psd_samplepos_large=PSD_monitor() AT ROTATED */ { Coords tc1, tc2; tc1 = coords_set(0,0,0); tc2 = coords_set(0,0,0); Rotation tr1; rot_set_rotation(tr1,0,0,0); rot_set_rotation(tr1, (0.0)*DEG2RAD, (0.0)*DEG2RAD, (0.0)*DEG2RAD); rot_mul(tr1, _aa2_var._rotation_absolute, _psd_samplepos_large_var._rotation_absolute); rot_transpose(_divmon_samplepos_1cm2_var._rotation_absolute, tr1); rot_mul(_psd_samplepos_large_var._rotation_absolute, tr1, _psd_samplepos_large_var._rotation_relative); _psd_samplepos_large_var._rotation_is_identity = rot_test_identity(_psd_samplepos_large_var._rotation_relative); tc1 = coords_set( 0, 0, dvs); rot_transpose(_aa2_var._rotation_absolute, tr1); tc2 = rot_apply(tr1, tc1); _psd_samplepos_large_var._position_absolute = coords_add(_aa2_var._position_absolute, tc2); tc1 = coords_sub(_divmon_samplepos_1cm2_var._position_absolute, _psd_samplepos_large_var._position_absolute); _psd_samplepos_large_var._position_relative = rot_apply(_psd_samplepos_large_var._rotation_absolute, tc1); } /* psd_samplepos_large=PSD_monitor() AT ROTATED */ DEBUG_COMPONENT("psd_samplepos_large", _psd_samplepos_large_var._position_absolute, _psd_samplepos_large_var._rotation_absolute); instrument->_position_absolute[72] = _psd_samplepos_large_var._position_absolute; instrument->_position_relative[72] = _psd_samplepos_large_var._position_relative; _psd_samplepos_large_var._position_relative_is_zero = coords_test_zero(_psd_samplepos_large_var._position_relative); instrument->counter_N[72] = instrument->counter_P[72] = instrument->counter_P2[72] = 0; instrument->counter_AbsorbProp[72]= 0; #ifdef USE_NEXUS if(nxhandle) { if ((!mcdotrace) && mcformat && strcasestr(mcformat, "NeXus")) { MPI_MASTER( mccomp_placement_type_nexus(nxhandle,"0071_psd_samplepos_large", _psd_samplepos_large_var._position_absolute, _psd_samplepos_large_var._rotation_absolute, "PSD_monitor"); mccomp_param_nexus(nxhandle,"0071_psd_samplepos_large", "nx", "90", "90","int"); mccomp_param_nexus(nxhandle,"0071_psd_samplepos_large", "ny", "90", "90","int"); mccomp_param_nexus(nxhandle,"0071_psd_samplepos_large", "filename", 0, "psd_samplepos_large.dat", "char*"); mccomp_param_nexus(nxhandle,"0071_psd_samplepos_large", "xmin", "-0.05", "-0.05","MCNUM"); mccomp_param_nexus(nxhandle,"0071_psd_samplepos_large", "xmax", "0.05", "0.05","MCNUM"); mccomp_param_nexus(nxhandle,"0071_psd_samplepos_large", "ymin", "-0.05", "-0.05","MCNUM"); mccomp_param_nexus(nxhandle,"0071_psd_samplepos_large", "ymax", "0.05", "0.05","MCNUM"); mccomp_param_nexus(nxhandle,"0071_psd_samplepos_large", "xwidth", "0", "0.06","MCNUM"); mccomp_param_nexus(nxhandle,"0071_psd_samplepos_large", "yheight", "0", "0.06","MCNUM"); mccomp_param_nexus(nxhandle,"0071_psd_samplepos_large", "restore_neutron", "0", "1","int"); mccomp_param_nexus(nxhandle,"0071_psd_samplepos_large", "nowritefile", "0", "0","int"); ); } } else { // fprintf(stderr,"NO NEXUS FILE"); } #endif return(0); } /* _psd_samplepos_large_setpos */ /* component a3=Arm() SETTING, POSITION/ROTATION */ int _a3_setpos(void) { /* sets initial component parameters, position and rotation */ SIG_MESSAGE("[_a3_setpos] component a3=Arm() SETTING [Arm:0]"); stracpy(_a3_var._name, "a3", 16384); stracpy(_a3_var._type, "Arm", 16384); _a3_var._index=73; int current_setpos_index = 73; /* component a3=Arm() AT ROTATED */ { Coords tc1, tc2; tc1 = coords_set(0,0,0); tc2 = coords_set(0,0,0); Rotation tr1; rot_set_rotation(tr1,0,0,0); rot_set_rotation(tr1, (0)*DEG2RAD, (machine_real . a3)*DEG2RAD, (0)*DEG2RAD); rot_mul(tr1, _aa2_var._rotation_absolute, _a3_var._rotation_absolute); rot_transpose(_psd_samplepos_large_var._rotation_absolute, tr1); rot_mul(_a3_var._rotation_absolute, tr1, _a3_var._rotation_relative); _a3_var._rotation_is_identity = rot_test_identity(_a3_var._rotation_relative); tc1 = coords_set( 0, 0, dvs); rot_transpose(_aa2_var._rotation_absolute, tr1); tc2 = rot_apply(tr1, tc1); _a3_var._position_absolute = coords_add(_aa2_var._position_absolute, tc2); tc1 = coords_sub(_psd_samplepos_large_var._position_absolute, _a3_var._position_absolute); _a3_var._position_relative = rot_apply(_a3_var._rotation_absolute, tc1); } /* a3=Arm() AT ROTATED */ DEBUG_COMPONENT("a3", _a3_var._position_absolute, _a3_var._rotation_absolute); instrument->_position_absolute[73] = _a3_var._position_absolute; instrument->_position_relative[73] = _a3_var._position_relative; _a3_var._position_relative_is_zero = coords_test_zero(_a3_var._position_relative); instrument->counter_N[73] = instrument->counter_P[73] = instrument->counter_P2[73] = 0; instrument->counter_AbsorbProp[73]= 0; #ifdef USE_NEXUS if(nxhandle) { if ((!mcdotrace) && mcformat && strcasestr(mcformat, "NeXus")) { MPI_MASTER( mccomp_placement_type_nexus(nxhandle,"0072_a3", _a3_var._position_absolute, _a3_var._rotation_absolute, "Arm"); ); } } else { // fprintf(stderr,"NO NEXUS FILE"); } #endif return(0); } /* _a3_setpos */ /* component aa3=Arm() SETTING, POSITION/ROTATION */ int _aa3_setpos(void) { /* sets initial component parameters, position and rotation */ SIG_MESSAGE("[_aa3_setpos] component aa3=Arm() SETTING [Arm:0]"); stracpy(_aa3_var._name, "aa3", 16384); stracpy(_aa3_var._type, "Arm", 16384); _aa3_var._index=74; int current_setpos_index = 74; /* component aa3=Arm() AT ROTATED */ { Coords tc1, tc2; tc1 = coords_set(0,0,0); tc2 = coords_set(0,0,0); Rotation tr1; rot_set_rotation(tr1,0,0,0); rot_set_rotation(tr1, (0)*DEG2RAD, (0)*DEG2RAD, (_instrument_var._parameters.TILT)*DEG2RAD); rot_mul(tr1, _a3_var._rotation_absolute, _aa3_var._rotation_absolute); rot_transpose(_psd_samplepos_large_var._rotation_absolute, tr1); rot_mul(_aa3_var._rotation_absolute, tr1, _aa3_var._rotation_relative); _aa3_var._rotation_is_identity = rot_test_identity(_aa3_var._rotation_relative); tc1 = coords_set( 0, 0, 0); rot_transpose(_a3_var._rotation_absolute, tr1); tc2 = rot_apply(tr1, tc1); _aa3_var._position_absolute = coords_add(_a3_var._position_absolute, tc2); tc1 = coords_sub(_psd_samplepos_large_var._position_absolute, _aa3_var._position_absolute); _aa3_var._position_relative = rot_apply(_aa3_var._rotation_absolute, tc1); } /* aa3=Arm() AT ROTATED */ DEBUG_COMPONENT("aa3", _aa3_var._position_absolute, _aa3_var._rotation_absolute); instrument->_position_absolute[74] = _aa3_var._position_absolute; instrument->_position_relative[74] = _aa3_var._position_relative; _aa3_var._position_relative_is_zero = coords_test_zero(_aa3_var._position_relative); instrument->counter_N[74] = instrument->counter_P[74] = instrument->counter_P2[74] = 0; instrument->counter_AbsorbProp[74]= 0; #ifdef USE_NEXUS if(nxhandle) { if ((!mcdotrace) && mcformat && strcasestr(mcformat, "NeXus")) { MPI_MASTER( mccomp_placement_type_nexus(nxhandle,"0073_aa3", _aa3_var._position_absolute, _aa3_var._rotation_absolute, "Arm"); ); } } else { // fprintf(stderr,"NO NEXUS FILE"); } #endif return(0); } /* _aa3_setpos */ /* component incohSample=Incoherent() SETTING, POSITION/ROTATION */ int _incohSample_setpos(void) { /* sets initial component parameters, position and rotation */ SIG_MESSAGE("[_incohSample_setpos] component incohSample=Incoherent() SETTING [Incoherent:0]"); stracpy(_incohSample_var._name, "incohSample", 16384); stracpy(_incohSample_var._type, "Incoherent", 16384); _incohSample_var._index=75; int current_setpos_index = 75; _incohSample_var._parameters.geometry[0]='\0'; _incohSample_var._parameters.radius = 0.0201 / 2; _incohSample_var._parameters.xwidth = 0; _incohSample_var._parameters.yheight = 0.0187; _incohSample_var._parameters.zdepth = 0; _incohSample_var._parameters.thickness = 0.0201 / 2 -0.0149 / 2; _incohSample_var._parameters.target_x = 0; _incohSample_var._parameters.target_y = 0; _incohSample_var._parameters.target_z = 0; _incohSample_var._parameters.focus_r = 0; _incohSample_var._parameters.focus_xw = 0.16; _incohSample_var._parameters.focus_yh = 0.16; _incohSample_var._parameters.focus_aw = 0; _incohSample_var._parameters.focus_ah = 0; _incohSample_var._parameters.target_index = 10; _incohSample_var._parameters.pack = 1; _incohSample_var._parameters.p_interact = 1; _incohSample_var._parameters.f_QE = 0; _incohSample_var._parameters.gamma = 0; _incohSample_var._parameters.Etrans = 0; _incohSample_var._parameters.deltaE = 0; _incohSample_var._parameters.sigma_abs = 5.08; _incohSample_var._parameters.sigma_inc = 5.08; _incohSample_var._parameters.Vc = 13.827; _incohSample_var._parameters.concentric = 0; _incohSample_var._parameters.order = 0; /* component incohSample=Incoherent() AT ROTATED */ { Coords tc1, tc2; tc1 = coords_set(0,0,0); tc2 = coords_set(0,0,0); Rotation tr1; rot_set_rotation(tr1,0,0,0); rot_set_rotation(tr1, (0.0)*DEG2RAD, (0.0)*DEG2RAD, (0.0)*DEG2RAD); rot_mul(tr1, _aa3_var._rotation_absolute, _incohSample_var._rotation_absolute); rot_transpose(_psd_samplepos_large_var._rotation_absolute, tr1); rot_mul(_incohSample_var._rotation_absolute, tr1, _incohSample_var._rotation_relative); _incohSample_var._rotation_is_identity = rot_test_identity(_incohSample_var._rotation_relative); tc1 = coords_set( 0, 0, 0); rot_transpose(_aa3_var._rotation_absolute, tr1); tc2 = rot_apply(tr1, tc1); _incohSample_var._position_absolute = coords_add(_aa3_var._position_absolute, tc2); tc1 = coords_sub(_psd_samplepos_large_var._position_absolute, _incohSample_var._position_absolute); _incohSample_var._position_relative = rot_apply(_incohSample_var._rotation_absolute, tc1); } /* incohSample=Incoherent() AT ROTATED */ DEBUG_COMPONENT("incohSample", _incohSample_var._position_absolute, _incohSample_var._rotation_absolute); instrument->_position_absolute[75] = _incohSample_var._position_absolute; instrument->_position_relative[75] = _incohSample_var._position_relative; _incohSample_var._position_relative_is_zero = coords_test_zero(_incohSample_var._position_relative); instrument->counter_N[75] = instrument->counter_P[75] = instrument->counter_P2[75] = 0; instrument->counter_AbsorbProp[75]= 0; #ifdef USE_NEXUS if(nxhandle) { if ((!mcdotrace) && mcformat && strcasestr(mcformat, "NeXus")) { MPI_MASTER( mccomp_placement_type_nexus(nxhandle,"0074_incohSample", _incohSample_var._position_absolute, _incohSample_var._rotation_absolute, "Incoherent"); mccomp_param_nexus(nxhandle,"0074_incohSample", "geometry", 0, 0, "char*"); mccomp_param_nexus(nxhandle,"0074_incohSample", "radius", "0", "0.0201 / 2","MCNUM"); mccomp_param_nexus(nxhandle,"0074_incohSample", "xwidth", "0", "0","MCNUM"); mccomp_param_nexus(nxhandle,"0074_incohSample", "yheight", "0", "0.0187","MCNUM"); mccomp_param_nexus(nxhandle,"0074_incohSample", "zdepth", "0", "0","MCNUM"); mccomp_param_nexus(nxhandle,"0074_incohSample", "thickness", "0", "0.0201 / 2 -0.0149 / 2","MCNUM"); mccomp_param_nexus(nxhandle,"0074_incohSample", "target_x", "0", "0","MCNUM"); mccomp_param_nexus(nxhandle,"0074_incohSample", "target_y", "0", "0","MCNUM"); mccomp_param_nexus(nxhandle,"0074_incohSample", "target_z", "0", "0","MCNUM"); mccomp_param_nexus(nxhandle,"0074_incohSample", "focus_r", "0", "0","MCNUM"); mccomp_param_nexus(nxhandle,"0074_incohSample", "focus_xw", "0", "0.16","MCNUM"); mccomp_param_nexus(nxhandle,"0074_incohSample", "focus_yh", "0", "0.16","MCNUM"); mccomp_param_nexus(nxhandle,"0074_incohSample", "focus_aw", "0", "0","MCNUM"); mccomp_param_nexus(nxhandle,"0074_incohSample", "focus_ah", "0", "0","MCNUM"); mccomp_param_nexus(nxhandle,"0074_incohSample", "target_index", "0", "10","int"); mccomp_param_nexus(nxhandle,"0074_incohSample", "pack", "1", "1","MCNUM"); mccomp_param_nexus(nxhandle,"0074_incohSample", "p_interact", "1", "1","MCNUM"); mccomp_param_nexus(nxhandle,"0074_incohSample", "f_QE", "0", "0","MCNUM"); mccomp_param_nexus(nxhandle,"0074_incohSample", "gamma", "0", "0","MCNUM"); mccomp_param_nexus(nxhandle,"0074_incohSample", "Etrans", "0", "0","MCNUM"); mccomp_param_nexus(nxhandle,"0074_incohSample", "deltaE", "0", "0","MCNUM"); mccomp_param_nexus(nxhandle,"0074_incohSample", "sigma_abs", "5.08", "5.08","MCNUM"); mccomp_param_nexus(nxhandle,"0074_incohSample", "sigma_inc", "5.08", "5.08","MCNUM"); mccomp_param_nexus(nxhandle,"0074_incohSample", "Vc", "13.827", "13.827","MCNUM"); mccomp_param_nexus(nxhandle,"0074_incohSample", "concentric", "0", "0","MCNUM"); mccomp_param_nexus(nxhandle,"0074_incohSample", "order", "0", "0","MCNUM"); ); } } else { // fprintf(stderr,"NO NEXUS FILE"); } #endif return(0); } /* _incohSample_setpos */ /* component powderSample=PowderN() SETTING, POSITION/ROTATION */ int _powderSample_setpos(void) { /* sets initial component parameters, position and rotation */ SIG_MESSAGE("[_powderSample_setpos] component powderSample=PowderN() SETTING [PowderN:0]"); stracpy(_powderSample_var._name, "powderSample", 16384); stracpy(_powderSample_var._type, "PowderN", 16384); _powderSample_var._index=76; int current_setpos_index = 76; if(PowderFile && strlen(PowderFile)) stracpy(_powderSample_var._parameters.reflections, PowderFile ? PowderFile : "", 16384); else _powderSample_var._parameters.reflections[0]='\0'; if("NULL" && strlen("NULL")) stracpy(_powderSample_var._parameters.geometry, "NULL" ? "NULL" : "", 16384); else _powderSample_var._parameters.geometry[0]='\0'; _powderSample_var._parameters.format[0] = 0; _powderSample_var._parameters.format[1] = 0; _powderSample_var._parameters.format[2] = 0; _powderSample_var._parameters.format[3] = 0; _powderSample_var._parameters.format[4] = 0; _powderSample_var._parameters.format[5] = 0; _powderSample_var._parameters.format[6] = 0; _powderSample_var._parameters.format[7] = 0; _powderSample_var._parameters.format[8] = 0; _powderSample_var._parameters.radius = 0.0068; _powderSample_var._parameters.yheight = 0.015; _powderSample_var._parameters.xwidth = 0; _powderSample_var._parameters.zdepth = 0; _powderSample_var._parameters.thickness = 0; _powderSample_var._parameters.pack = 1; _powderSample_var._parameters.Vc = 254.52; _powderSample_var._parameters.sigma_abs = 0.4625; _powderSample_var._parameters.sigma_inc = 0.0188; _powderSample_var._parameters.delta_d_d = 0; _powderSample_var._parameters.p_inc = 0; _powderSample_var._parameters.p_transmit = 0.1; _powderSample_var._parameters.DW = 0; _powderSample_var._parameters.nb_atoms = 1; _powderSample_var._parameters.d_omega = 0; _powderSample_var._parameters.d_phi = 12; _powderSample_var._parameters.tth_sign = 0; _powderSample_var._parameters.p_interact = 0.8; _powderSample_var._parameters.concentric = 0; _powderSample_var._parameters.density = 0; _powderSample_var._parameters.weight = 0; _powderSample_var._parameters.barns = _instrument_var._parameters.BARNS; _powderSample_var._parameters.Strain = 0; _powderSample_var._parameters.focus_flip = 0; _powderSample_var._parameters.target_index = 0; _powderSample_var._parameters.order = 1; /* component powderSample=PowderN() AT ROTATED */ { Coords tc1, tc2; tc1 = coords_set(0,0,0); tc2 = coords_set(0,0,0); Rotation tr1; rot_set_rotation(tr1,0,0,0); rot_set_rotation(tr1, (0.0)*DEG2RAD, (0.0)*DEG2RAD, (0.0)*DEG2RAD); rot_mul(tr1, _aa3_var._rotation_absolute, _powderSample_var._rotation_absolute); rot_transpose(_incohSample_var._rotation_absolute, tr1); rot_mul(_powderSample_var._rotation_absolute, tr1, _powderSample_var._rotation_relative); _powderSample_var._rotation_is_identity = rot_test_identity(_powderSample_var._rotation_relative); tc1 = coords_set( 0, 0, 0); rot_transpose(_aa3_var._rotation_absolute, tr1); tc2 = rot_apply(tr1, tc1); _powderSample_var._position_absolute = coords_add(_aa3_var._position_absolute, tc2); tc1 = coords_sub(_incohSample_var._position_absolute, _powderSample_var._position_absolute); _powderSample_var._position_relative = rot_apply(_powderSample_var._rotation_absolute, tc1); } /* powderSample=PowderN() AT ROTATED */ DEBUG_COMPONENT("powderSample", _powderSample_var._position_absolute, _powderSample_var._rotation_absolute); instrument->_position_absolute[76] = _powderSample_var._position_absolute; instrument->_position_relative[76] = _powderSample_var._position_relative; _powderSample_var._position_relative_is_zero = coords_test_zero(_powderSample_var._position_relative); instrument->counter_N[76] = instrument->counter_P[76] = instrument->counter_P2[76] = 0; instrument->counter_AbsorbProp[76]= 0; #ifdef USE_NEXUS if(nxhandle) { if ((!mcdotrace) && mcformat && strcasestr(mcformat, "NeXus")) { MPI_MASTER( mccomp_placement_type_nexus(nxhandle,"0075_powderSample", _powderSample_var._position_absolute, _powderSample_var._rotation_absolute, "PowderN"); mccomp_param_nexus(nxhandle,"0075_powderSample", "reflections", "NULL", PowderFile, "char*"); mccomp_param_nexus(nxhandle,"0075_powderSample", "geometry", "NULL", "NULL", "char*"); mccomp_param_nexus(nxhandle,"0075_powderSample", "format", "{ 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 }", "{ 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 }","MCNUM"); mccomp_param_nexus(nxhandle,"0075_powderSample", "radius", "0", "0.0068","MCNUM"); mccomp_param_nexus(nxhandle,"0075_powderSample", "yheight", "0", "0.015","MCNUM"); mccomp_param_nexus(nxhandle,"0075_powderSample", "xwidth", "0", "0","MCNUM"); mccomp_param_nexus(nxhandle,"0075_powderSample", "zdepth", "0", "0","MCNUM"); mccomp_param_nexus(nxhandle,"0075_powderSample", "thickness", "0", "0","MCNUM"); mccomp_param_nexus(nxhandle,"0075_powderSample", "pack", "1", "1","MCNUM"); mccomp_param_nexus(nxhandle,"0075_powderSample", "Vc", "0", "254.52","MCNUM"); mccomp_param_nexus(nxhandle,"0075_powderSample", "sigma_abs", "0", "0.4625","MCNUM"); mccomp_param_nexus(nxhandle,"0075_powderSample", "sigma_inc", "0", "0.0188","MCNUM"); mccomp_param_nexus(nxhandle,"0075_powderSample", "delta_d_d", "0", "0","MCNUM"); mccomp_param_nexus(nxhandle,"0075_powderSample", "p_inc", "0.1", "0","MCNUM"); mccomp_param_nexus(nxhandle,"0075_powderSample", "p_transmit", "0.1", "0.1","MCNUM"); mccomp_param_nexus(nxhandle,"0075_powderSample", "DW", "0", "0","MCNUM"); mccomp_param_nexus(nxhandle,"0075_powderSample", "nb_atoms", "1", "1","MCNUM"); mccomp_param_nexus(nxhandle,"0075_powderSample", "d_omega", "0", "0","MCNUM"); mccomp_param_nexus(nxhandle,"0075_powderSample", "d_phi", "0", "12","MCNUM"); mccomp_param_nexus(nxhandle,"0075_powderSample", "tth_sign", "0", "0","MCNUM"); mccomp_param_nexus(nxhandle,"0075_powderSample", "p_interact", "0.8", "0.8","MCNUM"); mccomp_param_nexus(nxhandle,"0075_powderSample", "concentric", "0", "0","MCNUM"); mccomp_param_nexus(nxhandle,"0075_powderSample", "density", "0", "0","MCNUM"); mccomp_param_nexus(nxhandle,"0075_powderSample", "weight", "0", "0","MCNUM"); mccomp_param_nexus(nxhandle,"0075_powderSample", "barns", "1", "_instrument_var._parameters.BARNS","MCNUM"); mccomp_param_nexus(nxhandle,"0075_powderSample", "Strain", "0", "0","MCNUM"); mccomp_param_nexus(nxhandle,"0075_powderSample", "focus_flip", "0", "0","MCNUM"); mccomp_param_nexus(nxhandle,"0075_powderSample", "target_index", "0", "0","int"); mccomp_param_nexus(nxhandle,"0075_powderSample", "order", "1", "1","int"); ); } } else { // fprintf(stderr,"NO NEXUS FILE"); } #endif return(0); } /* _powderSample_setpos */ /* component crystalSample=Single_crystal() SETTING, POSITION/ROTATION */ int _crystalSample_setpos(void) { /* sets initial component parameters, position and rotation */ SIG_MESSAGE("[_crystalSample_setpos] component crystalSample=Single_crystal() SETTING [Single_crystal:0]"); stracpy(_crystalSample_var._name, "crystalSample", 16384); stracpy(_crystalSample_var._type, "Single_crystal", 16384); _crystalSample_var._index=77; int current_setpos_index = 77; if(SingleXFile && strlen(SingleXFile)) stracpy(_crystalSample_var._parameters.reflections, SingleXFile ? SingleXFile : "", 16384); else _crystalSample_var._parameters.reflections[0]='\0'; _crystalSample_var._parameters.geometry[0]='\0'; _crystalSample_var._parameters.mosaic_AB[0] = 0; _crystalSample_var._parameters.mosaic_AB[1] = 0; _crystalSample_var._parameters.mosaic_AB[2] = 0; _crystalSample_var._parameters.mosaic_AB[3] = 0; _crystalSample_var._parameters.mosaic_AB[4] = 0; _crystalSample_var._parameters.mosaic_AB[5] = 0; _crystalSample_var._parameters.mosaic_AB[6] = 0; _crystalSample_var._parameters.mosaic_AB[7] = 0; _crystalSample_var._parameters.xwidth = _instrument_var._parameters.SAMPLESIZE; _crystalSample_var._parameters.yheight = _instrument_var._parameters.SAMPLESIZE; _crystalSample_var._parameters.zdepth = _instrument_var._parameters.SAMPLESIZE; _crystalSample_var._parameters.radius = 0; _crystalSample_var._parameters.delta_d_d = _instrument_var._parameters.DD_D; _crystalSample_var._parameters.mosaic = _instrument_var._parameters.MOS; _crystalSample_var._parameters.mosaic_a = -1; _crystalSample_var._parameters.mosaic_b = -1; _crystalSample_var._parameters.mosaic_c = -1; _crystalSample_var._parameters.recip_cell = 0; _crystalSample_var._parameters.barns = _instrument_var._parameters.BARNS; _crystalSample_var._parameters.ax = _instrument_var._parameters.AAX; _crystalSample_var._parameters.ay = _instrument_var._parameters.AAY; _crystalSample_var._parameters.az = _instrument_var._parameters.AAZ; _crystalSample_var._parameters.bx = _instrument_var._parameters.BBX; _crystalSample_var._parameters.by = _instrument_var._parameters.BBY; _crystalSample_var._parameters.bz = _instrument_var._parameters.BBZ; _crystalSample_var._parameters.cx = _instrument_var._parameters.CCX; _crystalSample_var._parameters.cy = _instrument_var._parameters.CCY; _crystalSample_var._parameters.cz = _instrument_var._parameters.CCZ; _crystalSample_var._parameters.p_transmit = 0.001; _crystalSample_var._parameters.sigma_abs = 0; _crystalSample_var._parameters.sigma_inc = 0; _crystalSample_var._parameters.aa = 0; _crystalSample_var._parameters.bb = 0; _crystalSample_var._parameters.cc = 0; _crystalSample_var._parameters.order = 0; _crystalSample_var._parameters.extra_order = 0; _crystalSample_var._parameters.RX = 0; _crystalSample_var._parameters.RY = 0; _crystalSample_var._parameters.powder = 0; _crystalSample_var._parameters.PG = 0; _crystalSample_var._parameters.deltak = 1e-6; /* component crystalSample=Single_crystal() AT ROTATED */ { Coords tc1, tc2; tc1 = coords_set(0,0,0); tc2 = coords_set(0,0,0); Rotation tr1; rot_set_rotation(tr1,0,0,0); rot_set_rotation(tr1, (0.0)*DEG2RAD, (0.0)*DEG2RAD, (0.0)*DEG2RAD); rot_mul(tr1, _aa3_var._rotation_absolute, _crystalSample_var._rotation_absolute); rot_transpose(_powderSample_var._rotation_absolute, tr1); rot_mul(_crystalSample_var._rotation_absolute, tr1, _crystalSample_var._rotation_relative); _crystalSample_var._rotation_is_identity = rot_test_identity(_crystalSample_var._rotation_relative); tc1 = coords_set( 0, 0, 0); rot_transpose(_aa3_var._rotation_absolute, tr1); tc2 = rot_apply(tr1, tc1); _crystalSample_var._position_absolute = coords_add(_aa3_var._position_absolute, tc2); tc1 = coords_sub(_powderSample_var._position_absolute, _crystalSample_var._position_absolute); _crystalSample_var._position_relative = rot_apply(_crystalSample_var._rotation_absolute, tc1); } /* crystalSample=Single_crystal() AT ROTATED */ DEBUG_COMPONENT("crystalSample", _crystalSample_var._position_absolute, _crystalSample_var._rotation_absolute); instrument->_position_absolute[77] = _crystalSample_var._position_absolute; instrument->_position_relative[77] = _crystalSample_var._position_relative; _crystalSample_var._position_relative_is_zero = coords_test_zero(_crystalSample_var._position_relative); instrument->counter_N[77] = instrument->counter_P[77] = instrument->counter_P2[77] = 0; instrument->counter_AbsorbProp[77]= 0; #ifdef USE_NEXUS if(nxhandle) { if ((!mcdotrace) && mcformat && strcasestr(mcformat, "NeXus")) { MPI_MASTER( mccomp_placement_type_nexus(nxhandle,"0076_crystalSample", _crystalSample_var._position_absolute, _crystalSample_var._rotation_absolute, "Single_crystal"); mccomp_param_nexus(nxhandle,"0076_crystalSample", "reflections", 0, SingleXFile, "char*"); mccomp_param_nexus(nxhandle,"0076_crystalSample", "geometry", 0, 0, "char*"); mccomp_param_nexus(nxhandle,"0076_crystalSample", "mosaic_AB", "{ 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 }", "{ 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 }","MCNUM"); mccomp_param_nexus(nxhandle,"0076_crystalSample", "xwidth", "0", "_instrument_var._parameters.SAMPLESIZE","MCNUM"); mccomp_param_nexus(nxhandle,"0076_crystalSample", "yheight", "0", "_instrument_var._parameters.SAMPLESIZE","MCNUM"); mccomp_param_nexus(nxhandle,"0076_crystalSample", "zdepth", "0", "_instrument_var._parameters.SAMPLESIZE","MCNUM"); mccomp_param_nexus(nxhandle,"0076_crystalSample", "radius", "0", "0","MCNUM"); mccomp_param_nexus(nxhandle,"0076_crystalSample", "delta_d_d", "1e-4", "_instrument_var._parameters.DD_D","MCNUM"); mccomp_param_nexus(nxhandle,"0076_crystalSample", "mosaic", "-1", "_instrument_var._parameters.MOS","MCNUM"); mccomp_param_nexus(nxhandle,"0076_crystalSample", "mosaic_a", "-1", "-1","MCNUM"); mccomp_param_nexus(nxhandle,"0076_crystalSample", "mosaic_b", "-1", "-1","MCNUM"); mccomp_param_nexus(nxhandle,"0076_crystalSample", "mosaic_c", "-1", "-1","MCNUM"); mccomp_param_nexus(nxhandle,"0076_crystalSample", "recip_cell", "0", "0","MCNUM"); mccomp_param_nexus(nxhandle,"0076_crystalSample", "barns", "0", "_instrument_var._parameters.BARNS","MCNUM"); mccomp_param_nexus(nxhandle,"0076_crystalSample", "ax", "0", "_instrument_var._parameters.AAX","MCNUM"); mccomp_param_nexus(nxhandle,"0076_crystalSample", "ay", "0", "_instrument_var._parameters.AAY","MCNUM"); mccomp_param_nexus(nxhandle,"0076_crystalSample", "az", "0", "_instrument_var._parameters.AAZ","MCNUM"); mccomp_param_nexus(nxhandle,"0076_crystalSample", "bx", "0", "_instrument_var._parameters.BBX","MCNUM"); mccomp_param_nexus(nxhandle,"0076_crystalSample", "by", "0", "_instrument_var._parameters.BBY","MCNUM"); mccomp_param_nexus(nxhandle,"0076_crystalSample", "bz", "0", "_instrument_var._parameters.BBZ","MCNUM"); mccomp_param_nexus(nxhandle,"0076_crystalSample", "cx", "0", "_instrument_var._parameters.CCX","MCNUM"); mccomp_param_nexus(nxhandle,"0076_crystalSample", "cy", "0", "_instrument_var._parameters.CCY","MCNUM"); mccomp_param_nexus(nxhandle,"0076_crystalSample", "cz", "0", "_instrument_var._parameters.CCZ","MCNUM"); mccomp_param_nexus(nxhandle,"0076_crystalSample", "p_transmit", "0.001", "0.001","MCNUM"); mccomp_param_nexus(nxhandle,"0076_crystalSample", "sigma_abs", "0", "0","MCNUM"); mccomp_param_nexus(nxhandle,"0076_crystalSample", "sigma_inc", "0", "0","MCNUM"); mccomp_param_nexus(nxhandle,"0076_crystalSample", "aa", "0", "0","MCNUM"); mccomp_param_nexus(nxhandle,"0076_crystalSample", "bb", "0", "0","MCNUM"); mccomp_param_nexus(nxhandle,"0076_crystalSample", "cc", "0", "0","MCNUM"); mccomp_param_nexus(nxhandle,"0076_crystalSample", "order", "0", "0","MCNUM"); mccomp_param_nexus(nxhandle,"0076_crystalSample", "extra_order", "0", "0","MCNUM"); mccomp_param_nexus(nxhandle,"0076_crystalSample", "RX", "0", "0","MCNUM"); mccomp_param_nexus(nxhandle,"0076_crystalSample", "RY", "0", "0","MCNUM"); mccomp_param_nexus(nxhandle,"0076_crystalSample", "powder", "0", "0","MCNUM"); mccomp_param_nexus(nxhandle,"0076_crystalSample", "PG", "0", "0","MCNUM"); mccomp_param_nexus(nxhandle,"0076_crystalSample", "deltak", "1e-6", "1e-6","MCNUM"); ); } } else { // fprintf(stderr,"NO NEXUS FILE"); } #endif return(0); } /* _crystalSample_setpos */ /* component phononSample=Phonon_simple() SETTING, POSITION/ROTATION */ int _phononSample_setpos(void) { /* sets initial component parameters, position and rotation */ SIG_MESSAGE("[_phononSample_setpos] component phononSample=Phonon_simple() SETTING [Phonon_simple:0]"); stracpy(_phononSample_var._name, "phononSample", 16384); stracpy(_phononSample_var._type, "Phonon_simple", 16384); _phononSample_var._index=78; int current_setpos_index = 78; _phononSample_var._parameters.radius = _instrument_var._parameters.SAMPLESIZE / 2; _phononSample_var._parameters.yheight = _instrument_var._parameters.SAMPLESIZE; _phononSample_var._parameters.sigma_abs = 0.171; _phononSample_var._parameters.sigma_inc = 0.003; _phononSample_var._parameters.a = 4.95; _phononSample_var._parameters.b = 4.95; _phononSample_var._parameters.M = 207.2; _phononSample_var._parameters.c = 10; _phononSample_var._parameters.DW = 1; _phononSample_var._parameters.T = 300; _phononSample_var._parameters.target_x = 0; _phononSample_var._parameters.target_y = 0; _phononSample_var._parameters.target_z = 0; _phononSample_var._parameters.target_index = 7; _phononSample_var._parameters.focus_r = 0; _phononSample_var._parameters.focus_xw = 0.16; _phononSample_var._parameters.focus_yh = 0.16; _phononSample_var._parameters.focus_aw = 0; _phononSample_var._parameters.focus_ah = 0; _phononSample_var._parameters.gap = 0; _phononSample_var._parameters.e_steps_low = 50; _phononSample_var._parameters.e_steps_high = 50; /* component phononSample=Phonon_simple() AT ROTATED */ { Coords tc1, tc2; tc1 = coords_set(0,0,0); tc2 = coords_set(0,0,0); Rotation tr1; rot_set_rotation(tr1,0,0,0); rot_set_rotation(tr1, (0.0)*DEG2RAD, (0.0)*DEG2RAD, (0.0)*DEG2RAD); rot_mul(tr1, _aa3_var._rotation_absolute, _phononSample_var._rotation_absolute); rot_transpose(_crystalSample_var._rotation_absolute, tr1); rot_mul(_phononSample_var._rotation_absolute, tr1, _phononSample_var._rotation_relative); _phononSample_var._rotation_is_identity = rot_test_identity(_phononSample_var._rotation_relative); tc1 = coords_set( 0, 0, 0); rot_transpose(_aa3_var._rotation_absolute, tr1); tc2 = rot_apply(tr1, tc1); _phononSample_var._position_absolute = coords_add(_aa3_var._position_absolute, tc2); tc1 = coords_sub(_crystalSample_var._position_absolute, _phononSample_var._position_absolute); _phononSample_var._position_relative = rot_apply(_phononSample_var._rotation_absolute, tc1); } /* phononSample=Phonon_simple() AT ROTATED */ DEBUG_COMPONENT("phononSample", _phononSample_var._position_absolute, _phononSample_var._rotation_absolute); instrument->_position_absolute[78] = _phononSample_var._position_absolute; instrument->_position_relative[78] = _phononSample_var._position_relative; _phononSample_var._position_relative_is_zero = coords_test_zero(_phononSample_var._position_relative); instrument->counter_N[78] = instrument->counter_P[78] = instrument->counter_P2[78] = 0; instrument->counter_AbsorbProp[78]= 0; #ifdef USE_NEXUS if(nxhandle) { if ((!mcdotrace) && mcformat && strcasestr(mcformat, "NeXus")) { MPI_MASTER( mccomp_placement_type_nexus(nxhandle,"0077_phononSample", _phononSample_var._position_absolute, _phononSample_var._rotation_absolute, "Phonon_simple"); mccomp_param_nexus(nxhandle,"0077_phononSample", "radius", "NONE", "_instrument_var._parameters.SAMPLESIZE / 2","MCNUM"); mccomp_param_nexus(nxhandle,"0077_phononSample", "yheight", "NONE", "_instrument_var._parameters.SAMPLESIZE","MCNUM"); mccomp_param_nexus(nxhandle,"0077_phononSample", "sigma_abs", "NONE", "0.171","MCNUM"); mccomp_param_nexus(nxhandle,"0077_phononSample", "sigma_inc", "NONE", "0.003","MCNUM"); mccomp_param_nexus(nxhandle,"0077_phononSample", "a", "NONE", "4.95","MCNUM"); mccomp_param_nexus(nxhandle,"0077_phononSample", "b", "NONE", "4.95","MCNUM"); mccomp_param_nexus(nxhandle,"0077_phononSample", "M", "NONE", "207.2","MCNUM"); mccomp_param_nexus(nxhandle,"0077_phononSample", "c", "NONE", "10","MCNUM"); mccomp_param_nexus(nxhandle,"0077_phononSample", "DW", "NONE", "1","MCNUM"); mccomp_param_nexus(nxhandle,"0077_phononSample", "T", "NONE", "300","MCNUM"); mccomp_param_nexus(nxhandle,"0077_phononSample", "target_x", "0", "0","MCNUM"); mccomp_param_nexus(nxhandle,"0077_phononSample", "target_y", "0", "0","MCNUM"); mccomp_param_nexus(nxhandle,"0077_phononSample", "target_z", "0", "0","MCNUM"); mccomp_param_nexus(nxhandle,"0077_phononSample", "target_index", "0", "7","int"); mccomp_param_nexus(nxhandle,"0077_phononSample", "focus_r", "0", "0","MCNUM"); mccomp_param_nexus(nxhandle,"0077_phononSample", "focus_xw", "0", "0.16","MCNUM"); mccomp_param_nexus(nxhandle,"0077_phononSample", "focus_yh", "0", "0.16","MCNUM"); mccomp_param_nexus(nxhandle,"0077_phononSample", "focus_aw", "0", "0","MCNUM"); mccomp_param_nexus(nxhandle,"0077_phononSample", "focus_ah", "0", "0","MCNUM"); mccomp_param_nexus(nxhandle,"0077_phononSample", "gap", "0", "0","MCNUM"); mccomp_param_nexus(nxhandle,"0077_phononSample", "e_steps_low", "50", "50","int"); mccomp_param_nexus(nxhandle,"0077_phononSample", "e_steps_high", "50", "50","int"); ); } } else { // fprintf(stderr,"NO NEXUS FILE"); } #endif return(0); } /* _phononSample_setpos */ /* component psd_4pi=PSD_monitor_4PI() SETTING, POSITION/ROTATION */ int _psd_4pi_setpos(void) { /* sets initial component parameters, position and rotation */ SIG_MESSAGE("[_psd_4pi_setpos] component psd_4pi=PSD_monitor_4PI() SETTING [PSD_monitor_4PI:0]"); stracpy(_psd_4pi_var._name, "psd_4pi", 16384); stracpy(_psd_4pi_var._type, "PSD_monitor_4PI", 16384); _psd_4pi_var._index=79; int current_setpos_index = 79; _psd_4pi_var._parameters.nx = 1000; _psd_4pi_var._parameters.ny = 1000; if("psd_4pi" && strlen("psd_4pi")) stracpy(_psd_4pi_var._parameters.filename, "psd_4pi" ? "psd_4pi" : "", 16384); else _psd_4pi_var._parameters.filename[0]='\0'; _psd_4pi_var._parameters.nowritefile = 0; _psd_4pi_var._parameters.radius = 0.1; _psd_4pi_var._parameters.restore_neutron = 1; /* component psd_4pi=PSD_monitor_4PI() AT ROTATED */ { Coords tc1, tc2; tc1 = coords_set(0,0,0); tc2 = coords_set(0,0,0); Rotation tr1; rot_set_rotation(tr1,0,0,0); rot_set_rotation(tr1, (0.0)*DEG2RAD, (0.0)*DEG2RAD, (0.0)*DEG2RAD); rot_mul(tr1, _aa2_var._rotation_absolute, _psd_4pi_var._rotation_absolute); rot_transpose(_phononSample_var._rotation_absolute, tr1); rot_mul(_psd_4pi_var._rotation_absolute, tr1, _psd_4pi_var._rotation_relative); _psd_4pi_var._rotation_is_identity = rot_test_identity(_psd_4pi_var._rotation_relative); tc1 = coords_set( 0, 0, dvs); rot_transpose(_aa2_var._rotation_absolute, tr1); tc2 = rot_apply(tr1, tc1); _psd_4pi_var._position_absolute = coords_add(_aa2_var._position_absolute, tc2); tc1 = coords_sub(_phononSample_var._position_absolute, _psd_4pi_var._position_absolute); _psd_4pi_var._position_relative = rot_apply(_psd_4pi_var._rotation_absolute, tc1); } /* psd_4pi=PSD_monitor_4PI() AT ROTATED */ DEBUG_COMPONENT("psd_4pi", _psd_4pi_var._position_absolute, _psd_4pi_var._rotation_absolute); instrument->_position_absolute[79] = _psd_4pi_var._position_absolute; instrument->_position_relative[79] = _psd_4pi_var._position_relative; _psd_4pi_var._position_relative_is_zero = coords_test_zero(_psd_4pi_var._position_relative); instrument->counter_N[79] = instrument->counter_P[79] = instrument->counter_P2[79] = 0; instrument->counter_AbsorbProp[79]= 0; #ifdef USE_NEXUS if(nxhandle) { if ((!mcdotrace) && mcformat && strcasestr(mcformat, "NeXus")) { MPI_MASTER( mccomp_placement_type_nexus(nxhandle,"0078_psd_4pi", _psd_4pi_var._position_absolute, _psd_4pi_var._rotation_absolute, "PSD_monitor_4PI"); mccomp_param_nexus(nxhandle,"0078_psd_4pi", "nx", "90", "1000","int"); mccomp_param_nexus(nxhandle,"0078_psd_4pi", "ny", "90", "1000","int"); mccomp_param_nexus(nxhandle,"0078_psd_4pi", "filename", 0, "psd_4pi", "char*"); mccomp_param_nexus(nxhandle,"0078_psd_4pi", "nowritefile", "0", "0","int"); mccomp_param_nexus(nxhandle,"0078_psd_4pi", "radius", "1", "0.1","MCNUM"); mccomp_param_nexus(nxhandle,"0078_psd_4pi", "restore_neutron", "0", "1","int"); ); } } else { // fprintf(stderr,"NO NEXUS FILE"); } #endif return(0); } /* _psd_4pi_setpos */ /* component a4=Arm() SETTING, POSITION/ROTATION */ int _a4_setpos(void) { /* sets initial component parameters, position and rotation */ SIG_MESSAGE("[_a4_setpos] component a4=Arm() SETTING [Arm:0]"); stracpy(_a4_var._name, "a4", 16384); stracpy(_a4_var._type, "Arm", 16384); _a4_var._index=80; int current_setpos_index = 80; /* component a4=Arm() AT ROTATED */ { Coords tc1, tc2; tc1 = coords_set(0,0,0); tc2 = coords_set(0,0,0); Rotation tr1; rot_set_rotation(tr1,0,0,0); rot_set_rotation(tr1, (0)*DEG2RAD, (machine_real . a4)*DEG2RAD, (0)*DEG2RAD); rot_mul(tr1, _aa2_var._rotation_absolute, _a4_var._rotation_absolute); rot_transpose(_psd_4pi_var._rotation_absolute, tr1); rot_mul(_a4_var._rotation_absolute, tr1, _a4_var._rotation_relative); _a4_var._rotation_is_identity = rot_test_identity(_a4_var._rotation_relative); tc1 = coords_set( 0, 0, 0); rot_transpose(_a3_var._rotation_absolute, tr1); tc2 = rot_apply(tr1, tc1); _a4_var._position_absolute = coords_add(_a3_var._position_absolute, tc2); tc1 = coords_sub(_psd_4pi_var._position_absolute, _a4_var._position_absolute); _a4_var._position_relative = rot_apply(_a4_var._rotation_absolute, tc1); } /* a4=Arm() AT ROTATED */ DEBUG_COMPONENT("a4", _a4_var._position_absolute, _a4_var._rotation_absolute); instrument->_position_absolute[80] = _a4_var._position_absolute; instrument->_position_relative[80] = _a4_var._position_relative; _a4_var._position_relative_is_zero = coords_test_zero(_a4_var._position_relative); instrument->counter_N[80] = instrument->counter_P[80] = instrument->counter_P2[80] = 0; instrument->counter_AbsorbProp[80]= 0; #ifdef USE_NEXUS if(nxhandle) { if ((!mcdotrace) && mcformat && strcasestr(mcformat, "NeXus")) { MPI_MASTER( mccomp_placement_type_nexus(nxhandle,"0079_a4", _a4_var._position_absolute, _a4_var._rotation_absolute, "Arm"); ); } } else { // fprintf(stderr,"NO NEXUS FILE"); } #endif return(0); } /* _a4_setpos */ /* component slitSample=Slit() SETTING, POSITION/ROTATION */ int _slitSample_setpos(void) { /* sets initial component parameters, position and rotation */ SIG_MESSAGE("[_slitSample_setpos] component slitSample=Slit() SETTING [Slit:0]"); stracpy(_slitSample_var._name, "slitSample", 16384); stracpy(_slitSample_var._type, "Slit", 16384); _slitSample_var._index=81; int current_setpos_index = 81; _slitSample_var._parameters.xmin = - _instrument_var._parameters.SSL / 1000.0; _slitSample_var._parameters.xmax = _instrument_var._parameters.SSR / 1000.0; _slitSample_var._parameters.ymin = - _instrument_var._parameters.SSB / 1000.0; _slitSample_var._parameters.ymax = _instrument_var._parameters.SST / 1000.0; _slitSample_var._parameters.radius = UNSET; _slitSample_var._parameters.xwidth = UNSET; _slitSample_var._parameters.yheight = UNSET; /* component slitSample=Slit() AT ROTATED */ { Coords tc1, tc2; tc1 = coords_set(0,0,0); tc2 = coords_set(0,0,0); Rotation tr1; rot_set_rotation(tr1,0,0,0); rot_set_rotation(tr1, (0.0)*DEG2RAD, (0.0)*DEG2RAD, (0.0)*DEG2RAD); rot_mul(tr1, _a4_var._rotation_absolute, _slitSample_var._rotation_absolute); rot_transpose(_psd_4pi_var._rotation_absolute, tr1); rot_mul(_slitSample_var._rotation_absolute, tr1, _slitSample_var._rotation_relative); _slitSample_var._rotation_is_identity = rot_test_identity(_slitSample_var._rotation_relative); tc1 = coords_set( 0, 0, d_sample_slit); rot_transpose(_a4_var._rotation_absolute, tr1); tc2 = rot_apply(tr1, tc1); _slitSample_var._position_absolute = coords_add(_a4_var._position_absolute, tc2); tc1 = coords_sub(_psd_4pi_var._position_absolute, _slitSample_var._position_absolute); _slitSample_var._position_relative = rot_apply(_slitSample_var._rotation_absolute, tc1); } /* slitSample=Slit() AT ROTATED */ DEBUG_COMPONENT("slitSample", _slitSample_var._position_absolute, _slitSample_var._rotation_absolute); instrument->_position_absolute[81] = _slitSample_var._position_absolute; instrument->_position_relative[81] = _slitSample_var._position_relative; _slitSample_var._position_relative_is_zero = coords_test_zero(_slitSample_var._position_relative); instrument->counter_N[81] = instrument->counter_P[81] = instrument->counter_P2[81] = 0; instrument->counter_AbsorbProp[81]= 0; #ifdef USE_NEXUS if(nxhandle) { if ((!mcdotrace) && mcformat && strcasestr(mcformat, "NeXus")) { MPI_MASTER( mccomp_placement_type_nexus(nxhandle,"0080_slitSample", _slitSample_var._position_absolute, _slitSample_var._rotation_absolute, "Slit"); mccomp_param_nexus(nxhandle,"0080_slitSample", "xmin", "UNSET", "- _instrument_var._parameters.SSL / 1000.0","MCNUM"); mccomp_param_nexus(nxhandle,"0080_slitSample", "xmax", "UNSET", "_instrument_var._parameters.SSR / 1000.0","MCNUM"); mccomp_param_nexus(nxhandle,"0080_slitSample", "ymin", "UNSET", "- _instrument_var._parameters.SSB / 1000.0","MCNUM"); mccomp_param_nexus(nxhandle,"0080_slitSample", "ymax", "UNSET", "_instrument_var._parameters.SST / 1000.0","MCNUM"); mccomp_param_nexus(nxhandle,"0080_slitSample", "radius", "UNSET", "UNSET","MCNUM"); mccomp_param_nexus(nxhandle,"0080_slitSample", "xwidth", "UNSET", "UNSET","MCNUM"); mccomp_param_nexus(nxhandle,"0080_slitSample", "yheight", "UNSET", "UNSET","MCNUM"); ); } } else { // fprintf(stderr,"NO NEXUS FILE"); } #endif return(0); } /* _slitSample_setpos */ /* component filter_coll=Exact_radial_coll() SETTING, POSITION/ROTATION */ int _filter_coll_setpos(void) { /* sets initial component parameters, position and rotation */ SIG_MESSAGE("[_filter_coll_setpos] component filter_coll=Exact_radial_coll() SETTING [Exact_radial_coll:0]"); stracpy(_filter_coll_var._name, "filter_coll", 16384); stracpy(_filter_coll_var._type, "Exact_radial_coll", 16384); _filter_coll_var._index=82; int current_setpos_index = 82; _filter_coll_var._parameters.theta_min = -10.26 / 2; _filter_coll_var._parameters.theta_max = 10.26 / 2; _filter_coll_var._parameters.nslit = 9; _filter_coll_var._parameters.radius = 0.4525; _filter_coll_var._parameters.length = 0.0988; _filter_coll_var._parameters.h_in = 0.2; _filter_coll_var._parameters.h_out = 0.2; _filter_coll_var._parameters.d = 0.000125; _filter_coll_var._parameters.verbose = 1; /* component filter_coll=Exact_radial_coll() AT ROTATED */ { Coords tc1, tc2; tc1 = coords_set(0,0,0); tc2 = coords_set(0,0,0); Rotation tr1; rot_set_rotation(tr1,0,0,0); rot_set_rotation(tr1, (0.0)*DEG2RAD, (0.0)*DEG2RAD, (0.0)*DEG2RAD); rot_mul(tr1, _a4_var._rotation_absolute, _filter_coll_var._rotation_absolute); rot_transpose(_slitSample_var._rotation_absolute, tr1); rot_mul(_filter_coll_var._rotation_absolute, tr1, _filter_coll_var._rotation_relative); _filter_coll_var._rotation_is_identity = rot_test_identity(_filter_coll_var._rotation_relative); tc1 = coords_set( 0, 0, d_sample_filter -0.4525 -0.0988 / 2); rot_transpose(_a4_var._rotation_absolute, tr1); tc2 = rot_apply(tr1, tc1); _filter_coll_var._position_absolute = coords_add(_a4_var._position_absolute, tc2); tc1 = coords_sub(_slitSample_var._position_absolute, _filter_coll_var._position_absolute); _filter_coll_var._position_relative = rot_apply(_filter_coll_var._rotation_absolute, tc1); } /* filter_coll=Exact_radial_coll() AT ROTATED */ DEBUG_COMPONENT("filter_coll", _filter_coll_var._position_absolute, _filter_coll_var._rotation_absolute); instrument->_position_absolute[82] = _filter_coll_var._position_absolute; instrument->_position_relative[82] = _filter_coll_var._position_relative; _filter_coll_var._position_relative_is_zero = coords_test_zero(_filter_coll_var._position_relative); instrument->counter_N[82] = instrument->counter_P[82] = instrument->counter_P2[82] = 0; instrument->counter_AbsorbProp[82]= 0; #ifdef USE_NEXUS if(nxhandle) { if ((!mcdotrace) && mcformat && strcasestr(mcformat, "NeXus")) { MPI_MASTER( mccomp_placement_type_nexus(nxhandle,"0081_filter_coll", _filter_coll_var._position_absolute, _filter_coll_var._rotation_absolute, "Exact_radial_coll"); mccomp_param_nexus(nxhandle,"0081_filter_coll", "theta_min", "-5", "-10.26 / 2","MCNUM"); mccomp_param_nexus(nxhandle,"0081_filter_coll", "theta_max", "5", "10.26 / 2","MCNUM"); mccomp_param_nexus(nxhandle,"0081_filter_coll", "nslit", "100", "9","MCNUM"); mccomp_param_nexus(nxhandle,"0081_filter_coll", "radius", "1.0", "0.4525","MCNUM"); mccomp_param_nexus(nxhandle,"0081_filter_coll", "length", ".5", "0.0988","MCNUM"); mccomp_param_nexus(nxhandle,"0081_filter_coll", "h_in", ".3", "0.2","MCNUM"); mccomp_param_nexus(nxhandle,"0081_filter_coll", "h_out", ".4", "0.2","MCNUM"); mccomp_param_nexus(nxhandle,"0081_filter_coll", "d", "0.0001", "0.000125","MCNUM"); mccomp_param_nexus(nxhandle,"0081_filter_coll", "verbose", "0", "1","MCNUM"); ); } } else { // fprintf(stderr,"NO NEXUS FILE"); } #endif return(0); } /* _filter_coll_setpos */ /* component filter=Filter_gen() SETTING, POSITION/ROTATION */ int _filter_setpos(void) { /* sets initial component parameters, position and rotation */ SIG_MESSAGE("[_filter_setpos] component filter=Filter_gen() SETTING [Filter_gen:0]"); stracpy(_filter_var._name, "filter", 16384); stracpy(_filter_var._type, "Filter_gen", 16384); _filter_var._index=83; int current_setpos_index = 83; if(_instrument_var._parameters.OUTFILTERFILE && strlen(_instrument_var._parameters.OUTFILTERFILE)) stracpy(_filter_var._parameters.filename, _instrument_var._parameters.OUTFILTERFILE ? _instrument_var._parameters.OUTFILTERFILE : "", 16384); else _filter_var._parameters.filename[0]='\0'; if("wavevector multiply" && strlen("wavevector multiply")) stracpy(_filter_var._parameters.options, "wavevector multiply" ? "wavevector multiply" : "", 16384); else _filter_var._parameters.options[0]='\0'; _filter_var._parameters.xmin = -0.1; _filter_var._parameters.xmax = 0.1; _filter_var._parameters.ymin = -0.1; _filter_var._parameters.ymax = 0.1; _filter_var._parameters.xwidth = 0; _filter_var._parameters.yheight = 0; _filter_var._parameters.thickness = 1; _filter_var._parameters.scaling = 1; _filter_var._parameters.verbose = 0; /* component filter=Filter_gen() AT ROTATED */ { Coords tc1, tc2; tc1 = coords_set(0,0,0); tc2 = coords_set(0,0,0); Rotation tr1; rot_set_rotation(tr1,0,0,0); rot_set_rotation(tr1, (0.0)*DEG2RAD, (0.0)*DEG2RAD, (0.0)*DEG2RAD); rot_mul(tr1, _filter_coll_var._rotation_absolute, _filter_var._rotation_absolute); rot_transpose(_filter_coll_var._rotation_absolute, tr1); rot_mul(_filter_var._rotation_absolute, tr1, _filter_var._rotation_relative); _filter_var._rotation_is_identity = rot_test_identity(_filter_var._rotation_relative); tc1 = coords_set( 0, 0, 0.4525 + 0.0988 + 0.0001); rot_transpose(_filter_coll_var._rotation_absolute, tr1); tc2 = rot_apply(tr1, tc1); _filter_var._position_absolute = coords_add(_filter_coll_var._position_absolute, tc2); tc1 = coords_sub(_filter_coll_var._position_absolute, _filter_var._position_absolute); _filter_var._position_relative = rot_apply(_filter_var._rotation_absolute, tc1); } /* filter=Filter_gen() AT ROTATED */ DEBUG_COMPONENT("filter", _filter_var._position_absolute, _filter_var._rotation_absolute); instrument->_position_absolute[83] = _filter_var._position_absolute; instrument->_position_relative[83] = _filter_var._position_relative; _filter_var._position_relative_is_zero = coords_test_zero(_filter_var._position_relative); instrument->counter_N[83] = instrument->counter_P[83] = instrument->counter_P2[83] = 0; instrument->counter_AbsorbProp[83]= 0; #ifdef USE_NEXUS if(nxhandle) { if ((!mcdotrace) && mcformat && strcasestr(mcformat, "NeXus")) { MPI_MASTER( mccomp_placement_type_nexus(nxhandle,"0082_filter", _filter_var._position_absolute, _filter_var._rotation_absolute, "Filter_gen"); mccomp_param_nexus(nxhandle,"0082_filter", "filename", 0, _instrument_var._parameters.OUTFILTERFILE, "char*"); mccomp_param_nexus(nxhandle,"0082_filter", "options", 0, "wavevector multiply", "char*"); mccomp_param_nexus(nxhandle,"0082_filter", "xmin", "-0.05", "-0.1","MCNUM"); mccomp_param_nexus(nxhandle,"0082_filter", "xmax", "0.05", "0.1","MCNUM"); mccomp_param_nexus(nxhandle,"0082_filter", "ymin", "-0.05", "-0.1","MCNUM"); mccomp_param_nexus(nxhandle,"0082_filter", "ymax", "0.05", "0.1","MCNUM"); mccomp_param_nexus(nxhandle,"0082_filter", "xwidth", "0", "0","MCNUM"); mccomp_param_nexus(nxhandle,"0082_filter", "yheight", "0", "0","MCNUM"); mccomp_param_nexus(nxhandle,"0082_filter", "thickness", "1", "1","MCNUM"); mccomp_param_nexus(nxhandle,"0082_filter", "scaling", "1", "1","MCNUM"); mccomp_param_nexus(nxhandle,"0082_filter", "verbose", "0", "0","MCNUM"); ); } } else { // fprintf(stderr,"NO NEXUS FILE"); } #endif return(0); } /* _filter_setpos */ /* component ana_slit1=Slit() SETTING, POSITION/ROTATION */ int _ana_slit1_setpos(void) { /* sets initial component parameters, position and rotation */ SIG_MESSAGE("[_ana_slit1_setpos] component ana_slit1=Slit() SETTING [Slit:0]"); stracpy(_ana_slit1_var._name, "ana_slit1", 16384); stracpy(_ana_slit1_var._type, "Slit", 16384); _ana_slit1_var._index=84; int current_setpos_index = 84; _ana_slit1_var._parameters.xmin = -0.158 / 2; _ana_slit1_var._parameters.xmax = 0.158 / 2; _ana_slit1_var._parameters.ymin = -0.08 / 2; _ana_slit1_var._parameters.ymax = 0.08 / 2; _ana_slit1_var._parameters.radius = UNSET; _ana_slit1_var._parameters.xwidth = UNSET; _ana_slit1_var._parameters.yheight = UNSET; /* component ana_slit1=Slit() AT ROTATED */ { Coords tc1, tc2; tc1 = coords_set(0,0,0); tc2 = coords_set(0,0,0); Rotation tr1; rot_set_rotation(tr1,0,0,0); rot_set_rotation(tr1, (0)*DEG2RAD, (0)*DEG2RAD, (0)*DEG2RAD); rot_mul(tr1, _a4_var._rotation_absolute, _ana_slit1_var._rotation_absolute); rot_transpose(_filter_var._rotation_absolute, tr1); rot_mul(_ana_slit1_var._rotation_absolute, tr1, _ana_slit1_var._rotation_relative); _ana_slit1_var._rotation_is_identity = rot_test_identity(_ana_slit1_var._rotation_relative); tc1 = coords_set( 0, 0, d_sample_filter + 0.13); rot_transpose(_a4_var._rotation_absolute, tr1); tc2 = rot_apply(tr1, tc1); _ana_slit1_var._position_absolute = coords_add(_a4_var._position_absolute, tc2); tc1 = coords_sub(_filter_var._position_absolute, _ana_slit1_var._position_absolute); _ana_slit1_var._position_relative = rot_apply(_ana_slit1_var._rotation_absolute, tc1); } /* ana_slit1=Slit() AT ROTATED */ DEBUG_COMPONENT("ana_slit1", _ana_slit1_var._position_absolute, _ana_slit1_var._rotation_absolute); instrument->_position_absolute[84] = _ana_slit1_var._position_absolute; instrument->_position_relative[84] = _ana_slit1_var._position_relative; _ana_slit1_var._position_relative_is_zero = coords_test_zero(_ana_slit1_var._position_relative); instrument->counter_N[84] = instrument->counter_P[84] = instrument->counter_P2[84] = 0; instrument->counter_AbsorbProp[84]= 0; #ifdef USE_NEXUS if(nxhandle) { if ((!mcdotrace) && mcformat && strcasestr(mcformat, "NeXus")) { MPI_MASTER( mccomp_placement_type_nexus(nxhandle,"0083_ana_slit1", _ana_slit1_var._position_absolute, _ana_slit1_var._rotation_absolute, "Slit"); mccomp_param_nexus(nxhandle,"0083_ana_slit1", "xmin", "UNSET", "-0.158 / 2","MCNUM"); mccomp_param_nexus(nxhandle,"0083_ana_slit1", "xmax", "UNSET", "0.158 / 2","MCNUM"); mccomp_param_nexus(nxhandle,"0083_ana_slit1", "ymin", "UNSET", "-0.08 / 2","MCNUM"); mccomp_param_nexus(nxhandle,"0083_ana_slit1", "ymax", "UNSET", "0.08 / 2","MCNUM"); mccomp_param_nexus(nxhandle,"0083_ana_slit1", "radius", "UNSET", "UNSET","MCNUM"); mccomp_param_nexus(nxhandle,"0083_ana_slit1", "xwidth", "UNSET", "UNSET","MCNUM"); mccomp_param_nexus(nxhandle,"0083_ana_slit1", "yheight", "UNSET", "UNSET","MCNUM"); ); } } else { // fprintf(stderr,"NO NEXUS FILE"); } #endif return(0); } /* _ana_slit1_setpos */ /* component ana_slit2=Slit() SETTING, POSITION/ROTATION */ int _ana_slit2_setpos(void) { /* sets initial component parameters, position and rotation */ SIG_MESSAGE("[_ana_slit2_setpos] component ana_slit2=Slit() SETTING [Slit:0]"); stracpy(_ana_slit2_var._name, "ana_slit2", 16384); stracpy(_ana_slit2_var._type, "Slit", 16384); _ana_slit2_var._index=85; int current_setpos_index = 85; _ana_slit2_var._parameters.xmin = -0.158 / 2; _ana_slit2_var._parameters.xmax = 0.158 / 2; _ana_slit2_var._parameters.ymin = -0.103 / 2; _ana_slit2_var._parameters.ymax = 0.103 / 2; _ana_slit2_var._parameters.radius = UNSET; _ana_slit2_var._parameters.xwidth = UNSET; _ana_slit2_var._parameters.yheight = UNSET; /* component ana_slit2=Slit() AT ROTATED */ { Coords tc1, tc2; tc1 = coords_set(0,0,0); tc2 = coords_set(0,0,0); Rotation tr1; rot_set_rotation(tr1,0,0,0); rot_set_rotation(tr1, (0)*DEG2RAD, (0)*DEG2RAD, (0)*DEG2RAD); rot_mul(tr1, _a4_var._rotation_absolute, _ana_slit2_var._rotation_absolute); rot_transpose(_ana_slit1_var._rotation_absolute, tr1); rot_mul(_ana_slit2_var._rotation_absolute, tr1, _ana_slit2_var._rotation_relative); _ana_slit2_var._rotation_is_identity = rot_test_identity(_ana_slit2_var._rotation_relative); tc1 = coords_set( 0, 0, d_sample_filter + 0.33); rot_transpose(_a4_var._rotation_absolute, tr1); tc2 = rot_apply(tr1, tc1); _ana_slit2_var._position_absolute = coords_add(_a4_var._position_absolute, tc2); tc1 = coords_sub(_ana_slit1_var._position_absolute, _ana_slit2_var._position_absolute); _ana_slit2_var._position_relative = rot_apply(_ana_slit2_var._rotation_absolute, tc1); } /* ana_slit2=Slit() AT ROTATED */ DEBUG_COMPONENT("ana_slit2", _ana_slit2_var._position_absolute, _ana_slit2_var._rotation_absolute); instrument->_position_absolute[85] = _ana_slit2_var._position_absolute; instrument->_position_relative[85] = _ana_slit2_var._position_relative; _ana_slit2_var._position_relative_is_zero = coords_test_zero(_ana_slit2_var._position_relative); instrument->counter_N[85] = instrument->counter_P[85] = instrument->counter_P2[85] = 0; instrument->counter_AbsorbProp[85]= 0; #ifdef USE_NEXUS if(nxhandle) { if ((!mcdotrace) && mcformat && strcasestr(mcformat, "NeXus")) { MPI_MASTER( mccomp_placement_type_nexus(nxhandle,"0084_ana_slit2", _ana_slit2_var._position_absolute, _ana_slit2_var._rotation_absolute, "Slit"); mccomp_param_nexus(nxhandle,"0084_ana_slit2", "xmin", "UNSET", "-0.158 / 2","MCNUM"); mccomp_param_nexus(nxhandle,"0084_ana_slit2", "xmax", "UNSET", "0.158 / 2","MCNUM"); mccomp_param_nexus(nxhandle,"0084_ana_slit2", "ymin", "UNSET", "-0.103 / 2","MCNUM"); mccomp_param_nexus(nxhandle,"0084_ana_slit2", "ymax", "UNSET", "0.103 / 2","MCNUM"); mccomp_param_nexus(nxhandle,"0084_ana_slit2", "radius", "UNSET", "UNSET","MCNUM"); mccomp_param_nexus(nxhandle,"0084_ana_slit2", "xwidth", "UNSET", "UNSET","MCNUM"); mccomp_param_nexus(nxhandle,"0084_ana_slit2", "yheight", "UNSET", "UNSET","MCNUM"); ); } } else { // fprintf(stderr,"NO NEXUS FILE"); } #endif return(0); } /* _ana_slit2_setpos */ /* component emon_before_ana=E_monitor() SETTING, POSITION/ROTATION */ int _emon_before_ana_setpos(void) { /* sets initial component parameters, position and rotation */ SIG_MESSAGE("[_emon_before_ana_setpos] component emon_before_ana=E_monitor() SETTING [E_monitor:0]"); stracpy(_emon_before_ana_var._name, "emon_before_ana", 16384); stracpy(_emon_before_ana_var._type, "E_monitor", 16384); _emon_before_ana_var._index=86; int current_setpos_index = 86; _emon_before_ana_var._parameters.nE = 100; if("emon_before_ana.dat" && strlen("emon_before_ana.dat")) stracpy(_emon_before_ana_var._parameters.filename, "emon_before_ana.dat" ? "emon_before_ana.dat" : "", 16384); else _emon_before_ana_var._parameters.filename[0]='\0'; _emon_before_ana_var._parameters.xmin = -0.060; _emon_before_ana_var._parameters.xmax = 0.060; _emon_before_ana_var._parameters.ymin = -0.085; _emon_before_ana_var._parameters.ymax = 0.085; _emon_before_ana_var._parameters.nowritefile = 0; _emon_before_ana_var._parameters.xwidth = 0; _emon_before_ana_var._parameters.yheight = 0; _emon_before_ana_var._parameters.Emin = eminf; _emon_before_ana_var._parameters.Emax = emaxi; _emon_before_ana_var._parameters.restore_neutron = 1; /* component emon_before_ana=E_monitor() AT ROTATED */ { Coords tc1, tc2; tc1 = coords_set(0,0,0); tc2 = coords_set(0,0,0); Rotation tr1; rot_set_rotation(tr1,0,0,0); rot_set_rotation(tr1, (0.0)*DEG2RAD, (0.0)*DEG2RAD, (0.0)*DEG2RAD); rot_mul(tr1, _a4_var._rotation_absolute, _emon_before_ana_var._rotation_absolute); rot_transpose(_ana_slit2_var._rotation_absolute, tr1); rot_mul(_emon_before_ana_var._rotation_absolute, tr1, _emon_before_ana_var._rotation_relative); _emon_before_ana_var._rotation_is_identity = rot_test_identity(_emon_before_ana_var._rotation_relative); tc1 = coords_set( 0, 0, dsa -5 * ana_d); rot_transpose(_a4_var._rotation_absolute, tr1); tc2 = rot_apply(tr1, tc1); _emon_before_ana_var._position_absolute = coords_add(_a4_var._position_absolute, tc2); tc1 = coords_sub(_ana_slit2_var._position_absolute, _emon_before_ana_var._position_absolute); _emon_before_ana_var._position_relative = rot_apply(_emon_before_ana_var._rotation_absolute, tc1); } /* emon_before_ana=E_monitor() AT ROTATED */ DEBUG_COMPONENT("emon_before_ana", _emon_before_ana_var._position_absolute, _emon_before_ana_var._rotation_absolute); instrument->_position_absolute[86] = _emon_before_ana_var._position_absolute; instrument->_position_relative[86] = _emon_before_ana_var._position_relative; _emon_before_ana_var._position_relative_is_zero = coords_test_zero(_emon_before_ana_var._position_relative); instrument->counter_N[86] = instrument->counter_P[86] = instrument->counter_P2[86] = 0; instrument->counter_AbsorbProp[86]= 0; #ifdef USE_NEXUS if(nxhandle) { if ((!mcdotrace) && mcformat && strcasestr(mcformat, "NeXus")) { MPI_MASTER( mccomp_placement_type_nexus(nxhandle,"0085_emon_before_ana", _emon_before_ana_var._position_absolute, _emon_before_ana_var._rotation_absolute, "E_monitor"); mccomp_param_nexus(nxhandle,"0085_emon_before_ana", "nE", "20", "100","int"); mccomp_param_nexus(nxhandle,"0085_emon_before_ana", "filename", 0, "emon_before_ana.dat", "char*"); mccomp_param_nexus(nxhandle,"0085_emon_before_ana", "xmin", "-0.05", "-0.060","MCNUM"); mccomp_param_nexus(nxhandle,"0085_emon_before_ana", "xmax", "0.05", "0.060","MCNUM"); mccomp_param_nexus(nxhandle,"0085_emon_before_ana", "ymin", "-0.05", "-0.085","MCNUM"); mccomp_param_nexus(nxhandle,"0085_emon_before_ana", "ymax", "0.05", "0.085","MCNUM"); mccomp_param_nexus(nxhandle,"0085_emon_before_ana", "nowritefile", "0", "0","int"); mccomp_param_nexus(nxhandle,"0085_emon_before_ana", "xwidth", "0", "0","MCNUM"); mccomp_param_nexus(nxhandle,"0085_emon_before_ana", "yheight", "0", "0","MCNUM"); mccomp_param_nexus(nxhandle,"0085_emon_before_ana", "Emin", "NONE", "eminf","MCNUM"); mccomp_param_nexus(nxhandle,"0085_emon_before_ana", "Emax", "NONE", "emaxi","MCNUM"); mccomp_param_nexus(nxhandle,"0085_emon_before_ana", "restore_neutron", "0", "1","int"); ); } } else { // fprintf(stderr,"NO NEXUS FILE"); } #endif return(0); } /* _emon_before_ana_setpos */ /* component psd_before_ana=PSD_monitor() SETTING, POSITION/ROTATION */ int _psd_before_ana_setpos(void) { /* sets initial component parameters, position and rotation */ SIG_MESSAGE("[_psd_before_ana_setpos] component psd_before_ana=PSD_monitor() SETTING [PSD_monitor:0]"); stracpy(_psd_before_ana_var._name, "psd_before_ana", 16384); stracpy(_psd_before_ana_var._type, "PSD_monitor", 16384); _psd_before_ana_var._index=87; int current_setpos_index = 87; _psd_before_ana_var._parameters.nx = 128; _psd_before_ana_var._parameters.ny = 128; if("psd_before_ana.dat" && strlen("psd_before_ana.dat")) stracpy(_psd_before_ana_var._parameters.filename, "psd_before_ana.dat" ? "psd_before_ana.dat" : "", 16384); else _psd_before_ana_var._parameters.filename[0]='\0'; _psd_before_ana_var._parameters.xmin = -0.060; _psd_before_ana_var._parameters.xmax = 0.060; _psd_before_ana_var._parameters.ymin = -0.085; _psd_before_ana_var._parameters.ymax = 0.085; _psd_before_ana_var._parameters.xwidth = 0; _psd_before_ana_var._parameters.yheight = 0; _psd_before_ana_var._parameters.restore_neutron = 0; _psd_before_ana_var._parameters.nowritefile = 0; /* component psd_before_ana=PSD_monitor() AT ROTATED */ { Coords tc1, tc2; tc1 = coords_set(0,0,0); tc2 = coords_set(0,0,0); Rotation tr1; rot_set_rotation(tr1,0,0,0); rot_set_rotation(tr1, (0.0)*DEG2RAD, (0.0)*DEG2RAD, (0.0)*DEG2RAD); rot_mul(tr1, _a4_var._rotation_absolute, _psd_before_ana_var._rotation_absolute); rot_transpose(_emon_before_ana_var._rotation_absolute, tr1); rot_mul(_psd_before_ana_var._rotation_absolute, tr1, _psd_before_ana_var._rotation_relative); _psd_before_ana_var._rotation_is_identity = rot_test_identity(_psd_before_ana_var._rotation_relative); tc1 = coords_set( 0, 0, dsa -5 * ana_d + 0.001); rot_transpose(_a4_var._rotation_absolute, tr1); tc2 = rot_apply(tr1, tc1); _psd_before_ana_var._position_absolute = coords_add(_a4_var._position_absolute, tc2); tc1 = coords_sub(_emon_before_ana_var._position_absolute, _psd_before_ana_var._position_absolute); _psd_before_ana_var._position_relative = rot_apply(_psd_before_ana_var._rotation_absolute, tc1); } /* psd_before_ana=PSD_monitor() AT ROTATED */ DEBUG_COMPONENT("psd_before_ana", _psd_before_ana_var._position_absolute, _psd_before_ana_var._rotation_absolute); instrument->_position_absolute[87] = _psd_before_ana_var._position_absolute; instrument->_position_relative[87] = _psd_before_ana_var._position_relative; _psd_before_ana_var._position_relative_is_zero = coords_test_zero(_psd_before_ana_var._position_relative); instrument->counter_N[87] = instrument->counter_P[87] = instrument->counter_P2[87] = 0; instrument->counter_AbsorbProp[87]= 0; #ifdef USE_NEXUS if(nxhandle) { if ((!mcdotrace) && mcformat && strcasestr(mcformat, "NeXus")) { MPI_MASTER( mccomp_placement_type_nexus(nxhandle,"0086_psd_before_ana", _psd_before_ana_var._position_absolute, _psd_before_ana_var._rotation_absolute, "PSD_monitor"); mccomp_param_nexus(nxhandle,"0086_psd_before_ana", "nx", "90", "128","int"); mccomp_param_nexus(nxhandle,"0086_psd_before_ana", "ny", "90", "128","int"); mccomp_param_nexus(nxhandle,"0086_psd_before_ana", "filename", 0, "psd_before_ana.dat", "char*"); mccomp_param_nexus(nxhandle,"0086_psd_before_ana", "xmin", "-0.05", "-0.060","MCNUM"); mccomp_param_nexus(nxhandle,"0086_psd_before_ana", "xmax", "0.05", "0.060","MCNUM"); mccomp_param_nexus(nxhandle,"0086_psd_before_ana", "ymin", "-0.05", "-0.085","MCNUM"); mccomp_param_nexus(nxhandle,"0086_psd_before_ana", "ymax", "0.05", "0.085","MCNUM"); mccomp_param_nexus(nxhandle,"0086_psd_before_ana", "xwidth", "0", "0","MCNUM"); mccomp_param_nexus(nxhandle,"0086_psd_before_ana", "yheight", "0", "0","MCNUM"); mccomp_param_nexus(nxhandle,"0086_psd_before_ana", "restore_neutron", "0", "0","int"); mccomp_param_nexus(nxhandle,"0086_psd_before_ana", "nowritefile", "0", "0","int"); ); } } else { // fprintf(stderr,"NO NEXUS FILE"); } #endif return(0); } /* _psd_before_ana_setpos */ /* component divmon_before_ana=Divergence_monitor() SETTING, POSITION/ROTATION */ int _divmon_before_ana_setpos(void) { /* sets initial component parameters, position and rotation */ SIG_MESSAGE("[_divmon_before_ana_setpos] component divmon_before_ana=Divergence_monitor() SETTING [Divergence_monitor:0]"); stracpy(_divmon_before_ana_var._name, "divmon_before_ana", 16384); stracpy(_divmon_before_ana_var._type, "Divergence_monitor", 16384); _divmon_before_ana_var._index=88; int current_setpos_index = 88; _divmon_before_ana_var._parameters.nh = 128; _divmon_before_ana_var._parameters.nv = 128; if("divmon_before_ana" && strlen("divmon_before_ana")) stracpy(_divmon_before_ana_var._parameters.filename, "divmon_before_ana" ? "divmon_before_ana" : "", 16384); else _divmon_before_ana_var._parameters.filename[0]='\0'; _divmon_before_ana_var._parameters.xmin = -0.05; _divmon_before_ana_var._parameters.xmax = 0.05; _divmon_before_ana_var._parameters.ymin = -0.05; _divmon_before_ana_var._parameters.ymax = 0.05; _divmon_before_ana_var._parameters.nowritefile = 0; _divmon_before_ana_var._parameters.xwidth = 0.02; _divmon_before_ana_var._parameters.yheight = 0.17; _divmon_before_ana_var._parameters.maxdiv_h = 1; _divmon_before_ana_var._parameters.maxdiv_v = 1; _divmon_before_ana_var._parameters.restore_neutron = 1; _divmon_before_ana_var._parameters.nx = 0; _divmon_before_ana_var._parameters.ny = 0; _divmon_before_ana_var._parameters.nz = 1; /* component divmon_before_ana=Divergence_monitor() AT ROTATED */ { Coords tc1, tc2; tc1 = coords_set(0,0,0); tc2 = coords_set(0,0,0); Rotation tr1; rot_set_rotation(tr1,0,0,0); rot_set_rotation(tr1, (0.0)*DEG2RAD, (0.0)*DEG2RAD, (0.0)*DEG2RAD); rot_mul(tr1, _a4_var._rotation_absolute, _divmon_before_ana_var._rotation_absolute); rot_transpose(_psd_before_ana_var._rotation_absolute, tr1); rot_mul(_divmon_before_ana_var._rotation_absolute, tr1, _divmon_before_ana_var._rotation_relative); _divmon_before_ana_var._rotation_is_identity = rot_test_identity(_divmon_before_ana_var._rotation_relative); tc1 = coords_set( 0, 0, dsa -5 * ana_d + 0.002); rot_transpose(_a4_var._rotation_absolute, tr1); tc2 = rot_apply(tr1, tc1); _divmon_before_ana_var._position_absolute = coords_add(_a4_var._position_absolute, tc2); tc1 = coords_sub(_psd_before_ana_var._position_absolute, _divmon_before_ana_var._position_absolute); _divmon_before_ana_var._position_relative = rot_apply(_divmon_before_ana_var._rotation_absolute, tc1); } /* divmon_before_ana=Divergence_monitor() AT ROTATED */ DEBUG_COMPONENT("divmon_before_ana", _divmon_before_ana_var._position_absolute, _divmon_before_ana_var._rotation_absolute); instrument->_position_absolute[88] = _divmon_before_ana_var._position_absolute; instrument->_position_relative[88] = _divmon_before_ana_var._position_relative; _divmon_before_ana_var._position_relative_is_zero = coords_test_zero(_divmon_before_ana_var._position_relative); instrument->counter_N[88] = instrument->counter_P[88] = instrument->counter_P2[88] = 0; instrument->counter_AbsorbProp[88]= 0; #ifdef USE_NEXUS if(nxhandle) { if ((!mcdotrace) && mcformat && strcasestr(mcformat, "NeXus")) { MPI_MASTER( mccomp_placement_type_nexus(nxhandle,"0087_divmon_before_ana", _divmon_before_ana_var._position_absolute, _divmon_before_ana_var._rotation_absolute, "Divergence_monitor"); mccomp_param_nexus(nxhandle,"0087_divmon_before_ana", "nh", "20", "128","int"); mccomp_param_nexus(nxhandle,"0087_divmon_before_ana", "nv", "20", "128","int"); mccomp_param_nexus(nxhandle,"0087_divmon_before_ana", "filename", 0, "divmon_before_ana", "char*"); mccomp_param_nexus(nxhandle,"0087_divmon_before_ana", "xmin", "-0.05", "-0.05","MCNUM"); mccomp_param_nexus(nxhandle,"0087_divmon_before_ana", "xmax", "0.05", "0.05","MCNUM"); mccomp_param_nexus(nxhandle,"0087_divmon_before_ana", "ymin", "-0.05", "-0.05","MCNUM"); mccomp_param_nexus(nxhandle,"0087_divmon_before_ana", "ymax", "0.05", "0.05","MCNUM"); mccomp_param_nexus(nxhandle,"0087_divmon_before_ana", "nowritefile", "0", "0","int"); mccomp_param_nexus(nxhandle,"0087_divmon_before_ana", "xwidth", "0", "0.02","MCNUM"); mccomp_param_nexus(nxhandle,"0087_divmon_before_ana", "yheight", "0", "0.17","MCNUM"); mccomp_param_nexus(nxhandle,"0087_divmon_before_ana", "maxdiv_h", "2", "1","MCNUM"); mccomp_param_nexus(nxhandle,"0087_divmon_before_ana", "maxdiv_v", "2", "1","MCNUM"); mccomp_param_nexus(nxhandle,"0087_divmon_before_ana", "restore_neutron", "0", "1","int"); mccomp_param_nexus(nxhandle,"0087_divmon_before_ana", "nx", "0", "0","MCNUM"); mccomp_param_nexus(nxhandle,"0087_divmon_before_ana", "ny", "0", "0","MCNUM"); mccomp_param_nexus(nxhandle,"0087_divmon_before_ana", "nz", "1", "1","MCNUM"); ); } } else { // fprintf(stderr,"NO NEXUS FILE"); } #endif return(0); } /* _divmon_before_ana_setpos */ /* component focus_ana=Arm() SETTING, POSITION/ROTATION */ int _focus_ana_setpos(void) { /* sets initial component parameters, position and rotation */ SIG_MESSAGE("[_focus_ana_setpos] component focus_ana=Arm() SETTING [Arm:0]"); stracpy(_focus_ana_var._name, "focus_ana", 16384); stracpy(_focus_ana_var._type, "Arm", 16384); _focus_ana_var._index=89; int current_setpos_index = 89; /* component focus_ana=Arm() AT ROTATED */ { Coords tc1, tc2; tc1 = coords_set(0,0,0); tc2 = coords_set(0,0,0); Rotation tr1; rot_set_rotation(tr1,0,0,0); rot_set_rotation(tr1, (0)*DEG2RAD, (machine_real . aa5)*DEG2RAD, (0)*DEG2RAD); rot_mul(tr1, _a4_var._rotation_absolute, _focus_ana_var._rotation_absolute); rot_transpose(_divmon_before_ana_var._rotation_absolute, tr1); rot_mul(_focus_ana_var._rotation_absolute, tr1, _focus_ana_var._rotation_relative); _focus_ana_var._rotation_is_identity = rot_test_identity(_focus_ana_var._rotation_relative); tc1 = coords_set( 0, 0, dsa); rot_transpose(_a4_var._rotation_absolute, tr1); tc2 = rot_apply(tr1, tc1); _focus_ana_var._position_absolute = coords_add(_a4_var._position_absolute, tc2); tc1 = coords_sub(_divmon_before_ana_var._position_absolute, _focus_ana_var._position_absolute); _focus_ana_var._position_relative = rot_apply(_focus_ana_var._rotation_absolute, tc1); } /* focus_ana=Arm() AT ROTATED */ DEBUG_COMPONENT("focus_ana", _focus_ana_var._position_absolute, _focus_ana_var._rotation_absolute); instrument->_position_absolute[89] = _focus_ana_var._position_absolute; instrument->_position_relative[89] = _focus_ana_var._position_relative; _focus_ana_var._position_relative_is_zero = coords_test_zero(_focus_ana_var._position_relative); instrument->counter_N[89] = instrument->counter_P[89] = instrument->counter_P2[89] = 0; instrument->counter_AbsorbProp[89]= 0; #ifdef USE_NEXUS if(nxhandle) { if ((!mcdotrace) && mcformat && strcasestr(mcformat, "NeXus")) { MPI_MASTER( mccomp_placement_type_nexus(nxhandle,"0088_focus_ana", _focus_ana_var._position_absolute, _focus_ana_var._rotation_absolute, "Arm"); ); } } else { // fprintf(stderr,"NO NEXUS FILE"); } #endif return(0); } /* _focus_ana_setpos */ /* component an1l=Monochromator_flat() SETTING, POSITION/ROTATION */ int _an1l_setpos(void) { /* sets initial component parameters, position and rotation */ SIG_MESSAGE("[_an1l_setpos] component an1l=Monochromator_flat() SETTING [Monochromator_flat:0]"); stracpy(_an1l_var._name, "an1l", 16384); stracpy(_an1l_var._type, "Monochromator_flat", 16384); _an1l_var._index=90; int current_setpos_index = 90; _an1l_var._parameters.zmin = - wan / 2.0; _an1l_var._parameters.zmax = wan / 2.0; _an1l_var._parameters.ymin = - ana_h / 2.0; _an1l_var._parameters.ymax = 0; _an1l_var._parameters.zwidth = 0; _an1l_var._parameters.yheight = 0; _an1l_var._parameters.mosaich = 40; _an1l_var._parameters.mosaicv = 40; _an1l_var._parameters.r0 = ana_r0; _an1l_var._parameters.Q = ana_q; _an1l_var._parameters.DM = 0; /* component an1l=Monochromator_flat() AT ROTATED */ { Coords tc1, tc2; tc1 = coords_set(0,0,0); tc2 = coords_set(0,0,0); Rotation tr1; rot_set_rotation(tr1,0,0,0); rot_set_rotation(tr1, (0)*DEG2RAD, (machine_real . c1)*DEG2RAD, (0)*DEG2RAD); rot_mul(tr1, _focus_ana_var._rotation_absolute, _an1l_var._rotation_absolute); rot_transpose(_focus_ana_var._rotation_absolute, tr1); rot_mul(_an1l_var._rotation_absolute, tr1, _an1l_var._rotation_relative); _an1l_var._rotation_is_identity = rot_test_identity(_an1l_var._rotation_relative); tc1 = coords_set( 0, 0, -4 * ana_d); rot_transpose(_focus_ana_var._rotation_absolute, tr1); tc2 = rot_apply(tr1, tc1); _an1l_var._position_absolute = coords_add(_focus_ana_var._position_absolute, tc2); tc1 = coords_sub(_focus_ana_var._position_absolute, _an1l_var._position_absolute); _an1l_var._position_relative = rot_apply(_an1l_var._rotation_absolute, tc1); } /* an1l=Monochromator_flat() AT ROTATED */ DEBUG_COMPONENT("an1l", _an1l_var._position_absolute, _an1l_var._rotation_absolute); instrument->_position_absolute[90] = _an1l_var._position_absolute; instrument->_position_relative[90] = _an1l_var._position_relative; _an1l_var._position_relative_is_zero = coords_test_zero(_an1l_var._position_relative); instrument->counter_N[90] = instrument->counter_P[90] = instrument->counter_P2[90] = 0; instrument->counter_AbsorbProp[90]= 0; #ifdef USE_NEXUS if(nxhandle) { if ((!mcdotrace) && mcformat && strcasestr(mcformat, "NeXus")) { MPI_MASTER( mccomp_placement_type_nexus(nxhandle,"0089_an1l", _an1l_var._position_absolute, _an1l_var._rotation_absolute, "Monochromator_flat"); mccomp_param_nexus(nxhandle,"0089_an1l", "zmin", "-0.05", "- wan / 2.0","MCNUM"); mccomp_param_nexus(nxhandle,"0089_an1l", "zmax", "0.05", "wan / 2.0","MCNUM"); mccomp_param_nexus(nxhandle,"0089_an1l", "ymin", "-0.05", "- ana_h / 2.0","MCNUM"); mccomp_param_nexus(nxhandle,"0089_an1l", "ymax", "0.05", "0","MCNUM"); mccomp_param_nexus(nxhandle,"0089_an1l", "zwidth", "0", "0","MCNUM"); mccomp_param_nexus(nxhandle,"0089_an1l", "yheight", "0", "0","MCNUM"); mccomp_param_nexus(nxhandle,"0089_an1l", "mosaich", "30.0", "40","MCNUM"); mccomp_param_nexus(nxhandle,"0089_an1l", "mosaicv", "30.0", "40","MCNUM"); mccomp_param_nexus(nxhandle,"0089_an1l", "r0", "0.7", "ana_r0","MCNUM"); mccomp_param_nexus(nxhandle,"0089_an1l", "Q", "1.8734", "ana_q","MCNUM"); mccomp_param_nexus(nxhandle,"0089_an1l", "DM", "0", "0","MCNUM"); ); } } else { // fprintf(stderr,"NO NEXUS FILE"); } #endif return(0); } /* _an1l_setpos */ /* component an1u=Monochromator_flat() SETTING, POSITION/ROTATION */ int _an1u_setpos(void) { /* sets initial component parameters, position and rotation */ SIG_MESSAGE("[_an1u_setpos] component an1u=Monochromator_flat() SETTING [Monochromator_flat:0]"); stracpy(_an1u_var._name, "an1u", 16384); stracpy(_an1u_var._type, "Monochromator_flat", 16384); _an1u_var._index=91; int current_setpos_index = 91; _an1u_var._parameters.zmin = - wan / 2.0; _an1u_var._parameters.zmax = wan / 2.0; _an1u_var._parameters.ymin = 0; _an1u_var._parameters.ymax = ana_h / 2.0; _an1u_var._parameters.zwidth = 0; _an1u_var._parameters.yheight = 0; _an1u_var._parameters.mosaich = 40; _an1u_var._parameters.mosaicv = 40; _an1u_var._parameters.r0 = ana_r0; _an1u_var._parameters.Q = ana_q; _an1u_var._parameters.DM = 0; /* component an1u=Monochromator_flat() AT ROTATED */ { Coords tc1, tc2; tc1 = coords_set(0,0,0); tc2 = coords_set(0,0,0); Rotation tr1; rot_set_rotation(tr1,0,0,0); rot_set_rotation(tr1, (0)*DEG2RAD, (machine_real . c1)*DEG2RAD, (0)*DEG2RAD); rot_mul(tr1, _focus_ana_var._rotation_absolute, _an1u_var._rotation_absolute); rot_transpose(_an1l_var._rotation_absolute, tr1); rot_mul(_an1u_var._rotation_absolute, tr1, _an1u_var._rotation_relative); _an1u_var._rotation_is_identity = rot_test_identity(_an1u_var._rotation_relative); tc1 = coords_set( 0, 0, -4 * ana_d); rot_transpose(_focus_ana_var._rotation_absolute, tr1); tc2 = rot_apply(tr1, tc1); _an1u_var._position_absolute = coords_add(_focus_ana_var._position_absolute, tc2); tc1 = coords_sub(_an1l_var._position_absolute, _an1u_var._position_absolute); _an1u_var._position_relative = rot_apply(_an1u_var._rotation_absolute, tc1); } /* an1u=Monochromator_flat() AT ROTATED */ DEBUG_COMPONENT("an1u", _an1u_var._position_absolute, _an1u_var._rotation_absolute); instrument->_position_absolute[91] = _an1u_var._position_absolute; instrument->_position_relative[91] = _an1u_var._position_relative; _an1u_var._position_relative_is_zero = coords_test_zero(_an1u_var._position_relative); instrument->counter_N[91] = instrument->counter_P[91] = instrument->counter_P2[91] = 0; instrument->counter_AbsorbProp[91]= 0; #ifdef USE_NEXUS if(nxhandle) { if ((!mcdotrace) && mcformat && strcasestr(mcformat, "NeXus")) { MPI_MASTER( mccomp_placement_type_nexus(nxhandle,"0090_an1u", _an1u_var._position_absolute, _an1u_var._rotation_absolute, "Monochromator_flat"); mccomp_param_nexus(nxhandle,"0090_an1u", "zmin", "-0.05", "- wan / 2.0","MCNUM"); mccomp_param_nexus(nxhandle,"0090_an1u", "zmax", "0.05", "wan / 2.0","MCNUM"); mccomp_param_nexus(nxhandle,"0090_an1u", "ymin", "-0.05", "0","MCNUM"); mccomp_param_nexus(nxhandle,"0090_an1u", "ymax", "0.05", "ana_h / 2.0","MCNUM"); mccomp_param_nexus(nxhandle,"0090_an1u", "zwidth", "0", "0","MCNUM"); mccomp_param_nexus(nxhandle,"0090_an1u", "yheight", "0", "0","MCNUM"); mccomp_param_nexus(nxhandle,"0090_an1u", "mosaich", "30.0", "40","MCNUM"); mccomp_param_nexus(nxhandle,"0090_an1u", "mosaicv", "30.0", "40","MCNUM"); mccomp_param_nexus(nxhandle,"0090_an1u", "r0", "0.7", "ana_r0","MCNUM"); mccomp_param_nexus(nxhandle,"0090_an1u", "Q", "1.8734", "ana_q","MCNUM"); mccomp_param_nexus(nxhandle,"0090_an1u", "DM", "0", "0","MCNUM"); ); } } else { // fprintf(stderr,"NO NEXUS FILE"); } #endif return(0); } /* _an1u_setpos */ /* component an2l=Monochromator_flat() SETTING, POSITION/ROTATION */ int _an2l_setpos(void) { /* sets initial component parameters, position and rotation */ SIG_MESSAGE("[_an2l_setpos] component an2l=Monochromator_flat() SETTING [Monochromator_flat:0]"); stracpy(_an2l_var._name, "an2l", 16384); stracpy(_an2l_var._type, "Monochromator_flat", 16384); _an2l_var._index=92; int current_setpos_index = 92; _an2l_var._parameters.zmin = - wan / 2.0; _an2l_var._parameters.zmax = wan / 2.0; _an2l_var._parameters.ymin = - ana_h / 2.0; _an2l_var._parameters.ymax = 0; _an2l_var._parameters.zwidth = 0; _an2l_var._parameters.yheight = 0; _an2l_var._parameters.mosaich = 38.7; _an2l_var._parameters.mosaicv = 38.7; _an2l_var._parameters.r0 = ana_r0; _an2l_var._parameters.Q = ana_q; _an2l_var._parameters.DM = 0; /* component an2l=Monochromator_flat() AT ROTATED */ { Coords tc1, tc2; tc1 = coords_set(0,0,0); tc2 = coords_set(0,0,0); Rotation tr1; rot_set_rotation(tr1,0,0,0); rot_set_rotation(tr1, (0)*DEG2RAD, (machine_real . c2)*DEG2RAD, (0)*DEG2RAD); rot_mul(tr1, _focus_ana_var._rotation_absolute, _an2l_var._rotation_absolute); rot_transpose(_an1u_var._rotation_absolute, tr1); rot_mul(_an2l_var._rotation_absolute, tr1, _an2l_var._rotation_relative); _an2l_var._rotation_is_identity = rot_test_identity(_an2l_var._rotation_relative); tc1 = coords_set( 0, 0, -3 * ana_d); rot_transpose(_focus_ana_var._rotation_absolute, tr1); tc2 = rot_apply(tr1, tc1); _an2l_var._position_absolute = coords_add(_focus_ana_var._position_absolute, tc2); tc1 = coords_sub(_an1u_var._position_absolute, _an2l_var._position_absolute); _an2l_var._position_relative = rot_apply(_an2l_var._rotation_absolute, tc1); } /* an2l=Monochromator_flat() AT ROTATED */ DEBUG_COMPONENT("an2l", _an2l_var._position_absolute, _an2l_var._rotation_absolute); instrument->_position_absolute[92] = _an2l_var._position_absolute; instrument->_position_relative[92] = _an2l_var._position_relative; _an2l_var._position_relative_is_zero = coords_test_zero(_an2l_var._position_relative); instrument->counter_N[92] = instrument->counter_P[92] = instrument->counter_P2[92] = 0; instrument->counter_AbsorbProp[92]= 0; #ifdef USE_NEXUS if(nxhandle) { if ((!mcdotrace) && mcformat && strcasestr(mcformat, "NeXus")) { MPI_MASTER( mccomp_placement_type_nexus(nxhandle,"0091_an2l", _an2l_var._position_absolute, _an2l_var._rotation_absolute, "Monochromator_flat"); mccomp_param_nexus(nxhandle,"0091_an2l", "zmin", "-0.05", "- wan / 2.0","MCNUM"); mccomp_param_nexus(nxhandle,"0091_an2l", "zmax", "0.05", "wan / 2.0","MCNUM"); mccomp_param_nexus(nxhandle,"0091_an2l", "ymin", "-0.05", "- ana_h / 2.0","MCNUM"); mccomp_param_nexus(nxhandle,"0091_an2l", "ymax", "0.05", "0","MCNUM"); mccomp_param_nexus(nxhandle,"0091_an2l", "zwidth", "0", "0","MCNUM"); mccomp_param_nexus(nxhandle,"0091_an2l", "yheight", "0", "0","MCNUM"); mccomp_param_nexus(nxhandle,"0091_an2l", "mosaich", "30.0", "38.7","MCNUM"); mccomp_param_nexus(nxhandle,"0091_an2l", "mosaicv", "30.0", "38.7","MCNUM"); mccomp_param_nexus(nxhandle,"0091_an2l", "r0", "0.7", "ana_r0","MCNUM"); mccomp_param_nexus(nxhandle,"0091_an2l", "Q", "1.8734", "ana_q","MCNUM"); mccomp_param_nexus(nxhandle,"0091_an2l", "DM", "0", "0","MCNUM"); ); } } else { // fprintf(stderr,"NO NEXUS FILE"); } #endif return(0); } /* _an2l_setpos */ /* component an2u=Monochromator_flat() SETTING, POSITION/ROTATION */ int _an2u_setpos(void) { /* sets initial component parameters, position and rotation */ SIG_MESSAGE("[_an2u_setpos] component an2u=Monochromator_flat() SETTING [Monochromator_flat:0]"); stracpy(_an2u_var._name, "an2u", 16384); stracpy(_an2u_var._type, "Monochromator_flat", 16384); _an2u_var._index=93; int current_setpos_index = 93; _an2u_var._parameters.zmin = - wan / 2.0; _an2u_var._parameters.zmax = wan / 2.0; _an2u_var._parameters.ymin = 0; _an2u_var._parameters.ymax = ana_h / 2.0; _an2u_var._parameters.zwidth = 0; _an2u_var._parameters.yheight = 0; _an2u_var._parameters.mosaich = 43.0; _an2u_var._parameters.mosaicv = 43.0; _an2u_var._parameters.r0 = ana_r0; _an2u_var._parameters.Q = ana_q; _an2u_var._parameters.DM = 0; /* component an2u=Monochromator_flat() AT ROTATED */ { Coords tc1, tc2; tc1 = coords_set(0,0,0); tc2 = coords_set(0,0,0); Rotation tr1; rot_set_rotation(tr1,0,0,0); rot_set_rotation(tr1, (0)*DEG2RAD, (machine_real . c2)*DEG2RAD, (0)*DEG2RAD); rot_mul(tr1, _focus_ana_var._rotation_absolute, _an2u_var._rotation_absolute); rot_transpose(_an2l_var._rotation_absolute, tr1); rot_mul(_an2u_var._rotation_absolute, tr1, _an2u_var._rotation_relative); _an2u_var._rotation_is_identity = rot_test_identity(_an2u_var._rotation_relative); tc1 = coords_set( 0, 0, -3 * ana_d); rot_transpose(_focus_ana_var._rotation_absolute, tr1); tc2 = rot_apply(tr1, tc1); _an2u_var._position_absolute = coords_add(_focus_ana_var._position_absolute, tc2); tc1 = coords_sub(_an2l_var._position_absolute, _an2u_var._position_absolute); _an2u_var._position_relative = rot_apply(_an2u_var._rotation_absolute, tc1); } /* an2u=Monochromator_flat() AT ROTATED */ DEBUG_COMPONENT("an2u", _an2u_var._position_absolute, _an2u_var._rotation_absolute); instrument->_position_absolute[93] = _an2u_var._position_absolute; instrument->_position_relative[93] = _an2u_var._position_relative; _an2u_var._position_relative_is_zero = coords_test_zero(_an2u_var._position_relative); instrument->counter_N[93] = instrument->counter_P[93] = instrument->counter_P2[93] = 0; instrument->counter_AbsorbProp[93]= 0; #ifdef USE_NEXUS if(nxhandle) { if ((!mcdotrace) && mcformat && strcasestr(mcformat, "NeXus")) { MPI_MASTER( mccomp_placement_type_nexus(nxhandle,"0092_an2u", _an2u_var._position_absolute, _an2u_var._rotation_absolute, "Monochromator_flat"); mccomp_param_nexus(nxhandle,"0092_an2u", "zmin", "-0.05", "- wan / 2.0","MCNUM"); mccomp_param_nexus(nxhandle,"0092_an2u", "zmax", "0.05", "wan / 2.0","MCNUM"); mccomp_param_nexus(nxhandle,"0092_an2u", "ymin", "-0.05", "0","MCNUM"); mccomp_param_nexus(nxhandle,"0092_an2u", "ymax", "0.05", "ana_h / 2.0","MCNUM"); mccomp_param_nexus(nxhandle,"0092_an2u", "zwidth", "0", "0","MCNUM"); mccomp_param_nexus(nxhandle,"0092_an2u", "yheight", "0", "0","MCNUM"); mccomp_param_nexus(nxhandle,"0092_an2u", "mosaich", "30.0", "43.0","MCNUM"); mccomp_param_nexus(nxhandle,"0092_an2u", "mosaicv", "30.0", "43.0","MCNUM"); mccomp_param_nexus(nxhandle,"0092_an2u", "r0", "0.7", "ana_r0","MCNUM"); mccomp_param_nexus(nxhandle,"0092_an2u", "Q", "1.8734", "ana_q","MCNUM"); mccomp_param_nexus(nxhandle,"0092_an2u", "DM", "0", "0","MCNUM"); ); } } else { // fprintf(stderr,"NO NEXUS FILE"); } #endif return(0); } /* _an2u_setpos */ /* component an3l=Monochromator_flat() SETTING, POSITION/ROTATION */ int _an3l_setpos(void) { /* sets initial component parameters, position and rotation */ SIG_MESSAGE("[_an3l_setpos] component an3l=Monochromator_flat() SETTING [Monochromator_flat:0]"); stracpy(_an3l_var._name, "an3l", 16384); stracpy(_an3l_var._type, "Monochromator_flat", 16384); _an3l_var._index=94; int current_setpos_index = 94; _an3l_var._parameters.zmin = - wan / 2.0; _an3l_var._parameters.zmax = wan / 2.0; _an3l_var._parameters.ymin = - ana_h / 2.0; _an3l_var._parameters.ymax = 0; _an3l_var._parameters.zwidth = 0; _an3l_var._parameters.yheight = 0; _an3l_var._parameters.mosaich = 31.1; _an3l_var._parameters.mosaicv = 31.1; _an3l_var._parameters.r0 = ana_r0; _an3l_var._parameters.Q = ana_q; _an3l_var._parameters.DM = 0; /* component an3l=Monochromator_flat() AT ROTATED */ { Coords tc1, tc2; tc1 = coords_set(0,0,0); tc2 = coords_set(0,0,0); Rotation tr1; rot_set_rotation(tr1,0,0,0); rot_set_rotation(tr1, (0)*DEG2RAD, (machine_real . c3)*DEG2RAD, (0)*DEG2RAD); rot_mul(tr1, _focus_ana_var._rotation_absolute, _an3l_var._rotation_absolute); rot_transpose(_an2u_var._rotation_absolute, tr1); rot_mul(_an3l_var._rotation_absolute, tr1, _an3l_var._rotation_relative); _an3l_var._rotation_is_identity = rot_test_identity(_an3l_var._rotation_relative); tc1 = coords_set( 0, 0, -2 * ana_d); rot_transpose(_focus_ana_var._rotation_absolute, tr1); tc2 = rot_apply(tr1, tc1); _an3l_var._position_absolute = coords_add(_focus_ana_var._position_absolute, tc2); tc1 = coords_sub(_an2u_var._position_absolute, _an3l_var._position_absolute); _an3l_var._position_relative = rot_apply(_an3l_var._rotation_absolute, tc1); } /* an3l=Monochromator_flat() AT ROTATED */ DEBUG_COMPONENT("an3l", _an3l_var._position_absolute, _an3l_var._rotation_absolute); instrument->_position_absolute[94] = _an3l_var._position_absolute; instrument->_position_relative[94] = _an3l_var._position_relative; _an3l_var._position_relative_is_zero = coords_test_zero(_an3l_var._position_relative); instrument->counter_N[94] = instrument->counter_P[94] = instrument->counter_P2[94] = 0; instrument->counter_AbsorbProp[94]= 0; #ifdef USE_NEXUS if(nxhandle) { if ((!mcdotrace) && mcformat && strcasestr(mcformat, "NeXus")) { MPI_MASTER( mccomp_placement_type_nexus(nxhandle,"0093_an3l", _an3l_var._position_absolute, _an3l_var._rotation_absolute, "Monochromator_flat"); mccomp_param_nexus(nxhandle,"0093_an3l", "zmin", "-0.05", "- wan / 2.0","MCNUM"); mccomp_param_nexus(nxhandle,"0093_an3l", "zmax", "0.05", "wan / 2.0","MCNUM"); mccomp_param_nexus(nxhandle,"0093_an3l", "ymin", "-0.05", "- ana_h / 2.0","MCNUM"); mccomp_param_nexus(nxhandle,"0093_an3l", "ymax", "0.05", "0","MCNUM"); mccomp_param_nexus(nxhandle,"0093_an3l", "zwidth", "0", "0","MCNUM"); mccomp_param_nexus(nxhandle,"0093_an3l", "yheight", "0", "0","MCNUM"); mccomp_param_nexus(nxhandle,"0093_an3l", "mosaich", "30.0", "31.1","MCNUM"); mccomp_param_nexus(nxhandle,"0093_an3l", "mosaicv", "30.0", "31.1","MCNUM"); mccomp_param_nexus(nxhandle,"0093_an3l", "r0", "0.7", "ana_r0","MCNUM"); mccomp_param_nexus(nxhandle,"0093_an3l", "Q", "1.8734", "ana_q","MCNUM"); mccomp_param_nexus(nxhandle,"0093_an3l", "DM", "0", "0","MCNUM"); ); } } else { // fprintf(stderr,"NO NEXUS FILE"); } #endif return(0); } /* _an3l_setpos */ /* component an3u=Monochromator_flat() SETTING, POSITION/ROTATION */ int _an3u_setpos(void) { /* sets initial component parameters, position and rotation */ SIG_MESSAGE("[_an3u_setpos] component an3u=Monochromator_flat() SETTING [Monochromator_flat:0]"); stracpy(_an3u_var._name, "an3u", 16384); stracpy(_an3u_var._type, "Monochromator_flat", 16384); _an3u_var._index=95; int current_setpos_index = 95; _an3u_var._parameters.zmin = - wan / 2.0; _an3u_var._parameters.zmax = wan / 2.0; _an3u_var._parameters.ymin = 0; _an3u_var._parameters.ymax = ana_h / 2.0; _an3u_var._parameters.zwidth = 0; _an3u_var._parameters.yheight = 0; _an3u_var._parameters.mosaich = 35.5; _an3u_var._parameters.mosaicv = 35.5; _an3u_var._parameters.r0 = ana_r0; _an3u_var._parameters.Q = ana_q; _an3u_var._parameters.DM = 0; /* component an3u=Monochromator_flat() AT ROTATED */ { Coords tc1, tc2; tc1 = coords_set(0,0,0); tc2 = coords_set(0,0,0); Rotation tr1; rot_set_rotation(tr1,0,0,0); rot_set_rotation(tr1, (0)*DEG2RAD, (machine_real . c3)*DEG2RAD, (0)*DEG2RAD); rot_mul(tr1, _focus_ana_var._rotation_absolute, _an3u_var._rotation_absolute); rot_transpose(_an3l_var._rotation_absolute, tr1); rot_mul(_an3u_var._rotation_absolute, tr1, _an3u_var._rotation_relative); _an3u_var._rotation_is_identity = rot_test_identity(_an3u_var._rotation_relative); tc1 = coords_set( 0, 0, -2 * ana_d); rot_transpose(_focus_ana_var._rotation_absolute, tr1); tc2 = rot_apply(tr1, tc1); _an3u_var._position_absolute = coords_add(_focus_ana_var._position_absolute, tc2); tc1 = coords_sub(_an3l_var._position_absolute, _an3u_var._position_absolute); _an3u_var._position_relative = rot_apply(_an3u_var._rotation_absolute, tc1); } /* an3u=Monochromator_flat() AT ROTATED */ DEBUG_COMPONENT("an3u", _an3u_var._position_absolute, _an3u_var._rotation_absolute); instrument->_position_absolute[95] = _an3u_var._position_absolute; instrument->_position_relative[95] = _an3u_var._position_relative; _an3u_var._position_relative_is_zero = coords_test_zero(_an3u_var._position_relative); instrument->counter_N[95] = instrument->counter_P[95] = instrument->counter_P2[95] = 0; instrument->counter_AbsorbProp[95]= 0; #ifdef USE_NEXUS if(nxhandle) { if ((!mcdotrace) && mcformat && strcasestr(mcformat, "NeXus")) { MPI_MASTER( mccomp_placement_type_nexus(nxhandle,"0094_an3u", _an3u_var._position_absolute, _an3u_var._rotation_absolute, "Monochromator_flat"); mccomp_param_nexus(nxhandle,"0094_an3u", "zmin", "-0.05", "- wan / 2.0","MCNUM"); mccomp_param_nexus(nxhandle,"0094_an3u", "zmax", "0.05", "wan / 2.0","MCNUM"); mccomp_param_nexus(nxhandle,"0094_an3u", "ymin", "-0.05", "0","MCNUM"); mccomp_param_nexus(nxhandle,"0094_an3u", "ymax", "0.05", "ana_h / 2.0","MCNUM"); mccomp_param_nexus(nxhandle,"0094_an3u", "zwidth", "0", "0","MCNUM"); mccomp_param_nexus(nxhandle,"0094_an3u", "yheight", "0", "0","MCNUM"); mccomp_param_nexus(nxhandle,"0094_an3u", "mosaich", "30.0", "35.5","MCNUM"); mccomp_param_nexus(nxhandle,"0094_an3u", "mosaicv", "30.0", "35.5","MCNUM"); mccomp_param_nexus(nxhandle,"0094_an3u", "r0", "0.7", "ana_r0","MCNUM"); mccomp_param_nexus(nxhandle,"0094_an3u", "Q", "1.8734", "ana_q","MCNUM"); mccomp_param_nexus(nxhandle,"0094_an3u", "DM", "0", "0","MCNUM"); ); } } else { // fprintf(stderr,"NO NEXUS FILE"); } #endif return(0); } /* _an3u_setpos */ /* component an4l=Monochromator_flat() SETTING, POSITION/ROTATION */ int _an4l_setpos(void) { /* sets initial component parameters, position and rotation */ SIG_MESSAGE("[_an4l_setpos] component an4l=Monochromator_flat() SETTING [Monochromator_flat:0]"); stracpy(_an4l_var._name, "an4l", 16384); stracpy(_an4l_var._type, "Monochromator_flat", 16384); _an4l_var._index=96; int current_setpos_index = 96; _an4l_var._parameters.zmin = - wan / 2.0; _an4l_var._parameters.zmax = wan / 2.0; _an4l_var._parameters.ymin = - ana_h / 2.0; _an4l_var._parameters.ymax = 0; _an4l_var._parameters.zwidth = 0; _an4l_var._parameters.yheight = 0; _an4l_var._parameters.mosaich = 27.2; _an4l_var._parameters.mosaicv = 27.2; _an4l_var._parameters.r0 = ana_r0; _an4l_var._parameters.Q = ana_q; _an4l_var._parameters.DM = 0; /* component an4l=Monochromator_flat() AT ROTATED */ { Coords tc1, tc2; tc1 = coords_set(0,0,0); tc2 = coords_set(0,0,0); Rotation tr1; rot_set_rotation(tr1,0,0,0); rot_set_rotation(tr1, (0)*DEG2RAD, (machine_real . c4)*DEG2RAD, (0)*DEG2RAD); rot_mul(tr1, _focus_ana_var._rotation_absolute, _an4l_var._rotation_absolute); rot_transpose(_an3u_var._rotation_absolute, tr1); rot_mul(_an4l_var._rotation_absolute, tr1, _an4l_var._rotation_relative); _an4l_var._rotation_is_identity = rot_test_identity(_an4l_var._rotation_relative); tc1 = coords_set( 0, 0, -1 * ana_d); rot_transpose(_focus_ana_var._rotation_absolute, tr1); tc2 = rot_apply(tr1, tc1); _an4l_var._position_absolute = coords_add(_focus_ana_var._position_absolute, tc2); tc1 = coords_sub(_an3u_var._position_absolute, _an4l_var._position_absolute); _an4l_var._position_relative = rot_apply(_an4l_var._rotation_absolute, tc1); } /* an4l=Monochromator_flat() AT ROTATED */ DEBUG_COMPONENT("an4l", _an4l_var._position_absolute, _an4l_var._rotation_absolute); instrument->_position_absolute[96] = _an4l_var._position_absolute; instrument->_position_relative[96] = _an4l_var._position_relative; _an4l_var._position_relative_is_zero = coords_test_zero(_an4l_var._position_relative); instrument->counter_N[96] = instrument->counter_P[96] = instrument->counter_P2[96] = 0; instrument->counter_AbsorbProp[96]= 0; #ifdef USE_NEXUS if(nxhandle) { if ((!mcdotrace) && mcformat && strcasestr(mcformat, "NeXus")) { MPI_MASTER( mccomp_placement_type_nexus(nxhandle,"0095_an4l", _an4l_var._position_absolute, _an4l_var._rotation_absolute, "Monochromator_flat"); mccomp_param_nexus(nxhandle,"0095_an4l", "zmin", "-0.05", "- wan / 2.0","MCNUM"); mccomp_param_nexus(nxhandle,"0095_an4l", "zmax", "0.05", "wan / 2.0","MCNUM"); mccomp_param_nexus(nxhandle,"0095_an4l", "ymin", "-0.05", "- ana_h / 2.0","MCNUM"); mccomp_param_nexus(nxhandle,"0095_an4l", "ymax", "0.05", "0","MCNUM"); mccomp_param_nexus(nxhandle,"0095_an4l", "zwidth", "0", "0","MCNUM"); mccomp_param_nexus(nxhandle,"0095_an4l", "yheight", "0", "0","MCNUM"); mccomp_param_nexus(nxhandle,"0095_an4l", "mosaich", "30.0", "27.2","MCNUM"); mccomp_param_nexus(nxhandle,"0095_an4l", "mosaicv", "30.0", "27.2","MCNUM"); mccomp_param_nexus(nxhandle,"0095_an4l", "r0", "0.7", "ana_r0","MCNUM"); mccomp_param_nexus(nxhandle,"0095_an4l", "Q", "1.8734", "ana_q","MCNUM"); mccomp_param_nexus(nxhandle,"0095_an4l", "DM", "0", "0","MCNUM"); ); } } else { // fprintf(stderr,"NO NEXUS FILE"); } #endif return(0); } /* _an4l_setpos */ /* component an4u=Monochromator_flat() SETTING, POSITION/ROTATION */ int _an4u_setpos(void) { /* sets initial component parameters, position and rotation */ SIG_MESSAGE("[_an4u_setpos] component an4u=Monochromator_flat() SETTING [Monochromator_flat:0]"); stracpy(_an4u_var._name, "an4u", 16384); stracpy(_an4u_var._type, "Monochromator_flat", 16384); _an4u_var._index=97; int current_setpos_index = 97; _an4u_var._parameters.zmin = - wan / 2.0; _an4u_var._parameters.zmax = wan / 2.0; _an4u_var._parameters.ymin = 0; _an4u_var._parameters.ymax = ana_h / 2.0; _an4u_var._parameters.zwidth = 0; _an4u_var._parameters.yheight = 0; _an4u_var._parameters.mosaich = 30.4; _an4u_var._parameters.mosaicv = 30.4; _an4u_var._parameters.r0 = ana_r0; _an4u_var._parameters.Q = ana_q; _an4u_var._parameters.DM = 0; /* component an4u=Monochromator_flat() AT ROTATED */ { Coords tc1, tc2; tc1 = coords_set(0,0,0); tc2 = coords_set(0,0,0); Rotation tr1; rot_set_rotation(tr1,0,0,0); rot_set_rotation(tr1, (0)*DEG2RAD, (machine_real . c4)*DEG2RAD, (0)*DEG2RAD); rot_mul(tr1, _focus_ana_var._rotation_absolute, _an4u_var._rotation_absolute); rot_transpose(_an4l_var._rotation_absolute, tr1); rot_mul(_an4u_var._rotation_absolute, tr1, _an4u_var._rotation_relative); _an4u_var._rotation_is_identity = rot_test_identity(_an4u_var._rotation_relative); tc1 = coords_set( 0, 0, -1 * ana_d); rot_transpose(_focus_ana_var._rotation_absolute, tr1); tc2 = rot_apply(tr1, tc1); _an4u_var._position_absolute = coords_add(_focus_ana_var._position_absolute, tc2); tc1 = coords_sub(_an4l_var._position_absolute, _an4u_var._position_absolute); _an4u_var._position_relative = rot_apply(_an4u_var._rotation_absolute, tc1); } /* an4u=Monochromator_flat() AT ROTATED */ DEBUG_COMPONENT("an4u", _an4u_var._position_absolute, _an4u_var._rotation_absolute); instrument->_position_absolute[97] = _an4u_var._position_absolute; instrument->_position_relative[97] = _an4u_var._position_relative; _an4u_var._position_relative_is_zero = coords_test_zero(_an4u_var._position_relative); instrument->counter_N[97] = instrument->counter_P[97] = instrument->counter_P2[97] = 0; instrument->counter_AbsorbProp[97]= 0; #ifdef USE_NEXUS if(nxhandle) { if ((!mcdotrace) && mcformat && strcasestr(mcformat, "NeXus")) { MPI_MASTER( mccomp_placement_type_nexus(nxhandle,"0096_an4u", _an4u_var._position_absolute, _an4u_var._rotation_absolute, "Monochromator_flat"); mccomp_param_nexus(nxhandle,"0096_an4u", "zmin", "-0.05", "- wan / 2.0","MCNUM"); mccomp_param_nexus(nxhandle,"0096_an4u", "zmax", "0.05", "wan / 2.0","MCNUM"); mccomp_param_nexus(nxhandle,"0096_an4u", "ymin", "-0.05", "0","MCNUM"); mccomp_param_nexus(nxhandle,"0096_an4u", "ymax", "0.05", "ana_h / 2.0","MCNUM"); mccomp_param_nexus(nxhandle,"0096_an4u", "zwidth", "0", "0","MCNUM"); mccomp_param_nexus(nxhandle,"0096_an4u", "yheight", "0", "0","MCNUM"); mccomp_param_nexus(nxhandle,"0096_an4u", "mosaich", "30.0", "30.4","MCNUM"); mccomp_param_nexus(nxhandle,"0096_an4u", "mosaicv", "30.0", "30.4","MCNUM"); mccomp_param_nexus(nxhandle,"0096_an4u", "r0", "0.7", "ana_r0","MCNUM"); mccomp_param_nexus(nxhandle,"0096_an4u", "Q", "1.8734", "ana_q","MCNUM"); mccomp_param_nexus(nxhandle,"0096_an4u", "DM", "0", "0","MCNUM"); ); } } else { // fprintf(stderr,"NO NEXUS FILE"); } #endif return(0); } /* _an4u_setpos */ /* component an5l=Monochromator_flat() SETTING, POSITION/ROTATION */ int _an5l_setpos(void) { /* sets initial component parameters, position and rotation */ SIG_MESSAGE("[_an5l_setpos] component an5l=Monochromator_flat() SETTING [Monochromator_flat:0]"); stracpy(_an5l_var._name, "an5l", 16384); stracpy(_an5l_var._type, "Monochromator_flat", 16384); _an5l_var._index=98; int current_setpos_index = 98; _an5l_var._parameters.zmin = - wan / 2.0; _an5l_var._parameters.zmax = wan / 2.0; _an5l_var._parameters.ymin = - ana_h / 2.0; _an5l_var._parameters.ymax = 0; _an5l_var._parameters.zwidth = 0; _an5l_var._parameters.yheight = 0; _an5l_var._parameters.mosaich = 36.6; _an5l_var._parameters.mosaicv = 36.6; _an5l_var._parameters.r0 = ana_r0; _an5l_var._parameters.Q = ana_q; _an5l_var._parameters.DM = 0; /* component an5l=Monochromator_flat() AT ROTATED */ { Coords tc1, tc2; tc1 = coords_set(0,0,0); tc2 = coords_set(0,0,0); Rotation tr1; rot_set_rotation(tr1,0,0,0); rot_set_rotation(tr1, (0)*DEG2RAD, (machine_real . c5)*DEG2RAD, (0)*DEG2RAD); rot_mul(tr1, _focus_ana_var._rotation_absolute, _an5l_var._rotation_absolute); rot_transpose(_an4u_var._rotation_absolute, tr1); rot_mul(_an5l_var._rotation_absolute, tr1, _an5l_var._rotation_relative); _an5l_var._rotation_is_identity = rot_test_identity(_an5l_var._rotation_relative); tc1 = coords_set( 0, 0, 0); rot_transpose(_focus_ana_var._rotation_absolute, tr1); tc2 = rot_apply(tr1, tc1); _an5l_var._position_absolute = coords_add(_focus_ana_var._position_absolute, tc2); tc1 = coords_sub(_an4u_var._position_absolute, _an5l_var._position_absolute); _an5l_var._position_relative = rot_apply(_an5l_var._rotation_absolute, tc1); } /* an5l=Monochromator_flat() AT ROTATED */ DEBUG_COMPONENT("an5l", _an5l_var._position_absolute, _an5l_var._rotation_absolute); instrument->_position_absolute[98] = _an5l_var._position_absolute; instrument->_position_relative[98] = _an5l_var._position_relative; _an5l_var._position_relative_is_zero = coords_test_zero(_an5l_var._position_relative); instrument->counter_N[98] = instrument->counter_P[98] = instrument->counter_P2[98] = 0; instrument->counter_AbsorbProp[98]= 0; #ifdef USE_NEXUS if(nxhandle) { if ((!mcdotrace) && mcformat && strcasestr(mcformat, "NeXus")) { MPI_MASTER( mccomp_placement_type_nexus(nxhandle,"0097_an5l", _an5l_var._position_absolute, _an5l_var._rotation_absolute, "Monochromator_flat"); mccomp_param_nexus(nxhandle,"0097_an5l", "zmin", "-0.05", "- wan / 2.0","MCNUM"); mccomp_param_nexus(nxhandle,"0097_an5l", "zmax", "0.05", "wan / 2.0","MCNUM"); mccomp_param_nexus(nxhandle,"0097_an5l", "ymin", "-0.05", "- ana_h / 2.0","MCNUM"); mccomp_param_nexus(nxhandle,"0097_an5l", "ymax", "0.05", "0","MCNUM"); mccomp_param_nexus(nxhandle,"0097_an5l", "zwidth", "0", "0","MCNUM"); mccomp_param_nexus(nxhandle,"0097_an5l", "yheight", "0", "0","MCNUM"); mccomp_param_nexus(nxhandle,"0097_an5l", "mosaich", "30.0", "36.6","MCNUM"); mccomp_param_nexus(nxhandle,"0097_an5l", "mosaicv", "30.0", "36.6","MCNUM"); mccomp_param_nexus(nxhandle,"0097_an5l", "r0", "0.7", "ana_r0","MCNUM"); mccomp_param_nexus(nxhandle,"0097_an5l", "Q", "1.8734", "ana_q","MCNUM"); mccomp_param_nexus(nxhandle,"0097_an5l", "DM", "0", "0","MCNUM"); ); } } else { // fprintf(stderr,"NO NEXUS FILE"); } #endif return(0); } /* _an5l_setpos */ /* component an5u=Monochromator_flat() SETTING, POSITION/ROTATION */ int _an5u_setpos(void) { /* sets initial component parameters, position and rotation */ SIG_MESSAGE("[_an5u_setpos] component an5u=Monochromator_flat() SETTING [Monochromator_flat:0]"); stracpy(_an5u_var._name, "an5u", 16384); stracpy(_an5u_var._type, "Monochromator_flat", 16384); _an5u_var._index=99; int current_setpos_index = 99; _an5u_var._parameters.zmin = - wan / 2.0; _an5u_var._parameters.zmax = wan / 2.0; _an5u_var._parameters.ymin = 0; _an5u_var._parameters.ymax = ana_h / 2.0; _an5u_var._parameters.zwidth = 0; _an5u_var._parameters.yheight = 0; _an5u_var._parameters.mosaich = 35.9; _an5u_var._parameters.mosaicv = 35.9; _an5u_var._parameters.r0 = ana_r0; _an5u_var._parameters.Q = ana_q; _an5u_var._parameters.DM = 0; /* component an5u=Monochromator_flat() AT ROTATED */ { Coords tc1, tc2; tc1 = coords_set(0,0,0); tc2 = coords_set(0,0,0); Rotation tr1; rot_set_rotation(tr1,0,0,0); rot_set_rotation(tr1, (0)*DEG2RAD, (machine_real . c5)*DEG2RAD, (0)*DEG2RAD); rot_mul(tr1, _focus_ana_var._rotation_absolute, _an5u_var._rotation_absolute); rot_transpose(_an5l_var._rotation_absolute, tr1); rot_mul(_an5u_var._rotation_absolute, tr1, _an5u_var._rotation_relative); _an5u_var._rotation_is_identity = rot_test_identity(_an5u_var._rotation_relative); tc1 = coords_set( 0, 0, 0); rot_transpose(_focus_ana_var._rotation_absolute, tr1); tc2 = rot_apply(tr1, tc1); _an5u_var._position_absolute = coords_add(_focus_ana_var._position_absolute, tc2); tc1 = coords_sub(_an5l_var._position_absolute, _an5u_var._position_absolute); _an5u_var._position_relative = rot_apply(_an5u_var._rotation_absolute, tc1); } /* an5u=Monochromator_flat() AT ROTATED */ DEBUG_COMPONENT("an5u", _an5u_var._position_absolute, _an5u_var._rotation_absolute); instrument->_position_absolute[99] = _an5u_var._position_absolute; instrument->_position_relative[99] = _an5u_var._position_relative; _an5u_var._position_relative_is_zero = coords_test_zero(_an5u_var._position_relative); instrument->counter_N[99] = instrument->counter_P[99] = instrument->counter_P2[99] = 0; instrument->counter_AbsorbProp[99]= 0; #ifdef USE_NEXUS if(nxhandle) { if ((!mcdotrace) && mcformat && strcasestr(mcformat, "NeXus")) { MPI_MASTER( mccomp_placement_type_nexus(nxhandle,"0098_an5u", _an5u_var._position_absolute, _an5u_var._rotation_absolute, "Monochromator_flat"); mccomp_param_nexus(nxhandle,"0098_an5u", "zmin", "-0.05", "- wan / 2.0","MCNUM"); mccomp_param_nexus(nxhandle,"0098_an5u", "zmax", "0.05", "wan / 2.0","MCNUM"); mccomp_param_nexus(nxhandle,"0098_an5u", "ymin", "-0.05", "0","MCNUM"); mccomp_param_nexus(nxhandle,"0098_an5u", "ymax", "0.05", "ana_h / 2.0","MCNUM"); mccomp_param_nexus(nxhandle,"0098_an5u", "zwidth", "0", "0","MCNUM"); mccomp_param_nexus(nxhandle,"0098_an5u", "yheight", "0", "0","MCNUM"); mccomp_param_nexus(nxhandle,"0098_an5u", "mosaich", "30.0", "35.9","MCNUM"); mccomp_param_nexus(nxhandle,"0098_an5u", "mosaicv", "30.0", "35.9","MCNUM"); mccomp_param_nexus(nxhandle,"0098_an5u", "r0", "0.7", "ana_r0","MCNUM"); mccomp_param_nexus(nxhandle,"0098_an5u", "Q", "1.8734", "ana_q","MCNUM"); mccomp_param_nexus(nxhandle,"0098_an5u", "DM", "0", "0","MCNUM"); ); } } else { // fprintf(stderr,"NO NEXUS FILE"); } #endif return(0); } /* _an5u_setpos */ /* component an6l=Monochromator_flat() SETTING, POSITION/ROTATION */ int _an6l_setpos(void) { /* sets initial component parameters, position and rotation */ SIG_MESSAGE("[_an6l_setpos] component an6l=Monochromator_flat() SETTING [Monochromator_flat:0]"); stracpy(_an6l_var._name, "an6l", 16384); stracpy(_an6l_var._type, "Monochromator_flat", 16384); _an6l_var._index=100; int current_setpos_index = 100; _an6l_var._parameters.zmin = - wan / 2.0; _an6l_var._parameters.zmax = wan / 2.0; _an6l_var._parameters.ymin = - ana_h / 2.0; _an6l_var._parameters.ymax = 0; _an6l_var._parameters.zwidth = 0; _an6l_var._parameters.yheight = 0; _an6l_var._parameters.mosaich = 31.5; _an6l_var._parameters.mosaicv = 31.5; _an6l_var._parameters.r0 = ana_r0; _an6l_var._parameters.Q = ana_q; _an6l_var._parameters.DM = 0; /* component an6l=Monochromator_flat() AT ROTATED */ { Coords tc1, tc2; tc1 = coords_set(0,0,0); tc2 = coords_set(0,0,0); Rotation tr1; rot_set_rotation(tr1,0,0,0); rot_set_rotation(tr1, (0)*DEG2RAD, (machine_real . c6)*DEG2RAD, (0)*DEG2RAD); rot_mul(tr1, _focus_ana_var._rotation_absolute, _an6l_var._rotation_absolute); rot_transpose(_an5u_var._rotation_absolute, tr1); rot_mul(_an6l_var._rotation_absolute, tr1, _an6l_var._rotation_relative); _an6l_var._rotation_is_identity = rot_test_identity(_an6l_var._rotation_relative); tc1 = coords_set( 0, 0, ana_d); rot_transpose(_focus_ana_var._rotation_absolute, tr1); tc2 = rot_apply(tr1, tc1); _an6l_var._position_absolute = coords_add(_focus_ana_var._position_absolute, tc2); tc1 = coords_sub(_an5u_var._position_absolute, _an6l_var._position_absolute); _an6l_var._position_relative = rot_apply(_an6l_var._rotation_absolute, tc1); } /* an6l=Monochromator_flat() AT ROTATED */ DEBUG_COMPONENT("an6l", _an6l_var._position_absolute, _an6l_var._rotation_absolute); instrument->_position_absolute[100] = _an6l_var._position_absolute; instrument->_position_relative[100] = _an6l_var._position_relative; _an6l_var._position_relative_is_zero = coords_test_zero(_an6l_var._position_relative); instrument->counter_N[100] = instrument->counter_P[100] = instrument->counter_P2[100] = 0; instrument->counter_AbsorbProp[100]= 0; #ifdef USE_NEXUS if(nxhandle) { if ((!mcdotrace) && mcformat && strcasestr(mcformat, "NeXus")) { MPI_MASTER( mccomp_placement_type_nexus(nxhandle,"0099_an6l", _an6l_var._position_absolute, _an6l_var._rotation_absolute, "Monochromator_flat"); mccomp_param_nexus(nxhandle,"0099_an6l", "zmin", "-0.05", "- wan / 2.0","MCNUM"); mccomp_param_nexus(nxhandle,"0099_an6l", "zmax", "0.05", "wan / 2.0","MCNUM"); mccomp_param_nexus(nxhandle,"0099_an6l", "ymin", "-0.05", "- ana_h / 2.0","MCNUM"); mccomp_param_nexus(nxhandle,"0099_an6l", "ymax", "0.05", "0","MCNUM"); mccomp_param_nexus(nxhandle,"0099_an6l", "zwidth", "0", "0","MCNUM"); mccomp_param_nexus(nxhandle,"0099_an6l", "yheight", "0", "0","MCNUM"); mccomp_param_nexus(nxhandle,"0099_an6l", "mosaich", "30.0", "31.5","MCNUM"); mccomp_param_nexus(nxhandle,"0099_an6l", "mosaicv", "30.0", "31.5","MCNUM"); mccomp_param_nexus(nxhandle,"0099_an6l", "r0", "0.7", "ana_r0","MCNUM"); mccomp_param_nexus(nxhandle,"0099_an6l", "Q", "1.8734", "ana_q","MCNUM"); mccomp_param_nexus(nxhandle,"0099_an6l", "DM", "0", "0","MCNUM"); ); } } else { // fprintf(stderr,"NO NEXUS FILE"); } #endif return(0); } /* _an6l_setpos */ /* component an6u=Monochromator_flat() SETTING, POSITION/ROTATION */ int _an6u_setpos(void) { /* sets initial component parameters, position and rotation */ SIG_MESSAGE("[_an6u_setpos] component an6u=Monochromator_flat() SETTING [Monochromator_flat:0]"); stracpy(_an6u_var._name, "an6u", 16384); stracpy(_an6u_var._type, "Monochromator_flat", 16384); _an6u_var._index=101; int current_setpos_index = 101; _an6u_var._parameters.zmin = - wan / 2.0; _an6u_var._parameters.zmax = wan / 2.0; _an6u_var._parameters.ymin = 0; _an6u_var._parameters.ymax = ana_h / 2.0; _an6u_var._parameters.zwidth = 0; _an6u_var._parameters.yheight = 0; _an6u_var._parameters.mosaich = 36.1; _an6u_var._parameters.mosaicv = 36.1; _an6u_var._parameters.r0 = ana_r0; _an6u_var._parameters.Q = ana_q; _an6u_var._parameters.DM = 0; /* component an6u=Monochromator_flat() AT ROTATED */ { Coords tc1, tc2; tc1 = coords_set(0,0,0); tc2 = coords_set(0,0,0); Rotation tr1; rot_set_rotation(tr1,0,0,0); rot_set_rotation(tr1, (0)*DEG2RAD, (machine_real . c6)*DEG2RAD, (0)*DEG2RAD); rot_mul(tr1, _focus_ana_var._rotation_absolute, _an6u_var._rotation_absolute); rot_transpose(_an6l_var._rotation_absolute, tr1); rot_mul(_an6u_var._rotation_absolute, tr1, _an6u_var._rotation_relative); _an6u_var._rotation_is_identity = rot_test_identity(_an6u_var._rotation_relative); tc1 = coords_set( 0, 0, ana_d); rot_transpose(_focus_ana_var._rotation_absolute, tr1); tc2 = rot_apply(tr1, tc1); _an6u_var._position_absolute = coords_add(_focus_ana_var._position_absolute, tc2); tc1 = coords_sub(_an6l_var._position_absolute, _an6u_var._position_absolute); _an6u_var._position_relative = rot_apply(_an6u_var._rotation_absolute, tc1); } /* an6u=Monochromator_flat() AT ROTATED */ DEBUG_COMPONENT("an6u", _an6u_var._position_absolute, _an6u_var._rotation_absolute); instrument->_position_absolute[101] = _an6u_var._position_absolute; instrument->_position_relative[101] = _an6u_var._position_relative; _an6u_var._position_relative_is_zero = coords_test_zero(_an6u_var._position_relative); instrument->counter_N[101] = instrument->counter_P[101] = instrument->counter_P2[101] = 0; instrument->counter_AbsorbProp[101]= 0; #ifdef USE_NEXUS if(nxhandle) { if ((!mcdotrace) && mcformat && strcasestr(mcformat, "NeXus")) { MPI_MASTER( mccomp_placement_type_nexus(nxhandle,"0100_an6u", _an6u_var._position_absolute, _an6u_var._rotation_absolute, "Monochromator_flat"); mccomp_param_nexus(nxhandle,"0100_an6u", "zmin", "-0.05", "- wan / 2.0","MCNUM"); mccomp_param_nexus(nxhandle,"0100_an6u", "zmax", "0.05", "wan / 2.0","MCNUM"); mccomp_param_nexus(nxhandle,"0100_an6u", "ymin", "-0.05", "0","MCNUM"); mccomp_param_nexus(nxhandle,"0100_an6u", "ymax", "0.05", "ana_h / 2.0","MCNUM"); mccomp_param_nexus(nxhandle,"0100_an6u", "zwidth", "0", "0","MCNUM"); mccomp_param_nexus(nxhandle,"0100_an6u", "yheight", "0", "0","MCNUM"); mccomp_param_nexus(nxhandle,"0100_an6u", "mosaich", "30.0", "36.1","MCNUM"); mccomp_param_nexus(nxhandle,"0100_an6u", "mosaicv", "30.0", "36.1","MCNUM"); mccomp_param_nexus(nxhandle,"0100_an6u", "r0", "0.7", "ana_r0","MCNUM"); mccomp_param_nexus(nxhandle,"0100_an6u", "Q", "1.8734", "ana_q","MCNUM"); mccomp_param_nexus(nxhandle,"0100_an6u", "DM", "0", "0","MCNUM"); ); } } else { // fprintf(stderr,"NO NEXUS FILE"); } #endif return(0); } /* _an6u_setpos */ /* component an7l=Monochromator_flat() SETTING, POSITION/ROTATION */ int _an7l_setpos(void) { /* sets initial component parameters, position and rotation */ SIG_MESSAGE("[_an7l_setpos] component an7l=Monochromator_flat() SETTING [Monochromator_flat:0]"); stracpy(_an7l_var._name, "an7l", 16384); stracpy(_an7l_var._type, "Monochromator_flat", 16384); _an7l_var._index=102; int current_setpos_index = 102; _an7l_var._parameters.zmin = - wan / 2.0; _an7l_var._parameters.zmax = wan / 2.0; _an7l_var._parameters.ymin = - ana_h / 2.0; _an7l_var._parameters.ymax = 0; _an7l_var._parameters.zwidth = 0; _an7l_var._parameters.yheight = 0; _an7l_var._parameters.mosaich = 33.1; _an7l_var._parameters.mosaicv = 33.1; _an7l_var._parameters.r0 = ana_r0; _an7l_var._parameters.Q = ana_q; _an7l_var._parameters.DM = 0; /* component an7l=Monochromator_flat() AT ROTATED */ { Coords tc1, tc2; tc1 = coords_set(0,0,0); tc2 = coords_set(0,0,0); Rotation tr1; rot_set_rotation(tr1,0,0,0); rot_set_rotation(tr1, (0)*DEG2RAD, (machine_real . c7)*DEG2RAD, (0)*DEG2RAD); rot_mul(tr1, _focus_ana_var._rotation_absolute, _an7l_var._rotation_absolute); rot_transpose(_an6u_var._rotation_absolute, tr1); rot_mul(_an7l_var._rotation_absolute, tr1, _an7l_var._rotation_relative); _an7l_var._rotation_is_identity = rot_test_identity(_an7l_var._rotation_relative); tc1 = coords_set( 0, 0, 2 * ana_d); rot_transpose(_focus_ana_var._rotation_absolute, tr1); tc2 = rot_apply(tr1, tc1); _an7l_var._position_absolute = coords_add(_focus_ana_var._position_absolute, tc2); tc1 = coords_sub(_an6u_var._position_absolute, _an7l_var._position_absolute); _an7l_var._position_relative = rot_apply(_an7l_var._rotation_absolute, tc1); } /* an7l=Monochromator_flat() AT ROTATED */ DEBUG_COMPONENT("an7l", _an7l_var._position_absolute, _an7l_var._rotation_absolute); instrument->_position_absolute[102] = _an7l_var._position_absolute; instrument->_position_relative[102] = _an7l_var._position_relative; _an7l_var._position_relative_is_zero = coords_test_zero(_an7l_var._position_relative); instrument->counter_N[102] = instrument->counter_P[102] = instrument->counter_P2[102] = 0; instrument->counter_AbsorbProp[102]= 0; #ifdef USE_NEXUS if(nxhandle) { if ((!mcdotrace) && mcformat && strcasestr(mcformat, "NeXus")) { MPI_MASTER( mccomp_placement_type_nexus(nxhandle,"0101_an7l", _an7l_var._position_absolute, _an7l_var._rotation_absolute, "Monochromator_flat"); mccomp_param_nexus(nxhandle,"0101_an7l", "zmin", "-0.05", "- wan / 2.0","MCNUM"); mccomp_param_nexus(nxhandle,"0101_an7l", "zmax", "0.05", "wan / 2.0","MCNUM"); mccomp_param_nexus(nxhandle,"0101_an7l", "ymin", "-0.05", "- ana_h / 2.0","MCNUM"); mccomp_param_nexus(nxhandle,"0101_an7l", "ymax", "0.05", "0","MCNUM"); mccomp_param_nexus(nxhandle,"0101_an7l", "zwidth", "0", "0","MCNUM"); mccomp_param_nexus(nxhandle,"0101_an7l", "yheight", "0", "0","MCNUM"); mccomp_param_nexus(nxhandle,"0101_an7l", "mosaich", "30.0", "33.1","MCNUM"); mccomp_param_nexus(nxhandle,"0101_an7l", "mosaicv", "30.0", "33.1","MCNUM"); mccomp_param_nexus(nxhandle,"0101_an7l", "r0", "0.7", "ana_r0","MCNUM"); mccomp_param_nexus(nxhandle,"0101_an7l", "Q", "1.8734", "ana_q","MCNUM"); mccomp_param_nexus(nxhandle,"0101_an7l", "DM", "0", "0","MCNUM"); ); } } else { // fprintf(stderr,"NO NEXUS FILE"); } #endif return(0); } /* _an7l_setpos */ /* component an7u=Monochromator_flat() SETTING, POSITION/ROTATION */ int _an7u_setpos(void) { /* sets initial component parameters, position and rotation */ SIG_MESSAGE("[_an7u_setpos] component an7u=Monochromator_flat() SETTING [Monochromator_flat:0]"); stracpy(_an7u_var._name, "an7u", 16384); stracpy(_an7u_var._type, "Monochromator_flat", 16384); _an7u_var._index=103; int current_setpos_index = 103; _an7u_var._parameters.zmin = - wan / 2.0; _an7u_var._parameters.zmax = wan / 2.0; _an7u_var._parameters.ymin = 0; _an7u_var._parameters.ymax = ana_h / 2.0; _an7u_var._parameters.zwidth = 0; _an7u_var._parameters.yheight = 0; _an7u_var._parameters.mosaich = 37.2; _an7u_var._parameters.mosaicv = 37.2; _an7u_var._parameters.r0 = ana_r0; _an7u_var._parameters.Q = ana_q; _an7u_var._parameters.DM = 0; /* component an7u=Monochromator_flat() AT ROTATED */ { Coords tc1, tc2; tc1 = coords_set(0,0,0); tc2 = coords_set(0,0,0); Rotation tr1; rot_set_rotation(tr1,0,0,0); rot_set_rotation(tr1, (0)*DEG2RAD, (machine_real . c7)*DEG2RAD, (0)*DEG2RAD); rot_mul(tr1, _focus_ana_var._rotation_absolute, _an7u_var._rotation_absolute); rot_transpose(_an7l_var._rotation_absolute, tr1); rot_mul(_an7u_var._rotation_absolute, tr1, _an7u_var._rotation_relative); _an7u_var._rotation_is_identity = rot_test_identity(_an7u_var._rotation_relative); tc1 = coords_set( 0, 0, 2 * ana_d); rot_transpose(_focus_ana_var._rotation_absolute, tr1); tc2 = rot_apply(tr1, tc1); _an7u_var._position_absolute = coords_add(_focus_ana_var._position_absolute, tc2); tc1 = coords_sub(_an7l_var._position_absolute, _an7u_var._position_absolute); _an7u_var._position_relative = rot_apply(_an7u_var._rotation_absolute, tc1); } /* an7u=Monochromator_flat() AT ROTATED */ DEBUG_COMPONENT("an7u", _an7u_var._position_absolute, _an7u_var._rotation_absolute); instrument->_position_absolute[103] = _an7u_var._position_absolute; instrument->_position_relative[103] = _an7u_var._position_relative; _an7u_var._position_relative_is_zero = coords_test_zero(_an7u_var._position_relative); instrument->counter_N[103] = instrument->counter_P[103] = instrument->counter_P2[103] = 0; instrument->counter_AbsorbProp[103]= 0; #ifdef USE_NEXUS if(nxhandle) { if ((!mcdotrace) && mcformat && strcasestr(mcformat, "NeXus")) { MPI_MASTER( mccomp_placement_type_nexus(nxhandle,"0102_an7u", _an7u_var._position_absolute, _an7u_var._rotation_absolute, "Monochromator_flat"); mccomp_param_nexus(nxhandle,"0102_an7u", "zmin", "-0.05", "- wan / 2.0","MCNUM"); mccomp_param_nexus(nxhandle,"0102_an7u", "zmax", "0.05", "wan / 2.0","MCNUM"); mccomp_param_nexus(nxhandle,"0102_an7u", "ymin", "-0.05", "0","MCNUM"); mccomp_param_nexus(nxhandle,"0102_an7u", "ymax", "0.05", "ana_h / 2.0","MCNUM"); mccomp_param_nexus(nxhandle,"0102_an7u", "zwidth", "0", "0","MCNUM"); mccomp_param_nexus(nxhandle,"0102_an7u", "yheight", "0", "0","MCNUM"); mccomp_param_nexus(nxhandle,"0102_an7u", "mosaich", "30.0", "37.2","MCNUM"); mccomp_param_nexus(nxhandle,"0102_an7u", "mosaicv", "30.0", "37.2","MCNUM"); mccomp_param_nexus(nxhandle,"0102_an7u", "r0", "0.7", "ana_r0","MCNUM"); mccomp_param_nexus(nxhandle,"0102_an7u", "Q", "1.8734", "ana_q","MCNUM"); mccomp_param_nexus(nxhandle,"0102_an7u", "DM", "0", "0","MCNUM"); ); } } else { // fprintf(stderr,"NO NEXUS FILE"); } #endif return(0); } /* _an7u_setpos */ /* component an8l=Monochromator_flat() SETTING, POSITION/ROTATION */ int _an8l_setpos(void) { /* sets initial component parameters, position and rotation */ SIG_MESSAGE("[_an8l_setpos] component an8l=Monochromator_flat() SETTING [Monochromator_flat:0]"); stracpy(_an8l_var._name, "an8l", 16384); stracpy(_an8l_var._type, "Monochromator_flat", 16384); _an8l_var._index=104; int current_setpos_index = 104; _an8l_var._parameters.zmin = - wan / 2.0; _an8l_var._parameters.zmax = wan / 2.0; _an8l_var._parameters.ymin = - ana_h / 2.0; _an8l_var._parameters.ymax = 0; _an8l_var._parameters.zwidth = 0; _an8l_var._parameters.yheight = 0; _an8l_var._parameters.mosaich = 46.8; _an8l_var._parameters.mosaicv = 46.8; _an8l_var._parameters.r0 = ana_r0; _an8l_var._parameters.Q = ana_q; _an8l_var._parameters.DM = 0; /* component an8l=Monochromator_flat() AT ROTATED */ { Coords tc1, tc2; tc1 = coords_set(0,0,0); tc2 = coords_set(0,0,0); Rotation tr1; rot_set_rotation(tr1,0,0,0); rot_set_rotation(tr1, (0)*DEG2RAD, (machine_real . c8)*DEG2RAD, (0)*DEG2RAD); rot_mul(tr1, _focus_ana_var._rotation_absolute, _an8l_var._rotation_absolute); rot_transpose(_an7u_var._rotation_absolute, tr1); rot_mul(_an8l_var._rotation_absolute, tr1, _an8l_var._rotation_relative); _an8l_var._rotation_is_identity = rot_test_identity(_an8l_var._rotation_relative); tc1 = coords_set( 0, 0, 3 * ana_d); rot_transpose(_focus_ana_var._rotation_absolute, tr1); tc2 = rot_apply(tr1, tc1); _an8l_var._position_absolute = coords_add(_focus_ana_var._position_absolute, tc2); tc1 = coords_sub(_an7u_var._position_absolute, _an8l_var._position_absolute); _an8l_var._position_relative = rot_apply(_an8l_var._rotation_absolute, tc1); } /* an8l=Monochromator_flat() AT ROTATED */ DEBUG_COMPONENT("an8l", _an8l_var._position_absolute, _an8l_var._rotation_absolute); instrument->_position_absolute[104] = _an8l_var._position_absolute; instrument->_position_relative[104] = _an8l_var._position_relative; _an8l_var._position_relative_is_zero = coords_test_zero(_an8l_var._position_relative); instrument->counter_N[104] = instrument->counter_P[104] = instrument->counter_P2[104] = 0; instrument->counter_AbsorbProp[104]= 0; #ifdef USE_NEXUS if(nxhandle) { if ((!mcdotrace) && mcformat && strcasestr(mcformat, "NeXus")) { MPI_MASTER( mccomp_placement_type_nexus(nxhandle,"0103_an8l", _an8l_var._position_absolute, _an8l_var._rotation_absolute, "Monochromator_flat"); mccomp_param_nexus(nxhandle,"0103_an8l", "zmin", "-0.05", "- wan / 2.0","MCNUM"); mccomp_param_nexus(nxhandle,"0103_an8l", "zmax", "0.05", "wan / 2.0","MCNUM"); mccomp_param_nexus(nxhandle,"0103_an8l", "ymin", "-0.05", "- ana_h / 2.0","MCNUM"); mccomp_param_nexus(nxhandle,"0103_an8l", "ymax", "0.05", "0","MCNUM"); mccomp_param_nexus(nxhandle,"0103_an8l", "zwidth", "0", "0","MCNUM"); mccomp_param_nexus(nxhandle,"0103_an8l", "yheight", "0", "0","MCNUM"); mccomp_param_nexus(nxhandle,"0103_an8l", "mosaich", "30.0", "46.8","MCNUM"); mccomp_param_nexus(nxhandle,"0103_an8l", "mosaicv", "30.0", "46.8","MCNUM"); mccomp_param_nexus(nxhandle,"0103_an8l", "r0", "0.7", "ana_r0","MCNUM"); mccomp_param_nexus(nxhandle,"0103_an8l", "Q", "1.8734", "ana_q","MCNUM"); mccomp_param_nexus(nxhandle,"0103_an8l", "DM", "0", "0","MCNUM"); ); } } else { // fprintf(stderr,"NO NEXUS FILE"); } #endif return(0); } /* _an8l_setpos */ /* component an8u=Monochromator_flat() SETTING, POSITION/ROTATION */ int _an8u_setpos(void) { /* sets initial component parameters, position and rotation */ SIG_MESSAGE("[_an8u_setpos] component an8u=Monochromator_flat() SETTING [Monochromator_flat:0]"); stracpy(_an8u_var._name, "an8u", 16384); stracpy(_an8u_var._type, "Monochromator_flat", 16384); _an8u_var._index=105; int current_setpos_index = 105; _an8u_var._parameters.zmin = - wan / 2.0; _an8u_var._parameters.zmax = wan / 2.0; _an8u_var._parameters.ymin = 0; _an8u_var._parameters.ymax = ana_h / 2.0; _an8u_var._parameters.zwidth = 0; _an8u_var._parameters.yheight = 0; _an8u_var._parameters.mosaich = 51.3; _an8u_var._parameters.mosaicv = 51.3; _an8u_var._parameters.r0 = ana_r0; _an8u_var._parameters.Q = ana_q; _an8u_var._parameters.DM = 0; /* component an8u=Monochromator_flat() AT ROTATED */ { Coords tc1, tc2; tc1 = coords_set(0,0,0); tc2 = coords_set(0,0,0); Rotation tr1; rot_set_rotation(tr1,0,0,0); rot_set_rotation(tr1, (0)*DEG2RAD, (machine_real . c8)*DEG2RAD, (0)*DEG2RAD); rot_mul(tr1, _focus_ana_var._rotation_absolute, _an8u_var._rotation_absolute); rot_transpose(_an8l_var._rotation_absolute, tr1); rot_mul(_an8u_var._rotation_absolute, tr1, _an8u_var._rotation_relative); _an8u_var._rotation_is_identity = rot_test_identity(_an8u_var._rotation_relative); tc1 = coords_set( 0, 0, 3 * ana_d); rot_transpose(_focus_ana_var._rotation_absolute, tr1); tc2 = rot_apply(tr1, tc1); _an8u_var._position_absolute = coords_add(_focus_ana_var._position_absolute, tc2); tc1 = coords_sub(_an8l_var._position_absolute, _an8u_var._position_absolute); _an8u_var._position_relative = rot_apply(_an8u_var._rotation_absolute, tc1); } /* an8u=Monochromator_flat() AT ROTATED */ DEBUG_COMPONENT("an8u", _an8u_var._position_absolute, _an8u_var._rotation_absolute); instrument->_position_absolute[105] = _an8u_var._position_absolute; instrument->_position_relative[105] = _an8u_var._position_relative; _an8u_var._position_relative_is_zero = coords_test_zero(_an8u_var._position_relative); instrument->counter_N[105] = instrument->counter_P[105] = instrument->counter_P2[105] = 0; instrument->counter_AbsorbProp[105]= 0; #ifdef USE_NEXUS if(nxhandle) { if ((!mcdotrace) && mcformat && strcasestr(mcformat, "NeXus")) { MPI_MASTER( mccomp_placement_type_nexus(nxhandle,"0104_an8u", _an8u_var._position_absolute, _an8u_var._rotation_absolute, "Monochromator_flat"); mccomp_param_nexus(nxhandle,"0104_an8u", "zmin", "-0.05", "- wan / 2.0","MCNUM"); mccomp_param_nexus(nxhandle,"0104_an8u", "zmax", "0.05", "wan / 2.0","MCNUM"); mccomp_param_nexus(nxhandle,"0104_an8u", "ymin", "-0.05", "0","MCNUM"); mccomp_param_nexus(nxhandle,"0104_an8u", "ymax", "0.05", "ana_h / 2.0","MCNUM"); mccomp_param_nexus(nxhandle,"0104_an8u", "zwidth", "0", "0","MCNUM"); mccomp_param_nexus(nxhandle,"0104_an8u", "yheight", "0", "0","MCNUM"); mccomp_param_nexus(nxhandle,"0104_an8u", "mosaich", "30.0", "51.3","MCNUM"); mccomp_param_nexus(nxhandle,"0104_an8u", "mosaicv", "30.0", "51.3","MCNUM"); mccomp_param_nexus(nxhandle,"0104_an8u", "r0", "0.7", "ana_r0","MCNUM"); mccomp_param_nexus(nxhandle,"0104_an8u", "Q", "1.8734", "ana_q","MCNUM"); mccomp_param_nexus(nxhandle,"0104_an8u", "DM", "0", "0","MCNUM"); ); } } else { // fprintf(stderr,"NO NEXUS FILE"); } #endif return(0); } /* _an8u_setpos */ /* component an9l=Monochromator_flat() SETTING, POSITION/ROTATION */ int _an9l_setpos(void) { /* sets initial component parameters, position and rotation */ SIG_MESSAGE("[_an9l_setpos] component an9l=Monochromator_flat() SETTING [Monochromator_flat:0]"); stracpy(_an9l_var._name, "an9l", 16384); stracpy(_an9l_var._type, "Monochromator_flat", 16384); _an9l_var._index=106; int current_setpos_index = 106; _an9l_var._parameters.zmin = - wan / 2.0; _an9l_var._parameters.zmax = wan / 2.0; _an9l_var._parameters.ymin = - ana_h / 2.0; _an9l_var._parameters.ymax = 0; _an9l_var._parameters.zwidth = 0; _an9l_var._parameters.yheight = 0; _an9l_var._parameters.mosaich = 40; _an9l_var._parameters.mosaicv = 40; _an9l_var._parameters.r0 = ana_r0; _an9l_var._parameters.Q = ana_q; _an9l_var._parameters.DM = 0; /* component an9l=Monochromator_flat() AT ROTATED */ { Coords tc1, tc2; tc1 = coords_set(0,0,0); tc2 = coords_set(0,0,0); Rotation tr1; rot_set_rotation(tr1,0,0,0); rot_set_rotation(tr1, (0)*DEG2RAD, (machine_real . c9)*DEG2RAD, (0)*DEG2RAD); rot_mul(tr1, _focus_ana_var._rotation_absolute, _an9l_var._rotation_absolute); rot_transpose(_an8u_var._rotation_absolute, tr1); rot_mul(_an9l_var._rotation_absolute, tr1, _an9l_var._rotation_relative); _an9l_var._rotation_is_identity = rot_test_identity(_an9l_var._rotation_relative); tc1 = coords_set( 0, 0, 4 * ana_d); rot_transpose(_focus_ana_var._rotation_absolute, tr1); tc2 = rot_apply(tr1, tc1); _an9l_var._position_absolute = coords_add(_focus_ana_var._position_absolute, tc2); tc1 = coords_sub(_an8u_var._position_absolute, _an9l_var._position_absolute); _an9l_var._position_relative = rot_apply(_an9l_var._rotation_absolute, tc1); } /* an9l=Monochromator_flat() AT ROTATED */ DEBUG_COMPONENT("an9l", _an9l_var._position_absolute, _an9l_var._rotation_absolute); instrument->_position_absolute[106] = _an9l_var._position_absolute; instrument->_position_relative[106] = _an9l_var._position_relative; _an9l_var._position_relative_is_zero = coords_test_zero(_an9l_var._position_relative); instrument->counter_N[106] = instrument->counter_P[106] = instrument->counter_P2[106] = 0; instrument->counter_AbsorbProp[106]= 0; #ifdef USE_NEXUS if(nxhandle) { if ((!mcdotrace) && mcformat && strcasestr(mcformat, "NeXus")) { MPI_MASTER( mccomp_placement_type_nexus(nxhandle,"0105_an9l", _an9l_var._position_absolute, _an9l_var._rotation_absolute, "Monochromator_flat"); mccomp_param_nexus(nxhandle,"0105_an9l", "zmin", "-0.05", "- wan / 2.0","MCNUM"); mccomp_param_nexus(nxhandle,"0105_an9l", "zmax", "0.05", "wan / 2.0","MCNUM"); mccomp_param_nexus(nxhandle,"0105_an9l", "ymin", "-0.05", "- ana_h / 2.0","MCNUM"); mccomp_param_nexus(nxhandle,"0105_an9l", "ymax", "0.05", "0","MCNUM"); mccomp_param_nexus(nxhandle,"0105_an9l", "zwidth", "0", "0","MCNUM"); mccomp_param_nexus(nxhandle,"0105_an9l", "yheight", "0", "0","MCNUM"); mccomp_param_nexus(nxhandle,"0105_an9l", "mosaich", "30.0", "40","MCNUM"); mccomp_param_nexus(nxhandle,"0105_an9l", "mosaicv", "30.0", "40","MCNUM"); mccomp_param_nexus(nxhandle,"0105_an9l", "r0", "0.7", "ana_r0","MCNUM"); mccomp_param_nexus(nxhandle,"0105_an9l", "Q", "1.8734", "ana_q","MCNUM"); mccomp_param_nexus(nxhandle,"0105_an9l", "DM", "0", "0","MCNUM"); ); } } else { // fprintf(stderr,"NO NEXUS FILE"); } #endif return(0); } /* _an9l_setpos */ /* component an9u=Monochromator_flat() SETTING, POSITION/ROTATION */ int _an9u_setpos(void) { /* sets initial component parameters, position and rotation */ SIG_MESSAGE("[_an9u_setpos] component an9u=Monochromator_flat() SETTING [Monochromator_flat:0]"); stracpy(_an9u_var._name, "an9u", 16384); stracpy(_an9u_var._type, "Monochromator_flat", 16384); _an9u_var._index=107; int current_setpos_index = 107; _an9u_var._parameters.zmin = - wan / 2.0; _an9u_var._parameters.zmax = wan / 2.0; _an9u_var._parameters.ymin = 0; _an9u_var._parameters.ymax = ana_h / 2.0; _an9u_var._parameters.zwidth = 0; _an9u_var._parameters.yheight = 0; _an9u_var._parameters.mosaich = 40; _an9u_var._parameters.mosaicv = 40; _an9u_var._parameters.r0 = ana_r0; _an9u_var._parameters.Q = ana_q; _an9u_var._parameters.DM = 0; /* component an9u=Monochromator_flat() AT ROTATED */ { Coords tc1, tc2; tc1 = coords_set(0,0,0); tc2 = coords_set(0,0,0); Rotation tr1; rot_set_rotation(tr1,0,0,0); rot_set_rotation(tr1, (0)*DEG2RAD, (machine_real . c9)*DEG2RAD, (0)*DEG2RAD); rot_mul(tr1, _focus_ana_var._rotation_absolute, _an9u_var._rotation_absolute); rot_transpose(_an9l_var._rotation_absolute, tr1); rot_mul(_an9u_var._rotation_absolute, tr1, _an9u_var._rotation_relative); _an9u_var._rotation_is_identity = rot_test_identity(_an9u_var._rotation_relative); tc1 = coords_set( 0, 0, 4 * ana_d); rot_transpose(_focus_ana_var._rotation_absolute, tr1); tc2 = rot_apply(tr1, tc1); _an9u_var._position_absolute = coords_add(_focus_ana_var._position_absolute, tc2); tc1 = coords_sub(_an9l_var._position_absolute, _an9u_var._position_absolute); _an9u_var._position_relative = rot_apply(_an9u_var._rotation_absolute, tc1); } /* an9u=Monochromator_flat() AT ROTATED */ DEBUG_COMPONENT("an9u", _an9u_var._position_absolute, _an9u_var._rotation_absolute); instrument->_position_absolute[107] = _an9u_var._position_absolute; instrument->_position_relative[107] = _an9u_var._position_relative; _an9u_var._position_relative_is_zero = coords_test_zero(_an9u_var._position_relative); instrument->counter_N[107] = instrument->counter_P[107] = instrument->counter_P2[107] = 0; instrument->counter_AbsorbProp[107]= 0; #ifdef USE_NEXUS if(nxhandle) { if ((!mcdotrace) && mcformat && strcasestr(mcformat, "NeXus")) { MPI_MASTER( mccomp_placement_type_nexus(nxhandle,"0106_an9u", _an9u_var._position_absolute, _an9u_var._rotation_absolute, "Monochromator_flat"); mccomp_param_nexus(nxhandle,"0106_an9u", "zmin", "-0.05", "- wan / 2.0","MCNUM"); mccomp_param_nexus(nxhandle,"0106_an9u", "zmax", "0.05", "wan / 2.0","MCNUM"); mccomp_param_nexus(nxhandle,"0106_an9u", "ymin", "-0.05", "0","MCNUM"); mccomp_param_nexus(nxhandle,"0106_an9u", "ymax", "0.05", "ana_h / 2.0","MCNUM"); mccomp_param_nexus(nxhandle,"0106_an9u", "zwidth", "0", "0","MCNUM"); mccomp_param_nexus(nxhandle,"0106_an9u", "yheight", "0", "0","MCNUM"); mccomp_param_nexus(nxhandle,"0106_an9u", "mosaich", "30.0", "40","MCNUM"); mccomp_param_nexus(nxhandle,"0106_an9u", "mosaicv", "30.0", "40","MCNUM"); mccomp_param_nexus(nxhandle,"0106_an9u", "r0", "0.7", "ana_r0","MCNUM"); mccomp_param_nexus(nxhandle,"0106_an9u", "Q", "1.8734", "ana_q","MCNUM"); mccomp_param_nexus(nxhandle,"0106_an9u", "DM", "0", "0","MCNUM"); ); } } else { // fprintf(stderr,"NO NEXUS FILE"); } #endif return(0); } /* _an9u_setpos */ /* component a6=Arm() SETTING, POSITION/ROTATION */ int _a6_setpos(void) { /* sets initial component parameters, position and rotation */ SIG_MESSAGE("[_a6_setpos] component a6=Arm() SETTING [Arm:0]"); stracpy(_a6_var._name, "a6", 16384); stracpy(_a6_var._type, "Arm", 16384); _a6_var._index=108; int current_setpos_index = 108; /* component a6=Arm() AT ROTATED */ { Coords tc1, tc2; tc1 = coords_set(0,0,0); tc2 = coords_set(0,0,0); Rotation tr1; rot_set_rotation(tr1,0,0,0); rot_set_rotation(tr1, (0)*DEG2RAD, (machine_real . a6)*DEG2RAD, (0)*DEG2RAD); rot_mul(tr1, _a4_var._rotation_absolute, _a6_var._rotation_absolute); rot_transpose(_an9u_var._rotation_absolute, tr1); rot_mul(_a6_var._rotation_absolute, tr1, _a6_var._rotation_relative); _a6_var._rotation_is_identity = rot_test_identity(_a6_var._rotation_relative); tc1 = coords_set( 0, 0, 0); rot_transpose(_focus_ana_var._rotation_absolute, tr1); tc2 = rot_apply(tr1, tc1); _a6_var._position_absolute = coords_add(_focus_ana_var._position_absolute, tc2); tc1 = coords_sub(_an9u_var._position_absolute, _a6_var._position_absolute); _a6_var._position_relative = rot_apply(_a6_var._rotation_absolute, tc1); } /* a6=Arm() AT ROTATED */ DEBUG_COMPONENT("a6", _a6_var._position_absolute, _a6_var._rotation_absolute); instrument->_position_absolute[108] = _a6_var._position_absolute; instrument->_position_relative[108] = _a6_var._position_relative; _a6_var._position_relative_is_zero = coords_test_zero(_a6_var._position_relative); instrument->counter_N[108] = instrument->counter_P[108] = instrument->counter_P2[108] = 0; instrument->counter_AbsorbProp[108]= 0; #ifdef USE_NEXUS if(nxhandle) { if ((!mcdotrace) && mcformat && strcasestr(mcformat, "NeXus")) { MPI_MASTER( mccomp_placement_type_nexus(nxhandle,"0107_a6", _a6_var._position_absolute, _a6_var._rotation_absolute, "Arm"); ); } } else { // fprintf(stderr,"NO NEXUS FILE"); } #endif return(0); } /* _a6_setpos */ /* component emon_before_coarse=E_monitor() SETTING, POSITION/ROTATION */ int _emon_before_coarse_setpos(void) { /* sets initial component parameters, position and rotation */ SIG_MESSAGE("[_emon_before_coarse_setpos] component emon_before_coarse=E_monitor() SETTING [E_monitor:0]"); stracpy(_emon_before_coarse_var._name, "emon_before_coarse", 16384); stracpy(_emon_before_coarse_var._type, "E_monitor", 16384); _emon_before_coarse_var._index=109; int current_setpos_index = 109; _emon_before_coarse_var._parameters.nE = 100; if("emon_before_coarse.dat" && strlen("emon_before_coarse.dat")) stracpy(_emon_before_coarse_var._parameters.filename, "emon_before_coarse.dat" ? "emon_before_coarse.dat" : "", 16384); else _emon_before_coarse_var._parameters.filename[0]='\0'; _emon_before_coarse_var._parameters.xmin = -0.01; _emon_before_coarse_var._parameters.xmax = 0.01; _emon_before_coarse_var._parameters.ymin = -0.15; _emon_before_coarse_var._parameters.ymax = 0.15; _emon_before_coarse_var._parameters.nowritefile = 0; _emon_before_coarse_var._parameters.xwidth = 0; _emon_before_coarse_var._parameters.yheight = 0; _emon_before_coarse_var._parameters.Emin = eminf; _emon_before_coarse_var._parameters.Emax = emaxf; _emon_before_coarse_var._parameters.restore_neutron = 1; /* component emon_before_coarse=E_monitor() AT ROTATED */ { Coords tc1, tc2; tc1 = coords_set(0,0,0); tc2 = coords_set(0,0,0); Rotation tr1; rot_set_rotation(tr1,0,0,0); rot_set_rotation(tr1, (0.0)*DEG2RAD, (0.0)*DEG2RAD, (0.0)*DEG2RAD); rot_mul(tr1, _a6_var._rotation_absolute, _emon_before_coarse_var._rotation_absolute); rot_transpose(_an9u_var._rotation_absolute, tr1); rot_mul(_emon_before_coarse_var._rotation_absolute, tr1, _emon_before_coarse_var._rotation_relative); _emon_before_coarse_var._rotation_is_identity = rot_test_identity(_emon_before_coarse_var._rotation_relative); tc1 = coords_set( 0, 0, dad - BladeLength -0.02); rot_transpose(_a6_var._rotation_absolute, tr1); tc2 = rot_apply(tr1, tc1); _emon_before_coarse_var._position_absolute = coords_add(_a6_var._position_absolute, tc2); tc1 = coords_sub(_an9u_var._position_absolute, _emon_before_coarse_var._position_absolute); _emon_before_coarse_var._position_relative = rot_apply(_emon_before_coarse_var._rotation_absolute, tc1); } /* emon_before_coarse=E_monitor() AT ROTATED */ DEBUG_COMPONENT("emon_before_coarse", _emon_before_coarse_var._position_absolute, _emon_before_coarse_var._rotation_absolute); instrument->_position_absolute[109] = _emon_before_coarse_var._position_absolute; instrument->_position_relative[109] = _emon_before_coarse_var._position_relative; _emon_before_coarse_var._position_relative_is_zero = coords_test_zero(_emon_before_coarse_var._position_relative); instrument->counter_N[109] = instrument->counter_P[109] = instrument->counter_P2[109] = 0; instrument->counter_AbsorbProp[109]= 0; #ifdef USE_NEXUS if(nxhandle) { if ((!mcdotrace) && mcformat && strcasestr(mcformat, "NeXus")) { MPI_MASTER( mccomp_placement_type_nexus(nxhandle,"0108_emon_before_coarse", _emon_before_coarse_var._position_absolute, _emon_before_coarse_var._rotation_absolute, "E_monitor"); mccomp_param_nexus(nxhandle,"0108_emon_before_coarse", "nE", "20", "100","int"); mccomp_param_nexus(nxhandle,"0108_emon_before_coarse", "filename", 0, "emon_before_coarse.dat", "char*"); mccomp_param_nexus(nxhandle,"0108_emon_before_coarse", "xmin", "-0.05", "-0.01","MCNUM"); mccomp_param_nexus(nxhandle,"0108_emon_before_coarse", "xmax", "0.05", "0.01","MCNUM"); mccomp_param_nexus(nxhandle,"0108_emon_before_coarse", "ymin", "-0.05", "-0.15","MCNUM"); mccomp_param_nexus(nxhandle,"0108_emon_before_coarse", "ymax", "0.05", "0.15","MCNUM"); mccomp_param_nexus(nxhandle,"0108_emon_before_coarse", "nowritefile", "0", "0","int"); mccomp_param_nexus(nxhandle,"0108_emon_before_coarse", "xwidth", "0", "0","MCNUM"); mccomp_param_nexus(nxhandle,"0108_emon_before_coarse", "yheight", "0", "0","MCNUM"); mccomp_param_nexus(nxhandle,"0108_emon_before_coarse", "Emin", "NONE", "eminf","MCNUM"); mccomp_param_nexus(nxhandle,"0108_emon_before_coarse", "Emax", "NONE", "emaxf","MCNUM"); mccomp_param_nexus(nxhandle,"0108_emon_before_coarse", "restore_neutron", "0", "1","int"); ); } } else { // fprintf(stderr,"NO NEXUS FILE"); } #endif return(0); } /* _emon_before_coarse_setpos */ /* component psd_before_coarse=PSD_monitor() SETTING, POSITION/ROTATION */ int _psd_before_coarse_setpos(void) { /* sets initial component parameters, position and rotation */ SIG_MESSAGE("[_psd_before_coarse_setpos] component psd_before_coarse=PSD_monitor() SETTING [PSD_monitor:0]"); stracpy(_psd_before_coarse_var._name, "psd_before_coarse", 16384); stracpy(_psd_before_coarse_var._type, "PSD_monitor", 16384); _psd_before_coarse_var._index=110; int current_setpos_index = 110; _psd_before_coarse_var._parameters.nx = 128; _psd_before_coarse_var._parameters.ny = 128; if("psd_before_coarse.dat" && strlen("psd_before_coarse.dat")) stracpy(_psd_before_coarse_var._parameters.filename, "psd_before_coarse.dat" ? "psd_before_coarse.dat" : "", 16384); else _psd_before_coarse_var._parameters.filename[0]='\0'; _psd_before_coarse_var._parameters.xmin = -0.15; _psd_before_coarse_var._parameters.xmax = 0.15; _psd_before_coarse_var._parameters.ymin = -0.15; _psd_before_coarse_var._parameters.ymax = 0.15; _psd_before_coarse_var._parameters.xwidth = 0; _psd_before_coarse_var._parameters.yheight = 0; _psd_before_coarse_var._parameters.restore_neutron = 1; _psd_before_coarse_var._parameters.nowritefile = 0; /* component psd_before_coarse=PSD_monitor() AT ROTATED */ { Coords tc1, tc2; tc1 = coords_set(0,0,0); tc2 = coords_set(0,0,0); Rotation tr1; rot_set_rotation(tr1,0,0,0); rot_set_rotation(tr1, (0)*DEG2RAD, (180)*DEG2RAD, (0)*DEG2RAD); rot_mul(tr1, _a6_var._rotation_absolute, _psd_before_coarse_var._rotation_absolute); rot_transpose(_emon_before_coarse_var._rotation_absolute, tr1); rot_mul(_psd_before_coarse_var._rotation_absolute, tr1, _psd_before_coarse_var._rotation_relative); _psd_before_coarse_var._rotation_is_identity = rot_test_identity(_psd_before_coarse_var._rotation_relative); tc1 = coords_set( 0, 0, dad - BladeLength -0.01); rot_transpose(_a6_var._rotation_absolute, tr1); tc2 = rot_apply(tr1, tc1); _psd_before_coarse_var._position_absolute = coords_add(_a6_var._position_absolute, tc2); tc1 = coords_sub(_emon_before_coarse_var._position_absolute, _psd_before_coarse_var._position_absolute); _psd_before_coarse_var._position_relative = rot_apply(_psd_before_coarse_var._rotation_absolute, tc1); } /* psd_before_coarse=PSD_monitor() AT ROTATED */ DEBUG_COMPONENT("psd_before_coarse", _psd_before_coarse_var._position_absolute, _psd_before_coarse_var._rotation_absolute); instrument->_position_absolute[110] = _psd_before_coarse_var._position_absolute; instrument->_position_relative[110] = _psd_before_coarse_var._position_relative; _psd_before_coarse_var._position_relative_is_zero = coords_test_zero(_psd_before_coarse_var._position_relative); instrument->counter_N[110] = instrument->counter_P[110] = instrument->counter_P2[110] = 0; instrument->counter_AbsorbProp[110]= 0; #ifdef USE_NEXUS if(nxhandle) { if ((!mcdotrace) && mcformat && strcasestr(mcformat, "NeXus")) { MPI_MASTER( mccomp_placement_type_nexus(nxhandle,"0109_psd_before_coarse", _psd_before_coarse_var._position_absolute, _psd_before_coarse_var._rotation_absolute, "PSD_monitor"); mccomp_param_nexus(nxhandle,"0109_psd_before_coarse", "nx", "90", "128","int"); mccomp_param_nexus(nxhandle,"0109_psd_before_coarse", "ny", "90", "128","int"); mccomp_param_nexus(nxhandle,"0109_psd_before_coarse", "filename", 0, "psd_before_coarse.dat", "char*"); mccomp_param_nexus(nxhandle,"0109_psd_before_coarse", "xmin", "-0.05", "-0.15","MCNUM"); mccomp_param_nexus(nxhandle,"0109_psd_before_coarse", "xmax", "0.05", "0.15","MCNUM"); mccomp_param_nexus(nxhandle,"0109_psd_before_coarse", "ymin", "-0.05", "-0.15","MCNUM"); mccomp_param_nexus(nxhandle,"0109_psd_before_coarse", "ymax", "0.05", "0.15","MCNUM"); mccomp_param_nexus(nxhandle,"0109_psd_before_coarse", "xwidth", "0", "0","MCNUM"); mccomp_param_nexus(nxhandle,"0109_psd_before_coarse", "yheight", "0", "0","MCNUM"); mccomp_param_nexus(nxhandle,"0109_psd_before_coarse", "restore_neutron", "0", "1","int"); mccomp_param_nexus(nxhandle,"0109_psd_before_coarse", "nowritefile", "0", "0","int"); ); } } else { // fprintf(stderr,"NO NEXUS FILE"); } #endif return(0); } /* _psd_before_coarse_setpos */ /* component ArmR1=Arm() SETTING, POSITION/ROTATION */ int _ArmR1_setpos(void) { /* sets initial component parameters, position and rotation */ SIG_MESSAGE("[_ArmR1_setpos] component ArmR1=Arm() SETTING [Arm:0]"); stracpy(_ArmR1_var._name, "ArmR1", 16384); stracpy(_ArmR1_var._type, "Arm", 16384); _ArmR1_var._index=111; int current_setpos_index = 111; /* component ArmR1=Arm() AT ROTATED */ { Coords tc1, tc2; tc1 = coords_set(0,0,0); tc2 = coords_set(0,0,0); Rotation tr1; rot_set_rotation(tr1,0,0,0); rot_set_rotation(tr1, (0)*DEG2RAD, (- _instrument_var._parameters.RC / 9)*DEG2RAD, (0)*DEG2RAD); rot_mul(tr1, _a6_var._rotation_absolute, _ArmR1_var._rotation_absolute); rot_transpose(_psd_before_coarse_var._rotation_absolute, tr1); rot_mul(_ArmR1_var._rotation_absolute, tr1, _ArmR1_var._rotation_relative); _ArmR1_var._rotation_is_identity = rot_test_identity(_ArmR1_var._rotation_relative); tc1 = coords_set( - WindowSize / 2, 0, dad -0.005); rot_transpose(_a6_var._rotation_absolute, tr1); tc2 = rot_apply(tr1, tc1); _ArmR1_var._position_absolute = coords_add(_a6_var._position_absolute, tc2); tc1 = coords_sub(_psd_before_coarse_var._position_absolute, _ArmR1_var._position_absolute); _ArmR1_var._position_relative = rot_apply(_ArmR1_var._rotation_absolute, tc1); } /* ArmR1=Arm() AT ROTATED */ DEBUG_COMPONENT("ArmR1", _ArmR1_var._position_absolute, _ArmR1_var._rotation_absolute); instrument->_position_absolute[111] = _ArmR1_var._position_absolute; instrument->_position_relative[111] = _ArmR1_var._position_relative; _ArmR1_var._position_relative_is_zero = coords_test_zero(_ArmR1_var._position_relative); instrument->counter_N[111] = instrument->counter_P[111] = instrument->counter_P2[111] = 0; instrument->counter_AbsorbProp[111]= 0; #ifdef USE_NEXUS if(nxhandle) { if ((!mcdotrace) && mcformat && strcasestr(mcformat, "NeXus")) { MPI_MASTER( mccomp_placement_type_nexus(nxhandle,"0110_ArmR1", _ArmR1_var._position_absolute, _ArmR1_var._rotation_absolute, "Arm"); ); } } else { // fprintf(stderr,"NO NEXUS FILE"); } #endif return(0); } /* _ArmR1_setpos */ /* component BladeR1=Absorber() SETTING, POSITION/ROTATION */ int _BladeR1_setpos(void) { /* sets initial component parameters, position and rotation */ SIG_MESSAGE("[_BladeR1_setpos] component BladeR1=Absorber() SETTING [Absorber:0]"); stracpy(_BladeR1_var._name, "BladeR1", 16384); stracpy(_BladeR1_var._type, "Absorber", 16384); _BladeR1_var._index=112; int current_setpos_index = 112; _BladeR1_var._parameters.xmin = - BladeThickness / 2; _BladeR1_var._parameters.xmax = BladeThickness / 2; _BladeR1_var._parameters.ymin = - BladeHeight / 2; _BladeR1_var._parameters.ymax = BladeHeight / 2; _BladeR1_var._parameters.zmin = - BladeLength; _BladeR1_var._parameters.zmax = 0; /* component BladeR1=Absorber() AT ROTATED */ { Coords tc1, tc2; tc1 = coords_set(0,0,0); tc2 = coords_set(0,0,0); Rotation tr1; rot_set_rotation(tr1,0,0,0); rot_set_rotation(tr1, (0.0)*DEG2RAD, (0.0)*DEG2RAD, (0.0)*DEG2RAD); rot_mul(tr1, _ArmR1_var._rotation_absolute, _BladeR1_var._rotation_absolute); rot_transpose(_psd_before_coarse_var._rotation_absolute, tr1); rot_mul(_BladeR1_var._rotation_absolute, tr1, _BladeR1_var._rotation_relative); _BladeR1_var._rotation_is_identity = rot_test_identity(_BladeR1_var._rotation_relative); tc1 = coords_set( 0, 0, 0); rot_transpose(_ArmR1_var._rotation_absolute, tr1); tc2 = rot_apply(tr1, tc1); _BladeR1_var._position_absolute = coords_add(_ArmR1_var._position_absolute, tc2); tc1 = coords_sub(_psd_before_coarse_var._position_absolute, _BladeR1_var._position_absolute); _BladeR1_var._position_relative = rot_apply(_BladeR1_var._rotation_absolute, tc1); } /* BladeR1=Absorber() AT ROTATED */ DEBUG_COMPONENT("BladeR1", _BladeR1_var._position_absolute, _BladeR1_var._rotation_absolute); instrument->_position_absolute[112] = _BladeR1_var._position_absolute; instrument->_position_relative[112] = _BladeR1_var._position_relative; _BladeR1_var._position_relative_is_zero = coords_test_zero(_BladeR1_var._position_relative); instrument->counter_N[112] = instrument->counter_P[112] = instrument->counter_P2[112] = 0; instrument->counter_AbsorbProp[112]= 0; #ifdef USE_NEXUS if(nxhandle) { if ((!mcdotrace) && mcformat && strcasestr(mcformat, "NeXus")) { MPI_MASTER( mccomp_placement_type_nexus(nxhandle,"0111_BladeR1", _BladeR1_var._position_absolute, _BladeR1_var._rotation_absolute, "Absorber"); mccomp_param_nexus(nxhandle,"0111_BladeR1", "xmin", "0", "- BladeThickness / 2","MCNUM"); mccomp_param_nexus(nxhandle,"0111_BladeR1", "xmax", "0", "BladeThickness / 2","MCNUM"); mccomp_param_nexus(nxhandle,"0111_BladeR1", "ymin", "0", "- BladeHeight / 2","MCNUM"); mccomp_param_nexus(nxhandle,"0111_BladeR1", "ymax", "0", "BladeHeight / 2","MCNUM"); mccomp_param_nexus(nxhandle,"0111_BladeR1", "zmin", "0", "- BladeLength","MCNUM"); mccomp_param_nexus(nxhandle,"0111_BladeR1", "zmax", "0", "0","MCNUM"); ); } } else { // fprintf(stderr,"NO NEXUS FILE"); } #endif return(0); } /* _BladeR1_setpos */ /* component ArmR2=Arm() SETTING, POSITION/ROTATION */ int _ArmR2_setpos(void) { /* sets initial component parameters, position and rotation */ SIG_MESSAGE("[_ArmR2_setpos] component ArmR2=Arm() SETTING [Arm:0]"); stracpy(_ArmR2_var._name, "ArmR2", 16384); stracpy(_ArmR2_var._type, "Arm", 16384); _ArmR2_var._index=113; int current_setpos_index = 113; /* component ArmR2=Arm() AT ROTATED */ { Coords tc1, tc2; tc1 = coords_set(0,0,0); tc2 = coords_set(0,0,0); Rotation tr1; rot_set_rotation(tr1,0,0,0); rot_set_rotation(tr1, (0)*DEG2RAD, (-3 * _instrument_var._parameters.RC / 9)*DEG2RAD, (0)*DEG2RAD); rot_mul(tr1, _a6_var._rotation_absolute, _ArmR2_var._rotation_absolute); rot_transpose(_BladeR1_var._rotation_absolute, tr1); rot_mul(_ArmR2_var._rotation_absolute, tr1, _ArmR2_var._rotation_relative); _ArmR2_var._rotation_is_identity = rot_test_identity(_ArmR2_var._rotation_relative); tc1 = coords_set( -3 * WindowSize / 2, 0, dad -0.005); rot_transpose(_a6_var._rotation_absolute, tr1); tc2 = rot_apply(tr1, tc1); _ArmR2_var._position_absolute = coords_add(_a6_var._position_absolute, tc2); tc1 = coords_sub(_BladeR1_var._position_absolute, _ArmR2_var._position_absolute); _ArmR2_var._position_relative = rot_apply(_ArmR2_var._rotation_absolute, tc1); } /* ArmR2=Arm() AT ROTATED */ DEBUG_COMPONENT("ArmR2", _ArmR2_var._position_absolute, _ArmR2_var._rotation_absolute); instrument->_position_absolute[113] = _ArmR2_var._position_absolute; instrument->_position_relative[113] = _ArmR2_var._position_relative; _ArmR2_var._position_relative_is_zero = coords_test_zero(_ArmR2_var._position_relative); instrument->counter_N[113] = instrument->counter_P[113] = instrument->counter_P2[113] = 0; instrument->counter_AbsorbProp[113]= 0; #ifdef USE_NEXUS if(nxhandle) { if ((!mcdotrace) && mcformat && strcasestr(mcformat, "NeXus")) { MPI_MASTER( mccomp_placement_type_nexus(nxhandle,"0112_ArmR2", _ArmR2_var._position_absolute, _ArmR2_var._rotation_absolute, "Arm"); ); } } else { // fprintf(stderr,"NO NEXUS FILE"); } #endif return(0); } /* _ArmR2_setpos */ /* component BladeR2=Absorber() SETTING, POSITION/ROTATION */ int _BladeR2_setpos(void) { /* sets initial component parameters, position and rotation */ SIG_MESSAGE("[_BladeR2_setpos] component BladeR2=Absorber() SETTING [Absorber:0]"); stracpy(_BladeR2_var._name, "BladeR2", 16384); stracpy(_BladeR2_var._type, "Absorber", 16384); _BladeR2_var._index=114; int current_setpos_index = 114; _BladeR2_var._parameters.xmin = - BladeThickness / 2; _BladeR2_var._parameters.xmax = BladeThickness / 2; _BladeR2_var._parameters.ymin = - BladeHeight / 2; _BladeR2_var._parameters.ymax = BladeHeight / 2; _BladeR2_var._parameters.zmin = - BladeLength; _BladeR2_var._parameters.zmax = 0; /* component BladeR2=Absorber() AT ROTATED */ { Coords tc1, tc2; tc1 = coords_set(0,0,0); tc2 = coords_set(0,0,0); Rotation tr1; rot_set_rotation(tr1,0,0,0); rot_set_rotation(tr1, (0.0)*DEG2RAD, (0.0)*DEG2RAD, (0.0)*DEG2RAD); rot_mul(tr1, _ArmR2_var._rotation_absolute, _BladeR2_var._rotation_absolute); rot_transpose(_BladeR1_var._rotation_absolute, tr1); rot_mul(_BladeR2_var._rotation_absolute, tr1, _BladeR2_var._rotation_relative); _BladeR2_var._rotation_is_identity = rot_test_identity(_BladeR2_var._rotation_relative); tc1 = coords_set( 0, 0, 0); rot_transpose(_ArmR2_var._rotation_absolute, tr1); tc2 = rot_apply(tr1, tc1); _BladeR2_var._position_absolute = coords_add(_ArmR2_var._position_absolute, tc2); tc1 = coords_sub(_BladeR1_var._position_absolute, _BladeR2_var._position_absolute); _BladeR2_var._position_relative = rot_apply(_BladeR2_var._rotation_absolute, tc1); } /* BladeR2=Absorber() AT ROTATED */ DEBUG_COMPONENT("BladeR2", _BladeR2_var._position_absolute, _BladeR2_var._rotation_absolute); instrument->_position_absolute[114] = _BladeR2_var._position_absolute; instrument->_position_relative[114] = _BladeR2_var._position_relative; _BladeR2_var._position_relative_is_zero = coords_test_zero(_BladeR2_var._position_relative); instrument->counter_N[114] = instrument->counter_P[114] = instrument->counter_P2[114] = 0; instrument->counter_AbsorbProp[114]= 0; #ifdef USE_NEXUS if(nxhandle) { if ((!mcdotrace) && mcformat && strcasestr(mcformat, "NeXus")) { MPI_MASTER( mccomp_placement_type_nexus(nxhandle,"0113_BladeR2", _BladeR2_var._position_absolute, _BladeR2_var._rotation_absolute, "Absorber"); mccomp_param_nexus(nxhandle,"0113_BladeR2", "xmin", "0", "- BladeThickness / 2","MCNUM"); mccomp_param_nexus(nxhandle,"0113_BladeR2", "xmax", "0", "BladeThickness / 2","MCNUM"); mccomp_param_nexus(nxhandle,"0113_BladeR2", "ymin", "0", "- BladeHeight / 2","MCNUM"); mccomp_param_nexus(nxhandle,"0113_BladeR2", "ymax", "0", "BladeHeight / 2","MCNUM"); mccomp_param_nexus(nxhandle,"0113_BladeR2", "zmin", "0", "- BladeLength","MCNUM"); mccomp_param_nexus(nxhandle,"0113_BladeR2", "zmax", "0", "0","MCNUM"); ); } } else { // fprintf(stderr,"NO NEXUS FILE"); } #endif return(0); } /* _BladeR2_setpos */ /* component ArmR3=Arm() SETTING, POSITION/ROTATION */ int _ArmR3_setpos(void) { /* sets initial component parameters, position and rotation */ SIG_MESSAGE("[_ArmR3_setpos] component ArmR3=Arm() SETTING [Arm:0]"); stracpy(_ArmR3_var._name, "ArmR3", 16384); stracpy(_ArmR3_var._type, "Arm", 16384); _ArmR3_var._index=115; int current_setpos_index = 115; /* component ArmR3=Arm() AT ROTATED */ { Coords tc1, tc2; tc1 = coords_set(0,0,0); tc2 = coords_set(0,0,0); Rotation tr1; rot_set_rotation(tr1,0,0,0); rot_set_rotation(tr1, (0)*DEG2RAD, (-5 * _instrument_var._parameters.RC / 9)*DEG2RAD, (0)*DEG2RAD); rot_mul(tr1, _a6_var._rotation_absolute, _ArmR3_var._rotation_absolute); rot_transpose(_BladeR2_var._rotation_absolute, tr1); rot_mul(_ArmR3_var._rotation_absolute, tr1, _ArmR3_var._rotation_relative); _ArmR3_var._rotation_is_identity = rot_test_identity(_ArmR3_var._rotation_relative); tc1 = coords_set( -5 * WindowSize / 2, 0, dad -0.005); rot_transpose(_a6_var._rotation_absolute, tr1); tc2 = rot_apply(tr1, tc1); _ArmR3_var._position_absolute = coords_add(_a6_var._position_absolute, tc2); tc1 = coords_sub(_BladeR2_var._position_absolute, _ArmR3_var._position_absolute); _ArmR3_var._position_relative = rot_apply(_ArmR3_var._rotation_absolute, tc1); } /* ArmR3=Arm() AT ROTATED */ DEBUG_COMPONENT("ArmR3", _ArmR3_var._position_absolute, _ArmR3_var._rotation_absolute); instrument->_position_absolute[115] = _ArmR3_var._position_absolute; instrument->_position_relative[115] = _ArmR3_var._position_relative; _ArmR3_var._position_relative_is_zero = coords_test_zero(_ArmR3_var._position_relative); instrument->counter_N[115] = instrument->counter_P[115] = instrument->counter_P2[115] = 0; instrument->counter_AbsorbProp[115]= 0; #ifdef USE_NEXUS if(nxhandle) { if ((!mcdotrace) && mcformat && strcasestr(mcformat, "NeXus")) { MPI_MASTER( mccomp_placement_type_nexus(nxhandle,"0114_ArmR3", _ArmR3_var._position_absolute, _ArmR3_var._rotation_absolute, "Arm"); ); } } else { // fprintf(stderr,"NO NEXUS FILE"); } #endif return(0); } /* _ArmR3_setpos */ /* component BladeR3=Absorber() SETTING, POSITION/ROTATION */ int _BladeR3_setpos(void) { /* sets initial component parameters, position and rotation */ SIG_MESSAGE("[_BladeR3_setpos] component BladeR3=Absorber() SETTING [Absorber:0]"); stracpy(_BladeR3_var._name, "BladeR3", 16384); stracpy(_BladeR3_var._type, "Absorber", 16384); _BladeR3_var._index=116; int current_setpos_index = 116; _BladeR3_var._parameters.xmin = - BladeThickness / 2; _BladeR3_var._parameters.xmax = BladeThickness / 2; _BladeR3_var._parameters.ymin = - BladeHeight / 2; _BladeR3_var._parameters.ymax = BladeHeight / 2; _BladeR3_var._parameters.zmin = - BladeLength; _BladeR3_var._parameters.zmax = 0; /* component BladeR3=Absorber() AT ROTATED */ { Coords tc1, tc2; tc1 = coords_set(0,0,0); tc2 = coords_set(0,0,0); Rotation tr1; rot_set_rotation(tr1,0,0,0); rot_set_rotation(tr1, (0.0)*DEG2RAD, (0.0)*DEG2RAD, (0.0)*DEG2RAD); rot_mul(tr1, _ArmR3_var._rotation_absolute, _BladeR3_var._rotation_absolute); rot_transpose(_BladeR2_var._rotation_absolute, tr1); rot_mul(_BladeR3_var._rotation_absolute, tr1, _BladeR3_var._rotation_relative); _BladeR3_var._rotation_is_identity = rot_test_identity(_BladeR3_var._rotation_relative); tc1 = coords_set( 0, 0, 0); rot_transpose(_ArmR3_var._rotation_absolute, tr1); tc2 = rot_apply(tr1, tc1); _BladeR3_var._position_absolute = coords_add(_ArmR3_var._position_absolute, tc2); tc1 = coords_sub(_BladeR2_var._position_absolute, _BladeR3_var._position_absolute); _BladeR3_var._position_relative = rot_apply(_BladeR3_var._rotation_absolute, tc1); } /* BladeR3=Absorber() AT ROTATED */ DEBUG_COMPONENT("BladeR3", _BladeR3_var._position_absolute, _BladeR3_var._rotation_absolute); instrument->_position_absolute[116] = _BladeR3_var._position_absolute; instrument->_position_relative[116] = _BladeR3_var._position_relative; _BladeR3_var._position_relative_is_zero = coords_test_zero(_BladeR3_var._position_relative); instrument->counter_N[116] = instrument->counter_P[116] = instrument->counter_P2[116] = 0; instrument->counter_AbsorbProp[116]= 0; #ifdef USE_NEXUS if(nxhandle) { if ((!mcdotrace) && mcformat && strcasestr(mcformat, "NeXus")) { MPI_MASTER( mccomp_placement_type_nexus(nxhandle,"0115_BladeR3", _BladeR3_var._position_absolute, _BladeR3_var._rotation_absolute, "Absorber"); mccomp_param_nexus(nxhandle,"0115_BladeR3", "xmin", "0", "- BladeThickness / 2","MCNUM"); mccomp_param_nexus(nxhandle,"0115_BladeR3", "xmax", "0", "BladeThickness / 2","MCNUM"); mccomp_param_nexus(nxhandle,"0115_BladeR3", "ymin", "0", "- BladeHeight / 2","MCNUM"); mccomp_param_nexus(nxhandle,"0115_BladeR3", "ymax", "0", "BladeHeight / 2","MCNUM"); mccomp_param_nexus(nxhandle,"0115_BladeR3", "zmin", "0", "- BladeLength","MCNUM"); mccomp_param_nexus(nxhandle,"0115_BladeR3", "zmax", "0", "0","MCNUM"); ); } } else { // fprintf(stderr,"NO NEXUS FILE"); } #endif return(0); } /* _BladeR3_setpos */ /* component ArmR4=Arm() SETTING, POSITION/ROTATION */ int _ArmR4_setpos(void) { /* sets initial component parameters, position and rotation */ SIG_MESSAGE("[_ArmR4_setpos] component ArmR4=Arm() SETTING [Arm:0]"); stracpy(_ArmR4_var._name, "ArmR4", 16384); stracpy(_ArmR4_var._type, "Arm", 16384); _ArmR4_var._index=117; int current_setpos_index = 117; /* component ArmR4=Arm() AT ROTATED */ { Coords tc1, tc2; tc1 = coords_set(0,0,0); tc2 = coords_set(0,0,0); Rotation tr1; rot_set_rotation(tr1,0,0,0); rot_set_rotation(tr1, (0)*DEG2RAD, (-7 * _instrument_var._parameters.RC / 9)*DEG2RAD, (0)*DEG2RAD); rot_mul(tr1, _a6_var._rotation_absolute, _ArmR4_var._rotation_absolute); rot_transpose(_BladeR3_var._rotation_absolute, tr1); rot_mul(_ArmR4_var._rotation_absolute, tr1, _ArmR4_var._rotation_relative); _ArmR4_var._rotation_is_identity = rot_test_identity(_ArmR4_var._rotation_relative); tc1 = coords_set( -7 * WindowSize / 2, 0, dad -0.005); rot_transpose(_a6_var._rotation_absolute, tr1); tc2 = rot_apply(tr1, tc1); _ArmR4_var._position_absolute = coords_add(_a6_var._position_absolute, tc2); tc1 = coords_sub(_BladeR3_var._position_absolute, _ArmR4_var._position_absolute); _ArmR4_var._position_relative = rot_apply(_ArmR4_var._rotation_absolute, tc1); } /* ArmR4=Arm() AT ROTATED */ DEBUG_COMPONENT("ArmR4", _ArmR4_var._position_absolute, _ArmR4_var._rotation_absolute); instrument->_position_absolute[117] = _ArmR4_var._position_absolute; instrument->_position_relative[117] = _ArmR4_var._position_relative; _ArmR4_var._position_relative_is_zero = coords_test_zero(_ArmR4_var._position_relative); instrument->counter_N[117] = instrument->counter_P[117] = instrument->counter_P2[117] = 0; instrument->counter_AbsorbProp[117]= 0; #ifdef USE_NEXUS if(nxhandle) { if ((!mcdotrace) && mcformat && strcasestr(mcformat, "NeXus")) { MPI_MASTER( mccomp_placement_type_nexus(nxhandle,"0116_ArmR4", _ArmR4_var._position_absolute, _ArmR4_var._rotation_absolute, "Arm"); ); } } else { // fprintf(stderr,"NO NEXUS FILE"); } #endif return(0); } /* _ArmR4_setpos */ /* component BladeR4=Absorber() SETTING, POSITION/ROTATION */ int _BladeR4_setpos(void) { /* sets initial component parameters, position and rotation */ SIG_MESSAGE("[_BladeR4_setpos] component BladeR4=Absorber() SETTING [Absorber:0]"); stracpy(_BladeR4_var._name, "BladeR4", 16384); stracpy(_BladeR4_var._type, "Absorber", 16384); _BladeR4_var._index=118; int current_setpos_index = 118; _BladeR4_var._parameters.xmin = - BladeThickness / 2; _BladeR4_var._parameters.xmax = BladeThickness / 2; _BladeR4_var._parameters.ymin = - BladeHeight / 2; _BladeR4_var._parameters.ymax = BladeHeight / 2; _BladeR4_var._parameters.zmin = - BladeLength; _BladeR4_var._parameters.zmax = 0; /* component BladeR4=Absorber() AT ROTATED */ { Coords tc1, tc2; tc1 = coords_set(0,0,0); tc2 = coords_set(0,0,0); Rotation tr1; rot_set_rotation(tr1,0,0,0); rot_set_rotation(tr1, (0.0)*DEG2RAD, (0.0)*DEG2RAD, (0.0)*DEG2RAD); rot_mul(tr1, _ArmR4_var._rotation_absolute, _BladeR4_var._rotation_absolute); rot_transpose(_BladeR3_var._rotation_absolute, tr1); rot_mul(_BladeR4_var._rotation_absolute, tr1, _BladeR4_var._rotation_relative); _BladeR4_var._rotation_is_identity = rot_test_identity(_BladeR4_var._rotation_relative); tc1 = coords_set( 0, 0, 0); rot_transpose(_ArmR4_var._rotation_absolute, tr1); tc2 = rot_apply(tr1, tc1); _BladeR4_var._position_absolute = coords_add(_ArmR4_var._position_absolute, tc2); tc1 = coords_sub(_BladeR3_var._position_absolute, _BladeR4_var._position_absolute); _BladeR4_var._position_relative = rot_apply(_BladeR4_var._rotation_absolute, tc1); } /* BladeR4=Absorber() AT ROTATED */ DEBUG_COMPONENT("BladeR4", _BladeR4_var._position_absolute, _BladeR4_var._rotation_absolute); instrument->_position_absolute[118] = _BladeR4_var._position_absolute; instrument->_position_relative[118] = _BladeR4_var._position_relative; _BladeR4_var._position_relative_is_zero = coords_test_zero(_BladeR4_var._position_relative); instrument->counter_N[118] = instrument->counter_P[118] = instrument->counter_P2[118] = 0; instrument->counter_AbsorbProp[118]= 0; #ifdef USE_NEXUS if(nxhandle) { if ((!mcdotrace) && mcformat && strcasestr(mcformat, "NeXus")) { MPI_MASTER( mccomp_placement_type_nexus(nxhandle,"0117_BladeR4", _BladeR4_var._position_absolute, _BladeR4_var._rotation_absolute, "Absorber"); mccomp_param_nexus(nxhandle,"0117_BladeR4", "xmin", "0", "- BladeThickness / 2","MCNUM"); mccomp_param_nexus(nxhandle,"0117_BladeR4", "xmax", "0", "BladeThickness / 2","MCNUM"); mccomp_param_nexus(nxhandle,"0117_BladeR4", "ymin", "0", "- BladeHeight / 2","MCNUM"); mccomp_param_nexus(nxhandle,"0117_BladeR4", "ymax", "0", "BladeHeight / 2","MCNUM"); mccomp_param_nexus(nxhandle,"0117_BladeR4", "zmin", "0", "- BladeLength","MCNUM"); mccomp_param_nexus(nxhandle,"0117_BladeR4", "zmax", "0", "0","MCNUM"); ); } } else { // fprintf(stderr,"NO NEXUS FILE"); } #endif return(0); } /* _BladeR4_setpos */ /* component ArmR5=Arm() SETTING, POSITION/ROTATION */ int _ArmR5_setpos(void) { /* sets initial component parameters, position and rotation */ SIG_MESSAGE("[_ArmR5_setpos] component ArmR5=Arm() SETTING [Arm:0]"); stracpy(_ArmR5_var._name, "ArmR5", 16384); stracpy(_ArmR5_var._type, "Arm", 16384); _ArmR5_var._index=119; int current_setpos_index = 119; /* component ArmR5=Arm() AT ROTATED */ { Coords tc1, tc2; tc1 = coords_set(0,0,0); tc2 = coords_set(0,0,0); Rotation tr1; rot_set_rotation(tr1,0,0,0); rot_set_rotation(tr1, (0)*DEG2RAD, (-9 * _instrument_var._parameters.RC / 9)*DEG2RAD, (0)*DEG2RAD); rot_mul(tr1, _a6_var._rotation_absolute, _ArmR5_var._rotation_absolute); rot_transpose(_BladeR4_var._rotation_absolute, tr1); rot_mul(_ArmR5_var._rotation_absolute, tr1, _ArmR5_var._rotation_relative); _ArmR5_var._rotation_is_identity = rot_test_identity(_ArmR5_var._rotation_relative); tc1 = coords_set( -9 * WindowSize / 2, 0, dad -0.005); rot_transpose(_a6_var._rotation_absolute, tr1); tc2 = rot_apply(tr1, tc1); _ArmR5_var._position_absolute = coords_add(_a6_var._position_absolute, tc2); tc1 = coords_sub(_BladeR4_var._position_absolute, _ArmR5_var._position_absolute); _ArmR5_var._position_relative = rot_apply(_ArmR5_var._rotation_absolute, tc1); } /* ArmR5=Arm() AT ROTATED */ DEBUG_COMPONENT("ArmR5", _ArmR5_var._position_absolute, _ArmR5_var._rotation_absolute); instrument->_position_absolute[119] = _ArmR5_var._position_absolute; instrument->_position_relative[119] = _ArmR5_var._position_relative; _ArmR5_var._position_relative_is_zero = coords_test_zero(_ArmR5_var._position_relative); instrument->counter_N[119] = instrument->counter_P[119] = instrument->counter_P2[119] = 0; instrument->counter_AbsorbProp[119]= 0; #ifdef USE_NEXUS if(nxhandle) { if ((!mcdotrace) && mcformat && strcasestr(mcformat, "NeXus")) { MPI_MASTER( mccomp_placement_type_nexus(nxhandle,"0118_ArmR5", _ArmR5_var._position_absolute, _ArmR5_var._rotation_absolute, "Arm"); ); } } else { // fprintf(stderr,"NO NEXUS FILE"); } #endif return(0); } /* _ArmR5_setpos */ /* component BladeR5=Absorber() SETTING, POSITION/ROTATION */ int _BladeR5_setpos(void) { /* sets initial component parameters, position and rotation */ SIG_MESSAGE("[_BladeR5_setpos] component BladeR5=Absorber() SETTING [Absorber:0]"); stracpy(_BladeR5_var._name, "BladeR5", 16384); stracpy(_BladeR5_var._type, "Absorber", 16384); _BladeR5_var._index=120; int current_setpos_index = 120; _BladeR5_var._parameters.xmin = - BladeThickness / 2; _BladeR5_var._parameters.xmax = BladeThickness / 2; _BladeR5_var._parameters.ymin = - BladeHeight / 2; _BladeR5_var._parameters.ymax = BladeHeight / 2; _BladeR5_var._parameters.zmin = - BladeLength; _BladeR5_var._parameters.zmax = 0; /* component BladeR5=Absorber() AT ROTATED */ { Coords tc1, tc2; tc1 = coords_set(0,0,0); tc2 = coords_set(0,0,0); Rotation tr1; rot_set_rotation(tr1,0,0,0); rot_set_rotation(tr1, (0.0)*DEG2RAD, (0.0)*DEG2RAD, (0.0)*DEG2RAD); rot_mul(tr1, _ArmR5_var._rotation_absolute, _BladeR5_var._rotation_absolute); rot_transpose(_BladeR4_var._rotation_absolute, tr1); rot_mul(_BladeR5_var._rotation_absolute, tr1, _BladeR5_var._rotation_relative); _BladeR5_var._rotation_is_identity = rot_test_identity(_BladeR5_var._rotation_relative); tc1 = coords_set( 0, 0, 0); rot_transpose(_ArmR5_var._rotation_absolute, tr1); tc2 = rot_apply(tr1, tc1); _BladeR5_var._position_absolute = coords_add(_ArmR5_var._position_absolute, tc2); tc1 = coords_sub(_BladeR4_var._position_absolute, _BladeR5_var._position_absolute); _BladeR5_var._position_relative = rot_apply(_BladeR5_var._rotation_absolute, tc1); } /* BladeR5=Absorber() AT ROTATED */ DEBUG_COMPONENT("BladeR5", _BladeR5_var._position_absolute, _BladeR5_var._rotation_absolute); instrument->_position_absolute[120] = _BladeR5_var._position_absolute; instrument->_position_relative[120] = _BladeR5_var._position_relative; _BladeR5_var._position_relative_is_zero = coords_test_zero(_BladeR5_var._position_relative); instrument->counter_N[120] = instrument->counter_P[120] = instrument->counter_P2[120] = 0; instrument->counter_AbsorbProp[120]= 0; #ifdef USE_NEXUS if(nxhandle) { if ((!mcdotrace) && mcformat && strcasestr(mcformat, "NeXus")) { MPI_MASTER( mccomp_placement_type_nexus(nxhandle,"0119_BladeR5", _BladeR5_var._position_absolute, _BladeR5_var._rotation_absolute, "Absorber"); mccomp_param_nexus(nxhandle,"0119_BladeR5", "xmin", "0", "- BladeThickness / 2","MCNUM"); mccomp_param_nexus(nxhandle,"0119_BladeR5", "xmax", "0", "BladeThickness / 2","MCNUM"); mccomp_param_nexus(nxhandle,"0119_BladeR5", "ymin", "0", "- BladeHeight / 2","MCNUM"); mccomp_param_nexus(nxhandle,"0119_BladeR5", "ymax", "0", "BladeHeight / 2","MCNUM"); mccomp_param_nexus(nxhandle,"0119_BladeR5", "zmin", "0", "- BladeLength","MCNUM"); mccomp_param_nexus(nxhandle,"0119_BladeR5", "zmax", "0", "0","MCNUM"); ); } } else { // fprintf(stderr,"NO NEXUS FILE"); } #endif return(0); } /* _BladeR5_setpos */ /* component ArmL1=Arm() SETTING, POSITION/ROTATION */ int _ArmL1_setpos(void) { /* sets initial component parameters, position and rotation */ SIG_MESSAGE("[_ArmL1_setpos] component ArmL1=Arm() SETTING [Arm:0]"); stracpy(_ArmL1_var._name, "ArmL1", 16384); stracpy(_ArmL1_var._type, "Arm", 16384); _ArmL1_var._index=121; int current_setpos_index = 121; /* component ArmL1=Arm() AT ROTATED */ { Coords tc1, tc2; tc1 = coords_set(0,0,0); tc2 = coords_set(0,0,0); Rotation tr1; rot_set_rotation(tr1,0,0,0); rot_set_rotation(tr1, (0)*DEG2RAD, (_instrument_var._parameters.LC / 9)*DEG2RAD, (0)*DEG2RAD); rot_mul(tr1, _a6_var._rotation_absolute, _ArmL1_var._rotation_absolute); rot_transpose(_BladeR5_var._rotation_absolute, tr1); rot_mul(_ArmL1_var._rotation_absolute, tr1, _ArmL1_var._rotation_relative); _ArmL1_var._rotation_is_identity = rot_test_identity(_ArmL1_var._rotation_relative); tc1 = coords_set( WindowSize / 2, 0, dad -0.005); rot_transpose(_a6_var._rotation_absolute, tr1); tc2 = rot_apply(tr1, tc1); _ArmL1_var._position_absolute = coords_add(_a6_var._position_absolute, tc2); tc1 = coords_sub(_BladeR5_var._position_absolute, _ArmL1_var._position_absolute); _ArmL1_var._position_relative = rot_apply(_ArmL1_var._rotation_absolute, tc1); } /* ArmL1=Arm() AT ROTATED */ DEBUG_COMPONENT("ArmL1", _ArmL1_var._position_absolute, _ArmL1_var._rotation_absolute); instrument->_position_absolute[121] = _ArmL1_var._position_absolute; instrument->_position_relative[121] = _ArmL1_var._position_relative; _ArmL1_var._position_relative_is_zero = coords_test_zero(_ArmL1_var._position_relative); instrument->counter_N[121] = instrument->counter_P[121] = instrument->counter_P2[121] = 0; instrument->counter_AbsorbProp[121]= 0; #ifdef USE_NEXUS if(nxhandle) { if ((!mcdotrace) && mcformat && strcasestr(mcformat, "NeXus")) { MPI_MASTER( mccomp_placement_type_nexus(nxhandle,"0120_ArmL1", _ArmL1_var._position_absolute, _ArmL1_var._rotation_absolute, "Arm"); ); } } else { // fprintf(stderr,"NO NEXUS FILE"); } #endif return(0); } /* _ArmL1_setpos */ /* component BladeL1=Absorber() SETTING, POSITION/ROTATION */ int _BladeL1_setpos(void) { /* sets initial component parameters, position and rotation */ SIG_MESSAGE("[_BladeL1_setpos] component BladeL1=Absorber() SETTING [Absorber:0]"); stracpy(_BladeL1_var._name, "BladeL1", 16384); stracpy(_BladeL1_var._type, "Absorber", 16384); _BladeL1_var._index=122; int current_setpos_index = 122; _BladeL1_var._parameters.xmin = - BladeThickness / 2; _BladeL1_var._parameters.xmax = BladeThickness / 2; _BladeL1_var._parameters.ymin = - BladeHeight / 2; _BladeL1_var._parameters.ymax = BladeHeight / 2; _BladeL1_var._parameters.zmin = - BladeLength; _BladeL1_var._parameters.zmax = 0; /* component BladeL1=Absorber() AT ROTATED */ { Coords tc1, tc2; tc1 = coords_set(0,0,0); tc2 = coords_set(0,0,0); Rotation tr1; rot_set_rotation(tr1,0,0,0); rot_set_rotation(tr1, (0.0)*DEG2RAD, (0.0)*DEG2RAD, (0.0)*DEG2RAD); rot_mul(tr1, _ArmL1_var._rotation_absolute, _BladeL1_var._rotation_absolute); rot_transpose(_BladeR5_var._rotation_absolute, tr1); rot_mul(_BladeL1_var._rotation_absolute, tr1, _BladeL1_var._rotation_relative); _BladeL1_var._rotation_is_identity = rot_test_identity(_BladeL1_var._rotation_relative); tc1 = coords_set( 0, 0, 0); rot_transpose(_ArmL1_var._rotation_absolute, tr1); tc2 = rot_apply(tr1, tc1); _BladeL1_var._position_absolute = coords_add(_ArmL1_var._position_absolute, tc2); tc1 = coords_sub(_BladeR5_var._position_absolute, _BladeL1_var._position_absolute); _BladeL1_var._position_relative = rot_apply(_BladeL1_var._rotation_absolute, tc1); } /* BladeL1=Absorber() AT ROTATED */ DEBUG_COMPONENT("BladeL1", _BladeL1_var._position_absolute, _BladeL1_var._rotation_absolute); instrument->_position_absolute[122] = _BladeL1_var._position_absolute; instrument->_position_relative[122] = _BladeL1_var._position_relative; _BladeL1_var._position_relative_is_zero = coords_test_zero(_BladeL1_var._position_relative); instrument->counter_N[122] = instrument->counter_P[122] = instrument->counter_P2[122] = 0; instrument->counter_AbsorbProp[122]= 0; #ifdef USE_NEXUS if(nxhandle) { if ((!mcdotrace) && mcformat && strcasestr(mcformat, "NeXus")) { MPI_MASTER( mccomp_placement_type_nexus(nxhandle,"0121_BladeL1", _BladeL1_var._position_absolute, _BladeL1_var._rotation_absolute, "Absorber"); mccomp_param_nexus(nxhandle,"0121_BladeL1", "xmin", "0", "- BladeThickness / 2","MCNUM"); mccomp_param_nexus(nxhandle,"0121_BladeL1", "xmax", "0", "BladeThickness / 2","MCNUM"); mccomp_param_nexus(nxhandle,"0121_BladeL1", "ymin", "0", "- BladeHeight / 2","MCNUM"); mccomp_param_nexus(nxhandle,"0121_BladeL1", "ymax", "0", "BladeHeight / 2","MCNUM"); mccomp_param_nexus(nxhandle,"0121_BladeL1", "zmin", "0", "- BladeLength","MCNUM"); mccomp_param_nexus(nxhandle,"0121_BladeL1", "zmax", "0", "0","MCNUM"); ); } } else { // fprintf(stderr,"NO NEXUS FILE"); } #endif return(0); } /* _BladeL1_setpos */ /* component ArmL2=Arm() SETTING, POSITION/ROTATION */ int _ArmL2_setpos(void) { /* sets initial component parameters, position and rotation */ SIG_MESSAGE("[_ArmL2_setpos] component ArmL2=Arm() SETTING [Arm:0]"); stracpy(_ArmL2_var._name, "ArmL2", 16384); stracpy(_ArmL2_var._type, "Arm", 16384); _ArmL2_var._index=123; int current_setpos_index = 123; /* component ArmL2=Arm() AT ROTATED */ { Coords tc1, tc2; tc1 = coords_set(0,0,0); tc2 = coords_set(0,0,0); Rotation tr1; rot_set_rotation(tr1,0,0,0); rot_set_rotation(tr1, (0)*DEG2RAD, (3 * _instrument_var._parameters.LC / 9)*DEG2RAD, (0)*DEG2RAD); rot_mul(tr1, _a6_var._rotation_absolute, _ArmL2_var._rotation_absolute); rot_transpose(_BladeL1_var._rotation_absolute, tr1); rot_mul(_ArmL2_var._rotation_absolute, tr1, _ArmL2_var._rotation_relative); _ArmL2_var._rotation_is_identity = rot_test_identity(_ArmL2_var._rotation_relative); tc1 = coords_set( 3 * WindowSize / 2, 0, dad -0.005); rot_transpose(_a6_var._rotation_absolute, tr1); tc2 = rot_apply(tr1, tc1); _ArmL2_var._position_absolute = coords_add(_a6_var._position_absolute, tc2); tc1 = coords_sub(_BladeL1_var._position_absolute, _ArmL2_var._position_absolute); _ArmL2_var._position_relative = rot_apply(_ArmL2_var._rotation_absolute, tc1); } /* ArmL2=Arm() AT ROTATED */ DEBUG_COMPONENT("ArmL2", _ArmL2_var._position_absolute, _ArmL2_var._rotation_absolute); instrument->_position_absolute[123] = _ArmL2_var._position_absolute; instrument->_position_relative[123] = _ArmL2_var._position_relative; _ArmL2_var._position_relative_is_zero = coords_test_zero(_ArmL2_var._position_relative); instrument->counter_N[123] = instrument->counter_P[123] = instrument->counter_P2[123] = 0; instrument->counter_AbsorbProp[123]= 0; #ifdef USE_NEXUS if(nxhandle) { if ((!mcdotrace) && mcformat && strcasestr(mcformat, "NeXus")) { MPI_MASTER( mccomp_placement_type_nexus(nxhandle,"0122_ArmL2", _ArmL2_var._position_absolute, _ArmL2_var._rotation_absolute, "Arm"); ); } } else { // fprintf(stderr,"NO NEXUS FILE"); } #endif return(0); } /* _ArmL2_setpos */ /* component BladeL2=Absorber() SETTING, POSITION/ROTATION */ int _BladeL2_setpos(void) { /* sets initial component parameters, position and rotation */ SIG_MESSAGE("[_BladeL2_setpos] component BladeL2=Absorber() SETTING [Absorber:0]"); stracpy(_BladeL2_var._name, "BladeL2", 16384); stracpy(_BladeL2_var._type, "Absorber", 16384); _BladeL2_var._index=124; int current_setpos_index = 124; _BladeL2_var._parameters.xmin = - BladeThickness / 2; _BladeL2_var._parameters.xmax = BladeThickness / 2; _BladeL2_var._parameters.ymin = - BladeHeight / 2; _BladeL2_var._parameters.ymax = BladeHeight / 2; _BladeL2_var._parameters.zmin = - BladeLength; _BladeL2_var._parameters.zmax = 0; /* component BladeL2=Absorber() AT ROTATED */ { Coords tc1, tc2; tc1 = coords_set(0,0,0); tc2 = coords_set(0,0,0); Rotation tr1; rot_set_rotation(tr1,0,0,0); rot_set_rotation(tr1, (0.0)*DEG2RAD, (0.0)*DEG2RAD, (0.0)*DEG2RAD); rot_mul(tr1, _ArmL2_var._rotation_absolute, _BladeL2_var._rotation_absolute); rot_transpose(_BladeL1_var._rotation_absolute, tr1); rot_mul(_BladeL2_var._rotation_absolute, tr1, _BladeL2_var._rotation_relative); _BladeL2_var._rotation_is_identity = rot_test_identity(_BladeL2_var._rotation_relative); tc1 = coords_set( 0, 0, 0); rot_transpose(_ArmL2_var._rotation_absolute, tr1); tc2 = rot_apply(tr1, tc1); _BladeL2_var._position_absolute = coords_add(_ArmL2_var._position_absolute, tc2); tc1 = coords_sub(_BladeL1_var._position_absolute, _BladeL2_var._position_absolute); _BladeL2_var._position_relative = rot_apply(_BladeL2_var._rotation_absolute, tc1); } /* BladeL2=Absorber() AT ROTATED */ DEBUG_COMPONENT("BladeL2", _BladeL2_var._position_absolute, _BladeL2_var._rotation_absolute); instrument->_position_absolute[124] = _BladeL2_var._position_absolute; instrument->_position_relative[124] = _BladeL2_var._position_relative; _BladeL2_var._position_relative_is_zero = coords_test_zero(_BladeL2_var._position_relative); instrument->counter_N[124] = instrument->counter_P[124] = instrument->counter_P2[124] = 0; instrument->counter_AbsorbProp[124]= 0; #ifdef USE_NEXUS if(nxhandle) { if ((!mcdotrace) && mcformat && strcasestr(mcformat, "NeXus")) { MPI_MASTER( mccomp_placement_type_nexus(nxhandle,"0123_BladeL2", _BladeL2_var._position_absolute, _BladeL2_var._rotation_absolute, "Absorber"); mccomp_param_nexus(nxhandle,"0123_BladeL2", "xmin", "0", "- BladeThickness / 2","MCNUM"); mccomp_param_nexus(nxhandle,"0123_BladeL2", "xmax", "0", "BladeThickness / 2","MCNUM"); mccomp_param_nexus(nxhandle,"0123_BladeL2", "ymin", "0", "- BladeHeight / 2","MCNUM"); mccomp_param_nexus(nxhandle,"0123_BladeL2", "ymax", "0", "BladeHeight / 2","MCNUM"); mccomp_param_nexus(nxhandle,"0123_BladeL2", "zmin", "0", "- BladeLength","MCNUM"); mccomp_param_nexus(nxhandle,"0123_BladeL2", "zmax", "0", "0","MCNUM"); ); } } else { // fprintf(stderr,"NO NEXUS FILE"); } #endif return(0); } /* _BladeL2_setpos */ /* component ArmL3=Arm() SETTING, POSITION/ROTATION */ int _ArmL3_setpos(void) { /* sets initial component parameters, position and rotation */ SIG_MESSAGE("[_ArmL3_setpos] component ArmL3=Arm() SETTING [Arm:0]"); stracpy(_ArmL3_var._name, "ArmL3", 16384); stracpy(_ArmL3_var._type, "Arm", 16384); _ArmL3_var._index=125; int current_setpos_index = 125; /* component ArmL3=Arm() AT ROTATED */ { Coords tc1, tc2; tc1 = coords_set(0,0,0); tc2 = coords_set(0,0,0); Rotation tr1; rot_set_rotation(tr1,0,0,0); rot_set_rotation(tr1, (0)*DEG2RAD, (5 * _instrument_var._parameters.LC / 9)*DEG2RAD, (0)*DEG2RAD); rot_mul(tr1, _a6_var._rotation_absolute, _ArmL3_var._rotation_absolute); rot_transpose(_BladeL2_var._rotation_absolute, tr1); rot_mul(_ArmL3_var._rotation_absolute, tr1, _ArmL3_var._rotation_relative); _ArmL3_var._rotation_is_identity = rot_test_identity(_ArmL3_var._rotation_relative); tc1 = coords_set( 5 * WindowSize / 2, 0, dad -0.005); rot_transpose(_a6_var._rotation_absolute, tr1); tc2 = rot_apply(tr1, tc1); _ArmL3_var._position_absolute = coords_add(_a6_var._position_absolute, tc2); tc1 = coords_sub(_BladeL2_var._position_absolute, _ArmL3_var._position_absolute); _ArmL3_var._position_relative = rot_apply(_ArmL3_var._rotation_absolute, tc1); } /* ArmL3=Arm() AT ROTATED */ DEBUG_COMPONENT("ArmL3", _ArmL3_var._position_absolute, _ArmL3_var._rotation_absolute); instrument->_position_absolute[125] = _ArmL3_var._position_absolute; instrument->_position_relative[125] = _ArmL3_var._position_relative; _ArmL3_var._position_relative_is_zero = coords_test_zero(_ArmL3_var._position_relative); instrument->counter_N[125] = instrument->counter_P[125] = instrument->counter_P2[125] = 0; instrument->counter_AbsorbProp[125]= 0; #ifdef USE_NEXUS if(nxhandle) { if ((!mcdotrace) && mcformat && strcasestr(mcformat, "NeXus")) { MPI_MASTER( mccomp_placement_type_nexus(nxhandle,"0124_ArmL3", _ArmL3_var._position_absolute, _ArmL3_var._rotation_absolute, "Arm"); ); } } else { // fprintf(stderr,"NO NEXUS FILE"); } #endif return(0); } /* _ArmL3_setpos */ /* component BladeL3=Absorber() SETTING, POSITION/ROTATION */ int _BladeL3_setpos(void) { /* sets initial component parameters, position and rotation */ SIG_MESSAGE("[_BladeL3_setpos] component BladeL3=Absorber() SETTING [Absorber:0]"); stracpy(_BladeL3_var._name, "BladeL3", 16384); stracpy(_BladeL3_var._type, "Absorber", 16384); _BladeL3_var._index=126; int current_setpos_index = 126; _BladeL3_var._parameters.xmin = - BladeThickness / 2; _BladeL3_var._parameters.xmax = BladeThickness / 2; _BladeL3_var._parameters.ymin = - BladeHeight / 2; _BladeL3_var._parameters.ymax = BladeHeight / 2; _BladeL3_var._parameters.zmin = - BladeLength; _BladeL3_var._parameters.zmax = 0; /* component BladeL3=Absorber() AT ROTATED */ { Coords tc1, tc2; tc1 = coords_set(0,0,0); tc2 = coords_set(0,0,0); Rotation tr1; rot_set_rotation(tr1,0,0,0); rot_set_rotation(tr1, (0.0)*DEG2RAD, (0.0)*DEG2RAD, (0.0)*DEG2RAD); rot_mul(tr1, _ArmL3_var._rotation_absolute, _BladeL3_var._rotation_absolute); rot_transpose(_BladeL2_var._rotation_absolute, tr1); rot_mul(_BladeL3_var._rotation_absolute, tr1, _BladeL3_var._rotation_relative); _BladeL3_var._rotation_is_identity = rot_test_identity(_BladeL3_var._rotation_relative); tc1 = coords_set( 0, 0, 0); rot_transpose(_ArmL3_var._rotation_absolute, tr1); tc2 = rot_apply(tr1, tc1); _BladeL3_var._position_absolute = coords_add(_ArmL3_var._position_absolute, tc2); tc1 = coords_sub(_BladeL2_var._position_absolute, _BladeL3_var._position_absolute); _BladeL3_var._position_relative = rot_apply(_BladeL3_var._rotation_absolute, tc1); } /* BladeL3=Absorber() AT ROTATED */ DEBUG_COMPONENT("BladeL3", _BladeL3_var._position_absolute, _BladeL3_var._rotation_absolute); instrument->_position_absolute[126] = _BladeL3_var._position_absolute; instrument->_position_relative[126] = _BladeL3_var._position_relative; _BladeL3_var._position_relative_is_zero = coords_test_zero(_BladeL3_var._position_relative); instrument->counter_N[126] = instrument->counter_P[126] = instrument->counter_P2[126] = 0; instrument->counter_AbsorbProp[126]= 0; #ifdef USE_NEXUS if(nxhandle) { if ((!mcdotrace) && mcformat && strcasestr(mcformat, "NeXus")) { MPI_MASTER( mccomp_placement_type_nexus(nxhandle,"0125_BladeL3", _BladeL3_var._position_absolute, _BladeL3_var._rotation_absolute, "Absorber"); mccomp_param_nexus(nxhandle,"0125_BladeL3", "xmin", "0", "- BladeThickness / 2","MCNUM"); mccomp_param_nexus(nxhandle,"0125_BladeL3", "xmax", "0", "BladeThickness / 2","MCNUM"); mccomp_param_nexus(nxhandle,"0125_BladeL3", "ymin", "0", "- BladeHeight / 2","MCNUM"); mccomp_param_nexus(nxhandle,"0125_BladeL3", "ymax", "0", "BladeHeight / 2","MCNUM"); mccomp_param_nexus(nxhandle,"0125_BladeL3", "zmin", "0", "- BladeLength","MCNUM"); mccomp_param_nexus(nxhandle,"0125_BladeL3", "zmax", "0", "0","MCNUM"); ); } } else { // fprintf(stderr,"NO NEXUS FILE"); } #endif return(0); } /* _BladeL3_setpos */ /* component ArmL4=Arm() SETTING, POSITION/ROTATION */ int _ArmL4_setpos(void) { /* sets initial component parameters, position and rotation */ SIG_MESSAGE("[_ArmL4_setpos] component ArmL4=Arm() SETTING [Arm:0]"); stracpy(_ArmL4_var._name, "ArmL4", 16384); stracpy(_ArmL4_var._type, "Arm", 16384); _ArmL4_var._index=127; int current_setpos_index = 127; /* component ArmL4=Arm() AT ROTATED */ { Coords tc1, tc2; tc1 = coords_set(0,0,0); tc2 = coords_set(0,0,0); Rotation tr1; rot_set_rotation(tr1,0,0,0); rot_set_rotation(tr1, (0)*DEG2RAD, (7 * _instrument_var._parameters.LC / 9)*DEG2RAD, (0)*DEG2RAD); rot_mul(tr1, _a6_var._rotation_absolute, _ArmL4_var._rotation_absolute); rot_transpose(_BladeL3_var._rotation_absolute, tr1); rot_mul(_ArmL4_var._rotation_absolute, tr1, _ArmL4_var._rotation_relative); _ArmL4_var._rotation_is_identity = rot_test_identity(_ArmL4_var._rotation_relative); tc1 = coords_set( 7 * WindowSize / 2, 0, dad -0.005); rot_transpose(_a6_var._rotation_absolute, tr1); tc2 = rot_apply(tr1, tc1); _ArmL4_var._position_absolute = coords_add(_a6_var._position_absolute, tc2); tc1 = coords_sub(_BladeL3_var._position_absolute, _ArmL4_var._position_absolute); _ArmL4_var._position_relative = rot_apply(_ArmL4_var._rotation_absolute, tc1); } /* ArmL4=Arm() AT ROTATED */ DEBUG_COMPONENT("ArmL4", _ArmL4_var._position_absolute, _ArmL4_var._rotation_absolute); instrument->_position_absolute[127] = _ArmL4_var._position_absolute; instrument->_position_relative[127] = _ArmL4_var._position_relative; _ArmL4_var._position_relative_is_zero = coords_test_zero(_ArmL4_var._position_relative); instrument->counter_N[127] = instrument->counter_P[127] = instrument->counter_P2[127] = 0; instrument->counter_AbsorbProp[127]= 0; #ifdef USE_NEXUS if(nxhandle) { if ((!mcdotrace) && mcformat && strcasestr(mcformat, "NeXus")) { MPI_MASTER( mccomp_placement_type_nexus(nxhandle,"0126_ArmL4", _ArmL4_var._position_absolute, _ArmL4_var._rotation_absolute, "Arm"); ); } } else { // fprintf(stderr,"NO NEXUS FILE"); } #endif return(0); } /* _ArmL4_setpos */ /* component BladeL4=Absorber() SETTING, POSITION/ROTATION */ int _BladeL4_setpos(void) { /* sets initial component parameters, position and rotation */ SIG_MESSAGE("[_BladeL4_setpos] component BladeL4=Absorber() SETTING [Absorber:0]"); stracpy(_BladeL4_var._name, "BladeL4", 16384); stracpy(_BladeL4_var._type, "Absorber", 16384); _BladeL4_var._index=128; int current_setpos_index = 128; _BladeL4_var._parameters.xmin = - BladeThickness / 2; _BladeL4_var._parameters.xmax = BladeThickness / 2; _BladeL4_var._parameters.ymin = - BladeHeight / 2; _BladeL4_var._parameters.ymax = BladeHeight / 2; _BladeL4_var._parameters.zmin = - BladeLength; _BladeL4_var._parameters.zmax = 0; /* component BladeL4=Absorber() AT ROTATED */ { Coords tc1, tc2; tc1 = coords_set(0,0,0); tc2 = coords_set(0,0,0); Rotation tr1; rot_set_rotation(tr1,0,0,0); rot_set_rotation(tr1, (0.0)*DEG2RAD, (0.0)*DEG2RAD, (0.0)*DEG2RAD); rot_mul(tr1, _ArmL4_var._rotation_absolute, _BladeL4_var._rotation_absolute); rot_transpose(_BladeL3_var._rotation_absolute, tr1); rot_mul(_BladeL4_var._rotation_absolute, tr1, _BladeL4_var._rotation_relative); _BladeL4_var._rotation_is_identity = rot_test_identity(_BladeL4_var._rotation_relative); tc1 = coords_set( 0, 0, 0); rot_transpose(_ArmL4_var._rotation_absolute, tr1); tc2 = rot_apply(tr1, tc1); _BladeL4_var._position_absolute = coords_add(_ArmL4_var._position_absolute, tc2); tc1 = coords_sub(_BladeL3_var._position_absolute, _BladeL4_var._position_absolute); _BladeL4_var._position_relative = rot_apply(_BladeL4_var._rotation_absolute, tc1); } /* BladeL4=Absorber() AT ROTATED */ DEBUG_COMPONENT("BladeL4", _BladeL4_var._position_absolute, _BladeL4_var._rotation_absolute); instrument->_position_absolute[128] = _BladeL4_var._position_absolute; instrument->_position_relative[128] = _BladeL4_var._position_relative; _BladeL4_var._position_relative_is_zero = coords_test_zero(_BladeL4_var._position_relative); instrument->counter_N[128] = instrument->counter_P[128] = instrument->counter_P2[128] = 0; instrument->counter_AbsorbProp[128]= 0; #ifdef USE_NEXUS if(nxhandle) { if ((!mcdotrace) && mcformat && strcasestr(mcformat, "NeXus")) { MPI_MASTER( mccomp_placement_type_nexus(nxhandle,"0127_BladeL4", _BladeL4_var._position_absolute, _BladeL4_var._rotation_absolute, "Absorber"); mccomp_param_nexus(nxhandle,"0127_BladeL4", "xmin", "0", "- BladeThickness / 2","MCNUM"); mccomp_param_nexus(nxhandle,"0127_BladeL4", "xmax", "0", "BladeThickness / 2","MCNUM"); mccomp_param_nexus(nxhandle,"0127_BladeL4", "ymin", "0", "- BladeHeight / 2","MCNUM"); mccomp_param_nexus(nxhandle,"0127_BladeL4", "ymax", "0", "BladeHeight / 2","MCNUM"); mccomp_param_nexus(nxhandle,"0127_BladeL4", "zmin", "0", "- BladeLength","MCNUM"); mccomp_param_nexus(nxhandle,"0127_BladeL4", "zmax", "0", "0","MCNUM"); ); } } else { // fprintf(stderr,"NO NEXUS FILE"); } #endif return(0); } /* _BladeL4_setpos */ /* component ArmL5=Arm() SETTING, POSITION/ROTATION */ int _ArmL5_setpos(void) { /* sets initial component parameters, position and rotation */ SIG_MESSAGE("[_ArmL5_setpos] component ArmL5=Arm() SETTING [Arm:0]"); stracpy(_ArmL5_var._name, "ArmL5", 16384); stracpy(_ArmL5_var._type, "Arm", 16384); _ArmL5_var._index=129; int current_setpos_index = 129; /* component ArmL5=Arm() AT ROTATED */ { Coords tc1, tc2; tc1 = coords_set(0,0,0); tc2 = coords_set(0,0,0); Rotation tr1; rot_set_rotation(tr1,0,0,0); rot_set_rotation(tr1, (0)*DEG2RAD, (9 * _instrument_var._parameters.LC / 9)*DEG2RAD, (0)*DEG2RAD); rot_mul(tr1, _a6_var._rotation_absolute, _ArmL5_var._rotation_absolute); rot_transpose(_BladeL4_var._rotation_absolute, tr1); rot_mul(_ArmL5_var._rotation_absolute, tr1, _ArmL5_var._rotation_relative); _ArmL5_var._rotation_is_identity = rot_test_identity(_ArmL5_var._rotation_relative); tc1 = coords_set( 9 * WindowSize / 2, 0, dad -0.005); rot_transpose(_a6_var._rotation_absolute, tr1); tc2 = rot_apply(tr1, tc1); _ArmL5_var._position_absolute = coords_add(_a6_var._position_absolute, tc2); tc1 = coords_sub(_BladeL4_var._position_absolute, _ArmL5_var._position_absolute); _ArmL5_var._position_relative = rot_apply(_ArmL5_var._rotation_absolute, tc1); } /* ArmL5=Arm() AT ROTATED */ DEBUG_COMPONENT("ArmL5", _ArmL5_var._position_absolute, _ArmL5_var._rotation_absolute); instrument->_position_absolute[129] = _ArmL5_var._position_absolute; instrument->_position_relative[129] = _ArmL5_var._position_relative; _ArmL5_var._position_relative_is_zero = coords_test_zero(_ArmL5_var._position_relative); instrument->counter_N[129] = instrument->counter_P[129] = instrument->counter_P2[129] = 0; instrument->counter_AbsorbProp[129]= 0; #ifdef USE_NEXUS if(nxhandle) { if ((!mcdotrace) && mcformat && strcasestr(mcformat, "NeXus")) { MPI_MASTER( mccomp_placement_type_nexus(nxhandle,"0128_ArmL5", _ArmL5_var._position_absolute, _ArmL5_var._rotation_absolute, "Arm"); ); } } else { // fprintf(stderr,"NO NEXUS FILE"); } #endif return(0); } /* _ArmL5_setpos */ /* component BladeL5=Absorber() SETTING, POSITION/ROTATION */ int _BladeL5_setpos(void) { /* sets initial component parameters, position and rotation */ SIG_MESSAGE("[_BladeL5_setpos] component BladeL5=Absorber() SETTING [Absorber:0]"); stracpy(_BladeL5_var._name, "BladeL5", 16384); stracpy(_BladeL5_var._type, "Absorber", 16384); _BladeL5_var._index=130; int current_setpos_index = 130; _BladeL5_var._parameters.xmin = - BladeThickness / 2; _BladeL5_var._parameters.xmax = BladeThickness / 2; _BladeL5_var._parameters.ymin = - BladeHeight / 2; _BladeL5_var._parameters.ymax = BladeHeight / 2; _BladeL5_var._parameters.zmin = - BladeLength; _BladeL5_var._parameters.zmax = 0; /* component BladeL5=Absorber() AT ROTATED */ { Coords tc1, tc2; tc1 = coords_set(0,0,0); tc2 = coords_set(0,0,0); Rotation tr1; rot_set_rotation(tr1,0,0,0); rot_set_rotation(tr1, (0.0)*DEG2RAD, (0.0)*DEG2RAD, (0.0)*DEG2RAD); rot_mul(tr1, _ArmL5_var._rotation_absolute, _BladeL5_var._rotation_absolute); rot_transpose(_ArmL5_var._rotation_absolute, tr1); rot_mul(_BladeL5_var._rotation_absolute, tr1, _BladeL5_var._rotation_relative); _BladeL5_var._rotation_is_identity = rot_test_identity(_BladeL5_var._rotation_relative); tc1 = coords_set( 0, 0, 0); rot_transpose(_ArmL5_var._rotation_absolute, tr1); tc2 = rot_apply(tr1, tc1); _BladeL5_var._position_absolute = coords_add(_ArmL5_var._position_absolute, tc2); tc1 = coords_sub(_ArmL5_var._position_absolute, _BladeL5_var._position_absolute); _BladeL5_var._position_relative = rot_apply(_BladeL5_var._rotation_absolute, tc1); } /* BladeL5=Absorber() AT ROTATED */ DEBUG_COMPONENT("BladeL5", _BladeL5_var._position_absolute, _BladeL5_var._rotation_absolute); instrument->_position_absolute[130] = _BladeL5_var._position_absolute; instrument->_position_relative[130] = _BladeL5_var._position_relative; _BladeL5_var._position_relative_is_zero = coords_test_zero(_BladeL5_var._position_relative); instrument->counter_N[130] = instrument->counter_P[130] = instrument->counter_P2[130] = 0; instrument->counter_AbsorbProp[130]= 0; #ifdef USE_NEXUS if(nxhandle) { if ((!mcdotrace) && mcformat && strcasestr(mcformat, "NeXus")) { MPI_MASTER( mccomp_placement_type_nexus(nxhandle,"0129_BladeL5", _BladeL5_var._position_absolute, _BladeL5_var._rotation_absolute, "Absorber"); mccomp_param_nexus(nxhandle,"0129_BladeL5", "xmin", "0", "- BladeThickness / 2","MCNUM"); mccomp_param_nexus(nxhandle,"0129_BladeL5", "xmax", "0", "BladeThickness / 2","MCNUM"); mccomp_param_nexus(nxhandle,"0129_BladeL5", "ymin", "0", "- BladeHeight / 2","MCNUM"); mccomp_param_nexus(nxhandle,"0129_BladeL5", "ymax", "0", "BladeHeight / 2","MCNUM"); mccomp_param_nexus(nxhandle,"0129_BladeL5", "zmin", "0", "- BladeLength","MCNUM"); mccomp_param_nexus(nxhandle,"0129_BladeL5", "zmax", "0", "0","MCNUM"); ); } } else { // fprintf(stderr,"NO NEXUS FILE"); } #endif return(0); } /* _BladeL5_setpos */ /* component psd_detector=PSD_monitor_psf_eff() SETTING, POSITION/ROTATION */ int _psd_detector_setpos(void) { /* sets initial component parameters, position and rotation */ SIG_MESSAGE("[_psd_detector_setpos] component psd_detector=PSD_monitor_psf_eff() SETTING [PSD_monitor_psf_eff:0]"); stracpy(_psd_detector_var._name, "psd_detector", 16384); stracpy(_psd_detector_var._type, "PSD_monitor_psf_eff", 16384); _psd_detector_var._index=131; int current_setpos_index = 131; _psd_detector_var._parameters.nx = 128; _psd_detector_var._parameters.ny = 128; if("psd_detector.dat" && strlen("psd_detector.dat")) stracpy(_psd_detector_var._parameters.filename, "psd_detector.dat" ? "psd_detector.dat" : "", 16384); else _psd_detector_var._parameters.filename[0]='\0'; _psd_detector_var._parameters.xmin = - det_width / 2.0; _psd_detector_var._parameters.xmax = det_width / 2.0; _psd_detector_var._parameters.ymin = - det_height / 2.0; _psd_detector_var._parameters.ymax = det_height / 2.0; _psd_detector_var._parameters.nowritefile = 0; _psd_detector_var._parameters.xwidth = 0; _psd_detector_var._parameters.yheight = 0; _psd_detector_var._parameters.psf = PSF; _psd_detector_var._parameters.k0 = 1.553; _psd_detector_var._parameters.eff = 0.8; _psd_detector_var._parameters.restore_neutron = 0; /* component psd_detector=PSD_monitor_psf_eff() AT ROTATED */ { Coords tc1, tc2; tc1 = coords_set(0,0,0); tc2 = coords_set(0,0,0); Rotation tr1; rot_set_rotation(tr1,0,0,0); rot_set_rotation(tr1, (0)*DEG2RAD, (180)*DEG2RAD, (0)*DEG2RAD); rot_mul(tr1, _a6_var._rotation_absolute, _psd_detector_var._rotation_absolute); rot_transpose(_BladeL5_var._rotation_absolute, tr1); rot_mul(_psd_detector_var._rotation_absolute, tr1, _psd_detector_var._rotation_relative); _psd_detector_var._rotation_is_identity = rot_test_identity(_psd_detector_var._rotation_relative); tc1 = coords_set( 0, 0, dad + 0.0215); rot_transpose(_a6_var._rotation_absolute, tr1); tc2 = rot_apply(tr1, tc1); _psd_detector_var._position_absolute = coords_add(_a6_var._position_absolute, tc2); tc1 = coords_sub(_BladeL5_var._position_absolute, _psd_detector_var._position_absolute); _psd_detector_var._position_relative = rot_apply(_psd_detector_var._rotation_absolute, tc1); } /* psd_detector=PSD_monitor_psf_eff() AT ROTATED */ DEBUG_COMPONENT("psd_detector", _psd_detector_var._position_absolute, _psd_detector_var._rotation_absolute); instrument->_position_absolute[131] = _psd_detector_var._position_absolute; instrument->_position_relative[131] = _psd_detector_var._position_relative; _psd_detector_var._position_relative_is_zero = coords_test_zero(_psd_detector_var._position_relative); instrument->counter_N[131] = instrument->counter_P[131] = instrument->counter_P2[131] = 0; instrument->counter_AbsorbProp[131]= 0; #ifdef USE_NEXUS if(nxhandle) { if ((!mcdotrace) && mcformat && strcasestr(mcformat, "NeXus")) { MPI_MASTER( mccomp_placement_type_nexus(nxhandle,"0130_psd_detector", _psd_detector_var._position_absolute, _psd_detector_var._rotation_absolute, "PSD_monitor_psf_eff"); mccomp_param_nexus(nxhandle,"0130_psd_detector", "nx", "90", "128","int"); mccomp_param_nexus(nxhandle,"0130_psd_detector", "ny", "90", "128","int"); mccomp_param_nexus(nxhandle,"0130_psd_detector", "filename", 0, "psd_detector.dat", "char*"); mccomp_param_nexus(nxhandle,"0130_psd_detector", "xmin", "0", "- det_width / 2.0","MCNUM"); mccomp_param_nexus(nxhandle,"0130_psd_detector", "xmax", "0", "det_width / 2.0","MCNUM"); mccomp_param_nexus(nxhandle,"0130_psd_detector", "ymin", "0", "- det_height / 2.0","MCNUM"); mccomp_param_nexus(nxhandle,"0130_psd_detector", "ymax", "0", "det_height / 2.0","MCNUM"); mccomp_param_nexus(nxhandle,"0130_psd_detector", "nowritefile", "0", "0","int"); mccomp_param_nexus(nxhandle,"0130_psd_detector", "xwidth", "0", "0","MCNUM"); mccomp_param_nexus(nxhandle,"0130_psd_detector", "yheight", "0", "0","MCNUM"); mccomp_param_nexus(nxhandle,"0130_psd_detector", "psf", "0", "PSF","MCNUM"); mccomp_param_nexus(nxhandle,"0130_psd_detector", "k0", "1", "1.553","MCNUM"); mccomp_param_nexus(nxhandle,"0130_psd_detector", "eff", "1", "0.8","MCNUM"); mccomp_param_nexus(nxhandle,"0130_psd_detector", "restore_neutron", "0", "0","int"); ); } } else { // fprintf(stderr,"NO NEXUS FILE"); } #endif return(0); } /* _psd_detector_setpos */ /* component emon_detector=E_monitor() SETTING, POSITION/ROTATION */ int _emon_detector_setpos(void) { /* sets initial component parameters, position and rotation */ SIG_MESSAGE("[_emon_detector_setpos] component emon_detector=E_monitor() SETTING [E_monitor:0]"); stracpy(_emon_detector_var._name, "emon_detector", 16384); stracpy(_emon_detector_var._type, "E_monitor", 16384); _emon_detector_var._index=132; int current_setpos_index = 132; _emon_detector_var._parameters.nE = 100; if("detector.dat" && strlen("detector.dat")) stracpy(_emon_detector_var._parameters.filename, "detector.dat" ? "detector.dat" : "", 16384); else _emon_detector_var._parameters.filename[0]='\0'; _emon_detector_var._parameters.xmin = -0.05; _emon_detector_var._parameters.xmax = 0.05; _emon_detector_var._parameters.ymin = -0.05; _emon_detector_var._parameters.ymax = 0.05; _emon_detector_var._parameters.nowritefile = 0; _emon_detector_var._parameters.xwidth = det_width; _emon_detector_var._parameters.yheight = det_height; _emon_detector_var._parameters.Emin = eminf; _emon_detector_var._parameters.Emax = emaxf; _emon_detector_var._parameters.restore_neutron = 1; /* component emon_detector=E_monitor() AT ROTATED */ { Coords tc1, tc2; tc1 = coords_set(0,0,0); tc2 = coords_set(0,0,0); Rotation tr1; rot_set_rotation(tr1,0,0,0); rot_set_rotation(tr1, (0)*DEG2RAD, (180)*DEG2RAD, (0)*DEG2RAD); rot_mul(tr1, _a6_var._rotation_absolute, _emon_detector_var._rotation_absolute); rot_transpose(_psd_detector_var._rotation_absolute, tr1); rot_mul(_emon_detector_var._rotation_absolute, tr1, _emon_detector_var._rotation_relative); _emon_detector_var._rotation_is_identity = rot_test_identity(_emon_detector_var._rotation_relative); tc1 = coords_set( 0, 0, dad + 0.0215); rot_transpose(_a6_var._rotation_absolute, tr1); tc2 = rot_apply(tr1, tc1); _emon_detector_var._position_absolute = coords_add(_a6_var._position_absolute, tc2); tc1 = coords_sub(_psd_detector_var._position_absolute, _emon_detector_var._position_absolute); _emon_detector_var._position_relative = rot_apply(_emon_detector_var._rotation_absolute, tc1); } /* emon_detector=E_monitor() AT ROTATED */ DEBUG_COMPONENT("emon_detector", _emon_detector_var._position_absolute, _emon_detector_var._rotation_absolute); instrument->_position_absolute[132] = _emon_detector_var._position_absolute; instrument->_position_relative[132] = _emon_detector_var._position_relative; _emon_detector_var._position_relative_is_zero = coords_test_zero(_emon_detector_var._position_relative); instrument->counter_N[132] = instrument->counter_P[132] = instrument->counter_P2[132] = 0; instrument->counter_AbsorbProp[132]= 0; #ifdef USE_NEXUS if(nxhandle) { if ((!mcdotrace) && mcformat && strcasestr(mcformat, "NeXus")) { MPI_MASTER( mccomp_placement_type_nexus(nxhandle,"0131_emon_detector", _emon_detector_var._position_absolute, _emon_detector_var._rotation_absolute, "E_monitor"); mccomp_param_nexus(nxhandle,"0131_emon_detector", "nE", "20", "100","int"); mccomp_param_nexus(nxhandle,"0131_emon_detector", "filename", 0, "detector.dat", "char*"); mccomp_param_nexus(nxhandle,"0131_emon_detector", "xmin", "-0.05", "-0.05","MCNUM"); mccomp_param_nexus(nxhandle,"0131_emon_detector", "xmax", "0.05", "0.05","MCNUM"); mccomp_param_nexus(nxhandle,"0131_emon_detector", "ymin", "-0.05", "-0.05","MCNUM"); mccomp_param_nexus(nxhandle,"0131_emon_detector", "ymax", "0.05", "0.05","MCNUM"); mccomp_param_nexus(nxhandle,"0131_emon_detector", "nowritefile", "0", "0","int"); mccomp_param_nexus(nxhandle,"0131_emon_detector", "xwidth", "0", "det_width","MCNUM"); mccomp_param_nexus(nxhandle,"0131_emon_detector", "yheight", "0", "det_height","MCNUM"); mccomp_param_nexus(nxhandle,"0131_emon_detector", "Emin", "NONE", "eminf","MCNUM"); mccomp_param_nexus(nxhandle,"0131_emon_detector", "Emax", "NONE", "emaxf","MCNUM"); mccomp_param_nexus(nxhandle,"0131_emon_detector", "restore_neutron", "0", "1","int"); ); } } else { // fprintf(stderr,"NO NEXUS FILE"); } #endif return(0); } /* _emon_detector_setpos */ /* component psd_window1=PSD_monitor_psf_eff() SETTING, POSITION/ROTATION */ int _psd_window1_setpos(void) { /* sets initial component parameters, position and rotation */ SIG_MESSAGE("[_psd_window1_setpos] component psd_window1=PSD_monitor_psf_eff() SETTING [PSD_monitor_psf_eff:0]"); stracpy(_psd_window1_var._name, "psd_window1", 16384); stracpy(_psd_window1_var._type, "PSD_monitor_psf_eff", 16384); _psd_window1_var._index=133; int current_setpos_index = 133; _psd_window1_var._parameters.nx = 128; _psd_window1_var._parameters.ny = 128; if("psd_window1.dat" && strlen("psd_window1.dat")) stracpy(_psd_window1_var._parameters.filename, "psd_window1.dat" ? "psd_window1.dat" : "", 16384); else _psd_window1_var._parameters.filename[0]='\0'; _psd_window1_var._parameters.xmin = - det_width / 2.0; _psd_window1_var._parameters.xmax = det_width / 2.0; _psd_window1_var._parameters.ymin = - det_height / 2.0; _psd_window1_var._parameters.ymax = det_height / 2.0; _psd_window1_var._parameters.nowritefile = 0; _psd_window1_var._parameters.xwidth = 0; _psd_window1_var._parameters.yheight = 0; _psd_window1_var._parameters.psf = PSF; _psd_window1_var._parameters.k0 = 1.553; _psd_window1_var._parameters.eff = 0.8; _psd_window1_var._parameters.restore_neutron = 1; /* component psd_window1=PSD_monitor_psf_eff() AT ROTATED */ { Coords tc1, tc2; tc1 = coords_set(0,0,0); tc2 = coords_set(0,0,0); Rotation tr1; rot_set_rotation(tr1,0,0,0); rot_set_rotation(tr1, (0)*DEG2RAD, (180)*DEG2RAD, (0)*DEG2RAD); rot_mul(tr1, _a6_var._rotation_absolute, _psd_window1_var._rotation_absolute); rot_transpose(_emon_detector_var._rotation_absolute, tr1); rot_mul(_psd_window1_var._rotation_absolute, tr1, _psd_window1_var._rotation_relative); _psd_window1_var._rotation_is_identity = rot_test_identity(_psd_window1_var._rotation_relative); tc1 = coords_set( 0, 0, dad + 0.0215); rot_transpose(_a6_var._rotation_absolute, tr1); tc2 = rot_apply(tr1, tc1); _psd_window1_var._position_absolute = coords_add(_a6_var._position_absolute, tc2); tc1 = coords_sub(_emon_detector_var._position_absolute, _psd_window1_var._position_absolute); _psd_window1_var._position_relative = rot_apply(_psd_window1_var._rotation_absolute, tc1); } /* psd_window1=PSD_monitor_psf_eff() AT ROTATED */ DEBUG_COMPONENT("psd_window1", _psd_window1_var._position_absolute, _psd_window1_var._rotation_absolute); instrument->_position_absolute[133] = _psd_window1_var._position_absolute; instrument->_position_relative[133] = _psd_window1_var._position_relative; _psd_window1_var._position_relative_is_zero = coords_test_zero(_psd_window1_var._position_relative); instrument->counter_N[133] = instrument->counter_P[133] = instrument->counter_P2[133] = 0; instrument->counter_AbsorbProp[133]= 0; #ifdef USE_NEXUS if(nxhandle) { if ((!mcdotrace) && mcformat && strcasestr(mcformat, "NeXus")) { MPI_MASTER( mccomp_placement_type_nexus(nxhandle,"0132_psd_window1", _psd_window1_var._position_absolute, _psd_window1_var._rotation_absolute, "PSD_monitor_psf_eff"); mccomp_param_nexus(nxhandle,"0132_psd_window1", "nx", "90", "128","int"); mccomp_param_nexus(nxhandle,"0132_psd_window1", "ny", "90", "128","int"); mccomp_param_nexus(nxhandle,"0132_psd_window1", "filename", 0, "psd_window1.dat", "char*"); mccomp_param_nexus(nxhandle,"0132_psd_window1", "xmin", "0", "- det_width / 2.0","MCNUM"); mccomp_param_nexus(nxhandle,"0132_psd_window1", "xmax", "0", "det_width / 2.0","MCNUM"); mccomp_param_nexus(nxhandle,"0132_psd_window1", "ymin", "0", "- det_height / 2.0","MCNUM"); mccomp_param_nexus(nxhandle,"0132_psd_window1", "ymax", "0", "det_height / 2.0","MCNUM"); mccomp_param_nexus(nxhandle,"0132_psd_window1", "nowritefile", "0", "0","int"); mccomp_param_nexus(nxhandle,"0132_psd_window1", "xwidth", "0", "0","MCNUM"); mccomp_param_nexus(nxhandle,"0132_psd_window1", "yheight", "0", "0","MCNUM"); mccomp_param_nexus(nxhandle,"0132_psd_window1", "psf", "0", "PSF","MCNUM"); mccomp_param_nexus(nxhandle,"0132_psd_window1", "k0", "1", "1.553","MCNUM"); mccomp_param_nexus(nxhandle,"0132_psd_window1", "eff", "1", "0.8","MCNUM"); mccomp_param_nexus(nxhandle,"0132_psd_window1", "restore_neutron", "0", "1","int"); ); } } else { // fprintf(stderr,"NO NEXUS FILE"); } #endif return(0); } /* _psd_window1_setpos */ /* component emon_window1=E_monitor() SETTING, POSITION/ROTATION */ int _emon_window1_setpos(void) { /* sets initial component parameters, position and rotation */ SIG_MESSAGE("[_emon_window1_setpos] component emon_window1=E_monitor() SETTING [E_monitor:0]"); stracpy(_emon_window1_var._name, "emon_window1", 16384); stracpy(_emon_window1_var._type, "E_monitor", 16384); _emon_window1_var._index=134; int current_setpos_index = 134; _emon_window1_var._parameters.nE = 100; if("window1.dat" && strlen("window1.dat")) stracpy(_emon_window1_var._parameters.filename, "window1.dat" ? "window1.dat" : "", 16384); else _emon_window1_var._parameters.filename[0]='\0'; _emon_window1_var._parameters.xmin = -0.05; _emon_window1_var._parameters.xmax = 0.05; _emon_window1_var._parameters.ymin = -0.05; _emon_window1_var._parameters.ymax = 0.05; _emon_window1_var._parameters.nowritefile = 0; _emon_window1_var._parameters.xwidth = det_width; _emon_window1_var._parameters.yheight = det_height; _emon_window1_var._parameters.Emin = eminf; _emon_window1_var._parameters.Emax = emaxf; _emon_window1_var._parameters.restore_neutron = 1; /* component emon_window1=E_monitor() AT ROTATED */ { Coords tc1, tc2; tc1 = coords_set(0,0,0); tc2 = coords_set(0,0,0); Rotation tr1; rot_set_rotation(tr1,0,0,0); rot_set_rotation(tr1, (0)*DEG2RAD, (180)*DEG2RAD, (0)*DEG2RAD); rot_mul(tr1, _a6_var._rotation_absolute, _emon_window1_var._rotation_absolute); rot_transpose(_psd_window1_var._rotation_absolute, tr1); rot_mul(_emon_window1_var._rotation_absolute, tr1, _emon_window1_var._rotation_relative); _emon_window1_var._rotation_is_identity = rot_test_identity(_emon_window1_var._rotation_relative); tc1 = coords_set( 0, 0, dad + 0.0215); rot_transpose(_a6_var._rotation_absolute, tr1); tc2 = rot_apply(tr1, tc1); _emon_window1_var._position_absolute = coords_add(_a6_var._position_absolute, tc2); tc1 = coords_sub(_psd_window1_var._position_absolute, _emon_window1_var._position_absolute); _emon_window1_var._position_relative = rot_apply(_emon_window1_var._rotation_absolute, tc1); } /* emon_window1=E_monitor() AT ROTATED */ DEBUG_COMPONENT("emon_window1", _emon_window1_var._position_absolute, _emon_window1_var._rotation_absolute); instrument->_position_absolute[134] = _emon_window1_var._position_absolute; instrument->_position_relative[134] = _emon_window1_var._position_relative; _emon_window1_var._position_relative_is_zero = coords_test_zero(_emon_window1_var._position_relative); instrument->counter_N[134] = instrument->counter_P[134] = instrument->counter_P2[134] = 0; instrument->counter_AbsorbProp[134]= 0; #ifdef USE_NEXUS if(nxhandle) { if ((!mcdotrace) && mcformat && strcasestr(mcformat, "NeXus")) { MPI_MASTER( mccomp_placement_type_nexus(nxhandle,"0133_emon_window1", _emon_window1_var._position_absolute, _emon_window1_var._rotation_absolute, "E_monitor"); mccomp_param_nexus(nxhandle,"0133_emon_window1", "nE", "20", "100","int"); mccomp_param_nexus(nxhandle,"0133_emon_window1", "filename", 0, "window1.dat", "char*"); mccomp_param_nexus(nxhandle,"0133_emon_window1", "xmin", "-0.05", "-0.05","MCNUM"); mccomp_param_nexus(nxhandle,"0133_emon_window1", "xmax", "0.05", "0.05","MCNUM"); mccomp_param_nexus(nxhandle,"0133_emon_window1", "ymin", "-0.05", "-0.05","MCNUM"); mccomp_param_nexus(nxhandle,"0133_emon_window1", "ymax", "0.05", "0.05","MCNUM"); mccomp_param_nexus(nxhandle,"0133_emon_window1", "nowritefile", "0", "0","int"); mccomp_param_nexus(nxhandle,"0133_emon_window1", "xwidth", "0", "det_width","MCNUM"); mccomp_param_nexus(nxhandle,"0133_emon_window1", "yheight", "0", "det_height","MCNUM"); mccomp_param_nexus(nxhandle,"0133_emon_window1", "Emin", "NONE", "eminf","MCNUM"); mccomp_param_nexus(nxhandle,"0133_emon_window1", "Emax", "NONE", "emaxf","MCNUM"); mccomp_param_nexus(nxhandle,"0133_emon_window1", "restore_neutron", "0", "1","int"); ); } } else { // fprintf(stderr,"NO NEXUS FILE"); } #endif return(0); } /* _emon_window1_setpos */ /* component psd_window2=PSD_monitor_psf_eff() SETTING, POSITION/ROTATION */ int _psd_window2_setpos(void) { /* sets initial component parameters, position and rotation */ SIG_MESSAGE("[_psd_window2_setpos] component psd_window2=PSD_monitor_psf_eff() SETTING [PSD_monitor_psf_eff:0]"); stracpy(_psd_window2_var._name, "psd_window2", 16384); stracpy(_psd_window2_var._type, "PSD_monitor_psf_eff", 16384); _psd_window2_var._index=135; int current_setpos_index = 135; _psd_window2_var._parameters.nx = 128; _psd_window2_var._parameters.ny = 128; if("psd_window2.dat" && strlen("psd_window2.dat")) stracpy(_psd_window2_var._parameters.filename, "psd_window2.dat" ? "psd_window2.dat" : "", 16384); else _psd_window2_var._parameters.filename[0]='\0'; _psd_window2_var._parameters.xmin = - det_width / 2.0; _psd_window2_var._parameters.xmax = det_width / 2.0; _psd_window2_var._parameters.ymin = - det_height / 2.0; _psd_window2_var._parameters.ymax = det_height / 2.0; _psd_window2_var._parameters.nowritefile = 0; _psd_window2_var._parameters.xwidth = 0; _psd_window2_var._parameters.yheight = 0; _psd_window2_var._parameters.psf = PSF; _psd_window2_var._parameters.k0 = 1.553; _psd_window2_var._parameters.eff = 0.8; _psd_window2_var._parameters.restore_neutron = 1; /* component psd_window2=PSD_monitor_psf_eff() AT ROTATED */ { Coords tc1, tc2; tc1 = coords_set(0,0,0); tc2 = coords_set(0,0,0); Rotation tr1; rot_set_rotation(tr1,0,0,0); rot_set_rotation(tr1, (0)*DEG2RAD, (180)*DEG2RAD, (0)*DEG2RAD); rot_mul(tr1, _a6_var._rotation_absolute, _psd_window2_var._rotation_absolute); rot_transpose(_emon_window1_var._rotation_absolute, tr1); rot_mul(_psd_window2_var._rotation_absolute, tr1, _psd_window2_var._rotation_relative); _psd_window2_var._rotation_is_identity = rot_test_identity(_psd_window2_var._rotation_relative); tc1 = coords_set( 0, 0, dad + 0.0215); rot_transpose(_a6_var._rotation_absolute, tr1); tc2 = rot_apply(tr1, tc1); _psd_window2_var._position_absolute = coords_add(_a6_var._position_absolute, tc2); tc1 = coords_sub(_emon_window1_var._position_absolute, _psd_window2_var._position_absolute); _psd_window2_var._position_relative = rot_apply(_psd_window2_var._rotation_absolute, tc1); } /* psd_window2=PSD_monitor_psf_eff() AT ROTATED */ DEBUG_COMPONENT("psd_window2", _psd_window2_var._position_absolute, _psd_window2_var._rotation_absolute); instrument->_position_absolute[135] = _psd_window2_var._position_absolute; instrument->_position_relative[135] = _psd_window2_var._position_relative; _psd_window2_var._position_relative_is_zero = coords_test_zero(_psd_window2_var._position_relative); instrument->counter_N[135] = instrument->counter_P[135] = instrument->counter_P2[135] = 0; instrument->counter_AbsorbProp[135]= 0; #ifdef USE_NEXUS if(nxhandle) { if ((!mcdotrace) && mcformat && strcasestr(mcformat, "NeXus")) { MPI_MASTER( mccomp_placement_type_nexus(nxhandle,"0134_psd_window2", _psd_window2_var._position_absolute, _psd_window2_var._rotation_absolute, "PSD_monitor_psf_eff"); mccomp_param_nexus(nxhandle,"0134_psd_window2", "nx", "90", "128","int"); mccomp_param_nexus(nxhandle,"0134_psd_window2", "ny", "90", "128","int"); mccomp_param_nexus(nxhandle,"0134_psd_window2", "filename", 0, "psd_window2.dat", "char*"); mccomp_param_nexus(nxhandle,"0134_psd_window2", "xmin", "0", "- det_width / 2.0","MCNUM"); mccomp_param_nexus(nxhandle,"0134_psd_window2", "xmax", "0", "det_width / 2.0","MCNUM"); mccomp_param_nexus(nxhandle,"0134_psd_window2", "ymin", "0", "- det_height / 2.0","MCNUM"); mccomp_param_nexus(nxhandle,"0134_psd_window2", "ymax", "0", "det_height / 2.0","MCNUM"); mccomp_param_nexus(nxhandle,"0134_psd_window2", "nowritefile", "0", "0","int"); mccomp_param_nexus(nxhandle,"0134_psd_window2", "xwidth", "0", "0","MCNUM"); mccomp_param_nexus(nxhandle,"0134_psd_window2", "yheight", "0", "0","MCNUM"); mccomp_param_nexus(nxhandle,"0134_psd_window2", "psf", "0", "PSF","MCNUM"); mccomp_param_nexus(nxhandle,"0134_psd_window2", "k0", "1", "1.553","MCNUM"); mccomp_param_nexus(nxhandle,"0134_psd_window2", "eff", "1", "0.8","MCNUM"); mccomp_param_nexus(nxhandle,"0134_psd_window2", "restore_neutron", "0", "1","int"); ); } } else { // fprintf(stderr,"NO NEXUS FILE"); } #endif return(0); } /* _psd_window2_setpos */ /* component emon_window2=E_monitor() SETTING, POSITION/ROTATION */ int _emon_window2_setpos(void) { /* sets initial component parameters, position and rotation */ SIG_MESSAGE("[_emon_window2_setpos] component emon_window2=E_monitor() SETTING [E_monitor:0]"); stracpy(_emon_window2_var._name, "emon_window2", 16384); stracpy(_emon_window2_var._type, "E_monitor", 16384); _emon_window2_var._index=136; int current_setpos_index = 136; _emon_window2_var._parameters.nE = 100; if("window2.dat" && strlen("window2.dat")) stracpy(_emon_window2_var._parameters.filename, "window2.dat" ? "window2.dat" : "", 16384); else _emon_window2_var._parameters.filename[0]='\0'; _emon_window2_var._parameters.xmin = -0.05; _emon_window2_var._parameters.xmax = 0.05; _emon_window2_var._parameters.ymin = -0.05; _emon_window2_var._parameters.ymax = 0.05; _emon_window2_var._parameters.nowritefile = 0; _emon_window2_var._parameters.xwidth = det_width; _emon_window2_var._parameters.yheight = det_height; _emon_window2_var._parameters.Emin = eminf; _emon_window2_var._parameters.Emax = emaxf; _emon_window2_var._parameters.restore_neutron = 1; /* component emon_window2=E_monitor() AT ROTATED */ { Coords tc1, tc2; tc1 = coords_set(0,0,0); tc2 = coords_set(0,0,0); Rotation tr1; rot_set_rotation(tr1,0,0,0); rot_set_rotation(tr1, (0)*DEG2RAD, (180)*DEG2RAD, (0)*DEG2RAD); rot_mul(tr1, _a6_var._rotation_absolute, _emon_window2_var._rotation_absolute); rot_transpose(_psd_window2_var._rotation_absolute, tr1); rot_mul(_emon_window2_var._rotation_absolute, tr1, _emon_window2_var._rotation_relative); _emon_window2_var._rotation_is_identity = rot_test_identity(_emon_window2_var._rotation_relative); tc1 = coords_set( 0, 0, dad + 0.0215); rot_transpose(_a6_var._rotation_absolute, tr1); tc2 = rot_apply(tr1, tc1); _emon_window2_var._position_absolute = coords_add(_a6_var._position_absolute, tc2); tc1 = coords_sub(_psd_window2_var._position_absolute, _emon_window2_var._position_absolute); _emon_window2_var._position_relative = rot_apply(_emon_window2_var._rotation_absolute, tc1); } /* emon_window2=E_monitor() AT ROTATED */ DEBUG_COMPONENT("emon_window2", _emon_window2_var._position_absolute, _emon_window2_var._rotation_absolute); instrument->_position_absolute[136] = _emon_window2_var._position_absolute; instrument->_position_relative[136] = _emon_window2_var._position_relative; _emon_window2_var._position_relative_is_zero = coords_test_zero(_emon_window2_var._position_relative); instrument->counter_N[136] = instrument->counter_P[136] = instrument->counter_P2[136] = 0; instrument->counter_AbsorbProp[136]= 0; #ifdef USE_NEXUS if(nxhandle) { if ((!mcdotrace) && mcformat && strcasestr(mcformat, "NeXus")) { MPI_MASTER( mccomp_placement_type_nexus(nxhandle,"0135_emon_window2", _emon_window2_var._position_absolute, _emon_window2_var._rotation_absolute, "E_monitor"); mccomp_param_nexus(nxhandle,"0135_emon_window2", "nE", "20", "100","int"); mccomp_param_nexus(nxhandle,"0135_emon_window2", "filename", 0, "window2.dat", "char*"); mccomp_param_nexus(nxhandle,"0135_emon_window2", "xmin", "-0.05", "-0.05","MCNUM"); mccomp_param_nexus(nxhandle,"0135_emon_window2", "xmax", "0.05", "0.05","MCNUM"); mccomp_param_nexus(nxhandle,"0135_emon_window2", "ymin", "-0.05", "-0.05","MCNUM"); mccomp_param_nexus(nxhandle,"0135_emon_window2", "ymax", "0.05", "0.05","MCNUM"); mccomp_param_nexus(nxhandle,"0135_emon_window2", "nowritefile", "0", "0","int"); mccomp_param_nexus(nxhandle,"0135_emon_window2", "xwidth", "0", "det_width","MCNUM"); mccomp_param_nexus(nxhandle,"0135_emon_window2", "yheight", "0", "det_height","MCNUM"); mccomp_param_nexus(nxhandle,"0135_emon_window2", "Emin", "NONE", "eminf","MCNUM"); mccomp_param_nexus(nxhandle,"0135_emon_window2", "Emax", "NONE", "emaxf","MCNUM"); mccomp_param_nexus(nxhandle,"0135_emon_window2", "restore_neutron", "0", "1","int"); ); } } else { // fprintf(stderr,"NO NEXUS FILE"); } #endif return(0); } /* _emon_window2_setpos */ /* component psd_window3=PSD_monitor_psf_eff() SETTING, POSITION/ROTATION */ int _psd_window3_setpos(void) { /* sets initial component parameters, position and rotation */ SIG_MESSAGE("[_psd_window3_setpos] component psd_window3=PSD_monitor_psf_eff() SETTING [PSD_monitor_psf_eff:0]"); stracpy(_psd_window3_var._name, "psd_window3", 16384); stracpy(_psd_window3_var._type, "PSD_monitor_psf_eff", 16384); _psd_window3_var._index=137; int current_setpos_index = 137; _psd_window3_var._parameters.nx = 128; _psd_window3_var._parameters.ny = 128; if("psd_window3.dat" && strlen("psd_window3.dat")) stracpy(_psd_window3_var._parameters.filename, "psd_window3.dat" ? "psd_window3.dat" : "", 16384); else _psd_window3_var._parameters.filename[0]='\0'; _psd_window3_var._parameters.xmin = - det_width / 2.0; _psd_window3_var._parameters.xmax = det_width / 2.0; _psd_window3_var._parameters.ymin = - det_height / 2.0; _psd_window3_var._parameters.ymax = det_height / 2.0; _psd_window3_var._parameters.nowritefile = 0; _psd_window3_var._parameters.xwidth = 0; _psd_window3_var._parameters.yheight = 0; _psd_window3_var._parameters.psf = PSF; _psd_window3_var._parameters.k0 = 1.553; _psd_window3_var._parameters.eff = 0.8; _psd_window3_var._parameters.restore_neutron = 1; /* component psd_window3=PSD_monitor_psf_eff() AT ROTATED */ { Coords tc1, tc2; tc1 = coords_set(0,0,0); tc2 = coords_set(0,0,0); Rotation tr1; rot_set_rotation(tr1,0,0,0); rot_set_rotation(tr1, (0)*DEG2RAD, (180)*DEG2RAD, (0)*DEG2RAD); rot_mul(tr1, _a6_var._rotation_absolute, _psd_window3_var._rotation_absolute); rot_transpose(_emon_window2_var._rotation_absolute, tr1); rot_mul(_psd_window3_var._rotation_absolute, tr1, _psd_window3_var._rotation_relative); _psd_window3_var._rotation_is_identity = rot_test_identity(_psd_window3_var._rotation_relative); tc1 = coords_set( 0, 0, dad + 0.0215); rot_transpose(_a6_var._rotation_absolute, tr1); tc2 = rot_apply(tr1, tc1); _psd_window3_var._position_absolute = coords_add(_a6_var._position_absolute, tc2); tc1 = coords_sub(_emon_window2_var._position_absolute, _psd_window3_var._position_absolute); _psd_window3_var._position_relative = rot_apply(_psd_window3_var._rotation_absolute, tc1); } /* psd_window3=PSD_monitor_psf_eff() AT ROTATED */ DEBUG_COMPONENT("psd_window3", _psd_window3_var._position_absolute, _psd_window3_var._rotation_absolute); instrument->_position_absolute[137] = _psd_window3_var._position_absolute; instrument->_position_relative[137] = _psd_window3_var._position_relative; _psd_window3_var._position_relative_is_zero = coords_test_zero(_psd_window3_var._position_relative); instrument->counter_N[137] = instrument->counter_P[137] = instrument->counter_P2[137] = 0; instrument->counter_AbsorbProp[137]= 0; #ifdef USE_NEXUS if(nxhandle) { if ((!mcdotrace) && mcformat && strcasestr(mcformat, "NeXus")) { MPI_MASTER( mccomp_placement_type_nexus(nxhandle,"0136_psd_window3", _psd_window3_var._position_absolute, _psd_window3_var._rotation_absolute, "PSD_monitor_psf_eff"); mccomp_param_nexus(nxhandle,"0136_psd_window3", "nx", "90", "128","int"); mccomp_param_nexus(nxhandle,"0136_psd_window3", "ny", "90", "128","int"); mccomp_param_nexus(nxhandle,"0136_psd_window3", "filename", 0, "psd_window3.dat", "char*"); mccomp_param_nexus(nxhandle,"0136_psd_window3", "xmin", "0", "- det_width / 2.0","MCNUM"); mccomp_param_nexus(nxhandle,"0136_psd_window3", "xmax", "0", "det_width / 2.0","MCNUM"); mccomp_param_nexus(nxhandle,"0136_psd_window3", "ymin", "0", "- det_height / 2.0","MCNUM"); mccomp_param_nexus(nxhandle,"0136_psd_window3", "ymax", "0", "det_height / 2.0","MCNUM"); mccomp_param_nexus(nxhandle,"0136_psd_window3", "nowritefile", "0", "0","int"); mccomp_param_nexus(nxhandle,"0136_psd_window3", "xwidth", "0", "0","MCNUM"); mccomp_param_nexus(nxhandle,"0136_psd_window3", "yheight", "0", "0","MCNUM"); mccomp_param_nexus(nxhandle,"0136_psd_window3", "psf", "0", "PSF","MCNUM"); mccomp_param_nexus(nxhandle,"0136_psd_window3", "k0", "1", "1.553","MCNUM"); mccomp_param_nexus(nxhandle,"0136_psd_window3", "eff", "1", "0.8","MCNUM"); mccomp_param_nexus(nxhandle,"0136_psd_window3", "restore_neutron", "0", "1","int"); ); } } else { // fprintf(stderr,"NO NEXUS FILE"); } #endif return(0); } /* _psd_window3_setpos */ /* component emon_window3=E_monitor() SETTING, POSITION/ROTATION */ int _emon_window3_setpos(void) { /* sets initial component parameters, position and rotation */ SIG_MESSAGE("[_emon_window3_setpos] component emon_window3=E_monitor() SETTING [E_monitor:0]"); stracpy(_emon_window3_var._name, "emon_window3", 16384); stracpy(_emon_window3_var._type, "E_monitor", 16384); _emon_window3_var._index=138; int current_setpos_index = 138; _emon_window3_var._parameters.nE = 100; if("window3.dat" && strlen("window3.dat")) stracpy(_emon_window3_var._parameters.filename, "window3.dat" ? "window3.dat" : "", 16384); else _emon_window3_var._parameters.filename[0]='\0'; _emon_window3_var._parameters.xmin = -0.05; _emon_window3_var._parameters.xmax = 0.05; _emon_window3_var._parameters.ymin = -0.05; _emon_window3_var._parameters.ymax = 0.05; _emon_window3_var._parameters.nowritefile = 0; _emon_window3_var._parameters.xwidth = det_width; _emon_window3_var._parameters.yheight = det_height; _emon_window3_var._parameters.Emin = eminf; _emon_window3_var._parameters.Emax = emaxf; _emon_window3_var._parameters.restore_neutron = 1; /* component emon_window3=E_monitor() AT ROTATED */ { Coords tc1, tc2; tc1 = coords_set(0,0,0); tc2 = coords_set(0,0,0); Rotation tr1; rot_set_rotation(tr1,0,0,0); rot_set_rotation(tr1, (0)*DEG2RAD, (180)*DEG2RAD, (0)*DEG2RAD); rot_mul(tr1, _a6_var._rotation_absolute, _emon_window3_var._rotation_absolute); rot_transpose(_psd_window3_var._rotation_absolute, tr1); rot_mul(_emon_window3_var._rotation_absolute, tr1, _emon_window3_var._rotation_relative); _emon_window3_var._rotation_is_identity = rot_test_identity(_emon_window3_var._rotation_relative); tc1 = coords_set( 0, 0, dad + 0.0215 + 0.0008); rot_transpose(_a6_var._rotation_absolute, tr1); tc2 = rot_apply(tr1, tc1); _emon_window3_var._position_absolute = coords_add(_a6_var._position_absolute, tc2); tc1 = coords_sub(_psd_window3_var._position_absolute, _emon_window3_var._position_absolute); _emon_window3_var._position_relative = rot_apply(_emon_window3_var._rotation_absolute, tc1); } /* emon_window3=E_monitor() AT ROTATED */ DEBUG_COMPONENT("emon_window3", _emon_window3_var._position_absolute, _emon_window3_var._rotation_absolute); instrument->_position_absolute[138] = _emon_window3_var._position_absolute; instrument->_position_relative[138] = _emon_window3_var._position_relative; _emon_window3_var._position_relative_is_zero = coords_test_zero(_emon_window3_var._position_relative); instrument->counter_N[138] = instrument->counter_P[138] = instrument->counter_P2[138] = 0; instrument->counter_AbsorbProp[138]= 0; #ifdef USE_NEXUS if(nxhandle) { if ((!mcdotrace) && mcformat && strcasestr(mcformat, "NeXus")) { MPI_MASTER( mccomp_placement_type_nexus(nxhandle,"0137_emon_window3", _emon_window3_var._position_absolute, _emon_window3_var._rotation_absolute, "E_monitor"); mccomp_param_nexus(nxhandle,"0137_emon_window3", "nE", "20", "100","int"); mccomp_param_nexus(nxhandle,"0137_emon_window3", "filename", 0, "window3.dat", "char*"); mccomp_param_nexus(nxhandle,"0137_emon_window3", "xmin", "-0.05", "-0.05","MCNUM"); mccomp_param_nexus(nxhandle,"0137_emon_window3", "xmax", "0.05", "0.05","MCNUM"); mccomp_param_nexus(nxhandle,"0137_emon_window3", "ymin", "-0.05", "-0.05","MCNUM"); mccomp_param_nexus(nxhandle,"0137_emon_window3", "ymax", "0.05", "0.05","MCNUM"); mccomp_param_nexus(nxhandle,"0137_emon_window3", "nowritefile", "0", "0","int"); mccomp_param_nexus(nxhandle,"0137_emon_window3", "xwidth", "0", "det_width","MCNUM"); mccomp_param_nexus(nxhandle,"0137_emon_window3", "yheight", "0", "det_height","MCNUM"); mccomp_param_nexus(nxhandle,"0137_emon_window3", "Emin", "NONE", "eminf","MCNUM"); mccomp_param_nexus(nxhandle,"0137_emon_window3", "Emax", "NONE", "emaxf","MCNUM"); mccomp_param_nexus(nxhandle,"0137_emon_window3", "restore_neutron", "0", "1","int"); ); } } else { // fprintf(stderr,"NO NEXUS FILE"); } #endif return(0); } /* _emon_window3_setpos */ /* component psd_window4=PSD_monitor_psf_eff() SETTING, POSITION/ROTATION */ int _psd_window4_setpos(void) { /* sets initial component parameters, position and rotation */ SIG_MESSAGE("[_psd_window4_setpos] component psd_window4=PSD_monitor_psf_eff() SETTING [PSD_monitor_psf_eff:0]"); stracpy(_psd_window4_var._name, "psd_window4", 16384); stracpy(_psd_window4_var._type, "PSD_monitor_psf_eff", 16384); _psd_window4_var._index=139; int current_setpos_index = 139; _psd_window4_var._parameters.nx = 128; _psd_window4_var._parameters.ny = 128; if("psd_window4.dat" && strlen("psd_window4.dat")) stracpy(_psd_window4_var._parameters.filename, "psd_window4.dat" ? "psd_window4.dat" : "", 16384); else _psd_window4_var._parameters.filename[0]='\0'; _psd_window4_var._parameters.xmin = - det_width / 2.0; _psd_window4_var._parameters.xmax = det_width / 2.0; _psd_window4_var._parameters.ymin = - det_height / 2.0; _psd_window4_var._parameters.ymax = det_height / 2.0; _psd_window4_var._parameters.nowritefile = 0; _psd_window4_var._parameters.xwidth = 0; _psd_window4_var._parameters.yheight = 0; _psd_window4_var._parameters.psf = PSF; _psd_window4_var._parameters.k0 = 1.553; _psd_window4_var._parameters.eff = 0.8; _psd_window4_var._parameters.restore_neutron = 1; /* component psd_window4=PSD_monitor_psf_eff() AT ROTATED */ { Coords tc1, tc2; tc1 = coords_set(0,0,0); tc2 = coords_set(0,0,0); Rotation tr1; rot_set_rotation(tr1,0,0,0); rot_set_rotation(tr1, (0)*DEG2RAD, (180)*DEG2RAD, (0)*DEG2RAD); rot_mul(tr1, _a6_var._rotation_absolute, _psd_window4_var._rotation_absolute); rot_transpose(_emon_window3_var._rotation_absolute, tr1); rot_mul(_psd_window4_var._rotation_absolute, tr1, _psd_window4_var._rotation_relative); _psd_window4_var._rotation_is_identity = rot_test_identity(_psd_window4_var._rotation_relative); tc1 = coords_set( 0, 0, dad + 0.0215); rot_transpose(_a6_var._rotation_absolute, tr1); tc2 = rot_apply(tr1, tc1); _psd_window4_var._position_absolute = coords_add(_a6_var._position_absolute, tc2); tc1 = coords_sub(_emon_window3_var._position_absolute, _psd_window4_var._position_absolute); _psd_window4_var._position_relative = rot_apply(_psd_window4_var._rotation_absolute, tc1); } /* psd_window4=PSD_monitor_psf_eff() AT ROTATED */ DEBUG_COMPONENT("psd_window4", _psd_window4_var._position_absolute, _psd_window4_var._rotation_absolute); instrument->_position_absolute[139] = _psd_window4_var._position_absolute; instrument->_position_relative[139] = _psd_window4_var._position_relative; _psd_window4_var._position_relative_is_zero = coords_test_zero(_psd_window4_var._position_relative); instrument->counter_N[139] = instrument->counter_P[139] = instrument->counter_P2[139] = 0; instrument->counter_AbsorbProp[139]= 0; #ifdef USE_NEXUS if(nxhandle) { if ((!mcdotrace) && mcformat && strcasestr(mcformat, "NeXus")) { MPI_MASTER( mccomp_placement_type_nexus(nxhandle,"0138_psd_window4", _psd_window4_var._position_absolute, _psd_window4_var._rotation_absolute, "PSD_monitor_psf_eff"); mccomp_param_nexus(nxhandle,"0138_psd_window4", "nx", "90", "128","int"); mccomp_param_nexus(nxhandle,"0138_psd_window4", "ny", "90", "128","int"); mccomp_param_nexus(nxhandle,"0138_psd_window4", "filename", 0, "psd_window4.dat", "char*"); mccomp_param_nexus(nxhandle,"0138_psd_window4", "xmin", "0", "- det_width / 2.0","MCNUM"); mccomp_param_nexus(nxhandle,"0138_psd_window4", "xmax", "0", "det_width / 2.0","MCNUM"); mccomp_param_nexus(nxhandle,"0138_psd_window4", "ymin", "0", "- det_height / 2.0","MCNUM"); mccomp_param_nexus(nxhandle,"0138_psd_window4", "ymax", "0", "det_height / 2.0","MCNUM"); mccomp_param_nexus(nxhandle,"0138_psd_window4", "nowritefile", "0", "0","int"); mccomp_param_nexus(nxhandle,"0138_psd_window4", "xwidth", "0", "0","MCNUM"); mccomp_param_nexus(nxhandle,"0138_psd_window4", "yheight", "0", "0","MCNUM"); mccomp_param_nexus(nxhandle,"0138_psd_window4", "psf", "0", "PSF","MCNUM"); mccomp_param_nexus(nxhandle,"0138_psd_window4", "k0", "1", "1.553","MCNUM"); mccomp_param_nexus(nxhandle,"0138_psd_window4", "eff", "1", "0.8","MCNUM"); mccomp_param_nexus(nxhandle,"0138_psd_window4", "restore_neutron", "0", "1","int"); ); } } else { // fprintf(stderr,"NO NEXUS FILE"); } #endif return(0); } /* _psd_window4_setpos */ /* component emon_window4=E_monitor() SETTING, POSITION/ROTATION */ int _emon_window4_setpos(void) { /* sets initial component parameters, position and rotation */ SIG_MESSAGE("[_emon_window4_setpos] component emon_window4=E_monitor() SETTING [E_monitor:0]"); stracpy(_emon_window4_var._name, "emon_window4", 16384); stracpy(_emon_window4_var._type, "E_monitor", 16384); _emon_window4_var._index=140; int current_setpos_index = 140; _emon_window4_var._parameters.nE = 100; if("window4.dat" && strlen("window4.dat")) stracpy(_emon_window4_var._parameters.filename, "window4.dat" ? "window4.dat" : "", 16384); else _emon_window4_var._parameters.filename[0]='\0'; _emon_window4_var._parameters.xmin = -0.05; _emon_window4_var._parameters.xmax = 0.05; _emon_window4_var._parameters.ymin = -0.05; _emon_window4_var._parameters.ymax = 0.05; _emon_window4_var._parameters.nowritefile = 0; _emon_window4_var._parameters.xwidth = det_width; _emon_window4_var._parameters.yheight = det_height; _emon_window4_var._parameters.Emin = eminf; _emon_window4_var._parameters.Emax = emaxf; _emon_window4_var._parameters.restore_neutron = 1; /* component emon_window4=E_monitor() AT ROTATED */ { Coords tc1, tc2; tc1 = coords_set(0,0,0); tc2 = coords_set(0,0,0); Rotation tr1; rot_set_rotation(tr1,0,0,0); rot_set_rotation(tr1, (0)*DEG2RAD, (180)*DEG2RAD, (0)*DEG2RAD); rot_mul(tr1, _a6_var._rotation_absolute, _emon_window4_var._rotation_absolute); rot_transpose(_psd_window4_var._rotation_absolute, tr1); rot_mul(_emon_window4_var._rotation_absolute, tr1, _emon_window4_var._rotation_relative); _emon_window4_var._rotation_is_identity = rot_test_identity(_emon_window4_var._rotation_relative); tc1 = coords_set( 0, 0, dad + 0.0215); rot_transpose(_a6_var._rotation_absolute, tr1); tc2 = rot_apply(tr1, tc1); _emon_window4_var._position_absolute = coords_add(_a6_var._position_absolute, tc2); tc1 = coords_sub(_psd_window4_var._position_absolute, _emon_window4_var._position_absolute); _emon_window4_var._position_relative = rot_apply(_emon_window4_var._rotation_absolute, tc1); } /* emon_window4=E_monitor() AT ROTATED */ DEBUG_COMPONENT("emon_window4", _emon_window4_var._position_absolute, _emon_window4_var._rotation_absolute); instrument->_position_absolute[140] = _emon_window4_var._position_absolute; instrument->_position_relative[140] = _emon_window4_var._position_relative; _emon_window4_var._position_relative_is_zero = coords_test_zero(_emon_window4_var._position_relative); instrument->counter_N[140] = instrument->counter_P[140] = instrument->counter_P2[140] = 0; instrument->counter_AbsorbProp[140]= 0; #ifdef USE_NEXUS if(nxhandle) { if ((!mcdotrace) && mcformat && strcasestr(mcformat, "NeXus")) { MPI_MASTER( mccomp_placement_type_nexus(nxhandle,"0139_emon_window4", _emon_window4_var._position_absolute, _emon_window4_var._rotation_absolute, "E_monitor"); mccomp_param_nexus(nxhandle,"0139_emon_window4", "nE", "20", "100","int"); mccomp_param_nexus(nxhandle,"0139_emon_window4", "filename", 0, "window4.dat", "char*"); mccomp_param_nexus(nxhandle,"0139_emon_window4", "xmin", "-0.05", "-0.05","MCNUM"); mccomp_param_nexus(nxhandle,"0139_emon_window4", "xmax", "0.05", "0.05","MCNUM"); mccomp_param_nexus(nxhandle,"0139_emon_window4", "ymin", "-0.05", "-0.05","MCNUM"); mccomp_param_nexus(nxhandle,"0139_emon_window4", "ymax", "0.05", "0.05","MCNUM"); mccomp_param_nexus(nxhandle,"0139_emon_window4", "nowritefile", "0", "0","int"); mccomp_param_nexus(nxhandle,"0139_emon_window4", "xwidth", "0", "det_width","MCNUM"); mccomp_param_nexus(nxhandle,"0139_emon_window4", "yheight", "0", "det_height","MCNUM"); mccomp_param_nexus(nxhandle,"0139_emon_window4", "Emin", "NONE", "eminf","MCNUM"); mccomp_param_nexus(nxhandle,"0139_emon_window4", "Emax", "NONE", "emaxf","MCNUM"); mccomp_param_nexus(nxhandle,"0139_emon_window4", "restore_neutron", "0", "1","int"); ); } } else { // fprintf(stderr,"NO NEXUS FILE"); } #endif return(0); } /* _emon_window4_setpos */ /* component psd_window5=PSD_monitor_psf_eff() SETTING, POSITION/ROTATION */ int _psd_window5_setpos(void) { /* sets initial component parameters, position and rotation */ SIG_MESSAGE("[_psd_window5_setpos] component psd_window5=PSD_monitor_psf_eff() SETTING [PSD_monitor_psf_eff:0]"); stracpy(_psd_window5_var._name, "psd_window5", 16384); stracpy(_psd_window5_var._type, "PSD_monitor_psf_eff", 16384); _psd_window5_var._index=141; int current_setpos_index = 141; _psd_window5_var._parameters.nx = 128; _psd_window5_var._parameters.ny = 128; if("psd_window5.dat" && strlen("psd_window5.dat")) stracpy(_psd_window5_var._parameters.filename, "psd_window5.dat" ? "psd_window5.dat" : "", 16384); else _psd_window5_var._parameters.filename[0]='\0'; _psd_window5_var._parameters.xmin = - det_width / 2.0; _psd_window5_var._parameters.xmax = det_width / 2.0; _psd_window5_var._parameters.ymin = - det_height / 2.0; _psd_window5_var._parameters.ymax = det_height / 2.0; _psd_window5_var._parameters.nowritefile = 0; _psd_window5_var._parameters.xwidth = 0; _psd_window5_var._parameters.yheight = 0; _psd_window5_var._parameters.psf = PSF; _psd_window5_var._parameters.k0 = 1.553; _psd_window5_var._parameters.eff = 0.8; _psd_window5_var._parameters.restore_neutron = 1; /* component psd_window5=PSD_monitor_psf_eff() AT ROTATED */ { Coords tc1, tc2; tc1 = coords_set(0,0,0); tc2 = coords_set(0,0,0); Rotation tr1; rot_set_rotation(tr1,0,0,0); rot_set_rotation(tr1, (0)*DEG2RAD, (180)*DEG2RAD, (0)*DEG2RAD); rot_mul(tr1, _a6_var._rotation_absolute, _psd_window5_var._rotation_absolute); rot_transpose(_emon_window4_var._rotation_absolute, tr1); rot_mul(_psd_window5_var._rotation_absolute, tr1, _psd_window5_var._rotation_relative); _psd_window5_var._rotation_is_identity = rot_test_identity(_psd_window5_var._rotation_relative); tc1 = coords_set( 0, 0, dad + 0.0215); rot_transpose(_a6_var._rotation_absolute, tr1); tc2 = rot_apply(tr1, tc1); _psd_window5_var._position_absolute = coords_add(_a6_var._position_absolute, tc2); tc1 = coords_sub(_emon_window4_var._position_absolute, _psd_window5_var._position_absolute); _psd_window5_var._position_relative = rot_apply(_psd_window5_var._rotation_absolute, tc1); } /* psd_window5=PSD_monitor_psf_eff() AT ROTATED */ DEBUG_COMPONENT("psd_window5", _psd_window5_var._position_absolute, _psd_window5_var._rotation_absolute); instrument->_position_absolute[141] = _psd_window5_var._position_absolute; instrument->_position_relative[141] = _psd_window5_var._position_relative; _psd_window5_var._position_relative_is_zero = coords_test_zero(_psd_window5_var._position_relative); instrument->counter_N[141] = instrument->counter_P[141] = instrument->counter_P2[141] = 0; instrument->counter_AbsorbProp[141]= 0; #ifdef USE_NEXUS if(nxhandle) { if ((!mcdotrace) && mcformat && strcasestr(mcformat, "NeXus")) { MPI_MASTER( mccomp_placement_type_nexus(nxhandle,"0140_psd_window5", _psd_window5_var._position_absolute, _psd_window5_var._rotation_absolute, "PSD_monitor_psf_eff"); mccomp_param_nexus(nxhandle,"0140_psd_window5", "nx", "90", "128","int"); mccomp_param_nexus(nxhandle,"0140_psd_window5", "ny", "90", "128","int"); mccomp_param_nexus(nxhandle,"0140_psd_window5", "filename", 0, "psd_window5.dat", "char*"); mccomp_param_nexus(nxhandle,"0140_psd_window5", "xmin", "0", "- det_width / 2.0","MCNUM"); mccomp_param_nexus(nxhandle,"0140_psd_window5", "xmax", "0", "det_width / 2.0","MCNUM"); mccomp_param_nexus(nxhandle,"0140_psd_window5", "ymin", "0", "- det_height / 2.0","MCNUM"); mccomp_param_nexus(nxhandle,"0140_psd_window5", "ymax", "0", "det_height / 2.0","MCNUM"); mccomp_param_nexus(nxhandle,"0140_psd_window5", "nowritefile", "0", "0","int"); mccomp_param_nexus(nxhandle,"0140_psd_window5", "xwidth", "0", "0","MCNUM"); mccomp_param_nexus(nxhandle,"0140_psd_window5", "yheight", "0", "0","MCNUM"); mccomp_param_nexus(nxhandle,"0140_psd_window5", "psf", "0", "PSF","MCNUM"); mccomp_param_nexus(nxhandle,"0140_psd_window5", "k0", "1", "1.553","MCNUM"); mccomp_param_nexus(nxhandle,"0140_psd_window5", "eff", "1", "0.8","MCNUM"); mccomp_param_nexus(nxhandle,"0140_psd_window5", "restore_neutron", "0", "1","int"); ); } } else { // fprintf(stderr,"NO NEXUS FILE"); } #endif return(0); } /* _psd_window5_setpos */ /* component emon_window5=E_monitor() SETTING, POSITION/ROTATION */ int _emon_window5_setpos(void) { /* sets initial component parameters, position and rotation */ SIG_MESSAGE("[_emon_window5_setpos] component emon_window5=E_monitor() SETTING [E_monitor:0]"); stracpy(_emon_window5_var._name, "emon_window5", 16384); stracpy(_emon_window5_var._type, "E_monitor", 16384); _emon_window5_var._index=142; int current_setpos_index = 142; _emon_window5_var._parameters.nE = 100; if("window5.dat" && strlen("window5.dat")) stracpy(_emon_window5_var._parameters.filename, "window5.dat" ? "window5.dat" : "", 16384); else _emon_window5_var._parameters.filename[0]='\0'; _emon_window5_var._parameters.xmin = -0.05; _emon_window5_var._parameters.xmax = 0.05; _emon_window5_var._parameters.ymin = -0.05; _emon_window5_var._parameters.ymax = 0.05; _emon_window5_var._parameters.nowritefile = 0; _emon_window5_var._parameters.xwidth = det_width; _emon_window5_var._parameters.yheight = det_height; _emon_window5_var._parameters.Emin = eminf; _emon_window5_var._parameters.Emax = emaxf; _emon_window5_var._parameters.restore_neutron = 1; /* component emon_window5=E_monitor() AT ROTATED */ { Coords tc1, tc2; tc1 = coords_set(0,0,0); tc2 = coords_set(0,0,0); Rotation tr1; rot_set_rotation(tr1,0,0,0); rot_set_rotation(tr1, (0)*DEG2RAD, (180)*DEG2RAD, (0)*DEG2RAD); rot_mul(tr1, _a6_var._rotation_absolute, _emon_window5_var._rotation_absolute); rot_transpose(_psd_window5_var._rotation_absolute, tr1); rot_mul(_emon_window5_var._rotation_absolute, tr1, _emon_window5_var._rotation_relative); _emon_window5_var._rotation_is_identity = rot_test_identity(_emon_window5_var._rotation_relative); tc1 = coords_set( 0, 0, dad + 0.0215); rot_transpose(_a6_var._rotation_absolute, tr1); tc2 = rot_apply(tr1, tc1); _emon_window5_var._position_absolute = coords_add(_a6_var._position_absolute, tc2); tc1 = coords_sub(_psd_window5_var._position_absolute, _emon_window5_var._position_absolute); _emon_window5_var._position_relative = rot_apply(_emon_window5_var._rotation_absolute, tc1); } /* emon_window5=E_monitor() AT ROTATED */ DEBUG_COMPONENT("emon_window5", _emon_window5_var._position_absolute, _emon_window5_var._rotation_absolute); instrument->_position_absolute[142] = _emon_window5_var._position_absolute; instrument->_position_relative[142] = _emon_window5_var._position_relative; _emon_window5_var._position_relative_is_zero = coords_test_zero(_emon_window5_var._position_relative); instrument->counter_N[142] = instrument->counter_P[142] = instrument->counter_P2[142] = 0; instrument->counter_AbsorbProp[142]= 0; #ifdef USE_NEXUS if(nxhandle) { if ((!mcdotrace) && mcformat && strcasestr(mcformat, "NeXus")) { MPI_MASTER( mccomp_placement_type_nexus(nxhandle,"0141_emon_window5", _emon_window5_var._position_absolute, _emon_window5_var._rotation_absolute, "E_monitor"); mccomp_param_nexus(nxhandle,"0141_emon_window5", "nE", "20", "100","int"); mccomp_param_nexus(nxhandle,"0141_emon_window5", "filename", 0, "window5.dat", "char*"); mccomp_param_nexus(nxhandle,"0141_emon_window5", "xmin", "-0.05", "-0.05","MCNUM"); mccomp_param_nexus(nxhandle,"0141_emon_window5", "xmax", "0.05", "0.05","MCNUM"); mccomp_param_nexus(nxhandle,"0141_emon_window5", "ymin", "-0.05", "-0.05","MCNUM"); mccomp_param_nexus(nxhandle,"0141_emon_window5", "ymax", "0.05", "0.05","MCNUM"); mccomp_param_nexus(nxhandle,"0141_emon_window5", "nowritefile", "0", "0","int"); mccomp_param_nexus(nxhandle,"0141_emon_window5", "xwidth", "0", "det_width","MCNUM"); mccomp_param_nexus(nxhandle,"0141_emon_window5", "yheight", "0", "det_height","MCNUM"); mccomp_param_nexus(nxhandle,"0141_emon_window5", "Emin", "NONE", "eminf","MCNUM"); mccomp_param_nexus(nxhandle,"0141_emon_window5", "Emax", "NONE", "emaxf","MCNUM"); mccomp_param_nexus(nxhandle,"0141_emon_window5", "restore_neutron", "0", "1","int"); ); } } else { // fprintf(stderr,"NO NEXUS FILE"); } #endif return(0); } /* _emon_window5_setpos */ /* component psd_window6=PSD_monitor_psf_eff() SETTING, POSITION/ROTATION */ int _psd_window6_setpos(void) { /* sets initial component parameters, position and rotation */ SIG_MESSAGE("[_psd_window6_setpos] component psd_window6=PSD_monitor_psf_eff() SETTING [PSD_monitor_psf_eff:0]"); stracpy(_psd_window6_var._name, "psd_window6", 16384); stracpy(_psd_window6_var._type, "PSD_monitor_psf_eff", 16384); _psd_window6_var._index=143; int current_setpos_index = 143; _psd_window6_var._parameters.nx = 128; _psd_window6_var._parameters.ny = 128; if("psd_window6.dat" && strlen("psd_window6.dat")) stracpy(_psd_window6_var._parameters.filename, "psd_window6.dat" ? "psd_window6.dat" : "", 16384); else _psd_window6_var._parameters.filename[0]='\0'; _psd_window6_var._parameters.xmin = - det_width / 2.0; _psd_window6_var._parameters.xmax = det_width / 2.0; _psd_window6_var._parameters.ymin = - det_height / 2.0; _psd_window6_var._parameters.ymax = det_height / 2.0; _psd_window6_var._parameters.nowritefile = 0; _psd_window6_var._parameters.xwidth = 0; _psd_window6_var._parameters.yheight = 0; _psd_window6_var._parameters.psf = PSF; _psd_window6_var._parameters.k0 = 1.553; _psd_window6_var._parameters.eff = 0.8; _psd_window6_var._parameters.restore_neutron = 1; /* component psd_window6=PSD_monitor_psf_eff() AT ROTATED */ { Coords tc1, tc2; tc1 = coords_set(0,0,0); tc2 = coords_set(0,0,0); Rotation tr1; rot_set_rotation(tr1,0,0,0); rot_set_rotation(tr1, (0)*DEG2RAD, (180)*DEG2RAD, (0)*DEG2RAD); rot_mul(tr1, _a6_var._rotation_absolute, _psd_window6_var._rotation_absolute); rot_transpose(_emon_window5_var._rotation_absolute, tr1); rot_mul(_psd_window6_var._rotation_absolute, tr1, _psd_window6_var._rotation_relative); _psd_window6_var._rotation_is_identity = rot_test_identity(_psd_window6_var._rotation_relative); tc1 = coords_set( 0, 0, dad + 0.0215); rot_transpose(_a6_var._rotation_absolute, tr1); tc2 = rot_apply(tr1, tc1); _psd_window6_var._position_absolute = coords_add(_a6_var._position_absolute, tc2); tc1 = coords_sub(_emon_window5_var._position_absolute, _psd_window6_var._position_absolute); _psd_window6_var._position_relative = rot_apply(_psd_window6_var._rotation_absolute, tc1); } /* psd_window6=PSD_monitor_psf_eff() AT ROTATED */ DEBUG_COMPONENT("psd_window6", _psd_window6_var._position_absolute, _psd_window6_var._rotation_absolute); instrument->_position_absolute[143] = _psd_window6_var._position_absolute; instrument->_position_relative[143] = _psd_window6_var._position_relative; _psd_window6_var._position_relative_is_zero = coords_test_zero(_psd_window6_var._position_relative); instrument->counter_N[143] = instrument->counter_P[143] = instrument->counter_P2[143] = 0; instrument->counter_AbsorbProp[143]= 0; #ifdef USE_NEXUS if(nxhandle) { if ((!mcdotrace) && mcformat && strcasestr(mcformat, "NeXus")) { MPI_MASTER( mccomp_placement_type_nexus(nxhandle,"0142_psd_window6", _psd_window6_var._position_absolute, _psd_window6_var._rotation_absolute, "PSD_monitor_psf_eff"); mccomp_param_nexus(nxhandle,"0142_psd_window6", "nx", "90", "128","int"); mccomp_param_nexus(nxhandle,"0142_psd_window6", "ny", "90", "128","int"); mccomp_param_nexus(nxhandle,"0142_psd_window6", "filename", 0, "psd_window6.dat", "char*"); mccomp_param_nexus(nxhandle,"0142_psd_window6", "xmin", "0", "- det_width / 2.0","MCNUM"); mccomp_param_nexus(nxhandle,"0142_psd_window6", "xmax", "0", "det_width / 2.0","MCNUM"); mccomp_param_nexus(nxhandle,"0142_psd_window6", "ymin", "0", "- det_height / 2.0","MCNUM"); mccomp_param_nexus(nxhandle,"0142_psd_window6", "ymax", "0", "det_height / 2.0","MCNUM"); mccomp_param_nexus(nxhandle,"0142_psd_window6", "nowritefile", "0", "0","int"); mccomp_param_nexus(nxhandle,"0142_psd_window6", "xwidth", "0", "0","MCNUM"); mccomp_param_nexus(nxhandle,"0142_psd_window6", "yheight", "0", "0","MCNUM"); mccomp_param_nexus(nxhandle,"0142_psd_window6", "psf", "0", "PSF","MCNUM"); mccomp_param_nexus(nxhandle,"0142_psd_window6", "k0", "1", "1.553","MCNUM"); mccomp_param_nexus(nxhandle,"0142_psd_window6", "eff", "1", "0.8","MCNUM"); mccomp_param_nexus(nxhandle,"0142_psd_window6", "restore_neutron", "0", "1","int"); ); } } else { // fprintf(stderr,"NO NEXUS FILE"); } #endif return(0); } /* _psd_window6_setpos */ /* component emon_window6=E_monitor() SETTING, POSITION/ROTATION */ int _emon_window6_setpos(void) { /* sets initial component parameters, position and rotation */ SIG_MESSAGE("[_emon_window6_setpos] component emon_window6=E_monitor() SETTING [E_monitor:0]"); stracpy(_emon_window6_var._name, "emon_window6", 16384); stracpy(_emon_window6_var._type, "E_monitor", 16384); _emon_window6_var._index=144; int current_setpos_index = 144; _emon_window6_var._parameters.nE = 100; if("window6.dat" && strlen("window6.dat")) stracpy(_emon_window6_var._parameters.filename, "window6.dat" ? "window6.dat" : "", 16384); else _emon_window6_var._parameters.filename[0]='\0'; _emon_window6_var._parameters.xmin = -0.05; _emon_window6_var._parameters.xmax = 0.05; _emon_window6_var._parameters.ymin = -0.05; _emon_window6_var._parameters.ymax = 0.05; _emon_window6_var._parameters.nowritefile = 0; _emon_window6_var._parameters.xwidth = det_width; _emon_window6_var._parameters.yheight = det_height; _emon_window6_var._parameters.Emin = eminf; _emon_window6_var._parameters.Emax = emaxf; _emon_window6_var._parameters.restore_neutron = 1; /* component emon_window6=E_monitor() AT ROTATED */ { Coords tc1, tc2; tc1 = coords_set(0,0,0); tc2 = coords_set(0,0,0); Rotation tr1; rot_set_rotation(tr1,0,0,0); rot_set_rotation(tr1, (0)*DEG2RAD, (180)*DEG2RAD, (0)*DEG2RAD); rot_mul(tr1, _a6_var._rotation_absolute, _emon_window6_var._rotation_absolute); rot_transpose(_psd_window6_var._rotation_absolute, tr1); rot_mul(_emon_window6_var._rotation_absolute, tr1, _emon_window6_var._rotation_relative); _emon_window6_var._rotation_is_identity = rot_test_identity(_emon_window6_var._rotation_relative); tc1 = coords_set( 0, 0, dad + 0.0215); rot_transpose(_a6_var._rotation_absolute, tr1); tc2 = rot_apply(tr1, tc1); _emon_window6_var._position_absolute = coords_add(_a6_var._position_absolute, tc2); tc1 = coords_sub(_psd_window6_var._position_absolute, _emon_window6_var._position_absolute); _emon_window6_var._position_relative = rot_apply(_emon_window6_var._rotation_absolute, tc1); } /* emon_window6=E_monitor() AT ROTATED */ DEBUG_COMPONENT("emon_window6", _emon_window6_var._position_absolute, _emon_window6_var._rotation_absolute); instrument->_position_absolute[144] = _emon_window6_var._position_absolute; instrument->_position_relative[144] = _emon_window6_var._position_relative; _emon_window6_var._position_relative_is_zero = coords_test_zero(_emon_window6_var._position_relative); instrument->counter_N[144] = instrument->counter_P[144] = instrument->counter_P2[144] = 0; instrument->counter_AbsorbProp[144]= 0; #ifdef USE_NEXUS if(nxhandle) { if ((!mcdotrace) && mcformat && strcasestr(mcformat, "NeXus")) { MPI_MASTER( mccomp_placement_type_nexus(nxhandle,"0143_emon_window6", _emon_window6_var._position_absolute, _emon_window6_var._rotation_absolute, "E_monitor"); mccomp_param_nexus(nxhandle,"0143_emon_window6", "nE", "20", "100","int"); mccomp_param_nexus(nxhandle,"0143_emon_window6", "filename", 0, "window6.dat", "char*"); mccomp_param_nexus(nxhandle,"0143_emon_window6", "xmin", "-0.05", "-0.05","MCNUM"); mccomp_param_nexus(nxhandle,"0143_emon_window6", "xmax", "0.05", "0.05","MCNUM"); mccomp_param_nexus(nxhandle,"0143_emon_window6", "ymin", "-0.05", "-0.05","MCNUM"); mccomp_param_nexus(nxhandle,"0143_emon_window6", "ymax", "0.05", "0.05","MCNUM"); mccomp_param_nexus(nxhandle,"0143_emon_window6", "nowritefile", "0", "0","int"); mccomp_param_nexus(nxhandle,"0143_emon_window6", "xwidth", "0", "det_width","MCNUM"); mccomp_param_nexus(nxhandle,"0143_emon_window6", "yheight", "0", "det_height","MCNUM"); mccomp_param_nexus(nxhandle,"0143_emon_window6", "Emin", "NONE", "eminf","MCNUM"); mccomp_param_nexus(nxhandle,"0143_emon_window6", "Emax", "NONE", "emaxf","MCNUM"); mccomp_param_nexus(nxhandle,"0143_emon_window6", "restore_neutron", "0", "1","int"); ); } } else { // fprintf(stderr,"NO NEXUS FILE"); } #endif return(0); } /* _emon_window6_setpos */ /* component psd_window7=PSD_monitor_psf_eff() SETTING, POSITION/ROTATION */ int _psd_window7_setpos(void) { /* sets initial component parameters, position and rotation */ SIG_MESSAGE("[_psd_window7_setpos] component psd_window7=PSD_monitor_psf_eff() SETTING [PSD_monitor_psf_eff:0]"); stracpy(_psd_window7_var._name, "psd_window7", 16384); stracpy(_psd_window7_var._type, "PSD_monitor_psf_eff", 16384); _psd_window7_var._index=145; int current_setpos_index = 145; _psd_window7_var._parameters.nx = 128; _psd_window7_var._parameters.ny = 128; if("psd_window7.dat" && strlen("psd_window7.dat")) stracpy(_psd_window7_var._parameters.filename, "psd_window7.dat" ? "psd_window7.dat" : "", 16384); else _psd_window7_var._parameters.filename[0]='\0'; _psd_window7_var._parameters.xmin = - det_width / 2.0; _psd_window7_var._parameters.xmax = det_width / 2.0; _psd_window7_var._parameters.ymin = - det_height / 2.0; _psd_window7_var._parameters.ymax = det_height / 2.0; _psd_window7_var._parameters.nowritefile = 0; _psd_window7_var._parameters.xwidth = 0; _psd_window7_var._parameters.yheight = 0; _psd_window7_var._parameters.psf = PSF; _psd_window7_var._parameters.k0 = 1.553; _psd_window7_var._parameters.eff = 0.8; _psd_window7_var._parameters.restore_neutron = 1; /* component psd_window7=PSD_monitor_psf_eff() AT ROTATED */ { Coords tc1, tc2; tc1 = coords_set(0,0,0); tc2 = coords_set(0,0,0); Rotation tr1; rot_set_rotation(tr1,0,0,0); rot_set_rotation(tr1, (0)*DEG2RAD, (180)*DEG2RAD, (0)*DEG2RAD); rot_mul(tr1, _a6_var._rotation_absolute, _psd_window7_var._rotation_absolute); rot_transpose(_emon_window6_var._rotation_absolute, tr1); rot_mul(_psd_window7_var._rotation_absolute, tr1, _psd_window7_var._rotation_relative); _psd_window7_var._rotation_is_identity = rot_test_identity(_psd_window7_var._rotation_relative); tc1 = coords_set( 0, 0, dad + 0.0215); rot_transpose(_a6_var._rotation_absolute, tr1); tc2 = rot_apply(tr1, tc1); _psd_window7_var._position_absolute = coords_add(_a6_var._position_absolute, tc2); tc1 = coords_sub(_emon_window6_var._position_absolute, _psd_window7_var._position_absolute); _psd_window7_var._position_relative = rot_apply(_psd_window7_var._rotation_absolute, tc1); } /* psd_window7=PSD_monitor_psf_eff() AT ROTATED */ DEBUG_COMPONENT("psd_window7", _psd_window7_var._position_absolute, _psd_window7_var._rotation_absolute); instrument->_position_absolute[145] = _psd_window7_var._position_absolute; instrument->_position_relative[145] = _psd_window7_var._position_relative; _psd_window7_var._position_relative_is_zero = coords_test_zero(_psd_window7_var._position_relative); instrument->counter_N[145] = instrument->counter_P[145] = instrument->counter_P2[145] = 0; instrument->counter_AbsorbProp[145]= 0; #ifdef USE_NEXUS if(nxhandle) { if ((!mcdotrace) && mcformat && strcasestr(mcformat, "NeXus")) { MPI_MASTER( mccomp_placement_type_nexus(nxhandle,"0144_psd_window7", _psd_window7_var._position_absolute, _psd_window7_var._rotation_absolute, "PSD_monitor_psf_eff"); mccomp_param_nexus(nxhandle,"0144_psd_window7", "nx", "90", "128","int"); mccomp_param_nexus(nxhandle,"0144_psd_window7", "ny", "90", "128","int"); mccomp_param_nexus(nxhandle,"0144_psd_window7", "filename", 0, "psd_window7.dat", "char*"); mccomp_param_nexus(nxhandle,"0144_psd_window7", "xmin", "0", "- det_width / 2.0","MCNUM"); mccomp_param_nexus(nxhandle,"0144_psd_window7", "xmax", "0", "det_width / 2.0","MCNUM"); mccomp_param_nexus(nxhandle,"0144_psd_window7", "ymin", "0", "- det_height / 2.0","MCNUM"); mccomp_param_nexus(nxhandle,"0144_psd_window7", "ymax", "0", "det_height / 2.0","MCNUM"); mccomp_param_nexus(nxhandle,"0144_psd_window7", "nowritefile", "0", "0","int"); mccomp_param_nexus(nxhandle,"0144_psd_window7", "xwidth", "0", "0","MCNUM"); mccomp_param_nexus(nxhandle,"0144_psd_window7", "yheight", "0", "0","MCNUM"); mccomp_param_nexus(nxhandle,"0144_psd_window7", "psf", "0", "PSF","MCNUM"); mccomp_param_nexus(nxhandle,"0144_psd_window7", "k0", "1", "1.553","MCNUM"); mccomp_param_nexus(nxhandle,"0144_psd_window7", "eff", "1", "0.8","MCNUM"); mccomp_param_nexus(nxhandle,"0144_psd_window7", "restore_neutron", "0", "1","int"); ); } } else { // fprintf(stderr,"NO NEXUS FILE"); } #endif return(0); } /* _psd_window7_setpos */ /* component emon_window7=E_monitor() SETTING, POSITION/ROTATION */ int _emon_window7_setpos(void) { /* sets initial component parameters, position and rotation */ SIG_MESSAGE("[_emon_window7_setpos] component emon_window7=E_monitor() SETTING [E_monitor:0]"); stracpy(_emon_window7_var._name, "emon_window7", 16384); stracpy(_emon_window7_var._type, "E_monitor", 16384); _emon_window7_var._index=146; int current_setpos_index = 146; _emon_window7_var._parameters.nE = 100; if("window7.dat" && strlen("window7.dat")) stracpy(_emon_window7_var._parameters.filename, "window7.dat" ? "window7.dat" : "", 16384); else _emon_window7_var._parameters.filename[0]='\0'; _emon_window7_var._parameters.xmin = -0.05; _emon_window7_var._parameters.xmax = 0.05; _emon_window7_var._parameters.ymin = -0.05; _emon_window7_var._parameters.ymax = 0.05; _emon_window7_var._parameters.nowritefile = 0; _emon_window7_var._parameters.xwidth = det_width; _emon_window7_var._parameters.yheight = det_height; _emon_window7_var._parameters.Emin = eminf; _emon_window7_var._parameters.Emax = emaxf; _emon_window7_var._parameters.restore_neutron = 1; /* component emon_window7=E_monitor() AT ROTATED */ { Coords tc1, tc2; tc1 = coords_set(0,0,0); tc2 = coords_set(0,0,0); Rotation tr1; rot_set_rotation(tr1,0,0,0); rot_set_rotation(tr1, (0)*DEG2RAD, (180)*DEG2RAD, (0)*DEG2RAD); rot_mul(tr1, _a6_var._rotation_absolute, _emon_window7_var._rotation_absolute); rot_transpose(_psd_window7_var._rotation_absolute, tr1); rot_mul(_emon_window7_var._rotation_absolute, tr1, _emon_window7_var._rotation_relative); _emon_window7_var._rotation_is_identity = rot_test_identity(_emon_window7_var._rotation_relative); tc1 = coords_set( 0, 0, dad + 0.0215); rot_transpose(_a6_var._rotation_absolute, tr1); tc2 = rot_apply(tr1, tc1); _emon_window7_var._position_absolute = coords_add(_a6_var._position_absolute, tc2); tc1 = coords_sub(_psd_window7_var._position_absolute, _emon_window7_var._position_absolute); _emon_window7_var._position_relative = rot_apply(_emon_window7_var._rotation_absolute, tc1); } /* emon_window7=E_monitor() AT ROTATED */ DEBUG_COMPONENT("emon_window7", _emon_window7_var._position_absolute, _emon_window7_var._rotation_absolute); instrument->_position_absolute[146] = _emon_window7_var._position_absolute; instrument->_position_relative[146] = _emon_window7_var._position_relative; _emon_window7_var._position_relative_is_zero = coords_test_zero(_emon_window7_var._position_relative); instrument->counter_N[146] = instrument->counter_P[146] = instrument->counter_P2[146] = 0; instrument->counter_AbsorbProp[146]= 0; #ifdef USE_NEXUS if(nxhandle) { if ((!mcdotrace) && mcformat && strcasestr(mcformat, "NeXus")) { MPI_MASTER( mccomp_placement_type_nexus(nxhandle,"0145_emon_window7", _emon_window7_var._position_absolute, _emon_window7_var._rotation_absolute, "E_monitor"); mccomp_param_nexus(nxhandle,"0145_emon_window7", "nE", "20", "100","int"); mccomp_param_nexus(nxhandle,"0145_emon_window7", "filename", 0, "window7.dat", "char*"); mccomp_param_nexus(nxhandle,"0145_emon_window7", "xmin", "-0.05", "-0.05","MCNUM"); mccomp_param_nexus(nxhandle,"0145_emon_window7", "xmax", "0.05", "0.05","MCNUM"); mccomp_param_nexus(nxhandle,"0145_emon_window7", "ymin", "-0.05", "-0.05","MCNUM"); mccomp_param_nexus(nxhandle,"0145_emon_window7", "ymax", "0.05", "0.05","MCNUM"); mccomp_param_nexus(nxhandle,"0145_emon_window7", "nowritefile", "0", "0","int"); mccomp_param_nexus(nxhandle,"0145_emon_window7", "xwidth", "0", "det_width","MCNUM"); mccomp_param_nexus(nxhandle,"0145_emon_window7", "yheight", "0", "det_height","MCNUM"); mccomp_param_nexus(nxhandle,"0145_emon_window7", "Emin", "NONE", "eminf","MCNUM"); mccomp_param_nexus(nxhandle,"0145_emon_window7", "Emax", "NONE", "emaxf","MCNUM"); mccomp_param_nexus(nxhandle,"0145_emon_window7", "restore_neutron", "0", "1","int"); ); } } else { // fprintf(stderr,"NO NEXUS FILE"); } #endif return(0); } /* _emon_window7_setpos */ /* component psd_window8=PSD_monitor_psf_eff() SETTING, POSITION/ROTATION */ int _psd_window8_setpos(void) { /* sets initial component parameters, position and rotation */ SIG_MESSAGE("[_psd_window8_setpos] component psd_window8=PSD_monitor_psf_eff() SETTING [PSD_monitor_psf_eff:0]"); stracpy(_psd_window8_var._name, "psd_window8", 16384); stracpy(_psd_window8_var._type, "PSD_monitor_psf_eff", 16384); _psd_window8_var._index=147; int current_setpos_index = 147; _psd_window8_var._parameters.nx = 128; _psd_window8_var._parameters.ny = 128; if("psd_window8.dat" && strlen("psd_window8.dat")) stracpy(_psd_window8_var._parameters.filename, "psd_window8.dat" ? "psd_window8.dat" : "", 16384); else _psd_window8_var._parameters.filename[0]='\0'; _psd_window8_var._parameters.xmin = - det_width / 2.0; _psd_window8_var._parameters.xmax = det_width / 2.0; _psd_window8_var._parameters.ymin = - det_height / 2.0; _psd_window8_var._parameters.ymax = det_height / 2.0; _psd_window8_var._parameters.nowritefile = 0; _psd_window8_var._parameters.xwidth = 0; _psd_window8_var._parameters.yheight = 0; _psd_window8_var._parameters.psf = PSF; _psd_window8_var._parameters.k0 = 1.553; _psd_window8_var._parameters.eff = 0.8; _psd_window8_var._parameters.restore_neutron = 1; /* component psd_window8=PSD_monitor_psf_eff() AT ROTATED */ { Coords tc1, tc2; tc1 = coords_set(0,0,0); tc2 = coords_set(0,0,0); Rotation tr1; rot_set_rotation(tr1,0,0,0); rot_set_rotation(tr1, (0)*DEG2RAD, (180)*DEG2RAD, (0)*DEG2RAD); rot_mul(tr1, _a6_var._rotation_absolute, _psd_window8_var._rotation_absolute); rot_transpose(_emon_window7_var._rotation_absolute, tr1); rot_mul(_psd_window8_var._rotation_absolute, tr1, _psd_window8_var._rotation_relative); _psd_window8_var._rotation_is_identity = rot_test_identity(_psd_window8_var._rotation_relative); tc1 = coords_set( 0, 0, dad + 0.0215); rot_transpose(_a6_var._rotation_absolute, tr1); tc2 = rot_apply(tr1, tc1); _psd_window8_var._position_absolute = coords_add(_a6_var._position_absolute, tc2); tc1 = coords_sub(_emon_window7_var._position_absolute, _psd_window8_var._position_absolute); _psd_window8_var._position_relative = rot_apply(_psd_window8_var._rotation_absolute, tc1); } /* psd_window8=PSD_monitor_psf_eff() AT ROTATED */ DEBUG_COMPONENT("psd_window8", _psd_window8_var._position_absolute, _psd_window8_var._rotation_absolute); instrument->_position_absolute[147] = _psd_window8_var._position_absolute; instrument->_position_relative[147] = _psd_window8_var._position_relative; _psd_window8_var._position_relative_is_zero = coords_test_zero(_psd_window8_var._position_relative); instrument->counter_N[147] = instrument->counter_P[147] = instrument->counter_P2[147] = 0; instrument->counter_AbsorbProp[147]= 0; #ifdef USE_NEXUS if(nxhandle) { if ((!mcdotrace) && mcformat && strcasestr(mcformat, "NeXus")) { MPI_MASTER( mccomp_placement_type_nexus(nxhandle,"0146_psd_window8", _psd_window8_var._position_absolute, _psd_window8_var._rotation_absolute, "PSD_monitor_psf_eff"); mccomp_param_nexus(nxhandle,"0146_psd_window8", "nx", "90", "128","int"); mccomp_param_nexus(nxhandle,"0146_psd_window8", "ny", "90", "128","int"); mccomp_param_nexus(nxhandle,"0146_psd_window8", "filename", 0, "psd_window8.dat", "char*"); mccomp_param_nexus(nxhandle,"0146_psd_window8", "xmin", "0", "- det_width / 2.0","MCNUM"); mccomp_param_nexus(nxhandle,"0146_psd_window8", "xmax", "0", "det_width / 2.0","MCNUM"); mccomp_param_nexus(nxhandle,"0146_psd_window8", "ymin", "0", "- det_height / 2.0","MCNUM"); mccomp_param_nexus(nxhandle,"0146_psd_window8", "ymax", "0", "det_height / 2.0","MCNUM"); mccomp_param_nexus(nxhandle,"0146_psd_window8", "nowritefile", "0", "0","int"); mccomp_param_nexus(nxhandle,"0146_psd_window8", "xwidth", "0", "0","MCNUM"); mccomp_param_nexus(nxhandle,"0146_psd_window8", "yheight", "0", "0","MCNUM"); mccomp_param_nexus(nxhandle,"0146_psd_window8", "psf", "0", "PSF","MCNUM"); mccomp_param_nexus(nxhandle,"0146_psd_window8", "k0", "1", "1.553","MCNUM"); mccomp_param_nexus(nxhandle,"0146_psd_window8", "eff", "1", "0.8","MCNUM"); mccomp_param_nexus(nxhandle,"0146_psd_window8", "restore_neutron", "0", "1","int"); ); } } else { // fprintf(stderr,"NO NEXUS FILE"); } #endif return(0); } /* _psd_window8_setpos */ /* component emon_window8=E_monitor() SETTING, POSITION/ROTATION */ int _emon_window8_setpos(void) { /* sets initial component parameters, position and rotation */ SIG_MESSAGE("[_emon_window8_setpos] component emon_window8=E_monitor() SETTING [E_monitor:0]"); stracpy(_emon_window8_var._name, "emon_window8", 16384); stracpy(_emon_window8_var._type, "E_monitor", 16384); _emon_window8_var._index=148; int current_setpos_index = 148; _emon_window8_var._parameters.nE = 100; if("window8.dat" && strlen("window8.dat")) stracpy(_emon_window8_var._parameters.filename, "window8.dat" ? "window8.dat" : "", 16384); else _emon_window8_var._parameters.filename[0]='\0'; _emon_window8_var._parameters.xmin = -0.05; _emon_window8_var._parameters.xmax = 0.05; _emon_window8_var._parameters.ymin = -0.05; _emon_window8_var._parameters.ymax = 0.05; _emon_window8_var._parameters.nowritefile = 0; _emon_window8_var._parameters.xwidth = det_width; _emon_window8_var._parameters.yheight = det_height; _emon_window8_var._parameters.Emin = eminf; _emon_window8_var._parameters.Emax = emaxf; _emon_window8_var._parameters.restore_neutron = 1; /* component emon_window8=E_monitor() AT ROTATED */ { Coords tc1, tc2; tc1 = coords_set(0,0,0); tc2 = coords_set(0,0,0); Rotation tr1; rot_set_rotation(tr1,0,0,0); rot_set_rotation(tr1, (0)*DEG2RAD, (180)*DEG2RAD, (0)*DEG2RAD); rot_mul(tr1, _a6_var._rotation_absolute, _emon_window8_var._rotation_absolute); rot_transpose(_psd_window8_var._rotation_absolute, tr1); rot_mul(_emon_window8_var._rotation_absolute, tr1, _emon_window8_var._rotation_relative); _emon_window8_var._rotation_is_identity = rot_test_identity(_emon_window8_var._rotation_relative); tc1 = coords_set( 0, 0, dad + 0.0215); rot_transpose(_a6_var._rotation_absolute, tr1); tc2 = rot_apply(tr1, tc1); _emon_window8_var._position_absolute = coords_add(_a6_var._position_absolute, tc2); tc1 = coords_sub(_psd_window8_var._position_absolute, _emon_window8_var._position_absolute); _emon_window8_var._position_relative = rot_apply(_emon_window8_var._rotation_absolute, tc1); } /* emon_window8=E_monitor() AT ROTATED */ DEBUG_COMPONENT("emon_window8", _emon_window8_var._position_absolute, _emon_window8_var._rotation_absolute); instrument->_position_absolute[148] = _emon_window8_var._position_absolute; instrument->_position_relative[148] = _emon_window8_var._position_relative; _emon_window8_var._position_relative_is_zero = coords_test_zero(_emon_window8_var._position_relative); instrument->counter_N[148] = instrument->counter_P[148] = instrument->counter_P2[148] = 0; instrument->counter_AbsorbProp[148]= 0; #ifdef USE_NEXUS if(nxhandle) { if ((!mcdotrace) && mcformat && strcasestr(mcformat, "NeXus")) { MPI_MASTER( mccomp_placement_type_nexus(nxhandle,"0147_emon_window8", _emon_window8_var._position_absolute, _emon_window8_var._rotation_absolute, "E_monitor"); mccomp_param_nexus(nxhandle,"0147_emon_window8", "nE", "20", "100","int"); mccomp_param_nexus(nxhandle,"0147_emon_window8", "filename", 0, "window8.dat", "char*"); mccomp_param_nexus(nxhandle,"0147_emon_window8", "xmin", "-0.05", "-0.05","MCNUM"); mccomp_param_nexus(nxhandle,"0147_emon_window8", "xmax", "0.05", "0.05","MCNUM"); mccomp_param_nexus(nxhandle,"0147_emon_window8", "ymin", "-0.05", "-0.05","MCNUM"); mccomp_param_nexus(nxhandle,"0147_emon_window8", "ymax", "0.05", "0.05","MCNUM"); mccomp_param_nexus(nxhandle,"0147_emon_window8", "nowritefile", "0", "0","int"); mccomp_param_nexus(nxhandle,"0147_emon_window8", "xwidth", "0", "det_width","MCNUM"); mccomp_param_nexus(nxhandle,"0147_emon_window8", "yheight", "0", "det_height","MCNUM"); mccomp_param_nexus(nxhandle,"0147_emon_window8", "Emin", "NONE", "eminf","MCNUM"); mccomp_param_nexus(nxhandle,"0147_emon_window8", "Emax", "NONE", "emaxf","MCNUM"); mccomp_param_nexus(nxhandle,"0147_emon_window8", "restore_neutron", "0", "1","int"); ); } } else { // fprintf(stderr,"NO NEXUS FILE"); } #endif return(0); } /* _emon_window8_setpos */ /* component psd_window9=PSD_monitor_psf_eff() SETTING, POSITION/ROTATION */ int _psd_window9_setpos(void) { /* sets initial component parameters, position and rotation */ SIG_MESSAGE("[_psd_window9_setpos] component psd_window9=PSD_monitor_psf_eff() SETTING [PSD_monitor_psf_eff:0]"); stracpy(_psd_window9_var._name, "psd_window9", 16384); stracpy(_psd_window9_var._type, "PSD_monitor_psf_eff", 16384); _psd_window9_var._index=149; int current_setpos_index = 149; _psd_window9_var._parameters.nx = 128; _psd_window9_var._parameters.ny = 128; if("psd_window9.dat" && strlen("psd_window9.dat")) stracpy(_psd_window9_var._parameters.filename, "psd_window9.dat" ? "psd_window9.dat" : "", 16384); else _psd_window9_var._parameters.filename[0]='\0'; _psd_window9_var._parameters.xmin = - det_width / 2.0; _psd_window9_var._parameters.xmax = det_width / 2.0; _psd_window9_var._parameters.ymin = - det_height / 2.0; _psd_window9_var._parameters.ymax = det_height / 2.0; _psd_window9_var._parameters.nowritefile = 0; _psd_window9_var._parameters.xwidth = 0; _psd_window9_var._parameters.yheight = 0; _psd_window9_var._parameters.psf = PSF; _psd_window9_var._parameters.k0 = 1.553; _psd_window9_var._parameters.eff = 0.8; _psd_window9_var._parameters.restore_neutron = 1; /* component psd_window9=PSD_monitor_psf_eff() AT ROTATED */ { Coords tc1, tc2; tc1 = coords_set(0,0,0); tc2 = coords_set(0,0,0); Rotation tr1; rot_set_rotation(tr1,0,0,0); rot_set_rotation(tr1, (0)*DEG2RAD, (180)*DEG2RAD, (0)*DEG2RAD); rot_mul(tr1, _a6_var._rotation_absolute, _psd_window9_var._rotation_absolute); rot_transpose(_emon_window8_var._rotation_absolute, tr1); rot_mul(_psd_window9_var._rotation_absolute, tr1, _psd_window9_var._rotation_relative); _psd_window9_var._rotation_is_identity = rot_test_identity(_psd_window9_var._rotation_relative); tc1 = coords_set( 0, 0, dad + 0.0215); rot_transpose(_a6_var._rotation_absolute, tr1); tc2 = rot_apply(tr1, tc1); _psd_window9_var._position_absolute = coords_add(_a6_var._position_absolute, tc2); tc1 = coords_sub(_emon_window8_var._position_absolute, _psd_window9_var._position_absolute); _psd_window9_var._position_relative = rot_apply(_psd_window9_var._rotation_absolute, tc1); } /* psd_window9=PSD_monitor_psf_eff() AT ROTATED */ DEBUG_COMPONENT("psd_window9", _psd_window9_var._position_absolute, _psd_window9_var._rotation_absolute); instrument->_position_absolute[149] = _psd_window9_var._position_absolute; instrument->_position_relative[149] = _psd_window9_var._position_relative; _psd_window9_var._position_relative_is_zero = coords_test_zero(_psd_window9_var._position_relative); instrument->counter_N[149] = instrument->counter_P[149] = instrument->counter_P2[149] = 0; instrument->counter_AbsorbProp[149]= 0; #ifdef USE_NEXUS if(nxhandle) { if ((!mcdotrace) && mcformat && strcasestr(mcformat, "NeXus")) { MPI_MASTER( mccomp_placement_type_nexus(nxhandle,"0148_psd_window9", _psd_window9_var._position_absolute, _psd_window9_var._rotation_absolute, "PSD_monitor_psf_eff"); mccomp_param_nexus(nxhandle,"0148_psd_window9", "nx", "90", "128","int"); mccomp_param_nexus(nxhandle,"0148_psd_window9", "ny", "90", "128","int"); mccomp_param_nexus(nxhandle,"0148_psd_window9", "filename", 0, "psd_window9.dat", "char*"); mccomp_param_nexus(nxhandle,"0148_psd_window9", "xmin", "0", "- det_width / 2.0","MCNUM"); mccomp_param_nexus(nxhandle,"0148_psd_window9", "xmax", "0", "det_width / 2.0","MCNUM"); mccomp_param_nexus(nxhandle,"0148_psd_window9", "ymin", "0", "- det_height / 2.0","MCNUM"); mccomp_param_nexus(nxhandle,"0148_psd_window9", "ymax", "0", "det_height / 2.0","MCNUM"); mccomp_param_nexus(nxhandle,"0148_psd_window9", "nowritefile", "0", "0","int"); mccomp_param_nexus(nxhandle,"0148_psd_window9", "xwidth", "0", "0","MCNUM"); mccomp_param_nexus(nxhandle,"0148_psd_window9", "yheight", "0", "0","MCNUM"); mccomp_param_nexus(nxhandle,"0148_psd_window9", "psf", "0", "PSF","MCNUM"); mccomp_param_nexus(nxhandle,"0148_psd_window9", "k0", "1", "1.553","MCNUM"); mccomp_param_nexus(nxhandle,"0148_psd_window9", "eff", "1", "0.8","MCNUM"); mccomp_param_nexus(nxhandle,"0148_psd_window9", "restore_neutron", "0", "1","int"); ); } } else { // fprintf(stderr,"NO NEXUS FILE"); } #endif return(0); } /* _psd_window9_setpos */ /* component emon_window9=E_monitor() SETTING, POSITION/ROTATION */ int _emon_window9_setpos(void) { /* sets initial component parameters, position and rotation */ SIG_MESSAGE("[_emon_window9_setpos] component emon_window9=E_monitor() SETTING [E_monitor:0]"); stracpy(_emon_window9_var._name, "emon_window9", 16384); stracpy(_emon_window9_var._type, "E_monitor", 16384); _emon_window9_var._index=150; int current_setpos_index = 150; _emon_window9_var._parameters.nE = 128; if("window9.dat" && strlen("window9.dat")) stracpy(_emon_window9_var._parameters.filename, "window9.dat" ? "window9.dat" : "", 16384); else _emon_window9_var._parameters.filename[0]='\0'; _emon_window9_var._parameters.xmin = -0.05; _emon_window9_var._parameters.xmax = 0.05; _emon_window9_var._parameters.ymin = -0.05; _emon_window9_var._parameters.ymax = 0.05; _emon_window9_var._parameters.nowritefile = 0; _emon_window9_var._parameters.xwidth = det_width; _emon_window9_var._parameters.yheight = det_height; _emon_window9_var._parameters.Emin = eminf; _emon_window9_var._parameters.Emax = emaxf; _emon_window9_var._parameters.restore_neutron = 1; /* component emon_window9=E_monitor() AT ROTATED */ { Coords tc1, tc2; tc1 = coords_set(0,0,0); tc2 = coords_set(0,0,0); Rotation tr1; rot_set_rotation(tr1,0,0,0); rot_set_rotation(tr1, (0)*DEG2RAD, (180)*DEG2RAD, (0)*DEG2RAD); rot_mul(tr1, _a6_var._rotation_absolute, _emon_window9_var._rotation_absolute); rot_transpose(_psd_window9_var._rotation_absolute, tr1); rot_mul(_emon_window9_var._rotation_absolute, tr1, _emon_window9_var._rotation_relative); _emon_window9_var._rotation_is_identity = rot_test_identity(_emon_window9_var._rotation_relative); tc1 = coords_set( 0, 0, dad + 0.0215); rot_transpose(_a6_var._rotation_absolute, tr1); tc2 = rot_apply(tr1, tc1); _emon_window9_var._position_absolute = coords_add(_a6_var._position_absolute, tc2); tc1 = coords_sub(_psd_window9_var._position_absolute, _emon_window9_var._position_absolute); _emon_window9_var._position_relative = rot_apply(_emon_window9_var._rotation_absolute, tc1); } /* emon_window9=E_monitor() AT ROTATED */ DEBUG_COMPONENT("emon_window9", _emon_window9_var._position_absolute, _emon_window9_var._rotation_absolute); instrument->_position_absolute[150] = _emon_window9_var._position_absolute; instrument->_position_relative[150] = _emon_window9_var._position_relative; _emon_window9_var._position_relative_is_zero = coords_test_zero(_emon_window9_var._position_relative); instrument->counter_N[150] = instrument->counter_P[150] = instrument->counter_P2[150] = 0; instrument->counter_AbsorbProp[150]= 0; #ifdef USE_NEXUS if(nxhandle) { if ((!mcdotrace) && mcformat && strcasestr(mcformat, "NeXus")) { MPI_MASTER( mccomp_placement_type_nexus(nxhandle,"0149_emon_window9", _emon_window9_var._position_absolute, _emon_window9_var._rotation_absolute, "E_monitor"); mccomp_param_nexus(nxhandle,"0149_emon_window9", "nE", "20", "128","int"); mccomp_param_nexus(nxhandle,"0149_emon_window9", "filename", 0, "window9.dat", "char*"); mccomp_param_nexus(nxhandle,"0149_emon_window9", "xmin", "-0.05", "-0.05","MCNUM"); mccomp_param_nexus(nxhandle,"0149_emon_window9", "xmax", "0.05", "0.05","MCNUM"); mccomp_param_nexus(nxhandle,"0149_emon_window9", "ymin", "-0.05", "-0.05","MCNUM"); mccomp_param_nexus(nxhandle,"0149_emon_window9", "ymax", "0.05", "0.05","MCNUM"); mccomp_param_nexus(nxhandle,"0149_emon_window9", "nowritefile", "0", "0","int"); mccomp_param_nexus(nxhandle,"0149_emon_window9", "xwidth", "0", "det_width","MCNUM"); mccomp_param_nexus(nxhandle,"0149_emon_window9", "yheight", "0", "det_height","MCNUM"); mccomp_param_nexus(nxhandle,"0149_emon_window9", "Emin", "NONE", "eminf","MCNUM"); mccomp_param_nexus(nxhandle,"0149_emon_window9", "Emax", "NONE", "emaxf","MCNUM"); mccomp_param_nexus(nxhandle,"0149_emon_window9", "restore_neutron", "0", "1","int"); ); } } else { // fprintf(stderr,"NO NEXUS FILE"); } #endif return(0); } /* _emon_window9_setpos */ _class_Progress_bar *class_Progress_bar_init(_class_Progress_bar *_comp ) { #define profile (_comp->_parameters.profile) #define percent (_comp->_parameters.percent) #define flag_save (_comp->_parameters.flag_save) #define minutes (_comp->_parameters.minutes) #define IntermediateCnts (_comp->_parameters.IntermediateCnts) #define StartTime (_comp->_parameters.StartTime) #define EndTime (_comp->_parameters.EndTime) #define CurrentTime (_comp->_parameters.CurrentTime) #define infostring (_comp->_parameters.infostring) SIG_MESSAGE("[_armSource_init] component armSource=Progress_bar() INITIALISE [Progress_bar:0]"); IntermediateCnts = 0; StartTime = 0; EndTime = 0; CurrentTime = 0; fprintf (stdout, "[%s] Initialize\n", instrument_name); if (percent * mcget_ncount () / 100 < 1e5) { percent = 1e5 * 100.0 / mcget_ncount (); } #ifdef OPENACC time (&StartTime); #endif #ifdef USE_MPI sprintf (infostring, "(%i MPI processes) ", mpi_node_count); #else sprintf (infostring, "(single process) "); #endif #undef profile #undef percent #undef flag_save #undef minutes #undef IntermediateCnts #undef StartTime #undef EndTime #undef CurrentTime #undef infostring return(_comp); } /* class_Progress_bar_init */ _class_Source_gen4 *class_Source_gen4_init(_class_Source_gen4 *_comp ) { #define flux_file (_comp->_parameters.flux_file) #define xdiv_file (_comp->_parameters.xdiv_file) #define ydiv_file (_comp->_parameters.ydiv_file) #define radius (_comp->_parameters.radius) #define dist (_comp->_parameters.dist) #define xw (_comp->_parameters.xw) #define yh (_comp->_parameters.yh) #define E0 (_comp->_parameters.E0) #define dE (_comp->_parameters.dE) #define Lambda0 (_comp->_parameters.Lambda0) #define dLambda (_comp->_parameters.dLambda) #define I1 (_comp->_parameters.I1) #define h (_comp->_parameters.h) #define w (_comp->_parameters.w) #define gaussian (_comp->_parameters.gaussian) #define verbose (_comp->_parameters.verbose) #define T1 (_comp->_parameters.T1) #define flux_file_perAA (_comp->_parameters.flux_file_perAA) #define flux_file_log (_comp->_parameters.flux_file_log) #define Lmin (_comp->_parameters.Lmin) #define Lmax (_comp->_parameters.Lmax) #define Emin (_comp->_parameters.Emin) #define Emax (_comp->_parameters.Emax) #define T2 (_comp->_parameters.T2) #define I2 (_comp->_parameters.I2) #define T3 (_comp->_parameters.T3) #define I3 (_comp->_parameters.I3) #define length (_comp->_parameters.length) #define phi_init (_comp->_parameters.phi_init) #define theta_init (_comp->_parameters.theta_init) #define HEtailA (_comp->_parameters.HEtailA) #define HEtailL0 (_comp->_parameters.HEtailL0) #define pTable (_comp->_parameters.pTable) #define pTable_x (_comp->_parameters.pTable_x) #define pTable_y (_comp->_parameters.pTable_y) #define p_in (_comp->_parameters.p_in) #define lambda0 (_comp->_parameters.lambda0) #define lambda02 (_comp->_parameters.lambda02) #define lambda0b (_comp->_parameters.lambda0b) #define lambda02b (_comp->_parameters.lambda02b) #define lambda0c (_comp->_parameters.lambda0c) #define lambda02c (_comp->_parameters.lambda02c) #define L2P (_comp->_parameters.L2P) #define L2Pb (_comp->_parameters.L2Pb) #define L2Pc (_comp->_parameters.L2Pc) #define pTable_xmin (_comp->_parameters.pTable_xmin) #define pTable_ymin (_comp->_parameters.pTable_ymin) #define pTable_xmax (_comp->_parameters.pTable_xmax) #define pTable_ymax (_comp->_parameters.pTable_ymax) #define pTable_xsum (_comp->_parameters.pTable_xsum) #define pTable_ysum (_comp->_parameters.pTable_ysum) #define pTable_dxmin (_comp->_parameters.pTable_dxmin) #define pTable_dxmax (_comp->_parameters.pTable_dxmax) #define pTable_dymin (_comp->_parameters.pTable_dymin) #define pTable_dymax (_comp->_parameters.pTable_dymax) SIG_MESSAGE("[_source_init] component source=Source_gen4() INITIALISE [Source_gen4:0]"); double source_area, k; pTable_xsum = pTable_ysum = 0; /* spectrum characteristics */ if (flux_file && strlen (flux_file) > 0) { if (Table_Read (&pTable, flux_file, 1) <= 0) /* read 1st block data from file into pTable */ exit (fprintf (stderr, "Source_gen: %s: can not read file %s\n", NAME_CURRENT_COMP, flux_file)); /* put table in Log scale */ int i; if (pTable.columns < 2) exit (fprintf (stderr, "Source_gen: %s: Flux file %s should contain at least 2 columns\n", NAME_CURRENT_COMP, flux_file)); double table_lmin = FLT_MAX, table_lmax = -FLT_MAX; double tmin = FLT_MAX, tmax = -FLT_MAX; for (i = 0; i < pTable.rows; i++) { double val = Table_Index (pTable, i, 1); val = Table_Index (pTable, i, 0); /* lambda */ if (val > tmax) tmax = val; if (val < tmin) tmin = val; } for (i = 0; i < pTable.rows; i++) { double val = Table_Index (pTable, i, 1); if (val < 0) fprintf (stderr, "Source_gen: %s: File %s has negative flux at row %i\n", NAME_CURRENT_COMP, flux_file, i + 1); if (flux_file_log) val = log (val > 0 ? val : tmin / 10); Table_SetElement (&pTable, i, 1, val); val = Table_Index (pTable, i, 0); /* lambda */ if (val > table_lmax) table_lmax = val; if (val < table_lmin) table_lmin = val; } if (!Lmin && !Lmax && !Lambda0 && !dLambda && !E0 && !dE && !Emin && !Emax) { Lmin = table_lmin; Lmax = table_lmax; } if (Lmax > table_lmax) { if (verbose) fprintf (stderr, "Source_gen: %s: Maximum wavelength %g is beyond table range upper limit %g. Constraining.\n", NAME_CURRENT_COMP, Lmax, table_lmax); Lmax = table_lmax; } if (Lmin < table_lmin) { if (verbose) fprintf (stderr, "Source_gen: %s: Minimum wavelength %g is below table range lower limit %g. Constraining.\n", NAME_CURRENT_COMP, Lmin, table_lmin); Lmin = table_lmin; } } else { k = 1.38066e-23; /* k_B */ if (T1 > 0) { lambda0 = 1.0e10 * sqrt (HBAR * HBAR * 4.0 * PI * PI / 2.0 / MNEUTRON / k / T1); lambda02 = lambda0 * lambda0; L2P = 2 * lambda02 * lambda02; } else { lambda0 = Lambda0; } if (T2 > 0) { lambda0b = 1.0e10 * sqrt (HBAR * HBAR * 4.0 * PI * PI / 2.0 / MNEUTRON / k / T2); lambda02b = lambda0b * lambda0b; L2Pb = 2 * lambda02b * lambda02b; } else { lambda0b = Lambda0; } if (T3 > 0) { lambda0c = 1.0e10 * sqrt (HBAR * HBAR * 4.0 * PI * PI / 2.0 / MNEUTRON / k / T3); lambda02c = lambda0c * lambda0c; L2Pc = 2 * lambda02c * lambda02c; } else { lambda0c = Lambda0; } } /* now read position-divergence files, if any */ if (xdiv_file && strlen (xdiv_file) > 0) { int i, j; if (Table_Read (&pTable_x, xdiv_file, 1) <= 0) /* read 1st block data from file into pTable */ exit (fprintf (stderr, "Source_gen: %s: can not read file %s\n", NAME_CURRENT_COMP, xdiv_file)); pTable_xsum = 0; for (i = 0; i < pTable_x.rows; i++) for (j = 0; j < pTable_x.columns; j++) pTable_xsum += Table_Index (pTable_x, i, j); /* now extract limits */ char** parsing; char xylimits[1024]; strcpy (xylimits, ""); parsing = Table_ParseHeader (pTable_x.header, "xlimits", "xylimits", NULL); if (parsing) { if (parsing[0]) strcpy (xylimits, str_dup_numeric (parsing[0])); if (parsing[1] && !strlen (xylimits)) strcpy (xylimits, str_dup_numeric (parsing[1])); for (i = 0; i <= 1; i++) { if (parsing[i]) free (parsing[i]); } free (parsing); } i = sscanf (xylimits, "%lg %lg %lg %lg", &(pTable_xmin), &(pTable_xmax), &(pTable_dxmin), &(pTable_dxmax)); if (i != 2 && i != 4 && verbose) fprintf (stderr, "Source_gen: %s: invalid xylimits '%s' from file %s. extracted %i values\n", NAME_CURRENT_COMP, xylimits, xdiv_file, i); if (!w) w = pTable_xmax - pTable_xmin; if (!xw && !dist) xw = fabs (pTable_dxmax - pTable_dxmin); } if (ydiv_file && strlen (ydiv_file) > 0) { int i, j; if (Table_Read (&pTable_y, ydiv_file, 1) <= 0) /* read 1st block data from file into pTable */ exit (fprintf (stderr, "Source_gen: %s: can not read file %s\n", NAME_CURRENT_COMP, ydiv_file)); pTable_ysum = 0; for (i = 0; i < pTable_y.rows; i++) for (j = 0; j < pTable_y.columns; j++) pTable_ysum += Table_Index (pTable_y, i, j); /* now extract limits */ char** parsing; char xylimits[1024]; strcpy (xylimits, ""); parsing = Table_ParseHeader (pTable_y.header, "xlimits", "xylimits", NULL); if (parsing) { if (parsing[0]) strcpy (xylimits, str_dup_numeric (parsing[0])); if (parsing[1] && !strlen (xylimits)) strcpy (xylimits, str_dup_numeric (parsing[1])); for (i = 0; i <= 1; i++) { if (parsing[i]) free (parsing[i]); } free (parsing); } i = sscanf (xylimits, "%lg %lg %lg %lg", &(pTable_ymin), &(pTable_ymax), &(pTable_dymin), &(pTable_dymax)); if (i != 2 && i != 4 && verbose) fprintf (stderr, "Source_gen: %s: invalid xylimits '%s' from file %s. extracted %i values\n", NAME_CURRENT_COMP, xylimits, ydiv_file, i); if (!h) h = pTable_ymax - pTable_ymin; if (!yh && !dist) yh = fabs (pTable_dymax - pTable_dymin); } /* tests for parameter values */ if (Emin < 0 || Emax < 0 || Lmin < 0 || Lmax < 0 || E0 < 0 || dE < 0 || Lambda0 < 0 || dLambda < 0) { fprintf (stderr, "Source_gen: %s: Error: Negative average\n" " or range values for wavelength or energy encountered\n", NAME_CURRENT_COMP); exit (-1); } if ((Emin == 0 && Emax > 0) || (dE > 0 && dE >= E0)) { fprintf (stderr, "Source_gen: %s: Error: minimal energy cannot be less or equal zero\n", NAME_CURRENT_COMP); exit (-1); } if ((Emax >= Emin) && (Emin > 0)) { E0 = (Emax + Emin) / 2; dE = (Emax - Emin) / 2; } if ((E0 > dE) && (dE >= 0)) { Lmin = sqrt (81.81 / (E0 + dE)); /* Angstroem */ Lmax = sqrt (81.81 / (E0 - dE)); } if (Lmax > 0) { Lambda0 = (Lmax + Lmin) / 2; dLambda = (Lmax - Lmin) / 2; } if ((Lambda0 < dLambda) || (dLambda < 0)) { fprintf (stderr, "Source_gen: %s: Error: Wavelength range %.3f +/- %.3f AA calculated \n", NAME_CURRENT_COMP, Lambda0, dLambda); fprintf (stderr, "- whole wavelength range must be >= 0 \n"); fprintf (stderr, "- range must be > 0; otherwise intensity gets zero, use other sources in this case \n\n"); exit (-1); } radius = fabs (radius); w = fabs (w); h = fabs (h); I1 = fabs (I1); Lambda0 = fabs (Lambda0); dLambda = fabs (dLambda); xw = fabs (xw); yh = fabs (yh); dist = fabs (dist); if (dist == 0) { fprintf (stderr, "Source_gen: %s: warning: focusing distance is null.\n" " xw and yh interpreted as full divergence in [deg]\n", NAME_CURRENT_COMP); } Lmin = Lambda0 - dLambda; /* Angstroem */ Lmax = Lambda0 + dLambda; /* compute initial weight factor p_in to get [n/s] */ if ((I1 > 0 && T1 >= 0) || (flux_file && strlen (flux_file) > 0)) { /* the I1,2,3 are usually in [n/s/cm2/st/AA] */ if (radius) source_area = radius * radius * PI * 1e4; /* circular cm^2 */ else source_area = h * w * 1e4; /* square cm^2 */ p_in = source_area; /* cm2 */ p_in *= (Lmax - Lmin); /* AA. 1 bin=AA/n */ if (flux_file && strlen (flux_file) && !flux_file_perAA) p_in *= pTable.rows / (Lmax - Lmin); } else p_in = (I1 > 0 ? I1 : 1) / 4 / PI; /* Small angle approx. */ p_in /= mcget_ncount (); if (!T1 && I1) p_in *= I1; if (radius == 0 && h == 0 && w == 0) { fprintf (stderr, "Source_gen: %s: Error: Please specify source geometry (radius, h, w)\n", NAME_CURRENT_COMP); exit (-1); } if (xw * yh == 0) { fprintf (stderr, "Source_gen: %s: Error: Please specify source target (xw, yh)\n", NAME_CURRENT_COMP); exit (-1); } if (verbose) { printf ("Source_gen: component %s ", NAME_CURRENT_COMP); if ((h == 0) || (w == 0)) printf ("(disk, radius=%g)", radius); else printf ("(square %g x %g)", h, w); printf ("\n spectra "); printf ("%.3f to %.3f AA (%.3f to %.3f meV)", Lmin, Lmax, 81.81 / Lmax / Lmax, 81.81 / Lmin / Lmin); if (gaussian) printf (", gaussian divergence beam"); printf ("\n"); if (flux_file && strlen (flux_file) > 0) { printf (" File %s for flux distribution used. Flux is dPhi/dLambda in [n/s/AA]. \n", flux_file); Table_Info (pTable); } else if (T1 >= 0 && I1) { if (T1 != 0) printf (" T1=%.1f K (%.3f AA)", T1, lambda0); if (T2 * I2 != 0) printf (", T2=%.1f K (%.3f AA)", T2, lambda0b); if (T3 * I3 != 0) printf (", T3=%.1f K (%.3f AA)", T3, lambda0c); if (T1) printf ("\n"); printf (" Flux is dPhi/dLambda in [n/s/cm2].\n"); } else { printf (" Flux is Phi in [n/s].\n"); } if (xdiv_file && strlen (xdiv_file) > 0) printf (" File %s x=[%g:%g] [m] xdiv=[%g:%g] [deg] used as horizontal phase space distribution.\n", xdiv_file, pTable_xmin, pTable_xmax, pTable_dxmin, pTable_dxmax); if (ydiv_file && strlen (ydiv_file) > 0) printf (" File %s y=[%g:%g] [m] ydiv=[%g:%g] [deg] used as vertical phase space distribution.\n", ydiv_file, pTable_ymin, pTable_ymax, pTable_dymin, pTable_dymax); } else if (verbose == -1) printf ("Source_gen: component %s inactivated", NAME_CURRENT_COMP); #undef flux_file #undef xdiv_file #undef ydiv_file #undef radius #undef dist #undef xw #undef yh #undef E0 #undef dE #undef Lambda0 #undef dLambda #undef I1 #undef h #undef w #undef gaussian #undef verbose #undef T1 #undef flux_file_perAA #undef flux_file_log #undef Lmin #undef Lmax #undef Emin #undef Emax #undef T2 #undef I2 #undef T3 #undef I3 #undef length #undef phi_init #undef theta_init #undef HEtailA #undef HEtailL0 #undef pTable #undef pTable_x #undef pTable_y #undef p_in #undef lambda0 #undef lambda02 #undef lambda0b #undef lambda02b #undef lambda0c #undef lambda02c #undef L2P #undef L2Pb #undef L2Pc #undef pTable_xmin #undef pTable_ymin #undef pTable_xmax #undef pTable_ymax #undef pTable_xsum #undef pTable_ysum #undef pTable_dxmin #undef pTable_dxmax #undef pTable_dymin #undef pTable_dymax return(_comp); } /* class_Source_gen4_init */ _class_Slit *class_Slit_init(_class_Slit *_comp ) { #define xmin (_comp->_parameters.xmin) #define xmax (_comp->_parameters.xmax) #define ymin (_comp->_parameters.ymin) #define ymax (_comp->_parameters.ymax) #define radius (_comp->_parameters.radius) #define xwidth (_comp->_parameters.xwidth) #define yheight (_comp->_parameters.yheight) #define isradial (_comp->_parameters.isradial) SIG_MESSAGE("[_slitGuideBegin_init] component slitGuideBegin=Slit() INITIALISE [Slit:0]"); if (is_unset (radius)) { isradial = 0; if (all_set (3, xwidth, xmin, xmax)) { slit_error_if (xwidth != xmax - xmin, "specifying xwidth, xmin and xmax requires consistent parameters", NAME_CURRENT_COMP); } else { slit_error_if (is_unset (xwidth) && any_unset (2, xmin, xmax), "specify either xwidth or xmin & xmax", NAME_CURRENT_COMP); } if (all_set (3, yheight, ymin, ymax)) { slit_error_if (yheight != ymax - ymin, "specifying yheight, ymin and ymax requires consistent parameters", NAME_CURRENT_COMP); } else { slit_error_if (is_unset (yheight) && any_unset (2, ymin, ymax), "specify either yheight or ymin & ymax", NAME_CURRENT_COMP); } if (is_unset (xmin)) { // xmax also unset but xwidth *is* set xmax = xwidth / 2; xmin = -xmax; } if (is_unset (ymin)) { // ymax also unset but yheight *is* set ymax = yheight / 2; ymin = -ymax; } slit_warning_if (xmin == xmax || ymin == ymax, "Running with CLOSED rectangular slit - is this intentional?", NAME_CURRENT_COMP); } else { isradial = 1; slit_error_if (any_set (6, xwidth, xmin, xmax, yheight, ymin, ymax), "specify radius OR width and height parameters", NAME_CURRENT_COMP); slit_warning_if (radius == 0., "Running with CLOSED radial slit - is this intentional?", NAME_CURRENT_COMP); } #undef xmin #undef xmax #undef ymin #undef ymax #undef radius #undef xwidth #undef yheight #undef isradial return(_comp); } /* class_Slit_init */ _class_L_monitor *class_L_monitor_init(_class_L_monitor *_comp ) { #define nL (_comp->_parameters.nL) #define filename (_comp->_parameters.filename) #define nowritefile (_comp->_parameters.nowritefile) #define xmin (_comp->_parameters.xmin) #define xmax (_comp->_parameters.xmax) #define ymin (_comp->_parameters.ymin) #define ymax (_comp->_parameters.ymax) #define xwidth (_comp->_parameters.xwidth) #define yheight (_comp->_parameters.yheight) #define Lmin (_comp->_parameters.Lmin) #define Lmax (_comp->_parameters.Lmax) #define restore_neutron (_comp->_parameters.restore_neutron) #define L_N (_comp->_parameters.L_N) #define L_p (_comp->_parameters.L_p) #define L_p2 (_comp->_parameters.L_p2) SIG_MESSAGE("[_lmon_guide_start_init] component lmon_guide_start=L_monitor() INITIALISE [L_monitor:0]"); if (xwidth > 0) { xmax = xwidth / 2; xmin = -xmax; } if (yheight > 0) { ymax = yheight / 2; ymin = -ymax; } if ((xmin >= xmax) || (ymin >= ymax)) { printf ("L_monitor: %s: Null detection area !\n" "ERROR (xwidth,yheight,xmin,xmax,ymin,ymax). Exiting", NAME_CURRENT_COMP); exit (0); } L_N = create_darr1d (nL); L_p = create_darr1d (nL); L_p2 = create_darr1d (nL); // Use instance name for monitor output if no input was given if (!strcmp (filename, "\0")) sprintf (filename, "%s", NAME_CURRENT_COMP); #undef nL #undef filename #undef nowritefile #undef xmin #undef xmax #undef ymin #undef ymax #undef xwidth #undef yheight #undef Lmin #undef Lmax #undef restore_neutron #undef L_N #undef L_p #undef L_p2 return(_comp); } /* class_L_monitor_init */ _class_Guide *class_Guide_init(_class_Guide *_comp ) { #define reflect (_comp->_parameters.reflect) #define w1 (_comp->_parameters.w1) #define h1 (_comp->_parameters.h1) #define w2 (_comp->_parameters.w2) #define h2 (_comp->_parameters.h2) #define l (_comp->_parameters.l) #define R0 (_comp->_parameters.R0) #define Qc (_comp->_parameters.Qc) #define alpha (_comp->_parameters.alpha) #define m (_comp->_parameters.m) #define W (_comp->_parameters.W) #define pTable (_comp->_parameters.pTable) #define table_present (_comp->_parameters.table_present) SIG_MESSAGE("[_guideStraight_init] component guideStraight=Guide() INITIALISE [Guide:0]"); if (mcgravitation) fprintf (stderr, "WARNING: Guide: %s: " "This component produces wrong results with gravitation !\n" "Use Guide_gravity.\n", NAME_CURRENT_COMP); if (!w2) w2 = w1; if (!h2) h2 = h1; if (reflect && strlen (reflect) && strcmp (reflect, "NULL") && strcmp (reflect, "0")) { if (Table_Read (&pTable, reflect, 1) <= 0) /* read 1st block data from file into pTable */ exit (fprintf (stderr, "Guide: %s: can not read file %s\n", NAME_CURRENT_COMP, reflect)); table_present = 1; } else { table_present = 0; if (W < 0 || R0 < 0 || Qc < 0 || m < 0) { fprintf (stderr, "Guide: %s: W R0 Qc must be >0.\n", NAME_CURRENT_COMP); exit (-1); } } #undef reflect #undef w1 #undef h1 #undef w2 #undef h2 #undef l #undef R0 #undef Qc #undef alpha #undef m #undef W #undef pTable #undef table_present return(_comp); } /* class_Guide_init */ _class_PSD_monitor *class_PSD_monitor_init(_class_PSD_monitor *_comp ) { #define nx (_comp->_parameters.nx) #define ny (_comp->_parameters.ny) #define filename (_comp->_parameters.filename) #define xmin (_comp->_parameters.xmin) #define xmax (_comp->_parameters.xmax) #define ymin (_comp->_parameters.ymin) #define ymax (_comp->_parameters.ymax) #define xwidth (_comp->_parameters.xwidth) #define yheight (_comp->_parameters.yheight) #define restore_neutron (_comp->_parameters.restore_neutron) #define nowritefile (_comp->_parameters.nowritefile) #define PSD_N (_comp->_parameters.PSD_N) #define PSD_p (_comp->_parameters.PSD_p) #define PSD_p2 (_comp->_parameters.PSD_p2) SIG_MESSAGE("[_psd_guide_end_init] component psd_guide_end=PSD_monitor() INITIALISE [PSD_monitor:0]"); if (xwidth > 0) { xmax = xwidth / 2; xmin = -xmax; } if (yheight > 0) { ymax = yheight / 2; ymin = -ymax; } if ((xmin >= xmax) || (ymin >= ymax)) { printf ("PSD_monitor: %s: Null detection area !\n" "ERROR (xwidth,yheight,xmin,xmax,ymin,ymax). Exiting", NAME_CURRENT_COMP); exit (0); } PSD_N = create_darr2d (nx, ny); PSD_p = create_darr2d (nx, ny); PSD_p2 = create_darr2d (nx, ny); // Use instance name for monitor output if no input was given if (!strcmp (filename, "\0")) sprintf (filename, "%s", NAME_CURRENT_COMP); #undef nx #undef ny #undef filename #undef xmin #undef xmax #undef ymin #undef ymax #undef xwidth #undef yheight #undef restore_neutron #undef nowritefile #undef PSD_N #undef PSD_p #undef PSD_p2 return(_comp); } /* class_PSD_monitor_init */ _class_E_monitor *class_E_monitor_init(_class_E_monitor *_comp ) { #define nE (_comp->_parameters.nE) #define filename (_comp->_parameters.filename) #define xmin (_comp->_parameters.xmin) #define xmax (_comp->_parameters.xmax) #define ymin (_comp->_parameters.ymin) #define ymax (_comp->_parameters.ymax) #define nowritefile (_comp->_parameters.nowritefile) #define xwidth (_comp->_parameters.xwidth) #define yheight (_comp->_parameters.yheight) #define Emin (_comp->_parameters.Emin) #define Emax (_comp->_parameters.Emax) #define restore_neutron (_comp->_parameters.restore_neutron) #define E_N (_comp->_parameters.E_N) #define E_p (_comp->_parameters.E_p) #define E_p2 (_comp->_parameters.E_p2) #define S_p (_comp->_parameters.S_p) #define S_pE (_comp->_parameters.S_pE) #define S_pE2 (_comp->_parameters.S_pE2) SIG_MESSAGE("[_emon_guide_end_init] component emon_guide_end=E_monitor() INITIALISE [E_monitor:0]"); if (xwidth > 0) { xmax = xwidth / 2; xmin = -xmax; } if (yheight > 0) { ymax = yheight / 2; ymin = -ymax; } if ((xmin >= xmax) || (ymin >= ymax)) { printf ("E_monitor: %s: Null detection area !\n" "ERROR (xwidth,yheight,xmin,xmax,ymin,ymax). Exiting", NAME_CURRENT_COMP); exit (0); } E_N = create_darr1d (nE); E_p = create_darr1d (nE); E_p2 = create_darr1d (nE); S_p = S_pE = S_pE2 = 0; // Use instance name for monitor output if no input was given if (!strcmp (filename, "\0")) sprintf (filename, "%s", NAME_CURRENT_COMP); #undef nE #undef filename #undef xmin #undef xmax #undef ymin #undef ymax #undef nowritefile #undef xwidth #undef yheight #undef Emin #undef Emax #undef restore_neutron #undef E_N #undef E_p #undef E_p2 #undef S_p #undef S_pE #undef S_pE2 return(_comp); } /* class_E_monitor_init */ _class_Divergence_monitor *class_Divergence_monitor_init(_class_Divergence_monitor *_comp ) { #define nh (_comp->_parameters.nh) #define nv (_comp->_parameters.nv) #define filename (_comp->_parameters.filename) #define xmin (_comp->_parameters.xmin) #define xmax (_comp->_parameters.xmax) #define ymin (_comp->_parameters.ymin) #define ymax (_comp->_parameters.ymax) #define nowritefile (_comp->_parameters.nowritefile) #define xwidth (_comp->_parameters.xwidth) #define yheight (_comp->_parameters.yheight) #define maxdiv_h (_comp->_parameters.maxdiv_h) #define maxdiv_v (_comp->_parameters.maxdiv_v) #define restore_neutron (_comp->_parameters.restore_neutron) #define nx (_comp->_parameters.nx) #define ny (_comp->_parameters.ny) #define nz (_comp->_parameters.nz) #define Div_N (_comp->_parameters.Div_N) #define Div_p (_comp->_parameters.Div_p) #define Div_p2 (_comp->_parameters.Div_p2) SIG_MESSAGE("[_divmon_guide_end_init] component divmon_guide_end=Divergence_monitor() INITIALISE [Divergence_monitor:0]"); if (xwidth > 0) { xmax = xwidth / 2; xmin = -xmax; } if (yheight > 0) { ymax = yheight / 2; ymin = -ymax; } if ((xmin >= xmax) || (ymin >= ymax)) { printf ("Divergence_monitor: %s: Null detection area !\n" "ERROR (xwidth,yheight,xmin,xmax,ymin,ymax). Exiting", NAME_CURRENT_COMP); exit (0); } Div_N = create_darr2d (nh, nv); Div_p = create_darr2d (nh, nv); Div_p2 = create_darr2d (nh, nv); NORM (nx, ny, nz); // Use instance name for monitor output if no input was given if (!strcmp (filename, "\0")) sprintf (filename, "%s", NAME_CURRENT_COMP); #undef nh #undef nv #undef filename #undef xmin #undef xmax #undef ymin #undef ymax #undef nowritefile #undef xwidth #undef yheight #undef maxdiv_h #undef maxdiv_v #undef restore_neutron #undef nx #undef ny #undef nz #undef Div_N #undef Div_p #undef Div_p2 return(_comp); } /* class_Divergence_monitor_init */ _class_Monochromator_curved *class_Monochromator_curved_init(_class_Monochromator_curved *_comp ) { #define reflect (_comp->_parameters.reflect) #define transmit (_comp->_parameters.transmit) #define zwidth (_comp->_parameters.zwidth) #define yheight (_comp->_parameters.yheight) #define gap (_comp->_parameters.gap) #define NH (_comp->_parameters.NH) #define NV (_comp->_parameters.NV) #define mosaich (_comp->_parameters.mosaich) #define mosaicv (_comp->_parameters.mosaicv) #define r0 (_comp->_parameters.r0) #define t0 (_comp->_parameters.t0) #define Q (_comp->_parameters.Q) #define RV (_comp->_parameters.RV) #define RH (_comp->_parameters.RH) #define DM (_comp->_parameters.DM) #define mosaic (_comp->_parameters.mosaic) #define width (_comp->_parameters.width) #define height (_comp->_parameters.height) #define verbose (_comp->_parameters.verbose) #define order (_comp->_parameters.order) #define mos_rms_y (_comp->_parameters.mos_rms_y) #define mos_rms_z (_comp->_parameters.mos_rms_z) #define mos_rms_max (_comp->_parameters.mos_rms_max) #define mono_Q (_comp->_parameters.mono_Q) #define SlabWidth (_comp->_parameters.SlabWidth) #define SlabHeight (_comp->_parameters.SlabHeight) #define rTable (_comp->_parameters.rTable) #define tTable (_comp->_parameters.tTable) #define rTableFlag (_comp->_parameters.rTableFlag) #define tTableFlag (_comp->_parameters.tTableFlag) #define tiltH (_comp->_parameters.tiltH) #define tiltV (_comp->_parameters.tiltV) #define ncol_var (_comp->_parameters.ncol_var) #define nrow_var (_comp->_parameters.nrow_var) SIG_MESSAGE("[_monochromator_curved_init] component monochromator_curved=Monochromator_curved() INITIALISE [Monochromator_curved:0]"); int i; if (mosaic != 0) { mos_rms_y = MIN2RAD * mosaic / sqrt (8 * log (2)); mos_rms_z = mos_rms_y; } else { mos_rms_y = MIN2RAD * mosaich / sqrt (8 * log (2)); mos_rms_z = MIN2RAD * mosaicv / sqrt (8 * log (2)); } mos_rms_max = mos_rms_y > mos_rms_z ? mos_rms_y : mos_rms_z; mono_Q = Q; if (DM != 0) mono_Q = 2 * PI / DM; if (mono_Q <= 0) { fprintf (stderr, "Monochromator_curved: %s: Error scattering vector Q = 0\n", NAME_CURRENT_COMP); exit (-1); } if (r0 < 0) { fprintf (stderr, "Monochromator_curved: %s: Error reflectivity r0 is negative\n", NAME_CURRENT_COMP); exit (-1); } if (r0 == 0) { fprintf (stderr, "Monochromator_curved: %s: Reflectivity r0 is null. Ignoring component.\n", NAME_CURRENT_COMP); } if (NH * NV == 0) { fprintf (stderr, "Monochromator_curved: %s: no slabs ??? (NH or NV=0)\n", NAME_CURRENT_COMP); exit (-1); } if (verbose && r0) { printf ("Monochromator_curved: component %s Q=%.3g Angs-1 (DM=%.4g Angs)\n", NAME_CURRENT_COMP, mono_Q, 2 * PI / mono_Q); if (NH * NV == 1) printf (" flat.\n"); else { if (NH > 1) { printf (" horizontal: %i blades", (int)NH); if (RH != 0) printf (" focusing with RH=%.3g [m]", RH); printf ("\n"); } if (NV > 1) { printf (" vertical: %i blades", (int)NV); if (RV != 0) printf (" focusing with RV=%.3g [m]", RV); printf ("\n"); } } } if (reflect != NULL && r0 && strlen (reflect) && strcmp (reflect, "NULL") && strcmp (reflect, "0")) { if (verbose) fprintf (stdout, "Monochromator_curved: %s: Reflectivity data (k, R) from %s\n", NAME_CURRENT_COMP, reflect); Table_Read (&rTable, reflect, 1); /* read 1st block data from file into rTable */ Table_Rebin (&rTable); /* rebin as evenly, increasing array */ if (rTable.rows < 2) Table_Free (&rTable); if (verbose) Table_Info (rTable); rTableFlag = 1; } else { rTableFlag = 0; } if (transmit != NULL && strlen (transmit) && strcmp (transmit, "NULL") && strcmp (transmit, "0")) { if (verbose) fprintf (stdout, "Monochromator_curved: %s: Transmission data (k, T) from %s\n", NAME_CURRENT_COMP, transmit); Table_Read (&tTable, transmit, 1); /* read 1st block data from file into rTable */ Table_Rebin (&tTable); /* rebin as evenly, increasing array */ if (tTable.rows < 2) Table_Free (&tTable); if (verbose) Table_Info (tTable); tTableFlag = 1; } else { tTableFlag = 0; } if (width == 0) SlabWidth = zwidth; else SlabWidth = (width + gap) / NH - gap; if (height == 0) SlabHeight = yheight; else SlabHeight = (height + gap) / NV - gap; tiltH = calloc ((int)2 * (NH + 1), sizeof (double)); tiltV = calloc ((int)2 * (NV + 1), sizeof (double)); if (!tiltH) printf ("Monochromator_curved: %s: Warning: not enough memory to allocate tilts (NH=%i).\n", NAME_CURRENT_COMP, NH); else if (RH) { /* pre-compute tilts */ for (i = 0; i <= NH; i++) { tiltH[i] = asin ((i - (NH + 1) / 2.0) * (SlabWidth + gap) / RH); } } if (!tiltV) printf ("Monochromator_curved: %s: Warning: not enough memory to allocate tilts (NV=%i).\n", NAME_CURRENT_COMP, NV); else if (RV) { for (i = 0; i <= NV; i++) { tiltV[i] = -asin ((i - (NV + 1) / 2.0) * (SlabHeight + gap) / RV); } } sprintf (ncol_var, "ncol_%ld", _comp->_index); sprintf (nrow_var, "nrow_%ld", _comp->_index); #undef reflect #undef transmit #undef zwidth #undef yheight #undef gap #undef NH #undef NV #undef mosaich #undef mosaicv #undef r0 #undef t0 #undef Q #undef RV #undef RH #undef DM #undef mosaic #undef width #undef height #undef verbose #undef order #undef mos_rms_y #undef mos_rms_z #undef mos_rms_max #undef mono_Q #undef SlabWidth #undef SlabHeight #undef rTable #undef tTable #undef rTableFlag #undef tTableFlag #undef tiltH #undef tiltV #undef ncol_var #undef nrow_var return(_comp); } /* class_Monochromator_curved_init */ _class_Collimator_linear *class_Collimator_linear_init(_class_Collimator_linear *_comp ) { #define xmin (_comp->_parameters.xmin) #define xmax (_comp->_parameters.xmax) #define ymin (_comp->_parameters.ymin) #define ymax (_comp->_parameters.ymax) #define xwidth (_comp->_parameters.xwidth) #define yheight (_comp->_parameters.yheight) #define length (_comp->_parameters.length) #define divergence (_comp->_parameters.divergence) #define transmission (_comp->_parameters.transmission) #define divergenceV (_comp->_parameters.divergenceV) #define slope (_comp->_parameters.slope) #define slopeV (_comp->_parameters.slopeV) SIG_MESSAGE("[_MSCollimator_init] component MSCollimator=Collimator_linear() INITIALISE [Collimator_linear:0]"); slope = tan (MIN2RAD * divergence); slopeV = tan (MIN2RAD * divergenceV); if (xwidth > 0) { xmax = xwidth / 2; xmin = -xmax; } if (yheight > 0) { ymax = yheight / 2; ymin = -ymax; } if ((xmin >= xmax) || (ymin >= ymax)) { printf ("Collimator_linear: %s: Null slit opening area !\n" "ERROR (xwidth,yheight,xmin,xmax,ymin,ymax). Exiting", NAME_CURRENT_COMP); exit (0); } #undef xmin #undef xmax #undef ymin #undef ymax #undef xwidth #undef yheight #undef length #undef divergence #undef transmission #undef divergenceV #undef slope #undef slopeV return(_comp); } /* class_Collimator_linear_init */ _class_Filter_gen *class_Filter_gen_init(_class_Filter_gen *_comp ) { #define filename (_comp->_parameters.filename) #define options (_comp->_parameters.options) #define xmin (_comp->_parameters.xmin) #define xmax (_comp->_parameters.xmax) #define ymin (_comp->_parameters.ymin) #define ymax (_comp->_parameters.ymax) #define xwidth (_comp->_parameters.xwidth) #define yheight (_comp->_parameters.yheight) #define thickness (_comp->_parameters.thickness) #define scaling (_comp->_parameters.scaling) #define verbose (_comp->_parameters.verbose) #define Mode_Table (_comp->_parameters.Mode_Table) #define Type_Table (_comp->_parameters.Type_Table) #define pTable (_comp->_parameters.pTable) SIG_MESSAGE("[_infilter_init] component infilter=Filter_gen() INITIALISE [Filter_gen:0]"); Mode_Table = FLUX_ADAPT_MULT; Type_Table = UNKNOWN_TABLE; if (xwidth > 0) { xmax = xwidth / 2; xmin = -xmax; } if (yheight > 0) { ymax = yheight / 2; ymin = -ymax; } FilterGen_Mode (options, &Mode_Table, &Type_Table, &verbose); if (filename != NULL && strlen (filename) && strcmp (filename, "NULL") && strcmp (filename, "0")) { if (Table_Read (&pTable, filename, 1) <= 0) /* read 1st block data from filename into pTable */ exit (fprintf (stderr, "Filter_gen: %s: can not read filename %s\n", NAME_CURRENT_COMP, filename)); Table_Rebin (&pTable); /* rebin as evenly, increasing array */ if (pTable.rows < 2 || !pTable.step_x) { Table_Free (&pTable); } if (pTable.data) { FilterGen_Mode (pTable.header, &Mode_Table, &Type_Table, &verbose); if (verbose) { Table_Info (pTable); printf ("Filter_gen: %s: Filter data [", NAME_CURRENT_COMP); if (Type_Table == ENERGY_TABLE) printf ("Energy"); if (Type_Table == WAVEVECTOR_TABLE) printf ("Wavevector"); if (Type_Table == WAVELENGTH_TABLE) printf ("Wavelength"); if (Type_Table == UNKNOWN_TABLE) printf ("UNKNOWN (not used)"); printf (", Flux] in "); if (Mode_Table == FLUX_ADAPT_MULT) printf ("multiply"); else if (Mode_Table == FLUX_ADAPT_ADD) printf ("add"); else printf ("set"); printf (" mode\n"); } } else fprintf (stderr, "Filter_gen: %s: file %s contains no data.\n", NAME_CURRENT_COMP, filename); } else pTable.data = NULL; #undef filename #undef options #undef xmin #undef xmax #undef ymin #undef ymax #undef xwidth #undef yheight #undef thickness #undef scaling #undef verbose #undef Mode_Table #undef Type_Table #undef pTable return(_comp); } /* class_Filter_gen_init */ _class_Monitor_nD *class_Monitor_nD_init(_class_Monitor_nD *_comp ) { #define user0 (_comp->_parameters.user0) #define user1 (_comp->_parameters.user1) #define user2 (_comp->_parameters.user2) #define user3 (_comp->_parameters.user3) #define user4 (_comp->_parameters.user4) #define user5 (_comp->_parameters.user5) #define user6 (_comp->_parameters.user6) #define user7 (_comp->_parameters.user7) #define user8 (_comp->_parameters.user8) #define user9 (_comp->_parameters.user9) #define xwidth (_comp->_parameters.xwidth) #define yheight (_comp->_parameters.yheight) #define zdepth (_comp->_parameters.zdepth) #define xmin (_comp->_parameters.xmin) #define xmax (_comp->_parameters.xmax) #define ymin (_comp->_parameters.ymin) #define ymax (_comp->_parameters.ymax) #define zmin (_comp->_parameters.zmin) #define zmax (_comp->_parameters.zmax) #define bins (_comp->_parameters.bins) #define min (_comp->_parameters.min) #define max (_comp->_parameters.max) #define restore_neutron (_comp->_parameters.restore_neutron) #define radius (_comp->_parameters.radius) #define options (_comp->_parameters.options) #define filename (_comp->_parameters.filename) #define geometry (_comp->_parameters.geometry) #define nowritefile (_comp->_parameters.nowritefile) #define nexus_bins (_comp->_parameters.nexus_bins) #define username0 (_comp->_parameters.username0) #define username1 (_comp->_parameters.username1) #define username2 (_comp->_parameters.username2) #define username3 (_comp->_parameters.username3) #define username4 (_comp->_parameters.username4) #define username5 (_comp->_parameters.username5) #define username6 (_comp->_parameters.username6) #define username7 (_comp->_parameters.username7) #define username8 (_comp->_parameters.username8) #define username9 (_comp->_parameters.username9) #define DEFS (_comp->_parameters.DEFS) #define Vars (_comp->_parameters.Vars) #define detector (_comp->_parameters.detector) #define offdata (_comp->_parameters.offdata) SIG_MESSAGE("[_OrderMon_init] component OrderMon=Monitor_nD() INITIALISE [Monitor_nD:0]"); char tmp[CHAR_BUF_LENGTH]; strcpy (Vars.compcurname, NAME_CURRENT_COMP); Vars.compcurindex = INDEX_CURRENT_COMP; if (options != NULL) strncpy (Vars.option, options, CHAR_BUF_LENGTH); else { strcpy (Vars.option, "x y"); printf ("Monitor_nD: %s has no option specified. Setting to PSD ('x y') monitor.\n", NAME_CURRENT_COMP); } Vars.compcurpos = POS_A_CURRENT_COMP; if (strstr (Vars.option, "source")) strcat (Vars.option, " list, x y z vx vy vz t sx sy sz "); if (bins) { sprintf (tmp, " all bins=%ld ", (long)bins); strcat (Vars.option, tmp); } if (min > -FLT_MAX && max < FLT_MAX) { sprintf (tmp, " all limits=[%g %g]", min, max); strcat (Vars.option, tmp); } else if (min > -FLT_MAX) { sprintf (tmp, " all min=%g", min); strcat (Vars.option, tmp); } else if (max < FLT_MAX) { sprintf (tmp, " all max=%g", max); strcat (Vars.option, tmp); } /* transfer, "zero", and check username- and user variable strings to Vars struct*/ strncpy (Vars.UserName0, username1&& strlen (username0) && strcmp (username0, "0") && strcmp (username0, "NULL") ? username0 : "", 128); strncpy (Vars.UserName1, username1&& strlen (username1) && strcmp (username1, "0") && strcmp (username1, "NULL") ? username1 : "", 128); strncpy (Vars.UserName2, username2&& strlen (username2) && strcmp (username2, "0") && strcmp (username2, "NULL") ? username2 : "", 128); strncpy (Vars.UserName3, username3&& strlen (username3) && strcmp (username3, "0") && strcmp (username3, "NULL") ? username3 : "", 128); strncpy (Vars.UserName4, username4&& strlen (username4) && strcmp (username4, "0") && strcmp (username4, "NULL") ? username4 : "", 128); strncpy (Vars.UserName5, username5&& strlen (username5) && strcmp (username5, "0") && strcmp (username5, "NULL") ? username5 : "", 128); strncpy (Vars.UserName6, username6&& strlen (username6) && strcmp (username6, "0") && strcmp (username6, "NULL") ? username6 : "", 128); strncpy (Vars.UserName7, username7&& strlen (username7) && strcmp (username7, "0") && strcmp (username7, "NULL") ? username7 : "", 128); strncpy (Vars.UserName8, username8&& strlen (username8) && strcmp (username8, "0") && strcmp (username8, "NULL") ? username8 : "", 128); strncpy (Vars.UserName9, username9&& strlen (username9) && strcmp (username9, "0") && strcmp (username9, "NULL") ? username9 : "", 128); if (user0 && strlen (user0) && strcmp (user0, "0") && strcmp (user0, "NULL")) { strncpy (Vars.UserVariable0, user0, 128); int fail; _class_particle testparticle; particle_getvar (&testparticle, Vars.UserVariable0, &fail); if (fail) { fprintf (stderr, "Warning (%s): user0=%s is unknown. The signal will not be resolved - this is likely not what you intended.\n", NAME_CURRENT_COMP, user0); } } if (user1 && strlen (user1) && strcmp (user1, "0") && strcmp (user1, "NULL")) { strncpy (Vars.UserVariable1, user1, 128); int fail; _class_particle testparticle; particle_getvar (&testparticle, Vars.UserVariable1, &fail); if (fail) { fprintf (stderr, "Warning (%s): user1=%s is unknown. The signal will not be resolved - this is likely not what you intended.\n", NAME_CURRENT_COMP, user1); } } if (user2 && strlen (user2) && strcmp (user2, "0") && strcmp (user2, "NULL")) { strncpy (Vars.UserVariable2, user2, 128); int fail; _class_particle testparticle; particle_getvar (&testparticle, Vars.UserVariable2, &fail); if (fail) { fprintf (stderr, "Warning (%s): user2=%s is unknown. The signal will not be resolved - this is likely not what you intended.\n", NAME_CURRENT_COMP, user2); } } if (user3 && strlen (user3) && strcmp (user3, "0") && strcmp (user3, "NULL")) { strncpy (Vars.UserVariable3, user3, 128); int fail; _class_particle testparticle; particle_getvar (&testparticle, Vars.UserVariable3, &fail); if (fail) { fprintf (stderr, "Warning (%s): user3=%s is unknown. The signal will not be resolved - this is likely not what you intended.\n", NAME_CURRENT_COMP, user3); } } if (user4 && strlen (user4) && strcmp (user4, "0") && strcmp (user4, "NULL")) { strncpy (Vars.UserVariable4, user4, 128); int fail; _class_particle testparticle; particle_getvar (&testparticle, Vars.UserVariable4, &fail); if (fail) { fprintf (stderr, "Warning (%s): user4=%s is unknown. The signal will not be resolved - this is likely not what you intended.\n", NAME_CURRENT_COMP, user4); } } if (user5 && strlen (user5) && strcmp (user5, "0") && strcmp (user5, "NULL")) { strncpy (Vars.UserVariable5, user5, 128); int fail; _class_particle testparticle; particle_getvar (&testparticle, Vars.UserVariable5, &fail); if (fail) { fprintf (stderr, "Warning (%s): user5=%s is unknown. The signal will not be resolved - this is likely not what you intended.\n", NAME_CURRENT_COMP, user5); } } if (user6 && strlen (user6) && strcmp (user6, "0") && strcmp (user6, "NULL")) { strncpy (Vars.UserVariable6, user6, 128); int fail; _class_particle testparticle; particle_getvar (&testparticle, Vars.UserVariable6, &fail); if (fail) { fprintf (stderr, "Warning (%s): user6=%s is unknown. The signal will not be resolved - this is likely not what you intended.\n", NAME_CURRENT_COMP, user6); } } if (user7 && strlen (user7) && strcmp (user7, "0") && strcmp (user7, "NULL")) { strncpy (Vars.UserVariable7, user7, 128); int fail; _class_particle testparticle; particle_getvar (&testparticle, Vars.UserVariable7, &fail); if (fail) { fprintf (stderr, "Warning (%s): user7=%s is unknown. The signal will not be resolved - this is likely not what you intended.\n", NAME_CURRENT_COMP, user7); } } if (user8 && strlen (user8) && strcmp (user8, "0") && strcmp (user8, "NULL")) { strncpy (Vars.UserVariable8, user8, 128); int fail; _class_particle testparticle; particle_getvar (&testparticle, Vars.UserVariable8, &fail); if (fail) { fprintf (stderr, "Warning (%s): user8=%s is unknown. The signal will not be resolved - this is likely not what you intended.\n", NAME_CURRENT_COMP, user8); } } if (user9 && strlen (user9) && strcmp (user9, "0") && strcmp (user9, "NULL")) { strncpy (Vars.UserVariable9, user9, 128); int fail; _class_particle testparticle; particle_getvar (&testparticle, Vars.UserVariable9, &fail); if (fail) { fprintf (stderr, "Warning (%s): user9=%s is unknown. The signal will not be resolved - this is likely not what you intended.\n", NAME_CURRENT_COMP, user9); } } /*sanitize parameters set for curved shapes*/ if (strstr (Vars.option, "cylinder") || strstr (Vars.option, "banana") || strstr (Vars.option, "sphere")) { /*this _is_ an explicit curved shape. Should have a radius. Inherit from xwidth or zdepth (diameters), x has precedence.*/ if (!radius) { if (xwidth) { radius = xwidth / 2.0; } else { radius = zdepth / 2.0; } } else { xwidth = 2 * radius; } if (!yheight) { /*if not set - use the diameter as height for the curved object. This will likely only happen for spheres*/ yheight = 2 * radius; } } else if (radius) { /*radius is set - this must be a curved shape. Infer shape from yheight, and set remaining values (xwidth etc. They are used inside monitor_nd-lib.*/ xwidth = zdepth = 2 * radius; if (yheight) { /*a height is given (and no shape explitly set - assume cylinder*/ strcat (Vars.option, " banana"); } else { strcat (Vars.option, " sphere"); yheight = 2 * radius; } } int offflag = 0; if (geometry && strlen (geometry) && strcmp (geometry, "0") && strcmp (geometry, "NULL")) { #ifndef USE_OFF fprintf (stderr, "Error: You are attempting to use an OFF geometry without -DUSE_OFF. You will need to recompile with that define set!\n"); exit (-1); #else if (!off_init (geometry, xwidth, yheight, zdepth, 1, &offdata)) { printf ("Monitor_nD: %s could not initiate the OFF geometry %s. \n" " Defaulting to normal Monitor dimensions.\n", NAME_CURRENT_COMP, geometry); strcpy (geometry, ""); } else { offflag = 1; } #endif } if (!radius && !xwidth && !yheight && !zdepth && !xmin && !xmax && !ymin && !ymax && !strstr (Vars.option, "previous") && (!geometry || !strlen (geometry))) exit (printf ("Monitor_nD: %s has no dimension specified. Aborting (radius, xwidth, yheight, zdepth, previous, geometry).\n", NAME_CURRENT_COMP)); Monitor_nD_Init (&DEFS, &Vars, xwidth, yheight, zdepth, xmin, xmax, ymin, ymax, zmin, zmax, offflag, nexus_bins); if (Vars.Flag_OFF) { offdata.mantidflag = Vars.Flag_mantid; offdata.mantidoffset = Vars.Coord_Min[Vars.Coord_Number - 1]; } if (filename && strlen (filename) && strcmp (filename, "NULL") && strcmp (filename, "0")) strncpy (Vars.Mon_File, filename, 128); /* check if user given filename with ext will be used more than once */ if (((Vars.Flag_Multiple && Vars.Coord_Number > 1) || Vars.Flag_List) && strchr (Vars.Mon_File, '.')) { char* XY; XY = strrchr (Vars.Mon_File, '.'); *XY = '_'; } if (restore_neutron) Vars.Flag_parallel = 1; detector.m = 0; #ifdef USE_MPI MPI_MASTER (if (strstr (Vars.option, "auto") && mpi_node_count > 1) printf ("Monitor_nD: %s is using automatic limits option 'auto' together with MPI.\n" "WARNING this may create incorrect distributions (but integrated flux will be right).\n", NAME_CURRENT_COMP);); #else #ifdef OPENACC if (strstr (Vars.option, "auto")) printf ("Monitor_nD: %s is requesting automatic limits option 'auto' together with OpenACC.\n" "WARNING this feature is NOT supported using OpenACC and has been disabled!\n", NAME_CURRENT_COMP); #endif #endif #undef user0 #undef user1 #undef user2 #undef user3 #undef user4 #undef user5 #undef user6 #undef user7 #undef user8 #undef user9 #undef xwidth #undef yheight #undef zdepth #undef xmin #undef xmax #undef ymin #undef ymax #undef zmin #undef zmax #undef bins #undef min #undef max #undef restore_neutron #undef radius #undef options #undef filename #undef geometry #undef nowritefile #undef nexus_bins #undef username0 #undef username1 #undef username2 #undef username3 #undef username4 #undef username5 #undef username6 #undef username7 #undef username8 #undef username9 #undef DEFS #undef Vars #undef detector #undef offdata return(_comp); } /* class_Monitor_nD_init */ _class_PSD_monitor_psf_eff *class_PSD_monitor_psf_eff_init(_class_PSD_monitor_psf_eff *_comp ) { #define nx (_comp->_parameters.nx) #define ny (_comp->_parameters.ny) #define filename (_comp->_parameters.filename) #define xmin (_comp->_parameters.xmin) #define xmax (_comp->_parameters.xmax) #define ymin (_comp->_parameters.ymin) #define ymax (_comp->_parameters.ymax) #define nowritefile (_comp->_parameters.nowritefile) #define xwidth (_comp->_parameters.xwidth) #define yheight (_comp->_parameters.yheight) #define psf (_comp->_parameters.psf) #define k0 (_comp->_parameters.k0) #define eff (_comp->_parameters.eff) #define restore_neutron (_comp->_parameters.restore_neutron) #define PSD_N (_comp->_parameters.PSD_N) #define PSD_p (_comp->_parameters.PSD_p) #define PSD_p2 (_comp->_parameters.PSD_p2) #define weight (_comp->_parameters.weight) SIG_MESSAGE("[_kMoni_init] component kMoni=PSD_monitor_psf_eff() INITIALISE [PSD_monitor_psf_eff:0]"); if (xwidth > 0) { xmax = xwidth / 2; xmin = -xmax; } if (yheight > 0) { ymax = yheight / 2; ymin = -ymax; } if ((xmin >= xmax) || (ymin >= ymax)) { printf ("PSD_monitor: %s: Null detection area !\n" "ERROR (xwidth,yheight,xmin,xmax,ymin,ymax). Exiting", NAME_CURRENT_COMP); exit (0); } PSD_N = create_darr2d (nx, ny); PSD_p = create_darr2d (nx, ny); PSD_p2 = create_darr2d (nx, ny); // Use instance name for monitor output if no input was given if (!strcmp (filename, "\0")) sprintf (filename, "%s", NAME_CURRENT_COMP); #undef nx #undef ny #undef filename #undef xmin #undef xmax #undef ymin #undef ymax #undef nowritefile #undef xwidth #undef yheight #undef psf #undef k0 #undef eff #undef restore_neutron #undef PSD_N #undef PSD_p #undef PSD_p2 #undef weight return(_comp); } /* class_PSD_monitor_psf_eff_init */ _class_Incoherent *class_Incoherent_init(_class_Incoherent *_comp ) { #define geometry (_comp->_parameters.geometry) #define radius (_comp->_parameters.radius) #define xwidth (_comp->_parameters.xwidth) #define yheight (_comp->_parameters.yheight) #define zdepth (_comp->_parameters.zdepth) #define thickness (_comp->_parameters.thickness) #define target_x (_comp->_parameters.target_x) #define target_y (_comp->_parameters.target_y) #define target_z (_comp->_parameters.target_z) #define focus_r (_comp->_parameters.focus_r) #define focus_xw (_comp->_parameters.focus_xw) #define focus_yh (_comp->_parameters.focus_yh) #define focus_aw (_comp->_parameters.focus_aw) #define focus_ah (_comp->_parameters.focus_ah) #define target_index (_comp->_parameters.target_index) #define pack (_comp->_parameters.pack) #define p_interact (_comp->_parameters.p_interact) #define f_QE (_comp->_parameters.f_QE) #define gamma (_comp->_parameters.gamma) #define Etrans (_comp->_parameters.Etrans) #define deltaE (_comp->_parameters.deltaE) #define sigma_abs (_comp->_parameters.sigma_abs) #define sigma_inc (_comp->_parameters.sigma_inc) #define Vc (_comp->_parameters.Vc) #define concentric (_comp->_parameters.concentric) #define order (_comp->_parameters.order) #define VarsInc (_comp->_parameters.VarsInc) #define offdata (_comp->_parameters.offdata) SIG_MESSAGE("[_Perspex_init] component Perspex=Incoherent() INITIALISE [Incoherent:0]"); VarsInc.shape = -1; /* -1:no shape, 0:cyl, 1:box, 2:sphere, 3:any-shape */ if (geometry && strlen (geometry) && strcmp (geometry, "NULL") && strcmp (geometry, "0")) { #ifndef USE_OFF fprintf (stderr, "Error: You are attempting to use an OFF geometry without -DUSE_OFF. You will need to recompile with that define set!\n"); exit (-1); #else if (off_init (geometry, xwidth, yheight, zdepth, 0, &offdata)) { VarsInc.shape = 3; thickness = 0; concentric = 0; } #endif } else if (xwidth && yheight && zdepth) VarsInc.shape = 1; /* box */ else if (radius > 0 && yheight) VarsInc.shape = 0; /* cylinder */ else if (radius > 0 && !yheight) VarsInc.shape = 2; /* sphere */ if (VarsInc.shape < 0) exit (fprintf (stderr, "Incoherent: %s: sample has invalid dimensions.\n" "ERROR Please check parameter values (xwidth, yheight, zdepth, radius).\n", NAME_CURRENT_COMP)); if (thickness) { if (radius && (radius < thickness || (yheight && (yheight < 2 * thickness)))) { fprintf (stderr, "Incoherent: %s: hollow sample thickness is larger than its volume (sphere/cylinder).\n" "WARNING Please check parameter values. Using bulk sample (thickness=0).\n", NAME_CURRENT_COMP); thickness = 0; } else if (!radius && (xwidth < 2 * thickness || yheight < 2 * thickness || zdepth < 2 * thickness)) { fprintf (stderr, "Incoherent: %s: hollow sample thickness is larger than its volume (box).\n" "WARNING Please check parameter values. Using bulk sample (thickness=0).\n", NAME_CURRENT_COMP); thickness = 0; } } if (concentric && thickness <= 0) { printf ("Incoherent: %s:Can not use concentric mode\n" "WARNING on non hollow shape. Ignoring.\n", NAME_CURRENT_COMP); concentric = 0; } VarsInc.sigma_a = sigma_abs; VarsInc.sigma_i = sigma_inc; VarsInc.rho = (pack / Vc); VarsInc.my_s = (VarsInc.rho * 100 * VarsInc.sigma_i); VarsInc.my_a_v = (VarsInc.rho * 100 * VarsInc.sigma_a); /* now compute target coords if a component index is supplied */ VarsInc.tx = VarsInc.ty = VarsInc.tz = 0; if (!target_index && !target_x && !target_y && !target_z) target_index = 1; if (target_index) { Coords ToTarget; ToTarget = coords_sub (POS_A_COMP_INDEX (INDEX_CURRENT_COMP + target_index), POS_A_CURRENT_COMP); ToTarget = rot_apply (ROT_A_CURRENT_COMP, ToTarget); coords_get (ToTarget, &VarsInc.tx, &VarsInc.ty, &VarsInc.tz); } else { VarsInc.tx = target_x; VarsInc.ty = target_y; VarsInc.tz = target_z; } if (!(VarsInc.tx || VarsInc.ty || VarsInc.tz)) { MPI_MASTER (printf ("Incoherent: %s: The target is not defined. Using direct beam (Z-axis).\n", NAME_CURRENT_COMP);); VarsInc.tz = 1; } /* different ways of setting rectangular area */ VarsInc.aw = VarsInc.ah = 0; if (focus_xw) { VarsInc.xw = focus_xw; } if (focus_yh) { VarsInc.yh = focus_yh; } if (focus_aw) { VarsInc.aw = DEG2RAD * focus_aw; } if (focus_ah) { VarsInc.ah = DEG2RAD * focus_ah; } MPI_MASTER (printf ("Incoherent: %s: Vc=%g [Angs] sigma_abs=%g [barn] sigma_inc=%g [barn]\n", NAME_CURRENT_COMP, Vc, VarsInc.sigma_a, VarsInc.sigma_i);); #undef geometry #undef radius #undef xwidth #undef yheight #undef zdepth #undef thickness #undef target_x #undef target_y #undef target_z #undef focus_r #undef focus_xw #undef focus_yh #undef focus_aw #undef focus_ah #undef target_index #undef pack #undef p_interact #undef f_QE #undef gamma #undef Etrans #undef deltaE #undef sigma_abs #undef sigma_inc #undef Vc #undef concentric #undef order #undef VarsInc #undef offdata return(_comp); } /* class_Incoherent_init */ _class_PowderN *class_PowderN_init(_class_PowderN *_comp ) { #define reflections (_comp->_parameters.reflections) #define geometry (_comp->_parameters.geometry) #define format (_comp->_parameters.format) #define radius (_comp->_parameters.radius) #define yheight (_comp->_parameters.yheight) #define xwidth (_comp->_parameters.xwidth) #define zdepth (_comp->_parameters.zdepth) #define thickness (_comp->_parameters.thickness) #define pack (_comp->_parameters.pack) #define Vc (_comp->_parameters.Vc) #define sigma_abs (_comp->_parameters.sigma_abs) #define sigma_inc (_comp->_parameters.sigma_inc) #define delta_d_d (_comp->_parameters.delta_d_d) #define p_inc (_comp->_parameters.p_inc) #define p_transmit (_comp->_parameters.p_transmit) #define DW (_comp->_parameters.DW) #define nb_atoms (_comp->_parameters.nb_atoms) #define d_omega (_comp->_parameters.d_omega) #define d_phi (_comp->_parameters.d_phi) #define tth_sign (_comp->_parameters.tth_sign) #define p_interact (_comp->_parameters.p_interact) #define concentric (_comp->_parameters.concentric) #define density (_comp->_parameters.density) #define weight (_comp->_parameters.weight) #define barns (_comp->_parameters.barns) #define Strain (_comp->_parameters.Strain) #define focus_flip (_comp->_parameters.focus_flip) #define target_index (_comp->_parameters.target_index) #define order (_comp->_parameters.order) #define line_info (_comp->_parameters.line_info) #define columns (_comp->_parameters.columns) #define offdata (_comp->_parameters.offdata) #define tgt_x (_comp->_parameters.tgt_x) #define tgt_y (_comp->_parameters.tgt_y) #define tgt_z (_comp->_parameters.tgt_z) SIG_MESSAGE("[_powderSample_init] component powderSample=PowderN() INITIALISE [PowderN:0]"); /* We ought to clean up the columns variable as format is now a proper vector/array */ columns = format; int i = 0; struct line_data* L; line_info.Dd = delta_d_d; line_info.DWfactor = DW; line_info.V_0 = Vc; line_info.rho = density; line_info.at_weight = weight; line_info.at_nb = nb_atoms; line_info.sigma_a = sigma_abs; line_info.sigma_i = sigma_inc; line_info.flag_barns = barns; line_info.shape = 0; line_info.flag_warning = 0; line_info.Epsilon = Strain; line_info.radius_i = line_info.xwidth_i = line_info.yheight_i = line_info.zdepth_i = 0; line_info.v = 0; line_info.Nq = 0; line_info.v_min = FLT_MAX; line_info.v_max = 0; line_info.neutron_passed = 0; line_info.nb_reuses = line_info.nb_refl = line_info.nb_refl_count = 0; line_info.xs_compute = line_info.xs_reuse = line_info.xs_calls = 0; for (i = 0; i < 9; i++) { line_info.column_order[i] = (int)columns[i]; } strncpy (line_info.compname, NAME_CURRENT_COMP, 256); line_info.shape = -1; /* -1:no shape, 0:cyl, 1:box, 2:sphere, 3:any-shape */ if (geometry && strlen (geometry) && strcmp (geometry, "NULL") && strcmp (geometry, "0")) { #ifndef USE_OFF fprintf (stderr, "Error: You are attempting to use an OFF geometry without -DUSE_OFF. You will need to recompile with that define set!\n"); exit (-1); #else if (off_init (geometry, xwidth, yheight, zdepth, 0, &offdata)) { line_info.shape = 3; thickness = 0; concentric = 0; } #endif } else if (xwidth && yheight && zdepth) line_info.shape = 1; /* box */ else if (radius > 0 && yheight) line_info.shape = 0; /* cylinder */ else if (radius > 0 && !yheight) line_info.shape = 2; /* sphere */ if (line_info.shape < 0) exit (fprintf (stderr, "PowderN: %s: sample has invalid dimensions.\n" "ERROR Please check parameter values (xwidth, yheight, zdepth, radius).\n", NAME_CURRENT_COMP)); if (thickness) { if (radius && (radius < fabs (thickness))) { MPI_MASTER (printf ("PowderN: %s: hollow sample thickness is larger than its volume (sphere/cylinder).\n" "WARNING Please check parameter values. Using bulk sample (thickness=0).\n", NAME_CURRENT_COMP);); thickness = 0; } else if (!radius && (xwidth < 2 * fabs (thickness) || yheight < 2 * fabs (thickness) || zdepth < 2 * fabs (thickness))) { MPI_MASTER (printf ("PowderN: %s: hollow sample thickness is larger than its volume (box).\n" "WARNING Please check parameter values.\n", NAME_CURRENT_COMP);); } } if (concentric && thickness == 0) { MPI_MASTER (printf ("PowderN: %s:Can not use concentric mode\n" "WARNING on non hollow shape. Ignoring.\n", NAME_CURRENT_COMP);); concentric = 0; } if (thickness > 0) { if (radius > thickness) { line_info.radius_i = radius - thickness; } else { if (xwidth > 2 * thickness) line_info.xwidth_i = xwidth - 2 * thickness; if (yheight > 2 * thickness) line_info.yheight_i = yheight - 2 * thickness; if (zdepth > 2 * thickness) line_info.zdepth_i = zdepth - 2 * thickness; } } else if (thickness < 0) { thickness = fabs (thickness); if (radius) { line_info.radius_i = radius; radius = line_info.radius_i + thickness; } else { line_info.xwidth_i = xwidth; line_info.yheight_i = yheight; line_info.zdepth_i = zdepth; xwidth = xwidth + 2 * thickness; yheight = yheight + 2 * thickness; zdepth = zdepth + 2 * thickness; } } if (!line_info.yheight_i) { line_info.yheight_i = yheight; } if (!p_interact) { fprintf (stderr, "WARNING(%s): p_interact=0, adjusting to 0.01, to avoid algorithm instability\n", NAME_CURRENT_COMP); p_interact = 1e-2; } if (!p_inc) { fprintf (stderr, "WARNING(%s): p_inc=0, adjusting to 0.01, to avoid algorithm instability\n", NAME_CURRENT_COMP); p_inc = 1e-2; } if (!p_transmit) { fprintf (stderr, "WARNING(%s): p_transmit=0, adjusting to 0.01, to avoid algorithm instability\n", NAME_CURRENT_COMP); p_transmit = 1e-2; } double p_sum = p_interact + p_inc + p_transmit; p_interact = p_interact / p_sum; p_inc = p_inc / p_sum; p_transmit = p_transmit / p_sum; if (concentric) { MPI_MASTER (printf ("PowderN: %s: Concentric mode - remember to include the 'opposite' copy of this component !\n" "WARNING The equivalent, 'opposite' comp should have concentric=0\n", NAME_CURRENT_COMP);); if (p_transmit < 0.1) { MPI_MASTER (printf ("PowderN: %s: Concentric mode and p_transmit<0.1 !\n" "WARNING Consider increasing p_transmit as few particles will reach the inner hollow.\n", NAME_CURRENT_COMP);); } } if (reflections && strlen (reflections) && strcmp (reflections, "NULL") && strcmp (reflections, "0")) { if (strstr (reflections, ".ncmat") != NULL || strstr (reflections, "::") != NULL) { MPI_MASTER (printf ("PowderN: %s: NCrystal cfg-string detected (\"%s\").\n", NAME_CURRENT_COMP, reflections);); i = read_line_data_ncrystal (reflections, &line_info); } else { i = read_line_data (reflections, &line_info); } if (i == 0) exit (fprintf (stderr, "PowderN: %s: reflection file %s is not valid.\n" "ERROR Please check file format (laz or lau or NCrystal).\n", NAME_CURRENT_COMP, reflections)); } else { MPI_MASTER (printf ("PowderN: %s: Using incoherent elastic scattering only.\n", NAME_CURRENT_COMP);); line_info.count = 0; i = 0; } /* compute the scattering unit density from material weight and density */ /* the weight of the scattering element is the chemical formula molecular weight * times the nb of chemical formulae in the scattering element (nb_atoms) */ if (!line_info.V_0 && line_info.at_nb > 0 && line_info.at_weight > 0 && line_info.rho > 0) { /* molar volume [cm^3/mol] = weight [g/mol] / density [g/cm^3] */ /* atom density per Angs^3 = [mol/cm^3] * N_Avogadro *(1e-8)^3 */ line_info.V_0 = line_info.at_nb / (line_info.rho / line_info.at_weight / 1e24 * 6.02214199e23); } /* the scattering unit cross sections are the chemical formula onces * times the nb of chemical formulae in the scattering element */ if (line_info.at_nb > 0) { line_info.sigma_a *= line_info.at_nb; line_info.sigma_i *= line_info.at_nb; } if (line_info.sigma_a < 0) line_info.sigma_a = 0; if (line_info.sigma_i < 0) line_info.sigma_i = 0; if (line_info.V_0 <= 0) MPI_MASTER (printf ("PowderN: %s: density/unit cell volume is NULL (Vc). Unactivating component.\n", NAME_CURRENT_COMP);); if (line_info.V_0 > 0 && p_inc && !line_info.sigma_i) { MPI_MASTER (printf ("PowderN: %s: WARNING: You have requested statistics for incoherent scattering but not defined sigma_inc!\n", NAME_CURRENT_COMP);); } if (line_info.flag_barns) { /* Factor 100 to convert from barns to fm^2 */ line_info.XsectionFactor = 100; } else { line_info.XsectionFactor = 1; } if (line_info.V_0 > 0 && i) { L = line_info.list; line_info.q_v = malloc (line_info.count * sizeof (double)); line_info.w_v = malloc (line_info.count * sizeof (double)); line_info.my_s_v2 = malloc (line_info.count * sizeof (double)); if (!line_info.q_v || !line_info.w_v || !line_info.my_s_v2) exit (fprintf (stderr, "PowderN: %s: ERROR allocating memory (init)\n", NAME_CURRENT_COMP)); for (i = 0; i < line_info.count; i++) { line_info.my_s_v2[i] = 4 * PI * PI * PI * pack * (L[i].DWfactor ? L[i].DWfactor : 1) / (line_info.V_0 * line_info.V_0 * V2K * V2K) * (L[i].j * L[i].F2 / L[i].q) * line_info.XsectionFactor; /* Is not yet divided by v^2 */ /* Squires [3.103] */ line_info.q_v[i] = L[i].q * K2V; line_info.w_v[i] = L[i].w; } } if (line_info.V_0 > 0) { /* Is not yet divided by v */ line_info.my_a_v = pack * line_info.sigma_a / line_info.V_0 * 2200 * 100; // Factor 100 to convert from barns to fm^2 line_info.my_inc = pack * line_info.sigma_i / line_info.V_0 * 100; // Factor 100 to convert from barns to fm^2 MPI_MASTER (printf ("PowderN: %s: Vc=%g [Angs] sigma_abs=%g [barn] sigma_inc=%g [barn] reflections=%s\n", NAME_CURRENT_COMP, line_info.V_0, line_info.sigma_a, line_info.sigma_i, reflections && strlen (reflections) ? reflections : "NULL");); } /* update JS, 1/7/2017 Get target coordinates relative to the local reference frame. */ if (target_index) { Coords ToTarget; ToTarget = coords_sub (POS_A_COMP_INDEX (INDEX_CURRENT_COMP + target_index), POS_A_CURRENT_COMP); ToTarget = rot_apply (ROT_A_CURRENT_COMP, ToTarget); coords_get (ToTarget, &tgt_x, &tgt_y, &tgt_z); NORM (tgt_x, tgt_y, tgt_z); printf ("PowderN: Target direction = (%g %g %g)\n", tgt_x, tgt_y, tgt_z); } else { tgt_x = 0.0; tgt_y = 0.0; tgt_z = 1.0; } #undef reflections #undef geometry #undef format #undef radius #undef yheight #undef xwidth #undef zdepth #undef thickness #undef pack #undef Vc #undef sigma_abs #undef sigma_inc #undef delta_d_d #undef p_inc #undef p_transmit #undef DW #undef nb_atoms #undef d_omega #undef d_phi #undef tth_sign #undef p_interact #undef concentric #undef density #undef weight #undef barns #undef Strain #undef focus_flip #undef target_index #undef order #undef line_info #undef columns #undef offdata #undef tgt_x #undef tgt_y #undef tgt_z return(_comp); } /* class_PowderN_init */ _class_Single_crystal *class_Single_crystal_init(_class_Single_crystal *_comp ) { #define reflections (_comp->_parameters.reflections) #define geometry (_comp->_parameters.geometry) #define mosaic_AB (_comp->_parameters.mosaic_AB) #define xwidth (_comp->_parameters.xwidth) #define yheight (_comp->_parameters.yheight) #define zdepth (_comp->_parameters.zdepth) #define radius (_comp->_parameters.radius) #define delta_d_d (_comp->_parameters.delta_d_d) #define mosaic (_comp->_parameters.mosaic) #define mosaic_a (_comp->_parameters.mosaic_a) #define mosaic_b (_comp->_parameters.mosaic_b) #define mosaic_c (_comp->_parameters.mosaic_c) #define recip_cell (_comp->_parameters.recip_cell) #define barns (_comp->_parameters.barns) #define ax (_comp->_parameters.ax) #define ay (_comp->_parameters.ay) #define az (_comp->_parameters.az) #define bx (_comp->_parameters.bx) #define by (_comp->_parameters.by) #define bz (_comp->_parameters.bz) #define cx (_comp->_parameters.cx) #define cy (_comp->_parameters.cy) #define cz (_comp->_parameters.cz) #define p_transmit (_comp->_parameters.p_transmit) #define sigma_abs (_comp->_parameters.sigma_abs) #define sigma_inc (_comp->_parameters.sigma_inc) #define aa (_comp->_parameters.aa) #define bb (_comp->_parameters.bb) #define cc (_comp->_parameters.cc) #define order (_comp->_parameters.order) #define extra_order (_comp->_parameters.extra_order) #define RX (_comp->_parameters.RX) #define RY (_comp->_parameters.RY) #define powder (_comp->_parameters.powder) #define PG (_comp->_parameters.PG) #define deltak (_comp->_parameters.deltak) #define hkl_info (_comp->_parameters.hkl_info) #define offdata (_comp->_parameters.offdata) #define hkl_list (_comp->_parameters.hkl_list) #define tau_list (_comp->_parameters.tau_list) SIG_MESSAGE("[_crystalSample_init] component crystalSample=Single_crystal() INITIALISE [Single_crystal:0]"); double as, bs, cs; int i = 0; /* transfer input parameters */ hkl_info.m_delta_d_d = delta_d_d; hkl_info.m_a = 0; hkl_info.m_b = 0; hkl_info.m_c = 0; hkl_info.m_aa = aa; hkl_info.m_bb = bb; hkl_info.m_cc = cc; hkl_info.m_ax = ax; hkl_info.m_ay = ay; hkl_info.m_az = az; hkl_info.m_bx = bx; hkl_info.m_by = by; hkl_info.m_bz = bz; hkl_info.m_cx = cx; hkl_info.m_cy = cy; hkl_info.m_cz = cz; hkl_info.sigma_a = sigma_abs; hkl_info.sigma_i = sigma_inc; hkl_info.recip = recip_cell; /* default format h,k,l,F,F2 */ hkl_info.column_order[0] = 1; hkl_info.column_order[1] = 2; hkl_info.column_order[2] = 3; hkl_info.column_order[3] = 0; hkl_info.column_order[4] = 7; hkl_info.kix = hkl_info.kiy = hkl_info.kiz = 0; hkl_info.nb_reuses = hkl_info.nb_refl = hkl_info.nb_refl_count = 0; hkl_info.tau_count = 0; hkl_info.flag_barns = barns; /* ought to be cleaned up as mosaic_AB now is a proper vector/array and not a define */ double* mosaic_ABin = mosaic_AB; /* Read in structure factors, and do some pre-calculations. */ if (!read_hkl_data (reflections, &hkl_info, &hkl_list, mosaic, mosaic_a, mosaic_b, mosaic_c, mosaic_ABin)) { printf ("Single_crystal: %s: Error: Aborting.\n", NAME_CURRENT_COMP); exit (-1); } if (hkl_info.sigma_a < 0) hkl_info.sigma_a = 0; if (hkl_info.sigma_i < 0) hkl_info.sigma_i = 0; if (hkl_info.count) { MPI_MASTER (printf ("Single_crystal: %s: Read %d reflections from file '%s'\n", NAME_CURRENT_COMP, hkl_info.count, reflections);); } else { MPI_MASTER (printf ("Single_crystal: %s: Using incoherent elastic scattering only sigma=%g.\n", NAME_CURRENT_COMP, hkl_info.sigma_i);); } /*this should not be in hkl_info*/ hkl_info.shape = -1; /* -1:no shape, 0:cyl, 1:box, 2:sphere, 3:any-shape */ if (geometry && strlen (geometry) && strcmp (geometry, "NULL") && strcmp (geometry, "0")) { #ifndef USE_OFF fprintf (stderr, "Error: You are attempting to use an OFF geometry without -DUSE_OFF. You will need to recompile with that define set!\n"); exit (-1); #else if (off_init (geometry, xwidth, yheight, zdepth, 0, &offdata)) { hkl_info.shape = 3; } #endif } else if (xwidth && yheight && zdepth) hkl_info.shape = 1; /* box */ else if (radius > 0 && yheight) hkl_info.shape = 0; /* cylinder */ else if (radius > 0 && !yheight) hkl_info.shape = 2; /* sphere */ if (hkl_info.shape < 0) exit (fprintf (stderr, "Single_crystal: %s: sample has invalid dimensions.\n" "ERROR Please check parameter values (xwidth, yheight, zdepth, radius).\n", NAME_CURRENT_COMP)); MPI_MASTER (printf ("Single_crystal: %s: Vc=%g [Angs] sigma_abs=%g [barn] sigma_inc=%g [barn] reflections=%s\n", NAME_CURRENT_COMP, hkl_info.V0, hkl_info.sigma_a, hkl_info.sigma_i, reflections&& strlen (reflections) ? reflections : "NULL");); if (powder && PG) exit (fprintf (stderr, "Single_crystal: %s: powder and PG modes can not be used together!\n" "ERROR Please use EITHER powder or PG mode.\n", NAME_CURRENT_COMP)); if (powder && !(order == 1)) { fprintf (stderr, "Single_crystal: %s: powder mode means implicit choice of no multiple scattering!\n" "WARNING setting order=1\n", NAME_CURRENT_COMP); order = 1; } if (PG && !(order == 1)) { fprintf (stderr, "Single_crystal: %s: PG mode means implicit choice of no multiple scattering!\n" "WARNING setting order=1\n", NAME_CURRENT_COMP); order = 1; } if (order == 0 && extra_order) { fprintf (stderr, "Single_crystal: %s: extra_order used while order=0, then this option has no effect\n", NAME_CURRENT_COMP); } MPI_MASTER (printf ("Direct space lattice orientation:\n"); printf (" a = [%g %g %g]\n", hkl_info.m_ax, hkl_info.m_ay, hkl_info.m_az); printf (" b = [%g %g %g]\n", hkl_info.m_bx, hkl_info.m_by, hkl_info.m_bz); printf (" c = [%g %g %g]\n", hkl_info.m_cx, hkl_info.m_cy, hkl_info.m_cz); printf ("Reciprocal space lattice orientation:\n"); printf (" a* = [%g %g %g]\n", hkl_info.asx, hkl_info.asy, hkl_info.asz); printf (" b* = [%g %g %g]\n", hkl_info.bsx, hkl_info.bsy, hkl_info.bsz); printf (" c* = [%g %g %g]\n", hkl_info.csx, hkl_info.csy, hkl_info.csz);); #undef reflections #undef geometry #undef mosaic_AB #undef xwidth #undef yheight #undef zdepth #undef radius #undef delta_d_d #undef mosaic #undef mosaic_a #undef mosaic_b #undef mosaic_c #undef recip_cell #undef barns #undef ax #undef ay #undef az #undef bx #undef by #undef bz #undef cx #undef cy #undef cz #undef p_transmit #undef sigma_abs #undef sigma_inc #undef aa #undef bb #undef cc #undef order #undef extra_order #undef RX #undef RY #undef powder #undef PG #undef deltak #undef hkl_info #undef offdata #undef hkl_list #undef tau_list return(_comp); } /* class_Single_crystal_init */ _class_Phonon_simple *class_Phonon_simple_init(_class_Phonon_simple *_comp ) { #define radius (_comp->_parameters.radius) #define yheight (_comp->_parameters.yheight) #define sigma_abs (_comp->_parameters.sigma_abs) #define sigma_inc (_comp->_parameters.sigma_inc) #define a (_comp->_parameters.a) #define b (_comp->_parameters.b) #define M (_comp->_parameters.M) #define c (_comp->_parameters.c) #define DW (_comp->_parameters.DW) #define T (_comp->_parameters.T) #define target_x (_comp->_parameters.target_x) #define target_y (_comp->_parameters.target_y) #define target_z (_comp->_parameters.target_z) #define target_index (_comp->_parameters.target_index) #define focus_r (_comp->_parameters.focus_r) #define focus_xw (_comp->_parameters.focus_xw) #define focus_yh (_comp->_parameters.focus_yh) #define focus_aw (_comp->_parameters.focus_aw) #define focus_ah (_comp->_parameters.focus_ah) #define gap (_comp->_parameters.gap) #define e_steps_low (_comp->_parameters.e_steps_low) #define e_steps_high (_comp->_parameters.e_steps_high) #define V_rho (_comp->_parameters.V_rho) #define V_my_s (_comp->_parameters.V_my_s) #define V_my_a_v (_comp->_parameters.V_my_a_v) #define DV (_comp->_parameters.DV) #define phonon (_comp->_parameters.phonon) SIG_MESSAGE("[_phononSample_init] component phononSample=Phonon_simple() INITIALISE [Phonon_simple:0]"); V_rho = 4 / (a * a * a); V_my_s = (V_rho * 100 * sigma_inc); V_my_a_v = (V_rho * 100 * sigma_abs * 2200); DV = 0.001; /* Velocity change used for numerical derivative */ if (focus_aw) focus_aw *= DEG2RAD; if (focus_ah) focus_ah *= DEG2RAD; // Set constant parameters for parms object phonon.a_ = a; phonon.c_ = c; phonon.gap_ = gap; phonon.ah = a / 2.0; phonon.e_steps_high_ = e_steps_high; phonon.e_steps_low_ = e_steps_low; /* now compute target coords if a component index is supplied */ if (!target_index && !target_x && !target_y && !target_z) target_index = 1; if (target_index) { Coords ToTarget; ToTarget = coords_sub (POS_A_COMP_INDEX (INDEX_CURRENT_COMP + target_index), POS_A_CURRENT_COMP); ToTarget = rot_apply (ROT_A_CURRENT_COMP, ToTarget); coords_get (ToTarget, &target_x, &target_y, &target_z); } if (!(target_x || target_y || target_z)) { printf ("Phonon_simple: %s: The target is not defined. Using direct beam (Z-axis).\n", NAME_CURRENT_COMP); target_z = 1; } #undef radius #undef yheight #undef sigma_abs #undef sigma_inc #undef a #undef b #undef M #undef c #undef DW #undef T #undef target_x #undef target_y #undef target_z #undef target_index #undef focus_r #undef focus_xw #undef focus_yh #undef focus_aw #undef focus_ah #undef gap #undef e_steps_low #undef e_steps_high #undef V_rho #undef V_my_s #undef V_my_a_v #undef DV #undef phonon return(_comp); } /* class_Phonon_simple_init */ _class_PSD_monitor_4PI *class_PSD_monitor_4PI_init(_class_PSD_monitor_4PI *_comp ) { #define nx (_comp->_parameters.nx) #define ny (_comp->_parameters.ny) #define filename (_comp->_parameters.filename) #define nowritefile (_comp->_parameters.nowritefile) #define radius (_comp->_parameters.radius) #define restore_neutron (_comp->_parameters.restore_neutron) #define PSD_N (_comp->_parameters.PSD_N) #define PSD_p (_comp->_parameters.PSD_p) #define PSD_p2 (_comp->_parameters.PSD_p2) SIG_MESSAGE("[_psd_4pi_init] component psd_4pi=PSD_monitor_4PI() INITIALISE [PSD_monitor_4PI:0]"); PSD_N = create_darr2d (nx, ny); PSD_p = create_darr2d (nx, ny); PSD_p2 = create_darr2d (nx, ny); // Use instance name for monitor output if no input was given if (!strcmp (filename, "\0")) sprintf (filename, "%s", NAME_CURRENT_COMP); #undef nx #undef ny #undef filename #undef nowritefile #undef radius #undef restore_neutron #undef PSD_N #undef PSD_p #undef PSD_p2 return(_comp); } /* class_PSD_monitor_4PI_init */ _class_Exact_radial_coll *class_Exact_radial_coll_init(_class_Exact_radial_coll *_comp ) { #define theta_min (_comp->_parameters.theta_min) #define theta_max (_comp->_parameters.theta_max) #define nslit (_comp->_parameters.nslit) #define radius (_comp->_parameters.radius) #define length (_comp->_parameters.length) #define h_in (_comp->_parameters.h_in) #define h_out (_comp->_parameters.h_out) #define d (_comp->_parameters.d) #define verbose (_comp->_parameters.verbose) #define alpha_in (_comp->_parameters.alpha_in) #define alpha_out (_comp->_parameters.alpha_out) #define beta_in (_comp->_parameters.beta_in) #define beta_out (_comp->_parameters.beta_out) #define theta (_comp->_parameters.theta) #define out_radius (_comp->_parameters.out_radius) #define iw (_comp->_parameters.iw) #define ow (_comp->_parameters.ow) #define divergence (_comp->_parameters.divergence) SIG_MESSAGE("[_filter_coll_init] component filter_coll=Exact_radial_coll() INITIALISE [Exact_radial_coll:0]"); /* check for input parameters */ if (radius <= 0) exit (printf ("Exact_radial_coll: %s: radius must be positive\n", NAME_CURRENT_COMP)); if (h_in <= 0) exit (printf ("Exact_radial_coll: %s: h_in must be positive\n", NAME_CURRENT_COMP)); if (h_out <= 0) exit (printf ("Exact_radial_coll: %s: h_out must be positive\n", NAME_CURRENT_COMP)); if (d <= 0) exit (printf ("Exact_radial_coll: %s: d must be positive\n", NAME_CURRENT_COMP)); if (nslit <= 0) exit (printf ("Exact_radial_coll: %s: number of channels must be positive\n", NAME_CURRENT_COMP)); if ((nslit - floor (nslit)) > 0) exit (printf ("Exact_radial_coll: %s: number of channels must be an integer\n", NAME_CURRENT_COMP)); if (length <= 0) exit (printf ("Exact_radial_coll: %s: collimator length must be positive\n", NAME_CURRENT_COMP)); if (theta_max <= theta_min) exit (printf ("Exact_radial_coll: %s: theta_max must be greater than theta_min\n", NAME_CURRENT_COMP)); theta_max *= DEG2RAD; theta_min *= DEG2RAD; theta = theta_max - theta_min; out_radius = radius + length; beta_in = 2 * asin (d / (2 * radius)); beta_out = 2 * asin (d / (2 * out_radius)); if (theta < nslit * beta_in) exit (printf ("Exact_radial_coll: %s: the %6.0f foils of %g [meter]\n" "do not fit within the angular range theta = %4.2f [deg]\n", NAME_CURRENT_COMP, nslit, d, theta* RAD2DEG)); alpha_in = (theta - nslit * beta_in) / nslit; alpha_out = (theta - nslit * beta_out) / nslit; iw = 2 * radius * sin ((alpha_in / 2)); ow = 2 * out_radius * sin ((alpha_out / 2)); divergence = (iw + ow) / (sqrt (4 * length * length - (ow - iw) * (ow - iw))); if (verbose) { printf ("Exact_radial_coll: %s: foil thickness is %.2g [millimeter]\n", NAME_CURRENT_COMP, d * 1000); printf (" opening each input slit [%.3g:%.0f] [millimeter]\n", iw * 1000, h_in * 1000); printf (" opening each output slit [%.3g:%.0f] [millimeter]\n", ow * 1000, h_out * 1000); printf (" divergence per channel is %g [min] \n", divergence * RAD2MIN); } #undef theta_min #undef theta_max #undef nslit #undef radius #undef length #undef h_in #undef h_out #undef d #undef verbose #undef alpha_in #undef alpha_out #undef beta_in #undef beta_out #undef theta #undef out_radius #undef iw #undef ow #undef divergence return(_comp); } /* class_Exact_radial_coll_init */ _class_Monochromator_flat *class_Monochromator_flat_init(_class_Monochromator_flat *_comp ) { #define zmin (_comp->_parameters.zmin) #define zmax (_comp->_parameters.zmax) #define ymin (_comp->_parameters.ymin) #define ymax (_comp->_parameters.ymax) #define zwidth (_comp->_parameters.zwidth) #define yheight (_comp->_parameters.yheight) #define mosaich (_comp->_parameters.mosaich) #define mosaicv (_comp->_parameters.mosaicv) #define r0 (_comp->_parameters.r0) #define Q (_comp->_parameters.Q) #define DM (_comp->_parameters.DM) #define mos_rms_y (_comp->_parameters.mos_rms_y) #define mos_rms_z (_comp->_parameters.mos_rms_z) #define mos_rms_max (_comp->_parameters.mos_rms_max) #define mono_Q (_comp->_parameters.mono_Q) SIG_MESSAGE("[_an1l_init] component an1l=Monochromator_flat() INITIALISE [Monochromator_flat:0]"); mos_rms_y = MIN2RAD * mosaicv / sqrt (8 * log (2)); mos_rms_z = MIN2RAD * mosaich / sqrt (8 * log (2)); mos_rms_max = mos_rms_y > mos_rms_z ? mos_rms_y : mos_rms_z; mono_Q = Q; if (DM != 0) mono_Q = 2 * PI / DM; if (zwidth > 0) { zmax = zwidth / 2; zmin = -zmax; } if (yheight > 0) { ymax = yheight / 2; ymin = -ymax; } if (zmin == zmax || ymin == ymax) exit (fprintf (stderr, "Monochromator_flat: %s : Surface is null (zmin,zmax,ymin,ymax)\n", NAME_CURRENT_COMP)); #undef zmin #undef zmax #undef ymin #undef ymax #undef zwidth #undef yheight #undef mosaich #undef mosaicv #undef r0 #undef Q #undef DM #undef mos_rms_y #undef mos_rms_z #undef mos_rms_max #undef mono_Q return(_comp); } /* class_Monochromator_flat_init */ _class_Absorber *class_Absorber_init(_class_Absorber *_comp ) { #define xmin (_comp->_parameters.xmin) #define xmax (_comp->_parameters.xmax) #define ymin (_comp->_parameters.ymin) #define ymax (_comp->_parameters.ymax) #define zmin (_comp->_parameters.zmin) #define zmax (_comp->_parameters.zmax) #define xw (_comp->_parameters.xw) #define yh (_comp->_parameters.yh) #define zt (_comp->_parameters.zt) #define xm (_comp->_parameters.xm) #define ym (_comp->_parameters.ym) #define zm (_comp->_parameters.zm) SIG_MESSAGE("[_BladeR1_init] component BladeR1=Absorber() INITIALISE [Absorber:0]"); xw = xmax - xmin; yh = ymax - ymin; zt = zmax - zmin; xm = (xmax + xmin) / 2; ym = (ymax + ymin) / 2; zm = (zmax + zmin) / 2; if (xw == 0 || yh == 0 || zt == 0) { fprintf (stderr, "Absorber: %s: Error: Slab volume is zero!\n", NAME_CURRENT_COMP); exit (-1); } #undef xmin #undef xmax #undef ymin #undef ymax #undef zmin #undef zmax #undef xw #undef yh #undef zt #undef xm #undef ym #undef zm return(_comp); } /* class_Absorber_init */ int init(void) { /* called by mccode_main for RITA_II:INITIALISE */ DEBUG_INSTR(); // Initialise rng srandom(_hash(mcseed-1)); /* code_main/parseoptions/readparams sets instrument parameters value */ stracpy(instrument->_name, "RITA_II", 256); /* Instrument 'RITA_II' INITIALISE */ SIG_MESSAGE("[RITA_II] INITIALISE [(null):-1]"); #define ITAR (instrument->_parameters.ITAR) #define L0 (instrument->_parameters.L0) #define BPL (instrument->_parameters.BPL) #define BPH (instrument->_parameters.BPH) #define MONO_N (instrument->_parameters.MONO_N) #define MONOFORCE (instrument->_parameters.MONOFORCE) #define MONO_MOS_H (instrument->_parameters.MONO_MOS_H) #define MONO_MOS_V (instrument->_parameters.MONO_MOS_V) #define EI (instrument->_parameters.EI) #define EF (instrument->_parameters.EF) #define EN (instrument->_parameters.EN) #define SM (instrument->_parameters.SM) #define SS (instrument->_parameters.SS) #define SA (instrument->_parameters.SA) #define QH (instrument->_parameters.QH) #define QK (instrument->_parameters.QK) #define QL (instrument->_parameters.QL) #define QM (instrument->_parameters.QM) #define AS (instrument->_parameters.AS) #define BS (instrument->_parameters.BS) #define CS (instrument->_parameters.CS) #define AA (instrument->_parameters.AA) #define BB (instrument->_parameters.BB) #define CC (instrument->_parameters.CC) #define AH (instrument->_parameters.AH) #define AK (instrument->_parameters.AK) #define AL (instrument->_parameters.AL) #define BH (instrument->_parameters.BH) #define BK (instrument->_parameters.BK) #define BL (instrument->_parameters.BL) #define INFILTER (instrument->_parameters.INFILTER) #define INFILTERFILE (instrument->_parameters.INFILTERFILE) #define COLL_MS (instrument->_parameters.COLL_MS) #define MST (instrument->_parameters.MST) #define MSB (instrument->_parameters.MSB) #define MSL (instrument->_parameters.MSL) #define MSR (instrument->_parameters.MSR) #define PTHICK (instrument->_parameters.PTHICK) #define PERSPEX (instrument->_parameters.PERSPEX) #define SAMPLE (instrument->_parameters.SAMPLE) #define SAMPLEFILE (instrument->_parameters.SAMPLEFILE) #define MOS (instrument->_parameters.MOS) #define DD_D (instrument->_parameters.DD_D) #define SAMPLESIZE (instrument->_parameters.SAMPLESIZE) #define BARNS (instrument->_parameters.BARNS) #define AAX (instrument->_parameters.AAX) #define AAY (instrument->_parameters.AAY) #define AAZ (instrument->_parameters.AAZ) #define BBX (instrument->_parameters.BBX) #define BBY (instrument->_parameters.BBY) #define BBZ (instrument->_parameters.BBZ) #define CCX (instrument->_parameters.CCX) #define CCY (instrument->_parameters.CCY) #define CCZ (instrument->_parameters.CCZ) #define A1 (instrument->_parameters.A1) #define A2 (instrument->_parameters.A2) #define A3 (instrument->_parameters.A3) #define A4 (instrument->_parameters.A4) #define A6 (instrument->_parameters.A6) #define TILT (instrument->_parameters.TILT) #define SST (instrument->_parameters.SST) #define SSB (instrument->_parameters.SSB) #define SSL (instrument->_parameters.SSL) #define SSR (instrument->_parameters.SSR) #define OUTFILTER (instrument->_parameters.OUTFILTER) #define OUTFILTERFILE (instrument->_parameters.OUTFILTERFILE) #define ANAFORCE (instrument->_parameters.ANAFORCE) #define AA5 (instrument->_parameters.AA5) #define C1 (instrument->_parameters.C1) #define C2 (instrument->_parameters.C2) #define C3 (instrument->_parameters.C3) #define C4 (instrument->_parameters.C4) #define C5 (instrument->_parameters.C5) #define C6 (instrument->_parameters.C6) #define C7 (instrument->_parameters.C7) #define C8 (instrument->_parameters.C8) #define C9 (instrument->_parameters.C9) #define COARSE (instrument->_parameters.COARSE) #define LC (instrument->_parameters.LC) #define RC (instrument->_parameters.RC) #define REP (instrument->_parameters.REP) #define VIRTUALOUT (instrument->_parameters.VIRTUALOUT) #define VIRTUALIN (instrument->_parameters.VIRTUALIN) #define SOURCEFILE (instrument->_parameters.SOURCEFILE) #define verbose (instrument->_parameters.verbose) { /* Source parameters */ //l0=9.045/sqrt(EI); l0=L0;// fix 20100222 by LU since we want source independent of mono lmin=BPL*l0;/* MONO_N is the order of the reflection */ lmax=BPH*l0; printf("Source wavelength interval=%.4g - %.4g[Ang] \n",lmin, lmax); /* Calculate min and max energy for source to use with energy monitors before sample */ emini=(9.045*9.045)/(lmax*lmax); emaxi=(9.045*9.045)/(lmin*lmin); //neichan=floor((emaxi-emini)/0.01); printf("Source energy interval=%.4g - %.4g[meV] \n",emini, emaxi); /* Calculate min and max energy for the detectors after the sample */ eminf=EF*0.95; emaxf=EF*1.05; //nefchan=floor((emaxf-eminf)/0.005); printf("Detector energy interval=%.4g - %.4g[meV] \n",eminf, emaxf); /* Only SPLIT if we are not running with VIRTUAL parms */ if (VIRTUALIN || VIRTUALOUT) { SPLITREP = 1; if (!VIRTUALOUT){ SPLITMREP = 1; }else{ SPLITMREP = REP; } if (!VIRTUALIN){ SPLITAREP = 1; }else{ SPLITAREP = REP; } } else { SPLITREP = REP; SPLITMREP = REP; SPLITAREP = REP; } /* Guide parameters */ angleGuideCurved=20.0/2408.0; /* calculate mirror reflectivity slope */ ALPHA=0;//(R0-R)/(Qc*(M-1)); printf("* GUIDE MIRROR ALPHA=%g [AA]\n", ALPHA); /* Monochromator parameters */ double Vi, Vf; double tmp=0; char Qmode = 0; DM = 2*PI/mono_q; DA = 2*PI/ana_q; mono_mosaic_h = MONO_MOS_H; /* MON_MOSAIC; */ mono_mosaic_v = MONO_MOS_V; /* MON_MOSAIC; */ dms = dmv+dvs;/* Distance between mono and sample*/ dmc = rmh-lc; /*distance monochromator to front of monocollimator*/ /* fix 08/02/2009 by LU */ /* Forcing monochromator to set value */ if (MONOFORCE) {/* Flat mono */ rv=0; printf("* MONOCHROMATOR IS VERTICALLY FOCUSING: RV=%g \n",rv); } else {rv=dms; /* curved mono */ printf("* MONOCHROMATOR IS FLAT: RV=%g \n", rv); } /* BEGIN HKL calculator adapted from templateTAS */ machine_real.a1 = A1; machine_real.a2 = A2; machine_real.a3 = A3; machine_real.a4 = A4; machine_real.a5 = A5; machine_real.a6 = A6; machine_real.c1 = -C1; machine_real.c2 = -C2; machine_real.c3 = -C3; machine_real.c4 = -C4; machine_real.c5 = -C5; machine_real.c6 = -C6; machine_real.c7 = -C7; machine_real.c8 = -C8; machine_real.c9 = -C9; /* energy conservation */ if (EI && EF) { EN = EI - EF; fprintf(stderr,"%s WARNING: EN is now set to %g since you provided both EI=%g (KI) and EF=%g (KF)\n", NAME_INSTRUMENT, EN, EI, EF); } else if (EI && !EF){ EF = EI - EN; fprintf(stderr,"%s WARNING: EF is now set to %g since you provided both EI=%g (KI) and EN=%g\n", NAME_INSTRUMENT, EF, EI, EN); fprintf(stderr,"%s POSSIBLE ERROR: On RITA, EF is normally SET, EI calculated - are you sure about this?\n", NAME_INSTRUMENT); } else if (EF && !EI) { EI = EF + EN; fprintf(stderr,"%s WARNING: EI is now set to %g since you provided both EF=%g (KF) and EN=%g\n", NAME_INSTRUMENT, EI, EF, EN); } else { fprintf(stderr,"%s WARNING: Neither EI, EF nor EN defined: Energies are set from user angle input:\n", NAME_INSTRUMENT); l0 = 2 * DM * sin(DEG2RAD*A2/2)/MONO_N; EI = 9.045/l0; EI = EI*EI; fprintf(stderr,"%s: WARNING: EI has been adjusted to %g[meV] (A2 = %g[deg])\n", NAME_INSTRUMENT, EI, A2); l0 = 2 * DA * sin(DEG2RAD*A6/2)/MONO_N; EF= 9.045/l0; EF = EF*EF; fprintf(stderr,"%s: WARNING: EF has been adjusted to %g[meV] (A6 = %g[deg])\n", NAME_INSTRUMENT, EF, A2); } /* determine remaining neutron energies */ Vi = SE2V*sqrt(EI); KI = V2K*Vi; Vf = SE2V*sqrt(EF); KF = V2K*Vf; /* transfered sample parameters */ sample.aa = AA; sample.bb = BB; sample.cc = CC; sample.as = AS; sample.bs = BS; sample.cs = CS; sample.ax = AH; sample.ay = AK; sample.az = AL; sample.bx = BH; sample.by = BK; sample.bz = BL; /* transfered target parameters */ machine_hkl.ki = KI; machine_hkl.kf = KF; machine_hkl.ei = EI; machine_hkl.ef = EF; machine_hkl.qh = QH; machine_hkl.qk = QK; machine_hkl.ql = QL; machine_hkl.en = EN; machine_real.qm = QM; if (QM || QH || QK || QL) { Qmode=1; fprintf(stderr,"%s: Running in HKL mode\n", NAME_INSTRUMENT); } else { fprintf(stderr,"%s: Running in angle mode\n", NAME_INSTRUMENT); } if (verbose && Qmode) { printf("%s: Detailed TAS configuration\n", NAME_INSTRUMENT); printf("* Incoming beam: EI=%.4g [meV] KI=%.4g [Angs-1] Vi=%g [m/s]\n", EI, KI, Vi); printf("* Outgoing beam: EF=%.4g [meV] KF=%.4g [Angs-1] Vf=%g [m/s]\n", EF, KF, Vf); } /* transfered machine parameters */ /* For W configuartion of TAS: */ machine_hkl.sm = SM; machine_hkl.ss = SS; machine_hkl.sa = SA; /* These two are actually constants, see top of INITIALIZE */ machine_hkl.dm = DM; machine_hkl.da = DA; if (Qmode) { machine_real = qhkl2angles(sample, machine_hkl, machine_real); if (strlen(machine_real.message)) { exit(fprintf(stderr, "%s: ERROR: %s [qhkl2angles]\n", NAME_INSTRUMENT, machine_real.message)); } } if (A1 && (machine_real.a1 != A1)) { printf("Warning, resetting A1 from calculated %g to user provided %g\n",machine_real.a1,A1); machine_real.a1 = A1; } if (A2 && (machine_real.a2 != A2)) { printf("Warning, resetting A2 from calculated %g to user provided %g\n",machine_real.a2,A2); machine_real.a2 = A2; } if (A3 && (machine_real.a3 != A3)) { printf("Warning, resetting A3 from calculated %g to user provided %g\n",machine_real.a3,A3); machine_real.a3 = A3; } if (A4 && (machine_real.a4 != A4)) { printf("Warning, resetting A4 from calculated %g to user provided %g\n",machine_real.a4,A4); machine_real.a4 = A4; } if (A5 && (machine_real.a5 != A5)) { printf("Warning, resetting A5 from calculated %g to user provided %g\n",machine_real.a5,A5); machine_real.a5 = A5; } if (A6 && (machine_real.a6 != A6)) { printf("Warning, resetting A6 from calculated %g to user provided %g\n",machine_real.a6,A6); machine_real.a6 = A6; } if (AA5 && (machine_real.aa5 != AA5) && !ANAFORCE) { printf("Warning, resetting AA5 from calculated %g to user provided %g\n",machine_real.aa5,AA5); machine_real.aa5 = AA5; /*A4 angle between blades */ machine_real.da4 = RAD2DEG*atan(ana_d*cos(DEG2RAD*machine_real.aa5)/dsa); /*Blade angle rotation */ machine_real.c1= -machine_real.aa5+machine_real.a5-(1-5)*machine_real.da4; machine_real.c2= -machine_real.aa5+machine_real.a5-(2-5)*machine_real.da4; machine_real.c3= -machine_real.aa5+machine_real.a5-(3-5)*machine_real.da4; machine_real.c4= -machine_real.aa5+machine_real.a5-(4-5)*machine_real.da4; machine_real.c5= -machine_real.aa5+machine_real.a5-(5-5)*machine_real.da4; machine_real.c6= -machine_real.aa5+machine_real.a5-(6-5)*machine_real.da4; machine_real.c7= -machine_real.aa5+machine_real.a5-(7-5)*machine_real.da4; machine_real.c8= -machine_real.aa5+machine_real.a5-(8-5)*machine_real.da4; machine_real.c9= -machine_real.aa5+machine_real.a5-(9-5)*machine_real.da4; printf("Warning, recalculating C's to %g %g %g %g %g %g %g %g %g \n",machine_real.c1,machine_real.c2,machine_real.c3,machine_real.c4,machine_real.c5,machine_real.c6,machine_real.c7,machine_real.c8,machine_real.c9); } if (C1 && (machine_real.c1 != -C1)) { printf("Warning, resetting C1 from calculated %g to user provided %g\n",machine_real.c1,-C1); machine_real.c1 = -C1; } if (C2 && (machine_real.c2 != -C2)) { printf("Warning, resetting C2 from calculated %g to user provided %g\n",machine_real.c2,-C2); machine_real.c2 = -C2; } if (C3 && (machine_real.c3 != -C3)) { printf("Warning, resetting C3 from calculated %g to user provided %g\n",machine_real.c3,-C3); machine_real.c3 = -C3; } if (C4 && (machine_real.c4 != -C4)) { printf("Warning, resetting C4 from calculated %g to user provided %g\n",machine_real.c4,-C4); machine_real.c4 = -C4; } if (C5 && (machine_real.c5 != -C5)) { printf("Warning, resetting C5 from calculated %g to user provided %g\n",machine_real.c5,-C5); machine_real.c5 = -C5; } if (C6 && (machine_real.c6 != -C6)) { printf("Warning, resetting C6 from calculated %g to user provided %g\n",machine_real.c6,-C6); machine_real.c6 = -C6; } if (C7 && (machine_real.c7 != -C7)) { printf("Warning, resetting C7 from calculated %g to user provided %g\n",machine_real.c7,-C7); machine_real.c7 = -C7; } if (C8 && (machine_real.c8 != -C8)) { printf("Warning, resetting C8 from calculated %g to user provided %g\n",machine_real.c8,-C8); machine_real.c8 = -C8; } if (C9 && (machine_real.c9 != -C9)) { printf("Warning, resetting C9 from calculated %g to user provided %g\n",machine_real.c9,-C9); machine_real.c9 = -C9; } /* Forcing ana to set value */ if (ANAFORCE) {/* Flat ana mode */ if (AA5 && machine_real.a5 != AA5){ machine_real.aa5=AA5; printf("Warning, resetting AA5 from calculated %g to user provided %g\n",machine_real.a5,AA5); } else{ machine_real.aa5=machine_real.a5; } machine_real.c1=0; machine_real.c2=0; machine_real.c3=0; machine_real.c4=0; machine_real.c5=0; machine_real.c6=0; machine_real.c7=0; machine_real.c8=0; machine_real.c9=0; C1 = machine_real.c1; C2 = machine_real.c2; C3 = machine_real.c3; C4 = machine_real.c4; C5 = machine_real.c5; C6 = machine_real.c6; C7 = machine_real.c7; C8 = machine_real.c8; C9 = machine_real.c9; printf("* ANALYSER IN FLAT MODE \n"); } else {/* else imaging mode ana */ printf("* ANALYSER IN IMAGING MODE \n"); } if (verbose) { printf("* Transfered: EN=%g [meV] QM=%g [Angs-1]\n", EN, machine_real.qm); printf("Angles: A1=%.4g A2=%.4g A3=%.4g A4=%.4g A5=%.4g A6=%.4g [deg]\n", machine_real.a1, machine_real.a2, machine_real.a3, machine_real.a4, machine_real.a5, machine_real.a6); printf("(RITA Analyzer Angles: AA5=%.4g C1=%.4g C2=%.4g C3=%.4g C4=%.4g C5=%.4g C6=%.4g C7=%.4g C8=%.4g C9=%.4g [deg])\n", machine_real.aa5, machine_real.c1,machine_real.c2,machine_real.c3, machine_real.c4,machine_real.c5,machine_real.c6, machine_real.c7,machine_real.c8,machine_real.c9); } /* END HKL calculator adapted from templateTAS */ /* Sample paramaters */ if (SAMPLE == 2){ /* Powder sample, relevant WHEN at sample position */ if (!strcmp(SAMPLEFILE,"default")) { PowderFile="Al2O3_sapphire.lau"; } else { PowderFile=SAMPLEFILE; } SingleXFile=""; } else if (SAMPLE == 3) { /* Single crystal sample, relevant WHEN at sample position */ if (!strcmp(SAMPLEFILE,"default")) { SingleXFile="Pb.laz"; } else { SingleXFile=SAMPLEFILE; } PowderFile=""; } else if (SAMPLE==4){ /* Phonon sample */ printf("Phonon sample used - no elastic contribution. \n"); }else { /* Purely incoherent scatterer, relevant WHEN at sample position */ SingleXFile=""; PowderFile=""; } /* Coarse collimator */ if (COARSE) {coarse = 1;} else {coarse = 0;} /* Opening slits of coarse collimator depends on analyzer settings: */ deltaL = 2 * WindowSize * cos(DEG2RAD*machine_real.a6 + fabs(DEG2RAD*machine_real.a5)); FirstWindowSizeL = WindowSize * (dad-BladeLength-deltaL+BladeLength*sin(DEG2RAD*machine_real.a6 + fabs(DEG2RAD*machine_real.a5)))/(dad-deltaL); FirstWindowSizeR = WindowSize * (dad-BladeLength+deltaL+BladeLength*sin(DEG2RAD*machine_real.a6 + fabs(DEG2RAD*machine_real.a5)))/(dad+deltaL); /* Window positions */ XwinMin[0] = 0; XwinMin[1] = 12; XwinMin[2] = 24; XwinMin[3] = 36; XwinMin[4] = 48; XwinMin[5] = 60; XwinMin[6] = 72; XwinMin[7] = 84; XwinMin[8] = 95; XwinMin[9] = 106; XwinMax[0] = 0; XwinMax[1] = 21; XwinMax[2] = 33; XwinMax[3] = 45; XwinMax[4] = 57; XwinMax[5] = 69; XwinMax[6] = 81; XwinMax[7] = 93; XwinMax[8] = 104; XwinMax[9] = 115; YwinMin[0] = 0; YwinMin[1] = 39; YwinMin[2] = 39; YwinMin[3] = 39; YwinMin[4] = 39; YwinMin[5] = 39; YwinMin[6] = 39; YwinMin[7] = 39; YwinMin[8] = 39; YwinMin[9] = 39; YwinMax[0] = 0; YwinMax[1] = 91; YwinMax[2] = 91; YwinMax[3] = 91; YwinMax[4] = 91; YwinMax[5] = 91; YwinMax[6] = 91; YwinMax[7] = 91; YwinMax[8] = 91; YwinMax[9] = 91; } #undef ITAR #undef L0 #undef BPL #undef BPH #undef MONO_N #undef MONOFORCE #undef MONO_MOS_H #undef MONO_MOS_V #undef EI #undef EF #undef EN #undef SM #undef SS #undef SA #undef QH #undef QK #undef QL #undef QM #undef AS #undef BS #undef CS #undef AA #undef BB #undef CC #undef AH #undef AK #undef AL #undef BH #undef BK #undef BL #undef INFILTER #undef INFILTERFILE #undef COLL_MS #undef MST #undef MSB #undef MSL #undef MSR #undef PTHICK #undef PERSPEX #undef SAMPLE #undef SAMPLEFILE #undef MOS #undef DD_D #undef SAMPLESIZE #undef BARNS #undef AAX #undef AAY #undef AAZ #undef BBX #undef BBY #undef BBZ #undef CCX #undef CCY #undef CCZ #undef A1 #undef A2 #undef A3 #undef A4 #undef A6 #undef TILT #undef SST #undef SSB #undef SSL #undef SSR #undef OUTFILTER #undef OUTFILTERFILE #undef ANAFORCE #undef AA5 #undef C1 #undef C2 #undef C3 #undef C4 #undef C5 #undef C6 #undef C7 #undef C8 #undef C9 #undef COARSE #undef LC #undef RC #undef REP #undef VIRTUALOUT #undef VIRTUALIN #undef SOURCEFILE #undef verbose _armSource_setpos(); /* type Progress_bar */ _source_setpos(); /* type Source_gen4 */ _slitGuideBegin_setpos(); /* type Slit */ _lmon_guide_start_setpos(); /* type L_monitor */ _guideStraight_setpos(); /* type Guide */ _guideCurved1_setpos(); /* type Guide */ _guideCurved2_setpos(); /* type Guide */ _guideCurved3_setpos(); /* type Guide */ _guideCurved4_setpos(); /* type Guide */ _guideCurved5_setpos(); /* type Guide */ _guideCurved6_setpos(); /* type Guide */ _guideCurved7_setpos(); /* type Guide */ _guideCurved8_setpos(); /* type Guide */ _guideCurved9_setpos(); /* type Guide */ _guideCurved10_setpos(); /* type Guide */ _guideCurved11_setpos(); /* type Guide */ _guideCurved12_setpos(); /* type Guide */ _guideCurved13_setpos(); /* type Guide */ _guideCurved14_setpos(); /* type Guide */ _guideCurved15_setpos(); /* type Guide */ _guideCurved16_setpos(); /* type Guide */ _guideCurved17_setpos(); /* type Guide */ _guideCurved18_setpos(); /* type Guide */ _guideCurved19_setpos(); /* type Guide */ _guideCurved20_setpos(); /* type Guide */ _guideCurved21_setpos(); /* type Guide */ _guideCurved22_setpos(); /* type Guide */ _guideCurved23_setpos(); /* type Guide */ _guideCurved24_setpos(); /* type Guide */ _guideCurved25_setpos(); /* type Guide */ _guideCurved26_setpos(); /* type Guide */ _guideCurved27_setpos(); /* type Guide */ _guideCurved28_setpos(); /* type Guide */ _guideCurved29_setpos(); /* type Guide */ _guideCurved30_setpos(); /* type Guide */ _guideCurved31_setpos(); /* type Guide */ _guideCurved32_setpos(); /* type Guide */ _guideCurved33_setpos(); /* type Guide */ _guideCurved34_setpos(); /* type Guide */ _guideCurved35_setpos(); /* type Guide */ _guideCurved36_setpos(); /* type Guide */ _guideCurved37_setpos(); /* type Guide */ _guideCurved38_setpos(); /* type Guide */ _guideCurved39_setpos(); /* type Guide */ _guideCurved40_setpos(); /* type Guide */ _bunker_setpos(); /* type Guide */ _guide3_setpos(); /* type Guide */ _slitGuideEnd_setpos(); /* type Slit */ _psd_guide_end_setpos(); /* type PSD_monitor */ _emon_guide_end_setpos(); /* type E_monitor */ _lmon_guide_end_setpos(); /* type L_monitor */ _divmon_guide_end_setpos(); /* type Divergence_monitor */ _focus_mono_setpos(); /* type Arm */ _monochromator_curved_setpos(); /* type Monochromator_curved */ _a2_setpos(); /* type Arm */ _slitShutter_setpos(); /* type Slit */ _MSCollimator_setpos(); /* type Collimator_linear */ _infilter_setpos(); /* type Filter_gen */ _psd_virt_setpos(); /* type PSD_monitor */ _lmon_virt_setpos(); /* type L_monitor */ _aa2_setpos(); /* type Arm */ _OrderMon_setpos(); /* type Monitor_nD */ _kMoni_setpos(); /* type PSD_monitor_psf_eff */ _kMoni1st_setpos(); /* type PSD_monitor_psf_eff */ _kMoni2nd_setpos(); /* type PSD_monitor_psf_eff */ _kMoni3rd_setpos(); /* type PSD_monitor_psf_eff */ _slitMonochromator_setpos(); /* type Slit */ _Perspex_setpos(); /* type Incoherent */ _psd_samplepos_1cm2_setpos(); /* type PSD_monitor */ _emon_samplepos_1cm2_setpos(); /* type E_monitor */ _divmon_samplepos_1cm2_setpos(); /* type Divergence_monitor */ _psd_samplepos_large_setpos(); /* type PSD_monitor */ _a3_setpos(); /* type Arm */ _aa3_setpos(); /* type Arm */ _incohSample_setpos(); /* type Incoherent */ _powderSample_setpos(); /* type PowderN */ _crystalSample_setpos(); /* type Single_crystal */ _phononSample_setpos(); /* type Phonon_simple */ _psd_4pi_setpos(); /* type PSD_monitor_4PI */ _a4_setpos(); /* type Arm */ _slitSample_setpos(); /* type Slit */ _filter_coll_setpos(); /* type Exact_radial_coll */ _filter_setpos(); /* type Filter_gen */ _ana_slit1_setpos(); /* type Slit */ _ana_slit2_setpos(); /* type Slit */ _emon_before_ana_setpos(); /* type E_monitor */ _psd_before_ana_setpos(); /* type PSD_monitor */ _divmon_before_ana_setpos(); /* type Divergence_monitor */ _focus_ana_setpos(); /* type Arm */ _an1l_setpos(); /* type Monochromator_flat */ _an1u_setpos(); /* type Monochromator_flat */ _an2l_setpos(); /* type Monochromator_flat */ _an2u_setpos(); /* type Monochromator_flat */ _an3l_setpos(); /* type Monochromator_flat */ _an3u_setpos(); /* type Monochromator_flat */ _an4l_setpos(); /* type Monochromator_flat */ _an4u_setpos(); /* type Monochromator_flat */ _an5l_setpos(); /* type Monochromator_flat */ _an5u_setpos(); /* type Monochromator_flat */ _an6l_setpos(); /* type Monochromator_flat */ _an6u_setpos(); /* type Monochromator_flat */ _an7l_setpos(); /* type Monochromator_flat */ _an7u_setpos(); /* type Monochromator_flat */ _an8l_setpos(); /* type Monochromator_flat */ _an8u_setpos(); /* type Monochromator_flat */ _an9l_setpos(); /* type Monochromator_flat */ _an9u_setpos(); /* type Monochromator_flat */ _a6_setpos(); /* type Arm */ _emon_before_coarse_setpos(); /* type E_monitor */ _psd_before_coarse_setpos(); /* type PSD_monitor */ _ArmR1_setpos(); /* type Arm */ _BladeR1_setpos(); /* type Absorber */ _ArmR2_setpos(); /* type Arm */ _BladeR2_setpos(); /* type Absorber */ _ArmR3_setpos(); /* type Arm */ _BladeR3_setpos(); /* type Absorber */ _ArmR4_setpos(); /* type Arm */ _BladeR4_setpos(); /* type Absorber */ _ArmR5_setpos(); /* type Arm */ _BladeR5_setpos(); /* type Absorber */ _ArmL1_setpos(); /* type Arm */ _BladeL1_setpos(); /* type Absorber */ _ArmL2_setpos(); /* type Arm */ _BladeL2_setpos(); /* type Absorber */ _ArmL3_setpos(); /* type Arm */ _BladeL3_setpos(); /* type Absorber */ _ArmL4_setpos(); /* type Arm */ _BladeL4_setpos(); /* type Absorber */ _ArmL5_setpos(); /* type Arm */ _BladeL5_setpos(); /* type Absorber */ _psd_detector_setpos(); /* type PSD_monitor_psf_eff */ _emon_detector_setpos(); /* type E_monitor */ _psd_window1_setpos(); /* type PSD_monitor_psf_eff */ _emon_window1_setpos(); /* type E_monitor */ _psd_window2_setpos(); /* type PSD_monitor_psf_eff */ _emon_window2_setpos(); /* type E_monitor */ _psd_window3_setpos(); /* type PSD_monitor_psf_eff */ _emon_window3_setpos(); /* type E_monitor */ _psd_window4_setpos(); /* type PSD_monitor_psf_eff */ _emon_window4_setpos(); /* type E_monitor */ _psd_window5_setpos(); /* type PSD_monitor_psf_eff */ _emon_window5_setpos(); /* type E_monitor */ _psd_window6_setpos(); /* type PSD_monitor_psf_eff */ _emon_window6_setpos(); /* type E_monitor */ _psd_window7_setpos(); /* type PSD_monitor_psf_eff */ _emon_window7_setpos(); /* type E_monitor */ _psd_window8_setpos(); /* type PSD_monitor_psf_eff */ _emon_window8_setpos(); /* type E_monitor */ _psd_window9_setpos(); /* type PSD_monitor_psf_eff */ _emon_window9_setpos(); /* type E_monitor */ /* call iteratively all components INITIALISE */ class_Progress_bar_init(&_armSource_var); class_Source_gen4_init(&_source_var); class_Slit_init(&_slitGuideBegin_var); class_L_monitor_init(&_lmon_guide_start_var); class_Guide_init(&_guideStraight_var); class_Guide_init(&_guideCurved1_var); class_Guide_init(&_guideCurved2_var); class_Guide_init(&_guideCurved3_var); class_Guide_init(&_guideCurved4_var); class_Guide_init(&_guideCurved5_var); class_Guide_init(&_guideCurved6_var); class_Guide_init(&_guideCurved7_var); class_Guide_init(&_guideCurved8_var); class_Guide_init(&_guideCurved9_var); class_Guide_init(&_guideCurved10_var); class_Guide_init(&_guideCurved11_var); class_Guide_init(&_guideCurved12_var); class_Guide_init(&_guideCurved13_var); class_Guide_init(&_guideCurved14_var); class_Guide_init(&_guideCurved15_var); class_Guide_init(&_guideCurved16_var); class_Guide_init(&_guideCurved17_var); class_Guide_init(&_guideCurved18_var); class_Guide_init(&_guideCurved19_var); class_Guide_init(&_guideCurved20_var); class_Guide_init(&_guideCurved21_var); class_Guide_init(&_guideCurved22_var); class_Guide_init(&_guideCurved23_var); class_Guide_init(&_guideCurved24_var); class_Guide_init(&_guideCurved25_var); class_Guide_init(&_guideCurved26_var); class_Guide_init(&_guideCurved27_var); class_Guide_init(&_guideCurved28_var); class_Guide_init(&_guideCurved29_var); class_Guide_init(&_guideCurved30_var); class_Guide_init(&_guideCurved31_var); class_Guide_init(&_guideCurved32_var); class_Guide_init(&_guideCurved33_var); class_Guide_init(&_guideCurved34_var); class_Guide_init(&_guideCurved35_var); class_Guide_init(&_guideCurved36_var); class_Guide_init(&_guideCurved37_var); class_Guide_init(&_guideCurved38_var); class_Guide_init(&_guideCurved39_var); class_Guide_init(&_guideCurved40_var); class_Guide_init(&_bunker_var); class_Guide_init(&_guide3_var); class_Slit_init(&_slitGuideEnd_var); class_PSD_monitor_init(&_psd_guide_end_var); class_E_monitor_init(&_emon_guide_end_var); class_L_monitor_init(&_lmon_guide_end_var); class_Divergence_monitor_init(&_divmon_guide_end_var); class_Monochromator_curved_init(&_monochromator_curved_var); class_Slit_init(&_slitShutter_var); class_Collimator_linear_init(&_MSCollimator_var); class_Filter_gen_init(&_infilter_var); class_PSD_monitor_init(&_psd_virt_var); class_L_monitor_init(&_lmon_virt_var); class_Monitor_nD_init(&_OrderMon_var); class_PSD_monitor_psf_eff_init(&_kMoni_var); class_PSD_monitor_psf_eff_init(&_kMoni1st_var); class_PSD_monitor_psf_eff_init(&_kMoni2nd_var); class_PSD_monitor_psf_eff_init(&_kMoni3rd_var); class_Slit_init(&_slitMonochromator_var); class_Incoherent_init(&_Perspex_var); class_PSD_monitor_init(&_psd_samplepos_1cm2_var); class_E_monitor_init(&_emon_samplepos_1cm2_var); class_Divergence_monitor_init(&_divmon_samplepos_1cm2_var); class_PSD_monitor_init(&_psd_samplepos_large_var); class_Incoherent_init(&_incohSample_var); class_PowderN_init(&_powderSample_var); class_Single_crystal_init(&_crystalSample_var); class_Phonon_simple_init(&_phononSample_var); class_PSD_monitor_4PI_init(&_psd_4pi_var); class_Slit_init(&_slitSample_var); class_Exact_radial_coll_init(&_filter_coll_var); class_Filter_gen_init(&_filter_var); class_Slit_init(&_ana_slit1_var); class_Slit_init(&_ana_slit2_var); class_E_monitor_init(&_emon_before_ana_var); class_PSD_monitor_init(&_psd_before_ana_var); class_Divergence_monitor_init(&_divmon_before_ana_var); class_Monochromator_flat_init(&_an1l_var); class_Monochromator_flat_init(&_an1u_var); class_Monochromator_flat_init(&_an2l_var); class_Monochromator_flat_init(&_an2u_var); class_Monochromator_flat_init(&_an3l_var); class_Monochromator_flat_init(&_an3u_var); class_Monochromator_flat_init(&_an4l_var); class_Monochromator_flat_init(&_an4u_var); class_Monochromator_flat_init(&_an5l_var); class_Monochromator_flat_init(&_an5u_var); class_Monochromator_flat_init(&_an6l_var); class_Monochromator_flat_init(&_an6u_var); class_Monochromator_flat_init(&_an7l_var); class_Monochromator_flat_init(&_an7u_var); class_Monochromator_flat_init(&_an8l_var); class_Monochromator_flat_init(&_an8u_var); class_Monochromator_flat_init(&_an9l_var); class_Monochromator_flat_init(&_an9u_var); class_E_monitor_init(&_emon_before_coarse_var); class_PSD_monitor_init(&_psd_before_coarse_var); class_Absorber_init(&_BladeR1_var); class_Absorber_init(&_BladeR2_var); class_Absorber_init(&_BladeR3_var); class_Absorber_init(&_BladeR4_var); class_Absorber_init(&_BladeR5_var); class_Absorber_init(&_BladeL1_var); class_Absorber_init(&_BladeL2_var); class_Absorber_init(&_BladeL3_var); class_Absorber_init(&_BladeL4_var); class_Absorber_init(&_BladeL5_var); class_PSD_monitor_psf_eff_init(&_psd_detector_var); class_E_monitor_init(&_emon_detector_var); class_PSD_monitor_psf_eff_init(&_psd_window1_var); class_E_monitor_init(&_emon_window1_var); class_PSD_monitor_psf_eff_init(&_psd_window2_var); class_E_monitor_init(&_emon_window2_var); class_PSD_monitor_psf_eff_init(&_psd_window3_var); class_E_monitor_init(&_emon_window3_var); class_PSD_monitor_psf_eff_init(&_psd_window4_var); class_E_monitor_init(&_emon_window4_var); class_PSD_monitor_psf_eff_init(&_psd_window5_var); class_E_monitor_init(&_emon_window5_var); class_PSD_monitor_psf_eff_init(&_psd_window6_var); class_E_monitor_init(&_emon_window6_var); class_PSD_monitor_psf_eff_init(&_psd_window7_var); class_E_monitor_init(&_emon_window7_var); class_PSD_monitor_psf_eff_init(&_psd_window8_var); class_E_monitor_init(&_emon_window8_var); class_PSD_monitor_psf_eff_init(&_psd_window9_var); class_E_monitor_init(&_emon_window9_var); if (mcdotrace) display(); DEBUG_INSTR_END(); #ifdef OPENACC #include #pragma acc update device(_armSource_var) #pragma acc update device(_source_var) #pragma acc update device(_slitGuideBegin_var) #pragma acc update device(_lmon_guide_start_var) #pragma acc update device(_guideStraight_var) #pragma acc update device(_guideCurved1_var) #pragma acc update device(_guideCurved2_var) #pragma acc update device(_guideCurved3_var) #pragma acc update device(_guideCurved4_var) #pragma acc update device(_guideCurved5_var) #pragma acc update device(_guideCurved6_var) #pragma acc update device(_guideCurved7_var) #pragma acc update device(_guideCurved8_var) #pragma acc update device(_guideCurved9_var) #pragma acc update device(_guideCurved10_var) #pragma acc update device(_guideCurved11_var) #pragma acc update device(_guideCurved12_var) #pragma acc update device(_guideCurved13_var) #pragma acc update device(_guideCurved14_var) #pragma acc update device(_guideCurved15_var) #pragma acc update device(_guideCurved16_var) #pragma acc update device(_guideCurved17_var) #pragma acc update device(_guideCurved18_var) #pragma acc update device(_guideCurved19_var) #pragma acc update device(_guideCurved20_var) #pragma acc update device(_guideCurved21_var) #pragma acc update device(_guideCurved22_var) #pragma acc update device(_guideCurved23_var) #pragma acc update device(_guideCurved24_var) #pragma acc update device(_guideCurved25_var) #pragma acc update device(_guideCurved26_var) #pragma acc update device(_guideCurved27_var) #pragma acc update device(_guideCurved28_var) #pragma acc update device(_guideCurved29_var) #pragma acc update device(_guideCurved30_var) #pragma acc update device(_guideCurved31_var) #pragma acc update device(_guideCurved32_var) #pragma acc update device(_guideCurved33_var) #pragma acc update device(_guideCurved34_var) #pragma acc update device(_guideCurved35_var) #pragma acc update device(_guideCurved36_var) #pragma acc update device(_guideCurved37_var) #pragma acc update device(_guideCurved38_var) #pragma acc update device(_guideCurved39_var) #pragma acc update device(_guideCurved40_var) #pragma acc update device(_bunker_var) #pragma acc update device(_guide3_var) #pragma acc update device(_slitGuideEnd_var) #pragma acc update device(_psd_guide_end_var) #pragma acc update device(_emon_guide_end_var) #pragma acc update device(_lmon_guide_end_var) #pragma acc update device(_divmon_guide_end_var) #pragma acc update device(_focus_mono_var) #pragma acc update device(_monochromator_curved_var) #pragma acc update device(_a2_var) #pragma acc update device(_slitShutter_var) #pragma acc update device(_MSCollimator_var) #pragma acc update device(_infilter_var) #pragma acc update device(_psd_virt_var) #pragma acc update device(_lmon_virt_var) #pragma acc update device(_aa2_var) #pragma acc update device(_OrderMon_var) #pragma acc update device(_kMoni_var) #pragma acc update device(_kMoni1st_var) #pragma acc update device(_kMoni2nd_var) #pragma acc update device(_kMoni3rd_var) #pragma acc update device(_slitMonochromator_var) #pragma acc update device(_Perspex_var) #pragma acc update device(_psd_samplepos_1cm2_var) #pragma acc update device(_emon_samplepos_1cm2_var) #pragma acc update device(_divmon_samplepos_1cm2_var) #pragma acc update device(_psd_samplepos_large_var) #pragma acc update device(_a3_var) #pragma acc update device(_aa3_var) #pragma acc update device(_incohSample_var) #pragma acc update device(_powderSample_var) #pragma acc update device(_crystalSample_var) #pragma acc update device(_phononSample_var) #pragma acc update device(_psd_4pi_var) #pragma acc update device(_a4_var) #pragma acc update device(_slitSample_var) #pragma acc update device(_filter_coll_var) #pragma acc update device(_filter_var) #pragma acc update device(_ana_slit1_var) #pragma acc update device(_ana_slit2_var) #pragma acc update device(_emon_before_ana_var) #pragma acc update device(_psd_before_ana_var) #pragma acc update device(_divmon_before_ana_var) #pragma acc update device(_focus_ana_var) #pragma acc update device(_an1l_var) #pragma acc update device(_an1u_var) #pragma acc update device(_an2l_var) #pragma acc update device(_an2u_var) #pragma acc update device(_an3l_var) #pragma acc update device(_an3u_var) #pragma acc update device(_an4l_var) #pragma acc update device(_an4u_var) #pragma acc update device(_an5l_var) #pragma acc update device(_an5u_var) #pragma acc update device(_an6l_var) #pragma acc update device(_an6u_var) #pragma acc update device(_an7l_var) #pragma acc update device(_an7u_var) #pragma acc update device(_an8l_var) #pragma acc update device(_an8u_var) #pragma acc update device(_an9l_var) #pragma acc update device(_an9u_var) #pragma acc update device(_a6_var) #pragma acc update device(_emon_before_coarse_var) #pragma acc update device(_psd_before_coarse_var) #pragma acc update device(_ArmR1_var) #pragma acc update device(_BladeR1_var) #pragma acc update device(_ArmR2_var) #pragma acc update device(_BladeR2_var) #pragma acc update device(_ArmR3_var) #pragma acc update device(_BladeR3_var) #pragma acc update device(_ArmR4_var) #pragma acc update device(_BladeR4_var) #pragma acc update device(_ArmR5_var) #pragma acc update device(_BladeR5_var) #pragma acc update device(_ArmL1_var) #pragma acc update device(_BladeL1_var) #pragma acc update device(_ArmL2_var) #pragma acc update device(_BladeL2_var) #pragma acc update device(_ArmL3_var) #pragma acc update device(_BladeL3_var) #pragma acc update device(_ArmL4_var) #pragma acc update device(_BladeL4_var) #pragma acc update device(_ArmL5_var) #pragma acc update device(_BladeL5_var) #pragma acc update device(_psd_detector_var) #pragma acc update device(_emon_detector_var) #pragma acc update device(_psd_window1_var) #pragma acc update device(_emon_window1_var) #pragma acc update device(_psd_window2_var) #pragma acc update device(_emon_window2_var) #pragma acc update device(_psd_window3_var) #pragma acc update device(_emon_window3_var) #pragma acc update device(_psd_window4_var) #pragma acc update device(_emon_window4_var) #pragma acc update device(_psd_window5_var) #pragma acc update device(_emon_window5_var) #pragma acc update device(_psd_window6_var) #pragma acc update device(_emon_window6_var) #pragma acc update device(_psd_window7_var) #pragma acc update device(_emon_window7_var) #pragma acc update device(_psd_window8_var) #pragma acc update device(_emon_window8_var) #pragma acc update device(_psd_window9_var) #pragma acc update device(_emon_window9_var) #pragma acc update device(_instrument_var) #endif return(0); } /* init */ /******************************************************************************* * components TRACE *******************************************************************************/ #define x (_particle->x) #define y (_particle->y) #define z (_particle->z) #define vx (_particle->vx) #define vy (_particle->vy) #define vz (_particle->vz) #define t (_particle->t) #define sx (_particle->sx) #define sy (_particle->sy) #define sz (_particle->sz) #define p (_particle->p) #define mcgravitation (_particle->mcgravitation) #define mcMagnet (_particle->mcMagnet) #define allow_backprop (_particle->allow_backprop) #define _mctmp_a (_particle->_mctmp_a) #define _mctmp_b (_particle->_mctmp_b) #define _mctmp_c (_particle->_mctmp_c) /* if on GPU, globally nullify sprintf,fprintf,printfs */ /* (Similar defines are available in each comp trace but */ /* those are not enough to handle external libs etc. ) */ #ifdef OPENACC #define fprintf(stderr,...) printf(__VA_ARGS__) #define sprintf(string,...) printf(__VA_ARGS__) #define exit(...) noprintf() #define strcmp(a,b) str_comp(a,b) #define strlen(a) str_len(a) #endif #define SCATTERED (_particle->_scattered) #define RESTORE (_particle->_restore) #define RESTORE_NEUTRON(_index, ...) _particle->_restore = _index; #define ABSORB0 do { DEBUG_STATE(); DEBUG_ABSORB(); MAGNET_OFF; ABSORBED++; return; } while(0) #define ABSORBED (_particle->_absorbed) #define mcget_run_num() _particle->_uid #define ABSORB ABSORB0 #pragma acc routine void class_Progress_bar_trace(_class_Progress_bar *_comp , _class_particle *_particle) { ABSORBED=SCATTERED=RESTORE=0; #define profile (_comp->_parameters.profile) #define percent (_comp->_parameters.percent) #define flag_save (_comp->_parameters.flag_save) #define minutes (_comp->_parameters.minutes) #define IntermediateCnts (_comp->_parameters.IntermediateCnts) #define StartTime (_comp->_parameters.StartTime) #define EndTime (_comp->_parameters.EndTime) #define CurrentTime (_comp->_parameters.CurrentTime) #define infostring (_comp->_parameters.infostring) SIG_MESSAGE("[_armSource_trace] component armSource=Progress_bar() TRACE [Progress_bar:0]"); #ifndef OPENACC double ncount; ncount = mcget_run_num (); if (!StartTime) { time (&StartTime); /* compute starting time */ IntermediateCnts = 1e3; } time_t NowTime; time (&NowTime); /* compute initial estimate of computation duration */ if (!EndTime && ncount >= IntermediateCnts) { CurrentTime = NowTime; if (difftime (NowTime, StartTime) > 10 && ncount) { /* wait 10 sec before writing ETA */ EndTime = StartTime + (time_t)(difftime (NowTime, StartTime) * (double)mcget_ncount () / ncount); IntermediateCnts = 0; MPI_MASTER (fprintf (stdout, "\nTrace ETA "); fprintf (stdout, "%s", infostring); if (difftime (EndTime, StartTime) < 60.0) fprintf (stdout, "%g [s] ", difftime (EndTime, StartTime)); else if (difftime (EndTime, StartTime) > 3600.0) fprintf (stdout, "%g [h] ", difftime (EndTime, StartTime) / 3600.0); else fprintf (stdout, "%g [min] ", difftime (EndTime, StartTime) / 60.0); fprintf (stdout, "\n");); } else IntermediateCnts += 1e3; fflush (stdout); } /* display percentage when percent or minutes have reached step */ if (EndTime && mcget_ncount () && ((minutes && difftime (NowTime, CurrentTime) > minutes * 60) || (percent && !minutes && ncount >= IntermediateCnts))) { MPI_MASTER (fprintf (stdout, "%llu %%\n", (unsigned long long)(ncount * 100.0 / mcget_ncount ())); fflush (stdout);); CurrentTime = NowTime; IntermediateCnts = ncount + percent * mcget_ncount () / 100; /* check that next intermediate ncount check is a multiple of the desired percentage */ IntermediateCnts = floor (IntermediateCnts * 100 / percent / mcget_ncount ()) * percent * mcget_ncount () / 100; /* raise flag to indicate that we did something */ SCATTER; if (flag_save) save (NULL); } #endif #ifndef NOABSORB_INF_NAN /* Check for nan or inf particle parms */ if(isnan(p + t + vx + vy + vz + x + y + z)) ABSORB; if(isinf(fabs(p) + fabs(t) + fabs(vx) + fabs(vy) + fabs(vz) + fabs(x) + fabs(y) + fabs(z))) ABSORB; #else if(isnan(p) || isinf(p)) printf("NAN or INF found in p, %s (particle %lld)\n",_comp->_name,_particle->_uid); if(isnan(t) || isinf(t)) printf("NAN or INF found in t, %s (particle %lld)\n",_comp->_name,_particle->_uid); if(isnan(vx) || isinf(vx)) printf("NAN or INF found in vx, %s (particle %lld)\n",_comp->_name,_particle->_uid); if(isnan(vy) || isinf(vy)) printf("NAN or INF found in vy, %s (particle %lld)\n",_comp->_name,_particle->_uid); if(isnan(vz) || isinf(vz)) printf("NAN or INF found in vz, %s (particle %lld)\n",_comp->_name,_particle->_uid); if(isnan(x) || isinf(x)) printf("NAN or INF found in x, %s (particle %lld)\n",_comp->_name,_particle->_uid); if(isnan(y) || isinf(y)) printf("NAN or INF found in y, %s (particle %lld)\n",_comp->_name,_particle->_uid); if(isnan(z) || isinf(z)) printf("NAN or INF found in z, %s (particle %lld)\n",_comp->_name,_particle->_uid); #endif #undef profile #undef percent #undef flag_save #undef minutes #undef IntermediateCnts #undef StartTime #undef EndTime #undef CurrentTime #undef infostring return; } /* class_Progress_bar_trace */ #pragma acc routine void class_Source_gen4_trace(_class_Source_gen4 *_comp , _class_particle *_particle) { ABSORBED=SCATTERED=RESTORE=0; #define flux_file (_comp->_parameters.flux_file) #define xdiv_file (_comp->_parameters.xdiv_file) #define ydiv_file (_comp->_parameters.ydiv_file) #define radius (_comp->_parameters.radius) #define dist (_comp->_parameters.dist) #define xw (_comp->_parameters.xw) #define yh (_comp->_parameters.yh) #define E0 (_comp->_parameters.E0) #define dE (_comp->_parameters.dE) #define Lambda0 (_comp->_parameters.Lambda0) #define dLambda (_comp->_parameters.dLambda) #define I1 (_comp->_parameters.I1) #define h (_comp->_parameters.h) #define w (_comp->_parameters.w) #define gaussian (_comp->_parameters.gaussian) #define verbose (_comp->_parameters.verbose) #define T1 (_comp->_parameters.T1) #define flux_file_perAA (_comp->_parameters.flux_file_perAA) #define flux_file_log (_comp->_parameters.flux_file_log) #define Lmin (_comp->_parameters.Lmin) #define Lmax (_comp->_parameters.Lmax) #define Emin (_comp->_parameters.Emin) #define Emax (_comp->_parameters.Emax) #define T2 (_comp->_parameters.T2) #define I2 (_comp->_parameters.I2) #define T3 (_comp->_parameters.T3) #define I3 (_comp->_parameters.I3) #define length (_comp->_parameters.length) #define phi_init (_comp->_parameters.phi_init) #define theta_init (_comp->_parameters.theta_init) #define HEtailA (_comp->_parameters.HEtailA) #define HEtailL0 (_comp->_parameters.HEtailL0) #define pTable (_comp->_parameters.pTable) #define pTable_x (_comp->_parameters.pTable_x) #define pTable_y (_comp->_parameters.pTable_y) #define p_in (_comp->_parameters.p_in) #define lambda0 (_comp->_parameters.lambda0) #define lambda02 (_comp->_parameters.lambda02) #define lambda0b (_comp->_parameters.lambda0b) #define lambda02b (_comp->_parameters.lambda02b) #define lambda0c (_comp->_parameters.lambda0c) #define lambda02c (_comp->_parameters.lambda02c) #define L2P (_comp->_parameters.L2P) #define L2Pb (_comp->_parameters.L2Pb) #define L2Pc (_comp->_parameters.L2Pc) #define pTable_xmin (_comp->_parameters.pTable_xmin) #define pTable_ymin (_comp->_parameters.pTable_ymin) #define pTable_xmax (_comp->_parameters.pTable_xmax) #define pTable_ymax (_comp->_parameters.pTable_ymax) #define pTable_xsum (_comp->_parameters.pTable_xsum) #define pTable_ysum (_comp->_parameters.pTable_ysum) #define pTable_dxmin (_comp->_parameters.pTable_dxmin) #define pTable_dxmax (_comp->_parameters.pTable_dxmax) #define pTable_dymin (_comp->_parameters.pTable_dymin) #define pTable_dymax (_comp->_parameters.pTable_dymax) SIG_MESSAGE("[_source_trace] component source=Source_gen4() TRACE [Source_gen4:0]"); double theta0, phi0, theta1, phi1, chi, theta, phi, v, r, lambda; double tan_h, tan_v, Maxwell, lambda2, lambda5; if (verbose >= 0) { z = 0; if ((h == 0) || (w == 0)) { chi = 2 * PI * rand01 (); /* Choose point on source */ r = sqrt (rand01 ()) * radius; /* with uniform distribution. */ x = r * cos (chi); y = r * sin (chi); } else { x = w * randpm1 () / 2; /* select point on source (uniform) */ y = h * randpm1 () / 2; } if (length != 0) z = length * randpm1 () / 2; if (dist == 0) { theta0 = DEG2RAD * xw / 2; phi0 = DEG2RAD * yh / 2; theta1 = -DEG2RAD * xw / 2; phi1 = -DEG2RAD * yh / 2; } else { theta0 = -atan ((x - xw / 2.0) / dist) + theta_init / 180 * 3.1415; /* Angles to aim at target */ phi0 = -atan ((y - yh / 2.0) / dist) + phi_init / 180 * 3.1415; theta1 = -atan ((x + xw / 2.0) / dist) + theta_init / 180 * 3.1415; phi1 = -atan ((y + yh / 2.0) / dist) + phi_init / 180 * 3.1415; } /* shot towards target : flat distribution */ if (gaussian) { theta = theta0 + (theta1 - theta0) * (randnorm () * FWHM2RMS + 0.5); phi = phi0 + (phi1 - phi0) * (randnorm () * FWHM2RMS + 0.5); } else { theta = theta0 + (theta1 - theta0) * rand01 (); phi = phi0 + (phi1 - phi0) * rand01 (); } /* Assume linear distribution */ lambda = Lambda0 + dLambda * randpm1 (); if (lambda <= 0) ABSORB; v = K2V * (2 * PI / lambda); p = p_in; if (!flux_file || !strlen (flux_file)) p *= 2 * fabs ((theta1 - theta0) * sin ((phi1 - phi0) / 2)); /* solid angle */ p *= cos (phi) * cos (theta); if (flux_file && strlen (flux_file) > 0) { double W = Table_Value (pTable, lambda, 1); if (flux_file_log) W = exp (W); p *= W; } else if (T1 > 0 && I1 > 0) { lambda2 = lambda * lambda; lambda5 = lambda2 * lambda2 * lambda; Maxwell = I1 * L2P / lambda5 * exp (-lambda02 / lambda2); /* 1/AA */ if ((T2 > 0) && (I2 > 0)) { Maxwell += I2 * L2Pb / lambda5 * exp (-lambda02b / lambda2); } if ((T3 > 0) && (I3 > 0)) { Maxwell += I3 * L2Pc / lambda5 * exp (-lambda02c / lambda2); } if (HEtailA > 0) { Maxwell += HEtailA / (lambda - HEtailL0) / (lambda - HEtailL0); } p *= Maxwell; } /* Perform the correct treatment - no small angle approx. here! */ tan_h = tan (theta); tan_v = tan (phi); vz = v / sqrt (1 + tan_v * tan_v + tan_h * tan_h); vy = tan_v * vz; vx = tan_h * vz; /* optional x-xdiv and y-ydiv weightening: position=along columns, div=along rows */ if (xdiv_file && strlen (xdiv_file) > 0 && pTable_xsum > 0) { double i, j; j = (x - pTable_xmin) / (pTable_xmax - pTable_xmin) * pTable_x.columns; i = (theta * RAD2DEG - pTable_dxmin) / (pTable_dxmax - pTable_dxmin) * pTable_x.rows; r = Table_Value2d (pTable_x, i, j); /* row, column */ p *= r / pTable_xsum; } if (ydiv_file && strlen (ydiv_file) > 0 && pTable_ysum > 0) { double i, j; j = (y - pTable_ymin) / (pTable_ymax - pTable_ymin) * pTable_y.columns; i = (phi * RAD2DEG - pTable_dymin) / (pTable_dymax - pTable_dymin) * pTable_y.rows; r = Table_Value2d (pTable_y, i, j); p *= r / pTable_ysum; } SCATTER; } #ifndef NOABSORB_INF_NAN /* Check for nan or inf particle parms */ if(isnan(p + t + vx + vy + vz + x + y + z)) ABSORB; if(isinf(fabs(p) + fabs(t) + fabs(vx) + fabs(vy) + fabs(vz) + fabs(x) + fabs(y) + fabs(z))) ABSORB; #else if(isnan(p) || isinf(p)) printf("NAN or INF found in p, %s (particle %lld)\n",_comp->_name,_particle->_uid); if(isnan(t) || isinf(t)) printf("NAN or INF found in t, %s (particle %lld)\n",_comp->_name,_particle->_uid); if(isnan(vx) || isinf(vx)) printf("NAN or INF found in vx, %s (particle %lld)\n",_comp->_name,_particle->_uid); if(isnan(vy) || isinf(vy)) printf("NAN or INF found in vy, %s (particle %lld)\n",_comp->_name,_particle->_uid); if(isnan(vz) || isinf(vz)) printf("NAN or INF found in vz, %s (particle %lld)\n",_comp->_name,_particle->_uid); if(isnan(x) || isinf(x)) printf("NAN or INF found in x, %s (particle %lld)\n",_comp->_name,_particle->_uid); if(isnan(y) || isinf(y)) printf("NAN or INF found in y, %s (particle %lld)\n",_comp->_name,_particle->_uid); if(isnan(z) || isinf(z)) printf("NAN or INF found in z, %s (particle %lld)\n",_comp->_name,_particle->_uid); #endif #undef flux_file #undef xdiv_file #undef ydiv_file #undef radius #undef dist #undef xw #undef yh #undef E0 #undef dE #undef Lambda0 #undef dLambda #undef I1 #undef h #undef w #undef gaussian #undef verbose #undef T1 #undef flux_file_perAA #undef flux_file_log #undef Lmin #undef Lmax #undef Emin #undef Emax #undef T2 #undef I2 #undef T3 #undef I3 #undef length #undef phi_init #undef theta_init #undef HEtailA #undef HEtailL0 #undef pTable #undef pTable_x #undef pTable_y #undef p_in #undef lambda0 #undef lambda02 #undef lambda0b #undef lambda02b #undef lambda0c #undef lambda02c #undef L2P #undef L2Pb #undef L2Pc #undef pTable_xmin #undef pTable_ymin #undef pTable_xmax #undef pTable_ymax #undef pTable_xsum #undef pTable_ysum #undef pTable_dxmin #undef pTable_dxmax #undef pTable_dymin #undef pTable_dymax return; } /* class_Source_gen4_trace */ #pragma acc routine void class_Slit_trace(_class_Slit *_comp , _class_particle *_particle) { ABSORBED=SCATTERED=RESTORE=0; #define xmin (_comp->_parameters.xmin) #define xmax (_comp->_parameters.xmax) #define ymin (_comp->_parameters.ymin) #define ymax (_comp->_parameters.ymax) #define radius (_comp->_parameters.radius) #define xwidth (_comp->_parameters.xwidth) #define yheight (_comp->_parameters.yheight) #define isradial (_comp->_parameters.isradial) SIG_MESSAGE("[_slitGuideBegin_trace] component slitGuideBegin=Slit() TRACE [Slit:0]"); PROP_Z0; if (!isradial ? (x < xmin || x > xmax || y < ymin || y > ymax) : (x * x + y * y > radius * radius)) ABSORB; else SCATTER; #ifndef NOABSORB_INF_NAN /* Check for nan or inf particle parms */ if(isnan(p + t + vx + vy + vz + x + y + z)) ABSORB; if(isinf(fabs(p) + fabs(t) + fabs(vx) + fabs(vy) + fabs(vz) + fabs(x) + fabs(y) + fabs(z))) ABSORB; #else if(isnan(p) || isinf(p)) printf("NAN or INF found in p, %s (particle %lld)\n",_comp->_name,_particle->_uid); if(isnan(t) || isinf(t)) printf("NAN or INF found in t, %s (particle %lld)\n",_comp->_name,_particle->_uid); if(isnan(vx) || isinf(vx)) printf("NAN or INF found in vx, %s (particle %lld)\n",_comp->_name,_particle->_uid); if(isnan(vy) || isinf(vy)) printf("NAN or INF found in vy, %s (particle %lld)\n",_comp->_name,_particle->_uid); if(isnan(vz) || isinf(vz)) printf("NAN or INF found in vz, %s (particle %lld)\n",_comp->_name,_particle->_uid); if(isnan(x) || isinf(x)) printf("NAN or INF found in x, %s (particle %lld)\n",_comp->_name,_particle->_uid); if(isnan(y) || isinf(y)) printf("NAN or INF found in y, %s (particle %lld)\n",_comp->_name,_particle->_uid); if(isnan(z) || isinf(z)) printf("NAN or INF found in z, %s (particle %lld)\n",_comp->_name,_particle->_uid); #endif #undef xmin #undef xmax #undef ymin #undef ymax #undef radius #undef xwidth #undef yheight #undef isradial return; } /* class_Slit_trace */ #pragma acc routine void class_L_monitor_trace(_class_L_monitor *_comp , _class_particle *_particle) { ABSORBED=SCATTERED=RESTORE=0; #define nL (_comp->_parameters.nL) #define filename (_comp->_parameters.filename) #define nowritefile (_comp->_parameters.nowritefile) #define xmin (_comp->_parameters.xmin) #define xmax (_comp->_parameters.xmax) #define ymin (_comp->_parameters.ymin) #define ymax (_comp->_parameters.ymax) #define xwidth (_comp->_parameters.xwidth) #define yheight (_comp->_parameters.yheight) #define Lmin (_comp->_parameters.Lmin) #define Lmax (_comp->_parameters.Lmax) #define restore_neutron (_comp->_parameters.restore_neutron) #define L_N (_comp->_parameters.L_N) #define L_p (_comp->_parameters.L_p) #define L_p2 (_comp->_parameters.L_p2) SIG_MESSAGE("[_lmon_guide_start_trace] component lmon_guide_start=L_monitor() TRACE [L_monitor:0]"); PROP_Z0; if (x > xmin && x < xmax && y > ymin && y < ymax) { double L = (2 * PI / V2K) / sqrt (vx * vx + vy * vy + vz * vz); int i = floor ((L - Lmin) * nL / (Lmax - Lmin)); if (i >= 0 && i < nL) { double p2 = p * p; #pragma acc atomic L_N[i] = L_N[i] + 1; #pragma acc atomic L_p[i] = L_p[i] + p; #pragma acc atomic L_p2[i] = L_p2[i] + p2; SCATTER; } } if (restore_neutron) { RESTORE_NEUTRON (INDEX_CURRENT_COMP, x, y, z, vx, vy, vz, t, sx, sy, sz, p); } #ifndef NOABSORB_INF_NAN /* Check for nan or inf particle parms */ if(isnan(p + t + vx + vy + vz + x + y + z)) ABSORB; if(isinf(fabs(p) + fabs(t) + fabs(vx) + fabs(vy) + fabs(vz) + fabs(x) + fabs(y) + fabs(z))) ABSORB; #else if(isnan(p) || isinf(p)) printf("NAN or INF found in p, %s (particle %lld)\n",_comp->_name,_particle->_uid); if(isnan(t) || isinf(t)) printf("NAN or INF found in t, %s (particle %lld)\n",_comp->_name,_particle->_uid); if(isnan(vx) || isinf(vx)) printf("NAN or INF found in vx, %s (particle %lld)\n",_comp->_name,_particle->_uid); if(isnan(vy) || isinf(vy)) printf("NAN or INF found in vy, %s (particle %lld)\n",_comp->_name,_particle->_uid); if(isnan(vz) || isinf(vz)) printf("NAN or INF found in vz, %s (particle %lld)\n",_comp->_name,_particle->_uid); if(isnan(x) || isinf(x)) printf("NAN or INF found in x, %s (particle %lld)\n",_comp->_name,_particle->_uid); if(isnan(y) || isinf(y)) printf("NAN or INF found in y, %s (particle %lld)\n",_comp->_name,_particle->_uid); if(isnan(z) || isinf(z)) printf("NAN or INF found in z, %s (particle %lld)\n",_comp->_name,_particle->_uid); #endif #undef nL #undef filename #undef nowritefile #undef xmin #undef xmax #undef ymin #undef ymax #undef xwidth #undef yheight #undef Lmin #undef Lmax #undef restore_neutron #undef L_N #undef L_p #undef L_p2 return; } /* class_L_monitor_trace */ #pragma acc routine void class_Guide_trace(_class_Guide *_comp , _class_particle *_particle) { ABSORBED=SCATTERED=RESTORE=0; #define reflect (_comp->_parameters.reflect) #define w1 (_comp->_parameters.w1) #define h1 (_comp->_parameters.h1) #define w2 (_comp->_parameters.w2) #define h2 (_comp->_parameters.h2) #define l (_comp->_parameters.l) #define R0 (_comp->_parameters.R0) #define Qc (_comp->_parameters.Qc) #define alpha (_comp->_parameters.alpha) #define m (_comp->_parameters.m) #define W (_comp->_parameters.W) #define pTable (_comp->_parameters.pTable) #define table_present (_comp->_parameters.table_present) SIG_MESSAGE("[_guideStraight_trace] component guideStraight=Guide() TRACE [Guide:0]"); double t1, t2; /* Intersection times. */ double av, ah, bv, bh, cv1, cv2, ch1, ch2, d; /* Intermediate values */ double weight; /* Internal probability weight */ double vdotn_v1, vdotn_v2, vdotn_h1, vdotn_h2; /* Dot products. */ int i; /* Which mirror hit? */ double q; /* Q [1/AA] of reflection */ double nlen2; /* Vector lengths squared */ double par[5] = { R0, Qc, alpha, m, W }; /* ToDo: These could be precalculated. */ double ww = .5 * (w2 - w1), hh = .5 * (h2 - h1); double whalf = .5 * w1, hhalf = .5 * h1; /* Propagate neutron to guide entrance. */ PROP_Z0; /* Scatter here to ensure that fully transmitted neutrons will not be absorbed in a GROUP construction, e.g. all neutrons - even the later absorbed ones are scattered at the guide entry. */ SCATTER; if (x <= -whalf || x >= whalf || y <= -hhalf || y >= hhalf) ABSORB; for (;;) { /* Compute the dot products of v and n for the four mirrors. */ av = l * vx; bv = ww * vz; ah = l * vy; bh = hh * vz; vdotn_v1 = bv + av; /* Left vertical */ vdotn_v2 = bv - av; /* Right vertical */ vdotn_h1 = bh + ah; /* Lower horizontal */ vdotn_h2 = bh - ah; /* Upper horizontal */ /* Compute the dot products of (O - r) and n as c1+c2 and c1-c2 */ cv1 = -whalf * l - z * ww; cv2 = x * l; ch1 = -hhalf * l - z * hh; ch2 = y * l; /* Compute intersection times. */ t1 = (l - z) / vz; i = 0; if (vdotn_v1 < 0 && (t2 = (cv1 - cv2) / vdotn_v1) < t1) { t1 = t2; i = 1; } if (vdotn_v2 < 0 && (t2 = (cv1 + cv2) / vdotn_v2) < t1) { t1 = t2; i = 2; } if (vdotn_h1 < 0 && (t2 = (ch1 - ch2) / vdotn_h1) < t1) { t1 = t2; i = 3; } if (vdotn_h2 < 0 && (t2 = (ch1 + ch2) / vdotn_h2) < t1) { t1 = t2; i = 4; } if (i == 0) break; /* Neutron left guide. */ PROP_DT (t1); switch (i) { case 1: /* Left vertical mirror */ nlen2 = l * l + ww * ww; q = V2Q * (-2) * vdotn_v1 / sqrt (nlen2); d = 2 * vdotn_v1 / nlen2; vx = vx - d * l; vz = vz - d * ww; break; case 2: /* Right vertical mirror */ nlen2 = l * l + ww * ww; q = V2Q * (-2) * vdotn_v2 / sqrt (nlen2); d = 2 * vdotn_v2 / nlen2; vx = vx + d * l; vz = vz - d * ww; break; case 3: /* Lower horizontal mirror */ nlen2 = l * l + hh * hh; q = V2Q * (-2) * vdotn_h1 / sqrt (nlen2); d = 2 * vdotn_h1 / nlen2; vy = vy - d * l; vz = vz - d * hh; break; case 4: /* Upper horizontal mirror */ nlen2 = l * l + hh * hh; q = V2Q * (-2) * vdotn_h2 / sqrt (nlen2); d = 2 * vdotn_h2 / nlen2; vy = vy + d * l; vz = vz - d * hh; break; } /* Now compute reflectivity. */ weight = 1.0; /* Initial internal weight factor */ if (m == 0) ABSORB; if (reflect && table_present == 1) TableReflecFunc (q, &pTable, &weight); else { StdReflecFunc (q, par, &weight); } if (weight > 0) p *= weight; else ABSORB; SCATTER; } #ifndef NOABSORB_INF_NAN /* Check for nan or inf particle parms */ if(isnan(p + t + vx + vy + vz + x + y + z)) ABSORB; if(isinf(fabs(p) + fabs(t) + fabs(vx) + fabs(vy) + fabs(vz) + fabs(x) + fabs(y) + fabs(z))) ABSORB; #else if(isnan(p) || isinf(p)) printf("NAN or INF found in p, %s (particle %lld)\n",_comp->_name,_particle->_uid); if(isnan(t) || isinf(t)) printf("NAN or INF found in t, %s (particle %lld)\n",_comp->_name,_particle->_uid); if(isnan(vx) || isinf(vx)) printf("NAN or INF found in vx, %s (particle %lld)\n",_comp->_name,_particle->_uid); if(isnan(vy) || isinf(vy)) printf("NAN or INF found in vy, %s (particle %lld)\n",_comp->_name,_particle->_uid); if(isnan(vz) || isinf(vz)) printf("NAN or INF found in vz, %s (particle %lld)\n",_comp->_name,_particle->_uid); if(isnan(x) || isinf(x)) printf("NAN or INF found in x, %s (particle %lld)\n",_comp->_name,_particle->_uid); if(isnan(y) || isinf(y)) printf("NAN or INF found in y, %s (particle %lld)\n",_comp->_name,_particle->_uid); if(isnan(z) || isinf(z)) printf("NAN or INF found in z, %s (particle %lld)\n",_comp->_name,_particle->_uid); #endif #undef reflect #undef w1 #undef h1 #undef w2 #undef h2 #undef l #undef R0 #undef Qc #undef alpha #undef m #undef W #undef pTable #undef table_present return; } /* class_Guide_trace */ #pragma acc routine void class_PSD_monitor_trace(_class_PSD_monitor *_comp , _class_particle *_particle) { ABSORBED=SCATTERED=RESTORE=0; #define nx (_comp->_parameters.nx) #define ny (_comp->_parameters.ny) #define filename (_comp->_parameters.filename) #define xmin (_comp->_parameters.xmin) #define xmax (_comp->_parameters.xmax) #define ymin (_comp->_parameters.ymin) #define ymax (_comp->_parameters.ymax) #define xwidth (_comp->_parameters.xwidth) #define yheight (_comp->_parameters.yheight) #define restore_neutron (_comp->_parameters.restore_neutron) #define nowritefile (_comp->_parameters.nowritefile) #define PSD_N (_comp->_parameters.PSD_N) #define PSD_p (_comp->_parameters.PSD_p) #define PSD_p2 (_comp->_parameters.PSD_p2) SIG_MESSAGE("[_psd_guide_end_trace] component psd_guide_end=PSD_monitor() TRACE [PSD_monitor:0]"); PROP_Z0; if (x > xmin && x < xmax && y > ymin && y < ymax) { int i = floor ((x - xmin) * nx / (xmax - xmin)); int j = floor ((y - ymin) * ny / (ymax - ymin)); double p2 = p * p; #pragma acc atomic PSD_N[i][j] = PSD_N[i][j] + 1; #pragma acc atomic PSD_p[i][j] = PSD_p[i][j] + p; #pragma acc atomic PSD_p2[i][j] = PSD_p2[i][j] + p2; SCATTER; } if (restore_neutron) { RESTORE_NEUTRON (INDEX_CURRENT_COMP, x, y, z, vx, vy, vz, t, sx, sy, sz, p); } #ifndef NOABSORB_INF_NAN /* Check for nan or inf particle parms */ if(isnan(p + t + vx + vy + vz + x + y + z)) ABSORB; if(isinf(fabs(p) + fabs(t) + fabs(vx) + fabs(vy) + fabs(vz) + fabs(x) + fabs(y) + fabs(z))) ABSORB; #else if(isnan(p) || isinf(p)) printf("NAN or INF found in p, %s (particle %lld)\n",_comp->_name,_particle->_uid); if(isnan(t) || isinf(t)) printf("NAN or INF found in t, %s (particle %lld)\n",_comp->_name,_particle->_uid); if(isnan(vx) || isinf(vx)) printf("NAN or INF found in vx, %s (particle %lld)\n",_comp->_name,_particle->_uid); if(isnan(vy) || isinf(vy)) printf("NAN or INF found in vy, %s (particle %lld)\n",_comp->_name,_particle->_uid); if(isnan(vz) || isinf(vz)) printf("NAN or INF found in vz, %s (particle %lld)\n",_comp->_name,_particle->_uid); if(isnan(x) || isinf(x)) printf("NAN or INF found in x, %s (particle %lld)\n",_comp->_name,_particle->_uid); if(isnan(y) || isinf(y)) printf("NAN or INF found in y, %s (particle %lld)\n",_comp->_name,_particle->_uid); if(isnan(z) || isinf(z)) printf("NAN or INF found in z, %s (particle %lld)\n",_comp->_name,_particle->_uid); #endif #undef nx #undef ny #undef filename #undef xmin #undef xmax #undef ymin #undef ymax #undef xwidth #undef yheight #undef restore_neutron #undef nowritefile #undef PSD_N #undef PSD_p #undef PSD_p2 return; } /* class_PSD_monitor_trace */ #pragma acc routine void class_E_monitor_trace(_class_E_monitor *_comp , _class_particle *_particle) { ABSORBED=SCATTERED=RESTORE=0; #define nE (_comp->_parameters.nE) #define filename (_comp->_parameters.filename) #define xmin (_comp->_parameters.xmin) #define xmax (_comp->_parameters.xmax) #define ymin (_comp->_parameters.ymin) #define ymax (_comp->_parameters.ymax) #define nowritefile (_comp->_parameters.nowritefile) #define xwidth (_comp->_parameters.xwidth) #define yheight (_comp->_parameters.yheight) #define Emin (_comp->_parameters.Emin) #define Emax (_comp->_parameters.Emax) #define restore_neutron (_comp->_parameters.restore_neutron) #define E_N (_comp->_parameters.E_N) #define E_p (_comp->_parameters.E_p) #define E_p2 (_comp->_parameters.E_p2) #define S_p (_comp->_parameters.S_p) #define S_pE (_comp->_parameters.S_pE) #define S_pE2 (_comp->_parameters.S_pE2) SIG_MESSAGE("[_emon_guide_end_trace] component emon_guide_end=E_monitor() TRACE [E_monitor:0]"); int i; double E; PROP_Z0; if (x > xmin && x < xmax && y > ymin && y < ymax) { E = VS2E * (vx * vx + vy * vy + vz * vz); S_p += p; S_pE += p * E; S_pE2 += p * E * E; i = floor ((E - Emin) * nE / (Emax - Emin)); if (i >= 0 && i < nE) { double p2 = p * p; #pragma acc atomic E_N[i] = E_N[i] + 1; #pragma acc atomic E_p[i] = E_p[i] + p; #pragma acc atomic E_p2[i] = E_p2[i] + p2; SCATTER; } } if (restore_neutron) { RESTORE_NEUTRON (INDEX_CURRENT_COMP, x, y, z, vx, vy, vz, t, sx, sy, sz, p); } #ifndef NOABSORB_INF_NAN /* Check for nan or inf particle parms */ if(isnan(p + t + vx + vy + vz + x + y + z)) ABSORB; if(isinf(fabs(p) + fabs(t) + fabs(vx) + fabs(vy) + fabs(vz) + fabs(x) + fabs(y) + fabs(z))) ABSORB; #else if(isnan(p) || isinf(p)) printf("NAN or INF found in p, %s (particle %lld)\n",_comp->_name,_particle->_uid); if(isnan(t) || isinf(t)) printf("NAN or INF found in t, %s (particle %lld)\n",_comp->_name,_particle->_uid); if(isnan(vx) || isinf(vx)) printf("NAN or INF found in vx, %s (particle %lld)\n",_comp->_name,_particle->_uid); if(isnan(vy) || isinf(vy)) printf("NAN or INF found in vy, %s (particle %lld)\n",_comp->_name,_particle->_uid); if(isnan(vz) || isinf(vz)) printf("NAN or INF found in vz, %s (particle %lld)\n",_comp->_name,_particle->_uid); if(isnan(x) || isinf(x)) printf("NAN or INF found in x, %s (particle %lld)\n",_comp->_name,_particle->_uid); if(isnan(y) || isinf(y)) printf("NAN or INF found in y, %s (particle %lld)\n",_comp->_name,_particle->_uid); if(isnan(z) || isinf(z)) printf("NAN or INF found in z, %s (particle %lld)\n",_comp->_name,_particle->_uid); #endif #undef nE #undef filename #undef xmin #undef xmax #undef ymin #undef ymax #undef nowritefile #undef xwidth #undef yheight #undef Emin #undef Emax #undef restore_neutron #undef E_N #undef E_p #undef E_p2 #undef S_p #undef S_pE #undef S_pE2 return; } /* class_E_monitor_trace */ #pragma acc routine void class_Divergence_monitor_trace(_class_Divergence_monitor *_comp , _class_particle *_particle) { ABSORBED=SCATTERED=RESTORE=0; #define nh (_comp->_parameters.nh) #define nv (_comp->_parameters.nv) #define filename (_comp->_parameters.filename) #define xmin (_comp->_parameters.xmin) #define xmax (_comp->_parameters.xmax) #define ymin (_comp->_parameters.ymin) #define ymax (_comp->_parameters.ymax) #define nowritefile (_comp->_parameters.nowritefile) #define xwidth (_comp->_parameters.xwidth) #define yheight (_comp->_parameters.yheight) #define maxdiv_h (_comp->_parameters.maxdiv_h) #define maxdiv_v (_comp->_parameters.maxdiv_v) #define restore_neutron (_comp->_parameters.restore_neutron) #define nx (_comp->_parameters.nx) #define ny (_comp->_parameters.ny) #define nz (_comp->_parameters.nz) #define Div_N (_comp->_parameters.Div_N) #define Div_p (_comp->_parameters.Div_p) #define Div_p2 (_comp->_parameters.Div_p2) SIG_MESSAGE("[_divmon_guide_end_trace] component divmon_guide_end=Divergence_monitor() TRACE [Divergence_monitor:0]"); int i, j; double h_div, v_div; double v, vn; PROP_Z0; if (x > xmin && x < xmax && y > ymin && y < ymax) { /* Find length of projection onto the [nx ny nz] axis */ vn = scalar_prod (vx, vy, vz, nx, ny, nz); h_div = RAD2DEG * atan2 (vx, vn); v_div = RAD2DEG * atan2 (vy, vn); if (h_div < maxdiv_h && h_div > -maxdiv_h && v_div < maxdiv_v && v_div > -maxdiv_v) { i = floor ((h_div + maxdiv_h) * nh / (2.0 * maxdiv_h)); j = floor ((v_div + maxdiv_v) * nv / (2.0 * maxdiv_v)); double p2 = p * p; #pragma acc atomic Div_N[i][j] = Div_N[i][j] + 1; #pragma acc atomic Div_p[i][j] = Div_p[i][j] + p; #pragma acc atomic Div_p2[i][j] = Div_p2[i][j] + p2; SCATTER; } } if (restore_neutron) { RESTORE_NEUTRON (INDEX_CURRENT_COMP, x, y, z, vx, vy, vz, t, sx, sy, sz, p); } #ifndef NOABSORB_INF_NAN /* Check for nan or inf particle parms */ if(isnan(p + t + vx + vy + vz + x + y + z)) ABSORB; if(isinf(fabs(p) + fabs(t) + fabs(vx) + fabs(vy) + fabs(vz) + fabs(x) + fabs(y) + fabs(z))) ABSORB; #else if(isnan(p) || isinf(p)) printf("NAN or INF found in p, %s (particle %lld)\n",_comp->_name,_particle->_uid); if(isnan(t) || isinf(t)) printf("NAN or INF found in t, %s (particle %lld)\n",_comp->_name,_particle->_uid); if(isnan(vx) || isinf(vx)) printf("NAN or INF found in vx, %s (particle %lld)\n",_comp->_name,_particle->_uid); if(isnan(vy) || isinf(vy)) printf("NAN or INF found in vy, %s (particle %lld)\n",_comp->_name,_particle->_uid); if(isnan(vz) || isinf(vz)) printf("NAN or INF found in vz, %s (particle %lld)\n",_comp->_name,_particle->_uid); if(isnan(x) || isinf(x)) printf("NAN or INF found in x, %s (particle %lld)\n",_comp->_name,_particle->_uid); if(isnan(y) || isinf(y)) printf("NAN or INF found in y, %s (particle %lld)\n",_comp->_name,_particle->_uid); if(isnan(z) || isinf(z)) printf("NAN or INF found in z, %s (particle %lld)\n",_comp->_name,_particle->_uid); #endif #undef nh #undef nv #undef filename #undef xmin #undef xmax #undef ymin #undef ymax #undef nowritefile #undef xwidth #undef yheight #undef maxdiv_h #undef maxdiv_v #undef restore_neutron #undef nx #undef ny #undef nz #undef Div_N #undef Div_p #undef Div_p2 return; } /* class_Divergence_monitor_trace */ #pragma acc routine void class_Arm_trace(_class_Arm *_comp , _class_particle *_particle) { ABSORBED=SCATTERED=RESTORE=0; SIG_MESSAGE("[_focus_mono_trace] component focus_mono=Arm() TRACE [Arm:0]"); #ifndef NOABSORB_INF_NAN /* Check for nan or inf particle parms */ if(isnan(p + t + vx + vy + vz + x + y + z)) ABSORB; if(isinf(fabs(p) + fabs(t) + fabs(vx) + fabs(vy) + fabs(vz) + fabs(x) + fabs(y) + fabs(z))) ABSORB; #else if(isnan(p) || isinf(p)) printf("NAN or INF found in p, %s (particle %lld)\n",_comp->_name,_particle->_uid); if(isnan(t) || isinf(t)) printf("NAN or INF found in t, %s (particle %lld)\n",_comp->_name,_particle->_uid); if(isnan(vx) || isinf(vx)) printf("NAN or INF found in vx, %s (particle %lld)\n",_comp->_name,_particle->_uid); if(isnan(vy) || isinf(vy)) printf("NAN or INF found in vy, %s (particle %lld)\n",_comp->_name,_particle->_uid); if(isnan(vz) || isinf(vz)) printf("NAN or INF found in vz, %s (particle %lld)\n",_comp->_name,_particle->_uid); if(isnan(x) || isinf(x)) printf("NAN or INF found in x, %s (particle %lld)\n",_comp->_name,_particle->_uid); if(isnan(y) || isinf(y)) printf("NAN or INF found in y, %s (particle %lld)\n",_comp->_name,_particle->_uid); if(isnan(z) || isinf(z)) printf("NAN or INF found in z, %s (particle %lld)\n",_comp->_name,_particle->_uid); #endif #define Mono_order (_particle->Mono_order) #define AnaBlade (_particle->AnaBlade) #define BinX (_particle->BinX) #define BinY (_particle->BinY) #define ncol_54 (_particle->ncol_54) #define nrow_54 (_particle->nrow_54) if (_comp->_index == 53) { // EXTEND 'focus_mono' Mono_order=-1; } if (_comp->_index == 89) { // EXTEND 'focus_ana' AnaBlade=0; } if (_comp->_index == 129) { // EXTEND 'ArmL5' BinX = 0; BinY=0; } #undef Mono_order #undef AnaBlade #undef BinX #undef BinY #undef ncol_54 #undef nrow_54 return; } /* class_Arm_trace */ #pragma acc routine void class_Monochromator_curved_trace(_class_Monochromator_curved *_comp , _class_particle *_particle) { ABSORBED=SCATTERED=RESTORE=0; #define reflect (_comp->_parameters.reflect) #define transmit (_comp->_parameters.transmit) #define zwidth (_comp->_parameters.zwidth) #define yheight (_comp->_parameters.yheight) #define gap (_comp->_parameters.gap) #define NH (_comp->_parameters.NH) #define NV (_comp->_parameters.NV) #define mosaich (_comp->_parameters.mosaich) #define mosaicv (_comp->_parameters.mosaicv) #define r0 (_comp->_parameters.r0) #define t0 (_comp->_parameters.t0) #define Q (_comp->_parameters.Q) #define RV (_comp->_parameters.RV) #define RH (_comp->_parameters.RH) #define DM (_comp->_parameters.DM) #define mosaic (_comp->_parameters.mosaic) #define width (_comp->_parameters.width) #define height (_comp->_parameters.height) #define verbose (_comp->_parameters.verbose) #define order (_comp->_parameters.order) #define mos_rms_y (_comp->_parameters.mos_rms_y) #define mos_rms_z (_comp->_parameters.mos_rms_z) #define mos_rms_max (_comp->_parameters.mos_rms_max) #define mono_Q (_comp->_parameters.mono_Q) #define SlabWidth (_comp->_parameters.SlabWidth) #define SlabHeight (_comp->_parameters.SlabHeight) #define rTable (_comp->_parameters.rTable) #define tTable (_comp->_parameters.tTable) #define rTableFlag (_comp->_parameters.rTableFlag) #define tTableFlag (_comp->_parameters.tTableFlag) #define tiltH (_comp->_parameters.tiltH) #define tiltV (_comp->_parameters.tiltV) #define ncol_var (_comp->_parameters.ncol_var) #define nrow_var (_comp->_parameters.nrow_var) SIG_MESSAGE("[_monochromator_curved_trace] component monochromator_curved=Monochromator_curved() TRACE [Monochromator_curved:0]"); double dt; double Gauss_X[] = { -0.987992518020485, -0.937273392400706, -0.848206583410427, -0.724417731360170, -0.570972172608539, -0.394151347077563, -0.201194093997435, 0, 0.201194093997435, 0.394151347077563, 0.570972172608539, 0.724417731360170, 0.848206583410427, 0.937273392400706, 0.987992518020485 }; double Gauss_W[] = { 0.030753241996117, 0.070366047488108, 0.107159220467172, 0.139570677926154, 0.166269205816994, 0.186161000115562, 0.198431485327111, 0.202578241925561, 0.198431485327111, 0.186161000115562, 0.166269205816994, 0.139570677926154, 0.107159220467172, 0.070366047488108, 0.030753241996117 }; if (vx != 0.0 && (dt = -x / vx) >= 0.0 && r0) { /* Moving towards crystal? */ double zmin, zmax, ymin, ymax; double yy, zz; zmax = ((NH * (SlabWidth + gap)) - gap) / 2; zmin = -zmax; ymax = ((NV * (SlabHeight + gap)) - gap) / 2; ymin = -ymax; /* Test-propagate to crystal plane */ zz = z + vz * dt; yy = y + vy * dt; if (zz > zmin && zz < zmax && yy > ymin && yy < ymax) { /* Intersect the crystal? */ double tilth, tiltv; /* used to calculate tilt angle of slab */ double ratio, Q_order, k, kux, kuy, kuz; double kix, kiy, kiz; int do_transmit = 0; int row, col; col = ceil ((zz - zmin) / (SlabWidth + gap)); /* which slab hit ? */ row = ceil ((yy - ymin) / (SlabHeight + gap)); particle_setvar_void (_particle, ncol_var, &col); particle_setvar_void (_particle, nrow_var, &row); if (RH != 0) { tilth = tiltH ? tiltH[(int)col] : asin ((col - (NH + 1) / 2.0) * (SlabWidth + gap) / RH); } else { tilth = 0; } if (RV != 0) { tiltv = tiltV ? tiltV[(int)row] : -asin ((row - (NV + 1) / 2.0) * (SlabHeight + gap) / RV); } else { tiltv = 0; } /* rotate with tilth (around Y) and tiltv (around Z), center on plate */ double center_z = zmin + (col - 0.5) * (SlabWidth + gap) - gap / 2; double center_y = ymin + (row - 0.5) * (SlabHeight + gap) - gap / 2; Rotation T; rot_set_rotation (T, 0, tilth, tiltv); /* now make the coordinate system change */ mccoordschange_polarisation (T, &vx, &vy, &vz); y = y - center_y; z = z - center_z; coords_get (rot_apply (T, coords_set (x, y, z)), &x, &y, &z); /* this is where polarisation should be handled, plus further down */ /* mccoordschange_polarisation(t, &sx, &sy, &sz); */ /* now propagate to slab plane */ PROP_X0; /* Hit a slab or a gap ?*/ int inside = inside_rectangle (z, y, SlabWidth, SlabHeight); if (inside) { /* not in gap ? */ kix = V2K * vx; /* Initial wave vector */ kiy = V2K * vy; kiz = V2K * vz; /* Get reflection order and corresponding nominal scattering vector q0 of correct length and direction. Only the order with the closest scattering vector is considered */ ratio = -2 * kix / mono_Q; Q_order = floor (ratio + .5); if (Q_order == 0.0) Q_order = ratio < 0 ? -1 : 1; /* Order will be negative when the neutron enters from the back, in which case the direction of Q0 is flipped. */ if (Q_order < 0) Q_order = -Q_order; /* Make sure the order is small enough to allow Bragg scattering at the given neutron wavelength */ k = sqrt (kix * kix + kiy * kiy + kiz * kiz); kux = kix / k; /* Unit vector along ki */ kuy = kiy / k; kuz = kiz / k; if (Q_order > 2 * k / mono_Q) Q_order--; if ((!order && Q_order > 0) || (Q_order == fabs (order) && order)) { /* Bragg scattering possible? */ double q0, q0x, theta, delta, p_reflect, my_r0; q0 = Q_order * mono_Q; q0x = ratio < 0 ? -q0 : q0; theta = asin (q0 / (2 * k)); /* Actual bragg angle */ /* Make MC choice: reflect or transmit? */ delta = asin (fabs (kux)) - theta; if (rTableFlag) { my_r0 = r0 * Table_Value (rTable, k, 1); /* 2nd column */ } else my_r0 = r0; if (my_r0 > 1) { if (my_r0 > 1.01 && verbose) fprintf (stdout, "Warning: Monochromator_curved : lowered reflectivity from %f to 1 (k=%f)\n", my_r0, k); my_r0 = 0.999; } if (my_r0 < 0) { if (verbose) fprintf (stdout, "Warning: Monochromator_curved : raised reflectivity from %f to 0 (k=%f)\n", my_r0, k); my_r0 = 0; } p_reflect = fabs (my_r0) * exp (-kiz * kiz / (kiy * kiy + kiz * kiz) * (delta * delta) / (2 * mos_rms_y * mos_rms_y)) * exp (-kiy * kiy / (kiy * kiy + kiz * kiz) * (delta * delta) / (2 * mos_rms_z * mos_rms_z)); double rr = rand01 (); if (rr <= p_reflect) { /* Reflect */ double bx, by, bz, ax, ay, az, phi; double cos_2theta, k_sin_2theta, cos_phi, sin_phi, q_x, q_y, q_z; double total, c1x, c1y, c1z, w, mos_sample; int i = 0; cos_2theta = cos (2 * theta); k_sin_2theta = k * sin (2 * theta); /* Get unit normal to plane containing ki and most probable kf */ vec_prod (bx, by, bz, kix, kiy, kiz, q0x, 0, 0); NORM (bx, by, bz); bx = bx * k_sin_2theta; by = by * k_sin_2theta; bz = bz * k_sin_2theta; /* Get unit vector normal to ki and b */ vec_prod (ax, ay, az, bx, by, bz, kux, kuy, kuz); /* Compute the total scattering probability at this ki */ total = 0; /* Choose width of Gaussian distribution to sample the angle * phi on the Debye-Scherrer cone for the scattered neutron. * The radius of the Debye-Scherrer cone is smaller by a * factor 1/cos(theta) than the radius of the (partial) sphere * describing the possible orientations of Q due to mosaicity, so we * start with a width 1/cos(theta) greater than the largest of * the two mosaics. */ mos_sample = mos_rms_max / cos (theta); c1x = kix * (cos_2theta - 1); c1y = kiy * (cos_2theta - 1); c1z = kiz * (cos_2theta - 1); /* Loop, repeatedly reducing the sample width until it is small * enough to avoid sampling scattering directions with * ridiculously low scattering probability. * Use a cut-off at 5 times the gauss width for considering * scattering probability as well as for integration limits * when integrating the sampled distribution below. */ for (i = 0; i < 100; i++) { w = 5 * mos_sample; cos_phi = cos (w); sin_phi = sin (w); q_x = c1x + cos_phi * ax + sin_phi * bx; q_y = (c1y + cos_phi * ay + sin_phi * by) / mos_rms_z; q_z = (c1z + cos_phi * az + sin_phi * bz) / mos_rms_y; /* Stop when we get near a factor of 25=5^2. */ if (q_z * q_z + q_y * q_y < (25 / (2.0 / 3.0)) * (q_x * q_x)) break; mos_sample *= (2.0 / 3.0); } /* Now integrate the chosen sampling distribution, using a * cut-off at five times sigma. */ for (i = 0; i < (sizeof (Gauss_X) / sizeof (double)); i++) { phi = w * Gauss_X[i]; cos_phi = cos (phi); sin_phi = sin (phi); q_x = c1x + cos_phi * ax + sin_phi * bx; q_y = c1y + cos_phi * ay + sin_phi * by; q_z = c1z + cos_phi * az + sin_phi * bz; p_reflect = GAUSS_monocurved ((q_z / q_x), 0, mos_rms_y) * GAUSS_monocurved ((q_y / q_x), 0, mos_rms_z); total += Gauss_W[i] * p_reflect; } total *= w; /* Choose point on Debye-Scherrer cone. Sample from a Gaussian of * width 1/cos(theta) greater than the mosaic and correct for any * error by adjusting the neutron weight later. */ phi = mos_sample * randnorm (); /* Compute final wave vector kf and scattering vector q = ki - kf */ cos_phi = cos (phi); sin_phi = sin (phi); q_x = c1x + cos_phi * ax + sin_phi * bx; q_y = c1y + cos_phi * ay + sin_phi * by; q_z = c1z + cos_phi * az + sin_phi * bz; p_reflect = GAUSS_monocurved ((q_z / q_x), 0, mos_rms_y) * GAUSS_monocurved ((q_y / q_x), 0, mos_rms_z); vx = K2V * (kix + q_x); vy = K2V * (kiy + q_y); vz = K2V * (kiz + q_z); p_reflect /= total * GAUSS_monocurved (phi, 0, mos_sample); if (p_reflect <= 0) ABSORB; if (p_reflect > 1) p_reflect = 1; p = p * p_reflect; } /* End MC choice to reflect or transmit neutron (if tmp 1) { if (my_t0 > 1.01 && verbose) fprintf (stdout, "Warning: Monochromator_curved : lowered transmission from %f to 1 (k=%f)\n", my_t0, k); my_t0 = 0.999; } if (my_t0 > 0) p = p * my_t0; else ABSORB; } } /* end if not in gap */ /* rotate back in component frame */ Rotation TT; rot_transpose (T, TT); /* now make the coordinate system change */ mccoordschange_polarisation (TT, &vx, &vy, &vz); coords_get (rot_apply (TT, coords_set (x, y, z)), &x, &y, &z); y = y + center_y; z = z + center_z; /* Visualise scattering point in proper, component frame - but only if the neutron is reflected, that is none of: * transmitted * falling outside the slab material */ if (!do_transmit) SCATTER; /* mccoordschange_polarisation(tt, &sx, &sy, &sz); */ } /* End intersect the crystal (if z) */ else { /* restore neutron state when no interaction */ RESTORE_NEUTRON (INDEX_CURRENT_COMP, x, y, z, vx, vy, vz, t, sx, sy, sz, p); } } /* End neutron moving towards crystal (if vx)*/ #ifndef NOABSORB_INF_NAN /* Check for nan or inf particle parms */ if(isnan(p + t + vx + vy + vz + x + y + z)) ABSORB; if(isinf(fabs(p) + fabs(t) + fabs(vx) + fabs(vy) + fabs(vz) + fabs(x) + fabs(y) + fabs(z))) ABSORB; #else if(isnan(p) || isinf(p)) printf("NAN or INF found in p, %s (particle %lld)\n",_comp->_name,_particle->_uid); if(isnan(t) || isinf(t)) printf("NAN or INF found in t, %s (particle %lld)\n",_comp->_name,_particle->_uid); if(isnan(vx) || isinf(vx)) printf("NAN or INF found in vx, %s (particle %lld)\n",_comp->_name,_particle->_uid); if(isnan(vy) || isinf(vy)) printf("NAN or INF found in vy, %s (particle %lld)\n",_comp->_name,_particle->_uid); if(isnan(vz) || isinf(vz)) printf("NAN or INF found in vz, %s (particle %lld)\n",_comp->_name,_particle->_uid); if(isnan(x) || isinf(x)) printf("NAN or INF found in x, %s (particle %lld)\n",_comp->_name,_particle->_uid); if(isnan(y) || isinf(y)) printf("NAN or INF found in y, %s (particle %lld)\n",_comp->_name,_particle->_uid); if(isnan(z) || isinf(z)) printf("NAN or INF found in z, %s (particle %lld)\n",_comp->_name,_particle->_uid); #endif #define Mono_order (_particle->Mono_order) #define AnaBlade (_particle->AnaBlade) #define BinX (_particle->BinX) #define BinY (_particle->BinY) #define ncol_54 (_particle->ncol_54) #define nrow_54 (_particle->nrow_54) if (_comp->_index == 54) { // EXTEND 'monochromator_curved' if(SCATTERED) Mono_order=order; } #undef Mono_order #undef AnaBlade #undef BinX #undef BinY #undef ncol_54 #undef nrow_54 #undef reflect #undef transmit #undef zwidth #undef yheight #undef gap #undef NH #undef NV #undef mosaich #undef mosaicv #undef r0 #undef t0 #undef Q #undef RV #undef RH #undef DM #undef mosaic #undef width #undef height #undef verbose #undef order #undef mos_rms_y #undef mos_rms_z #undef mos_rms_max #undef mono_Q #undef SlabWidth #undef SlabHeight #undef rTable #undef tTable #undef rTableFlag #undef tTableFlag #undef tiltH #undef tiltV #undef ncol_var #undef nrow_var return; } /* class_Monochromator_curved_trace */ #pragma acc routine void class_Collimator_linear_trace(_class_Collimator_linear *_comp , _class_particle *_particle) { ABSORBED=SCATTERED=RESTORE=0; #define xmin (_comp->_parameters.xmin) #define xmax (_comp->_parameters.xmax) #define ymin (_comp->_parameters.ymin) #define ymax (_comp->_parameters.ymax) #define xwidth (_comp->_parameters.xwidth) #define yheight (_comp->_parameters.yheight) #define length (_comp->_parameters.length) #define divergence (_comp->_parameters.divergence) #define transmission (_comp->_parameters.transmission) #define divergenceV (_comp->_parameters.divergenceV) #define slope (_comp->_parameters.slope) #define slopeV (_comp->_parameters.slopeV) SIG_MESSAGE("[_MSCollimator_trace] component MSCollimator=Collimator_linear() TRACE [Collimator_linear:0]"); double phi, dt; PROP_Z0; if (x < xmin || x > xmax || y < ymin || y > ymax) ABSORB; dt = length / vz; PROP_DT (dt); if (x < xmin || x > xmax || y < ymin || y > ymax) ABSORB; if (slope > 0.0) { phi = fabs (vx / vz); if (phi > slope) ABSORB; else p *= transmission * (1.0 - phi / slope); SCATTER; } if (slopeV > 0) { phi = fabs (vy / vz); if (phi > slopeV) ABSORB; else p *= transmission * (1.0 - phi / slopeV); SCATTER; } #ifndef NOABSORB_INF_NAN /* Check for nan or inf particle parms */ if(isnan(p + t + vx + vy + vz + x + y + z)) ABSORB; if(isinf(fabs(p) + fabs(t) + fabs(vx) + fabs(vy) + fabs(vz) + fabs(x) + fabs(y) + fabs(z))) ABSORB; #else if(isnan(p) || isinf(p)) printf("NAN or INF found in p, %s (particle %lld)\n",_comp->_name,_particle->_uid); if(isnan(t) || isinf(t)) printf("NAN or INF found in t, %s (particle %lld)\n",_comp->_name,_particle->_uid); if(isnan(vx) || isinf(vx)) printf("NAN or INF found in vx, %s (particle %lld)\n",_comp->_name,_particle->_uid); if(isnan(vy) || isinf(vy)) printf("NAN or INF found in vy, %s (particle %lld)\n",_comp->_name,_particle->_uid); if(isnan(vz) || isinf(vz)) printf("NAN or INF found in vz, %s (particle %lld)\n",_comp->_name,_particle->_uid); if(isnan(x) || isinf(x)) printf("NAN or INF found in x, %s (particle %lld)\n",_comp->_name,_particle->_uid); if(isnan(y) || isinf(y)) printf("NAN or INF found in y, %s (particle %lld)\n",_comp->_name,_particle->_uid); if(isnan(z) || isinf(z)) printf("NAN or INF found in z, %s (particle %lld)\n",_comp->_name,_particle->_uid); #endif #undef xmin #undef xmax #undef ymin #undef ymax #undef xwidth #undef yheight #undef length #undef divergence #undef transmission #undef divergenceV #undef slope #undef slopeV return; } /* class_Collimator_linear_trace */ #pragma acc routine void class_Filter_gen_trace(_class_Filter_gen *_comp , _class_particle *_particle) { ABSORBED=SCATTERED=RESTORE=0; #define filename (_comp->_parameters.filename) #define options (_comp->_parameters.options) #define xmin (_comp->_parameters.xmin) #define xmax (_comp->_parameters.xmax) #define ymin (_comp->_parameters.ymin) #define ymax (_comp->_parameters.ymax) #define xwidth (_comp->_parameters.xwidth) #define yheight (_comp->_parameters.yheight) #define thickness (_comp->_parameters.thickness) #define scaling (_comp->_parameters.scaling) #define verbose (_comp->_parameters.verbose) #define Mode_Table (_comp->_parameters.Mode_Table) #define Type_Table (_comp->_parameters.Type_Table) #define pTable (_comp->_parameters.pTable) SIG_MESSAGE("[_infilter_trace] component infilter=Filter_gen() TRACE [Filter_gen:0]"); double v2, K, L, E, X, new_p; PROP_Z0; if (Type_Table && (x > xmin && x < xmax && y > ymin && y < ymax)) { v2 = (vx * vx + vy * vy + vz * vz); K = V2K * sqrt (v2); /* k */ L = (2 * PI / K); /* lambda */ E = VS2E * v2; /* energy */ if (Type_Table == ENERGY_TABLE) X = E; if (Type_Table == WAVEVECTOR_TABLE) X = K; if (Type_Table == WAVELENGTH_TABLE) X = L; /* table look up */ if (pTable.data != NULL) { double y1, y2, x1; long Index; Index = floor ((X - pTable.min_x) / pTable.step_x); y1 = Table_Index (pTable, Index, 1); /* 2nd column */ x1 = Table_Index (pTable, Index, 0); /* 1st column */ y2 = Table_Index (pTable, Index + 1, 1); /* 2nd column */ new_p = scaling * (y1 + (X - x1) * (y2 - y1) / pTable.step_x); /* 2nd column */ if (thickness != 1) new_p = pow (new_p, thickness); } else new_p = 1; if (Mode_Table == FLUX_ADAPT_MULT) p *= new_p; else p = new_p; SCATTER; } else if (Type_Table) ABSORB; #ifndef NOABSORB_INF_NAN /* Check for nan or inf particle parms */ if(isnan(p + t + vx + vy + vz + x + y + z)) ABSORB; if(isinf(fabs(p) + fabs(t) + fabs(vx) + fabs(vy) + fabs(vz) + fabs(x) + fabs(y) + fabs(z))) ABSORB; #else if(isnan(p) || isinf(p)) printf("NAN or INF found in p, %s (particle %lld)\n",_comp->_name,_particle->_uid); if(isnan(t) || isinf(t)) printf("NAN or INF found in t, %s (particle %lld)\n",_comp->_name,_particle->_uid); if(isnan(vx) || isinf(vx)) printf("NAN or INF found in vx, %s (particle %lld)\n",_comp->_name,_particle->_uid); if(isnan(vy) || isinf(vy)) printf("NAN or INF found in vy, %s (particle %lld)\n",_comp->_name,_particle->_uid); if(isnan(vz) || isinf(vz)) printf("NAN or INF found in vz, %s (particle %lld)\n",_comp->_name,_particle->_uid); if(isnan(x) || isinf(x)) printf("NAN or INF found in x, %s (particle %lld)\n",_comp->_name,_particle->_uid); if(isnan(y) || isinf(y)) printf("NAN or INF found in y, %s (particle %lld)\n",_comp->_name,_particle->_uid); if(isnan(z) || isinf(z)) printf("NAN or INF found in z, %s (particle %lld)\n",_comp->_name,_particle->_uid); #endif #undef filename #undef options #undef xmin #undef xmax #undef ymin #undef ymax #undef xwidth #undef yheight #undef thickness #undef scaling #undef verbose #undef Mode_Table #undef Type_Table #undef pTable return; } /* class_Filter_gen_trace */ #pragma acc routine void class_Monitor_nD_trace(_class_Monitor_nD *_comp , _class_particle *_particle) { ABSORBED=SCATTERED=RESTORE=0; #define user0 (_comp->_parameters.user0) #define user1 (_comp->_parameters.user1) #define user2 (_comp->_parameters.user2) #define user3 (_comp->_parameters.user3) #define user4 (_comp->_parameters.user4) #define user5 (_comp->_parameters.user5) #define user6 (_comp->_parameters.user6) #define user7 (_comp->_parameters.user7) #define user8 (_comp->_parameters.user8) #define user9 (_comp->_parameters.user9) #define xwidth (_comp->_parameters.xwidth) #define yheight (_comp->_parameters.yheight) #define zdepth (_comp->_parameters.zdepth) #define xmin (_comp->_parameters.xmin) #define xmax (_comp->_parameters.xmax) #define ymin (_comp->_parameters.ymin) #define ymax (_comp->_parameters.ymax) #define zmin (_comp->_parameters.zmin) #define zmax (_comp->_parameters.zmax) #define bins (_comp->_parameters.bins) #define min (_comp->_parameters.min) #define max (_comp->_parameters.max) #define restore_neutron (_comp->_parameters.restore_neutron) #define radius (_comp->_parameters.radius) #define options (_comp->_parameters.options) #define filename (_comp->_parameters.filename) #define geometry (_comp->_parameters.geometry) #define nowritefile (_comp->_parameters.nowritefile) #define nexus_bins (_comp->_parameters.nexus_bins) #define username0 (_comp->_parameters.username0) #define username1 (_comp->_parameters.username1) #define username2 (_comp->_parameters.username2) #define username3 (_comp->_parameters.username3) #define username4 (_comp->_parameters.username4) #define username5 (_comp->_parameters.username5) #define username6 (_comp->_parameters.username6) #define username7 (_comp->_parameters.username7) #define username8 (_comp->_parameters.username8) #define username9 (_comp->_parameters.username9) #define DEFS (_comp->_parameters.DEFS) #define Vars (_comp->_parameters.Vars) #define detector (_comp->_parameters.detector) #define offdata (_comp->_parameters.offdata) SIG_MESSAGE("[_OrderMon_trace] component OrderMon=Monitor_nD() TRACE [Monitor_nD:0]"); double transmit_he3 = 1.0; double multiplier_capture = 1.0; double t0 = 0; double t1 = 0; int pp; int intersect = 0; char Flag_Restore = 0; #ifdef OPENACC #ifdef USE_OFF off_struct thread_offdata = offdata; #endif #else #define thread_offdata offdata #endif /* this is done automatically STORE_NEUTRON(INDEX_CURRENT_COMP, x, y, z, vx, vy, vz, t, sx, sy, sz, p); */ #ifdef USE_OFF if (geometry && strlen (geometry) && strcmp (geometry, "0") && strcmp (geometry, "NULL")) { /* determine intersections with object */ intersect = off_intersect_all (&t0, &t1, NULL, NULL, x, y, z, vx, vy, vz, 0, 0, 0, &thread_offdata); if (Vars.Flag_mantid) { if (intersect) { Vars.OFF_polyidx = thread_offdata.nextintersect; } else { Vars.OFF_polyidx = -1; } } } else #endif if ((abs (Vars.Flag_Shape) == DEFS.SHAPE_SQUARE) || (abs (Vars.Flag_Shape) == DEFS.SHAPE_DISK)) /* square xy or disk xy */ { // propagate to xy plane and find intersection // make sure the event is recoverable afterwards t0 = t; ALLOW_BACKPROP; PROP_Z0; if ((t >= t0) && (z == 0.0)) // forward propagation to xy plane was successful { if (abs (Vars.Flag_Shape) == DEFS.SHAPE_SQUARE) { // square xy intersect = (x >= Vars.mxmin && x <= Vars.mxmax && y >= Vars.mymin && y <= Vars.mymax); } else { // disk xy intersect = (SQR (x) + SQR (y)) <= SQR (Vars.Sphere_Radius); } } else { intersect = 0; } } else if (abs (Vars.Flag_Shape) == DEFS.SHAPE_SPHERE) /* sphere */ { intersect = sphere_intersect (&t0, &t1, x, y, z, vx, vy, vz, Vars.Sphere_Radius); /* intersect = (intersect && t0 > 0); */ } else if ((abs (Vars.Flag_Shape) == DEFS.SHAPE_CYLIND) || (abs (Vars.Flag_Shape) == DEFS.SHAPE_BANANA)) /* cylinder */ { intersect = cylinder_intersect (&t0, &t1, x, y, z, vx, vy, vz, Vars.Sphere_Radius, Vars.Cylinder_Height); } else if (abs (Vars.Flag_Shape) == DEFS.SHAPE_BOX) /* box */ { intersect = box_intersect (&t0, &t1, x, y, z, vx, vy, vz, fabs (Vars.mxmax - Vars.mxmin), fabs (Vars.mymax - Vars.mymin), fabs (Vars.mzmax - Vars.mzmin)); } else if (abs (Vars.Flag_Shape) == DEFS.SHAPE_PREVIOUS) /* previous comp */ { intersect = 1; } if (intersect) { 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) || (geometry && strlen (geometry) && strcmp (geometry, "0") && strcmp (geometry, "NULL"))) { /* check if we have to remove the top/bottom with BANANA shape */ if (abs (Vars.Flag_Shape) == DEFS.SHAPE_BANANA) { if (intersect == 1) { // Entered and left through sides if (t0 < 0 && t1 > 0) { t0 = t; /* neutron was already inside ! */ } if (t1 < 0 && t0 > 0) { /* neutron exit before entering !! */ t1 = t; } /* t0 is now time of incoming intersection with the detection area */ if ((Vars.Flag_Shape < 0) && (t1 > 0)) { PROP_DT (t1); /* t1 outgoing beam */ } else { PROP_DT (t0); /* t0 incoming beam */ } } else if (intersect == 3 || intersect == 5) { // Entered from top or bottom, left through side if ((Vars.Flag_Shape < 0) && (t1 > 0)) { PROP_DT (t1); /* t1 outgoing beam */ } else { intersect = 0; Flag_Restore = 1; } } else if (intersect == 9 || intersect == 17) { // Entered through side, left from top or bottom if ((Vars.Flag_Shape < 0) && (t1 > 0)) { intersect = 0; Flag_Restore = 1; } else { PROP_DT (t0); /* t0 incoming beam */ } } else if (intersect == 13 || intersect == 19) { // Went through top/bottom on entry and exit intersect = 0; Flag_Restore = 1; } else { printf ("Cylinder_intersect returned unexpected value %i\n", intersect); } } else { // All other shapes than the BANANA if (t0 < 0 && t1 > 0) t0 = t; /* neutron was already inside ! */ if (t1 < 0 && t0 > 0) /* neutron exit before entering !! */ t1 = t; /* t0 is now time of incoming intersection with the detection area */ if ((Vars.Flag_Shape < 0) && (t1 > 0)) PROP_DT (t1); /* t1 outgoing beam */ else PROP_DT (t0); /* t0 incoming beam */ } /* Final test if we are on lid / bottom of banana/sphere */ if (abs (Vars.Flag_Shape) == DEFS.SHAPE_BANANA || abs (Vars.Flag_Shape) == DEFS.SHAPE_SPHERE) { if (Vars.Cylinder_Height && fabs (y) >= Vars.Cylinder_Height / 2 - FLT_EPSILON) { intersect = 0; Flag_Restore = 1; } } } } if (intersect) { if ((Vars.He3_pressure > 0) && (t1 != t0) && ((abs (Vars.Flag_Shape) == DEFS.SHAPE_SPHERE) || (abs (Vars.Flag_Shape) == DEFS.SHAPE_CYLIND) || (abs (Vars.Flag_Shape) == DEFS.SHAPE_BOX))) { transmit_he3 = exp (-7.417 * Vars.He3_pressure * fabs (t1 - t0) * 2 * PI * K2V); /* will monitor the absorbed part */ p = p * (1 - transmit_he3); } if (Vars.Flag_capture) { multiplier_capture = V2K * sqrt (vx * vx + vy * vy + vz * vz); if (multiplier_capture != 0) multiplier_capture = 2 * PI / multiplier_capture; /* lambda. lambda(2200 m/2) = 1.7985 Angs */ p = p * multiplier_capture / 1.7985; } pp = Monitor_nD_Trace (&DEFS, &Vars, _particle); if (pp == 0.0) { ABSORB; } else if (pp == 1) { SCATTER; } /*set weight to undetected part if capture and/or he3_pressure*/ if (Vars.He3_pressure > 0) { /* after monitor, only remains 1-p_detect */ p = p * transmit_he3 / (1.0 - transmit_he3); } if (Vars.Flag_capture) { p = p / multiplier_capture * 1.7985; } if (Vars.Flag_parallel) /* back to neutron state before detection */ Flag_Restore = 1; } /* end if intersection */ else { if (Vars.Flag_Absorb && !Vars.Flag_parallel) { // restore neutron ray before absorbing for correct mcdisplay RESTORE_NEUTRON (INDEX_CURRENT_COMP, x, y, z, vx, vy, vz, t, sx, sy, sz, p); ABSORB; } else Flag_Restore = 1; /* no intersection, back to previous state */ } if (Flag_Restore) { RESTORE_NEUTRON (INDEX_CURRENT_COMP, x, y, z, vx, vy, vz, t, sx, sy, sz, p); } #ifndef NOABSORB_INF_NAN /* Check for nan or inf particle parms */ if(isnan(p + t + vx + vy + vz + x + y + z)) ABSORB; if(isinf(fabs(p) + fabs(t) + fabs(vx) + fabs(vy) + fabs(vz) + fabs(x) + fabs(y) + fabs(z))) ABSORB; #else if(isnan(p) || isinf(p)) printf("NAN or INF found in p, %s (particle %lld)\n",_comp->_name,_particle->_uid); if(isnan(t) || isinf(t)) printf("NAN or INF found in t, %s (particle %lld)\n",_comp->_name,_particle->_uid); if(isnan(vx) || isinf(vx)) printf("NAN or INF found in vx, %s (particle %lld)\n",_comp->_name,_particle->_uid); if(isnan(vy) || isinf(vy)) printf("NAN or INF found in vy, %s (particle %lld)\n",_comp->_name,_particle->_uid); if(isnan(vz) || isinf(vz)) printf("NAN or INF found in vz, %s (particle %lld)\n",_comp->_name,_particle->_uid); if(isnan(x) || isinf(x)) printf("NAN or INF found in x, %s (particle %lld)\n",_comp->_name,_particle->_uid); if(isnan(y) || isinf(y)) printf("NAN or INF found in y, %s (particle %lld)\n",_comp->_name,_particle->_uid); if(isnan(z) || isinf(z)) printf("NAN or INF found in z, %s (particle %lld)\n",_comp->_name,_particle->_uid); #endif #undef user0 #undef user1 #undef user2 #undef user3 #undef user4 #undef user5 #undef user6 #undef user7 #undef user8 #undef user9 #undef xwidth #undef yheight #undef zdepth #undef xmin #undef xmax #undef ymin #undef ymax #undef zmin #undef zmax #undef bins #undef min #undef max #undef restore_neutron #undef radius #undef options #undef filename #undef geometry #undef nowritefile #undef nexus_bins #undef username0 #undef username1 #undef username2 #undef username3 #undef username4 #undef username5 #undef username6 #undef username7 #undef username8 #undef username9 #undef DEFS #undef Vars #undef detector #undef offdata return; } /* class_Monitor_nD_trace */ #pragma acc routine void class_PSD_monitor_psf_eff_trace(_class_PSD_monitor_psf_eff *_comp , _class_particle *_particle) { ABSORBED=SCATTERED=RESTORE=0; #define nx (_comp->_parameters.nx) #define ny (_comp->_parameters.ny) #define filename (_comp->_parameters.filename) #define xmin (_comp->_parameters.xmin) #define xmax (_comp->_parameters.xmax) #define ymin (_comp->_parameters.ymin) #define ymax (_comp->_parameters.ymax) #define nowritefile (_comp->_parameters.nowritefile) #define xwidth (_comp->_parameters.xwidth) #define yheight (_comp->_parameters.yheight) #define psf (_comp->_parameters.psf) #define k0 (_comp->_parameters.k0) #define eff (_comp->_parameters.eff) #define restore_neutron (_comp->_parameters.restore_neutron) #define PSD_N (_comp->_parameters.PSD_N) #define PSD_p (_comp->_parameters.PSD_p) #define PSD_p2 (_comp->_parameters.PSD_p2) #define weight (_comp->_parameters.weight) SIG_MESSAGE("[_kMoni_trace] component kMoni=PSD_monitor_psf_eff() TRACE [PSD_monitor_psf_eff:0]"); int i, j; double xp, yp; PROP_Z0; xp = x + psf * randnorm (); yp = y + psf * randnorm (); if (xp > xmin && xp < xmax && yp > ymin && yp < ymax) { weight = eff * k0 / (V2K * sqrt (vx * vx + vy * vy + vz * vz)); i = floor ((xp - xmin) * nx / (xmax - xmin)); j = floor ((yp - ymin) * ny / (ymax - ymin)); double p2w = p * p * weight * weight; double pw = p * weight; #pragma acc atomic PSD_N[i][j] = PSD_N[i][j] + 1; #pragma acc atomic PSD_p[i][j] = PSD_p[i][j] + pw; #pragma acc atomic PSD_p2[i][j] = PSD_p2[i][j] + p2w; SCATTER; } if (restore_neutron) { RESTORE_NEUTRON (INDEX_CURRENT_COMP, x, y, z, vx, vy, vz, t, sx, sy, sz, p); } #ifndef NOABSORB_INF_NAN /* Check for nan or inf particle parms */ if(isnan(p + t + vx + vy + vz + x + y + z)) ABSORB; if(isinf(fabs(p) + fabs(t) + fabs(vx) + fabs(vy) + fabs(vz) + fabs(x) + fabs(y) + fabs(z))) ABSORB; #else if(isnan(p) || isinf(p)) printf("NAN or INF found in p, %s (particle %lld)\n",_comp->_name,_particle->_uid); if(isnan(t) || isinf(t)) printf("NAN or INF found in t, %s (particle %lld)\n",_comp->_name,_particle->_uid); if(isnan(vx) || isinf(vx)) printf("NAN or INF found in vx, %s (particle %lld)\n",_comp->_name,_particle->_uid); if(isnan(vy) || isinf(vy)) printf("NAN or INF found in vy, %s (particle %lld)\n",_comp->_name,_particle->_uid); if(isnan(vz) || isinf(vz)) printf("NAN or INF found in vz, %s (particle %lld)\n",_comp->_name,_particle->_uid); if(isnan(x) || isinf(x)) printf("NAN or INF found in x, %s (particle %lld)\n",_comp->_name,_particle->_uid); if(isnan(y) || isinf(y)) printf("NAN or INF found in y, %s (particle %lld)\n",_comp->_name,_particle->_uid); if(isnan(z) || isinf(z)) printf("NAN or INF found in z, %s (particle %lld)\n",_comp->_name,_particle->_uid); #endif #define Mono_order (_particle->Mono_order) #define AnaBlade (_particle->AnaBlade) #define BinX (_particle->BinX) #define BinY (_particle->BinY) #define ncol_54 (_particle->ncol_54) #define nrow_54 (_particle->nrow_54) if (_comp->_index == 131) { // EXTEND 'psd_detector' BinX = floor((x - xmin)*nx/(xmax - xmin)); BinY = floor((y - ymin)*ny/(ymax - ymin)); } #undef Mono_order #undef AnaBlade #undef BinX #undef BinY #undef ncol_54 #undef nrow_54 #undef nx #undef ny #undef filename #undef xmin #undef xmax #undef ymin #undef ymax #undef nowritefile #undef xwidth #undef yheight #undef psf #undef k0 #undef eff #undef restore_neutron #undef PSD_N #undef PSD_p #undef PSD_p2 #undef weight return; } /* class_PSD_monitor_psf_eff_trace */ #pragma acc routine void class_Incoherent_trace(_class_Incoherent *_comp , _class_particle *_particle) { ABSORBED=SCATTERED=RESTORE=0; #define geometry (_comp->_parameters.geometry) #define radius (_comp->_parameters.radius) #define xwidth (_comp->_parameters.xwidth) #define yheight (_comp->_parameters.yheight) #define zdepth (_comp->_parameters.zdepth) #define thickness (_comp->_parameters.thickness) #define target_x (_comp->_parameters.target_x) #define target_y (_comp->_parameters.target_y) #define target_z (_comp->_parameters.target_z) #define focus_r (_comp->_parameters.focus_r) #define focus_xw (_comp->_parameters.focus_xw) #define focus_yh (_comp->_parameters.focus_yh) #define focus_aw (_comp->_parameters.focus_aw) #define focus_ah (_comp->_parameters.focus_ah) #define target_index (_comp->_parameters.target_index) #define pack (_comp->_parameters.pack) #define p_interact (_comp->_parameters.p_interact) #define f_QE (_comp->_parameters.f_QE) #define gamma (_comp->_parameters.gamma) #define Etrans (_comp->_parameters.Etrans) #define deltaE (_comp->_parameters.deltaE) #define sigma_abs (_comp->_parameters.sigma_abs) #define sigma_inc (_comp->_parameters.sigma_inc) #define Vc (_comp->_parameters.Vc) #define concentric (_comp->_parameters.concentric) #define order (_comp->_parameters.order) #define VarsInc (_comp->_parameters.VarsInc) #define offdata (_comp->_parameters.offdata) SIG_MESSAGE("[_Perspex_trace] component Perspex=Incoherent() TRACE [Incoherent:0]"); double t0, t3; /* Entry/exit time for outer surface */ double t1, t2; /* Entry/exit time for inner surface */ double dt0, dt1, dt2, dt; /* Flight times through sample */ double v = 0; /* Neutron velocity */ double d_path; /* Flight path length for non-scattered neutron */ double l_i, l_o = 0; /* Flight path lenght in/out for scattered neutron */ double my_a = 0, my_t = 0; /* Velocity-dependent attenuation factor and total Xsec */ double solid_angle = 0; /* Solid angle of target as seen from scattering point */ double aim_x = 0, aim_y = 0, aim_z = 1; /* Position of target relative to scattering point */ double v_i, v_f, E_i, E_f; /* initial and final energies and velocities */ double dE; /* Energy transfer */ int intersect = 0; int flag_concentric = 0; int flag = 0; double mc_trans, p_trans, mc_scatt, p_scatt, ws; double p_mult = 1; int flag_ishollow = 0; #ifdef OPENACC #ifdef USE_OFF off_struct thread_offdata = offdata; #endif #else #define thread_offdata offdata #endif do { /* Main interaction loop. Ends with intersect=0 */ /* Intersection neutron trajectory / sample (sample surface) */ if (VarsInc.shape == 0) intersect = cylinder_intersect (&t0, &t3, x, y, z, vx, vy, vz, radius, yheight); else if (VarsInc.shape == 1) intersect = box_intersect (&t0, &t3, x, y, z, vx, vy, vz, xwidth, yheight, zdepth); else if (VarsInc.shape == 2) intersect = sphere_intersect (&t0, &t3, x, y, z, vx, vy, vz, radius); #ifdef USE_OFF else if (VarsInc.shape == 3) intersect = off_intersect (&t0, &t3, NULL, NULL, x, y, z, vx, vy, vz, 0, 0, 0, thread_offdata); #endif if (intersect) { flag_ishollow = 0; if (thickness > 0) { if (VarsInc.shape == 0 && cylinder_intersect (&t1, &t2, x, y, z, vx, vy, vz, radius - thickness, yheight - 2 * thickness)) flag_ishollow = 1; else if (VarsInc.shape == 2 && sphere_intersect (&t1, &t2, x, y, z, vx, vy, vz, radius - thickness)) flag_ishollow = 1; else if (VarsInc.shape == 1 && box_intersect (&t1, &t2, x, y, z, vx, vy, vz, xwidth - 2 * thickness, yheight - 2 * thickness, zdepth - 2 * thickness)) flag_ishollow = 1; } if (!flag_ishollow) t1 = t2 = t3; /* no empty space inside */ dt0 = t1 - t0; /* Time in sample, ingoing */ dt1 = t2 - t1; /* Time in hole */ dt2 = t3 - t2; /* Time in sample, outgoing */ if (t0 > 0) { /* we are before the sample */ PROP_DT (t0); /* propagates neutron to the entry of the sample */ } else if (t1 > 0 && t1 > t0) { /* we are inside first part of the sample */ /* no propagation, stay inside */ } else if (t2 > 0 && t2 > t1) { /* we are in the hole */ PROP_DT (t2); /* propagate to inner surface of 2nd part of sample */ } else if (t3 > 0 && t3 > t2) { /* we are in the 2nd part of sample */ /* no propagation, stay inside */ } dt0 = t1 - (t0 > 0 ? t0 : 0); /* Time in first part of hollow/cylinder/box */ dt1 = t2 - (t1 > 0 ? t1 : 0); /* Time in hole */ dt2 = t3 - (t2 > 0 ? t2 : 0); /* Time in 2nd part of hollow cylinder */ if (dt0 < 0) dt0 = 0; if (dt1 < 0) dt1 = 0; if (dt2 < 0) dt2 = 0; /* initialize concentric mode */ if (concentric && !flag_concentric && t0 >= 0 && VarsInc.shape == 0 && thickness > 0) { flag_concentric = 1; } if (flag_concentric == 1) { dt1 = dt2 = 0; /* force exit when reaching hole/2nd part */ } if (!dt0 && !dt2) { intersect = 0; /* the sample was passed entirely */ break; } p_mult = 1; if (!v) v = sqrt (vx * vx + vy * vy + vz * vz); if (v) my_a = VarsInc.my_a_v * (2200 / v); else { printf ("Incoherent: %s: ERROR: Null velocity\n", NAME_CURRENT_COMP); ABSORB; /* should never occur */ } my_t = my_a + VarsInc.my_s; /* total scattering Xsect (tmp var) */ if (my_t <= 0) { printf ("Incoherent: %s: ERROR: Null total cross section %g. Removing event.\n", NAME_CURRENT_COMP, my_t); ABSORB; /* should never occur */ } d_path = v * (dt0 + dt2); /* Length of full path through sample */ /* Proba of scattering vs absorption (integrating along the whole trajectory) */ ws = VarsInc.my_s / my_t; /* (inc+coh)/(inc+coh+abs) */ /* Proba of transmission along length d_path */ p_trans = exp (-my_t * d_path); p_scatt = 1 - p_trans; /* portion of beam which scatters */ flag = 0; /* flag used for propagation to exit point before ending */ /* are we next to the exit ? probably no scattering (avoid rounding errors) */ if (VarsInc.my_s * d_path <= 4e-7) { flag = 1; /* No interaction before the exit */ } /* force a given fraction of the beam to scatter */ if (p_interact > 0 && p_interact <= 1) { /* we force a portion of the beam to interact */ /* This is used to improve statistics on single scattering (and multiple) */ if (!SCATTERED) mc_trans = 1 - p_interact; else mc_trans = 1 - p_interact / (4 * SCATTERED + 1); /* reduce effect on multi scatt */ } else { mc_trans = p_trans; /* 1 - p_scatt */ } mc_scatt = 1 - mc_trans; /* portion of beam to scatter (or force to) */ if (mc_scatt <= 0 || mc_scatt > 1) flag = 1; /* MC choice: Interaction or transmission ? */ if (!flag && mc_scatt > 0 && (mc_scatt >= 1 || (rand01 ()) < mc_scatt)) { /* Interaction neutron/sample */ p_mult *= ws; /* Update weight ; account for absorption and retain scattered fraction */ if (!mc_scatt) ABSORB; /* we have chosen portion mc_scatt of beam instead of p_scatt, so we compensate */ p_mult *= fabs (p_scatt / mc_scatt); /* lower than 1 */ } else { flag = 1; /* Transmission : no interaction neutron/sample */ if (!mc_trans) ABSORB; p_mult *= fabs (p_trans / mc_trans); /* attenuate beam by portion which is scattered (and left along) */ } if (flag) { /* propagate to exit of sample and finish */ intersect = 0; p *= p_mult; /* apply absorption correction */ PROP_DT (dt0 + dt2); break; /* exit main multi scatt while loop */ } if (my_t * d_path < 1e-6) /* For very weak scattering, use simple uniform sampling of scattering point to avoid rounding errors. */ dt = rand0max (d_path); /* length */ else dt = -log (1 - rand0max ((1 - exp (-my_t * d_path)))) / my_t; /* length */ l_i = dt; /* Penetration in sample: scattering+abs */ dt /= v; /* Time from present position to scattering point */ /* If t0 is in hole, propagate to next part of the hollow cylinder */ if (dt1 > 0 && dt0 > 0 && dt > dt0) dt += dt1; PROP_DT (dt); /* Point of scattering */ if ((VarsInc.tx || VarsInc.ty || VarsInc.tz)) { aim_x = VarsInc.tx - x; /* Vector pointing at target (anal./det.) */ aim_y = VarsInc.ty - y; aim_z = VarsInc.tz - z; } if (VarsInc.aw && VarsInc.ah) { randvec_target_rect_angular (&vx, &vy, &vz, &solid_angle, aim_x, aim_y, aim_z, VarsInc.aw, VarsInc.ah, ROT_A_CURRENT_COMP); } else if (VarsInc.xw && VarsInc.yh) { randvec_target_rect (&vx, &vy, &vz, &solid_angle, aim_x, aim_y, aim_z, VarsInc.xw, VarsInc.yh, ROT_A_CURRENT_COMP); } else { randvec_target_circle (&vx, &vy, &vz, &solid_angle, aim_x, aim_y, aim_z, focus_r); } NORM (vx, vy, vz); v_i = v; /* Store initial velocity in case of quasielastic */ E_i = VS2E * v_i * v_i; if (deltaE == 0) { if (rand01 () < f_QE) /* Quasielastic contribution */ { dE = gamma * tan (PI / 2 * randpm1 ()); E_f = E_i + dE; if (E_f <= 0) ABSORB; v_f = SE2V * sqrt (E_f); v = v_f; /* printf("vi: %g Ei: %g dE: %g Ef %g vf: %g v: %g \n", v_i,E_i,dE,E_f,v_f,v); */ } } else { E_f = E_i - Etrans + deltaE * randpm1 (); // E_f=E0; v_f = SE2V * sqrt (E_f); v = v_f; } vx *= v; vy *= v; vz *= v; /* We do not consider scattering from 2nd part (outgoing) */ p_mult *= solid_angle / 4 / PI; p *= p_mult; /* Polarisation part (1/3 NSF, 2/3 SF) */ sx *= -1.0 / 3.0; sy *= -1.0 / 3.0; sz *= -1.0 / 3.0; SCATTER; /* test for a given multiple order */ if (order && SCATTERED >= order) { intersect = 0; /* reached required number of SCATTERing */ break; /* finish multiple scattering loop */ } } /* end if intersect */ } while (intersect); /* end do (intersect) (multiple scattering loop) */ // Add attenuation of exit flight path for non-multiple scattering if (order && SCATTERED) { if (VarsInc.shape == 0) intersect = cylinder_intersect (&t0, &t3, x, y, z, vx, vy, vz, radius, yheight); else if (VarsInc.shape == 1) intersect = box_intersect (&t0, &t3, x, y, z, vx, vy, vz, xwidth, yheight, zdepth); else if (VarsInc.shape == 2) intersect = sphere_intersect (&t0, &t3, x, y, z, vx, vy, vz, radius); #ifdef USE_OFF else if (VarsInc.shape == 3) intersect = off_intersect (&t0, &t3, NULL, NULL, x, y, z, vx, vy, vz, 0, 0, 0, thread_offdata); #endif flag_ishollow = 0; if (thickness > 0) { if (VarsInc.shape == 0 && cylinder_intersect (&t1, &t2, x, y, z, vx, vy, vz, radius - thickness, yheight - 2 * thickness)) flag_ishollow = 1; else if (VarsInc.shape == 2 && sphere_intersect (&t1, &t2, x, y, z, vx, vy, vz, radius - thickness)) flag_ishollow = 1; else if (VarsInc.shape == 1 && box_intersect (&t1, &t2, x, y, z, vx, vy, vz, xwidth - 2 * thickness, yheight - 2 * thickness, zdepth - 2 * thickness)) flag_ishollow = 1; } if (!flag_ishollow) t1 = t2 = t3; /* no empty space inside */ dt0 = t1 - (t0 > 0 ? t0 : 0); /* Time in first part of hollow/cylinder/box */ dt1 = t2 - (t1 > 0 ? t1 : 0); /* Time in hole */ dt2 = t3 - (t2 > 0 ? t2 : 0); /* Time in 2nd part of hollow cylinder */ if (dt0 < 0) dt0 = 0; if (dt1 < 0) dt1 = 0; if (dt2 < 0) dt2 = 0; /* initialize concentric mode */ if (concentric && !flag_concentric && t0 >= 0 && VarsInc.shape == 0 && thickness > 0) { flag_concentric = 1; } if (flag_concentric == 1) { dt1 = dt2 = 0; /* force exit when reaching hole/2nd part */ } d_path = v * (dt0 + dt2); // Attenuate only for material part, not hollow part p_trans = exp (-my_t * d_path); p *= p_trans; if (flag_concentric == 1 && flag_ishollow == 1 && t1 > 0) { PROP_DT (t1); // When conentric, only propagate ray to start of hollow part } else { PROP_DT (t3); // Otherwise propagate out of the sample } } #ifndef NOABSORB_INF_NAN /* Check for nan or inf particle parms */ if(isnan(p + t + vx + vy + vz + x + y + z)) ABSORB; if(isinf(fabs(p) + fabs(t) + fabs(vx) + fabs(vy) + fabs(vz) + fabs(x) + fabs(y) + fabs(z))) ABSORB; #else if(isnan(p) || isinf(p)) printf("NAN or INF found in p, %s (particle %lld)\n",_comp->_name,_particle->_uid); if(isnan(t) || isinf(t)) printf("NAN or INF found in t, %s (particle %lld)\n",_comp->_name,_particle->_uid); if(isnan(vx) || isinf(vx)) printf("NAN or INF found in vx, %s (particle %lld)\n",_comp->_name,_particle->_uid); if(isnan(vy) || isinf(vy)) printf("NAN or INF found in vy, %s (particle %lld)\n",_comp->_name,_particle->_uid); if(isnan(vz) || isinf(vz)) printf("NAN or INF found in vz, %s (particle %lld)\n",_comp->_name,_particle->_uid); if(isnan(x) || isinf(x)) printf("NAN or INF found in x, %s (particle %lld)\n",_comp->_name,_particle->_uid); if(isnan(y) || isinf(y)) printf("NAN or INF found in y, %s (particle %lld)\n",_comp->_name,_particle->_uid); if(isnan(z) || isinf(z)) printf("NAN or INF found in z, %s (particle %lld)\n",_comp->_name,_particle->_uid); #endif #undef geometry #undef radius #undef xwidth #undef yheight #undef zdepth #undef thickness #undef target_x #undef target_y #undef target_z #undef focus_r #undef focus_xw #undef focus_yh #undef focus_aw #undef focus_ah #undef target_index #undef pack #undef p_interact #undef f_QE #undef gamma #undef Etrans #undef deltaE #undef sigma_abs #undef sigma_inc #undef Vc #undef concentric #undef order #undef VarsInc #undef offdata return; } /* class_Incoherent_trace */ #pragma acc routine void class_PowderN_trace(_class_PowderN *_comp , _class_particle *_particle) { ABSORBED=SCATTERED=RESTORE=0; #define reflections (_comp->_parameters.reflections) #define geometry (_comp->_parameters.geometry) #define format (_comp->_parameters.format) #define radius (_comp->_parameters.radius) #define yheight (_comp->_parameters.yheight) #define xwidth (_comp->_parameters.xwidth) #define zdepth (_comp->_parameters.zdepth) #define thickness (_comp->_parameters.thickness) #define pack (_comp->_parameters.pack) #define Vc (_comp->_parameters.Vc) #define sigma_abs (_comp->_parameters.sigma_abs) #define sigma_inc (_comp->_parameters.sigma_inc) #define delta_d_d (_comp->_parameters.delta_d_d) #define p_inc (_comp->_parameters.p_inc) #define p_transmit (_comp->_parameters.p_transmit) #define DW (_comp->_parameters.DW) #define nb_atoms (_comp->_parameters.nb_atoms) #define d_omega (_comp->_parameters.d_omega) #define d_phi (_comp->_parameters.d_phi) #define tth_sign (_comp->_parameters.tth_sign) #define p_interact (_comp->_parameters.p_interact) #define concentric (_comp->_parameters.concentric) #define density (_comp->_parameters.density) #define weight (_comp->_parameters.weight) #define barns (_comp->_parameters.barns) #define Strain (_comp->_parameters.Strain) #define focus_flip (_comp->_parameters.focus_flip) #define target_index (_comp->_parameters.target_index) #define order (_comp->_parameters.order) #define line_info (_comp->_parameters.line_info) #define columns (_comp->_parameters.columns) #define offdata (_comp->_parameters.offdata) #define tgt_x (_comp->_parameters.tgt_x) #define tgt_y (_comp->_parameters.tgt_y) #define tgt_z (_comp->_parameters.tgt_z) SIG_MESSAGE("[_powderSample_trace] component powderSample=PowderN() TRACE [PowderN:0]"); double t0, t1, t2, t3, v, v1, l_full, l, l_1, dt, alpha0, alpha, theta, my_s, my_s_n, sg; double solid_angle; double neutrontype = 0; double ntype = 0; double arg, tmp_vx, tmp_vy, tmp_vz, vout_x, vout_y, vout_z, nx, ny, nz, pmul = 1; int line; char intersect = 0; char intersecti = 0; // Variables calculated within thread for thread purpose only char type = '\0'; int itype = 0; double d_phi_thread = d_phi; // These ones are injected back to struct at the end of TRACE in non-OpenACC case int nb_reuses = line_info.nb_reuses; int nb_refl = line_info.nb_refl; int nb_refl_count = line_info.nb_refl_count; double vcache = line_info.v; double Nq = line_info.Nq; double v_min = line_info.v_min; double v_max = line_info.v_max; double lfree = line_info.lfree; long xs_compute = line_info.xs_compute; long xs_reuse = line_info.xs_reuse; long xs_calls = line_info.xs_calls; double dq = line_info.dq; #ifdef OPENACC #ifdef USE_OFF off_struct thread_offdata = offdata; #endif #else #define thread_offdata offdata #endif if (line_info.V_0 > 0 && (line_info.count || line_info.my_inc)) { if (line_info.shape == 1) { intersect = box_intersect (&t0, &t3, x, y, z, vx, vy, vz, xwidth, yheight, zdepth); intersecti = box_intersect (&t1, &t2, x, y, z, vx, vy, vz, line_info.xwidth_i, line_info.yheight_i, line_info.zdepth_i); } else if (line_info.shape == 0) { intersect = cylinder_intersect (&t0, &t3, x, y, z, vx, vy, vz, radius, yheight); intersecti = cylinder_intersect (&t1, &t2, x, y, z, vx, vy, vz, line_info.radius_i, line_info.yheight_i); } else if (line_info.shape == 2) { intersect = sphere_intersect (&t0, &t3, x, y, z, vx, vy, vz, radius); intersecti = sphere_intersect (&t1, &t2, x, y, z, vx, vy, vz, line_info.radius_i); } #ifdef USE_OFF else if (line_info.shape == 3) { intersect = off_intersect (&t0, &t3, NULL, NULL, x, y, z, vx, vy, vz, 0, 0, 0, thread_offdata); intersecti = 0; } #endif } if (intersect && t3 > 0) { if (concentric) { /* Set up for concentric case */ /* 'Remove' the backside of this comp */ if (!intersecti) { t1 = (t3 + t0) / 2; } t2 = t1; t3 = t1; dt = -1.0 * rand01 (); /* In case of scattering we will scatter on 'forward' part of sample */ } else { if (!intersecti) { t1 = (t3 + t0) / 2; t2 = t1; } dt = randpm1 (); /* Possibility to scatter at all points in line of sight */ } /* Neutron enters at t=t0. */ if (t0 < 0) t0 = 0; /* already in sample */ if (t1 < 0) t1 = 0; /* already in inner hollow */ if (t2 < 0) t2 = 0; /* already past inner hollow */ v = sqrt (vx * vx + vy * vy + vz * vz); l_full = v * (t3 - t2 + t1 - t0); if (line_info.neutron_passed < CHAR_BUF_LENGTH) { if (v < v_min) v_min = v; if (v > v_max) v_max = v; line_info.neutron_passed++; } /* Calculate total scattering cross section at relevant velocity - but not on GPU*/ #ifndef OPENACC if (fabs (v - vcache) < 1e-6) { nb_reuses++; } else { #endif Nq = calc_xsect (v, line_info.q_v, line_info.my_s_v2, line_info.count, &line_info.my_s_v2_sum, &line_info); vcache = v; nb_refl += Nq; nb_refl_count++; #ifndef OPENACC } #endif if (t3 < 0) { t3 = 0; /* Already past sample?! */ if (line_info.flag_warning < 10) printf ("PowderN: %s: Warning: Neutron has already passed us? (Skipped).\n" " In concentric geometry, this may be caused by a missing concentric=0 option in 2nd enclosing instance.\n", NAME_CURRENT_COMP); line_info.flag_warning++; } else { if (dt < 0) { /* Calculate scattering point position */ dt = fabs (dt) * (t1 - t0); /* 'Forward' part */ } else { dt = dt * (t3 - t2) + (t2 - t0); /* Possibly also 'backside' part */ } if (order) { my_s = line_info.my_s_v2_sum / (v * v) + line_info.my_inc; } else { my_s = line_info.my_inc; } /* Total attenuation from scattering */ lfree = 0; ntype = rand01 (); /* How to handle this one? Transmit (1) / Incoherent (2) / Coherent (3) ? */ if (ntype < p_transmit) { neutrontype = 1; l = l_full; /* Passing through, full length */ PROP_DT (t3); } else if (ntype >= p_transmit && ntype < (p_transmit + p_inc)) { neutrontype = 2; l = v * dt; /* Penetration in sample */ PROP_DT (dt + t0); /* Point of scattering */ SCATTER; } else if (ntype >= p_transmit + p_inc) { neutrontype = 3; l = v * dt; /* Penetration in sample */ PROP_DT (dt + t0); /* Point of scattering */ SCATTER; } else { exit (fprintf (stderr, "PowderN %s: DEAD - this shouldn't happen!\n", NAME_CURRENT_COMP)); } if (neutrontype == 3) { /* Make coherent scattering event */ if (line_info.count > 0) { /* choose line */ if (Nq > 1) line = floor (Nq * rand01 ()); /* Select between Nq powder lines */ else line = 0; if (line_info.w_v[line]) arg = line_info.q_v[line] * (1 + line_info.w_v[line] * randnorm ()) / (2.0 * v); else arg = line_info.q_v[line] / (2.0 * v); my_s_n = line_info.my_s_v2[line] / (v * v); if (fabs (arg) > 1) ABSORB; /* No bragg scattering possible*/ if (tth_sign == 0) { sg = randpm1 (); if (sg > 0) sg = 1; else sg = -1; } else { sg = tth_sign / fabs (tth_sign); } theta = asin (arg); /* Bragg scattering law */ /* Choose point on Debye-Scherrer cone */ if (d_phi_thread) { /* relate height of detector to the height on DS cone */ arg = sin (d_phi_thread * DEG2RAD / 2) / sin (2 * theta); /* If full Debye-Scherrer cone is within d_phi, don't focus */ if (arg < -1 || arg > 1) d_phi_thread = 0; /* Otherwise, determine alpha to rotate from scattering plane into d_phi focusing area*/ else alpha = 2 * asin (arg); } if (d_phi_thread) { /* Focusing */ alpha = fabs (alpha); alpha0 = 0.5 * randpm1 () * alpha; if (focus_flip) { alpha0 += M_PI_2; } } else alpha0 = PI * randpm1 (); /* now find a nearly vertical rotation axis: * Either * (v along Z) x (X axis) -> nearly Y axis * Or * (v along X) x (Z axis) -> nearly Y axis */ /* update JS, 1/7/2017 If a target is defined, try to define vertical axis as a normal to the plane defined by the incident neutron velocity and target position. Check that v is not ~ parallel to the target direction. */ double vnorm = 0.0; if (target_index) { vec_prod (tmp_vx, tmp_vy, tmp_vz, vx, vy, vz, tgt_x, tgt_y, tgt_z); vnorm = sqrt (tmp_vx * tmp_vx + tmp_vy * tmp_vy + tmp_vz * tmp_vz) / v; } // no target or direction is nearly parallel to v: if (vnorm < 0.01) { if (fabs (vx / v) < fabs (vz / v)) { nx = 1; ny = 0; nz = 0; } else { nx = 0; ny = 0; nz = 1; } vec_prod (tmp_vx, tmp_vy, tmp_vz, vx, vy, vz, nx, ny, nz); } /* v_out = rotate 'v' by 2*theta around tmp_v: Bragg angle */ rotate (vout_x, vout_y, vout_z, vx, vy, vz, 2 * sg * theta, tmp_vx, tmp_vy, tmp_vz); /* tmp_v = rotate v_out by alpha0 around 'v' (Debye-Scherrer cone) */ rotate (tmp_vx, tmp_vy, tmp_vz, vout_x, vout_y, vout_z, alpha0, vx, vy, vz); vx = tmp_vx; vy = tmp_vy; vz = tmp_vz; /* Since now scattered and new direction given, calculate path to exit */ if (line_info.shape == 1) { intersect = box_intersect (&t0, &t3, x, y, z, vx, vy, vz, xwidth, yheight, zdepth); intersecti = box_intersect (&t1, &t2, x, y, z, vx, vy, vz, line_info.xwidth_i, line_info.yheight_i, line_info.zdepth_i); } else if (line_info.shape == 0) { intersect = cylinder_intersect (&t0, &t3, x, y, z, vx, vy, vz, radius, yheight); intersecti = cylinder_intersect (&t1, &t2, x, y, z, vx, vy, vz, line_info.radius_i, line_info.yheight_i); } else if (line_info.shape == 2) { intersect = sphere_intersect (&t0, &t3, x, y, z, vx, vy, vz, radius); intersecti = sphere_intersect (&t1, &t2, x, y, z, vx, vy, vz, line_info.radius_i); } #ifdef USE_OFF else if (line_info.shape == 3) { intersect = off_intersect (&t0, &t3, NULL, NULL, x, y, z, vx, vy, vz, 0, 0, 0, thread_offdata); intersecti = 0; } #endif if (!intersect) { /* Strange error: did not hit cylinder */ if (line_info.flag_warning < 10) printf ("PowderN: %s: WARNING: Did not hit sample from inside (coh). ABSORB.\n", NAME_CURRENT_COMP); line_info.flag_warning++; ABSORB; } if (!intersecti) { t1 = (t3 + t0) / 2; t2 = t1; } if (concentric && intersecti) { /* In case of concentricity, 'remove' backward wall of sample */ t2 = t1; t3 = t1; } if (t0 < 0) t0 = 0; /* already in sample */ if (t1 < 0) t1 = 0; /* already in inner hollow */ if (t2 < 0) t2 = 0; /* already past inner hollow */ l_1 = v * (t3 - t2 + t1 - t0); /* Length to exit */ pmul *= Nq * l_full * my_s_n * exp (-(line_info.my_a_v / v + my_s) * (l + l_1)) / (1 - (p_inc + p_transmit)); /* Correction in case of d_phi focusing - BUT only when d_phi != 0 */ if (d_phi_thread) { pmul *= alpha / PI; if (tth_sign) pmul *= 0.5; } type = 'c'; itype = 1; dq = line_info.q_v[line] * V2K; lfree = 1 / (line_info.my_a_v / v + my_s); } /* else transmit <-- No powder lines in file */ } /* Coherent scattering event */ else if (neutrontype == 2) { /* Make incoherent scattering event */ if (d_omega && d_phi_thread) { randvec_target_rect_angular (&vx, &vy, &vz, &solid_angle, tgt_x, tgt_y, tgt_z, d_omega * DEG2RAD, d_phi_thread * DEG2RAD, ROT_A_CURRENT_COMP); } else if (d_phi_thread) { randvec_target_rect_angular (&vx, &vy, &vz, &solid_angle, tgt_x, tgt_y, tgt_z, 2 * PI, d_phi_thread * DEG2RAD, ROT_A_CURRENT_COMP); } else { randvec_target_circle (&vx, &vy, &vz, &solid_angle, 0, 0, 1, 0); } v1 = sqrt (vx * vx + vy * vy + vz * vz); vx *= v / v1; vy *= v / v1; vz *= v / v1; /* Since now scattered and new direction given, calculate path to exit */ if (line_info.shape == 1) { intersect = box_intersect (&t0, &t3, x, y, z, vx, vy, vz, xwidth, yheight, zdepth); intersecti = box_intersect (&t1, &t2, x, y, z, vx, vy, vz, line_info.xwidth_i, line_info.yheight_i, line_info.zdepth_i); } else if (line_info.shape == 0) { intersect = cylinder_intersect (&t0, &t3, x, y, z, vx, vy, vz, radius, yheight); intersecti = cylinder_intersect (&t1, &t2, x, y, z, vx, vy, vz, line_info.radius_i, line_info.yheight_i); } else if (line_info.shape == 2) { intersect = sphere_intersect (&t0, &t3, x, y, z, vx, vy, vz, radius); intersecti = sphere_intersect (&t1, &t2, x, y, z, vx, vy, vz, line_info.radius_i); } #ifdef USE_OFF else if (line_info.shape == 3) { intersect = off_intersect (&t0, &t3, NULL, NULL, x, y, z, vx, vy, vz, 0, 0, 0, thread_offdata); intersecti = 0; } #endif if (!intersect) { /* Strange error: did not hit cylinder */ if (line_info.flag_warning < 10) printf ("PowderN: %s: WARNING: Did not hit sample from inside (inc). ABSORB.\n", NAME_CURRENT_COMP); line_info.flag_warning++; ABSORB; } if (!intersecti) { t1 = (t3 + t0) / 2; t2 = t1; } if (concentric && intersecti) { /* In case of concentricity, 'remove' backward wall of sample */ t2 = t1; t3 = t1; } if (t0 < 0) t0 = 0; /* already in sample */ if (t1 < 0) t1 = 0; /* already in inner hollow */ if (t2 < 0) t2 = 0; /* already past inner hollow */ l_1 = v * (t3 - t2 + t1 - t0); /* Length to exit */ pmul *= l_full * line_info.my_inc * exp (-(line_info.my_a_v / v + my_s) * (l + l_1)) / (p_inc); pmul *= solid_angle / (4 * PI); lfree = 1 / (line_info.my_a_v / v + my_s); type = 'i'; itype = 2; } /* Incoherent scattering event */ else if (neutrontype == 1) { /* Make transmitted (absorption-corrected) event */ /* No coordinate changes here, simply change neutron weight */ pmul *= exp (-(line_info.my_a_v / v + my_s) * (l)) / (p_transmit); lfree = 1 / (line_info.my_a_v / v + my_s); type = 't'; itype = 3; } p *= pmul; } /* Neutron leaving since it has passed already */ } /* else transmit non interacting neutrons */ // Inject these back to global struct in non-OpenACC case #ifndef OPENACC line_info.nb_reuses = nb_reuses; line_info.nb_refl = nb_refl; line_info.nb_refl_count = nb_refl_count; line_info.v = vcache; line_info.Nq = Nq; line_info.v_min = v_min; line_info.v_max = v_max; line_info.lfree = lfree; line_info.xs_compute = xs_compute; line_info.xs_reuse = xs_reuse; line_info.xs_calls = xs_calls; line_info.dq = dq; #endif #ifndef NOABSORB_INF_NAN /* Check for nan or inf particle parms */ if(isnan(p + t + vx + vy + vz + x + y + z)) ABSORB; if(isinf(fabs(p) + fabs(t) + fabs(vx) + fabs(vy) + fabs(vz) + fabs(x) + fabs(y) + fabs(z))) ABSORB; #else if(isnan(p) || isinf(p)) printf("NAN or INF found in p, %s (particle %lld)\n",_comp->_name,_particle->_uid); if(isnan(t) || isinf(t)) printf("NAN or INF found in t, %s (particle %lld)\n",_comp->_name,_particle->_uid); if(isnan(vx) || isinf(vx)) printf("NAN or INF found in vx, %s (particle %lld)\n",_comp->_name,_particle->_uid); if(isnan(vy) || isinf(vy)) printf("NAN or INF found in vy, %s (particle %lld)\n",_comp->_name,_particle->_uid); if(isnan(vz) || isinf(vz)) printf("NAN or INF found in vz, %s (particle %lld)\n",_comp->_name,_particle->_uid); if(isnan(x) || isinf(x)) printf("NAN or INF found in x, %s (particle %lld)\n",_comp->_name,_particle->_uid); if(isnan(y) || isinf(y)) printf("NAN or INF found in y, %s (particle %lld)\n",_comp->_name,_particle->_uid); if(isnan(z) || isinf(z)) printf("NAN or INF found in z, %s (particle %lld)\n",_comp->_name,_particle->_uid); #endif #undef reflections #undef geometry #undef format #undef radius #undef yheight #undef xwidth #undef zdepth #undef thickness #undef pack #undef Vc #undef sigma_abs #undef sigma_inc #undef delta_d_d #undef p_inc #undef p_transmit #undef DW #undef nb_atoms #undef d_omega #undef d_phi #undef tth_sign #undef p_interact #undef concentric #undef density #undef weight #undef barns #undef Strain #undef focus_flip #undef target_index #undef order #undef line_info #undef columns #undef offdata #undef tgt_x #undef tgt_y #undef tgt_z return; } /* class_PowderN_trace */ #pragma acc routine void class_Single_crystal_trace(_class_Single_crystal *_comp , _class_particle *_particle) { ABSORBED=SCATTERED=RESTORE=0; #define reflections (_comp->_parameters.reflections) #define geometry (_comp->_parameters.geometry) #define mosaic_AB (_comp->_parameters.mosaic_AB) #define xwidth (_comp->_parameters.xwidth) #define yheight (_comp->_parameters.yheight) #define zdepth (_comp->_parameters.zdepth) #define radius (_comp->_parameters.radius) #define delta_d_d (_comp->_parameters.delta_d_d) #define mosaic (_comp->_parameters.mosaic) #define mosaic_a (_comp->_parameters.mosaic_a) #define mosaic_b (_comp->_parameters.mosaic_b) #define mosaic_c (_comp->_parameters.mosaic_c) #define recip_cell (_comp->_parameters.recip_cell) #define barns (_comp->_parameters.barns) #define ax (_comp->_parameters.ax) #define ay (_comp->_parameters.ay) #define az (_comp->_parameters.az) #define bx (_comp->_parameters.bx) #define by (_comp->_parameters.by) #define bz (_comp->_parameters.bz) #define cx (_comp->_parameters.cx) #define cy (_comp->_parameters.cy) #define cz (_comp->_parameters.cz) #define p_transmit (_comp->_parameters.p_transmit) #define sigma_abs (_comp->_parameters.sigma_abs) #define sigma_inc (_comp->_parameters.sigma_inc) #define aa (_comp->_parameters.aa) #define bb (_comp->_parameters.bb) #define cc (_comp->_parameters.cc) #define order (_comp->_parameters.order) #define extra_order (_comp->_parameters.extra_order) #define RX (_comp->_parameters.RX) #define RY (_comp->_parameters.RY) #define powder (_comp->_parameters.powder) #define PG (_comp->_parameters.PG) #define deltak (_comp->_parameters.deltak) #define hkl_info (_comp->_parameters.hkl_info) #define offdata (_comp->_parameters.offdata) #define hkl_list (_comp->_parameters.hkl_list) #define tau_list (_comp->_parameters.tau_list) SIG_MESSAGE("[_crystalSample_trace] component crystalSample=Single_crystal() TRACE [Single_crystal:0]"); double t1, t2 = 0; /* Entry and exit times in sample */ struct hkl_data* L; /* Structure factor list */ int i; /* Index into structure factor list */ #ifndef OPENACC struct tau_data* T; /* List of reflections close to Ewald sphere */ #else struct tau_data T[MCSX_REFL_SLIST_SIZE]; #endif int tau_count; /* Number of reflections close to Ewald sphere*/ int j; /* Index into reflection list */ int event_counter; /* scattering event counter */ double kix, kiy, kiz, ki; /* Initial wave vector [1/AA] */ double kfx, kfy, kfz; /* Final wave vector */ double v; /* Neutron velocity */ double rho_x, rho_y, rho_z; /* the vector ki - tau */ double rho; double diff; /* Deviation from Bragg condition */ double ox, oy, oz; /* Origin of Ewald sphere tangent plane */ double b1x, b1y, b1z; /* First vector spanning tangent plane */ double b2x, b2y, b2z; /* Second vector spanning tangent plane */ double n11, n12, n22; /* 2D Gauss description matrix N */ double det_N; /* Determinant of N */ double inv_n11, inv_n12, inv_n22; /* Inverse of N */ double l11, l12, l22; /* Cholesky decomposition L of 1/2*inv(N) */ double det_L; /* Determinant of L */ double Bt_D_O_x, Bt_D_O_y; /* Temporaries */ double y0x, y0y; /* Center of 2D Gauss in plane coordinates */ double alpha; /* Offset of 2D Gauss center from 3D center */ double V0; /* Volume of unit cell */ double l_full; /* Neutron path length for transmission */ double l; /* Path length to scattering event */ double abs_xsect, abs_xlen; /* Absorption cross section and length */ double inc_xsect, inc_xlen; /* Incoherent scattering cross section and length */ double coh_xlen; /* Coherent cross section and length */ double tot_xsect, tot_xlen; /* Total cross section and length */ double z1, z2, y1, y2; /* Temporaries to choose kf from 2D Gauss */ double adjust, sum; /* Temporaries */ double p_trans; /* Transmission probability */ double mc_trans, mc_interact; /* Transmission, interaction MC choices */ int intersect = 0; double theta, phi; /* rotation angles for curved lattice option */ double curv_xangle; double curv_yangle; double _vx; double _vy; double _vz; char type; /* type of last event: t=transmit,c=coherent or i=incoherent */ int itype; /* type of last event: t=1,c=2 or i=3 */ #ifdef OPENACC #ifdef USE_OFF off_struct thread_offdata = offdata; #endif #else #define thread_offdata offdata #endif /* Intersection neutron trajectory / sample (sample surface) */ if (hkl_info.shape == 0) intersect = cylinder_intersect (&t1, &t2, x, y, z, vx, vy, vz, radius, yheight); else if (hkl_info.shape == 1) intersect = box_intersect (&t1, &t2, x, y, z, vx, vy, vz, xwidth, yheight, zdepth); else if (hkl_info.shape == 2) intersect = sphere_intersect (&t1, &t2, x, y, z, vx, vy, vz, radius); #ifdef USE_OFF else if (hkl_info.shape == 3) intersect = off_intersect (&t1, &t2, NULL, NULL, x, y, z, vx, vy, vz, 0, 0, 0, thread_offdata); #endif if (t2 < 0) intersect = 0; /* we passed sample volume already */ if (intersect) { /* Neutron intersects crystal */ if (t1 > 0) PROP_DT (t1); /* Move to crystal surface if not inside */ v = sqrt (vx * vx + vy * vy + vz * vz); ki = V2K * v; event_counter = 0; abs_xsect = hkl_info.sigma_a * 2200 / v; inc_xsect = hkl_info.sigma_i; V0 = hkl_info.V0; abs_xlen = abs_xsect / V0; inc_xlen = inc_xsect / V0; /* Scalar cross sections for inc/abs are given in barns, so we need a scaling factor of 100 to get scattering lengths in m, since V0 is assumed to be in AA*/ abs_xlen *= 100; inc_xlen *= 100; L = hkl_list; type = '\0'; itype = 0; #ifndef OPENACC T = tau_list; hkl_info.type = type; #endif do { /* Loop over multiple scattering events */ /* Angles for powder randomization */ double Alpha, Beta, Gamma; double lab_vx, lab_vy, lab_vz; lab_vx = vx; lab_vy = vy; lab_vz = vz; if (hkl_info.shape == 0) intersect = cylinder_intersect (&t1, &t2, x, y, z, vx, vy, vz, radius, yheight); else if (hkl_info.shape == 1) intersect = box_intersect (&t1, &t2, x, y, z, vx, vy, vz, xwidth, yheight, zdepth); else if (hkl_info.shape == 2) intersect = sphere_intersect (&t1, &t2, x, y, z, vx, vy, vz, radius); #ifdef USE_OFF else if (hkl_info.shape == 3) intersect = off_intersect (&t1, &t2, NULL, NULL, x, y, z, vx, vy, vz, 0, 0, 0, thread_offdata); #endif if (!intersect || t2 * v < -1e-9 || t1 * v > 1e-9) { /* neutron is leaving the sample */ if (hkl_info.flag_warning < 10) #ifndef OPENACC fprintf (stderr, "Single_crystal: %s: Warning: neutron has unexpectedly left the crystal!\n" " t1=%g t2=%g x=%g y=%g z=%g vx=%g vy=%g vz=%g\n", NAME_CURRENT_COMP, t1, t2, x, y, z, vx, vy, vz); hkl_info.flag_warning++; #endif break; } l_full = t2 * v; if ((order && !(extra_order) && event_counter >= order) || (order && extra_order && event_counter >= order + extra_order)) { // Exit due to truncated order, weight with relevant cross-sections to distance l_full p *= exp (-abs_xlen * l_full); intersect = 0; break; } /* (1). Compute incoming wave vector ki */ if (powder) { /* orientation of crystallite is random */ Alpha = randpm1 () * PI * powder; Beta = randpm1 () * PI / 2; Gamma = randpm1 () * PI; randrotate (&vx, &vy, &vz, Alpha, Beta, Gamma); } if (PG) { /* orientation of crystallite is random along axis */ Alpha = randpm1 () * PI * PG; PGrotate (&vx, &vy, &vz, Alpha, hkl_info.csx, hkl_info.csy, hkl_info.csz); } /* ------------------------------------------------------------------------- */ /* lattice curvature option: rotate neutron velocity */ /* WARNING: cannot be used together with the PG c-rotation! */ curv_xangle = 0; curv_yangle = 0; _vx = vx; _vy = vy; _vz = vz; if (RY) { /* rotate v around x axis based on y pos, for vertical focus */ curv_yangle = atan2 (y, RY); vec_rotate_2d (&vy, &vz, curv_yangle); vec_rotate_2d (&sy, &sz, curv_yangle); /*changing y,z actually curves the crystal, not only the planes*/ /*comment out if only curvature of the lattice planes is needed*/ vec_rotate_2d (&y, &z, curv_yangle); } if (RX) { /* rotate v around y axis based on x pos, for horizontal focus */ curv_xangle = atan2 (x, RX); vec_rotate_2d (&vx, &vz, curv_xangle); vec_rotate_2d (&sx, &sz, curv_xangle); /*changing x,z actually curves the crystal, not only the planes*/ /*comment out if only curvature of the lattice planes is needed*/ vec_rotate_2d (&x, &z, curv_xangle); } kix = V2K * vx; kiy = V2K * vy; kiz = V2K * vz; vx = _vx; vy = _vy; vz = _vz; /* ------------------------------------------------------------------------- */ /* (2). Intersection of Ewald sphere with reciprocal lattice points */ double coh_xsect = 0, coh_refl = 0; // Condition to skip calculation of coherent cross section when, needed for extra_order feature if (order == 0 || extra_order == 0 || event_counter < order) { #ifndef OPENACC /* in case we use 'SPLIT' then consecutive neutrons can be identical when entering here and we may skip the hkl_search call. One tau_list is reserved for data for the initial ray results so that it potentially can be reused later. */ T = tau_list; if (order == 1 && fabs (kix - hkl_info.kix) < deltak && fabs (kiy - hkl_info.kiy) < deltak && fabs (kiz - hkl_info.kiz) < deltak) { hkl_info.nb_reuses++; /* Restore in case of matching event (e.g. SPLIT) */ coh_refl = hkl_info.coh_refl; coh_xsect = hkl_info.coh_xsect; tau_count = hkl_info.tau_count; } else { #endif /* Max possible tau for this ki with 5*sigma delta-d/d cutoff. */ double tau_max = 2 * ki / (1 - 5 * hkl_info.m_delta_d_d); /* call hkl_search */ #ifdef USE_OPENCL if (oclContext_SX.Kernel != NULL) { // the Kernel could be initialised tau_count = hkl_search_opencl (L, T, hkl_info.count, hkl_info.V0, kix, kiy, kiz, tau_max, &coh_refl, &coh_xsect, oclContext_SX, d_L, d_T, d_tau_count, d_coh_refl, d_coh_xsect); if (tau_count != 0) MPI_MASTER (printf ("\nGPU tau_count:%i\n", tau_count);); } else #endif tau_count = hkl_search (L, T, hkl_info.count, hkl_info.V0, kix, kiy, kiz, tau_max, &coh_refl, &coh_xsect); /* store ki so that we can check for further SPLIT iterations */ #ifndef OPENACC if (tau_count > hkl_info.max_tau_count) { hkl_info.max_tau_count = tau_count; } if (event_counter == 0) { /* only for incoming neutron */ hkl_info.kix = kix; hkl_info.kiy = kiy; hkl_info.kiz = kiz; /* Store for potential re-use (e.g. SPLIT) */ hkl_info.coh_refl = coh_refl; hkl_info.coh_xsect = coh_xsect; hkl_info.tau_count = tau_count; hkl_info.nb_refl += tau_count; hkl_info.nb_refl_count++; } } #endif } else { // When extra_order used, disable coherent scattering after order reached, but continue // Set coherent cross section to zero to ignore coherent part coh_refl = 0; coh_xsect = 0; tau_count = 0; } /* (3). Probabilities of the different possible interactions. */ /* Cross-sections are in barns = 10**-28 m**2, and unit cell volumes are in AA**3 = 10**-30 m**2. Hence a factor of 100 is used to convert scattering lengths to m**-1 */ coh_xlen = coh_xsect / V0; if (hkl_info.flag_barns) { coh_xlen *= 100; } /* else assume fm^2 */ tot_xlen = abs_xlen + inc_xlen + coh_xlen; if (tot_xlen <= 0) { ABSORB; // Should we really absorb here? If "nothing" can happen we perhaps ought to "pass" instead? } /* (5). Transmission */ p_trans = exp (-tot_xlen * l_full); if (!event_counter && p_transmit >= 0 && p_transmit <= 1) { mc_trans = p_transmit; /* first event */ } else { mc_trans = p_trans; } mc_interact = 1 - mc_trans; if (mc_trans > 0 && (mc_trans >= 1 || rand01 () < mc_trans)) /* Transmit */ { p *= p_trans / mc_trans; intersect = 0; if (powder) { /* orientation of crystallite is longer random */ randderotate (&vx, &vy, &vz, Alpha, Beta, Gamma); } if (PG) { /* orientation of crystallite is longer random */ PGderotate (&vx, &vy, &vz, Alpha, hkl_info.csx, hkl_info.csy, hkl_info.csz); } type = 't'; if (!itype) itype = 1; #ifndef OPENACC hkl_info.type = type; #endif break; /* This break means that we are leaving the while-loop, exiting the crystal by "tunneling". */ } /* Scattering "proper", i.e. coh or incoh */ if (mc_interact <= 0) /* Protect against rounding errors */ { intersect = 0; if (powder) { /* orientation of crystallite is no longer random */ randderotate (&vx, &vy, &vz, Alpha, Beta, Gamma); } if (PG) { /* orientation of crystallite is no longer random, rotation around */ PGderotate (&vx, &vy, &vz, Alpha, hkl_info.csx, hkl_info.csy, hkl_info.csz); } break; } /* First-pass considerations: */ if (!event_counter) p *= fabs (1 - p_trans) / mc_interact; /* Select a point at which to scatter the neutron, taking secondary extinction into account. */ /* dP(l) = exp(-tot_xlen*l)dl P(l= tau_count) { #ifndef OPENACC if (hkl_info.flag_warning < 10) fprintf (stderr, "Single_crystal: Error: Illegal tau search " "(sum=%g, j=%i, tau_count=%i).\n", sum, j, tau_count); hkl_info.flag_warning++; #endif j = tau_count - 1; } i = T[j].index; /* (8). Pick scattered wavevector kf from 2D Gauss distribution. */ z1 = randnorm (); z2 = randnorm (); y1 = T[j].l11 * z1 + T[j].y0x; y2 = T[j].l12 * z1 + T[j].l22 * z2 + T[j].y0y; kfx = T[j].rho_x + T[j].ox + T[j].b1x * y1 + T[j].b2x * y2; kfy = T[j].rho_y + T[j].oy + T[j].b1y * y1 + T[j].b2y * y2; kfz = T[j].rho_z + T[j].oz + T[j].b1z * y1 + T[j].b2z * y2; /* Normalize kf to length of ki, to account for planer approximation of the Ewald sphere. */ adjust = ki / sqrt (kfx * kfx + kfy * kfy + kfz * kfz); kfx *= adjust; kfy *= adjust; kfz *= adjust; /* Adjust neutron weight (see manual for explanation). */ double pmul = T[j].xsect * coh_refl / (coh_xsect * T[j].refl); if (!isnan (pmul)) p *= pmul; vx = K2V * (L[i].u1x * kfx + L[i].u2x * kfy + L[i].u3x * kfz); vy = K2V * (L[i].u1y * kfx + L[i].u2y * kfy + L[i].u3y * kfz); vz = K2V * (L[i].u1z * kfx + L[i].u2z * kfy + L[i].u3z * kfz); type = 'c'; if (!itype) itype = 3; #ifndef OPENACC hkl_info.type = type; hkl_info.h = L[i].h; hkl_info.k = L[i].k; hkl_info.l = L[i].l; #endif } /* ------------------------------------------------------------------------- */ /* lattice curvature option: rotate back neutron velocity */ if (RX) { vec_rotate_2d (&vx, &vz, -curv_xangle); vec_rotate_2d (&sx, &sz, -curv_xangle); /*changing x,z actually curves the crystal, not only the planes*/ /*comment out if only curvature of the lattice planes is needed*/ vec_rotate_2d (&x, &z, -curv_xangle); } if (RY) { vec_rotate_2d (&vy, &vz, -curv_yangle); vec_rotate_2d (&sy, &sz, -curv_yangle); /*changing y,z actually curves the crystal, not only the planes*/ /*comment out if only curvature of the lattice planes is needed*/ vec_rotate_2d (&y, &z, -curv_yangle); } /* ------------------------------------------------------------------------- */ SCATTER; if (powder) { /* orientation of crystallite is no longer random */ randderotate (&vx, &vy, &vz, Alpha, Beta, Gamma); } if (PG) { /* orientation of crystallite is longer random */ PGderotate (&vx, &vy, &vz, Alpha, hkl_info.csx, hkl_info.csy, hkl_info.csz); } /* Repeat loop for next scattering event. */ } while (intersect); /* end do (intersect) (multiple scattering loop) */ } /* if intersect */ #ifndef NOABSORB_INF_NAN /* Check for nan or inf particle parms */ if(isnan(p + t + vx + vy + vz + x + y + z)) ABSORB; if(isinf(fabs(p) + fabs(t) + fabs(vx) + fabs(vy) + fabs(vz) + fabs(x) + fabs(y) + fabs(z))) ABSORB; #else if(isnan(p) || isinf(p)) printf("NAN or INF found in p, %s (particle %lld)\n",_comp->_name,_particle->_uid); if(isnan(t) || isinf(t)) printf("NAN or INF found in t, %s (particle %lld)\n",_comp->_name,_particle->_uid); if(isnan(vx) || isinf(vx)) printf("NAN or INF found in vx, %s (particle %lld)\n",_comp->_name,_particle->_uid); if(isnan(vy) || isinf(vy)) printf("NAN or INF found in vy, %s (particle %lld)\n",_comp->_name,_particle->_uid); if(isnan(vz) || isinf(vz)) printf("NAN or INF found in vz, %s (particle %lld)\n",_comp->_name,_particle->_uid); if(isnan(x) || isinf(x)) printf("NAN or INF found in x, %s (particle %lld)\n",_comp->_name,_particle->_uid); if(isnan(y) || isinf(y)) printf("NAN or INF found in y, %s (particle %lld)\n",_comp->_name,_particle->_uid); if(isnan(z) || isinf(z)) printf("NAN or INF found in z, %s (particle %lld)\n",_comp->_name,_particle->_uid); #endif #define Mono_order (_particle->Mono_order) #define AnaBlade (_particle->AnaBlade) #define BinX (_particle->BinX) #define BinY (_particle->BinY) #define ncol_54 (_particle->ncol_54) #define nrow_54 (_particle->nrow_54) if (_comp->_index == 77) { // EXTEND 'crystalSample' if(!SCATTERED) ABSORB; } #undef Mono_order #undef AnaBlade #undef BinX #undef BinY #undef ncol_54 #undef nrow_54 #undef reflections #undef geometry #undef mosaic_AB #undef xwidth #undef yheight #undef zdepth #undef radius #undef delta_d_d #undef mosaic #undef mosaic_a #undef mosaic_b #undef mosaic_c #undef recip_cell #undef barns #undef ax #undef ay #undef az #undef bx #undef by #undef bz #undef cx #undef cy #undef cz #undef p_transmit #undef sigma_abs #undef sigma_inc #undef aa #undef bb #undef cc #undef order #undef extra_order #undef RX #undef RY #undef powder #undef PG #undef deltak #undef hkl_info #undef offdata #undef hkl_list #undef tau_list return; } /* class_Single_crystal_trace */ #pragma acc routine void class_Phonon_simple_trace(_class_Phonon_simple *_comp , _class_particle *_particle) { ABSORBED=SCATTERED=RESTORE=0; #define radius (_comp->_parameters.radius) #define yheight (_comp->_parameters.yheight) #define sigma_abs (_comp->_parameters.sigma_abs) #define sigma_inc (_comp->_parameters.sigma_inc) #define a (_comp->_parameters.a) #define b (_comp->_parameters.b) #define M (_comp->_parameters.M) #define c (_comp->_parameters.c) #define DW (_comp->_parameters.DW) #define T (_comp->_parameters.T) #define target_x (_comp->_parameters.target_x) #define target_y (_comp->_parameters.target_y) #define target_z (_comp->_parameters.target_z) #define target_index (_comp->_parameters.target_index) #define focus_r (_comp->_parameters.focus_r) #define focus_xw (_comp->_parameters.focus_xw) #define focus_yh (_comp->_parameters.focus_yh) #define focus_aw (_comp->_parameters.focus_aw) #define focus_ah (_comp->_parameters.focus_ah) #define gap (_comp->_parameters.gap) #define e_steps_low (_comp->_parameters.e_steps_low) #define e_steps_high (_comp->_parameters.e_steps_high) #define V_rho (_comp->_parameters.V_rho) #define V_my_s (_comp->_parameters.V_my_s) #define V_my_a_v (_comp->_parameters.V_my_a_v) #define DV (_comp->_parameters.DV) #define phonon (_comp->_parameters.phonon) SIG_MESSAGE("[_phononSample_trace] component phononSample=Phonon_simple() TRACE [Phonon_simple:0]"); double* vf_list; #ifdef OPENACC vf_list = (double*)malloc ((e_steps_low + e_steps_high) * sizeof (double)); // List of allowed final velocities. Has length of scan_steps #else vf_list = (double*)calloc (e_steps_low + e_steps_high, sizeof (double)); // List of allowed final velocities. Has length of scan_steps #endif if (!vf_list) { printf ("Memory allocation failed, fatal error!\n"); exit (-1); } #ifdef OPENACC for (int ii = 0; ii < e_steps_low + e_steps_high; ii++) { vf_list[ii] = 0; } #endif struct neutron_params neutron; double t0, t1; /* Entry/exit time for cylinder */ double v_i, v_f; /* Neutron velocities: initial, final */ double vx_i, vy_i, vz_i; /* Neutron initial velocity vector */ double dt0, dt; /* Flight times through sample */ double l_full; /* Flight path length for non-scattered neutron */ double l_i, l_o; /* Flight path lenght in/out for scattered neutron */ double my_a_i; /* Initial attenuation factor */ double my_a_f; /* Final attenuation factor */ double solid_angle; /* Solid angle of target as seen from scattering point */ double aim_x = 0, aim_y = 0, aim_z = 1; /* Position of target relative to scattering point */ double kappa_x, kappa_y, kappa_z; /* Scattering vector */ double kappa2; /* Square of the scattering vector */ double bose_factor; /* Calculated value of the Bose factor */ double omega; /* energy transfer */ int nf, index; /* Number of allowed final velocities */ double J_factor; /* Jacobian from delta fnc.s in cross section */ double f1, f2; /* probed values of omega_q minus omega */ double p1, p2, p3, p4, p5; /* temporary multipliers */ if (cylinder_intersect (&t0, &t1, x, y, z, vx, vy, vz, radius, yheight)) { if (t0 < 0) ABSORB; /* Neutron came from the sample or begins inside */ /* Neutron enters at t=t0. */ dt0 = t1 - t0; /* Time in sample */ v_i = sqrt (vx * vx + vy * vy + vz * vz); l_full = v_i * dt0; /* Length of path through sample if not scattered */ dt = rand01 () * dt0; /* Time of scattering (relative to t0) */ l_i = v_i * dt; /* Penetration in sample at scattering */ vx_i = vx; vy_i = vy; vz_i = vz; PROP_DT (dt + t0); /* Point of scattering */ aim_x = target_x - x; /* Vector pointing at target (e.g. analyzer) */ aim_y = target_y - y; aim_z = target_z - z; if (focus_aw && focus_ah) { randvec_target_rect_angular (&vx, &vy, &vz, &solid_angle, aim_x, aim_y, aim_z, focus_aw, focus_ah, ROT_A_CURRENT_COMP); } else if (focus_xw && focus_yh) { randvec_target_rect (&vx, &vy, &vz, &solid_angle, aim_x, aim_y, aim_z, focus_xw, focus_yh, ROT_A_CURRENT_COMP); } else { randvec_target_sphere (&vx, &vy, &vz, &solid_angle, aim_x, aim_y, aim_z, focus_r); } NORM (vx, vy, vz); nf = 0; neutron.vf = -1; neutron.vi = v_i; neutron.vv_x = vx; neutron.vv_y = vy; neutron.vv_z = vz; neutron.vi_x = vx_i; neutron.vi_y = vy_i; neutron.vi_z = vz_i; #ifndef OPENACC findroots (0, v_i, v_i + 2 * c * V2K / VS2E, vf_list, &nf, omega_q, &neutron, &phonon); #else findroots_gpu (0, v_i, v_i + 2 * c * V2K / VS2E, vf_list, &nf, &neutron, &phonon); #endif index = (int)floor (rand01 () * nf); v_f = vf_list[index]; neutron.vf = v_f - DV; f1 = omega_q (&neutron, &phonon); neutron.vf = v_f + DV; f2 = omega_q (&neutron, &phonon); J_factor = fabs (f2 - f1) / (2 * DV); omega = VS2E * (v_i * v_i - v_f * v_f); vx *= v_f; vy *= v_f; vz *= v_f; kappa_x = V2K * (vx_i - vx); kappa_y = V2K * (vy_i - vy); kappa_z = V2K * (vz_i - vz); kappa2 = kappa_z * kappa_z + kappa_y * kappa_y + kappa_x * kappa_x; if (!cylinder_intersect (&t0, &t1, x, y, z, vx, vy, vz, radius, yheight)) { /* ??? did not hit cylinder */ printf ("FATAL ERROR: Did not hit cylinder from inside.\n"); exit (1); } dt = t1; l_o = v_f * dt; my_a_i = V_my_a_v / v_i; my_a_f = V_my_a_v / v_f; bose_factor = nbose (omega, T); p1 = exp (-(V_my_s * (l_i + l_o) + my_a_i * l_i + my_a_f * l_o)); /* Absorption factor */ p2 = nf * solid_angle * l_full * V_rho / (4 * PI); /* Focusing factors; assume random choice of n_f possibilities */ p3 = (v_f / v_i) * DW * (kappa2 * K2V * K2V * VS2E) / fabs (omega) * bose_factor; /* Cross section factor 1 */ p4 = 2 * VS2E * v_f / J_factor; /* Jacobian of delta functions in cross section */ p5 = b * b / M; /* Cross section factor 2 */ p *= p1 * p2 * p3 * p4 * p5; } /* else transmit: Neutron did not hit the sample */ free (vf_list); #ifndef NOABSORB_INF_NAN /* Check for nan or inf particle parms */ if(isnan(p + t + vx + vy + vz + x + y + z)) ABSORB; if(isinf(fabs(p) + fabs(t) + fabs(vx) + fabs(vy) + fabs(vz) + fabs(x) + fabs(y) + fabs(z))) ABSORB; #else if(isnan(p) || isinf(p)) printf("NAN or INF found in p, %s (particle %lld)\n",_comp->_name,_particle->_uid); if(isnan(t) || isinf(t)) printf("NAN or INF found in t, %s (particle %lld)\n",_comp->_name,_particle->_uid); if(isnan(vx) || isinf(vx)) printf("NAN or INF found in vx, %s (particle %lld)\n",_comp->_name,_particle->_uid); if(isnan(vy) || isinf(vy)) printf("NAN or INF found in vy, %s (particle %lld)\n",_comp->_name,_particle->_uid); if(isnan(vz) || isinf(vz)) printf("NAN or INF found in vz, %s (particle %lld)\n",_comp->_name,_particle->_uid); if(isnan(x) || isinf(x)) printf("NAN or INF found in x, %s (particle %lld)\n",_comp->_name,_particle->_uid); if(isnan(y) || isinf(y)) printf("NAN or INF found in y, %s (particle %lld)\n",_comp->_name,_particle->_uid); if(isnan(z) || isinf(z)) printf("NAN or INF found in z, %s (particle %lld)\n",_comp->_name,_particle->_uid); #endif #undef radius #undef yheight #undef sigma_abs #undef sigma_inc #undef a #undef b #undef M #undef c #undef DW #undef T #undef target_x #undef target_y #undef target_z #undef target_index #undef focus_r #undef focus_xw #undef focus_yh #undef focus_aw #undef focus_ah #undef gap #undef e_steps_low #undef e_steps_high #undef V_rho #undef V_my_s #undef V_my_a_v #undef DV #undef phonon return; } /* class_Phonon_simple_trace */ #pragma acc routine void class_PSD_monitor_4PI_trace(_class_PSD_monitor_4PI *_comp , _class_particle *_particle) { ABSORBED=SCATTERED=RESTORE=0; #define nx (_comp->_parameters.nx) #define ny (_comp->_parameters.ny) #define filename (_comp->_parameters.filename) #define nowritefile (_comp->_parameters.nowritefile) #define radius (_comp->_parameters.radius) #define restore_neutron (_comp->_parameters.restore_neutron) #define PSD_N (_comp->_parameters.PSD_N) #define PSD_p (_comp->_parameters.PSD_p) #define PSD_p2 (_comp->_parameters.PSD_p2) SIG_MESSAGE("[_psd_4pi_trace] component psd_4pi=PSD_monitor_4PI() TRACE [PSD_monitor_4PI:0]"); double t0, t1, theta, phi; int i, j; if (sphere_intersect (&t0, &t1, x, y, z, vx, vy, vz, radius) && t1 > 0) { if (t0 < 0) t0 = t1; /* t0 is now time of intersection with the sphere. */ mcPROP_DT (t0); /* Measure longitude via atan2. Returned values will be in [-PI PI] */ theta = atan2 (x, z); /* Map to nx * [0 1] interval */ i = floor (nx * 0.5*(theta / PI+1)); /* Measure latitude via asin(elevation/radius). Returned values will be in [-PI/2 PI/2] */ phi = asin (y / radius); /* Map to ny * [0 1] interval */ j = floor (ny * (phi + PI / 2) / PI); double p2 = p * p; #pragma acc atomic PSD_N[i][j] = PSD_N[i][j] + 1; #pragma acc atomic PSD_p[i][j] = PSD_p[i][j] + p; #pragma acc atomic PSD_p2[i][j] = PSD_p2[i][j] + p2; SCATTER; } if (restore_neutron) { RESTORE_NEUTRON (INDEX_CURRENT_COMP, x, y, z, vx, vy, vz, t, sx, sy, sz, p); } #ifndef NOABSORB_INF_NAN /* Check for nan or inf particle parms */ if(isnan(p + t + vx + vy + vz + x + y + z)) ABSORB; if(isinf(fabs(p) + fabs(t) + fabs(vx) + fabs(vy) + fabs(vz) + fabs(x) + fabs(y) + fabs(z))) ABSORB; #else if(isnan(p) || isinf(p)) printf("NAN or INF found in p, %s (particle %lld)\n",_comp->_name,_particle->_uid); if(isnan(t) || isinf(t)) printf("NAN or INF found in t, %s (particle %lld)\n",_comp->_name,_particle->_uid); if(isnan(vx) || isinf(vx)) printf("NAN or INF found in vx, %s (particle %lld)\n",_comp->_name,_particle->_uid); if(isnan(vy) || isinf(vy)) printf("NAN or INF found in vy, %s (particle %lld)\n",_comp->_name,_particle->_uid); if(isnan(vz) || isinf(vz)) printf("NAN or INF found in vz, %s (particle %lld)\n",_comp->_name,_particle->_uid); if(isnan(x) || isinf(x)) printf("NAN or INF found in x, %s (particle %lld)\n",_comp->_name,_particle->_uid); if(isnan(y) || isinf(y)) printf("NAN or INF found in y, %s (particle %lld)\n",_comp->_name,_particle->_uid); if(isnan(z) || isinf(z)) printf("NAN or INF found in z, %s (particle %lld)\n",_comp->_name,_particle->_uid); #endif #undef nx #undef ny #undef filename #undef nowritefile #undef radius #undef restore_neutron #undef PSD_N #undef PSD_p #undef PSD_p2 return; } /* class_PSD_monitor_4PI_trace */ #pragma acc routine void class_Exact_radial_coll_trace(_class_Exact_radial_coll *_comp , _class_particle *_particle) { ABSORBED=SCATTERED=RESTORE=0; #define theta_min (_comp->_parameters.theta_min) #define theta_max (_comp->_parameters.theta_max) #define nslit (_comp->_parameters.nslit) #define radius (_comp->_parameters.radius) #define length (_comp->_parameters.length) #define h_in (_comp->_parameters.h_in) #define h_out (_comp->_parameters.h_out) #define d (_comp->_parameters.d) #define verbose (_comp->_parameters.verbose) #define alpha_in (_comp->_parameters.alpha_in) #define alpha_out (_comp->_parameters.alpha_out) #define beta_in (_comp->_parameters.beta_in) #define beta_out (_comp->_parameters.beta_out) #define theta (_comp->_parameters.theta) #define out_radius (_comp->_parameters.out_radius) #define iw (_comp->_parameters.iw) #define ow (_comp->_parameters.ow) #define divergence (_comp->_parameters.divergence) SIG_MESSAGE("[_filter_coll_trace] component filter_coll=Exact_radial_coll() TRACE [Exact_radial_coll:0]"); double phi, t0, t1, t2, t3; int intersect; long input_chan, output_chan; double input_theta, output_theta; double input_center, output_center; double window_theta; char ok = 0; /* first compute intersection time with input cylinder */ intersect = cylinder_intersect (&t0, &t3, x, y, z, vx, vy, vz, radius, h_in); if (!intersect) ABSORB; else if (t3 > t0) t0 = t3; intersect = cylinder_intersect (&t1, &t2, x, y, z, vx, vy, vz, out_radius, h_out); if (!intersect) ABSORB; else if (t2 > t1) t1 = t2; /* get index of input slit */ if (t0 > 0 && t1 > t0) { PROP_DT (t0); input_theta = atan2 (x, z); /* channel number (start at 0) */ window_theta = (theta_max - theta_min) / nslit; input_chan = floor ((input_theta - theta_min) / window_theta); if (input_chan >= 0 && input_chan < nslit && fabs (y) < h_in / 2) ok = 1; if (ok) { input_center = theta_min + input_chan * window_theta + (window_theta) / 2; /* are we outside the soller or in the foil? */ phi = input_theta - input_center; if (fabs (phi) > alpha_in / 2) ABSORB; /* inside the foil*/ SCATTER; /* propagate to output radius */ PROP_DT (t1 - t0); SCATTER; output_theta = atan2 (x, z); /* channel number (start at 0) */ output_chan = floor ((output_theta - theta_min) / window_theta); /* did we change channel ? */ if (output_chan != input_chan) ABSORB; /* changed slit */ output_center = theta_min + output_chan * window_theta + (window_theta) / 2; /* are we outside the soller */ phi = output_theta - output_center; if (fabs (phi) > alpha_out / 2 || fabs (y) > h_out / 2) ABSORB; /* outside output slit */ } /* else we pass aside the entrance window of radial collimator */ else { /* propagate to output radius */ PROP_DT (t1 - t0); SCATTER; output_theta = atan2 (x, z); /* channel number (start at 0) */ output_chan = floor ((output_theta - theta_min) / window_theta); /* are we come from outside into the soller or in the foil?*/ if (output_chan >= 0 || output_chan < nslit) ABSORB; } /* else we pass aside the exit window of radial collimator */ } /* else did not encounter collimator */ #ifndef NOABSORB_INF_NAN /* Check for nan or inf particle parms */ if(isnan(p + t + vx + vy + vz + x + y + z)) ABSORB; if(isinf(fabs(p) + fabs(t) + fabs(vx) + fabs(vy) + fabs(vz) + fabs(x) + fabs(y) + fabs(z))) ABSORB; #else if(isnan(p) || isinf(p)) printf("NAN or INF found in p, %s (particle %lld)\n",_comp->_name,_particle->_uid); if(isnan(t) || isinf(t)) printf("NAN or INF found in t, %s (particle %lld)\n",_comp->_name,_particle->_uid); if(isnan(vx) || isinf(vx)) printf("NAN or INF found in vx, %s (particle %lld)\n",_comp->_name,_particle->_uid); if(isnan(vy) || isinf(vy)) printf("NAN or INF found in vy, %s (particle %lld)\n",_comp->_name,_particle->_uid); if(isnan(vz) || isinf(vz)) printf("NAN or INF found in vz, %s (particle %lld)\n",_comp->_name,_particle->_uid); if(isnan(x) || isinf(x)) printf("NAN or INF found in x, %s (particle %lld)\n",_comp->_name,_particle->_uid); if(isnan(y) || isinf(y)) printf("NAN or INF found in y, %s (particle %lld)\n",_comp->_name,_particle->_uid); if(isnan(z) || isinf(z)) printf("NAN or INF found in z, %s (particle %lld)\n",_comp->_name,_particle->_uid); #endif #undef theta_min #undef theta_max #undef nslit #undef radius #undef length #undef h_in #undef h_out #undef d #undef verbose #undef alpha_in #undef alpha_out #undef beta_in #undef beta_out #undef theta #undef out_radius #undef iw #undef ow #undef divergence return; } /* class_Exact_radial_coll_trace */ #pragma acc routine void class_Monochromator_flat_trace(_class_Monochromator_flat *_comp , _class_particle *_particle) { ABSORBED=SCATTERED=RESTORE=0; #define zmin (_comp->_parameters.zmin) #define zmax (_comp->_parameters.zmax) #define ymin (_comp->_parameters.ymin) #define ymax (_comp->_parameters.ymax) #define zwidth (_comp->_parameters.zwidth) #define yheight (_comp->_parameters.yheight) #define mosaich (_comp->_parameters.mosaich) #define mosaicv (_comp->_parameters.mosaicv) #define r0 (_comp->_parameters.r0) #define Q (_comp->_parameters.Q) #define DM (_comp->_parameters.DM) #define mos_rms_y (_comp->_parameters.mos_rms_y) #define mos_rms_z (_comp->_parameters.mos_rms_z) #define mos_rms_max (_comp->_parameters.mos_rms_max) #define mono_Q (_comp->_parameters.mono_Q) SIG_MESSAGE("[_an1l_trace] component an1l=Monochromator_flat() TRACE [Monochromator_flat:0]"); double y1, z1, t1, dt, kix, kiy, kiz, ratio, order, q0x, k, q0, theta; double bx, by, bz, kux, kuy, kuz, ax, ay, az, phi; double cos_2theta, k_sin_2theta, cos_phi, sin_phi, q_x, q_y, q_z; double delta, p_reflect, total, c1x, c1y, c1z, width, mos_sample; int i; if (vx != 0.0 && (dt = -x / vx) >= 0.0) { /* Moving towards crystal? */ y1 = y + vy * dt; /* Propagate to crystal plane */ z1 = z + vz * dt; t1 = t + dt; if (z1 > zmin && z1 < zmax && y1 > ymin && y1 < ymax) { /* Intersect the crystal? */ kix = V2K * vx; /* Initial wave vector */ kiy = V2K * vy; kiz = V2K * vz; /* Get reflection order and corresponding nominal scattering vector q0 of correct length and direction. Only the order with the closest scattering vector is considered */ ratio = -2 * kix / mono_Q; order = floor (ratio + .5); if (order == 0.0) order = ratio < 0 ? -1 : 1; /* Order will be negative when the neutron enters from the back, in which case the direction of Q0 is flipped. */ if (order < 0) order = -order; /* Make sure the order is small enough to allow Bragg scattering at the given neutron wavelength */ k = sqrt (kix * kix + kiy * kiy + kiz * kiz); kux = kix / k; /* Unit vector along ki */ kuy = kiy / k; kuz = kiz / k; if (order > 2 * k / mono_Q) order--; if (order > 0) /* Bragg scattering possible? */ { q0 = order * mono_Q; q0x = ratio < 0 ? -q0 : q0; theta = asin (q0 / (2 * k)); /* Actual bragg angle */ /* Make MC choice: reflect or transmit? */ delta = asin (fabs (kux)) - theta; p_reflect = r0 * exp (-kiy * kiy / (kiy * kiy + kiz * kiz) * (delta * delta) / (2 * mos_rms_y * mos_rms_y)) * exp (-kiz * kiz / (kiy * kiy + kiz * kiz) * (delta * delta) / (2 * mos_rms_z * mos_rms_z)); if (rand01 () < p_reflect) { /* Reflect */ cos_2theta = cos (2 * theta); k_sin_2theta = k * sin (2 * theta); /* Get unit normal to plane containing ki and most probable kf */ vec_prod (bx, by, bz, kix, kiy, kiz, q0x, 0, 0); NORM (bx, by, bz); bx *= k_sin_2theta; by *= k_sin_2theta; bz *= k_sin_2theta; /* Get unit vector normal to ki and b */ vec_prod (ax, ay, az, bx, by, bz, kux, kuy, kuz); /* Compute the total scattering probability at this ki */ total = 0; /* Choose width of Gaussian distribution to sample the angle * phi on the Debye-Scherrer cone for the scattered neutron. * The radius of the Debye-Scherrer cone is smaller by a * factor 1/cos(theta) than the radius of the (partial) sphere * describing the possible orientations of Q due to mosaicity, so we * start with a width 1/cos(theta) greater than the largest of * the two mosaics. */ mos_sample = mos_rms_max / cos (theta); c1x = kix * (cos_2theta - 1); c1y = kiy * (cos_2theta - 1); c1z = kiz * (cos_2theta - 1); /* Loop, repeatedly reducing the sample width until it is small * enough to avoid sampling scattering directions with * ridiculously low scattering probability. * Use a cut-off at 5 times the gauss width for considering * scattering probability as well as for integration limits * when integrating the sampled distribution below. */ for (i = 0; i < 100; i++) { width = 5 * mos_sample; cos_phi = cos (width); sin_phi = sin (width); q_x = c1x + cos_phi * ax + sin_phi * bx; q_y = (c1y + cos_phi * ay + sin_phi * by) / mos_rms_y; q_z = (c1z + cos_phi * az + sin_phi * bz) / mos_rms_z; /* Stop when we get near a factor of 25=5^2. */ if (q_z * q_z + q_y * q_y < (25 / (2.0 / 3.0)) * (q_x * q_x)) break; mos_sample *= (2.0 / 3.0); } /* Now integrate the chosen sampling distribution, using a * cut-off at five times sigma. */ for (i = 0; i < (sizeof (Gauss_X) / sizeof (double)); i++) { phi = width * Gauss_X[i]; cos_phi = cos (phi); sin_phi = sin (phi); q_x = c1x + cos_phi * ax + sin_phi * bx; q_y = c1y + cos_phi * ay + sin_phi * by; q_z = c1z + cos_phi * az + sin_phi * bz; p_reflect = GAUSS ((q_y / q_x), 0, mos_rms_y) * GAUSS ((q_z / q_x), 0, mos_rms_z); total += Gauss_W[i] * p_reflect; } total *= width; /* Choose point on Debye-Scherrer cone. Sample from a Gaussian of * width 1/cos(theta) greater than the mosaic and correct for any * error by adjusting the neutron weight later. */ phi = mos_sample * randnorm (); /* Compute final wave vector kf and scattering vector q = ki - kf */ cos_phi = cos (phi); sin_phi = sin (phi); q_x = c1x + cos_phi * ax + sin_phi * bx; q_y = c1y + cos_phi * ay + sin_phi * by; q_z = c1z + cos_phi * az + sin_phi * bz; p_reflect = GAUSS ((q_y / q_x), 0, mos_rms_y) * GAUSS ((q_z / q_x), 0, mos_rms_z); x = 0; y = y1; z = z1; t = t1; vx = K2V * (kix + q_x); vy = K2V * (kiy + q_y); vz = K2V * (kiz + q_z); p_reflect /= total * GAUSS (phi, 0, mos_sample); if (p_reflect <= 0) ABSORB; if (p_reflect > 1) p_reflect = 1; p *= p_reflect; SCATTER; } /* End MC choice to reflect or transmit neutron */ } /* End bragg scattering possible */ } /* End intersect the crystal */ } /* End neutron moving towards crystal */ #ifndef NOABSORB_INF_NAN /* Check for nan or inf particle parms */ if(isnan(p + t + vx + vy + vz + x + y + z)) ABSORB; if(isinf(fabs(p) + fabs(t) + fabs(vx) + fabs(vy) + fabs(vz) + fabs(x) + fabs(y) + fabs(z))) ABSORB; #else if(isnan(p) || isinf(p)) printf("NAN or INF found in p, %s (particle %lld)\n",_comp->_name,_particle->_uid); if(isnan(t) || isinf(t)) printf("NAN or INF found in t, %s (particle %lld)\n",_comp->_name,_particle->_uid); if(isnan(vx) || isinf(vx)) printf("NAN or INF found in vx, %s (particle %lld)\n",_comp->_name,_particle->_uid); if(isnan(vy) || isinf(vy)) printf("NAN or INF found in vy, %s (particle %lld)\n",_comp->_name,_particle->_uid); if(isnan(vz) || isinf(vz)) printf("NAN or INF found in vz, %s (particle %lld)\n",_comp->_name,_particle->_uid); if(isnan(x) || isinf(x)) printf("NAN or INF found in x, %s (particle %lld)\n",_comp->_name,_particle->_uid); if(isnan(y) || isinf(y)) printf("NAN or INF found in y, %s (particle %lld)\n",_comp->_name,_particle->_uid); if(isnan(z) || isinf(z)) printf("NAN or INF found in z, %s (particle %lld)\n",_comp->_name,_particle->_uid); #endif #define Mono_order (_particle->Mono_order) #define AnaBlade (_particle->AnaBlade) #define BinX (_particle->BinX) #define BinY (_particle->BinY) #define ncol_54 (_particle->ncol_54) #define nrow_54 (_particle->nrow_54) if (_comp->_index == 90) { // EXTEND 'an1l' if(SCATTERED) AnaBlade = 1; } if (_comp->_index == 91) { // EXTEND 'an1u' if(SCATTERED) AnaBlade = 1; } if (_comp->_index == 92) { // EXTEND 'an2l' if(SCATTERED) AnaBlade = 2; } if (_comp->_index == 93) { // EXTEND 'an2u' if(SCATTERED) AnaBlade = 2; } if (_comp->_index == 94) { // EXTEND 'an3l' if(SCATTERED) AnaBlade = 3; } if (_comp->_index == 95) { // EXTEND 'an3u' if(SCATTERED) AnaBlade = 3; } if (_comp->_index == 96) { // EXTEND 'an4l' if(SCATTERED) AnaBlade = 4; } if (_comp->_index == 97) { // EXTEND 'an4u' if(SCATTERED) AnaBlade = 4; } if (_comp->_index == 98) { // EXTEND 'an5l' if(SCATTERED) AnaBlade = 5; } if (_comp->_index == 99) { // EXTEND 'an5u' if(SCATTERED) AnaBlade = 5; } if (_comp->_index == 100) { // EXTEND 'an6l' if(SCATTERED) AnaBlade = 6; } if (_comp->_index == 101) { // EXTEND 'an6u' if(SCATTERED) AnaBlade = 6; } if (_comp->_index == 102) { // EXTEND 'an7l' if(SCATTERED) AnaBlade = 7; } if (_comp->_index == 103) { // EXTEND 'an7u' if(SCATTERED) AnaBlade = 7; } if (_comp->_index == 104) { // EXTEND 'an8l' if(SCATTERED) AnaBlade = 8; } if (_comp->_index == 105) { // EXTEND 'an8u' if(SCATTERED) AnaBlade = 8; } if (_comp->_index == 106) { // EXTEND 'an9l' if(SCATTERED) AnaBlade = 9; } if (_comp->_index == 107) { // EXTEND 'an9u' if(SCATTERED) AnaBlade = 9; } #undef Mono_order #undef AnaBlade #undef BinX #undef BinY #undef ncol_54 #undef nrow_54 #undef zmin #undef zmax #undef ymin #undef ymax #undef zwidth #undef yheight #undef mosaich #undef mosaicv #undef r0 #undef Q #undef DM #undef mos_rms_y #undef mos_rms_z #undef mos_rms_max #undef mono_Q return; } /* class_Monochromator_flat_trace */ #pragma acc routine void class_Absorber_trace(_class_Absorber *_comp , _class_particle *_particle) { ABSORBED=SCATTERED=RESTORE=0; #define xmin (_comp->_parameters.xmin) #define xmax (_comp->_parameters.xmax) #define ymin (_comp->_parameters.ymin) #define ymax (_comp->_parameters.ymax) #define zmin (_comp->_parameters.zmin) #define zmax (_comp->_parameters.zmax) #define xw (_comp->_parameters.xw) #define yh (_comp->_parameters.yh) #define zt (_comp->_parameters.zt) #define xm (_comp->_parameters.xm) #define ym (_comp->_parameters.ym) #define zm (_comp->_parameters.zm) SIG_MESSAGE("[_BladeR1_trace] component BladeR1=Absorber() TRACE [Absorber:0]"); double t0, t1, xp, yp, zp; xp = x - xm; yp = y - ym; zp = z - zm; if (box_intersect (&t0, &t1, xp, yp, zp, vx, vy, vz, xw, yh, zt)) { if (t1 >= 0) { PROP_DT ((t1 + t0) / 2); SCATTER; ABSORB; } } #ifndef NOABSORB_INF_NAN /* Check for nan or inf particle parms */ if(isnan(p + t + vx + vy + vz + x + y + z)) ABSORB; if(isinf(fabs(p) + fabs(t) + fabs(vx) + fabs(vy) + fabs(vz) + fabs(x) + fabs(y) + fabs(z))) ABSORB; #else if(isnan(p) || isinf(p)) printf("NAN or INF found in p, %s (particle %lld)\n",_comp->_name,_particle->_uid); if(isnan(t) || isinf(t)) printf("NAN or INF found in t, %s (particle %lld)\n",_comp->_name,_particle->_uid); if(isnan(vx) || isinf(vx)) printf("NAN or INF found in vx, %s (particle %lld)\n",_comp->_name,_particle->_uid); if(isnan(vy) || isinf(vy)) printf("NAN or INF found in vy, %s (particle %lld)\n",_comp->_name,_particle->_uid); if(isnan(vz) || isinf(vz)) printf("NAN or INF found in vz, %s (particle %lld)\n",_comp->_name,_particle->_uid); if(isnan(x) || isinf(x)) printf("NAN or INF found in x, %s (particle %lld)\n",_comp->_name,_particle->_uid); if(isnan(y) || isinf(y)) printf("NAN or INF found in y, %s (particle %lld)\n",_comp->_name,_particle->_uid); if(isnan(z) || isinf(z)) printf("NAN or INF found in z, %s (particle %lld)\n",_comp->_name,_particle->_uid); #endif #define Mono_order (_particle->Mono_order) #define AnaBlade (_particle->AnaBlade) #define BinX (_particle->BinX) #define BinY (_particle->BinY) #define ncol_54 (_particle->ncol_54) #define nrow_54 (_particle->nrow_54) if (_comp->_index == 112) { // EXTEND 'BladeR1' if (SCATTERED) printf("Absorption in R1\n"); } #undef Mono_order #undef AnaBlade #undef BinX #undef BinY #undef ncol_54 #undef nrow_54 #undef xmin #undef xmax #undef ymin #undef ymax #undef zmin #undef zmax #undef xw #undef yh #undef zt #undef xm #undef ym #undef zm return; } /* class_Absorber_trace */ #define Mono_order (_particle->Mono_order) #define AnaBlade (_particle->AnaBlade) #define BinX (_particle->BinX) #define BinY (_particle->BinY) #define ncol_54 (_particle->ncol_54) #define nrow_54 (_particle->nrow_54) /* ***************************************************************************** * instrument 'RITA_II' TRACE ***************************************************************************** */ #ifndef FUNNEL #pragma acc routine int raytrace(_class_particle* _particle) { /* single event propagation, called by mccode_main for RITA_II:TRACE */ /* init variables and counters for TRACE */ #undef ABSORB0 #undef ABSORB #define ABSORB0 do { DEBUG_ABSORB(); MAGNET_OFF; ABSORBED++;} while(0) #define ABSORB ABSORB0 DEBUG_ENTER(); DEBUG_STATE(); _particle->flag_nocoordschange=0; /* Init */ _class_particle _particle_save=*_particle; /* the main iteration loop for one incoming event */ while (!ABSORBED) { /* iterate event until absorbed */ /* send particle event to component instance, one after the other */ /* begin component armSource=Progress_bar() [1] */ if (!_particle->flag_nocoordschange) { // flag activated by JUMP to pass coords change if (_armSource_var._rotation_is_identity) { if(!_armSource_var._position_relative_is_zero) { coords_get(coords_add(coords_set(x,y,z), _armSource_var._position_relative),&x, &y, &z); } } else { mccoordschange(_armSource_var._position_relative, _armSource_var._rotation_relative, _particle); } } if (!ABSORBED && _particle->_index == 1) { _particle->flag_nocoordschange=0; /* Reset if we came here from a JUMP */ _particle_save = *_particle; DEBUG_COMP(_armSource_var._name); DEBUG_STATE(); class_Progress_bar_trace(&_armSource_var, _particle); if (_particle->_restore) particle_restore(_particle, &_particle_save); _particle->_index++; if (!ABSORBED) { DEBUG_STATE(); } } /* end component armSource [1] */ /* begin component source=Source_gen4() [2] */ if (!_particle->flag_nocoordschange) { // flag activated by JUMP to pass coords change if (_source_var._rotation_is_identity) { if(!_source_var._position_relative_is_zero) { coords_get(coords_add(coords_set(x,y,z), _source_var._position_relative),&x, &y, &z); } } else { mccoordschange(_source_var._position_relative, _source_var._rotation_relative, _particle); } } if (!ABSORBED && _particle->_index == 2) { _particle->flag_nocoordschange=0; /* Reset if we came here from a JUMP */ _particle_save = *_particle; DEBUG_COMP(_source_var._name); DEBUG_STATE(); if ((( ! _instrument_var._parameters.VIRTUALIN ))) // conditional WHEN execution class_Source_gen4_trace(&_source_var, _particle); if (_particle->_restore) particle_restore(_particle, &_particle_save); _particle->_index++; if (!ABSORBED) { DEBUG_STATE(); } } /* end component source [2] */ /* begin component slitGuideBegin=Slit() [3] */ if (!_particle->flag_nocoordschange) { // flag activated by JUMP to pass coords change if (_slitGuideBegin_var._rotation_is_identity) { if(!_slitGuideBegin_var._position_relative_is_zero) { coords_get(coords_add(coords_set(x,y,z), _slitGuideBegin_var._position_relative),&x, &y, &z); } } else { mccoordschange(_slitGuideBegin_var._position_relative, _slitGuideBegin_var._rotation_relative, _particle); } } if (!ABSORBED && _particle->_index == 3) { _particle->flag_nocoordschange=0; /* Reset if we came here from a JUMP */ _particle_save = *_particle; DEBUG_COMP(_slitGuideBegin_var._name); DEBUG_STATE(); if ((( ! _instrument_var._parameters.VIRTUALIN ))) // conditional WHEN execution class_Slit_trace(&_slitGuideBegin_var, _particle); if (_particle->_restore) particle_restore(_particle, &_particle_save); _particle->_index++; if (!ABSORBED) { DEBUG_STATE(); } } /* end component slitGuideBegin [3] */ /* begin component lmon_guide_start=L_monitor() [4] */ if (!_particle->flag_nocoordschange) { // flag activated by JUMP to pass coords change if (_lmon_guide_start_var._rotation_is_identity) { if(!_lmon_guide_start_var._position_relative_is_zero) { coords_get(coords_add(coords_set(x,y,z), _lmon_guide_start_var._position_relative),&x, &y, &z); } } else { mccoordschange(_lmon_guide_start_var._position_relative, _lmon_guide_start_var._rotation_relative, _particle); } } if (!ABSORBED && _particle->_index == 4) { _particle->flag_nocoordschange=0; /* Reset if we came here from a JUMP */ _particle_save = *_particle; DEBUG_COMP(_lmon_guide_start_var._name); DEBUG_STATE(); if ((( ! _instrument_var._parameters.VIRTUALIN ))) // conditional WHEN execution class_L_monitor_trace(&_lmon_guide_start_var, _particle); if (_particle->_restore) particle_restore(_particle, &_particle_save); _particle->_index++; if (!ABSORBED) { DEBUG_STATE(); } } /* end component lmon_guide_start [4] */ /* begin component guideStraight=Guide() [5] */ if (!_particle->flag_nocoordschange) { // flag activated by JUMP to pass coords change if (_guideStraight_var._rotation_is_identity) { if(!_guideStraight_var._position_relative_is_zero) { coords_get(coords_add(coords_set(x,y,z), _guideStraight_var._position_relative),&x, &y, &z); } } else { mccoordschange(_guideStraight_var._position_relative, _guideStraight_var._rotation_relative, _particle); } } if (!ABSORBED && _particle->_index == 5) { _particle->flag_nocoordschange=0; /* Reset if we came here from a JUMP */ _particle_save = *_particle; DEBUG_COMP(_guideStraight_var._name); DEBUG_STATE(); if ((( ! _instrument_var._parameters.VIRTUALIN ))) // conditional WHEN execution class_Guide_trace(&_guideStraight_var, _particle); if (_particle->_restore) particle_restore(_particle, &_particle_save); _particle->_index++; if (!ABSORBED) { DEBUG_STATE(); } } /* end component guideStraight [5] */ /* begin component guideCurved1=Guide() [6] */ if (!_particle->flag_nocoordschange) { // flag activated by JUMP to pass coords change if (_guideCurved1_var._rotation_is_identity) { if(!_guideCurved1_var._position_relative_is_zero) { coords_get(coords_add(coords_set(x,y,z), _guideCurved1_var._position_relative),&x, &y, &z); } } else { mccoordschange(_guideCurved1_var._position_relative, _guideCurved1_var._rotation_relative, _particle); } } if (!ABSORBED && _particle->_index == 6) { _particle->flag_nocoordschange=0; /* Reset if we came here from a JUMP */ _particle_save = *_particle; DEBUG_COMP(_guideCurved1_var._name); DEBUG_STATE(); if ((( ! _instrument_var._parameters.VIRTUALIN ))) // conditional WHEN execution class_Guide_trace(&_guideCurved1_var, _particle); if (_particle->_restore) particle_restore(_particle, &_particle_save); _particle->_index++; if (!ABSORBED) { DEBUG_STATE(); } } /* end component guideCurved1 [6] */ /* begin component guideCurved2=Guide() [7] */ if (!_particle->flag_nocoordschange) { // flag activated by JUMP to pass coords change if (_guideCurved2_var._rotation_is_identity) { if(!_guideCurved2_var._position_relative_is_zero) { coords_get(coords_add(coords_set(x,y,z), _guideCurved2_var._position_relative),&x, &y, &z); } } else { mccoordschange(_guideCurved2_var._position_relative, _guideCurved2_var._rotation_relative, _particle); } } if (!ABSORBED && _particle->_index == 7) { _particle->flag_nocoordschange=0; /* Reset if we came here from a JUMP */ _particle_save = *_particle; DEBUG_COMP(_guideCurved2_var._name); DEBUG_STATE(); if ((( ! _instrument_var._parameters.VIRTUALIN ))) // conditional WHEN execution class_Guide_trace(&_guideCurved2_var, _particle); if (_particle->_restore) particle_restore(_particle, &_particle_save); _particle->_index++; if (!ABSORBED) { DEBUG_STATE(); } } /* end component guideCurved2 [7] */ /* begin component guideCurved3=Guide() [8] */ if (!_particle->flag_nocoordschange) { // flag activated by JUMP to pass coords change if (_guideCurved3_var._rotation_is_identity) { if(!_guideCurved3_var._position_relative_is_zero) { coords_get(coords_add(coords_set(x,y,z), _guideCurved3_var._position_relative),&x, &y, &z); } } else { mccoordschange(_guideCurved3_var._position_relative, _guideCurved3_var._rotation_relative, _particle); } } if (!ABSORBED && _particle->_index == 8) { _particle->flag_nocoordschange=0; /* Reset if we came here from a JUMP */ _particle_save = *_particle; DEBUG_COMP(_guideCurved3_var._name); DEBUG_STATE(); if ((( ! _instrument_var._parameters.VIRTUALIN ))) // conditional WHEN execution class_Guide_trace(&_guideCurved3_var, _particle); if (_particle->_restore) particle_restore(_particle, &_particle_save); _particle->_index++; if (!ABSORBED) { DEBUG_STATE(); } } /* end component guideCurved3 [8] */ /* begin component guideCurved4=Guide() [9] */ if (!_particle->flag_nocoordschange) { // flag activated by JUMP to pass coords change if (_guideCurved4_var._rotation_is_identity) { if(!_guideCurved4_var._position_relative_is_zero) { coords_get(coords_add(coords_set(x,y,z), _guideCurved4_var._position_relative),&x, &y, &z); } } else { mccoordschange(_guideCurved4_var._position_relative, _guideCurved4_var._rotation_relative, _particle); } } if (!ABSORBED && _particle->_index == 9) { _particle->flag_nocoordschange=0; /* Reset if we came here from a JUMP */ _particle_save = *_particle; DEBUG_COMP(_guideCurved4_var._name); DEBUG_STATE(); if ((( ! _instrument_var._parameters.VIRTUALIN ))) // conditional WHEN execution class_Guide_trace(&_guideCurved4_var, _particle); if (_particle->_restore) particle_restore(_particle, &_particle_save); _particle->_index++; if (!ABSORBED) { DEBUG_STATE(); } } /* end component guideCurved4 [9] */ /* begin component guideCurved5=Guide() [10] */ if (!_particle->flag_nocoordschange) { // flag activated by JUMP to pass coords change if (_guideCurved5_var._rotation_is_identity) { if(!_guideCurved5_var._position_relative_is_zero) { coords_get(coords_add(coords_set(x,y,z), _guideCurved5_var._position_relative),&x, &y, &z); } } else { mccoordschange(_guideCurved5_var._position_relative, _guideCurved5_var._rotation_relative, _particle); } } if (!ABSORBED && _particle->_index == 10) { _particle->flag_nocoordschange=0; /* Reset if we came here from a JUMP */ _particle_save = *_particle; DEBUG_COMP(_guideCurved5_var._name); DEBUG_STATE(); if ((( ! _instrument_var._parameters.VIRTUALIN ))) // conditional WHEN execution class_Guide_trace(&_guideCurved5_var, _particle); if (_particle->_restore) particle_restore(_particle, &_particle_save); _particle->_index++; if (!ABSORBED) { DEBUG_STATE(); } } /* end component guideCurved5 [10] */ /* begin component guideCurved6=Guide() [11] */ if (!_particle->flag_nocoordschange) { // flag activated by JUMP to pass coords change if (_guideCurved6_var._rotation_is_identity) { if(!_guideCurved6_var._position_relative_is_zero) { coords_get(coords_add(coords_set(x,y,z), _guideCurved6_var._position_relative),&x, &y, &z); } } else { mccoordschange(_guideCurved6_var._position_relative, _guideCurved6_var._rotation_relative, _particle); } } if (!ABSORBED && _particle->_index == 11) { _particle->flag_nocoordschange=0; /* Reset if we came here from a JUMP */ _particle_save = *_particle; DEBUG_COMP(_guideCurved6_var._name); DEBUG_STATE(); if ((( ! _instrument_var._parameters.VIRTUALIN ))) // conditional WHEN execution class_Guide_trace(&_guideCurved6_var, _particle); if (_particle->_restore) particle_restore(_particle, &_particle_save); _particle->_index++; if (!ABSORBED) { DEBUG_STATE(); } } /* end component guideCurved6 [11] */ /* begin component guideCurved7=Guide() [12] */ if (!_particle->flag_nocoordschange) { // flag activated by JUMP to pass coords change if (_guideCurved7_var._rotation_is_identity) { if(!_guideCurved7_var._position_relative_is_zero) { coords_get(coords_add(coords_set(x,y,z), _guideCurved7_var._position_relative),&x, &y, &z); } } else { mccoordschange(_guideCurved7_var._position_relative, _guideCurved7_var._rotation_relative, _particle); } } if (!ABSORBED && _particle->_index == 12) { _particle->flag_nocoordschange=0; /* Reset if we came here from a JUMP */ _particle_save = *_particle; DEBUG_COMP(_guideCurved7_var._name); DEBUG_STATE(); if ((( ! _instrument_var._parameters.VIRTUALIN ))) // conditional WHEN execution class_Guide_trace(&_guideCurved7_var, _particle); if (_particle->_restore) particle_restore(_particle, &_particle_save); _particle->_index++; if (!ABSORBED) { DEBUG_STATE(); } } /* end component guideCurved7 [12] */ /* begin component guideCurved8=Guide() [13] */ if (!_particle->flag_nocoordschange) { // flag activated by JUMP to pass coords change if (_guideCurved8_var._rotation_is_identity) { if(!_guideCurved8_var._position_relative_is_zero) { coords_get(coords_add(coords_set(x,y,z), _guideCurved8_var._position_relative),&x, &y, &z); } } else { mccoordschange(_guideCurved8_var._position_relative, _guideCurved8_var._rotation_relative, _particle); } } if (!ABSORBED && _particle->_index == 13) { _particle->flag_nocoordschange=0; /* Reset if we came here from a JUMP */ _particle_save = *_particle; DEBUG_COMP(_guideCurved8_var._name); DEBUG_STATE(); if ((( ! _instrument_var._parameters.VIRTUALIN ))) // conditional WHEN execution class_Guide_trace(&_guideCurved8_var, _particle); if (_particle->_restore) particle_restore(_particle, &_particle_save); _particle->_index++; if (!ABSORBED) { DEBUG_STATE(); } } /* end component guideCurved8 [13] */ /* begin component guideCurved9=Guide() [14] */ if (!_particle->flag_nocoordschange) { // flag activated by JUMP to pass coords change if (_guideCurved9_var._rotation_is_identity) { if(!_guideCurved9_var._position_relative_is_zero) { coords_get(coords_add(coords_set(x,y,z), _guideCurved9_var._position_relative),&x, &y, &z); } } else { mccoordschange(_guideCurved9_var._position_relative, _guideCurved9_var._rotation_relative, _particle); } } if (!ABSORBED && _particle->_index == 14) { _particle->flag_nocoordschange=0; /* Reset if we came here from a JUMP */ _particle_save = *_particle; DEBUG_COMP(_guideCurved9_var._name); DEBUG_STATE(); if ((( ! _instrument_var._parameters.VIRTUALIN ))) // conditional WHEN execution class_Guide_trace(&_guideCurved9_var, _particle); if (_particle->_restore) particle_restore(_particle, &_particle_save); _particle->_index++; if (!ABSORBED) { DEBUG_STATE(); } } /* end component guideCurved9 [14] */ /* begin component guideCurved10=Guide() [15] */ if (!_particle->flag_nocoordschange) { // flag activated by JUMP to pass coords change if (_guideCurved10_var._rotation_is_identity) { if(!_guideCurved10_var._position_relative_is_zero) { coords_get(coords_add(coords_set(x,y,z), _guideCurved10_var._position_relative),&x, &y, &z); } } else { mccoordschange(_guideCurved10_var._position_relative, _guideCurved10_var._rotation_relative, _particle); } } if (!ABSORBED && _particle->_index == 15) { _particle->flag_nocoordschange=0; /* Reset if we came here from a JUMP */ _particle_save = *_particle; DEBUG_COMP(_guideCurved10_var._name); DEBUG_STATE(); if ((( ! _instrument_var._parameters.VIRTUALIN ))) // conditional WHEN execution class_Guide_trace(&_guideCurved10_var, _particle); if (_particle->_restore) particle_restore(_particle, &_particle_save); _particle->_index++; if (!ABSORBED) { DEBUG_STATE(); } } /* end component guideCurved10 [15] */ /* begin component guideCurved11=Guide() [16] */ if (!_particle->flag_nocoordschange) { // flag activated by JUMP to pass coords change if (_guideCurved11_var._rotation_is_identity) { if(!_guideCurved11_var._position_relative_is_zero) { coords_get(coords_add(coords_set(x,y,z), _guideCurved11_var._position_relative),&x, &y, &z); } } else { mccoordschange(_guideCurved11_var._position_relative, _guideCurved11_var._rotation_relative, _particle); } } if (!ABSORBED && _particle->_index == 16) { _particle->flag_nocoordschange=0; /* Reset if we came here from a JUMP */ _particle_save = *_particle; DEBUG_COMP(_guideCurved11_var._name); DEBUG_STATE(); if ((( ! _instrument_var._parameters.VIRTUALIN ))) // conditional WHEN execution class_Guide_trace(&_guideCurved11_var, _particle); if (_particle->_restore) particle_restore(_particle, &_particle_save); _particle->_index++; if (!ABSORBED) { DEBUG_STATE(); } } /* end component guideCurved11 [16] */ /* begin component guideCurved12=Guide() [17] */ if (!_particle->flag_nocoordschange) { // flag activated by JUMP to pass coords change if (_guideCurved12_var._rotation_is_identity) { if(!_guideCurved12_var._position_relative_is_zero) { coords_get(coords_add(coords_set(x,y,z), _guideCurved12_var._position_relative),&x, &y, &z); } } else { mccoordschange(_guideCurved12_var._position_relative, _guideCurved12_var._rotation_relative, _particle); } } if (!ABSORBED && _particle->_index == 17) { _particle->flag_nocoordschange=0; /* Reset if we came here from a JUMP */ _particle_save = *_particle; DEBUG_COMP(_guideCurved12_var._name); DEBUG_STATE(); if ((( ! _instrument_var._parameters.VIRTUALIN ))) // conditional WHEN execution class_Guide_trace(&_guideCurved12_var, _particle); if (_particle->_restore) particle_restore(_particle, &_particle_save); _particle->_index++; if (!ABSORBED) { DEBUG_STATE(); } } /* end component guideCurved12 [17] */ /* begin component guideCurved13=Guide() [18] */ if (!_particle->flag_nocoordschange) { // flag activated by JUMP to pass coords change if (_guideCurved13_var._rotation_is_identity) { if(!_guideCurved13_var._position_relative_is_zero) { coords_get(coords_add(coords_set(x,y,z), _guideCurved13_var._position_relative),&x, &y, &z); } } else { mccoordschange(_guideCurved13_var._position_relative, _guideCurved13_var._rotation_relative, _particle); } } if (!ABSORBED && _particle->_index == 18) { _particle->flag_nocoordschange=0; /* Reset if we came here from a JUMP */ _particle_save = *_particle; DEBUG_COMP(_guideCurved13_var._name); DEBUG_STATE(); if ((( ! _instrument_var._parameters.VIRTUALIN ))) // conditional WHEN execution class_Guide_trace(&_guideCurved13_var, _particle); if (_particle->_restore) particle_restore(_particle, &_particle_save); _particle->_index++; if (!ABSORBED) { DEBUG_STATE(); } } /* end component guideCurved13 [18] */ /* begin component guideCurved14=Guide() [19] */ if (!_particle->flag_nocoordschange) { // flag activated by JUMP to pass coords change if (_guideCurved14_var._rotation_is_identity) { if(!_guideCurved14_var._position_relative_is_zero) { coords_get(coords_add(coords_set(x,y,z), _guideCurved14_var._position_relative),&x, &y, &z); } } else { mccoordschange(_guideCurved14_var._position_relative, _guideCurved14_var._rotation_relative, _particle); } } if (!ABSORBED && _particle->_index == 19) { _particle->flag_nocoordschange=0; /* Reset if we came here from a JUMP */ _particle_save = *_particle; DEBUG_COMP(_guideCurved14_var._name); DEBUG_STATE(); if ((( ! _instrument_var._parameters.VIRTUALIN ))) // conditional WHEN execution class_Guide_trace(&_guideCurved14_var, _particle); if (_particle->_restore) particle_restore(_particle, &_particle_save); _particle->_index++; if (!ABSORBED) { DEBUG_STATE(); } } /* end component guideCurved14 [19] */ /* begin component guideCurved15=Guide() [20] */ if (!_particle->flag_nocoordschange) { // flag activated by JUMP to pass coords change if (_guideCurved15_var._rotation_is_identity) { if(!_guideCurved15_var._position_relative_is_zero) { coords_get(coords_add(coords_set(x,y,z), _guideCurved15_var._position_relative),&x, &y, &z); } } else { mccoordschange(_guideCurved15_var._position_relative, _guideCurved15_var._rotation_relative, _particle); } } if (!ABSORBED && _particle->_index == 20) { _particle->flag_nocoordschange=0; /* Reset if we came here from a JUMP */ _particle_save = *_particle; DEBUG_COMP(_guideCurved15_var._name); DEBUG_STATE(); if ((( ! _instrument_var._parameters.VIRTUALIN ))) // conditional WHEN execution class_Guide_trace(&_guideCurved15_var, _particle); if (_particle->_restore) particle_restore(_particle, &_particle_save); _particle->_index++; if (!ABSORBED) { DEBUG_STATE(); } } /* end component guideCurved15 [20] */ /* begin component guideCurved16=Guide() [21] */ if (!_particle->flag_nocoordschange) { // flag activated by JUMP to pass coords change if (_guideCurved16_var._rotation_is_identity) { if(!_guideCurved16_var._position_relative_is_zero) { coords_get(coords_add(coords_set(x,y,z), _guideCurved16_var._position_relative),&x, &y, &z); } } else { mccoordschange(_guideCurved16_var._position_relative, _guideCurved16_var._rotation_relative, _particle); } } if (!ABSORBED && _particle->_index == 21) { _particle->flag_nocoordschange=0; /* Reset if we came here from a JUMP */ _particle_save = *_particle; DEBUG_COMP(_guideCurved16_var._name); DEBUG_STATE(); if ((( ! _instrument_var._parameters.VIRTUALIN ))) // conditional WHEN execution class_Guide_trace(&_guideCurved16_var, _particle); if (_particle->_restore) particle_restore(_particle, &_particle_save); _particle->_index++; if (!ABSORBED) { DEBUG_STATE(); } } /* end component guideCurved16 [21] */ /* begin component guideCurved17=Guide() [22] */ if (!_particle->flag_nocoordschange) { // flag activated by JUMP to pass coords change if (_guideCurved17_var._rotation_is_identity) { if(!_guideCurved17_var._position_relative_is_zero) { coords_get(coords_add(coords_set(x,y,z), _guideCurved17_var._position_relative),&x, &y, &z); } } else { mccoordschange(_guideCurved17_var._position_relative, _guideCurved17_var._rotation_relative, _particle); } } if (!ABSORBED && _particle->_index == 22) { _particle->flag_nocoordschange=0; /* Reset if we came here from a JUMP */ _particle_save = *_particle; DEBUG_COMP(_guideCurved17_var._name); DEBUG_STATE(); if ((( ! _instrument_var._parameters.VIRTUALIN ))) // conditional WHEN execution class_Guide_trace(&_guideCurved17_var, _particle); if (_particle->_restore) particle_restore(_particle, &_particle_save); _particle->_index++; if (!ABSORBED) { DEBUG_STATE(); } } /* end component guideCurved17 [22] */ /* begin component guideCurved18=Guide() [23] */ if (!_particle->flag_nocoordschange) { // flag activated by JUMP to pass coords change if (_guideCurved18_var._rotation_is_identity) { if(!_guideCurved18_var._position_relative_is_zero) { coords_get(coords_add(coords_set(x,y,z), _guideCurved18_var._position_relative),&x, &y, &z); } } else { mccoordschange(_guideCurved18_var._position_relative, _guideCurved18_var._rotation_relative, _particle); } } if (!ABSORBED && _particle->_index == 23) { _particle->flag_nocoordschange=0; /* Reset if we came here from a JUMP */ _particle_save = *_particle; DEBUG_COMP(_guideCurved18_var._name); DEBUG_STATE(); if ((( ! _instrument_var._parameters.VIRTUALIN ))) // conditional WHEN execution class_Guide_trace(&_guideCurved18_var, _particle); if (_particle->_restore) particle_restore(_particle, &_particle_save); _particle->_index++; if (!ABSORBED) { DEBUG_STATE(); } } /* end component guideCurved18 [23] */ /* begin component guideCurved19=Guide() [24] */ if (!_particle->flag_nocoordschange) { // flag activated by JUMP to pass coords change if (_guideCurved19_var._rotation_is_identity) { if(!_guideCurved19_var._position_relative_is_zero) { coords_get(coords_add(coords_set(x,y,z), _guideCurved19_var._position_relative),&x, &y, &z); } } else { mccoordschange(_guideCurved19_var._position_relative, _guideCurved19_var._rotation_relative, _particle); } } if (!ABSORBED && _particle->_index == 24) { _particle->flag_nocoordschange=0; /* Reset if we came here from a JUMP */ _particle_save = *_particle; DEBUG_COMP(_guideCurved19_var._name); DEBUG_STATE(); if ((( ! _instrument_var._parameters.VIRTUALIN ))) // conditional WHEN execution class_Guide_trace(&_guideCurved19_var, _particle); if (_particle->_restore) particle_restore(_particle, &_particle_save); _particle->_index++; if (!ABSORBED) { DEBUG_STATE(); } } /* end component guideCurved19 [24] */ /* begin component guideCurved20=Guide() [25] */ if (!_particle->flag_nocoordschange) { // flag activated by JUMP to pass coords change if (_guideCurved20_var._rotation_is_identity) { if(!_guideCurved20_var._position_relative_is_zero) { coords_get(coords_add(coords_set(x,y,z), _guideCurved20_var._position_relative),&x, &y, &z); } } else { mccoordschange(_guideCurved20_var._position_relative, _guideCurved20_var._rotation_relative, _particle); } } if (!ABSORBED && _particle->_index == 25) { _particle->flag_nocoordschange=0; /* Reset if we came here from a JUMP */ _particle_save = *_particle; DEBUG_COMP(_guideCurved20_var._name); DEBUG_STATE(); if ((( ! _instrument_var._parameters.VIRTUALIN ))) // conditional WHEN execution class_Guide_trace(&_guideCurved20_var, _particle); if (_particle->_restore) particle_restore(_particle, &_particle_save); _particle->_index++; if (!ABSORBED) { DEBUG_STATE(); } } /* end component guideCurved20 [25] */ /* begin component guideCurved21=Guide() [26] */ if (!_particle->flag_nocoordschange) { // flag activated by JUMP to pass coords change if (_guideCurved21_var._rotation_is_identity) { if(!_guideCurved21_var._position_relative_is_zero) { coords_get(coords_add(coords_set(x,y,z), _guideCurved21_var._position_relative),&x, &y, &z); } } else { mccoordschange(_guideCurved21_var._position_relative, _guideCurved21_var._rotation_relative, _particle); } } if (!ABSORBED && _particle->_index == 26) { _particle->flag_nocoordschange=0; /* Reset if we came here from a JUMP */ _particle_save = *_particle; DEBUG_COMP(_guideCurved21_var._name); DEBUG_STATE(); if ((( ! _instrument_var._parameters.VIRTUALIN ))) // conditional WHEN execution class_Guide_trace(&_guideCurved21_var, _particle); if (_particle->_restore) particle_restore(_particle, &_particle_save); _particle->_index++; if (!ABSORBED) { DEBUG_STATE(); } } /* end component guideCurved21 [26] */ /* begin component guideCurved22=Guide() [27] */ if (!_particle->flag_nocoordschange) { // flag activated by JUMP to pass coords change if (_guideCurved22_var._rotation_is_identity) { if(!_guideCurved22_var._position_relative_is_zero) { coords_get(coords_add(coords_set(x,y,z), _guideCurved22_var._position_relative),&x, &y, &z); } } else { mccoordschange(_guideCurved22_var._position_relative, _guideCurved22_var._rotation_relative, _particle); } } if (!ABSORBED && _particle->_index == 27) { _particle->flag_nocoordschange=0; /* Reset if we came here from a JUMP */ _particle_save = *_particle; DEBUG_COMP(_guideCurved22_var._name); DEBUG_STATE(); if ((( ! _instrument_var._parameters.VIRTUALIN ))) // conditional WHEN execution class_Guide_trace(&_guideCurved22_var, _particle); if (_particle->_restore) particle_restore(_particle, &_particle_save); _particle->_index++; if (!ABSORBED) { DEBUG_STATE(); } } /* end component guideCurved22 [27] */ /* begin component guideCurved23=Guide() [28] */ if (!_particle->flag_nocoordschange) { // flag activated by JUMP to pass coords change if (_guideCurved23_var._rotation_is_identity) { if(!_guideCurved23_var._position_relative_is_zero) { coords_get(coords_add(coords_set(x,y,z), _guideCurved23_var._position_relative),&x, &y, &z); } } else { mccoordschange(_guideCurved23_var._position_relative, _guideCurved23_var._rotation_relative, _particle); } } if (!ABSORBED && _particle->_index == 28) { _particle->flag_nocoordschange=0; /* Reset if we came here from a JUMP */ _particle_save = *_particle; DEBUG_COMP(_guideCurved23_var._name); DEBUG_STATE(); if ((( ! _instrument_var._parameters.VIRTUALIN ))) // conditional WHEN execution class_Guide_trace(&_guideCurved23_var, _particle); if (_particle->_restore) particle_restore(_particle, &_particle_save); _particle->_index++; if (!ABSORBED) { DEBUG_STATE(); } } /* end component guideCurved23 [28] */ /* begin component guideCurved24=Guide() [29] */ if (!_particle->flag_nocoordschange) { // flag activated by JUMP to pass coords change if (_guideCurved24_var._rotation_is_identity) { if(!_guideCurved24_var._position_relative_is_zero) { coords_get(coords_add(coords_set(x,y,z), _guideCurved24_var._position_relative),&x, &y, &z); } } else { mccoordschange(_guideCurved24_var._position_relative, _guideCurved24_var._rotation_relative, _particle); } } if (!ABSORBED && _particle->_index == 29) { _particle->flag_nocoordschange=0; /* Reset if we came here from a JUMP */ _particle_save = *_particle; DEBUG_COMP(_guideCurved24_var._name); DEBUG_STATE(); if ((( ! _instrument_var._parameters.VIRTUALIN ))) // conditional WHEN execution class_Guide_trace(&_guideCurved24_var, _particle); if (_particle->_restore) particle_restore(_particle, &_particle_save); _particle->_index++; if (!ABSORBED) { DEBUG_STATE(); } } /* end component guideCurved24 [29] */ /* begin component guideCurved25=Guide() [30] */ if (!_particle->flag_nocoordschange) { // flag activated by JUMP to pass coords change if (_guideCurved25_var._rotation_is_identity) { if(!_guideCurved25_var._position_relative_is_zero) { coords_get(coords_add(coords_set(x,y,z), _guideCurved25_var._position_relative),&x, &y, &z); } } else { mccoordschange(_guideCurved25_var._position_relative, _guideCurved25_var._rotation_relative, _particle); } } if (!ABSORBED && _particle->_index == 30) { _particle->flag_nocoordschange=0; /* Reset if we came here from a JUMP */ _particle_save = *_particle; DEBUG_COMP(_guideCurved25_var._name); DEBUG_STATE(); if ((( ! _instrument_var._parameters.VIRTUALIN ))) // conditional WHEN execution class_Guide_trace(&_guideCurved25_var, _particle); if (_particle->_restore) particle_restore(_particle, &_particle_save); _particle->_index++; if (!ABSORBED) { DEBUG_STATE(); } } /* end component guideCurved25 [30] */ /* begin component guideCurved26=Guide() [31] */ if (!_particle->flag_nocoordschange) { // flag activated by JUMP to pass coords change if (_guideCurved26_var._rotation_is_identity) { if(!_guideCurved26_var._position_relative_is_zero) { coords_get(coords_add(coords_set(x,y,z), _guideCurved26_var._position_relative),&x, &y, &z); } } else { mccoordschange(_guideCurved26_var._position_relative, _guideCurved26_var._rotation_relative, _particle); } } if (!ABSORBED && _particle->_index == 31) { _particle->flag_nocoordschange=0; /* Reset if we came here from a JUMP */ _particle_save = *_particle; DEBUG_COMP(_guideCurved26_var._name); DEBUG_STATE(); if ((( ! _instrument_var._parameters.VIRTUALIN ))) // conditional WHEN execution class_Guide_trace(&_guideCurved26_var, _particle); if (_particle->_restore) particle_restore(_particle, &_particle_save); _particle->_index++; if (!ABSORBED) { DEBUG_STATE(); } } /* end component guideCurved26 [31] */ /* begin component guideCurved27=Guide() [32] */ if (!_particle->flag_nocoordschange) { // flag activated by JUMP to pass coords change if (_guideCurved27_var._rotation_is_identity) { if(!_guideCurved27_var._position_relative_is_zero) { coords_get(coords_add(coords_set(x,y,z), _guideCurved27_var._position_relative),&x, &y, &z); } } else { mccoordschange(_guideCurved27_var._position_relative, _guideCurved27_var._rotation_relative, _particle); } } if (!ABSORBED && _particle->_index == 32) { _particle->flag_nocoordschange=0; /* Reset if we came here from a JUMP */ _particle_save = *_particle; DEBUG_COMP(_guideCurved27_var._name); DEBUG_STATE(); if ((( ! _instrument_var._parameters.VIRTUALIN ))) // conditional WHEN execution class_Guide_trace(&_guideCurved27_var, _particle); if (_particle->_restore) particle_restore(_particle, &_particle_save); _particle->_index++; if (!ABSORBED) { DEBUG_STATE(); } } /* end component guideCurved27 [32] */ /* begin component guideCurved28=Guide() [33] */ if (!_particle->flag_nocoordschange) { // flag activated by JUMP to pass coords change if (_guideCurved28_var._rotation_is_identity) { if(!_guideCurved28_var._position_relative_is_zero) { coords_get(coords_add(coords_set(x,y,z), _guideCurved28_var._position_relative),&x, &y, &z); } } else { mccoordschange(_guideCurved28_var._position_relative, _guideCurved28_var._rotation_relative, _particle); } } if (!ABSORBED && _particle->_index == 33) { _particle->flag_nocoordschange=0; /* Reset if we came here from a JUMP */ _particle_save = *_particle; DEBUG_COMP(_guideCurved28_var._name); DEBUG_STATE(); if ((( ! _instrument_var._parameters.VIRTUALIN ))) // conditional WHEN execution class_Guide_trace(&_guideCurved28_var, _particle); if (_particle->_restore) particle_restore(_particle, &_particle_save); _particle->_index++; if (!ABSORBED) { DEBUG_STATE(); } } /* end component guideCurved28 [33] */ /* begin component guideCurved29=Guide() [34] */ if (!_particle->flag_nocoordschange) { // flag activated by JUMP to pass coords change if (_guideCurved29_var._rotation_is_identity) { if(!_guideCurved29_var._position_relative_is_zero) { coords_get(coords_add(coords_set(x,y,z), _guideCurved29_var._position_relative),&x, &y, &z); } } else { mccoordschange(_guideCurved29_var._position_relative, _guideCurved29_var._rotation_relative, _particle); } } if (!ABSORBED && _particle->_index == 34) { _particle->flag_nocoordschange=0; /* Reset if we came here from a JUMP */ _particle_save = *_particle; DEBUG_COMP(_guideCurved29_var._name); DEBUG_STATE(); if ((( ! _instrument_var._parameters.VIRTUALIN ))) // conditional WHEN execution class_Guide_trace(&_guideCurved29_var, _particle); if (_particle->_restore) particle_restore(_particle, &_particle_save); _particle->_index++; if (!ABSORBED) { DEBUG_STATE(); } } /* end component guideCurved29 [34] */ /* begin component guideCurved30=Guide() [35] */ if (!_particle->flag_nocoordschange) { // flag activated by JUMP to pass coords change if (_guideCurved30_var._rotation_is_identity) { if(!_guideCurved30_var._position_relative_is_zero) { coords_get(coords_add(coords_set(x,y,z), _guideCurved30_var._position_relative),&x, &y, &z); } } else { mccoordschange(_guideCurved30_var._position_relative, _guideCurved30_var._rotation_relative, _particle); } } if (!ABSORBED && _particle->_index == 35) { _particle->flag_nocoordschange=0; /* Reset if we came here from a JUMP */ _particle_save = *_particle; DEBUG_COMP(_guideCurved30_var._name); DEBUG_STATE(); if ((( ! _instrument_var._parameters.VIRTUALIN ))) // conditional WHEN execution class_Guide_trace(&_guideCurved30_var, _particle); if (_particle->_restore) particle_restore(_particle, &_particle_save); _particle->_index++; if (!ABSORBED) { DEBUG_STATE(); } } /* end component guideCurved30 [35] */ /* begin component guideCurved31=Guide() [36] */ if (!_particle->flag_nocoordschange) { // flag activated by JUMP to pass coords change if (_guideCurved31_var._rotation_is_identity) { if(!_guideCurved31_var._position_relative_is_zero) { coords_get(coords_add(coords_set(x,y,z), _guideCurved31_var._position_relative),&x, &y, &z); } } else { mccoordschange(_guideCurved31_var._position_relative, _guideCurved31_var._rotation_relative, _particle); } } if (!ABSORBED && _particle->_index == 36) { _particle->flag_nocoordschange=0; /* Reset if we came here from a JUMP */ _particle_save = *_particle; DEBUG_COMP(_guideCurved31_var._name); DEBUG_STATE(); if ((( ! _instrument_var._parameters.VIRTUALIN ))) // conditional WHEN execution class_Guide_trace(&_guideCurved31_var, _particle); if (_particle->_restore) particle_restore(_particle, &_particle_save); _particle->_index++; if (!ABSORBED) { DEBUG_STATE(); } } /* end component guideCurved31 [36] */ /* begin component guideCurved32=Guide() [37] */ if (!_particle->flag_nocoordschange) { // flag activated by JUMP to pass coords change if (_guideCurved32_var._rotation_is_identity) { if(!_guideCurved32_var._position_relative_is_zero) { coords_get(coords_add(coords_set(x,y,z), _guideCurved32_var._position_relative),&x, &y, &z); } } else { mccoordschange(_guideCurved32_var._position_relative, _guideCurved32_var._rotation_relative, _particle); } } if (!ABSORBED && _particle->_index == 37) { _particle->flag_nocoordschange=0; /* Reset if we came here from a JUMP */ _particle_save = *_particle; DEBUG_COMP(_guideCurved32_var._name); DEBUG_STATE(); if ((( ! _instrument_var._parameters.VIRTUALIN ))) // conditional WHEN execution class_Guide_trace(&_guideCurved32_var, _particle); if (_particle->_restore) particle_restore(_particle, &_particle_save); _particle->_index++; if (!ABSORBED) { DEBUG_STATE(); } } /* end component guideCurved32 [37] */ /* begin component guideCurved33=Guide() [38] */ if (!_particle->flag_nocoordschange) { // flag activated by JUMP to pass coords change if (_guideCurved33_var._rotation_is_identity) { if(!_guideCurved33_var._position_relative_is_zero) { coords_get(coords_add(coords_set(x,y,z), _guideCurved33_var._position_relative),&x, &y, &z); } } else { mccoordschange(_guideCurved33_var._position_relative, _guideCurved33_var._rotation_relative, _particle); } } if (!ABSORBED && _particle->_index == 38) { _particle->flag_nocoordschange=0; /* Reset if we came here from a JUMP */ _particle_save = *_particle; DEBUG_COMP(_guideCurved33_var._name); DEBUG_STATE(); if ((( ! _instrument_var._parameters.VIRTUALIN ))) // conditional WHEN execution class_Guide_trace(&_guideCurved33_var, _particle); if (_particle->_restore) particle_restore(_particle, &_particle_save); _particle->_index++; if (!ABSORBED) { DEBUG_STATE(); } } /* end component guideCurved33 [38] */ /* begin component guideCurved34=Guide() [39] */ if (!_particle->flag_nocoordschange) { // flag activated by JUMP to pass coords change if (_guideCurved34_var._rotation_is_identity) { if(!_guideCurved34_var._position_relative_is_zero) { coords_get(coords_add(coords_set(x,y,z), _guideCurved34_var._position_relative),&x, &y, &z); } } else { mccoordschange(_guideCurved34_var._position_relative, _guideCurved34_var._rotation_relative, _particle); } } if (!ABSORBED && _particle->_index == 39) { _particle->flag_nocoordschange=0; /* Reset if we came here from a JUMP */ _particle_save = *_particle; DEBUG_COMP(_guideCurved34_var._name); DEBUG_STATE(); if ((( ! _instrument_var._parameters.VIRTUALIN ))) // conditional WHEN execution class_Guide_trace(&_guideCurved34_var, _particle); if (_particle->_restore) particle_restore(_particle, &_particle_save); _particle->_index++; if (!ABSORBED) { DEBUG_STATE(); } } /* end component guideCurved34 [39] */ /* begin component guideCurved35=Guide() [40] */ if (!_particle->flag_nocoordschange) { // flag activated by JUMP to pass coords change if (_guideCurved35_var._rotation_is_identity) { if(!_guideCurved35_var._position_relative_is_zero) { coords_get(coords_add(coords_set(x,y,z), _guideCurved35_var._position_relative),&x, &y, &z); } } else { mccoordschange(_guideCurved35_var._position_relative, _guideCurved35_var._rotation_relative, _particle); } } if (!ABSORBED && _particle->_index == 40) { _particle->flag_nocoordschange=0; /* Reset if we came here from a JUMP */ _particle_save = *_particle; DEBUG_COMP(_guideCurved35_var._name); DEBUG_STATE(); if ((( ! _instrument_var._parameters.VIRTUALIN ))) // conditional WHEN execution class_Guide_trace(&_guideCurved35_var, _particle); if (_particle->_restore) particle_restore(_particle, &_particle_save); _particle->_index++; if (!ABSORBED) { DEBUG_STATE(); } } /* end component guideCurved35 [40] */ /* begin component guideCurved36=Guide() [41] */ if (!_particle->flag_nocoordschange) { // flag activated by JUMP to pass coords change if (_guideCurved36_var._rotation_is_identity) { if(!_guideCurved36_var._position_relative_is_zero) { coords_get(coords_add(coords_set(x,y,z), _guideCurved36_var._position_relative),&x, &y, &z); } } else { mccoordschange(_guideCurved36_var._position_relative, _guideCurved36_var._rotation_relative, _particle); } } if (!ABSORBED && _particle->_index == 41) { _particle->flag_nocoordschange=0; /* Reset if we came here from a JUMP */ _particle_save = *_particle; DEBUG_COMP(_guideCurved36_var._name); DEBUG_STATE(); if ((( ! _instrument_var._parameters.VIRTUALIN ))) // conditional WHEN execution class_Guide_trace(&_guideCurved36_var, _particle); if (_particle->_restore) particle_restore(_particle, &_particle_save); _particle->_index++; if (!ABSORBED) { DEBUG_STATE(); } } /* end component guideCurved36 [41] */ /* begin component guideCurved37=Guide() [42] */ if (!_particle->flag_nocoordschange) { // flag activated by JUMP to pass coords change if (_guideCurved37_var._rotation_is_identity) { if(!_guideCurved37_var._position_relative_is_zero) { coords_get(coords_add(coords_set(x,y,z), _guideCurved37_var._position_relative),&x, &y, &z); } } else { mccoordschange(_guideCurved37_var._position_relative, _guideCurved37_var._rotation_relative, _particle); } } if (!ABSORBED && _particle->_index == 42) { _particle->flag_nocoordschange=0; /* Reset if we came here from a JUMP */ _particle_save = *_particle; DEBUG_COMP(_guideCurved37_var._name); DEBUG_STATE(); if ((( ! _instrument_var._parameters.VIRTUALIN ))) // conditional WHEN execution class_Guide_trace(&_guideCurved37_var, _particle); if (_particle->_restore) particle_restore(_particle, &_particle_save); _particle->_index++; if (!ABSORBED) { DEBUG_STATE(); } } /* end component guideCurved37 [42] */ /* begin component guideCurved38=Guide() [43] */ if (!_particle->flag_nocoordschange) { // flag activated by JUMP to pass coords change if (_guideCurved38_var._rotation_is_identity) { if(!_guideCurved38_var._position_relative_is_zero) { coords_get(coords_add(coords_set(x,y,z), _guideCurved38_var._position_relative),&x, &y, &z); } } else { mccoordschange(_guideCurved38_var._position_relative, _guideCurved38_var._rotation_relative, _particle); } } if (!ABSORBED && _particle->_index == 43) { _particle->flag_nocoordschange=0; /* Reset if we came here from a JUMP */ _particle_save = *_particle; DEBUG_COMP(_guideCurved38_var._name); DEBUG_STATE(); if ((( ! _instrument_var._parameters.VIRTUALIN ))) // conditional WHEN execution class_Guide_trace(&_guideCurved38_var, _particle); if (_particle->_restore) particle_restore(_particle, &_particle_save); _particle->_index++; if (!ABSORBED) { DEBUG_STATE(); } } /* end component guideCurved38 [43] */ /* begin component guideCurved39=Guide() [44] */ if (!_particle->flag_nocoordschange) { // flag activated by JUMP to pass coords change if (_guideCurved39_var._rotation_is_identity) { if(!_guideCurved39_var._position_relative_is_zero) { coords_get(coords_add(coords_set(x,y,z), _guideCurved39_var._position_relative),&x, &y, &z); } } else { mccoordschange(_guideCurved39_var._position_relative, _guideCurved39_var._rotation_relative, _particle); } } if (!ABSORBED && _particle->_index == 44) { _particle->flag_nocoordschange=0; /* Reset if we came here from a JUMP */ _particle_save = *_particle; DEBUG_COMP(_guideCurved39_var._name); DEBUG_STATE(); if ((( ! _instrument_var._parameters.VIRTUALIN ))) // conditional WHEN execution class_Guide_trace(&_guideCurved39_var, _particle); if (_particle->_restore) particle_restore(_particle, &_particle_save); _particle->_index++; if (!ABSORBED) { DEBUG_STATE(); } } /* end component guideCurved39 [44] */ /* begin component guideCurved40=Guide() [45] */ if (!_particle->flag_nocoordschange) { // flag activated by JUMP to pass coords change if (_guideCurved40_var._rotation_is_identity) { if(!_guideCurved40_var._position_relative_is_zero) { coords_get(coords_add(coords_set(x,y,z), _guideCurved40_var._position_relative),&x, &y, &z); } } else { mccoordschange(_guideCurved40_var._position_relative, _guideCurved40_var._rotation_relative, _particle); } } if (!ABSORBED && _particle->_index == 45) { _particle->flag_nocoordschange=0; /* Reset if we came here from a JUMP */ _particle_save = *_particle; DEBUG_COMP(_guideCurved40_var._name); DEBUG_STATE(); if ((( ! _instrument_var._parameters.VIRTUALIN ))) // conditional WHEN execution class_Guide_trace(&_guideCurved40_var, _particle); if (_particle->_restore) particle_restore(_particle, &_particle_save); _particle->_index++; if (!ABSORBED) { DEBUG_STATE(); } } /* end component guideCurved40 [45] */ /* begin component bunker=Guide() [46] */ if (!_particle->flag_nocoordschange) { // flag activated by JUMP to pass coords change if (_bunker_var._rotation_is_identity) { if(!_bunker_var._position_relative_is_zero) { coords_get(coords_add(coords_set(x,y,z), _bunker_var._position_relative),&x, &y, &z); } } else { mccoordschange(_bunker_var._position_relative, _bunker_var._rotation_relative, _particle); } } if (!ABSORBED && _particle->_index == 46) { _particle->flag_nocoordschange=0; /* Reset if we came here from a JUMP */ _particle_save = *_particle; DEBUG_COMP(_bunker_var._name); DEBUG_STATE(); if ((( ! _instrument_var._parameters.VIRTUALIN ))) // conditional WHEN execution class_Guide_trace(&_bunker_var, _particle); if (_particle->_restore) particle_restore(_particle, &_particle_save); _particle->_index++; if (!ABSORBED) { DEBUG_STATE(); } } /* end component bunker [46] */ /* begin component guide3=Guide() [47] */ if (!_particle->flag_nocoordschange) { // flag activated by JUMP to pass coords change if (_guide3_var._rotation_is_identity) { if(!_guide3_var._position_relative_is_zero) { coords_get(coords_add(coords_set(x,y,z), _guide3_var._position_relative),&x, &y, &z); } } else { mccoordschange(_guide3_var._position_relative, _guide3_var._rotation_relative, _particle); } } if (!ABSORBED && _particle->_index == 47) { _particle->flag_nocoordschange=0; /* Reset if we came here from a JUMP */ _particle_save = *_particle; DEBUG_COMP(_guide3_var._name); DEBUG_STATE(); if ((( ! _instrument_var._parameters.VIRTUALIN ))) // conditional WHEN execution class_Guide_trace(&_guide3_var, _particle); if (_particle->_restore) particle_restore(_particle, &_particle_save); _particle->_index++; if (!ABSORBED) { DEBUG_STATE(); } } /* end component guide3 [47] */ /* begin component slitGuideEnd=Slit() [48] */ if (!_particle->flag_nocoordschange) { // flag activated by JUMP to pass coords change if (_slitGuideEnd_var._rotation_is_identity) { if(!_slitGuideEnd_var._position_relative_is_zero) { coords_get(coords_add(coords_set(x,y,z), _slitGuideEnd_var._position_relative),&x, &y, &z); } } else { mccoordschange(_slitGuideEnd_var._position_relative, _slitGuideEnd_var._rotation_relative, _particle); } } if (!ABSORBED && _particle->_index == 48) { _particle->flag_nocoordschange=0; /* Reset if we came here from a JUMP */ _particle_save = *_particle; DEBUG_COMP(_slitGuideEnd_var._name); DEBUG_STATE(); if ((( ! _instrument_var._parameters.VIRTUALIN ))) // conditional WHEN execution class_Slit_trace(&_slitGuideEnd_var, _particle); if (_particle->_restore) particle_restore(_particle, &_particle_save); _particle->_index++; if (!ABSORBED) { DEBUG_STATE(); } } /* end component slitGuideEnd [48] */ /* begin component psd_guide_end=PSD_monitor() [49] */ if (!_particle->flag_nocoordschange) { // flag activated by JUMP to pass coords change if (_psd_guide_end_var._rotation_is_identity) { if(!_psd_guide_end_var._position_relative_is_zero) { coords_get(coords_add(coords_set(x,y,z), _psd_guide_end_var._position_relative),&x, &y, &z); } } else { mccoordschange(_psd_guide_end_var._position_relative, _psd_guide_end_var._rotation_relative, _particle); } } if (!ABSORBED && _particle->_index == 49) { _particle->flag_nocoordschange=0; /* Reset if we came here from a JUMP */ _particle_save = *_particle; DEBUG_COMP(_psd_guide_end_var._name); DEBUG_STATE(); if ((( ! _instrument_var._parameters.VIRTUALIN ))) // conditional WHEN execution class_PSD_monitor_trace(&_psd_guide_end_var, _particle); if (_particle->_restore) particle_restore(_particle, &_particle_save); _particle->_index++; if (!ABSORBED) { DEBUG_STATE(); } } /* end component psd_guide_end [49] */ /* begin component emon_guide_end=E_monitor() [50] */ if (!_particle->flag_nocoordschange) { // flag activated by JUMP to pass coords change if (_emon_guide_end_var._rotation_is_identity) { if(!_emon_guide_end_var._position_relative_is_zero) { coords_get(coords_add(coords_set(x,y,z), _emon_guide_end_var._position_relative),&x, &y, &z); } } else { mccoordschange(_emon_guide_end_var._position_relative, _emon_guide_end_var._rotation_relative, _particle); } } if (!ABSORBED && _particle->_index == 50) { _particle->flag_nocoordschange=0; /* Reset if we came here from a JUMP */ _particle_save = *_particle; DEBUG_COMP(_emon_guide_end_var._name); DEBUG_STATE(); class_E_monitor_trace(&_emon_guide_end_var, _particle); if (_particle->_restore) particle_restore(_particle, &_particle_save); _particle->_index++; if (!ABSORBED) { DEBUG_STATE(); } } /* end component emon_guide_end [50] */ /* begin component lmon_guide_end=L_monitor() [51] */ if (!_particle->flag_nocoordschange) { // flag activated by JUMP to pass coords change if (_lmon_guide_end_var._rotation_is_identity) { if(!_lmon_guide_end_var._position_relative_is_zero) { coords_get(coords_add(coords_set(x,y,z), _lmon_guide_end_var._position_relative),&x, &y, &z); } } else { mccoordschange(_lmon_guide_end_var._position_relative, _lmon_guide_end_var._rotation_relative, _particle); } } if (!ABSORBED && _particle->_index == 51) { _particle->flag_nocoordschange=0; /* Reset if we came here from a JUMP */ _particle_save = *_particle; DEBUG_COMP(_lmon_guide_end_var._name); DEBUG_STATE(); if ((( ! _instrument_var._parameters.VIRTUALIN ))) // conditional WHEN execution class_L_monitor_trace(&_lmon_guide_end_var, _particle); if (_particle->_restore) particle_restore(_particle, &_particle_save); _particle->_index++; if (!ABSORBED) { DEBUG_STATE(); } } /* end component lmon_guide_end [51] */ /* begin component divmon_guide_end=Divergence_monitor() [52] */ if (!_particle->flag_nocoordschange) { // flag activated by JUMP to pass coords change if (_divmon_guide_end_var._rotation_is_identity) { if(!_divmon_guide_end_var._position_relative_is_zero) { coords_get(coords_add(coords_set(x,y,z), _divmon_guide_end_var._position_relative),&x, &y, &z); } } else { mccoordschange(_divmon_guide_end_var._position_relative, _divmon_guide_end_var._rotation_relative, _particle); } } if (!ABSORBED && _particle->_index == 52) { _particle->flag_nocoordschange=0; /* Reset if we came here from a JUMP */ _particle_save = *_particle; DEBUG_COMP(_divmon_guide_end_var._name); DEBUG_STATE(); if ((( ! _instrument_var._parameters.VIRTUALIN ))) // conditional WHEN execution class_Divergence_monitor_trace(&_divmon_guide_end_var, _particle); if (_particle->_restore) particle_restore(_particle, &_particle_save); _particle->_index++; if (!ABSORBED) { DEBUG_STATE(); } } /* end component divmon_guide_end [52] */ /* begin component focus_mono=Arm() [53] */ if (!_particle->flag_nocoordschange) { // flag activated by JUMP to pass coords change if (_focus_mono_var._rotation_is_identity) { if(!_focus_mono_var._position_relative_is_zero) { coords_get(coords_add(coords_set(x,y,z), _focus_mono_var._position_relative),&x, &y, &z); } } else { mccoordschange(_focus_mono_var._position_relative, _focus_mono_var._rotation_relative, _particle); } } if (!ABSORBED && _particle->_index == 53) { _particle->flag_nocoordschange=0; /* Reset if we came here from a JUMP */ _particle_save = *_particle; DEBUG_COMP(_focus_mono_var._name); DEBUG_STATE(); if ((( ! _instrument_var._parameters.VIRTUALIN ))) // conditional WHEN execution class_Arm_trace(&_focus_mono_var, _particle); /* contains EXTEND code */ if (_particle->_restore) particle_restore(_particle, &_particle_save); _particle->_index++; if (!ABSORBED) { DEBUG_STATE(); } } /* end component focus_mono [53] */ #ifndef NOSPLIT /* start SPLIT at monochromator_curved */ if (!ABSORBED) { _class_particle Split_monochromator_curved_particle=*_particle; int Split_monochromator_curved_counter; int SplitS_monochromator_curved = SPLITMREP; #pragma acc loop independent for (Split_monochromator_curved_counter = 0; Split_monochromator_curved_counter< SplitS_monochromator_curved; Split_monochromator_curved_counter++) { randstate_t randbackup = *_particle->randstate; *_particle=Split_monochromator_curved_particle; *_particle->randstate = randbackup; p /= SplitS_monochromator_curved > 0 ? SplitS_monochromator_curved : 1; #endif /* begin component monochromator_curved=Monochromator_curved() [54] */ if (!_particle->flag_nocoordschange) { // flag activated by JUMP to pass coords change if (_monochromator_curved_var._rotation_is_identity) { if(!_monochromator_curved_var._position_relative_is_zero) { coords_get(coords_add(coords_set(x,y,z), _monochromator_curved_var._position_relative),&x, &y, &z); } } else { mccoordschange(_monochromator_curved_var._position_relative, _monochromator_curved_var._rotation_relative, _particle); } } if (!ABSORBED && _particle->_index == 54) { _particle->flag_nocoordschange=0; /* Reset if we came here from a JUMP */ _particle_save = *_particle; DEBUG_COMP(_monochromator_curved_var._name); DEBUG_STATE(); if ((( ! _instrument_var._parameters.VIRTUALIN ))) // conditional WHEN execution class_Monochromator_curved_trace(&_monochromator_curved_var, _particle); /* contains EXTEND code */ if (_particle->_restore) particle_restore(_particle, &_particle_save); _particle->_index++; if (!ABSORBED) { DEBUG_STATE(); } } /* end component monochromator_curved [54] */ /* begin component a2=Arm() [55] */ if (!ABSORBED && _particle->_index == 55) { _particle->flag_nocoordschange=0; /* Reset if we came here from a JUMP */ _particle->_index++; } /* end component a2 [55] */ /* begin component slitShutter=Slit() [56] */ if (!_particle->flag_nocoordschange) { // flag activated by JUMP to pass coords change if (_slitShutter_var._rotation_is_identity) { if(!_slitShutter_var._position_relative_is_zero) { coords_get(coords_add(coords_set(x,y,z), _slitShutter_var._position_relative),&x, &y, &z); } } else { mccoordschange(_slitShutter_var._position_relative, _slitShutter_var._rotation_relative, _particle); } } if (!ABSORBED && _particle->_index == 56) { _particle->flag_nocoordschange=0; /* Reset if we came here from a JUMP */ _particle_save = *_particle; DEBUG_COMP(_slitShutter_var._name); DEBUG_STATE(); if ((( ! _instrument_var._parameters.VIRTUALIN ))) // conditional WHEN execution class_Slit_trace(&_slitShutter_var, _particle); if (_particle->_restore) particle_restore(_particle, &_particle_save); _particle->_index++; if (!ABSORBED) { DEBUG_STATE(); } } /* end component slitShutter [56] */ /* begin component MSCollimator=Collimator_linear() [57] */ if (!_particle->flag_nocoordschange) { // flag activated by JUMP to pass coords change if (_MSCollimator_var._rotation_is_identity) { if(!_MSCollimator_var._position_relative_is_zero) { coords_get(coords_add(coords_set(x,y,z), _MSCollimator_var._position_relative),&x, &y, &z); } } else { mccoordschange(_MSCollimator_var._position_relative, _MSCollimator_var._rotation_relative, _particle); } } if (!ABSORBED && _particle->_index == 57) { _particle->flag_nocoordschange=0; /* Reset if we came here from a JUMP */ _particle_save = *_particle; DEBUG_COMP(_MSCollimator_var._name); DEBUG_STATE(); if ((( ! _instrument_var._parameters.VIRTUALIN ))) // conditional WHEN execution class_Collimator_linear_trace(&_MSCollimator_var, _particle); if (_particle->_restore) particle_restore(_particle, &_particle_save); _particle->_index++; if (!ABSORBED) { DEBUG_STATE(); } } /* end component MSCollimator [57] */ /* begin component infilter=Filter_gen() [58] */ if (!_particle->flag_nocoordschange) { // flag activated by JUMP to pass coords change if (_infilter_var._rotation_is_identity) { if(!_infilter_var._position_relative_is_zero) { coords_get(coords_add(coords_set(x,y,z), _infilter_var._position_relative),&x, &y, &z); } } else { mccoordschange(_infilter_var._position_relative, _infilter_var._rotation_relative, _particle); } } if (!ABSORBED && _particle->_index == 58) { _particle->flag_nocoordschange=0; /* Reset if we came here from a JUMP */ _particle_save = *_particle; DEBUG_COMP(_infilter_var._name); DEBUG_STATE(); if ((( _instrument_var._parameters.INFILTER > 0 && ! _instrument_var._parameters.VIRTUALIN ))) // conditional WHEN execution class_Filter_gen_trace(&_infilter_var, _particle); if (_particle->_restore) particle_restore(_particle, &_particle_save); _particle->_index++; if (!ABSORBED) { DEBUG_STATE(); } } /* end component infilter [58] */ /* begin component psd_virt=PSD_monitor() [59] */ if (!_particle->flag_nocoordschange) { // flag activated by JUMP to pass coords change if (_psd_virt_var._rotation_is_identity) { if(!_psd_virt_var._position_relative_is_zero) { coords_get(coords_add(coords_set(x,y,z), _psd_virt_var._position_relative),&x, &y, &z); } } else { mccoordschange(_psd_virt_var._position_relative, _psd_virt_var._rotation_relative, _particle); } } if (!ABSORBED && _particle->_index == 59) { _particle->flag_nocoordschange=0; /* Reset if we came here from a JUMP */ _particle_save = *_particle; DEBUG_COMP(_psd_virt_var._name); DEBUG_STATE(); if ((( ! _instrument_var._parameters.VIRTUALIN ))) // conditional WHEN execution class_PSD_monitor_trace(&_psd_virt_var, _particle); if (_particle->_restore) particle_restore(_particle, &_particle_save); _particle->_index++; if (!ABSORBED) { DEBUG_STATE(); } } /* end component psd_virt [59] */ /* begin component lmon_virt=L_monitor() [60] */ if (!_particle->flag_nocoordschange) { // flag activated by JUMP to pass coords change if (_lmon_virt_var._rotation_is_identity) { if(!_lmon_virt_var._position_relative_is_zero) { coords_get(coords_add(coords_set(x,y,z), _lmon_virt_var._position_relative),&x, &y, &z); } } else { mccoordschange(_lmon_virt_var._position_relative, _lmon_virt_var._rotation_relative, _particle); } } if (!ABSORBED && _particle->_index == 60) { _particle->flag_nocoordschange=0; /* Reset if we came here from a JUMP */ _particle_save = *_particle; DEBUG_COMP(_lmon_virt_var._name); DEBUG_STATE(); if ((( ! _instrument_var._parameters.VIRTUALIN ))) // conditional WHEN execution class_L_monitor_trace(&_lmon_virt_var, _particle); if (_particle->_restore) particle_restore(_particle, &_particle_save); _particle->_index++; if (!ABSORBED) { DEBUG_STATE(); } } /* end component lmon_virt [60] */ /* begin component aa2=Arm() [61] */ if (!ABSORBED && _particle->_index == 61) { _particle->flag_nocoordschange=0; /* Reset if we came here from a JUMP */ _particle->_index++; } /* end component aa2 [61] */ /* begin component OrderMon=Monitor_nD() [62] */ if (!_particle->flag_nocoordschange) { // flag activated by JUMP to pass coords change if (_OrderMon_var._rotation_is_identity) { if(!_OrderMon_var._position_relative_is_zero) { coords_get(coords_add(coords_set(x,y,z), _OrderMon_var._position_relative),&x, &y, &z); } } else { mccoordschange(_OrderMon_var._position_relative, _OrderMon_var._rotation_relative, _particle); } } if (!ABSORBED && _particle->_index == 62) { _particle->flag_nocoordschange=0; /* Reset if we came here from a JUMP */ _particle_save = *_particle; DEBUG_COMP(_OrderMon_var._name); DEBUG_STATE(); if ((( Mono_order && ! _instrument_var._parameters.VIRTUALOUT ))) // conditional WHEN execution class_Monitor_nD_trace(&_OrderMon_var, _particle); if (_particle->_restore) particle_restore(_particle, &_particle_save); _particle->_index++; if (!ABSORBED) { DEBUG_STATE(); } } /* end component OrderMon [62] */ /* begin component kMoni=PSD_monitor_psf_eff() [63] */ if (!_particle->flag_nocoordschange) { // flag activated by JUMP to pass coords change if (_kMoni_var._rotation_is_identity) { if(!_kMoni_var._position_relative_is_zero) { coords_get(coords_add(coords_set(x,y,z), _kMoni_var._position_relative),&x, &y, &z); } } else { mccoordschange(_kMoni_var._position_relative, _kMoni_var._rotation_relative, _particle); } } if (!ABSORBED && _particle->_index == 63) { _particle->flag_nocoordschange=0; /* Reset if we came here from a JUMP */ _particle_save = *_particle; DEBUG_COMP(_kMoni_var._name); DEBUG_STATE(); if ((( ! _instrument_var._parameters.VIRTUALOUT ))) // conditional WHEN execution class_PSD_monitor_psf_eff_trace(&_kMoni_var, _particle); if (_particle->_restore) particle_restore(_particle, &_particle_save); _particle->_index++; if (!ABSORBED) { DEBUG_STATE(); } } /* end component kMoni [63] */ /* begin component kMoni1st=PSD_monitor_psf_eff() [64] */ if (!_particle->flag_nocoordschange) { // flag activated by JUMP to pass coords change if (_kMoni1st_var._rotation_is_identity) { if(!_kMoni1st_var._position_relative_is_zero) { coords_get(coords_add(coords_set(x,y,z), _kMoni1st_var._position_relative),&x, &y, &z); } } else { mccoordschange(_kMoni1st_var._position_relative, _kMoni1st_var._rotation_relative, _particle); } } if (!ABSORBED && _particle->_index == 64) { _particle->flag_nocoordschange=0; /* Reset if we came here from a JUMP */ _particle_save = *_particle; DEBUG_COMP(_kMoni1st_var._name); DEBUG_STATE(); if ((( Mono_order == 1 && ! _instrument_var._parameters.VIRTUALOUT ))) // conditional WHEN execution class_PSD_monitor_psf_eff_trace(&_kMoni1st_var, _particle); if (_particle->_restore) particle_restore(_particle, &_particle_save); _particle->_index++; if (!ABSORBED) { DEBUG_STATE(); } } /* end component kMoni1st [64] */ /* begin component kMoni2nd=PSD_monitor_psf_eff() [65] */ if (!_particle->flag_nocoordschange) { // flag activated by JUMP to pass coords change if (_kMoni2nd_var._rotation_is_identity) { if(!_kMoni2nd_var._position_relative_is_zero) { coords_get(coords_add(coords_set(x,y,z), _kMoni2nd_var._position_relative),&x, &y, &z); } } else { mccoordschange(_kMoni2nd_var._position_relative, _kMoni2nd_var._rotation_relative, _particle); } } if (!ABSORBED && _particle->_index == 65) { _particle->flag_nocoordschange=0; /* Reset if we came here from a JUMP */ _particle_save = *_particle; DEBUG_COMP(_kMoni2nd_var._name); DEBUG_STATE(); if ((( Mono_order == 2 && ! _instrument_var._parameters.VIRTUALOUT ))) // conditional WHEN execution class_PSD_monitor_psf_eff_trace(&_kMoni2nd_var, _particle); if (_particle->_restore) particle_restore(_particle, &_particle_save); _particle->_index++; if (!ABSORBED) { DEBUG_STATE(); } } /* end component kMoni2nd [65] */ /* begin component kMoni3rd=PSD_monitor_psf_eff() [66] */ if (!_particle->flag_nocoordschange) { // flag activated by JUMP to pass coords change if (_kMoni3rd_var._rotation_is_identity) { if(!_kMoni3rd_var._position_relative_is_zero) { coords_get(coords_add(coords_set(x,y,z), _kMoni3rd_var._position_relative),&x, &y, &z); } } else { mccoordschange(_kMoni3rd_var._position_relative, _kMoni3rd_var._rotation_relative, _particle); } } if (!ABSORBED && _particle->_index == 66) { _particle->flag_nocoordschange=0; /* Reset if we came here from a JUMP */ _particle_save = *_particle; DEBUG_COMP(_kMoni3rd_var._name); DEBUG_STATE(); if ((( Mono_order == 3 && ! _instrument_var._parameters.VIRTUALOUT ))) // conditional WHEN execution class_PSD_monitor_psf_eff_trace(&_kMoni3rd_var, _particle); if (_particle->_restore) particle_restore(_particle, &_particle_save); _particle->_index++; if (!ABSORBED) { DEBUG_STATE(); } } /* end component kMoni3rd [66] */ /* begin component slitMonochromator=Slit() [67] */ if (!_particle->flag_nocoordschange) { // flag activated by JUMP to pass coords change if (_slitMonochromator_var._rotation_is_identity) { if(!_slitMonochromator_var._position_relative_is_zero) { coords_get(coords_add(coords_set(x,y,z), _slitMonochromator_var._position_relative),&x, &y, &z); } } else { mccoordschange(_slitMonochromator_var._position_relative, _slitMonochromator_var._rotation_relative, _particle); } } if (!ABSORBED && _particle->_index == 67) { _particle->flag_nocoordschange=0; /* Reset if we came here from a JUMP */ _particle_save = *_particle; DEBUG_COMP(_slitMonochromator_var._name); DEBUG_STATE(); if ((( ! _instrument_var._parameters.VIRTUALOUT ))) // conditional WHEN execution class_Slit_trace(&_slitMonochromator_var, _particle); if (_particle->_restore) particle_restore(_particle, &_particle_save); _particle->_index++; if (!ABSORBED) { DEBUG_STATE(); } } /* end component slitMonochromator [67] */ /* begin component Perspex=Incoherent() [68] */ if (!_particle->flag_nocoordschange) { // flag activated by JUMP to pass coords change if (_Perspex_var._rotation_is_identity) { if(!_Perspex_var._position_relative_is_zero) { coords_get(coords_add(coords_set(x,y,z), _Perspex_var._position_relative),&x, &y, &z); } } else { mccoordschange(_Perspex_var._position_relative, _Perspex_var._rotation_relative, _particle); } } if (!ABSORBED && _particle->_index == 68) { _particle->flag_nocoordschange=0; /* Reset if we came here from a JUMP */ _particle_save = *_particle; DEBUG_COMP(_Perspex_var._name); DEBUG_STATE(); if ((( _instrument_var._parameters.PERSPEX > 0 && ! _instrument_var._parameters.VIRTUALOUT ))) // conditional WHEN execution class_Incoherent_trace(&_Perspex_var, _particle); if (_particle->_restore) particle_restore(_particle, &_particle_save); _particle->_index++; if (!ABSORBED) { DEBUG_STATE(); } } /* end component Perspex [68] */ /* begin component psd_samplepos_1cm2=PSD_monitor() [69] */ if (!_particle->flag_nocoordschange) { // flag activated by JUMP to pass coords change if (_psd_samplepos_1cm2_var._rotation_is_identity) { if(!_psd_samplepos_1cm2_var._position_relative_is_zero) { coords_get(coords_add(coords_set(x,y,z), _psd_samplepos_1cm2_var._position_relative),&x, &y, &z); } } else { mccoordschange(_psd_samplepos_1cm2_var._position_relative, _psd_samplepos_1cm2_var._rotation_relative, _particle); } } if (!ABSORBED && _particle->_index == 69) { _particle->flag_nocoordschange=0; /* Reset if we came here from a JUMP */ _particle_save = *_particle; DEBUG_COMP(_psd_samplepos_1cm2_var._name); DEBUG_STATE(); if ((( ! _instrument_var._parameters.VIRTUALOUT ))) // conditional WHEN execution class_PSD_monitor_trace(&_psd_samplepos_1cm2_var, _particle); if (_particle->_restore) particle_restore(_particle, &_particle_save); _particle->_index++; if (!ABSORBED) { DEBUG_STATE(); } } /* end component psd_samplepos_1cm2 [69] */ /* begin component emon_samplepos_1cm2=E_monitor() [70] */ if (!_particle->flag_nocoordschange) { // flag activated by JUMP to pass coords change if (_emon_samplepos_1cm2_var._rotation_is_identity) { if(!_emon_samplepos_1cm2_var._position_relative_is_zero) { coords_get(coords_add(coords_set(x,y,z), _emon_samplepos_1cm2_var._position_relative),&x, &y, &z); } } else { mccoordschange(_emon_samplepos_1cm2_var._position_relative, _emon_samplepos_1cm2_var._rotation_relative, _particle); } } if (!ABSORBED && _particle->_index == 70) { _particle->flag_nocoordschange=0; /* Reset if we came here from a JUMP */ _particle_save = *_particle; DEBUG_COMP(_emon_samplepos_1cm2_var._name); DEBUG_STATE(); if ((( ! _instrument_var._parameters.VIRTUALOUT ))) // conditional WHEN execution class_E_monitor_trace(&_emon_samplepos_1cm2_var, _particle); if (_particle->_restore) particle_restore(_particle, &_particle_save); _particle->_index++; if (!ABSORBED) { DEBUG_STATE(); } } /* end component emon_samplepos_1cm2 [70] */ /* begin component divmon_samplepos_1cm2=Divergence_monitor() [71] */ if (!_particle->flag_nocoordschange) { // flag activated by JUMP to pass coords change if (_divmon_samplepos_1cm2_var._rotation_is_identity) { if(!_divmon_samplepos_1cm2_var._position_relative_is_zero) { coords_get(coords_add(coords_set(x,y,z), _divmon_samplepos_1cm2_var._position_relative),&x, &y, &z); } } else { mccoordschange(_divmon_samplepos_1cm2_var._position_relative, _divmon_samplepos_1cm2_var._rotation_relative, _particle); } } if (!ABSORBED && _particle->_index == 71) { _particle->flag_nocoordschange=0; /* Reset if we came here from a JUMP */ _particle_save = *_particle; DEBUG_COMP(_divmon_samplepos_1cm2_var._name); DEBUG_STATE(); if ((( ! _instrument_var._parameters.VIRTUALOUT ))) // conditional WHEN execution class_Divergence_monitor_trace(&_divmon_samplepos_1cm2_var, _particle); if (_particle->_restore) particle_restore(_particle, &_particle_save); _particle->_index++; if (!ABSORBED) { DEBUG_STATE(); } } /* end component divmon_samplepos_1cm2 [71] */ /* begin component psd_samplepos_large=PSD_monitor() [72] */ if (!_particle->flag_nocoordschange) { // flag activated by JUMP to pass coords change if (_psd_samplepos_large_var._rotation_is_identity) { if(!_psd_samplepos_large_var._position_relative_is_zero) { coords_get(coords_add(coords_set(x,y,z), _psd_samplepos_large_var._position_relative),&x, &y, &z); } } else { mccoordschange(_psd_samplepos_large_var._position_relative, _psd_samplepos_large_var._rotation_relative, _particle); } } if (!ABSORBED && _particle->_index == 72) { _particle->flag_nocoordschange=0; /* Reset if we came here from a JUMP */ _particle_save = *_particle; DEBUG_COMP(_psd_samplepos_large_var._name); DEBUG_STATE(); if ((( ! _instrument_var._parameters.VIRTUALOUT ))) // conditional WHEN execution class_PSD_monitor_trace(&_psd_samplepos_large_var, _particle); if (_particle->_restore) particle_restore(_particle, &_particle_save); _particle->_index++; if (!ABSORBED) { DEBUG_STATE(); } } /* end component psd_samplepos_large [72] */ #ifndef NOSPLIT /* start SPLIT at a3 */ if (!ABSORBED) { _class_particle Split_a3_particle=*_particle; int Split_a3_counter; int SplitS_a3 = SPLITREP; #pragma acc loop independent for (Split_a3_counter = 0; Split_a3_counter< SplitS_a3; Split_a3_counter++) { randstate_t randbackup = *_particle->randstate; *_particle=Split_a3_particle; *_particle->randstate = randbackup; p /= SplitS_a3 > 0 ? SplitS_a3 : 1; #endif /* begin component a3=Arm() [73] */ if (!ABSORBED && _particle->_index == 73) { _particle->flag_nocoordschange=0; /* Reset if we came here from a JUMP */ _particle->_index++; } /* end component a3 [73] */ /* begin component aa3=Arm() [74] */ if (!ABSORBED && _particle->_index == 74) { _particle->flag_nocoordschange=0; /* Reset if we came here from a JUMP */ _particle->_index++; } /* end component aa3 [74] */ /* begin component incohSample=Incoherent() [75] */ if (!_particle->flag_nocoordschange) { // flag activated by JUMP to pass coords change if (_incohSample_var._rotation_is_identity) { if(!_incohSample_var._position_relative_is_zero) { coords_get(coords_add(coords_set(x,y,z), _incohSample_var._position_relative),&x, &y, &z); } } else { mccoordschange(_incohSample_var._position_relative, _incohSample_var._rotation_relative, _particle); } } if (!ABSORBED && _particle->_index == 75) { _particle->flag_nocoordschange=0; /* Reset if we came here from a JUMP */ _particle_save = *_particle; DEBUG_COMP(_incohSample_var._name); DEBUG_STATE(); if ((( _instrument_var._parameters.SAMPLE == 1 && ! _instrument_var._parameters.VIRTUALOUT ))) // conditional WHEN execution class_Incoherent_trace(&_incohSample_var, _particle); if (_particle->_restore) particle_restore(_particle, &_particle_save); _particle->_index++; if (!ABSORBED) { DEBUG_STATE(); } } /* end component incohSample [75] */ /* begin component powderSample=PowderN() [76] */ if (!_particle->flag_nocoordschange) { // flag activated by JUMP to pass coords change if (_powderSample_var._rotation_is_identity) { if(!_powderSample_var._position_relative_is_zero) { coords_get(coords_add(coords_set(x,y,z), _powderSample_var._position_relative),&x, &y, &z); } } else { mccoordschange(_powderSample_var._position_relative, _powderSample_var._rotation_relative, _particle); } } if (!ABSORBED && _particle->_index == 76) { _particle->flag_nocoordschange=0; /* Reset if we came here from a JUMP */ _particle_save = *_particle; DEBUG_COMP(_powderSample_var._name); DEBUG_STATE(); if ((( _instrument_var._parameters.SAMPLE == 2 && ! _instrument_var._parameters.VIRTUALOUT ))) // conditional WHEN execution class_PowderN_trace(&_powderSample_var, _particle); if (_particle->_restore) particle_restore(_particle, &_particle_save); _particle->_index++; if (!ABSORBED) { DEBUG_STATE(); } } /* end component powderSample [76] */ /* begin component crystalSample=Single_crystal() [77] */ if (!_particle->flag_nocoordschange) { // flag activated by JUMP to pass coords change if (_crystalSample_var._rotation_is_identity) { if(!_crystalSample_var._position_relative_is_zero) { coords_get(coords_add(coords_set(x,y,z), _crystalSample_var._position_relative),&x, &y, &z); } } else { mccoordschange(_crystalSample_var._position_relative, _crystalSample_var._rotation_relative, _particle); } } if (!ABSORBED && _particle->_index == 77) { _particle->flag_nocoordschange=0; /* Reset if we came here from a JUMP */ _particle_save = *_particle; DEBUG_COMP(_crystalSample_var._name); DEBUG_STATE(); if ((( _instrument_var._parameters.SAMPLE == 3 && ! _instrument_var._parameters.VIRTUALOUT ))) // conditional WHEN execution class_Single_crystal_trace(&_crystalSample_var, _particle); /* contains EXTEND code */ if (_particle->_restore) particle_restore(_particle, &_particle_save); _particle->_index++; if (!ABSORBED) { DEBUG_STATE(); } } /* end component crystalSample [77] */ /* begin component phononSample=Phonon_simple() [78] */ if (!_particle->flag_nocoordschange) { // flag activated by JUMP to pass coords change if (_phononSample_var._rotation_is_identity) { if(!_phononSample_var._position_relative_is_zero) { coords_get(coords_add(coords_set(x,y,z), _phononSample_var._position_relative),&x, &y, &z); } } else { mccoordschange(_phononSample_var._position_relative, _phononSample_var._rotation_relative, _particle); } } if (!ABSORBED && _particle->_index == 78) { _particle->flag_nocoordschange=0; /* Reset if we came here from a JUMP */ _particle_save = *_particle; DEBUG_COMP(_phononSample_var._name); DEBUG_STATE(); if ((( _instrument_var._parameters.SAMPLE == 4 && ! _instrument_var._parameters.VIRTUALOUT ))) // conditional WHEN execution class_Phonon_simple_trace(&_phononSample_var, _particle); if (_particle->_restore) particle_restore(_particle, &_particle_save); _particle->_index++; if (!ABSORBED) { DEBUG_STATE(); } } /* end component phononSample [78] */ /* begin component psd_4pi=PSD_monitor_4PI() [79] */ if (!_particle->flag_nocoordschange) { // flag activated by JUMP to pass coords change if (_psd_4pi_var._rotation_is_identity) { if(!_psd_4pi_var._position_relative_is_zero) { coords_get(coords_add(coords_set(x,y,z), _psd_4pi_var._position_relative),&x, &y, &z); } } else { mccoordschange(_psd_4pi_var._position_relative, _psd_4pi_var._rotation_relative, _particle); } } if (!ABSORBED && _particle->_index == 79) { _particle->flag_nocoordschange=0; /* Reset if we came here from a JUMP */ _particle_save = *_particle; DEBUG_COMP(_psd_4pi_var._name); DEBUG_STATE(); if ((( ! _instrument_var._parameters.VIRTUALOUT ))) // conditional WHEN execution class_PSD_monitor_4PI_trace(&_psd_4pi_var, _particle); if (_particle->_restore) particle_restore(_particle, &_particle_save); _particle->_index++; if (!ABSORBED) { DEBUG_STATE(); } } /* end component psd_4pi [79] */ /* begin component a4=Arm() [80] */ if (!ABSORBED && _particle->_index == 80) { _particle->flag_nocoordschange=0; /* Reset if we came here from a JUMP */ _particle->_index++; } /* end component a4 [80] */ /* begin component slitSample=Slit() [81] */ if (!_particle->flag_nocoordschange) { // flag activated by JUMP to pass coords change if (_slitSample_var._rotation_is_identity) { if(!_slitSample_var._position_relative_is_zero) { coords_get(coords_add(coords_set(x,y,z), _slitSample_var._position_relative),&x, &y, &z); } } else { mccoordschange(_slitSample_var._position_relative, _slitSample_var._rotation_relative, _particle); } } if (!ABSORBED && _particle->_index == 81) { _particle->flag_nocoordschange=0; /* Reset if we came here from a JUMP */ _particle_save = *_particle; DEBUG_COMP(_slitSample_var._name); DEBUG_STATE(); if ((( ! _instrument_var._parameters.VIRTUALOUT ))) // conditional WHEN execution class_Slit_trace(&_slitSample_var, _particle); if (_particle->_restore) particle_restore(_particle, &_particle_save); _particle->_index++; if (!ABSORBED) { DEBUG_STATE(); } } /* end component slitSample [81] */ /* begin component filter_coll=Exact_radial_coll() [82] */ if (!_particle->flag_nocoordschange) { // flag activated by JUMP to pass coords change if (_filter_coll_var._rotation_is_identity) { if(!_filter_coll_var._position_relative_is_zero) { coords_get(coords_add(coords_set(x,y,z), _filter_coll_var._position_relative),&x, &y, &z); } } else { mccoordschange(_filter_coll_var._position_relative, _filter_coll_var._rotation_relative, _particle); } } if (!ABSORBED && _particle->_index == 82) { _particle->flag_nocoordschange=0; /* Reset if we came here from a JUMP */ _particle_save = *_particle; DEBUG_COMP(_filter_coll_var._name); DEBUG_STATE(); if ((( _instrument_var._parameters.OUTFILTER > 0 && ! _instrument_var._parameters.VIRTUALOUT ))) // conditional WHEN execution class_Exact_radial_coll_trace(&_filter_coll_var, _particle); if (_particle->_restore) particle_restore(_particle, &_particle_save); _particle->_index++; if (!ABSORBED) { DEBUG_STATE(); } } /* end component filter_coll [82] */ /* begin component filter=Filter_gen() [83] */ if (!_particle->flag_nocoordschange) { // flag activated by JUMP to pass coords change if (_filter_var._rotation_is_identity) { if(!_filter_var._position_relative_is_zero) { coords_get(coords_add(coords_set(x,y,z), _filter_var._position_relative),&x, &y, &z); } } else { mccoordschange(_filter_var._position_relative, _filter_var._rotation_relative, _particle); } } if (!ABSORBED && _particle->_index == 83) { _particle->flag_nocoordschange=0; /* Reset if we came here from a JUMP */ _particle_save = *_particle; DEBUG_COMP(_filter_var._name); DEBUG_STATE(); if ((( _instrument_var._parameters.OUTFILTER > 0 && ! _instrument_var._parameters.VIRTUALOUT ))) // conditional WHEN execution class_Filter_gen_trace(&_filter_var, _particle); if (_particle->_restore) particle_restore(_particle, &_particle_save); _particle->_index++; if (!ABSORBED) { DEBUG_STATE(); } } /* end component filter [83] */ /* begin component ana_slit1=Slit() [84] */ if (!_particle->flag_nocoordschange) { // flag activated by JUMP to pass coords change if (_ana_slit1_var._rotation_is_identity) { if(!_ana_slit1_var._position_relative_is_zero) { coords_get(coords_add(coords_set(x,y,z), _ana_slit1_var._position_relative),&x, &y, &z); } } else { mccoordschange(_ana_slit1_var._position_relative, _ana_slit1_var._rotation_relative, _particle); } } if (!ABSORBED && _particle->_index == 84) { _particle->flag_nocoordschange=0; /* Reset if we came here from a JUMP */ _particle_save = *_particle; DEBUG_COMP(_ana_slit1_var._name); DEBUG_STATE(); if ((( ! _instrument_var._parameters.VIRTUALOUT ))) // conditional WHEN execution class_Slit_trace(&_ana_slit1_var, _particle); if (_particle->_restore) particle_restore(_particle, &_particle_save); _particle->_index++; if (!ABSORBED) { DEBUG_STATE(); } } /* end component ana_slit1 [84] */ /* begin component ana_slit2=Slit() [85] */ if (!_particle->flag_nocoordschange) { // flag activated by JUMP to pass coords change if (_ana_slit2_var._rotation_is_identity) { if(!_ana_slit2_var._position_relative_is_zero) { coords_get(coords_add(coords_set(x,y,z), _ana_slit2_var._position_relative),&x, &y, &z); } } else { mccoordschange(_ana_slit2_var._position_relative, _ana_slit2_var._rotation_relative, _particle); } } if (!ABSORBED && _particle->_index == 85) { _particle->flag_nocoordschange=0; /* Reset if we came here from a JUMP */ _particle_save = *_particle; DEBUG_COMP(_ana_slit2_var._name); DEBUG_STATE(); if ((( ! _instrument_var._parameters.VIRTUALOUT ))) // conditional WHEN execution class_Slit_trace(&_ana_slit2_var, _particle); if (_particle->_restore) particle_restore(_particle, &_particle_save); _particle->_index++; if (!ABSORBED) { DEBUG_STATE(); } } /* end component ana_slit2 [85] */ /* begin component emon_before_ana=E_monitor() [86] */ if (!_particle->flag_nocoordschange) { // flag activated by JUMP to pass coords change if (_emon_before_ana_var._rotation_is_identity) { if(!_emon_before_ana_var._position_relative_is_zero) { coords_get(coords_add(coords_set(x,y,z), _emon_before_ana_var._position_relative),&x, &y, &z); } } else { mccoordschange(_emon_before_ana_var._position_relative, _emon_before_ana_var._rotation_relative, _particle); } } if (!ABSORBED && _particle->_index == 86) { _particle->flag_nocoordschange=0; /* Reset if we came here from a JUMP */ _particle_save = *_particle; DEBUG_COMP(_emon_before_ana_var._name); DEBUG_STATE(); if ((( ! _instrument_var._parameters.VIRTUALOUT ))) // conditional WHEN execution class_E_monitor_trace(&_emon_before_ana_var, _particle); if (_particle->_restore) particle_restore(_particle, &_particle_save); _particle->_index++; if (!ABSORBED) { DEBUG_STATE(); } } /* end component emon_before_ana [86] */ /* begin component psd_before_ana=PSD_monitor() [87] */ if (!_particle->flag_nocoordschange) { // flag activated by JUMP to pass coords change if (_psd_before_ana_var._rotation_is_identity) { if(!_psd_before_ana_var._position_relative_is_zero) { coords_get(coords_add(coords_set(x,y,z), _psd_before_ana_var._position_relative),&x, &y, &z); } } else { mccoordschange(_psd_before_ana_var._position_relative, _psd_before_ana_var._rotation_relative, _particle); } } if (!ABSORBED && _particle->_index == 87) { _particle->flag_nocoordschange=0; /* Reset if we came here from a JUMP */ _particle_save = *_particle; DEBUG_COMP(_psd_before_ana_var._name); DEBUG_STATE(); if ((( ! _instrument_var._parameters.VIRTUALOUT ))) // conditional WHEN execution class_PSD_monitor_trace(&_psd_before_ana_var, _particle); if (_particle->_restore) particle_restore(_particle, &_particle_save); _particle->_index++; if (!ABSORBED) { DEBUG_STATE(); } } /* end component psd_before_ana [87] */ /* begin component divmon_before_ana=Divergence_monitor() [88] */ if (!_particle->flag_nocoordschange) { // flag activated by JUMP to pass coords change if (_divmon_before_ana_var._rotation_is_identity) { if(!_divmon_before_ana_var._position_relative_is_zero) { coords_get(coords_add(coords_set(x,y,z), _divmon_before_ana_var._position_relative),&x, &y, &z); } } else { mccoordschange(_divmon_before_ana_var._position_relative, _divmon_before_ana_var._rotation_relative, _particle); } } if (!ABSORBED && _particle->_index == 88) { _particle->flag_nocoordschange=0; /* Reset if we came here from a JUMP */ _particle_save = *_particle; DEBUG_COMP(_divmon_before_ana_var._name); DEBUG_STATE(); if ((( ! _instrument_var._parameters.VIRTUALOUT ))) // conditional WHEN execution class_Divergence_monitor_trace(&_divmon_before_ana_var, _particle); if (_particle->_restore) particle_restore(_particle, &_particle_save); _particle->_index++; if (!ABSORBED) { DEBUG_STATE(); } } /* end component divmon_before_ana [88] */ #ifndef NOSPLIT /* start SPLIT at focus_ana */ if (!ABSORBED) { _class_particle Split_focus_ana_particle=*_particle; int Split_focus_ana_counter; int SplitS_focus_ana = SPLITAREP; #pragma acc loop independent for (Split_focus_ana_counter = 0; Split_focus_ana_counter< SplitS_focus_ana; Split_focus_ana_counter++) { randstate_t randbackup = *_particle->randstate; *_particle=Split_focus_ana_particle; *_particle->randstate = randbackup; p /= SplitS_focus_ana > 0 ? SplitS_focus_ana : 1; #endif /* begin component focus_ana=Arm() [89] */ if (!_particle->flag_nocoordschange) { // flag activated by JUMP to pass coords change if (_focus_ana_var._rotation_is_identity) { if(!_focus_ana_var._position_relative_is_zero) { coords_get(coords_add(coords_set(x,y,z), _focus_ana_var._position_relative),&x, &y, &z); } } else { mccoordschange(_focus_ana_var._position_relative, _focus_ana_var._rotation_relative, _particle); } } if (!ABSORBED && _particle->_index == 89) { _particle->flag_nocoordschange=0; /* Reset if we came here from a JUMP */ _particle_save = *_particle; DEBUG_COMP(_focus_ana_var._name); DEBUG_STATE(); if ((( ! _instrument_var._parameters.VIRTUALOUT ))) // conditional WHEN execution class_Arm_trace(&_focus_ana_var, _particle); /* contains EXTEND code */ if (_particle->_restore) particle_restore(_particle, &_particle_save); _particle->_index++; if (!ABSORBED) { DEBUG_STATE(); } } /* end component focus_ana [89] */ /* begin component an1l=Monochromator_flat() [90] */ if (!_particle->flag_nocoordschange) { // flag activated by JUMP to pass coords change if (_an1l_var._rotation_is_identity) { if(!_an1l_var._position_relative_is_zero) { coords_get(coords_add(coords_set(x,y,z), _an1l_var._position_relative),&x, &y, &z); } } else { mccoordschange(_an1l_var._position_relative, _an1l_var._rotation_relative, _particle); } } if (!ABSORBED && _particle->_index == 90) { _particle->flag_nocoordschange=0; /* Reset if we came here from a JUMP */ _particle_save = *_particle; DEBUG_COMP(_an1l_var._name); DEBUG_STATE(); if ((( ! _instrument_var._parameters.VIRTUALOUT ))) // conditional WHEN execution class_Monochromator_flat_trace(&_an1l_var, _particle); /* contains EXTEND code */ if (_particle->_restore) particle_restore(_particle, &_particle_save); _particle->_index++; if (!ABSORBED) { DEBUG_STATE(); } } /* end component an1l [90] */ /* begin component an1u=Monochromator_flat() [91] */ if (!_particle->flag_nocoordschange) { // flag activated by JUMP to pass coords change if (_an1u_var._rotation_is_identity) { if(!_an1u_var._position_relative_is_zero) { coords_get(coords_add(coords_set(x,y,z), _an1u_var._position_relative),&x, &y, &z); } } else { mccoordschange(_an1u_var._position_relative, _an1u_var._rotation_relative, _particle); } } if (!ABSORBED && _particle->_index == 91) { _particle->flag_nocoordschange=0; /* Reset if we came here from a JUMP */ _particle_save = *_particle; DEBUG_COMP(_an1u_var._name); DEBUG_STATE(); if ((( ! _instrument_var._parameters.VIRTUALOUT ))) // conditional WHEN execution class_Monochromator_flat_trace(&_an1u_var, _particle); /* contains EXTEND code */ if (_particle->_restore) particle_restore(_particle, &_particle_save); _particle->_index++; if (!ABSORBED) { DEBUG_STATE(); } } /* end component an1u [91] */ /* begin component an2l=Monochromator_flat() [92] */ if (!_particle->flag_nocoordschange) { // flag activated by JUMP to pass coords change if (_an2l_var._rotation_is_identity) { if(!_an2l_var._position_relative_is_zero) { coords_get(coords_add(coords_set(x,y,z), _an2l_var._position_relative),&x, &y, &z); } } else { mccoordschange(_an2l_var._position_relative, _an2l_var._rotation_relative, _particle); } } if (!ABSORBED && _particle->_index == 92) { _particle->flag_nocoordschange=0; /* Reset if we came here from a JUMP */ _particle_save = *_particle; DEBUG_COMP(_an2l_var._name); DEBUG_STATE(); if ((( ! _instrument_var._parameters.VIRTUALOUT ))) // conditional WHEN execution class_Monochromator_flat_trace(&_an2l_var, _particle); /* contains EXTEND code */ if (_particle->_restore) particle_restore(_particle, &_particle_save); _particle->_index++; if (!ABSORBED) { DEBUG_STATE(); } } /* end component an2l [92] */ /* begin component an2u=Monochromator_flat() [93] */ if (!_particle->flag_nocoordschange) { // flag activated by JUMP to pass coords change if (_an2u_var._rotation_is_identity) { if(!_an2u_var._position_relative_is_zero) { coords_get(coords_add(coords_set(x,y,z), _an2u_var._position_relative),&x, &y, &z); } } else { mccoordschange(_an2u_var._position_relative, _an2u_var._rotation_relative, _particle); } } if (!ABSORBED && _particle->_index == 93) { _particle->flag_nocoordschange=0; /* Reset if we came here from a JUMP */ _particle_save = *_particle; DEBUG_COMP(_an2u_var._name); DEBUG_STATE(); if ((( ! _instrument_var._parameters.VIRTUALOUT ))) // conditional WHEN execution class_Monochromator_flat_trace(&_an2u_var, _particle); /* contains EXTEND code */ if (_particle->_restore) particle_restore(_particle, &_particle_save); _particle->_index++; if (!ABSORBED) { DEBUG_STATE(); } } /* end component an2u [93] */ /* begin component an3l=Monochromator_flat() [94] */ if (!_particle->flag_nocoordschange) { // flag activated by JUMP to pass coords change if (_an3l_var._rotation_is_identity) { if(!_an3l_var._position_relative_is_zero) { coords_get(coords_add(coords_set(x,y,z), _an3l_var._position_relative),&x, &y, &z); } } else { mccoordschange(_an3l_var._position_relative, _an3l_var._rotation_relative, _particle); } } if (!ABSORBED && _particle->_index == 94) { _particle->flag_nocoordschange=0; /* Reset if we came here from a JUMP */ _particle_save = *_particle; DEBUG_COMP(_an3l_var._name); DEBUG_STATE(); if ((( ! _instrument_var._parameters.VIRTUALOUT ))) // conditional WHEN execution class_Monochromator_flat_trace(&_an3l_var, _particle); /* contains EXTEND code */ if (_particle->_restore) particle_restore(_particle, &_particle_save); _particle->_index++; if (!ABSORBED) { DEBUG_STATE(); } } /* end component an3l [94] */ /* begin component an3u=Monochromator_flat() [95] */ if (!_particle->flag_nocoordschange) { // flag activated by JUMP to pass coords change if (_an3u_var._rotation_is_identity) { if(!_an3u_var._position_relative_is_zero) { coords_get(coords_add(coords_set(x,y,z), _an3u_var._position_relative),&x, &y, &z); } } else { mccoordschange(_an3u_var._position_relative, _an3u_var._rotation_relative, _particle); } } if (!ABSORBED && _particle->_index == 95) { _particle->flag_nocoordschange=0; /* Reset if we came here from a JUMP */ _particle_save = *_particle; DEBUG_COMP(_an3u_var._name); DEBUG_STATE(); if ((( ! _instrument_var._parameters.VIRTUALOUT ))) // conditional WHEN execution class_Monochromator_flat_trace(&_an3u_var, _particle); /* contains EXTEND code */ if (_particle->_restore) particle_restore(_particle, &_particle_save); _particle->_index++; if (!ABSORBED) { DEBUG_STATE(); } } /* end component an3u [95] */ /* begin component an4l=Monochromator_flat() [96] */ if (!_particle->flag_nocoordschange) { // flag activated by JUMP to pass coords change if (_an4l_var._rotation_is_identity) { if(!_an4l_var._position_relative_is_zero) { coords_get(coords_add(coords_set(x,y,z), _an4l_var._position_relative),&x, &y, &z); } } else { mccoordschange(_an4l_var._position_relative, _an4l_var._rotation_relative, _particle); } } if (!ABSORBED && _particle->_index == 96) { _particle->flag_nocoordschange=0; /* Reset if we came here from a JUMP */ _particle_save = *_particle; DEBUG_COMP(_an4l_var._name); DEBUG_STATE(); if ((( ! _instrument_var._parameters.VIRTUALOUT ))) // conditional WHEN execution class_Monochromator_flat_trace(&_an4l_var, _particle); /* contains EXTEND code */ if (_particle->_restore) particle_restore(_particle, &_particle_save); _particle->_index++; if (!ABSORBED) { DEBUG_STATE(); } } /* end component an4l [96] */ /* begin component an4u=Monochromator_flat() [97] */ if (!_particle->flag_nocoordschange) { // flag activated by JUMP to pass coords change if (_an4u_var._rotation_is_identity) { if(!_an4u_var._position_relative_is_zero) { coords_get(coords_add(coords_set(x,y,z), _an4u_var._position_relative),&x, &y, &z); } } else { mccoordschange(_an4u_var._position_relative, _an4u_var._rotation_relative, _particle); } } if (!ABSORBED && _particle->_index == 97) { _particle->flag_nocoordschange=0; /* Reset if we came here from a JUMP */ _particle_save = *_particle; DEBUG_COMP(_an4u_var._name); DEBUG_STATE(); if ((( ! _instrument_var._parameters.VIRTUALOUT ))) // conditional WHEN execution class_Monochromator_flat_trace(&_an4u_var, _particle); /* contains EXTEND code */ if (_particle->_restore) particle_restore(_particle, &_particle_save); _particle->_index++; if (!ABSORBED) { DEBUG_STATE(); } } /* end component an4u [97] */ /* begin component an5l=Monochromator_flat() [98] */ if (!_particle->flag_nocoordschange) { // flag activated by JUMP to pass coords change if (_an5l_var._rotation_is_identity) { if(!_an5l_var._position_relative_is_zero) { coords_get(coords_add(coords_set(x,y,z), _an5l_var._position_relative),&x, &y, &z); } } else { mccoordschange(_an5l_var._position_relative, _an5l_var._rotation_relative, _particle); } } if (!ABSORBED && _particle->_index == 98) { _particle->flag_nocoordschange=0; /* Reset if we came here from a JUMP */ _particle_save = *_particle; DEBUG_COMP(_an5l_var._name); DEBUG_STATE(); if ((( ! _instrument_var._parameters.VIRTUALOUT ))) // conditional WHEN execution class_Monochromator_flat_trace(&_an5l_var, _particle); /* contains EXTEND code */ if (_particle->_restore) particle_restore(_particle, &_particle_save); _particle->_index++; if (!ABSORBED) { DEBUG_STATE(); } } /* end component an5l [98] */ /* begin component an5u=Monochromator_flat() [99] */ if (!_particle->flag_nocoordschange) { // flag activated by JUMP to pass coords change if (_an5u_var._rotation_is_identity) { if(!_an5u_var._position_relative_is_zero) { coords_get(coords_add(coords_set(x,y,z), _an5u_var._position_relative),&x, &y, &z); } } else { mccoordschange(_an5u_var._position_relative, _an5u_var._rotation_relative, _particle); } } if (!ABSORBED && _particle->_index == 99) { _particle->flag_nocoordschange=0; /* Reset if we came here from a JUMP */ _particle_save = *_particle; DEBUG_COMP(_an5u_var._name); DEBUG_STATE(); if ((( ! _instrument_var._parameters.VIRTUALOUT ))) // conditional WHEN execution class_Monochromator_flat_trace(&_an5u_var, _particle); /* contains EXTEND code */ if (_particle->_restore) particle_restore(_particle, &_particle_save); _particle->_index++; if (!ABSORBED) { DEBUG_STATE(); } } /* end component an5u [99] */ /* begin component an6l=Monochromator_flat() [100] */ if (!_particle->flag_nocoordschange) { // flag activated by JUMP to pass coords change if (_an6l_var._rotation_is_identity) { if(!_an6l_var._position_relative_is_zero) { coords_get(coords_add(coords_set(x,y,z), _an6l_var._position_relative),&x, &y, &z); } } else { mccoordschange(_an6l_var._position_relative, _an6l_var._rotation_relative, _particle); } } if (!ABSORBED && _particle->_index == 100) { _particle->flag_nocoordschange=0; /* Reset if we came here from a JUMP */ _particle_save = *_particle; DEBUG_COMP(_an6l_var._name); DEBUG_STATE(); if ((( ! _instrument_var._parameters.VIRTUALOUT ))) // conditional WHEN execution class_Monochromator_flat_trace(&_an6l_var, _particle); /* contains EXTEND code */ if (_particle->_restore) particle_restore(_particle, &_particle_save); _particle->_index++; if (!ABSORBED) { DEBUG_STATE(); } } /* end component an6l [100] */ /* begin component an6u=Monochromator_flat() [101] */ if (!_particle->flag_nocoordschange) { // flag activated by JUMP to pass coords change if (_an6u_var._rotation_is_identity) { if(!_an6u_var._position_relative_is_zero) { coords_get(coords_add(coords_set(x,y,z), _an6u_var._position_relative),&x, &y, &z); } } else { mccoordschange(_an6u_var._position_relative, _an6u_var._rotation_relative, _particle); } } if (!ABSORBED && _particle->_index == 101) { _particle->flag_nocoordschange=0; /* Reset if we came here from a JUMP */ _particle_save = *_particle; DEBUG_COMP(_an6u_var._name); DEBUG_STATE(); if ((( ! _instrument_var._parameters.VIRTUALOUT ))) // conditional WHEN execution class_Monochromator_flat_trace(&_an6u_var, _particle); /* contains EXTEND code */ if (_particle->_restore) particle_restore(_particle, &_particle_save); _particle->_index++; if (!ABSORBED) { DEBUG_STATE(); } } /* end component an6u [101] */ /* begin component an7l=Monochromator_flat() [102] */ if (!_particle->flag_nocoordschange) { // flag activated by JUMP to pass coords change if (_an7l_var._rotation_is_identity) { if(!_an7l_var._position_relative_is_zero) { coords_get(coords_add(coords_set(x,y,z), _an7l_var._position_relative),&x, &y, &z); } } else { mccoordschange(_an7l_var._position_relative, _an7l_var._rotation_relative, _particle); } } if (!ABSORBED && _particle->_index == 102) { _particle->flag_nocoordschange=0; /* Reset if we came here from a JUMP */ _particle_save = *_particle; DEBUG_COMP(_an7l_var._name); DEBUG_STATE(); if ((( ! _instrument_var._parameters.VIRTUALOUT ))) // conditional WHEN execution class_Monochromator_flat_trace(&_an7l_var, _particle); /* contains EXTEND code */ if (_particle->_restore) particle_restore(_particle, &_particle_save); _particle->_index++; if (!ABSORBED) { DEBUG_STATE(); } } /* end component an7l [102] */ /* begin component an7u=Monochromator_flat() [103] */ if (!_particle->flag_nocoordschange) { // flag activated by JUMP to pass coords change if (_an7u_var._rotation_is_identity) { if(!_an7u_var._position_relative_is_zero) { coords_get(coords_add(coords_set(x,y,z), _an7u_var._position_relative),&x, &y, &z); } } else { mccoordschange(_an7u_var._position_relative, _an7u_var._rotation_relative, _particle); } } if (!ABSORBED && _particle->_index == 103) { _particle->flag_nocoordschange=0; /* Reset if we came here from a JUMP */ _particle_save = *_particle; DEBUG_COMP(_an7u_var._name); DEBUG_STATE(); if ((( ! _instrument_var._parameters.VIRTUALOUT ))) // conditional WHEN execution class_Monochromator_flat_trace(&_an7u_var, _particle); /* contains EXTEND code */ if (_particle->_restore) particle_restore(_particle, &_particle_save); _particle->_index++; if (!ABSORBED) { DEBUG_STATE(); } } /* end component an7u [103] */ /* begin component an8l=Monochromator_flat() [104] */ if (!_particle->flag_nocoordschange) { // flag activated by JUMP to pass coords change if (_an8l_var._rotation_is_identity) { if(!_an8l_var._position_relative_is_zero) { coords_get(coords_add(coords_set(x,y,z), _an8l_var._position_relative),&x, &y, &z); } } else { mccoordschange(_an8l_var._position_relative, _an8l_var._rotation_relative, _particle); } } if (!ABSORBED && _particle->_index == 104) { _particle->flag_nocoordschange=0; /* Reset if we came here from a JUMP */ _particle_save = *_particle; DEBUG_COMP(_an8l_var._name); DEBUG_STATE(); if ((( ! _instrument_var._parameters.VIRTUALOUT ))) // conditional WHEN execution class_Monochromator_flat_trace(&_an8l_var, _particle); /* contains EXTEND code */ if (_particle->_restore) particle_restore(_particle, &_particle_save); _particle->_index++; if (!ABSORBED) { DEBUG_STATE(); } } /* end component an8l [104] */ /* begin component an8u=Monochromator_flat() [105] */ if (!_particle->flag_nocoordschange) { // flag activated by JUMP to pass coords change if (_an8u_var._rotation_is_identity) { if(!_an8u_var._position_relative_is_zero) { coords_get(coords_add(coords_set(x,y,z), _an8u_var._position_relative),&x, &y, &z); } } else { mccoordschange(_an8u_var._position_relative, _an8u_var._rotation_relative, _particle); } } if (!ABSORBED && _particle->_index == 105) { _particle->flag_nocoordschange=0; /* Reset if we came here from a JUMP */ _particle_save = *_particle; DEBUG_COMP(_an8u_var._name); DEBUG_STATE(); if ((( ! _instrument_var._parameters.VIRTUALOUT ))) // conditional WHEN execution class_Monochromator_flat_trace(&_an8u_var, _particle); /* contains EXTEND code */ if (_particle->_restore) particle_restore(_particle, &_particle_save); _particle->_index++; if (!ABSORBED) { DEBUG_STATE(); } } /* end component an8u [105] */ /* begin component an9l=Monochromator_flat() [106] */ if (!_particle->flag_nocoordschange) { // flag activated by JUMP to pass coords change if (_an9l_var._rotation_is_identity) { if(!_an9l_var._position_relative_is_zero) { coords_get(coords_add(coords_set(x,y,z), _an9l_var._position_relative),&x, &y, &z); } } else { mccoordschange(_an9l_var._position_relative, _an9l_var._rotation_relative, _particle); } } if (!ABSORBED && _particle->_index == 106) { _particle->flag_nocoordschange=0; /* Reset if we came here from a JUMP */ _particle_save = *_particle; DEBUG_COMP(_an9l_var._name); DEBUG_STATE(); if ((( ! _instrument_var._parameters.VIRTUALOUT ))) // conditional WHEN execution class_Monochromator_flat_trace(&_an9l_var, _particle); /* contains EXTEND code */ if (_particle->_restore) particle_restore(_particle, &_particle_save); _particle->_index++; if (!ABSORBED) { DEBUG_STATE(); } } /* end component an9l [106] */ /* begin component an9u=Monochromator_flat() [107] */ if (!_particle->flag_nocoordschange) { // flag activated by JUMP to pass coords change if (_an9u_var._rotation_is_identity) { if(!_an9u_var._position_relative_is_zero) { coords_get(coords_add(coords_set(x,y,z), _an9u_var._position_relative),&x, &y, &z); } } else { mccoordschange(_an9u_var._position_relative, _an9u_var._rotation_relative, _particle); } } if (!ABSORBED && _particle->_index == 107) { _particle->flag_nocoordschange=0; /* Reset if we came here from a JUMP */ _particle_save = *_particle; DEBUG_COMP(_an9u_var._name); DEBUG_STATE(); if ((( ! _instrument_var._parameters.VIRTUALOUT ))) // conditional WHEN execution class_Monochromator_flat_trace(&_an9u_var, _particle); /* contains EXTEND code */ if (_particle->_restore) particle_restore(_particle, &_particle_save); _particle->_index++; if (!ABSORBED) { DEBUG_STATE(); } } /* end component an9u [107] */ /* begin component a6=Arm() [108] */ if (!ABSORBED && _particle->_index == 108) { _particle->flag_nocoordschange=0; /* Reset if we came here from a JUMP */ _particle->_index++; } /* end component a6 [108] */ /* begin component emon_before_coarse=E_monitor() [109] */ if (!_particle->flag_nocoordschange) { // flag activated by JUMP to pass coords change if (_emon_before_coarse_var._rotation_is_identity) { if(!_emon_before_coarse_var._position_relative_is_zero) { coords_get(coords_add(coords_set(x,y,z), _emon_before_coarse_var._position_relative),&x, &y, &z); } } else { mccoordschange(_emon_before_coarse_var._position_relative, _emon_before_coarse_var._rotation_relative, _particle); } } if (!ABSORBED && _particle->_index == 109) { _particle->flag_nocoordschange=0; /* Reset if we came here from a JUMP */ _particle_save = *_particle; DEBUG_COMP(_emon_before_coarse_var._name); DEBUG_STATE(); if ((( ! _instrument_var._parameters.VIRTUALOUT ))) // conditional WHEN execution class_E_monitor_trace(&_emon_before_coarse_var, _particle); if (_particle->_restore) particle_restore(_particle, &_particle_save); _particle->_index++; if (!ABSORBED) { DEBUG_STATE(); } } /* end component emon_before_coarse [109] */ /* begin component psd_before_coarse=PSD_monitor() [110] */ if (!_particle->flag_nocoordschange) { // flag activated by JUMP to pass coords change if (_psd_before_coarse_var._rotation_is_identity) { if(!_psd_before_coarse_var._position_relative_is_zero) { coords_get(coords_add(coords_set(x,y,z), _psd_before_coarse_var._position_relative),&x, &y, &z); } } else { mccoordschange(_psd_before_coarse_var._position_relative, _psd_before_coarse_var._rotation_relative, _particle); } } if (!ABSORBED && _particle->_index == 110) { _particle->flag_nocoordschange=0; /* Reset if we came here from a JUMP */ _particle_save = *_particle; DEBUG_COMP(_psd_before_coarse_var._name); DEBUG_STATE(); if ((( ! _instrument_var._parameters.VIRTUALOUT ))) // conditional WHEN execution class_PSD_monitor_trace(&_psd_before_coarse_var, _particle); if (_particle->_restore) particle_restore(_particle, &_particle_save); _particle->_index++; if (!ABSORBED) { DEBUG_STATE(); } } /* end component psd_before_coarse [110] */ /* begin component ArmR1=Arm() [111] */ if (!ABSORBED && _particle->_index == 111) { _particle->flag_nocoordschange=0; /* Reset if we came here from a JUMP */ _particle->_index++; } /* end component ArmR1 [111] */ /* begin component BladeR1=Absorber() [112] */ if (!_particle->flag_nocoordschange) { // flag activated by JUMP to pass coords change if (_BladeR1_var._rotation_is_identity) { if(!_BladeR1_var._position_relative_is_zero) { coords_get(coords_add(coords_set(x,y,z), _BladeR1_var._position_relative),&x, &y, &z); } } else { mccoordschange(_BladeR1_var._position_relative, _BladeR1_var._rotation_relative, _particle); } } if (!ABSORBED && _particle->_index == 112) { _particle->flag_nocoordschange=0; /* Reset if we came here from a JUMP */ _particle_save = *_particle; DEBUG_COMP(_BladeR1_var._name); DEBUG_STATE(); if ((( _instrument_var._parameters.COARSE > 0 && ! _instrument_var._parameters.VIRTUALOUT ))) // conditional WHEN execution class_Absorber_trace(&_BladeR1_var, _particle); /* contains EXTEND code */ if (_particle->_restore) particle_restore(_particle, &_particle_save); _particle->_index++; if (!ABSORBED) { DEBUG_STATE(); } } /* end component BladeR1 [112] */ /* begin component ArmR2=Arm() [113] */ if (!ABSORBED && _particle->_index == 113) { _particle->flag_nocoordschange=0; /* Reset if we came here from a JUMP */ _particle->_index++; } /* end component ArmR2 [113] */ /* begin component BladeR2=Absorber() [114] */ if (!_particle->flag_nocoordschange) { // flag activated by JUMP to pass coords change if (_BladeR2_var._rotation_is_identity) { if(!_BladeR2_var._position_relative_is_zero) { coords_get(coords_add(coords_set(x,y,z), _BladeR2_var._position_relative),&x, &y, &z); } } else { mccoordschange(_BladeR2_var._position_relative, _BladeR2_var._rotation_relative, _particle); } } if (!ABSORBED && _particle->_index == 114) { _particle->flag_nocoordschange=0; /* Reset if we came here from a JUMP */ _particle_save = *_particle; DEBUG_COMP(_BladeR2_var._name); DEBUG_STATE(); if ((( _instrument_var._parameters.COARSE > 0 && ! _instrument_var._parameters.VIRTUALOUT ))) // conditional WHEN execution class_Absorber_trace(&_BladeR2_var, _particle); if (_particle->_restore) particle_restore(_particle, &_particle_save); _particle->_index++; if (!ABSORBED) { DEBUG_STATE(); } } /* end component BladeR2 [114] */ /* begin component ArmR3=Arm() [115] */ if (!ABSORBED && _particle->_index == 115) { _particle->flag_nocoordschange=0; /* Reset if we came here from a JUMP */ _particle->_index++; } /* end component ArmR3 [115] */ /* begin component BladeR3=Absorber() [116] */ if (!_particle->flag_nocoordschange) { // flag activated by JUMP to pass coords change if (_BladeR3_var._rotation_is_identity) { if(!_BladeR3_var._position_relative_is_zero) { coords_get(coords_add(coords_set(x,y,z), _BladeR3_var._position_relative),&x, &y, &z); } } else { mccoordschange(_BladeR3_var._position_relative, _BladeR3_var._rotation_relative, _particle); } } if (!ABSORBED && _particle->_index == 116) { _particle->flag_nocoordschange=0; /* Reset if we came here from a JUMP */ _particle_save = *_particle; DEBUG_COMP(_BladeR3_var._name); DEBUG_STATE(); if ((( _instrument_var._parameters.COARSE > 0 ))) // conditional WHEN execution class_Absorber_trace(&_BladeR3_var, _particle); if (_particle->_restore) particle_restore(_particle, &_particle_save); _particle->_index++; if (!ABSORBED) { DEBUG_STATE(); } } /* end component BladeR3 [116] */ /* begin component ArmR4=Arm() [117] */ if (!ABSORBED && _particle->_index == 117) { _particle->flag_nocoordschange=0; /* Reset if we came here from a JUMP */ _particle->_index++; } /* end component ArmR4 [117] */ /* begin component BladeR4=Absorber() [118] */ if (!_particle->flag_nocoordschange) { // flag activated by JUMP to pass coords change if (_BladeR4_var._rotation_is_identity) { if(!_BladeR4_var._position_relative_is_zero) { coords_get(coords_add(coords_set(x,y,z), _BladeR4_var._position_relative),&x, &y, &z); } } else { mccoordschange(_BladeR4_var._position_relative, _BladeR4_var._rotation_relative, _particle); } } if (!ABSORBED && _particle->_index == 118) { _particle->flag_nocoordschange=0; /* Reset if we came here from a JUMP */ _particle_save = *_particle; DEBUG_COMP(_BladeR4_var._name); DEBUG_STATE(); if ((( _instrument_var._parameters.COARSE > 0 ))) // conditional WHEN execution class_Absorber_trace(&_BladeR4_var, _particle); if (_particle->_restore) particle_restore(_particle, &_particle_save); _particle->_index++; if (!ABSORBED) { DEBUG_STATE(); } } /* end component BladeR4 [118] */ /* begin component ArmR5=Arm() [119] */ if (!ABSORBED && _particle->_index == 119) { _particle->flag_nocoordschange=0; /* Reset if we came here from a JUMP */ _particle->_index++; } /* end component ArmR5 [119] */ /* begin component BladeR5=Absorber() [120] */ if (!_particle->flag_nocoordschange) { // flag activated by JUMP to pass coords change if (_BladeR5_var._rotation_is_identity) { if(!_BladeR5_var._position_relative_is_zero) { coords_get(coords_add(coords_set(x,y,z), _BladeR5_var._position_relative),&x, &y, &z); } } else { mccoordschange(_BladeR5_var._position_relative, _BladeR5_var._rotation_relative, _particle); } } if (!ABSORBED && _particle->_index == 120) { _particle->flag_nocoordschange=0; /* Reset if we came here from a JUMP */ _particle_save = *_particle; DEBUG_COMP(_BladeR5_var._name); DEBUG_STATE(); if ((( _instrument_var._parameters.COARSE > 0 ))) // conditional WHEN execution class_Absorber_trace(&_BladeR5_var, _particle); if (_particle->_restore) particle_restore(_particle, &_particle_save); _particle->_index++; if (!ABSORBED) { DEBUG_STATE(); } } /* end component BladeR5 [120] */ /* begin component ArmL1=Arm() [121] */ if (!ABSORBED && _particle->_index == 121) { _particle->flag_nocoordschange=0; /* Reset if we came here from a JUMP */ _particle->_index++; } /* end component ArmL1 [121] */ /* begin component BladeL1=Absorber() [122] */ if (!_particle->flag_nocoordschange) { // flag activated by JUMP to pass coords change if (_BladeL1_var._rotation_is_identity) { if(!_BladeL1_var._position_relative_is_zero) { coords_get(coords_add(coords_set(x,y,z), _BladeL1_var._position_relative),&x, &y, &z); } } else { mccoordschange(_BladeL1_var._position_relative, _BladeL1_var._rotation_relative, _particle); } } if (!ABSORBED && _particle->_index == 122) { _particle->flag_nocoordschange=0; /* Reset if we came here from a JUMP */ _particle_save = *_particle; DEBUG_COMP(_BladeL1_var._name); DEBUG_STATE(); if ((( _instrument_var._parameters.COARSE > 0 && ! _instrument_var._parameters.VIRTUALOUT ))) // conditional WHEN execution class_Absorber_trace(&_BladeL1_var, _particle); if (_particle->_restore) particle_restore(_particle, &_particle_save); _particle->_index++; if (!ABSORBED) { DEBUG_STATE(); } } /* end component BladeL1 [122] */ /* begin component ArmL2=Arm() [123] */ if (!ABSORBED && _particle->_index == 123) { _particle->flag_nocoordschange=0; /* Reset if we came here from a JUMP */ _particle->_index++; } /* end component ArmL2 [123] */ /* begin component BladeL2=Absorber() [124] */ if (!_particle->flag_nocoordschange) { // flag activated by JUMP to pass coords change if (_BladeL2_var._rotation_is_identity) { if(!_BladeL2_var._position_relative_is_zero) { coords_get(coords_add(coords_set(x,y,z), _BladeL2_var._position_relative),&x, &y, &z); } } else { mccoordschange(_BladeL2_var._position_relative, _BladeL2_var._rotation_relative, _particle); } } if (!ABSORBED && _particle->_index == 124) { _particle->flag_nocoordschange=0; /* Reset if we came here from a JUMP */ _particle_save = *_particle; DEBUG_COMP(_BladeL2_var._name); DEBUG_STATE(); if ((( _instrument_var._parameters.COARSE > 0 && ! _instrument_var._parameters.VIRTUALOUT ))) // conditional WHEN execution class_Absorber_trace(&_BladeL2_var, _particle); if (_particle->_restore) particle_restore(_particle, &_particle_save); _particle->_index++; if (!ABSORBED) { DEBUG_STATE(); } } /* end component BladeL2 [124] */ /* begin component ArmL3=Arm() [125] */ if (!ABSORBED && _particle->_index == 125) { _particle->flag_nocoordschange=0; /* Reset if we came here from a JUMP */ _particle->_index++; } /* end component ArmL3 [125] */ /* begin component BladeL3=Absorber() [126] */ if (!_particle->flag_nocoordschange) { // flag activated by JUMP to pass coords change if (_BladeL3_var._rotation_is_identity) { if(!_BladeL3_var._position_relative_is_zero) { coords_get(coords_add(coords_set(x,y,z), _BladeL3_var._position_relative),&x, &y, &z); } } else { mccoordschange(_BladeL3_var._position_relative, _BladeL3_var._rotation_relative, _particle); } } if (!ABSORBED && _particle->_index == 126) { _particle->flag_nocoordschange=0; /* Reset if we came here from a JUMP */ _particle_save = *_particle; DEBUG_COMP(_BladeL3_var._name); DEBUG_STATE(); if ((( _instrument_var._parameters.COARSE > 0 && ! _instrument_var._parameters.VIRTUALOUT ))) // conditional WHEN execution class_Absorber_trace(&_BladeL3_var, _particle); if (_particle->_restore) particle_restore(_particle, &_particle_save); _particle->_index++; if (!ABSORBED) { DEBUG_STATE(); } } /* end component BladeL3 [126] */ /* begin component ArmL4=Arm() [127] */ if (!ABSORBED && _particle->_index == 127) { _particle->flag_nocoordschange=0; /* Reset if we came here from a JUMP */ _particle->_index++; } /* end component ArmL4 [127] */ /* begin component BladeL4=Absorber() [128] */ if (!_particle->flag_nocoordschange) { // flag activated by JUMP to pass coords change if (_BladeL4_var._rotation_is_identity) { if(!_BladeL4_var._position_relative_is_zero) { coords_get(coords_add(coords_set(x,y,z), _BladeL4_var._position_relative),&x, &y, &z); } } else { mccoordschange(_BladeL4_var._position_relative, _BladeL4_var._rotation_relative, _particle); } } if (!ABSORBED && _particle->_index == 128) { _particle->flag_nocoordschange=0; /* Reset if we came here from a JUMP */ _particle_save = *_particle; DEBUG_COMP(_BladeL4_var._name); DEBUG_STATE(); if ((( _instrument_var._parameters.COARSE > 0 && ! _instrument_var._parameters.VIRTUALOUT ))) // conditional WHEN execution class_Absorber_trace(&_BladeL4_var, _particle); if (_particle->_restore) particle_restore(_particle, &_particle_save); _particle->_index++; if (!ABSORBED) { DEBUG_STATE(); } } /* end component BladeL4 [128] */ /* begin component ArmL5=Arm() [129] */ if (!_particle->flag_nocoordschange) { // flag activated by JUMP to pass coords change if (_ArmL5_var._rotation_is_identity) { if(!_ArmL5_var._position_relative_is_zero) { coords_get(coords_add(coords_set(x,y,z), _ArmL5_var._position_relative),&x, &y, &z); } } else { mccoordschange(_ArmL5_var._position_relative, _ArmL5_var._rotation_relative, _particle); } } if (!ABSORBED && _particle->_index == 129) { _particle->flag_nocoordschange=0; /* Reset if we came here from a JUMP */ _particle_save = *_particle; DEBUG_COMP(_ArmL5_var._name); DEBUG_STATE(); if ((( ! _instrument_var._parameters.VIRTUALOUT ))) // conditional WHEN execution class_Arm_trace(&_ArmL5_var, _particle); /* contains EXTEND code */ if (_particle->_restore) particle_restore(_particle, &_particle_save); _particle->_index++; if (!ABSORBED) { DEBUG_STATE(); } } /* end component ArmL5 [129] */ /* begin component BladeL5=Absorber() [130] */ if (!_particle->flag_nocoordschange) { // flag activated by JUMP to pass coords change if (_BladeL5_var._rotation_is_identity) { if(!_BladeL5_var._position_relative_is_zero) { coords_get(coords_add(coords_set(x,y,z), _BladeL5_var._position_relative),&x, &y, &z); } } else { mccoordschange(_BladeL5_var._position_relative, _BladeL5_var._rotation_relative, _particle); } } if (!ABSORBED && _particle->_index == 130) { _particle->flag_nocoordschange=0; /* Reset if we came here from a JUMP */ _particle_save = *_particle; DEBUG_COMP(_BladeL5_var._name); DEBUG_STATE(); if ((( _instrument_var._parameters.COARSE > 0 && ! _instrument_var._parameters.VIRTUALOUT ))) // conditional WHEN execution class_Absorber_trace(&_BladeL5_var, _particle); if (_particle->_restore) particle_restore(_particle, &_particle_save); _particle->_index++; if (!ABSORBED) { DEBUG_STATE(); } } /* end component BladeL5 [130] */ /* begin component psd_detector=PSD_monitor_psf_eff() [131] */ if (!_particle->flag_nocoordschange) { // flag activated by JUMP to pass coords change if (_psd_detector_var._rotation_is_identity) { if(!_psd_detector_var._position_relative_is_zero) { coords_get(coords_add(coords_set(x,y,z), _psd_detector_var._position_relative),&x, &y, &z); } } else { mccoordschange(_psd_detector_var._position_relative, _psd_detector_var._rotation_relative, _particle); } } if (!ABSORBED && _particle->_index == 131) { _particle->flag_nocoordschange=0; /* Reset if we came here from a JUMP */ _particle_save = *_particle; DEBUG_COMP(_psd_detector_var._name); DEBUG_STATE(); if ((( ! _instrument_var._parameters.VIRTUALOUT ))) // conditional WHEN execution class_PSD_monitor_psf_eff_trace(&_psd_detector_var, _particle); /* contains EXTEND code */ if (_particle->_restore) particle_restore(_particle, &_particle_save); _particle->_index++; if (!ABSORBED) { DEBUG_STATE(); } } /* end component psd_detector [131] */ /* begin component emon_detector=E_monitor() [132] */ if (!_particle->flag_nocoordschange) { // flag activated by JUMP to pass coords change if (_emon_detector_var._rotation_is_identity) { if(!_emon_detector_var._position_relative_is_zero) { coords_get(coords_add(coords_set(x,y,z), _emon_detector_var._position_relative),&x, &y, &z); } } else { mccoordschange(_emon_detector_var._position_relative, _emon_detector_var._rotation_relative, _particle); } } if (!ABSORBED && _particle->_index == 132) { _particle->flag_nocoordschange=0; /* Reset if we came here from a JUMP */ _particle_save = *_particle; DEBUG_COMP(_emon_detector_var._name); DEBUG_STATE(); if ((( ! _instrument_var._parameters.VIRTUALOUT ))) // conditional WHEN execution class_E_monitor_trace(&_emon_detector_var, _particle); if (_particle->_restore) particle_restore(_particle, &_particle_save); _particle->_index++; if (!ABSORBED) { DEBUG_STATE(); } } /* end component emon_detector [132] */ /* begin component psd_window1=PSD_monitor_psf_eff() [133] */ if (!_particle->flag_nocoordschange) { // flag activated by JUMP to pass coords change if (_psd_window1_var._rotation_is_identity) { if(!_psd_window1_var._position_relative_is_zero) { coords_get(coords_add(coords_set(x,y,z), _psd_window1_var._position_relative),&x, &y, &z); } } else { mccoordschange(_psd_window1_var._position_relative, _psd_window1_var._rotation_relative, _particle); } } if (!ABSORBED && _particle->_index == 133) { _particle->flag_nocoordschange=0; /* Reset if we came here from a JUMP */ _particle_save = *_particle; DEBUG_COMP(_psd_window1_var._name); DEBUG_STATE(); if ((( BinX >= XwinMin [ 1 ] && BinX <= XwinMax [ 1 ] && BinY >= YwinMin [ 1 ] && BinY <= YwinMax [ 1 ] && ! _instrument_var._parameters.VIRTUALOUT ))) // conditional WHEN execution class_PSD_monitor_psf_eff_trace(&_psd_window1_var, _particle); if (_particle->_restore) particle_restore(_particle, &_particle_save); _particle->_index++; if (!ABSORBED) { DEBUG_STATE(); } } /* end component psd_window1 [133] */ /* begin component emon_window1=E_monitor() [134] */ if (!_particle->flag_nocoordschange) { // flag activated by JUMP to pass coords change if (_emon_window1_var._rotation_is_identity) { if(!_emon_window1_var._position_relative_is_zero) { coords_get(coords_add(coords_set(x,y,z), _emon_window1_var._position_relative),&x, &y, &z); } } else { mccoordschange(_emon_window1_var._position_relative, _emon_window1_var._rotation_relative, _particle); } } if (!ABSORBED && _particle->_index == 134) { _particle->flag_nocoordschange=0; /* Reset if we came here from a JUMP */ _particle_save = *_particle; DEBUG_COMP(_emon_window1_var._name); DEBUG_STATE(); if ((( BinX >= XwinMin [ 1 ] && BinX <= XwinMax [ 1 ] && BinY >= YwinMin [ 1 ] && BinY <= YwinMax [ 1 ] && ! _instrument_var._parameters.VIRTUALOUT ))) // conditional WHEN execution class_E_monitor_trace(&_emon_window1_var, _particle); if (_particle->_restore) particle_restore(_particle, &_particle_save); _particle->_index++; if (!ABSORBED) { DEBUG_STATE(); } } /* end component emon_window1 [134] */ /* begin component psd_window2=PSD_monitor_psf_eff() [135] */ if (!_particle->flag_nocoordschange) { // flag activated by JUMP to pass coords change if (_psd_window2_var._rotation_is_identity) { if(!_psd_window2_var._position_relative_is_zero) { coords_get(coords_add(coords_set(x,y,z), _psd_window2_var._position_relative),&x, &y, &z); } } else { mccoordschange(_psd_window2_var._position_relative, _psd_window2_var._rotation_relative, _particle); } } if (!ABSORBED && _particle->_index == 135) { _particle->flag_nocoordschange=0; /* Reset if we came here from a JUMP */ _particle_save = *_particle; DEBUG_COMP(_psd_window2_var._name); DEBUG_STATE(); if ((( BinX >= XwinMin [ 2 ] && BinX <= XwinMax [ 2 ] && BinY >= YwinMin [ 2 ] && BinY <= YwinMax [ 2 ] && ! _instrument_var._parameters.VIRTUALOUT ))) // conditional WHEN execution class_PSD_monitor_psf_eff_trace(&_psd_window2_var, _particle); if (_particle->_restore) particle_restore(_particle, &_particle_save); _particle->_index++; if (!ABSORBED) { DEBUG_STATE(); } } /* end component psd_window2 [135] */ /* begin component emon_window2=E_monitor() [136] */ if (!_particle->flag_nocoordschange) { // flag activated by JUMP to pass coords change if (_emon_window2_var._rotation_is_identity) { if(!_emon_window2_var._position_relative_is_zero) { coords_get(coords_add(coords_set(x,y,z), _emon_window2_var._position_relative),&x, &y, &z); } } else { mccoordschange(_emon_window2_var._position_relative, _emon_window2_var._rotation_relative, _particle); } } if (!ABSORBED && _particle->_index == 136) { _particle->flag_nocoordschange=0; /* Reset if we came here from a JUMP */ _particle_save = *_particle; DEBUG_COMP(_emon_window2_var._name); DEBUG_STATE(); if ((( BinX >= XwinMin [ 2 ] && BinX <= XwinMax [ 2 ] && BinY >= YwinMin [ 2 ] && BinY <= YwinMax [ 2 ] && ! _instrument_var._parameters.VIRTUALOUT ))) // conditional WHEN execution class_E_monitor_trace(&_emon_window2_var, _particle); if (_particle->_restore) particle_restore(_particle, &_particle_save); _particle->_index++; if (!ABSORBED) { DEBUG_STATE(); } } /* end component emon_window2 [136] */ /* begin component psd_window3=PSD_monitor_psf_eff() [137] */ if (!_particle->flag_nocoordschange) { // flag activated by JUMP to pass coords change if (_psd_window3_var._rotation_is_identity) { if(!_psd_window3_var._position_relative_is_zero) { coords_get(coords_add(coords_set(x,y,z), _psd_window3_var._position_relative),&x, &y, &z); } } else { mccoordschange(_psd_window3_var._position_relative, _psd_window3_var._rotation_relative, _particle); } } if (!ABSORBED && _particle->_index == 137) { _particle->flag_nocoordschange=0; /* Reset if we came here from a JUMP */ _particle_save = *_particle; DEBUG_COMP(_psd_window3_var._name); DEBUG_STATE(); if ((( BinX >= XwinMin [ 3 ] && BinX <= XwinMax [ 3 ] && BinY >= YwinMin [ 3 ] && BinY <= YwinMax [ 3 ] && ! _instrument_var._parameters.VIRTUALOUT ))) // conditional WHEN execution class_PSD_monitor_psf_eff_trace(&_psd_window3_var, _particle); if (_particle->_restore) particle_restore(_particle, &_particle_save); _particle->_index++; if (!ABSORBED) { DEBUG_STATE(); } } /* end component psd_window3 [137] */ /* begin component emon_window3=E_monitor() [138] */ if (!_particle->flag_nocoordschange) { // flag activated by JUMP to pass coords change if (_emon_window3_var._rotation_is_identity) { if(!_emon_window3_var._position_relative_is_zero) { coords_get(coords_add(coords_set(x,y,z), _emon_window3_var._position_relative),&x, &y, &z); } } else { mccoordschange(_emon_window3_var._position_relative, _emon_window3_var._rotation_relative, _particle); } } if (!ABSORBED && _particle->_index == 138) { _particle->flag_nocoordschange=0; /* Reset if we came here from a JUMP */ _particle_save = *_particle; DEBUG_COMP(_emon_window3_var._name); DEBUG_STATE(); if ((( BinX >= XwinMin [ 3 ] && BinX <= XwinMax [ 3 ] && BinY >= YwinMin [ 3 ] && BinY <= YwinMax [ 3 ] && ! _instrument_var._parameters.VIRTUALOUT ))) // conditional WHEN execution class_E_monitor_trace(&_emon_window3_var, _particle); if (_particle->_restore) particle_restore(_particle, &_particle_save); _particle->_index++; if (!ABSORBED) { DEBUG_STATE(); } } /* end component emon_window3 [138] */ /* begin component psd_window4=PSD_monitor_psf_eff() [139] */ if (!_particle->flag_nocoordschange) { // flag activated by JUMP to pass coords change if (_psd_window4_var._rotation_is_identity) { if(!_psd_window4_var._position_relative_is_zero) { coords_get(coords_add(coords_set(x,y,z), _psd_window4_var._position_relative),&x, &y, &z); } } else { mccoordschange(_psd_window4_var._position_relative, _psd_window4_var._rotation_relative, _particle); } } if (!ABSORBED && _particle->_index == 139) { _particle->flag_nocoordschange=0; /* Reset if we came here from a JUMP */ _particle_save = *_particle; DEBUG_COMP(_psd_window4_var._name); DEBUG_STATE(); if ((( BinX >= XwinMin [ 4 ] && BinX <= XwinMax [ 4 ] && BinY >= YwinMin [ 4 ] && BinY <= YwinMax [ 4 ] && ! _instrument_var._parameters.VIRTUALOUT ))) // conditional WHEN execution class_PSD_monitor_psf_eff_trace(&_psd_window4_var, _particle); if (_particle->_restore) particle_restore(_particle, &_particle_save); _particle->_index++; if (!ABSORBED) { DEBUG_STATE(); } } /* end component psd_window4 [139] */ /* begin component emon_window4=E_monitor() [140] */ if (!_particle->flag_nocoordschange) { // flag activated by JUMP to pass coords change if (_emon_window4_var._rotation_is_identity) { if(!_emon_window4_var._position_relative_is_zero) { coords_get(coords_add(coords_set(x,y,z), _emon_window4_var._position_relative),&x, &y, &z); } } else { mccoordschange(_emon_window4_var._position_relative, _emon_window4_var._rotation_relative, _particle); } } if (!ABSORBED && _particle->_index == 140) { _particle->flag_nocoordschange=0; /* Reset if we came here from a JUMP */ _particle_save = *_particle; DEBUG_COMP(_emon_window4_var._name); DEBUG_STATE(); if ((( BinX >= XwinMin [ 4 ] && BinX <= XwinMax [ 4 ] && BinY >= YwinMin [ 4 ] && BinY <= YwinMax [ 4 ] && ! _instrument_var._parameters.VIRTUALOUT ))) // conditional WHEN execution class_E_monitor_trace(&_emon_window4_var, _particle); if (_particle->_restore) particle_restore(_particle, &_particle_save); _particle->_index++; if (!ABSORBED) { DEBUG_STATE(); } } /* end component emon_window4 [140] */ /* begin component psd_window5=PSD_monitor_psf_eff() [141] */ if (!_particle->flag_nocoordschange) { // flag activated by JUMP to pass coords change if (_psd_window5_var._rotation_is_identity) { if(!_psd_window5_var._position_relative_is_zero) { coords_get(coords_add(coords_set(x,y,z), _psd_window5_var._position_relative),&x, &y, &z); } } else { mccoordschange(_psd_window5_var._position_relative, _psd_window5_var._rotation_relative, _particle); } } if (!ABSORBED && _particle->_index == 141) { _particle->flag_nocoordschange=0; /* Reset if we came here from a JUMP */ _particle_save = *_particle; DEBUG_COMP(_psd_window5_var._name); DEBUG_STATE(); if ((( BinX >= XwinMin [ 5 ] && BinX <= XwinMax [ 5 ] && BinY >= YwinMin [ 5 ] && BinY <= YwinMax [ 5 ] && ! _instrument_var._parameters.VIRTUALOUT ))) // conditional WHEN execution class_PSD_monitor_psf_eff_trace(&_psd_window5_var, _particle); if (_particle->_restore) particle_restore(_particle, &_particle_save); _particle->_index++; if (!ABSORBED) { DEBUG_STATE(); } } /* end component psd_window5 [141] */ /* begin component emon_window5=E_monitor() [142] */ if (!_particle->flag_nocoordschange) { // flag activated by JUMP to pass coords change if (_emon_window5_var._rotation_is_identity) { if(!_emon_window5_var._position_relative_is_zero) { coords_get(coords_add(coords_set(x,y,z), _emon_window5_var._position_relative),&x, &y, &z); } } else { mccoordschange(_emon_window5_var._position_relative, _emon_window5_var._rotation_relative, _particle); } } if (!ABSORBED && _particle->_index == 142) { _particle->flag_nocoordschange=0; /* Reset if we came here from a JUMP */ _particle_save = *_particle; DEBUG_COMP(_emon_window5_var._name); DEBUG_STATE(); if ((( BinX >= XwinMin [ 5 ] && BinX <= XwinMax [ 5 ] && BinY >= YwinMin [ 5 ] && BinY <= YwinMax [ 5 ] && ! _instrument_var._parameters.VIRTUALOUT ))) // conditional WHEN execution class_E_monitor_trace(&_emon_window5_var, _particle); if (_particle->_restore) particle_restore(_particle, &_particle_save); _particle->_index++; if (!ABSORBED) { DEBUG_STATE(); } } /* end component emon_window5 [142] */ /* begin component psd_window6=PSD_monitor_psf_eff() [143] */ if (!_particle->flag_nocoordschange) { // flag activated by JUMP to pass coords change if (_psd_window6_var._rotation_is_identity) { if(!_psd_window6_var._position_relative_is_zero) { coords_get(coords_add(coords_set(x,y,z), _psd_window6_var._position_relative),&x, &y, &z); } } else { mccoordschange(_psd_window6_var._position_relative, _psd_window6_var._rotation_relative, _particle); } } if (!ABSORBED && _particle->_index == 143) { _particle->flag_nocoordschange=0; /* Reset if we came here from a JUMP */ _particle_save = *_particle; DEBUG_COMP(_psd_window6_var._name); DEBUG_STATE(); if ((( BinX >= XwinMin [ 6 ] && BinX <= XwinMax [ 6 ] && BinY >= YwinMin [ 6 ] && BinY <= YwinMax [ 6 ] && ! _instrument_var._parameters.VIRTUALOUT ))) // conditional WHEN execution class_PSD_monitor_psf_eff_trace(&_psd_window6_var, _particle); if (_particle->_restore) particle_restore(_particle, &_particle_save); _particle->_index++; if (!ABSORBED) { DEBUG_STATE(); } } /* end component psd_window6 [143] */ /* begin component emon_window6=E_monitor() [144] */ if (!_particle->flag_nocoordschange) { // flag activated by JUMP to pass coords change if (_emon_window6_var._rotation_is_identity) { if(!_emon_window6_var._position_relative_is_zero) { coords_get(coords_add(coords_set(x,y,z), _emon_window6_var._position_relative),&x, &y, &z); } } else { mccoordschange(_emon_window6_var._position_relative, _emon_window6_var._rotation_relative, _particle); } } if (!ABSORBED && _particle->_index == 144) { _particle->flag_nocoordschange=0; /* Reset if we came here from a JUMP */ _particle_save = *_particle; DEBUG_COMP(_emon_window6_var._name); DEBUG_STATE(); if ((( BinX >= XwinMin [ 6 ] && BinX <= XwinMax [ 6 ] && BinY >= YwinMin [ 6 ] && BinY <= YwinMax [ 6 ] && ! _instrument_var._parameters.VIRTUALOUT ))) // conditional WHEN execution class_E_monitor_trace(&_emon_window6_var, _particle); if (_particle->_restore) particle_restore(_particle, &_particle_save); _particle->_index++; if (!ABSORBED) { DEBUG_STATE(); } } /* end component emon_window6 [144] */ /* begin component psd_window7=PSD_monitor_psf_eff() [145] */ if (!_particle->flag_nocoordschange) { // flag activated by JUMP to pass coords change if (_psd_window7_var._rotation_is_identity) { if(!_psd_window7_var._position_relative_is_zero) { coords_get(coords_add(coords_set(x,y,z), _psd_window7_var._position_relative),&x, &y, &z); } } else { mccoordschange(_psd_window7_var._position_relative, _psd_window7_var._rotation_relative, _particle); } } if (!ABSORBED && _particle->_index == 145) { _particle->flag_nocoordschange=0; /* Reset if we came here from a JUMP */ _particle_save = *_particle; DEBUG_COMP(_psd_window7_var._name); DEBUG_STATE(); if ((( BinX >= XwinMin [ 7 ] && BinX <= XwinMax [ 7 ] && BinY >= YwinMin [ 7 ] && BinY <= YwinMax [ 7 ] && ! _instrument_var._parameters.VIRTUALOUT ))) // conditional WHEN execution class_PSD_monitor_psf_eff_trace(&_psd_window7_var, _particle); if (_particle->_restore) particle_restore(_particle, &_particle_save); _particle->_index++; if (!ABSORBED) { DEBUG_STATE(); } } /* end component psd_window7 [145] */ /* begin component emon_window7=E_monitor() [146] */ if (!_particle->flag_nocoordschange) { // flag activated by JUMP to pass coords change if (_emon_window7_var._rotation_is_identity) { if(!_emon_window7_var._position_relative_is_zero) { coords_get(coords_add(coords_set(x,y,z), _emon_window7_var._position_relative),&x, &y, &z); } } else { mccoordschange(_emon_window7_var._position_relative, _emon_window7_var._rotation_relative, _particle); } } if (!ABSORBED && _particle->_index == 146) { _particle->flag_nocoordschange=0; /* Reset if we came here from a JUMP */ _particle_save = *_particle; DEBUG_COMP(_emon_window7_var._name); DEBUG_STATE(); if ((( BinX >= XwinMin [ 7 ] && BinX <= XwinMax [ 7 ] && BinY >= YwinMin [ 7 ] && BinY <= YwinMax [ 7 ] && ! _instrument_var._parameters.VIRTUALOUT ))) // conditional WHEN execution class_E_monitor_trace(&_emon_window7_var, _particle); if (_particle->_restore) particle_restore(_particle, &_particle_save); _particle->_index++; if (!ABSORBED) { DEBUG_STATE(); } } /* end component emon_window7 [146] */ /* begin component psd_window8=PSD_monitor_psf_eff() [147] */ if (!_particle->flag_nocoordschange) { // flag activated by JUMP to pass coords change if (_psd_window8_var._rotation_is_identity) { if(!_psd_window8_var._position_relative_is_zero) { coords_get(coords_add(coords_set(x,y,z), _psd_window8_var._position_relative),&x, &y, &z); } } else { mccoordschange(_psd_window8_var._position_relative, _psd_window8_var._rotation_relative, _particle); } } if (!ABSORBED && _particle->_index == 147) { _particle->flag_nocoordschange=0; /* Reset if we came here from a JUMP */ _particle_save = *_particle; DEBUG_COMP(_psd_window8_var._name); DEBUG_STATE(); if ((( BinX >= XwinMin [ 8 ] && BinX <= XwinMax [ 8 ] && BinY >= YwinMin [ 8 ] && BinY <= YwinMax [ 8 ] && ! _instrument_var._parameters.VIRTUALOUT ))) // conditional WHEN execution class_PSD_monitor_psf_eff_trace(&_psd_window8_var, _particle); if (_particle->_restore) particle_restore(_particle, &_particle_save); _particle->_index++; if (!ABSORBED) { DEBUG_STATE(); } } /* end component psd_window8 [147] */ /* begin component emon_window8=E_monitor() [148] */ if (!_particle->flag_nocoordschange) { // flag activated by JUMP to pass coords change if (_emon_window8_var._rotation_is_identity) { if(!_emon_window8_var._position_relative_is_zero) { coords_get(coords_add(coords_set(x,y,z), _emon_window8_var._position_relative),&x, &y, &z); } } else { mccoordschange(_emon_window8_var._position_relative, _emon_window8_var._rotation_relative, _particle); } } if (!ABSORBED && _particle->_index == 148) { _particle->flag_nocoordschange=0; /* Reset if we came here from a JUMP */ _particle_save = *_particle; DEBUG_COMP(_emon_window8_var._name); DEBUG_STATE(); if ((( BinX >= XwinMin [ 8 ] && BinX <= XwinMax [ 8 ] && BinY >= YwinMin [ 8 ] && BinY <= YwinMax [ 8 ] && ! _instrument_var._parameters.VIRTUALOUT ))) // conditional WHEN execution class_E_monitor_trace(&_emon_window8_var, _particle); if (_particle->_restore) particle_restore(_particle, &_particle_save); _particle->_index++; if (!ABSORBED) { DEBUG_STATE(); } } /* end component emon_window8 [148] */ /* begin component psd_window9=PSD_monitor_psf_eff() [149] */ if (!_particle->flag_nocoordschange) { // flag activated by JUMP to pass coords change if (_psd_window9_var._rotation_is_identity) { if(!_psd_window9_var._position_relative_is_zero) { coords_get(coords_add(coords_set(x,y,z), _psd_window9_var._position_relative),&x, &y, &z); } } else { mccoordschange(_psd_window9_var._position_relative, _psd_window9_var._rotation_relative, _particle); } } if (!ABSORBED && _particle->_index == 149) { _particle->flag_nocoordschange=0; /* Reset if we came here from a JUMP */ _particle_save = *_particle; DEBUG_COMP(_psd_window9_var._name); DEBUG_STATE(); if ((( BinX >= XwinMin [ 9 ] && BinX <= XwinMax [ 9 ] && BinY >= YwinMin [ 9 ] && BinY <= YwinMax [ 9 ] && ! _instrument_var._parameters.VIRTUALOUT ))) // conditional WHEN execution class_PSD_monitor_psf_eff_trace(&_psd_window9_var, _particle); if (_particle->_restore) particle_restore(_particle, &_particle_save); _particle->_index++; if (!ABSORBED) { DEBUG_STATE(); } } /* end component psd_window9 [149] */ /* begin component emon_window9=E_monitor() [150] */ if (!_particle->flag_nocoordschange) { // flag activated by JUMP to pass coords change if (_emon_window9_var._rotation_is_identity) { if(!_emon_window9_var._position_relative_is_zero) { coords_get(coords_add(coords_set(x,y,z), _emon_window9_var._position_relative),&x, &y, &z); } } else { mccoordschange(_emon_window9_var._position_relative, _emon_window9_var._rotation_relative, _particle); } } if (!ABSORBED && _particle->_index == 150) { _particle->flag_nocoordschange=0; /* Reset if we came here from a JUMP */ _particle_save = *_particle; DEBUG_COMP(_emon_window9_var._name); DEBUG_STATE(); if ((( BinX >= XwinMin [ 9 ] && BinX <= XwinMax [ 9 ] && BinY >= YwinMin [ 9 ] && BinY <= YwinMax [ 9 ] && ! _instrument_var._parameters.VIRTUALOUT ))) // conditional WHEN execution class_E_monitor_trace(&_emon_window9_var, _particle); if (_particle->_restore) particle_restore(_particle, &_particle_save); _particle->_index++; if (!ABSORBED) { DEBUG_STATE(); } } /* end component emon_window9 [150] */ #ifndef NOSPLIT } /* end SPLIT at focus_ana */ } /* if (!ABSORBED) relating to SPLIT at focus_ana */ #endif #ifndef NOSPLIT } /* end SPLIT at a3 */ } /* if (!ABSORBED) relating to SPLIT at a3 */ #endif #ifndef NOSPLIT } /* end SPLIT at monochromator_curved */ } /* if (!ABSORBED) relating to SPLIT at monochromator_curved */ #endif if (_particle->_index > 150) ABSORBED++; /* absorbed when passed all components */ } /* while !ABSORBED */ DEBUG_LEAVE() particle_restore(_particle, &_particle_save); DEBUG_STATE() return(_particle->_index); } /* raytrace */ /* loop to generate events and call raytrace() propagate them */ void raytrace_all(unsigned long long ncount, unsigned long seed) { // if on GPU and mcdotrace just exit #ifdef OPENACC if (!mcdotrace) { #endif /* CPU-loop */ unsigned long long loops; loops = ceil((double)ncount/gpu_innerloop); /* if on GPU, printf has been globally nullified, re-enable here */ #ifdef OPENACC #undef strlen #undef strcmp #undef exit #undef printf #undef sprintf #undef fprintf #endif #ifdef OPENACC if (ncount>gpu_innerloop) { printf("Defining %llu CPU loops around GPU kernel and adjusting ncount\n",loops); mcset_ncount(loops*gpu_innerloop); } else { #endif loops=1; gpu_innerloop = ncount; #ifdef OPENACC } #endif for (unsigned long long cloop=0; cloop1) fprintf(stdout, "%d..", (int)cloop); fflush(stdout); #endif /* if on GPU, re-nullify printf */ #ifdef OPENACC #undef strlen #undef strcmp #undef exit #undef printf #undef sprintf #undef fprintf #endif #pragma acc parallel loop num_gangs(numgangs) vector_length(vecsize) for (unsigned long pidx=0 ; pidx < gpu_innerloop ; pidx++) { _class_particle particleN = mcgenstate(); // initial particle _class_particle* _particle = &particleN; particleN._uid = pidx; #ifdef USE_MPI particleN._uid += mpi_node_rank * ncount; #endif srandom(_hash((pidx+1)*(seed+1))); raytrace(_particle); } /* inner for */ seed = seed+gpu_innerloop; } /* CPU for */ /* if on GPU, printf has been globally nullified, re-enable here */ #ifdef OPENACC #undef strlen #undef strcmp #undef exit #undef printf #undef sprintf #undef fprintf #endif MPI_MASTER( printf("*** TRACE end *** \n"); ); // if on GPU and mcdotrace just exit #ifdef OPENACC } #endif } /* raytrace_all */ #endif //no-FUNNEL #ifdef FUNNEL // Alternative raytrace algorithm which iterates all particles through // one component at the time, can remove absorbs from the next loop and // switch between cpu/gpu. void raytrace_all_funnel(unsigned long long ncount, unsigned long seed) { // if on GPU and mcdotrace just exit #ifdef OPENACC if (!mcdotrace) { #endif // set up outer (CPU) loop / particle batches unsigned long long loops; /* if on GPU, printf has been globally nullified, re-enable here */ #ifdef OPENACC #undef strlen #undef strcmp #undef exit #undef printf #undef sprintf #undef fprintf #endif #ifdef OPENACC loops = ceil((double)ncount/gpu_innerloop); if (ncount>gpu_innerloop) { printf("Defining %llu CPU loops around kernel and adjusting ncount\n",loops); mcset_ncount(loops*gpu_innerloop); } else { #endif loops=1; gpu_innerloop = ncount; #ifdef OPENACC } #endif // create particles struct and pointer arrays (same memory used by all batches) _class_particle* particles = malloc(gpu_innerloop*sizeof(_class_particle)); _class_particle* pbuffer = malloc(gpu_innerloop*sizeof(_class_particle)); long livebatchsize = gpu_innerloop; #undef ABSORB0 #undef ABSORB #define ABSORB0 do { DEBUG_ABSORB(); MAGNET_OFF; ABSORBED++; } while(0) #define ABSORB ABSORB0 // outer loop / particle batches for (unsigned long long cloop=0; cloop1) fprintf(stdout, "%d..", (int)cloop); fflush(stdout); // init particles #pragma acc parallel loop present(particles[0:livebatchsize]) for (unsigned long pidx=0 ; pidx < livebatchsize ; pidx++) { // generate particle state, set loop index and seed particles[pidx] = mcgenstate(); _class_particle* _particle = particles + pidx; _particle->_uid = pidx; #ifdef USE_MPI _particle->_uid += mpi_node_rank * ncount; #endif srandom(_hash((pidx+1)*(seed+1))); // _particle->state usage built into srandom macro } // iterate components #pragma acc parallel loop present(particles[0:livebatchsize]) for (unsigned long pidx=0 ; pidx < livebatchsize ; pidx++) { _class_particle* _particle = &particles[pidx]; _class_particle _particle_save; // armSource if (!ABSORBED && _particle->_index == 1) { #ifndef MULTICORE if (_armSource_var._rotation_is_identity) coords_get(coords_add(coords_set(x,y,z), _armSource_var._position_relative),&x, &y, &z); else #endif mccoordschange(_armSource_var._position_relative, _armSource_var._rotation_relative, _particle); _particle_save = *_particle; class_Progress_bar_trace(&_armSource_var, _particle); if (_particle->_restore) particle_restore(_particle, &_particle_save); _particle->_index++; } // source if (!ABSORBED && _particle->_index == 2) { #ifndef MULTICORE if (_source_var._rotation_is_identity) coords_get(coords_add(coords_set(x,y,z), _source_var._position_relative),&x, &y, &z); else #endif mccoordschange(_source_var._position_relative, _source_var._rotation_relative, _particle); _particle_save = *_particle; if ((( ! _instrument_var._parameters.VIRTUALIN ))) // conditional WHEN class_Source_gen4_trace(&_source_var, _particle); if (_particle->_restore) particle_restore(_particle, &_particle_save); _particle->_index++; } // slitGuideBegin if (!ABSORBED && _particle->_index == 3) { #ifndef MULTICORE if (_slitGuideBegin_var._rotation_is_identity) coords_get(coords_add(coords_set(x,y,z), _slitGuideBegin_var._position_relative),&x, &y, &z); else #endif mccoordschange(_slitGuideBegin_var._position_relative, _slitGuideBegin_var._rotation_relative, _particle); _particle_save = *_particle; if ((( ! _instrument_var._parameters.VIRTUALIN ))) // conditional WHEN class_Slit_trace(&_slitGuideBegin_var, _particle); if (_particle->_restore) particle_restore(_particle, &_particle_save); _particle->_index++; } // lmon_guide_start if (!ABSORBED && _particle->_index == 4) { #ifndef MULTICORE if (_lmon_guide_start_var._rotation_is_identity) coords_get(coords_add(coords_set(x,y,z), _lmon_guide_start_var._position_relative),&x, &y, &z); else #endif mccoordschange(_lmon_guide_start_var._position_relative, _lmon_guide_start_var._rotation_relative, _particle); _particle_save = *_particle; if ((( ! _instrument_var._parameters.VIRTUALIN ))) // conditional WHEN class_L_monitor_trace(&_lmon_guide_start_var, _particle); if (_particle->_restore) particle_restore(_particle, &_particle_save); _particle->_index++; } // guideStraight if (!ABSORBED && _particle->_index == 5) { #ifndef MULTICORE if (_guideStraight_var._rotation_is_identity) coords_get(coords_add(coords_set(x,y,z), _guideStraight_var._position_relative),&x, &y, &z); else #endif mccoordschange(_guideStraight_var._position_relative, _guideStraight_var._rotation_relative, _particle); _particle_save = *_particle; if ((( ! _instrument_var._parameters.VIRTUALIN ))) // conditional WHEN class_Guide_trace(&_guideStraight_var, _particle); if (_particle->_restore) particle_restore(_particle, &_particle_save); _particle->_index++; } // guideCurved1 if (!ABSORBED && _particle->_index == 6) { #ifndef MULTICORE if (_guideCurved1_var._rotation_is_identity) coords_get(coords_add(coords_set(x,y,z), _guideCurved1_var._position_relative),&x, &y, &z); else #endif mccoordschange(_guideCurved1_var._position_relative, _guideCurved1_var._rotation_relative, _particle); _particle_save = *_particle; if ((( ! _instrument_var._parameters.VIRTUALIN ))) // conditional WHEN class_Guide_trace(&_guideCurved1_var, _particle); if (_particle->_restore) particle_restore(_particle, &_particle_save); _particle->_index++; } // guideCurved2 if (!ABSORBED && _particle->_index == 7) { #ifndef MULTICORE if (_guideCurved2_var._rotation_is_identity) coords_get(coords_add(coords_set(x,y,z), _guideCurved2_var._position_relative),&x, &y, &z); else #endif mccoordschange(_guideCurved2_var._position_relative, _guideCurved2_var._rotation_relative, _particle); _particle_save = *_particle; if ((( ! _instrument_var._parameters.VIRTUALIN ))) // conditional WHEN class_Guide_trace(&_guideCurved2_var, _particle); if (_particle->_restore) particle_restore(_particle, &_particle_save); _particle->_index++; } // guideCurved3 if (!ABSORBED && _particle->_index == 8) { #ifndef MULTICORE if (_guideCurved3_var._rotation_is_identity) coords_get(coords_add(coords_set(x,y,z), _guideCurved3_var._position_relative),&x, &y, &z); else #endif mccoordschange(_guideCurved3_var._position_relative, _guideCurved3_var._rotation_relative, _particle); _particle_save = *_particle; if ((( ! _instrument_var._parameters.VIRTUALIN ))) // conditional WHEN class_Guide_trace(&_guideCurved3_var, _particle); if (_particle->_restore) particle_restore(_particle, &_particle_save); _particle->_index++; } // guideCurved4 if (!ABSORBED && _particle->_index == 9) { #ifndef MULTICORE if (_guideCurved4_var._rotation_is_identity) coords_get(coords_add(coords_set(x,y,z), _guideCurved4_var._position_relative),&x, &y, &z); else #endif mccoordschange(_guideCurved4_var._position_relative, _guideCurved4_var._rotation_relative, _particle); _particle_save = *_particle; if ((( ! _instrument_var._parameters.VIRTUALIN ))) // conditional WHEN class_Guide_trace(&_guideCurved4_var, _particle); if (_particle->_restore) particle_restore(_particle, &_particle_save); _particle->_index++; } // guideCurved5 if (!ABSORBED && _particle->_index == 10) { #ifndef MULTICORE if (_guideCurved5_var._rotation_is_identity) coords_get(coords_add(coords_set(x,y,z), _guideCurved5_var._position_relative),&x, &y, &z); else #endif mccoordschange(_guideCurved5_var._position_relative, _guideCurved5_var._rotation_relative, _particle); _particle_save = *_particle; if ((( ! _instrument_var._parameters.VIRTUALIN ))) // conditional WHEN class_Guide_trace(&_guideCurved5_var, _particle); if (_particle->_restore) particle_restore(_particle, &_particle_save); _particle->_index++; } // guideCurved6 if (!ABSORBED && _particle->_index == 11) { #ifndef MULTICORE if (_guideCurved6_var._rotation_is_identity) coords_get(coords_add(coords_set(x,y,z), _guideCurved6_var._position_relative),&x, &y, &z); else #endif mccoordschange(_guideCurved6_var._position_relative, _guideCurved6_var._rotation_relative, _particle); _particle_save = *_particle; if ((( ! _instrument_var._parameters.VIRTUALIN ))) // conditional WHEN class_Guide_trace(&_guideCurved6_var, _particle); if (_particle->_restore) particle_restore(_particle, &_particle_save); _particle->_index++; } // guideCurved7 if (!ABSORBED && _particle->_index == 12) { #ifndef MULTICORE if (_guideCurved7_var._rotation_is_identity) coords_get(coords_add(coords_set(x,y,z), _guideCurved7_var._position_relative),&x, &y, &z); else #endif mccoordschange(_guideCurved7_var._position_relative, _guideCurved7_var._rotation_relative, _particle); _particle_save = *_particle; if ((( ! _instrument_var._parameters.VIRTUALIN ))) // conditional WHEN class_Guide_trace(&_guideCurved7_var, _particle); if (_particle->_restore) particle_restore(_particle, &_particle_save); _particle->_index++; } // guideCurved8 if (!ABSORBED && _particle->_index == 13) { #ifndef MULTICORE if (_guideCurved8_var._rotation_is_identity) coords_get(coords_add(coords_set(x,y,z), _guideCurved8_var._position_relative),&x, &y, &z); else #endif mccoordschange(_guideCurved8_var._position_relative, _guideCurved8_var._rotation_relative, _particle); _particle_save = *_particle; if ((( ! _instrument_var._parameters.VIRTUALIN ))) // conditional WHEN class_Guide_trace(&_guideCurved8_var, _particle); if (_particle->_restore) particle_restore(_particle, &_particle_save); _particle->_index++; } // guideCurved9 if (!ABSORBED && _particle->_index == 14) { #ifndef MULTICORE if (_guideCurved9_var._rotation_is_identity) coords_get(coords_add(coords_set(x,y,z), _guideCurved9_var._position_relative),&x, &y, &z); else #endif mccoordschange(_guideCurved9_var._position_relative, _guideCurved9_var._rotation_relative, _particle); _particle_save = *_particle; if ((( ! _instrument_var._parameters.VIRTUALIN ))) // conditional WHEN class_Guide_trace(&_guideCurved9_var, _particle); if (_particle->_restore) particle_restore(_particle, &_particle_save); _particle->_index++; } // guideCurved10 if (!ABSORBED && _particle->_index == 15) { #ifndef MULTICORE if (_guideCurved10_var._rotation_is_identity) coords_get(coords_add(coords_set(x,y,z), _guideCurved10_var._position_relative),&x, &y, &z); else #endif mccoordschange(_guideCurved10_var._position_relative, _guideCurved10_var._rotation_relative, _particle); _particle_save = *_particle; if ((( ! _instrument_var._parameters.VIRTUALIN ))) // conditional WHEN class_Guide_trace(&_guideCurved10_var, _particle); if (_particle->_restore) particle_restore(_particle, &_particle_save); _particle->_index++; } // guideCurved11 if (!ABSORBED && _particle->_index == 16) { #ifndef MULTICORE if (_guideCurved11_var._rotation_is_identity) coords_get(coords_add(coords_set(x,y,z), _guideCurved11_var._position_relative),&x, &y, &z); else #endif mccoordschange(_guideCurved11_var._position_relative, _guideCurved11_var._rotation_relative, _particle); _particle_save = *_particle; if ((( ! _instrument_var._parameters.VIRTUALIN ))) // conditional WHEN class_Guide_trace(&_guideCurved11_var, _particle); if (_particle->_restore) particle_restore(_particle, &_particle_save); _particle->_index++; } // guideCurved12 if (!ABSORBED && _particle->_index == 17) { #ifndef MULTICORE if (_guideCurved12_var._rotation_is_identity) coords_get(coords_add(coords_set(x,y,z), _guideCurved12_var._position_relative),&x, &y, &z); else #endif mccoordschange(_guideCurved12_var._position_relative, _guideCurved12_var._rotation_relative, _particle); _particle_save = *_particle; if ((( ! _instrument_var._parameters.VIRTUALIN ))) // conditional WHEN class_Guide_trace(&_guideCurved12_var, _particle); if (_particle->_restore) particle_restore(_particle, &_particle_save); _particle->_index++; } // guideCurved13 if (!ABSORBED && _particle->_index == 18) { #ifndef MULTICORE if (_guideCurved13_var._rotation_is_identity) coords_get(coords_add(coords_set(x,y,z), _guideCurved13_var._position_relative),&x, &y, &z); else #endif mccoordschange(_guideCurved13_var._position_relative, _guideCurved13_var._rotation_relative, _particle); _particle_save = *_particle; if ((( ! _instrument_var._parameters.VIRTUALIN ))) // conditional WHEN class_Guide_trace(&_guideCurved13_var, _particle); if (_particle->_restore) particle_restore(_particle, &_particle_save); _particle->_index++; } // guideCurved14 if (!ABSORBED && _particle->_index == 19) { #ifndef MULTICORE if (_guideCurved14_var._rotation_is_identity) coords_get(coords_add(coords_set(x,y,z), _guideCurved14_var._position_relative),&x, &y, &z); else #endif mccoordschange(_guideCurved14_var._position_relative, _guideCurved14_var._rotation_relative, _particle); _particle_save = *_particle; if ((( ! _instrument_var._parameters.VIRTUALIN ))) // conditional WHEN class_Guide_trace(&_guideCurved14_var, _particle); if (_particle->_restore) particle_restore(_particle, &_particle_save); _particle->_index++; } // guideCurved15 if (!ABSORBED && _particle->_index == 20) { #ifndef MULTICORE if (_guideCurved15_var._rotation_is_identity) coords_get(coords_add(coords_set(x,y,z), _guideCurved15_var._position_relative),&x, &y, &z); else #endif mccoordschange(_guideCurved15_var._position_relative, _guideCurved15_var._rotation_relative, _particle); _particle_save = *_particle; if ((( ! _instrument_var._parameters.VIRTUALIN ))) // conditional WHEN class_Guide_trace(&_guideCurved15_var, _particle); if (_particle->_restore) particle_restore(_particle, &_particle_save); _particle->_index++; } // guideCurved16 if (!ABSORBED && _particle->_index == 21) { #ifndef MULTICORE if (_guideCurved16_var._rotation_is_identity) coords_get(coords_add(coords_set(x,y,z), _guideCurved16_var._position_relative),&x, &y, &z); else #endif mccoordschange(_guideCurved16_var._position_relative, _guideCurved16_var._rotation_relative, _particle); _particle_save = *_particle; if ((( ! _instrument_var._parameters.VIRTUALIN ))) // conditional WHEN class_Guide_trace(&_guideCurved16_var, _particle); if (_particle->_restore) particle_restore(_particle, &_particle_save); _particle->_index++; } // guideCurved17 if (!ABSORBED && _particle->_index == 22) { #ifndef MULTICORE if (_guideCurved17_var._rotation_is_identity) coords_get(coords_add(coords_set(x,y,z), _guideCurved17_var._position_relative),&x, &y, &z); else #endif mccoordschange(_guideCurved17_var._position_relative, _guideCurved17_var._rotation_relative, _particle); _particle_save = *_particle; if ((( ! _instrument_var._parameters.VIRTUALIN ))) // conditional WHEN class_Guide_trace(&_guideCurved17_var, _particle); if (_particle->_restore) particle_restore(_particle, &_particle_save); _particle->_index++; } // guideCurved18 if (!ABSORBED && _particle->_index == 23) { #ifndef MULTICORE if (_guideCurved18_var._rotation_is_identity) coords_get(coords_add(coords_set(x,y,z), _guideCurved18_var._position_relative),&x, &y, &z); else #endif mccoordschange(_guideCurved18_var._position_relative, _guideCurved18_var._rotation_relative, _particle); _particle_save = *_particle; if ((( ! _instrument_var._parameters.VIRTUALIN ))) // conditional WHEN class_Guide_trace(&_guideCurved18_var, _particle); if (_particle->_restore) particle_restore(_particle, &_particle_save); _particle->_index++; } // guideCurved19 if (!ABSORBED && _particle->_index == 24) { #ifndef MULTICORE if (_guideCurved19_var._rotation_is_identity) coords_get(coords_add(coords_set(x,y,z), _guideCurved19_var._position_relative),&x, &y, &z); else #endif mccoordschange(_guideCurved19_var._position_relative, _guideCurved19_var._rotation_relative, _particle); _particle_save = *_particle; if ((( ! _instrument_var._parameters.VIRTUALIN ))) // conditional WHEN class_Guide_trace(&_guideCurved19_var, _particle); if (_particle->_restore) particle_restore(_particle, &_particle_save); _particle->_index++; } // guideCurved20 if (!ABSORBED && _particle->_index == 25) { #ifndef MULTICORE if (_guideCurved20_var._rotation_is_identity) coords_get(coords_add(coords_set(x,y,z), _guideCurved20_var._position_relative),&x, &y, &z); else #endif mccoordschange(_guideCurved20_var._position_relative, _guideCurved20_var._rotation_relative, _particle); _particle_save = *_particle; if ((( ! _instrument_var._parameters.VIRTUALIN ))) // conditional WHEN class_Guide_trace(&_guideCurved20_var, _particle); if (_particle->_restore) particle_restore(_particle, &_particle_save); _particle->_index++; } // guideCurved21 if (!ABSORBED && _particle->_index == 26) { #ifndef MULTICORE if (_guideCurved21_var._rotation_is_identity) coords_get(coords_add(coords_set(x,y,z), _guideCurved21_var._position_relative),&x, &y, &z); else #endif mccoordschange(_guideCurved21_var._position_relative, _guideCurved21_var._rotation_relative, _particle); _particle_save = *_particle; if ((( ! _instrument_var._parameters.VIRTUALIN ))) // conditional WHEN class_Guide_trace(&_guideCurved21_var, _particle); if (_particle->_restore) particle_restore(_particle, &_particle_save); _particle->_index++; } // guideCurved22 if (!ABSORBED && _particle->_index == 27) { #ifndef MULTICORE if (_guideCurved22_var._rotation_is_identity) coords_get(coords_add(coords_set(x,y,z), _guideCurved22_var._position_relative),&x, &y, &z); else #endif mccoordschange(_guideCurved22_var._position_relative, _guideCurved22_var._rotation_relative, _particle); _particle_save = *_particle; if ((( ! _instrument_var._parameters.VIRTUALIN ))) // conditional WHEN class_Guide_trace(&_guideCurved22_var, _particle); if (_particle->_restore) particle_restore(_particle, &_particle_save); _particle->_index++; } // guideCurved23 if (!ABSORBED && _particle->_index == 28) { #ifndef MULTICORE if (_guideCurved23_var._rotation_is_identity) coords_get(coords_add(coords_set(x,y,z), _guideCurved23_var._position_relative),&x, &y, &z); else #endif mccoordschange(_guideCurved23_var._position_relative, _guideCurved23_var._rotation_relative, _particle); _particle_save = *_particle; if ((( ! _instrument_var._parameters.VIRTUALIN ))) // conditional WHEN class_Guide_trace(&_guideCurved23_var, _particle); if (_particle->_restore) particle_restore(_particle, &_particle_save); _particle->_index++; } // guideCurved24 if (!ABSORBED && _particle->_index == 29) { #ifndef MULTICORE if (_guideCurved24_var._rotation_is_identity) coords_get(coords_add(coords_set(x,y,z), _guideCurved24_var._position_relative),&x, &y, &z); else #endif mccoordschange(_guideCurved24_var._position_relative, _guideCurved24_var._rotation_relative, _particle); _particle_save = *_particle; if ((( ! _instrument_var._parameters.VIRTUALIN ))) // conditional WHEN class_Guide_trace(&_guideCurved24_var, _particle); if (_particle->_restore) particle_restore(_particle, &_particle_save); _particle->_index++; } // guideCurved25 if (!ABSORBED && _particle->_index == 30) { #ifndef MULTICORE if (_guideCurved25_var._rotation_is_identity) coords_get(coords_add(coords_set(x,y,z), _guideCurved25_var._position_relative),&x, &y, &z); else #endif mccoordschange(_guideCurved25_var._position_relative, _guideCurved25_var._rotation_relative, _particle); _particle_save = *_particle; if ((( ! _instrument_var._parameters.VIRTUALIN ))) // conditional WHEN class_Guide_trace(&_guideCurved25_var, _particle); if (_particle->_restore) particle_restore(_particle, &_particle_save); _particle->_index++; } // guideCurved26 if (!ABSORBED && _particle->_index == 31) { #ifndef MULTICORE if (_guideCurved26_var._rotation_is_identity) coords_get(coords_add(coords_set(x,y,z), _guideCurved26_var._position_relative),&x, &y, &z); else #endif mccoordschange(_guideCurved26_var._position_relative, _guideCurved26_var._rotation_relative, _particle); _particle_save = *_particle; if ((( ! _instrument_var._parameters.VIRTUALIN ))) // conditional WHEN class_Guide_trace(&_guideCurved26_var, _particle); if (_particle->_restore) particle_restore(_particle, &_particle_save); _particle->_index++; } // guideCurved27 if (!ABSORBED && _particle->_index == 32) { #ifndef MULTICORE if (_guideCurved27_var._rotation_is_identity) coords_get(coords_add(coords_set(x,y,z), _guideCurved27_var._position_relative),&x, &y, &z); else #endif mccoordschange(_guideCurved27_var._position_relative, _guideCurved27_var._rotation_relative, _particle); _particle_save = *_particle; if ((( ! _instrument_var._parameters.VIRTUALIN ))) // conditional WHEN class_Guide_trace(&_guideCurved27_var, _particle); if (_particle->_restore) particle_restore(_particle, &_particle_save); _particle->_index++; } // guideCurved28 if (!ABSORBED && _particle->_index == 33) { #ifndef MULTICORE if (_guideCurved28_var._rotation_is_identity) coords_get(coords_add(coords_set(x,y,z), _guideCurved28_var._position_relative),&x, &y, &z); else #endif mccoordschange(_guideCurved28_var._position_relative, _guideCurved28_var._rotation_relative, _particle); _particle_save = *_particle; if ((( ! _instrument_var._parameters.VIRTUALIN ))) // conditional WHEN class_Guide_trace(&_guideCurved28_var, _particle); if (_particle->_restore) particle_restore(_particle, &_particle_save); _particle->_index++; } // guideCurved29 if (!ABSORBED && _particle->_index == 34) { #ifndef MULTICORE if (_guideCurved29_var._rotation_is_identity) coords_get(coords_add(coords_set(x,y,z), _guideCurved29_var._position_relative),&x, &y, &z); else #endif mccoordschange(_guideCurved29_var._position_relative, _guideCurved29_var._rotation_relative, _particle); _particle_save = *_particle; if ((( ! _instrument_var._parameters.VIRTUALIN ))) // conditional WHEN class_Guide_trace(&_guideCurved29_var, _particle); if (_particle->_restore) particle_restore(_particle, &_particle_save); _particle->_index++; } // guideCurved30 if (!ABSORBED && _particle->_index == 35) { #ifndef MULTICORE if (_guideCurved30_var._rotation_is_identity) coords_get(coords_add(coords_set(x,y,z), _guideCurved30_var._position_relative),&x, &y, &z); else #endif mccoordschange(_guideCurved30_var._position_relative, _guideCurved30_var._rotation_relative, _particle); _particle_save = *_particle; if ((( ! _instrument_var._parameters.VIRTUALIN ))) // conditional WHEN class_Guide_trace(&_guideCurved30_var, _particle); if (_particle->_restore) particle_restore(_particle, &_particle_save); _particle->_index++; } // guideCurved31 if (!ABSORBED && _particle->_index == 36) { #ifndef MULTICORE if (_guideCurved31_var._rotation_is_identity) coords_get(coords_add(coords_set(x,y,z), _guideCurved31_var._position_relative),&x, &y, &z); else #endif mccoordschange(_guideCurved31_var._position_relative, _guideCurved31_var._rotation_relative, _particle); _particle_save = *_particle; if ((( ! _instrument_var._parameters.VIRTUALIN ))) // conditional WHEN class_Guide_trace(&_guideCurved31_var, _particle); if (_particle->_restore) particle_restore(_particle, &_particle_save); _particle->_index++; } // guideCurved32 if (!ABSORBED && _particle->_index == 37) { #ifndef MULTICORE if (_guideCurved32_var._rotation_is_identity) coords_get(coords_add(coords_set(x,y,z), _guideCurved32_var._position_relative),&x, &y, &z); else #endif mccoordschange(_guideCurved32_var._position_relative, _guideCurved32_var._rotation_relative, _particle); _particle_save = *_particle; if ((( ! _instrument_var._parameters.VIRTUALIN ))) // conditional WHEN class_Guide_trace(&_guideCurved32_var, _particle); if (_particle->_restore) particle_restore(_particle, &_particle_save); _particle->_index++; } // guideCurved33 if (!ABSORBED && _particle->_index == 38) { #ifndef MULTICORE if (_guideCurved33_var._rotation_is_identity) coords_get(coords_add(coords_set(x,y,z), _guideCurved33_var._position_relative),&x, &y, &z); else #endif mccoordschange(_guideCurved33_var._position_relative, _guideCurved33_var._rotation_relative, _particle); _particle_save = *_particle; if ((( ! _instrument_var._parameters.VIRTUALIN ))) // conditional WHEN class_Guide_trace(&_guideCurved33_var, _particle); if (_particle->_restore) particle_restore(_particle, &_particle_save); _particle->_index++; } // guideCurved34 if (!ABSORBED && _particle->_index == 39) { #ifndef MULTICORE if (_guideCurved34_var._rotation_is_identity) coords_get(coords_add(coords_set(x,y,z), _guideCurved34_var._position_relative),&x, &y, &z); else #endif mccoordschange(_guideCurved34_var._position_relative, _guideCurved34_var._rotation_relative, _particle); _particle_save = *_particle; if ((( ! _instrument_var._parameters.VIRTUALIN ))) // conditional WHEN class_Guide_trace(&_guideCurved34_var, _particle); if (_particle->_restore) particle_restore(_particle, &_particle_save); _particle->_index++; } // guideCurved35 if (!ABSORBED && _particle->_index == 40) { #ifndef MULTICORE if (_guideCurved35_var._rotation_is_identity) coords_get(coords_add(coords_set(x,y,z), _guideCurved35_var._position_relative),&x, &y, &z); else #endif mccoordschange(_guideCurved35_var._position_relative, _guideCurved35_var._rotation_relative, _particle); _particle_save = *_particle; if ((( ! _instrument_var._parameters.VIRTUALIN ))) // conditional WHEN class_Guide_trace(&_guideCurved35_var, _particle); if (_particle->_restore) particle_restore(_particle, &_particle_save); _particle->_index++; } // guideCurved36 if (!ABSORBED && _particle->_index == 41) { #ifndef MULTICORE if (_guideCurved36_var._rotation_is_identity) coords_get(coords_add(coords_set(x,y,z), _guideCurved36_var._position_relative),&x, &y, &z); else #endif mccoordschange(_guideCurved36_var._position_relative, _guideCurved36_var._rotation_relative, _particle); _particle_save = *_particle; if ((( ! _instrument_var._parameters.VIRTUALIN ))) // conditional WHEN class_Guide_trace(&_guideCurved36_var, _particle); if (_particle->_restore) particle_restore(_particle, &_particle_save); _particle->_index++; } // guideCurved37 if (!ABSORBED && _particle->_index == 42) { #ifndef MULTICORE if (_guideCurved37_var._rotation_is_identity) coords_get(coords_add(coords_set(x,y,z), _guideCurved37_var._position_relative),&x, &y, &z); else #endif mccoordschange(_guideCurved37_var._position_relative, _guideCurved37_var._rotation_relative, _particle); _particle_save = *_particle; if ((( ! _instrument_var._parameters.VIRTUALIN ))) // conditional WHEN class_Guide_trace(&_guideCurved37_var, _particle); if (_particle->_restore) particle_restore(_particle, &_particle_save); _particle->_index++; } // guideCurved38 if (!ABSORBED && _particle->_index == 43) { #ifndef MULTICORE if (_guideCurved38_var._rotation_is_identity) coords_get(coords_add(coords_set(x,y,z), _guideCurved38_var._position_relative),&x, &y, &z); else #endif mccoordschange(_guideCurved38_var._position_relative, _guideCurved38_var._rotation_relative, _particle); _particle_save = *_particle; if ((( ! _instrument_var._parameters.VIRTUALIN ))) // conditional WHEN class_Guide_trace(&_guideCurved38_var, _particle); if (_particle->_restore) particle_restore(_particle, &_particle_save); _particle->_index++; } // guideCurved39 if (!ABSORBED && _particle->_index == 44) { #ifndef MULTICORE if (_guideCurved39_var._rotation_is_identity) coords_get(coords_add(coords_set(x,y,z), _guideCurved39_var._position_relative),&x, &y, &z); else #endif mccoordschange(_guideCurved39_var._position_relative, _guideCurved39_var._rotation_relative, _particle); _particle_save = *_particle; if ((( ! _instrument_var._parameters.VIRTUALIN ))) // conditional WHEN class_Guide_trace(&_guideCurved39_var, _particle); if (_particle->_restore) particle_restore(_particle, &_particle_save); _particle->_index++; } // guideCurved40 if (!ABSORBED && _particle->_index == 45) { #ifndef MULTICORE if (_guideCurved40_var._rotation_is_identity) coords_get(coords_add(coords_set(x,y,z), _guideCurved40_var._position_relative),&x, &y, &z); else #endif mccoordschange(_guideCurved40_var._position_relative, _guideCurved40_var._rotation_relative, _particle); _particle_save = *_particle; if ((( ! _instrument_var._parameters.VIRTUALIN ))) // conditional WHEN class_Guide_trace(&_guideCurved40_var, _particle); if (_particle->_restore) particle_restore(_particle, &_particle_save); _particle->_index++; } // bunker if (!ABSORBED && _particle->_index == 46) { #ifndef MULTICORE if (_bunker_var._rotation_is_identity) coords_get(coords_add(coords_set(x,y,z), _bunker_var._position_relative),&x, &y, &z); else #endif mccoordschange(_bunker_var._position_relative, _bunker_var._rotation_relative, _particle); _particle_save = *_particle; if ((( ! _instrument_var._parameters.VIRTUALIN ))) // conditional WHEN class_Guide_trace(&_bunker_var, _particle); if (_particle->_restore) particle_restore(_particle, &_particle_save); _particle->_index++; } // guide3 if (!ABSORBED && _particle->_index == 47) { #ifndef MULTICORE if (_guide3_var._rotation_is_identity) coords_get(coords_add(coords_set(x,y,z), _guide3_var._position_relative),&x, &y, &z); else #endif mccoordschange(_guide3_var._position_relative, _guide3_var._rotation_relative, _particle); _particle_save = *_particle; if ((( ! _instrument_var._parameters.VIRTUALIN ))) // conditional WHEN class_Guide_trace(&_guide3_var, _particle); if (_particle->_restore) particle_restore(_particle, &_particle_save); _particle->_index++; } // slitGuideEnd if (!ABSORBED && _particle->_index == 48) { #ifndef MULTICORE if (_slitGuideEnd_var._rotation_is_identity) coords_get(coords_add(coords_set(x,y,z), _slitGuideEnd_var._position_relative),&x, &y, &z); else #endif mccoordschange(_slitGuideEnd_var._position_relative, _slitGuideEnd_var._rotation_relative, _particle); _particle_save = *_particle; if ((( ! _instrument_var._parameters.VIRTUALIN ))) // conditional WHEN class_Slit_trace(&_slitGuideEnd_var, _particle); if (_particle->_restore) particle_restore(_particle, &_particle_save); _particle->_index++; } // psd_guide_end if (!ABSORBED && _particle->_index == 49) { #ifndef MULTICORE if (_psd_guide_end_var._rotation_is_identity) coords_get(coords_add(coords_set(x,y,z), _psd_guide_end_var._position_relative),&x, &y, &z); else #endif mccoordschange(_psd_guide_end_var._position_relative, _psd_guide_end_var._rotation_relative, _particle); _particle_save = *_particle; if ((( ! _instrument_var._parameters.VIRTUALIN ))) // conditional WHEN class_PSD_monitor_trace(&_psd_guide_end_var, _particle); if (_particle->_restore) particle_restore(_particle, &_particle_save); _particle->_index++; } // emon_guide_end if (!ABSORBED && _particle->_index == 50) { #ifndef MULTICORE if (_emon_guide_end_var._rotation_is_identity) coords_get(coords_add(coords_set(x,y,z), _emon_guide_end_var._position_relative),&x, &y, &z); else #endif mccoordschange(_emon_guide_end_var._position_relative, _emon_guide_end_var._rotation_relative, _particle); _particle_save = *_particle; class_E_monitor_trace(&_emon_guide_end_var, _particle); if (_particle->_restore) particle_restore(_particle, &_particle_save); _particle->_index++; } // lmon_guide_end if (!ABSORBED && _particle->_index == 51) { #ifndef MULTICORE if (_lmon_guide_end_var._rotation_is_identity) coords_get(coords_add(coords_set(x,y,z), _lmon_guide_end_var._position_relative),&x, &y, &z); else #endif mccoordschange(_lmon_guide_end_var._position_relative, _lmon_guide_end_var._rotation_relative, _particle); _particle_save = *_particle; if ((( ! _instrument_var._parameters.VIRTUALIN ))) // conditional WHEN class_L_monitor_trace(&_lmon_guide_end_var, _particle); if (_particle->_restore) particle_restore(_particle, &_particle_save); _particle->_index++; } // divmon_guide_end if (!ABSORBED && _particle->_index == 52) { #ifndef MULTICORE if (_divmon_guide_end_var._rotation_is_identity) coords_get(coords_add(coords_set(x,y,z), _divmon_guide_end_var._position_relative),&x, &y, &z); else #endif mccoordschange(_divmon_guide_end_var._position_relative, _divmon_guide_end_var._rotation_relative, _particle); _particle_save = *_particle; if ((( ! _instrument_var._parameters.VIRTUALIN ))) // conditional WHEN class_Divergence_monitor_trace(&_divmon_guide_end_var, _particle); if (_particle->_restore) particle_restore(_particle, &_particle_save); _particle->_index++; } // focus_mono if (!ABSORBED && _particle->_index == 53) { #ifndef MULTICORE if (_focus_mono_var._rotation_is_identity) coords_get(coords_add(coords_set(x,y,z), _focus_mono_var._position_relative),&x, &y, &z); else #endif mccoordschange(_focus_mono_var._position_relative, _focus_mono_var._rotation_relative, _particle); _particle_save = *_particle; if ((( ! _instrument_var._parameters.VIRTUALIN ))) // conditional WHEN class_Arm_trace(&_focus_mono_var, _particle); /* contains EXTEND code */ if (_particle->_restore) particle_restore(_particle, &_particle_save); _particle->_index++; } } // SPLIT with available livebatchsize long mult_monochromator_curved; livebatchsize = sort_absorb_last(particles, pbuffer, livebatchsize, gpu_innerloop, 1, &mult_monochromator_curved); //printf("livebatchsize: %ld, split: %ld\n", livebatchsize, mult); #pragma acc parallel loop present(particles[0:livebatchsize]) for (unsigned long pidx=0 ; pidx < livebatchsize ; pidx++) { _class_particle* _particle = &particles[pidx]; _class_particle _particle_save; // monochromator_curved if (!ABSORBED && _particle->_index == 54) { #ifndef MULTICORE if (_monochromator_curved_var._rotation_is_identity) coords_get(coords_add(coords_set(x,y,z), _monochromator_curved_var._position_relative),&x, &y, &z); else #endif mccoordschange(_monochromator_curved_var._position_relative, _monochromator_curved_var._rotation_relative, _particle); _particle_save = *_particle; if ((( ! _instrument_var._parameters.VIRTUALIN ))) // conditional WHEN class_Monochromator_curved_trace(&_monochromator_curved_var, _particle); /* contains EXTEND code */ if (_particle->_restore) particle_restore(_particle, &_particle_save); _particle->_index++; } // a2 if (!ABSORBED && _particle->_index == 55) { _particle->_index++; } // slitShutter if (!ABSORBED && _particle->_index == 56) { #ifndef MULTICORE if (_slitShutter_var._rotation_is_identity) coords_get(coords_add(coords_set(x,y,z), _slitShutter_var._position_relative),&x, &y, &z); else #endif mccoordschange(_slitShutter_var._position_relative, _slitShutter_var._rotation_relative, _particle); _particle_save = *_particle; if ((( ! _instrument_var._parameters.VIRTUALIN ))) // conditional WHEN class_Slit_trace(&_slitShutter_var, _particle); if (_particle->_restore) particle_restore(_particle, &_particle_save); _particle->_index++; } // MSCollimator if (!ABSORBED && _particle->_index == 57) { #ifndef MULTICORE if (_MSCollimator_var._rotation_is_identity) coords_get(coords_add(coords_set(x,y,z), _MSCollimator_var._position_relative),&x, &y, &z); else #endif mccoordschange(_MSCollimator_var._position_relative, _MSCollimator_var._rotation_relative, _particle); _particle_save = *_particle; if ((( ! _instrument_var._parameters.VIRTUALIN ))) // conditional WHEN class_Collimator_linear_trace(&_MSCollimator_var, _particle); if (_particle->_restore) particle_restore(_particle, &_particle_save); _particle->_index++; } // infilter if (!ABSORBED && _particle->_index == 58) { #ifndef MULTICORE if (_infilter_var._rotation_is_identity) coords_get(coords_add(coords_set(x,y,z), _infilter_var._position_relative),&x, &y, &z); else #endif mccoordschange(_infilter_var._position_relative, _infilter_var._rotation_relative, _particle); _particle_save = *_particle; if ((( _instrument_var._parameters.INFILTER > 0 && ! _instrument_var._parameters.VIRTUALIN ))) // conditional WHEN class_Filter_gen_trace(&_infilter_var, _particle); if (_particle->_restore) particle_restore(_particle, &_particle_save); _particle->_index++; } // psd_virt if (!ABSORBED && _particle->_index == 59) { #ifndef MULTICORE if (_psd_virt_var._rotation_is_identity) coords_get(coords_add(coords_set(x,y,z), _psd_virt_var._position_relative),&x, &y, &z); else #endif mccoordschange(_psd_virt_var._position_relative, _psd_virt_var._rotation_relative, _particle); _particle_save = *_particle; if ((( ! _instrument_var._parameters.VIRTUALIN ))) // conditional WHEN class_PSD_monitor_trace(&_psd_virt_var, _particle); if (_particle->_restore) particle_restore(_particle, &_particle_save); _particle->_index++; } // lmon_virt if (!ABSORBED && _particle->_index == 60) { #ifndef MULTICORE if (_lmon_virt_var._rotation_is_identity) coords_get(coords_add(coords_set(x,y,z), _lmon_virt_var._position_relative),&x, &y, &z); else #endif mccoordschange(_lmon_virt_var._position_relative, _lmon_virt_var._rotation_relative, _particle); _particle_save = *_particle; if ((( ! _instrument_var._parameters.VIRTUALIN ))) // conditional WHEN class_L_monitor_trace(&_lmon_virt_var, _particle); if (_particle->_restore) particle_restore(_particle, &_particle_save); _particle->_index++; } // aa2 if (!ABSORBED && _particle->_index == 61) { _particle->_index++; } // OrderMon if (!ABSORBED && _particle->_index == 62) { #ifndef MULTICORE if (_OrderMon_var._rotation_is_identity) coords_get(coords_add(coords_set(x,y,z), _OrderMon_var._position_relative),&x, &y, &z); else #endif mccoordschange(_OrderMon_var._position_relative, _OrderMon_var._rotation_relative, _particle); _particle_save = *_particle; if ((( Mono_order && ! _instrument_var._parameters.VIRTUALOUT ))) // conditional WHEN class_Monitor_nD_trace(&_OrderMon_var, _particle); if (_particle->_restore) particle_restore(_particle, &_particle_save); _particle->_index++; } // kMoni if (!ABSORBED && _particle->_index == 63) { #ifndef MULTICORE if (_kMoni_var._rotation_is_identity) coords_get(coords_add(coords_set(x,y,z), _kMoni_var._position_relative),&x, &y, &z); else #endif mccoordschange(_kMoni_var._position_relative, _kMoni_var._rotation_relative, _particle); _particle_save = *_particle; if ((( ! _instrument_var._parameters.VIRTUALOUT ))) // conditional WHEN class_PSD_monitor_psf_eff_trace(&_kMoni_var, _particle); if (_particle->_restore) particle_restore(_particle, &_particle_save); _particle->_index++; } // kMoni1st if (!ABSORBED && _particle->_index == 64) { #ifndef MULTICORE if (_kMoni1st_var._rotation_is_identity) coords_get(coords_add(coords_set(x,y,z), _kMoni1st_var._position_relative),&x, &y, &z); else #endif mccoordschange(_kMoni1st_var._position_relative, _kMoni1st_var._rotation_relative, _particle); _particle_save = *_particle; if ((( Mono_order == 1 && ! _instrument_var._parameters.VIRTUALOUT ))) // conditional WHEN class_PSD_monitor_psf_eff_trace(&_kMoni1st_var, _particle); if (_particle->_restore) particle_restore(_particle, &_particle_save); _particle->_index++; } // kMoni2nd if (!ABSORBED && _particle->_index == 65) { #ifndef MULTICORE if (_kMoni2nd_var._rotation_is_identity) coords_get(coords_add(coords_set(x,y,z), _kMoni2nd_var._position_relative),&x, &y, &z); else #endif mccoordschange(_kMoni2nd_var._position_relative, _kMoni2nd_var._rotation_relative, _particle); _particle_save = *_particle; if ((( Mono_order == 2 && ! _instrument_var._parameters.VIRTUALOUT ))) // conditional WHEN class_PSD_monitor_psf_eff_trace(&_kMoni2nd_var, _particle); if (_particle->_restore) particle_restore(_particle, &_particle_save); _particle->_index++; } // kMoni3rd if (!ABSORBED && _particle->_index == 66) { #ifndef MULTICORE if (_kMoni3rd_var._rotation_is_identity) coords_get(coords_add(coords_set(x,y,z), _kMoni3rd_var._position_relative),&x, &y, &z); else #endif mccoordschange(_kMoni3rd_var._position_relative, _kMoni3rd_var._rotation_relative, _particle); _particle_save = *_particle; if ((( Mono_order == 3 && ! _instrument_var._parameters.VIRTUALOUT ))) // conditional WHEN class_PSD_monitor_psf_eff_trace(&_kMoni3rd_var, _particle); if (_particle->_restore) particle_restore(_particle, &_particle_save); _particle->_index++; } // slitMonochromator if (!ABSORBED && _particle->_index == 67) { #ifndef MULTICORE if (_slitMonochromator_var._rotation_is_identity) coords_get(coords_add(coords_set(x,y,z), _slitMonochromator_var._position_relative),&x, &y, &z); else #endif mccoordschange(_slitMonochromator_var._position_relative, _slitMonochromator_var._rotation_relative, _particle); _particle_save = *_particle; if ((( ! _instrument_var._parameters.VIRTUALOUT ))) // conditional WHEN class_Slit_trace(&_slitMonochromator_var, _particle); if (_particle->_restore) particle_restore(_particle, &_particle_save); _particle->_index++; } // Perspex if (!ABSORBED && _particle->_index == 68) { #ifndef MULTICORE if (_Perspex_var._rotation_is_identity) coords_get(coords_add(coords_set(x,y,z), _Perspex_var._position_relative),&x, &y, &z); else #endif mccoordschange(_Perspex_var._position_relative, _Perspex_var._rotation_relative, _particle); _particle_save = *_particle; if ((( _instrument_var._parameters.PERSPEX > 0 && ! _instrument_var._parameters.VIRTUALOUT ))) // conditional WHEN class_Incoherent_trace(&_Perspex_var, _particle); if (_particle->_restore) particle_restore(_particle, &_particle_save); _particle->_index++; } // psd_samplepos_1cm2 if (!ABSORBED && _particle->_index == 69) { #ifndef MULTICORE if (_psd_samplepos_1cm2_var._rotation_is_identity) coords_get(coords_add(coords_set(x,y,z), _psd_samplepos_1cm2_var._position_relative),&x, &y, &z); else #endif mccoordschange(_psd_samplepos_1cm2_var._position_relative, _psd_samplepos_1cm2_var._rotation_relative, _particle); _particle_save = *_particle; if ((( ! _instrument_var._parameters.VIRTUALOUT ))) // conditional WHEN class_PSD_monitor_trace(&_psd_samplepos_1cm2_var, _particle); if (_particle->_restore) particle_restore(_particle, &_particle_save); _particle->_index++; } // emon_samplepos_1cm2 if (!ABSORBED && _particle->_index == 70) { #ifndef MULTICORE if (_emon_samplepos_1cm2_var._rotation_is_identity) coords_get(coords_add(coords_set(x,y,z), _emon_samplepos_1cm2_var._position_relative),&x, &y, &z); else #endif mccoordschange(_emon_samplepos_1cm2_var._position_relative, _emon_samplepos_1cm2_var._rotation_relative, _particle); _particle_save = *_particle; if ((( ! _instrument_var._parameters.VIRTUALOUT ))) // conditional WHEN class_E_monitor_trace(&_emon_samplepos_1cm2_var, _particle); if (_particle->_restore) particle_restore(_particle, &_particle_save); _particle->_index++; } // divmon_samplepos_1cm2 if (!ABSORBED && _particle->_index == 71) { #ifndef MULTICORE if (_divmon_samplepos_1cm2_var._rotation_is_identity) coords_get(coords_add(coords_set(x,y,z), _divmon_samplepos_1cm2_var._position_relative),&x, &y, &z); else #endif mccoordschange(_divmon_samplepos_1cm2_var._position_relative, _divmon_samplepos_1cm2_var._rotation_relative, _particle); _particle_save = *_particle; if ((( ! _instrument_var._parameters.VIRTUALOUT ))) // conditional WHEN class_Divergence_monitor_trace(&_divmon_samplepos_1cm2_var, _particle); if (_particle->_restore) particle_restore(_particle, &_particle_save); _particle->_index++; } // psd_samplepos_large if (!ABSORBED && _particle->_index == 72) { #ifndef MULTICORE if (_psd_samplepos_large_var._rotation_is_identity) coords_get(coords_add(coords_set(x,y,z), _psd_samplepos_large_var._position_relative),&x, &y, &z); else #endif mccoordschange(_psd_samplepos_large_var._position_relative, _psd_samplepos_large_var._rotation_relative, _particle); _particle_save = *_particle; if ((( ! _instrument_var._parameters.VIRTUALOUT ))) // conditional WHEN class_PSD_monitor_trace(&_psd_samplepos_large_var, _particle); if (_particle->_restore) particle_restore(_particle, &_particle_save); _particle->_index++; } } // SPLIT with available livebatchsize long mult_a3; livebatchsize = sort_absorb_last(particles, pbuffer, livebatchsize, gpu_innerloop, 1, &mult_a3); //printf("livebatchsize: %ld, split: %ld\n", livebatchsize, mult); #pragma acc parallel loop present(particles[0:livebatchsize]) for (unsigned long pidx=0 ; pidx < livebatchsize ; pidx++) { _class_particle* _particle = &particles[pidx]; _class_particle _particle_save; // a3 if (!ABSORBED && _particle->_index == 73) { _particle->_index++; } // aa3 if (!ABSORBED && _particle->_index == 74) { _particle->_index++; } // incohSample if (!ABSORBED && _particle->_index == 75) { #ifndef MULTICORE if (_incohSample_var._rotation_is_identity) coords_get(coords_add(coords_set(x,y,z), _incohSample_var._position_relative),&x, &y, &z); else #endif mccoordschange(_incohSample_var._position_relative, _incohSample_var._rotation_relative, _particle); _particle_save = *_particle; if ((( _instrument_var._parameters.SAMPLE == 1 && ! _instrument_var._parameters.VIRTUALOUT ))) // conditional WHEN class_Incoherent_trace(&_incohSample_var, _particle); if (_particle->_restore) particle_restore(_particle, &_particle_save); _particle->_index++; } // powderSample if (!ABSORBED && _particle->_index == 76) { #ifndef MULTICORE if (_powderSample_var._rotation_is_identity) coords_get(coords_add(coords_set(x,y,z), _powderSample_var._position_relative),&x, &y, &z); else #endif mccoordschange(_powderSample_var._position_relative, _powderSample_var._rotation_relative, _particle); _particle_save = *_particle; if ((( _instrument_var._parameters.SAMPLE == 2 && ! _instrument_var._parameters.VIRTUALOUT ))) // conditional WHEN class_PowderN_trace(&_powderSample_var, _particle); if (_particle->_restore) particle_restore(_particle, &_particle_save); _particle->_index++; } // crystalSample if (!ABSORBED && _particle->_index == 77) { #ifndef MULTICORE if (_crystalSample_var._rotation_is_identity) coords_get(coords_add(coords_set(x,y,z), _crystalSample_var._position_relative),&x, &y, &z); else #endif mccoordschange(_crystalSample_var._position_relative, _crystalSample_var._rotation_relative, _particle); _particle_save = *_particle; if ((( _instrument_var._parameters.SAMPLE == 3 && ! _instrument_var._parameters.VIRTUALOUT ))) // conditional WHEN class_Single_crystal_trace(&_crystalSample_var, _particle); /* contains EXTEND code */ if (_particle->_restore) particle_restore(_particle, &_particle_save); _particle->_index++; } // phononSample if (!ABSORBED && _particle->_index == 78) { #ifndef MULTICORE if (_phononSample_var._rotation_is_identity) coords_get(coords_add(coords_set(x,y,z), _phononSample_var._position_relative),&x, &y, &z); else #endif mccoordschange(_phononSample_var._position_relative, _phononSample_var._rotation_relative, _particle); _particle_save = *_particle; if ((( _instrument_var._parameters.SAMPLE == 4 && ! _instrument_var._parameters.VIRTUALOUT ))) // conditional WHEN class_Phonon_simple_trace(&_phononSample_var, _particle); if (_particle->_restore) particle_restore(_particle, &_particle_save); _particle->_index++; } // psd_4pi if (!ABSORBED && _particle->_index == 79) { #ifndef MULTICORE if (_psd_4pi_var._rotation_is_identity) coords_get(coords_add(coords_set(x,y,z), _psd_4pi_var._position_relative),&x, &y, &z); else #endif mccoordschange(_psd_4pi_var._position_relative, _psd_4pi_var._rotation_relative, _particle); _particle_save = *_particle; if ((( ! _instrument_var._parameters.VIRTUALOUT ))) // conditional WHEN class_PSD_monitor_4PI_trace(&_psd_4pi_var, _particle); if (_particle->_restore) particle_restore(_particle, &_particle_save); _particle->_index++; } // a4 if (!ABSORBED && _particle->_index == 80) { _particle->_index++; } // slitSample if (!ABSORBED && _particle->_index == 81) { #ifndef MULTICORE if (_slitSample_var._rotation_is_identity) coords_get(coords_add(coords_set(x,y,z), _slitSample_var._position_relative),&x, &y, &z); else #endif mccoordschange(_slitSample_var._position_relative, _slitSample_var._rotation_relative, _particle); _particle_save = *_particle; if ((( ! _instrument_var._parameters.VIRTUALOUT ))) // conditional WHEN class_Slit_trace(&_slitSample_var, _particle); if (_particle->_restore) particle_restore(_particle, &_particle_save); _particle->_index++; } // filter_coll if (!ABSORBED && _particle->_index == 82) { #ifndef MULTICORE if (_filter_coll_var._rotation_is_identity) coords_get(coords_add(coords_set(x,y,z), _filter_coll_var._position_relative),&x, &y, &z); else #endif mccoordschange(_filter_coll_var._position_relative, _filter_coll_var._rotation_relative, _particle); _particle_save = *_particle; if ((( _instrument_var._parameters.OUTFILTER > 0 && ! _instrument_var._parameters.VIRTUALOUT ))) // conditional WHEN class_Exact_radial_coll_trace(&_filter_coll_var, _particle); if (_particle->_restore) particle_restore(_particle, &_particle_save); _particle->_index++; } // filter if (!ABSORBED && _particle->_index == 83) { #ifndef MULTICORE if (_filter_var._rotation_is_identity) coords_get(coords_add(coords_set(x,y,z), _filter_var._position_relative),&x, &y, &z); else #endif mccoordschange(_filter_var._position_relative, _filter_var._rotation_relative, _particle); _particle_save = *_particle; if ((( _instrument_var._parameters.OUTFILTER > 0 && ! _instrument_var._parameters.VIRTUALOUT ))) // conditional WHEN class_Filter_gen_trace(&_filter_var, _particle); if (_particle->_restore) particle_restore(_particle, &_particle_save); _particle->_index++; } // ana_slit1 if (!ABSORBED && _particle->_index == 84) { #ifndef MULTICORE if (_ana_slit1_var._rotation_is_identity) coords_get(coords_add(coords_set(x,y,z), _ana_slit1_var._position_relative),&x, &y, &z); else #endif mccoordschange(_ana_slit1_var._position_relative, _ana_slit1_var._rotation_relative, _particle); _particle_save = *_particle; if ((( ! _instrument_var._parameters.VIRTUALOUT ))) // conditional WHEN class_Slit_trace(&_ana_slit1_var, _particle); if (_particle->_restore) particle_restore(_particle, &_particle_save); _particle->_index++; } // ana_slit2 if (!ABSORBED && _particle->_index == 85) { #ifndef MULTICORE if (_ana_slit2_var._rotation_is_identity) coords_get(coords_add(coords_set(x,y,z), _ana_slit2_var._position_relative),&x, &y, &z); else #endif mccoordschange(_ana_slit2_var._position_relative, _ana_slit2_var._rotation_relative, _particle); _particle_save = *_particle; if ((( ! _instrument_var._parameters.VIRTUALOUT ))) // conditional WHEN class_Slit_trace(&_ana_slit2_var, _particle); if (_particle->_restore) particle_restore(_particle, &_particle_save); _particle->_index++; } // emon_before_ana if (!ABSORBED && _particle->_index == 86) { #ifndef MULTICORE if (_emon_before_ana_var._rotation_is_identity) coords_get(coords_add(coords_set(x,y,z), _emon_before_ana_var._position_relative),&x, &y, &z); else #endif mccoordschange(_emon_before_ana_var._position_relative, _emon_before_ana_var._rotation_relative, _particle); _particle_save = *_particle; if ((( ! _instrument_var._parameters.VIRTUALOUT ))) // conditional WHEN class_E_monitor_trace(&_emon_before_ana_var, _particle); if (_particle->_restore) particle_restore(_particle, &_particle_save); _particle->_index++; } // psd_before_ana if (!ABSORBED && _particle->_index == 87) { #ifndef MULTICORE if (_psd_before_ana_var._rotation_is_identity) coords_get(coords_add(coords_set(x,y,z), _psd_before_ana_var._position_relative),&x, &y, &z); else #endif mccoordschange(_psd_before_ana_var._position_relative, _psd_before_ana_var._rotation_relative, _particle); _particle_save = *_particle; if ((( ! _instrument_var._parameters.VIRTUALOUT ))) // conditional WHEN class_PSD_monitor_trace(&_psd_before_ana_var, _particle); if (_particle->_restore) particle_restore(_particle, &_particle_save); _particle->_index++; } // divmon_before_ana if (!ABSORBED && _particle->_index == 88) { #ifndef MULTICORE if (_divmon_before_ana_var._rotation_is_identity) coords_get(coords_add(coords_set(x,y,z), _divmon_before_ana_var._position_relative),&x, &y, &z); else #endif mccoordschange(_divmon_before_ana_var._position_relative, _divmon_before_ana_var._rotation_relative, _particle); _particle_save = *_particle; if ((( ! _instrument_var._parameters.VIRTUALOUT ))) // conditional WHEN class_Divergence_monitor_trace(&_divmon_before_ana_var, _particle); if (_particle->_restore) particle_restore(_particle, &_particle_save); _particle->_index++; } } // SPLIT with available livebatchsize long mult_focus_ana; livebatchsize = sort_absorb_last(particles, pbuffer, livebatchsize, gpu_innerloop, 1, &mult_focus_ana); //printf("livebatchsize: %ld, split: %ld\n", livebatchsize, mult); #pragma acc parallel loop present(particles[0:livebatchsize]) for (unsigned long pidx=0 ; pidx < livebatchsize ; pidx++) { _class_particle* _particle = &particles[pidx]; _class_particle _particle_save; // focus_ana if (!ABSORBED && _particle->_index == 89) { #ifndef MULTICORE if (_focus_ana_var._rotation_is_identity) coords_get(coords_add(coords_set(x,y,z), _focus_ana_var._position_relative),&x, &y, &z); else #endif mccoordschange(_focus_ana_var._position_relative, _focus_ana_var._rotation_relative, _particle); _particle_save = *_particle; if ((( ! _instrument_var._parameters.VIRTUALOUT ))) // conditional WHEN class_Arm_trace(&_focus_ana_var, _particle); /* contains EXTEND code */ if (_particle->_restore) particle_restore(_particle, &_particle_save); _particle->_index++; } // an1l if (!ABSORBED && _particle->_index == 90) { #ifndef MULTICORE if (_an1l_var._rotation_is_identity) coords_get(coords_add(coords_set(x,y,z), _an1l_var._position_relative),&x, &y, &z); else #endif mccoordschange(_an1l_var._position_relative, _an1l_var._rotation_relative, _particle); _particle_save = *_particle; if ((( ! _instrument_var._parameters.VIRTUALOUT ))) // conditional WHEN class_Monochromator_flat_trace(&_an1l_var, _particle); /* contains EXTEND code */ if (_particle->_restore) particle_restore(_particle, &_particle_save); _particle->_index++; } // an1u if (!ABSORBED && _particle->_index == 91) { #ifndef MULTICORE if (_an1u_var._rotation_is_identity) coords_get(coords_add(coords_set(x,y,z), _an1u_var._position_relative),&x, &y, &z); else #endif mccoordschange(_an1u_var._position_relative, _an1u_var._rotation_relative, _particle); _particle_save = *_particle; if ((( ! _instrument_var._parameters.VIRTUALOUT ))) // conditional WHEN class_Monochromator_flat_trace(&_an1u_var, _particle); /* contains EXTEND code */ if (_particle->_restore) particle_restore(_particle, &_particle_save); _particle->_index++; } // an2l if (!ABSORBED && _particle->_index == 92) { #ifndef MULTICORE if (_an2l_var._rotation_is_identity) coords_get(coords_add(coords_set(x,y,z), _an2l_var._position_relative),&x, &y, &z); else #endif mccoordschange(_an2l_var._position_relative, _an2l_var._rotation_relative, _particle); _particle_save = *_particle; if ((( ! _instrument_var._parameters.VIRTUALOUT ))) // conditional WHEN class_Monochromator_flat_trace(&_an2l_var, _particle); /* contains EXTEND code */ if (_particle->_restore) particle_restore(_particle, &_particle_save); _particle->_index++; } // an2u if (!ABSORBED && _particle->_index == 93) { #ifndef MULTICORE if (_an2u_var._rotation_is_identity) coords_get(coords_add(coords_set(x,y,z), _an2u_var._position_relative),&x, &y, &z); else #endif mccoordschange(_an2u_var._position_relative, _an2u_var._rotation_relative, _particle); _particle_save = *_particle; if ((( ! _instrument_var._parameters.VIRTUALOUT ))) // conditional WHEN class_Monochromator_flat_trace(&_an2u_var, _particle); /* contains EXTEND code */ if (_particle->_restore) particle_restore(_particle, &_particle_save); _particle->_index++; } // an3l if (!ABSORBED && _particle->_index == 94) { #ifndef MULTICORE if (_an3l_var._rotation_is_identity) coords_get(coords_add(coords_set(x,y,z), _an3l_var._position_relative),&x, &y, &z); else #endif mccoordschange(_an3l_var._position_relative, _an3l_var._rotation_relative, _particle); _particle_save = *_particle; if ((( ! _instrument_var._parameters.VIRTUALOUT ))) // conditional WHEN class_Monochromator_flat_trace(&_an3l_var, _particle); /* contains EXTEND code */ if (_particle->_restore) particle_restore(_particle, &_particle_save); _particle->_index++; } // an3u if (!ABSORBED && _particle->_index == 95) { #ifndef MULTICORE if (_an3u_var._rotation_is_identity) coords_get(coords_add(coords_set(x,y,z), _an3u_var._position_relative),&x, &y, &z); else #endif mccoordschange(_an3u_var._position_relative, _an3u_var._rotation_relative, _particle); _particle_save = *_particle; if ((( ! _instrument_var._parameters.VIRTUALOUT ))) // conditional WHEN class_Monochromator_flat_trace(&_an3u_var, _particle); /* contains EXTEND code */ if (_particle->_restore) particle_restore(_particle, &_particle_save); _particle->_index++; } // an4l if (!ABSORBED && _particle->_index == 96) { #ifndef MULTICORE if (_an4l_var._rotation_is_identity) coords_get(coords_add(coords_set(x,y,z), _an4l_var._position_relative),&x, &y, &z); else #endif mccoordschange(_an4l_var._position_relative, _an4l_var._rotation_relative, _particle); _particle_save = *_particle; if ((( ! _instrument_var._parameters.VIRTUALOUT ))) // conditional WHEN class_Monochromator_flat_trace(&_an4l_var, _particle); /* contains EXTEND code */ if (_particle->_restore) particle_restore(_particle, &_particle_save); _particle->_index++; } // an4u if (!ABSORBED && _particle->_index == 97) { #ifndef MULTICORE if (_an4u_var._rotation_is_identity) coords_get(coords_add(coords_set(x,y,z), _an4u_var._position_relative),&x, &y, &z); else #endif mccoordschange(_an4u_var._position_relative, _an4u_var._rotation_relative, _particle); _particle_save = *_particle; if ((( ! _instrument_var._parameters.VIRTUALOUT ))) // conditional WHEN class_Monochromator_flat_trace(&_an4u_var, _particle); /* contains EXTEND code */ if (_particle->_restore) particle_restore(_particle, &_particle_save); _particle->_index++; } // an5l if (!ABSORBED && _particle->_index == 98) { #ifndef MULTICORE if (_an5l_var._rotation_is_identity) coords_get(coords_add(coords_set(x,y,z), _an5l_var._position_relative),&x, &y, &z); else #endif mccoordschange(_an5l_var._position_relative, _an5l_var._rotation_relative, _particle); _particle_save = *_particle; if ((( ! _instrument_var._parameters.VIRTUALOUT ))) // conditional WHEN class_Monochromator_flat_trace(&_an5l_var, _particle); /* contains EXTEND code */ if (_particle->_restore) particle_restore(_particle, &_particle_save); _particle->_index++; } // an5u if (!ABSORBED && _particle->_index == 99) { #ifndef MULTICORE if (_an5u_var._rotation_is_identity) coords_get(coords_add(coords_set(x,y,z), _an5u_var._position_relative),&x, &y, &z); else #endif mccoordschange(_an5u_var._position_relative, _an5u_var._rotation_relative, _particle); _particle_save = *_particle; if ((( ! _instrument_var._parameters.VIRTUALOUT ))) // conditional WHEN class_Monochromator_flat_trace(&_an5u_var, _particle); /* contains EXTEND code */ if (_particle->_restore) particle_restore(_particle, &_particle_save); _particle->_index++; } // an6l if (!ABSORBED && _particle->_index == 100) { #ifndef MULTICORE if (_an6l_var._rotation_is_identity) coords_get(coords_add(coords_set(x,y,z), _an6l_var._position_relative),&x, &y, &z); else #endif mccoordschange(_an6l_var._position_relative, _an6l_var._rotation_relative, _particle); _particle_save = *_particle; if ((( ! _instrument_var._parameters.VIRTUALOUT ))) // conditional WHEN class_Monochromator_flat_trace(&_an6l_var, _particle); /* contains EXTEND code */ if (_particle->_restore) particle_restore(_particle, &_particle_save); _particle->_index++; } // an6u if (!ABSORBED && _particle->_index == 101) { #ifndef MULTICORE if (_an6u_var._rotation_is_identity) coords_get(coords_add(coords_set(x,y,z), _an6u_var._position_relative),&x, &y, &z); else #endif mccoordschange(_an6u_var._position_relative, _an6u_var._rotation_relative, _particle); _particle_save = *_particle; if ((( ! _instrument_var._parameters.VIRTUALOUT ))) // conditional WHEN class_Monochromator_flat_trace(&_an6u_var, _particle); /* contains EXTEND code */ if (_particle->_restore) particle_restore(_particle, &_particle_save); _particle->_index++; } // an7l if (!ABSORBED && _particle->_index == 102) { #ifndef MULTICORE if (_an7l_var._rotation_is_identity) coords_get(coords_add(coords_set(x,y,z), _an7l_var._position_relative),&x, &y, &z); else #endif mccoordschange(_an7l_var._position_relative, _an7l_var._rotation_relative, _particle); _particle_save = *_particle; if ((( ! _instrument_var._parameters.VIRTUALOUT ))) // conditional WHEN class_Monochromator_flat_trace(&_an7l_var, _particle); /* contains EXTEND code */ if (_particle->_restore) particle_restore(_particle, &_particle_save); _particle->_index++; } // an7u if (!ABSORBED && _particle->_index == 103) { #ifndef MULTICORE if (_an7u_var._rotation_is_identity) coords_get(coords_add(coords_set(x,y,z), _an7u_var._position_relative),&x, &y, &z); else #endif mccoordschange(_an7u_var._position_relative, _an7u_var._rotation_relative, _particle); _particle_save = *_particle; if ((( ! _instrument_var._parameters.VIRTUALOUT ))) // conditional WHEN class_Monochromator_flat_trace(&_an7u_var, _particle); /* contains EXTEND code */ if (_particle->_restore) particle_restore(_particle, &_particle_save); _particle->_index++; } // an8l if (!ABSORBED && _particle->_index == 104) { #ifndef MULTICORE if (_an8l_var._rotation_is_identity) coords_get(coords_add(coords_set(x,y,z), _an8l_var._position_relative),&x, &y, &z); else #endif mccoordschange(_an8l_var._position_relative, _an8l_var._rotation_relative, _particle); _particle_save = *_particle; if ((( ! _instrument_var._parameters.VIRTUALOUT ))) // conditional WHEN class_Monochromator_flat_trace(&_an8l_var, _particle); /* contains EXTEND code */ if (_particle->_restore) particle_restore(_particle, &_particle_save); _particle->_index++; } // an8u if (!ABSORBED && _particle->_index == 105) { #ifndef MULTICORE if (_an8u_var._rotation_is_identity) coords_get(coords_add(coords_set(x,y,z), _an8u_var._position_relative),&x, &y, &z); else #endif mccoordschange(_an8u_var._position_relative, _an8u_var._rotation_relative, _particle); _particle_save = *_particle; if ((( ! _instrument_var._parameters.VIRTUALOUT ))) // conditional WHEN class_Monochromator_flat_trace(&_an8u_var, _particle); /* contains EXTEND code */ if (_particle->_restore) particle_restore(_particle, &_particle_save); _particle->_index++; } // an9l if (!ABSORBED && _particle->_index == 106) { #ifndef MULTICORE if (_an9l_var._rotation_is_identity) coords_get(coords_add(coords_set(x,y,z), _an9l_var._position_relative),&x, &y, &z); else #endif mccoordschange(_an9l_var._position_relative, _an9l_var._rotation_relative, _particle); _particle_save = *_particle; if ((( ! _instrument_var._parameters.VIRTUALOUT ))) // conditional WHEN class_Monochromator_flat_trace(&_an9l_var, _particle); /* contains EXTEND code */ if (_particle->_restore) particle_restore(_particle, &_particle_save); _particle->_index++; } // an9u if (!ABSORBED && _particle->_index == 107) { #ifndef MULTICORE if (_an9u_var._rotation_is_identity) coords_get(coords_add(coords_set(x,y,z), _an9u_var._position_relative),&x, &y, &z); else #endif mccoordschange(_an9u_var._position_relative, _an9u_var._rotation_relative, _particle); _particle_save = *_particle; if ((( ! _instrument_var._parameters.VIRTUALOUT ))) // conditional WHEN class_Monochromator_flat_trace(&_an9u_var, _particle); /* contains EXTEND code */ if (_particle->_restore) particle_restore(_particle, &_particle_save); _particle->_index++; } // a6 if (!ABSORBED && _particle->_index == 108) { _particle->_index++; } // emon_before_coarse if (!ABSORBED && _particle->_index == 109) { #ifndef MULTICORE if (_emon_before_coarse_var._rotation_is_identity) coords_get(coords_add(coords_set(x,y,z), _emon_before_coarse_var._position_relative),&x, &y, &z); else #endif mccoordschange(_emon_before_coarse_var._position_relative, _emon_before_coarse_var._rotation_relative, _particle); _particle_save = *_particle; if ((( ! _instrument_var._parameters.VIRTUALOUT ))) // conditional WHEN class_E_monitor_trace(&_emon_before_coarse_var, _particle); if (_particle->_restore) particle_restore(_particle, &_particle_save); _particle->_index++; } // psd_before_coarse if (!ABSORBED && _particle->_index == 110) { #ifndef MULTICORE if (_psd_before_coarse_var._rotation_is_identity) coords_get(coords_add(coords_set(x,y,z), _psd_before_coarse_var._position_relative),&x, &y, &z); else #endif mccoordschange(_psd_before_coarse_var._position_relative, _psd_before_coarse_var._rotation_relative, _particle); _particle_save = *_particle; if ((( ! _instrument_var._parameters.VIRTUALOUT ))) // conditional WHEN class_PSD_monitor_trace(&_psd_before_coarse_var, _particle); if (_particle->_restore) particle_restore(_particle, &_particle_save); _particle->_index++; } // ArmR1 if (!ABSORBED && _particle->_index == 111) { _particle->_index++; } // BladeR1 if (!ABSORBED && _particle->_index == 112) { #ifndef MULTICORE if (_BladeR1_var._rotation_is_identity) coords_get(coords_add(coords_set(x,y,z), _BladeR1_var._position_relative),&x, &y, &z); else #endif mccoordschange(_BladeR1_var._position_relative, _BladeR1_var._rotation_relative, _particle); _particle_save = *_particle; if ((( _instrument_var._parameters.COARSE > 0 && ! _instrument_var._parameters.VIRTUALOUT ))) // conditional WHEN class_Absorber_trace(&_BladeR1_var, _particle); /* contains EXTEND code */ if (_particle->_restore) particle_restore(_particle, &_particle_save); _particle->_index++; } // ArmR2 if (!ABSORBED && _particle->_index == 113) { _particle->_index++; } // BladeR2 if (!ABSORBED && _particle->_index == 114) { #ifndef MULTICORE if (_BladeR2_var._rotation_is_identity) coords_get(coords_add(coords_set(x,y,z), _BladeR2_var._position_relative),&x, &y, &z); else #endif mccoordschange(_BladeR2_var._position_relative, _BladeR2_var._rotation_relative, _particle); _particle_save = *_particle; if ((( _instrument_var._parameters.COARSE > 0 && ! _instrument_var._parameters.VIRTUALOUT ))) // conditional WHEN class_Absorber_trace(&_BladeR2_var, _particle); if (_particle->_restore) particle_restore(_particle, &_particle_save); _particle->_index++; } // ArmR3 if (!ABSORBED && _particle->_index == 115) { _particle->_index++; } // BladeR3 if (!ABSORBED && _particle->_index == 116) { #ifndef MULTICORE if (_BladeR3_var._rotation_is_identity) coords_get(coords_add(coords_set(x,y,z), _BladeR3_var._position_relative),&x, &y, &z); else #endif mccoordschange(_BladeR3_var._position_relative, _BladeR3_var._rotation_relative, _particle); _particle_save = *_particle; if ((( _instrument_var._parameters.COARSE > 0 ))) // conditional WHEN class_Absorber_trace(&_BladeR3_var, _particle); if (_particle->_restore) particle_restore(_particle, &_particle_save); _particle->_index++; } // ArmR4 if (!ABSORBED && _particle->_index == 117) { _particle->_index++; } // BladeR4 if (!ABSORBED && _particle->_index == 118) { #ifndef MULTICORE if (_BladeR4_var._rotation_is_identity) coords_get(coords_add(coords_set(x,y,z), _BladeR4_var._position_relative),&x, &y, &z); else #endif mccoordschange(_BladeR4_var._position_relative, _BladeR4_var._rotation_relative, _particle); _particle_save = *_particle; if ((( _instrument_var._parameters.COARSE > 0 ))) // conditional WHEN class_Absorber_trace(&_BladeR4_var, _particle); if (_particle->_restore) particle_restore(_particle, &_particle_save); _particle->_index++; } // ArmR5 if (!ABSORBED && _particle->_index == 119) { _particle->_index++; } // BladeR5 if (!ABSORBED && _particle->_index == 120) { #ifndef MULTICORE if (_BladeR5_var._rotation_is_identity) coords_get(coords_add(coords_set(x,y,z), _BladeR5_var._position_relative),&x, &y, &z); else #endif mccoordschange(_BladeR5_var._position_relative, _BladeR5_var._rotation_relative, _particle); _particle_save = *_particle; if ((( _instrument_var._parameters.COARSE > 0 ))) // conditional WHEN class_Absorber_trace(&_BladeR5_var, _particle); if (_particle->_restore) particle_restore(_particle, &_particle_save); _particle->_index++; } // ArmL1 if (!ABSORBED && _particle->_index == 121) { _particle->_index++; } // BladeL1 if (!ABSORBED && _particle->_index == 122) { #ifndef MULTICORE if (_BladeL1_var._rotation_is_identity) coords_get(coords_add(coords_set(x,y,z), _BladeL1_var._position_relative),&x, &y, &z); else #endif mccoordschange(_BladeL1_var._position_relative, _BladeL1_var._rotation_relative, _particle); _particle_save = *_particle; if ((( _instrument_var._parameters.COARSE > 0 && ! _instrument_var._parameters.VIRTUALOUT ))) // conditional WHEN class_Absorber_trace(&_BladeL1_var, _particle); if (_particle->_restore) particle_restore(_particle, &_particle_save); _particle->_index++; } // ArmL2 if (!ABSORBED && _particle->_index == 123) { _particle->_index++; } // BladeL2 if (!ABSORBED && _particle->_index == 124) { #ifndef MULTICORE if (_BladeL2_var._rotation_is_identity) coords_get(coords_add(coords_set(x,y,z), _BladeL2_var._position_relative),&x, &y, &z); else #endif mccoordschange(_BladeL2_var._position_relative, _BladeL2_var._rotation_relative, _particle); _particle_save = *_particle; if ((( _instrument_var._parameters.COARSE > 0 && ! _instrument_var._parameters.VIRTUALOUT ))) // conditional WHEN class_Absorber_trace(&_BladeL2_var, _particle); if (_particle->_restore) particle_restore(_particle, &_particle_save); _particle->_index++; } // ArmL3 if (!ABSORBED && _particle->_index == 125) { _particle->_index++; } // BladeL3 if (!ABSORBED && _particle->_index == 126) { #ifndef MULTICORE if (_BladeL3_var._rotation_is_identity) coords_get(coords_add(coords_set(x,y,z), _BladeL3_var._position_relative),&x, &y, &z); else #endif mccoordschange(_BladeL3_var._position_relative, _BladeL3_var._rotation_relative, _particle); _particle_save = *_particle; if ((( _instrument_var._parameters.COARSE > 0 && ! _instrument_var._parameters.VIRTUALOUT ))) // conditional WHEN class_Absorber_trace(&_BladeL3_var, _particle); if (_particle->_restore) particle_restore(_particle, &_particle_save); _particle->_index++; } // ArmL4 if (!ABSORBED && _particle->_index == 127) { _particle->_index++; } // BladeL4 if (!ABSORBED && _particle->_index == 128) { #ifndef MULTICORE if (_BladeL4_var._rotation_is_identity) coords_get(coords_add(coords_set(x,y,z), _BladeL4_var._position_relative),&x, &y, &z); else #endif mccoordschange(_BladeL4_var._position_relative, _BladeL4_var._rotation_relative, _particle); _particle_save = *_particle; if ((( _instrument_var._parameters.COARSE > 0 && ! _instrument_var._parameters.VIRTUALOUT ))) // conditional WHEN class_Absorber_trace(&_BladeL4_var, _particle); if (_particle->_restore) particle_restore(_particle, &_particle_save); _particle->_index++; } // ArmL5 if (!ABSORBED && _particle->_index == 129) { #ifndef MULTICORE if (_ArmL5_var._rotation_is_identity) coords_get(coords_add(coords_set(x,y,z), _ArmL5_var._position_relative),&x, &y, &z); else #endif mccoordschange(_ArmL5_var._position_relative, _ArmL5_var._rotation_relative, _particle); _particle_save = *_particle; if ((( ! _instrument_var._parameters.VIRTUALOUT ))) // conditional WHEN class_Arm_trace(&_ArmL5_var, _particle); /* contains EXTEND code */ if (_particle->_restore) particle_restore(_particle, &_particle_save); _particle->_index++; } // BladeL5 if (!ABSORBED && _particle->_index == 130) { #ifndef MULTICORE if (_BladeL5_var._rotation_is_identity) coords_get(coords_add(coords_set(x,y,z), _BladeL5_var._position_relative),&x, &y, &z); else #endif mccoordschange(_BladeL5_var._position_relative, _BladeL5_var._rotation_relative, _particle); _particle_save = *_particle; if ((( _instrument_var._parameters.COARSE > 0 && ! _instrument_var._parameters.VIRTUALOUT ))) // conditional WHEN class_Absorber_trace(&_BladeL5_var, _particle); if (_particle->_restore) particle_restore(_particle, &_particle_save); _particle->_index++; } // psd_detector if (!ABSORBED && _particle->_index == 131) { #ifndef MULTICORE if (_psd_detector_var._rotation_is_identity) coords_get(coords_add(coords_set(x,y,z), _psd_detector_var._position_relative),&x, &y, &z); else #endif mccoordschange(_psd_detector_var._position_relative, _psd_detector_var._rotation_relative, _particle); _particle_save = *_particle; if ((( ! _instrument_var._parameters.VIRTUALOUT ))) // conditional WHEN class_PSD_monitor_psf_eff_trace(&_psd_detector_var, _particle); /* contains EXTEND code */ if (_particle->_restore) particle_restore(_particle, &_particle_save); _particle->_index++; } // emon_detector if (!ABSORBED && _particle->_index == 132) { #ifndef MULTICORE if (_emon_detector_var._rotation_is_identity) coords_get(coords_add(coords_set(x,y,z), _emon_detector_var._position_relative),&x, &y, &z); else #endif mccoordschange(_emon_detector_var._position_relative, _emon_detector_var._rotation_relative, _particle); _particle_save = *_particle; if ((( ! _instrument_var._parameters.VIRTUALOUT ))) // conditional WHEN class_E_monitor_trace(&_emon_detector_var, _particle); if (_particle->_restore) particle_restore(_particle, &_particle_save); _particle->_index++; } // psd_window1 if (!ABSORBED && _particle->_index == 133) { #ifndef MULTICORE if (_psd_window1_var._rotation_is_identity) coords_get(coords_add(coords_set(x,y,z), _psd_window1_var._position_relative),&x, &y, &z); else #endif mccoordschange(_psd_window1_var._position_relative, _psd_window1_var._rotation_relative, _particle); _particle_save = *_particle; if ((( BinX >= XwinMin [ 1 ] && BinX <= XwinMax [ 1 ] && BinY >= YwinMin [ 1 ] && BinY <= YwinMax [ 1 ] && ! _instrument_var._parameters.VIRTUALOUT ))) // conditional WHEN class_PSD_monitor_psf_eff_trace(&_psd_window1_var, _particle); if (_particle->_restore) particle_restore(_particle, &_particle_save); _particle->_index++; } // emon_window1 if (!ABSORBED && _particle->_index == 134) { #ifndef MULTICORE if (_emon_window1_var._rotation_is_identity) coords_get(coords_add(coords_set(x,y,z), _emon_window1_var._position_relative),&x, &y, &z); else #endif mccoordschange(_emon_window1_var._position_relative, _emon_window1_var._rotation_relative, _particle); _particle_save = *_particle; if ((( BinX >= XwinMin [ 1 ] && BinX <= XwinMax [ 1 ] && BinY >= YwinMin [ 1 ] && BinY <= YwinMax [ 1 ] && ! _instrument_var._parameters.VIRTUALOUT ))) // conditional WHEN class_E_monitor_trace(&_emon_window1_var, _particle); if (_particle->_restore) particle_restore(_particle, &_particle_save); _particle->_index++; } // psd_window2 if (!ABSORBED && _particle->_index == 135) { #ifndef MULTICORE if (_psd_window2_var._rotation_is_identity) coords_get(coords_add(coords_set(x,y,z), _psd_window2_var._position_relative),&x, &y, &z); else #endif mccoordschange(_psd_window2_var._position_relative, _psd_window2_var._rotation_relative, _particle); _particle_save = *_particle; if ((( BinX >= XwinMin [ 2 ] && BinX <= XwinMax [ 2 ] && BinY >= YwinMin [ 2 ] && BinY <= YwinMax [ 2 ] && ! _instrument_var._parameters.VIRTUALOUT ))) // conditional WHEN class_PSD_monitor_psf_eff_trace(&_psd_window2_var, _particle); if (_particle->_restore) particle_restore(_particle, &_particle_save); _particle->_index++; } // emon_window2 if (!ABSORBED && _particle->_index == 136) { #ifndef MULTICORE if (_emon_window2_var._rotation_is_identity) coords_get(coords_add(coords_set(x,y,z), _emon_window2_var._position_relative),&x, &y, &z); else #endif mccoordschange(_emon_window2_var._position_relative, _emon_window2_var._rotation_relative, _particle); _particle_save = *_particle; if ((( BinX >= XwinMin [ 2 ] && BinX <= XwinMax [ 2 ] && BinY >= YwinMin [ 2 ] && BinY <= YwinMax [ 2 ] && ! _instrument_var._parameters.VIRTUALOUT ))) // conditional WHEN class_E_monitor_trace(&_emon_window2_var, _particle); if (_particle->_restore) particle_restore(_particle, &_particle_save); _particle->_index++; } // psd_window3 if (!ABSORBED && _particle->_index == 137) { #ifndef MULTICORE if (_psd_window3_var._rotation_is_identity) coords_get(coords_add(coords_set(x,y,z), _psd_window3_var._position_relative),&x, &y, &z); else #endif mccoordschange(_psd_window3_var._position_relative, _psd_window3_var._rotation_relative, _particle); _particle_save = *_particle; if ((( BinX >= XwinMin [ 3 ] && BinX <= XwinMax [ 3 ] && BinY >= YwinMin [ 3 ] && BinY <= YwinMax [ 3 ] && ! _instrument_var._parameters.VIRTUALOUT ))) // conditional WHEN class_PSD_monitor_psf_eff_trace(&_psd_window3_var, _particle); if (_particle->_restore) particle_restore(_particle, &_particle_save); _particle->_index++; } // emon_window3 if (!ABSORBED && _particle->_index == 138) { #ifndef MULTICORE if (_emon_window3_var._rotation_is_identity) coords_get(coords_add(coords_set(x,y,z), _emon_window3_var._position_relative),&x, &y, &z); else #endif mccoordschange(_emon_window3_var._position_relative, _emon_window3_var._rotation_relative, _particle); _particle_save = *_particle; if ((( BinX >= XwinMin [ 3 ] && BinX <= XwinMax [ 3 ] && BinY >= YwinMin [ 3 ] && BinY <= YwinMax [ 3 ] && ! _instrument_var._parameters.VIRTUALOUT ))) // conditional WHEN class_E_monitor_trace(&_emon_window3_var, _particle); if (_particle->_restore) particle_restore(_particle, &_particle_save); _particle->_index++; } // psd_window4 if (!ABSORBED && _particle->_index == 139) { #ifndef MULTICORE if (_psd_window4_var._rotation_is_identity) coords_get(coords_add(coords_set(x,y,z), _psd_window4_var._position_relative),&x, &y, &z); else #endif mccoordschange(_psd_window4_var._position_relative, _psd_window4_var._rotation_relative, _particle); _particle_save = *_particle; if ((( BinX >= XwinMin [ 4 ] && BinX <= XwinMax [ 4 ] && BinY >= YwinMin [ 4 ] && BinY <= YwinMax [ 4 ] && ! _instrument_var._parameters.VIRTUALOUT ))) // conditional WHEN class_PSD_monitor_psf_eff_trace(&_psd_window4_var, _particle); if (_particle->_restore) particle_restore(_particle, &_particle_save); _particle->_index++; } // emon_window4 if (!ABSORBED && _particle->_index == 140) { #ifndef MULTICORE if (_emon_window4_var._rotation_is_identity) coords_get(coords_add(coords_set(x,y,z), _emon_window4_var._position_relative),&x, &y, &z); else #endif mccoordschange(_emon_window4_var._position_relative, _emon_window4_var._rotation_relative, _particle); _particle_save = *_particle; if ((( BinX >= XwinMin [ 4 ] && BinX <= XwinMax [ 4 ] && BinY >= YwinMin [ 4 ] && BinY <= YwinMax [ 4 ] && ! _instrument_var._parameters.VIRTUALOUT ))) // conditional WHEN class_E_monitor_trace(&_emon_window4_var, _particle); if (_particle->_restore) particle_restore(_particle, &_particle_save); _particle->_index++; } // psd_window5 if (!ABSORBED && _particle->_index == 141) { #ifndef MULTICORE if (_psd_window5_var._rotation_is_identity) coords_get(coords_add(coords_set(x,y,z), _psd_window5_var._position_relative),&x, &y, &z); else #endif mccoordschange(_psd_window5_var._position_relative, _psd_window5_var._rotation_relative, _particle); _particle_save = *_particle; if ((( BinX >= XwinMin [ 5 ] && BinX <= XwinMax [ 5 ] && BinY >= YwinMin [ 5 ] && BinY <= YwinMax [ 5 ] && ! _instrument_var._parameters.VIRTUALOUT ))) // conditional WHEN class_PSD_monitor_psf_eff_trace(&_psd_window5_var, _particle); if (_particle->_restore) particle_restore(_particle, &_particle_save); _particle->_index++; } // emon_window5 if (!ABSORBED && _particle->_index == 142) { #ifndef MULTICORE if (_emon_window5_var._rotation_is_identity) coords_get(coords_add(coords_set(x,y,z), _emon_window5_var._position_relative),&x, &y, &z); else #endif mccoordschange(_emon_window5_var._position_relative, _emon_window5_var._rotation_relative, _particle); _particle_save = *_particle; if ((( BinX >= XwinMin [ 5 ] && BinX <= XwinMax [ 5 ] && BinY >= YwinMin [ 5 ] && BinY <= YwinMax [ 5 ] && ! _instrument_var._parameters.VIRTUALOUT ))) // conditional WHEN class_E_monitor_trace(&_emon_window5_var, _particle); if (_particle->_restore) particle_restore(_particle, &_particle_save); _particle->_index++; } // psd_window6 if (!ABSORBED && _particle->_index == 143) { #ifndef MULTICORE if (_psd_window6_var._rotation_is_identity) coords_get(coords_add(coords_set(x,y,z), _psd_window6_var._position_relative),&x, &y, &z); else #endif mccoordschange(_psd_window6_var._position_relative, _psd_window6_var._rotation_relative, _particle); _particle_save = *_particle; if ((( BinX >= XwinMin [ 6 ] && BinX <= XwinMax [ 6 ] && BinY >= YwinMin [ 6 ] && BinY <= YwinMax [ 6 ] && ! _instrument_var._parameters.VIRTUALOUT ))) // conditional WHEN class_PSD_monitor_psf_eff_trace(&_psd_window6_var, _particle); if (_particle->_restore) particle_restore(_particle, &_particle_save); _particle->_index++; } // emon_window6 if (!ABSORBED && _particle->_index == 144) { #ifndef MULTICORE if (_emon_window6_var._rotation_is_identity) coords_get(coords_add(coords_set(x,y,z), _emon_window6_var._position_relative),&x, &y, &z); else #endif mccoordschange(_emon_window6_var._position_relative, _emon_window6_var._rotation_relative, _particle); _particle_save = *_particle; if ((( BinX >= XwinMin [ 6 ] && BinX <= XwinMax [ 6 ] && BinY >= YwinMin [ 6 ] && BinY <= YwinMax [ 6 ] && ! _instrument_var._parameters.VIRTUALOUT ))) // conditional WHEN class_E_monitor_trace(&_emon_window6_var, _particle); if (_particle->_restore) particle_restore(_particle, &_particle_save); _particle->_index++; } // psd_window7 if (!ABSORBED && _particle->_index == 145) { #ifndef MULTICORE if (_psd_window7_var._rotation_is_identity) coords_get(coords_add(coords_set(x,y,z), _psd_window7_var._position_relative),&x, &y, &z); else #endif mccoordschange(_psd_window7_var._position_relative, _psd_window7_var._rotation_relative, _particle); _particle_save = *_particle; if ((( BinX >= XwinMin [ 7 ] && BinX <= XwinMax [ 7 ] && BinY >= YwinMin [ 7 ] && BinY <= YwinMax [ 7 ] && ! _instrument_var._parameters.VIRTUALOUT ))) // conditional WHEN class_PSD_monitor_psf_eff_trace(&_psd_window7_var, _particle); if (_particle->_restore) particle_restore(_particle, &_particle_save); _particle->_index++; } // emon_window7 if (!ABSORBED && _particle->_index == 146) { #ifndef MULTICORE if (_emon_window7_var._rotation_is_identity) coords_get(coords_add(coords_set(x,y,z), _emon_window7_var._position_relative),&x, &y, &z); else #endif mccoordschange(_emon_window7_var._position_relative, _emon_window7_var._rotation_relative, _particle); _particle_save = *_particle; if ((( BinX >= XwinMin [ 7 ] && BinX <= XwinMax [ 7 ] && BinY >= YwinMin [ 7 ] && BinY <= YwinMax [ 7 ] && ! _instrument_var._parameters.VIRTUALOUT ))) // conditional WHEN class_E_monitor_trace(&_emon_window7_var, _particle); if (_particle->_restore) particle_restore(_particle, &_particle_save); _particle->_index++; } // psd_window8 if (!ABSORBED && _particle->_index == 147) { #ifndef MULTICORE if (_psd_window8_var._rotation_is_identity) coords_get(coords_add(coords_set(x,y,z), _psd_window8_var._position_relative),&x, &y, &z); else #endif mccoordschange(_psd_window8_var._position_relative, _psd_window8_var._rotation_relative, _particle); _particle_save = *_particle; if ((( BinX >= XwinMin [ 8 ] && BinX <= XwinMax [ 8 ] && BinY >= YwinMin [ 8 ] && BinY <= YwinMax [ 8 ] && ! _instrument_var._parameters.VIRTUALOUT ))) // conditional WHEN class_PSD_monitor_psf_eff_trace(&_psd_window8_var, _particle); if (_particle->_restore) particle_restore(_particle, &_particle_save); _particle->_index++; } // emon_window8 if (!ABSORBED && _particle->_index == 148) { #ifndef MULTICORE if (_emon_window8_var._rotation_is_identity) coords_get(coords_add(coords_set(x,y,z), _emon_window8_var._position_relative),&x, &y, &z); else #endif mccoordschange(_emon_window8_var._position_relative, _emon_window8_var._rotation_relative, _particle); _particle_save = *_particle; if ((( BinX >= XwinMin [ 8 ] && BinX <= XwinMax [ 8 ] && BinY >= YwinMin [ 8 ] && BinY <= YwinMax [ 8 ] && ! _instrument_var._parameters.VIRTUALOUT ))) // conditional WHEN class_E_monitor_trace(&_emon_window8_var, _particle); if (_particle->_restore) particle_restore(_particle, &_particle_save); _particle->_index++; } // psd_window9 if (!ABSORBED && _particle->_index == 149) { #ifndef MULTICORE if (_psd_window9_var._rotation_is_identity) coords_get(coords_add(coords_set(x,y,z), _psd_window9_var._position_relative),&x, &y, &z); else #endif mccoordschange(_psd_window9_var._position_relative, _psd_window9_var._rotation_relative, _particle); _particle_save = *_particle; if ((( BinX >= XwinMin [ 9 ] && BinX <= XwinMax [ 9 ] && BinY >= YwinMin [ 9 ] && BinY <= YwinMax [ 9 ] && ! _instrument_var._parameters.VIRTUALOUT ))) // conditional WHEN class_PSD_monitor_psf_eff_trace(&_psd_window9_var, _particle); if (_particle->_restore) particle_restore(_particle, &_particle_save); _particle->_index++; } // emon_window9 if (!ABSORBED && _particle->_index == 150) { #ifndef MULTICORE if (_emon_window9_var._rotation_is_identity) coords_get(coords_add(coords_set(x,y,z), _emon_window9_var._position_relative),&x, &y, &z); else #endif mccoordschange(_emon_window9_var._position_relative, _emon_window9_var._rotation_relative, _particle); _particle_save = *_particle; if ((( BinX >= XwinMin [ 9 ] && BinX <= XwinMax [ 9 ] && BinY >= YwinMin [ 9 ] && BinY <= YwinMax [ 9 ] && ! _instrument_var._parameters.VIRTUALOUT ))) // conditional WHEN class_E_monitor_trace(&_emon_window9_var, _particle); if (_particle->_restore) particle_restore(_particle, &_particle_save); _particle->_index++; } } // jump to next viable seed seed = seed + gpu_innerloop; } // outer loop / particle batches free(particles); free(pbuffer); printf("\n"); // if on GPU and mcdotrace just exit #ifdef OPENACC } #endif } /* raytrace_all_funnel */ #endif // FUNNEL #undef Mono_order #undef AnaBlade #undef BinX #undef BinY #undef ncol_54 #undef nrow_54 #undef x #undef y #undef z #undef vx #undef vy #undef vz #undef t #undef sx #undef sy #undef sz #undef p #undef mcgravitation #undef mcMagnet #undef allow_backprop #undef _mctmp_a #undef _mctmp_b #undef _mctmp_c #ifdef OPENACC #undef strlen #undef strcmp #undef exit #undef printf #undef sprintf #undef fprintf #endif #undef SCATTERED #undef RESTORE #undef RESTORE_NEUTRON #undef STORE_NEUTRON #undef ABSORBED #undef ABSORB #undef ABSORB0 /* ***************************************************************************** * instrument 'RITA_II' and components SAVE ***************************************************************************** */ _class_Progress_bar *class_Progress_bar_save(_class_Progress_bar *_comp ) { #define profile (_comp->_parameters.profile) #define percent (_comp->_parameters.percent) #define flag_save (_comp->_parameters.flag_save) #define minutes (_comp->_parameters.minutes) #define IntermediateCnts (_comp->_parameters.IntermediateCnts) #define StartTime (_comp->_parameters.StartTime) #define EndTime (_comp->_parameters.EndTime) #define CurrentTime (_comp->_parameters.CurrentTime) #define infostring (_comp->_parameters.infostring) SIG_MESSAGE("[_armSource_save] component armSource=Progress_bar() SAVE [Progress_bar:0]"); MPI_MASTER (fprintf (stdout, "\nSave [%s]\n", instrument_name);); if (profile && strlen (profile) && strcmp (profile, "NULL") && strcmp (profile, "0")) { char filename[256]; if (!strlen (profile) || !strcmp (profile, "NULL") || !strcmp (profile, "0")) strcpy (filename, instrument_name); else strcpy (filename, profile); DETECTOR_OUT_1D ("Intensity profiler", "Component index [1]", "Intensity", "prof", 1, mcNUMCOMP, mcNUMCOMP - 1, &(instrument->counter_N[1]), &(instrument->counter_P[1]), &(instrument->counter_P2[1]), filename); } #undef profile #undef percent #undef flag_save #undef minutes #undef IntermediateCnts #undef StartTime #undef EndTime #undef CurrentTime #undef infostring return(_comp); } /* class_Progress_bar_save */ _class_L_monitor *class_L_monitor_save(_class_L_monitor *_comp ) { #define nL (_comp->_parameters.nL) #define filename (_comp->_parameters.filename) #define nowritefile (_comp->_parameters.nowritefile) #define xmin (_comp->_parameters.xmin) #define xmax (_comp->_parameters.xmax) #define ymin (_comp->_parameters.ymin) #define ymax (_comp->_parameters.ymax) #define xwidth (_comp->_parameters.xwidth) #define yheight (_comp->_parameters.yheight) #define Lmin (_comp->_parameters.Lmin) #define Lmax (_comp->_parameters.Lmax) #define restore_neutron (_comp->_parameters.restore_neutron) #define L_N (_comp->_parameters.L_N) #define L_p (_comp->_parameters.L_p) #define L_p2 (_comp->_parameters.L_p2) SIG_MESSAGE("[_lmon_guide_start_save] component lmon_guide_start=L_monitor() SAVE [L_monitor:0]"); if (!nowritefile) { DETECTOR_OUT_1D ("Wavelength monitor", "Wavelength [AA]", "Intensity", "L", Lmin, Lmax, nL, &L_N[0], &L_p[0], &L_p2[0], filename); } #undef nL #undef filename #undef nowritefile #undef xmin #undef xmax #undef ymin #undef ymax #undef xwidth #undef yheight #undef Lmin #undef Lmax #undef restore_neutron #undef L_N #undef L_p #undef L_p2 return(_comp); } /* class_L_monitor_save */ _class_PSD_monitor *class_PSD_monitor_save(_class_PSD_monitor *_comp ) { #define nx (_comp->_parameters.nx) #define ny (_comp->_parameters.ny) #define filename (_comp->_parameters.filename) #define xmin (_comp->_parameters.xmin) #define xmax (_comp->_parameters.xmax) #define ymin (_comp->_parameters.ymin) #define ymax (_comp->_parameters.ymax) #define xwidth (_comp->_parameters.xwidth) #define yheight (_comp->_parameters.yheight) #define restore_neutron (_comp->_parameters.restore_neutron) #define nowritefile (_comp->_parameters.nowritefile) #define PSD_N (_comp->_parameters.PSD_N) #define PSD_p (_comp->_parameters.PSD_p) #define PSD_p2 (_comp->_parameters.PSD_p2) SIG_MESSAGE("[_psd_guide_end_save] component psd_guide_end=PSD_monitor() SAVE [PSD_monitor:0]"); if (!nowritefile) { DETECTOR_OUT_2D ("PSD monitor", "X position [cm]", "Y position [cm]", xmin * 100.0, xmax * 100.0, ymin * 100.0, ymax * 100.0, nx, ny, &PSD_N[0][0], &PSD_p[0][0], &PSD_p2[0][0], filename); } #undef nx #undef ny #undef filename #undef xmin #undef xmax #undef ymin #undef ymax #undef xwidth #undef yheight #undef restore_neutron #undef nowritefile #undef PSD_N #undef PSD_p #undef PSD_p2 return(_comp); } /* class_PSD_monitor_save */ _class_E_monitor *class_E_monitor_save(_class_E_monitor *_comp ) { #define nE (_comp->_parameters.nE) #define filename (_comp->_parameters.filename) #define xmin (_comp->_parameters.xmin) #define xmax (_comp->_parameters.xmax) #define ymin (_comp->_parameters.ymin) #define ymax (_comp->_parameters.ymax) #define nowritefile (_comp->_parameters.nowritefile) #define xwidth (_comp->_parameters.xwidth) #define yheight (_comp->_parameters.yheight) #define Emin (_comp->_parameters.Emin) #define Emax (_comp->_parameters.Emax) #define restore_neutron (_comp->_parameters.restore_neutron) #define E_N (_comp->_parameters.E_N) #define E_p (_comp->_parameters.E_p) #define E_p2 (_comp->_parameters.E_p2) #define S_p (_comp->_parameters.S_p) #define S_pE (_comp->_parameters.S_pE) #define S_pE2 (_comp->_parameters.S_pE2) SIG_MESSAGE("[_emon_guide_end_save] component emon_guide_end=E_monitor() SAVE [E_monitor:0]"); if (!nowritefile) { DETECTOR_OUT_1D ("Energy monitor", "Energy [meV]", "Intensity", "E", Emin, Emax, nE, &E_N[0], &E_p[0], &E_p2[0], filename); if (S_p) printf (" : %g meV , E-width : %g meV \n", S_pE / S_p, sqrt (S_pE2 / S_p - S_pE * S_pE / (S_p * S_p))); } #undef nE #undef filename #undef xmin #undef xmax #undef ymin #undef ymax #undef nowritefile #undef xwidth #undef yheight #undef Emin #undef Emax #undef restore_neutron #undef E_N #undef E_p #undef E_p2 #undef S_p #undef S_pE #undef S_pE2 return(_comp); } /* class_E_monitor_save */ _class_Divergence_monitor *class_Divergence_monitor_save(_class_Divergence_monitor *_comp ) { #define nh (_comp->_parameters.nh) #define nv (_comp->_parameters.nv) #define filename (_comp->_parameters.filename) #define xmin (_comp->_parameters.xmin) #define xmax (_comp->_parameters.xmax) #define ymin (_comp->_parameters.ymin) #define ymax (_comp->_parameters.ymax) #define nowritefile (_comp->_parameters.nowritefile) #define xwidth (_comp->_parameters.xwidth) #define yheight (_comp->_parameters.yheight) #define maxdiv_h (_comp->_parameters.maxdiv_h) #define maxdiv_v (_comp->_parameters.maxdiv_v) #define restore_neutron (_comp->_parameters.restore_neutron) #define nx (_comp->_parameters.nx) #define ny (_comp->_parameters.ny) #define nz (_comp->_parameters.nz) #define Div_N (_comp->_parameters.Div_N) #define Div_p (_comp->_parameters.Div_p) #define Div_p2 (_comp->_parameters.Div_p2) SIG_MESSAGE("[_divmon_guide_end_save] component divmon_guide_end=Divergence_monitor() SAVE [Divergence_monitor:0]"); if (!nowritefile) { DETECTOR_OUT_2D ("Divergence monitor", "X divergence [deg]", "Y divergence [deg]", -maxdiv_h, maxdiv_h, -maxdiv_v, maxdiv_v, nh, nv, &Div_N[0][0], &Div_p[0][0], &Div_p2[0][0], filename); } #undef nh #undef nv #undef filename #undef xmin #undef xmax #undef ymin #undef ymax #undef nowritefile #undef xwidth #undef yheight #undef maxdiv_h #undef maxdiv_v #undef restore_neutron #undef nx #undef ny #undef nz #undef Div_N #undef Div_p #undef Div_p2 return(_comp); } /* class_Divergence_monitor_save */ _class_Monitor_nD *class_Monitor_nD_save(_class_Monitor_nD *_comp ) { #define user0 (_comp->_parameters.user0) #define user1 (_comp->_parameters.user1) #define user2 (_comp->_parameters.user2) #define user3 (_comp->_parameters.user3) #define user4 (_comp->_parameters.user4) #define user5 (_comp->_parameters.user5) #define user6 (_comp->_parameters.user6) #define user7 (_comp->_parameters.user7) #define user8 (_comp->_parameters.user8) #define user9 (_comp->_parameters.user9) #define xwidth (_comp->_parameters.xwidth) #define yheight (_comp->_parameters.yheight) #define zdepth (_comp->_parameters.zdepth) #define xmin (_comp->_parameters.xmin) #define xmax (_comp->_parameters.xmax) #define ymin (_comp->_parameters.ymin) #define ymax (_comp->_parameters.ymax) #define zmin (_comp->_parameters.zmin) #define zmax (_comp->_parameters.zmax) #define bins (_comp->_parameters.bins) #define min (_comp->_parameters.min) #define max (_comp->_parameters.max) #define restore_neutron (_comp->_parameters.restore_neutron) #define radius (_comp->_parameters.radius) #define options (_comp->_parameters.options) #define filename (_comp->_parameters.filename) #define geometry (_comp->_parameters.geometry) #define nowritefile (_comp->_parameters.nowritefile) #define nexus_bins (_comp->_parameters.nexus_bins) #define username0 (_comp->_parameters.username0) #define username1 (_comp->_parameters.username1) #define username2 (_comp->_parameters.username2) #define username3 (_comp->_parameters.username3) #define username4 (_comp->_parameters.username4) #define username5 (_comp->_parameters.username5) #define username6 (_comp->_parameters.username6) #define username7 (_comp->_parameters.username7) #define username8 (_comp->_parameters.username8) #define username9 (_comp->_parameters.username9) #define DEFS (_comp->_parameters.DEFS) #define Vars (_comp->_parameters.Vars) #define detector (_comp->_parameters.detector) #define offdata (_comp->_parameters.offdata) SIG_MESSAGE("[_OrderMon_save] component OrderMon=Monitor_nD() SAVE [Monitor_nD:0]"); if (!nowritefile) { /* save results, but do not free pointers */ detector = Monitor_nD_Save (&DEFS, &Vars); } #undef user0 #undef user1 #undef user2 #undef user3 #undef user4 #undef user5 #undef user6 #undef user7 #undef user8 #undef user9 #undef xwidth #undef yheight #undef zdepth #undef xmin #undef xmax #undef ymin #undef ymax #undef zmin #undef zmax #undef bins #undef min #undef max #undef restore_neutron #undef radius #undef options #undef filename #undef geometry #undef nowritefile #undef nexus_bins #undef username0 #undef username1 #undef username2 #undef username3 #undef username4 #undef username5 #undef username6 #undef username7 #undef username8 #undef username9 #undef DEFS #undef Vars #undef detector #undef offdata return(_comp); } /* class_Monitor_nD_save */ _class_PSD_monitor_psf_eff *class_PSD_monitor_psf_eff_save(_class_PSD_monitor_psf_eff *_comp ) { #define nx (_comp->_parameters.nx) #define ny (_comp->_parameters.ny) #define filename (_comp->_parameters.filename) #define xmin (_comp->_parameters.xmin) #define xmax (_comp->_parameters.xmax) #define ymin (_comp->_parameters.ymin) #define ymax (_comp->_parameters.ymax) #define nowritefile (_comp->_parameters.nowritefile) #define xwidth (_comp->_parameters.xwidth) #define yheight (_comp->_parameters.yheight) #define psf (_comp->_parameters.psf) #define k0 (_comp->_parameters.k0) #define eff (_comp->_parameters.eff) #define restore_neutron (_comp->_parameters.restore_neutron) #define PSD_N (_comp->_parameters.PSD_N) #define PSD_p (_comp->_parameters.PSD_p) #define PSD_p2 (_comp->_parameters.PSD_p2) #define weight (_comp->_parameters.weight) SIG_MESSAGE("[_kMoni_save] component kMoni=PSD_monitor_psf_eff() SAVE [PSD_monitor_psf_eff:0]"); if (!nowritefile) { DETECTOR_OUT_2D ("PSD monitor", "X position [cm]", "Y position [cm]", xmin * 100.0, xmax * 100.0, ymin * 100.0, ymax * 100.0, nx, ny, &PSD_N[0][0], &PSD_p[0][0], &PSD_p2[0][0], filename); } #undef nx #undef ny #undef filename #undef xmin #undef xmax #undef ymin #undef ymax #undef nowritefile #undef xwidth #undef yheight #undef psf #undef k0 #undef eff #undef restore_neutron #undef PSD_N #undef PSD_p #undef PSD_p2 #undef weight return(_comp); } /* class_PSD_monitor_psf_eff_save */ _class_PSD_monitor_4PI *class_PSD_monitor_4PI_save(_class_PSD_monitor_4PI *_comp ) { #define nx (_comp->_parameters.nx) #define ny (_comp->_parameters.ny) #define filename (_comp->_parameters.filename) #define nowritefile (_comp->_parameters.nowritefile) #define radius (_comp->_parameters.radius) #define restore_neutron (_comp->_parameters.restore_neutron) #define PSD_N (_comp->_parameters.PSD_N) #define PSD_p (_comp->_parameters.PSD_p) #define PSD_p2 (_comp->_parameters.PSD_p2) SIG_MESSAGE("[_psd_4pi_save] component psd_4pi=PSD_monitor_4PI() SAVE [PSD_monitor_4PI:0]"); if (!nowritefile) { DETECTOR_OUT_2D ("4PI PSD monitor", "Longitude [deg]", "Latitude [deg]", -180, 180, -90, 90, nx, ny, &PSD_N[0][0], &PSD_p[0][0], &PSD_p2[0][0], filename); } #undef nx #undef ny #undef filename #undef nowritefile #undef radius #undef restore_neutron #undef PSD_N #undef PSD_p #undef PSD_p2 return(_comp); } /* class_PSD_monitor_4PI_save */ int save(FILE *handle) { /* called by mccode_main for RITA_II:SAVE */ if (!handle) siminfo_init(NULL); /* call iteratively all components SAVE */ class_Progress_bar_save(&_armSource_var); class_L_monitor_save(&_lmon_guide_start_var); class_PSD_monitor_save(&_psd_guide_end_var); class_E_monitor_save(&_emon_guide_end_var); class_L_monitor_save(&_lmon_guide_end_var); class_Divergence_monitor_save(&_divmon_guide_end_var); class_PSD_monitor_save(&_psd_virt_var); class_L_monitor_save(&_lmon_virt_var); class_Monitor_nD_save(&_OrderMon_var); class_PSD_monitor_psf_eff_save(&_kMoni_var); class_PSD_monitor_psf_eff_save(&_kMoni1st_var); class_PSD_monitor_psf_eff_save(&_kMoni2nd_var); class_PSD_monitor_psf_eff_save(&_kMoni3rd_var); class_PSD_monitor_save(&_psd_samplepos_1cm2_var); class_E_monitor_save(&_emon_samplepos_1cm2_var); class_Divergence_monitor_save(&_divmon_samplepos_1cm2_var); class_PSD_monitor_save(&_psd_samplepos_large_var); class_PSD_monitor_4PI_save(&_psd_4pi_var); class_E_monitor_save(&_emon_before_ana_var); class_PSD_monitor_save(&_psd_before_ana_var); class_Divergence_monitor_save(&_divmon_before_ana_var); class_E_monitor_save(&_emon_before_coarse_var); class_PSD_monitor_save(&_psd_before_coarse_var); class_PSD_monitor_psf_eff_save(&_psd_detector_var); class_E_monitor_save(&_emon_detector_var); class_PSD_monitor_psf_eff_save(&_psd_window1_var); class_E_monitor_save(&_emon_window1_var); class_PSD_monitor_psf_eff_save(&_psd_window2_var); class_E_monitor_save(&_emon_window2_var); class_PSD_monitor_psf_eff_save(&_psd_window3_var); class_E_monitor_save(&_emon_window3_var); class_PSD_monitor_psf_eff_save(&_psd_window4_var); class_E_monitor_save(&_emon_window4_var); class_PSD_monitor_psf_eff_save(&_psd_window5_var); class_E_monitor_save(&_emon_window5_var); class_PSD_monitor_psf_eff_save(&_psd_window6_var); class_E_monitor_save(&_emon_window6_var); class_PSD_monitor_psf_eff_save(&_psd_window7_var); class_E_monitor_save(&_emon_window7_var); class_PSD_monitor_psf_eff_save(&_psd_window8_var); class_E_monitor_save(&_emon_window8_var); class_PSD_monitor_psf_eff_save(&_psd_window9_var); class_E_monitor_save(&_emon_window9_var); if (!handle) siminfo_close(); return(0); } /* save */ /* ***************************************************************************** * instrument 'RITA_II' and components FINALLY ***************************************************************************** */ _class_Progress_bar *class_Progress_bar_finally(_class_Progress_bar *_comp ) { #define profile (_comp->_parameters.profile) #define percent (_comp->_parameters.percent) #define flag_save (_comp->_parameters.flag_save) #define minutes (_comp->_parameters.minutes) #define IntermediateCnts (_comp->_parameters.IntermediateCnts) #define StartTime (_comp->_parameters.StartTime) #define EndTime (_comp->_parameters.EndTime) #define CurrentTime (_comp->_parameters.CurrentTime) #define infostring (_comp->_parameters.infostring) SIG_MESSAGE("[_armSource_finally] component armSource=Progress_bar() FINALLY [Progress_bar:0]"); time_t NowTime; time (&NowTime); fprintf (stdout, "\nFinally [%s: %s]. Time: ", instrument_name, dirname ? dirname : "."); if (difftime (NowTime, StartTime) < 60.0) fprintf (stdout, "%g [s] ", difftime (NowTime, StartTime)); else if (difftime (NowTime, StartTime) > 3600.0) fprintf (stdout, "%g [h] ", difftime (NowTime, StartTime) / 3600.0); else fprintf (stdout, "%g [min] ", difftime (NowTime, StartTime) / 60.0); fprintf (stdout, "\n"); #undef profile #undef percent #undef flag_save #undef minutes #undef IntermediateCnts #undef StartTime #undef EndTime #undef CurrentTime #undef infostring return(_comp); } /* class_Progress_bar_finally */ _class_Source_gen4 *class_Source_gen4_finally(_class_Source_gen4 *_comp ) { #define flux_file (_comp->_parameters.flux_file) #define xdiv_file (_comp->_parameters.xdiv_file) #define ydiv_file (_comp->_parameters.ydiv_file) #define radius (_comp->_parameters.radius) #define dist (_comp->_parameters.dist) #define xw (_comp->_parameters.xw) #define yh (_comp->_parameters.yh) #define E0 (_comp->_parameters.E0) #define dE (_comp->_parameters.dE) #define Lambda0 (_comp->_parameters.Lambda0) #define dLambda (_comp->_parameters.dLambda) #define I1 (_comp->_parameters.I1) #define h (_comp->_parameters.h) #define w (_comp->_parameters.w) #define gaussian (_comp->_parameters.gaussian) #define verbose (_comp->_parameters.verbose) #define T1 (_comp->_parameters.T1) #define flux_file_perAA (_comp->_parameters.flux_file_perAA) #define flux_file_log (_comp->_parameters.flux_file_log) #define Lmin (_comp->_parameters.Lmin) #define Lmax (_comp->_parameters.Lmax) #define Emin (_comp->_parameters.Emin) #define Emax (_comp->_parameters.Emax) #define T2 (_comp->_parameters.T2) #define I2 (_comp->_parameters.I2) #define T3 (_comp->_parameters.T3) #define I3 (_comp->_parameters.I3) #define length (_comp->_parameters.length) #define phi_init (_comp->_parameters.phi_init) #define theta_init (_comp->_parameters.theta_init) #define HEtailA (_comp->_parameters.HEtailA) #define HEtailL0 (_comp->_parameters.HEtailL0) #define pTable (_comp->_parameters.pTable) #define pTable_x (_comp->_parameters.pTable_x) #define pTable_y (_comp->_parameters.pTable_y) #define p_in (_comp->_parameters.p_in) #define lambda0 (_comp->_parameters.lambda0) #define lambda02 (_comp->_parameters.lambda02) #define lambda0b (_comp->_parameters.lambda0b) #define lambda02b (_comp->_parameters.lambda02b) #define lambda0c (_comp->_parameters.lambda0c) #define lambda02c (_comp->_parameters.lambda02c) #define L2P (_comp->_parameters.L2P) #define L2Pb (_comp->_parameters.L2Pb) #define L2Pc (_comp->_parameters.L2Pc) #define pTable_xmin (_comp->_parameters.pTable_xmin) #define pTable_ymin (_comp->_parameters.pTable_ymin) #define pTable_xmax (_comp->_parameters.pTable_xmax) #define pTable_ymax (_comp->_parameters.pTable_ymax) #define pTable_xsum (_comp->_parameters.pTable_xsum) #define pTable_ysum (_comp->_parameters.pTable_ysum) #define pTable_dxmin (_comp->_parameters.pTable_dxmin) #define pTable_dxmax (_comp->_parameters.pTable_dxmax) #define pTable_dymin (_comp->_parameters.pTable_dymin) #define pTable_dymax (_comp->_parameters.pTable_dymax) SIG_MESSAGE("[_source_finally] component source=Source_gen4() FINALLY [Source_gen4:0]"); Table_Free (&pTable); Table_Free (&pTable_x); Table_Free (&pTable_y); #undef flux_file #undef xdiv_file #undef ydiv_file #undef radius #undef dist #undef xw #undef yh #undef E0 #undef dE #undef Lambda0 #undef dLambda #undef I1 #undef h #undef w #undef gaussian #undef verbose #undef T1 #undef flux_file_perAA #undef flux_file_log #undef Lmin #undef Lmax #undef Emin #undef Emax #undef T2 #undef I2 #undef T3 #undef I3 #undef length #undef phi_init #undef theta_init #undef HEtailA #undef HEtailL0 #undef pTable #undef pTable_x #undef pTable_y #undef p_in #undef lambda0 #undef lambda02 #undef lambda0b #undef lambda02b #undef lambda0c #undef lambda02c #undef L2P #undef L2Pb #undef L2Pc #undef pTable_xmin #undef pTable_ymin #undef pTable_xmax #undef pTable_ymax #undef pTable_xsum #undef pTable_ysum #undef pTable_dxmin #undef pTable_dxmax #undef pTable_dymin #undef pTable_dymax return(_comp); } /* class_Source_gen4_finally */ _class_L_monitor *class_L_monitor_finally(_class_L_monitor *_comp ) { #define nL (_comp->_parameters.nL) #define filename (_comp->_parameters.filename) #define nowritefile (_comp->_parameters.nowritefile) #define xmin (_comp->_parameters.xmin) #define xmax (_comp->_parameters.xmax) #define ymin (_comp->_parameters.ymin) #define ymax (_comp->_parameters.ymax) #define xwidth (_comp->_parameters.xwidth) #define yheight (_comp->_parameters.yheight) #define Lmin (_comp->_parameters.Lmin) #define Lmax (_comp->_parameters.Lmax) #define restore_neutron (_comp->_parameters.restore_neutron) #define L_N (_comp->_parameters.L_N) #define L_p (_comp->_parameters.L_p) #define L_p2 (_comp->_parameters.L_p2) SIG_MESSAGE("[_lmon_guide_start_finally] component lmon_guide_start=L_monitor() FINALLY [L_monitor:0]"); destroy_darr1d (L_N); destroy_darr1d (L_p); destroy_darr1d (L_p2); #undef nL #undef filename #undef nowritefile #undef xmin #undef xmax #undef ymin #undef ymax #undef xwidth #undef yheight #undef Lmin #undef Lmax #undef restore_neutron #undef L_N #undef L_p #undef L_p2 return(_comp); } /* class_L_monitor_finally */ _class_PSD_monitor *class_PSD_monitor_finally(_class_PSD_monitor *_comp ) { #define nx (_comp->_parameters.nx) #define ny (_comp->_parameters.ny) #define filename (_comp->_parameters.filename) #define xmin (_comp->_parameters.xmin) #define xmax (_comp->_parameters.xmax) #define ymin (_comp->_parameters.ymin) #define ymax (_comp->_parameters.ymax) #define xwidth (_comp->_parameters.xwidth) #define yheight (_comp->_parameters.yheight) #define restore_neutron (_comp->_parameters.restore_neutron) #define nowritefile (_comp->_parameters.nowritefile) #define PSD_N (_comp->_parameters.PSD_N) #define PSD_p (_comp->_parameters.PSD_p) #define PSD_p2 (_comp->_parameters.PSD_p2) SIG_MESSAGE("[_psd_guide_end_finally] component psd_guide_end=PSD_monitor() FINALLY [PSD_monitor:0]"); destroy_darr2d(PSD_N); destroy_darr2d(PSD_p); destroy_darr2d(PSD_p2); #undef nx #undef ny #undef filename #undef xmin #undef xmax #undef ymin #undef ymax #undef xwidth #undef yheight #undef restore_neutron #undef nowritefile #undef PSD_N #undef PSD_p #undef PSD_p2 return(_comp); } /* class_PSD_monitor_finally */ _class_E_monitor *class_E_monitor_finally(_class_E_monitor *_comp ) { #define nE (_comp->_parameters.nE) #define filename (_comp->_parameters.filename) #define xmin (_comp->_parameters.xmin) #define xmax (_comp->_parameters.xmax) #define ymin (_comp->_parameters.ymin) #define ymax (_comp->_parameters.ymax) #define nowritefile (_comp->_parameters.nowritefile) #define xwidth (_comp->_parameters.xwidth) #define yheight (_comp->_parameters.yheight) #define Emin (_comp->_parameters.Emin) #define Emax (_comp->_parameters.Emax) #define restore_neutron (_comp->_parameters.restore_neutron) #define E_N (_comp->_parameters.E_N) #define E_p (_comp->_parameters.E_p) #define E_p2 (_comp->_parameters.E_p2) #define S_p (_comp->_parameters.S_p) #define S_pE (_comp->_parameters.S_pE) #define S_pE2 (_comp->_parameters.S_pE2) SIG_MESSAGE("[_emon_guide_end_finally] component emon_guide_end=E_monitor() FINALLY [E_monitor:0]"); destroy_darr1d (E_N); destroy_darr1d (E_p); destroy_darr1d (E_p2); #undef nE #undef filename #undef xmin #undef xmax #undef ymin #undef ymax #undef nowritefile #undef xwidth #undef yheight #undef Emin #undef Emax #undef restore_neutron #undef E_N #undef E_p #undef E_p2 #undef S_p #undef S_pE #undef S_pE2 return(_comp); } /* class_E_monitor_finally */ _class_Divergence_monitor *class_Divergence_monitor_finally(_class_Divergence_monitor *_comp ) { #define nh (_comp->_parameters.nh) #define nv (_comp->_parameters.nv) #define filename (_comp->_parameters.filename) #define xmin (_comp->_parameters.xmin) #define xmax (_comp->_parameters.xmax) #define ymin (_comp->_parameters.ymin) #define ymax (_comp->_parameters.ymax) #define nowritefile (_comp->_parameters.nowritefile) #define xwidth (_comp->_parameters.xwidth) #define yheight (_comp->_parameters.yheight) #define maxdiv_h (_comp->_parameters.maxdiv_h) #define maxdiv_v (_comp->_parameters.maxdiv_v) #define restore_neutron (_comp->_parameters.restore_neutron) #define nx (_comp->_parameters.nx) #define ny (_comp->_parameters.ny) #define nz (_comp->_parameters.nz) #define Div_N (_comp->_parameters.Div_N) #define Div_p (_comp->_parameters.Div_p) #define Div_p2 (_comp->_parameters.Div_p2) SIG_MESSAGE("[_divmon_guide_end_finally] component divmon_guide_end=Divergence_monitor() FINALLY [Divergence_monitor:0]"); destroy_darr2d (Div_N); destroy_darr2d (Div_p); destroy_darr2d (Div_p2); #undef nh #undef nv #undef filename #undef xmin #undef xmax #undef ymin #undef ymax #undef nowritefile #undef xwidth #undef yheight #undef maxdiv_h #undef maxdiv_v #undef restore_neutron #undef nx #undef ny #undef nz #undef Div_N #undef Div_p #undef Div_p2 return(_comp); } /* class_Divergence_monitor_finally */ _class_Monochromator_curved *class_Monochromator_curved_finally(_class_Monochromator_curved *_comp ) { #define reflect (_comp->_parameters.reflect) #define transmit (_comp->_parameters.transmit) #define zwidth (_comp->_parameters.zwidth) #define yheight (_comp->_parameters.yheight) #define gap (_comp->_parameters.gap) #define NH (_comp->_parameters.NH) #define NV (_comp->_parameters.NV) #define mosaich (_comp->_parameters.mosaich) #define mosaicv (_comp->_parameters.mosaicv) #define r0 (_comp->_parameters.r0) #define t0 (_comp->_parameters.t0) #define Q (_comp->_parameters.Q) #define RV (_comp->_parameters.RV) #define RH (_comp->_parameters.RH) #define DM (_comp->_parameters.DM) #define mosaic (_comp->_parameters.mosaic) #define width (_comp->_parameters.width) #define height (_comp->_parameters.height) #define verbose (_comp->_parameters.verbose) #define order (_comp->_parameters.order) #define mos_rms_y (_comp->_parameters.mos_rms_y) #define mos_rms_z (_comp->_parameters.mos_rms_z) #define mos_rms_max (_comp->_parameters.mos_rms_max) #define mono_Q (_comp->_parameters.mono_Q) #define SlabWidth (_comp->_parameters.SlabWidth) #define SlabHeight (_comp->_parameters.SlabHeight) #define rTable (_comp->_parameters.rTable) #define tTable (_comp->_parameters.tTable) #define rTableFlag (_comp->_parameters.rTableFlag) #define tTableFlag (_comp->_parameters.tTableFlag) #define tiltH (_comp->_parameters.tiltH) #define tiltV (_comp->_parameters.tiltV) #define ncol_var (_comp->_parameters.ncol_var) #define nrow_var (_comp->_parameters.nrow_var) SIG_MESSAGE("[_monochromator_curved_finally] component monochromator_curved=Monochromator_curved() FINALLY [Monochromator_curved:0]"); if (rTableFlag) { Table_Free (&rTable); } if (tTableFlag) { Table_Free (&tTable); } if (tiltH) free (tiltH); if (tiltV) free (tiltV); #undef reflect #undef transmit #undef zwidth #undef yheight #undef gap #undef NH #undef NV #undef mosaich #undef mosaicv #undef r0 #undef t0 #undef Q #undef RV #undef RH #undef DM #undef mosaic #undef width #undef height #undef verbose #undef order #undef mos_rms_y #undef mos_rms_z #undef mos_rms_max #undef mono_Q #undef SlabWidth #undef SlabHeight #undef rTable #undef tTable #undef rTableFlag #undef tTableFlag #undef tiltH #undef tiltV #undef ncol_var #undef nrow_var return(_comp); } /* class_Monochromator_curved_finally */ _class_Filter_gen *class_Filter_gen_finally(_class_Filter_gen *_comp ) { #define filename (_comp->_parameters.filename) #define options (_comp->_parameters.options) #define xmin (_comp->_parameters.xmin) #define xmax (_comp->_parameters.xmax) #define ymin (_comp->_parameters.ymin) #define ymax (_comp->_parameters.ymax) #define xwidth (_comp->_parameters.xwidth) #define yheight (_comp->_parameters.yheight) #define thickness (_comp->_parameters.thickness) #define scaling (_comp->_parameters.scaling) #define verbose (_comp->_parameters.verbose) #define Mode_Table (_comp->_parameters.Mode_Table) #define Type_Table (_comp->_parameters.Type_Table) #define pTable (_comp->_parameters.pTable) SIG_MESSAGE("[_infilter_finally] component infilter=Filter_gen() FINALLY [Filter_gen:0]"); Table_Free (&pTable); #undef filename #undef options #undef xmin #undef xmax #undef ymin #undef ymax #undef xwidth #undef yheight #undef thickness #undef scaling #undef verbose #undef Mode_Table #undef Type_Table #undef pTable return(_comp); } /* class_Filter_gen_finally */ _class_Monitor_nD *class_Monitor_nD_finally(_class_Monitor_nD *_comp ) { #define user0 (_comp->_parameters.user0) #define user1 (_comp->_parameters.user1) #define user2 (_comp->_parameters.user2) #define user3 (_comp->_parameters.user3) #define user4 (_comp->_parameters.user4) #define user5 (_comp->_parameters.user5) #define user6 (_comp->_parameters.user6) #define user7 (_comp->_parameters.user7) #define user8 (_comp->_parameters.user8) #define user9 (_comp->_parameters.user9) #define xwidth (_comp->_parameters.xwidth) #define yheight (_comp->_parameters.yheight) #define zdepth (_comp->_parameters.zdepth) #define xmin (_comp->_parameters.xmin) #define xmax (_comp->_parameters.xmax) #define ymin (_comp->_parameters.ymin) #define ymax (_comp->_parameters.ymax) #define zmin (_comp->_parameters.zmin) #define zmax (_comp->_parameters.zmax) #define bins (_comp->_parameters.bins) #define min (_comp->_parameters.min) #define max (_comp->_parameters.max) #define restore_neutron (_comp->_parameters.restore_neutron) #define radius (_comp->_parameters.radius) #define options (_comp->_parameters.options) #define filename (_comp->_parameters.filename) #define geometry (_comp->_parameters.geometry) #define nowritefile (_comp->_parameters.nowritefile) #define nexus_bins (_comp->_parameters.nexus_bins) #define username0 (_comp->_parameters.username0) #define username1 (_comp->_parameters.username1) #define username2 (_comp->_parameters.username2) #define username3 (_comp->_parameters.username3) #define username4 (_comp->_parameters.username4) #define username5 (_comp->_parameters.username5) #define username6 (_comp->_parameters.username6) #define username7 (_comp->_parameters.username7) #define username8 (_comp->_parameters.username8) #define username9 (_comp->_parameters.username9) #define DEFS (_comp->_parameters.DEFS) #define Vars (_comp->_parameters.Vars) #define detector (_comp->_parameters.detector) #define offdata (_comp->_parameters.offdata) SIG_MESSAGE("[_OrderMon_finally] component OrderMon=Monitor_nD() FINALLY [Monitor_nD:0]"); /* free pointers */ Monitor_nD_Finally (&DEFS, &Vars); #undef user0 #undef user1 #undef user2 #undef user3 #undef user4 #undef user5 #undef user6 #undef user7 #undef user8 #undef user9 #undef xwidth #undef yheight #undef zdepth #undef xmin #undef xmax #undef ymin #undef ymax #undef zmin #undef zmax #undef bins #undef min #undef max #undef restore_neutron #undef radius #undef options #undef filename #undef geometry #undef nowritefile #undef nexus_bins #undef username0 #undef username1 #undef username2 #undef username3 #undef username4 #undef username5 #undef username6 #undef username7 #undef username8 #undef username9 #undef DEFS #undef Vars #undef detector #undef offdata return(_comp); } /* class_Monitor_nD_finally */ _class_PSD_monitor_psf_eff *class_PSD_monitor_psf_eff_finally(_class_PSD_monitor_psf_eff *_comp ) { #define nx (_comp->_parameters.nx) #define ny (_comp->_parameters.ny) #define filename (_comp->_parameters.filename) #define xmin (_comp->_parameters.xmin) #define xmax (_comp->_parameters.xmax) #define ymin (_comp->_parameters.ymin) #define ymax (_comp->_parameters.ymax) #define nowritefile (_comp->_parameters.nowritefile) #define xwidth (_comp->_parameters.xwidth) #define yheight (_comp->_parameters.yheight) #define psf (_comp->_parameters.psf) #define k0 (_comp->_parameters.k0) #define eff (_comp->_parameters.eff) #define restore_neutron (_comp->_parameters.restore_neutron) #define PSD_N (_comp->_parameters.PSD_N) #define PSD_p (_comp->_parameters.PSD_p) #define PSD_p2 (_comp->_parameters.PSD_p2) #define weight (_comp->_parameters.weight) SIG_MESSAGE("[_kMoni_finally] component kMoni=PSD_monitor_psf_eff() FINALLY [PSD_monitor_psf_eff:0]"); destroy_darr2d (PSD_N); destroy_darr2d (PSD_p); destroy_darr2d (PSD_p2); #undef nx #undef ny #undef filename #undef xmin #undef xmax #undef ymin #undef ymax #undef nowritefile #undef xwidth #undef yheight #undef psf #undef k0 #undef eff #undef restore_neutron #undef PSD_N #undef PSD_p #undef PSD_p2 #undef weight return(_comp); } /* class_PSD_monitor_psf_eff_finally */ _class_PowderN *class_PowderN_finally(_class_PowderN *_comp ) { #define reflections (_comp->_parameters.reflections) #define geometry (_comp->_parameters.geometry) #define format (_comp->_parameters.format) #define radius (_comp->_parameters.radius) #define yheight (_comp->_parameters.yheight) #define xwidth (_comp->_parameters.xwidth) #define zdepth (_comp->_parameters.zdepth) #define thickness (_comp->_parameters.thickness) #define pack (_comp->_parameters.pack) #define Vc (_comp->_parameters.Vc) #define sigma_abs (_comp->_parameters.sigma_abs) #define sigma_inc (_comp->_parameters.sigma_inc) #define delta_d_d (_comp->_parameters.delta_d_d) #define p_inc (_comp->_parameters.p_inc) #define p_transmit (_comp->_parameters.p_transmit) #define DW (_comp->_parameters.DW) #define nb_atoms (_comp->_parameters.nb_atoms) #define d_omega (_comp->_parameters.d_omega) #define d_phi (_comp->_parameters.d_phi) #define tth_sign (_comp->_parameters.tth_sign) #define p_interact (_comp->_parameters.p_interact) #define concentric (_comp->_parameters.concentric) #define density (_comp->_parameters.density) #define weight (_comp->_parameters.weight) #define barns (_comp->_parameters.barns) #define Strain (_comp->_parameters.Strain) #define focus_flip (_comp->_parameters.focus_flip) #define target_index (_comp->_parameters.target_index) #define order (_comp->_parameters.order) #define line_info (_comp->_parameters.line_info) #define columns (_comp->_parameters.columns) #define offdata (_comp->_parameters.offdata) #define tgt_x (_comp->_parameters.tgt_x) #define tgt_y (_comp->_parameters.tgt_y) #define tgt_z (_comp->_parameters.tgt_z) SIG_MESSAGE("[_powderSample_finally] component powderSample=PowderN() FINALLY [PowderN:0]"); free (line_info.list); free (line_info.q_v); free (line_info.w_v); free (line_info.my_s_v2); MPI_MASTER (if (line_info.flag_warning) printf ("PowderN: %s: Error messages were repeated %i times with absorbed neutrons.\n", NAME_CURRENT_COMP, line_info.flag_warning); /* in case this instance is used in a SPLIT, we can recommend the optimal iteration value */ if (line_info.nb_refl_count) { double split_iterations = (double)line_info.nb_reuses / line_info.nb_refl_count + 1; double split_optimal = (double)line_info.nb_refl / line_info.nb_refl_count; if (split_optimal > split_iterations + 5) printf ("PowderN: %s: Info: you may highly improve the computation efficiency by using\n" " SPLIT %i COMPONENT %s=PowderN(...)\n" " in the instrument description %s.\n", NAME_CURRENT_COMP, (int)split_optimal, NAME_CURRENT_COMP, instrument_source); }); #undef reflections #undef geometry #undef format #undef radius #undef yheight #undef xwidth #undef zdepth #undef thickness #undef pack #undef Vc #undef sigma_abs #undef sigma_inc #undef delta_d_d #undef p_inc #undef p_transmit #undef DW #undef nb_atoms #undef d_omega #undef d_phi #undef tth_sign #undef p_interact #undef concentric #undef density #undef weight #undef barns #undef Strain #undef focus_flip #undef target_index #undef order #undef line_info #undef columns #undef offdata #undef tgt_x #undef tgt_y #undef tgt_z return(_comp); } /* class_PowderN_finally */ _class_Single_crystal *class_Single_crystal_finally(_class_Single_crystal *_comp ) { #define reflections (_comp->_parameters.reflections) #define geometry (_comp->_parameters.geometry) #define mosaic_AB (_comp->_parameters.mosaic_AB) #define xwidth (_comp->_parameters.xwidth) #define yheight (_comp->_parameters.yheight) #define zdepth (_comp->_parameters.zdepth) #define radius (_comp->_parameters.radius) #define delta_d_d (_comp->_parameters.delta_d_d) #define mosaic (_comp->_parameters.mosaic) #define mosaic_a (_comp->_parameters.mosaic_a) #define mosaic_b (_comp->_parameters.mosaic_b) #define mosaic_c (_comp->_parameters.mosaic_c) #define recip_cell (_comp->_parameters.recip_cell) #define barns (_comp->_parameters.barns) #define ax (_comp->_parameters.ax) #define ay (_comp->_parameters.ay) #define az (_comp->_parameters.az) #define bx (_comp->_parameters.bx) #define by (_comp->_parameters.by) #define bz (_comp->_parameters.bz) #define cx (_comp->_parameters.cx) #define cy (_comp->_parameters.cy) #define cz (_comp->_parameters.cz) #define p_transmit (_comp->_parameters.p_transmit) #define sigma_abs (_comp->_parameters.sigma_abs) #define sigma_inc (_comp->_parameters.sigma_inc) #define aa (_comp->_parameters.aa) #define bb (_comp->_parameters.bb) #define cc (_comp->_parameters.cc) #define order (_comp->_parameters.order) #define extra_order (_comp->_parameters.extra_order) #define RX (_comp->_parameters.RX) #define RY (_comp->_parameters.RY) #define powder (_comp->_parameters.powder) #define PG (_comp->_parameters.PG) #define deltak (_comp->_parameters.deltak) #define hkl_info (_comp->_parameters.hkl_info) #define offdata (_comp->_parameters.offdata) #define hkl_list (_comp->_parameters.hkl_list) #define tau_list (_comp->_parameters.tau_list) SIG_MESSAGE("[_crystalSample_finally] component crystalSample=Single_crystal() FINALLY [Single_crystal:0]"); #ifdef USE_MPI if (mpi_node_rank == mpi_node_root) { #endif if (hkl_info.flag_warning) fprintf (stderr, "Single_crystal: %s: Error message was repeated %i times with absorbed neutrons.\n", NAME_CURRENT_COMP, hkl_info.flag_warning); /* in case this instance is used in a SPLIT, we can recommend the optimal iteration value */ if (hkl_info.max_tau_count >= MCSX_REFL_SLIST_SIZE) { fprintf (stderr, "Warning (%s): The reflection short list buffer was exhausted at least once. Please consider redefining MCSX_REFL_SLIST_SIZE > %d\n", NAME_CURRENT_COMP, MCSX_REFL_SLIST_SIZE); } if (hkl_info.nb_refl_count) { double split_iterations = (double)hkl_info.nb_reuses / hkl_info.nb_refl_count + 1; double split_optimal = (double)hkl_info.nb_refl / hkl_info.nb_refl_count; if (split_optimal > split_iterations + 5) printf ("Single_crystal: %s: Info: you may highly improve the computation efficiency by using\n" " SPLIT %i COMPONENT %s=Single_crystal(order=1, ...)\n" " in the instrument description %s.\n", NAME_CURRENT_COMP, (int)split_optimal, NAME_CURRENT_COMP, instrument_source); } #ifdef USE_OPENCL if (oclContext_SX.Kernel) { int iDevice = 0; // clear OpenCL memory if (oclContext_SX.GPUContext) clReleaseContext (oclContext_SX.GPUContext); if (oclContext_SX.Kernel) clReleaseKernel (oclContext_SX.Kernel); if (oclContext_SX.CommandQueue[iDevice]) clReleaseCommandQueue (oclContext_SX.CommandQueue[iDevice]); if (d_L) clReleaseMemObject (d_L); if (d_T) clReleaseMemObject (d_T); if (d_tau_count) clReleaseMemObject (d_tau_count); if (d_coh_refl) clReleaseMemObject (d_coh_refl); if (d_coh_xsect) clReleaseMemObject (d_coh_xsect); } #endif #ifdef USE_MPI } #endif #undef reflections #undef geometry #undef mosaic_AB #undef xwidth #undef yheight #undef zdepth #undef radius #undef delta_d_d #undef mosaic #undef mosaic_a #undef mosaic_b #undef mosaic_c #undef recip_cell #undef barns #undef ax #undef ay #undef az #undef bx #undef by #undef bz #undef cx #undef cy #undef cz #undef p_transmit #undef sigma_abs #undef sigma_inc #undef aa #undef bb #undef cc #undef order #undef extra_order #undef RX #undef RY #undef powder #undef PG #undef deltak #undef hkl_info #undef offdata #undef hkl_list #undef tau_list return(_comp); } /* class_Single_crystal_finally */ _class_Phonon_simple *class_Phonon_simple_finally(_class_Phonon_simple *_comp ) { #define radius (_comp->_parameters.radius) #define yheight (_comp->_parameters.yheight) #define sigma_abs (_comp->_parameters.sigma_abs) #define sigma_inc (_comp->_parameters.sigma_inc) #define a (_comp->_parameters.a) #define b (_comp->_parameters.b) #define M (_comp->_parameters.M) #define c (_comp->_parameters.c) #define DW (_comp->_parameters.DW) #define T (_comp->_parameters.T) #define target_x (_comp->_parameters.target_x) #define target_y (_comp->_parameters.target_y) #define target_z (_comp->_parameters.target_z) #define target_index (_comp->_parameters.target_index) #define focus_r (_comp->_parameters.focus_r) #define focus_xw (_comp->_parameters.focus_xw) #define focus_yh (_comp->_parameters.focus_yh) #define focus_aw (_comp->_parameters.focus_aw) #define focus_ah (_comp->_parameters.focus_ah) #define gap (_comp->_parameters.gap) #define e_steps_low (_comp->_parameters.e_steps_low) #define e_steps_high (_comp->_parameters.e_steps_high) #define V_rho (_comp->_parameters.V_rho) #define V_my_s (_comp->_parameters.V_my_s) #define V_my_a_v (_comp->_parameters.V_my_a_v) #define DV (_comp->_parameters.DV) #define phonon (_comp->_parameters.phonon) SIG_MESSAGE("[_phononSample_finally] component phononSample=Phonon_simple() FINALLY [Phonon_simple:0]"); #undef radius #undef yheight #undef sigma_abs #undef sigma_inc #undef a #undef b #undef M #undef c #undef DW #undef T #undef target_x #undef target_y #undef target_z #undef target_index #undef focus_r #undef focus_xw #undef focus_yh #undef focus_aw #undef focus_ah #undef gap #undef e_steps_low #undef e_steps_high #undef V_rho #undef V_my_s #undef V_my_a_v #undef DV #undef phonon return(_comp); } /* class_Phonon_simple_finally */ _class_PSD_monitor_4PI *class_PSD_monitor_4PI_finally(_class_PSD_monitor_4PI *_comp ) { #define nx (_comp->_parameters.nx) #define ny (_comp->_parameters.ny) #define filename (_comp->_parameters.filename) #define nowritefile (_comp->_parameters.nowritefile) #define radius (_comp->_parameters.radius) #define restore_neutron (_comp->_parameters.restore_neutron) #define PSD_N (_comp->_parameters.PSD_N) #define PSD_p (_comp->_parameters.PSD_p) #define PSD_p2 (_comp->_parameters.PSD_p2) SIG_MESSAGE("[_psd_4pi_finally] component psd_4pi=PSD_monitor_4PI() FINALLY [PSD_monitor_4PI:0]"); destroy_darr2d (PSD_N); destroy_darr2d (PSD_p); destroy_darr2d (PSD_p2); #undef nx #undef ny #undef filename #undef nowritefile #undef radius #undef restore_neutron #undef PSD_N #undef PSD_p #undef PSD_p2 return(_comp); } /* class_PSD_monitor_4PI_finally */ int finally(void) { /* called by mccode_main for RITA_II:FINALLY */ #pragma acc update host(_armSource_var) #pragma acc update host(_source_var) #pragma acc update host(_slitGuideBegin_var) #pragma acc update host(_lmon_guide_start_var) #pragma acc update host(_guideStraight_var) #pragma acc update host(_guideCurved1_var) #pragma acc update host(_guideCurved2_var) #pragma acc update host(_guideCurved3_var) #pragma acc update host(_guideCurved4_var) #pragma acc update host(_guideCurved5_var) #pragma acc update host(_guideCurved6_var) #pragma acc update host(_guideCurved7_var) #pragma acc update host(_guideCurved8_var) #pragma acc update host(_guideCurved9_var) #pragma acc update host(_guideCurved10_var) #pragma acc update host(_guideCurved11_var) #pragma acc update host(_guideCurved12_var) #pragma acc update host(_guideCurved13_var) #pragma acc update host(_guideCurved14_var) #pragma acc update host(_guideCurved15_var) #pragma acc update host(_guideCurved16_var) #pragma acc update host(_guideCurved17_var) #pragma acc update host(_guideCurved18_var) #pragma acc update host(_guideCurved19_var) #pragma acc update host(_guideCurved20_var) #pragma acc update host(_guideCurved21_var) #pragma acc update host(_guideCurved22_var) #pragma acc update host(_guideCurved23_var) #pragma acc update host(_guideCurved24_var) #pragma acc update host(_guideCurved25_var) #pragma acc update host(_guideCurved26_var) #pragma acc update host(_guideCurved27_var) #pragma acc update host(_guideCurved28_var) #pragma acc update host(_guideCurved29_var) #pragma acc update host(_guideCurved30_var) #pragma acc update host(_guideCurved31_var) #pragma acc update host(_guideCurved32_var) #pragma acc update host(_guideCurved33_var) #pragma acc update host(_guideCurved34_var) #pragma acc update host(_guideCurved35_var) #pragma acc update host(_guideCurved36_var) #pragma acc update host(_guideCurved37_var) #pragma acc update host(_guideCurved38_var) #pragma acc update host(_guideCurved39_var) #pragma acc update host(_guideCurved40_var) #pragma acc update host(_bunker_var) #pragma acc update host(_guide3_var) #pragma acc update host(_slitGuideEnd_var) #pragma acc update host(_psd_guide_end_var) #pragma acc update host(_emon_guide_end_var) #pragma acc update host(_lmon_guide_end_var) #pragma acc update host(_divmon_guide_end_var) #pragma acc update host(_focus_mono_var) #pragma acc update host(_monochromator_curved_var) #pragma acc update host(_a2_var) #pragma acc update host(_slitShutter_var) #pragma acc update host(_MSCollimator_var) #pragma acc update host(_infilter_var) #pragma acc update host(_psd_virt_var) #pragma acc update host(_lmon_virt_var) #pragma acc update host(_aa2_var) #pragma acc update host(_OrderMon_var) #pragma acc update host(_kMoni_var) #pragma acc update host(_kMoni1st_var) #pragma acc update host(_kMoni2nd_var) #pragma acc update host(_kMoni3rd_var) #pragma acc update host(_slitMonochromator_var) #pragma acc update host(_Perspex_var) #pragma acc update host(_psd_samplepos_1cm2_var) #pragma acc update host(_emon_samplepos_1cm2_var) #pragma acc update host(_divmon_samplepos_1cm2_var) #pragma acc update host(_psd_samplepos_large_var) #pragma acc update host(_a3_var) #pragma acc update host(_aa3_var) #pragma acc update host(_incohSample_var) #pragma acc update host(_powderSample_var) #pragma acc update host(_crystalSample_var) #pragma acc update host(_phononSample_var) #pragma acc update host(_psd_4pi_var) #pragma acc update host(_a4_var) #pragma acc update host(_slitSample_var) #pragma acc update host(_filter_coll_var) #pragma acc update host(_filter_var) #pragma acc update host(_ana_slit1_var) #pragma acc update host(_ana_slit2_var) #pragma acc update host(_emon_before_ana_var) #pragma acc update host(_psd_before_ana_var) #pragma acc update host(_divmon_before_ana_var) #pragma acc update host(_focus_ana_var) #pragma acc update host(_an1l_var) #pragma acc update host(_an1u_var) #pragma acc update host(_an2l_var) #pragma acc update host(_an2u_var) #pragma acc update host(_an3l_var) #pragma acc update host(_an3u_var) #pragma acc update host(_an4l_var) #pragma acc update host(_an4u_var) #pragma acc update host(_an5l_var) #pragma acc update host(_an5u_var) #pragma acc update host(_an6l_var) #pragma acc update host(_an6u_var) #pragma acc update host(_an7l_var) #pragma acc update host(_an7u_var) #pragma acc update host(_an8l_var) #pragma acc update host(_an8u_var) #pragma acc update host(_an9l_var) #pragma acc update host(_an9u_var) #pragma acc update host(_a6_var) #pragma acc update host(_emon_before_coarse_var) #pragma acc update host(_psd_before_coarse_var) #pragma acc update host(_ArmR1_var) #pragma acc update host(_BladeR1_var) #pragma acc update host(_ArmR2_var) #pragma acc update host(_BladeR2_var) #pragma acc update host(_ArmR3_var) #pragma acc update host(_BladeR3_var) #pragma acc update host(_ArmR4_var) #pragma acc update host(_BladeR4_var) #pragma acc update host(_ArmR5_var) #pragma acc update host(_BladeR5_var) #pragma acc update host(_ArmL1_var) #pragma acc update host(_BladeL1_var) #pragma acc update host(_ArmL2_var) #pragma acc update host(_BladeL2_var) #pragma acc update host(_ArmL3_var) #pragma acc update host(_BladeL3_var) #pragma acc update host(_ArmL4_var) #pragma acc update host(_BladeL4_var) #pragma acc update host(_ArmL5_var) #pragma acc update host(_BladeL5_var) #pragma acc update host(_psd_detector_var) #pragma acc update host(_emon_detector_var) #pragma acc update host(_psd_window1_var) #pragma acc update host(_emon_window1_var) #pragma acc update host(_psd_window2_var) #pragma acc update host(_emon_window2_var) #pragma acc update host(_psd_window3_var) #pragma acc update host(_emon_window3_var) #pragma acc update host(_psd_window4_var) #pragma acc update host(_emon_window4_var) #pragma acc update host(_psd_window5_var) #pragma acc update host(_emon_window5_var) #pragma acc update host(_psd_window6_var) #pragma acc update host(_emon_window6_var) #pragma acc update host(_psd_window7_var) #pragma acc update host(_emon_window7_var) #pragma acc update host(_psd_window8_var) #pragma acc update host(_emon_window8_var) #pragma acc update host(_psd_window9_var) #pragma acc update host(_emon_window9_var) #pragma acc update host(_instrument_var) siminfo_init(NULL); save(siminfo_file); /* save data when simulation ends */ /* call iteratively all components FINALLY */ class_Progress_bar_finally(&_armSource_var); class_Source_gen4_finally(&_source_var); class_L_monitor_finally(&_lmon_guide_start_var); class_PSD_monitor_finally(&_psd_guide_end_var); class_E_monitor_finally(&_emon_guide_end_var); class_L_monitor_finally(&_lmon_guide_end_var); class_Divergence_monitor_finally(&_divmon_guide_end_var); class_Monochromator_curved_finally(&_monochromator_curved_var); class_Filter_gen_finally(&_infilter_var); class_PSD_monitor_finally(&_psd_virt_var); class_L_monitor_finally(&_lmon_virt_var); class_Monitor_nD_finally(&_OrderMon_var); class_PSD_monitor_psf_eff_finally(&_kMoni_var); class_PSD_monitor_psf_eff_finally(&_kMoni1st_var); class_PSD_monitor_psf_eff_finally(&_kMoni2nd_var); class_PSD_monitor_psf_eff_finally(&_kMoni3rd_var); class_PSD_monitor_finally(&_psd_samplepos_1cm2_var); class_E_monitor_finally(&_emon_samplepos_1cm2_var); class_Divergence_monitor_finally(&_divmon_samplepos_1cm2_var); class_PSD_monitor_finally(&_psd_samplepos_large_var); class_PowderN_finally(&_powderSample_var); class_Single_crystal_finally(&_crystalSample_var); class_Phonon_simple_finally(&_phononSample_var); class_PSD_monitor_4PI_finally(&_psd_4pi_var); class_Filter_gen_finally(&_filter_var); class_E_monitor_finally(&_emon_before_ana_var); class_PSD_monitor_finally(&_psd_before_ana_var); class_Divergence_monitor_finally(&_divmon_before_ana_var); class_E_monitor_finally(&_emon_before_coarse_var); class_PSD_monitor_finally(&_psd_before_coarse_var); class_PSD_monitor_psf_eff_finally(&_psd_detector_var); class_E_monitor_finally(&_emon_detector_var); class_PSD_monitor_psf_eff_finally(&_psd_window1_var); class_E_monitor_finally(&_emon_window1_var); class_PSD_monitor_psf_eff_finally(&_psd_window2_var); class_E_monitor_finally(&_emon_window2_var); class_PSD_monitor_psf_eff_finally(&_psd_window3_var); class_E_monitor_finally(&_emon_window3_var); class_PSD_monitor_psf_eff_finally(&_psd_window4_var); class_E_monitor_finally(&_emon_window4_var); class_PSD_monitor_psf_eff_finally(&_psd_window5_var); class_E_monitor_finally(&_emon_window5_var); class_PSD_monitor_psf_eff_finally(&_psd_window6_var); class_E_monitor_finally(&_emon_window6_var); class_PSD_monitor_psf_eff_finally(&_psd_window7_var); class_E_monitor_finally(&_emon_window7_var); class_PSD_monitor_psf_eff_finally(&_psd_window8_var); class_E_monitor_finally(&_emon_window8_var); class_PSD_monitor_psf_eff_finally(&_psd_window9_var); class_E_monitor_finally(&_emon_window9_var); siminfo_close(); return(0); } /* finally */ /* ***************************************************************************** * instrument 'RITA_II' and components DISPLAY ***************************************************************************** */ #define magnify mcdis_magnify #define line mcdis_line #define dashed_line mcdis_dashed_line #define multiline mcdis_multiline #define rectangle mcdis_rectangle #define box mcdis_box #define circle mcdis_circle #define cylinder mcdis_cylinder #define sphere mcdis_sphere #define cone mcdis_cone #define polygon mcdis_polygon #define polyhedron mcdis_polyhedron _class_Progress_bar *class_Progress_bar_display(_class_Progress_bar *_comp ) { #define profile (_comp->_parameters.profile) #define percent (_comp->_parameters.percent) #define flag_save (_comp->_parameters.flag_save) #define minutes (_comp->_parameters.minutes) #define IntermediateCnts (_comp->_parameters.IntermediateCnts) #define StartTime (_comp->_parameters.StartTime) #define EndTime (_comp->_parameters.EndTime) #define CurrentTime (_comp->_parameters.CurrentTime) #define infostring (_comp->_parameters.infostring) SIG_MESSAGE("[_armSource_display] component armSource=Progress_bar() DISPLAY [Progress_bar:0]"); printf("MCDISPLAY: component %s\n", _comp->_name); #undef profile #undef percent #undef flag_save #undef minutes #undef IntermediateCnts #undef StartTime #undef EndTime #undef CurrentTime #undef infostring return(_comp); } /* class_Progress_bar_display */ _class_Source_gen4 *class_Source_gen4_display(_class_Source_gen4 *_comp ) { #define flux_file (_comp->_parameters.flux_file) #define xdiv_file (_comp->_parameters.xdiv_file) #define ydiv_file (_comp->_parameters.ydiv_file) #define radius (_comp->_parameters.radius) #define dist (_comp->_parameters.dist) #define xw (_comp->_parameters.xw) #define yh (_comp->_parameters.yh) #define E0 (_comp->_parameters.E0) #define dE (_comp->_parameters.dE) #define Lambda0 (_comp->_parameters.Lambda0) #define dLambda (_comp->_parameters.dLambda) #define I1 (_comp->_parameters.I1) #define h (_comp->_parameters.h) #define w (_comp->_parameters.w) #define gaussian (_comp->_parameters.gaussian) #define verbose (_comp->_parameters.verbose) #define T1 (_comp->_parameters.T1) #define flux_file_perAA (_comp->_parameters.flux_file_perAA) #define flux_file_log (_comp->_parameters.flux_file_log) #define Lmin (_comp->_parameters.Lmin) #define Lmax (_comp->_parameters.Lmax) #define Emin (_comp->_parameters.Emin) #define Emax (_comp->_parameters.Emax) #define T2 (_comp->_parameters.T2) #define I2 (_comp->_parameters.I2) #define T3 (_comp->_parameters.T3) #define I3 (_comp->_parameters.I3) #define length (_comp->_parameters.length) #define phi_init (_comp->_parameters.phi_init) #define theta_init (_comp->_parameters.theta_init) #define HEtailA (_comp->_parameters.HEtailA) #define HEtailL0 (_comp->_parameters.HEtailL0) #define pTable (_comp->_parameters.pTable) #define pTable_x (_comp->_parameters.pTable_x) #define pTable_y (_comp->_parameters.pTable_y) #define p_in (_comp->_parameters.p_in) #define lambda0 (_comp->_parameters.lambda0) #define lambda02 (_comp->_parameters.lambda02) #define lambda0b (_comp->_parameters.lambda0b) #define lambda02b (_comp->_parameters.lambda02b) #define lambda0c (_comp->_parameters.lambda0c) #define lambda02c (_comp->_parameters.lambda02c) #define L2P (_comp->_parameters.L2P) #define L2Pb (_comp->_parameters.L2Pb) #define L2Pc (_comp->_parameters.L2Pc) #define pTable_xmin (_comp->_parameters.pTable_xmin) #define pTable_ymin (_comp->_parameters.pTable_ymin) #define pTable_xmax (_comp->_parameters.pTable_xmax) #define pTable_ymax (_comp->_parameters.pTable_ymax) #define pTable_xsum (_comp->_parameters.pTable_xsum) #define pTable_ysum (_comp->_parameters.pTable_ysum) #define pTable_dxmin (_comp->_parameters.pTable_dxmin) #define pTable_dxmax (_comp->_parameters.pTable_dxmax) #define pTable_dymin (_comp->_parameters.pTable_dymin) #define pTable_dymax (_comp->_parameters.pTable_dymax) SIG_MESSAGE("[_source_display] component source=Source_gen4() DISPLAY [Source_gen4:0]"); printf("MCDISPLAY: component %s\n", _comp->_name); double xmin; double xmax; double ymin; double ymax; if ((h == 0) || (w == 0)) { circle ("xy", 0, 0, 0, radius); if (gaussian) circle ("xy", 0, 0, 0, radius / 2); } else { xmin = -w / 2; xmax = w / 2; ymin = -h / 2; ymax = h / 2; multiline (5, (double)xmin, (double)ymin, 0.0, (double)xmax, (double)ymin, 0.0, (double)xmax, (double)ymax, 0.0, (double)xmin, (double)ymax, 0.0, (double)xmin, (double)ymin, 0.0); if (gaussian) circle ("xy", 0, 0, 0, sqrt (w * w + h * h) / 4); } #undef flux_file #undef xdiv_file #undef ydiv_file #undef radius #undef dist #undef xw #undef yh #undef E0 #undef dE #undef Lambda0 #undef dLambda #undef I1 #undef h #undef w #undef gaussian #undef verbose #undef T1 #undef flux_file_perAA #undef flux_file_log #undef Lmin #undef Lmax #undef Emin #undef Emax #undef T2 #undef I2 #undef T3 #undef I3 #undef length #undef phi_init #undef theta_init #undef HEtailA #undef HEtailL0 #undef pTable #undef pTable_x #undef pTable_y #undef p_in #undef lambda0 #undef lambda02 #undef lambda0b #undef lambda02b #undef lambda0c #undef lambda02c #undef L2P #undef L2Pb #undef L2Pc #undef pTable_xmin #undef pTable_ymin #undef pTable_xmax #undef pTable_ymax #undef pTable_xsum #undef pTable_ysum #undef pTable_dxmin #undef pTable_dxmax #undef pTable_dymin #undef pTable_dymax return(_comp); } /* class_Source_gen4_display */ _class_Slit *class_Slit_display(_class_Slit *_comp ) { #define xmin (_comp->_parameters.xmin) #define xmax (_comp->_parameters.xmax) #define ymin (_comp->_parameters.ymin) #define ymax (_comp->_parameters.ymax) #define radius (_comp->_parameters.radius) #define xwidth (_comp->_parameters.xwidth) #define yheight (_comp->_parameters.yheight) #define isradial (_comp->_parameters.isradial) SIG_MESSAGE("[_slitGuideBegin_display] component slitGuideBegin=Slit() DISPLAY [Slit:0]"); printf("MCDISPLAY: component %s\n", _comp->_name); if (is_unset (radius)) { double xw, yh; xw = (xmax - xmin) / 2.0; yh = (ymax - ymin) / 2.0; multiline (3, xmin - xw, (double)ymax, 0.0, (double)xmin, (double)ymax, 0.0, (double)xmin, ymax + yh, 0.0); multiline (3, xmax + xw, (double)ymax, 0.0, (double)xmax, (double)ymax, 0.0, (double)xmax, ymax + yh, 0.0); multiline (3, xmin - xw, (double)ymin, 0.0, (double)xmin, (double)ymin, 0.0, (double)xmin, ymin - yh, 0.0); multiline (3, xmax + xw, (double)ymin, 0.0, (double)xmax, (double)ymin, 0.0, (double)xmax, ymin - yh, 0.0); } else { circle ("xy", 0, 0, 0, radius); } #undef xmin #undef xmax #undef ymin #undef ymax #undef radius #undef xwidth #undef yheight #undef isradial return(_comp); } /* class_Slit_display */ _class_L_monitor *class_L_monitor_display(_class_L_monitor *_comp ) { #define nL (_comp->_parameters.nL) #define filename (_comp->_parameters.filename) #define nowritefile (_comp->_parameters.nowritefile) #define xmin (_comp->_parameters.xmin) #define xmax (_comp->_parameters.xmax) #define ymin (_comp->_parameters.ymin) #define ymax (_comp->_parameters.ymax) #define xwidth (_comp->_parameters.xwidth) #define yheight (_comp->_parameters.yheight) #define Lmin (_comp->_parameters.Lmin) #define Lmax (_comp->_parameters.Lmax) #define restore_neutron (_comp->_parameters.restore_neutron) #define L_N (_comp->_parameters.L_N) #define L_p (_comp->_parameters.L_p) #define L_p2 (_comp->_parameters.L_p2) SIG_MESSAGE("[_lmon_guide_start_display] component lmon_guide_start=L_monitor() DISPLAY [L_monitor:0]"); printf("MCDISPLAY: component %s\n", _comp->_name); multiline (5, (double)xmin, (double)ymin, 0.0, (double)xmax, (double)ymin, 0.0, (double)xmax, (double)ymax, 0.0, (double)xmin, (double)ymax, 0.0, (double)xmin, (double)ymin, 0.0); #undef nL #undef filename #undef nowritefile #undef xmin #undef xmax #undef ymin #undef ymax #undef xwidth #undef yheight #undef Lmin #undef Lmax #undef restore_neutron #undef L_N #undef L_p #undef L_p2 return(_comp); } /* class_L_monitor_display */ _class_Guide *class_Guide_display(_class_Guide *_comp ) { #define reflect (_comp->_parameters.reflect) #define w1 (_comp->_parameters.w1) #define h1 (_comp->_parameters.h1) #define w2 (_comp->_parameters.w2) #define h2 (_comp->_parameters.h2) #define l (_comp->_parameters.l) #define R0 (_comp->_parameters.R0) #define Qc (_comp->_parameters.Qc) #define alpha (_comp->_parameters.alpha) #define m (_comp->_parameters.m) #define W (_comp->_parameters.W) #define pTable (_comp->_parameters.pTable) #define table_present (_comp->_parameters.table_present) SIG_MESSAGE("[_guideStraight_display] component guideStraight=Guide() DISPLAY [Guide:0]"); printf("MCDISPLAY: component %s\n", _comp->_name); /* V3, independent "polygons": */ // TOP polygon (4, -w1 / 2.0, h1 / 2.0, 0.0, w1 / 2.0, h1 / 2.0, 0.0, w2 / 2.0, h2 / 2.0, (double)l, -w2 / 2.0, h2 / 2.0, (double)l); // BOTTOM polygon (4, -w1 / 2.0, -h1 / 2.0, 0.0, w1 / 2.0, -h1 / 2.0, 0.0, w2 / 2.0, -h2 / 2.0, (double)l, -w2 / 2.0, -h2 / 2.0, (double)l); // RIGHT polygon (4, -w1 / 2.0, h1 / 2.0, 0.0, -w1 / 2.0, -h1 / 2.0, 0.0, -w2 / 2.0, -h2 / 2.0, (double)l, -w2 / 2.0, h2 / 2.0, (double)l); // LEFT polygon (4, w1 / 2.0, h1 / 2.0, 0.0, w1 / 2.0, -h1 / 2.0, 0.0, w2 / 2.0, -h2 / 2.0, (double)l, w2 / 2.0, h2 / 2.0, (double)l); /* V2, draw top, bottom, sides independently: */ // TOP /* multiline(5, */ /* -w1/2.0, h1/2.0, 0.0, */ /* w1/2.0, h1/2.0, 0.0, */ /* w2/2.0, h2/2.0, (double)l, */ /* -w2/2.0, h2/2.0, (double)l, */ /* -w1/2.0, h1/2.0, 0.0); */ /* // BOTTOM */ /* multiline(5, */ /* -w1/2.0, -h1/2.0, 0.0, */ /* w1/2.0, -h1/2.0, 0.0, */ /* w2/2.0, -h2/2.0, (double)l, */ /* -w2/2.0, -h2/2.0, (double)l, */ /* -w1/2.0, -h1/2.0, 0.0); */ /* // RIGHT */ /* multiline(5, */ /* -w1/2.0, h1/2.0, 0.0, */ /* -w1/2.0, -h1/2.0, 0.0, */ /* -w2/2.0, -h2/2.0, (double)l, */ /* -w2/2.0, h2/2.0, (double)l, */ /* -w1/2.0, h1/2.0, 0.0); */ /* // LEFT */ /* multiline(5, */ /* w1/2.0, h1/2.0, 0.0, */ /* w1/2.0, -h1/2.0, 0.0, */ /* w2/2.0, -h2/2.0, (double)l, */ /* w2/2.0, h2/2.0, (double)l, */ /* w1/2.0, h1/2.0, 0.0); */ /* Original implementation: multiline(5, -w1/2.0, -h1/2.0, 0.0, w1/2.0, -h1/2.0, 0.0, w1/2.0, h1/2.0, 0.0, -w1/2.0, h1/2.0, 0.0, -w1/2.0, -h1/2.0, 0.0); multiline(5, -w2/2.0, -h2/2.0, (double)l, w2/2.0, -h2/2.0, (double)l, w2/2.0, h2/2.0, (double)l, -w2/2.0, h2/2.0, (double)l, -w2/2.0, -h2/2.0, (double)l); line(-w1/2.0, -h1/2.0, 0, -w2/2.0, -h2/2.0, (double)l); line( w1/2.0, -h1/2.0, 0, w2/2.0, -h2/2.0, (double)l); line( w1/2.0, h1/2.0, 0, w2/2.0, h2/2.0, (double)l); line(-w1/2.0, h1/2.0, 0, -w2/2.0, h2/2.0, (double)l); */ #undef reflect #undef w1 #undef h1 #undef w2 #undef h2 #undef l #undef R0 #undef Qc #undef alpha #undef m #undef W #undef pTable #undef table_present return(_comp); } /* class_Guide_display */ _class_PSD_monitor *class_PSD_monitor_display(_class_PSD_monitor *_comp ) { #define nx (_comp->_parameters.nx) #define ny (_comp->_parameters.ny) #define filename (_comp->_parameters.filename) #define xmin (_comp->_parameters.xmin) #define xmax (_comp->_parameters.xmax) #define ymin (_comp->_parameters.ymin) #define ymax (_comp->_parameters.ymax) #define xwidth (_comp->_parameters.xwidth) #define yheight (_comp->_parameters.yheight) #define restore_neutron (_comp->_parameters.restore_neutron) #define nowritefile (_comp->_parameters.nowritefile) #define PSD_N (_comp->_parameters.PSD_N) #define PSD_p (_comp->_parameters.PSD_p) #define PSD_p2 (_comp->_parameters.PSD_p2) SIG_MESSAGE("[_psd_guide_end_display] component psd_guide_end=PSD_monitor() DISPLAY [PSD_monitor:0]"); printf("MCDISPLAY: component %s\n", _comp->_name); multiline (5, (double)xmin, (double)ymin, 0.0, (double)xmax, (double)ymin, 0.0, (double)xmax, (double)ymax, 0.0, (double)xmin, (double)ymax, 0.0, (double)xmin, (double)ymin, 0.0); #undef nx #undef ny #undef filename #undef xmin #undef xmax #undef ymin #undef ymax #undef xwidth #undef yheight #undef restore_neutron #undef nowritefile #undef PSD_N #undef PSD_p #undef PSD_p2 return(_comp); } /* class_PSD_monitor_display */ _class_E_monitor *class_E_monitor_display(_class_E_monitor *_comp ) { #define nE (_comp->_parameters.nE) #define filename (_comp->_parameters.filename) #define xmin (_comp->_parameters.xmin) #define xmax (_comp->_parameters.xmax) #define ymin (_comp->_parameters.ymin) #define ymax (_comp->_parameters.ymax) #define nowritefile (_comp->_parameters.nowritefile) #define xwidth (_comp->_parameters.xwidth) #define yheight (_comp->_parameters.yheight) #define Emin (_comp->_parameters.Emin) #define Emax (_comp->_parameters.Emax) #define restore_neutron (_comp->_parameters.restore_neutron) #define E_N (_comp->_parameters.E_N) #define E_p (_comp->_parameters.E_p) #define E_p2 (_comp->_parameters.E_p2) #define S_p (_comp->_parameters.S_p) #define S_pE (_comp->_parameters.S_pE) #define S_pE2 (_comp->_parameters.S_pE2) SIG_MESSAGE("[_emon_guide_end_display] component emon_guide_end=E_monitor() DISPLAY [E_monitor:0]"); printf("MCDISPLAY: component %s\n", _comp->_name); multiline (5, (double)xmin, (double)ymin, 0.0, (double)xmax, (double)ymin, 0.0, (double)xmax, (double)ymax, 0.0, (double)xmin, (double)ymax, 0.0, (double)xmin, (double)ymin, 0.0); #undef nE #undef filename #undef xmin #undef xmax #undef ymin #undef ymax #undef nowritefile #undef xwidth #undef yheight #undef Emin #undef Emax #undef restore_neutron #undef E_N #undef E_p #undef E_p2 #undef S_p #undef S_pE #undef S_pE2 return(_comp); } /* class_E_monitor_display */ _class_Divergence_monitor *class_Divergence_monitor_display(_class_Divergence_monitor *_comp ) { #define nh (_comp->_parameters.nh) #define nv (_comp->_parameters.nv) #define filename (_comp->_parameters.filename) #define xmin (_comp->_parameters.xmin) #define xmax (_comp->_parameters.xmax) #define ymin (_comp->_parameters.ymin) #define ymax (_comp->_parameters.ymax) #define nowritefile (_comp->_parameters.nowritefile) #define xwidth (_comp->_parameters.xwidth) #define yheight (_comp->_parameters.yheight) #define maxdiv_h (_comp->_parameters.maxdiv_h) #define maxdiv_v (_comp->_parameters.maxdiv_v) #define restore_neutron (_comp->_parameters.restore_neutron) #define nx (_comp->_parameters.nx) #define ny (_comp->_parameters.ny) #define nz (_comp->_parameters.nz) #define Div_N (_comp->_parameters.Div_N) #define Div_p (_comp->_parameters.Div_p) #define Div_p2 (_comp->_parameters.Div_p2) SIG_MESSAGE("[_divmon_guide_end_display] component divmon_guide_end=Divergence_monitor() DISPLAY [Divergence_monitor:0]"); printf("MCDISPLAY: component %s\n", _comp->_name); multiline (5, (double)xmin, (double)ymin, 0.0, (double)xmax, (double)ymin, 0.0, (double)xmax, (double)ymax, 0.0, (double)xmin, (double)ymax, 0.0, (double)xmin, (double)ymin, 0.0); #undef nh #undef nv #undef filename #undef xmin #undef xmax #undef ymin #undef ymax #undef nowritefile #undef xwidth #undef yheight #undef maxdiv_h #undef maxdiv_v #undef restore_neutron #undef nx #undef ny #undef nz #undef Div_N #undef Div_p #undef Div_p2 return(_comp); } /* class_Divergence_monitor_display */ _class_Arm *class_Arm_display(_class_Arm *_comp ) { SIG_MESSAGE("[_focus_mono_display] component focus_mono=Arm() DISPLAY [Arm:0]"); printf("MCDISPLAY: component %s\n", _comp->_name); /* A bit ugly; hard-coded dimensions. */ line (0, 0, 0, 0.2, 0, 0); line (0, 0, 0, 0, 0.2, 0); line (0, 0, 0, 0, 0, 0.2); cone (0.2, 0, 0, 0.01, 0.02, 1, 0, 0); cone (0, 0.2, 0, 0.01, 0.02, 0, 1, 0); cone (0, 0, 0.2, 0.01, 0.02, 0, 0, 1); return(_comp); } /* class_Arm_display */ _class_Monochromator_curved *class_Monochromator_curved_display(_class_Monochromator_curved *_comp ) { #define reflect (_comp->_parameters.reflect) #define transmit (_comp->_parameters.transmit) #define zwidth (_comp->_parameters.zwidth) #define yheight (_comp->_parameters.yheight) #define gap (_comp->_parameters.gap) #define NH (_comp->_parameters.NH) #define NV (_comp->_parameters.NV) #define mosaich (_comp->_parameters.mosaich) #define mosaicv (_comp->_parameters.mosaicv) #define r0 (_comp->_parameters.r0) #define t0 (_comp->_parameters.t0) #define Q (_comp->_parameters.Q) #define RV (_comp->_parameters.RV) #define RH (_comp->_parameters.RH) #define DM (_comp->_parameters.DM) #define mosaic (_comp->_parameters.mosaic) #define width (_comp->_parameters.width) #define height (_comp->_parameters.height) #define verbose (_comp->_parameters.verbose) #define order (_comp->_parameters.order) #define mos_rms_y (_comp->_parameters.mos_rms_y) #define mos_rms_z (_comp->_parameters.mos_rms_z) #define mos_rms_max (_comp->_parameters.mos_rms_max) #define mono_Q (_comp->_parameters.mono_Q) #define SlabWidth (_comp->_parameters.SlabWidth) #define SlabHeight (_comp->_parameters.SlabHeight) #define rTable (_comp->_parameters.rTable) #define tTable (_comp->_parameters.tTable) #define rTableFlag (_comp->_parameters.rTableFlag) #define tTableFlag (_comp->_parameters.tTableFlag) #define tiltH (_comp->_parameters.tiltH) #define tiltV (_comp->_parameters.tiltV) #define ncol_var (_comp->_parameters.ncol_var) #define nrow_var (_comp->_parameters.nrow_var) SIG_MESSAGE("[_monochromator_curved_display] component monochromator_curved=Monochromator_curved() DISPLAY [Monochromator_curved:0]"); printf("MCDISPLAY: component %s\n", _comp->_name); int ih; for (ih = 0; ih < NH; ih++) { int iv; for (iv = 0; iv < NV; iv++) { double zmin, zmax, ymin, ymax; double xt, yt; zmin = (SlabWidth + gap) * (ih - NH / 2.0) + gap / 2; zmax = zmin + SlabWidth; ymin = (SlabHeight + gap) * (iv - NV / 2.0) + gap / 2; ymax = ymin + SlabHeight; if (RH) xt = -(zmax * zmax - zmin * zmin) / RH / 2; else xt = 0; if (RV) yt = -(ymax * ymax - ymin * ymin) / RV / 2; else yt = 0; multiline (5, xt + yt, (double)ymin, (double)zmin, xt - yt, (double)ymax, (double)zmin, -xt - yt, (double)ymax, (double)zmax, -xt + yt, (double)ymin, (double)zmax, xt + yt, (double)ymin, (double)zmin); } } #undef reflect #undef transmit #undef zwidth #undef yheight #undef gap #undef NH #undef NV #undef mosaich #undef mosaicv #undef r0 #undef t0 #undef Q #undef RV #undef RH #undef DM #undef mosaic #undef width #undef height #undef verbose #undef order #undef mos_rms_y #undef mos_rms_z #undef mos_rms_max #undef mono_Q #undef SlabWidth #undef SlabHeight #undef rTable #undef tTable #undef rTableFlag #undef tTableFlag #undef tiltH #undef tiltV #undef ncol_var #undef nrow_var return(_comp); } /* class_Monochromator_curved_display */ _class_Collimator_linear *class_Collimator_linear_display(_class_Collimator_linear *_comp ) { #define xmin (_comp->_parameters.xmin) #define xmax (_comp->_parameters.xmax) #define ymin (_comp->_parameters.ymin) #define ymax (_comp->_parameters.ymax) #define xwidth (_comp->_parameters.xwidth) #define yheight (_comp->_parameters.yheight) #define length (_comp->_parameters.length) #define divergence (_comp->_parameters.divergence) #define transmission (_comp->_parameters.transmission) #define divergenceV (_comp->_parameters.divergenceV) #define slope (_comp->_parameters.slope) #define slopeV (_comp->_parameters.slopeV) SIG_MESSAGE("[_MSCollimator_display] component MSCollimator=Collimator_linear() DISPLAY [Collimator_linear:0]"); printf("MCDISPLAY: component %s\n", _comp->_name); double x; int i; for (x = xmin, i = 0; i <= 3; i++, x += (xmax - xmin) / 3.0) multiline (5, x, (double)ymin, 0.0, x, (double)ymax, 0.0, x, (double)ymax, (double)length, x, (double)ymin, (double)length, x, (double)ymin, 0.0); line (xmin, ymin, 0, xmax, ymin, 0); line (xmin, ymax, 0, xmax, ymax, 0); line (xmin, ymin, length, xmax, ymin, length); line (xmin, ymax, length, xmax, ymax, length); #undef xmin #undef xmax #undef ymin #undef ymax #undef xwidth #undef yheight #undef length #undef divergence #undef transmission #undef divergenceV #undef slope #undef slopeV return(_comp); } /* class_Collimator_linear_display */ _class_Filter_gen *class_Filter_gen_display(_class_Filter_gen *_comp ) { #define filename (_comp->_parameters.filename) #define options (_comp->_parameters.options) #define xmin (_comp->_parameters.xmin) #define xmax (_comp->_parameters.xmax) #define ymin (_comp->_parameters.ymin) #define ymax (_comp->_parameters.ymax) #define xwidth (_comp->_parameters.xwidth) #define yheight (_comp->_parameters.yheight) #define thickness (_comp->_parameters.thickness) #define scaling (_comp->_parameters.scaling) #define verbose (_comp->_parameters.verbose) #define Mode_Table (_comp->_parameters.Mode_Table) #define Type_Table (_comp->_parameters.Type_Table) #define pTable (_comp->_parameters.pTable) SIG_MESSAGE("[_infilter_display] component infilter=Filter_gen() DISPLAY [Filter_gen:0]"); printf("MCDISPLAY: component %s\n", _comp->_name); multiline (5, (double)xmin, (double)ymin, 0.0, (double)xmax, (double)ymin, 0.0, (double)xmax, (double)ymax, 0.0, (double)xmin, (double)ymax, 0.0, (double)xmin, (double)ymin, 0.0); #undef filename #undef options #undef xmin #undef xmax #undef ymin #undef ymax #undef xwidth #undef yheight #undef thickness #undef scaling #undef verbose #undef Mode_Table #undef Type_Table #undef pTable return(_comp); } /* class_Filter_gen_display */ _class_Monitor_nD *class_Monitor_nD_display(_class_Monitor_nD *_comp ) { #define user0 (_comp->_parameters.user0) #define user1 (_comp->_parameters.user1) #define user2 (_comp->_parameters.user2) #define user3 (_comp->_parameters.user3) #define user4 (_comp->_parameters.user4) #define user5 (_comp->_parameters.user5) #define user6 (_comp->_parameters.user6) #define user7 (_comp->_parameters.user7) #define user8 (_comp->_parameters.user8) #define user9 (_comp->_parameters.user9) #define xwidth (_comp->_parameters.xwidth) #define yheight (_comp->_parameters.yheight) #define zdepth (_comp->_parameters.zdepth) #define xmin (_comp->_parameters.xmin) #define xmax (_comp->_parameters.xmax) #define ymin (_comp->_parameters.ymin) #define ymax (_comp->_parameters.ymax) #define zmin (_comp->_parameters.zmin) #define zmax (_comp->_parameters.zmax) #define bins (_comp->_parameters.bins) #define min (_comp->_parameters.min) #define max (_comp->_parameters.max) #define restore_neutron (_comp->_parameters.restore_neutron) #define radius (_comp->_parameters.radius) #define options (_comp->_parameters.options) #define filename (_comp->_parameters.filename) #define geometry (_comp->_parameters.geometry) #define nowritefile (_comp->_parameters.nowritefile) #define nexus_bins (_comp->_parameters.nexus_bins) #define username0 (_comp->_parameters.username0) #define username1 (_comp->_parameters.username1) #define username2 (_comp->_parameters.username2) #define username3 (_comp->_parameters.username3) #define username4 (_comp->_parameters.username4) #define username5 (_comp->_parameters.username5) #define username6 (_comp->_parameters.username6) #define username7 (_comp->_parameters.username7) #define username8 (_comp->_parameters.username8) #define username9 (_comp->_parameters.username9) #define DEFS (_comp->_parameters.DEFS) #define Vars (_comp->_parameters.Vars) #define detector (_comp->_parameters.detector) #define offdata (_comp->_parameters.offdata) SIG_MESSAGE("[_OrderMon_display] component OrderMon=Monitor_nD() DISPLAY [Monitor_nD:0]"); printf("MCDISPLAY: component %s\n", _comp->_name); if (geometry && strlen (geometry) && strcmp (geometry, "0") && strcmp (geometry, "NULL")) { off_display (offdata); } else { Monitor_nD_McDisplay (&DEFS, &Vars); } #undef user0 #undef user1 #undef user2 #undef user3 #undef user4 #undef user5 #undef user6 #undef user7 #undef user8 #undef user9 #undef xwidth #undef yheight #undef zdepth #undef xmin #undef xmax #undef ymin #undef ymax #undef zmin #undef zmax #undef bins #undef min #undef max #undef restore_neutron #undef radius #undef options #undef filename #undef geometry #undef nowritefile #undef nexus_bins #undef username0 #undef username1 #undef username2 #undef username3 #undef username4 #undef username5 #undef username6 #undef username7 #undef username8 #undef username9 #undef DEFS #undef Vars #undef detector #undef offdata return(_comp); } /* class_Monitor_nD_display */ _class_PSD_monitor_psf_eff *class_PSD_monitor_psf_eff_display(_class_PSD_monitor_psf_eff *_comp ) { #define nx (_comp->_parameters.nx) #define ny (_comp->_parameters.ny) #define filename (_comp->_parameters.filename) #define xmin (_comp->_parameters.xmin) #define xmax (_comp->_parameters.xmax) #define ymin (_comp->_parameters.ymin) #define ymax (_comp->_parameters.ymax) #define nowritefile (_comp->_parameters.nowritefile) #define xwidth (_comp->_parameters.xwidth) #define yheight (_comp->_parameters.yheight) #define psf (_comp->_parameters.psf) #define k0 (_comp->_parameters.k0) #define eff (_comp->_parameters.eff) #define restore_neutron (_comp->_parameters.restore_neutron) #define PSD_N (_comp->_parameters.PSD_N) #define PSD_p (_comp->_parameters.PSD_p) #define PSD_p2 (_comp->_parameters.PSD_p2) #define weight (_comp->_parameters.weight) SIG_MESSAGE("[_kMoni_display] component kMoni=PSD_monitor_psf_eff() DISPLAY [PSD_monitor_psf_eff:0]"); printf("MCDISPLAY: component %s\n", _comp->_name); multiline (5, (double)xmin, (double)ymin, 0.0, (double)xmax, (double)ymin, 0.0, (double)xmax, (double)ymax, 0.0, (double)xmin, (double)ymax, 0.0, (double)xmin, (double)ymin, 0.0); #undef nx #undef ny #undef filename #undef xmin #undef xmax #undef ymin #undef ymax #undef nowritefile #undef xwidth #undef yheight #undef psf #undef k0 #undef eff #undef restore_neutron #undef PSD_N #undef PSD_p #undef PSD_p2 #undef weight return(_comp); } /* class_PSD_monitor_psf_eff_display */ _class_Incoherent *class_Incoherent_display(_class_Incoherent *_comp ) { #define geometry (_comp->_parameters.geometry) #define radius (_comp->_parameters.radius) #define xwidth (_comp->_parameters.xwidth) #define yheight (_comp->_parameters.yheight) #define zdepth (_comp->_parameters.zdepth) #define thickness (_comp->_parameters.thickness) #define target_x (_comp->_parameters.target_x) #define target_y (_comp->_parameters.target_y) #define target_z (_comp->_parameters.target_z) #define focus_r (_comp->_parameters.focus_r) #define focus_xw (_comp->_parameters.focus_xw) #define focus_yh (_comp->_parameters.focus_yh) #define focus_aw (_comp->_parameters.focus_aw) #define focus_ah (_comp->_parameters.focus_ah) #define target_index (_comp->_parameters.target_index) #define pack (_comp->_parameters.pack) #define p_interact (_comp->_parameters.p_interact) #define f_QE (_comp->_parameters.f_QE) #define gamma (_comp->_parameters.gamma) #define Etrans (_comp->_parameters.Etrans) #define deltaE (_comp->_parameters.deltaE) #define sigma_abs (_comp->_parameters.sigma_abs) #define sigma_inc (_comp->_parameters.sigma_inc) #define Vc (_comp->_parameters.Vc) #define concentric (_comp->_parameters.concentric) #define order (_comp->_parameters.order) #define VarsInc (_comp->_parameters.VarsInc) #define offdata (_comp->_parameters.offdata) SIG_MESSAGE("[_Perspex_display] component Perspex=Incoherent() DISPLAY [Incoherent:0]"); printf("MCDISPLAY: component %s\n", _comp->_name); if (geometry && strlen (geometry) && strcmp (geometry, "NULL") && strcmp (geometry, "0")) { /* OFF file */ off_display (offdata); } else if (radius > 0 && yheight) { /* cylinder along y*/ cylinder (0, 0, 0, radius, yheight, thickness, 0, 1, 0); } else if (xwidth && yheight) { /* box/rectangle */ box (0, 0, 0, xwidth, yheight, zdepth, thickness, 0, 1, 0); } else if (radius > 0 && !yheight) { /* sphere */ sphere (0, 0, 0, radius); } #undef geometry #undef radius #undef xwidth #undef yheight #undef zdepth #undef thickness #undef target_x #undef target_y #undef target_z #undef focus_r #undef focus_xw #undef focus_yh #undef focus_aw #undef focus_ah #undef target_index #undef pack #undef p_interact #undef f_QE #undef gamma #undef Etrans #undef deltaE #undef sigma_abs #undef sigma_inc #undef Vc #undef concentric #undef order #undef VarsInc #undef offdata return(_comp); } /* class_Incoherent_display */ _class_PowderN *class_PowderN_display(_class_PowderN *_comp ) { #define reflections (_comp->_parameters.reflections) #define geometry (_comp->_parameters.geometry) #define format (_comp->_parameters.format) #define radius (_comp->_parameters.radius) #define yheight (_comp->_parameters.yheight) #define xwidth (_comp->_parameters.xwidth) #define zdepth (_comp->_parameters.zdepth) #define thickness (_comp->_parameters.thickness) #define pack (_comp->_parameters.pack) #define Vc (_comp->_parameters.Vc) #define sigma_abs (_comp->_parameters.sigma_abs) #define sigma_inc (_comp->_parameters.sigma_inc) #define delta_d_d (_comp->_parameters.delta_d_d) #define p_inc (_comp->_parameters.p_inc) #define p_transmit (_comp->_parameters.p_transmit) #define DW (_comp->_parameters.DW) #define nb_atoms (_comp->_parameters.nb_atoms) #define d_omega (_comp->_parameters.d_omega) #define d_phi (_comp->_parameters.d_phi) #define tth_sign (_comp->_parameters.tth_sign) #define p_interact (_comp->_parameters.p_interact) #define concentric (_comp->_parameters.concentric) #define density (_comp->_parameters.density) #define weight (_comp->_parameters.weight) #define barns (_comp->_parameters.barns) #define Strain (_comp->_parameters.Strain) #define focus_flip (_comp->_parameters.focus_flip) #define target_index (_comp->_parameters.target_index) #define order (_comp->_parameters.order) #define line_info (_comp->_parameters.line_info) #define columns (_comp->_parameters.columns) #define offdata (_comp->_parameters.offdata) #define tgt_x (_comp->_parameters.tgt_x) #define tgt_y (_comp->_parameters.tgt_y) #define tgt_z (_comp->_parameters.tgt_z) SIG_MESSAGE("[_powderSample_display] component powderSample=PowderN() DISPLAY [PowderN:0]"); printf("MCDISPLAY: component %s\n", _comp->_name); if (line_info.V_0) { if (line_info.shape == 0) { /* cyl */ circle ("xz", 0, yheight / 2.0, 0, radius); circle ("xz", 0, -yheight / 2.0, 0, radius); line (-radius, -yheight / 2.0, 0, -radius, +yheight / 2.0, 0); line (+radius, -yheight / 2.0, 0, +radius, +yheight / 2.0, 0); line (0, -yheight / 2.0, -radius, 0, +yheight / 2.0, -radius); line (0, -yheight / 2.0, +radius, 0, +yheight / 2.0, +radius); if (thickness) { double radius_i = radius - thickness; circle ("xz", 0, yheight / 2.0, 0, radius_i); circle ("xz", 0, -yheight / 2.0, 0, radius_i); line (-radius_i, -yheight / 2.0, 0, -radius_i, +yheight / 2.0, 0); line (+radius_i, -yheight / 2.0, 0, +radius_i, +yheight / 2.0, 0); line (0, -yheight / 2.0, -radius_i, 0, +yheight / 2.0, -radius_i); line (0, -yheight / 2.0, +radius_i, 0, +yheight / 2.0, +radius_i); } } else if (line_info.shape == 1) { /* box */ double xmin = -0.5 * xwidth; double xmax = 0.5 * xwidth; double ymin = -0.5 * yheight; double ymax = 0.5 * yheight; double zmin = -0.5 * zdepth; double zmax = 0.5 * zdepth; multiline (5, xmin, ymin, zmin, xmax, ymin, zmin, xmax, ymax, zmin, xmin, ymax, zmin, xmin, ymin, zmin); multiline (5, xmin, ymin, zmax, xmax, ymin, zmax, xmax, ymax, zmax, xmin, ymax, zmax, xmin, ymin, zmax); line (xmin, ymin, zmin, xmin, ymin, zmax); line (xmax, ymin, zmin, xmax, ymin, zmax); line (xmin, ymax, zmin, xmin, ymax, zmax); line (xmax, ymax, zmin, xmax, ymax, zmax); if (line_info.zdepth_i) { xmin = -0.5 * line_info.xwidth_i; xmax = 0.5 * line_info.xwidth_i; ymin = -0.5 * line_info.yheight_i; ymax = 0.5 * line_info.yheight_i; zmin = -0.5 * line_info.zdepth_i; zmax = 0.5 * line_info.zdepth_i; multiline (5, xmin, ymin, zmin, xmax, ymin, zmin, xmax, ymax, zmin, xmin, ymax, zmin, xmin, ymin, zmin); multiline (5, xmin, ymin, zmax, xmax, ymin, zmax, xmax, ymax, zmax, xmin, ymax, zmax, xmin, ymin, zmax); line (xmin, ymin, zmin, xmin, ymin, zmax); line (xmax, ymin, zmin, xmax, ymin, zmax); line (xmin, ymax, zmin, xmin, ymax, zmax); line (xmax, ymax, zmin, xmax, ymax, zmax); } } if (line_info.shape == 2) { /* sphere */ if (line_info.radius_i) { circle ("xy", 0, 0, 0, line_info.radius_i); circle ("xz", 0, 0, 0, line_info.radius_i); circle ("yz", 0, 0, 0, line_info.radius_i); } circle ("xy", 0, 0, 0, radius); circle ("xz", 0, 0, 0, radius); circle ("yz", 0, 0, 0, radius); } else if (line_info.shape == 3) { /* OFF file */ off_display (offdata); } } #undef reflections #undef geometry #undef format #undef radius #undef yheight #undef xwidth #undef zdepth #undef thickness #undef pack #undef Vc #undef sigma_abs #undef sigma_inc #undef delta_d_d #undef p_inc #undef p_transmit #undef DW #undef nb_atoms #undef d_omega #undef d_phi #undef tth_sign #undef p_interact #undef concentric #undef density #undef weight #undef barns #undef Strain #undef focus_flip #undef target_index #undef order #undef line_info #undef columns #undef offdata #undef tgt_x #undef tgt_y #undef tgt_z return(_comp); } /* class_PowderN_display */ _class_Single_crystal *class_Single_crystal_display(_class_Single_crystal *_comp ) { #define reflections (_comp->_parameters.reflections) #define geometry (_comp->_parameters.geometry) #define mosaic_AB (_comp->_parameters.mosaic_AB) #define xwidth (_comp->_parameters.xwidth) #define yheight (_comp->_parameters.yheight) #define zdepth (_comp->_parameters.zdepth) #define radius (_comp->_parameters.radius) #define delta_d_d (_comp->_parameters.delta_d_d) #define mosaic (_comp->_parameters.mosaic) #define mosaic_a (_comp->_parameters.mosaic_a) #define mosaic_b (_comp->_parameters.mosaic_b) #define mosaic_c (_comp->_parameters.mosaic_c) #define recip_cell (_comp->_parameters.recip_cell) #define barns (_comp->_parameters.barns) #define ax (_comp->_parameters.ax) #define ay (_comp->_parameters.ay) #define az (_comp->_parameters.az) #define bx (_comp->_parameters.bx) #define by (_comp->_parameters.by) #define bz (_comp->_parameters.bz) #define cx (_comp->_parameters.cx) #define cy (_comp->_parameters.cy) #define cz (_comp->_parameters.cz) #define p_transmit (_comp->_parameters.p_transmit) #define sigma_abs (_comp->_parameters.sigma_abs) #define sigma_inc (_comp->_parameters.sigma_inc) #define aa (_comp->_parameters.aa) #define bb (_comp->_parameters.bb) #define cc (_comp->_parameters.cc) #define order (_comp->_parameters.order) #define extra_order (_comp->_parameters.extra_order) #define RX (_comp->_parameters.RX) #define RY (_comp->_parameters.RY) #define powder (_comp->_parameters.powder) #define PG (_comp->_parameters.PG) #define deltak (_comp->_parameters.deltak) #define hkl_info (_comp->_parameters.hkl_info) #define offdata (_comp->_parameters.offdata) #define hkl_list (_comp->_parameters.hkl_list) #define tau_list (_comp->_parameters.tau_list) SIG_MESSAGE("[_crystalSample_display] component crystalSample=Single_crystal() DISPLAY [Single_crystal:0]"); printf("MCDISPLAY: component %s\n", _comp->_name); if (hkl_info.shape == 0) { /* cylinder */ circle ("xz", 0, yheight / 2.0, 0, radius); circle ("xz", 0, -yheight / 2.0, 0, radius); line (-radius, -yheight / 2.0, 0, -radius, +yheight / 2.0, 0); line (+radius, -yheight / 2.0, 0, +radius, +yheight / 2.0, 0); line (0, -yheight / 2.0, -radius, 0, +yheight / 2.0, -radius); line (0, -yheight / 2.0, +radius, 0, +yheight / 2.0, +radius); } else if (hkl_info.shape == 1) { /* box */ double xmin = -0.5 * xwidth; double xmax = 0.5 * xwidth; double ymin = -0.5 * yheight; double ymax = 0.5 * yheight; double zmin = -0.5 * zdepth; double zmax = 0.5 * zdepth; multiline (5, xmin, ymin, zmin, xmax, ymin, zmin, xmax, ymax, zmin, xmin, ymax, zmin, xmin, ymin, zmin); multiline (5, xmin, ymin, zmax, xmax, ymin, zmax, xmax, ymax, zmax, xmin, ymax, zmax, xmin, ymin, zmax); line (xmin, ymin, zmin, xmin, ymin, zmax); line (xmax, ymin, zmin, xmax, ymin, zmax); line (xmin, ymax, zmin, xmin, ymax, zmax); line (xmax, ymax, zmin, xmax, ymax, zmax); } else if (hkl_info.shape == 2) { /* sphere */ circle ("xy", 0, 0.0, 0, radius); circle ("xz", 0, 0.0, 0, radius); circle ("yz", 0, 0.0, 0, radius); } else if (hkl_info.shape == 3) { /* OFF file */ off_display (offdata); } #undef reflections #undef geometry #undef mosaic_AB #undef xwidth #undef yheight #undef zdepth #undef radius #undef delta_d_d #undef mosaic #undef mosaic_a #undef mosaic_b #undef mosaic_c #undef recip_cell #undef barns #undef ax #undef ay #undef az #undef bx #undef by #undef bz #undef cx #undef cy #undef cz #undef p_transmit #undef sigma_abs #undef sigma_inc #undef aa #undef bb #undef cc #undef order #undef extra_order #undef RX #undef RY #undef powder #undef PG #undef deltak #undef hkl_info #undef offdata #undef hkl_list #undef tau_list return(_comp); } /* class_Single_crystal_display */ _class_Phonon_simple *class_Phonon_simple_display(_class_Phonon_simple *_comp ) { #define radius (_comp->_parameters.radius) #define yheight (_comp->_parameters.yheight) #define sigma_abs (_comp->_parameters.sigma_abs) #define sigma_inc (_comp->_parameters.sigma_inc) #define a (_comp->_parameters.a) #define b (_comp->_parameters.b) #define M (_comp->_parameters.M) #define c (_comp->_parameters.c) #define DW (_comp->_parameters.DW) #define T (_comp->_parameters.T) #define target_x (_comp->_parameters.target_x) #define target_y (_comp->_parameters.target_y) #define target_z (_comp->_parameters.target_z) #define target_index (_comp->_parameters.target_index) #define focus_r (_comp->_parameters.focus_r) #define focus_xw (_comp->_parameters.focus_xw) #define focus_yh (_comp->_parameters.focus_yh) #define focus_aw (_comp->_parameters.focus_aw) #define focus_ah (_comp->_parameters.focus_ah) #define gap (_comp->_parameters.gap) #define e_steps_low (_comp->_parameters.e_steps_low) #define e_steps_high (_comp->_parameters.e_steps_high) #define V_rho (_comp->_parameters.V_rho) #define V_my_s (_comp->_parameters.V_my_s) #define V_my_a_v (_comp->_parameters.V_my_a_v) #define DV (_comp->_parameters.DV) #define phonon (_comp->_parameters.phonon) SIG_MESSAGE("[_phononSample_display] component phononSample=Phonon_simple() DISPLAY [Phonon_simple:0]"); printf("MCDISPLAY: component %s\n", _comp->_name); circle ("xz", 0, yheight / 2.0, 0, radius); circle ("xz", 0, -yheight / 2.0, 0, radius); line (-radius, -yheight / 2.0, 0, -radius, +yheight / 2.0, 0); line (+radius, -yheight / 2.0, 0, +radius, +yheight / 2.0, 0); line (0, -yheight / 2.0, -radius, 0, +yheight / 2.0, -radius); line (0, -yheight / 2.0, +radius, 0, +yheight / 2.0, +radius); #undef radius #undef yheight #undef sigma_abs #undef sigma_inc #undef a #undef b #undef M #undef c #undef DW #undef T #undef target_x #undef target_y #undef target_z #undef target_index #undef focus_r #undef focus_xw #undef focus_yh #undef focus_aw #undef focus_ah #undef gap #undef e_steps_low #undef e_steps_high #undef V_rho #undef V_my_s #undef V_my_a_v #undef DV #undef phonon return(_comp); } /* class_Phonon_simple_display */ _class_PSD_monitor_4PI *class_PSD_monitor_4PI_display(_class_PSD_monitor_4PI *_comp ) { #define nx (_comp->_parameters.nx) #define ny (_comp->_parameters.ny) #define filename (_comp->_parameters.filename) #define nowritefile (_comp->_parameters.nowritefile) #define radius (_comp->_parameters.radius) #define restore_neutron (_comp->_parameters.restore_neutron) #define PSD_N (_comp->_parameters.PSD_N) #define PSD_p (_comp->_parameters.PSD_p) #define PSD_p2 (_comp->_parameters.PSD_p2) SIG_MESSAGE("[_psd_4pi_display] component psd_4pi=PSD_monitor_4PI() DISPLAY [PSD_monitor_4PI:0]"); printf("MCDISPLAY: component %s\n", _comp->_name); circle ("xy", 0, 0, 0, radius); circle ("xz", 0, 0, 0, radius); circle ("yz", 0, 0, 0, radius); #undef nx #undef ny #undef filename #undef nowritefile #undef radius #undef restore_neutron #undef PSD_N #undef PSD_p #undef PSD_p2 return(_comp); } /* class_PSD_monitor_4PI_display */ _class_Exact_radial_coll *class_Exact_radial_coll_display(_class_Exact_radial_coll *_comp ) { #define theta_min (_comp->_parameters.theta_min) #define theta_max (_comp->_parameters.theta_max) #define nslit (_comp->_parameters.nslit) #define radius (_comp->_parameters.radius) #define length (_comp->_parameters.length) #define h_in (_comp->_parameters.h_in) #define h_out (_comp->_parameters.h_out) #define d (_comp->_parameters.d) #define verbose (_comp->_parameters.verbose) #define alpha_in (_comp->_parameters.alpha_in) #define alpha_out (_comp->_parameters.alpha_out) #define beta_in (_comp->_parameters.beta_in) #define beta_out (_comp->_parameters.beta_out) #define theta (_comp->_parameters.theta) #define out_radius (_comp->_parameters.out_radius) #define iw (_comp->_parameters.iw) #define ow (_comp->_parameters.ow) #define divergence (_comp->_parameters.divergence) SIG_MESSAGE("[_filter_coll_display] component filter_coll=Exact_radial_coll() DISPLAY [Exact_radial_coll:0]"); printf("MCDISPLAY: component %s\n", _comp->_name); int i; double theta1, theta2, theta3, theta4; double x_in_l, z_in_l, x_in_r, z_in_r; double x_out_l, z_out_l, x_out_r, z_out_r; double window_theta, y1, y2; window_theta = alpha_in + beta_in; y1 = h_in / 2; y2 = h_out / 2; theta1 = theta_min; theta3 = theta1 + beta_in / 2; theta4 = theta1 + beta_out / 2; z_in_l = radius * cos (theta1); x_in_l = radius * sin (theta1); z_in_r = radius * cos (theta3); x_in_r = radius * sin (theta3); z_out_l = out_radius * cos (theta1); x_out_l = out_radius * sin (theta1); z_out_r = out_radius * cos (theta4); x_out_r = out_radius * sin (theta4); multiline (5, x_in_l, -y1, z_in_l, x_in_l, y1, z_in_l, x_out_l, y2, z_out_l, x_out_l, -y2, z_out_l, x_in_l, -y1, z_in_l); line (x_in_l, y1, z_in_l, x_in_r, y1, z_in_r); line (x_in_l, -y1, z_in_l, x_in_r, -y1, z_in_r); line (x_out_l, y2, z_out_l, x_out_r, y2, z_out_r); line (x_out_l, -y2, z_out_l, x_out_r, -y2, z_out_r); multiline (5, x_in_r, -y1, z_in_r, x_in_r, y1, z_in_r, x_out_r, y2, z_out_r, x_out_r, -y2, z_out_r, x_in_r, -y1, z_in_r); for (i = 1; i < nslit; i++) { theta1 = i * window_theta + theta_min - beta_in / 2; theta2 = i * window_theta + theta_min + beta_in / 2; theta3 = i * window_theta + theta_min - beta_out / 2; theta4 = i * window_theta + theta_min + beta_out / 2; z_in_l = radius * cos (theta1); x_in_l = radius * sin (theta1); z_in_r = radius * cos (theta2); x_in_r = radius * sin (theta2); z_out_l = out_radius * cos (theta3); x_out_l = out_radius * sin (theta3); z_out_r = out_radius * cos (theta4); x_out_r = out_radius * sin (theta4); /* left side */ multiline (5, x_in_l, -y1, z_in_l, x_in_l, y1, z_in_l, x_out_l, y2, z_out_l, x_out_l, -y2, z_out_l, x_in_l, -y1, z_in_l); /* left -> right lines */ line (x_in_l, y1, z_in_l, x_in_r, y1, z_in_r); line (x_in_l, -y1, z_in_l, x_in_r, -y1, z_in_r); line (x_out_l, y2, z_out_l, x_out_r, y2, z_out_r); line (x_out_l, -y2, z_out_l, x_out_r, -y2, z_out_r); /* right side */ multiline (5, x_in_r, -y1, z_in_r, x_in_r, y1, z_in_r, x_out_r, y2, z_out_r, x_out_r, -y2, z_out_r, x_in_r, -y1, z_in_r); } /* remaining bits */ theta1 = theta_max; theta3 = theta1 - beta_in / 2; theta4 = theta1 - beta_out / 2; z_in_l = radius * cos (theta1); x_in_l = radius * sin (theta1); z_in_r = radius * cos (theta3); x_in_r = radius * sin (theta3); z_out_l = out_radius * cos (theta1); x_out_l = out_radius * sin (theta1); z_out_r = out_radius * cos (theta4); x_out_r = out_radius * sin (theta4); multiline (5, x_in_l, -y1, z_in_l, x_in_l, y1, z_in_l, x_out_l, y2, z_out_l, x_out_l, -y2, z_out_l, x_in_l, -y1, z_in_l); line (x_in_l, y1, z_in_l, x_in_r, y1, z_in_r); line (x_in_l, -y1, z_in_l, x_in_r, -y1, z_in_r); line (x_out_l, y2, z_out_l, x_out_r, y2, z_out_r); line (x_out_l, -y2, z_out_l, x_out_r, -y2, z_out_r); multiline (5, x_in_r, -y1, z_in_r, x_in_r, y1, z_in_r, x_out_r, y2, z_out_r, x_out_r, -y2, z_out_r, x_in_r, -y1, z_in_r); #undef theta_min #undef theta_max #undef nslit #undef radius #undef length #undef h_in #undef h_out #undef d #undef verbose #undef alpha_in #undef alpha_out #undef beta_in #undef beta_out #undef theta #undef out_radius #undef iw #undef ow #undef divergence return(_comp); } /* class_Exact_radial_coll_display */ _class_Monochromator_flat *class_Monochromator_flat_display(_class_Monochromator_flat *_comp ) { #define zmin (_comp->_parameters.zmin) #define zmax (_comp->_parameters.zmax) #define ymin (_comp->_parameters.ymin) #define ymax (_comp->_parameters.ymax) #define zwidth (_comp->_parameters.zwidth) #define yheight (_comp->_parameters.yheight) #define mosaich (_comp->_parameters.mosaich) #define mosaicv (_comp->_parameters.mosaicv) #define r0 (_comp->_parameters.r0) #define Q (_comp->_parameters.Q) #define DM (_comp->_parameters.DM) #define mos_rms_y (_comp->_parameters.mos_rms_y) #define mos_rms_z (_comp->_parameters.mos_rms_z) #define mos_rms_max (_comp->_parameters.mos_rms_max) #define mono_Q (_comp->_parameters.mono_Q) SIG_MESSAGE("[_an1l_display] component an1l=Monochromator_flat() DISPLAY [Monochromator_flat:0]"); printf("MCDISPLAY: component %s\n", _comp->_name); multiline (5, 0.0, (double)ymin, (double)zmin, 0.0, (double)ymax, (double)zmin, 0.0, (double)ymax, (double)zmax, 0.0, (double)ymin, (double)zmax, 0.0, (double)ymin, (double)zmin); #undef zmin #undef zmax #undef ymin #undef ymax #undef zwidth #undef yheight #undef mosaich #undef mosaicv #undef r0 #undef Q #undef DM #undef mos_rms_y #undef mos_rms_z #undef mos_rms_max #undef mono_Q return(_comp); } /* class_Monochromator_flat_display */ _class_Absorber *class_Absorber_display(_class_Absorber *_comp ) { #define xmin (_comp->_parameters.xmin) #define xmax (_comp->_parameters.xmax) #define ymin (_comp->_parameters.ymin) #define ymax (_comp->_parameters.ymax) #define zmin (_comp->_parameters.zmin) #define zmax (_comp->_parameters.zmax) #define xw (_comp->_parameters.xw) #define yh (_comp->_parameters.yh) #define zt (_comp->_parameters.zt) #define xm (_comp->_parameters.xm) #define ym (_comp->_parameters.ym) #define zm (_comp->_parameters.zm) SIG_MESSAGE("[_BladeR1_display] component BladeR1=Absorber() DISPLAY [Absorber:0]"); printf("MCDISPLAY: component %s\n", _comp->_name); box (xm, ym, zm, xw, yh, zt, 0, 0, 1, 0); #undef xmin #undef xmax #undef ymin #undef ymax #undef zmin #undef zmax #undef xw #undef yh #undef zt #undef xm #undef ym #undef zm return(_comp); } /* class_Absorber_display */ #undef magnify #undef line #undef dashed_line #undef multiline #undef rectangle #undef box #undef circle #undef cylinder #undef sphere int display(void) { /* called by mccode_main for RITA_II:DISPLAY */ printf("MCDISPLAY: start\n"); /* call iteratively all components DISPLAY */ class_Progress_bar_display(&_armSource_var); class_Source_gen4_display(&_source_var); class_Slit_display(&_slitGuideBegin_var); class_L_monitor_display(&_lmon_guide_start_var); class_Guide_display(&_guideStraight_var); class_Guide_display(&_guideCurved1_var); class_Guide_display(&_guideCurved2_var); class_Guide_display(&_guideCurved3_var); class_Guide_display(&_guideCurved4_var); class_Guide_display(&_guideCurved5_var); class_Guide_display(&_guideCurved6_var); class_Guide_display(&_guideCurved7_var); class_Guide_display(&_guideCurved8_var); class_Guide_display(&_guideCurved9_var); class_Guide_display(&_guideCurved10_var); class_Guide_display(&_guideCurved11_var); class_Guide_display(&_guideCurved12_var); class_Guide_display(&_guideCurved13_var); class_Guide_display(&_guideCurved14_var); class_Guide_display(&_guideCurved15_var); class_Guide_display(&_guideCurved16_var); class_Guide_display(&_guideCurved17_var); class_Guide_display(&_guideCurved18_var); class_Guide_display(&_guideCurved19_var); class_Guide_display(&_guideCurved20_var); class_Guide_display(&_guideCurved21_var); class_Guide_display(&_guideCurved22_var); class_Guide_display(&_guideCurved23_var); class_Guide_display(&_guideCurved24_var); class_Guide_display(&_guideCurved25_var); class_Guide_display(&_guideCurved26_var); class_Guide_display(&_guideCurved27_var); class_Guide_display(&_guideCurved28_var); class_Guide_display(&_guideCurved29_var); class_Guide_display(&_guideCurved30_var); class_Guide_display(&_guideCurved31_var); class_Guide_display(&_guideCurved32_var); class_Guide_display(&_guideCurved33_var); class_Guide_display(&_guideCurved34_var); class_Guide_display(&_guideCurved35_var); class_Guide_display(&_guideCurved36_var); class_Guide_display(&_guideCurved37_var); class_Guide_display(&_guideCurved38_var); class_Guide_display(&_guideCurved39_var); class_Guide_display(&_guideCurved40_var); class_Guide_display(&_bunker_var); class_Guide_display(&_guide3_var); class_Slit_display(&_slitGuideEnd_var); class_PSD_monitor_display(&_psd_guide_end_var); class_E_monitor_display(&_emon_guide_end_var); class_L_monitor_display(&_lmon_guide_end_var); class_Divergence_monitor_display(&_divmon_guide_end_var); class_Arm_display(&_focus_mono_var); class_Monochromator_curved_display(&_monochromator_curved_var); class_Arm_display(&_a2_var); class_Slit_display(&_slitShutter_var); class_Collimator_linear_display(&_MSCollimator_var); class_Filter_gen_display(&_infilter_var); class_PSD_monitor_display(&_psd_virt_var); class_L_monitor_display(&_lmon_virt_var); class_Arm_display(&_aa2_var); class_Monitor_nD_display(&_OrderMon_var); class_PSD_monitor_psf_eff_display(&_kMoni_var); class_PSD_monitor_psf_eff_display(&_kMoni1st_var); class_PSD_monitor_psf_eff_display(&_kMoni2nd_var); class_PSD_monitor_psf_eff_display(&_kMoni3rd_var); class_Slit_display(&_slitMonochromator_var); class_Incoherent_display(&_Perspex_var); class_PSD_monitor_display(&_psd_samplepos_1cm2_var); class_E_monitor_display(&_emon_samplepos_1cm2_var); class_Divergence_monitor_display(&_divmon_samplepos_1cm2_var); class_PSD_monitor_display(&_psd_samplepos_large_var); class_Arm_display(&_a3_var); class_Arm_display(&_aa3_var); class_Incoherent_display(&_incohSample_var); class_PowderN_display(&_powderSample_var); class_Single_crystal_display(&_crystalSample_var); class_Phonon_simple_display(&_phononSample_var); class_PSD_monitor_4PI_display(&_psd_4pi_var); class_Arm_display(&_a4_var); class_Slit_display(&_slitSample_var); class_Exact_radial_coll_display(&_filter_coll_var); class_Filter_gen_display(&_filter_var); class_Slit_display(&_ana_slit1_var); class_Slit_display(&_ana_slit2_var); class_E_monitor_display(&_emon_before_ana_var); class_PSD_monitor_display(&_psd_before_ana_var); class_Divergence_monitor_display(&_divmon_before_ana_var); class_Arm_display(&_focus_ana_var); class_Monochromator_flat_display(&_an1l_var); class_Monochromator_flat_display(&_an1u_var); class_Monochromator_flat_display(&_an2l_var); class_Monochromator_flat_display(&_an2u_var); class_Monochromator_flat_display(&_an3l_var); class_Monochromator_flat_display(&_an3u_var); class_Monochromator_flat_display(&_an4l_var); class_Monochromator_flat_display(&_an4u_var); class_Monochromator_flat_display(&_an5l_var); class_Monochromator_flat_display(&_an5u_var); class_Monochromator_flat_display(&_an6l_var); class_Monochromator_flat_display(&_an6u_var); class_Monochromator_flat_display(&_an7l_var); class_Monochromator_flat_display(&_an7u_var); class_Monochromator_flat_display(&_an8l_var); class_Monochromator_flat_display(&_an8u_var); class_Monochromator_flat_display(&_an9l_var); class_Monochromator_flat_display(&_an9u_var); class_Arm_display(&_a6_var); class_E_monitor_display(&_emon_before_coarse_var); class_PSD_monitor_display(&_psd_before_coarse_var); class_Arm_display(&_ArmR1_var); class_Absorber_display(&_BladeR1_var); class_Arm_display(&_ArmR2_var); class_Absorber_display(&_BladeR2_var); class_Arm_display(&_ArmR3_var); class_Absorber_display(&_BladeR3_var); class_Arm_display(&_ArmR4_var); class_Absorber_display(&_BladeR4_var); class_Arm_display(&_ArmR5_var); class_Absorber_display(&_BladeR5_var); class_Arm_display(&_ArmL1_var); class_Absorber_display(&_BladeL1_var); class_Arm_display(&_ArmL2_var); class_Absorber_display(&_BladeL2_var); class_Arm_display(&_ArmL3_var); class_Absorber_display(&_BladeL3_var); class_Arm_display(&_ArmL4_var); class_Absorber_display(&_BladeL4_var); class_Arm_display(&_ArmL5_var); class_Absorber_display(&_BladeL5_var); class_PSD_monitor_psf_eff_display(&_psd_detector_var); class_E_monitor_display(&_emon_detector_var); class_PSD_monitor_psf_eff_display(&_psd_window1_var); class_E_monitor_display(&_emon_window1_var); class_PSD_monitor_psf_eff_display(&_psd_window2_var); class_E_monitor_display(&_emon_window2_var); class_PSD_monitor_psf_eff_display(&_psd_window3_var); class_E_monitor_display(&_emon_window3_var); class_PSD_monitor_psf_eff_display(&_psd_window4_var); class_E_monitor_display(&_emon_window4_var); class_PSD_monitor_psf_eff_display(&_psd_window5_var); class_E_monitor_display(&_emon_window5_var); class_PSD_monitor_psf_eff_display(&_psd_window6_var); class_E_monitor_display(&_emon_window6_var); class_PSD_monitor_psf_eff_display(&_psd_window7_var); class_E_monitor_display(&_emon_window7_var); class_PSD_monitor_psf_eff_display(&_psd_window8_var); class_E_monitor_display(&_emon_window8_var); class_PSD_monitor_psf_eff_display(&_psd_window9_var); class_E_monitor_display(&_emon_window9_var); printf("MCDISPLAY: end\n"); return(0); } /* display */ void* _getvar_parameters(char* compname) /* enables settings parameters based use of the GETPAR macro */ { #ifdef OPENACC #define strcmp(a,b) str_comp(a,b) #endif if (!strcmp(compname, "armSource")) return (void *) &(_armSource_var._parameters); if (!strcmp(compname, "source")) return (void *) &(_source_var._parameters); if (!strcmp(compname, "slitGuideBegin")) return (void *) &(_slitGuideBegin_var._parameters); if (!strcmp(compname, "lmon_guide_start")) return (void *) &(_lmon_guide_start_var._parameters); if (!strcmp(compname, "guideStraight")) return (void *) &(_guideStraight_var._parameters); if (!strcmp(compname, "guideCurved1")) return (void *) &(_guideCurved1_var._parameters); if (!strcmp(compname, "guideCurved2")) return (void *) &(_guideCurved2_var._parameters); if (!strcmp(compname, "guideCurved3")) return (void *) &(_guideCurved3_var._parameters); if (!strcmp(compname, "guideCurved4")) return (void *) &(_guideCurved4_var._parameters); if (!strcmp(compname, "guideCurved5")) return (void *) &(_guideCurved5_var._parameters); if (!strcmp(compname, "guideCurved6")) return (void *) &(_guideCurved6_var._parameters); if (!strcmp(compname, "guideCurved7")) return (void *) &(_guideCurved7_var._parameters); if (!strcmp(compname, "guideCurved8")) return (void *) &(_guideCurved8_var._parameters); if (!strcmp(compname, "guideCurved9")) return (void *) &(_guideCurved9_var._parameters); if (!strcmp(compname, "guideCurved10")) return (void *) &(_guideCurved10_var._parameters); if (!strcmp(compname, "guideCurved11")) return (void *) &(_guideCurved11_var._parameters); if (!strcmp(compname, "guideCurved12")) return (void *) &(_guideCurved12_var._parameters); if (!strcmp(compname, "guideCurved13")) return (void *) &(_guideCurved13_var._parameters); if (!strcmp(compname, "guideCurved14")) return (void *) &(_guideCurved14_var._parameters); if (!strcmp(compname, "guideCurved15")) return (void *) &(_guideCurved15_var._parameters); if (!strcmp(compname, "guideCurved16")) return (void *) &(_guideCurved16_var._parameters); if (!strcmp(compname, "guideCurved17")) return (void *) &(_guideCurved17_var._parameters); if (!strcmp(compname, "guideCurved18")) return (void *) &(_guideCurved18_var._parameters); if (!strcmp(compname, "guideCurved19")) return (void *) &(_guideCurved19_var._parameters); if (!strcmp(compname, "guideCurved20")) return (void *) &(_guideCurved20_var._parameters); if (!strcmp(compname, "guideCurved21")) return (void *) &(_guideCurved21_var._parameters); if (!strcmp(compname, "guideCurved22")) return (void *) &(_guideCurved22_var._parameters); if (!strcmp(compname, "guideCurved23")) return (void *) &(_guideCurved23_var._parameters); if (!strcmp(compname, "guideCurved24")) return (void *) &(_guideCurved24_var._parameters); if (!strcmp(compname, "guideCurved25")) return (void *) &(_guideCurved25_var._parameters); if (!strcmp(compname, "guideCurved26")) return (void *) &(_guideCurved26_var._parameters); if (!strcmp(compname, "guideCurved27")) return (void *) &(_guideCurved27_var._parameters); if (!strcmp(compname, "guideCurved28")) return (void *) &(_guideCurved28_var._parameters); if (!strcmp(compname, "guideCurved29")) return (void *) &(_guideCurved29_var._parameters); if (!strcmp(compname, "guideCurved30")) return (void *) &(_guideCurved30_var._parameters); if (!strcmp(compname, "guideCurved31")) return (void *) &(_guideCurved31_var._parameters); if (!strcmp(compname, "guideCurved32")) return (void *) &(_guideCurved32_var._parameters); if (!strcmp(compname, "guideCurved33")) return (void *) &(_guideCurved33_var._parameters); if (!strcmp(compname, "guideCurved34")) return (void *) &(_guideCurved34_var._parameters); if (!strcmp(compname, "guideCurved35")) return (void *) &(_guideCurved35_var._parameters); if (!strcmp(compname, "guideCurved36")) return (void *) &(_guideCurved36_var._parameters); if (!strcmp(compname, "guideCurved37")) return (void *) &(_guideCurved37_var._parameters); if (!strcmp(compname, "guideCurved38")) return (void *) &(_guideCurved38_var._parameters); if (!strcmp(compname, "guideCurved39")) return (void *) &(_guideCurved39_var._parameters); if (!strcmp(compname, "guideCurved40")) return (void *) &(_guideCurved40_var._parameters); if (!strcmp(compname, "bunker")) return (void *) &(_bunker_var._parameters); if (!strcmp(compname, "guide3")) return (void *) &(_guide3_var._parameters); if (!strcmp(compname, "slitGuideEnd")) return (void *) &(_slitGuideEnd_var._parameters); if (!strcmp(compname, "psd_guide_end")) return (void *) &(_psd_guide_end_var._parameters); if (!strcmp(compname, "emon_guide_end")) return (void *) &(_emon_guide_end_var._parameters); if (!strcmp(compname, "lmon_guide_end")) return (void *) &(_lmon_guide_end_var._parameters); if (!strcmp(compname, "divmon_guide_end")) return (void *) &(_divmon_guide_end_var._parameters); if (!strcmp(compname, "focus_mono")) return (void *) &(_focus_mono_var._parameters); if (!strcmp(compname, "monochromator_curved")) return (void *) &(_monochromator_curved_var._parameters); if (!strcmp(compname, "a2")) return (void *) &(_a2_var._parameters); if (!strcmp(compname, "slitShutter")) return (void *) &(_slitShutter_var._parameters); if (!strcmp(compname, "MSCollimator")) return (void *) &(_MSCollimator_var._parameters); if (!strcmp(compname, "infilter")) return (void *) &(_infilter_var._parameters); if (!strcmp(compname, "psd_virt")) return (void *) &(_psd_virt_var._parameters); if (!strcmp(compname, "lmon_virt")) return (void *) &(_lmon_virt_var._parameters); if (!strcmp(compname, "aa2")) return (void *) &(_aa2_var._parameters); if (!strcmp(compname, "OrderMon")) return (void *) &(_OrderMon_var._parameters); if (!strcmp(compname, "kMoni")) return (void *) &(_kMoni_var._parameters); if (!strcmp(compname, "kMoni1st")) return (void *) &(_kMoni1st_var._parameters); if (!strcmp(compname, "kMoni2nd")) return (void *) &(_kMoni2nd_var._parameters); if (!strcmp(compname, "kMoni3rd")) return (void *) &(_kMoni3rd_var._parameters); if (!strcmp(compname, "slitMonochromator")) return (void *) &(_slitMonochromator_var._parameters); if (!strcmp(compname, "Perspex")) return (void *) &(_Perspex_var._parameters); if (!strcmp(compname, "psd_samplepos_1cm2")) return (void *) &(_psd_samplepos_1cm2_var._parameters); if (!strcmp(compname, "emon_samplepos_1cm2")) return (void *) &(_emon_samplepos_1cm2_var._parameters); if (!strcmp(compname, "divmon_samplepos_1cm2")) return (void *) &(_divmon_samplepos_1cm2_var._parameters); if (!strcmp(compname, "psd_samplepos_large")) return (void *) &(_psd_samplepos_large_var._parameters); if (!strcmp(compname, "a3")) return (void *) &(_a3_var._parameters); if (!strcmp(compname, "aa3")) return (void *) &(_aa3_var._parameters); if (!strcmp(compname, "incohSample")) return (void *) &(_incohSample_var._parameters); if (!strcmp(compname, "powderSample")) return (void *) &(_powderSample_var._parameters); if (!strcmp(compname, "crystalSample")) return (void *) &(_crystalSample_var._parameters); if (!strcmp(compname, "phononSample")) return (void *) &(_phononSample_var._parameters); if (!strcmp(compname, "psd_4pi")) return (void *) &(_psd_4pi_var._parameters); if (!strcmp(compname, "a4")) return (void *) &(_a4_var._parameters); if (!strcmp(compname, "slitSample")) return (void *) &(_slitSample_var._parameters); if (!strcmp(compname, "filter_coll")) return (void *) &(_filter_coll_var._parameters); if (!strcmp(compname, "filter")) return (void *) &(_filter_var._parameters); if (!strcmp(compname, "ana_slit1")) return (void *) &(_ana_slit1_var._parameters); if (!strcmp(compname, "ana_slit2")) return (void *) &(_ana_slit2_var._parameters); if (!strcmp(compname, "emon_before_ana")) return (void *) &(_emon_before_ana_var._parameters); if (!strcmp(compname, "psd_before_ana")) return (void *) &(_psd_before_ana_var._parameters); if (!strcmp(compname, "divmon_before_ana")) return (void *) &(_divmon_before_ana_var._parameters); if (!strcmp(compname, "focus_ana")) return (void *) &(_focus_ana_var._parameters); if (!strcmp(compname, "an1l")) return (void *) &(_an1l_var._parameters); if (!strcmp(compname, "an1u")) return (void *) &(_an1u_var._parameters); if (!strcmp(compname, "an2l")) return (void *) &(_an2l_var._parameters); if (!strcmp(compname, "an2u")) return (void *) &(_an2u_var._parameters); if (!strcmp(compname, "an3l")) return (void *) &(_an3l_var._parameters); if (!strcmp(compname, "an3u")) return (void *) &(_an3u_var._parameters); if (!strcmp(compname, "an4l")) return (void *) &(_an4l_var._parameters); if (!strcmp(compname, "an4u")) return (void *) &(_an4u_var._parameters); if (!strcmp(compname, "an5l")) return (void *) &(_an5l_var._parameters); if (!strcmp(compname, "an5u")) return (void *) &(_an5u_var._parameters); if (!strcmp(compname, "an6l")) return (void *) &(_an6l_var._parameters); if (!strcmp(compname, "an6u")) return (void *) &(_an6u_var._parameters); if (!strcmp(compname, "an7l")) return (void *) &(_an7l_var._parameters); if (!strcmp(compname, "an7u")) return (void *) &(_an7u_var._parameters); if (!strcmp(compname, "an8l")) return (void *) &(_an8l_var._parameters); if (!strcmp(compname, "an8u")) return (void *) &(_an8u_var._parameters); if (!strcmp(compname, "an9l")) return (void *) &(_an9l_var._parameters); if (!strcmp(compname, "an9u")) return (void *) &(_an9u_var._parameters); if (!strcmp(compname, "a6")) return (void *) &(_a6_var._parameters); if (!strcmp(compname, "emon_before_coarse")) return (void *) &(_emon_before_coarse_var._parameters); if (!strcmp(compname, "psd_before_coarse")) return (void *) &(_psd_before_coarse_var._parameters); if (!strcmp(compname, "ArmR1")) return (void *) &(_ArmR1_var._parameters); if (!strcmp(compname, "BladeR1")) return (void *) &(_BladeR1_var._parameters); if (!strcmp(compname, "ArmR2")) return (void *) &(_ArmR2_var._parameters); if (!strcmp(compname, "BladeR2")) return (void *) &(_BladeR2_var._parameters); if (!strcmp(compname, "ArmR3")) return (void *) &(_ArmR3_var._parameters); if (!strcmp(compname, "BladeR3")) return (void *) &(_BladeR3_var._parameters); if (!strcmp(compname, "ArmR4")) return (void *) &(_ArmR4_var._parameters); if (!strcmp(compname, "BladeR4")) return (void *) &(_BladeR4_var._parameters); if (!strcmp(compname, "ArmR5")) return (void *) &(_ArmR5_var._parameters); if (!strcmp(compname, "BladeR5")) return (void *) &(_BladeR5_var._parameters); if (!strcmp(compname, "ArmL1")) return (void *) &(_ArmL1_var._parameters); if (!strcmp(compname, "BladeL1")) return (void *) &(_BladeL1_var._parameters); if (!strcmp(compname, "ArmL2")) return (void *) &(_ArmL2_var._parameters); if (!strcmp(compname, "BladeL2")) return (void *) &(_BladeL2_var._parameters); if (!strcmp(compname, "ArmL3")) return (void *) &(_ArmL3_var._parameters); if (!strcmp(compname, "BladeL3")) return (void *) &(_BladeL3_var._parameters); if (!strcmp(compname, "ArmL4")) return (void *) &(_ArmL4_var._parameters); if (!strcmp(compname, "BladeL4")) return (void *) &(_BladeL4_var._parameters); if (!strcmp(compname, "ArmL5")) return (void *) &(_ArmL5_var._parameters); if (!strcmp(compname, "BladeL5")) return (void *) &(_BladeL5_var._parameters); if (!strcmp(compname, "psd_detector")) return (void *) &(_psd_detector_var._parameters); if (!strcmp(compname, "emon_detector")) return (void *) &(_emon_detector_var._parameters); if (!strcmp(compname, "psd_window1")) return (void *) &(_psd_window1_var._parameters); if (!strcmp(compname, "emon_window1")) return (void *) &(_emon_window1_var._parameters); if (!strcmp(compname, "psd_window2")) return (void *) &(_psd_window2_var._parameters); if (!strcmp(compname, "emon_window2")) return (void *) &(_emon_window2_var._parameters); if (!strcmp(compname, "psd_window3")) return (void *) &(_psd_window3_var._parameters); if (!strcmp(compname, "emon_window3")) return (void *) &(_emon_window3_var._parameters); if (!strcmp(compname, "psd_window4")) return (void *) &(_psd_window4_var._parameters); if (!strcmp(compname, "emon_window4")) return (void *) &(_emon_window4_var._parameters); if (!strcmp(compname, "psd_window5")) return (void *) &(_psd_window5_var._parameters); if (!strcmp(compname, "emon_window5")) return (void *) &(_emon_window5_var._parameters); if (!strcmp(compname, "psd_window6")) return (void *) &(_psd_window6_var._parameters); if (!strcmp(compname, "emon_window6")) return (void *) &(_emon_window6_var._parameters); if (!strcmp(compname, "psd_window7")) return (void *) &(_psd_window7_var._parameters); if (!strcmp(compname, "emon_window7")) return (void *) &(_emon_window7_var._parameters); if (!strcmp(compname, "psd_window8")) return (void *) &(_psd_window8_var._parameters); if (!strcmp(compname, "emon_window8")) return (void *) &(_emon_window8_var._parameters); if (!strcmp(compname, "psd_window9")) return (void *) &(_psd_window9_var._parameters); if (!strcmp(compname, "emon_window9")) return (void *) &(_emon_window9_var._parameters); return 0; } void* _get_particle_var(char *token, _class_particle *p) /* enables setpars based use of GET_PARTICLE_DVAR macro and similar */ { if (!strcmp(token, "Mono_order")) return (void *) &(p->Mono_order); if (!strcmp(token, "AnaBlade")) return (void *) &(p->AnaBlade); if (!strcmp(token, "BinX")) return (void *) &(p->BinX); if (!strcmp(token, "BinY")) return (void *) &(p->BinY); if (!strcmp(token, "ncol_54")) return (void *) &(p->ncol_54); if (!strcmp(token, "nrow_54")) return (void *) &(p->nrow_54); return 0; } int _getcomp_index(char* compname) /* Enables retrieving the component position & rotation when the index is not known. * Component indexing into MACROS, e.g., POS_A_COMP_INDEX, are 1-based! */ { if (!strcmp(compname, "armSource")) return 1; if (!strcmp(compname, "source")) return 2; if (!strcmp(compname, "slitGuideBegin")) return 3; if (!strcmp(compname, "lmon_guide_start")) return 4; if (!strcmp(compname, "guideStraight")) return 5; if (!strcmp(compname, "guideCurved1")) return 6; if (!strcmp(compname, "guideCurved2")) return 7; if (!strcmp(compname, "guideCurved3")) return 8; if (!strcmp(compname, "guideCurved4")) return 9; if (!strcmp(compname, "guideCurved5")) return 10; if (!strcmp(compname, "guideCurved6")) return 11; if (!strcmp(compname, "guideCurved7")) return 12; if (!strcmp(compname, "guideCurved8")) return 13; if (!strcmp(compname, "guideCurved9")) return 14; if (!strcmp(compname, "guideCurved10")) return 15; if (!strcmp(compname, "guideCurved11")) return 16; if (!strcmp(compname, "guideCurved12")) return 17; if (!strcmp(compname, "guideCurved13")) return 18; if (!strcmp(compname, "guideCurved14")) return 19; if (!strcmp(compname, "guideCurved15")) return 20; if (!strcmp(compname, "guideCurved16")) return 21; if (!strcmp(compname, "guideCurved17")) return 22; if (!strcmp(compname, "guideCurved18")) return 23; if (!strcmp(compname, "guideCurved19")) return 24; if (!strcmp(compname, "guideCurved20")) return 25; if (!strcmp(compname, "guideCurved21")) return 26; if (!strcmp(compname, "guideCurved22")) return 27; if (!strcmp(compname, "guideCurved23")) return 28; if (!strcmp(compname, "guideCurved24")) return 29; if (!strcmp(compname, "guideCurved25")) return 30; if (!strcmp(compname, "guideCurved26")) return 31; if (!strcmp(compname, "guideCurved27")) return 32; if (!strcmp(compname, "guideCurved28")) return 33; if (!strcmp(compname, "guideCurved29")) return 34; if (!strcmp(compname, "guideCurved30")) return 35; if (!strcmp(compname, "guideCurved31")) return 36; if (!strcmp(compname, "guideCurved32")) return 37; if (!strcmp(compname, "guideCurved33")) return 38; if (!strcmp(compname, "guideCurved34")) return 39; if (!strcmp(compname, "guideCurved35")) return 40; if (!strcmp(compname, "guideCurved36")) return 41; if (!strcmp(compname, "guideCurved37")) return 42; if (!strcmp(compname, "guideCurved38")) return 43; if (!strcmp(compname, "guideCurved39")) return 44; if (!strcmp(compname, "guideCurved40")) return 45; if (!strcmp(compname, "bunker")) return 46; if (!strcmp(compname, "guide3")) return 47; if (!strcmp(compname, "slitGuideEnd")) return 48; if (!strcmp(compname, "psd_guide_end")) return 49; if (!strcmp(compname, "emon_guide_end")) return 50; if (!strcmp(compname, "lmon_guide_end")) return 51; if (!strcmp(compname, "divmon_guide_end")) return 52; if (!strcmp(compname, "focus_mono")) return 53; if (!strcmp(compname, "monochromator_curved")) return 54; if (!strcmp(compname, "a2")) return 55; if (!strcmp(compname, "slitShutter")) return 56; if (!strcmp(compname, "MSCollimator")) return 57; if (!strcmp(compname, "infilter")) return 58; if (!strcmp(compname, "psd_virt")) return 59; if (!strcmp(compname, "lmon_virt")) return 60; if (!strcmp(compname, "aa2")) return 61; if (!strcmp(compname, "OrderMon")) return 62; if (!strcmp(compname, "kMoni")) return 63; if (!strcmp(compname, "kMoni1st")) return 64; if (!strcmp(compname, "kMoni2nd")) return 65; if (!strcmp(compname, "kMoni3rd")) return 66; if (!strcmp(compname, "slitMonochromator")) return 67; if (!strcmp(compname, "Perspex")) return 68; if (!strcmp(compname, "psd_samplepos_1cm2")) return 69; if (!strcmp(compname, "emon_samplepos_1cm2")) return 70; if (!strcmp(compname, "divmon_samplepos_1cm2")) return 71; if (!strcmp(compname, "psd_samplepos_large")) return 72; if (!strcmp(compname, "a3")) return 73; if (!strcmp(compname, "aa3")) return 74; if (!strcmp(compname, "incohSample")) return 75; if (!strcmp(compname, "powderSample")) return 76; if (!strcmp(compname, "crystalSample")) return 77; if (!strcmp(compname, "phononSample")) return 78; if (!strcmp(compname, "psd_4pi")) return 79; if (!strcmp(compname, "a4")) return 80; if (!strcmp(compname, "slitSample")) return 81; if (!strcmp(compname, "filter_coll")) return 82; if (!strcmp(compname, "filter")) return 83; if (!strcmp(compname, "ana_slit1")) return 84; if (!strcmp(compname, "ana_slit2")) return 85; if (!strcmp(compname, "emon_before_ana")) return 86; if (!strcmp(compname, "psd_before_ana")) return 87; if (!strcmp(compname, "divmon_before_ana")) return 88; if (!strcmp(compname, "focus_ana")) return 89; if (!strcmp(compname, "an1l")) return 90; if (!strcmp(compname, "an1u")) return 91; if (!strcmp(compname, "an2l")) return 92; if (!strcmp(compname, "an2u")) return 93; if (!strcmp(compname, "an3l")) return 94; if (!strcmp(compname, "an3u")) return 95; if (!strcmp(compname, "an4l")) return 96; if (!strcmp(compname, "an4u")) return 97; if (!strcmp(compname, "an5l")) return 98; if (!strcmp(compname, "an5u")) return 99; if (!strcmp(compname, "an6l")) return 100; if (!strcmp(compname, "an6u")) return 101; if (!strcmp(compname, "an7l")) return 102; if (!strcmp(compname, "an7u")) return 103; if (!strcmp(compname, "an8l")) return 104; if (!strcmp(compname, "an8u")) return 105; if (!strcmp(compname, "an9l")) return 106; if (!strcmp(compname, "an9u")) return 107; if (!strcmp(compname, "a6")) return 108; if (!strcmp(compname, "emon_before_coarse")) return 109; if (!strcmp(compname, "psd_before_coarse")) return 110; if (!strcmp(compname, "ArmR1")) return 111; if (!strcmp(compname, "BladeR1")) return 112; if (!strcmp(compname, "ArmR2")) return 113; if (!strcmp(compname, "BladeR2")) return 114; if (!strcmp(compname, "ArmR3")) return 115; if (!strcmp(compname, "BladeR3")) return 116; if (!strcmp(compname, "ArmR4")) return 117; if (!strcmp(compname, "BladeR4")) return 118; if (!strcmp(compname, "ArmR5")) return 119; if (!strcmp(compname, "BladeR5")) return 120; if (!strcmp(compname, "ArmL1")) return 121; if (!strcmp(compname, "BladeL1")) return 122; if (!strcmp(compname, "ArmL2")) return 123; if (!strcmp(compname, "BladeL2")) return 124; if (!strcmp(compname, "ArmL3")) return 125; if (!strcmp(compname, "BladeL3")) return 126; if (!strcmp(compname, "ArmL4")) return 127; if (!strcmp(compname, "BladeL4")) return 128; if (!strcmp(compname, "ArmL5")) return 129; if (!strcmp(compname, "BladeL5")) return 130; if (!strcmp(compname, "psd_detector")) return 131; if (!strcmp(compname, "emon_detector")) return 132; if (!strcmp(compname, "psd_window1")) return 133; if (!strcmp(compname, "emon_window1")) return 134; if (!strcmp(compname, "psd_window2")) return 135; if (!strcmp(compname, "emon_window2")) return 136; if (!strcmp(compname, "psd_window3")) return 137; if (!strcmp(compname, "emon_window3")) return 138; if (!strcmp(compname, "psd_window4")) return 139; if (!strcmp(compname, "emon_window4")) return 140; if (!strcmp(compname, "psd_window5")) return 141; if (!strcmp(compname, "emon_window5")) return 142; if (!strcmp(compname, "psd_window6")) return 143; if (!strcmp(compname, "emon_window6")) return 144; if (!strcmp(compname, "psd_window7")) return 145; if (!strcmp(compname, "emon_window7")) return 146; if (!strcmp(compname, "psd_window8")) return 147; if (!strcmp(compname, "emon_window8")) return 148; if (!strcmp(compname, "psd_window9")) return 149; if (!strcmp(compname, "emon_window9")) return 150; return -1; } /* embedding file "metadata-r.c" */ /** --- Contents of metadata-r.c ---------------------------------------------------------------------------------- */ // Created by Gregory Tucker, Data Management Software Centre, European Spallation Source ERIC on 07/07/23. #ifndef MCCODE_NAME #include "metadata-r.h" #endif char * metadata_table_key_component(char* key){ if (strlen(key) == 0) return NULL; char sep[2] = ":\0"; // matches any number of repeated colons // look for the separator in the provided key; strtok is allowed to modify the string, so copy it char * tok = malloc((strlen(key) + 1) * sizeof(char)); if (!tok) { fprintf(stderr,"Error allocating token\n"); exit(-1); } strcpy(tok, key); char * pch = strtok(tok, sep); // this *is* the component name (if provided) -- but we need to move the pointer char * comp = malloc((1 + strlen(pch)) * sizeof(char)); if (!comp) { fprintf(stderr,"Error allocating comp\n"); exit(-1); } strcpy(comp, pch); if (tok) free(tok); return comp; } char * metadata_table_key_literal(char * key){ if (strlen(key) == 0) return NULL; char sep[3] = ":\0"; char * tok = malloc((strlen(key) + 1 ) * sizeof(char)); if (!tok) { fprintf(stderr,"Error allocating token\n"); exit(-1); } strcpy(tok, key); char * pch = strtok(tok, sep); // this *is* the component name (if provided) if (pch) pch = strtok(NULL, sep); // either NULL or the literal name char * name = NULL; if (pch) { name = malloc((1 + strlen(pch)) * sizeof(char)); if (!name) { fprintf(stderr,"Error allocating name\n"); exit(-1); } strcpy(name, pch); } if (tok) free(tok); return name; } int metadata_table_defined(int no, metadata_table_t * tab, char * key){ if (strlen(key) == 0){ /* This is 0 instead of `no` independent of any wildcard-matching logic * because a caller _already_ knows `no` and can verify * that `key` is not "" at call-time. So returning `no` is useless. */ return 0; } char * comp = metadata_table_key_component(key); char * name = metadata_table_key_literal(key); // look through the table for the matching component and literal names int number = 0; for (int i=0; i 1) { MPI_MASTER( printf("Simulation '%s' (%s): running on %i nodes (master is '%s', MPI version %i.%i).\n", instrument_name, instrument_source, mpi_node_count, mpi_node_name, MPI_VERSION, MPI_SUBVERSION); ); /* share the same seed, then adapt random seed for each node */ MPI_Bcast(&mcseed, 1, MPI_LONG, 0, MPI_COMM_WORLD); /* root sends its seed to slaves */ mcseed += mpi_node_rank; /* make sure we use different seeds per noe */ } #endif /* USE_MPI */ #ifdef OPENACC #ifdef USE_MPI int num_devices = acc_get_num_devices(acc_device_nvidia); if(num_devices>0){ int my_device = mpi_node_rank % num_devices; acc_set_device_num( my_device, acc_device_nvidia ); printf("Have found %d GPU devices on rank %d. Will use device %d.\n", num_devices, mpi_node_rank, my_device); }else{ printf("There was an issue probing acc_get_num_devices, fallback to host\n"); acc_set_device_type( acc_device_host ); } #endif #endif /* *** parse options ******************************************************* */ SIG_MESSAGE("[" __FILE__ "] main START"); mcformat = getenv(FLAVOR_UPPER "_FORMAT") ? getenv(FLAVOR_UPPER "_FORMAT") : FLAVOR_UPPER; instrument_exe = argv[0]; /* store the executable path */ /* read simulation parameters and options */ mcparseoptions(argc, argv); /* sets output dir and format */ #ifdef USE_MPI if (mpi_node_count > 1) { /* share the same seed, then adapt random seed for each node */ MPI_Bcast(&mcseed, 1, MPI_LONG, 0, MPI_COMM_WORLD); /* root sends its seed to slaves */ mcseed += mpi_node_rank; /* make sure we use different seeds per node */ } #endif /* *** install sig handler, but only once !! after parameters parsing ******* */ #ifndef NOSIGNALS #ifdef SIGQUIT if (signal( SIGQUIT ,sighandler) == SIG_IGN) signal( SIGQUIT,SIG_IGN); /* quit (ASCII FS) */ #endif #ifdef SIGABRT if (signal( SIGABRT ,sighandler) == SIG_IGN) signal( SIGABRT,SIG_IGN); /* used by abort, replace SIGIOT in the future */ #endif #ifdef SIGTERM if (signal( SIGTERM ,sighandler) == SIG_IGN) signal( SIGTERM,SIG_IGN); /* software termination signal from kill */ #endif #ifdef SIGUSR1 if (signal( SIGUSR1 ,sighandler) == SIG_IGN) signal( SIGUSR1,SIG_IGN); /* display simulation status */ #endif #ifdef SIGUSR2 if (signal( SIGUSR2 ,sighandler) == SIG_IGN) signal( SIGUSR2,SIG_IGN); #endif #ifdef SIGHUP if (signal( SIGHUP ,sighandler) == SIG_IGN) signal( SIGHUP,SIG_IGN); #endif #ifdef SIGILL if (signal( SIGILL ,sighandler) == SIG_IGN) signal( SIGILL,SIG_IGN); /* illegal instruction (not reset when caught) */ #endif #ifdef SIGFPE if (signal( SIGFPE ,sighandler) == SIG_IGN) signal( SIGSEGV,SIG_IGN); /* floating point exception */ #endif #ifdef SIGBUS if (signal( SIGBUS ,sighandler) == SIG_IGN) signal( SIGSEGV,SIG_IGN); /* bus error */ #endif #ifdef SIGSEGV if (signal( SIGSEGV ,sighandler) == SIG_IGN) signal( SIGSEGV,SIG_IGN); /* segmentation violation */ #endif #endif /* !NOSIGNALS */ // init executed by master/host siminfo_init(NULL); /* open SIM */ SIG_MESSAGE("[" __FILE__ "] main INITIALISE"); init(); #ifndef NOSIGNALS #ifdef SIGINT if (signal( SIGINT ,sighandler) == SIG_IGN) signal( SIGINT,SIG_IGN); /* interrupt (rubout) only after INIT */ #endif #endif /* !NOSIGNALS */ /* ================ main particle generation/propagation loop ================ */ #ifdef USE_MPI /* sliced Ncount on each MPI node */ mcncount = mpi_node_count > 1 ? floor(mcncount / mpi_node_count) : mcncount; /* number of rays per node */ #endif // MT specific init, note that per-ray init is empty #if RNG_ALG == 2 mt_srandom(mcseed); #endif // main raytrace work loop #ifndef FUNNEL // legacy version raytrace_all(mcncount, mcseed); #else MPI_MASTER( // "funneled" version in which propagation is more parallelizable printf("\nNOTE: CPU COMPONENT grammar activated:\n 1) \"FUNNEL\" raytrace algorithm enabled.\n 2) Any SPLIT's are dynamically allocated based on available buffer size. \n"); ); raytrace_all_funnel(mcncount, mcseed); #endif #ifdef USE_MPI /* merge run_num from MPI nodes */ if (mpi_node_count > 1) { double mcrun_num_double = (double)mcrun_num; mc_MPI_Sum(&mcrun_num_double, 1); mcrun_num = (unsigned long long)mcrun_num_double; } #endif // save/finally executed by master node/thread/host finally(); #ifdef USE_MPI MPI_Finalize(); #endif /* USE_MPI */ return 0; } /* mccode_main */ /* End of file "mccode_main.c". */ /* end of generated C code ./RITA-II.c */