Changeset 362 in PSPA for Interface_Web
- Timestamp:
- Mar 5, 2013, 11:48:58 AM (12 years ago)
- Location:
- Interface_Web/trunk/pspaWT/sources
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
Interface_Web/trunk/pspaWT/sources/controler/include/particleBeam.h
r356 r362 43 43 unsigned indexFromPspaToTransport(unsigned index) const; 44 44 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); 47 45 48 public: 46 49 … … 73 76 virtual bool FileInput(ifstream& ifs); 74 77 void histogramme(vector<double>&xcor,vector<int>& hist,int& cnts,double out[3]); 78 void histogramme(int index,vector<double>&xcor,vector<int>& hist,int& cnts,double out[3]); 75 79 }; 76 80 #endif -
Interface_Web/trunk/pspaWT/sources/controler/src/particleBeam.cc
r356 r362 510 510 } 511 511 512 void particleBeam::histogramme(int iabs,vector<double>&xcor,vector<int>& hist,int& cnts,double out[3]) 513 { 514 vector<double> vshf; 515 preparationDesHistogrammes(iabs,vshf,out); 516 remplissageDesHistogrammes(out,vshf,xcor,hist,cnts); 517 518 // sortie pour la legende: out[0]= entries, out[1]= mean, out[2]= std deviation 519 if(iabs < 3) { 520 out[1] *= 1.0 ; // en m ? 521 out[2] *= 1000.0; //mm 522 } else { 523 out[1] *= EREST_MeV ; //MeV 524 out[2] *= EREST_keV; //KeV 525 } 526 } 527 528 void particleBeam::preparationDesHistogrammes(int index,vector<double>& vshf,double out[3]) 529 { 530 double vmin= GRAND; 531 double vmax= -vmin; 532 double vmoy= 0.0; 533 double ecatyp= 0.0; 534 535 double sum= (float)goodPartic_.size(); 536 if(index < 3) 537 { 538 // collecte d'une coordonnee x(index= 0), y(index= 1) ou z(index= 2) des particules 539 for (unsigned int k = 0; k < goodPartic_.size(); k++) { 540 double val = goodPartic_.at(k).getPosition().getComponent(index); 541 if (val < vmin) vmin = val; 542 else if (val > vmax) vmax = val; 543 vmoy += val; 544 ecatyp += val*val; 545 } 546 547 out[0]= sum; 548 vmoy /= sum; 549 out[1]= vmoy; 550 ecatyp /= sum; 551 ecatyp = sqrt(abs(ecatyp-vmoy*vmoy)); 552 out[2]= ecatyp; 553 } 554 else 555 { 556 // collecte de l'energie acquise par les particules 557 for (unsigned int k = 0; k < goodPartic_.size(); k++) { 558 double gamma = goodPartic_.at(k).getGamma(); 559 if (gamma < vmin) vmin = gamma; 560 else if (gamma > vmax) vmax = gamma; 561 double val = gamma-1.0; 562 vmoy += val; 563 ecatyp += val*val; 564 } 565 566 out[0]= sum; 567 vmoy /= sum; 568 out[1]= vmoy; 569 ecatyp /= sum; 570 ecatyp = sqrt(abs(ecatyp-vmoy*vmoy)); 571 out[2]= ecatyp; 572 } 573 574 if(index == 0) { 575 cout << "position X -moyenne " << vmoy << " m " << "-mini " << vmin << " m " << "-maxi " << vmax << " m " << "ecart type " << ecatyp*1000.0 << " mm" << endl; 576 } else if(index == 1) { 577 cout << "position Y -moyenne " << vmoy << " m " << "-mini " << vmin << " m " << "-maxi " << vmax << " m " << "ecart type " << ecatyp*1000.0 << " mm" << endl; 578 } else if(index == 2) { 579 cout << "position Z -moyenne " << vmoy << " m " << "-mini " << vmin << " m " << "-maxi " << vmax << " m " << "ecart type " << ecatyp*1000.0 << " mm" << endl; 580 } else { 581 double gmin = vmin-1.0; 582 double gmax = vmax-1.0; 583 cout << "energie cinetique -moyenne " << vmoy*EREST_MeV << " Mev " << "-mini " << gmin*EREST_MeV << " Mev " << "-maxi " << gmax*EREST_MeV << " Mev " << "ecart type " << ecatyp*EREST_MeV << " Kev" << endl; 584 } 585 586 //pouVoir: autre maniere de calculer l'ecart-type 587 double stdev= 0.0; 588 589 if(!vshf.empty()) vshf.clear(); 590 vshf.resize(goodPartic_.size()); 591 if(index < 3) 592 { 593 for (unsigned int k = 0; k < goodPartic_.size(); k++) { 594 double val = goodPartic_.at(k).getPosition().getComponent(index); 595 vshf[k]= val-vmoy; 596 stdev += vshf[k]*vshf[k]; 597 } 598 } 599 else 600 { 601 for (unsigned int k = 0; k < goodPartic_.size(); k++) { 602 double gamma = goodPartic_.at(k).getGamma(); 603 double val = gamma-1.0; 604 vshf[k]= val-vmoy; 605 stdev += vshf[k]*vshf[k]; 606 } 607 } 608 609 stdev /= sum; 610 stdev = sqrt(stdev); 611 cout << "stdev " << stdev << ", ecatyp " << ecatyp << ", diff " << stdev-ecatyp << endl; 612 } 613 614 void particleBeam::remplissageDesHistogrammes(double out[3],vector<double>vshf,vector<double>&xcor,vector<int>& hist,int& cnts) 615 { 616 // recupere la moyenne et l'ecart-type 617 double vmoy= out[1]; 618 double ecatyp= out[2]; 619 620 // demi fenetre hfene= max(3.*ecatyp-vmoy,vmoy-3.*ecatyp); 621 double hfene= 3.*ecatyp; 622 // et pas de l'histogramme 623 double hpas = hfene/25.; 624 625 cout << "demi fenetre " << hfene << ", hpas= " << hpas << endl; 626 627 double vmin = -hfene; 628 double dfen = 2.*hfene; 629 int ihist = dfen/hpas; 630 double phist = ihist*hpas; 631 double dpas = hpas-(dfen-phist); 632 if(dpas <= hpas*1.e-03) { 633 ihist++; 634 phist= ihist*hpas; 635 } 636 double vmax= vmin+hpas*ihist; 637 638 cout << "'xAxisNumberOfBins= " << ihist <<", xAxisMinimum= " << vmin << ", xAxisMaximum= " << vmax << ", NParticules= " << vshf.size() << ", phist " << phist << endl; 639 640 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 645 xcor[i]= 100.*( vmin+i*hpas )/vmoy; 646 } 647 648 if(!hist.empty()) hist.clear(); 649 hist.resize(ihist,0); 650 for (unsigned i = 0; i < vshf.size(); ++i) { 651 double var= vshf[i]-vmin; 652 if(var < 0 ) { 653 cout<<"lesser that the minimum "<<var<<", ("<< i<<")"<< endl; 654 hist[0]++; 655 } 656 657 if(var >= phist) { 658 cout<<"greater that the maximum "<<var<<", ("<< i<<")"<< endl; 659 hist[ihist-1]++; 660 } 661 662 int kk= (int)floor(var/hpas); 663 hist[kk]++; 664 } 665 666 cnts= 0; 667 for (int i = 0; i < ihist; ++i) { 668 if(hist.at(i) > 0) cnts++; 669 } 670 cout<< " ... cnts= " << cnts << endl; 671 } 672 512 673 void particleBeam::histogramme(vector<double>&xcor,vector<int>& hist,int& cnts,double out[3]) 513 674 { -
Interface_Web/trunk/pspaWT/sources/userInterface/include/GWt_pspaApplication.h
r354 r362 53 53 WComboBox* choixEnveloppeDessin_; 54 54 WComboBox* choixHistoDessin_; 55 WComboBox* choixVariableHisto_; 55 56 56 57 WContainerWidget* toto_; -
Interface_Web/trunk/pspaWT/sources/userInterface/src/GWt_pspaApplication.cc
r356 r362 273 273 ///////////////////////////////////////////////////////////////////// 274 274 275 choixVariableHisto_= new WComboBox(); 276 choixVariableHisto_->addItem("x"); 277 choixVariableHisto_->addItem("y"); 278 choixVariableHisto_->addItem("z"); 279 choixVariableHisto_->addItem("dE/E"); 280 choixVariableHisto_->setCurrentIndex(3); 281 275 282 choixHistoDessin_ = new WComboBox(); 276 Wt::WRadioButton *button3= new WRadioButton(" histogram after element");283 Wt::WRadioButton *button3= new WRadioButton(" histogram of"); 277 284 group_->addButton(button3,3); 285 278 286 glayout->addWidget(button3,3,1); 279 glayout->addWidget(choixHistoDessin_,3,2); 287 glayout->addWidget(choixVariableHisto_,3,2); 288 glayout->addWidget(new WText("after element"),3,3); 289 glayout->addWidget(choixHistoDessin_,3,4); 280 290 ///////////////////////////////////////////////////////////////////// 281 291 … … 805 815 histoDialog->setMinimumSize(400,400); 806 816 histoDialog->setClosable(true); 807 histoDialog->show();808 817 809 818 int index = choixHistoDessin_->currentIndex(); … … 821 830 } 822 831 832 histoDialog->show(); 823 833 vector<double> xcor; 824 834 vector<int> hist; 825 835 int cnts; 826 836 double out[3]= {0.0}; 827 beam->histogramme(xcor,hist,cnts,out); 828 837 838 int iabs= choixVariableHisto_->currentIndex(); 839 string xname= choixVariableHisto_->currentText().toUTF8(); 840 beam->histogramme(iabs,xcor,hist,cnts,out); 841 829 842 cout<<"xcor.size()= "<<xcor.size()<<", hist.size()= "<<hist.size()<<endl; 830 843 ////////////////////////////////////////////////////////////////////////////////// … … 833 846 int nbpts= xcor.size()+cnts+1; 834 847 WStandardItemModel *model = new WStandardItemModel(nbpts,2,w); 835 model->setHeaderData(1, WString("energie"));848 //model->setHeaderData(1, WString("energie")); 836 849 837 850 int j= 0; … … 868 881 new WText(" entries : "+ mixedTools::intToString((int)out[0]),w); 869 882 new WBreak(w); 870 new WText(" mean : "+ mixedTools::doubleToString(out[1])+" MeV",w); 871 new WBreak(w); 872 new WText(" sigma rms : "+ mixedTools::doubleToString(out[2])+" KeV",w); 873 883 if(iabs < 3) { 884 new WText(" mean : "+ mixedTools::doubleToString(out[1])+" m",w); 885 new WBreak(w); 886 new WText(" sigma rms : "+ mixedTools::doubleToString(1000.0*out[2])+" mm",w); 887 } else { 888 new WText(" mean : "+ mixedTools::doubleToString(out[1])+" MeV",w); 889 new WBreak(w); 890 new WText(" sigma rms : "+ mixedTools::doubleToString(out[2])+" KeV",w); 891 } 892 874 893 WCartesianChart *chart = new WCartesianChart(w); 875 chart->setTitle("Histogram of kinetic energy"); 894 895 if(iabs == 0) { 896 chart->setTitle("Histogram of particle x-coordinate"); 897 } else if(iabs == 1) { 898 chart->setTitle("Histogram of particle y-coordinate"); 899 } else if(iabs == 2) { 900 chart->setTitle("Histogram of particle z-coordinate"); 901 } else { 902 chart->setTitle("Histogram of kinetic energy"); 903 } 904 876 905 chart->setModel(model); // set the model 877 906 chart->setXSeriesColumn(0); // set the column that holds the categories … … 888 917 axis.setLabelFormat("%.3f"); 889 918 axis.setGridLinesEnabled(true); 890 axis.setTitle(WString(" dEcin/Ecin (%)")); 919 920 if(iabs < 3) { 921 axis.setTitle(WString(" ??? (%)")); 922 } else { 923 axis.setTitle(WString(" dEcin/Ecin (%)")); 924 } 891 925 892 926 chart->axis(Y1Axis).setGridLinesEnabled(true); 893 chart->axis(Y1Axis).setTitle(WString("legende y"));927 //chart->axis(Y1Axis).setTitle(WString("legende y")); 894 928 895 929 WDataSeries s(1, LineSeries);
Note: See TracChangeset
for help on using the changeset viewer.