Changeset 363 in PSPA for Interface_Web/trunk/pspaWT
- Timestamp:
- Mar 5, 2013, 4:34:39 PM (11 years ago)
- Location:
- Interface_Web/trunk/pspaWT/sources
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
Interface_Web/trunk/pspaWT/sources/controler/include/particleBeam.h
r362 r363 44 44 45 45 void preparationDesHistogrammes(int index,vector<double>& vshf,double out[3]); 46 void remplissageDesHistogrammes(double out[3],vector<double>vshf,vector<double>&xcor,vector<int>& hist,int& cnts);46 void remplissageDesHistogrammes(double val[2],vector<double>vshf,vector<double>&xcor,vector<int>& hist,int& cnts); 47 47 48 48 public: … … 75 75 virtual string FileOutputFlow() const; 76 76 virtual bool FileInput(ifstream& ifs); 77 void histogramme(vector<double>&xcor,vector<int>& hist,int& cnts,double out[3]);77 //void histogramme(vector<double>&xcor,vector<int>& hist,int& cnts,double out[3]); 78 78 void histogramme(int index,vector<double>&xcor,vector<int>& hist,int& cnts,double out[3]); 79 79 }; -
Interface_Web/trunk/pspaWT/sources/controler/src/particleBeam.cc
r362 r363 514 514 vector<double> vshf; 515 515 preparationDesHistogrammes(iabs,vshf,out); 516 remplissageDesHistogrammes(out,vshf,xcor,hist,cnts); 516 517 double val[2]; 518 if(iabs < 3) { 519 val[0] = 100.0; 520 val[1] = out[2]; 521 } else { 522 val[0] = out[1]; 523 val[1] = out[2]; 524 } 525 remplissageDesHistogrammes(val,vshf,xcor,hist,cnts); 517 526 518 527 // sortie pour la legende: out[0]= entries, out[1]= mean, out[2]= std deviation … … 612 621 } 613 622 614 void particleBeam::remplissageDesHistogrammes(double out[3],vector<double>vshf,vector<double>&xcor,vector<int>& hist,int& cnts)623 void particleBeam::remplissageDesHistogrammes(double val[2],vector<double>vshf,vector<double>&xcor,vector<int>& hist,int& cnts) 615 624 { 616 // recupere la moyenne et l'ecart-type 617 double vmoy= out[1]; 618 double ecatyp= out[2]; 625 double vmoy = val[0]; 626 double ecatyp= val[1]; 619 627 620 628 // demi fenetre hfene= max(3.*ecatyp-vmoy,vmoy-3.*ecatyp); … … 639 647 640 648 if(!xcor.empty()) xcor.clear(); 641 xcor.resize(ihist); 642 for (int i = 0; i < ihist; ++i) { 643 644 // on gradue l'abscisse en pourcents 649 650 // pourVoir ///////////////////////////////////// 651 // xcor.resize(ihist); 652 // for (int i = 0; i < ihist; ++i) { 653 // // on gradue l'abscisse en pourcents 654 // xcor[i]= 100.*( vmin+i*hpas )/vmoy; 655 // } 656 657 xcor.resize(ihist+1); 658 for (int i = 0; i <= ihist; ++i) { 645 659 xcor[i]= 100.*( vmin+i*hpas )/vmoy; 646 660 } 661 ///////////////////////////////////// 647 662 648 663 if(!hist.empty()) hist.clear(); … … 671 686 } 672 687 673 void particleBeam::histogramme(vector<double>&xcor,vector<int>& hist,int& cnts,double out[3])674 {675 // sortie pour la legende: out[0]= entries, out[1]= mean, out[2]= rms676 677 // on calcule avec les gammas ; les MeV c'est pour les sorties678 679 double gammin= GRAND;680 double gammax= -gammin;681 // double Emoy= 0.0;682 double ecatyp= 0.0;683 double gmoy=0.0;684 for (unsigned int k = 0; k < goodPartic_.size(); k++)685 {686 double gamma = goodPartic_.at(k).getGamma();687 // double EMev = (gamma-1.0)*ERESTMeV;688 if (gamma < gammin) gammin = gamma;689 else if (gamma > gammax) gammax = gamma;690 // Emoy += EMev;691 double g = gamma-1.0;692 gmoy += g;693 // ecatyp += EMev*EMev;694 ecatyp += g*g;695 }696 697 double sum= (float)goodPartic_.size();698 out[0]= sum;699 // Emoy /= sum;700 gmoy /= sum;701 // out[1]= Emoy; //MeV702 out[1]= gmoy*EREST_MeV ; //MeV703 ecatyp /= sum;704 // out[2]= 1000.0*sqrt(ecatyp); //KeV705 // ecatyp = sqrt(abs(ecatyp-Emoy*Emoy));706 707 ecatyp = sqrt(abs(ecatyp-gmoy*gmoy));708 out[2]= ecatyp*EREST_keV; //KeV709 710 double gmin = gammin-1.0;711 double gmax = gammax-1.0;712 cout << "energie cinetique -moyenne " << gmoy*EREST_MeV << " Mev " << "-mini " << gmin*EREST_MeV << " Mev " << "-maxi " << gmax*EREST_MeV << " Mev " << "ecart type " << ecatyp*EREST_keV << " Kev" << endl;713 714 vector<double> Eshf;715 for (unsigned int k = 0; k < goodPartic_.size(); k++)716 {717 double gamma = goodPartic_.at(k).getGamma();718 // double EMev = (gamma-1.0)*ERESTMeV;719 // Eshf.push_back(EMev-Emoy);720 // modif glm 2/03/2013721 double g = (gamma-1.0);722 Eshf.push_back( (g-gmoy) );723 }724 725 //////////////////////////////////////////////////////////////////////////////688 // void particleBeam::histogramme(vector<double>&xcor,vector<int>& hist,int& cnts,double out[3]) 689 // { 690 // // sortie pour la legende: out[0]= entries, out[1]= mean, out[2]= rms 691 692 // // on calcule avec les gammas ; les MeV c'est pour les sorties 693 694 // double gammin= GRAND; 695 // double gammax= -gammin; 696 // // double Emoy= 0.0; 697 // double ecatyp= 0.0; 698 // double gmoy=0.0; 699 // for (unsigned int k = 0; k < goodPartic_.size(); k++) 700 // { 701 // double gamma = goodPartic_.at(k).getGamma(); 702 // // double EMev = (gamma-1.0)*ERESTMeV; 703 // if (gamma < gammin) gammin = gamma; 704 // else if (gamma > gammax) gammax = gamma; 705 // // Emoy += EMev; 706 // double g = gamma-1.0; 707 // gmoy += g; 708 // // ecatyp += EMev*EMev; 709 // ecatyp += g*g; 710 // } 711 712 // double sum= (float)goodPartic_.size(); 713 // out[0]= sum; 714 // // Emoy /= sum; 715 // gmoy /= sum; 716 // // out[1]= Emoy; //MeV 717 // out[1]= gmoy*EREST_MeV ; //MeV 718 // ecatyp /= sum; 719 // // out[2]= 1000.0*sqrt(ecatyp); //KeV 720 // // ecatyp = sqrt(abs(ecatyp-Emoy*Emoy)); 721 722 // ecatyp = sqrt(abs(ecatyp-gmoy*gmoy)); 723 // out[2]= ecatyp*EREST_keV; //KeV 724 725 // double gmin = gammin-1.0; 726 // double gmax = gammax-1.0; 727 // cout << "energie cinetique -moyenne " << gmoy*EREST_MeV << " Mev " << "-mini " << gmin*EREST_MeV << " Mev " << "-maxi " << gmax*EREST_MeV << " Mev " << "ecart type " << ecatyp*EREST_keV << " Kev" << endl; 728 729 // vector<double> Eshf; 730 // for (unsigned int k = 0; k < goodPartic_.size(); k++) 731 // { 732 // double gamma = goodPartic_.at(k).getGamma(); 733 // // double EMev = (gamma-1.0)*ERESTMeV; 734 // // Eshf.push_back(EMev-Emoy); 735 // // modif glm 2/03/2013 736 // double g = (gamma-1.0); 737 // Eshf.push_back( (g-gmoy) ); 738 // } 739 740 // ////////////////////////////////////////////////////////////////////////////// 726 741 727 // demi fenetre en energie, et pas de l'histogramme728 // double hfene= max(3.*ecatyp-Emoy,Emoy-3.*ecatyp);729 double hfene= 3.*ecatyp;730 double hpas = hfene/25.;731 732 cout << "demi fenetre " << hfene << ", hpas= " << hpas << endl;733 734 double vmin = -hfene;735 double dfen = 2.*hfene;736 int ihist = dfen/hpas;737 double phist = ihist*hpas;738 double dpas = hpas-(dfen-phist);739 if(dpas <= hpas*1.e-03) {740 ihist++;741 phist= ihist*hpas;742 }743 double vmax= vmin+hpas*ihist;742 // // demi fenetre en energie, et pas de l'histogramme 743 // // double hfene= max(3.*ecatyp-Emoy,Emoy-3.*ecatyp); 744 // double hfene= 3.*ecatyp; 745 // double hpas = hfene/25.; 746 747 // cout << "demi fenetre " << hfene << ", hpas= " << hpas << endl; 748 749 // double vmin = -hfene; 750 // double dfen = 2.*hfene; 751 // int ihist = dfen/hpas; 752 // double phist = ihist*hpas; 753 // double dpas = hpas-(dfen-phist); 754 // if(dpas <= hpas*1.e-03) { 755 // ihist++; 756 // phist= ihist*hpas; 757 // } 758 // double vmax= vmin+hpas*ihist; 744 759 745 cout << "'xAxisNumberOfBins= " << ihist <<", xAxisMinimum= " << vmin << ", xAxisMaximum= " << vmax << ", NParticules= " << Eshf.size() << ", phist " << phist << endl;746 747 xcor= vector<double>(ihist);748 for (int i = 0; i < ihist; ++i) {749 750 // on gradue l'abscisse en pourcents751 // xcor[i]= 100.*( vmin+i*hpas );752 xcor[i]= 100.*( vmin+i*hpas )/gmoy;753 }754 755 hist= vector<int>(ihist,0);756 for (unsigned i = 0; i < Eshf.size(); ++i) {757 double var= Eshf[i]-vmin;758 // if(var < 0 || var >= phist) cout<<"out of range "<<var<<", ("<< i<<")"<< endl;759 if(var < 0 ) {760 cout<<"lesser that the minimum "<<var<<", ("<< i<<")"<< endl;761 hist[0]++;762 }763 if(var >= phist) {764 cout<<"greater that the maximum "<<var<<", ("<< i<<")"<< endl;765 hist[ihist-1]++;766 }767 // int k= var/hpas;768 int kk= (int)floor(var/hpas);769 //if(i%20 == 0) cout<<"v("<<i<<")= " <<var<<" ["<<k<<"-"<<kk<<"], "<<endl;770 hist[kk]++;771 }772 773 cnts= 0;774 for (int i = 0; i < ihist; ++i) {775 if(hist.at(i) > 0) cnts++;776 //cout<<"("<<xcor.at(i)<<","<<hist.at(i)<<") ";777 }778 cout<< " ... cnts= " << cnts << endl;779 }760 // cout << "'xAxisNumberOfBins= " << ihist <<", xAxisMinimum= " << vmin << ", xAxisMaximum= " << vmax << ", NParticules= " << Eshf.size() << ", phist " << phist << endl; 761 762 // xcor= vector<double>(ihist); 763 // for (int i = 0; i < ihist; ++i) { 764 765 // // on gradue l'abscisse en pourcents 766 // // xcor[i]= 100.*( vmin+i*hpas ); 767 // xcor[i]= 100.*( vmin+i*hpas )/gmoy; 768 // } 769 770 // hist= vector<int>(ihist,0); 771 // for (unsigned i = 0; i < Eshf.size(); ++i) { 772 // double var= Eshf[i]-vmin; 773 // // if(var < 0 || var >= phist) cout<<"out of range "<<var<<", ("<< i<<")"<< endl; 774 // if(var < 0 ) { 775 // cout<<"lesser that the minimum "<<var<<", ("<< i<<")"<< endl; 776 // hist[0]++; 777 // } 778 // if(var >= phist) { 779 // cout<<"greater that the maximum "<<var<<", ("<< i<<")"<< endl; 780 // hist[ihist-1]++; 781 // } 782 // // int k= var/hpas; 783 // int kk= (int)floor(var/hpas); 784 // //if(i%20 == 0) cout<<"v("<<i<<")= " <<var<<" ["<<k<<"-"<<kk<<"], "<<endl; 785 // hist[kk]++; 786 // } 787 788 // cnts= 0; 789 // for (int i = 0; i < ihist; ++i) { 790 // if(hist.at(i) > 0) cnts++; 791 // //cout<<"("<<xcor.at(i)<<","<<hist.at(i)<<") "; 792 // } 793 // cout<< " ... cnts= " << cnts << endl; 794 // } -
Interface_Web/trunk/pspaWT/sources/userInterface/src/GWt_pspaApplication.cc
r362 r363 844 844 845 845 WContainerWidget *w= histoDialog->contents(); 846 int nbpts= xcor.size()+cnts+1; 846 847 // int nbpts= xcor.size()+cnts+1; 848 // WStandardItemModel *model = new WStandardItemModel(nbpts,2,w); 849 // //model->setHeaderData(1, WString("energie")); 850 851 // int j= 0; 852 // if(hist[0] > 0) { 853 // model->setData(j,0,xcor[0]); 854 // model->setData(j,1,hist[0]); 855 // j++; 856 // } 857 // model->setData(j,0,xcor[0]); 858 // model->setData(j,1,hist[0]); 859 // j++; 860 // for (int i = 1; i < nbpts; ++i) { 861 // if(hist[i] == 0) { 862 // if(hist[i-1] > 0) { 863 // model->setData(j,0,xcor[i]); 864 // model->setData(j,1,hist[i-1]); 865 // j++; 866 // } 867 // model->setData(j,0,xcor[i]); 868 // model->setData(j,1,hist[i]); 869 // j++; 870 // } 871 // if(hist[i] > 0) { 872 // model->setData(j,0,xcor[i]); 873 // model->setData(j,1,hist[i-1]); 874 // j++; 875 // model->setData(j,0,xcor[i]); 876 // model->setData(j,1,hist[i]); 877 // j++; 878 // } 879 // } 880 881 int n = hist.size(); 882 int nbpts= 2*(n+1); 883 cout << " nbre de points nbpts= " << nbpts << endl; 847 884 WStandardItemModel *model = new WStandardItemModel(nbpts,2,w); 848 //model->setHeaderData(1, WString("energie")); 849 885 850 886 int j= 0; 851 if(hist[0] > 0) { 852 model->setData(j,0,xcor[0]); 853 model->setData(j,1,hist[0]); 854 j++; 855 } 887 model->setData(j,0,xcor[0]); 888 model->setData(j,1,0.0); 889 j++; 856 890 model->setData(j,0,xcor[0]); 857 891 model->setData(j,1,hist[0]); 858 892 j++; 859 for (int i = 1; i < nbpts; ++i) { 860 if(hist[i] == 0) { 861 if(hist[i-1] > 0) { 862 model->setData(j,0,xcor[i]); 863 model->setData(j,1,hist[i-1]); 864 j++; 865 } 866 model->setData(j,0,xcor[i]); 867 model->setData(j,1,hist[i]); 868 j++; 869 } 870 if(hist[i] > 0) { 871 model->setData(j,0,xcor[i]); 872 model->setData(j,1,hist[i-1]); 873 j++; 874 model->setData(j,0,xcor[i]); 875 model->setData(j,1,hist[i]); 876 j++; 877 } 878 } 893 for (int i = 1; i < n; ++i) { 894 model->setData(j,0,xcor[i]); 895 model->setData(j,1,hist[i-1]); 896 j++; 897 model->setData(j,0,xcor[i]); 898 model->setData(j,1,hist[i]); 899 j++; 900 } 901 902 model->setData(j,0,xcor[n]); 903 model->setData(j,1,hist[n-1]); 904 j++; 905 model->setData(j,0,xcor[n]); 906 model->setData(j,1,0.0); 879 907 880 908 // legendes
Note: See TracChangeset
for help on using the changeset viewer.