Fork me on GitHub

source: git/external/Hector/H_BeamLineParser.cc@ c5696dd

Last change on this file since c5696dd was 3c40083, checked in by pavel <pavel@…>, 11 years ago

switch to a more stable Hector version

  • Property mode set to 100644
File size: 4.7 KB
Line 
1/*
2---- Hector the simulator ----
3 A fast simulator of particles through generic beamlines.
4 J. de Favereau, X. Rouby ~~~ hector_devel@cp3.phys.ucl.ac.be
5
6 http://www.fynu.ucl.ac.be/hector.html
7
8 Centre de Physique des Particules et de Phénoménologie (CP3)
9 Université Catholique de Louvain (UCL)
10*/
11
12/// \file H_BeamLineParser.cc
13/// \brief Reader for madx tables
14///
15/// Notes : Vᅵifier que tous les SBEND sont toujours appelᅵ MB. Et seulement comme ᅵ !
16/// Vï¿œifier qu'il n'y a pas de problï¿œe d'inversion H/V QUADRUPOLES
17/// no distinction between H and Vkickers ?
18/// The identification of the element is based on the values of k1l, k2l, hkick, vkick and on their name.
19/// x and y are put in m
20
21// c++ #includes
22#include <iostream>
23#include <fstream>
24#include <sstream>
25
26//local #includes
27#include "H_BeamLineParser.h"
28#include "H_Parameters.h"
29using namespace std;
30
31
32/// Identifies the column content from its header
33int column_identification(const string header) {
34 // identifies the column type from its name
35
36 if (header=="NAME") {return MADX_NAME; }
37 else if (header=="KEYWORD") {return MADX_KEYWORD; }
38 else if (header=="S") {return MADX_S; }
39 else if (header=="L") {return MADX_L; }
40 else if (header=="K0L") {return MADX_K0L; }
41 else if (header=="K1L") {return MADX_K1L;}
42 else if (header=="K2L") {return MADX_K2L;}
43 else if (header=="K3L") {return MADX_K3L;}
44 else if (header=="HKICK") {return MADX_HKICK;}
45 else if (header=="VKICK") {return MADX_VKICK;}
46 else if (header=="KICK") {return MADX_KICK;}
47 else if (header=="BETX") {return MADX_BETX;}
48 else if (header=="BETY") {return MADX_BETY;}
49 else if (header=="ALFX") {return MADX_ALFX;}
50 else if (header=="ALFY") {return MADX_ALFY;}
51 else if (header=="MUX") {return MADX_MUX;}
52 else if (header=="MUY") {return MADX_MUY;}
53 else if (header=="DX") {return MADX_DX;}
54 else if (header=="DY") {return MADX_DY;}
55 else if (header=="DPX") {return MADX_DPX;}
56 else if (header=="DPY") {return MADX_DPY;}
57 else if (header=="X") {return MADX_X;}
58 else if (header=="Y") {return MADX_Y;}
59 else if (header=="PX") {return MADX_PX;}
60 else if (header=="PY") {return MADX_PY;}
61 else if (header=="APERTYPE") {return MADX_APERTYPE;}
62 else if (header=="APER_1") {return MADX_APER_1;}
63 else if (header=="APER_2") {return MADX_APER_2;}
64 else if (header=="APER_3") {return MADX_APER_3;}
65 else if (header=="APER_4") {return MADX_APER_4;}
66 else if (header=="PARENT") {return MADX_PARENT;}
67 return MADX_UNKNOWN;
68}
69
70void H_BeamLineParser::init() {
71 name="";
72 apertype="";
73 keyword="";
74 parent="";
75 s=0; l=0; k0l=0; k1l=0; k2l=0; k3l=0; hkick=0; vkick=0; betx=0;
76 alfx=0; mux=0; dx=0; dpx=0; x=0; px=0; bety=0; alfy=0; muy=0;
77 dy=0; dpy=0; y=0; py=0; aper_1=0; aper_2=0; aper_3=0; aper_4=0;
78}
79
80void H_BeamLineParser::setProperties(istream& input, const unsigned int col_type) {
81
82 switch(col_type) {
83 case MADX_NAME: input >> name; break;
84 case MADX_KEYWORD: input >> keyword; break;
85 case MADX_S: input >> s; break;
86 case MADX_L: input >> l; break;
87 case MADX_K0L: input >> k0l; break;
88 case MADX_K1L : input >> k1l; break;
89 case MADX_K2L: input >> k2l; break;
90 case MADX_K3L: input >> k3l; break;
91 case MADX_HKICK: input >> hkick; break;
92 case MADX_VKICK: input >> vkick; break;
93 case MADX_BETX: input >> betx; break;
94 case MADX_ALFX: input >> alfx; break;
95 case MADX_MUX: input >> mux; break;
96 case MADX_DX: input >> dx; break;
97 case MADX_DPX: input >> dpx; break;
98 case MADX_X: input >> x; x *=URAD; break;
99 case MADX_PX: input >> px; break;
100 case MADX_BETY: input >> bety; break;
101 case MADX_ALFY: input >> alfy; break;
102 case MADX_MUY: input >> muy; break;
103 case MADX_DY: input >> dy; break;
104 case MADX_DPY: input >> dpy; break;
105 case MADX_Y: input >> y; y*=URAD; break;
106 case MADX_PY: input >> py; break;
107 case MADX_APERTYPE: input >> apertype; break;
108 case MADX_APER_1: input >> aper_1; break;
109 case MADX_APER_2: input >> aper_2; break;
110 case MADX_APER_3: input >> aper_3; break;
111 case MADX_APER_4: input >> aper_4; break;
112 case MADX_PARENT: input >> parent; break;
113 default:break;
114 } // switch
115}
116
117
118void H_BeamLineParser::printProperties() const {
119//KEYWORD NAME PARENT L K0L K1L K2L K3L S BETX BETY DX DY XC YC ALFX ALFY MUX MUY DPX PXC PYC
120 cout << " keyword = " << keyword;
121 cout << " name = " << name;
122 cout << " l = " << l;
123 cout << " k0l = " << k0l;
124 cout << " k1l = " << k1l;
125 cout << " k2l = " << k2l;
126 cout << " k3l = " << k3l;
127 cout << " s = " << s << endl;
128 cout << endl;
129}
Note: See TracBrowser for help on using the repository browser.