source: GLBFrejus/HEAD/src/degener.cxx@ 587

Last change on this file since 587 was 150, checked in by campagne, 19 years ago

add new appli

  • Property svn:executable set to *
File size: 8.3 KB
Line 
1//std
2#include <stdio.h>
3#include <stdlib.h>
4#include <math.h>
5#include <string.h>
6#include <cmath>
7#include <fstream>
8#include <iostream>
9
10//Globes
11#include <globes/globes.h>
12
13// AIDA :
14#include <AIDA/IAnalysisFactory.h>
15#include <AIDA/ITreeFactory.h>
16#include <AIDA/IHistogramFactory.h>
17#include <AIDA/ITree.h>
18#include <AIDA/ITupleFactory.h>
19#include <AIDA/ITuple.h>
20
21
22
23#define TH12 ( asin(sqrt(0.3)) )
24#define TH23 ( asin(sqrt(0.6)) )
25#define TH13 ( 0.5 * asin(sqrt(0.03)) )
26
27#define DELTA (-0.85 * M_PI )
28
29#define DMQ21 8.1e-5
30#define DMQ31 2.2e-3
31
32
33int WRONG_TH23, WRONG_HIER;
34
35
36bool test_th23(glb_params fit_values) {
37 double fit_th23 = glbGetOscParams(fit_values, GLB_THETA_23);
38
39 // testing if fit_th23 is at the same side as the true value
40
41 return (
42 (WRONG_TH23 == 0 &&
43 (TH23 > M_PI/4. && fit_th23 > M_PI/4.) ||
44 (TH23 < M_PI/4. && fit_th23 < M_PI/4.))
45 ||
46 (WRONG_TH23 == 1 &&
47 (TH23 > M_PI/4. && fit_th23 < M_PI/4.) ||
48 (TH23 < M_PI/4. && fit_th23 > M_PI/4.))
49 );
50}//same_th23
51
52//---------------------------------------------------------------------
53bool test_hier(glb_params fit_values) {
54 double fit_dmq = glbGetOscParams(fit_values, GLB_DM_ATM);
55
56 // testing if fit_dmq has the same sign as the true value
57 return (
58 (WRONG_HIER == 0 && fit_dmq * DMQ31 > 0) ||
59 (WRONG_HIER == 1 && fit_dmq * DMQ31 < 0)
60 );
61}//same_hier
62
63//---------------------------------------------------------------------
64
65bool test(glb_params fit_values) {
66 return test_th23(fit_values) && test_hier(fit_values);
67}
68
69
70/**************************************/
71/* main */
72/**************************************/
73
74int main(int argc, char *argv[])
75{
76 if(argc != 3){
77 std::cerr << "usage:" << argv[0] << "WRONG_TH23 WRONG_HIER" << std::endl;
78 std::cerr<< "WRONG_* = '1' for wrong * and '0' for right *" << std::endl;
79 return 0;
80 }
81
82 if(sscanf(argv[1], "%d", &WRONG_TH23) != 1 ||
83 (WRONG_TH23 != 1 && WRONG_TH23 != 0) ||
84 sscanf(argv[2], "%d", &WRONG_HIER) != 1 ||
85 (WRONG_HIER != 1 && WRONG_HIER != 0)){
86 std::cerr<< "cannot read parameters" << std::endl;
87 return 0;
88 }
89
90 //init AIDA for Histo/Tuple
91 AIDA::IAnalysisFactory* aida = AIDA_createAnalysisFactory();
92 if(!aida) {
93 std::cerr << " AIDA not found." << std::endl;
94 return 0;
95 }
96
97 //ROOT tree :
98 AIDA::ITreeFactory* treeFactory = aida->createTreeFactory();
99 std::string opts = "export=root";
100 AIDA::ITree* fTree =
101 treeFactory->create("degener.root","root",false,true,opts);
102 delete treeFactory;
103
104 //Booking Tuple
105 AIDA::ITupleFactory* tf = aida->createTupleFactory(*fTree);
106
107 int NumberOfColumn = 7;
108 std::vector<std::string> column(NumberOfColumn);
109 const char* c_column[] = {"theta12", "theta13", "theta23",
110 "deltaCP", "dm21", "dm31",
111 "chi2"};
112 std::vector<std::string> coltype(NumberOfColumn);
113 const char* c_coltype[] = {"double","double","double",
114 "double","double","double",
115 "double"};
116 for (int icol = 0; icol<NumberOfColumn; ++icol) {
117 column[icol] = c_column[icol];
118 coltype[icol] = c_coltype[icol];
119 }
120
121 AIDA::ITuple* myTuple =
122 tf->create("SplGlb","Theta23 [0,90deg]:Dm31>0 scan",column,coltype);
123
124
125 //Init Globes
126 glbInit(argv[0]);
127 glbInitExperiment("../data/SPL.glb",
128 &glb_experiment_list[0],
129 &glb_num_of_exps);
130
131 // true values (reference for future Chi2 computations)
132 glb_params true_values = glbAllocParams();
133 glbDefineParams(true_values, TH12, TH13, TH23, DELTA, DMQ21, DMQ31);
134 std::cout << "The Initial True_values" << std::endl;
135 glbPrintParams(stdout,true_values);
136
137 glbSetOscillationParameters(true_values);
138 glbSetRates();
139
140 // set Starting Values (1st trial)
141 glb_params start_values = glbAllocParams();
142 glbDefineParams(start_values, TH12, TH13, TH23, DELTA, DMQ21, DMQ31);
143
144 if(WRONG_HIER == 1)
145 glbSetOscParams(start_values, -DMQ31+DMQ21, GLB_DM_ATM);
146
147 if(WRONG_TH23 == 1)
148 glbSetOscParams(start_values, 0.5*M_PI - TH23, GLB_THETA_23);
149
150 glbSetStartingValues(start_values);
151 std::cout << "The Starting values 1st trail" << std::endl;
152 glbPrintParams(stdout,start_values);
153 glbFreeParams(start_values);
154
155
156 // init test values
157 glb_params test_values = glbAllocParams();
158 glbDefineParams(test_values, TH12, TH13, TH23, DELTA, DMQ21, DMQ31);
159
160 if(WRONG_HIER == 1)
161 glbSetOscParams(test_values, -DMQ31+DMQ21, GLB_DM_ATM);
162
163 if(WRONG_TH23 == 1)
164 glbSetOscParams(test_values, 0.5*M_PI - TH23, GLB_THETA_23);
165 std::cout << "The Test_values" << std::endl;
166 glbPrintParams(stdout,test_values);
167
168 glb_params fit_values = glbAllocParams(); //final minimization
169
170 // Set theta23 error very low to constraint the minimizer in the right octant
171 // input errors
172 glb_params input_errors = glbAllocParams();
173 glbDefineParams(input_errors,
174 TH12*0.1, 0., TH23*0.05, 0.,
175 DMQ21*0.05, fabs(DMQ31)*0.05);
176 glbSetDensityParams(input_errors, 0.05, GLB_ALL);
177 glbSetInputErrors(input_errors);
178
179 //double err_fit_theta12 = glbGetOscParams(input_errors, GLB_THETA_12);
180 //double err_fit_theta13 = glbGetOscParams(input_errors, GLB_THETA_13);
181 double err_fit_theta23 = glbGetOscParams(input_errors, GLB_THETA_23);
182 //double err_fit_deltaCP = glbGetOscParams(input_errors, GLB_DELTA_CP);
183 //double err_fit_dmSol = glbGetOscParams(input_errors, GLB_DM_SOL);
184 double err_fit_dmAtm = glbGetOscParams(input_errors, GLB_DM_ATM);
185 std::cout << "Theta23 error " << err_fit_theta23/TH23
186 << " and Dm31 error " << err_fit_dmAtm/fabs(DMQ31)
187 << std::endl;
188
189 static const int NDM31 =26;
190 static const int NTH23 =91;
191 static const double DM31MIN = 1e-3;
192 static const double DM31MAX = 5e-3;
193 static const double THETA23MIN = 0.0; //degree
194 static const double THETA23MAX = 90.0;
195
196 std::cout << "Start to loop...." << std::endl;
197
198 double res;
199 double fit_theta12, fit_theta13,fit_theta23,fit_deltaCP,fit_dmSol,fit_dmAtm;
200 double dm31cur, theta23cur;
201
202
203 //set a DELTA_CP test value
204 glbSetOscParams(test_values,-0.12*M_PI,GLB_DELTA_CP);
205 glbSetOscParams(test_values,0.5*asin(sqrt(0.025)),GLB_THETA_13);
206
207
208 //Scan in theta23 and Dm31 to find minimum Chi2
209 for(int j = 0; j < NDM31; j++)
210 {
211 dm31cur = DM31MIN
212 + (DM31MAX-DM31MIN) * double(j)/double(NDM31-1);
213
214 glbSetOscParams(test_values, dm31cur, GLB_DM_ATM);
215
216 for(int k = 0; k < NTH23; k++)
217 {
218 theta23cur = THETA23MIN
219 + (THETA23MAX - THETA23MIN) * double(k)/double(NTH23-1);
220
221 std::cout << "delta j:" << j << " theta13 k:" << k << std::endl;
222
223 glbSetOscParams(test_values,theta23cur*M_PI/180.0, GLB_THETA_23);
224
225
226 //Find Chi2 associated
227 res = glbChiSys(test_values,0,GLB_ALL);
228
229
230 fit_theta12 = glbGetOscParams(test_values, GLB_THETA_12);
231 fit_theta13 = glbGetOscParams(test_values, GLB_THETA_13);
232 fit_theta23 = glbGetOscParams(test_values, GLB_THETA_23);
233 fit_deltaCP = glbGetOscParams(test_values, GLB_DELTA_CP);
234 fit_dmSol = glbGetOscParams(test_values, GLB_DM_SOL);
235 fit_dmAtm = glbGetOscParams(test_values, GLB_DM_ATM);
236
237// if (!test(fit_values)) {
238// std::cout << "Problem at (j,k): " << j << " , " << k << std::endl;
239// std::cout << "Theta_12 " << fit_theta12 << " "
240// << "Theta_13 " << fit_theta13 << " "
241// << "Theta_23 " << fit_theta23*180./M_PI << " "
242// << "Delta_CP " << fit_deltaCP << " "
243// << "DM_21 " << fit_dmSol << " "
244// << "DM_31 " << fit_dmAtm << " "
245// << "Chi2 (mini) " << res
246// << std::endl;
247// continue;
248// }
249
250
251// std::cout << "Theta_12 " << fit_theta12 << " "
252// << "Theta_13 " << fit_theta13 << " "
253// << "Theta_23 " << fit_theta23*180./M_PI << " "
254// << "Delta_CP " << fit_deltaCP << " "
255// << "DM_21 " << fit_dmSol << " "
256// << "DM_31 " << fit_dmAtm << " "
257// << "Chi2 (mini) " << res
258// << std::endl;
259
260
261 myTuple->fill(0,fit_theta12);
262 myTuple->fill(1,fit_theta13);
263 myTuple->fill(2,fit_theta23);
264 myTuple->fill(3,fit_deltaCP);
265 myTuple->fill(4,fit_dmSol);
266 myTuple->fill(5,fit_dmAtm);
267 myTuple->fill(6,res);
268 myTuple->addRow();
269
270
271
272 }//Loop on Theta13
273 }//Loop on DeltaCP
274
275 glbFreeParams(true_values);
276 glbFreeParams(test_values);
277 glbFreeParams(fit_values);
278
279
280 //save Tuple
281 fTree->commit();
282 delete fTree;
283
284 delete aida;
285 return 0;
286}
287
288
289
290
291
Note: See TracBrowser for help on using the repository browser.