-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathalign_mbh_v1.madx
72 lines (63 loc) · 2.09 KB
/
align_mbh_v1.madx
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
if ( ver_hllhc_optics>1.2) {
print, text="Fatal error: align_mbh_v2 is only compatible with HL-LHC optics 1.2 and lower.";
stop;
};
align_elem(RREF,EELEM,SSHIFT): macro={
stest=table(survey,EELEM,s);
value,stest;
if ( stest > 1e-9 ) {
ttt=table(survey,RREF,theta); ctt=cos(ttt);stt=sin(ttt);
xvz=stt; xvx=-ctt; zvz=ctt; zvx=stt; ! x and s directions
zzz=table(survey,EELEM,z)-table(survey,RREF,z);
xxx=table(survey,EELEM,x)-table(survey,RREF,x);
dx_EELEM=zzz*xvz+xxx*xvx;
sx_EELEM=zzz*zvz+xxx*zvx;
value,dx_EELEM,sx_EELEM;
if (dx_EELEM>0){
dx_EELEM=dx_EELEM-(SSHIFT/1000);
} else {
dx_EELEM=dx_EELEM+(SSHIFT/1000);
};
value,dx_EELEM;
select, flag=error, range=EELEM;
ealign, dx=dx_EELEM;
select, flag=error, clear;
!r_MBHt=0.022;
!show,EELEM;
!EELEM,APERTYPE=RECTELLIPSE,APERTURE={r_MBHt,g_MBH,r_MBHt,r_MBHt},APER_TOL={r_tol_MBH,h_tol_MBH,v_tol_MBH};
};
};
align_slice(RREF,EELEM,NSLICE,SSHIFT): macro={
exec,align_elem(RREF,EELEM..NSLICE,SSHIFT);
};
align_group(RREF,EELEM,SSHIFT): macro={
align_group_n=0;
stest=1;
while(align_group_n<64 && stest>1e-9){
align_group_n=align_group_n+1;
exec,align_slice(RREF,EELEM,$align_group_n,SSHIFT);
};
};
align_mbh(mbn,irn,bim): macro={
mbh_hsag_mm=mbh_hsag*1000;
if (mbh_irirnqmbn >0){
exec, align_group(MBH.AmbnRirn.bim,MBH.AmbnRirn.bim,mbh_hsag_mm);
exec, align_group(MBH.AmbnLirn.bim,MBH.AmbnLirn.bim,mbh_hsag_mm);
exec, align_group(MBH.BmbnRirn.bim,MBH.BmbnRirn.bim,mbh_hsag_mm);
exec, align_group(MBH.BmbnLirn.bim,MBH.BmbnLirn.bim,mbh_hsag_mm);
};
};
print,text="Running survey for alignment calculations...";
survey;
if (mylhcbeam==1){
exec,align_mbh(8,1,b1); exec,align_mbh(9,1,b1); exec,align_mbh(10,1,b1);
exec,align_mbh(8,2,b1); exec,align_mbh(10,2,b1);
exec,align_mbh(8,5,b1); exec,align_mbh(9,5,b1); exec,align_mbh(10,5,b1);
exec,align_mbh(8,7,b1); exec,align_mbh(10,7,b1);
};
if (mylhcbeam>1){
exec,align_mbh(8,1,b2); exec,align_mbh(9,1,b1); exec,align_mbh(10,1,b2);
exec,align_mbh(8,2,b2); exec,align_mbh(10,2,b2);
exec,align_mbh(8,5,b2); exec,align_mbh(9,5,b2); exec,align_mbh(10,5,b2);
exec,align_mbh(8,7,b2); exec,align_mbh(10,7,b2);
};