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 | Theta13 discovery potential (Test theta13 = 0) |
---|
23 | Xi2 as the function of the true delta and the true theta_13 to test if the |
---|
24 | experiment may be fit by Theta13 = 0 |
---|
25 | the true values are used to build the referenced experiments |
---|
26 | use chi2Delta to marginalized over all parameters except delta |
---|
27 | |
---|
28 | |
---|
29 | 11/7/05 JEC creation |
---|
30 | */ |
---|
31 | |
---|
32 | |
---|
33 | #define TH13_0 0.0 |
---|
34 | #define TEST_OCTANT false |
---|
35 | |
---|
36 | int WRONG_TH23, WRONG_HIER; //condition on octant/hierarchy |
---|
37 | float TH12, TH23,DMQ21,DMQ31; //theta12,theta23,Dm^2_21,Dm^2_31 |
---|
38 | |
---|
39 | int ND; //number of bins to scan delta parameter [0,2pi] |
---|
40 | int NTH; //number of bins to scan theta13 parameter |
---|
41 | float LOG10MIN; //minimal Log10(sin^2(2theta13)) |
---|
42 | float LOG10MAX; //minimal Log10(sin^2(2theta13)) |
---|
43 | |
---|
44 | //--------------------------------------------------------------------- |
---|
45 | bool test_th23(glb_params fit_values) { |
---|
46 | if(TEST_OCTANT) { |
---|
47 | double fit_th23 = glbGetOscParams(fit_values, GLB_THETA_23); |
---|
48 | |
---|
49 | // testing if fit_th23 is at the same side as the true value |
---|
50 | |
---|
51 | return ( |
---|
52 | (WRONG_TH23 == 0 && |
---|
53 | (TH23 > M_PI/4. && fit_th23 > M_PI/4.) || |
---|
54 | (TH23 < M_PI/4. && fit_th23 < M_PI/4.)) |
---|
55 | || |
---|
56 | (WRONG_TH23 == 1 && |
---|
57 | (TH23 > M_PI/4. && fit_th23 < M_PI/4.) || |
---|
58 | (TH23 < M_PI/4. && fit_th23 > M_PI/4.)) |
---|
59 | ); |
---|
60 | } |
---|
61 | return true; |
---|
62 | }//same_th23 |
---|
63 | |
---|
64 | //--------------------------------------------------------------------- |
---|
65 | bool test_hier(glb_params fit_values) { |
---|
66 | double fit_dmq = glbGetOscParams(fit_values, GLB_DM_ATM); |
---|
67 | |
---|
68 | // testing if fit_dmq has the same sign as the true value |
---|
69 | return ( |
---|
70 | (WRONG_HIER == 0 && fit_dmq * DMQ31 > 0) || |
---|
71 | (WRONG_HIER == 1 && fit_dmq * DMQ31 < 0) |
---|
72 | ); |
---|
73 | }//same_hier |
---|
74 | |
---|
75 | //--------------------------------------------------------------------- |
---|
76 | |
---|
77 | bool test(glb_params fit_values) { |
---|
78 | // testing Octant and Hierarchy |
---|
79 | return test_th23(fit_values) && test_hier(fit_values); |
---|
80 | }//test |
---|
81 | |
---|
82 | //--------------------------------------------------------------------- |
---|
83 | |
---|
84 | /**************************************/ |
---|
85 | /* main */ |
---|
86 | /**************************************/ |
---|
87 | |
---|
88 | int main(int argc, char *argv[]) { |
---|
89 | |
---|
90 | //Process data card file |
---|
91 | std::string ROOTDIR = getenv("GLBFREJUSROOT"); |
---|
92 | std::string DATACARD; |
---|
93 | DATACARD = ROOTDIR + "/run/discoTheta13.data"; |
---|
94 | std::ifstream fileDataCard; |
---|
95 | std::cout << "Open DataCard file : " << DATACARD <<std::endl; |
---|
96 | fileDataCard.open(DATACARD.data()); |
---|
97 | std::string DUMMYSTR; //comment string of the variables |
---|
98 | |
---|
99 | std::string ROOTFILENAME; |
---|
100 | |
---|
101 | |
---|
102 | fileDataCard >> DUMMYSTR >> WRONG_TH23; |
---|
103 | std::cout << DUMMYSTR << WRONG_TH23 << std::endl; |
---|
104 | fileDataCard >> DUMMYSTR >> WRONG_HIER; |
---|
105 | std::cout << DUMMYSTR << WRONG_HIER << std::endl; |
---|
106 | fileDataCard >> DUMMYSTR >> TH12; |
---|
107 | std::cout << DUMMYSTR << TH12 << std::endl; |
---|
108 | fileDataCard >> DUMMYSTR >> TH23; |
---|
109 | std::cout << DUMMYSTR << TH23 << std::endl; |
---|
110 | fileDataCard >> DUMMYSTR >> DMQ21; |
---|
111 | std::cout << DUMMYSTR << DMQ21 << std::endl; |
---|
112 | fileDataCard >> DUMMYSTR >> DMQ31; |
---|
113 | std::cout << DUMMYSTR << DMQ31 << std::endl; |
---|
114 | fileDataCard >> DUMMYSTR >> ROOTFILENAME; |
---|
115 | |
---|
116 | //add to ROOT file name the conditions on the Octant/Hierarchy |
---|
117 | ROOTFILENAME += "-h"; |
---|
118 | char hier[40]; |
---|
119 | sprintf(hier,"%d",WRONG_HIER); |
---|
120 | ROOTFILENAME += hier; |
---|
121 | char octo[40]; |
---|
122 | sprintf(octo,"%d",WRONG_TH23); |
---|
123 | ROOTFILENAME += "-o"; |
---|
124 | ROOTFILENAME += octo; |
---|
125 | ROOTFILENAME += ".root"; |
---|
126 | std::cout << DUMMYSTR <<ROOTFILENAME << std::endl; |
---|
127 | |
---|
128 | fileDataCard >> DUMMYSTR >> ND; |
---|
129 | std::cout << DUMMYSTR << ND << std::endl; |
---|
130 | fileDataCard >> DUMMYSTR >> NTH; |
---|
131 | std::cout << DUMMYSTR << NTH << std::endl; |
---|
132 | fileDataCard >> DUMMYSTR >> LOG10MIN; |
---|
133 | std::cout << DUMMYSTR << LOG10MIN << std::endl; |
---|
134 | fileDataCard >> DUMMYSTR >> LOG10MAX; |
---|
135 | std::cout << DUMMYSTR << LOG10MAX << std::endl; |
---|
136 | |
---|
137 | |
---|
138 | |
---|
139 | |
---|
140 | //init AIDA for Histo/Tuple |
---|
141 | AIDA::IAnalysisFactory* aida = AIDA_createAnalysisFactory(); |
---|
142 | if(!aida) { |
---|
143 | std::cerr << " AIDA not found." << std::endl; |
---|
144 | return 0; |
---|
145 | } |
---|
146 | |
---|
147 | //ROOT tree : |
---|
148 | AIDA::ITreeFactory* treeFactory = aida->createTreeFactory(); |
---|
149 | std::string opts = "export=root"; |
---|
150 | AIDA::ITree* fTree = |
---|
151 | treeFactory->create(ROOTFILENAME,"root",false,true,opts); |
---|
152 | delete treeFactory; |
---|
153 | |
---|
154 | //Booking Tuple |
---|
155 | AIDA::ITupleFactory* tf = aida->createTupleFactory(*fTree); |
---|
156 | |
---|
157 | int NumberOfColumn = 7; |
---|
158 | std::vector<std::string> column(NumberOfColumn); |
---|
159 | const char* c_column[] = {"theta12", "theta13", "theta23", |
---|
160 | "deltaCP", "dm21", "dm31", |
---|
161 | "chi2"}; |
---|
162 | std::vector<std::string> coltype(NumberOfColumn); |
---|
163 | const char* c_coltype[] = {"double","double","double", |
---|
164 | "double","double","double", |
---|
165 | "double"}; |
---|
166 | for (int icol = 0; icol<NumberOfColumn; ++icol) { |
---|
167 | column[icol] = c_column[icol]; |
---|
168 | coltype[icol] = c_coltype[icol]; |
---|
169 | } |
---|
170 | |
---|
171 | AIDA::ITuple* myTuple = |
---|
172 | tf->create("SplGlb","CP violation discovery",column,coltype); |
---|
173 | |
---|
174 | |
---|
175 | //Init Globes |
---|
176 | glbInit(argv[0]); |
---|
177 | glbInitExperiment("../data/SPL.glb", |
---|
178 | &glb_experiment_list[0], |
---|
179 | &glb_num_of_exps); |
---|
180 | |
---|
181 | // input Prior errors: |
---|
182 | // 5% on Solar parameters, the atmospheric parameters are |
---|
183 | // better determined by disappearence channels here 30% to drive the |
---|
184 | // minimizer |
---|
185 | glb_params input_errors = glbAllocParams(); |
---|
186 | glbDefineParams(input_errors, |
---|
187 | TH12*0.05, 0., TH23*0.30, 0., |
---|
188 | DMQ21*0.05, fabs(DMQ31)*0.30); |
---|
189 | glbSetDensityParams(input_errors, 0.05, GLB_ALL); |
---|
190 | glbSetInputErrors(input_errors); |
---|
191 | |
---|
192 | |
---|
193 | |
---|
194 | |
---|
195 | std::cout << "Start to loop...." << std::endl; |
---|
196 | |
---|
197 | |
---|
198 | double res,res0,resPi; |
---|
199 | double fit_theta12, fit_theta13,fit_theta23,fit_deltaCP,fit_dmSol,fit_dmAtm; |
---|
200 | double delta, log10s2, sq2th, th; |
---|
201 | |
---|
202 | |
---|
203 | glb_params true_values = glbAllocParams(); |
---|
204 | glb_params start_values = glbAllocParams(); |
---|
205 | glb_params test_values = glbAllocParams(); |
---|
206 | glb_params fit_values = glbAllocParams(); |
---|
207 | |
---|
208 | for(int k = 0; k < NTH; k++) { |
---|
209 | |
---|
210 | log10s2 = LOG10MIN + (LOG10MAX-LOG10MIN) * double(k) / (NTH-1); |
---|
211 | sq2th = pow(10.,log10s2); |
---|
212 | th = 0.5 * asin(sqrt(sq2th)); |
---|
213 | |
---|
214 | for(int j = 0; j < ND; j++) { |
---|
215 | //scan de 0 a +Pi pour delta_CP |
---|
216 | delta = 2. * M_PI * double(j) / (ND-1); |
---|
217 | |
---|
218 | std::cout << "Consider (k,j) = (" << k << "," << j << ")" << std::endl; |
---|
219 | |
---|
220 | // true values (reference for future Chi2 computations) |
---|
221 | glbDefineParams(true_values, TH12, th, TH23, delta, DMQ21, DMQ31); |
---|
222 | |
---|
223 | glbSetOscillationParameters(true_values); |
---|
224 | glbSetRates(); |
---|
225 | |
---|
226 | // set Starting Values |
---|
227 | glbDefineParams(start_values, TH12, th, TH23, delta, DMQ21, DMQ31); |
---|
228 | if(WRONG_HIER == 1) |
---|
229 | glbSetOscParams(start_values, -DMQ31+DMQ21, GLB_DM_ATM); |
---|
230 | if(WRONG_TH23 == 1) |
---|
231 | glbSetOscParams(start_values, 0.5*M_PI - TH23, GLB_THETA_23); |
---|
232 | |
---|
233 | glbSetStartingValues(start_values); |
---|
234 | |
---|
235 | // init test values with current TRUE delta but Fixed THETA13=0 |
---|
236 | glbDefineParams(test_values, TH12, TH13_0, TH23, delta, DMQ21, DMQ31); |
---|
237 | if(WRONG_HIER == 1) |
---|
238 | glbSetOscParams(test_values, -DMQ31+DMQ21, GLB_DM_ATM); |
---|
239 | |
---|
240 | if(WRONG_TH23 == 1) |
---|
241 | glbSetOscParams(test_values, 0.5*M_PI - TH23, GLB_THETA_23); |
---|
242 | |
---|
243 | |
---|
244 | //check whether the data can be fitted with the THETA13=0 |
---|
245 | res = glbChiTheta(test_values,fit_values,GLB_ALL); |
---|
246 | //Add a big factor in case if fit_values does not respect the Octant & |
---|
247 | //Mass Hierarchy of the true values |
---|
248 | if (!test(fit_values)) res += 1e6; |
---|
249 | |
---|
250 | |
---|
251 | //store the true_values theta13,delta_CP, the other variables are there |
---|
252 | //just for compatibility for the Tuple definition |
---|
253 | fit_theta12 = glbGetOscParams(true_values, GLB_THETA_12); |
---|
254 | fit_theta13 = glbGetOscParams(true_values, GLB_THETA_13); |
---|
255 | fit_theta23 = glbGetOscParams(true_values, GLB_THETA_23); |
---|
256 | fit_deltaCP = glbGetOscParams(true_values, GLB_DELTA_CP); |
---|
257 | fit_dmSol = glbGetOscParams(true_values, GLB_DM_SOL); |
---|
258 | fit_dmAtm = glbGetOscParams(true_values, GLB_DM_ATM); |
---|
259 | |
---|
260 | |
---|
261 | // std::cout << "Theta_12(rad) " << fit_theta12 << " " |
---|
262 | // << "Theta_13(rad) " << fit_theta13 << " " |
---|
263 | // << "Theta_23(deg) " << fit_theta23*180./M_PI << " " |
---|
264 | // << "Delta_CP(deg) " << fit_deltaCP*180./M_PI << " " |
---|
265 | // << "DM_21 " << fit_dmSol << " " |
---|
266 | // << "DM_31 " << fit_dmAtm << " " |
---|
267 | // << "Chi2 (fin) " << res |
---|
268 | // << std::endl; |
---|
269 | |
---|
270 | //Store in the Tuple |
---|
271 | myTuple->fill(0,fit_theta12); |
---|
272 | myTuple->fill(1,fit_theta13); |
---|
273 | myTuple->fill(2,fit_theta23); |
---|
274 | myTuple->fill(3,fit_deltaCP); |
---|
275 | myTuple->fill(4,fit_dmSol); |
---|
276 | myTuple->fill(5,fit_dmAtm); |
---|
277 | myTuple->fill(6,res); |
---|
278 | myTuple->addRow(); |
---|
279 | |
---|
280 | |
---|
281 | }//Loop on Theta13 |
---|
282 | }//Loop on DeltaCP |
---|
283 | |
---|
284 | //free GLoBES arrays |
---|
285 | glbFreeParams(true_values); |
---|
286 | glbFreeParams(test_values); |
---|
287 | glbFreeParams(start_values); |
---|
288 | glbFreeParams(fit_values); |
---|
289 | |
---|
290 | |
---|
291 | //save Tuple |
---|
292 | fTree->commit(); |
---|
293 | |
---|
294 | //Clean Tuple management |
---|
295 | delete fTree; |
---|
296 | delete aida; |
---|
297 | |
---|
298 | return 0; |
---|
299 | } |
---|
300 | |
---|
301 | |
---|
302 | |
---|
303 | |
---|
304 | |
---|