1 | #ifndef PARTICLEBEAM_SEEN |
---|
2 | #define PARTICLEBEAM_SEEN |
---|
3 | #include <iostream> |
---|
4 | #include <sstream> |
---|
5 | #include <stdio.h> |
---|
6 | #include<cmath> |
---|
7 | #include <vector> |
---|
8 | |
---|
9 | #include "bareParticle.h" |
---|
10 | #include "nomdElements.h" |
---|
11 | #include "beam2Moments.h" |
---|
12 | |
---|
13 | using namespace std; |
---|
14 | |
---|
15 | class particleBeam |
---|
16 | { |
---|
17 | bool particleRepresentationOk_; |
---|
18 | bool momentRepresentationOk_; |
---|
19 | beam2Moments rij_; |
---|
20 | double P0Transport_; |
---|
21 | |
---|
22 | // la representation du faisceau de particules sera a preciser ulterieurement |
---|
23 | // Pour l'instant une particule courante est definie par : |
---|
24 | // x |
---|
25 | // y |
---|
26 | // deltaz = z - z0 (z0 est le z de la particule de reference) |
---|
27 | // gamma.betax |
---|
28 | // gamma.betay |
---|
29 | // gamma.betaz |
---|
30 | vector<bareParticle> goodPartic_; |
---|
31 | |
---|
32 | // par ailleurs, la particules de reference est definie par x,y,z,gamma.betax, gamma.betay, gamma.betaz |
---|
33 | // elle est dupliquee dans le faisceau prorement dit (goodPartic_) avec z = z-z0 et ne doit, par consequent, |
---|
34 | // pas etre prise en compte dans les calculs de trajectoire. |
---|
35 | bareParticle referenceParticle_; |
---|
36 | |
---|
37 | |
---|
38 | vector<double> centroid_; |
---|
39 | |
---|
40 | void impressionDesMoments() const; |
---|
41 | void razDesMoments(); |
---|
42 | void particlesPhaseSpaceComponent(vector<double>& coord, unsigned index); |
---|
43 | unsigned indexFromPspaToTransport(unsigned index) const; |
---|
44 | |
---|
45 | void histogramInitialize(unsigned int index,vector<double>& vshf,double out[3]); |
---|
46 | void histogramPacking(double ecatyp,vector<double>vshf,vector<double>&xcor,vector<int>& hist); |
---|
47 | |
---|
48 | double getSigmaTransportij(unsigned indexI, unsigned indexJ); |
---|
49 | double getUnnormalizedTranspPhaseSpaceArea(unsigned TranspIndexAbs, unsigned TranspIndexOrd); |
---|
50 | |
---|
51 | |
---|
52 | unsigned pspaCoorIndexFromString(string nameCoor) const; |
---|
53 | unsigned transportCoorIndexFromString(string nameCoor) const; |
---|
54 | |
---|
55 | inline double dimensionalFactorFromTransportToGraphics(unsigned index) { |
---|
56 | if ( index == 0 || index == 2 || index == 4 ) return 10.; // mm |
---|
57 | else return 1.0; // mrad |
---|
58 | } |
---|
59 | |
---|
60 | |
---|
61 | |
---|
62 | |
---|
63 | inline string transportVariableName(unsigned index) { |
---|
64 | switch ( index ) { |
---|
65 | case 0 : return " x "; |
---|
66 | case 1 : return " x' "; |
---|
67 | case 2 : return " y "; |
---|
68 | case 3 : return " y' "; |
---|
69 | case 4 : return " l "; |
---|
70 | case 5 : return "dp/p"; |
---|
71 | default : { |
---|
72 | cout << " particleBeam::transportVariableName : coordinate index ERROR index : "<< index << endl; |
---|
73 | return ""; |
---|
74 | } |
---|
75 | } |
---|
76 | } |
---|
77 | |
---|
78 | |
---|
79 | |
---|
80 | |
---|
81 | inline string graphicTransportUnitName(unsigned index) { |
---|
82 | switch ( index ) { |
---|
83 | case 0 : return " mm "; |
---|
84 | case 1 : return " mrad "; |
---|
85 | case 2 : return " mm "; |
---|
86 | case 3 : return " mrad "; |
---|
87 | case 4 : return " mm "; |
---|
88 | case 5 : return " % "; |
---|
89 | default : { |
---|
90 | cout << " particleBeam::transportVariableName : coordinate index ERROR index : "<< index << endl; |
---|
91 | return ""; |
---|
92 | } |
---|
93 | } |
---|
94 | } |
---|
95 | |
---|
96 | public: |
---|
97 | |
---|
98 | particleBeam(); |
---|
99 | virtual ~particleBeam() {;} |
---|
100 | |
---|
101 | void buildMomentRepresentation(); |
---|
102 | void clear(); |
---|
103 | int getNbParticles() const; |
---|
104 | const beam2Moments& getTransportMoments() const; |
---|
105 | double getUnnormalizedEmittanceX(); |
---|
106 | double getP0Transport() const; |
---|
107 | double referenceKineticEnergyMeV() const; |
---|
108 | bool particleRepresentationOk() const; |
---|
109 | bool momentRepresentationOk() const; |
---|
110 | void addParticle( bareParticle p); |
---|
111 | const vector<bareParticle>& getParticleVector() const; |
---|
112 | vector<bareParticle>& getParticleVector(); |
---|
113 | double getXmaxRms(); |
---|
114 | void getVariance(double& varx, double& vary, double& varz) const; |
---|
115 | void set2Moments(beam2Moments& moments); |
---|
116 | void setWithParticles(vector<double>& centroid, bareParticle& referencePart, vector<bareParticle>& particles); |
---|
117 | void printAllXYZ() const; |
---|
118 | void Zrange(double& zmin, double& zmax) const; |
---|
119 | void donneesDessinEllipse(vector<double>& xcor, vector<double>& ycor, vector<string>& legende, string namex, string namey); |
---|
120 | void particlesPhaseSpaceData(vector<double>& xcor, vector<double>& ycor, vector<string>& legende, string namex, string namey); |
---|
121 | virtual string FileOutputFlow() const; |
---|
122 | virtual bool FileInput(ifstream& ifs); |
---|
123 | |
---|
124 | void histogramme(unsigned int index,vector<double>&xcor,vector<int>& hist,vector<string>& legende); |
---|
125 | }; |
---|
126 | #endif |
---|