Changeset 366 in PSPA for Interface_Web


Ignore:
Timestamp:
Mar 5, 2013, 6:59:13 PM (11 years ago)
Author:
lemeur
Message:

amelioration des les graphiques d'espace de phase

Location:
Interface_Web/trunk/pspaWT/sources
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • Interface_Web/trunk/pspaWT/sources/controler/include/particleBeam.h

    r363 r366  
    4646  void remplissageDesHistogrammes(double val[2],vector<double>vshf,vector<double>&xcor,vector<int>& hist,int& cnts);
    4747
     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
    4886 public:
    4987
     
    5593  int getNbParticles() const;
    5694  const beam2Moments&  getTransportMoments() const;
    57   double getSigmaTransportij(unsigned i, unsigned j);
    5895  double getUnnormalizedEmittanceX();
    5996  double getP0Transport() const;
  • Interface_Web/trunk/pspaWT/sources/controler/src/particleBeam.cc

    r363 r366  
    3434}
    3535
    36 double particleBeam::getSigmaTransportij(unsigned i, unsigned j)  {
    37   if ( i < 1 || i > 6 || j < 1 || j > 6 ) {
     36double particleBeam::getSigmaTransportij(unsigned indexI, unsigned indexJ)  {
     37  if (  indexI > 5 ||  indexJ > 5 ) {
    3838    cerr << " particleBeam::getSigmaTransportij() indices out of range  " << endl;
    3939    return 0.0;
     
    4343    return 0.0;
    4444  }
    45 
    46   i--;
    47   j--;
    48   if ( j > i ) {
    49     unsigned aux = i;
    50     i = j;
    51     j = aux;
    52   }
    53   return ( rij_.getMatrix().at(i) ).at(j);
    54 }
    55 
    56 double particleBeam::getUnnormalizedEmittanceX()
    57 {
    58   double r = getSigmaTransportij(2,1);
     45 if ( indexI >= indexJ ) {
     46   return ( rij_.getMatrix().at(indexI) ).at(indexJ);
     47 } else {
     48   return ( rij_.getMatrix().at(indexJ) ).at(indexI);
     49 }
     50 
     51}
     52
     53double particleBeam::getUnnormalizedEmittanceX() {
     54  double r = getSigmaTransportij(1,0);
    5955  double rac = (1 - r*r);
    6056  if ( rac <= 0.0 ) {
     
    6258  }
    6359  rac = sqrt(1 - r*r);
    64   return  10.*getSigmaTransportij(1,1) * getSigmaTransportij(2,2) * rac; // en pi.mm.mrad
    65 }
     60  return  dimensionalFactorFromTransportToGraphics(0)*getSigmaTransportij(0,0) * getSigmaTransportij(1,1) * rac; // en pi.mm.mrad
     61}
     62
     63double particleBeam::getUnnormalizedTranspPhaseSpaceArea(unsigned TranspIndexAbs, unsigned TranspIndexOrd) {
     64  if (  TranspIndexAbs == TranspIndexOrd ) return 0.0;
     65  double r = getSigmaTransportij(TranspIndexAbs,TranspIndexOrd);
     66  double rac = (1 - r*r);
     67  if ( rac <= 0.0 ) {
     68    return 0.0;
     69  }
     70  rac = sqrt(1 - r*r);
     71  return  dimensionalFactorFromTransportToGraphics(TranspIndexAbs)*getSigmaTransportij(TranspIndexAbs,TranspIndexAbs) *
     72             dimensionalFactorFromTransportToGraphics(TranspIndexOrd)*getSigmaTransportij(TranspIndexOrd,TranspIndexOrd) * rac; // en pi.mm.mrad
     73}
     74
     75
    6676
    6777double particleBeam::getP0Transport() const {
     
    375385  }
    376386}
     387
    377388unsigned particleBeam::indexFromPspaToTransport(unsigned index) const {
    378389  cout << " indexFromPspaToTransport entree : " << index << endl;
    379   unsigned indexRetour;
    380390  switch ( index ) {
    381   case 0 : return  0; break; // x
    382   case 1 : return  2; break; // y
    383   case 2 : return  4; break; // z -> l
    384   case 3 : return  1; break; // xp
    385   case 4 : return  3; break; // yp
    386   case 5 : return  5; break; // de/E
     391  case 0 : return  0; // x
     392  case 1 : return  2; // y
     393  case 2 : return  4; // z -> l
     394  case 3 : return  1; // xp
     395  case 4 : return  3; // yp
     396  case 5 : return  5; // de/E
    387397  default : {
    388398    cout << " particleBeam::indexFromPspaToTransport : coordinate index ERROR inital index :  "<< index << endl;
     
    391401  }
    392402}
     403
    393404
    394405void particleBeam::donneesDessinEllipse(vector<double>& xcor, vector<double>& ycor, vector<string>& legende, unsigned indexAbs, unsigned indexOrd) {
     
    409420  indexOrd = indexFromPspaToTransport(indexOrd);
    410421
     422
     423  double dimensionalFactorX, dimensionalFactorY; // to mm, if necessary
     424  dimensionalFactorX = dimensionalFactorFromTransportToGraphics(indexAbs);
     425  dimensionalFactorY = dimensionalFactorFromTransportToGraphics(indexOrd);
     426
     427
    411428  // a completer
    412429  legende.clear();
    413   if ( indexAbs == 0 && indexOrd == 1 ) {
    414     string namx = " x ";
    415     string namy = " xp ";
    416     string  emitt = mixedTools::doubleToString(getUnnormalizedEmittanceX());
    417     string xmax = "x max= ";
    418     string valXmax = mixedTools::doubleToString(10.0*getSigmaTransportij(1,1)); // mm
    419     string ymax = "x' max= ";
    420     string valYmax = mixedTools::doubleToString(getSigmaTransportij(2,2)); // mm
     430  //  if ( indexAbs == 0 && indexOrd == 1 ) {
     431    string namx = transportVariableName(indexAbs);
     432    string namy = transportVariableName(indexOrd);
     433    double em = getUnnormalizedTranspPhaseSpaceArea(indexAbs,indexOrd) ;
     434    string  emitt = mixedTools::doubleToString(getUnnormalizedTranspPhaseSpaceArea(indexAbs,indexOrd));
     435    string xmax = namx + "max= ";
     436    string valXmax = mixedTools::doubleToString(dimensionalFactorX*getSigmaTransportij(indexAbs,indexAbs));
     437    string ymax = namy + "max= ";
     438    string valYmax = mixedTools::doubleToString(dimensionalFactorY*getSigmaTransportij(indexOrd,indexOrd)); // mm
    421439    string correl = " correlation ";
    422     string valCorrel = mixedTools::doubleToString(getSigmaTransportij(2,1));
    423     string xunit = " mm";
    424     string yunit = " mrad";
     440    string valCorrel = mixedTools::doubleToString(getSigmaTransportij(1,0));
     441    string xunit = graphicTransportUnitName(indexAbs);
     442    string yunit = graphicTransportUnitName(indexOrd);
    425443    legende.push_back( "emittance" + namx + "," + namy + ": " + emitt + " pi." + xunit + "." + yunit);
    426444    legende.push_back( xmax + valXmax + xunit);
    427445    legende.push_back( ymax + valYmax + yunit);
    428   } else {
    429     legende.push_back(" text of legend not yet programmed ");
    430   }
     446  // } else {
     447  //   legende.push_back(" text of legend not yet programmed ");
     448  // }
    431449
    432450  cout << " index x" << indexAbs << " index y " << indexOrd << endl;
    433 
    434   double xm = ( rij_.getMatrix().at(indexAbs) ).at(indexAbs);
    435   double ym = ( rij_.getMatrix().at(indexOrd) ).at(indexOrd);
     451  double xm = dimensionalFactorX*( rij_.getMatrix().at(indexAbs) ).at(indexAbs);
     452  double ym = dimensionalFactorY*( rij_.getMatrix().at(indexOrd) ).at(indexOrd);
    436453  double r;
    437454  if ( indexOrd > indexAbs ) {
  • Interface_Web/trunk/pspaWT/sources/userInterface/src/GWt_pspaApplication.cc

    r363 r366  
    594594  ellipseDialog->show();
    595595  new WText(nameOfCase_, ellipseDialog->contents());
    596   // new WText(nameOfCase_ + " : emittance " + namex + " , " + namey + " : " + mixedTools::doubleToString(beam->getUnnormalizedEmittanceX()) + " pi.mm.mrad" , ellipseDialog->contents());
    597   // new WBreak(ellipseDialog->contents());
    598   // new WText(" xmax = " + mixedTools::doubleToString(beam->getSigmaTransportij(1,1)) + " cm ", ellipseDialog->contents());
    599   // new WBreak(ellipseDialog->contents());
    600   // new WText(" x' max = " + mixedTools::doubleToString(beam->getSigmaTransportij(2,2)) + " mrad ", ellipseDialog->contents());
    601   // new WBreak(ellipseDialog->contents());
    602   // new WText(" corr. 12 = " + mixedTools::doubleToString(beam->getSigmaTransportij(2,1))  + " sqrt(cm.rad) ", ellipseDialog->contents());
    603596 
    604597  vector<double> xcor;
     
    836829  double out[3]= {0.0};
    837830
    838   int iabs= choixVariableHisto_->currentIndex(); 
     831  unsigned iabs= choixVariableHisto_->currentIndex(); 
    839832  string xname= choixVariableHisto_->currentText().toUTF8();
    840833  beam->histogramme(iabs,xcor,hist,cnts,out);
Note: See TracChangeset for help on using the changeset viewer.