Changeset 371 in PSPA for Interface_Web/trunk/pspaWT/sources
- Timestamp:
- Mar 6, 2013, 3:19:19 PM (12 years ago)
- Location:
- Interface_Web/trunk/pspaWT/sources
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
Interface_Web/trunk/pspaWT/sources/controler/include/particleBeam.h
r366 r371 43 43 unsigned indexFromPspaToTransport(unsigned index) const; 44 44 45 void preparationDesHistogrammes(int index,vector<double>& vshf,double out[3]); 46 void remplissageDesHistogrammes(double val[2],vector<double>vshf,vector<double>&xcor,vector<int>& hist,int& cnts); 45 void histogramComponent(vector<double>& coord,unsigned int index); 46 void histogramInitialize(unsigned int index,vector<double>& vshf,double out[3]); 47 void histogramPacking(double ecatyp,vector<double>vshf,vector<double>&xcor,vector<int>& hist); 47 48 48 49 double getSigmaTransportij(unsigned indexI, unsigned indexJ); … … 112 113 virtual string FileOutputFlow() const; 113 114 virtual bool FileInput(ifstream& ifs); 114 //void histogramme(vector<double>&xcor,vector<int>& hist,int& cnts,double out[3]); 115 void histogramme( int index,vector<double>&xcor,vector<int>& hist,int& cnts,double out[3]);115 116 void histogramme(unsigned int index,vector<double>&xcor,vector<int>& hist,double out[3]); 116 117 }; 117 118 #endif -
Interface_Web/trunk/pspaWT/sources/controler/src/abstractElement.cc
r361 r371 119 119 tb = TBoolError; 120 120 } 121 121 122 if ((tb == TBoolOk) || (tb == TBoolIgnore)) { 122 if (prog == nomDeLogiciel::parmela){123 124 125 126 127 128 129 130 131 132 123 if (prog == nomDeLogiciel::parmela) { 124 abstractSoftware_ = new softwareParmela(); 125 } else if (prog == nomDeLogiciel::transport) { 126 abstractSoftware_ = new softwareTransport(); 127 } else if (prog == nomDeLogiciel::generator) { 128 abstractSoftware_ = new softwareGenerator(); 129 } else if (prog == nomDeLogiciel::test) { 130 abstractSoftware_ = new softwareTest(); 131 } else if (prog == nomDeLogiciel::unknownSoftware) { 132 abstractSoftware_ = NULL; 133 } 133 134 } 134 135 return tb; -
Interface_Web/trunk/pspaWT/sources/controler/src/dataManager.cc
r368 r371 61 61 abstractElement* dataManager::getElementPointerFromNumero(int k) 62 62 { 63 return pspa_->getBeamLine()->getAbstractElement(k-1); 64 } 65 63 return pspa_->getBeamLine()->getAbstractElement(k-1); 64 } 66 65 67 66 void dataManager::addSectionToExecute(int debut, int fin, nomDeLogiciel prog) … … 84 83 85 84 86 87 88 89 85 void dataManager::initializeExecution() 90 86 { 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 87 string workingDir = pspa_->getWorkingDir(); 88 if (workingDir == "") { 89 return; 90 } 91 removeFile(workingDir + "parmdesz"); 92 removeFile(workingDir + "parmin"); 93 removeFile(workingDir + "parin.input0"); 94 removeFile(workingDir + "transport.input"); 95 removeFile(workingDir + "transport.output"); 96 removeFile(workingDir + "generator.in"); 97 removeFile(workingDir + "faisceau.ini"); 98 removeFile(workingDir + "generator.output"); 99 diagnosticBeam_.clear(); 100 currentBeam_ = NULL; 101 firstComputedElemNumero_ = getBeamLineSize(); 102 lastComputedElemNumero_ = 1; 103 clearSectionToExecute(); 108 104 } 109 105 … … 120 116 bool dataManager::executeAll() 121 117 { 122 123 124 125 126 118 bool success = true; 119 abstractSoftware* softw = NULL; 120 string workingDir = pspa_->getWorkingDir(); 121 122 for(unsigned k = 0; k < jobList_.size(); k++) 127 123 { 128 cout << " dataManager::executeAll je m'apprete a executer : " << (jobList_[k]->software).getString() << endl; 124 cout << " dataManager::executeAll je m'apprete a executer : " << (jobList_[k]->software).getString() << endl; 125 126 int debut = jobList_[k]->firstElement; 127 int fin = jobList_[k]->lastElement; 128 softw = createSoftwareConnexion(jobList_[k]->software); 129 130 if (softw == NULL) { 131 success = false; 132 consoleMessage("dataManager::executeAll : unknown software"); 133 break; 134 } 129 135 130 int debut = jobList_[k]->firstElement; 131 int fin = jobList_[k]->lastElement; 132 softw = createSoftwareConnexion(jobList_[k]->software); 136 success = softw->createInputFile(currentBeam_,debut,fin,workingDir); 137 if ( success ) { 138 success = softw->execute(debut,fin,workingDir); 139 if ( success ) { 140 success = softw->buildBeamAfterElements(debut,fin,diagnosticBeam_,workingDir); 141 } 142 } 133 143 134 if (softw == NULL) { 135 success = false; 136 consoleMessage("dataManager::executeAll : unknown software"); 137 break; 138 } 139 140 success = softw->createInputFile(currentBeam_,debut,fin,workingDir); 141 if ( success ) { 142 success = softw->execute(debut,fin,workingDir); 143 if ( success ) { 144 success = softw->buildBeamAfterElements(debut,fin,diagnosticBeam_,workingDir); 145 } 146 } 147 148 delete softw; 149 if ( success ) { 150 currentBeam_ = &diagnosticBeam_.back(); 151 cout << " execute termine avec succes " << endl; 152 } else { 153 currentBeam_ = NULL; 154 cout << " execute termine en ECHEC " << endl; 155 } 156 if ( !success ) break; 157 158 159 if ( debut < firstComputedElemNumero_ ) firstComputedElemNumero_ = debut; 160 if ( fin > lastComputedElemNumero_ ) lastComputedElemNumero_ = fin; 161 162 //debug 163 cout << "dataManager::executeAll #diagnosticBeam= " << diagnosticBeam_.size() << endl; 164 cout << "dataManager::executeAll #getBeamLineSize()= " << getBeamLineSize() << endl; 165 for (int j = debut; j <= fin; j++) { 166 abstractElement* elPtr= getElementPointerFromNumero(j); 167 cout << "[" << j << "] " << elPtr->getNomdElement().getElementName() << endl; 168 } 169 144 delete softw; 145 if ( success ) { 146 currentBeam_ = &diagnosticBeam_.back(); 147 cout << " execute termine avec succes " << endl; 148 } else { 149 currentBeam_ = NULL; 150 cout << " execute termine en ECHEC " << endl; 151 } 152 if ( !success ) break; 153 154 155 if ( debut < firstComputedElemNumero_ ) firstComputedElemNumero_ = debut; 156 if ( fin > lastComputedElemNumero_ ) lastComputedElemNumero_ = fin; 157 158 //debug 159 cout << "dataManager::executeAll #diagnosticBeam= " << diagnosticBeam_.size() << endl; 160 cout << "dataManager::executeAll #getBeamLineSize()= " << getBeamLineSize() << endl; 161 for (int j = debut; j <= fin; j++) { 162 abstractElement* elPtr= getElementPointerFromNumero(j); 163 cout << "[" << j << "] " << elPtr->getNomdElement().getElementName() << endl; 164 } 170 165 } //k 171 cout << " dataManager::executeAll premier element : " << firstComputedElemNumero_ << " dernier : " << lastComputedElemNumero_ << endl; 172 return success; 166 167 cout << " dataManager::executeAll premier element : " << firstComputedElemNumero_ << " dernier : " << lastComputedElemNumero_ << endl; 168 169 return success; 173 170 } 174 171 -
Interface_Web/trunk/pspaWT/sources/controler/src/particleBeam.cc
r366 r371 350 350 } 351 351 352 void particleBeam::particlesPhaseSpaceComponent(vector<double>& coord, unsigned index) { 352 void particleBeam::particlesPhaseSpaceComponent(vector<double>& coord, unsigned index) 353 { 353 354 if ( !particleRepresentationOk_ ) return; 355 354 356 coord.clear(); 355 357 coord.resize(goodPartic_.size(), 0.0 ); … … 527 529 } 528 530 529 void particleBeam::histogramme( int iabs,vector<double>&xcor,vector<int>& hist,int& cnts,double out[3])530 { 531 void particleBeam::histogramme(unsigned int iabs,vector<double>&xcor,vector<int>& hist,double out[3]) 532 { 531 533 vector<double> vshf; 532 preparationDesHistogrammes(iabs,vshf,out); 533 534 double val[2]; 535 if(iabs < 3) { 536 val[0] = 100.0; 537 val[1] = out[2]; 538 } else { 539 val[0] = out[1]; 540 val[1] = out[2]; 541 } 542 remplissageDesHistogrammes(val,vshf,xcor,hist,cnts); 543 544 // sortie pour la legende: out[0]= entries, out[1]= mean, out[2]= std deviation 545 if(iabs < 3) { 546 out[1] *= 1.0 ; // en m ? 547 out[2] *= 1000.0; //mm 548 } else { 549 out[1] *= EREST_MeV ; //MeV 550 out[2] *= EREST_keV; //KeV 551 } 552 } 553 554 void particleBeam::preparationDesHistogrammes(int index,vector<double>& vshf,double out[3]) 534 histogramComponent(vshf,iabs); 535 histogramInitialize(iabs,vshf,out); 536 histogramPacking(out[2],vshf,xcor,hist); 537 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 543 if(iabs == 5) { 544 for (unsigned int i = 0; i <= xcor.size(); ++i) { 545 xcor[i] = 100.*xcor[i]/out[1]; // en % 546 } 547 out[1] *= EREST_MeV; // moyenne en MeV 548 out[2] *= EREST_keV; // ecart-type en KeV 549 } 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 } 584 } 585 586 void particleBeam::histogramInitialize(unsigned int index,vector<double>& vshf,double out[3]) 555 587 { 556 588 double vmin= GRAND; … … 558 590 double vmoy= 0.0; 559 591 double ecatyp= 0.0; 592 593 for (unsigned int k = 0; k < goodPartic_.size(); k++) { 594 if (vshf[k] < vmin) vmin = vshf[k]; 595 else if (vshf[k] > vmax) vmax = vshf[k]; 596 vmoy += vshf[k]; 597 ecatyp += vshf[k]*vshf[k]; 598 } 560 599 561 600 double sum= (float)goodPartic_.size(); 562 if(index < 3) 563 { 564 // collecte d'une coordonnee x(index= 0), y(index= 1) ou z(index= 2) des particules 565 for (unsigned int k = 0; k < goodPartic_.size(); k++) { 566 double val = goodPartic_.at(k).getPosition().getComponent(index); 567 if (val < vmin) vmin = val; 568 else if (val > vmax) vmax = val; 569 vmoy += val; 570 ecatyp += val*val; 571 } 572 573 out[0]= sum; 574 vmoy /= sum; 575 out[1]= vmoy; 576 ecatyp /= sum; 577 ecatyp = sqrt(abs(ecatyp-vmoy*vmoy)); 578 out[2]= ecatyp; 579 } 580 else 581 { 582 // collecte de l'energie acquise par les particules 583 for (unsigned int k = 0; k < goodPartic_.size(); k++) { 584 double gamma = goodPartic_.at(k).getGamma(); 585 if (gamma < vmin) vmin = gamma; 586 else if (gamma > vmax) vmax = gamma; 587 double val = gamma-1.0; 588 vmoy += val; 589 ecatyp += val*val; 590 } 591 592 out[0]= sum; 593 vmoy /= sum; 594 out[1]= vmoy; 595 ecatyp /= sum; 596 ecatyp = sqrt(abs(ecatyp-vmoy*vmoy)); 597 out[2]= ecatyp; 598 } 599 601 out[0]= sum; 602 vmoy /= sum; 603 out[1]= vmoy; 604 ecatyp /= sum; 605 ecatyp = sqrt(abs(ecatyp-vmoy*vmoy)); 606 out[2]= ecatyp; 607 600 608 if(index == 0) { 601 cout << "position X -moyenne " << vmoy << " m " << "-mini " << vmin << " m " << "-maxi " << vmax << " m " << "ecart type " << ecatyp*1000.0 << " mm" << endl; 602 } else if(index == 1) { 603 cout << "position Y -moyenne " << vmoy << " m " << "-mini " << vmin << " m " << "-maxi " << vmax << " m " << "ecart type " << ecatyp*1000.0 << " mm" << endl; 604 } else if(index == 2) { 605 cout << "position Z -moyenne " << vmoy << " m " << "-mini " << vmin << " m " << "-maxi " << vmax << " m " << "ecart type " << ecatyp*1000.0 << " mm" << endl; 606 } else { 609 cout << "position x -moyenne " << vmoy << " m " << "-mini " << vmin << " m " << "-maxi " << vmax << " m " << "ecart type " << ecatyp*1000.0 << " mm" << endl; 610 } 611 if(index == 1) { 612 cout << "position y -moyenne " << vmoy << " m " << "-mini " << vmin << " m " << "-maxi " << vmax << " m " << "ecart type " << ecatyp*1000.0 << " mm" << endl; 613 } 614 if(index == 2) { 615 cout << "position z -moyenne " << vmoy << " m " << "-mini " << vmin << " m " << "-maxi " << vmax << " m " << "ecart type " << ecatyp*1000.0 << " mm" << endl; 616 } 617 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; 619 } 620 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; 622 } 623 if(index == 5) { 607 624 double gmin = vmin-1.0; 608 625 double gmax = vmax-1.0; … … 610 627 } 611 628 612 //pouVoir: autre maniere de calculer l'ecart-type 613 double stdev= 0.0; 614 615 if(!vshf.empty()) vshf.clear(); 616 vshf.resize(goodPartic_.size()); 617 if(index < 3) 618 { 619 for (unsigned int k = 0; k < goodPartic_.size(); k++) { 620 double val = goodPartic_.at(k).getPosition().getComponent(index); 621 vshf[k]= val-vmoy; 622 stdev += vshf[k]*vshf[k]; 623 } 624 } 625 else 626 { 627 for (unsigned int k = 0; k < goodPartic_.size(); k++) { 628 double gamma = goodPartic_.at(k).getGamma(); 629 double val = gamma-1.0; 630 vshf[k]= val-vmoy; 631 stdev += vshf[k]*vshf[k]; 632 } 633 } 634 635 stdev /= sum; 636 stdev = sqrt(stdev); 637 cout << "stdev " << stdev << ", ecatyp " << ecatyp << ", diff " << stdev-ecatyp << endl; 638 } 639 640 void particleBeam::remplissageDesHistogrammes(double val[2],vector<double>vshf,vector<double>&xcor,vector<int>& hist,int& cnts) 629 for (unsigned int k = 0; k < goodPartic_.size(); k++) { 630 vshf[k] -= vmoy; 631 } 632 } 633 634 void particleBeam::histogramPacking(double ecatyp,vector<double>vshf,vector<double>&xcor,vector<int>& hist) 641 635 { 642 double vmoy = val[0];643 double ecatyp= val[1];644 645 636 // demi fenetre hfene= max(3.*ecatyp-vmoy,vmoy-3.*ecatyp); 646 637 double hfene= 3.*ecatyp; … … 661 652 double vmax= vmin+hpas*ihist; 662 653 663 cout << " 'xAxisNumberOfBins= " << ihist <<", xAxisMinimum= " << vmin << ", xAxisMaximum= " << vmax << ", NParticules= " << vshf.size() << ", phist " << phist << endl;664 654 cout << "xAxisNumberOfBins= " << ihist <<", xAxisMinimum= " << vmin << ", xAxisMaximum= " << vmax << ", NParticules= " << vshf.size() << ", phist " << phist << endl; 655 665 656 if(!xcor.empty()) xcor.clear(); 666 667 // pourVoir /////////////////////////////////////668 // xcor.resize(ihist);669 // for (int i = 0; i < ihist; ++i) {670 // // on gradue l'abscisse en pourcents671 // xcor[i]= 100.*( vmin+i*hpas )/vmoy;672 // }673 674 657 xcor.resize(ihist+1); 675 658 for (int i = 0; i <= ihist; ++i) { 676 xcor[i]= 100.*( vmin+i*hpas )/vmoy; 677 } 659 xcor[i] = vmin+i*hpas; 660 } 661 678 662 ///////////////////////////////////// 679 663 680 664 if(!hist.empty()) hist.clear(); 681 665 hist.resize(ihist,0); 682 for (unsigned i = 0; i < vshf.size(); ++i) {666 for (unsigned int i = 0; i < vshf.size(); ++i) { 683 667 double var= vshf[i]-vmin; 684 668 if(var < 0 ) { … … 695 679 hist[kk]++; 696 680 } 697 698 cnts= 0; 699 for (int i = 0; i < ihist; ++i) { 700 if(hist.at(i) > 0) cnts++; 701 } 702 cout<< " ... cnts= " << cnts << endl; 703 } 704 705 // void particleBeam::histogramme(vector<double>&xcor,vector<int>& hist,int& cnts,double out[3]) 706 // { 707 // // sortie pour la legende: out[0]= entries, out[1]= mean, out[2]= rms 708 709 // // on calcule avec les gammas ; les MeV c'est pour les sorties 710 711 // double gammin= GRAND; 712 // double gammax= -gammin; 713 // // double Emoy= 0.0; 714 // double ecatyp= 0.0; 715 // double gmoy=0.0; 716 // for (unsigned int k = 0; k < goodPartic_.size(); k++) 717 // { 718 // double gamma = goodPartic_.at(k).getGamma(); 719 // // double EMev = (gamma-1.0)*ERESTMeV; 720 // if (gamma < gammin) gammin = gamma; 721 // else if (gamma > gammax) gammax = gamma; 722 // // Emoy += EMev; 723 // double g = gamma-1.0; 724 // gmoy += g; 725 // // ecatyp += EMev*EMev; 726 // ecatyp += g*g; 727 // } 728 729 // double sum= (float)goodPartic_.size(); 730 // out[0]= sum; 731 // // Emoy /= sum; 732 // gmoy /= sum; 733 // // out[1]= Emoy; //MeV 734 // out[1]= gmoy*EREST_MeV ; //MeV 735 // ecatyp /= sum; 736 // // out[2]= 1000.0*sqrt(ecatyp); //KeV 737 // // ecatyp = sqrt(abs(ecatyp-Emoy*Emoy)); 738 739 // ecatyp = sqrt(abs(ecatyp-gmoy*gmoy)); 740 // out[2]= ecatyp*EREST_keV; //KeV 741 742 // double gmin = gammin-1.0; 743 // double gmax = gammax-1.0; 744 // 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; 745 746 // vector<double> Eshf; 747 // for (unsigned int k = 0; k < goodPartic_.size(); k++) 748 // { 749 // double gamma = goodPartic_.at(k).getGamma(); 750 // // double EMev = (gamma-1.0)*ERESTMeV; 751 // // Eshf.push_back(EMev-Emoy); 752 // // modif glm 2/03/2013 753 // double g = (gamma-1.0); 754 // Eshf.push_back( (g-gmoy) ); 755 // } 756 757 // ////////////////////////////////////////////////////////////////////////////// 758 759 // // demi fenetre en energie, et pas de l'histogramme 760 // // double hfene= max(3.*ecatyp-Emoy,Emoy-3.*ecatyp); 761 // double hfene= 3.*ecatyp; 762 // double hpas = hfene/25.; 763 764 // cout << "demi fenetre " << hfene << ", hpas= " << hpas << endl; 765 766 // double vmin = -hfene; 767 // double dfen = 2.*hfene; 768 // int ihist = dfen/hpas; 769 // double phist = ihist*hpas; 770 // double dpas = hpas-(dfen-phist); 771 // if(dpas <= hpas*1.e-03) { 772 // ihist++; 773 // phist= ihist*hpas; 774 // } 775 // double vmax= vmin+hpas*ihist; 776 777 // cout << "'xAxisNumberOfBins= " << ihist <<", xAxisMinimum= " << vmin << ", xAxisMaximum= " << vmax << ", NParticules= " << Eshf.size() << ", phist " << phist << endl; 778 779 // xcor= vector<double>(ihist); 780 // for (int i = 0; i < ihist; ++i) { 781 782 // // on gradue l'abscisse en pourcents 783 // // xcor[i]= 100.*( vmin+i*hpas ); 784 // xcor[i]= 100.*( vmin+i*hpas )/gmoy; 785 // } 786 787 // hist= vector<int>(ihist,0); 788 // for (unsigned i = 0; i < Eshf.size(); ++i) { 789 // double var= Eshf[i]-vmin; 790 // // if(var < 0 || var >= phist) cout<<"out of range "<<var<<", ("<< i<<")"<< endl; 791 // if(var < 0 ) { 792 // cout<<"lesser that the minimum "<<var<<", ("<< i<<")"<< endl; 793 // hist[0]++; 794 // } 795 // if(var >= phist) { 796 // cout<<"greater that the maximum "<<var<<", ("<< i<<")"<< endl; 797 // hist[ihist-1]++; 798 // } 799 // // int k= var/hpas; 800 // int kk= (int)floor(var/hpas); 801 // //if(i%20 == 0) cout<<"v("<<i<<")= " <<var<<" ["<<k<<"-"<<kk<<"], "<<endl; 802 // hist[kk]++; 803 // } 804 805 // cnts= 0; 806 // for (int i = 0; i < ihist; ++i) { 807 // if(hist.at(i) > 0) cnts++; 808 // //cout<<"("<<xcor.at(i)<<","<<hist.at(i)<<") "; 809 // } 810 // cout<< " ... cnts= " << cnts << endl; 811 // } 681 } 682 -
Interface_Web/trunk/pspaWT/sources/controler/src/softwareParmela.cc
r359 r371 15 15 bool softwareParmela::createInputFile(particleBeam* beamBefore,unsigned int numeroDeb,unsigned int numeroFin,string workingDir) 16 16 { 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 { 67 68 69 70 71 72 } 73 74 75 76 77 78 79 17 unsigned int k; 18 19 if ( numeroDeb < 1 || numeroFin > dataManager_->getBeamLineSize() ) { 20 dataManager_->consoleMessage(" softwareParmela::createInputFile : numero of element out of limits " ); 21 cerr << " numero of element out of limits " << endl; 22 return false; 23 } 24 25 string name = workingDir + inputFileName_; 26 ofstream outfile; 27 outfile.open(name.c_str(), ios::out); 28 if (!outfile) { 29 dataManager_->consoleMessage(" softwareParmela::createInputFile : error opening output stream " ); 30 cerr << " softwareParmela::createInputFile : error opening output stream " << name << endl; 31 return false; 32 } 33 34 abstractElement* elPtr; 35 double initalKineticEnergy = 0.0; 36 elPtr = dataManager_->getElementPointerFromNumero(numeroDeb); 37 bool there_is_rfgun = ( elPtr->getNomdElement().getElementType() == RFgun ); 38 39 if ( !there_is_rfgun ) { 40 string nameOfInput = workingDir + "parin.input0"; 41 if ( !beamToParmela(nameOfInput,beamBefore) ) return false; 42 initalKineticEnergy = beamBefore->referenceKineticEnergyMeV(); 43 // les elements de parmela sont indexes de 1 Ã max, s'il n'y a pas de rfgun 44 offsetNumElem_ = numeroDeb -1; 45 } else { 46 elPtr->setPhaseStep( globParamPtr_->getIntegrationStep() ); 47 initalKineticEnergy = elPtr->getInitialKineticEnergy(); 48 // les elements de parmela sont indexes de 0 Ã max, s'il y a un rfgun 49 offsetNumElem_ = numeroDeb; 50 } 51 52 outfile << "TITLE" << endl; 53 outfile << " titre provisoire " << endl; 54 outfile << "RUN /n0=1 /ip=999 /freq=" << globParamPtr_->getFrequency() << " /z0=0.0 /W0=" << initalKineticEnergy << " /itype=1" << endl; 55 outfile << "OUTPUT 0" << endl; 56 unsigned int premier = numeroDeb ; 57 if ( there_is_rfgun ) { 58 outfile << dataManager_->getElementPointerFromNumero(numeroDeb)->parmelaOutputFlow() << endl; 59 premier++; 60 } else { 61 outfile << "INPUT 0 /NP=" << beamBefore->getNbParticles() << endl; 62 } 63 64 // commentaire : si l'element est un snapshot ne rien ecrire dans inputFileName_ (= parmin) un saut de ligne perturbe l'execution de parmela 65 for ( k = premier; k <= numeroFin; k++) 66 { 67 elPtr = dataManager_->getElementPointerFromNumero(k); 68 if (elPtr) { 69 if(elPtr->getNomdElement().getElementType() == snapshot) continue; 70 outfile << elPtr->parmelaOutputFlow() << endl; 71 } 72 } 73 74 outfile << "ZOUT" << endl; 75 outfile << "START /wt=0.0 /dwt=" << globParamPtr_->getIntegrationStep() << " /nsteps=" << globParamPtr_->getNbSteps() << " nsc=" << globParamPtr_->getScPeriod() << " /nout=10" << endl; 76 outfile << "END" << endl; 77 outfile.close(); 78 dataManager_->consoleMessage("fichier input termine pour PARMELA"); 79 return true; 80 80 } 81 81 82 82 bool softwareParmela::execute(unsigned int numeroDeb,unsigned int numeroFin,string workingDir) 83 83 { 84 bool ExecuteStatus = true; 85 86 ostringstream sortie; 87 sortie << " EXECUTION DE PARMELA DE l'ELEMENT " << numeroDeb << " A L'ELEMENT " << numeroFin << endl; 88 89 string parmelaJob = workingDir + "parmela"; 90 parmelaJob += string(" "); 91 parmelaJob += workingDir; 92 93 string resultOfRun; 94 bool success = launchJob(parmelaJob,resultOfRun); 95 sortie << resultOfRun << endl; 96 if ( !success ) { 97 sortie << " launching of parmela failed " << endl; 98 ExecuteStatus = false; 99 } else { 100 sortie << " successful launching of parmela " << endl; 101 cout << " execution parmela MARCHE " << endl; 102 string::size_type nn = (resultOfRun).find("normal"); 103 if ( nn == string::npos ) 84 bool ExecuteStatus = true; 85 86 ostringstream sortie; 87 sortie << " EXECUTION DE PARMELA DE l'ELEMENT " << numeroDeb << " A L'ELEMENT " << numeroFin << endl; 88 89 string parmelaJob = workingDir + "parmela"; 90 parmelaJob += string(" "); 91 parmelaJob += workingDir; 92 93 string resultOfRun; 94 bool success = launchJob(parmelaJob,resultOfRun); 95 sortie << resultOfRun << endl; 96 if ( !success ) { 97 sortie << " launching of parmela failed " << endl; 98 ExecuteStatus = false; 99 } else { 100 sortie << " successful launching of parmela " << endl; 101 cout << " execution parmela MARCHE " << endl; 102 string::size_type nn = (resultOfRun).find("normal"); 103 if ( nn == string::npos ) 104 { 105 sortie << " abnormal exit of parmela " << endl; 106 ExecuteStatus = false; 107 } 108 } 109 110 dataManager_->consoleMessage(sortie.str()); 111 return ExecuteStatus; 112 } 113 114 bool softwareParmela::buildBeamAfterElements(unsigned int numeroDeb,unsigned int numeroFin, vector<particleBeam>& beams, string workingDir) 115 { 116 bool result = true; 117 cout << "debug:: debut " << numeroDeb << ", fin " << numeroFin << endl; 118 119 // index du premier element de parmela 120 int id= numeroDeb-offsetNumElem_; 121 122 for(unsigned k = numeroDeb; k <= numeroFin; k++) 123 { 124 abstractElement* elem = dataManager_->getElementPointerFromNumero(k); 125 126 // si l'element est un snapshot, recuperer la sortie precedente 127 if(elem->getNomdElement().getElementType() == snapshot) { 128 int avantDernier = beams.size() - 1; 129 string* param = elem->getParametersString(); 130 string cliche = workingDir + param[2].c_str(); 131 if( beamToParmela(cliche,&beams.at(avantDernier)) ) { 132 cout<<"["<<k<<"] : ecrit sur fichier " << cliche << " le contenu de beam["<<avantDernier<<"]"<<endl; 133 } 134 continue; 135 } 136 137 // sinon c'est un element de parmela d'index id 138 beams.push_back(particleBeam()); 139 cout << " creation diagn. no " << beams.size() << " par PARMELA " << endl; 140 vector<double> centroid; 141 bareParticle refPart; 142 vector<bareParticle> particles; 143 double freq= globParamPtr_->getFrequency(); 144 145 if(!beamFromParmela(workingDir,id,freq,centroid,refPart,particles)) 104 146 { 105 sortie << " abnormal exit of parmela " << endl; 106 ExecuteStatus = false; 107 } 108 } 109 110 dataManager_->consoleMessage(sortie.str()); 111 return ExecuteStatus; 112 } 113 114 bool softwareParmela::buildBeamAfterElements(unsigned int numeroDeb,unsigned int numeroFin, vector<particleBeam>& beams, string workingDir) 115 { 116 bool result = true; 117 cout << "debug:: debut " << numeroDeb << ", fin " << numeroFin << endl; 118 119 // index du premier element de parmela 120 int id= numeroDeb-offsetNumElem_; 121 122 for(unsigned k = numeroDeb; k <= numeroFin; k++) 123 { 124 abstractElement* elem = dataManager_->getElementPointerFromNumero(k); 125 126 // si l'element est un snapshot, recuperer la sortie precedente 127 if(elem->getNomdElement().getElementType() == snapshot) { 128 int avantDernier = beams.size() - 1; 129 string* param = elem->getParametersString(); 130 string cliche = workingDir + param[2].c_str(); 131 if( beamToParmela(cliche,&beams.at(avantDernier)) ) { 132 cout<<"["<<k<<"] : ecrit sur fichier " << cliche << " le contenu de beam["<<avantDernier<<"]"<<endl; 133 } 134 continue; 135 } 136 137 // sinon c'est un element de parmela d'index id 138 beams.push_back(particleBeam()); 139 cout << " creation diagn. no " << beams.size() << " par PARMELA " << endl; 140 vector<double> centroid; 141 bareParticle refPart; 142 vector<bareParticle> particles; 143 double freq= globParamPtr_->getFrequency(); 144 145 if(!beamFromParmela(workingDir,id,freq,centroid,refPart,particles)) 146 { 147 if(elem->is_accepted_by_software(nomDeLogiciel::parmela) == TBoolIgnore) { 148 int avantDernier = beams.size() -2; 149 beams.back() = beams.at(avantDernier); 150 } else { 151 dataManager_->consoleMessage("softwareParmela::buildBeamAfterElements : reading parmdesz failed"); 152 result = false; 153 break; 154 } 155 147 if(elem->is_accepted_by_software(nomDeLogiciel::parmela) == TBoolIgnore) { 148 int avantDernier = beams.size() -2; 149 beams.back() = beams.at(avantDernier); 150 } else { 151 dataManager_->consoleMessage("softwareParmela::buildBeamAfterElements : reading parmdesz failed"); 152 result = false; 153 break; 154 } 155 156 156 } else { 157 158 159 160 161 162 } 163 164 157 beams.back().setWithParticles(centroid,refPart,particles); 158 } 159 160 // l'element de parmela suivant 161 id++; 162 } 163 164 return result; 165 165 } 166 166 -
Interface_Web/trunk/pspaWT/sources/userInterface/src/GWt_pspaApplication.cc
r370 r371 277 277 choixVariableHisto_->addItem("y"); 278 278 choixVariableHisto_->addItem("z"); 279 choixVariableHisto_->addItem("xp"); 280 choixVariableHisto_->addItem("yp"); 279 281 choixVariableHisto_->addItem("dE/E"); 280 choixVariableHisto_->setCurrentIndex( 3);282 choixVariableHisto_->setCurrentIndex(5); 281 283 282 284 choixHistoDessin_ = new WComboBox(); … … 286 288 glayout->addWidget(button3,3,1); 287 289 glayout->addWidget(choixHistoDessin_,3,2); 288 // glayout->addWidget(new WText(" of "),3,3);289 290 glayout->addWidget(choixVariableHisto_,3,3); 290 291 ///////////////////////////////////////////////////////////////////// … … 600 601 vector<string> legende; 601 602 beam->donneesDessinEllipse(xcor,ycor,legende, indexAbs, indexOrd); 602 unsigned k; 603 603 604 for (int k=0 ; k < legende.size(); k++) { 604 new WBreak(ellipseDialog->contents());605 new WBreak(ellipseDialog->contents()); 605 606 new WText(legende.at(k), ellipseDialog->contents()); 606 607 } 607 608 // beam->donneesDessinEllipseXxp(xcor,ycor); 608 609 // scatterPlot1D(ellipseDialog->contents(),xcor,ycor); 609 chartPlot2vec(ellipseDialog->contents(), xcor, ycor, false,500,300); 610 611 } 612 613 610 chartPlot2vec(ellipseDialog->contents(), xcor, ycor, false,500,300); 611 } 614 612 615 613 // void PspaApplication::scatterPlot1D(WContainerWidget* toto, vector<double>& xcor, vector<double>& ycor) … … 844 842 vector<double> xcor; 845 843 vector<int> hist; 846 int cnts;847 844 double out[3]= {0.0}; 848 845 849 846 unsigned iabs= choixVariableHisto_->currentIndex(); 850 string xname= choixVariableHisto_->currentText().toUTF8(); 851 beam->histogramme(iabs,xcor,hist,cnts,out); 847 beam->histogramme(iabs,xcor,hist,out); 852 848 853 849 cout<<"xcor.size()= "<<xcor.size()<<", hist.size()= "<<hist.size()<<endl; … … 918 914 919 915 // legendes 916 string unites[2]; 917 if(iabs == 0 || iabs == 1 || iabs == 2) { 918 unites[0]= " m"; unites[1]= " mm"; 919 } 920 if(iabs == 3 || iabs == 4) { 921 unites[0]= unites[1]= " pi.mm.mrad"; 922 } 923 if(iabs == 5) { 924 unites[0]= " MeV"; unites[1]= " KeV"; 925 } 926 920 927 new WText(" entries : "+ mixedTools::intToString((int)out[0]),w); 921 928 new WBreak(w); 922 if(iabs < 3) { 923 new WText(" mean : "+ mixedTools::doubleToString(out[1])+" m",w); 924 new WBreak(w); 925 new WText(" sigma rms : "+ mixedTools::doubleToString(1000.0*out[2])+" mm",w); 926 } else { 927 new WText(" mean : "+ mixedTools::doubleToString(out[1])+" MeV",w); 928 new WBreak(w); 929 new WText(" sigma rms : "+ mixedTools::doubleToString(out[2])+" KeV",w); 930 } 931 929 new WText(" mean : "+ mixedTools::doubleToString(out[1])+unites[0],w); 930 new WBreak(w); 931 new WText(" sigma rms : "+ mixedTools::doubleToString(out[2])+unites[1],w); 932 932 933 WCartesianChart *chart = new WCartesianChart(w); 933 934 934 if(iabs == 0) { 935 chart->setTitle("Histogram of particle x-coordinate"); 936 } else if(iabs == 1) { 937 chart->setTitle("Histogram of particle y-coordinate"); 938 } else if(iabs == 2) { 939 chart->setTitle("Histogram of particle z-coordinate"); 940 } else { 941 chart->setTitle("Histogram of kinetic energy"); 942 } 943 935 if(iabs == 0) chart->setTitle("Histogram of x-coordinate"); 936 if(iabs == 1) chart->setTitle("Histogram of y-coordinate"); 937 if(iabs == 2) chart->setTitle("Histogram of z-coordinate"); 938 if(iabs == 3) chart->setTitle("Histogram of xp- ??? "); 939 if(iabs == 4) chart->setTitle("Histogram of yp- ???"); 940 if(iabs == 5) chart->setTitle("Histogram of kinetic energy"); 941 944 942 chart->setModel(model); // set the model 945 943 chart->setXSeriesColumn(0); // set the column that holds the categories … … 957 955 axis.setGridLinesEnabled(true); 958 956 959 if(iabs < 3) {960 axis.setTitle(WString(" ??? (%)"));957 if(iabs < 5) { 958 axis.setTitle(WString(" ???")); 961 959 } else { 962 960 axis.setTitle(WString(" dEcin/Ecin (%)")); -
Interface_Web/trunk/pspaWT/sources/userInterface/src/GWt_softwarePanel.cc
r367 r371 264 264 bool GWt_softwarePanel::areDataCoherent() 265 265 { 266 267 268 269 270 271 272 266 bool caMarche = true; 267 trivaluedBool tbResume = TBoolOk; 268 dtmanage_->initializeExecution(); 269 string diagnostic; 270 271 list<GWt_sectionToExecute*>::iterator itr; 272 for(itr = selectedSections_.begin(); itr != selectedSections_.end(); itr++) 273 273 { 274 string debString = (*itr)->debut->text().toUTF8(); 275 string finString = (*itr)->fin->text().toUTF8(); 274 string debString = (*itr)->debut->text().toUTF8(); 275 string finString = (*itr)->fin->text().toUTF8(); 276 277 int debut = dtmanage_->getNumeroFromElementLabel(debString); 278 int fin = dtmanage_->getNumeroFromElementLabel(finString); 279 nomDeLogiciel prog = nomDeLogiciel ( (*itr)->selection->currentIndex() ); 280 dtmanage_->addSectionToExecute(debut,fin,prog); 276 281 277 int debut = dtmanage_->getNumeroFromElementLabel(debString); 278 int fin = dtmanage_->getNumeroFromElementLabel(finString); 279 nomDeLogiciel prog = nomDeLogiciel ( (*itr)->selection->currentIndex() ); 280 dtmanage_->addSectionToExecute(debut,fin,prog); 281 282 // check sections 283 for (int i=debut-1; i<fin; i++) { 284 if (pspa_->getBeamLine()) { 285 if (pspa_->getBeamLine()->getAbstractElement(i)) { 286 trivaluedBool tb = pspa_->getBeamLine()->getAbstractElement(i)->setSoftware(prog.getString()); 287 if (tb == TBoolError ) { 288 diagnostic += pspa_->getBeamLine()->getAbstractElement(i)->getNomdElement().getElementName() + " is not allowed with "+ prog.getString()+"\n "; 289 caMarche = false; 290 tbResume = tb; 291 } else if ( tb == TBoolIgnore ) { 292 diagnostic += pspa_->getBeamLine()->getAbstractElement(i)->getNomdElement().getElementName() + " will be ignored by "+ prog.getString()+"\n "; 293 if ( tbResume != TBoolError ) tbResume = tb; 294 } else { 295 pspa_->getBeamLine()->update(i); 296 } 297 } 298 } 299 } 300 } 301 302 if ( tbResume == TBoolError ) { 303 GWt_dialog calculDialog("PSPA check execute : ERROR", diagnostic , GWt_dialog::Error,true,true); 304 calculDialog.exec(); 305 } else if (tbResume == TBoolIgnore ) { 306 GWt_dialog calculDialog("PSPA check execute : WARNING", diagnostic , GWt_dialog::Warning,false,true); 307 calculDialog.exec(); 308 } 309 /* 310 } else if ( essai == warning ) { 311 GWt_dialog calculDialog("PSPA check execute : warning ", diagnostic , GWt_dialog::Warning, false,true); 312 calculDialog.exec(); 313 */ 314 315 316 return caMarche; 282 // check sections 283 for (int i=debut-1; i<fin; i++) { 284 if (pspa_->getBeamLine()) { 285 if (pspa_->getBeamLine()->getAbstractElement(i)) { 286 trivaluedBool tb = pspa_->getBeamLine()->getAbstractElement(i)->setSoftware(prog.getString()); 287 if (tb == TBoolError ) { 288 diagnostic += pspa_->getBeamLine()->getAbstractElement(i)->getNomdElement().getElementName() + " is not allowed with "+ prog.getString()+"\n "; 289 caMarche = false; 290 tbResume = tb; 291 } else if ( tb == TBoolIgnore ) { 292 diagnostic += pspa_->getBeamLine()->getAbstractElement(i)->getNomdElement().getElementName() + " will be ignored by "+ prog.getString()+"\n "; 293 if ( tbResume != TBoolError ) tbResume = tb; 294 } else { 295 pspa_->getBeamLine()->update(i); 296 } 297 } 298 } 299 } 300 } 301 302 if ( tbResume == TBoolError ) { 303 GWt_dialog calculDialog("PSPA check execute : ERROR", diagnostic , GWt_dialog::Error,true,true); 304 calculDialog.exec(); 305 } else if (tbResume == TBoolIgnore ) { 306 GWt_dialog calculDialog("PSPA check execute : WARNING", diagnostic , GWt_dialog::Warning,false,true); 307 calculDialog.exec(); 308 } 309 310 /* 311 } else if ( essai == warning ) { 312 GWt_dialog calculDialog("PSPA check execute : warning ", diagnostic , GWt_dialog::Warning, false,true); 313 calculDialog.exec(); 314 */ 315 316 return caMarche; 317 317 } 318 318
Note: See TracChangeset
for help on using the changeset viewer.