Presentation is loading. Please wait.

Presentation is loading. Please wait.

INSTITUTE OF HIGH ENERGY PHYSICS

Similar presentations


Presentation on theme: "INSTITUTE OF HIGH ENERGY PHYSICS"— Presentation transcript:

1 INSTITUTE OF HIGH ENERGY PHYSICS
中国科学院高能物理研究所 INSTITUTE OF HIGH ENERGY PHYSICS Program for sorting the magnet Dengjie Xiao Jie Gao Sha Bai Dou Wang Yiwei Wang Tianjian Bian Feng Su Huiping Geng CEPC AP meeting,

2 The instrument for the program
1. Mathematica 9 2. Eclipse+Java

3 The code in Mathematica 9
ClearAll["`*"] SetDirectory[NotebookDirectory[]]; t = Import["./cepc.txt", "Words"]; Import["./cepc.txt", "Elements"] a = VS22FFS_RN; b = B0; c = B2; d = B3; e = B4; f = B5; g = QDF; h = QDH; m = QDHFFS; n = SD; j = 1; For[i = 1, i <= 15381, i++, y = ToString[a] <> ToString[j] <> ","; If[t[[i]] == a, x[i] = y, x[i] = t[[i]]]; If[t[[i]] == a, j++, 0]]; Export["cepc.txt", Table[x[i], {i, 1, 15381}]]; y = ToString[b] <> ToString[j] <> ","; If[t[[i]] == b, x[i] = y, x[i] = t[[i]]]; If[t[[i]] == b, j++, 0]]; y = ToString[c] <> ToString[j] <> ","; If[t[[i]] == c, x[i] = y, x[i] = t[[i]]]; If[t[[i]] == c, j++, 0]]; y = ToString[d] <> ToString[j] <> ","; If[t[[i]] == d, x[i] = y, x[i] = t[[i]]]; If[t[[i]] == d, j++, 0]]; Export["cepc.txt", Table[x[i], {i, 1, 15381}]]; j = 1; For[i = 1, i <= 15381, i++, y = ToString[e] <> ToString[j] <> ","; If[t[[i]] == e, x[i] = y, x[i] = t[[i]]]; If[t[[i]] == e, j++, 0]]; y = ToString[f] <> ToString[j] <> ","; If[t[[i]] == f, x[i] = y, x[i] = t[[i]]]; If[t[[i]] == f, j++, 0]]; y = ToString[g] <> ToString[j] <> ","; If[t[[i]] == g, x[i] = y, x[i] = t[[i]]]; If[t[[i]] == g, j++, 0]]; y = ToString[h] <> ToString[j] <> ","; If[t[[i]] == h, x[i] = y, x[i] = t[[i]]]; If[t[[i]] == h, j++, 0]]; y = ToString[m] <> ToString[j] <> ","; If[t[[i]] == m, x[i] = y, x[i] = t[[i]]]; If[t[[i]] == m, j++, 0]]; y = ToString[n] <> ToString[j] <> ","; If[t[[i]] == n, x[i] = y, x[i] = t[[i]]]; If[t[[i]] == n, j++, 0]];

4 Result

5 Problem 1.需要手动输入每个磁铁名称,过程繁琐。 2.失去原来的转行标记,不方便查阅lattice。
3.步骤较多,仍需大量时间去编号,且容易出错。

6 The code in JAVA import java.io.File;
import java.io.BufferedReader; import java.io.File; import java.io.FileInputStream; //import java.io.FileNotFoundException; //import java.io.FileReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; public class ChangeFile { public static void main(String[] argv) { try { BufferedReader bufReader = new BufferedReader( new InputStreamReader( new FileInputStream( new File("D:/123.txt")))); StringBuffer strBuf = new StringBuffer(); int cnt=1; for (String tmp = null; (tmp = bufReader.readLine()) != null; tmp = null) { int pos=0; while ((pos = tmp.indexOf("B0", pos)) >= 0) { tmp = tmp.substring(0, pos) + ("B0" + (cnt++)) + tmp.substring((pos += "B0".length())); }// 在这里做替换操作 tmp = tmp.replaceAll("\\*", "#"); tmp = tmp.replaceFirst("===", "\\* "); tmp = tmp.replaceAll("===", ""); tmp = tmp.replaceAll("==", "==="); strBuf.append(tmp); strBuf.append(System.getProperty("line.separator")); } bufReader.close(); PrintWriter printWriter = new PrintWriter("D:/123.txt"); printWriter.write(strBuf.toString().toCharArray()); printWriter.flush(); printWriter.close(); } catch (IOException e) { e.printStackTrace();

7 Result

8 Summary 原先lattice磁铁的命名规则不是很好, 对编号过程产生了麻烦,以后可以在 允许的条件下先改磁铁命名再编号。
编号过程了解了两种工具,对接下来 做madx扫孔径的程序也很有帮助。

9 Thanks!


Download ppt "INSTITUTE OF HIGH ENERGY PHYSICS"

Similar presentations


Ads by Google