ࡱ> OQN %bjbj ANhhxx\0Lp|||||WWW#%%%%%%$ZIWWWWWI||^W||#W#|5 mt0X4WWWWWWWIIWWWWWWWWWWWWWWWWx : PC-MCP.cpp /* Simulation of electrons emitted by the photocathode from a single point (0,0) to the 1st MCP */ /* All the parameters (#define) are set in the file functions.h */ /* additionnal informations could be found in the PDF/PPT document */ #include #include #include #include #include "functions.h" using namespace std; const double RANDMAX = (double)RAND_MAX; // used to normalize the random number int main(void) { int n_T = 0,n_X = 0; // number of events out of range double gap = 0.; // gap between PC and MCPs (called 'd' in the document) double dt = 0., dx = 0;; // size of intervals in histograms double tof = 0.; // result of the function called 'fTOF' Electron electron; unsigned int nTOF[PRECISION_T]={0}, nX[PRECISION_X]={0}; // these 2 tables will contain histograms data /* Initialization of the random generator */ srand((unsigned)time(NULL)); /* Initial position of electrons and initialisation of the other parameters */ electron.x0 = 0.; electron.z0 = 0.; electron.v_r0 = 0.; electron.v_theta0 = 0.; electron.x = 0.; electron.z = 0.; electron.v_r = 0.; electron.v_theta = 0.; /* Keyboard input: size of the gap */ cout << "Which size of the gap do you want to test (in millimeters) ? "; cin >> gap; gap /= 1000.; // conversion into meters /* dt and dx calculation */ dt = (T_MAX-T_MIN) / PRECISION_T; dx = X_MAX / PRECISION_X; /* Creation of 2 data files in write mode */ fstream data_t("data_time.txt",ios::out); fstream data_x("data_x.txt",ios::out); /* Header of data files */ data_t << "========== METADATA: 'Time' histogram ==========" << endl; data_t << "== ==" << endl; data_t << "== T_MIN (in seconds):\t\t" << T_MIN << endl; data_t << "== T_MAX (in seconds):\t\t" << T_MAX << endl; data_t << "== dt (in seconds):\t\t" << dt << endl; data_t << "== PRECISION_T:\t\t" << PRECISION_T << endl; data_t << "== Nb of simulated electrons:\t" << NBELECTRONS << endl; data_t << "== gap size (in meters):\t" << gap << endl; data_x << "========== METADATA: 'X' histogram ==========" << endl; data_x << "== ==" << endl; data_x << "== X_MIN (in meters):\t\t" << X_MIN << endl; data_x << "== X_MAX (in meters):\t\t" << X_MAX << endl; data_x << "== dx (in meters):\t\t" << dx << endl; data_x << "== PRECISION_X:\t\t" << PRECISION_X << endl; data_x << "== Nb of simulated electrons:\t" << NBELECTRONS << endl; data_x << "== gap size (in meters):\t" << gap << endl; /* Data calculation */ cout << endl << "Beginning of calculation... Please wait"; for (int i=0; i(PRECISION_T-1)) n_T++; else nTOF[j]++; j = (int)(fabs(electron.x)/dx); if (j<0 || j>(PRECISION_X - 1)) n_X++; else nX[j]++; } /* RMS calculation */ cout << endl << endl << "RMS calculation and writing of data files..." << endl << endl << endl << endl; double t_med, x_med; double rms_T = RMS(nTOF, PRECISION_T, dt, T_MIN, n_T, T_sym, t_med); double rms_X = RMS(nX, PRECISION_X, dx, X_MIN, n_X, X_sym, x_med); /* Writing of data into the files */ data_t << "== Nb electrons out of range:\t" << n_T << endl; data_t << "== RMS:\t\t\t" << rms_T << endl; data_t << "== Medium time (in seconds):\t" << t_med << endl; data_t << "== ==" << endl; data_t << "==================================================" << endl << endl; data_x << "== Nb electrons out of range:\t" << n_X << endl; data_x << "== RMS:\t\t\t" << rms_X << endl; data_x << "== Medium 'X' (in meters):\t" << x_med << endl; data_x << "== ==" << endl; data_x << "===============================================" << endl << endl; cout << "Events out of range in time:\t" << n_T << endl; cout << "Events out of range in X:\t" << n_X << endl << endl; for(int i=0; i #define Q 1.602177e-19 // elementary charge #define ME 9.109390e-31 // electron masse #define DV 200 // potential difference between PC and MCP1 #define V0 324853.0 // maximum velocity module (called v0MAX in the document) #define VK (Q*DV/ME) // constant whose dimension is the square of a velocity #define NBELECTRONS 10000000 // number of simulated electrons #define PRECISION_T 5000 // number of intervals for the 'time' histogram #define T_MIN (4.57e-10) #define T_MAX (4.87e-10) // 'time' histogram defined in the range: T_MIN -> T_MAX (in seconds!) #define T_sym false // the 'time' histogram is not symmetric with respect to 0 #define PRECISION_X 5000 // number of intervals for the 'X' histogram #define X_MIN 0. #define X_MAX (1.6e-4) // 'X' histogram defined in the range: 0 -> XMAX (in meters!) #define X_sym true // the 'X' histogram is symmetric with respect to 0 struct Electron { double x0,z0,v_r0,v_theta0; // initial conditions double x,z,v_r,v_theta; // final results }; /* Calculation of the time of flight of an electron with final position and velocity */ double fTOF(Electron &electron, const double gap); /* RMS calculation */ double RMS(const unsigned int nA[], const int precision_A, const double da, const double A_min, const int n_A, const bool A_sym, double &A_med); functions.cpp /* Functions used in PC-MCP.cpp */ #include "functions.h" using namespace std; /* Calculation of the time of flight of an electron with final position and velocity */ double fTOF(Electron &electron,const double gap) { /* Calculation of the TOF, final position and final velocity of the electron */ double delta, v_z; v_z = electron.v_r0 * cos(electron.v_theta0); delta = v_z*v_z + 2*VK; // delta = 'LAMBDA'^2 in the document double tof = (sqrt(delta) - v_z) * gap/VK; /* Calculation of the final position (see document for more details) */ electron.z = gap; electron.x = electron.v_r0 * tof * sin(electron.v_theta0); /* Calculation of the final velocity */ electron.v_r = sqrt(electron.v_r0*electron.v_r0 + VK*VK/(gap*gap)*tof*tof + 2*VK/gap*tof*electron.v_r0*cos(electron.v_theta0)); electron.v_theta = asin(electron.v_r0*sin(electron.v_theta0)/electron.v_r); return tof; } /* RMS calculation */ double RMS(const unsigned int nA[], const int precision_A, const double da, const double A_min, const int n_A, const bool A_sym, double &A_med) { double i_A = A_min; // i -> true 'A' (time or length) double med_A = 0.; int s_A = NBELECTRONS - n_A; // sum of all counted events in 'A' if (A_sym) // if 'A' histogram is symmetric A_med = 0.; else { for (int i=0; iCGH5<CGKLTZtyzɪɪɪɪɪɪɪɪɪɐɐɪ3h<hICJOJQJ^JaJmHnHsH tH u<h<hIB*CJOJQJ^JaJmHnHphsH tH u<h<hIB* CJOJQJ^JaJmHnHphsH tH u-hTCJOJQJ^JaJmHnHsH tH u8'(h05T1d7$8$H$gdI !'12@dlm{¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨f<h<hIB* CJOJQJ^JaJmHnHphsH tH u'h<hICJaJmHnHsH tH uh<hICJaJmH sH 3h<hICJOJQJ^JaJmHnHsH tH u<h<hIB*CJOJQJ^JaJmHnHphsH tH u<h<hIB* CJOJQJ^JaJmHnHphsH tH u%1@cd{| r "!#!m!!!!!h"""d7$8$H$gdI ]^gdI{|    " r s y ūūūūūmS4S<h<hIB* CJOJQJ^JaJmHnHphsH tH u3h<hICJOJQJ^JaJmHnHsH tH u<h<hIB*CJOJQJ^JaJmHnHphsH tH u<h<hIB* CJOJQJ^JaJmHnHphsH tH u3h<hICJOJQJ^JaJmHnHsH tH u<h<hIB*CJOJQJ^JaJmHnHphsH tH u6h<B*CJOJQJ^JaJmHnHphsH tH u "!#!%!m!!!i""""""""""""### ####%#*#/#0#6#>#C#D#ˬxYYYYYYYYYYYY<h<hIB*CJOJQJ^JaJmHnHphsH tH u3h<hICJOJQJ^JaJmHnHsH tH u3h<hICJOJQJ^JaJmHnHsH tH u<h<hIB* CJOJQJ^JaJmHnHphsH tH u/h<hICJOJQJ^JaJmHnHtH u8h<hIB*CJOJQJ^JaJmHnHphtH u"""""""n#p###$$3$A$G$J$$$$$$$$$ %0%S%V%%d7$8$H$gdID#G#M#R#S#W#_#e#q#w########$$$$3$B$G$L$O$Q$T$m$$$$$$ %%"%0%1%4%6%9%%%%%%ǨǨǨǨǐǨǨǨ/h<hICJOJQJ^JaJmHnHtH u<h<hIB* CJOJQJ^JaJmHnHphsH tH u3h<hICJOJQJ^JaJmHnHsH tH u<h<hIB*CJOJQJ^JaJmHnHphsH tH u.%%%%%d7$8$H$gdI?0P1+:pI/ =!"#$% Dpj 666666666vvvvvvvvv666666>6666666666666666666666666666666666666666666666666hH6666666666666666666666666666666666666666666666666666666666666666662 0@P`p2( 0@P`p 0@P`p 0@P`p 0@P`p 0@P`p 0@P`p8XV~ OJPJQJ_HmH nH sH tH J`J bkNormal dCJ_HaJmH sH tH :A : Police par dfautViV 0Tableau Normal4 l4a 2k 2 0 Aucune liste |@| ICitation intense+&dPO]^56B*\]phOb/b ICitation intense Car!56B*CJ\]aJphOtH PK![Content_Types].xmlj0Eжr(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me/_rels/themeManager.xml.relsM 0wooӺ&݈Э5 6?$Q ,.aic21h:qm@RN;d`o7gK(M&$R(.1r'JЊT8V"AȻHu}|$b{P8g/]QAsم(#L[PK-![Content_Types].xmlPK-!֧6 +_rels/.relsPK-!kytheme/theme/themeManager.xmlPK-!oQtheme/theme/theme1.xmlPK-! ѐ' theme/theme/_rels/themeManager.xml.relsPK]  N ({ D#% "#% 1"%%!$&8@0(  B S  ?LN5 O|IT*^abkD<,@LLLLh@UnknownG*Ax Times New Roman5Symbol3. *Cx Arial?= *Cx Courier New7.{ @CalibriA BCambria Math"tftf )5)5$nr02HP $PD2!xx Lionel de S Lionel de SOh+'0, px   $Lionel de S Normal.dotmLionel de S4Microsoft Office Word@d@^@ )՜.+,0 hp|  5  Titre  !"#$%&')*+,-./123456789:;<=?@ABCDEGHIJKLMPRoot Entry F)5 RData (1Table0WordDocumentANSummaryInformation(>DocumentSummaryInformation8FCompObjy  F'Document Microsoft Office Word 97-2003 MSWordDocWord.Document.89q