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

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

erreur de remplissage des histos corrigée

File size: 3.8 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  // 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);
49double getUnnormalizedTranspPhaseSpaceArea(unsigned TranspIndexAbs, unsigned TranspIndexOrd);
50
51inline double dimensionalFactorFromTransportToGraphics(unsigned index) {
52  if ( index == 0 || index == 2 || index == 4 ) return 10.;
53  else return  1.0;
54}
55
56 inline string transportVariableName(unsigned index) {
57  switch ( index ) {
58  case 0 : return  " x ";
59  case 1 : return  " x' ";
60  case 2 : return " y ";
61  case 3 : return " y' ";
62  case 4 : return " l ";
63  case 5 : return "dp/p";
64  default : { 
65    cout << " particleBeam::transportVariableName : coordinate index ERROR index :  "<< index << endl;
66    return "";
67  }
68  }
69 }
70
71 inline string graphicTransportUnitName(unsigned index) {
72  switch ( index ) {
73  case 0 : return  " mm ";
74  case 1 : return  " mrad ";
75  case 2 : return " mm ";
76  case 3 : return " mrad ";
77  case 4 : return " mm ";
78  case 5 : return " % ";
79  default : { 
80    cout << " particleBeam::transportVariableName : coordinate index ERROR index :  "<< index << endl;
81    return "";
82  }
83  }
84 }
85
86 public:
87
88  particleBeam(); 
89  virtual ~particleBeam() {;}
90
91  void buildMomentRepresentation();
92  void clear();
93  int getNbParticles() const;
94  const beam2Moments&  getTransportMoments() const;
95  double getUnnormalizedEmittanceX();
96  double getP0Transport() const;
97  double referenceKineticEnergyMeV() const;
98  bool particleRepresentationOk() const;
99  bool momentRepresentationOk() const;
100  void  addParticle( bareParticle p);
101  const vector<bareParticle>& getParticleVector() const;
102  vector<bareParticle>& getParticleVector(); 
103  double getXmaxRms();
104  void getVariance(double& varx, double& vary, double& varz) const;
105  void set2Moments(beam2Moments& moments);
106  void setWithParticles(vector<double>& centroid, bareParticle& referencePart, vector<bareParticle>& particles);
107  void printAllXYZ() const;
108  void Zrange(double& zmin, double& zmax) const;
109  //  void donneesDessinEllipseXxp(vector<double>& xcor, vector<double>& ycor);
110  void donneesDessinEllipse(vector<double>& xcor, vector<double>& ycor, vector<string>& legende, unsigned indexAbs, unsigned indexOrd);
111  void particlesPhaseSpaceData(vector<double>& xcor, vector<double>& ycor, unsigned indexAbs, unsigned indexOrd);
112  virtual string FileOutputFlow() const;
113  virtual bool FileInput(ifstream& ifs);
114
115  void histogramme(unsigned int index,vector<double>&xcor,vector<int>& hist,double out[3]);
116};
117#endif
Note: See TracBrowser for help on using the repository browser.