source: ZHANGProjects/ICOSIM/CPP/trunk/source/debug.cc @ 2

Last change on this file since 2 was 2, checked in by zhangj, 10 years ago

Initial import

File size: 4.6 KB
Line 
1#include <iostream>
2#include <vector>
3#include <string>
4#include "Collimator.h"
5#include "MagneticCollimator.h"
6using namespace std;
7
8
9/*
10##############################################################################################################
11
12can be used to debug some parts of the code (e.g. using integer values instead of doubles in some function)
13
14The interest of this file is that it can be modified to see some special outputs of function without the
15need to modify the real function integrated in the program and using the fact that this file is already
16built in the makefile.
17
18We have here three examples of tests of parts of the code with specifics parameters values which were done
19using this file.
20
21To run it, after the 'make' command, just type
22
23./debug
24
25##############################################################################################################
26*/
27
28
29
30
31double Bcalc(double x, double y, double z, double w)
32{
33
34    double percent, n;
35
36    int nn;
37
38    percent = 0.1;
39    double a(log(percent));
40    double b(log((y - z) / y));
41    n = a / b;
42    nn = (int)floor(n);
43    if ((nn % 2) == 1) {
44        n = floor(n);
45    } else {
46        n = ceil(n);
47    }
48
49    return (w * pow((x / y), n));
50}
51
52int main()
53{
54
55    //============================ DEBUGGING I: BeBloMuSca =======================================
56
57
58    double ALFX(1.715332938);
59    double ALFY(-2.070815068);
60    double APER_1(0.04);
61    double APER_2(0.04);
62    double APER_3(0.04);
63    double APER_4(0.04);
64    string APERTYPE;
65    APERTYPE = "RECTELLIPSE";
66    double BETX(130.4920061);
67    double BETY(145.9347602);
68    double DPX(-0.032633675);
69    double DPY(-0.005893863);
70    double DX(2.182119904);
71    double DY(-0.355863926);
72    string KEYWORD;
73    KEYWORD = "RCOLLIMATOR";
74    double L(0.6);
75    double MUX(16.31640483);
76    double MUY(14.85010143);
77    string NAME;
78    NAME = "TCP.6L3.B1";
79    double PTC(0);
80    double PXC(4.43e-13);
81    double PYC(-1.24e-12);
82    double S(6487.9713);
83    double TC(-1.64e-06);
84    double XC(-7.94e-11);
85    double YC(-7e-11);
86    double K0L(0);
87    double K0SL(0);
88    double K1L(0);
89    double K1SL(0);
90    double K2L(0);
91    double K2SL(0);
92    string PARENT;
93    PARENT =  "TCP";
94    string meth;
95    meth =  "standard";
96    double hgap( 0.0038544149873210331);
97    double hgap2( 0.0038544149873210331);
98    double collang(-10);
99    double pdepth(0);
100    double pdepth2(0);
101    double tcang(0);
102    double nsig(15);
103    double Bmax(2);
104    double thicknessMagneticField(0.0001);
105    double energyPerIon(574000);
106    double mass(193.6872);
107    double deltaGap(0.0000015);
108
109
110    MagneticCollimator collim(ALFX, ALFY, APER_1, APER_2, APER_3, APER_4, APERTYPE, BETX, BETY, DPX, DPY, DX, DY, KEYWORD, L, MUX, MUY, NAME, PTC, PXC, PYC, S, TC, XC, YC, K0L, K0SL, K1L, K1SL, K2L, K2SL, PARENT, meth, hgap, hgap2, collang, pdepth, pdepth2, tcang, nsig, Bmax, thicknessMagneticField, energyPerIon, mass);
111
112    collim.deltaGap = deltaGap;
113    collim.material = "carbon";
114    collim.crossSectionPath =  "crossSectionInfos/" + collim.material + '/';
115
116    double wx(0);
117    double wy(0);
118    double dpopdx;
119    double betgam(2963.5410461902575);
120    string filename;
121    filename = "crossSectionInfos/carbon/materialinfo.csv";
122    double rho(1700);
123    double s(0);
124    double atarget(12.011);
125    Particle p1(-9.62058e-07, -0.000153021, -4.97476e-05, -4.80766e-05, -8.21051e-05, 0, 208, 82,  -0.00012159388136310807);
126    Particle p2(-2.29177e-05, -0.000135618, -6.02201e-05, 3.8913e-05, -6.28236e-05, 0, 208, 82,  -6.569201361245118e-05);
127
128    collim.BeBloMuSca(wx, wy, dpopdx, betgam, filename, rho, collim.L - s, atarget, p1);
129
130    cout << wx << endl;
131    cout << wy << endl;
132    cout << dpopdx << endl;
133
134
135    //===================================== DEBUGGING II: MagneticCollimator::collipass  ====================================
136
137    double dpopeff(-8.21051e-05);
138    double scaleorbit(1);
139    double dx(0.082457875);
140    double dpx(-0.004199663);
141    double dy(0.648364612);
142    double dpy(-0.000636128);
143    double delta_s(3214.988584 - 144.7);
144    double Apr(208);
145    double Zpr(82);
146
147
148    collim.collipass(p1, dpopeff, scaleorbit, -1.2012125562536251, -164.13050747492346, -0.0043269348629002072, -1.4237130688947441, 0.66187442286836129, -226.98360345972108, 0.0036126697814305862, 0.2719295211935373, dx, dpx, dy, dpy, delta_s, Apr, Zpr, betgam);
149
150
151    //====================================== DEBUGGING III: Bcalc ===================================================
152
153    cout << Bcalc(4, 3, 1, 2) << endl;
154    double(pdepthEnd);
155
156    pdepthEnd = abs(1 + (5 - 2) * 4) - 6;
157
158    cout << pdepthEnd << endl;
159
160
161    return 0;
162}
Note: See TracBrowser for help on using the repository browser.