Changeset 17 in ZHANGProjects
- Timestamp:
- Sep 30, 2014, 11:05:33 AM (10 years ago)
- Location:
- ICOSIM/CPP/trunk/source
- Files:
-
- 16 edited
Legend:
- Unmodified
- Added
- Removed
-
ICOSIM/CPP/trunk/source/Collimator.h
r9 r17 52 52 53 53 54 virtual void collipassCrystal(vector <Particle>& bunch, const double& betgam, const int& pas, string outputpath) {};54 virtual void collipassCrystal(vector <Particle>& bunch, const double& betgam, const int& pas, long int& nhit, string outputpath) {}; 55 55 //these methods are specific for a fluka/crystal collimator. They are just defined here. 56 56 #if defined(FLUKA) -
ICOSIM/CPP/trunk/source/CrystalCollimator.cc
r15 r17 32 32 33 33 34 void CrystalCollimator::collipassCrystal(vector <Particle>& bunch, const double& betgam, const int& pas, string outputpath)34 void CrystalCollimator::collipassCrystal(vector <Particle>& bunch, const double& betgam, const int& pas, long int& nhit, string outputpath) 35 35 { 36 36 //pas: number of turns 37 37 //Calculate proton energy 38 38 double Mproton(0.93827231); //rest mass [GeV] … … 62 62 63 63 for (int k(0); k < bunch.size(); ++k) { 64 64 //simulate the particles that are not lost on the previous aperture 65 if(bunch[k].inabs !=0){ 65 66 sortie << bunch[k].coordonnees[0][0] << "," << bunch[k].coordonnees[0][2] << "," << bunch[k].coordonnees[0][1] << "," << bunch[k].coordonnees[0][3] << "," << Eproton[k] << endl; 67 } 66 68 } 67 69 … … 93 95 // sim.general(sim, pas, outputpath, NAME, emitx0, emity0,enum, C_rotation, C_aperture, C_offset, C_tilt, Cry_tilt); 94 96 95 sim.general(sim, pas, outputpath, Mirror, C_rotation, C_aperture, C_offset, C_tilt, Cry_tilt);97 sim.general(sim, pas, nhit, outputpath, Mirror, C_rotation, C_aperture, C_offset, C_tilt, Cry_tilt); 96 98 99 100 //assign the new bunch coordinates after the crystal 101 for (int k(0); k < bunch.size(); ++k) { 102 bunch[k].inabs =0 ; 103 } 104 105 97 106 ifstream enter; 98 107 string file_in; … … 105 114 } else { 106 115 107 for (int k(0); k < bunch.size() ; ++k) {116 for (int k(0); k < bunch.size()-nhit; ++k) { 108 117 109 118 string rest; … … 120 129 getline(enter, rest, ','); 121 130 bunch[k].coordonnees[1][3] = atof(rest.c_str()); 122 131 132 //particle is not lost (interact) with the crystal 133 bunch[k].inabs = 1; 134 123 135 getline(enter, rest); 124 136 Eproton[k] = atof(rest.c_str()); 137 125 138 } 126 139 … … 128 141 } 129 142 143 130 144 vector <double> gamProton; 131 145 vector <double> betProton; -
ICOSIM/CPP/trunk/source/CrystalCollimator.h
r5 r17 44 44 //method specific to the passage through a Crystal collimator 45 45 46 void collipassCrystal(vector <Particle>& bunch, const double& betgam, const int& pas, string outputpath);46 void collipassCrystal(vector <Particle>& bunch, const double& betgam, const int& pas, long int& nhit, string outputpath); 47 47 48 48 -
ICOSIM/CPP/trunk/source/PlotRunSummary1.p
r5 r17 1 1 #Gnuplot script file for the PlotRunSummary (Plot of the loss map) 2 2 3 set autoscale xmax 4 set autoscale y 5 set key default 6 set xrange [-1:] 7 set ylabel "P' (W/m)" 8 set xlabel "Distance from starting point (km)" 9 set title "Loss map" 3 10 4 set autoscale xmax 5 set autoscale y 6 set key default 7 set xrange [-1:] 8 set ylabel "P'(W/m)" 9 set xlabel "Distance from starting point (km)" 10 set title "Loss map" 11 12 load 'labelsIP.p' 13 14 plot "PlotRunSummary1.dat" using 2:1 title 'Losses' with boxes, \ 15 "PlotRunSummary2.dat" using 2:1 title 'IP' with impulses 16 17 load 'labelsIPend.p' 11 plot "PlotRunSummary1.dat" using 2:1 title 'Losses' with boxes -
ICOSIM/CPP/trunk/source/PlotRunSummary2.p
r5 r17 1 #Gnuplot script f or the PlotRunSummary (Plot of the collimator load)1 #Gnuplot script file for the PlotRunSummary (Plot of the collimator load) 2 2 3 set autoscale 4 set key default 5 set style fill solid 0.5 6 set ylabel "P_coll (W)" 7 set xlabel "Collimators" 8 set title "Collimator load distribution" 3 9 4 set autoscale 5 set key default 6 set title "Collimator load distribution" 7 set ylabel "P_coll (W)" 8 set xlabel "Collimators" 9 set style fill solid 0.5 10 load 'labelscolli.p' 11 plot "PlotRunSummary3.dat" using 1:2 title 'Collimator load' with boxes 10 load 'labelscolli.p' 12 11 13 load 'labelscolliend.p' 12 plot "PlotRunSummary3.dat" using 1:2 title 'Collimator load' with boxes 13 14 load 'labelscolliend.p' -
ICOSIM/CPP/trunk/source/PlotRunSummary3.p
r5 r17 1 #Gnuplot script f or PlotRunSummary (Plot of thedevelopment after the first impact on collimator)1 #Gnuplot script file for the PlotRunSummary (Plot of the development after the first impact on collimator) 2 2 3 set autoscale 4 set key default 5 set ylabel "Number of particles" 6 set xlabel "N_turn" 7 set title "Time Development after first impact on collimator" 3 8 4 set autoscale 5 set key default 6 set title "Time Development after first impact on collimator" 7 set xlabel "N_turn" 8 set ylabel "Number of particles" 9 set logscale y 9 set logscale y 10 10 11 plot "PlotRunSummary4.dat" using 1:2 title 'particles in beam' with line, \ 12 "PlotRunSummary4.dat" using 1:3 title 'particles lost on collimators' with line, \ 13 "PlotRunSummary4.dat" using 1:4 title 'particles lost elsewhere' with line 11 plot "PlotRunSummary4.dat" using 1:2 title 'rest particles in beam' with line, "PlotRunSummary4.dat" using 1:3 title 'particles lost on collimators' with line, "PlotRunSummary4.dat" using 1:4 title 'particles lost elsewhere' with line 14 12 15 16 unset logscale y 13 unset logscale y -
ICOSIM/CPP/trunk/source/PlotTrajectory1.p
r5 r17 1 #Gnuplot script f or PlotTrajectory plotin x1 #Gnuplot script file for the PlotTrajectory in x 2 2 3 set autoscale x 4 set yrange [-25:25] 5 set style line 1 lw 1 6 set ylabel "x [mm]" 7 set xlabel "S-S_IP1 [km]" 8 set title "Trajectory in x" 3 9 4 set autoscale x 5 set yrange [-25:25] 6 set xlabel "S-S_IP1 [km]" 7 set ylabel "x [mm]" 8 set title "Trajectory in x" 9 set style line 1 lw 1 10 set style line 2 lw 1 lt 6 11 set key outside below 10 set style line 2 lw 1 lt 6 12 11 12 set key outside below 13 13 14 load 'plotxco.p' 15 16 17 unset key 18 14 load 'plotxco.p' 15 unset key -
ICOSIM/CPP/trunk/source/PlotTrajectory2.p
r5 r17 1 #Gnuplot script f or PlotTrajectory plotin y1 #Gnuplot script file for the PlotTrajectory in y 2 2 3 set autoscale x 4 set yrange [-25:25] 5 set style line 1 lw 1 6 set ylabel "y [mm]" 7 set xlabel "S-S_IP1 [km]" 8 set title "Trajectory in x" 3 9 4 set autoscale x 5 set yrange [-25:25] 6 set xlabel "S-S_IP1 [km]" 7 set ylabel "y [mm]" 8 set title "Trajectory in y" 9 set style line 1 lw 1 10 set style line 2 lw 1 lt 6 11 set key outside below 10 set style line 2 lw 1 lt 6 12 11 12 set key outside below 13 13 14 load 'plotyco.p' 15 16 17 unset key 14 load 'plotyco.p' 15 unset key -
ICOSIM/CPP/trunk/source/crystal_dan_FINAL_VERSION_CHvsVR.f
r16 r17 453 453 454 454 c write(*,*) "y = ", y 455 write(*,*) "before enter VR: x = ", x, " xp = ",xp456 write(*,*) "y = ",y, "yp = ", yp, "PC = ", PC455 c write(*,*) "before enter VR: x = ", x, " xp = ",xp 456 c write(*,*) "y = ",y, "yp = ", yp, "PC = ", PC 457 457 458 458 xp=xp+0.45*(xp/xpcrit+1)*Ang_avr … … 465 465 + xp ,yp,PC) 466 466 467 write(*,*) "after enter VR: x = ", x, " xp = ",xp468 write(*,*) "y = ",y, "yp = ", yp, "PC = ", PC467 c write(*,*) "after enter VR: x = ", x, " xp = ",xp 468 c write(*,*) "y = ",y, "yp = ", yp, "PC = ", PC 469 469 470 470 x = x + 0.5*s_length * xp … … 501 501 ! + DLRi(IS),xp ,yp,PC) 502 502 503 write(*,*) "before enter VR: x = ", x, " xp = ",xp504 write(*,*) "y = ",y, "yp = ", yp, "PC = ", PC503 c write(*,*) "before enter VR: x = ", x, " xp = ",xp 504 c write(*,*) "y = ",y, "yp = ", yp, "PC = ", PC 505 505 506 506 CALL CALC_ION_LOSS(IS,PC,s_length-Srefl,DESt) 507 507 508 write(*,*) "before enter VR: x = ", x, " xp = ",xp509 write(*,*) "y = ",y, "yp = ", yp, "PC = ", PC510 write(*,*) "IS = ", IS, " NAM = ", NAM511 write(*,*) "s_length-Srefl = ",s_length-Srefl512 write(*,*) "DESt = ", DESt, " DLYi(IS) = ", DLYi(IS)513 write(*,*) "DLRi(IS) = ", DLRi(IS)508 c write(*,*) "before enter VR: x = ", x, " xp = ",xp 509 c write(*,*) "y = ",y, "yp = ", yp, "PC = ", PC 510 c write(*,*) "IS = ", IS, " NAM = ", NAM 511 c write(*,*) "s_length-Srefl = ",s_length-Srefl 512 c write(*,*) "DESt = ", DESt, " DLYi(IS) = ", DLYi(IS) 513 c write(*,*) "DLRi(IS) = ", DLRi(IS) 514 514 515 515 CALL MOVE_AM_(IS,NAM,s_length-Srefl,DESt,DLYi(IS), 516 516 + DLRi(IS),xp ,yp,PC) 517 517 518 write(*,*) "after enter VR: x = ", x, " xp = ",xp519 write(*,*) "y = ",y, "yp = ", yp, "PC = ", PC518 c write(*,*) "after enter VR: x = ", x, " xp = ",xp 519 c write(*,*) "y = ",y, "yp = ", yp, "PC = ", PC 520 520 521 521 x = x + 0.5 * xp * (s_length - Srefl) … … 618 618 c endif 619 619 c 620 WRITE(*,*)'Crystal process: ',PROC620 c WRITE(*,*)'Crystal process: ',PROC 621 621 c write(*,*)'xp_final :', xp 622 622 c WRITE(*,*)'Crystal process: ',PROC,'Chann Angle',Ch_angle/1000, + … … 838 838 839 839 840 write(*,*) "In Move_AM(): "840 c write(*,*) "In Move_AM(): " 841 841 842 842 843 843 xp=xp*1000 844 844 yp=yp*1000 845 write(*,*)'xp initial:', xp, 'yp initial', yp845 c write(*,*)'xp initial:', xp, 'yp initial', yp 846 846 C. DEI - dE/dx stoping energy 847 847 PC = PC - DEI*DZ ! energy lost because of ionization process[GeV] … … 849 849 C. DYA - rms of coloumb scattering 850 850 DYA = (13.6/PC)*SQRT(DZ/DLr) !MCS (mrad) 851 write(*,*)'dya= ',dya851 c write(*,*)'dya= ',dya 852 852 853 853 ran_x = RAN_GAUSS(1.) 854 write(*,*) "ran_x = ", ran_x854 c write(*,*) "ran_x = ", ran_x 855 855 856 856 ran_y = RAN_GAUSS(1.) 857 write(*,*) "ran_y = ", ran_y857 c write(*,*) "ran_y = ", ran_y 858 858 859 859 kxmcs = DYA*ran_x … … 867 867 868 868 c write(*,*) "ran_x = ", ran_x, "ran_y = ", ran_y 869 write(*,*) "kxmcs = ", kxmcs, "kymcs = ", kymcs870 write(*,*)'xp + kxmcs:', XP, 'yp + kxmcs', YP869 c write(*,*) "kxmcs = ", kxmcs, "kymcs = ", kymcs 870 c write(*,*)'xp + kxmcs:', XP, 'yp + kxmcs', YP 871 871 872 872 cc XP = XP+DYA*RAN_GAUSS(1.) … … 938 938 endif 939 939 940 write(*,*) "ichoix = ", ichoix941 write(*,*)'xp final:', xp, 'yp final', yp940 c write(*,*) "ichoix = ", ichoix 941 c write(*,*)'xp final:', xp, 'yp final', yp 942 942 943 943 !---------- calculate the related kick ----------- … … 980 980 981 981 982 write(*,*) "tx = ", tx, " tz = ", tz982 c write(*,*) "tx = ", tx, " tz = ", tz 983 983 984 984 XP = XP + tx … … 990 990 yp=yp/1000 991 991 992 write(*,*)'xp final:', xp, 'yp final', yp992 c write(*,*)'xp final:', xp, 'yp final', yp 993 993 !----------------------------------------------- 994 994 ! print out the energy loss and process experienced -
ICOSIM/CPP/trunk/source/crystalprotonfuns.f
r15 r17 28 28 save 29 29 30 write(*,*) "In RAN_GAUSS: "30 c write(*,*) "In RAN_GAUSS: " 31 31 c write(*,*) "flag = ",flag 32 32 c write(*,*) "U1 = ", U1,"U2 = ", U2 … … 53 53 RAN_GAUSS = x 54 54 55 write(*,*) "ran_gauss = ", RAN_GAUSS55 c write(*,*) "ran_gauss = ", RAN_GAUSS 56 56 57 57 return -
ICOSIM/CPP/trunk/source/lattice.cc
r15 r17 441 441 { 442 442 443 cout << "bunch size is: " << bunch.size() << endl; 444 445 443 446 if (idpart >= 0) { 444 447 if (idpart > bunch.size()) { … … 602 605 read(bunch); 603 606 }*/ 604 607 608 605 609 for (int p(0); p < bunch.size(); ++p) { //loop througt the particles 606 610 607 611 double dpopeff; 608 612 613 // .inabs = 0, particle lost, .inabs = 1, particle not lost 609 614 if (bunch[p].inabs == 1) { 610 615 … … 743 748 744 749 int lost(bunch.size()); 745 746 resColli[icop]->collipassCrystal(bunch, betgam, turn, outputpath); 747 748 nhitcolli[icop] = lost - bunch.size(); //nhitcolli(icop) gives the number particles getting lost in collimator number icop, 749 750 751 long int nhit = 0; 752 753 resColli[icop]->collipassCrystal(bunch, betgam, turn, nhit, outputpath); 754 755 //nhitcolli[icop] = lost - bunch.size(); //nhitcolli(icop) gives the number particles getting lost in collimator number icop, 756 757 nhitcolli[icop] = nhit; 758 759 // cout << "after the crystal: bunch size = " << bunch.size()<< endl; 750 760 } 751 761 … … 924 934 if (inside == false) { 925 935 cout <<"The particle is lost at element " << reseau[i]->NAME << endl; 936 // cout << "Particle ID is: " << p << endl; 937 // cout << "bunch size is: " << bunch.size() << endl; 938 // cout << "bunch status is: " << bunch[p].inabs << endl; 939 // 926 940 xh0 = bunch[p].coordonnees[0][0]; 927 941 bunch[p].inabs = 0; … … 1100 1114 } 1101 1115 } 1116 // cout << "bunch size is ...." << bunch.size() << endl; 1102 1117 1103 1118 if (plotflag == "Yes") { … … 1132 1147 vector <Particle> tempinabs; 1133 1148 1134 //we contine just with particles that are not lost1149 //we contine to track for the next turn; just with particles that are not lost 1135 1150 for (int w(0); w < bunch.size(); ++w) { 1136 1151 if (bunch[w].inabs != 0) { … … 1139 1154 } 1140 1155 1156 // cout << "bunch size before the turn: "<< bunch.size() << endl; 1157 1141 1158 bunch.clear(); 1142 1159 … … 1147 1164 tempinabs.clear(); 1148 1165 1149 } 1166 // cout << "bunch size after the turn " <<bunch.size() << endl; 1167 } -
ICOSIM/CPP/trunk/source/partcrys.h
r15 r17 44 44 int nvcapt; 45 45 int nvrefl; 46 int nabsorbed; 46 47 int nout; //number of particles that not hit the crystal collimator 47 int effet; //Number that defini the effect :1 --> Out ;;; 2 --> Amorphous ;;; 3 --> Channeling ;;; 4 --> Dechanneling ;;; 5 --> V. Reflection ;;; 6 --> V. Capture 48 int effet; //Number that defini the effect :1 --> Out ;;; 2 --> Amorphous ;;; 3 --> Channeling ;;; 4 --> Dechanneling ;;; 5 --> V. Reflection ;;; 6 --> V. Capture, 7 --> absorbed 49 long int nhit; //number of particles that hit the crystal collimator 50 48 51 49 52 }; -
ICOSIM/CPP/trunk/source/simcrys.cc
r16 r17 576 576 * original crystal routine 577 577 * *******************************************************************************/ 578 void SimCrys::general(SimCrys& sim, const int& pas, string outputpath, double Mirror, double C_rotation, double C_aperture, double C_offset, double C_tilt, double Crystal_tilt)578 void SimCrys::general(SimCrys& sim, const int& pas, long int& nhit, string outputpath, double Mirror, double C_rotation, double C_aperture, double C_offset, double C_tilt, double Crystal_tilt) 579 579 { 580 580 srand ( time(NULL) ); … … 659 659 660 660 661 661 662 663 662 664 //----------------------------------END OF INITATING REFERNENTIAL PARAMETERS------------------------------------------------------------------------- 663 665 c_length = crys.Cry_length; … … 692 694 * xmin=x-, xmax=x+, etc. from the input file 693 695 */ 694 long int nhit = 0; 696 697 698 //initialize particle variables 699 part.n_part = 0; 700 part.nabsorbed = 0; 701 part.namor = 0; 702 part.nchann = 0; 703 part.ndechann = 0; 704 part.nout =0; 705 part.nvcapt = 0; 706 part.nvrefl = 0; 707 part.nhit = 0; 708 nhit = 0; 695 709 double fracab = 0; 696 710 // int n_chan = 0; // valentina :initialize to zero the counters for crystal effects … … 748 762 while (!entree.eof()) { 749 763 count = count + 1; 764 765 //particle hit the crystal or not 766 bool hitflag = false; 767 750 768 751 769 getline(entree, rest, ','); … … 927 945 s_impact = s_in0; //!(for the first impact) 928 946 929 if( 1){947 if(0){ 930 948 cout<<"hit the cry entrance face"<<endl; 931 949 cout<<"impact at s = "<< s_impact<< ", x = "<<x_in0<<endl; … … 1062 1080 //cout<<"----------------------1111111111111111111111111-----------------"<<endl; 1063 1081 1064 1082 if(layerflag == 0){ 1083 part.namor = part.namor + 1; /////////////COUNT///////////// 1084 part.effet = 2; 1085 } 1086 1065 1087 if (strncmp(Proc,"out",3)==0) 1066 1088 crossing = false; … … 1069 1091 1070 1092 if (crossing == true){ 1071 nhit = nhit + 1; 1093 hitflag = true; 1094 nhit = nhit + 1; 1095 part.nhit = nhit; 1072 1096 // lhit = 100000000*ie + ITURN; 1073 1097 impact = x_in0; … … 1261 1285 xp_in0 = xp_shift; 1262 1286 } ////////////////////////// fin IF NUMERO 17////////////////// 1263 1287 hitflag = true; 1264 1288 nhit = nhit + 1; 1289 part.nhit = nhit; 1265 1290 //lhit = 100000000*ie + ITURN; 1266 1291 impact = x_in0; … … 1339 1364 1340 1365 1341 nabs = 0; 1366 nabs = 0; //particle lost or not lost..... 1342 1367 part.effet = nabs; 1343 1368 //cout<< "debug - S Coll RF 2" , s_rot <<endl; … … 1375 1400 part.nvcapt = part.nvcapt + 1; /////////////COUNT///////////// 1376 1401 part.effet = 6;} 1402 if(strncmp(Proc,"absorbed",8==0)){ 1403 part.nabsorbed = part.nabsorbed +1; 1404 part.effet = 7; 1405 } 1406 /* 1407 if (PROC(1:3).eq.'pne') 1408 PROC_dan=7 1409 if (PROC(1:3).eq.'ppe') 1410 PROC_dan=8 1411 if (PROC(1:4).eq.'diff') 1412 PROC_dan=9 1413 if (PROC(1:4).eq.'ruth') 1414 PROC_dan=10 1415 */ 1416 1377 1417 1378 1418 // ????????????????????????????????????? … … 1471 1511 av_pc1 = av_pc1 + part.PC; 1472 1512 1473 1513 if(0){ 1474 1514 cout<<" X apres :"<<part.x<<" XP apres :"<<part.xp<<" Y apres :"<<part.y<<" YP apres :"<<part.yp<<" PC apres :"<<part.PC<<endl; 1475 1515 //cout<<endl; 1516 } 1517 //only record the particles that hit the collimator. 1518 if(hitflag != true){ 1476 1519 //sortieIco.setf(ios::scientific); 1477 sortieIco << part.x << "," << part.y << "," << part.xp << "," << part.yp << "," << part.PC << endl;1520 sortieIco << part.x << "," << part.y << "," << part.xp << "," << part.yp << "," << part.PC << endl; 1478 1521 //}//end of for.... 1479 1522 } 1523 1480 1524 } 1481 1525 } //End of while … … 1525 1569 file_out(pas, outputpath); 1526 1570 1571 if(1){ 1572 cout << "number of particles before the crystal: " << count<< endl; 1573 cout << "number of particle hit the crystal: " << part.nhit << endl; 1574 cout << "number of particles after the crystal: " << count - part.nhit << endl; 1575 } 1527 1576 //cout<<endl; 1528 1577 //cout<<endl; … … 1667 1716 cout << "N.OUT :" << part.nout << endl; 1668 1717 cout << "N.VREFLECTION :" << part.nvrefl << endl; 1669 cout << "N.VCAPTURE :" << part.nvcapt << endl; 1718 cout << "N.VCAPTURE:" << part.nvcapt << endl; 1719 cout << "N.ABSORBED: "<< part.nabsorbed << endl; 1670 1720 1671 1721 //cout << "Si la somme ne donne pas le nbre de part., c est normale !! En effet, il est possible que plusieurs evenement se produisent!!!"; … … 1688 1738 out << "Crystal Curved Length [m] :" << crys.Cry_length << endl; 1689 1739 out << "Crystal Curvature Radius [m] :" << crys.Rcurv << endl; 1690 out << "Crystal Bending Angle [urad] :" << crys.cry_bend << " , " << crys.Cry_length / crys.Rcurv << endl;1740 out << "Crystal Bending Angle [urad] :" << crys.cry_bend << " , " << 1e6*crys.Cry_length / crys.Rcurv << endl; 1691 1741 out << "Critical Radius :" << crys.Rcrit << endl; 1692 1742 out << "Ratio :" << crys.ratio << endl; … … 1702 1752 out << "N.OUT :" << part.nout << endl; 1703 1753 out << "N.VREFLECTION :" << part.nvrefl << endl; 1704 out << "N.VCAPTURE :" << part.nvcapt << endl << endl << endl; 1705 1754 out << "N.VCAPTURE :" << part.nvcapt << endl ; 1755 out << "N.ABSORBED: "<< part.nabsorbed << endl; 1756 out << "N. of particles that hit the crystal collimator: " << part.nhit << endl; 1757 cout << endl; 1758 cout << endl; 1759 1706 1760 out.close(); 1707 1761 } -
ICOSIM/CPP/trunk/source/simcrys.h
r9 r17 53 53 //THE GENERAL FUNCTION OF THE TEST THAT REGROUP ALL THE PREVIOUS FUNCTIONS!!!! 54 54 55 void general(SimCrys& sim, const int& pas, string outputpath, double Mirror, double C_rotation, double C_aperture, double C_offset, double C_tilt, double Crystal_tilt);55 void general(SimCrys& sim, const int& pas, long int& nhit, string outputpath, double Mirror, double C_rotation, double C_aperture, double C_offset, double C_tilt, double Crystal_tilt); 56 56 57 57 -
ICOSIM/CPP/trunk/source/simulation.cc
r15 r17 78 78 particlefile = inputfile + "initial.dat"; 79 79 80 cout << "READ THE BUNCH OF PARTICLES FROM THE FILE: " << particlefile <<endl; 81 80 82 //if the name of the file is not 'initial.dat', uncomment the following two lines 81 83 … … 663 665 cout <<"********************************"<<endl; 664 666 cout << "RunningFlag = " << RunningFlag << endl; 665 cout << "READ THE BUNCH OF PARTICLES FROM THE FILE: " <<inputfile <<endl;667 666 668 readParticle(Apr, Zpr, inputfile); 667 669 … … 676 678 cout << "RunningFlag = " << RunningFlag << endl; 677 679 cout << "GENERATION OF THE BUNCH OF PARTICLES." << endl; 678 genbunch(i0, nparti, partdistr, r1r2skin, nsigi * nsigi * emix, nsigi * nsigi * emiy, sigdpp, lat.reseau[i0]->BETX, lat.reseau[i0]->ALFX, lat.reseau[i0]->DX, lat.reseau[i0]->DPX, lat.reseau[i0]->BETY, lat.reseau[i0]->ALFY, lat.reseau[i0]->DY, lat.reseau[i0]->DPY, nsigi );680 genbunch(i0, nparti, partdistr, r1r2skin, nsigi * nsigi * emix, nsigi * nsigi * emiy, sigdpp, lat.reseau[i0]->BETX, lat.reseau[i0]->ALFX, lat.reseau[i0]->DX, lat.reseau[i0]->DPX, lat.reseau[i0]->BETY, lat.reseau[i0]->ALFY, lat.reseau[i0]->DY, lat.reseau[i0]->DPY, nsigi, inputfile); 679 681 680 682 //we set the id of the particles … … 742 744 cout <<"********************************"<<endl; 743 745 cout << "RunningFlag = " << RunningFlag << endl; 744 cout << "READ THE BUNCH OF PARTICLES FROM THE FILE: " <<inputfile <<endl;745 746 readParticle(Apr, Zpr, inputfile); 746 747 } else if (RunningFlag == 3) { … … 749 750 cout << "RunningFlag = " << RunningFlag << endl; 750 751 cout << "GENERATION OF THE BUNCH OF PARTICLES." << endl; 751 genbunch(i0, nparti, partdistr, r1r2skin, nsigi * nsigi * emix, nsigi * nsigi * emiy, sigdpp, lat.reseau[i0]->BETX, lat.reseau[i0]->ALFX, lat.reseau[i0]->DX, lat.reseau[i0]->DPX, lat.reseau[i0]->BETY, lat.reseau[i0]->ALFY, lat.reseau[i0]->DY, lat.reseau[i0]->DPY, nsigi );752 genbunch(i0, nparti, partdistr, r1r2skin, nsigi * nsigi * emix, nsigi * nsigi * emiy, sigdpp, lat.reseau[i0]->BETX, lat.reseau[i0]->ALFX, lat.reseau[i0]->DX, lat.reseau[i0]->DPX, lat.reseau[i0]->BETY, lat.reseau[i0]->ALFY, lat.reseau[i0]->DY, lat.reseau[i0]->DPY, nsigi, inputfile); 752 753 } 753 754 … … 827 828 828 829 829 //We take the particles hitting collimators during the previous tracking (we take their coordinates at the beginning of the last turn before the hit), and do a more precisetracking830 //We take the particles hitting collimators during the previous tracking (we take their coordinates at the beginning of the last turn before the hit), and do a preciser tracking 830 831 cout <<" "<<endl; 831 832 cout <<"********************************"<<endl; … … 1101 1102 1102 1103 for (int m(0); m < lat.nhitcolli.size(); ++m) { 1104 cout << "m = " << m << "nhitcollio[m] is: " << nhitcollio[m] << " lat.nhitcolli[m] is: " << lat.nhitcolli[m] << endl; 1103 1105 nhitcollio[m] = nhitcollio[m] + lat.nhitcolli[m]; 1104 1106 } … … 1106 1108 for (int m(0); m < lat.nhitspoiler.size(); ++m) { 1107 1109 nhitspoilero[m] = nhitspoilero[m] + lat.nhitspoiler[m]; 1110 1108 1111 } 1109 1112 … … 1871 1874 1872 1875 1873 void Simulation::genbunch(const int& i0, const int& npart, const string& partdistr, const double& r1r2skin, const double& emx, const double& emy, const double& sigdpp, const double& bx, const double& ax, const double& dx, const double& dpx, const double& by, const double& ay, const double& dy, const double& dpy, const double& nsigi )1876 void Simulation::genbunch(const int& i0, const int& npart, const string& partdistr, const double& r1r2skin, const double& emx, const double& emy, const double& sigdpp, const double& bx, const double& ax, const double& dx, const double& dpx, const double& by, const double& ay, const double& dy, const double& dpy, const double& nsigi, const string& inputfile) 1874 1877 { 1875 1878 1876 1879 //save bunch distribution 1877 1880 1878 //string path1;1879 //path1 = outputpath+ "initial.dat";1880 ofstream sortie( "initial.dat");1881 string outfile; 1882 outfile = inputfile + "initial.dat"; 1883 ofstream sortie(outfile.c_str()); 1881 1884 1882 1885 if (sortie.fail()) { … … 1999 2002 sortie << endl; 2000 2003 2001 sortie << " Number of particles that have hit another element during a preceding turn(asumhits):";2004 sortie << "(Total) Number of particles that have hit another element during the preceding turns (asumhits):"; 2002 2005 2003 2006 for (int i(0); i < asumhits.size(); ++i) { … … 2007 2010 sortie << endl; 2008 2011 2009 sortie << " Number of particles that have hit the collimators, for each collimator (nhitcolli):";2012 sortie << "(Total) Number of particles that have hit the collimators, for each collimator (nhitcolli):"; 2010 2013 2011 2014 for (int i(0); i < nhitcollio.size(); ++i) { … … 2102 2105 2103 2106 for (int i(0); i < plosslocal.size(); ++i) { 2104 outplot1 2107 outplot1<< setw(10) << plosslocal[i]*PlossPb / NLostTotal << setw(10) << zlosslocal[i] / 1000 << endl; 2105 2108 } 2106 2109 … … 2190 2193 vector <int> newnhitcolli, ipsnew; 2191 2194 2195 cout << " size of nhitcollio.size(): "<<nhitcollio.size()<<endl; 2192 2196 for (int i(0); i < nhitcollio.size(); ++i) { 2193 2197 if (removedCollimators[i] == 0) { … … 2209 2213 2210 2214 for (int i(0); i < newnhitcolli.size(); ++i) { 2211 outplot3 << setw(10) << i + 1 << setw(10) << newnhitcolli[i]*PlossPb / NLostTotal << setw(10) << ipsnew[i] << setw(20) << lat.reseau[ipsnew[i]]->NAME << endl; 2215 cout << newnhitcolli[i]*PlossPb / NLostTotal << endl; 2216 outplot3 << setw(10) << i + 1 << setw(20) << newnhitcolli[i]*PlossPb / NLostTotal << setw(10) << ipsnew[i] << setw(20) << lat.reseau[ipsnew[i]]->NAME << endl; 2212 2217 } 2213 2218 outplot3.close(); … … 2262 2267 2263 2268 for (int i(0); i < asumrem.size(); ++i) { 2264 outplot4 << setw(10) << i << setw(10) << asumrem[i] << setw(10) << asumhitcolli[i] << setw(10) << asumhits[i] << endl;2269 outplot4 << setw(10) << i << setw(10) << asumrem[i] << setw(10) << asumhitcolli[i] << setw(10) << asumhits[i] << setw(10) << (asumrem[i]+asumhitcolli[i]+asumhits[i])<<endl; 2265 2270 } 2266 2271 outplot4.close(); … … 2273 2278 //Writing PlotRunSummary1.p 2274 2279 2280 //flag to switch to generate GUNPLOT script or not, default is false 2281 bool gnuplotflag = true; 2282 if(gnuplotflag) 2283 { 2275 2284 ofstream PlotRun1; 2276 2285 string plotrunname1; … … 2288 2297 PlotRun1 << "set key default" << endl; 2289 2298 PlotRun1 << "set xrange [-1:]" << endl; 2290 PlotRun1 << "set ylabel \"P\' (W/m)\"" << endl;2299 PlotRun1 << "set ylabel \"P\' (W/m)\"" << endl; 2291 2300 PlotRun1 << "set xlabel \"Distance from starting point (km)\"" << endl; 2292 2301 PlotRun1 << "set title \"Loss map\"" << endl << endl; … … 2352 2361 } 2353 2362 2363 } 2364 2354 2365 } 2355 2366 -
ICOSIM/CPP/trunk/source/simulation.h
r8 r17 83 83 //method generating an initial bunch of particles 84 84 85 void genbunch(const int& i0, const int& npart, const string& partdistr, const double& r1r2skin, const double& emx, const double& emy, const double& sigdpp, const double& bx, const double& ax, const double& dx, const double& dpx, const double& by, const double& ay, const double& dy, const double& dpy, const double& nsigi );85 void genbunch(const int& i0, const int& npart, const string& partdistr, const double& r1r2skin, const double& emx, const double& emy, const double& sigdpp, const double& bx, const double& ax, const double& dx, const double& dpx, const double& by, const double& ay, const double& dy, const double& dpy, const double& nsigi, const string& inputfile); 86 86 87 87
Note: See TracChangeset
for help on using the changeset viewer.