Fork me on GitHub

source: svn/trunk/Utilities/Hector/src/H_BeamLineParser.cc@ 495

Last change on this file since 495 was 281, checked in by Xavier Rouby, 16 years ago

new Hector version

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