-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtables.tex
More file actions
1179 lines (1031 loc) · 46.3 KB
/
tables.tex
File metadata and controls
1179 lines (1031 loc) · 46.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
\chapter{Table Handling Statements}
\label{chap:tables}
\section{CREATE}
\label{sec:create}
\madbox{
CREATE, TABLE=tabname, COLUMN= var\{, var\} \{, \_name\} ;
}
creates a table with the specified variables as columns.
The table created is initially empty and can be subsequently
\hyperref[sec:fill]{filled}, and eventually
\hyperref[sec:write]{written} to file in
\hyperref[chap:tfs]{\texttt{TFS}} format.
The special variable name attribute \texttt{\_name} (name preceded by
underscore) adds the element name to the table at the specified column.
\section{DELETE}
\label{sec:delete}
\madbox{
DELETE, SEQUENCE=seqname, TABLE=tabname;
}
deletes a sequence with name \texttt{seqname} or a table with name
\texttt{tabname} from memory. The sequence deletion is done without
influence on other sequences that may have elements that werein common
with the deleted sequence.
\section{READTABLE}
\label{sec:readtable}
\madbox{
READTABLE, FILE="filename", TABLE=tabname;
}
reads the \texttt{TFS} file \texttt{filename} containing a \mad table
loads the table into memory with the name \texttt{tabname}. If the table
name is not specified, use the name specified in the
information section of the TFS file. The table can then be manipulated
as any other table, \textsl{i.e.} its values can be accessed, its data
can be plotted or changed, and it can be written out again.
\section{READMYTABLE}
\label{sec:readmytable}
\madbox{
READMYTABLE, FILE="filename", TABLE=tabname;
}
deprecated alias for \texttt{READTABLE}.
\section{WRITE}
\label{sec:write}
\madbox{
WRITE, TABLE=tabname, FILE="filename";
}
writes the table "tabname" onto the file "filename"; only the rows and
columns of a preceding \texttt{SELECT, FLAG=table,...;} are written.
If no \texttt{SELECT} has been issued for this table, only the header is
written to file.
If the FILE argument is omitted, the table is written to standard output.
%\href{http://www.cern.ch/Hans.Grote/hansg_sign.html}{hansg}, June 17, 2002
\section{SETVARS}
\label{sec:setvars}
The \texttt{SETVARS} command sets the variables with values extracted
from the row of a table.
\madbox{
SETVARS, TABLE=tabname, ROW=integer;
}
The attributes of \texttt{SETVARS} are:
\begin{madlist}
\ttitem{TABLE} the name of the table. (Default: none)
\ttitem{ROW} the row number containing the values. (Default: -1)
\end{madlist}
Negative \texttt{ROW} values are allowed and count the row numbers from
the last row, allowing access to the table in reverse order of rows:
\texttt{ROW~=~-1} accesses the last row of the table,
\texttt{ROW~=~-2} accesses the penultimate (one before last) row,
etc\ldots
Trying to access the table forward beyond the last row, i.e. \texttt{ROW}
strictly greater than \texttt{nrow} the number of rows in the table, or
trying to access the table backwards before the first row, i.e. \texttt{ROW}
strictly lower than \texttt{-nrow}, or trying to access the illegal
\texttt{ROW=0}, all result in a ``row out of bound'' message and no
variable values are returned and set.
%% If \texttt{nrow} is the number of rows in the table, the conditions
%% \texttt{ROW $>$ nrow}, ie trying to access the table forward beyond the
%% last row, or \texttt{ROW $<$ -nrow}, ie trying to access the table
%% backwards before the first row, or \texttt{ROW=0}
%% result in a ``row out of bound'' message and no variable values are
%% returned and set.
\section{SETVARS\_LIN}
\label{sec:setvars-lin}
The \texttt{SETVARS\_LIN} command sets the variables with values calculated
by linear interpolation, or extrapolation, between two rows of a table.
\madbox{
SETVARS\_LIN, \=TABLE=tabname, \\
\>ROW1=integer, ROW2=integer, PARAM=string;
}
The attributes of \texttt{SETVARS\_LIN} are:
\begin{madlist}
\ttitem{TABLE} the name of the table. (Default: none)
\ttitem{ROW1} a first row number with values for interpolation. (Default: 0)
\ttitem{ROW2} a second row number with values for interpolation. (Default: 0)
\ttitem{PARAM} a string containing the linear interpolation factor or
the name of a variable or expression containing the interpolation
factor. If the resulting value of \texttt{PARAM} is outside the
$[0,1]$ interval, the result is a linear extrapolation. \\
(Default: "interp", itself defaulting to a value of 0.0 when evaluated)
\end{madlist}
\texttt{SETVARS\_LIN} sets the variables with values calculated through
the following formula that \madx constructs internally as a deferred
expression which is immediately evaluated:
\madxmp{value := value(row1)*(1-param) + value(row2)*param;}
Both the expression and the value of the expression are available to the
user through respectively the commands \hyperref[sec:show]{\texttt{SHOW}}
and \hyperref[sec:value]{\texttt{VALUE}}.
When the values are represented as strings, \textsl{e.g.} the name or
keyword of elements, the resulting value is the string in \texttt{ROW1}.
Negative \texttt{ROW\textit{i}} values are allowed and count the row
numbers from the last row, allowing access to the table in reverse order
of rows:
\texttt{ROW\textit{i}~=~-1} accesses the last row of the table,
\texttt{ROW\textit{i}~=~-2} accesses the penultimate (one before last)
row, etc\ldots
Trying to access the table forward beyond the last row,
i.e. \texttt{ROW\textit{i}} strictly greater than \texttt{nrow} the
number of rows in the table, or trying to access the table backwards
before the first row, i.e. \texttt{ROW\textit{i}} strictly lower than
\texttt{-nrow}, or trying to access the illegal
\texttt{ROW\textit{i}=0}, all result in a ``row out of bound'' message
and the expression is not constructed or evaluated.
\textbf{Example:}
\madxmp{
! extracts the position of the centre of each element from a standard \\
! TWISS table giving positions at end of elements: \\
len = table(twiss,tablelength); \\
interpolate = 0.5; \\
i = 2;\\
WHILE \=(i < len) \{ \\
\>SETVARS\_LIN, TABLE=twiss, ROW1=i-1, ROW2=i, PARAM=interpolate; \\
\>! now variables are interpolated at the center of the elements. \\
\>! in particular S holds the position of the center of the element. \\
\>SHOW, s; VALUE, s; \\
\>\ldots \\
\>i = i + 1; \};
}
\section{SETVARS\_KNOB}
\label{sec:setvars-knob}
The \texttt{SETVARS\_KNOB} command creates or manipulates the expression for the variables by adding a term \texttt{"+ val * knob"} where val is extracted from the row of a table and knob from the command.
\madbox{
SETVARS, TABLE=tabname, ROW=integer, KNOB=knobname;
}
The attributes of \texttt{SETVARS} are:
\begin{madlist}
\ttitem{TABLE} the name of the table. (Default: none)
\ttitem{ROW} the row number containing the values. (Default: -1)
\ttitem{KNOB} the name of the knob. (Default: none)
\ttitem{NOAPPEND} when true the term is not appended but replace the exisint value or expression.
\end{madlist}
Negative \texttt{ROW} values are allowed and count the row numbers from
the last row, allowing access to the table in reverse order of rows:
\texttt{ROW~=~-1} accesses the last row of the table,
\texttt{ROW~=~-2} accesses the penultimate (one before last) row,
etc\ldots
\section{SETVARS\_CONST}
\label{sec:setvars-const}
The \texttt{SETVARS\_CONST} sets the value for the variables to constant.
\madbox{
SETVARS, TABLE=tabname, CONST=value;
}
The attributes of \texttt{SETVARS} are:
\begin{madlist}
\ttitem{TABLE} the name of the table. (Default: none)
\ttitem{CONST} the value used to set the variables. (Default: 0)
\end{madlist}
\section{FILL}
\label{sec:fill}
The \texttt{FILL} command fills a row of a table with the current values
of all declared column variables of the table.
\madbox{
FILL, TABLE=tabname, ROW=integer;
}
The \texttt{FILL} command takes two arguments:
\begin{madlist}
\ttitem{TABLE} is the name of the table to be filled. The table must
have been \hyperref[sec:create]{created} beforehand.
The table can then be \hyperref[sec:write]{written} to file in
\texttt{TFS} format.
\ttitem{ROW} is the row number to be filled with the current values of
all column variables. \\
\texttt{ROW=0}, or \texttt{ROW=nrow + 1}, where \texttt{nrow} is the
current number of rows in the table, causes \texttt{FILL} to add a row at
the end of the table and fill it with the current values of all
column variables. \\ (Default: 0)
\end{madlist}
Negative \texttt{ROW} values are allowed and count the row numbers from
the last row, allowing access to the table in reverse order of rows:
\texttt{ROW = -1} accesses the last row of the table,
\texttt{ROW = -2} accesses the penultimate (one before last) row,
etc\ldots
Trying to access the table forward beyond the last row, i.e. \texttt{ROW}
strictly greater than \texttt{nrow + 1}, where \texttt{nrow} is the number of
rows in the table, or trying to access the table backwards before the
first row, i.e. \texttt{ROW} strictly lower than \texttt{-nrow}, both
result in a ``row out of bound'' message and no values are filled in the
table.
%% If \texttt{nrow} is the number of rows in the table, the conditions
%% \texttt{ROW $>$ nrow}, ie trying to access the table forward beyond the
%% last row, or \texttt{ROW $<$ -nrow}, ie trying to access the table
%% backwards before the first row, result in a ``row out of bound'' message
%% and no values are filled in the table.
\textbf{Reminder:} One can get access to the current number of rows in a
table using the variable \madxmp{TABLE(tablenanme, TABLELENGTH)}
%% See as well the \href{../Introduction/select.html#ucreate}{user
%% table} example.
\section{FILL\_KNOB}
\label{sec:fill-knob}
The \texttt{FILL\_KNOB} command fills a row of a table with the variation (multiplied by scaling factor) of all declared column variables of the table when the knob value change by 1.
\madbox{
FILL, TABLE=tabname, ROW=integer, KNOB=knobname, SCALE=scaling;
}
The \texttt{FILL} command takes two arguments:
\begin{madlist}
\ttitem{TABLE} is the name of the table to be filled. The table must
have been \hyperref[sec:create]{created} beforehand.
\ttitem{ROW} is the row number to be filled with the current values of
all column variables. \\
\texttt{ROW=0}, or \texttt{ROW=nrow + 1}, where \texttt{nrow} is the
current number of rows in the table, causes \texttt{FILL} to add a row at
the end of the table and fill it with the current values of all
column variables. \\ (Default: 0)
\ttitem{KNOB} the name of the variable that is varied to calculate the values to fill a table.
\ttitem{SCALE} scaling factor applied to all the variation calculated by varying the knob.
\end{madlist}
\section{SHRINK}
\label{sec:shrink}
The \texttt{SHRINK} command removes a number of rows at the end of a table.
\madbox{
SHRINK, TABLE=tabname, ROW=integer;
}
The \texttt{SHRINK} command takes two arguments:
\begin{madlist}
\ttitem{TABLE} is the name of the table from which rows should be removed.
The table must have been previously \hyperref[sec:create]{created} and
\hyperref[sec:fill]{filled} or read from file with
\hyperref[sec:readtable]{\texttt{READTABLE}}.
\ttitem{ROW} is the number of the last row to be kept in the table.
All rows beyond the given row number are removed. \\
Negative values are allowed and count the row numbers from
the last row, allowing access to the table in reverse order of rows:
\texttt{ROW~=~-1} removes the last row of the table,
\texttt{ROW~=~-2} removes the last two rows of the table,
etc\ldots \\
(Default: -1)
\end{madlist}
Trying to access the table forward beyond the last row, i.e. \texttt{ROW}
strictly greater than \texttt{nrow}, where \texttt{nrow} is the number of
rows in the table, or trying to access the table backwards before the
first row, \textsl{i.e.} \texttt{ROW} strictly lower than \texttt{-nrow},
both result in a ``row out of bound'' message and no values are filled
in the table.
%% \section{SELECT}
%% \label{sec:select}
%% \begin{verbatim}
%% select, flag=string, range=string, class=string, pattern=string,
%% sequence=string, full, clear,
%% column = string{, string}, slice=integer, thick=logical;
%% \end{verbatim}
%% selects one or several elements for special treatment in a subsequent
%% command based on selection criteria.
%% The selection criteria on a single SELECT statement are logically
%% ANDed, in other words, selected elements have to fulfill the \texttt{RANGE},
%% \texttt{CLASS}, and \texttt{PATTERN} criteria.
%% The selection criteria on different SELECT statements are logically
%% ORed, in other words selected elements have to fulfill any of the
%% selection criteria accumulated by the different statements.
%% All selections for a given command remain valid until the "clear" argument
%% is specified;
%% The "flag" argument allows a determination of the applicability of the
%% SELECT statement and can be one of the following:
%% \begin{madlist}
%% \ttitem{seqedit} selection of elements for the
%% \href{seqedit.html}{seqedit} module.
%% \ttitem{error} selection of elements for the
%% \href{../error/error.html}{error} assignment module.
%% \ttitem{makethin} selection of elements for the
%% \href{../makethin/makethin.html}{makethin} module that
%% converts the sequence into one with thin elements only.
%% \ttitem{sectormap} selection of elements for the
%% \href{../Introduction/sectormap.html}{sectormap} output file
%% from the Twiss module.
%% \ttitem{save} selection of elements for the \texttt{SAVE} command.
%% \ttitem{table} is a table name such as \texttt{twiss}, \texttt{track}
%% etc., and the rows and columns to be written are selected.
%% \end{madlist}
%% The statement
%% \begin{verbatim}
%% SELECT, FLAG=name, FULL;
%% \end{verbatim}
%% selects ALL positions in the sequence for the flag "name". This is the default
%% for flags for all tables and \texttt{MAKETHIN}.
%% The statement
%% \begin{verbatim}
%% SELECT, FLAG=name, CLEAR;
%% \end{verbatim}
%% deselects ALL positions in the sequence for the flag "name". This is the default
%% for flags \texttt{ERROR} and \texttt{SEQEDIT}.
%% "slice" is only used by \href{../makethin/makethin.html}{makethin} and
%% prescribes the number of slices into which the selected elements have to
%% be cut (default = 1).
%% "column" is only valid for tables and determines the selection of columns
%% to be written into the TFS file. The "name" argument is special in that
%% it refers to the actual name of the selected element. For an example,
%% see \href{../Introduction/select.html}{SELECT}.
%% "thick" is used to determine whether the selected elements will be
%% treated as thick elements by the MAKETHIN command. This only applies to
%% QUADRUPOLES and BENDS for which thick maps have been explicitely
%% derived. (see ...)
%% %%2014-Apr-08 17:43:44 ghislain: A completer.
%% Example:
%% \begin{verbatim}
%% select, flag = error, class = quadrupole, range = mb[1]/mb[5];
%% select, flag = error, pattern = "^mqw.*";
%% \end{verbatim}
%% selects all quadrupoles in the range mb[1] to mb[5], as well as all
%% elements (in the whole sequence) with name starting with "mqw", for
%% treatment by the error module.
%% Example:
%% \begin{verbatim}
%% select, flag=save, class=variable, pattern="abc.*";
%% save, file=mysave;
%% \end{verbatim}
%% will save all variables containing "abc" in their name.
%% However note that since the element class "variable" does not exist, any
%% element with name containing "abc" will not be saved.
%% \vskip 1cm
%% \hrule
%% \vskip 1cm
%% %% Imported from chapter 2
%% %\subsection{Selection Statements}
%% The elements, or a range of elements, in a sequence can be selected for
%% various purposes. Such selections remain valid until cleared (in
%% difference to \madeight); it is therefore recommended to always start with a
%% \begin{verbatim}
%% select, flag =..., clear;
%% \end{verbatim}
%% before setting a new selection.
%% \begin{verbatim}
%% SELECT, FLAG=name, RANGE=range, CLASS=class, PATTERN=pattern [,FULL] [,CLEAR];
%% \end{verbatim}
%% where the name for FLAG can be one of ERROR, MAKETHIN, SEQEDIT or the
%% name of a twiss table which is established for all sequence positions in
%% general.
%% Selected elements have to fulfill the \href{ranges.html#range}{RANGE},
%% \href{ranges.html#class}{CLASS}, and \href{wildcard.html}{PATTERN}
%% criteria.
%% Any number of SELECT commands can be issued for the same flag and are
%% accumulated (logically ORed). In this context note the following:
%% \begin{verbatim}
%% SELECT, FLAG=name, FULL;
%% \end{verbatim}
%% selects all positions in the sequence for this flag. This is the default
%% for all tables and makethin, whereas for ERROR and SEQEDIT the default
%% is "nothing selected".
%% %\href{save_select}{}
%% \label{save_select}
%% SAVE: A SELECT,FLAG=SAVE statement causes the
%% selected sequences, elements, and variables to be written into the save
%% file. A class (only used for element selection), and a pattern can be
%% specified. Example:
%% \begin{verbatim}
%% select, flag=save, class=variable, pattern="abc.*";
%% save, file=mysave;
%% \end{verbatim}
%% will save all variables containing "abc" in their name,
%% but not elements with names containing "abc" since the class "variable"
%% does not exist (astucieux, non ?).
%% SECTORMAP: A SELECT,FLAG=SECTORMAP statement causes sectormaps to be
%% written into the file "sectormap" like in \madeight. For the file to be
%% written, a flag SECTORMAP must be issued on the TWISS command in
%% addition.
%% TWISS: A SELECT,FLAG=TWISS statement causes the selected rows and
%% columns to be written into the Twiss TFS file (former OPTICS command in
%% \madeight). The column selection is done on the same select. See as well
%% example 2.
%% %% Example 1:
%% %% \begin{verbatim}
%% %% TITLE,'Test input for MAD-X';
%% %% option,rbarc=false; // use arc length of rbends
%% %% beam; ! sets the default beam for the following sequence
%% %% option,-echo;
%% %% call file=fv9.opt; ! contains optics parameters
%% %% call file="fv9.seq"; ! contains a small sequence "fivecell"
%% %% OPTION,ECHO;
%% %% SELECT,FLAG=SECTORMAP,clear;
%% %% SELECT,FLAG=SECTORMAP,PATTERN="^m.*";
%% %% SELECT,FLAG=TWISS,clear;
%% %% SELECT,FLAG=TWISS,PATTERN="^m.*",column=name,s,betx,bety;
%% %% USE,PERIOD=FIVECELL;
%% %% twiss,file=optics,sectormap;
%% %% stop;
%% %% \end{verbatim}
%% %% This produces a file \href{sectormap.html}{sectormap}, and a
%% %% twiss output file \label{tfs} (name = optics):
%% %% \begin{verbatim}
%% %% @ TYPE %05s "TWISS"
%% %% @ PARTICLE %08s "POSITRON"
%% %% @ MASS %le 0.000510998902
%% %% @ CHARGE %le 1
%% %% @ E0 %le 1
%% %% @ PC %le 0.99999986944
%% %% @ GAMMA %le 1956.95136738
%% %% @ KBUNCH %le 1
%% %% @ NPART %le 0
%% %% @ EX %le 1
%% %% @ EY %le 1
%% %% @ ET %le 0
%% %% @ LENGTH %le 534.6
%% %% @ ALFA %le 0.00044339992938
%% %% @ ORBIT5 %le -0
%% %% @ GAMMATR %le 47.4900022541
%% %% @ Q1 %le 1.25413071556
%% %% @ Q2 %le 1.25485338377
%% %% @ DQ1 %le 1.05329608302
%% %% @ DQ2 %le 1.04837000224
%% %% @ DXMAX %le 2.17763211131
%% %% @ DYMAX %le 0
%% %% @ XCOMAX %le 0
%% %% @ YCOMAX %le 0
%% %% @ BETXMAX %le 177.70993499
%% %% @ BETYMAX %le 177.671582415
%% %% @ XCORMS %le 0
%% %% @ YCORMS %le 0
%% %% @ DXRMS %le 1.66004270906
%% %% @ DYRMS %le 0
%% %% @ DELTAP %le 0
%% %% @ TITLE %20s "Test input for MAD-X"
%% %% @ ORIGIN %16s "MAD-X 0.20 Linux"
%% %% @ DATE %08s "07/06/02"
%% %% @ TIME %08s "14.25.51"
%% %% * NAME S BETX BETY
%% %% $ %s %le %le %le
%% %% "MSCBH" 4.365 171.6688159 33.31817319
%% %% "MB" 19.72 108.1309095 58.58680717
%% %% "MB" 35.38 61.96499987 102.9962313
%% %% "MB" 51.04 34.61640793 166.2227523
%% %% "MSCBV.1" 57.825 33.34442808 171.6309057
%% %% "MB" 73.18 58.61984637 108.0956006
%% %% "MB" 88.84 103.0313887 61.93159422
%% %% "MB" 104.5 166.2602486 34.58939635
%% %% "MSCBH" 111.285 171.6688159 33.31817319
%% %% "MB" 126.64 108.1309095 58.58680717
%% %% "MB" 142.3 61.96499987 102.9962313
%% %% "MB" 157.96 34.61640793 166.2227523
%% %% "MSCBV" 164.745 33.34442808 171.6309057
%% %% "MB" 180.1 58.61984637 108.0956006
%% %% "MB" 195.76 103.0313887 61.93159422
%% %% "MB" 211.42 166.2602486 34.58939635
%% %% "MSCBH" 218.205 171.6688159 33.31817319
%% %% "MB" 233.56 108.1309095 58.58680717
%% %% "MB" 249.22 61.96499987 102.9962313
%% %% "MB" 264.88 34.61640793 166.2227523
%% %% "MSCBV" 271.665 33.34442808 171.6309057
%% %% "MB" 287.02 58.61984637 108.0956006
%% %% "MB" 302.68 103.0313887 61.93159422
%% %% "MB" 318.34 166.2602486 34.58939635
%% %% "MSCBH" 325.125 171.6688159 33.31817319
%% %% "MB" 340.48 108.1309095 58.58680717
%% %% "MB" 356.14 61.96499987 102.9962313
%% %% "MB" 371.8 34.61640793 166.2227523
%% %% "MSCBV" 378.585 33.34442808 171.6309057
%% %% "MB" 393.94 58.61984637 108.0956006
%% %% "MB" 409.6 103.0313887 61.93159422
%% %% "MB" 425.26 166.2602486 34.58939635
%% %% "MSCBH" 432.045 171.6688159 33.31817319
%% %% "MB" 447.4 108.1309095 58.58680717
%% %% "MB" 463.06 61.96499987 102.9962313
%% %% "MB" 478.72 34.61640793 166.2227523
%% %% "MSCBV" 485.505 33.34442808 171.6309057
%% %% "MB" 500.86 58.61984637 108.0956006
%% %% "MB" 516.52 103.0313887 61.93159422
%% %% "MB" 532.18 166.2602486 34.58939635
%% %% \end{verbatim}
%% %% Example 2:
%% %% Addition of variables to (any internal) table:
%% %% \begin{verbatim}
%% %% select, flag=table, column=name, s, betx, ..., var1, var2, ...; ! or
%% %% select, flag=table, full, column=var1, var2, ...; ! default col.s + new
%% %% \end{verbatim}
%% %% will write the current value of var1 etc. into the table each time a new
%% %% line is added; values from the same (current) line can be accessed by
%% %% these variables, e.g.
%% %% \begin{verbatim}
%% %% var1 := sqrt(beam->ex*table(twiss,betx));
%% %% \end{verbatim}
%% %% in the case of table above being "twiss". The plot command accepts the
%% %% new variables.
%% %% Remark: this replaces the "string" variables of MAD-8.
%% %% This example demonstrates as well the usage of a user defined table \label{ucreate}.
%% %% \begin{verbatim}
%% %% beam,ex=1.e-6,ey=1.e-3;
%% %% // element definitions
%% %% mb:rbend, l=14.2, angle:=0,k0:=bang/14.2;
%% %% mq:quadrupole, l:=3.1,apertype=ellipse,aperture={1,2};
%% %% qft:mq, l:=0.31, k1:=kqf,tilt=-pi/4;
%% %% qf.1:mq, l:=3.1, k1:=kqf;
%% %% qf.2:mq, l:=3.1, k1:=kqf;
%% %% qf.3:mq, l:=3.1, k1:=kqf;
%% %% qf.4:mq, l:=3.1, k1:=kqf;
%% %% qf.5:mq, l:=3.1, k1:=kqf;
%% %% qd.1:mq, l:=3.1, k1:=kqd;
%% %% qd.2:mq, l:=3.1, k1:=kqd;
%% %% qd.3:mq, l:=3.1, k1:=kqd;
%% %% qd.4:mq, l:=3.1, k1:=kqd;
%% %% qd.5:mq, l:=3.1, k1:=kqd;
%% %% bph:hmonitor, l:=l.bpm;
%% %% bpv:vmonitor, l:=l.bpm;
%% %% cbh:hkicker;
%% %% cbv:vkicker;
%% %% cbh.1:cbh, kick:=acbh1;
%% %% cbh.2:cbh, kick:=acbh2;
%% %% cbh.3:cbh, kick:=acbh3;
%% %% cbh.4:cbh, kick:=acbh4;
%% %% cbh.5:cbh, kick:=acbh5;
%% %% cbv.1:cbv, kick:=acbv1;
%% %% cbv.2:cbv, kick:=acbv2;
%% %% cbv.3:cbv, kick:=acbv3;
%% %% cbv.4:cbv, kick:=acbv4;
%% %% cbv.5:cbv, kick:=acbv5;
%% %% !mscbh:sextupole, l:=1.1, k2:=ksf;
%% %% mscbh:multipole, knl:={0,0,0,ksf},tilt=-pi/8;
%% %% mscbv:sextupole, l:=1.1, k2:=ksd;
%% %% !mscbv:octupole, l:=1.1, k3:=ksd,tilt=-pi/8;
%% %% // sequence declaration
%% %% fivecell:sequence, refer=centre, l=534.6;
%% %% qf.1:qf.1, at=1.550000e+00;
%% %% qft:qft, at=3.815000e+00;
%% %% ! mscbh:mscbh, at=3.815000e+00;
%% %% cbh.1:cbh.1, at=4.365000e+00;
%% %% mb:mb, at=1.262000e+01;
%% %% mb:mb, at=2.828000e+01;
%% %% mb:mb, at=4.394000e+01;
%% %% bpv:bpv, at=5.246000e+01;
%% %% qd.1:qd.1, at=5.501000e+01;
%% %% mscbv:mscbv, at=5.727500e+01;
%% %% cbv.1:cbv.1, at=5.782500e+01;
%% %% mb:mb, at=6.608000e+01;
%% %% mb:mb, at=8.174000e+01;
%% %% mb:mb, at=9.740000e+01;
%% %% bph:bph, at=1.059200e+02;
%% %% qf.2:qf.2, at=1.084700e+02;
%% %% mscbh:mscbh, at=1.107350e+02;
%% %% cbh.2:cbh.2, at=1.112850e+02;
%% %% mb:mb, at=1.195400e+02;
%% %% mb:mb, at=1.352000e+02;
%% %% mb:mb, at=1.508600e+02;
%% %% bpv:bpv, at=1.593800e+02;
%% %% qd.2:qd.2, at=1.619300e+02;
%% %% mscbv:mscbv, at=1.641950e+02;
%% %% cbv.2:cbv.2, at=1.647450e+02;
%% %% mb:mb, at=1.730000e+02;
%% %% mb:mb, at=1.886600e+02;
%% %% mb:mb, at=2.043200e+02;
%% %% bph:bph, at=2.128400e+02;
%% %% qf.3:qf.3, at=2.153900e+02;
%% %% mscbh:mscbh, at=2.176550e+02;
%% %% cbh.3:cbh.3, at=2.182050e+02;
%% %% mb:mb, at=2.264600e+02;
%% %% mb:mb, at=2.421200e+02;
%% %% mb:mb, at=2.577800e+02;
%% %% bpv:bpv, at=2.663000e+02;
%% %% qd.3:qd.3, at=2.688500e+02;
%% %% mscbv:mscbv, at=2.711150e+02;
%% %% cbv.3:cbv.3, at=2.716650e+02;
%% %% mb:mb, at=2.799200e+02;
%% %% mb:mb, at=2.955800e+02;
%% %% mb:mb, at=3.112400e+02;
%% %% bph:bph, at=3.197600e+02;
%% %% qf.4:qf.4, at=3.223100e+02;
%% %% mscbh:mscbh, at=3.245750e+02;
%% %% cbh.4:cbh.4, at=3.251250e+02;
%% %% mb:mb, at=3.333800e+02;
%% %% mb:mb, at=3.490400e+02;
%% %% mb:mb, at=3.647000e+02;
%% %% bpv:bpv, at=3.732200e+02;
%% %% qd.4:qd.4, at=3.757700e+02;
%% %% mscbv:mscbv, at=3.780350e+02;
%% %% cbv.4:cbv.4, at=3.785850e+02;
%% %% mb:mb, at=3.868400e+02;
%% %% mb:mb, at=4.025000e+02;
%% %% mb:mb, at=4.181600e+02;
%% %% bph:bph, at=4.266800e+02;
%% %% qf.5:qf.5, at=4.292300e+02;
%% %% mscbh:mscbh, at=4.314950e+02;
%% %% cbh.5:cbh.5, at=4.320450e+02;
%% %% mb:mb, at=4.403000e+02;
%% %% mb:mb, at=4.559600e+02;
%% %% mb:mb, at=4.716200e+02;
%% %% bpv:bpv, at=4.801400e+02;
%% %% qd.5:qd.5, at=4.826900e+02;
%% %% mscbv:mscbv, at=4.849550e+02;
%% %% cbv.5:cbv.5, at=4.855050e+02;
%% %% mb:mb, at=4.937600e+02;
%% %% mb:mb, at=5.094200e+02;
%% %% mb:mb, at=5.250800e+02;
%% %% bph:bph, at=5.336000e+02;
%% %% end:marker, at=5.346000e+02;
%% %% endsequence;
%% %% // forces and other constants
%% %% l.bpm:=.3;
%% %% bang:=.509998807401e-2;
%% %% kqf:=.872651312e-2;
%% %% kqd:=-.872777242e-2;
%% %% ksf:=.0198492943;
%% %% ksd:=-.039621283;
%% %% acbv1:=1.e-4;
%% %% acbh1:=1.e-4;
%% %% !save,sequence=fivecell,file,mad8;
%% %% s := table(twiss,bpv[5],betx);
%% %% myvar := sqrt(beam->ex*table(twiss,betx));
%% %% use, period=fivecell;
%% %% select,flag=twiss,column=name,s,myvar,apertype;
%% %% twiss,file;
%% %% n = 0;
%% %% create,table=mytab,column=dp,mq1,mq2;
%% %% mq1:=table(summ,q1);
%% %% mq2:=table(summ,q2);
%% %% while ( n < 11)
%% %% {
%% %% n = n + 1;
%% %% dp = 1.e-4*(n-6);
%% %% twiss,deltap=dp;
%% %% fill,table=mytab;
%% %% }
%% %% write,table=mytab;
%% %% plot,haxis=s,vaxis=aper_1,aper_2,colour=100,range=#s/cbv.1,notitle;
%% %% stop;
%% %% \end{verbatim}
%% %% prints the following user table on output:
%% %% \begin{verbatim}
%% %% @ NAME %05s "MYTAB"
%% %% @ TYPE %04s "USER"
%% %% @ TITLE %08s "no-title"
%% %% @ ORIGIN %16s "MAD-X 1.09 Linux"
%% %% @ DATE %08s "10/12/02"
%% %% @ TIME %08s "10.45.25"
%% %% * DP MQ1 MQ2
%% %% $ %le %le %le
%% %% -0.0005 1.242535951 1.270211135
%% %% -0.0004 1.242495534 1.270197018
%% %% -0.0003 1.242452432 1.270185673
%% %% -0.0002 1.242406653 1.270177093
%% %% -0.0001 1.242358206 1.270171269
%% %% 0 1.242307102 1.27016819
%% %% 0.0001 1.242253353 1.270167843
%% %% 0.0002 1.242196974 1.270170214
%% %% 0.0003 1.24213798 1.270175288
%% %% 0.0004 1.242076387 1.270183048
%% %% 0.0005 1.242012214 1.270193477
%% %% \end{verbatim}
%% %% and produces a twiss file with the additional column myvar, as well as a plot
%% %% file with the aperture values plotted.
%% %% \href{screate}{}
%% %% Example of joining two tables with different length into a third table
%% %% making use of the length of either table as given by
%% %% table("your\_table\_name", tablelength) and adding names by the "\_name"
%% %% attribute.
%% %% \begin{verbatim}
%% %% title, "summing of offset and alignment tables";
%% %% set, format="13.6f";
%% %% readtable, table=align, file="align.ip2.b1.tfs"; // mesured alignment
%% %% readtable, table=offset, file="offset.ip2.b1.tfs"; // nominal offsets
%% %% n_elem = table(offset, tablelength);
%% %% create, table=align_offset, column=_name,s_ip,x_off,dx_off,ddx_off,y_off,dy_off,ddy_off;
%% %% calcul(elem_name) : macro = {
%% %% x_off = table(align, elem_name, x_ali) + x_off;
%% %% y_off = table(align, elem_name, y_ali) + y_off;
%% %% }
%% %% one_elem(j_elem) : macro = {
%% %% setvars, table=offset, row=j_elem;
%% %% exec, calcul(tabstring(offset, name, j_elem));
%% %% fill, table=align_offset;
%% %% }
%% %% i_elem = 0;
%% %% while (i_elem < n_elem) { i_elem = i_elem + 1; exec, one_elem($i_elem); }
%% %% write, table=align_offset, file="align_offset.tfs";
%% %% stop;
%% %% \end{verbatim}
%% %%
%% %\input{Introduction/select}
%% \section{SELECT}
%% \label{sec:selection}
%% The elements, or a range of elements, in a sequence can be selected for
%% various purposes. Such selections remain valid until cleared (in
%% difference to \madeight); it is therefore recommended to always start with a
%% \begin{verbatim}
%% select, flag =..., clear;
%% \end{verbatim}
%% before setting a new selection.
%% \begin{verbatim}
%% SELECT, FLAG=name, RANGE=range, CLASS=class, PATTERN=pattern [,FULL] [,CLEAR];
%% \end{verbatim}
%% where the name for FLAG can be one of ERROR, MAKETHIN, SEQEDIT or the
%% name of a twiss table which is established for all sequence positions in
%% general.
%% Selected elements have to fulfill the \href{ranges.html#range}{RANGE},
%% \href{ranges.html#class}{CLASS}, and \href{wildcard.html}{PATTERN}
%% criteria.
%% Any number of SELECT commands can be issued for the same flag and are
%% accumulated (logically ORed). In this context note the following:
%% \begin{verbatim}
%% SELECT, FLAG=name, FULL;
%% \end{verbatim}
%% selects all positions in the sequence for this flag. This is the default
%% for all tables and makethin, whereas for ERROR and SEQEDIT the default
%% is "nothing selected".
%% %\href{save_select}{}
%% \label{save_select}
%% SAVE: A SELECT,FLAG=SAVE statement causes the
%% selected sequences, elements, and variables to be written into the save
%% file. A class (only used for element selection), and a pattern can be
%% specified. Example:
%% \begin{verbatim}
%% select, flag=save, class=variable, pattern="abc.*";
%% save, file=mysave;
%% \end{verbatim}
%% will save all variables containing "abc" in their name,
%% but not elements with names containing "abc" since the class "variable"
%% does not exist (astucieux, non ?).
%% SECTORMAP: A SELECT,FLAG=SECTORMAP statement causes sectormaps to be
%% written into the file "sectormap" like in \madeight. For the file to be
%% written, a flag SECTORMAP must be issued on the TWISS command in
%% addition.
%% TWISS: A SELECT,FLAG=TWISS statement causes the selected rows and
%% columns to be written into the Twiss TFS file (former OPTICS command in
%% \madeight). The column selection is done on the same select. See as well
%% example 2.
%% Example 1:
%% \begin{verbatim}
%% TITLE,'Test input for MAD-X';
%% option,rbarc=false; // use arc length of rbends
%% beam; ! sets the default beam for the following sequence
%% option,-echo;
%% call file=fv9.opt; ! contains optics parameters
%% call file="fv9.seq"; ! contains a small sequence "fivecell"
%% OPTION,ECHO;
%% SELECT,FLAG=SECTORMAP,clear;
%% SELECT,FLAG=SECTORMAP,PATTERN="^m.*";
%% SELECT,FLAG=TWISS,clear;
%% SELECT,FLAG=TWISS,PATTERN="^m.*",column=name,s,betx,bety;
%% USE,PERIOD=FIVECELL;
%% twiss,file=optics,sectormap;
%% stop;
%% \end{verbatim}
%% This produces a file \href{sectormap.html}{sectormap}, and a
%% twiss output file \label{tfs} (name = optics):
%% \begin{verbatim}
%% @ TYPE %05s "TWISS"
%% @ PARTICLE %08s "POSITRON"
%% @ MASS %le 0.000510998902
%% @ CHARGE %le 1
%% @ E0 %le 1
%% @ PC %le 0.99999986944
%% @ GAMMA %le 1956.95136738
%% @ KBUNCH %le 1
%% @ NPART %le 0
%% @ EX %le 1
%% @ EY %le 1
%% @ ET %le 0
%% @ LENGTH %le 534.6
%% @ ALFA %le 0.00044339992938
%% @ ORBIT5 %le -0
%% @ GAMMATR %le 47.4900022541
%% @ Q1 %le 1.25413071556
%% @ Q2 %le 1.25485338377
%% @ DQ1 %le 1.05329608302
%% @ DQ2 %le 1.04837000224
%% @ DXMAX %le 2.17763211131
%% @ DYMAX %le 0
%% @ XCOMAX %le 0
%% @ YCOMAX %le 0
%% @ BETXMAX %le 177.70993499
%% @ BETYMAX %le 177.671582415
%% @ XCORMS %le 0
%% @ YCORMS %le 0
%% @ DXRMS %le 1.66004270906
%% @ DYRMS %le 0
%% @ DELTAP %le 0
%% @ TITLE %20s "Test input for MAD-X"
%% @ ORIGIN %16s "MAD-X 0.20 Linux"
%% @ DATE %08s "07/06/02"
%% @ TIME %08s "14.25.51"
%% * NAME S BETX BETY
%% $ %s %le %le %le
%% "MSCBH" 4.365 171.6688159 33.31817319
%% "MB" 19.72 108.1309095 58.58680717
%% "MB" 35.38 61.96499987 102.9962313
%% "MB" 51.04 34.61640793 166.2227523
%% "MSCBV.1" 57.825 33.34442808 171.6309057
%% "MB" 73.18 58.61984637 108.0956006
%% "MB" 88.84 103.0313887 61.93159422
%% "MB" 104.5 166.2602486 34.58939635
%% "MSCBH" 111.285 171.6688159 33.31817319
%% "MB" 126.64 108.1309095 58.58680717
%% "MB" 142.3 61.96499987 102.9962313
%% "MB" 157.96 34.61640793 166.2227523
%% "MSCBV" 164.745 33.34442808 171.6309057
%% "MB" 180.1 58.61984637 108.0956006
%% "MB" 195.76 103.0313887 61.93159422
%% "MB" 211.42 166.2602486 34.58939635
%% "MSCBH" 218.205 171.6688159 33.31817319
%% "MB" 233.56 108.1309095 58.58680717
%% "MB" 249.22 61.96499987 102.9962313
%% "MB" 264.88 34.61640793 166.2227523
%% "MSCBV" 271.665 33.34442808 171.6309057
%% "MB" 287.02 58.61984637 108.0956006
%% "MB" 302.68 103.0313887 61.93159422
%% "MB" 318.34 166.2602486 34.58939635
%% "MSCBH" 325.125 171.6688159 33.31817319
%% "MB" 340.48 108.1309095 58.58680717
%% "MB" 356.14 61.96499987 102.9962313
%% "MB" 371.8 34.61640793 166.2227523
%% "MSCBV" 378.585 33.34442808 171.6309057
%% "MB" 393.94 58.61984637 108.0956006
%% "MB" 409.6 103.0313887 61.93159422
%% "MB" 425.26 166.2602486 34.58939635
%% "MSCBH" 432.045 171.6688159 33.31817319
%% "MB" 447.4 108.1309095 58.58680717
%% "MB" 463.06 61.96499987 102.9962313
%% "MB" 478.72 34.61640793 166.2227523
%% "MSCBV" 485.505 33.34442808 171.6309057
%% "MB" 500.86 58.61984637 108.0956006
%% "MB" 516.52 103.0313887 61.93159422
%% "MB" 532.18 166.2602486 34.58939635
%% \end{verbatim}
%% Example 2:
%% Addition of variables to (any internal) table:
%% \begin{verbatim}
%% select, flag=table, column=name, s, betx, ..., var1, var2, ...; ! or
%% select, flag=table, full, column=var1, var2, ...; ! default col.s + new
%% \end{verbatim}
%% will write the current value of var1 etc. into the table each time a new
%% line is added; values from the same (current) line can be accessed by
%% these variables, e.g.
%% \begin{verbatim}
%% var1 := sqrt(beam->ex*table(twiss,betx));
%% \end{verbatim}
%% in the case of table above being "twiss". The plot command accepts the
%% new variables.
%% Remark: this replaces the "string" variables of \madeight.
%% This example demonstrates as well the usage of a user defined table \label{ucreate}.
%% \begin{verbatim}
%% beam,ex=1.e-6,ey=1.e-3;
%% // element definitions
%% mb:rbend, l=14.2, angle:=0,k0:=bang/14.2;
%% mq:quadrupole, l:=3.1,apertype=ellipse,aperture={1,2};
%% qft:mq, l:=0.31, k1:=kqf,tilt=-pi/4;
%% qf.1:mq, l:=3.1, k1:=kqf;
%% qf.2:mq, l:=3.1, k1:=kqf;
%% qf.3:mq, l:=3.1, k1:=kqf;
%% qf.4:mq, l:=3.1, k1:=kqf;
%% qf.5:mq, l:=3.1, k1:=kqf;
%% qd.1:mq, l:=3.1, k1:=kqd;
%% qd.2:mq, l:=3.1, k1:=kqd;
%% qd.3:mq, l:=3.1, k1:=kqd;
%% qd.4:mq, l:=3.1, k1:=kqd;
%% qd.5:mq, l:=3.1, k1:=kqd;
%% bph:hmonitor, l:=l.bpm;
%% bpv:vmonitor, l:=l.bpm;
%% cbh:hkicker;
%% cbv:vkicker;
%% cbh.1:cbh, kick:=acbh1;
%% cbh.2:cbh, kick:=acbh2;
%% cbh.3:cbh, kick:=acbh3;
%% cbh.4:cbh, kick:=acbh4;
%% cbh.5:cbh, kick:=acbh5;
%% cbv.1:cbv, kick:=acbv1;
%% cbv.2:cbv, kick:=acbv2;
%% cbv.3:cbv, kick:=acbv3;
%% cbv.4:cbv, kick:=acbv4;
%% cbv.5:cbv, kick:=acbv5;
%% !mscbh:sextupole, l:=1.1, k2:=ksf;
%% mscbh:multipole, knl:={0,0,0,ksf},tilt=-pi/8;
%% mscbv:sextupole, l:=1.1, k2:=ksd;
%% !mscbv:octupole, l:=1.1, k3:=ksd,tilt=-pi/8;