| | 1032 | |
| | 1033 | static char *statepars_all[NUM_STATE_PARS] = |
| | 1034 | { /* these particle state parameter names are used for all calls */ |
| | 1035 | #if MCCODE_PROJECT == 1 /* neutron */ |
| | 1036 | "x", "y", "z", "vx", "vy", "vz", |
| | 1037 | "t", "sx", "sy", "sz", "p" |
| | 1038 | #elif MCCODE_PROJECT == 2 /* xray */ |
| | 1039 | "x", "y", "z", "kx", "ky", "kz", |
| | 1040 | "phi", "t", "Ex", "Ey","Ez", "p" |
| | 1041 | #endif |
| | 1042 | }; |
| | 1043 | static char *statepars_change[9] = |
| | 1044 | { /* these particle state parameter names are used for coordinate change only */ |
| | 1045 | #if MCCODE_PROJECT == 1 /* neutron */ |
| | 1046 | "x", "y", "z", "vx", "vy", "vz", "sx", "sy", "sz" |
| | 1047 | #elif MCCODE_PROJECT == 2 /* xray */ |
| | 1048 | "x", "y", "z", "kx", "ky", "kz", "Ex", "Ey","Ez" |
| | 1049 | #endif |
| | 1050 | }; |
| 1036 | | coutf(" MCNUM %snlx = %snx;", ID_PRE, ID_PRE); |
| 1037 | | coutf(" MCNUM %snly = %sny;", ID_PRE, ID_PRE); |
| 1038 | | coutf(" MCNUM %snlz = %snz;", ID_PRE, ID_PRE); |
| 1039 | | #if MCCODE_PROJECT == 1 /* neutron */ |
| 1040 | | coutf(" MCNUM %snlvx = %snvx;", ID_PRE, ID_PRE); |
| 1041 | | coutf(" MCNUM %snlvy = %snvy;", ID_PRE, ID_PRE); |
| 1042 | | coutf(" MCNUM %snlvz = %snvz;", ID_PRE, ID_PRE); |
| 1043 | | coutf(" MCNUM %snlt = %snt;", ID_PRE, ID_PRE); |
| 1044 | | coutf(" MCNUM %snlsx = %snsx;", ID_PRE, ID_PRE); |
| 1045 | | coutf(" MCNUM %snlsy = %snsy;", ID_PRE, ID_PRE); |
| 1046 | | coutf(" MCNUM %snlsz = %snsz;", ID_PRE, ID_PRE); |
| 1047 | | #elif MCCODE_PROJECT == 2 /* xray */ |
| 1048 | | coutf(" MCNUM %snlkx = %snkx;", ID_PRE, ID_PRE); |
| 1049 | | coutf(" MCNUM %snlky = %snky;", ID_PRE, ID_PRE); |
| 1050 | | coutf(" MCNUM %snlkz = %snkz;", ID_PRE, ID_PRE); |
| 1051 | | coutf(" MCNUM %snlphi = %snphi;", ID_PRE, ID_PRE); |
| 1052 | | coutf(" MCNUM %snlt = %snt;", ID_PRE, ID_PRE); |
| 1053 | | coutf(" MCNUM %snlEx = %snEx;", ID_PRE, ID_PRE); |
| 1054 | | coutf(" MCNUM %snlEy = %snEy;", ID_PRE, ID_PRE); |
| 1055 | | coutf(" MCNUM %snlEz = %snEz;", ID_PRE, ID_PRE); |
| 1056 | | #endif |
| 1057 | | coutf(" MCNUM %snlp = %snp;", ID_PRE, ID_PRE); |
| | 1056 | for(i = 0; i < NUM_STATE_PARS; i++) |
| | 1057 | coutf(" MCNUM %snl%s = %sn%s;", ID_PRE, statepars_all[i], ID_PRE, statepars_all[i]); |
| 1062 | | #if MCCODE_PROJECT == 1 /* neutron */ |
| 1063 | | coutf(" %sDEBUG_STATE(%snlx, %snly, %snlz, %snlvx, %snlvy, %snlvz," |
| 1064 | | " %snlt, %snlsx,%snlsy,%snlsz, %snlp)", |
| 1065 | | ID_PRE, ID_PRE, ID_PRE, ID_PRE, ID_PRE, ID_PRE, ID_PRE, |
| 1066 | | ID_PRE, ID_PRE, ID_PRE, ID_PRE, ID_PRE); |
| 1067 | | #elif MCCODE_PROJECT == 2 /* xray */ |
| 1068 | | coutf(" %sDEBUG_STATE(%snlx, %snly, %snlz, %snlkx, %snlky, %snlkz," |
| 1069 | | "%snlphi,%snlt, %snlEx,%snlEy,%snlEz, %snlp)", |
| 1070 | | ID_PRE, ID_PRE, ID_PRE, ID_PRE, ID_PRE, ID_PRE, ID_PRE, |
| 1071 | | ID_PRE, ID_PRE, ID_PRE, ID_PRE, ID_PRE, ID_PRE); |
| 1072 | | #endif |
| | 1062 | coutf(" %sDEBUG_STATE(" , ID_PRE); |
| | 1063 | for(i = 0; i < NUM_STATE_PARS; i++) |
| | 1064 | if (i < NUM_STATE_PARS-1) coutf(" %snl%s,", ID_PRE, statepars_all[i]); |
| | 1065 | else coutf(" %snl%s)", ID_PRE, statepars_all[i]); |
| 1124 | | |
| 1125 | | char *statepars[NUM_STATE_PARS]; |
| 1126 | | static char *statepars_names[NUM_STATE_PARS] = |
| 1127 | | { |
| 1128 | | #if MCCODE_PROJECT == 1 /* neutron */ |
| 1129 | | "nlx", "nly", "nlz", "nlvx", "nlvy", "nlvz", |
| 1130 | | "nlt", "nlsx", "nlsy", "nlsz", "nlp" |
| 1131 | | #elif MCCODE_PROJECT == 2 /* xray */ |
| 1132 | | "nlx", "nly", "nlz", "nlkx", "nlky", "nlkz", |
| 1133 | | "nlphi", "nlt", "nlEx", "nlEy","nlEz", "nlp" |
| 1134 | | #endif |
| 1135 | | }; |
| 1136 | | int i; |
| 1144 | | coutf(" &%snlx, &%snly, &%snlz,", ID_PRE, ID_PRE, ID_PRE); |
| 1145 | | #if MCCODE_PROJECT == 1 /* neutron */ |
| 1146 | | coutf(" &%snlvx, &%snlvy, &%snlvz);", ID_PRE, ID_PRE, ID_PRE); |
| 1147 | | #elif MCCODE_PROJECT == 2 /* xray */ |
| 1148 | | coutf(" &%snlkx, &%snlky, &%snlkz);", ID_PRE, ID_PRE, ID_PRE); |
| 1149 | | // coutf(" &%snlphi, &%snlEx, &%snlEy);", ID_PRE, ID_PRE, ID_PRE); |
| 1150 | | #endif |
| 1151 | | |
| 1152 | | /* Change of spin to local frame. */ |
| 1153 | | coutf(" %scoordschange_polarisation(" |
| 1154 | | #if MCCODE_PROJECT == 1 /* neutron */ |
| 1155 | | "%srotr%s, &%snlsx, &%snlsy, &%snlsz);", |
| 1156 | | #elif MCCODE_PROJECT == 2 /* xray */ |
| 1157 | | "%srotr%s, &%snlEx, &%snlEy, &%snlEz);", |
| 1158 | | #endif |
| 1159 | | ID_PRE, ID_PRE, comp->name, ID_PRE, ID_PRE, ID_PRE); |
| 1160 | | |
| | 1124 | for(i = 0; i < 9; i++) |
| | 1125 | if (i < 9-1) coutf(" &%snl%s,", ID_PRE, statepars_change[i]); |
| | 1126 | else coutf(" &%snl%s);", ID_PRE, statepars_change[i]); |
| 1170 | | coutf(" %sDEBUG_STATE(%snlx, %snly, %snlz, %snlvx, %snlvy, %snlvz," |
| 1171 | | "%snlt, %snlsx,%snlsy,%snlsz, %snlp)", |
| 1172 | | ID_PRE, ID_PRE, ID_PRE, ID_PRE, ID_PRE, ID_PRE, ID_PRE, |
| 1173 | | ID_PRE, ID_PRE, ID_PRE, ID_PRE, ID_PRE); |
| | 1144 | static char *store ="STORE_NEUTRON"; |
| | 1145 | static char *restore="RESTORE_NEUTRON"; |
| 1175 | | coutf(" %sDEBUG_STATE(%snlx, %snly, %snlz, %snlkx, %snlky, %snlkz," |
| 1176 | | "%snlphi,%snlt,%snlEx,%snlEy,%snlEz, %snlp)", |
| 1177 | | ID_PRE, ID_PRE, ID_PRE, ID_PRE, ID_PRE, ID_PRE, ID_PRE, |
| 1178 | | ID_PRE, ID_PRE, ID_PRE, ID_PRE, ID_PRE, ID_PRE); |
| | 1147 | static char *store ="STORE_XRAY"; |
| | 1148 | static char *restore="RESTORE_XRAY"; |
| 1200 | | if (!comp->split) |
| 1201 | | #if MCCODE_PROJECT == 1 /* neutron */ |
| 1202 | | coutf(" STORE_NEUTRON(%i,%snlx, %snly, %snlz, %snlvx," |
| 1203 | | "%snlvy,%snlvz,%snlt,%snlsx,%snlsy, %snlsz, %snlp);", |
| 1204 | | comp->index, ID_PRE, ID_PRE, ID_PRE, ID_PRE, ID_PRE, ID_PRE, |
| 1205 | | ID_PRE, ID_PRE, ID_PRE, ID_PRE, ID_PRE, ID_PRE); |
| 1206 | | #elif MCCODE_PROJECT == 2 /* xray */ |
| 1207 | | coutf(" STORE_XRAY(%i,%snlx, %snly, %snlz, %snlkx," |
| 1208 | | "%snlky,%snlkz,%snlphi,%snlt, %snlEx,%snlEy, %snlEz, %snlp);", |
| 1209 | | comp->index, ID_PRE, ID_PRE, ID_PRE, ID_PRE, ID_PRE, ID_PRE, |
| 1210 | | ID_PRE, ID_PRE, ID_PRE, ID_PRE, ID_PRE, ID_PRE, ID_PRE); |
| 1211 | | #endif |
| 1212 | | |
| 1213 | | else { |
| | 1152 | if (!comp->split) { |
| | 1153 | coutf(" %s(%i,", store, comp->index); /* STORE */ |
| | 1154 | for(i = 0; i < NUM_STATE_PARS; i++) |
| | 1155 | if (i < NUM_STATE_PARS-1) coutf(" %snl%s,", ID_PRE, statepars_all[i]); |
| | 1156 | else coutf(" %snl%s);",ID_PRE, statepars_all[i]); |
| | 1157 | } else { |
| 1218 | | #if MCCODE_PROJECT == 1 /* neutron */ |
| 1219 | | coutf(" STORE_NEUTRON(%i,%snlx, %snly, %snlz, %snlvx," |
| 1220 | | "%snlvy,%snlvz,%snlt,%snlsx,%snlsy, %snlsz, %snlp);", |
| 1221 | | comp->index, ID_PRE, ID_PRE, ID_PRE, ID_PRE, ID_PRE, ID_PRE, |
| 1222 | | ID_PRE, ID_PRE, ID_PRE, ID_PRE, ID_PRE); |
| | 1162 | coutf(" %s(%i,", store, comp->index); /* STORE */ |
| | 1163 | for(i = 0; i < NUM_STATE_PARS; i++) |
| | 1164 | if (i < NUM_STATE_PARS-1) coutf(" %snl%s,", ID_PRE, statepars_all[i]); |
| | 1165 | else coutf(" %snl%s);",ID_PRE, statepars_all[i]); |
| 1224 | | coutf(" RESTORE_NEUTRON(%i,%snlx, %snly, %snlz, %snlvx," |
| 1225 | | "%snlvy,%snlvz,%snlt,%snlsx,%snlsy, %snlsz, %snlp); }", |
| 1226 | | comp->index, ID_PRE, ID_PRE, ID_PRE, ID_PRE, ID_PRE, ID_PRE, |
| 1227 | | ID_PRE, ID_PRE, ID_PRE, ID_PRE, ID_PRE); |
| 1228 | | #elif MCCODE_PROJECT == 2 /* xray */ |
| 1229 | | coutf(" STORE_XRAY(%i,%snlx, %snly, %snlz, %snlkx," |
| 1230 | | "%snlky,%snlkz,%snlphi,%snlt, %snlEx,%snlEy, %snlEz, %snlp);", |
| 1231 | | comp->index, ID_PRE, ID_PRE, ID_PRE, ID_PRE, ID_PRE, ID_PRE, |
| 1232 | | ID_PRE, ID_PRE, ID_PRE, ID_PRE, ID_PRE, ID_PRE); |
| 1233 | | coutf(" } else {"); |
| 1234 | | coutf(" RESTORE_XRAY(%i,%snlx, %snly, %snlz, %snlkx," |
| 1235 | | "%snlky,%snlkz,%snlphi,%snlt, %snlEx,%snlEy, %snlEz, %snlp); }", |
| 1236 | | comp->index, ID_PRE, ID_PRE, ID_PRE, ID_PRE, ID_PRE, ID_PRE, |
| 1237 | | ID_PRE, ID_PRE, ID_PRE, ID_PRE, ID_PRE, ID_PRE, ID_PRE); |
| 1238 | | #endif |
| | 1167 | coutf(" %s(%i,", restore, comp->index); /* RESTORE */ |
| | 1168 | for(i = 0; i < NUM_STATE_PARS; i++) |
| | 1169 | if (i < NUM_STATE_PARS-1) coutf(" %snl%s,", ID_PRE, statepars_all[i]); |
| | 1170 | else coutf(" %snl%s);",ID_PRE, statepars_all[i]); |
| | 1171 | cout (" }"); |
| 1274 | | #if MCCODE_PROJECT == 1 /* neutron */ |
| 1275 | | coutf(" { RESTORE_NEUTRON(%i,%snlx, %snly, %snlz, %snlvx," |
| 1276 | | "%snlvy,%snlvz,%snlt,%snlsx,%snlsy, %snlsz, %snlp); }", |
| 1277 | | comp->index, ID_PRE, ID_PRE, ID_PRE, ID_PRE, ID_PRE, ID_PRE, |
| 1278 | | ID_PRE, ID_PRE, ID_PRE, ID_PRE, ID_PRE); |
| 1279 | | #elif MCCODE_PROJECT == 2 /* xray */ |
| 1280 | | coutf(" { RESTORE_XRAY(%i,%snlx, %snly, %snlz, %snlkx," |
| 1281 | | "%snlky,%snlkz,%snlphi,%snlt, %snlEx,%snlEy, %snlEz, %snlp); }", |
| 1282 | | comp->index, ID_PRE, ID_PRE, ID_PRE, ID_PRE, ID_PRE, ID_PRE, |
| 1283 | | ID_PRE, ID_PRE, ID_PRE, ID_PRE, ID_PRE, ID_PRE); |
| 1284 | | #endif |
| | 1207 | coutf(" { %s(%i,", restore, comp->index); /* RESTORE */ |
| | 1208 | for(i = 0; i < NUM_STATE_PARS; i++) |
| | 1209 | if (i < NUM_STATE_PARS-1) coutf(" %snl%s,", ID_PRE, statepars_all[i]); |
| | 1210 | else coutf(" %snl%s);",ID_PRE, statepars_all[i]); |
| 1298 | | #if MCCODE_PROJECT == 1 /* neutron */ |
| 1299 | | coutf(" %sDEBUG_STATE(%snlx, %snly, %snlz, %snlvx, %snlvy, %snlvz," |
| 1300 | | "%snlt, %snlsx,%snlsy,%snlsz, %snlp)", |
| 1301 | | ID_PRE, ID_PRE, ID_PRE, ID_PRE, ID_PRE, ID_PRE, ID_PRE, |
| 1302 | | ID_PRE, ID_PRE, ID_PRE, ID_PRE, ID_PRE); |
| 1303 | | #elif MCCODE_PROJECT == 2 /* xray */ |
| 1304 | | coutf(" %sDEBUG_STATE(%snlx, %snly, %snlz, %snlkx, %snlky, %snlkz," |
| 1305 | | "%snlphi,%snlt, %snlEx,%snlEy,%snlEz, %snlp)", |
| 1306 | | ID_PRE, ID_PRE, ID_PRE, ID_PRE, ID_PRE, ID_PRE, ID_PRE, |
| 1307 | | ID_PRE, ID_PRE, ID_PRE, ID_PRE, ID_PRE, ID_PRE); |
| 1308 | | #endif |
| | 1221 | coutf(" %sDEBUG_STATE(", ID_PRE); |
| | 1222 | for(i = 0; i < NUM_STATE_PARS; i++) |
| | 1223 | if (i < NUM_STATE_PARS-1) coutf("%snl%s,", ID_PRE, statepars_all[i]); |
| | 1224 | else coutf("%snl%s)", ID_PRE, statepars_all[i]); |
| 1348 | | #if MCCODE_PROJECT == 1 /* neutron */ |
| 1349 | | coutf(" %sDEBUG_STATE(%snlx, %snly, %snlz, %snlvx, %snlvy, %snlvz," |
| 1350 | | "%snlt, %snlsx,%snlsy,%snlsz, %snlp)", |
| 1351 | | ID_PRE, ID_PRE, ID_PRE, ID_PRE, ID_PRE, ID_PRE, ID_PRE, |
| 1352 | | ID_PRE, ID_PRE, ID_PRE, ID_PRE, ID_PRE); |
| 1353 | | #elif MCCODE_PROJECT == 2 /* xray */ |
| 1354 | | coutf(" %sDEBUG_STATE(%snlx, %snly, %snlz, %snlkx, %snlky, %snlkz," |
| 1355 | | "%snlphi,%snlt, %snlEx,%snlEy,%snlEz, %snlp)", |
| 1356 | | ID_PRE, ID_PRE, ID_PRE, ID_PRE, ID_PRE, ID_PRE, ID_PRE, |
| 1357 | | ID_PRE, ID_PRE, ID_PRE, ID_PRE, ID_PRE, ID_PRE); |
| 1358 | | #endif |
| | 1264 | coutf(" %sDEBUG_STATE(", ID_PRE); |
| | 1265 | for(i = 0; i < NUM_STATE_PARS; i++) |
| | 1266 | if (i < NUM_STATE_PARS-1) coutf("%snl%s,", ID_PRE, statepars_all[i]); |
| | 1267 | else coutf("%snl%s)", ID_PRE, statepars_all[i]); |
| 1364 | | coutf(" %snx = %snlx;", ID_PRE, ID_PRE); |
| 1365 | | coutf(" %sny = %snly;", ID_PRE, ID_PRE); |
| 1366 | | coutf(" %snz = %snlz;", ID_PRE, ID_PRE); |
| 1367 | | #if MCCODE_PROJECT == 1 /* neutron */ |
| 1368 | | coutf(" %snvx = %snlvx;", ID_PRE, ID_PRE); |
| 1369 | | coutf(" %snvy = %snlvy;", ID_PRE, ID_PRE); |
| 1370 | | coutf(" %snvz = %snlvz;", ID_PRE, ID_PRE); |
| 1371 | | coutf(" %snt = %snlt;", ID_PRE, ID_PRE); |
| 1372 | | coutf(" %snsx = %snlsx;", ID_PRE, ID_PRE); |
| 1373 | | coutf(" %snsy = %snlsy;", ID_PRE, ID_PRE); |
| 1374 | | coutf(" %snsz = %snlsz;", ID_PRE, ID_PRE); |
| 1375 | | #elif MCCODE_PROJECT == 2 /* xray */ |
| 1376 | | coutf(" %snkx = %snlkx;", ID_PRE, ID_PRE); |
| 1377 | | coutf(" %snky = %snlky;", ID_PRE, ID_PRE); |
| 1378 | | coutf(" %snkz = %snlkz;", ID_PRE, ID_PRE); |
| 1379 | | coutf(" %snphi = %snlphi;", ID_PRE, ID_PRE); |
| 1380 | | coutf(" %snt = %snlt;", ID_PRE, ID_PRE); |
| 1381 | | coutf(" %snEx = %snlEx;", ID_PRE, ID_PRE); |
| 1382 | | coutf(" %snEy = %snlEy;", ID_PRE, ID_PRE); |
| 1383 | | coutf(" %snEz = %snlEz;", ID_PRE, ID_PRE); |
| 1384 | | #endif |
| 1385 | | coutf(" %snp = %snlp;", ID_PRE, ID_PRE); |
| | 1273 | for(i = 0; i < NUM_STATE_PARS; i++) |
| | 1274 | coutf(" %sn%s = %snl%s;", ID_PRE, statepars_all[i], ID_PRE, statepars_all[i]); |
| | 1275 | cout(""); |