1 | #ifndef PARTICLEBEAM_SEEN |
---|
2 | #define PARTICLEBEAM_SEEN |
---|
3 | #include <iostream> |
---|
4 | #include <sstream> |
---|
5 | #include <stdio.h> |
---|
6 | |
---|
7 | #include<cmath> |
---|
8 | |
---|
9 | #include <vector> |
---|
10 | |
---|
11 | #include "bareParticle.h" |
---|
12 | #include "mathematicalTools.h" |
---|
13 | #include "mathematicalConstants.h" |
---|
14 | #include "PhysicalConstants.h" |
---|
15 | #include "nomdElements.h" |
---|
16 | |
---|
17 | using namespace std; |
---|
18 | |
---|
19 | struct particle |
---|
20 | { |
---|
21 | float xx, xxp, begamx,yy,yyp,begamy,z, begamz,phi,wz; |
---|
22 | float phi0, ksi1,ksi2,ksi3; |
---|
23 | int ne,np,ngood,npart; |
---|
24 | |
---|
25 | int readFromParmelaFile(FILE* fp) |
---|
26 | { |
---|
27 | return fscanf(fp, " %e %e %e %e %e %e %e %e %e %e %d %d %d %d %e %e %e %e \n", &xx, &xxp, &begamx,&yy,&yyp,&begamy,&z, &begamz,&phi,&wz,&ne,&np,&ngood,&npart,&phi0, &ksi1,&ksi2,&ksi3); |
---|
28 | } |
---|
29 | void imprim() |
---|
30 | { |
---|
31 | printf( " %e %e %e %e %e %e %e %e %e %e %d %d %d, %d %e %e %e %e \n", xx, xxp, begamx,yy,yyp,begamy,z, begamz,phi,wz,ne,np,ngood,npart,phi0, ksi1,ksi2,ksi3); |
---|
32 | } |
---|
33 | }; |
---|
34 | |
---|
35 | |
---|
36 | |
---|
37 | class particleBeam |
---|
38 | { |
---|
39 | |
---|
40 | bool particleRepresentationOk_; |
---|
41 | bool momentRepresentationOk_; |
---|
42 | |
---|
43 | bareParticle referenceParticle_; |
---|
44 | |
---|
45 | vector<bareParticle> goodPartic_; |
---|
46 | |
---|
47 | vector< vector<double> > rij_transportMoments_; |
---|
48 | vector<double> centroid_; |
---|
49 | double P0Transport_; |
---|
50 | |
---|
51 | |
---|
52 | void readTransportMoments(ifstream& inp); |
---|
53 | |
---|
54 | void impressionDesMoments() const; |
---|
55 | |
---|
56 | |
---|
57 | public: |
---|
58 | |
---|
59 | particleBeam() |
---|
60 | { |
---|
61 | rij_transportMoments_.resize(6); |
---|
62 | unsigned dim=0; |
---|
63 | unsigned k; |
---|
64 | for ( k=0; k < 6; k++) |
---|
65 | { |
---|
66 | rij_transportMoments_.at(k).resize(++dim); |
---|
67 | } |
---|
68 | P0Transport_ = 0.0; |
---|
69 | particleRepresentationOk_ = false; |
---|
70 | momentRepresentationOk_ = false; |
---|
71 | |
---|
72 | } |
---|
73 | |
---|
74 | ~particleBeam() {;} |
---|
75 | |
---|
76 | bool setFromParmela(unsigned numeroElement,double referencefrequency); |
---|
77 | void buildMomentRepresentation(); |
---|
78 | |
---|
79 | // bool setFromTransport(ifstream& inp, unsigned nblignes); |
---|
80 | bool setFromTransport(string elementLabel, typedElement elemType); |
---|
81 | |
---|
82 | inline void clear() |
---|
83 | { |
---|
84 | goodPartic_.clear(); |
---|
85 | P0Transport_ = 0.0; |
---|
86 | particleRepresentationOk_ = false; |
---|
87 | momentRepresentationOk_ = false; |
---|
88 | } |
---|
89 | |
---|
90 | inline int getNbParticles() const |
---|
91 | { |
---|
92 | return goodPartic_.size(); |
---|
93 | } |
---|
94 | |
---|
95 | inline const vector< vector<double> >& getTransportMoments() const { return rij_transportMoments_;} |
---|
96 | inline double getP0Transport() const { return P0Transport_;} |
---|
97 | inline bool particleRepresentationOk() const {return particleRepresentationOk_;} |
---|
98 | inline bool momentRepresentationOk() const {return momentRepresentationOk_;} |
---|
99 | |
---|
100 | |
---|
101 | inline void addParticle( bareParticle p) |
---|
102 | { |
---|
103 | goodPartic_.push_back(p); |
---|
104 | } |
---|
105 | |
---|
106 | |
---|
107 | |
---|
108 | inline const vector<bareParticle>& getParticleVector() const |
---|
109 | { |
---|
110 | return goodPartic_; |
---|
111 | } |
---|
112 | |
---|
113 | inline vector<bareParticle>& getParticleVector() |
---|
114 | { |
---|
115 | return goodPartic_; |
---|
116 | } |
---|
117 | |
---|
118 | void getVariance(double& varx, double& vary, double& varz) const; |
---|
119 | |
---|
120 | |
---|
121 | void printAllXYZ() const; |
---|
122 | |
---|
123 | |
---|
124 | void Zrange(double& zmin, double& zmax) const; |
---|
125 | |
---|
126 | void donneesDessinEllipseXxp(vector<double>& xcor, vector<double>& ycor); |
---|
127 | |
---|
128 | |
---|
129 | virtual string FileOutputFlow() const; |
---|
130 | |
---|
131 | |
---|
132 | virtual bool FileInput(ifstream& ifs); |
---|
133 | |
---|
134 | |
---|
135 | }; |
---|
136 | |
---|
137 | |
---|
138 | #endif |
---|