File: Histogrammer.instr

package info (click to toggle)
mccode 3.5.19%2Bds5-2
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 1,113,256 kB
  • sloc: ansic: 40,697; python: 25,137; yacc: 8,438; sh: 5,405; javascript: 4,596; lex: 1,632; cpp: 742; perl: 296; lisp: 273; makefile: 226; fortran: 132
file content (128 lines) | stat: -rw-r--r-- 4,904 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
/*******************************************************************************
*         McStas instrument definition URL=http://www.mcstas.org
*
* Instrument: Histogrammer
*
* %Identification
* Written by: Peter Willendrup (peter.willendrup@risoe.dk)
* Date: 2007-03-19
* Origin: Risoe
* %INSTRUMENT_SITE: Tools
*
* Takes eventfile input (Virtual_input/Vitess/MCNP/Tripoli4/MCPL formats) and applies Monitor_nD to generate
* histograms. Histograms can be chosen freely using the options string, see mcdoc Monitor_nD.comp
*
*
* %Description
*
* Takes any possible  McStas eventfile inputs (Virtual_input/Vitess/MCNP/Tripoli4 formats) and applies
* Monitor_nD to generate user-selectable neutron histograms.
*
* The 'options' parameter allows to customize the type of histogram to generate.
* We suggest:
*   "sphere theta phi outgoing previous" (this is the default)
*   "previous, multiple, auto, x, y, z, vx, vy, vz, hdiv, vdiv, tof, lambda"
*   "previous, auto, x, y"
*   "previous, auto, tof, lambda"
*
* Example: mcrun Histogrammer.instr MODE=0
*   - Gives information on the input parameters
*
* Example: mcrun Histogrammer.instr filename="events.dat" MODE=1 options="sphere theta phi outgoing previous"
*   - Reads a Virtual_output generated event file and applies a spherical PSD
*
* %Parameters
* MODE: [int]         Input file mode/format - 0 for help on usage 1=McStas,2=Vitess,3=MCNP,4=Tripoli4,5=MCPL
* filename: [string]  Specifies input event file
* options: [string]   Specifies the histogramming rules used by Monitor_nD.
*                     It <b>MUST</b> contain the 'previous' word - see mcdoc Monitor_nD
* bufsize: [int]      Vitess_input 'buffersize' parameter - see mcdoc Vitess_input
* xwidth: [m]         Horizontal width of detector, or diameter for banana,cylinder and shpere geometry
* yheight: [m]        Vertical height of detector, for plate, cylinder, banana shape
*
* %BUGS
* The options string currently does not work with commas (mcrun interprets this as scan parms)
*
* %Link
* <a href="../sources/Virtual_input.html">Virtual_input</a> component (McStas event file)
* %Link
* <a href="../misc/Vitess_input.html">Vitess_input</a> component (Vitess event file)
* %Link
* <a href="../contrib/Virtual_mcnp_input.html">Virtual_mcnp_input</a> component (MCNP PTRAC event file)
* %Link
* <a href="../contrib/Virtual_tripoli4_input.html">Virtual_tripoli4_input</a> component (Tripoli4 BATCH event file)
* %Link
* <a href="../monitors/Monitor_nD.html">Monitor_nD</a> component (detector/histogrammer)
* %Link
* <a href="../misc/MCPL_input.html">MCPL_input</a> component (MCPL event file)
*
* %End
*******************************************************************************/
DEFINE INSTRUMENT Histogrammer(string filename=0, int MODE=0 ,
  string options="sphere theta phi outgoing previous",
  int bufsize=10000, xwidth=0.1, yheight=0.1)

/* The DECLARE section allows us to declare variables or  small      */
/* functions in C syntax. These may be used in the whole instrument. */
DECLARE
%{
   int   file_mode;
   char *VirtualI_filename;
   char *MCPL_filename;

%}

/* The INITIALIZE section is executed when the simulation starts     */
/* (C code). You may use them as component parameter values.         */
INITIALIZE
%{
  file_mode = MODE;
  /* Set all filenames empty */
  VirtualI_filename = NULL;
  MCPL_filename     = NULL;
  if (file_mode == 0) {
    printf("\n%s usage:\n'filename' input event file (in Virtual_input/Vitess/MCNP/Tripoli4 formats)\n", NAME_INSTRUMENT);
    printf("'MODE':\n");
    printf("  0 - Print this help and exit)\n");
    printf("  1 - Virtual_input event file\n");
    printf("  2 - MCPL event file\n");
    printf("'options' - options string for Monitor_nD, see mcdoc Monitor_nD.comp\n\n");

    exit(0);
  } else if (file_mode == 1) {
    printf("%s: Mode is 1 (Virtual_input event file)\n", NAME_INSTRUMENT);
    VirtualI_filename = filename;
  } else if (file_mode == 2) {
    printf("%s: Mode is 5 (MCPL event file)\n", NAME_INSTRUMENT);
    MCPL_filename = filename;
  }
%}

/* Here comes the TRACE section, where the actual      */
/* instrument is defined as a sequence of components.  */
TRACE


COMPONENT Origin = Progress_bar()
  AT (0,0,0) ABSOLUTE

/* event file readers *********************************************************/

COMPONENT Virtualinput = Virtual_input(
  filename=VirtualI_filename)
WHEN (file_mode ==1)  AT (0, 0, 0) RELATIVE Origin

COMPONENT MCPLinput = MCPL_input(
  filename=MCPL_filename, verbose=1)
WHEN (file_mode ==5)  AT (0, 0, 0) RELATIVE Origin

/* end   file readers *********************************************************/

/*COMPONENT Sphere = PSD_monitor_4PI(*/
/*    nx = 360, ny = 360, filename = "kugle.dat", radius = 1)*/
/*    AT (0, 0, 0) RELATIVE Origin */

COMPONENT Monitor = Monitor_nD(options=options,xwidth=xwidth,yheight=yheight)
  AT (0, 0, 0) RELATIVE Origin

END