Changeset 377 in PSPA


Ignore:
Timestamp:
Mar 8, 2013, 2:24:40 PM (11 years ago)
Author:
touze
Message:

erreur de remplissage des histos corrigée

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

Legend:

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

    r371 r377  
    4343  unsigned indexFromPspaToTransport(unsigned index) const;
    4444
    45   void histogramComponent(vector<double>& coord,unsigned int index);
    4645  void histogramInitialize(unsigned int index,vector<double>& vshf,double out[3]);
    4746  void histogramPacking(double ecatyp,vector<double>vshf,vector<double>&xcor,vector<int>& hist);
  • Interface_Web/trunk/pspaWT/sources/controler/src/particleBeam.cc

    r371 r377  
    357357  coord.resize(goodPartic_.size(), 0.0 );
    358358  cout << " particleBeam::particlesPhaseSpaceComponent index = " << index << endl;
     359
    359360  if ( index <= 2 ) {
    360361    for (unsigned i = 0; i < goodPartic_.size(); ++i) {
     
    363364    return;
    364365  }
    365 
     366 
    366367  if ( index >  2 && index < 5 ) {
    367368    for (unsigned i = 0; i < goodPartic_.size(); ++i) {
     
    378379  if ( index == 5 ) {
    379380    double gamma0 = referenceParticle_.getGamma();
    380     //    cout << " gamma0 = " << gamma0 << endl;
    381381    if ( gamma0 == 0.0 ) return;
    382382    for (unsigned i = 0; i < goodPartic_.size(); ++i) {
    383383      coord.at(i) =  100.*(goodPartic_.at(i).getGamma() - gamma0)/gamma0;  // en %
    384       //      cout << " gamma0 = " << gamma0 << " gamma = " << goodPartic_.at(i).getGamma() << endl;
    385384    }
    386385    return;
     
    529528}
    530529
    531 void particleBeam::histogramme(unsigned int iabs,vector<double>&xcor,vector<int>& hist,double out[3])
     530void particleBeam::histogramme(unsigned int iabs,vector<double>& xcor,vector<int>& hist,double out[3])
    532531{
     532  // out[0]= nbre de particules, out[1]= moyenne, out[2]= ecart-type
    533533  vector<double> vshf;
    534   histogramComponent(vshf,iabs);
     534  particlesPhaseSpaceComponent(vshf,iabs);
    535535  histogramInitialize(iabs,vshf,out);
    536536  histogramPacking(out[2],vshf,xcor,hist);
    537537
    538   // out[0]= nbre de particules, out[1]= moyenne, out[2]= ecart-type
    539   if(iabs == 0 || iabs == 1 || iabs == 2) {
    540     out[2] *= 1000.0; // ecart-type en mm
    541   }
    542 
    543538  if(iabs == 5) {
    544     for (unsigned int i = 0; i <= xcor.size(); ++i) {
    545       xcor[i] = 100.*xcor[i]/out[1]; // en %
    546     }
    547539    out[1] *= EREST_MeV; // moyenne en MeV
    548540    out[2] *= EREST_keV; // ecart-type en KeV
    549541  }
    550 }
    551 
    552 void particleBeam::histogramComponent(vector<double>& coord,unsigned int index)
    553 
    554   coord.clear();
    555   coord.resize(goodPartic_.size(),0.0);
    556  
    557   if(index == 0 || index == 1 || index == 2)
    558     {
    559       // collecte d'une coordonnee x(index= 0), y(index= 1) ou z(index= 2) des particules
    560       for (unsigned int k = 0; k < goodPartic_.size(); k++) {
    561         coord.at(k) = goodPartic_.at(k).getPosition().getComponent(index);
    562       }
    563     }
    564 
    565   if(index == 3 || index == 4)
    566     {
    567       // collecte de begamx (index= 3), begamy (index= 4)
    568       for (unsigned int k = 0; k < goodPartic_.size(); k++) {
    569         double begamz = goodPartic_.at(k).getBetaGamma().getComponent(2);
    570         if (begamz == 0.0) continue;
    571         double begam = goodPartic_.at(k).getBetaGamma().getComponent(index-3);
    572         coord.at(k) = 1000.0*begam/begamz;  //pi.mm.mradians
    573       }
    574     }
    575  
    576   if(index == 5)
    577     {
    578       // collecte de l'energie acquise par les particules
    579       for (unsigned int k = 0; k < goodPartic_.size(); k++) {
    580         double gamma = goodPartic_.at(k).getGamma();
    581         coord.at(k) = gamma-1.0;
    582       }
    583     }
    584542}
    585543
     
    607565
    608566  if(index == 0) {
    609     cout << "position x -moyenne " << vmoy << " m " << "-mini " << vmin << " m " << "-maxi " << vmax << " m " << "ecart type " << ecatyp*1000.0 << " mm" << endl;
     567    cout << "position x -moyenne " << vmoy << " cm " << "-mini " << vmin << " cm " << "-maxi " << vmax << " cm " << "ecart type " << ecatyp << " cm" << endl;
    610568  }
    611569  if(index == 1) {
    612     cout << "position y -moyenne " << vmoy << " m " << "-mini " << vmin << " m " << "-maxi " << vmax << " m " << "ecart type " << ecatyp*1000.0 << " mm" << endl;
     570    cout << "position y -moyenne " << vmoy << " cm " << "-mini " << vmin << " cm " << "-maxi " << vmax << " cm " << "ecart type " << ecatyp << " cm" << endl;
    613571  }
    614572  if(index == 2) {
    615     cout << "position z -moyenne " << vmoy << " m " << "-mini " << vmin << " m " << "-maxi " << vmax << " m " << "ecart type " << ecatyp*1000.0 << " mm" << endl;
     573    cout << "position z -moyenne " << vmoy << " cm " << "-mini " << vmin << " cm " << "-maxi " << vmax << " cm " << "ecart type " << ecatyp << " cm" << endl;
    616574  }
    617575  if(index == 3) {
    618     cout << "divergence xp -moyenne " << vmoy << " pi.mm.mrad " << "-mini " << vmin << " pi.mm.mrad " << "-maxi " << vmax << " pi.mm.mrad " << "ecart type " << ecatyp << " pi.mm.mrad" << endl;
     576    cout << "divergence xp -moyenne " << vmoy << " mrad " << "-mini " << vmin << " mrad " << "-maxi " << vmax << " mrad " << "ecart type " << ecatyp << " mrad" << endl;
    619577  }
    620578  if(index == 4) {
    621     cout << "divergence yp -moyenne " << vmoy << " pi.mm.mrad " << "-mini " << vmin << " pi.mm.mrad " << "-maxi " << vmax << " pi.mm.mrad " << "ecart type " << ecatyp << " pi.mm.mrad" << endl;
     579    cout << "divergence yp -moyenne " << vmoy << " mrad " << "-mini " << vmin << " mrad " << "-maxi " << vmax << " mrad " << "ecart type " << ecatyp << " mrad" << endl;
    622580  }
    623581  if(index == 5) {
     
    668626    if(var < 0 ) {
    669627      cout<<"lesser that the minimum "<<var<<", ("<< i<<")"<< endl;
    670       hist[0]++;
    671     }
    672 
    673     if(var >= phist) {
     628      hist.at(0)++;
     629    } else if(var >= phist) {
    674630      cout<<"greater that the maximum "<<var<<", ("<< i<<")"<< endl;
    675       hist[ihist-1]++;
    676     }
    677 
    678     int kk= (int)floor(var/hpas);
    679     hist[kk]++;
    680   }
    681 }
    682 
     631      hist.at(ihist-1)++;
     632    } else {
     633      int kk= (int)floor(var/hpas);
     634      hist.at(kk)++;
     635    }
     636  }
     637}
     638
  • Interface_Web/trunk/pspaWT/sources/userInterface/src/GWt_pspaApplication.cc

    r376 r377  
    873873
    874874  WContainerWidget *w= histoDialog->contents();
    875 
    876   // int nbpts= xcor.size()+cnts+1;
    877   // WStandardItemModel *model = new WStandardItemModel(nbpts,2,w);
    878   // //model->setHeaderData(1, WString("energie"));
    879  
    880   // int j= 0;
    881   // if(hist[0] > 0) {
    882   //   model->setData(j,0,xcor[0]);
    883   //   model->setData(j,1,hist[0]);
    884   //   j++;
    885   // }
    886   // model->setData(j,0,xcor[0]);
    887   // model->setData(j,1,hist[0]);
    888   // j++;
    889   // for (int i = 1; i < nbpts; ++i) {
    890   //   if(hist[i] == 0) {
    891   //     if(hist[i-1] > 0) {
    892   //    model->setData(j,0,xcor[i]);
    893   //    model->setData(j,1,hist[i-1]);
    894   //    j++;
    895   //     }
    896   //     model->setData(j,0,xcor[i]);
    897   //     model->setData(j,1,hist[i]);
    898   //     j++;
    899   //   }
    900   //   if(hist[i] > 0) {
    901   //     model->setData(j,0,xcor[i]);
    902   //     model->setData(j,1,hist[i-1]);
    903   //     j++;
    904   //     model->setData(j,0,xcor[i]);
    905   //     model->setData(j,1,hist[i]);
    906   //     j++;
    907   //   }
    908   // }
    909 
    910875  int n = hist.size();
    911876  int nbpts= 2*(n+1);
    912   cout << " nbre de points nbpts= " << nbpts << endl;
    913877  WStandardItemModel *model = new WStandardItemModel(nbpts,2,w);
    914    
     878
    915879  int j= 0;
    916880  model->setData(j,0,xcor[0]);
     
    920884  model->setData(j,1,hist[0]);
    921885  j++;
     886
    922887  for (int i = 1; i < n; ++i) {
    923888    model->setData(j,0,xcor[i]);
     
    928893    j++;
    929894  }
    930  
     895
    931896  model->setData(j,0,xcor[n]);
    932897  model->setData(j,1,hist[n-1]);
     
    934899  model->setData(j,0,xcor[n]);
    935900  model->setData(j,1,0.0);
    936  
     901
    937902  // legendes
    938903  string unites[2];
    939904  if(iabs == 0 || iabs == 1 || iabs == 2) {
    940     unites[0]= " m"; unites[1]= " mm";
     905    unites[0]= unites[1]= " cm";
    941906  }
    942907  if(iabs == 3 || iabs == 4) {
    943     unites[0]= unites[1]= " pi.mm.mrad";
     908    unites[0]= unites[1]= " mrad";
    944909  }
    945910  if(iabs == 5) {
     
    955920  WCartesianChart *chart = new WCartesianChart(w);
    956921
    957   if(iabs == 0) chart->setTitle("Histogram of x-coordinate");
    958   if(iabs == 1) chart->setTitle("Histogram of y-coordinate");
    959   if(iabs == 2) chart->setTitle("Histogram of z-coordinate");
    960   if(iabs == 3) chart->setTitle("Histogram of xp- ??? ");
    961   if(iabs == 4) chart->setTitle("Histogram of yp- ???");
    962   if(iabs == 5) chart->setTitle("Histogram of kinetic energy");
     922  if(iabs == 0) chart->setTitle("x-coordinate");
     923  if(iabs == 1) chart->setTitle("y-coordinate");
     924  if(iabs == 2) chart->setTitle("z-coordinate");
     925  if(iabs == 3) chart->setTitle("xp-divergence");
     926  if(iabs == 4) chart->setTitle("yp-devergence");
     927  if(iabs == 5) chart->setTitle("kinetic energy");
    963928 
    964929  chart->setModel(model);        // set the model
     
    977942  axis.setGridLinesEnabled(true);
    978943
    979   if(iabs < 5) {
    980     axis.setTitle(WString(" ???"));
    981   } else {
    982     axis.setTitle(WString(" dEcin/Ecin (%)"));
    983   }
    984 
     944  if(iabs == 0) axis.setTitle(WString(" x (cm)"));
     945  if(iabs == 1) axis.setTitle(WString(" y (cm)"));
     946  if(iabs == 2) axis.setTitle(WString(" z (cm)"));
     947  if(iabs == 3) axis.setTitle(WString(" xp (mrad)"));
     948  if(iabs == 4) axis.setTitle(WString(" yp (mrad)"));
     949  if(iabs == 5) axis.setTitle(WString(" dEcin/Ecin (%)"));
     950 
    985951  chart->axis(Y1Axis).setGridLinesEnabled(true);
    986952  //chart->axis(Y1Axis).setTitle(WString("legende y"));
Note: See TracChangeset for help on using the changeset viewer.