source: GLBFrejus/tags/v7r0/src/discoTheta13.cxx @ 700

Last change on this file since 700 was 4, checked in by campagne, 19 years ago

cleanup the repositiry

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