1 | <head> |
---|
2 | <title>Range Selection</title> |
---|
3 | <!-- Changed by: Chris ISELIN, 27-Jan-1997 --> |
---|
4 | <!-- Changed by: Hans Grote, 10-Jun-2002 --> |
---|
5 | </head> |
---|
6 | |
---|
7 | <body bgcolor="#ffffff"> |
---|
8 | |
---|
9 | <center> |
---|
10 | EUROPEAN ORGANIZATION FOR NUCLEAR RESEARCH |
---|
11 | <IMG SRC="http://cern.ch/madx/icons/mx7_25.gif" align=right> |
---|
12 | <h4>Real life example for IF statements, and MACRO usage</h4> |
---|
13 | </center> |
---|
14 | <p> |
---|
15 | <pre> |
---|
16 | ! Creates a footprint for head-on + parasitic collisions at IP1+5 |
---|
17 | ! of lhc.6.5; both lhcb1 (for tracking) and lhcb2 (to define the |
---|
18 | ! beam-beam elements, i.e. weak-strong) are used; there are flags to |
---|
19 | ! select head-on, left, and right parasitic separately at all IPs. |
---|
20 | ! The bunch spacing can be given in nanosec and automatically creates |
---|
21 | ! the beam-beam interaction points at the correct positions. |
---|
22 | ! It is important to set the correct BEAM parameters, i.e. number |
---|
23 | ! of particles, emittances, bunch length, energy. |
---|
24 | |
---|
25 | !--- For completeness, all files needed by this job are copied |
---|
26 | ! to the local directory ldb. The links to the the originals |
---|
27 | ! in offdb (official database) are commented out. |
---|
28 | |
---|
29 | Option, warn,info,echo; |
---|
30 | !System, |
---|
31 | "ln -fns /afs/cern.ch/eng/sl/MAD-X/dev/test_suite/foot/V3.01.01 ldb"; |
---|
32 | !system,"ln -fns /afs/cern.ch/eng/lhc/optics/V6.4 offdb"; |
---|
33 | Option, -echo,-info,warn; |
---|
34 | SU=1.0; |
---|
35 | call, file = "ldb/V6.5.seq"; |
---|
36 | call,file="ldb/slice_new.madx"; |
---|
37 | Option, echo,info,warn; |
---|
38 | |
---|
39 | !+++++++++++++++++++++++++ Step 1 +++++++++++++++++++++++ |
---|
40 | ! define beam constants |
---|
41 | !++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
---|
42 | |
---|
43 | b_t_dist = 25.e-9; !--- bunch distance in [sec] |
---|
44 | b_h_dist = clight * b_t_dist / 2 ; !--- bunch half-distance in [m] |
---|
45 | ip1_range = 58.; ! range for parasitic collisions |
---|
46 | ip5_range = ip1_range; |
---|
47 | ip2_range = 60.; |
---|
48 | ip8_range = ip2_range; |
---|
49 | |
---|
50 | npara_1 = ip1_range / b_h_dist; ! # parasitic either side |
---|
51 | npara_2 = ip2_range / b_h_dist; |
---|
52 | npara_5 = ip5_range / b_h_dist; |
---|
53 | npara_8 = ip8_range / b_h_dist; |
---|
54 | |
---|
55 | value,npara_1,npara_2,npara_5,npara_8; |
---|
56 | |
---|
57 | eg = 7000; |
---|
58 | bg = eg/pmass; |
---|
59 | en = 3.75e-06; |
---|
60 | epsx = en/bg; |
---|
61 | epsy = en/bg; |
---|
62 | |
---|
63 | Beam, particle = proton, sequence=lhcb1, energy = eg, |
---|
64 | sigt= 0.077 , |
---|
65 | bv = +1, NPART=1.1E11, sige= 1.1e-4, |
---|
66 | ex=epsx, ey=epsy; |
---|
67 | |
---|
68 | Beam, particle = proton, sequence=lhcb2, energy = eg, |
---|
69 | sigt= 0.077 , |
---|
70 | bv = -1, NPART=1.1E11, sige= 1.1e-4, |
---|
71 | ex=epsx, ey=epsy; |
---|
72 | |
---|
73 | beamx = beam%lhcb1->ex; beamy%lhcb1 = beam->ey; |
---|
74 | sigz = beam%lhcb1->sigt; sige = beam%lhcb1->sige; |
---|
75 | |
---|
76 | !--- split5, 4d |
---|
77 | long_a= 0.53 * sigz/2; |
---|
78 | long_b= 1.40 * sigz/2; |
---|
79 | value,long_a,long_b; |
---|
80 | |
---|
81 | ho_charge = 0.2; |
---|
82 | |
---|
83 | !+++++++++++++++++++++++++ Step 2 +++++++++++++++++++++++ |
---|
84 | ! slice, flatten sequence, and cycle start to ip3 |
---|
85 | !++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
---|
86 | |
---|
87 | use,sequence=lhcb1; |
---|
88 | makethin,sequence=lhcb1; |
---|
89 | !save,sequence=lhcb1,file=lhcb1_thin_new_seq; |
---|
90 | use,sequence=lhcb2; |
---|
91 | makethin,sequence=lhcb2; |
---|
92 | !save,sequence=lhcb2,file=lhcb2_thin_new_seq; |
---|
93 | !stop; |
---|
94 | |
---|
95 | option,-warn,-echo,-info; |
---|
96 | call,file="ldb/V6.5.thin.coll.str"; |
---|
97 | option,warn,echo,info; |
---|
98 | |
---|
99 | ! keep sextupoles |
---|
100 | ksf0=ksf; ksd0=ksd; |
---|
101 | use,period=lhcb1; |
---|
102 | select,flag=twiss.1,column=name,x,y,betx,bety; |
---|
103 | twiss,file; |
---|
104 | plot,haxis=s,vaxis=x,y,colour=100,noline; |
---|
105 | |
---|
106 | use,period=lhcb2; |
---|
107 | select,flag=twiss.2,column=name,x,y,betx,bety; |
---|
108 | twiss,file; |
---|
109 | plot,haxis=s,vaxis=x,y,colour=100,noline; |
---|
110 | seqedit,sequence=lhcb1; |
---|
111 | flatten; |
---|
112 | endedit; |
---|
113 | |
---|
114 | seqedit,sequence=lhcb1; |
---|
115 | cycle,start=ip3.b1; |
---|
116 | endedit; |
---|
117 | |
---|
118 | seqedit,sequence=lhcb2; |
---|
119 | flatten; |
---|
120 | endedit; |
---|
121 | |
---|
122 | seqedit,sequence=lhcb2; |
---|
123 | cycle,start=ip3.b2; |
---|
124 | endedit; |
---|
125 | |
---|
126 | bbmarker: marker; /* for subsequent remove */ |
---|
127 | |
---|
128 | |
---|
129 | !+++++++++++++++++++++++++ Step 3 +++++++++++++++++++++++ |
---|
130 | ! define the beam-beam elements |
---|
131 | !++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
---|
132 | ! |
---|
133 | !=========================================================== |
---|
134 | ! read macro definitions |
---|
135 | option,-echo; |
---|
136 | call,file="ldb/bb.macros"; |
---|
137 | option,echo; |
---|
138 | |
---|
139 | ! |
---|
140 | !=========================================================== |
---|
141 | ! this sets CHARGE in the head-on beam-beam elements. |
---|
142 | ! set +1 * ho_charge for parasitic on, 0 for off |
---|
143 | |
---|
144 | on_ho1 = +1 * ho_charge; ! ho_charge depends on split |
---|
145 | on_ho2 = +0 * ho_charge; ! because of the "by hand" splitting |
---|
146 | on_ho5 = +1 * ho_charge; |
---|
147 | on_ho8 = +0 * ho_charge; |
---|
148 | |
---|
149 | ! |
---|
150 | !=========================================================== |
---|
151 | ! set CHARGE in the parasitic beam-beam elements. |
---|
152 | ! set +1 for parasitic on, 0 for off |
---|
153 | on_lr1l = +1; |
---|
154 | on_lr1r = +1; |
---|
155 | on_lr2l = +0; |
---|
156 | on_lr2r = +0; |
---|
157 | on_lr5l = +1; |
---|
158 | on_lr5r = +1; |
---|
159 | on_lr8l = +0; |
---|
160 | on_lr8r = +0; |
---|
161 | |
---|
162 | ! |
---|
163 | !=========================================================== |
---|
164 | ! define markers and savebetas |
---|
165 | assign,echo=temp.bb.install; |
---|
166 | !--- ip1 |
---|
167 | if (on_ho1 <> 0) |
---|
168 | { |
---|
169 | exec, mkho(1); |
---|
170 | exec, sbhomk(1); |
---|
171 | } |
---|
172 | if (on_lr1l <> 0 || on_lr1r <> 0) |
---|
173 | { |
---|
174 | n=1; ! counter |
---|
175 | while (n < npara_1) |
---|
176 | { |
---|
177 | exec, mkl(1,$n); |
---|
178 | exec, sbl(1,$n); |
---|
179 | n=n+1; |
---|
180 | }; |
---|
181 | } |
---|
182 | if (on_lr1r <> 0 || on_lr1l <> 0) |
---|
183 | { |
---|
184 | n=1; ! counter |
---|
185 | while (n < npara_1) |
---|
186 | { |
---|
187 | exec, mkr(1,$n); |
---|
188 | exec, sbr(1,$n); |
---|
189 | n=n+1; |
---|
190 | }; |
---|
191 | } |
---|
192 | !--- ip5 |
---|
193 | if (on_ho5 <> 0) |
---|
194 | { |
---|
195 | exec, mkho(5); |
---|
196 | exec, sbhomk(5); |
---|
197 | } |
---|
198 | if (on_lr5l <> 0 || on_lr5r <> 0) |
---|
199 | { |
---|
200 | n=1; ! counter |
---|
201 | while (n < npara_5) |
---|
202 | { |
---|
203 | exec, mkl(5,$n); |
---|
204 | exec, sbl(5,$n); |
---|
205 | n=n+1; |
---|
206 | }; |
---|
207 | } |
---|
208 | if (on_lr5r <> 0 || on_lr5l <> 0) |
---|
209 | { |
---|
210 | n=1; ! counter |
---|
211 | while (n < npara_5) |
---|
212 | { |
---|
213 | exec, mkr(5,$n); |
---|
214 | exec, sbr(5,$n); |
---|
215 | n=n+1; |
---|
216 | }; |
---|
217 | } |
---|
218 | !--- ip2 |
---|
219 | if (on_ho2 <> 0) |
---|
220 | { |
---|
221 | exec, mkho(2); |
---|
222 | exec, sbhomk(2); |
---|
223 | } |
---|
224 | if (on_lr2l <> 0 || on_lr2r <> 0) |
---|
225 | { |
---|
226 | n=1; ! counter |
---|
227 | while (n < npara_2) |
---|
228 | { |
---|
229 | exec, mkl(2,$n); |
---|
230 | exec, sbl(2,$n); |
---|
231 | n=n+1; |
---|
232 | }; |
---|
233 | } |
---|
234 | if (on_lr2r <> 0 || on_lr2l <> 0) |
---|
235 | { |
---|
236 | n=1; ! counter |
---|
237 | while (n < npara_2) |
---|
238 | { |
---|
239 | exec, mkr(2,$n); |
---|
240 | exec, sbr(2,$n); |
---|
241 | n=n+1; |
---|
242 | }; |
---|
243 | } |
---|
244 | !--- ip8 |
---|
245 | if (on_ho8 <> 0) |
---|
246 | { |
---|
247 | exec, mkho(8); |
---|
248 | exec, sbhomk(8); |
---|
249 | } |
---|
250 | if (on_lr8l <> 0 || on_lr8r <> 0) |
---|
251 | { |
---|
252 | n=1; ! counter |
---|
253 | while (n < npara_8) |
---|
254 | { |
---|
255 | exec, mkl(8,$n); |
---|
256 | exec, sbl(8,$n); |
---|
257 | n=n+1; |
---|
258 | }; |
---|
259 | } |
---|
260 | if (on_lr8r <> 0 || on_lr8l <> 0) |
---|
261 | { |
---|
262 | n=1; ! counter |
---|
263 | while (n < npara_8) |
---|
264 | { |
---|
265 | exec, mkr(8,$n); |
---|
266 | exec, sbr(8,$n); |
---|
267 | n=n+1; |
---|
268 | }; |
---|
269 | } |
---|
270 | assign,echo=terminal; |
---|
271 | call,file=temp.bb.install; |
---|
272 | system, "rm temp.bb.install"; |
---|
273 | ! |
---|
274 | !=========================================================== |
---|
275 | ! install bb markers |
---|
276 | assign,echo=temp.bb.install; |
---|
277 | !--- ip1 |
---|
278 | if (on_ho1 <> 0) |
---|
279 | { |
---|
280 | exec, inho(mk,1); |
---|
281 | } |
---|
282 | if (on_lr1l <> 0 || on_lr1r <> 0) |
---|
283 | { |
---|
284 | n=1; ! counter |
---|
285 | while (n < npara_1) |
---|
286 | { |
---|
287 | exec, inl(mk,1,$n); |
---|
288 | n=n+1; |
---|
289 | }; |
---|
290 | } |
---|
291 | if (on_lr1r <> 0 || on_lr1l <> 0) |
---|
292 | { |
---|
293 | n=1; ! counter |
---|
294 | while (n < npara_1) |
---|
295 | { |
---|
296 | exec, inr(mk,1,$n); |
---|
297 | n=n+1; |
---|
298 | }; |
---|
299 | } |
---|
300 | !--- ip5 |
---|
301 | if (on_ho5 <> 0) |
---|
302 | { |
---|
303 | exec, inho(mk,5); |
---|
304 | } |
---|
305 | if (on_lr5l <> 0 || on_lr5r <> 0) |
---|
306 | { |
---|
307 | n=1; ! counter |
---|
308 | while (n < npara_5) |
---|
309 | { |
---|
310 | exec, inl(mk,5,$n); |
---|
311 | n=n+1; |
---|
312 | }; |
---|
313 | } |
---|
314 | if (on_lr5r <> 0 || on_lr5l <> 0) |
---|
315 | { |
---|
316 | n=1; ! counter |
---|
317 | while (n < npara_5) |
---|
318 | { |
---|
319 | exec, inr(mk,5,$n); |
---|
320 | n=n+1; |
---|
321 | }; |
---|
322 | } |
---|
323 | !--- ip2 |
---|
324 | if (on_ho2 <> 0) |
---|
325 | { |
---|
326 | exec, inho(mk,2); |
---|
327 | } |
---|
328 | if (on_lr2l <> 0 || on_lr2r <> 0) |
---|
329 | { |
---|
330 | n=1; ! counter |
---|
331 | while (n < npara_2) |
---|
332 | { |
---|
333 | exec, inl(mk,2,$n); |
---|
334 | n=n+1; |
---|
335 | }; |
---|
336 | } |
---|
337 | if (on_lr2r <> 0 || on_lr2l <> 0) |
---|
338 | { |
---|
339 | n=1; ! counter |
---|
340 | while (n < npara_2) |
---|
341 | { |
---|
342 | exec, inr(mk,2,$n); |
---|
343 | n=n+1; |
---|
344 | }; |
---|
345 | } |
---|
346 | !--- ip8 |
---|
347 | if (on_ho8 <> 0) |
---|
348 | { |
---|
349 | exec, inho(mk,8); |
---|
350 | } |
---|
351 | if (on_lr8l <> 0 || on_lr8r <> 0) |
---|
352 | { |
---|
353 | n=1; ! counter |
---|
354 | while (n < npara_8) |
---|
355 | { |
---|
356 | exec, inl(mk,8,$n); |
---|
357 | n=n+1; |
---|
358 | }; |
---|
359 | } |
---|
360 | if (on_lr8r <> 0 || on_lr8l <> 0) |
---|
361 | { |
---|
362 | n=1; ! counter |
---|
363 | while (n < npara_8) |
---|
364 | { |
---|
365 | exec, inr(mk,8,$n); |
---|
366 | n=n+1; |
---|
367 | }; |
---|
368 | } |
---|
369 | assign,echo=terminal; |
---|
370 | seqedit,sequence=lhcb2; |
---|
371 | call,file=temp.bb.install; |
---|
372 | endedit; |
---|
373 | system, "rm temp.bb.install"; |
---|
374 | |
---|
375 | ! |
---|
376 | !=========================================================== |
---|
377 | !--- get beta functions at bb in all four IPs |
---|
378 | use,period=lhcb2; |
---|
379 | !select,flag=twiss,class=bbmarker,column=name,s,x,y; |
---|
380 | twiss, sequence=lhcb2; !,file; |
---|
381 | !--- separation for halo collisions at IP2 |
---|
382 | on_sep2 = 2.118 * sqrt(epsx * r2ip2->betx) / 0.0007999979093; |
---|
383 | value,on_sep2; |
---|
384 | !=========================================================== |
---|
385 | ! define bb elements |
---|
386 | assign,echo=temp.bb.install; |
---|
387 | !--- ip1 |
---|
388 | if (on_ho1 <> 0) |
---|
389 | { |
---|
390 | exec, bbho(1); |
---|
391 | } |
---|
392 | if (on_lr1l <> 0) |
---|
393 | { |
---|
394 | n=1; ! counter |
---|
395 | while (n < npara_1) |
---|
396 | { |
---|
397 | exec, bbl(1,$n); |
---|
398 | n=n+1; |
---|
399 | }; |
---|
400 | } |
---|
401 | if (on_lr1r <> 0) |
---|
402 | { |
---|
403 | n=1; ! counter |
---|
404 | while (n < npara_1) |
---|
405 | { |
---|
406 | exec, bbr(1,$n); |
---|
407 | n=n+1; |
---|
408 | }; |
---|
409 | } |
---|
410 | !--- ip5 |
---|
411 | if (on_ho5 <> 0) |
---|
412 | { |
---|
413 | exec, bbho(5); |
---|
414 | } |
---|
415 | if (on_lr5l <> 0) |
---|
416 | { |
---|
417 | n=1; ! counter |
---|
418 | while (n < npara_5) |
---|
419 | { |
---|
420 | exec, bbl(5,$n); |
---|
421 | n=n+1; |
---|
422 | }; |
---|
423 | } |
---|
424 | if (on_lr5r <> 0) |
---|
425 | { |
---|
426 | n=1; ! counter |
---|
427 | while (n < npara_5) |
---|
428 | { |
---|
429 | exec, bbr(5,$n); |
---|
430 | n=n+1; |
---|
431 | }; |
---|
432 | } |
---|
433 | !--- ip2 |
---|
434 | if (on_ho2 <> 0) |
---|
435 | { |
---|
436 | exec, bbho(2); |
---|
437 | } |
---|
438 | if (on_lr2l <> 0) |
---|
439 | { |
---|
440 | n=1; ! counter |
---|
441 | while (n < npara_2) |
---|
442 | { |
---|
443 | exec, bbl(2,$n); |
---|
444 | n=n+1; |
---|
445 | }; |
---|
446 | } |
---|
447 | if (on_lr2r <> 0) |
---|
448 | { |
---|
449 | n=1; ! counter |
---|
450 | while (n < npara_2) |
---|
451 | { |
---|
452 | exec, bbr(2,$n); |
---|
453 | n=n+1; |
---|
454 | }; |
---|
455 | } |
---|
456 | !--- ip8 |
---|
457 | if (on_ho8 <> 0) |
---|
458 | { |
---|
459 | exec, bbho(8); |
---|
460 | } |
---|
461 | if (on_lr8l <> 0) |
---|
462 | { |
---|
463 | n=1; ! counter |
---|
464 | while (n < npara_8) |
---|
465 | { |
---|
466 | exec, bbl(8,$n); |
---|
467 | n=n+1; |
---|
468 | }; |
---|
469 | } |
---|
470 | if (on_lr8r <> 0) |
---|
471 | { |
---|
472 | n=1; ! counter |
---|
473 | while (n < npara_8) |
---|
474 | { |
---|
475 | exec, bbr(8,$n); |
---|
476 | n=n+1; |
---|
477 | }; |
---|
478 | } |
---|
479 | assign,echo=terminal; |
---|
480 | call,file=temp.bb.install; |
---|
481 | system, "rm temp.bb.install"; |
---|
482 | ! |
---|
483 | !=========================================================== |
---|
484 | ! install bb elements |
---|
485 | assign,echo=temp.bb.install; |
---|
486 | !--- ip1 |
---|
487 | if (on_ho1 <> 0) |
---|
488 | { |
---|
489 | exec, inho(bb,1); |
---|
490 | } |
---|
491 | if (on_lr1l <> 0) |
---|
492 | { |
---|
493 | n=1; ! counter |
---|
494 | while (n < npara_1) |
---|
495 | { |
---|
496 | exec, inl(bb,1,$n); |
---|
497 | n=n+1; |
---|
498 | }; |
---|
499 | } |
---|
500 | if (on_lr1r <> 0) |
---|
501 | { |
---|
502 | n=1; ! counter |
---|
503 | while (n < npara_1) |
---|
504 | { |
---|
505 | exec, inr(bb,1,$n); |
---|
506 | n=n+1; |
---|
507 | }; |
---|
508 | } |
---|
509 | !--- ip5 |
---|
510 | if (on_ho5 <> 0) |
---|
511 | { |
---|
512 | exec, inho(bb,5); |
---|
513 | } |
---|
514 | if (on_lr5l <> 0) |
---|
515 | { |
---|
516 | n=1; ! counter |
---|
517 | while (n < npara_5) |
---|
518 | { |
---|
519 | exec, inl(bb,5,$n); |
---|
520 | n=n+1; |
---|
521 | }; |
---|
522 | } |
---|
523 | if (on_lr5r <> 0) |
---|
524 | { |
---|
525 | n=1; ! counter |
---|
526 | while (n < npara_5) |
---|
527 | { |
---|
528 | exec, inr(bb,5,$n); |
---|
529 | n=n+1; |
---|
530 | }; |
---|
531 | } |
---|
532 | !--- ip2 |
---|
533 | if (on_ho2 <> 0) |
---|
534 | { |
---|
535 | exec, inho(bb,2); |
---|
536 | } |
---|
537 | if (on_lr2l <> 0) |
---|
538 | { |
---|
539 | n=1; ! counter |
---|
540 | while (n < npara_2) |
---|
541 | { |
---|
542 | exec, inl(bb,2,$n); |
---|
543 | n=n+1; |
---|
544 | }; |
---|
545 | } |
---|
546 | if (on_lr2r <> 0) |
---|
547 | { |
---|
548 | n=1; ! counter |
---|
549 | while (n < npara_2) |
---|
550 | { |
---|
551 | exec, inr(bb,2,$n); |
---|
552 | n=n+1; |
---|
553 | }; |
---|
554 | } |
---|
555 | !--- ip8 |
---|
556 | if (on_ho8 <> 0) |
---|
557 | { |
---|
558 | exec, inho(bb,8); |
---|
559 | } |
---|
560 | if (on_lr8l <> 0) |
---|
561 | { |
---|
562 | n=1; ! counter |
---|
563 | while (n < npara_8) |
---|
564 | { |
---|
565 | exec, inl(bb,8,$n); |
---|
566 | n=n+1; |
---|
567 | }; |
---|
568 | } |
---|
569 | if (on_lr8r <> 0) |
---|
570 | { |
---|
571 | n=1; ! counter |
---|
572 | while (n < npara_8) |
---|
573 | { |
---|
574 | exec, inr(bb,8,$n); |
---|
575 | n=n+1; |
---|
576 | }; |
---|
577 | } |
---|
578 | assign,echo=terminal; |
---|
579 | select,flag=seqedit,class=bbmarker; |
---|
580 | seqedit,sequence=lhcb2; |
---|
581 | remove,element=selected; |
---|
582 | endedit; |
---|
583 | select,flag=seqedit,clear; |
---|
584 | |
---|
585 | seqedit,sequence=lhcb1; |
---|
586 | call,file=temp.bb.install; |
---|
587 | endedit; |
---|
588 | |
---|
589 | !--- Now the beam-beam element installation is complete |
---|
590 | |
---|
591 | system, "rm temp.bb.install"; |
---|
592 | |
---|
593 | seqedit,sequence=lhcb1; |
---|
594 | cycle,start=ip1; |
---|
595 | endedit; |
---|
596 | |
---|
597 | use,period=lhcb1; |
---|
598 | !twiss, sequence=lhcb1; |
---|
599 | ! |
---|
600 | ! make footprint |
---|
601 | ! |
---|
602 | |
---|
603 | option,trace; |
---|
604 | small=0.05; |
---|
605 | big=sqrt(1.-small^2); |
---|
606 | track; |
---|
607 | xs=small; ys=small; |
---|
608 | value,xs,ys; |
---|
609 | start,fx=xs,fy=ys; // zero amplitude |
---|
610 | nsigmax=6; |
---|
611 | n=1; // sigma multiplier |
---|
612 | m=0; // angle multiplier |
---|
613 | while (n <= nsigmax) |
---|
614 | { |
---|
615 | angle = 15*m*pi/180; |
---|
616 | if (m == 0) {xs=n*big; ys=n*small;} |
---|
617 | elseif (m == 6) {xs=n*small; ys=n*big;} |
---|
618 | else |
---|
619 | { |
---|
620 | xs=n*cos(angle); |
---|
621 | ys=n*sin(angle); |
---|
622 | } |
---|
623 | value,xs,ys; |
---|
624 | start,fx=xs,fy=ys; |
---|
625 | m=m+1; |
---|
626 | if (m == 7) { m=0; n=n+1;} |
---|
627 | }; |
---|
628 | dynap,fastune,turns=1024; |
---|
629 | endtrack; |
---|
630 | write,table=dynap,file; |
---|
631 | write,table=dynaptune,file; |
---|
632 | system,"foot < dynaptune > footprint"; |
---|
633 | stop; |
---|
634 | </pre> |
---|
635 | |
---|
636 | <h4><a name=macro>Real life example of MACRO definitions</a></h4> |
---|
637 | <p> |
---|
638 | <pre> |
---|
639 | bbho(nn): macro = { |
---|
640 | !--- macro defining head-on beam-beam elements; nn = IP number |
---|
641 | print, text="bbipnnl2: beambeam, sigx=sqrt(rnnipnnl2->betx*epsx),"; |
---|
642 | print, text=" sigy=sqrt(rnnipnnl2->bety*epsy),"; |
---|
643 | print, text=" xma=rnnipnnl2->x,yma=rnnipnnl2->y,"; |
---|
644 | print, text=" charge:=on_honn;"; |
---|
645 | print, text="bbipnnl1: beambeam, sigx=sqrt(rnnipnnl1->betx*epsx),"; |
---|
646 | print, text=" sigy=sqrt(rnnipnnl1->bety*epsy),"; |
---|
647 | print, text=" xma=rnnipnnl1->x,yma=rnnipnnl1->y,"; |
---|
648 | print, text=" charge:=on_honn;"; |
---|
649 | print, text="bbipnn: beambeam, sigx=sqrt(rnnipnn->betx*epsx),"; |
---|
650 | print, text=" sigy=sqrt(rnnipnn->bety*epsy),"; |
---|
651 | print, text=" xma=rnnipnn->x,yma=rnnipnn->y,"; |
---|
652 | print, text=" charge:=on_honn;"; |
---|
653 | print, text="bbipnnr1: beambeam, sigx=sqrt(rnnipnnr1->betx*epsx),"; |
---|
654 | print, text=" sigy=sqrt(rnnipnnr1->bety*epsy),"; |
---|
655 | print, text=" xma=rnnipnnr1->x,yma=rnnipnnr1->y,"; |
---|
656 | print, text=" charge:=on_honn;"; |
---|
657 | print, text="bbipnnr2: beambeam, sigx=sqrt(rnnipnnr2->betx*epsx),"; |
---|
658 | print, text=" sigy=sqrt(rnnipnnr2->bety*epsy),"; |
---|
659 | print, text=" xma=rnnipnnr2->x,yma=rnnipnnr2->y,"; |
---|
660 | print, text=" charge:=on_honn;"; |
---|
661 | }; |
---|
662 | |
---|
663 | mkho(nn): macro = { |
---|
664 | !--- macro defining head-on markers; nn = IP number |
---|
665 | print, text="mkipnnl2: bbmarker;"; |
---|
666 | print, text="mkipnnl1: bbmarker;"; |
---|
667 | print, text="mkipnn: bbmarker;"; |
---|
668 | print, text="mkipnnr1: bbmarker;"; |
---|
669 | print, text="mkipnnr2: bbmarker;"; |
---|
670 | }; |
---|
671 | |
---|
672 | inho(xx,nn): macro = { |
---|
673 | !--- macro installing bb or markers for head-on beam-beam (split into 5) |
---|
674 | print, text="install, element= xxipnnl2, at=-long_b, from=ipnn;"; |
---|
675 | print, text="install, element= xxipnnl1, at=-long_a, from=ipnn;"; |
---|
676 | print, text="install, element= xxipnn, at=1.e-9, from=ipnn;"; |
---|
677 | print, text="install, element= xxipnnr1, at=+long_a, from=ipnn;"; |
---|
678 | print, text="install, element= xxipnnr2, at=+long_b, from=ipnn;"; |
---|
679 | }; |
---|
680 | |
---|
681 | sbhomk(nn): macro = { |
---|
682 | !--- macro to create savebetas for ho markers |
---|
683 | print, text="savebeta, label=rnnipnnl2, place=mkipnnl2;"; |
---|
684 | print, text="savebeta, label=rnnipnnl1, place=mkipnnl1;"; |
---|
685 | print, text="savebeta, label=rnnipnn, place=mkipnn;"; |
---|
686 | print, text="savebeta, label=rnnipnnr1, place=mkipnnr1;"; |
---|
687 | print, text="savebeta, label=rnnipnnr2, place=mkipnnr2;"; |
---|
688 | }; |
---|
689 | |
---|
690 | mkl(nn,cc): macro = { |
---|
691 | !--- macro to create parasitic bb marker on left side of ip nn; cc = count |
---|
692 | print, text="mkipnnplcc: bbmarker;"; |
---|
693 | }; |
---|
694 | |
---|
695 | mkr(nn,cc): macro = { |
---|
696 | !--- macro to create parasitic bb marker on right side of ip nn; cc = count |
---|
697 | print, text="mkipnnprcc: bbmarker;"; |
---|
698 | }; |
---|
699 | |
---|
700 | sbl(nn,cc): macro = { |
---|
701 | !--- macro to create savebetas for left parasitic |
---|
702 | print, text="savebeta, label=rnnipnnplcc, place=mkipnnplcc;"; |
---|
703 | }; |
---|
704 | |
---|
705 | sbr(nn,cc): macro = { |
---|
706 | !--- macro to create savebetas for right parasitic |
---|
707 | print, text="savebeta, label=rnnipnnprcc, place=mkipnnprcc;"; |
---|
708 | }; |
---|
709 | |
---|
710 | inl(xx,nn,cc): macro = { |
---|
711 | !--- macro installing bb and markers for left side parasitic beam-beam |
---|
712 | print, text="install, element= xxipnnplcc, at=-cc*b_h_dist, from=ipnn;"; |
---|
713 | }; |
---|
714 | |
---|
715 | inr(xx,nn,cc): macro = { |
---|
716 | !--- macro installing bb and markers for right side parasitic beam-beam |
---|
717 | print, text="install, element= xxipnnprcc, at=cc*b_h_dist, from=ipnn;"; |
---|
718 | }; |
---|
719 | |
---|
720 | bbl(nn,cc): macro = { |
---|
721 | !--- macro defining parasitic beam-beam elements; nn = IP number |
---|
722 | print, text="bbipnnplcc: beambeam, sigx=sqrt(rnnipnnplcc->betx*epsx),"; |
---|
723 | print, text=" sigy=sqrt(rnnipnnplcc->bety*epsy),"; |
---|
724 | print, text=" xma=rnnipnnplcc->x,yma=rnnipnnplcc->y,"; |
---|
725 | print, text=" charge:=on_lrnnl;"; |
---|
726 | }; |
---|
727 | |
---|
728 | bbr(nn,cc): macro = { |
---|
729 | !--- macro defining parasitic beam-beam elements; nn = IP number |
---|
730 | print, text="bbipnnprcc: beambeam, sigx=sqrt(rnnipnnprcc->betx*epsx),"; |
---|
731 | print, text=" sigy=sqrt(rnnipnnprcc->bety*epsy),"; |
---|
732 | print, text=" xma=rnnipnnprcc->x,yma=rnnipnnprcc->y,"; |
---|
733 | print, text=" charge:=on_lrnnr;"; |
---|
734 | }; |
---|
735 | </pre> |
---|
736 | |
---|
737 | <address> |
---|
738 | <a href="http://www.cern.ch/Hans.Grote/hansg_sign.html">hansg</a>, |
---|
739 | June 17, 2002 |
---|
740 | </address> |
---|
741 | |
---|
742 | </body> |
---|