source: PSPA/Interface_Web/trunk/pspaWT/sources/controler/src/sectorParameters.cc @ 431

Last change on this file since 431 was 431, checked in by touze, 11 years ago

systeme periodique (mailles) + multipoles + madx

File size: 2.0 KB
Line 
1
2//#include <cstdlib>
3
4#include "sectorParameters.h"
5#include "mixedTools.h"
6
7sectorParameters::sectorParameters() : parametersString_(NULL)
8{
9  geometry_= string("CIRCULAR");
10  nCells_ = 0;
11  lCell_ = 0.0;
12  pc_ = 0.0;
13  nbParam_ = 4;
14  parametersString_ = new string[nbParam_+1];
15}
16
17string* sectorParameters::getParametersString() const 
18{
19  parametersString_[0] = mixedTools::intToString(nbParam_);
20  parametersString_[1] = geometry_;
21  parametersString_[2] = mixedTools::intToString(nCells_);
22  parametersString_[3] = mixedTools::doubleToString(lCell_);
23  parametersString_[4] = mixedTools::doubleToString(pc_);
24  return parametersString_;
25}
26
27void sectorParameters::setParametersString(string* param)
28{
29  geometry_ = param[1].c_str();
30  nCells_ = atoi(param[2].c_str());
31  lCell_ = atof(param[3].c_str());
32  pc_ = atof(param[4].c_str());
33}
34
35void sectorParameters::raz()
36{
37  geometry_= string("CIRCULAR");
38  nCells_ = 0;
39  lCell_ = 0.0;
40  pc_ = 0.0;
41}
42
43string sectorParameters::FileOutputFlow() const
44{
45  ostringstream sortie;
46  sortie<<" lattice "<<endl;
47  sortie<<geometry_<<" "<<nCells_<<" "<<lCell_<<" "<<pc_<<endl;
48  return sortie.str(); 
49}
50
51void sectorParameters::FileInput(ifstream& ifs)
52{
53  ifs >> geometry_ >> nCells_ >> lCell_ >> pc_;
54}
55
56void sectorParameters::InputRep(UAPNode* root)
57{
58  UAPNode* node = root->addChild("lattice");
59  node->addAttribute("name","global_lattice");
60  node->addChild("geometry")->addAttribute("type",geometry_);
61  string txt = "";
62  txt = mixedTools::doubleToString(pc_);
63  node->addChild("pc")->addAttribute("design",txt);
64
65  node = root->addChild("sector");
66  node->addAttribute("name","sect");
67  txt = mixedTools::doubleToString(lCell_);
68  node->addAttribute("length",txt);
69  txt = mixedTools::intToString(nCells_);
70  node->addAttribute("repeat",txt);
71}
72
73int sectorParameters::getNumberOfCells() const {
74  return nCells_;
75}
76
77double sectorParameters::getCellLength() const {
78  return lCell_;
79}
80
81double sectorParameters::getParticleMomentum() const {
82  return pc_;
83}
84
85
Note: See TracBrowser for help on using the repository browser.