Angular analysis of B+->K*+(K+pi0)mumu
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

294 lines
11 KiB

  1. //Renata Kopecna
  2. #include "ReferencePlots.hh"
  3. #include <vector>
  4. #include "ScriptHelpers.hh"
  5. #include <bu2kstarmumu_parameters.hh>
  6. #include <paths.hh>
  7. #include <helpers.hh>
  8. #include <TColor.h>
  9. #include <TH2D.h>
  10. #include <TCanvas.h>
  11. #include <TROOT.h>
  12. #include <TFile.h>
  13. #include <TTree.h>
  14. #include <spdlog.h>
  15. const int oneSigma_RGB[3] = {34,136,51};
  16. const int twoSigma_RGB[3] = {170,170,0};
  17. const int threeSigma_RGB[3] = {238,22,136};
  18. const int moreSigma_RGB[3] = {204,51,17};
  19. //TODO: make it into a texfile instead of a cout!
  20. const std::vector<valErr> Davids = {
  21. valErr(+0.572,0.005),//valErr(+0.321,0.004),
  22. valErr(-0.002,0.007),
  23. valErr(-0.246,0.008),
  24. valErr(-0.003,0.008),
  25. valErr(-0.002,0.005),//valErr(-0.003,0.006),
  26. valErr(-0.001,0.008),
  27. valErr(-0.063,0.008),
  28. valErr(-0.084,0.007)
  29. };
  30. const std::vector<valErr> Belles = {
  31. valErr(+0.604,0.015),//valErr(+0.297,0.011),
  32. valErr(-0.018,0.017),
  33. valErr(-0.255,0.010),
  34. valErr(0.0,0.0),
  35. valErr(0.0,0.0),
  36. valErr(0.0,0.0),
  37. valErr(-0.037,0.018),
  38. valErr(-0.041,0.016)
  39. };
  40. const std::vector<valErr> BaBars = {
  41. valErr(+0.556,0.009),//valErr(+0.333,0.007),
  42. valErr(+0.011,0.011),
  43. valErr(-0.237,0.007),
  44. valErr(0.0,0.0),
  45. valErr(0.0,0.0),
  46. valErr(0.0,0.0),
  47. valErr(-0.058,0.015),
  48. valErr(-0.095,0.014)
  49. };
  50. const std::vector<valErr> B0s = {
  51. valErr(+0.572,0.008),//valErr(+0.321,0.006),
  52. valErr(-0.013,0.010),
  53. valErr(-0.250,0.006),
  54. valErr(0.0,0.0),
  55. valErr(0.0,0.0),
  56. valErr(0.0,0.0),
  57. valErr(-0.048,0.007),
  58. valErr(-0.084,0.006)
  59. };
  60. std::vector<double>getSigma(std::vector<valErr> vec_a, std::vector<valErr> vec_b){
  61. if (vec_a.size() != vec_b.size()){
  62. spdlog::error("Two valErr vectors have different lenghts! Abort.");
  63. assert(0);
  64. }
  65. std::vector<double>sigs;
  66. for_indexed(auto a: vec_a){
  67. sigs.push_back(sigmaAway(a,vec_b[i]));
  68. }
  69. return sigs;
  70. }
  71. std::vector<const int*>getSigmaColor(std::vector<double>vec_sigma){
  72. std::vector<const int*> tmp;
  73. for(auto sigma: vec_sigma){
  74. if (fabs(sigma) < 1.0) tmp.push_back(oneSigma_RGB);
  75. else if (fabs(sigma) < 2.0) tmp.push_back(twoSigma_RGB);
  76. else if (fabs(sigma) < 3.0) tmp.push_back(threeSigma_RGB);
  77. else tmp.push_back(moreSigma_RGB);
  78. }
  79. return tmp;
  80. }
  81. std::string getSigmaColor_str(double sigma){
  82. if (fabs(sigma) < 1.0) return "\\cellcolor{oneSigma}";
  83. else if (fabs(sigma) < 2.0) return "\\cellcolor{twoSigmas}";
  84. else if (fabs(sigma) < 3.0) return"\\cellcolor{threeSigmas}";
  85. else return "\\cellcolor{moreSigmas}";
  86. }
  87. std::vector<std::string>getSigmaColor_strVec(std::vector<double>vec_sigma){
  88. std::vector<std::string> tmp;
  89. for(auto sigma: vec_sigma) tmp.push_back(getSigmaColor_str(sigma));
  90. return tmp;
  91. }
  92. double getCorrectedError(std::string name, double err, int jobID){ //For now, no bins, cause it is used anyhow only for reference //TODO
  93. basic_params tmpParams; //This is dumb, but no time
  94. tmpParams.jobID = jobID;
  95. std::string fileName = get_ToyPullPlot_folder(tmpParams)+"pullResults.root";
  96. spdlog::info("Opening " + fileName);
  97. TFile* file = new TFile(fileName.c_str(), "READ");
  98. if (!file->GetListOfKeys()->Contains(name.c_str())){
  99. spdlog::critical("Wrong tree name " + name + "! Abort.");
  100. assert(0);
  101. }
  102. //Get the tree and set the branches to active
  103. TTree* tree = (TTree*)file->Get(name.c_str());
  104. tree->SetBranchStatus("*",1); //Activate all branches
  105. double width = DEFAULT_TREE_ERR;
  106. double mean = DEFAULT_TREE_VAL;
  107. tree->SetBranchAddress("width", &width);
  108. tree->SetBranchAddress("mean", &mean);
  109. tree->GetEntry(0);
  110. file->Close();
  111. //get_param_valueError_from_rootfile()
  112. return err*width;
  113. }
  114. int plotComparisonFull(){
  115. spdlog::debug("Starting with printing the values for RefChan measurement in a nice table.");
  116. double fractionOfStats = 1.0;
  117. basic_params params_Fit= basic_params();
  118. params_Fit.Run = 12;
  119. params_Fit.nBins = 1;
  120. params_Fit.reference =true;
  121. std::string fitFile = final_result_name(true, false, params_Fit,
  122. true, 1, params_Fit.Run,
  123. false, fractionOfStats,
  124. false, -1);
  125. std::vector<valErr> myValues;
  126. spdlog::debug("Filling my values into a vector");
  127. for (auto obs: ANG_OBS){
  128. //The easiest rounding in c++
  129. double err = get_param_error_from_rootfile(fitFile, obs, 1,0);
  130. //The easiest rounding in c++
  131. err = round(getCorrectedError(obs,err,649)*1000.0)/1000.0; //TODO
  132. double val = round(get_param_value_from_rootfile(fitFile, obs, 1,0)*1000.0)/1000.0;
  133. myValues.push_back(valErr(val,err));
  134. }
  135. std::vector<std::string>col_Davids = getSigmaColor_strVec(getSigma(myValues,Davids));
  136. std::vector<std::string>col_Belles = getSigmaColor_strVec(getSigma(myValues,Belles));
  137. std::vector<std::string>col_BaBars = getSigmaColor_strVec(getSigma(myValues,BaBars));
  138. std::vector<std::string>col_B0s = getSigmaColor_strVec( getSigma(myValues,B0s));
  139. std::cout << "\\begin{table}[]" << std::endl;
  140. std::cout << "\\begin{tabular}{llllll}" << std::endl;
  141. std::cout << " & this fit & \\lhcb \\Bu & Belle (\\Bu) & BaBar (\\Bu + \\Bd) & \\lhcb \\Bd \\\\\\hline" << std::endl;
  142. for_indexed(auto myVal: myValues){
  143. std::cout << std::setprecision(3) << "$" << ANG_OBS_TLaTeX[i] << "$";
  144. std::cout << " & " << myVal.val << "$\\pm$" <<myVal.err;
  145. std::cout << " & " << col_Davids[i] << " " << Davids[i].val << "$\\pm$" <<Davids[i].err;
  146. std::cout << " & " << col_Belles[i] << " " << Belles[i].val << "$\\pm$" <<Belles[i].err;
  147. std::cout << " & " << col_BaBars[i] << " " << BaBars[i].val << "$\\pm$" <<BaBars[i].err;
  148. std::cout << " & " << col_B0s[i] << " " << B0s[i].val << "$\\pm$" <<B0s[i].err;
  149. std::cout << "\\\\" << std::endl;
  150. }
  151. std::cout << " \\end{tabular}" << std::endl;
  152. std::cout << " \\end{table}" << std::endl;
  153. return 0;
  154. }
  155. int foldingTable(){
  156. spdlog::debug("Starting with printing the values for different foldings RefChan measurement in a nice table.");
  157. double fractionOfStats = 1.0;
  158. basic_params params_Fit= basic_params();
  159. params_Fit.Run = 12;
  160. params_Fit.nBins = 1;
  161. params_Fit.reference =true;
  162. std::cout << "\\begin{table}[]" << std::endl;
  163. std::cout << "\\begin{tabular}{l|"; //First cell is for the obs name
  164. for (int f = -1; f<MAX_FOLDING; f++) std::cout << "l";
  165. std::cout << "}" << std::endl;
  166. std::cout << std::setprecision(1) << " & No folding" ;
  167. for (int f = 0; f<MAX_FOLDING; f++) std::cout << " & Folding " << f;
  168. std::cout <<"\\\\\\hline" << std::endl;
  169. for_indexed (auto obs: ANG_OBS){ //TODO: if it would be for me, this would be a struct of name and latexname
  170. std::cout << std::setprecision(3) << "$" << ANG_OBS_TLaTeX[i] << "$";
  171. params_Fit.folding = -1; //Needed extra as it has to be saved to myVec to get the sigmas away
  172. std::string fitFile = final_result_name(true, false, params_Fit,
  173. true, 1, params_Fit.Run,
  174. false, fractionOfStats,
  175. false, -1);
  176. //The easiest rounding in c++
  177. double err = get_param_error_from_rootfile(fitFile, obs, 1,0);
  178. //The easiest rounding in c++
  179. err = round(getCorrectedError(obs,err,649)*1000.0)/1000.0; //TODO
  180. double val = round(get_param_value_from_rootfile(fitFile, obs, 1,0)*1000.0)/1000.0;
  181. valErr full(err,val);
  182. std::cout << " & " << val << "$\\pm$" << err;
  183. for (int f = 0; f<MAX_FOLDING; f++){
  184. if (plotObsv(f,obs)){
  185. params_Fit.folding = f;
  186. int jobID = 626+params_Fit.folding;
  187. if (params_Fit.folding==4) jobID = 650;
  188. std::string fitFile = final_result_name(true, false, params_Fit,
  189. true, 1, params_Fit.Run,
  190. false, fractionOfStats,
  191. false, -1);
  192. //The easiest rounding in c++
  193. double err = get_param_error_from_rootfile(fitFile, obs, 1,0);
  194. //The easiest rounding in c++
  195. err = round(getCorrectedError(obs,err,jobID)*1000.0)/1000.0;
  196. double val = round(get_param_value_from_rootfile(fitFile, obs, 1,0)*1000.0)/1000.0;
  197. std::cout << " & " << getSigmaColor_str(sigmaAway(full,valErr(err,val))) << val << "$\\pm$" << err;
  198. }
  199. else std::cout << " & ";
  200. }
  201. std::cout << "\\\\" << std::endl;
  202. }
  203. std::cout << " \\end{tabular}" << std::endl;
  204. std::cout << " \\end{table}" << std::endl;
  205. return 0;
  206. }
  207. int plotComparisonSigmas(){
  208. spdlog::debug("Starting with printing the values for RefChan measurement in a nice table.");
  209. double fractionOfStats = 1.0;
  210. basic_params params_Fit= basic_params();
  211. params_Fit.Run = 12;
  212. params_Fit.nBins = 1;
  213. params_Fit.reference =true;
  214. std::string fitFile = final_result_name(true, false, params_Fit,
  215. true, 1, params_Fit.Run,
  216. false, fractionOfStats,
  217. false, -1);
  218. std::vector<valErr> myValues;
  219. spdlog::debug("Filling my values into a vector");
  220. for (auto obs: ANG_OBS){
  221. double err = get_param_error_from_rootfile(fitFile, obs, 1,0);
  222. //The easiest rounding in c++
  223. err = round(getCorrectedError(obs,err,649)*1000.0)/1000.0; //TODO
  224. double val = round(get_param_value_from_rootfile(fitFile, obs, 1,0)*1000.0)/1000.0;
  225. myValues.push_back(valErr(val,err));
  226. }
  227. std::vector<double>sig_Davids = getSigma(myValues,Davids);
  228. std::vector<double>sig_Belles = getSigma(myValues,Belles);
  229. std::vector<double>sig_BaBars = getSigma(myValues,BaBars);
  230. std::vector<double>sig_B0s = getSigma(myValues,B0s);
  231. std::cout << "\\begin{table}[]" << std::endl;
  232. std::cout << "\\begin{tabular}{l|llll}" << std::endl;
  233. std::cout << " & \\lhcb \\Bu & Belle (\\Bu) & BaBar (\\Bu + \\Bd) & \\lhcb \\Bd \\\\\\hline" << std::endl;
  234. //for_indexed(auto myVal: myValues){ //TODO remove: yields warning in compilation due to unused 'myVals'
  235. for(UInt_t i = 0; i < sig_Davids.size(); i++){
  236. std::cout << std::setprecision(2) << "$" << ANG_OBS_TLaTeX[i] << "$";
  237. std::cout << " & " << sig_Davids[i];
  238. std::cout << " & " << sig_Belles[i];
  239. std::cout << " & " << sig_BaBars[i];
  240. std::cout << " & " << sig_B0s[i];
  241. std::cout << "\\\\" << std::endl;
  242. }
  243. std::cout << " \\end{tabular}" << std::endl;
  244. std::cout << " \\end{table}" << std::endl;
  245. return 0;
  246. }