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 | CP discovery potential (Test delta = 0, and delta = pi)
|
---|
23 | Xi2 as the function of the true delta and the true theta_13 to test if the
|
---|
24 | experiment may be fit by CP conserving oscillations
|
---|
25 | the true values are used to build the referenced experiments
|
---|
26 | use chi2Delta to marginalized over all parameters except delta
|
---|
27 |
|
---|
28 |
|
---|
29 | 29/6/05 JEC clean the code
|
---|
30 | 7/7/05 JEC introduce the Mass hierachy and Octant degeneracy from Th.Schwetz
|
---|
31 | 8/7/05 JEC introduce data card management
|
---|
32 | */
|
---|
33 |
|
---|
34 |
|
---|
35 | #define DELTA_0 0.0
|
---|
36 | #define DELTA_PI M_PI
|
---|
37 |
|
---|
38 |
|
---|
39 | int WRONG_TH23, WRONG_HIER; //condition on octant/hierarchy
|
---|
40 | float TH12, TH23,DMQ21,DMQ31; //theta12,theta23,Dm^2_21,Dm^2_31
|
---|
41 |
|
---|
42 | int ND; //number of bins to scan delta parameter [0,2pi]
|
---|
43 | int NTH; //number of bins to scan theta13 parameter
|
---|
44 | float LOG10MIN; //minimal Log10(sin^2(2theta13))
|
---|
45 | float LOG10MAX; //minimal Log10(sin^2(2theta13))
|
---|
46 |
|
---|
47 | //---------------------------------------------------------------------
|
---|
48 | bool test_th23(glb_params fit_values) {
|
---|
49 | double fit_th23 = glbGetOscParams(fit_values, GLB_THETA_23);
|
---|
50 |
|
---|
51 | // testing if fit_th23 is at the same side as the true value
|
---|
52 |
|
---|
53 | return (
|
---|
54 | (WRONG_TH23 == 0 &&
|
---|
55 | (TH23 > M_PI/4. && fit_th23 > M_PI/4.) ||
|
---|
56 | (TH23 < M_PI/4. && fit_th23 < M_PI/4.))
|
---|
57 | ||
|
---|
58 | (WRONG_TH23 == 1 &&
|
---|
59 | (TH23 > M_PI/4. && fit_th23 < M_PI/4.) ||
|
---|
60 | (TH23 < M_PI/4. && fit_th23 > M_PI/4.))
|
---|
61 | );
|
---|
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/discoCP.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 = 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 Theta13 but Fixed DELTA=0
|
---|
236 | glbDefineParams(test_values, TH12, th, TH23, DELTA_0, 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 CP conserving values
|
---|
245 | res0 = glbChiDelta(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)) res0 += 1e6;
|
---|
249 |
|
---|
250 | // init test values with current TRUE Theta13 but Fixed DELTA=PI
|
---|
251 | glbDefineParams(test_values, TH12, th, TH23, DELTA_PI, DMQ21, DMQ31);
|
---|
252 | if(WRONG_HIER == 1)
|
---|
253 | glbSetOscParams(test_values, -DMQ31+DMQ21, GLB_DM_ATM);
|
---|
254 |
|
---|
255 | if(WRONG_TH23 == 1)
|
---|
256 | glbSetOscParams(test_values, 0.5*M_PI - TH23, GLB_THETA_23);
|
---|
257 |
|
---|
258 | //check whether the data can be fitted with the CP conserving values
|
---|
259 | resPi = glbChiDelta(test_values,fit_values,GLB_ALL);
|
---|
260 | //Add a big factor in case if fit_values does not respect the Octant &
|
---|
261 | //Mass Hierarchy of the true values
|
---|
262 | if (!test(fit_values)) resPi += 1e6;
|
---|
263 |
|
---|
264 | //store the true_values theta13,delta_CP, the other variables are there
|
---|
265 | //just for compatibility for the Tuple definition
|
---|
266 | fit_theta12 = glbGetOscParams(true_values, GLB_THETA_12);
|
---|
267 | fit_theta13 = glbGetOscParams(true_values, GLB_THETA_13);
|
---|
268 | fit_theta23 = glbGetOscParams(true_values, GLB_THETA_23);
|
---|
269 | fit_deltaCP = glbGetOscParams(true_values, GLB_DELTA_CP);
|
---|
270 | fit_dmSol = glbGetOscParams(true_values, GLB_DM_SOL);
|
---|
271 | fit_dmAtm = glbGetOscParams(true_values, GLB_DM_ATM);
|
---|
272 |
|
---|
273 | //Get the Minimum Chi2 between the 2 hypothesis Delta=0 Delta=PI
|
---|
274 | res = res0;
|
---|
275 | if (resPi < res0) res = resPi;
|
---|
276 |
|
---|
277 | // std::cout << "Theta_12(rad) " << fit_theta12 << " "
|
---|
278 | // << "Theta_13(rad) " << fit_theta13 << " "
|
---|
279 | // << "Theta_23(deg) " << fit_theta23*180./M_PI << " "
|
---|
280 | // << "Delta_CP(deg) " << fit_deltaCP*180./M_PI << " "
|
---|
281 | // << "DM_21 " << fit_dmSol << " "
|
---|
282 | // << "DM_31 " << fit_dmAtm << " "
|
---|
283 | // << "Chi2 (fin) " << res
|
---|
284 | // << std::endl;
|
---|
285 |
|
---|
286 | //Store in the Tuple
|
---|
287 | myTuple->fill(0,fit_theta12);
|
---|
288 | myTuple->fill(1,fit_theta13);
|
---|
289 | myTuple->fill(2,fit_theta23);
|
---|
290 | myTuple->fill(3,fit_deltaCP);
|
---|
291 | myTuple->fill(4,fit_dmSol);
|
---|
292 | myTuple->fill(5,fit_dmAtm);
|
---|
293 | myTuple->fill(6,res);
|
---|
294 | myTuple->addRow();
|
---|
295 |
|
---|
296 |
|
---|
297 | }//Loop on Theta13
|
---|
298 | }//Loop on DeltaCP
|
---|
299 |
|
---|
300 | //free GLoBES arrays
|
---|
301 | glbFreeParams(true_values);
|
---|
302 | glbFreeParams(test_values);
|
---|
303 | glbFreeParams(start_values);
|
---|
304 | glbFreeParams(fit_values);
|
---|
305 |
|
---|
306 |
|
---|
307 | //save Tuple
|
---|
308 | fTree->commit();
|
---|
309 |
|
---|
310 | //Clean Tuple management
|
---|
311 | delete fTree;
|
---|
312 | delete aida;
|
---|
313 |
|
---|
314 | return 0;
|
---|
315 | }
|
---|
316 |
|
---|
317 |
|
---|
318 |
|
---|
319 |
|
---|
320 |
|
---|