source: PSPA/Interface_Web/trunk/pspaWT/sources/controler/include/particleBeam.h @ 442

Last change on this file since 442 was 442, checked in by lemeur, 11 years ago

ajout traitement utilisateur

File size: 4.6 KB
Line 
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
13using namespace std;
14
15class particleBeam
16{
17  bool particleRepresentationOk_;
18  bool momentRepresentationOk_;
19  beam2Moments rij_;
20  double P0Transport_;
21
22  // ce faisceau contient les coordonnees des particules quand elles
23  // passe en un z, qui est celui de la particules de reference (
24  // (particule donne par l'attribut  referenceParticle_ ci-dessous ;
25  // cette particule est abstraite, car elle est dupliquee dans le faisceau
26  // proprement dit, et n'intervient plus, en tant que telle, dans la dynamique)
27
28  // Une particule courante est definie par :
29  // x (cm)
30  // y (cm)
31  // cdeltat = dephasage, donc décalage en z, exprime en c.dt soit, en cm 
32  // cdeltat > 0 implique que la particule est en avance sur la particule de ref.
33  // gamma.betax (radians ? a verifier)
34  // gamma.betay
35  // gamma.betaz
36
37  vector<bareParticle> relativePartic_;
38  // La particule de reference (abstraite) est definie par x,y,z,gamma.betax, gamma.betay, gamma.betaz
39  // elle est dupliquee dans le faisceau proprement dit (relativePartic_) avec z = 0;
40
41  bareParticle referenceParticle_;
42 
43
44  vector<double> centroid_;
45
46  void impressionDesMoments() const;
47  void razDesMoments();
48  void particlesPhaseSpaceComponent(vector<double>& coord, unsigned index);
49  unsigned indexFromPspaToTransport(unsigned index) const;
50
51  void histogramInitialize(unsigned int index,vector<double>& vshf,double out[3]);
52  void histogramPacking(double ecatyp,vector<double>vshf,vector<double>&xcor,vector<int>& hist);
53
54  double getSigmaTransportij(unsigned indexI, unsigned indexJ);
55double getUnnormalizedTranspPhaseSpaceArea(unsigned TranspIndexAbs, unsigned TranspIndexOrd);
56
57
58 unsigned pspaCoorIndexFromString(string nameCoor) const;
59 unsigned transportCoorIndexFromString(string nameCoor) const;
60
61inline double dimensionalFactorFromTransportToGraphics(unsigned index) {
62  if ( index == 0 || index == 2 || index == 4 ) return 10.;   // mm
63  else return  1.0;  // mrad
64}
65
66
67
68
69 inline string transportVariableName(unsigned index) {
70  switch ( index ) {
71  case 0 : return  " x ";
72  case 1 : return  " x' ";
73  case 2 : return " y ";
74  case 3 : return " y' ";
75  case 4 : return " l ";
76  case 5 : return "dp/p";
77  default : { 
78    cout << " particleBeam::transportVariableName : coordinate index ERROR index :  "<< index << endl;
79    return "";
80  }
81  }
82 }
83
84
85
86
87 inline string graphicTransportUnitName(unsigned index) {
88  switch ( index ) {
89  case 0 : return  " mm ";
90  case 1 : return  " mrad ";
91  case 2 : return " mm ";
92  case 3 : return " mrad ";
93  case 4 : return " mm ";
94  case 5 : return " % ";
95  default : { 
96    cout << " particleBeam::transportVariableName : coordinate index ERROR index :  "<< index << endl;
97    return "";
98  }
99  }
100 }
101
102
103 public:
104
105  particleBeam(); 
106  virtual ~particleBeam() {;}
107
108  void buildMomentRepresentation();
109  void clear();
110  int getNbParticles() const;
111  const beam2Moments&  getTransportMoments() const;
112  double getUnnormalizedEmittanceX();
113  double getP0Transport() const;
114  double referenceKineticEnergyMeV() const;
115  bool particleRepresentationOk() const;
116  bool momentRepresentationOk() const;
117  void  addParticle( bareParticle p);
118  const vector<bareParticle>& getParticleVector() const;
119  vector<bareParticle>& getParticleVector(); 
120  double getXmaxRms();
121  //  void getVariance(double& varx, double& vary, double& varz) const;
122  void set2Moments(beam2Moments& moments);
123  void setWithParticles(vector<double>& centroid, bareParticle& referencePart, vector<bareParticle>& particles);
124  void printAllXYZ() const;
125  void ZrangeCdt(double& zmin, double& zmax) const; // extension en phase (cm)
126  void donneesDessinEllipse(vector<double>& xcor, vector<double>& ycor, vector<string>& legende, string namex, string namey);
127  void particlesPhaseSpaceData(vector<double>& xcor, vector<double>& ycor, vector<string>& legende, string namex, string namey);
128
129
130 // coordonnees d'une particule dans le faisceau deploye ( passage
131 // d'une representation z=cte a une representation t=cte)
132 TRIDVECTOR coordonneesDeployees(unsigned particleIndex, double cdtShift = 0.0);
133
134 inline TRIDVECTOR betaGamma(unsigned particleIndex) {
135     return relativePartic_.at(particleIndex).getBetaGamma();
136   }
137
138  virtual string fileOutputFlow() const;
139  virtual bool FileInput(ifstream& ifs);
140  virtual void writeToAMLFile(string fileName);
141  virtual bool readFromAMLFile(string fileName);
142
143  void histogramme(unsigned int index,vector<double>&xcor,vector<int>& hist,vector<string>& legende);
144};
145#endif
Note: See TracBrowser for help on using the repository browser.