Service calls:
Procedure name | Purpose |
---|---|
INQUIRE_FILE
| Tells whether a file exists |
INQUIRE_MEMBER
| Tells whether a member of a library exists |
INQUIRE_TYPE
| Returns the type of a global variables |
LIST_OBJECTS
| Lists the current booking state of objects |
PRINT
| Prints its arguments |
TIME_LOGGING
| Enters a timing record |
Numeric procedures:
Procedure name | Purpose |
---|---|
CARTESIAN_TO_POLAR
| Converts Cartesian to polar coordinates |
CARTESIAN_TO_INTERNAL
| Converts Cartesian to internal coordinates |
EXTREMUM
| Searches for an extremum of a function |
INTERNAL_TO_CARTESIAN
| Converts internal to Cartesian coordinates |
INTERNAL_TO_POLAR
| Converts internal to polar coordinates |
POLAR_TO_CARTESIAN
| Converts polar to Cartesian coordinates |
POLAR_TO_INTERNAL
| Converts polar to internal coordinates |
PREPARE_RND_FUNCTION
| Prepares random number generation for functions |
ZEROES
| Searches for zeroes of a function |
Cell related procedures:
Procedure name | Purpose |
---|---|
GET_CELL_DATA
| Returns # of wires, coordinate system etc |
GET_CELL_SIZE
| Returns the size of the cell |
GET_PERIODS
| Returns the periodicities |
GET_X_PLANE_DATA
| Returns the x-plane descriptions |
GET_Y_PLANE_DATA
| Returns the y-plane descriptions |
GET_WIRE_DATA
| Returns information on a wire |
Gas related procedures:
Procedure name | Purpose |
---|---|
ATTACHMENT
| Returns the attachment coeff. for a given E/p |
DRIFT_VELOCITY
| Returns the drift velocity for a given E/p |
GAS_AVAILABILITY
| Tells which gas description elements are present |
GET_GAS_DATA
| Returns pressure, temperature and gas identifier |
GET_E/P_TABLE
| Returns the list of E/p values in the table |
ION_MOBILITY
| Returns the ion mobility for a given E/p |
LONGITUDINAL_DIFFUSION
| Returns sigma_L for a given E/p |
LORENTZ_ANGLE
| Returns the Lorentz angle for a given E/p |
TOWNSEND
| Returns the Townsend coefficient for a given E/p |
TRANSVERSE_DIFFUSION
| Returns sigma_T for a given E/p |
VELOCITY_BTRANSVERSE
| Returns the drift velocity component || Btrans |
VELOCITY_E
| Returns the drift velocity component || E |
VELOCITY_ExB
| Returns the drift velocity component || ExB |
Electric field calculation:
Procedure name | Purpose |
---|---|
ELECTRIC_FIELD
| Computes the electric field for a given (x,y) |
ELECTRIC_FIELD_3
| Computes the electric field for a given (x,y,z) |
FORCE_FIELD
| Electrostatic force component (debugging only) |
INTEGRATE_CHARGE
| Integrates the charge contained in an area. |
INTEGRATE_FLUX
| Integrates the E flux over a parallelogram |
MAGNETIC_FIELD
| Computes the magnetic field for a given (x,y) |
MAGNETIC_FIELD_3
| Computes the magnetic field for a given (x,y,z) |
MAP_ELEMENT
| Returns a field map element description |
MAP_INDEX
| Returns a field map element index |
MAP_MATERIAL
| Returns a field map material reference |
PLOT_FIELD_AREA
| Plots the current field area |
Drift line related procedures:
Procedure name | Purpose |
---|---|
AVALANCHE
| Simulates an electron induced avalanche |
DRIFT_ELECTRON
| Drifts an electron from a given (x,y) |
DRIFT_ELECTRON_3
| Drifts an electron from a given (x,y,z) |
DRIFT_INFORMATION
| Returns information about the current drift line |
DRIFT_ION
| Drifts a positive ion from a given (x,y) |
DRIFT_ION_3
| Drifts a positive ion from a given (x,y,z) |
DRIFT_MC_ELECTRON
| MC drift of an electron from a given (x,y,z) |
DRIFT_MC_ION
| MC drift of a positive ion from a given (x,y,z) |
DRIFT_MC_NEGATIVE_ION
| MC drift of a negative ion from a given (x,y,z) |
DRIFT_MC_POSITRON
| MC drift of a positron from a given (x,y,z) |
DRIFT_NEGATIVE_ION
| Drifts a negatvie ion from a given (x,y) |
DRIFT_NEGATIVE_ION_3
| Drifts a negative ion from a given (x,y,z) |
DRIFT_POSITRON
| Drifts a positron from a given (x,y) |
DRIFT_POSITRON_3
| Drifts a positron from a given (x,y,z) |
ELECTRON_VELOCITY
| Returns the electron velocity vector at (x,y,z) |
ION_VELOCITY
| Returns the ion velocity vector at (x,y,z) |
GET_CLUSTER
| Returns a new cluster position |
GET_DRIFT_LINE
| Copies the current drift line to vectors |
INTERPOLATE_TRACK
| Performs interpolation on prepared tracks |
NEW_TRACK
| Reinitialises the track |
PLOT_DRIFT_AREA
| Plots the current drift area |
PLOT_DRIFT_LINE
| Plots projections of the current drift line |
PLOT_TRACK
| Plots the current track with clusters |
PRINT_DRIFT_LINE
| Prints the current drift line |
RND_MULTIPLICATION
| Simulates multiplication over a drift line |
Signal related procedures:
Procedure name | Purpose |
---|---|
ADD_SIGNALS
| Computes signals for the current drift line |
GET_RAW_SIGNAL
| Stores a raw signal in a 1-dimensional matrix |
GET_SIGNAL
| Copies a signal to a 1-dimensional matrix |
INDUCED_CHARGE
| Computes total charges induced in electrodes |
LIST_RAW_SIGNALS
| Lists the raw signals currently in store |
STORE_SIGNAL
| Copies a 1-dimensional matrix to a signal |
THRESHOLD_CROSSING
| Returns threshold crossings in a signal |
WEIGHTING_FIELD
| Computes single electrode ("weighting") fields |
WEIGHTING_FIELD_3
| Same as WEIGHTING_FIELD for (x,y,z) coordinates |
Histogramming:
Procedure name | Purpose |
---|---|
BARYCENTRE
| Computes the barycentre of an histogram |
BOOK_HISTOGRAM
| Books an histogram |
CONVOLUTE
| Convolutes two histograms |
CUT_HISTOGRAM
| Returns a sub-range of an histogram |
DELETE_HISTOGRAM
| Deletes one or more histograms |
FILL_HISTOGRAM
| Fills an histogram |
GET_HISTOGRAM
| Retrieves an histogram from a file |
INQUIRE_HISTOGRAM
| Returns information about an histogram |
LIST_HISTOGRAMS
| Lists the histograms currently in memory |
PLOT_HISTOGRAM
| Plots an histogram |
PRINT_HISTOGRAM
| Prints an histogram |
REBIN_HISTOGRAM
| Rebins an histogram |
RESET_HISTOGRAM
| Resets the contents of an histogram |
WRITE_HISTOGRAM
| Writes an histogram to a Garfield library |
WRITE_HISTOGRAM_RZ
| Writes an histogram to an RZ file |
HISTOGRAM_TO_MATRIX
| Copies an histogram to a matrix |
MATRIX_TO_HISTOGRAM
| Copies a matrix to an histogram |
Matrix manipulation:
Procedure name | Purpose |
---|---|
ADJUST_MATRIX
| Modifies on or more dimensions of a matrix |
BOOK_MATRIX
| Creates a new matrix |
DELETE_MATRIX
| Deletes one or more matrices |
DERIVATIVE
| Computes numerically a derivative |
DIMENSIONS
| Returns the dimensions of a matrix |
EXTRACT_SUBMATRIX
| Returns a sub-matrix of a matrix (internal) |
GET_MATRIX
| Retrieves a matrix from a file |
INTERPOLATE
| Linear interpolation in an n-dimensional matrix |
INTERPOLATE_i
| Local polynomial interpolation in a vector |
LIST_MATRICES
| Lists the matrices currently in memory |
MULTIPLY_MATRICES
| Multiplies 2 matrices |
PRINT_MATRIX
| Prints a matrix |
RESHAPE_MATRIX
| Changes the format of a matrix |
SOLVE_EQUATION
| Solves a matrix equation |
STORE_SUBMATRIX
| Stores a sub-matrix in a matrix (internal) |
WRITE_MATRIX
| Writes a matrix to a file |
Fitting:
Procedure name | Purpose |
---|---|
FIT_EXPONENTIAL
| Fits a exponential to an histogram or to vectors |
FIT_FUNCTION
| Fits an arbitrary function |
FIT_GAUSSIAN
| Fits a Gaussian to an histogram or to vectors |
FIT_MATHIESON
| Fits a Mathieson distribution to an histogram |
FIT_POLYA
| Fits a Polya distribution |
FIT_POLYNOMIAL
| Fits a polynomial to an histogram or to vectors |
String manipulation:
Procedure name | Purpose |
---|---|
DELETE_STRING
| Deletes one or more strings |
LIST_STRINGS
| Lists the currently known stringss |
STRING_DELETE
| Deletes a portion from a string |
STRING_INDEX
| Returns the start position of a sub-string |
STRING_LENGTH
| Returns the length of a string |
STRING_LOWER
| Converts a string to lower case |
STRING_MATCH
| Tells whether 2 strings match |
STRING_PORTION
| Returns a sub-string |
STRING_REPLACE
| Replaces parts of a string |
STRING_UPPER
| Converts a string to upper case |
STRING_WORDS
| Counts the number of words in a string |
STRING_WORD
| Returns a selected word from a string |
Graphics:
Procedure name | Purpose |
---|---|
GKS_AREA
| Plots an area |
GKS_POLYLINE
| Plots a polyline |
GKS_POLYMARKER
| Plots a polymarker |
GKS_SELECT_NT
| Selects a normalisation transformation |
GKS_SET_CHARACTER_EXPANSION
| Sets the character expansion factor |
GKS_SET_CHARACTER_HEIGHT
| Sets the character height |
GKS_SET_CHARACTER_SPACING
| Sets the character spacing |
GKS_SET_CHARACTER_UP_VECTOR
| Sets the character up vector |
GKS_SET_TEXT_ALIGNMENT
| Sets the text alignment |
GKS_SET_TEXT_COLOUR
| Sets the text colour index |
GKS_SET_TEXT_FONT_PRECISION
| Sets the text font and precision |
GKS_TEXT
| Plots a text string |
GKS_VIEWPORT
| Sets a viewport |
GKS_WINDOW
| Sets a window |
PLOT_AREA
| Plots a fill-area |
PLOT_ARROW
| Plots an arrow |
PLOT_COMMENT
| Places a comment on the current plot |
PLOT_CONTOURS
| Plots 2-matrix as a set of contours |
PLOT_END
| Closes the current plot |
PLOT_ERROR_BAND
| Plots an error band |
PLOT_ERROR_BAR
| Plots a series of error bars |
PLOT_FRAME
| Plots a set of coordinate axes |
PLOT_GRAPH
| Plots a graph |
PLOT_LINE
| Plots a line |
PLOT_MARKERS
| Plots a series of markers |
PLOT_START
| Starts a plot |
PLOT_SURFACE
| Plots a 2-matrix as a 3D surface plot |
PLOT_TEXT
| Plots a text string |
PLOT_TITLE
| Plots a string in the title area |
PLOT_X_LABEL
| Plots a string in the x-label area |
PLOT_Y_LABEL
| Plots a string in the y-label area |
PROJECT_LINE
| Projects a line |
PROJECT_MARKERS
| Projects a set of markers |
SET_LINE_ATTRIBUTES
| Selects the representation to use next |
SET_MARKER_ATTRIBUTES
| Selects the representation to use next |
SET_TEXT_ATTRIBUTES
| Selects the representation to use next |
SET_AREA_ATTRIBUTES
| Selects the representation to use next |
This call should be issued from the signal section and it should be preceded by:
A RESET SIGNALS command should be issued prior to the procedure call if you wish to obtain only the newly computed signals.
Use INDUCED_CHARGE instead of ADD_SIGNALS if you wish to compute the charge induced in the various electrodes.
Format:
CALL ADD_SIGNALS(options)
Example:
&SIGNAL area -1 -1 1 1 sel s res 0 0.001 Call drift_ion(0, 0.001001) Call add_signal Call get_signal(1,time,direct,cross) Global qe 1.60217733E-19 Say "Summed signal: {sum(cross)*0.001*1e-12/qe}" Call induced_charge(0, 0.001001, 0, `ion`, 1, 0, 1, q) Say "Induced charge: {q}"
After setting the time window and selecting the read-out electrode, we compute an ion drift line from a point near a wire, located at (0,0). We then use the ADD_SIGNALS procedure to compute the signals induced by this ion and compare the integral of the current with the more accurate estimate from INDUCED_CHARGE over the same time window [0,1] microsec.
Additional information on:
ADJUST_MATRIX changes the size of a matrix in one or more dimensions, without changing the place the elements occupy. If you wish to change the number of dimensions of a matrix, then use RESHAPE_MATRIX.
ADJUST_MATRIX operates by creating a new matrix of the requested dimensions, then copying the elements from the old matrix to the same place in the new matrix. If the new matrix is smaller in any dimension, some elements are lost, even if the overall size of the matrix is larger. If a dimension of the new matrix is larger than the corresponding dimension of the old matrix, then the new elements are filled with PAD (the last argument).
Format:
CALL ADJUST_MATRIX(matrix, size_1, size_2, ... size_n, pad)
Example:
Global n=3 Call book_matrix(a,2,n) For i From 1 To 2 Do Say "How many elements to initialise in row {i} ?" Global n_new=n Parse Terminal n_new If n_new>n Then Call adjust_matrix(a,2,n_new,pi) Global n=n_new Endif For j From 1 To n Do Global a[i;j]=i*j Enddo Enddo Call print_matrix(a)
A matrix is initially booked as 2x3, but since the amount of data to be stored in the matrix is not a priori known, the matrix may have to be extended. This is the approach followed by the Vector command. The PAD argument is compulsory in ADJUST_MATRIX, and is likely to be used in this example.
Additional information on:
Each of the field components can either be a Number or a Matrix. It is permissable to specify 1 or 2 components of the field as Numbers and the other(s) as Matrices.
All components which are specified as Matrix, must have the same total size - they do not have to be 1-dimensional. If at least one component is specified as Matrix, then the output will be a 1-dimensional Matrix with length equal to the overall size of the arguments of type Matrix. Otherwise the result will be a Number.
The electric field should be in V/cm, the attachment coefficient is returned in 1/cm.
Format:
CALL ATTACHMENT(ex, ey, ez, attachment)
This procedure can produce 3 kinds of output:
The procedure first drifts an initial electron from the specified starting point. At each step, a number of secondary electrons and ions is drawn according to the local Townsend and attachment coefficients and the newly produced electrons are traced like the initial electron.
Ion drift lines are computed only if needed, i.e. when their start or end point has to be histogrammed, and when their path has to be plotted.
Drifting of both electrons and ions is performed using the Monte_Carlo technique. Care has to be taken therefore that the step_size is set properly. The use of the PROJECTED-PATH-INTEGRATION integration parameter is recommended in order to avoid a dependence of the multiplication on the step size.
Format:
CALL AVALANCHE(x, y, z, options, n_electron, n_ion, ... formula_1, histogram_1, formula_2, histogram_2 ...)
Example:
&DRIFT area -0.02 -0.02 0.02 0.02 int-par m-c-dist-int 0.0002 Call book_histogram(elec,50,0,2500) Call book_histogram(ion,50,0,2500) Call book_histogram(created,50,-0.02,+0.02) Call book_histogram(lost,50,-0.02,+0.02) Call book_histogram(end_e,50,-0.02,+0.02) Call book_histogram(end_ion,50,-0.02,+0.02) For i From 1 To 100 Do Call plot_drift_area Call avalanche(0.010,0.019,0,`plot-electron,plot-ion`,ne,ni,... `y_created`,created,`y_lost`,lost,`y_e`,end_e,`y_ion`,end_ion) Say "Electrons: {ne}, ions: {ni} (avalanche {i})" Call fill_histogram(elec,ne) Call fill_histogram(ion,ni) Call plot_end Enddo Call fit_exponential(elec,a,b,ea,eb,`plot`) Say "Slope: {-1/b}" !opt log-y Call hplot(elec,`Electrons`,`Number of electrons after avalanche`) Call plot_end Call hplot(ion,`Ions`,`Number of ions produced in avalanche`) Call plot_end Call hplot(created,`y [cm]`,`Production point of electrons`) Call plot_end Call hplot(lost,`y [cm]`,`Absorption point of electrons`) Call plot_end Call hplot(end_e,`y [cm]`,`End point of electrons`) Call plot_end Call hplot(end_ion,`y [cm]`,`End point of ions`) Call plot_end
After setting the AREA, the parameters for Monte Carlo drift line integration are set such that there are about 100 steps on each drift line. The output histograms are booked beforehand so as to ensure they have a common scale. Then, 100 avalanches are produced, all of which are fully plotted, after which the overview statistics are shown.
Additional information on:
The procedure first drifts an initial electron from the specified starting point. The currents induced by the electron are added to the signals if requested. At each step, a number of secondary electrons and ions is drawn according to the local Townsend and attachment coefficients. Trajectories, signals and secondaries are computed for the newly produced electrons as for the initial electron. Start and end points of all electrons can be histogrammed.
Ion drift lines are computed if needed, i.e. when ion induced currents have been requested, when their start or end point has to be histogrammed, and when their path has to be plotted. Ions do not generate secondaries in this procedure.
This call should be issued from the signal section and it should be preceded by:
Drifting of both electrons and ions is performed using the Monte_Carlo technique. Care has to be taken therefore that the step_size is set properly. The use of the PROJECTED-PATH-INTEGRATION integration parameter is recommended in order to avoid a dependence of the multiplication on the step size. Ion tail calculation requires the possibility of drifting ions from the vicinity of electrodes. To enable this, one may have to switch CHECK-ALL-WIRES off. If electron induced currents are to be computed in chambers with wires, then you have to reduce the TRAP-RADIUS considerably.
This procedure adds the newly computed signals to the signal banks. A RESET SIGNALS command should therefore be issued prior to the procedure call if you wish to obtain only the newly computed signals.
Format:
CALL AVALANCHE_SIGNAL(x, y, z, options, n_electron, n_ion, ... formula_1, histogram_1, formula_2, histogram_2 ...)
Example:
&SIGNAL area -0.2 -0.2 0.2 0.2 int-par max-step 0.01 int-acc 1e-10 m-c-dist-int 0.0002 projected ... trap-radius 1.01 sel s res 0 0.001 Call plot_drift_area Call avalanche_signal(0.01,0.01,0,`plot-electron,ion-tail`,ne,ni) Call plot_end pl-sig
The integration parameters are set such that very small steps are taken, for higher accuracy. Also, the trapping radius is made small to avoid avalanche truncation near the wire. Then. we use the AVALANCHE_SIGNAL procedure to generate an avalanche, which is plotted, and to compute the signal it induces.
Global sumaval=0 Global sumdetail=0 For i From 1 To 10 Do reset signals Call avalanche_signal(0.01,0.01,0,`noplot-electron,ion-tail`,ne,ni) Say "Avalanche {i}, electrons/ions: {ne}/{ni}" Call get_signal(1,time,direct,cross) Global sumaval=sumaval+cross reset signals signal detailed-ion-tail cross-induced mc-drift Call get_signal(1,time,direct,cross) Global sumdetail=sumdetail+direct EnddoGlobal sumaval=sumaval/sum(sumaval) Global sumdetail=sumdetail/sum(sumdetail) Call plot_graph(time,sumaval,`Time [microsec]`,`Signal`, ... `Comparison`) Call plot_line(time,sumdetail,`function-2`) Call plot_end
This example demonstrates a comparison with the DETAILED-ION-TAIL method of calculating a signal.
Additional information on:
The procedure works by sliding a window of width NBIN over the histogram to locate a maximum (if several peaks have the same maximum, then the first peak is taken). Then, the weighted mean of the entries within the window is computed and returned.
If the calculation fails (no maximum), then the global variable OK will be set to False, otherwise to True.
Format:
CALL BARYCENTRE(histogram, barycentre [, nbin])
Additional information on:
Histograms can be filled with FILL_HISTOGRAM, plotted with PLOT_HISTOGRAM, fitted with a variety of functions (e.g. FIT_POLYA) and written to a file with WRITE_HISTOGRAM. One can also apply arithmetic to them.
Garfield histograms can either be created with a user determined range, or can be declared with the AUTOSCALE option. In the latter case, the first few entries are used to set a range.
Only the histogram reference argument is mandatory, all other arguments are optional.
Format:
CALL BOOK_HISTOGRAM(reference, [number of bins, ... [minimum, maximum]] [, options]])
Example:
Call book_histogram(ref,10,2,3) Call book_histogram(ref,10,`integer`)
The first example books an histogram of 10 bins for the range [2,3]. The second example books an histogram with 10 bins each spanning an integer range with an automatically chosen scale.
See also FILL_HISTOGRAM.
Additional information on:
Format:
CALL BOOK_MATRIX(reference, size_1, size_2, ...)
Example:
Call book_matrix(cube,3,3,3)
Books a 3x3x3 matrix which can be accessed via the global variable CUBE.
Additional information on:
rho = 0.5*log(x**2+y**2) [dimension not defined] phi = arctan(y/x) [phi in radians]
The input arguments of this procedure can be either of type Number or of type Matrix. If the input type is Matrix, then the two input matrices must have the same total number of elements. The output matrices will have the same structure as the first input matrix.
The abbreviated procedure name CTR is also accepted.
Format:
CALL CARTESIAN_TO_INTERNAL(x,y,rho,phi)
The input arguments of this procedure can be either of type Number or of type Matrix. If the input type is Matrix, then the two input matrices must have the same total number of elements. The output matrices will have the same structure as the first input matrix.
The abbreviated procedure name CTP is also accepted.
Format:
CALL CARTESIAN_TO_POLAR(x,y,r,phi)
The range of the output histogram is chosen as the combined range of the two input histograms. The bin width of the output histogram is the same as the bin width of the input histograms.
If the calculation fails (different bin widths, not enough memory), then the global variable OK will be set to False, otherwise to True.
Format:
CALL CONVOLUTE(ref1, ref2, ref3)
Format:
CALL CUMULATE_HISTOGRAM(refin, refout)
Example:
Vector a 1 2 3 2 1Call matrix_to_histogram(a,1,6,aa)
Call plot_histogram(aa) Call plot_end
Call cumulate_histogram(aa,bb)
Call plot_histogram(bb) Call plot_end
An small histogram is created using Vector and a call to MATRIX_TO_HISTOGRAM. We then call CUMULATE_HISTOGRAM and verify the result with PLOT_HISTOGRAM.
This procedure does not change the bin width - use the REBIN_HISTOGRAM for that purpose.
This procedure may be called while filling is in progress, but should not be called for AUTOSCALE histograms before the range has been established.
If the calculation fails (sub-range doesn't overlap with the histogram, input histogram doesn't exist etc), then the global variable OK will be set to False, otherwise to True.
Format:
CALL CUT_HISTOGRAM(ref_in, xmin, xmax, ref_out)
Example:
Call book_histogram(gauss,500,-50,50) For i From 1 To 500 Do Call fill_histogram(gauss,rnd_gauss) Enddo Call plot_histogram(gauss) Call plot_endCall cut_histogram(gauss,-5,5,new) Call hplot(new) Call plot_end
Gaussian random numbers are entered in an histogram which is much wider than the spread of the entries. Using the CUT_HISTOGRAM procedure, the central part of the histogram is isolated.
Additional information on:
The memory associated with the histograms is only released at the next histogram garbage collect, usually only carried out when there are no free histogram slots left.
If the histograms were known via a Global variable, as is usually the case, then the global variables will exist after this call but their type will have changed to Undefined.
Format:
CALL DELETE_HISTOGRAM(reference_1, reference_2, ...)
Additional information on:
If a DELETE_MATRIX call is issued without arguments, then all existing matrices are deleted, whether associated with a global variable or not, whether in use as a constant of an active instruction or not. The use of this procedure in a loop is therefore not recommended.
Format:
CALL DELETE_MATRIX(matrix_1, matrix_2, ...)
Example:
Call book_matrix(a,2,3,4,5) Call delete_matrix(a) Call list_matrices
If called without arguments, then all global variables of type String are deleted, but strings not associated with a global variable are left in peace - strings are used also outside the context global variables.
This procedure is almost never used since liberating string storage can also be achieved by assigning e.g. a number to global variables representing strings.
Format:
CALL DELETE_STRING(string_1, string_2, ...)
Example:
Global a=`test` Call delete_string(a) Say {a}
The calculation is using an interpolation between y and x of an order that can be specified as an option and which is by default quadratic.
Format:
CALL DERIVATIVE(x, y, x_int, dy [, option])
Example:
Vector x -3,-2.3,-1,0,1,2,5,7,8,12Global y=x**2 Say "Please enter a value" Parse Terminal xint Call derivative(x,y,xint,dy) Say "Derivative: {dy} should be {2*xint}."
This example verifies that the derivative is approximately correct. If y had been set to x**3, the derivative would be inaccurate unless one adds the option `cubic`.
Additional information on:
Format:
CALL DIMENSIONS(matrix, n_dimensions, dimension_vector)
Example:
Call get_matrix(abc,`abc.mat`) Call dimensions(abc,n_dim,dim_abc) Global nx=number(dim_abc[1]) Global ny=number(dim_abc[2]) Say "Matrix abc has {n_dim} dimensions, shape is {nx}x{ny}x..." Call delete_matrix(dim_abc)
A matrix is read from a file, and the example shows how one can find out what the dimensions of the object are. The NUMBER function is used to convert the 1-matrices dim_abc[1] and dim_abc[2] into numbers - this is purely esthetic since Say would place parentheses around the values of nx and ny.
This procedure should be called only from within the drift or signal sections, after the cell and the gas have been entered.
The integrated diffusion, the multiplication and the attachment losses can only be computed if resp. longitudinal diffusion, Townsend and attachment data have been supplied in the &GAS section. The integrated diffusion takes the transverse diffusion into account if both transverse and longitudinal diffusion coefficients have been entered.
This procedure uses the Runge_Kutta_Fehlberg integration method.
Format:
CALL DRIFT_ELECTRON(x, y [, status [, time [, diffusion ... [, multiplication [, attachment]]]]])
Additional information on:
This procedure should be called only from within the drift or signal sections, after the cell and the gas have been entered.
The integrated diffusion, the multiplication and the attachment losses can only be computed if resp. longitudinal diffusion, Townsend and attachment data have been supplied in the &GAS section. The integrated diffusion takes the transverse diffusion into account if both transverse and longitudinal diffusion coefficients have been entered.
This procedure uses the Runge_Kutta_Fehlberg integration method.
Format:
CALL DRIFT_ELECTRON_3(x, y, z [, status [, time [, diffusion ... [, multiplication [, attachment]]]]])
Additional information on:
The integrated diffusion, the multiplication and the attachment losses are not computed.
This procedure should be called only from within the drift or signal sections, after the cell and the gas have been entered.
This procedure uses the Runge_Kutta_Fehlberg integration method.
Format:
CALL DRIFT_ION(x, y [, status [, time]])
Additional information on:
This procedure should be called only from within the drift or signal sections, after the cell and the gas have been entered.
The integrated diffusion, the multiplication and the attachment losses are not computed.
This procedure uses the Runge_Kutta_Fehlberg integration method.
Format:
CALL DRIFT_ION_3(x, y , z [, status [, time]])
Additional information on:
This procedure should be called only from within the drift or signal sections, after the cell and the gas have been entered.
This procedure can only meaningfully be used if both the transverse and the longitudinal diffusion have been supplied in the gas section. The multiplication and the attachment losses can only be computed if Townsend and attachment data have been entered.
The Monte Carlo integration method is described in the drift section under Monte_Carlo.
Format:
CALL DRIFT_MC_ELECTRON(x, y, z [, status [, time ... [, multiplication [, attachment]]]])
Additional information on:
This procedure should be called only from within the drift or signal sections, after the cell and the gas have been entered.
It should be noted that MC drift of electrons and ions uses the same set of integration parameters (step size in particular). Care should be taken to set these parameters to reasonable values for ions before this procedure is called.
Diffusion coefficients for ions can be set with the PARAMETERS statement in the gas section (see sigma).
Multiplication and attachment losses are not evaluated.
The Monte Carlo integration method is described in the drift section under Monte_Carlo.
Format:
CALL DRIFT_MC_ION(x, y, z [, status [, time]])
Additional information on:
This procedure should be called only from within the drift or signal sections, after the cell and the gas have been entered.
It should be noted that MC drift of electrons and ions uses the same set of integration parameters (step size in particular). Care should be taken to set these parameters to reasonable values for ions before this procedure is called.
Diffusion coefficients for ions can be set with the PARAMETERS statement in the gas section (see sigma).
Multiplication and attachment losses are not evaluated.
The Monte Carlo integration method is described in the drift section under Monte_Carlo.
Format:
CALL DRIFT_MC_NEGATIVE_ION(x, y, z [, status [, time]])
Additional information on:
This procedure should be called only from within the drift or signal sections, after the cell and the gas have been entered.
This procedure can only meaningfully be used if both the transverse and the longitudinal diffusion have been supplied in the &GAS section.
The Monte Carlo integration method is described in the drift section under Monte_Carlo.
Format:
CALL DRIFT_MC_POSITRON(x, y, z [, status [, time]])
Additional information on:
This procedure should be called only from within the drift or signal sections, after the cell and the gas have been entered.
This procedure uses the Runge_Kutta_Fehlberg integration method.
Format:
CALL DRIFT_POSITRON(x, y [, status [, time]])
Additional information on:
This procedure should be called only from within the drift or signal sections, after the cell and the gas have been entered.
This procedure uses the Runge_Kutta_Fehlberg integration method.
Format:
CALL DRIFT_POSITRON_3(x, y, z [, status [, time]])
Additional information on:
The integrated diffusion, the multiplication and the losses through attachment are not computed.
This procedure should be called only from within the drift or signal sections, after the cell and the gas have been entered.
This procedure uses the Runge_Kutta_Fehlberg integration method.
Format:
CALL DRIFT_NEGATIVE_ION(x, y [, status [, time]])
Additional information on:
This procedure should be called only from within the drift or signal sections, after the cell and the gas have been entered.
The integrated diffusion, the multiplication and the losses through attachment are not computed.
This procedure uses the Runge_Kutta_Fehlberg integration method.
Format:
CALL DRIFT_NEGATIVE_ION_3(x, y, z [, status [, time]])
Additional information on:
This procedure can be called after any of the drift line computation procedures has been called (e.g. DRIFT_ELECTRON).
Format:
CALL DRIFT_INFORMATION( ... [ `CHARGE`, q ] , ... [ `DRIFT-TIME`, time ] , ... [ `ELECTRODE`, electrode ] , ... [ `PARTICLE`, particle ] , ... [ `PATH-LENGTH`, path ] , ... [ `STATUS-CODE`, istat ] , ... [ `STATUS-STRING`, status ] , ... [ `STEPS`, nsteps ] , ... [ `TECHNIQUE`, technique ] , ... [ `X-START`, coordinate ] , ... [ `Y-START`, coordinate ] , ... [ `Z-START`, coordinate ] , ... [ `X-END`, coordinate ] , ... [ `Y-END`, coordinate ] , ... [ `Z-END`, coordinate ])
Example:
Call plot_drift_area Call drift_electron_3(2.5,3.5,4.5,status,time) Call plot_drift_line Call plot_end Say "Status: {status}" Call string_index(status,`wire`,index1) Call string_index(status,`replica`,index2) If 'index1>0 & index2=0' Then Call drift_information('status-code',wire) Say "The particle hit wire {wire}." Endif
An electron drift line is computed using the Runge Kutta method with DRIFT_ELECTRON_3 which returns a formatted status string. This string has, if the electron hits a wire, the format "Hit X wire n" or "Hit a replica of X wire n". With the help of the STRING_INDEX procedure, we search for the strings "wire" and "replica" to determine whether an original copy of a wire has been hit. If so, DRIFT_INFORMATION is called to find the number of the wire that has been hit.
Additional information on:
If there is no magnetic field, then the magnetic field must not be specified. In this case, the values returned by this procedure coincide with those returned by VELOCITY_E.
If the magnetic field is non-zero, then the magnetic field must be specified. The velocity that is returned is equal to the vectorial sum of VELOCITY_E, VELOCITY_BTRANSVERSE and VELOCITY_ExB.
Each of the field components can either be a Number or a Matrix. It is permissable to specify some components of the field as Numbers and the other(s) as Matrices.
All components which are specified as Matrix, must have the same total size - they do not have to be 1-dimensional. If at least one component is specified as Matrix, then the output will be a 1-dimensional Matrix with length equal to the overall size of the arguments of type Matrix. Otherwise the result will be a Number.
The electric field should be in V/cm, the magnetic field has to be in native units of 100 G or 0.01 T, and the drift velocity is returned in cm/microsec.
Format:
CALL DRIFT_VELOCITY(ex, ey, ez, [bx, by, bz,] drift)
The arguments ex, ey, ez, e, v and status are optional.
Format:
CALL ELECTRIC_FIELD(x, y, ex, ey, ez, e, v, status)
Example:
&CELL plane x=-1 plane y=-1 rows s * * 1 1 1000&FIELD Global n=6 Call book_matrix(x,n,n) Call book_matrix(y,n,n) For i From 1 To n Do For j From 1 To n Do Global x[i;j]=(i-1)/(n-1) Global y[i;j]=(j-1)/(n-1) Enddo Enddo Call efield(x,y,ex,ey,ez,e,v,stat) Call print_matrix(x,y,ex,ey,ez,e,v,stat) area 0 0 1 1 grid {n} print ex ey e v
In a simple chamber, one uses on the one hand the ELECTRIC_FIELD procedure to compute the field on a 6x6 grid, on the other hand the PRINT command is used to verify the result.
Additional information on:
The arguments ex, ey, ez, e, v and status are optional.
Format:
CALL ELECTRIC_FIELD_3(x, y, z, ex, ey, ez, e, v, status)
Example:
See ELECTRIC_FIELD.
Additional information on:
This procedure needs electron drift velocity data, which can be computed with the MAGBOLTZ gas section command. The magnetic field, if present, is taken into account. Diffusion data is not used, even if present - the vector that is returned represents the mean electron drift velocity at a given point.
This procedure provides functionality similar to the SPEED command.
Format:
CALL ELECTRON_VELOCITY(x, y, z, vx, vy, vz [, status])
Example:
Call electron_velocity(2,3,0,vx,vy,vz,status) Say "Velocity: ({vx,vy,vz}), Status: {status}"
Additional information on:
The matrix from which elements are to be extracted should exist prior to the call, the receiving matrix should not exist prior to the call.
This procedure is used to process array indexing on the right hand side of formulae, in procedure calls etc. This procedure is not meant to called by the user. It is much simpler to get sub-matrices using indexing expressions.
Format:
CALL EXTRACT_SUBMATRIX(ndim, nsel_1, nsel_2, ... , ... isel_1_1, isel_1_2, ..., isel_2_1, isel_2_2, ... , ... isel_n_1, isel_n_2, ref_submatrix, ref_matrix)
When the search is successful, the global variable OK is set to True, otherwise to False. The following conditions can lead to un unsuccssful search:
This procedure works by parabolic iteration over a set of 3 near-extreme values, which is initialised with a random search. If the boundary values are better, than the result of the random search, then the parabolic search is skipped.
Format for functions:
CALL EXTREMUM(function, extremum, minimum, maximum, ... [ options [, eps_loc [, eps_fun [, itermax ]]]])
Format for matrices:
CALL EXTREMUM(ordinates, values, extremum, ... [ options [, eps_loc [, eps_fun [, itermax ]]]])
Examples:
Call extremum(`1+5*x-(x-2)**3`,x,-1,4,`plot,print,minimum`) Global min=x Call extremum(`1+5*x-(x-2)**3`,x,-1,4,`plot,print,maximum`) Global max=x Say "Extrema: {min,max}"
The function 1+5*x-(x-2)**3 has a local minimum near x=0.7 and a local maximum near x=3.3. The first call will indeed find the local minimum, while the second call will set x to -1 since the function value on this boundary is higher than in the local maximum.
Global a=2 Global b=3 Call extremum(`1+cosh(a-b)`,b,-1,4,`plot,print,minimum`) Say "Minimum found is {b}, should be {a}."
This example shows a function of two global variables, A and B. The function is minimised as function of B in this example. During the minimisation, A retains its value.
Additional information on:
Format:
CALL FILL_HISTOGRAM(reference, entry [, weight])
Example:
Call book_histogram(ref,100) For i From 1 To 10000 Do Call fill_histogram(ref,rnd_landau) Enddo Call plot_histogram(ref,`Energy loss`,`Landau distribution`) Call plot_end
This example could be used to check that the Landau random number generator does indeed work.
Additional information on:
In addition to the parameters, the global variable OK is set by this procedure. Its value is True is the fit converged, and False otherwise.
Format for histograms:
CALL FIT_EXPONENTIAL(reference, a0, a1, a2, ..., an, ... err_a0, err_a1, err_a2, ..., err_an [, options])
Format for matrices:
CALL FIT_EXPONENTIAL(x, y, err_y, a0, a1, a2, ..., an, ... err_a0, err_a1, err_a2, ..., err_an [, options])
Examples:
&SIGNAL aval polya-town 0.5 check avalanche from 0 0.5 range 0.1 10000 keep-histograms Call fit_exponential(avalanche,a0,a1,ea0,ea1,`print,plot`) Say "a0 = {a0}+/-{ea0}, a1 = {a1}+/-{ea1}."
In this example, the user wishes to see how well a Polya distribution with parameter theta=0.5, can be reproduced by an exponential.
Vector ep ap 0.13158 0 0.65789 0 1.31579 0 2.63158 0 6.57895 0 13.1579 0.0089211 19.7368 0.10592 26.3158 0.24737 39.4737 0.62105 52.6316 0.97995 78.9474 1.86895 105.263 2.74474 131.579 3.605 197.368 5.515 230.263 6.39237 300 8.07711Global epfit=ep[6,7,8,9] Global apfit=ap[6,7,8,9]
Global p=760 Call fit_exponential(1/epfit,apfit,0.1*apfit,a0,a1,ea0,ea1, ... `noplot,noprint`)
Global emin=5000 Global emax=300000 Global ne=100 Global ekorff=emin*(emax/emin)**((row(ne)-1)/(ne-1)) Global akorff=exp(a0+a1*p/ekorff)*p !opt log-x log-y Call plot_frame(emin,0.1,emax,8000,`E [V/cm]`,`α [1/cm]`, ... `Korff fit`) Call plot_error_bar(ep*p,ap*p) Call plot_line(ekorff,akorff,`function-1`) Global a=exp(a0) Global ea=ea0*a Global a=entier(a*10)/10 Global ea=entier(ea*10)/10 Global b=-entier(a1) Global eb=entier(ea1) Call plot_text(40000,100,`A = `/string(a)/` ± `/string(ea), ... `title`) Call plot_text(40000,60,`B = `/string(b)/` ± `/string(eb), ... `title`) Call plot_end
The Townsend coefficients are sometimes approximated using the Rose-Korff formula:
alpha/p = A.exp(-B.p/E)This example performs such a fit on Townsend coefficients that have been computed by the Imonte program for a mixture of 90 % Argon and 10 % isobutane.
Additional information on:
This procedure, unlike the other fitting procedures, does not try to find suitable starting values for the fitting parameters. A starting value for each parameter must therefore be supplied by the user.
Since this procedure uses the symbolic evaluation procedures of Garfield, the fit works essentially in single precision. In order to have a chance to be successful, the problem must therefore be well conditioned.
In addition to the parameters, the global variable OK is set by this procedure. Its value is True is the fit converged, and False otherwise.
Format for histograms:
CALL FIT_FUNCTION(reference, function, ... par1, par2, par3, ... , err1, err2, err3, ... [, options])
Format for matrices:
CALL FIT_FUNCTION(x, y, err_y, function, ... par1, par2, par3, ... , err1, err2, err3, ... [, options])
Example:
Call book_histogram(ref,50,-1,3) For i From 1 To 500 Do Global x=-1+4*rnd_uniform Global w=x**2+1 Call fill_histogram(ref,x,w) Enddo Global c=100 Global a=2 Global b=1 Call fit_function(ref,`c+a*(1+b*x**2)`,a,b,ea,eb,`plot,print`) Say "Function: {c}+{a}*(1+{b}*x**2), errors {ea,eb}" Say "{a+c} +/- {abs(ea)} should be equal to" Say "{a*b} +/- {a*b*sqrt((ea/a)**2+(eb/b)**2)}"
(This is a simple test of the FIT_FUNCTION procedure in which the function depends on 3 global variables A, B and C of which A and B are varied while C is kept fixed.)
Additional information on:
In addition to the parameters, the global variable OK is set by this procedure. Its value is True is the fit converged, and False otherwise.
Format for histograms:
CALL FIT_GAUSSIAN(reference, integral, mean, sigma ... [, err_int [, err_mean [, err_sigma [, options]]]])
Format for matrices:
CALL FIT_GAUSSIAN(x, y, err_y, integral, mean, sigma ... [, err_int [, err_mean [, err_sigma [, options]]]])
Example 1:
Call get_histogram(sel_5,`arrival.hist`,`sel_5`) Call fit_gaussian(sel_5,dum,dum,sigma,dum,dum,esigma,`PLOT`) Say "Gaussian width is {sigma} +/- {esigma}."
The ARRIVAL-TIME-DISTRIBUTION instruction returns the RMS of the arrival time distributions. To obtain Gaussian fits in addition, you can specify the KEEP-HISTOGRAMS option and then use FIT_GAUSSIAN. You can also do the fit in a separate job as explained in http://consult.cern.ch/writeup/garfield/examples/
Example 2:
Call book_histogram(hist) For i From 1 To 10000 Do Global sum=0 For j From 1 To 12 Do Global sum=sum+rnd_uniform Enddo Call fill_histogram(hist,sum) Enddo Call fit_gaussian(hist,a,b,c,ea,eb,ec,`print,plot`)
(This verifies the approximation of a Gaussian distribution by the sum of 12 uniformly distributed random numbers.)
Additional information on:
The Mathieson distribution depends on a shape parameter, called K3, which is a function of the geometrical structure of the chamber, and on the ratio of strip width and anode-cathode distance. The distribution assumes that the avalanche is localised on anode wires placed centrally with respect to the cathode strips.
The procedure derives the strip width from the bin width of the input histogram, the anode-cathode distance has to be entered as an argument. The K3 parameter can be fitted, but may optionally also be kept constant during the fit at a user-specified value.
In addition to the parameters, the global variable OK is set by this procedure. Its value is True is the fit converged, and False otherwise.
Format:
CALL FIT_MATHIESON(reference, distance, norm, centre, k3, ... err_norm, err_centre, err_k3, [, options])
Example:
Call book_histogram(ref_m,50) Call book_histogram(ref_b,50) For i From 1 To 65 Do Call get_histogram(hist,`profile.hist`,string(i)) Global k3=0.1 Global s=0.254 Call fit_mathieson(hist,s,f,xc,k3,ef,exc,ek3,... `noplot,noprint,equal,fitk3`) Call fill_histogram(ref_m,xc) Call barycentre(hist,b,5) Call fill_histogram(ref_b,b) Say "Centre: {xc} +/- {exc}" Say "Barycentre: {b}" Say "K3: {k3} +/- {ek3}" Enddo Call plot_histogram(ref_m,`Reconstructed x [cm]`,`Mathieson fits`) Call plot_end Call plot_histogram(ref_b,`Reconstructed x [cm]`,`Barycentre`) Call plot_end
(We have already produced a file that contains for 65 events a distribution of induced charges in the pads, and now we fit each of these with a Mathieson distribution and compare these fits with barycentres. The K3 parameter is left free.)
References:
Additional information on:
This procedure optionally tries to determine the a linear horizontal scale correction for which the fit is optimal. But, fitting a Polya distribution with a free scale is a numerically poorly conditioned problem because of the high correlation between the Polya parameter and the scale parameters. If the scale is known, then it is preferable to fix the scale.
Similarly, the routine will make an attempt to estimate the Polya parameter if no starting value is known, but it is better to provide a starting value if one is known with reasonable accuracy.
In addition to the parameters, the global variable OK is set by this procedure. Its value is True is the fit converged, and False otherwise.
Format for histograms:
CALL FIT_POLYA(reference, factor, offset, slope, theta, ... err_factor, err_offset, err_slope, err_theta [, options])
Format for matrices:
CALL FIT_POLYA(x, y, err_y, factor, offset, slope, theta, ... err_factor, err_offset, err_slope, err_theta [, options])
Example:
Call book_histogram(ref,100,0,10) For i From 1 To 2000 Do Call fill_histogram(ref,1+2*rnd_polya(1)) Enddo Global o=-1/2 Global s=1/2 Global t=500 Global f=200 Call fit_polya(ref,f,o,s,t,ef,eo,es,et,`plot,print,poisson,auto`) Say "Scaling X={o}+{s}*x, theta={t}+/-{et}, contents={f}."
(First we fill a histogram with a Polya distribution of which we know the theta parameter and the scale, then we check whether the fit finds the input values back. We don't need to give initial values in this case since the AUTO option is specified.)
Additional information on:
In addition to the parameters, the global variable OK is set by this procedure. Its value is True is the fit converged, and False otherwise.
Format for histograms:
CALL FIT_POLYNOMIAL(reference, a0, a1, a2, ..., an, ... err_a0, err_a1, err_a2, ..., err_an [, options])
Format for matrices:
CALL FIT_POLYNOMIAL(x, y, err_y, a0, a1, a2, ..., an, ... err_a0, err_a1, err_a2, ..., err_an [, options])
Example:
Call hdelete(ref) Call hbook(ref,100,-2,2) For i From 1 To 10000 Do Global x=(rnd_uniform-0.5)*4 Global dy=0.01*(rnd_uniform-0.5) Call hfill(ref,x,1+2*x+x**2+dy) Enddo Call fit_polynomial(ref,a0,a1,a2,ea0,ea1,ea2,`print,plot`) Say "a0 = {a0}+/-{ea0}, a1 = {a1}+/-{ea1}, a2 = {a2}+/-{ea2}."
This example is a test to verify that the fit works.
Additional information on:
This procedure is only of use for debugging, and must be used with caution since it is on purpose not protected for locations inside wires (the call can result in a division by zero).
Format:
CALL FORCE_FIELD(x, y, ex, ey)
Additional information on:
Format:
CALL GAS_AVAILABILITY(object, available)
Additional information on:
All arguments are optional.
Format:
CALL GET_CELL_DATA([number_of_wires [, cell_type [, ... coordinates [, identifier]]]])
Additional information on:
If the cell has been entered in polar coordinates, then the dimensions are returned in internal coordinates. These can be converted to Cartesian or polar coordinates with the INTERNAL_TO_CARTESIAN and INTERNAL_TO_POLAR procedures.
If 4 arguments are provided, only the (x,y) part of the cell dimensions is returned. If 6 arguments are present, also the z part is set.
Formats:
CALL GET_CELL_SIZE(xmin, ymin, zmin, xmax, ymax, zmax) CALL GET_CELL_SIZE(xmin, ymin, xmax, ymax)
Example: see GET_WIRE_DATA
In addition to the parameters, the global variable OK is set by this procedure. Its value is True if generating the clusters worked properly, otherwise it will be set to False. OK is set to False if done has been set to True.
Before using the cluster location and energy, the value of the done argument and of the OK global variable should be checked. The parameters should not be used if either of these two has been set to True.
Format:
CALL GET_CLUSTER(xcls, ycls, zcls, npair, ecls, done)
Example:
track 0 1 1 1 muon energy 10000 nodelta Call book_histogram(size,100) For i From 1 To 100 Do Call new_track Until done Do Call get_cluster(xcls,ycls,zcls,npair,ecls,done) If done Then Iterate Call fill_histogram(size,npair) Enddo Enddo !opt log-y Call plot_histogram(size,`Cluster size`,... `Cluster size distribution`) Call plot_end
This example shows how one can obtain the cluster size distribution for tracks generated by the Heed program. Since Heed doesn't generate clusters but always delta electrons (they usually have a very short range), we use the NODELTA-ELECTRONS option on the TRACK command. This compresses the delta electrons into clusters.
Additional information on:
If you wish to retrieve e.g. the length or the coordinates of the end point of the drift path, then DRIFT_INFORMATION provides easier access to the information.
The drift time is expressed in microsec and the z-component of the drift path in cm. Also the (x,y) part of the path is in cm if Cartesian or tube coordinates are used. If the cell has been described in polar coordinates, then (x,y) is represented in internal coordinates:
(rho,phi)=(log(sqrt(x**2+y**2),arctan(y/x))
These can be converted to Cartesian or polar coordinates with the INTERNAL_TO_CARTESIAN and INTERNAL_TO_POLAR procedures.
Format:
CALL GET_DRIFT_LINE(x [, y [, z [, t]]])
Example:
Say "Please enter (x,y) of the starting point" Parse Terminal x_start y_start Call drift_electron(1,1,status,time) Call get_drift_line(x,y,z,t) Call plot_graph(t,x,`Time [microsec]`,`x [cm]`,`x vs time`) Call plot_comment(`UP-LEFT`,`Status: `/status) Call plot_comment(`DOWN-LEFT`,`Drift time: `/string(time)/` [microsec]`) Call plot_comment(`UP-RIGHT`, `From (x,y)=(`/string(x_start)/`,`/... string(y_start)/`)`) Call plot_end
A way to plot the relation between the x-coordinate of a drift line and the drift time.
After the call, the argument is a 1-dimensional Matrix. Any value this argument has before the procedure call, is lost after the call.
Format:
CALL GET_E/P_TABLE(ep)
Example:
Call get_e/p_table(ep) Call get_gas_data(p) Call townsend(ep*p,0,0,a) Call plot_graph(ep*p,a,`E [V/cm]`,`α [1/cm]`, ... `Townsend coefficient`) Call plot_error_bar(ep*p,a,0,0.1*a) Call plot_end
Retrieves the set of E/p points, the pressure and the Townsend coefficients, and then makes a plot showing 10 % error bars for the values.
Format:
CALL GET_GAS_DATA(pressure [, temperature [, identifier]])
Example:
Call get_gas_data(p, t, gasid) Say "Gas identifier is {gasid}."
Additional information on:
Format:
CALL GET_HISTOGRAM(reference, file [, member])
Additional information on:
Format:
CALL GET_MATRIX(matrix, file [, member])
Example:
See WRITE_MATRIX.
Additional information on:
Format:
CALL GET_PERIODS(yesno_x, length_x, yesno_y, length_y)
Additional information on:
Format:
CALL GET_RAW_SIGNAL(type, electrode, avalanche_wire, angle, ... time, signal)
Additional information on:
Format:
CALL GET_SIGNAL(electrode, time, direct [, cross])
Example:
Additional information on:
Internal coordinates are used for the plane locations. Use the INTERNAL_TO_POLAR procedure to convert to, for instance, polar coordinates.
All arguments are mandatory.
Format:
CALL GET_X_PLANE_DATA(yn_1, x_1, V_1, label_1, ... yn_2, x_2, V_2, label_2)
Example:
Call get_cell_data(wires,type,coord,id) Call get_x_plane_data(yn1,x1,V1,lab1, yn2,x2,V2,lab2) If 'coord="Polar"' Then If yn1 Then Say "There is a plane at r={exp(x1)} and with V={V1}." If yn2 Then Say "There is a plane at r={exp(x2)} and with V={V2}." Else If yn1 Then Say "There is a plane at x={x1} and with V={V1}." If yn2 Then Say "There is a plane at x={x2} and with V={V2}." Endif
Internal coordinates are used for the plane locations, use the INTERNAL_TO_POLAR procedure to convert to polar coordinates.
All arguments are mandatory.
Format:
CALL GET_Y_PLANE_DATA(yn_1, y_1, V_1, label1, ... yn_2, y_2, V_2, label2)
Example:
Call get_cell_data(wires,type,coord,id) Call get_y_plane_data(yn1,y1,V1,lab1, yn2,y2,V2,lab2) If 'coord="Polar"' Then If yn1 Then Say "There is a plane at phi={180*y1/pi} and with V={V1}." If yn2 Then Say "There is a plane at phi={180*y2/pi} and with V={V2}." Else If yn1 Then Say "There is a plane at y={y1} and with V={V1}." If yn2 Then Say "There is a plane at y={y2} and with V={V2}." Endif
All arguments are optional.
Format:
CALL GET_WIRE_DATA(wire [, x [, y [, V [, d [, q [, label [, ... length [, weight [, density]]]]]]]]])
Example:
Call get_cell_data(nwire,dummy,dummy,id) Say "List of wires with a negative charge:" For i From 1 To nwire Do Call get_wire_data(i,xw,yw,vw,dw,qw,labelw) If qw>0 Then Iterate Say "Wire {i} at (x,y)=({xw,yw}), type {labelw}" Enddo
This example shows how one can produce a list of the wires that have a negative charge. One could also select a sense wire and store its coordinates using this technique.
Additional information on:
This procedure is a direct interface to the GKS routine GFA. The first argument of GFA, the vector length, is absent.
The area is plotted with the area attributes, and using the normalisation transformation that are in effect at the time the procedure is called.
Format:
CALL GKS_AREA(x,y)
Additional information on:
This procedure is a direct interface to the GKS routine GPL. The first argument of GPL, the vector length, is absent.
The polyline is plotted with the polyline attributes, and using the normalisation transformation that are in effect at the time the procedure is called.
Format:
CALL GKS_POLYLINE(x,y)
Additional information on:
This procedure is a direct interface to the GKS routine GPM. The first argument of GPM, the vector length, is absent.
The polymarker is plotted with the polymarker attributes, and using the normalisation transformation that are in effect at the time the procedure is called.
Format:
CALL GKS_POLYMARKER(x,y)
Additional information on:
This procedure is equivalent to the GKS routine GSELNT.
Format:
CALL GKS_SELECT_NT(nt)
Additional information on:
This procedure is an interface to the GKS routine GSCHXP.
Format:
CALL GKS_SET_CHARACTER_EXPANSION(expansion)
Additional information on:
This procedure is an interface to the GKS routine GSCHH.
Format:
CALL GKS_SET_CHARACTER_HEIGHT(height)
This procedure is an interface to the GKS routine GSCHSP.
Format:
CALL GKS_SET_CHARACTER_SPACING(spacing)
Additional information on:
This procedure is an interface to the GKS routine GSCHUP.
Format:
CALL GKS_SET_CHARACTER_UP_VECTOR(x, y)
Additional information on:
The text alignments specify where a piece of text is to placed with respect to its anchor point.
This procedure is an interface to the GKS routine GSTXAL.
Format:
CALL GKS_SET_TEXT_ALIGNMENT(hor, vert)
Additional information on:
This procedure is a direct interface to the GKS routine GSTXCI.
Format:
CALL GKS_SET_TEXT_COLOUR(colour)
Additional information on:
This procedure is a direct interface to the GKS routine GSTXFP.
CALL GKS_SET_TEXT_FONT_PRECISION(font, precision)
Additional information on:
This procedure is a direct interface to the GKS routine GTX.
The text is plotted with the polyline attributes, the alignment, the up-vector and using the normalisation transformation that are in effect at the time the procedure is called. These attributes can either be set at the GKS level by calling GKS_SET_CHARACTER_EXPANSION, GKS_SET_CHARACTER_HEIGHT, GKS_SET_CHARACTER_SPACING, GKS_SET_CHARACTER_UP_VECTOR, GKS_SET_TEXT_ALIGNMENT, GKS_SET_TEXT_COLOUR and GKS_SET_TEXT_FONT_PRECISION, or at the Garfield level by calling SET_TEXT_ATTRIBUTES.
Format:
CALL GKS_TEXT(x,y,text)
Additional information on:
Specifying a window doesn't entail an automatic change of normalisation transformation.
This procedure is equivalent to the GKS routine GSVP.
Format:
CALL GKS_VIEWPORT(nt, xmin, xmax, ymin, ymax)
Additional information on:
Specifying a window doesn't entail an automatic change of normalisation transformation.
This procedure is equivalent to the GKS routine GSWN.
Format:
CALL GKS_WINDOW(nt, xmin, xmax, ymin, ymax)
Additional information on:
The histogram is not affected by this operation.
Format:
CALL HISTOGRAM_TO_MATRIX(hist, matrix [, min [, max]])
Example:
Call book_histogram(ref1,10,0,1) For i From 1 To 1000 Do Call fill_histogram(ref1,rnd_uniform) Enddo Call plot_histogram(ref1) Call plot_end Call histogram_to_matrix(ref1,a,min,max) Call matrix_to_histogram(a,min,max,ref2) Call plot_histogram(ref2) Call plot_end
First, we book an histogram and fill it with uniformly distributed random numbers. The histogram is then copied to a matrix A, and then copied back to a histogram. Both histograms are plotted to check they are indeed the same.
To take the effect of electronics into account, one should calculate pure signals with the SIGNAL command or with the ADD_SIGNALS procedure, process them (e.g. with CONVOLUTE-SIGNALS), recuperate the electronics output with GET_SIGNAL and integrate the signal using the SUM function.
The procedure first drifts a particle of the desired kind from the starting point. Next, the routine integrates the internal product of the weighting field for the electrode that is read out and the drift velocity between the time limits over the drift path. The result is multiplied with minus the charge of the particle that has been drifting.
Contrary to appearances, the total induced charge (i.e. integrated over the entire drift path) thus computed is a surprisingly boring quantity. A charged particle that moves from one electrode to another can only induce a total charge of +1, 0 or -1. The total charge is +1 or -1 in case the particles moves from an electrode that is read out to one that is not, or vv. The total charge is 0 if the particle moves between electrodes which are both read out or are both not read out.
The sum of charges induced on all electrodes vanishes: the effect of a moving charge in a chamber is a reshuffling of the charges on the conductors, charges are not created and do not vanish.
Format:
CALL INDUCED_CHARGE(x, y, z, particle, electrode ... [, tmin, tmax], q)
Example:
&CELL pl y -1 label p pl y +1 label q rows a * * +0.5 0 -1000 s * * 0 0 1000 b * * -0.5 0 -1000&GAS co2
&SIG area -1.1 -1.1 1.1 1.1 sel (pq)s(ab) Call induced_charge(-0.4,-0.5,0,`e-`,2,q1) Call induced_charge(-0.4,-0.5,0,`e+`,2,q2) Say "Status e-: {stat1}, e+: {stat2}" Say "Charge between wire and plane: {q1+q2}"
Verifies that the total charge induced by a particle moving between two conductors (the B wire and a plane) other than the one that is read out (the S wire), is indeed 0.
A more elaborate application of this procedure can be found in http://consult.cern.ch/writeup/garfield/examples/charge
Additional information on:
The file does not have to be a Garfield library. If you wish to test the presence of, for instance, a gas description is a given library, then you should use INQUIRE_MEMBER.
Format:
CALL INQUIRE_FILE(file, exists)
Example:
&CELL Call inquire_file(`new_cell`,exist) If exist Then % del "dc1.lib" cell < new_cell write "dc1.lib" cell Else get "dc1.lib" cell Endif
In this example a cell description is retrieved from a library called dc1.lib, unless a file called new_cell is found. In that case, the cell description is deleted from the library, the new description is read and stored in compact format in the library.
Additional information on:
Calling this procedure does not interfere with the filling process.
The first 2 arguments are mandatory, the rest is optional.
Format:
CALL INQUIRE_HISTOGRAM(reference, exists, set, channels, minimum, maximum, entries, mean, rms)
Additional information on:
The exists argument is set to True only if all of the following conditions are fulfilled:
Otherwise exists is set to False and the arguments member, remark, date and time are not touched.
Use the INQUIRE_FILE procedure if you only wish to find out whether a file exists.
Format:
CALL INQUIRE_MEMBER(file, member, type, exists ... [,remark [, date [, time]]])
Example:
&GAS Call inquire_member(`straw.gas`,`xe50e50`,`gas`,exist) If exist Then get gas.dat xe50e50 Else pressure 500 temperature 300 magboltz xenon 50 ethane 50 write gas.dat xe50e50 Endif
In this example the existence of a member called XE50E50 in a library called straw.gas is checked. Since the type is set to GAS, only compact gas descriptions are considered. If the member exists, the data is read, otherwise a new table is prepared and is then written to the file.
Additional information on:
The return parameter, type, can have the following values: `String`, `Number`, `Logical`, `Histogram`, `Matrix`, `Undefined` and `# Invalid`.
This procedure provides a functionality which is similar to that of the TYPE function. The main difference is that it is permissible to give the INQUIRE_TYPE procedure as first argument a variable that does not yet exist while this is not allowed with the TYPE function. The reason for this is that the arguments of procedures are automatically declared if they do not yet exist, while the arguments of functions must be existing variables.
Format:
CALL INQUIRE_TYPE(variable, type)
Example:
Call book_histogram(hist,10,0,10) Call inquire_type(hist,type) Say "Type is {type}"
In the 2-dimensional case, the charge is normalised such that a line charge with potential
1 2 2 V = --- log(x + y ) 2pi
would return a charge of 1. In the 3-dimensional case, a point charge with potential
__________ -1 1 / 2 2 2 V = --- \/ x + y + z 4pi
would also yield a total charge of 1. These normalisations should match the fields that are used for wires and space charges.
Integration is performed using 6-point Gaussian quadrature over 50 equal intervals for the 2-dimensional case, and over 20 equal intervals both in phi and in theta for the 3-dimensional case.
Format:
CALL INTEGRATE_CHARGE(x, y, [z,] r, q)
Example:
&CELL rows s * * 1 1 1000 s * * -1 -1 -1000opt cell-print
&OPT charges 2 2 2 1 3 2 3 4.5
&FIELD Call integrate_charge(1.1, 0.5, 0.8, q) Say "One wire: {q}" Call integrate_charge(5, 2, 2.5, 3.5, q) Say "Both point charges together: {q}"
Verifies the line and point charges.
Integration is performed using 6-point Gaussian quadrature over (nu x nv) equal intervals along the two sides of the reactangle. The arguments nu and nv are optional. They are by default set to 20.
This procedure is used to investigate transmission losses.
Format:
CALL INTEGRATE_FLUX(x0,y0,z0, dx1,dy1,dz1, dx2,dy2,dz2, flux ... [, nu [, nv]])
Example:
&CELL plane x=-1 v=-1000 plane x=+1 v=+1000 rows s * * 20 20 0&FIELD Call flux(0,-1,-1, 0,2,0, 0,0,2, flux) Say "Flux={flux} [V.cm]"
In a parallel plate chamber, with a field of 1 kV/cm, we compute the flux through a rectangle of 2 cm by 2 cm. The flux is equal to 1000 V/cm x 4 cm^2 = 4000 V.cm
Internal coordinates are related to Cartesian coordinates by:
x = cos(phi)*exp(rho) [phi in radian, x in cm] y = sin(phi)*exp(rho) [phi in radian, y in cm]
The input arguments of this procedure can be either of type Number or of type Matrix. If the input type is Matrix, then the two input matrices must have the same total number of elements. The output matrices will have the same structure as the first input matrix.
The abbreviated procedure name RTC is also accepted.
Format:
CALL INTERNAL_TO_CARTESIAN(rho,phi,x,y)
Internal coordinates are related to polar coordinates by:
r = exp(rho) [dimensions not defined] phi' = 180*phi/pi [phi' in degrees]
The input arguments of this procedure can be either of type Number or of type Matrix. If the input type is Matrix, then the two input matrices must have the same total number of elements. The output matrices will have the same structure as the first input matrix.
The abbreviated procedure name RTP is also accepted.
Format:
CALL INTERNAL_TO_CARTESIAN(rho,phi,x,y)
This procedure is intended for interpolations in multi-dimensional matrices for a series of points at the time. For single-point interpolations in 1-dimensional arrays, it is easier to use the INTERPOLATE_i (i = 1, 2, 3 or 4) procedures which furthermore permit higher order polynomial interpolation.
Format:
CALL INTERPOLATE(matrix, ord_1, ... ord_n, points, out)
Example:
Call get_matrix(time,`transfer.mat`) Call get_matrix(z,`transfer.mat`) Call get_matrix(delta,`transfer.mat`)Say "Please enter the value of z for which you wish the transfer function:" Global OK=False Global z_hit=-1 While ^OK Do Parse Terminal z_hit Global OK=z_hit>=0 & z_hit<=6 If ^OK Then Say "Please enter a value between 0 and 6 m." Enddo
Call dimensions(time,ndim_time,dim_time) Call book_matrix(point,2,dim_time[1]) Call delete_matrix(dim_time) Global point[1;]=z_hit Global point[2;]=time
Call interpolate(delta,z,time,point,trans) Call delete_matrix(point)
The matrix delta contains the delta-responses of a tube measured at various points along the tube (written z) and as function of time (written time). The purpose of the example is to show how one can compute the delta- response for intermediate values of z by interpolation.
Additional information on:
For (linear) interpolation in higher-dimensional matrices, use the INTERPOLATE procedure.
Format:
CALL INTERPOLATE_i(x_vector, y_vector, x, y)
Example:
sel 1 check wire keep-results Call interpolate_2(phi_1, e_1, pi/2, e90) Call interpolate_2(phi_1, e_1, 3*pi/2, e270) Say "Electric field at 90 degrees is {e90} and at 270 degrees {e270}."
In this example, one computes the field at the surface of wire 1 and asks to save the results in a series of vectors. Since the values at 90 and 270 degrees are not present in these vectors, one uses one of the INTERPOLATE_i procedures to interpolate for these angles.
Additional information on:
Track preparation is a means to obtain rapidly, mainly for the sake of Monte Carlo calculations, numerous drift times, integrated diffusions and multiplications for a single track.
Format:
CALL INTERPOLATE_TRACK(x, y, z, status [, time [, ... diffusion [, multiplication [, attachment [, angle]]]]])
Example:
Global n 20 track 0.5 -0.9 0.5 0.9 lines {n} prepare-track Call book_matrix(yvec,n) Call book_matrix(tvec,n) Call book_matrix(dvec,n) Call book_matrix(avec,n) Call book_matrix(bvec,n) Call new_track For i From 1 To n Do Call get_cluster(x,y,z,npair,e,done) Call interpolate_track(x,y,z,status,time,diff,aval,loss) Say "From ({x,y,z}), t={time}, status={status}" Global yvec[i]=y Global tvec[i]=time Global dvec[i]=diff Global avec[i]=aval Global bvec[i]=loss Enddo Call plot_graph(yvec,tvec,`y [cm]`,`Time [microsec]`, ... `Drift time`) Call plot_end Call plot_graph(yvec,dvec,`y [cm]`,`Diffusion [microsec]`, ... `Diffusion`) Call plot_end Call plot_graph(yvec,avec*bvec,`y [cm]`,`Electron`, ... `Multiplication and loss`) Call plot_end
A track is defined by its location and its clustering model. In this example, the clustering model is chosen to be a fixed number of regularly spaced points along the track, a convenient choice for making the drift time, diffusion and multiplication graphs.
Additional information on:
Each of the field components can either be a Number or a Matrix. It is permissable to specify 1 or 2 components of the field as Numbers and the other(s) as Matrices.
All components which are specified as Matrix, must have the same total size - they do not have to be 1-dimensional. If at least one component is specified as Matrix, then the output will be a 1-dimensional Matrix with length equal to the overall size of the arguments of type Matrix. Otherwise the result will be a Number.
The electric field should be in V/cm, the ion mobility is returned in cm2/V.microsec.
Format:
CALL ION_MOBILITY(ex, ey, ez, mobility)
This procedure needs ion mobility data, which can for instance be entered with the TABLE and ADD gas section commands. The magnetic field, if present, is taken into account for the calculation of the vector. Diffusion data is not used, even if present - the vector that is returned represents the mean ion drift velocity at a given point.
This procedure provides functionality similar to the SPEED command.
Format:
CALL ION_VELOCITY(x, y, z, vx, vy, vz [, status])
Example:
Call ion_velocity(2,3,0,vx,vy,vz,status) Say "Velocity: ({vx,vy,vz}), Status: {status}"
Additional information on:
Histograms should in principle always be associated with a global variable. Memory leaks can occur however because of incomplete garbage collects. If all available memory is occupied by orphan histograms, then memory can be freed with the DELETE_HISTOGRAM procedure.
Format:
CALL LIST_HISTOGRAMS
Example:
Call book_histogram(hist,50,`integer`) Call list_histograms For i From 1 To 10000 Do Call fill_histogram(hist,rnd_poisson(10)) Enddo Call list_histograms
An histogram is booked in autorange mode with integer bins. The listing will indicate this, adding that there are no entries yet. During filling, the range of the histogram is set, as is revealed in the second listing.
Matrices should in principle always be associated with a global variable. Memory leaks can occur however because of incomplete garbage collects. If all available memory is occupied by orphan matrices, then memory can be freed with the DELETE_MATRIX procedure.
Format:
CALL LIST_MATRICES
Example:
Call book_matrix(a,2,3,4,5) Call list_matrices Call delete_matrix(a) Call list_matrices
Objects are e.g. memory areas which can be shared by various calculations. Some procedures can proceed faster if some area of memory contains data of a certain kind, and they test this by looking into the object booking list.
Usually, you do not need to worry about this.
CALL LIST_OBJECTS
Example:
&CELL rows s 5 * i i 1000*i&FIELD Call list_objects plot surf v Call list_objects
Will show that the area called MATRIX is first used for the capacitance matrix. Once the charges have been computed, the area is released. It is claimed again for making the surface plot, and released once this plot has been made. The capacitance matrix is lost at this point, and e.g. CHANGE-VOLTAGES would now recompute the capacitance matrix.
Format:
CALL LIST_RAW_SIGNALS
Example:
&SIGNAL track 0.5 -0.5 0.5 0.5 ava exp 10000 res 0 0.01 200 opt nocl-pr nocl-pl sel 1 signal Call list_raw_signals Call get_raw_signal(`ion`,1,1,0,time,sig) Call plot_frame(0,0,4,10,` `,` `,` `) Call plot_line(time,sig) Call plot_end
In this example, the LIST_RAW_SIGNALS call is used to determine which raw signals are currently available. Then, one of them is retrieved and plotted.
Unlike histograms and matrices, not all strings are associated with a global. For instance, names of metafiles are kept in the string buffer.
Format:
CALL LIST_STRINGS
Example:
Global a=`This is a string` Call string_listing
Each of the field components can either be a Number or a Matrix. It is permissable to specify 1 or 2 components of the field as Numbers and the other(s) as Matrices.
All components which are specified as Matrix, must have the same total size - they do not have to be 1-dimensional. If at least one component is specified as Matrix, then the output will be a 1-dimensional Matrix with length equal to the overall size of the arguments of type Matrix. Otherwise the result will be a Number.
The electric field should be in V/cm, the diffusion is returned in sqrt(cm).
SIGMA_L can be typed as a synonym to LONGITUDINAL_DIFFUSION.
Format:
CALL LONGITUDINAL_DIFFUSION(ex, ey, ez, sigma_l)
If the field is specified with vectors, then the result will also be a vector. Otherwise the result will be a scalar. It is permitted to specify 1 or 2 components of the field with scalars and the other(s) with vectors. The result will still be a vector in that case.
The electric field should be in V/cm, the Lorentz angles are returned in radians.
Format:
CALL LORENTZ_ANGLE(ex, ey, ez, angle)
Format:
CALL MAGNETIC_FIELD(x, y, bx, by, bz [, b])
Additional information on:
Format:
CALL MAGNETIC_FIELD_3(x, y, z, bx, by, bz [, b])
Additional information on:
The input argument is an element number which, for a given location, can be obtained with the related MAP_INDEX procedure. The dielectric constant of the element can be found with MAP_MATERIAL.
The output arguments depend on the elements used in the field map:
If the element does not exist, then a warning is printed, the global variable OK is set to False and the return arguments are not touched.
This procedure is meaningful only when the field is generated by a field map. This procedure is used for debugging such maps.
Formats:
CALL MAP_ELEMENT(element, x1, y1, x2, y2, x3, y3) CALL MAP_ELEMENT(element, x1, y1, z1, x2, y2, z1, x3, y3, z3, ... x4, y4, z4)
Example:
Call plot_frame(-1.6,-1.6,1.6,1.6,`x [cm]`,`y [cm]`,`Mesh structure`) For i From 1 Step 1 Until ^OK To 10000 Do Call map_element(i,x1,y1,x2,y2,x3,y3) If ^OK Then Leave Call plot_area(x1,y1,x2,y2,x3,y3,`material-2`) Enddo Call plot_end
This example assumes a triangular map of less than 10000 elements. It fetches one element at the time, then plots it.
The arguments to be provided depend on the elements used in the field map:
Use the MAP_ELEMENT procedure to obtain geometric information about the field map element. The MAP_MATERIAL procedure supplies information on the material with which the element is filled.
This procedure does not reduce the input coordinates to the elementary cell, even if the cell has been declared to have symmetries.
If the point is not located in any element, then a warning is printed, the global variable OK is set to False and the return arguments of the procedure are not touched.
Due to numerical rounding errors, points which are located in the immediate vicinity of the boundaries of the field map, are sometimes mistakenly declared to be outside the map. One should therefore test on OK.
This procedure is meaningful only when the field is generated by a field map. This procedure is used for debugging such maps.
Format:
CALL MAP_INDEX(x, y [, z], element, [t1, t2, t3 [,t4]])
The first argument of the procedure is the element number which, for a given location, can be obtained with the MAP_INDEX procedure. The geometric aspects of the element can be found with MAP_ELEMENT.
If the element does not exist, then a warning is printed, the global variable OK is set to False and the return arguments of the procedure are not touched.
Format:
CALL MAP_MATERIAL(element, material, epsilon)
Example:
Global xmin=-0.0100 Global xmax=+0.0100 Global ymin=-0.0180 Global ymax=+0.01800 Global z=0.0032 Global n=50 !rep function-1 polymarker-colour green marker-type circle marker-size 0.2 !rep function-2 polymarker-colour blue marker-type circle marker-size 0.2 !rep function-3 polymarker-colour red marker-type circle marker-size 0.2 Call plot_field_area For i From 1 Step 1 To n Do Global x=xmin+(i-1)*(xmax-xmin)/(n-1) For j From 1 Step 1 To n Do Global y=ymin+(j-1)*(ymax-ymin)/(n-1) Call map_index(x,y,0,index) Call map_material(index,ieps,eps) If eps<4 Then Iterate Call efield3(x,y,z,ex,ey,ez,e) If ez<0 Then Call plot_markers(x,y,`function-1`) Elseif ez>5000 Then Call plot_markers(x,y,`function-3`) Else Call plot_markers(x,y,`function-2`) Endif Enddo Enddo Call plot_end
This example shows how one can find areas of a GEM foil that attract electrons, and thus can cause inefficiencies. A scan is made just above the foil (at z=32 micron). over a grid of n x n points. A green marker is plotted in places where the z-component of the field is negative (i.e. areas where the foil will not attract electrons), a red marker shows spots where electrons are attracted and a blue marker is used for the transition regions. To exclude the hole in the GEM, which should not be shown in red since this area attracts electrons when the GEM operates properly, the dielectric constant at z=0, i.e. in the middle of the kapton layer, is checked.
The matrix should be 1-dimensional, if you give a matrix with a higher number of dimensions, then it will be unfolded.
Format:
CALL MATRIX_TO_HISTOGRAM(matrix, min, max, hist)
Example:
See HISTOGRAM_TO_MATRIX.
The track location and the clustering model should be specified on beforehand with the TRACK command.
Once NEW_TRACK has been called, cluster positions and cluster sizes can be obtained from GET_CLUSTER.
Format:
CALL NEW_TRACK
Example:
See GET_CLUSTER.
This procedure should only be called after a call to PLOT_FRAME.
Format:
CALL PLOT_AREA(x1, y1, x2, y2, ..., x_n, y_n [, area_type])
Example:
!rep times-roman character-height 0.075 ch-exp {1.2/8.5} !rep box polyline-col background !rep grid polyline-col background !rep numbers text-col background Call plot_frame(0,0,1.2,8.5,` `,` `,` `) For i from 0 to 1.01 step 0.2 do For j from 0 to 1.01 step 0.2 do For k from 0 to 1.01 step 0.2 do !colour a red {i} green {j} blue {k} !rep wires fill-area-colour a fill-area-int-style solid Call plot_area(j,7*i+k, j,7*i+k+0.2, j+0.2,7*i+k+0.2, ... j+0.2,7*i+k, j,7*i+k, `WIRES`) Call plot_text(j+0.1,7*i+k+0.1, ... `R=`/string(i)/`, B=`/string(k)/`, G=`/string(j), ... `TIMES-ROMAN`,`CENTRE-HALF`) Enddo Enddo Enddo Call plot_end
This example illustrates how one can generate an RGB colour map. The colour A is repeatedly redefined in the loop and is used to modify also the representation of WIRES (one of the few pre- defined FILL-AREA representations). In each box with a given colour, the RGB value is plotted in TIMES-ROMAN. You may have to change this name depending on the graphics system that you are using.
Additional information on:
The appearance of the arrow is affected by the representation used to draw the lines, and also by the settings of ARROW-TIP-ANGLE and ARROW-TIP-LENGTH.
Format:
CALL PLOT_ARROW(x0, x1, y0, y1 [, type])
Example:
Call plot_arrow(0,0,1,1,`function-1`)
Additional information on:
Format:
CALL PLOT_COMMENT(place, text)
Example:
Call plot_frame(1,1,2,2,`x`,`y`,`Title`) Call plot_comment(`up-left`,`Made on `/machine) Call plot_comment('down-right`,`Time left: `/string(time_left)) Call plot_end
Will place a comment string on the left in the top row that reads (on a Vax) "Made on Vax".
Additional information on:
Format:
CALL PLOT_CONTOURS(matrix [, n_contours [, options ... [, x-vector [, y-vector ... [, x-label [, y-label [, title ]]]]]]])
Example:
Call book_matrix(a,30,30) Call plot_contours(a)
Additional information on:
Use PLOT_FIELD_AREA to plot the field area.
Format:
CALL PLOT_DRIFT_AREA([title])
Example:
area -1 -1 -2 1 1 2 view x+2*y+3*z=5 call plot_drift_area
Additional information on:
The desired projection should be set with the AREA command.
Format:
CALL PLOT_DRIFT_LINE
Example:
Global x0=0.001 Global y0=0.028 Call plot_drift_area For i From 1 To 50 Do Call drift_mc_electron(x0, y0, 0, status, time) Call plot_drift_line Enddo Call plot_end
This examples would make a plot of 50 Monte Carlo integrated drift lines all starting from the same point (x0,y0). One can of course exand the example by adding histograms of the drift time and the arrival point.
The procedure empties the graphics buffer to ensure that the plot is complete. If the WAIT-AFTER-PLOT option is in effect, a prompt is displayed before proceeding with the next plot.
Yoy may optionally specify a string as argument. The string will be entered in the list of plots that is printed at the end of the job output.
Format:
CALL PLOT_END( [string] )
This call would typically be combined with PLOT_ERROR_BAR.
Format:
CALL PLOT_ERROR_BAND(x, y1, y2)
Example:
Call plot_frame(0,0,5,5,`x`,`y`,`title`) Global x1=(row(51)-1)/10 Global y1=1+x1**2/10 Global y2=y1*1.2 Call plot_error_band(x1,y1,y2) Call plot_end
First, we create a vector X1 that contains 50 numbers regularly spaced between 0 and 5. Using X1, an error band between Y1 and Y2 is constructed with 20 % uncertainty.
Additional information on:
Format:
CALL PLOT_ERROR_BAR(x, y [, ex-, ey- [, ex+, ey+]] [, type [, size]])
Example:
Vector x y ex1 ey1 ex2 ey2 1 1 0.5 0.5 0.25 0.25 2 2 0.5 0.25 0.5 0.25call plot_frame(0,0,5,5,`x`,`y`,`title`) call plot_error_bars(x,y,ex1,ey1,`circle`,0.02) call plot_error_bar(x+2,y,ex1,ey1,ex2,ey2,`square`) call plot_end
Additional information on:
Use PLOT_DRIFT_AREA to plot the drift area.
Format:
CALL PLOT_FIELD_AREA([title])
Example:
area -1 -1 -2 1 1 2 view x+2*y+3*z=5 cut call plot_field_area
Additional information on:
Call PLOT_END to end the plot.
Format:
CALL PLOT_FRAME(xmin, ymin, xmax, ymax ... [, x_label [, y_label [, title]]])
Additional information on:
The scales are chosen automatically on the basis of the range of the vectors and axes are plotted accordingly. The procedure PLOT_FRAME should not be called prior to PLOT_GRAPH.
The graph is left open after the call and further elements can be added to the plot. PLOT_END should be called to end the plot.
Format:
CALL PLOT_GRAPH(x_vector, y_vector [, x_label [, y_label, [,title]]])
Example:
Global n=20 Call book_matrix(x,n) Call book_matrix(y,n) Global m=3 For i From 1 To n Do Global x[i]=cos(m*2*pi*i/(n-1)) Global y[i]=sin(m*2*pi*i/(n-1)) Enddo Call plot_graph(x,y) !rep circle polymarker-colour green Call plot_markers(x,y,`circle`) Call plot_end
The plot in this example is a kind of star pattern. The axis labels are omitted and will therefore be replaced by X and Y, the names of the variables that have been plotted.
Additional information on:
Calling this procedure does not interfere with filling of the histogram but an autotange histogram will only be shown if the range has been set.
This procedure, by default, plots the histogram in a frame with dimensions adjusted to the the histogram. If you wish to control the axes yourself, then use the PLOT_FRAME procedure to plot the axes and use the NOFRAME option of PLOT_HISTOGRAM. This option can also be used to superimpose several histograms.
The procedure leaves the plot open for further additions, the PLOT_END procedure should be called when the plot is complete.
Format:
CALL PLOT_HISTOGRAM(histogram [, x_label [, title [, options]]])
Example:
!col red red 1 blue 0 green 0 !col blue red 0 blue 1 green 0 !col green red 0 blue 0 green 1 !rep function-1 polyline-colour green Call hplot(all_1,`Time [microsec]`,`Arrival time spectrum`) !rep function-1 polyline-colour red Call hplot(sel_1,` `,` `,`noframe`) !rep function-1 polyline-colour blue Call hplot(sel_2,` `,` `,`noframe`) Call plot_end
In this example, the overall arrival time spectrum is plotted together with the arrival time distributions for a number of selected electron. The 3 histograms are distinghuised by colour.
Additional information on:
If you wish to make a graph, then using the PLOT_GRAPH procedure is probably simpler. If the curve you wish to plot is in fact a projection of a line in 3 dimensions, then consider using PROJECT_LINE.
Two formats are accepted: one takes a series of (x,y) coordinates, the other takes a pair of vectors as arguments.
Formats:
CALL PLOT_LINE(x1, y1, x2, y2, ..., x_n, y_n [, option]) CALL PLOT_LINE(x_vector, y_vector [, option])
Example 1:
!col cyan red 0 green 1 blue 1 !rep function-4 polyline-colour cyan Call plot_frame(-1,-1,2,2) Call plot_line(0,0, 1,0, 0,1, 1,1, 0,0, `function-4`) Call plot_end
A colour called CYAN is defined, this colour is used to modify the appearance of FUNCTION-4 polylines. This polyline representation is used to produce a figure.
Example 2:
Call book_matrix(time,20) Vector time 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20Call plot_frame(0,-1.1,21,1.1,`Time`,`Sinus`,`A curve`) Call plot_line(time,sin(time/3),`FUNCTION-1`) Call plot_end
This example shows how one can plot a simple curve: the vector TIME is declared and initialised with the numbers 1 through 20. This is actually not necessary since a matrix has this contents when it is created. Then, a plot is made of TIME vs sin(TIME/3). A slightly simpler way to achieve this result would have been to use PLOT_GRAPH.
Additional information on:
If the markers you wish to plot are in fact located in 3-dimensional space, then consider using PROJECT_MARKERS.
Formats:
CALL PLOT_MARKERS(x1, y1, x2, y2, x3, y3, ... [, marker_type]) CALL PLOT_MARKERS(x_vector, y_vector [, marker_type])
Example:
Global n=50 Call book_matrix(x,n) Call book_matrix(y,n) For i From 1 To n Do Global x[i]=i Global y[i]=rnd_gauss Enddo Call plot_frame(number(x[1]),-3,number(x[n]),3,... `Time`,`Random`,`Scattered points`) !rep circle polymarker-colour orange Call plot_markers(x,y,`CIRCLE`) Call plot_end
First, 2 matrices are created. One is filled with the numbers 1-n, the other with Gaussian distributed random numbers. Then, the pairs are plotted as orange circles.
Additional information on:
You only need to call this procedure if you wish to set window, viewport and normalisation transformation manually. All plot routines do this automatically.
Format:
CALL PLOT_START
Format:
CALL PLOT_SURFACE(matrix ... [, theta [, phi ... [, x-vector [, y-vector ... [, x-label [, y-label [, title]]]]]]])
Example:
Call book_matrix(a,30,30) Call plot_surface(a)
Additional information on:
On some graphics systems (provided that the graphics option DISPLAY-CONTROL-CHARACTERS is on, this is by default the case) special symbols are available through the following mechanisms:
Format:
CALL PLOT_TEXT(x, y, string [, font [, alignment [, orientation]]])
Example:
Call plot_text(0.5, 0.5, `Some text`, `TIMES-ROMAN`, `LEFT-BASE`)
The string "Some text" will be plotted horizontally with its lower left corner at (0.5,0.5).
Additional information on:
This procedure is used if you wish to replace the default title of a plot with your own.
The title is shown according to the TITLE representation. The location is determined with the LAYOUT command.
Format:
CALL PLOT_TITLE(title)
Example:
!rep title text-colour background drift track !rep title text-colour red Call plot_title(`Track at 1 m from the membrane`) Call plot_end
To make the default title invisible, the text colour of the title is set to BACKGROUND before the drift line plot is made. Once this plot is finished, the title colour is restored and a new title is put in place. The PLOT_END procedure is used to close the graph.
For most track models, this will simply be a line from the starting point of the track to the end point.
To plot a track that has been generated with Heed, you must first call NEW_TRACK and then at least once GET_CLUSTER, even if you don't use the data returned by the latter procedure.
Format:
CALL PLOT_TRACK
Example:
For i From 1 To nstat Do If 'i=10*entier(i/10)' Then Say "Iteration {i}" Call plot_drift_area Call new_track Do Call get_cluster(xcls,ycls,zcls,npair,done) If done Then Leave Else For n From 1 To npair Do Call drift_mc_electron(xcls, ycls, zcls, status, time) Call plot_drift_line Enddo Endif Enddo Call plot_track Call plot_end Enddo
(This example shows how one can make the same kind of plot as DRIFT TRACK by calling procedures.)
Additional information on:
This procedure is used if you wish to replace the default label of a plot with your own.
The label is shown according to the LABELS representation. The location is determined with the LAYOUT command.
Format:
CALL PLOT_X_LABEL(label)
Example:
See PLOT_TITLE
This procedure is used if you wish to replace the default label of a plot with your own.
The label is shown according to the LABELS representation. The location is determined with the LAYOUT command.
Format:
CALL PLOT_Y_LABEL(label)
Example:
See PLOT_TITLE
The input arguments of this procedure can be either of type Number or of type Matrix. If the input type is Matrix, then the two input matrices must have the same total number of elements. The output matrices will have the same structure as the first input matrix.
The abbreviated procedure name PTC is also accepted.
Format:
CALL POLAR_TO_CARTESIAN(r,phi,x,y)
If the condition r>0 is not met, then the global variable OK is set to False, otherwise to True.
Internal coordinates are related to polar coordinates by:
rho = log(r) [dimension not defined] phi' = pi*phi/180 [radians]
The input arguments of this procedure can be either of type Number or of type Matrix. If the input type is Matrix, then the two input matrices must have the same total number of elements. The output matrices will have the same structure as the first input matrix.
The abbreviated procedure name PTR is also accepted.
Format:
CALL POLAR_TO_INTERNAL(r,phi,rho,phi')
If the distribution to be generated originates from an histogram, then the RND_HISTOGRAM function should be used.
RND_FUNCTION is based on the FUNLUX routine from the CERN program library.
Format:
CALL PREPARE_RND_FUNCTION(function, min, max)
Example:
Call book_histogram(hist,100,-1,2) Call prepare_rnd_function(`1.5+sin(6*x)`,-1,2) For i From 1 To 10000 Do Call fill_histogram(hist,rnd_function) Enddo Call plot_histogram(hist) Call plot_end
Additional information on:
Format:
CALL PRINT(any number of arguments)
Format:
CALL PRINT_DRIFT_LINE
Example:
Call drift_electron(1,2) Call print_drift_line
Format:
CALL PRINT_HISTOGRAM(reference [, x-title [, title]])
Additional information on:
Format:
CALL PRINT_MATRIX(matrix_1, matrix2, ...)
Example:
Call book_matrix(a,2,3) Call print_matrix(a)
A matrix called A is booked, and is then immediately printed. This shows how matrices are initialised.
The procedure should be only be called after a plot frame has been opened, e.g. with PLOT_FIELD_AREA or PLOT_DRIFT_AREA.
Format:
CALL PROJECT_LINE(vector_1, vector_2, vector_3 [, representation])
Example:
&DRIFT Global n=20 Global nmax=5000 Call delete_matrices Call book_matrix(xbuf,nmax) Call book_matrix(ybuf,nmax) Call book_matrix(zbuf,nmax) Call book_matrix(nbuf,n) Call book_matrix(ibuf,n) Global i0=1 For i From 1 Step 1 To n Do Global y=4*(i-1)/(n-1)-0.5 Call drift_electron_3(-0.5,y,1.5,status,time) Call get_drift_line(xd,yd,zd,t) Call drift_info(`steps`,nd) If i0+nd>nmax Then Say "Buffer overflow, reducing n to {i-1}." Global n=i-1 Leave Endif Call book_matrix(ind,nd) Global xbuf[i0+ind]=xd Global ybuf[i0+ind]=yd Global zbuf[i0+ind]=zd Global ibuf[i]=i0 Global nbuf[i]=nd Global i0=i0+nd EnddoDo Global a Global b Global c Say "Please enter the normal vector of the viewing plane:" Parse Terminal a b c If 'type(a)=`Undefined`' Then Leave Elseif 'type(a)#`Number` | type(b)#`Number` | type(c)#`Number`' Then Say "The vector is not fully numeric" Iterate Endif area -1.5 -1.5 -1.5 4.5 4.5 4.5 view {a}*x+{b}*y+{c}*z=0 3d Call plot_drift_area For i From 1 Step 1 To n Do Call book_matrix(ind,nbuf[i]) Global i0=number(ibuf[i]) Global xd=xbuf[i0+ind] Global yd=ybuf[i0+ind] Global zd=zbuf[i0+ind] Call project_line(xd,yd,zd,`e-drift-line`) Enddo Call plot_end Enddo
This shows how one can compute a set of drift lines and then look at them from various angles - probably more interesting for drift lines computed with the MC procedures, where the method ensures that the drift lines are the same in all projections.
Additional information on:
The procedure should be only be called after a plot frame has been opened, e.g. with PLOT_FIELD_AREA or PLOT_DRIFT_AREA.
Format:
CALL PROJECT_MARKERS(vector_1, vector_2, vector_3 [, representation])
Example:
Additional information on:
This procedure does not change the range of the histogram. To reduce the range, use CUT_HISTOGRAM.
This procedure may be called while filling is in progress, but should not be called for AUTOSCALE histograms before the range has been established.
If the calculation fails (invalid arguments etc), then the global variable OK will be set to False, otherwise to True.
Format:
CALL REBIN_HISTOGRAM(ref_in, ngroup, ref_out)
Example:
Call book_histogram(gauss,200,-10,10) For i From 1 To 500 Do Call fill_histogram(gauss,rnd_gauss) Enddo Call plot_histogram(gauss) Call plot_endCall rebin_histogram(gauss,5,new) Call hplot(new) Call plot_end
An histogram is filled with fine binning, and then rebinned for better readability.
Additional information on:
The range, if set, and number of bins is not touched.
If the range has not been established for an histogram of the AUTOSCALE type, then the range will eventually be computed from only those entries that were entered after the call to RESET_HISTOGRAM. In case the range of such an histogram has already been established, and you wish the histogram to regain its auto scale status, then you should book the histogram anew with BOOK_HISTOGRAM.
If arguments are omitted altogether, then all histograms currently stored as global variables are reset.
Format:
CALL RESET_HISTOGRAM(hist1, hist2, ...)
RESHAPE_MATRIX first unpacks the matrix in a string of numbers, then fills these numbers in a new matrix of the specified dimensions. This procedure can therefore be used to change the number of dimensions of a matrix. If you wish to truncate or expand a matrix keeping the elements in place, then use ADJUST_MATRIX.
If the new matrix contains more elements than the old matrix did, then the remaining elements are assigned the value PAD (the last argument of the procedure).
If the new matrix is smaller than the old matrix, then the remaining elements are simply lost.
Format:
CALL RESHAPE_MATRIX(matrix, size_1, size_2, ..., size_n, pad)
Example:
(assume that B is a 3x4 matrix) Global a=b[2;] Call reshape_matrix(b,4,0.0)
The 2nd row of the matrix B is extracted with the Global statement. At this point, A is a 1x4 matrix. In order to reduce A to a 4-matrix, RESHAPE_MATRIX is used. The PAD argument is compulsory, but its value is not used here.
Additional information on:
For each step of the drift line, the procedure uses the Townsend coefficients to compute the probability that an electron is produced, and the attachment coefficients to compute the probability that an electron is lost.
According to these probabilities, electrons are created or absorbed at each step.
The procedure can be applied both to drift lines computed with the Runge_Kutta_Fehlberg and with Monte_Carlo methods. In the latter case, the use of the PROJECTED-PATH-INTEGRATION integration parameter is recommended in order to avoid a step size dependence in the multiplication.
The procedure can be called repeatedly for the same drift line.
Format:
CALL RND_MULTIPLICATION(ne, [ni])
Example:
&DRIFT int-par projected m-c-dist-int 0.0002 Call drift_electron_3(0.15,0,0,status,time,diff,aval,att) Say "Mean RKF aval: {aval}, loss: {att}, product: {aval*att}, status {status}" Call book_histogram(hist,50,0,2*aval*att) Global nrndm=500 For i From 1 To nrndm Do Call drift_mc_electron(0.15,0,0) Call rnd_multiplication(a) Call fill_histogram(hist,a) If 'entier(i/100)*100=i' Then !opt log-y Call plot_histogram(hist) Call plot_end Endif Enddo
Calling this procedure is useful only if you draw the next fill area with GKS_AREA, most other procedures set the attributes before plotting.
Format:
CALL SET_AREA_ATTRIBUTES(representation)
Additional information on:
Calling this procedure is useful only if you draw the next polyline with GKS_POLYLINE, most other procedures set the attributes before plotting.
Format:
CALL SET_LINE_ATTRIBUTES(representation)
Additional information on:
Calling this procedure is useful only if you draw the next polymarker with GKS_POLYMARKER, most other procedures set the attributes before plotting.
Format:
CALL SET_MARKER_ATTRIBUTES(representation)
Additional information on:
Calling this procedure is useful only if you draw the next text with GKS_TEXT, most other procedures set the attributes before plotting.
Format:
CALL SET_TEXT_ATTRIBUTES(representation)
Additional information on:
The vectors to be stored must have the same length as the other signals currently stored. The time vector can not be changed with this command.
Format:
CALL STORE_SIGNAL(electrode, direct [, cross-induced])
Additional information on:
Both matrices should exist prior to the call and the size of the selected area should match the size of the matrix which is to be stored.
This procedure is used to process array indexing on the left hand side of Global statements. The procedure is not intended to be called by the user. Using the Global statement is much simpler.
Format:
CALL STORE_SUBMATRIX(ndim, nsel_1, nsel_2, ..., isel_1_1, ... isel_1_2, ..., isel_2_1, isel_2_2, ... , isel_n_1, isel_n_2, ... ref_submatrix, ref_matrix)
Format:
CALL STRING_DELETE(string, istart, iend, output)
Example:
Call string_delete(`abc def ghi`,4,8,out)
Additional information on:
The first character of a string is numbered 1. Returns 0 if the substring is not found within the string.
Format:
CALL STRING_INDEX(string, substring, index)
Example:
Call string_index(`abc def`,`def`,pos) Say "`def` starts at character {pos} in `abc def`"
Format:
CALL STRING_LENGTH(string, length)
Example:
Call string_length(`abc`,n) Say "Length of string is {n} characters."
Format:
CALL STRING_LOWER(string)
Example:
Global str=`ABCDEF` Call string_lower(str) Say {str}
Format:
CALL STRING_MATCH(string, pattern, match)
Example:
Call string_match(`abc-def`,`ab#cdef-de#fghi-#ghijkl`,match) If match Then Say "The strings match." Else Say "The strings do not match." Endif
Format:
CALL STRING_PORTION(string, istart, iend, portion)
Example:
Call string_portion(`abc def ghi`,5,7,out) Say "Characters 5 through 7 of `abc def ghi` are: {out}"
This procedure does not replace characters that stem from earlier replacements.
Format:
CALL STRING_REPLACE(string, search, replace)
Examples:
Global mixture=`Argon 90 methane 10` Global gas_file=mixture/`.gas` Call string_replace(gas_file,` `,`_`) Say "|{gas_file}|"
In order to create a file name without blanks from a gas mixture, the blanks are replaced by underscores.
Vector a 1.23 2.34 3.45 4.56Global b=string(a) Call string_replace(b,`, `,` `) Call string_replace(b,`(`,``) Call string_replace(b,`)`,``) Say "-{b}-"
Prints the vector A without parentheses and commata.
Global a=`baaaaa` Call string_replace(a,`ba`,`bbb`) Say "|{a}|"
After the call, a will be equal to `bbbaaaa` and not `bbbbbbbbbbb`.
Format:
CALL STRING_UPPER(string)
Example:
Global str=`abcdef` Call string_upper(str) Say {str}
Format:
CALL STRING_WORD(string, i, word)
Example:
Global str=`abc def ghi` Call string_words(str,n) Say "The string contains {n} words." For i From 1 To n Do Call string_word(str,i,out) Say "Word {i} is {out}." Enddo
Format:
CALL STRING_WORDS(string, n)
Example:
See STRING_WORD
The entire buffer is printed out at job completion.
Format:
CALL TIME_LOGGING( string )
Example:
Call time_logging(`Until timing test`) Global x0=0.5 Global y0=1.5 Call plot_drift_area For i From 1 To 100 Do Call drift_mc_electron(x0, y0, 0, status, time) Call plot_drift)line Enddo Call time_logging(`MC drifting`)
The TIME_LOGGING routine is called a first time to ensure that in the end we will record only the time spent in MC drifting will be recorded.
Each of the field components can either be a Number or a Matrix. It is permissable to specify 1 or 2 components of the field as Numbers and the other(s) as Matrices.
All components which are specified as Matrix, must have the same total size - they do not have to be 1-dimensional. If at least one component is specified as Matrix, then the output will be a 1-dimensional Matrix with length equal to the overall size of the arguments of type Matrix. Otherwise the result will be a Number.
The electric field should be in V/cm, the Townsend coefficient is returned in 1/cm.
Format:
CALL TOWNSEND(ex, ey, ez, townsend)
Format:
CALL THRESHOLD_CROSSING(electrode, threshold, options, ... ntime, time1 [,time2 [,time3 ...]])
Example:
For i From 1 To 100 Do signal conv-sig range 0 1000 ... transfer-function (5*t/0.01)**5*exp(-5*t/0.01) Call threshold_crossing(1,-0.02,`rising,linear`,n,t1,t2) Say "Found {n} threshold crossings, 1st at {t1} nsec." Enddo
Additional information on:
Each of the field components can either be a Number or a Matrix. It is permissable to specify 1 or 2 components of the field as Numbers and the other(s) as Matrices.
All components which are specified as Matrix, must have the same total size - they do not have to be 1-dimensional. If at least one component is specified as Matrix, then the output will be a 1-dimensional Matrix with length equal to the overall size of the arguments of type Matrix. Otherwise the result will be a Number.
The electric field should be in V/cm, the diffusion is returned in sqrt(cm).
SIGMA_T can be used as a synonym for TRANSVERSE_DIFFUSION.
Format:
CALL TRANSVERSE_DIFFUSION(ex, ey, ez, sigma_t)
This component is zero when there is no magnetic field.
Each of the field components can either be a Number or a Matrix. It is permissable to specify some components of the field as Numbers and the other(s) as Matrices.
All components which are specified as Matrix, must have the same total size - they do not have to be 1-dimensional. If at least one component is specified as Matrix, then the output will be a 1-dimensional Matrix with length equal to the overall size of the arguments of type Matrix. Otherwise the result will be a Number.
The electric field should be in V/cm, the magnetic field has to be in native units of 100 G or 0.01 T, and the drift velocity is returned in cm/microsec.
Format:
CALL VELOCITY_BTRANSVERSE(ex, ey, ez, bx, by, bz, drift)
If there is no magnetic field, then the magnetic field must not be specified. In this case, the values returned by this procedure coincide with those returned by DRIFT_VELOCITY.
Each of the field components can either be a Number or a Matrix. It is permissable to specify some components of the field as Numbers and the other(s) as Matrices.
All components which are specified as Matrix, must have the same total size - they do not have to be 1-dimensional. If at least one component is specified as Matrix, then the output will be a 1-dimensional Matrix with length equal to the overall size of the arguments of type Matrix. Otherwise the result will be a Number.
The electric field should be in V/cm, the magnetic field has to be in native units of 100 G or 0.01 T, and the drift velocity is returned in cm/microsec.
Format:
CALL VELOCITY_E(ex, ey, ez, [bx, by, bz,] drift)
Example:
&GAS magboltz argon 92 co2 8 e/p-range 0.05 8&MAIN Global emin=60 Global emax=7000 Global n=200 Global e=emin*(emax/emin)**((row(n)-1)/(n-1)) Call drift_velocity(0,0,e,v) !opt log-x Call plot_graph(e,v,`E [V/cm]`,`Drift velocity [cm/microsec]`, ... `Magboltz vs Zhao et al.`) Vector ezhao 0.07 0.14 0.21 0.28 0.35 0.42 0.49 0.559 0.629 0.699 0.769 0.839 0.909 0.979 1.049 1.119 1.189 1.259 1.329 1.399 1.573 1.748 1.923 2.098 2.448 2.797 3.147 3.497 3.846 4.196 4.545 4.895 5.245 5.735
Vector vzhao 0.52 1.15 1.89 2.77 3.56 4.18 4.57 4.78 4.82 4.79 4.71 4.62 4.53 4.43 4.35 4.3 4.26 4.23 4.2 4.2 4.2 4.24 4.29 4.36 4.49 4.57 4.59 4.58 4.56 4.5 4.47 4.44 4.4 4.4
Call plot_error_bar(ezhao*1000,vzhao,`circle`) Call plot_end
Magboltz is used to compute the drift velocity in a mixture of 92 % Argon and 8 % CO2. The results are compared with the measurements of T. Zhao et al., NIM A340 (1994) 485. The E > 3000 V/cm region is controversial, apart from that the two are in good agreement. This is an abridged version of http://consult.cern.ch/writeup/garfield/examples/gas/ArCO2_detail.html
This component is zero when there is no magnetic field.
Each of the field components can either be a Number or a Matrix. It is permissable to specify some components of the field as Numbers and the other(s) as Matrices.
All components which are specified as Matrix, must have the same total size - they do not have to be 1-dimensional. If at least one component is specified as Matrix, then the output will be a 1-dimensional Matrix with length equal to the overall size of the arguments of type Matrix. Otherwise the result will be a Number.
The electric field should be in V/cm, the magnetic field has to be in native units of 100 G or 0.01 T, and the drift velocity is returned in cm/microsec.
Format:
CALL VELOCITY_ExB(ex, ey, ez, bx, by, bz, drift)
This routine differs from WEIGHTING_FIELD_3 in that it expects only the (x,y) part of the location, assuming z=0.
This procedure should be called from within the signal section.
Format:
CALL WEIGHTING_FIELD(x, y, ex, ey, ez, electrode)
Additional information on:
This procedure differs from WEIGHTING_FIELD in that it expects an (x,y,z) set of coordinates.
This procedure should be called from within the signal section.
Format:
CALL WEIGHTING_FIELD_3(x, y, z, ex, ey, ez, electrode)
Additional information on:
Histograms can, by means of the WRITE_HISTOGRAM_RZ procedure, also be written out in a format suitable for use with PAW.
Calling this procedure does not interfere with filling of the histogram and an autorange histogram can be written to disk before the range has been set.
This procedure is for instance used when one job fills a set of histograms which are, probably repeatedly, fitted by another job. Another application is a found in calculations where statistics are accumulated over a series of jobs. The first job would create the histogram and fill it, all successive jobs read the existing histogram, continue filling it, and write it back to the file at the end of the job. Care should be taken that the global option DELETE-OLD-MEMBER has been switched on before doing this.
Format:
CALL WRITE_HISTOGRAM(reference, file [, member [, remark]])
Example:
Global chamber=1(calculation of e.g. arrival time histograms for chamber 1)
Global hfile `CHAMBER`/string(chamber)/`.HIST` Global i=0 Global exist=True Global n=0 While exist Do Global i=i+1 Call inquire_histogram(reference(i),exist) If exist Then Call write_histogram(reference(i),hfile) Global n=n+1 Endif Enddo Say "Have written {n} histograms."
In this example, the input file is assumed to contain a cell section that enters the elements for chambers 1, 2, etc depending on the setting of the global variable "chamber".
At the end of the run, the user wishes to keep all histograms for further examination. The loop in the example writes all histograms to a file (hfile) the name of which is CHAMBER1.HIST, CHAMBER2.HIST etc. depending on the setting of the global variable "chamber".
All histograms are written to the same file, but they will be distinguished by their member names which are defaulted to the name of the global variables associated with the histogram.
This example assumes that no histograms have been deleted during the run, as it assumes the histograms are numbered from 1 on.
Additional information on:
An autorange histogram can only be written out to an RZ file once its range has been established.
Format:
CALL WRITE_HISTOGRAM_RZ([reference [, file [, title]]])
Example:
Call book_histogram(a,200) For i From 1 To 10000 Do Call fill_histogram(a,rnd_landau) Enddo Call plot_histogram(a,`Energy`,`Landau`) Call plot_end Call write_histogram_rz(a,`hist.rz`,`Landau distribution`)
This generates an histogram with a Landau distribution and writes the histogram to a file called "hist.rz". Garfield replies telling that the histogram has been written with PAW identifier 1 and cycle number 1. To read it back with PAW, one would type:
h/file 20 hist.rz h/pl 1
Additional information on:
The Garfield WWW example pages contain a Matlab function that reads a file written by WRITE_MATRIX (contributed by Guy Garty): http://consult.cern.ch/writeup/garfield/examples/load_garf.m
Format:
CALL WRITE_MATRIX(matrix, file [, member])
Example:
If 'type(global(`ABC`))#`Matrix`' Then Call inquire_member(`abc.mat`,`abc`,`matrix`,exist) If exist Then Call get_matrix(abc,`abc.mat`) Call dimensions(abc,n_dim,dim_abc) Global nx=number(dim_abc[1]) Global ny=number(dim_abc[2]) Call delete_matrix(dim_abc) Else Global nx=20 Global ny=30 Call book_matrix(abc,nx,ny) For i From 1 To nx Do For j From 1 To ny Do Global abc[i;j]=sin(i)*exp(j/10) Enddo Enddo Call write_matrix(abc,`abc.mat`) Endif Endif
First, one checks whether ABC is already in memory. If it is, nothing is done. Otherwise, an attempt is made to recuperate the matrix from a file. If this doesn't work, then the matrix is generated and stored in the file so that next time, the matrix can be recuperated from there.
Additional information on:
The procedure searches for zero crossings between 2 adjacent tabulated values, then performs a linear or quadratic interpolation over the neighbouring range.
Format:
CALL ZEROES(x_vector, y_vector, nzero, zero1, zero2, ...)
Example:
Global r=row(200)/10 Global v=sin(r) Call zeroes(r,v,nz,z1,z2,z3) Say "Zeroes: {nz} - {z1,z2,z3}"
Additional information on:
Formatted on 15/01/01 at 23:07.