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.

836 lines
37 KiB

  1. #include "../GlobalFunctions.hh"
  2. //////////////////////////////////////////////////////////////////////
  3. /// OptimizePreSelection()
  4. /// loops over all .root-files created by Preselection() defined in BDTSelection.cc.
  5. /// More kinematic, PID and some more cuts are applied and saved in a new file.
  6. ///
  7. THStack *stack(vector<TH1F*> histos){
  8. THStack *tmp = new THStack("IncMC","IncMC");
  9. for(unsigned int h = 0; h < histos.size(); h++){
  10. histos.at(h)->SetFillColor(2+h);
  11. tmp->Add(histos.at(h));
  12. }
  13. return tmp;
  14. }
  15. int plotIncSample(std::string year = "2012", std::string magnet = "down") {
  16. bool ReferenceChannel = true;
  17. TFile* input = 0;
  18. TFile* histos = 0;
  19. TTree *tree;
  20. // Kst2Kpluspi0Resolved case
  21. if(Kst2Kpluspi0Resolved){
  22. input = TFile::Open(Form("%s/data/MC/BtoXJpsi/%s%s/%s%s_pi0Resolved%s.root",path_to_output_KplusPizero.c_str(), year.c_str(),magnet.c_str(),year.c_str(),magnet.c_str(),(smallSample ? "_small":"") ));
  23. histos = TFile::Open(Form("%s/data/MC/BtoXJpsi/%s%s/%s%s_pi0Resolved_histos%s.root",path_to_output_KplusPizero.c_str(), year.c_str(),magnet.c_str(),year.c_str(),magnet.c_str(),(smallSample ? "_small":"") ));
  24. }
  25. // Kst2Kpluspi0Merged case
  26. if(Kst2Kpluspi0Merged){
  27. //TODO
  28. }
  29. // Kst2Kspiplus case
  30. if(Kst2Kspiplus){
  31. //TODO
  32. }
  33. input->cd();
  34. cout << "In input" << endl;
  35. tree = (TTree*)input->Get("DecayTree");
  36. cout << "Tree has " << tree->GetEntries() << " entries" << endl;
  37. tree->SetBranchStatus("*",1);
  38. Double_t B_plus_M_DTF;
  39. //assign variables to TRUEID
  40. Int_t B_plus_TRUEID;
  41. Int_t K_star_plus_TRUEID;
  42. Int_t K_plus_TRUEID;
  43. Int_t K_short_TRUEID;
  44. Int_t Ks_pi_plus_TRUEID;
  45. Int_t Ks_pi_minus_TRUEID;
  46. Int_t pi_plus_TRUEID;
  47. Int_t pi_zero_TRUEID;
  48. Int_t mu_plus_TRUEID;
  49. Int_t mu_minus_TRUEID;
  50. Int_t J_psi_TRUEID;
  51. Int_t gamma1_TRUEID;
  52. Int_t gamma2_TRUEID;
  53. //assign variables to TRUE_MOTHER_ID
  54. Int_t B_plus_MOTHER_ID;
  55. Int_t K_star_plus_MOTHER_ID;
  56. Int_t K_plus_MOTHER_ID;
  57. Int_t K_short_MOTHER_ID;
  58. Int_t Ks_pi_plus_MOTHER_ID;
  59. Int_t Ks_pi_minus_MOTHER_ID;
  60. Int_t pi_plus_MOTHER_ID;
  61. Int_t pi_zero_MOTHER_ID;
  62. Int_t mu_plus_MOTHER_ID;
  63. Int_t mu_minus_MOTHER_ID;
  64. Int_t J_psi_MOTHER_ID;
  65. Int_t gamma1_MOTHER_ID;
  66. Int_t gamma2_MOTHER_ID;
  67. //assign variables to TRUE_GD_MOTHER_ID
  68. Int_t K_plus_GD_MOTHER_ID;
  69. Int_t K_plus_GD_GD_MOTHER_ID;
  70. Int_t K_short_GD_MOTHER_ID;
  71. Int_t Ks_pi_plus_GD_MOTHER_ID;
  72. Int_t Ks_pi_minus_GD_MOTHER_ID;
  73. Int_t pi_plus_GD_MOTHER_ID;
  74. Int_t pi_zero_GD_MOTHER_ID;
  75. Int_t mu_plus_GD_MOTHER_ID;
  76. Int_t mu_minus_GD_MOTHER_ID;
  77. Int_t gamma1_GD_MOTHER_ID;
  78. Int_t gamma2_GD_MOTHER_ID;
  79. //assign variables to TRUE_GD_MOTHER_ID
  80. Int_t Ks_pi_plus_GD_GD_MOTHER_ID;
  81. Int_t Ks_pi_minus_GD_GD_MOTHER_ID;
  82. Int_t gamma1_GD_GD_MOTHER_ID;
  83. Int_t gamma2_GD_GD_MOTHER_ID;
  84. Int_t pi_zero_merged_MC_GD_GD_MOTHER_ID;
  85. //link variables to branches
  86. tree -> SetBranchAddress( "B_plus_M_DTF" , &B_plus_M_DTF );
  87. tree -> SetBranchAddress( "B_plus_TRUEID" , &B_plus_TRUEID );
  88. tree -> SetBranchAddress( "K_star_plus_TRUEID" , &K_star_plus_TRUEID );
  89. tree -> SetBranchAddress( "mu_plus_TRUEID" , &mu_plus_TRUEID );
  90. tree -> SetBranchAddress( "mu_minus_TRUEID" , &mu_minus_TRUEID );
  91. tree -> SetBranchAddress( "B_plus_MC_MOTHER_ID" , &B_plus_MOTHER_ID );
  92. tree -> SetBranchAddress( "K_star_plus_MC_MOTHER_ID" , &K_star_plus_MOTHER_ID );
  93. tree -> SetBranchAddress( "mu_plus_MC_MOTHER_ID" , &mu_plus_MOTHER_ID );
  94. tree -> SetBranchAddress( "mu_minus_MC_MOTHER_ID" , &mu_minus_MOTHER_ID );
  95. tree -> SetBranchAddress( "mu_plus_MC_GD_MOTHER_ID" , &mu_plus_GD_MOTHER_ID );
  96. tree -> SetBranchAddress( "mu_minus_MC_GD_MOTHER_ID" , &mu_minus_GD_MOTHER_ID );
  97. if(Kst2Kpluspi0Resolved){
  98. tree -> SetBranchAddress( "K_plus_TRUEID" , &K_plus_TRUEID );
  99. tree -> SetBranchAddress( "pi_zero_resolved_TRUEID" , &pi_zero_TRUEID );
  100. tree -> SetBranchAddress( "gamma1_TRUEID" , &gamma1_TRUEID );
  101. tree -> SetBranchAddress( "gamma2_TRUEID" , &gamma2_TRUEID );
  102. tree -> SetBranchAddress( "K_plus_MC_MOTHER_ID" , &K_plus_MOTHER_ID );
  103. tree -> SetBranchAddress( "pi_zero_resolved_MC_MOTHER_ID" , &pi_zero_MOTHER_ID );
  104. tree -> SetBranchAddress( "gamma1_MC_MOTHER_ID" , &gamma1_MOTHER_ID );
  105. tree -> SetBranchAddress( "gamma2_MC_MOTHER_ID" , &gamma2_MOTHER_ID );
  106. tree -> SetBranchAddress( "K_plus_MC_GD_MOTHER_ID" , &K_plus_GD_MOTHER_ID );
  107. tree -> SetBranchAddress( "K_plus_MC_GD_GD_MOTHER_ID" , &K_plus_GD_GD_MOTHER_ID );
  108. tree -> SetBranchAddress( "pi_zero_resolved_MC_GD_MOTHER_ID" , &pi_zero_GD_MOTHER_ID );
  109. tree -> SetBranchAddress( "gamma1_MC_GD_MOTHER_ID" , &gamma1_GD_MOTHER_ID );
  110. tree -> SetBranchAddress( "gamma2_MC_GD_MOTHER_ID" , &gamma2_GD_MOTHER_ID );
  111. tree -> SetBranchAddress( "gamma1_MC_GD_GD_MOTHER_ID" , &gamma1_GD_GD_MOTHER_ID );
  112. tree -> SetBranchAddress( "gamma2_MC_GD_GD_MOTHER_ID" , &gamma2_GD_GD_MOTHER_ID );
  113. }
  114. if(Kst2Kpluspi0Merged){
  115. tree -> SetBranchAddress( "K_plus_TRUEID" , &K_plus_TRUEID );
  116. tree -> SetBranchAddress( "pi_zero_merged_TRUEID" , &pi_zero_TRUEID );
  117. tree -> SetBranchAddress( "K_plus_MC_MOTHER_ID" , &K_plus_MOTHER_ID );
  118. tree -> SetBranchAddress( "pi_zero_merged_MC_MOTHER_ID" , &pi_zero_MOTHER_ID );
  119. tree -> SetBranchAddress( "K_plus_MC_GD_MOTHER_ID" , &K_plus_GD_MOTHER_ID );
  120. tree -> SetBranchAddress( "pi_zero_merged_MC_GD_MOTHER_ID" , &pi_zero_GD_MOTHER_ID );
  121. tree -> SetBranchAddress( "pi_zero_merged_MC_GD_GD_MOTHER_ID" , &pi_zero_merged_MC_GD_GD_MOTHER_ID );
  122. }
  123. if(Kst2Kspiplus){
  124. tree -> SetBranchAddress( "K_short_TRUEID" , &K_short_TRUEID );
  125. tree -> SetBranchAddress( "pi_plus_TRUEID" , &pi_plus_TRUEID );
  126. tree -> SetBranchAddress( "Ks_pi_plus_TRUEID" , &Ks_pi_plus_TRUEID );
  127. tree -> SetBranchAddress( "Ks_pi_minus_TRUEID" , &Ks_pi_minus_TRUEID );
  128. tree -> SetBranchAddress( "K_short_MC_MOTHER_ID" , &K_short_MOTHER_ID );
  129. tree -> SetBranchAddress( "pi_plus_MC_MOTHER_ID" , &pi_plus_MOTHER_ID );
  130. tree -> SetBranchAddress( "Ks_pi_plus_MC_MOTHER_ID" , &Ks_pi_plus_MOTHER_ID );
  131. tree -> SetBranchAddress( "Ks_pi_minus_MC_MOTHER_ID" , &Ks_pi_minus_MOTHER_ID );
  132. tree -> SetBranchAddress( "K_short_MC_GD_MOTHER_ID" , &K_short_GD_MOTHER_ID );
  133. tree -> SetBranchAddress( "pi_plus_MC_GD_MOTHER_ID" , &pi_plus_GD_MOTHER_ID );
  134. tree -> SetBranchAddress( "Ks_pi_plus_MC_GD_MOTHER_ID" , &Ks_pi_plus_GD_MOTHER_ID );
  135. tree -> SetBranchAddress( "Ks_pi_minus_MC_GD_MOTHER_ID" , &Ks_pi_minus_GD_MOTHER_ID );
  136. tree -> SetBranchAddress( "Ks_pi_plus_MC_GD_GD_MOTHER_ID" , &Ks_pi_plus_GD_GD_MOTHER_ID );
  137. tree -> SetBranchAddress( "Ks_pi_minus_MC_GD_GD_MOTHER_ID" , &Ks_pi_minus_GD_GD_MOTHER_ID );
  138. }
  139. tree -> SetBranchAddress( "J_psi_TRUEID" , &J_psi_TRUEID );
  140. tree -> SetBranchAddress( "J_psi_MC_MOTHER_ID" , &J_psi_MOTHER_ID );
  141. //counter
  142. Int_t B_plus_VETO = 0;
  143. Int_t K_star_plus_VETO = 0;
  144. Int_t K_plus_VETO = 0;
  145. Int_t K_short_VETO = 0;
  146. Int_t Ks_pi_plus_VETO = 0;
  147. Int_t Ks_pi_minus_VETO = 0;
  148. Int_t pi_plus_VETO = 0;
  149. Int_t pi_zero_VETO = 0;
  150. Int_t mu_plus_VETO = 0;
  151. Int_t mu_minus_VETO = 0;
  152. Int_t J_psi_VETO = 0;
  153. Int_t gamma1_VETO = 0;
  154. Int_t gamma2_VETO = 0;
  155. Int_t MOTHER_ID_VETO = 0;
  156. Int_t GD_MOTHER_ID_VETO = 0;
  157. Int_t GD_GD_MOTHER_ID_VETO = 0;
  158. Int_t TRUE_events = 0;
  159. //count the numbers of Kshort daughters, which are pi_zeros
  160. Int_t Kshort_pi_zero_daughters = 0;
  161. //count muons, mis-IDed as pions
  162. Int_t ReconstructedPionsWhichAreMuons = 0;
  163. //======================================
  164. //Get histos of all possible backgrounds
  165. //======================================
  166. //control plots for pi0
  167. Double_t pi_zero_resolved_M = 0.0;
  168. if (Kst2Kpluspi0Resolved)
  169. tree -> SetBranchAddress( "pi_zero_resolved_M" , &pi_zero_resolved_M );
  170. TH1 * h_pi0_resolved_mass= new TH1D("h_pi0_resolved_mass" , "m_{#pi_{0}} resolved", 100, 75, 175);
  171. h_pi0_resolved_mass->GetXaxis()->SetTitle("m_{pi_{0}} resolved [MeV]");
  172. h_pi0_resolved_mass->GetYaxis()->SetTitle("Counts / 1MeV");
  173. TH1 * h_pi0_mismatched_mass= new TH1D("h_pi0_mismatched_mass" , "m_{#pi_{0}} IDed as gamma", 100, 75, 175);
  174. h_pi0_mismatched_mass->GetXaxis()->SetTitle("m_{pi_{0}}[MeV] MisIDed");
  175. h_pi0_mismatched_mass->GetYaxis()->SetTitle("Counts / 1MeV");
  176. TH1 * h_B_plus_TRUEID = new TH1D("h_B_plus_TRUEID", "B^{+} TRUEID", 100000, -1, 99999);
  177. TH1 * h_K_star_plus_TRUEID = new TH1D("h_K_star_plus_TRUEID", "K^{*+} TRUEID", 100000, -1, 99999);
  178. TH1 * h_K_plus_TRUEID = new TH1D("h_K_plus_TRUEID", "K^{+} TRUEID", 100000, -1, 99999);
  179. TH1 * h_pi_zero_TRUEID = new TH1D("h_pi_zero_TRUEID", "#pi^{0} TRUEID", 100000, -1, 99999);
  180. TH1 * h_B_plus_TRUEID_rm = new TH1D("h_B_plus_TRUEID_rm", "B^{+} TRUEID", 100000, -1, 99999);
  181. TH1 * h_K_star_plus_TRUEID_rm= new TH1D("h_K_star_plus_TRUEID_rm", "K^{*+} TRUEID", 100000, -1, 99999);
  182. TH1 * h_K_plus_TRUEID_rm = new TH1D("h_K_plus_TRUEID_rm", "K^{+} TRUEID", 100000, -1, 99999);
  183. TH1 * h_pi_zero_TRUEID_rm = new TH1D("h_pi_zero_TRUEID_rm", "#pi^{0} TRUEID", 100000, -1, 99999);
  184. TH1 * h_B_plus_K1 = new TH1D("h_B_plus_K1", "h_B_plus_K1", 100, cut_B_plus_M_low, cut_B_plus_M_high);
  185. TH1 * h_B_plus_Kst = new TH1D("h_B_plus_Kst", "h_B_plus_Kst", 100, cut_B_plus_M_low, cut_B_plus_M_high);
  186. TH1 * h_B_plus_Kpl = new TH1D("h_B_plus_Kpl", "h_B_plus_Kpl", 100, cut_B_plus_M_low, cut_B_plus_M_high);
  187. vector<std::string> Cuts;
  188. string tmp_string = "";
  189. int nBins = 75;
  190. TH1 * h_BplusMass_tot= new TH1D("h_BplusMass_tot" , "h_BplusMass_tot", nBins ,cut_B_plus_M_low, cut_B_plus_M_high);
  191. h_BplusMass_tot->GetXaxis()->SetTitle("B^{+} mass [MeV]");
  192. //======================================
  193. // Define trees for all channels
  194. //======================================
  195. TTree *tree_correct = tree->CloneTree(0);
  196. tree_correct->SetName("tree_correct");
  197. TH1 * h_BplusMass_correct = new TH1D("h_BplusMass_correct" , "h_BplusMass_correct", nBins ,cut_B_plus_M_low, cut_B_plus_M_high);
  198. h_BplusMass_correct->GetXaxis()->SetTitle("B^{+} mass [MeV]");
  199. TTree *tree_K1_1270 = tree->CloneTree(0);
  200. tree_K1_1270->SetName("tree_K1_1270");
  201. TH1 * h_BplusMass_K1_1270 = new TH1D("h_BplusMass_K1_1270" , "h_BplusMass_K1_1270", nBins ,cut_B_plus_M_low, cut_B_plus_M_high);
  202. h_BplusMass_K1_1270->GetXaxis()->SetTitle("B^{+} mass [MeV]");
  203. TTree *tree_K1_1410 = tree->CloneTree(0);
  204. tree_K1_1410->SetName("tree_K1_1410");
  205. TH1 * h_BplusMass_K1_1410 = new TH1D("h_BplusMass_K1_1410" , "h_BplusMass_K1_1410", nBins ,cut_B_plus_M_low, cut_B_plus_M_high);
  206. h_BplusMass_K1_1410->GetXaxis()->SetTitle("B^{+} mass [MeV]");
  207. TTree *tree_K1_1400 = tree->CloneTree(0);
  208. tree_K1_1400->SetName("tree_K1_1400");
  209. TH1 * h_BplusMass_K1_1400 = new TH1D("h_BplusMass_K1_1400" , "h_BplusMass_K1_1400", nBins ,cut_B_plus_M_low, cut_B_plus_M_high);
  210. h_BplusMass_K1_1400->GetXaxis()->SetTitle("B^{+} mass [MeV]");
  211. TTree *tree_K_plus= tree->CloneTree(0);
  212. tree_K_plus->SetName("tree_K_plus");
  213. TH1 * h_BplusMass_K_plus = new TH1D("h_BplusMass_K_plus" , "h_BplusMass_K_plus", nBins ,cut_B_plus_M_low, cut_B_plus_M_high);
  214. h_BplusMass_K_plus->GetXaxis()->SetTitle("B^{+} mass [MeV]");
  215. TTree *tree_K_plus_misID= tree->CloneTree(0);
  216. tree_K_plus_misID->SetName("tree_K_plus_misID");
  217. TH1 * h_BplusMass_K_plus_misID = new TH1D("h_BplusMass_K_plus_misID" , "h_BplusMass_K_plus_misID", nBins ,cut_B_plus_M_low, cut_B_plus_M_high);
  218. h_BplusMass_K_plus_misID->GetXaxis()->SetTitle("B^{+} mass [MeV]");
  219. TTree *tree_B_star= tree->CloneTree(0);
  220. tree_B_star->SetName("tree_B_star");
  221. TH1 * h_BplusMass_B_star = new TH1D("h_BplusMass_B_star" , "h_BplusMass_B_star", nBins ,cut_B_plus_M_low, cut_B_plus_M_high);
  222. h_BplusMass_B_star->GetXaxis()->SetTitle("B^{+} mass [MeV]");
  223. TTree *tree_Kstar_misID= tree->CloneTree(0);
  224. tree_Kstar_misID->SetName("tree_Kstar_misID");
  225. TH1 * h_BplusMass_Kstar_misID = new TH1D("h_BplusMass_Kstar_misID" , "h_BplusMass_Kstar_misID", nBins ,cut_B_plus_M_low, cut_B_plus_M_high);
  226. h_BplusMass_Kstar_misID->GetXaxis()->SetTitle("B^{+} mass [MeV]");
  227. TTree *tree_bquark= tree->CloneTree(0);
  228. tree_bquark->SetName("tree_bquark");
  229. TH1 * h_BplusMass_bquark = new TH1D("h_BplusMass_bquark" , "h_BplusMass_bquark", nBins ,cut_B_plus_M_low, cut_B_plus_M_high);
  230. h_BplusMass_bquark->GetXaxis()->SetTitle("B^{+} mass [MeV]");
  231. TTree *tree_combinatorics= tree->CloneTree(0);
  232. tree_combinatorics->SetName("tree_combinatorics");
  233. TH1 * h_BplusMass_combinatorics = new TH1D("h_BplusMass_combinatorics" , "h_BplusMass_combinatorics", nBins ,cut_B_plus_M_low, cut_B_plus_M_high);
  234. h_BplusMass_combinatorics->GetXaxis()->SetTitle("B^{+} mass [MeV]");
  235. TTree *tree_others = tree->CloneTree(0);
  236. tree_others->SetName("tree_others");
  237. TH1 * h_BplusMass_others = new TH1D("h_BplusMass_others" , "h_BplusMass_others", nBins ,cut_B_plus_M_low, cut_B_plus_M_high);
  238. h_BplusMass_others->GetXaxis()->SetTitle("B^{+} mass [MeV]");
  239. TH1 * h_BplusMass_JpsiVETO = new TH1D("h_BplusMass_JpsiVETO" , "h_BplusMass_JpsiVETO", nBins ,cut_B_plus_M_low, cut_B_plus_M_high);
  240. h_BplusMass_JpsiVETO->GetXaxis()->SetTitle("B^{+} mass [MeV]");
  241. TH1 * h_BplusMass_GDVETO = new TH1D("h_BplusMass_GDVETO" , "h_BplusMass_GDVETO", nBins ,cut_B_plus_M_low, cut_B_plus_M_high);
  242. h_BplusMass_GDVETO->GetXaxis()->SetTitle("B^{+} mass [MeV]");
  243. //======================================
  244. //check all particles for correct TRUEID
  245. //======================================
  246. //MC loop
  247. cout << "Tree has " << tree->GetEntries() << " entries" << endl;
  248. int nEvents = tree->GetEntries();
  249. std::cout << "Truth matching of " << nEvents << " INC MC events for " << year << magnet << "!" << std::endl;
  250. for(int i = 0; i < nEvents; i++){
  251. if(i%2000==0 && i != 0)std::cout << "Loading MC event " << i << " / " << nEvents << std::endl;
  252. bool flag_other = true;
  253. //others
  254. tree->GetEntry(i);
  255. h_BplusMass_tot->Fill(B_plus_M_DTF);
  256. //remove nonsense from B and Jpsi
  257. if(TMath::Abs(B_plus_TRUEID) != TRUEID.B_PLUS && TMath::Abs(B_plus_TRUEID) != 0 && TMath::Abs(B_plus_TRUEID) != 5){
  258. B_plus_VETO++;
  259. h_B_plus_TRUEID_rm->Fill(B_plus_TRUEID);
  260. continue;
  261. }
  262. if(ReferenceChannel){
  263. if(TMath::Abs(J_psi_TRUEID) != TRUEID.J_PSI){
  264. J_psi_VETO++;
  265. h_BplusMass_JpsiVETO->Fill(B_plus_M_DTF);
  266. continue;
  267. }
  268. if(TMath::Abs(mu_plus_MOTHER_ID) != TRUEID.J_PSI){
  269. MOTHER_ID_VETO++;
  270. h_BplusMass_others->Fill(B_plus_M_DTF);
  271. continue;
  272. }
  273. if(TMath::Abs(mu_minus_MOTHER_ID) != TRUEID.J_PSI){
  274. MOTHER_ID_VETO++;
  275. h_BplusMass_others->Fill(B_plus_M_DTF);
  276. continue;
  277. }
  278. if(TMath::Abs(mu_plus_GD_MOTHER_ID) != TRUEID.B_PLUS){
  279. GD_MOTHER_ID_VETO++;
  280. h_BplusMass_GDVETO->Fill(B_plus_M_DTF);
  281. continue;
  282. }
  283. if(TMath::Abs(mu_minus_GD_MOTHER_ID) != TRUEID.B_PLUS){
  284. GD_MOTHER_ID_VETO++;
  285. h_BplusMass_GDVETO->Fill(B_plus_M_DTF);
  286. continue;
  287. }
  288. }
  289. else{
  290. if(TMath::Abs(J_psi_TRUEID) == TRUEID.J_PSI){
  291. J_psi_VETO++;
  292. h_BplusMass_JpsiVETO->Fill(B_plus_M_DTF);
  293. continue;
  294. }
  295. if(TMath::Abs(mu_plus_MOTHER_ID) != TRUEID.B_PLUS){
  296. MOTHER_ID_VETO++;
  297. h_BplusMass_others->Fill(B_plus_M_DTF);
  298. continue;
  299. }
  300. if(TMath::Abs(mu_minus_MOTHER_ID) != TRUEID.B_PLUS){
  301. MOTHER_ID_VETO++;
  302. h_BplusMass_others->Fill(B_plus_M_DTF);
  303. continue;
  304. }
  305. }
  306. //correct tree
  307. if (TMath::Abs(K_star_plus_TRUEID) == TRUEID.K_STAR_PLUS)
  308. if(TMath::Abs(K_plus_TRUEID) == TRUEID.K_PLUS){ //Paticle IDs
  309. if(TMath::Abs(K_star_plus_MOTHER_ID) == TRUEID.B_PLUS)
  310. if(TMath::Abs(K_plus_MOTHER_ID) == TRUEID.K_STAR_PLUS){ //Mother IDs
  311. if(TMath::Abs(K_plus_GD_MOTHER_ID) == TRUEID.B_PLUS){//Grandmother IDs
  312. tree_correct->Fill();
  313. h_BplusMass_correct->Fill(B_plus_M_DTF);
  314. continue;
  315. }
  316. }
  317. }
  318. //K1 tree
  319. if (TMath::Abs(K_star_plus_TRUEID) == TRUEID.K_ONE_PLUS || TMath::Abs(K_star_plus_TRUEID) == 0 || TMath::Abs(K_star_plus_TRUEID) == TRUEID.B_PLUS )
  320. if(TMath::Abs(K_plus_TRUEID) == TRUEID.K_STAR_PLUS || TMath::Abs(K_plus_TRUEID) == TRUEID.K_PLUS){ //Paticle IDs
  321. if(TMath::Abs(K_star_plus_MOTHER_ID) == TRUEID.B_PLUS || TMath::Abs(K_star_plus_MOTHER_ID) == TRUEID.K_ONE_PLUS || TMath::Abs(K_star_plus_MOTHER_ID) == 0)
  322. if(TMath::Abs(K_plus_MOTHER_ID) == TRUEID.K_STAR_PLUS || TMath::Abs(K_plus_MOTHER_ID) == TRUEID.K_ONE_PLUS){ //Mother IDs
  323. if(TMath::Abs(K_plus_GD_MOTHER_ID) == TRUEID.B_PLUS || TMath::Abs(K_plus_GD_MOTHER_ID) == TRUEID.K_ONE_PLUS){//Grandmother IDs
  324. tree_K1_1270->Fill();
  325. h_BplusMass_K1_1270->Fill(B_plus_M_DTF);
  326. continue;
  327. }
  328. }
  329. }
  330. //K1 1400 tree
  331. if (TMath::Abs(K_star_plus_TRUEID) == TRUEID.K_ONE_PLUS_1400 || TMath::Abs(K_star_plus_TRUEID) == 0|| TMath::Abs(K_star_plus_TRUEID) == TRUEID.B_PLUS )
  332. if(TMath::Abs(K_plus_TRUEID) == TRUEID.K_STAR_PLUS || TMath::Abs(K_plus_TRUEID) == TRUEID.K_PLUS){ //Paticle ID
  333. if(TMath::Abs(K_star_plus_MOTHER_ID) == TRUEID.B_PLUS || TMath::Abs(K_star_plus_MOTHER_ID) == TRUEID.K_ONE_PLUS_1400)
  334. if(TMath::Abs(K_plus_MOTHER_ID) == TRUEID.K_STAR_PLUS || TMath::Abs(K_plus_MOTHER_ID) == TRUEID.K_ONE_PLUS_1400){ //Mother IDs
  335. if(TMath::Abs(K_plus_GD_MOTHER_ID) == TRUEID.B_PLUS || TMath::Abs(K_plus_GD_MOTHER_ID) == TRUEID.K_ONE_PLUS_1400){//Grandmother IDs
  336. tree_K1_1400->Fill();
  337. h_BplusMass_K1_1410->Fill(B_plus_M_DTF);
  338. tree_others->Fill();
  339. h_BplusMass_others->Fill(B_plus_M_DTF);
  340. continue;
  341. }
  342. }
  343. }
  344. //K1 1410 tree
  345. if (TMath::Abs(K_star_plus_TRUEID) == TRUEID.K_ONE_PLUS_1410 || TMath::Abs(K_star_plus_TRUEID) == 0 )
  346. if(TMath::Abs(K_plus_TRUEID) == TRUEID.K_PLUS){ //Paticle IDs
  347. if(TMath::Abs(K_star_plus_MOTHER_ID) == TRUEID.B_PLUS || TMath::Abs(K_star_plus_MOTHER_ID) == 0 || TMath::Abs(K_star_plus_MOTHER_ID) == TRUEID.K_ONE_PLUS_1410)
  348. if(TMath::Abs(K_plus_MOTHER_ID) == TRUEID.K_STAR_PLUS || TMath::Abs(K_plus_MOTHER_ID) == TRUEID.K_ONE_PLUS_1410){ //Mother IDs
  349. if(TMath::Abs(K_plus_GD_MOTHER_ID) == 0 || TMath::Abs(K_plus_GD_MOTHER_ID) == TRUEID.K_ONE_PLUS_1410){//Grandmother IDs
  350. tree_K1_1410->Fill();
  351. h_BplusMass_K1_1410->Fill(B_plus_M_DTF);
  352. tree_others->Fill();
  353. h_BplusMass_others->Fill(B_plus_M_DTF);
  354. continue;
  355. }
  356. }
  357. }
  358. //K1 1270 tree 2.0
  359. if (TMath::Abs(K_star_plus_TRUEID) == TRUEID.K_STAR_PLUS)
  360. if(TMath::Abs(K_plus_TRUEID) == TRUEID.K_PLUS){ //Paticle IDs
  361. if(TMath::Abs(K_star_plus_MOTHER_ID) == TRUEID.K_ONE_PLUS)
  362. if(TMath::Abs(K_plus_MOTHER_ID) == TRUEID.K_STAR_PLUS){ //Mother IDs
  363. if(TMath::Abs(K_plus_GD_MOTHER_ID) == TRUEID.K_ONE_PLUS){//Grandmother IDs
  364. tree_K1_1270->Fill();
  365. h_BplusMass_K1_1270->Fill(B_plus_M_DTF);
  366. continue;
  367. }
  368. }
  369. }
  370. //tree_K_plus_misID tree
  371. if (TMath::Abs(K_star_plus_TRUEID) == TRUEID.K_ONE_PLUS || TMath::Abs(K_star_plus_TRUEID) == TRUEID.K_STAR_PLUS|| TMath::Abs(K_star_plus_TRUEID) == 0 )
  372. if(TMath::Abs(K_plus_TRUEID) == TRUEID.PI_PLUS){ //Paticle IDs
  373. if(TMath::Abs(K_star_plus_MOTHER_ID) == TRUEID.B_PLUS || TMath::Abs(K_star_plus_MOTHER_ID) == TRUEID.K_ONE_PLUS)
  374. if(TMath::Abs(K_plus_MOTHER_ID) == TRUEID.K_STAR_PLUS || TMath::Abs(K_plus_MOTHER_ID) == TRUEID.K_ONE_PLUS){ //Mother IDs
  375. if(TMath::Abs(K_plus_GD_MOTHER_ID) == TRUEID.B_PLUS || TMath::Abs(K_plus_GD_MOTHER_ID) == TRUEID.K_ONE_PLUS){//Grandmother IDs
  376. tree_K_plus_misID->Fill();
  377. h_BplusMass_K_plus_misID->Fill(B_plus_M_DTF);
  378. tree_others->Fill();
  379. h_BplusMass_others->Fill(B_plus_M_DTF);
  380. continue;
  381. }
  382. }
  383. }
  384. //tree_K_plus_misID tree 2.0 (K+->pi+)
  385. if (TMath::Abs(K_star_plus_TRUEID) == TRUEID.K_STAR_PLUS)
  386. if(TMath::Abs(K_plus_TRUEID) == TRUEID.PI_PLUS){ //Paticle IDs
  387. if(TMath::Abs(K_star_plus_MOTHER_ID) == TRUEID.B_PLUS)
  388. if(TMath::Abs(K_plus_MOTHER_ID) == TRUEID.K_PLUS){ //Mother IDs
  389. if(TMath::Abs(K_plus_GD_MOTHER_ID) == TRUEID.K_STAR_PLUS)
  390. if (TMath::Abs(K_plus_GD_GD_MOTHER_ID) == TRUEID.B_PLUS){//Grandmother IDs
  391. tree_K_plus_misID->Fill();
  392. h_BplusMass_K_plus_misID->Fill(B_plus_M_DTF);
  393. tree_others->Fill();
  394. h_BplusMass_others->Fill(B_plus_M_DTF);
  395. continue;
  396. }
  397. }
  398. }
  399. //Kplus tree
  400. if (TMath::Abs(K_star_plus_TRUEID) == TRUEID.K_PLUS || TMath::Abs(K_star_plus_TRUEID) == 0)
  401. if(TMath::Abs(K_plus_TRUEID) == TRUEID.K_PLUS){ //Paticle IDs
  402. if(TMath::Abs(K_plus_MOTHER_ID) == TRUEID.B_PLUS){ //Mother IDs
  403. if(TMath::Abs(K_plus_GD_MOTHER_ID) == 0){//Grandmother IDs
  404. tree_K_plus->Fill();
  405. h_BplusMass_K_plus->Fill(B_plus_M_DTF);
  406. tree_others->Fill();
  407. h_BplusMass_others->Fill(B_plus_M_DTF);
  408. continue;
  409. }
  410. }
  411. }
  412. //K star misID tree
  413. if (TMath::Abs(K_star_plus_TRUEID) == TRUEID.K_PLUS)
  414. if(TMath::Abs(K_plus_TRUEID) == TRUEID.K_PLUS){ //Paticle IDs
  415. if(TMath::Abs(K_star_plus_MOTHER_ID) == TRUEID.K_STAR_PLUS)
  416. if(TMath::Abs(K_plus_MOTHER_ID) == TRUEID.K_STAR_PLUS){ //Mother IDs
  417. if(TMath::Abs(K_plus_GD_MOTHER_ID) == TRUEID.B_PLUS){//Grandmother IDs
  418. tree_Kstar_misID->Fill();
  419. h_BplusMass_Kstar_misID->Fill(B_plus_M_DTF);
  420. tree_others->Fill();
  421. h_BplusMass_others->Fill(B_plus_M_DTF);
  422. continue;
  423. }
  424. }
  425. }
  426. //B+ <-> b quark
  427. if (TMath::Abs(K_star_plus_TRUEID) == TRUEID.B_PLUS)
  428. if(TMath::Abs(K_plus_TRUEID) == TRUEID.K_PLUS){ //Paticle IDs
  429. if(TMath::Abs(K_star_plus_MOTHER_ID) == 5)
  430. if(TMath::Abs(K_plus_MOTHER_ID) == TRUEID.B_PLUS){ //Mother IDs
  431. tree_bquark->Fill();
  432. h_BplusMass_bquark->Fill(B_plus_M_DTF);
  433. continue;
  434. }
  435. }
  436. //B+ <-> b quark 2.0
  437. if (TMath::Abs(K_star_plus_TRUEID) ==5)
  438. if(TMath::Abs(K_plus_TRUEID) == TRUEID.K_PLUS){ //Paticle IDs
  439. if(TMath::Abs(K_star_plus_MOTHER_ID) == 0)
  440. if(TMath::Abs(K_plus_MOTHER_ID) == TRUEID.B_PLUS || TMath::Abs(K_plus_MOTHER_ID) == TRUEID.K_STAR_PLUS ){ //Mother IDs
  441. tree_bquark->Fill();
  442. h_BplusMass_bquark->Fill(B_plus_M_DTF);
  443. continue;
  444. }
  445. }
  446. //Bstar tree
  447. if (TMath::Abs(K_star_plus_TRUEID) == TRUEID.B_PLUS)
  448. if(TMath::Abs(K_plus_TRUEID) == TRUEID.K_PLUS){ //Paticle IDs
  449. if(TMath::Abs(K_star_plus_MOTHER_ID) == 523)
  450. if(TMath::Abs(K_plus_MOTHER_ID) == TRUEID.B_PLUS){ //Mother IDs
  451. if(TMath::Abs(K_plus_GD_MOTHER_ID) == 523){//Grandmother IDs
  452. tree_B_star->Fill();
  453. h_BplusMass_B_star->Fill(B_plus_M_DTF);
  454. continue;
  455. }
  456. }
  457. }
  458. //Bstar tree 2.0
  459. if (TMath::Abs(K_star_plus_TRUEID) == TRUEID.K_PLUS)
  460. if(TMath::Abs(K_plus_TRUEID) == TRUEID.K_PLUS){ //Paticle IDs
  461. if(TMath::Abs(K_star_plus_MOTHER_ID) == 523)
  462. if(TMath::Abs(K_plus_MOTHER_ID) == TRUEID.B_PLUS){ //Mother IDs
  463. if(TMath::Abs(K_plus_GD_MOTHER_ID) == 523){//Grandmother IDs
  464. tree_B_star->Fill();
  465. h_BplusMass_B_star->Fill(B_plus_M_DTF);
  466. continue;
  467. }
  468. }
  469. }
  470. //Bstar tree 3.0 (K* misID B+)
  471. if (TMath::Abs(K_star_plus_TRUEID) == TRUEID.K_PLUS)
  472. if(TMath::Abs(K_plus_TRUEID) == TRUEID.K_PLUS){ //Paticle IDs
  473. if(TMath::Abs(K_star_plus_MOTHER_ID) == TRUEID.B_PLUS)
  474. if(TMath::Abs(K_plus_MOTHER_ID) == TRUEID.B_PLUS){ //Mother IDs
  475. if(TMath::Abs(K_plus_GD_MOTHER_ID) == 523){//Grandmother IDs
  476. tree_B_star->Fill();
  477. h_BplusMass_B_star->Fill(B_plus_M_DTF);
  478. continue;
  479. }
  480. }
  481. }
  482. //Bstar tree 4.0 (K* misID B+)
  483. if (TMath::Abs(K_star_plus_TRUEID) == 0)
  484. if(TMath::Abs(K_plus_TRUEID) == TRUEID.K_PLUS){ //Paticle IDs
  485. if(TMath::Abs(K_star_plus_MOTHER_ID) == 0)
  486. if(TMath::Abs(K_plus_MOTHER_ID) == TRUEID.B_PLUS){ //Mother IDs
  487. if(TMath::Abs(K_plus_GD_MOTHER_ID) == 523 ||TMath::Abs(K_plus_GD_MOTHER_ID) == 10521){//Grandmother IDs
  488. tree_B_star->Fill();
  489. h_BplusMass_B_star->Fill(B_plus_M_DTF);
  490. continue;
  491. }
  492. }
  493. }
  494. //combinatorics tree
  495. if (TMath::Abs(K_star_plus_TRUEID) == 0)
  496. if(TMath::Abs(K_plus_TRUEID) == TRUEID.K_PLUS ||TMath::Abs(K_plus_TRUEID) == 0 ){ //Paticle IDs
  497. if(TMath::Abs(K_star_plus_MOTHER_ID) == 0)
  498. if(TMath::Abs(K_plus_MOTHER_ID) == TRUEID.K_STAR_PLUS ||TMath::Abs(K_plus_TRUEID) == 0 ){ //Mother IDs
  499. if(TMath::Abs(K_plus_GD_MOTHER_ID) == TRUEID.B_PLUS){//Grandmother IDs
  500. tree_combinatorics->Fill();
  501. h_BplusMass_combinatorics->Fill(B_plus_M_DTF);
  502. continue;
  503. }
  504. }
  505. }
  506. //the rest of stuff
  507. tree_others->Fill();
  508. h_BplusMass_others->Fill(B_plus_M_DTF);
  509. }
  510. //output truthmatching results
  511. std::cout << "Resulting TruthMatching data: " << TRUE_events << "/" << nEvents << " are found to be correctly reconstructed!" << std::endl;
  512. std::cout << "The incorrect reconstructed particles are the following:" << std::endl;
  513. std::cout << "(only the first found-incorrect particle is counted)" << std::endl;
  514. std::cout << std::endl;
  515. //std::cout << (B0 ? "B_zero:\t\t" : "B_plus:\t\t") << B_plus_VETO << std::endl;
  516. //std::cout << (B0 ? "K_star_zero:\t" : ( K1 ? "K_one_plus:\t" : "K_star_plus:\t")) << K_star_plus_VETO << std::endl;
  517. std::cout << "mu_plus:\t" << mu_plus_VETO << std::endl;
  518. std::cout << "mu_minus:\t" << mu_minus_VETO << std::endl;
  519. if(Kst2Kpluspi0Resolved){
  520. std::cout << "K_plus:\t\t" << K_plus_VETO << std::endl;
  521. std::cout << "pi_zero:\t" << pi_zero_VETO << std::endl;
  522. std::cout << "gamma1:\t\t" << gamma1_VETO << std::endl;
  523. std::cout << "gamma2:\t\t" << gamma2_VETO << std::endl;
  524. }
  525. if(Kst2Kpluspi0Merged){
  526. std::cout << "K_plus:\t\t" << K_plus_VETO << std::endl;
  527. std::cout << "pi_zero:\t" << pi_zero_VETO << std::endl;
  528. }
  529. if(Kst2Kspiplus){
  530. std::cout << "K_short:\t" << K_short_VETO << std::endl;
  531. std::cout << "Ks_pi_plus:\t" << Ks_pi_plus_VETO << std::endl;
  532. std::cout << "Ks_pi_minus:\t" << Ks_pi_minus_VETO << std::endl;
  533. std::cout << "pi_plus:\t" << pi_plus_VETO << std::endl;
  534. }
  535. std::cout << "J_psi:\t\t" <<J_psi_VETO << std::endl;
  536. if(Kst2Kspiplus){
  537. std::cout << "Pi0 daughers of the Kshort:\t" << Kshort_pi_zero_daughters << std::endl;
  538. std::cout << "Muons mis-IDed as pions:\t" << ReconstructedPionsWhichAreMuons << "/" << Ks_pi_plus_VETO + Ks_pi_minus_VETO + pi_plus_VETO << std::endl;
  539. }
  540. std::cout << "Total incorrect family members of all particles: " << MOTHER_ID_VETO + GD_MOTHER_ID_VETO + GD_GD_MOTHER_ID_VETO << std::endl;
  541. std::cout << "MotherID:\t" << MOTHER_ID_VETO << std::endl;
  542. std::cout << "GDmotherID:\t" << GD_MOTHER_ID_VETO << std::endl;
  543. std::cout << "GDGDmotherID:\t" << GD_GD_MOTHER_ID_VETO << std::endl;
  544. //save to file
  545. TFile * outputFile = nullptr;
  546. // Kst2Kpluspi0Resolved case
  547. if(Kst2Kpluspi0Resolved){
  548. outputFile = new TFile(Form("%s/data/MC/BtoXJpsi/%s%s/%s%s_pi0Resolved_plots.root",path_to_output_KplusPizero.c_str(),year.c_str(),magnet.c_str(),year.c_str(),magnet.c_str()), "RECREATE");
  549. outputFile->cd();
  550. tree_correct->Write();
  551. cout << "Correctly id'd entries " << tree_correct->GetEntries() << endl;
  552. tree_K1_1270->Write();
  553. cout << "B+->K1(1270) entries " << tree_K1_1270->GetEntries() << endl;
  554. tree_K1_1400->Write();
  555. cout << "B+->K1(1400) entries " << tree_K1_1400->GetEntries() << endl;
  556. tree_K1_1410->Write();
  557. cout << "B+->K1(1410) entries " << tree_K1_1410->GetEntries() << endl;
  558. tree_K_plus->Write();
  559. cout << "B+->K+pi0 entries " << tree_K_plus->GetEntries() << endl;
  560. tree_K_plus_misID->Write();
  561. cout << "B+->K*->pi+pi0 " << tree_K_plus_misID->GetEntries() << endl;
  562. tree_B_star->Write();
  563. cout << "B*-> B+->K+ entries " << tree_B_star->GetEntries() << endl;
  564. tree_Kstar_misID->Write();
  565. cout << "K* misID entries " << tree_Kstar_misID->GetEntries() << endl;
  566. tree_combinatorics->Write();
  567. cout << "b-quark entries " << tree_bquark->GetEntries() << endl;
  568. tree_bquark->Write();
  569. cout << "Combinatorics " << tree_combinatorics->GetEntries() << endl;
  570. tree_others->Write();
  571. cout << "Other entries " << tree_others->GetEntries() << endl;
  572. THStack *tmp = new THStack("IncMC","IncMC;B^{+} mass [MeV];Entries");
  573. //tmp->GetXaxis()->SetTitle("B^{+} mass [MeV]");
  574. //tmp->GetYaxis()->SetTitle("Entries");
  575. h_BplusMass_others->SetFillColor(kGreen);
  576. h_BplusMass_others->SetLineColor(kGreen);
  577. tmp->Add(h_BplusMass_others);
  578. h_BplusMass_bquark->SetFillColor(kGreen);
  579. h_BplusMass_bquark->SetLineColor(kGreen);
  580. tmp->Add(h_BplusMass_bquark);
  581. h_BplusMass_K1_1270->SetFillColor(kBlue);
  582. h_BplusMass_K1_1270->SetLineColor(kBlue);
  583. tmp->Add(h_BplusMass_K1_1270);
  584. // h_BplusMass_K1_1400->SetFillColor(0);
  585. // h_BplusMass_K1_1400->SetLineColor(0);
  586. // tmp->Add(h_BplusMass_K1_1400);
  587. // h_BplusMass_K1_1410->SetFillColor(0);
  588. // h_BplusMass_K1_1410->SetLineColor(0);
  589. // tmp->Add(h_BplusMass_K1_1410);
  590. // h_BplusMass_K_plus->SetFillColor(0);
  591. // h_BplusMass_K_plus->SetLineColor(0);
  592. // tmp->Add(h_BplusMass_K_plus);
  593. // h_BplusMass_K_plus_misID->SetFillColor(0);
  594. // h_BplusMass_K_plus_misID->SetLineColor(0);
  595. // tmp->Add(h_BplusMass_K_plus_misID);
  596. h_BplusMass_B_star->SetFillColor(kYellow);
  597. h_BplusMass_B_star->SetLineColor(kYellow);
  598. tmp->Add(h_BplusMass_B_star);
  599. // h_BplusMass_Kstar_misID->SetFillColor(0);
  600. // h_BplusMass_Kstar_misID->SetLineColor(0);
  601. // tmp->Add(h_BplusMass_Kstar_misID);
  602. //
  603. // h_BplusMass_combinatorics->SetFillColor(kBlack);
  604. // h_BplusMass_combinatorics->SetLineColor(kBlack);
  605. // tmp->Add(h_BplusMass_combinatorics);
  606. h_BplusMass_JpsiVETO->SetFillColor(kMagenta-10);
  607. h_BplusMass_JpsiVETO->SetLineColor(kMagenta-10);
  608. tmp->Add(h_BplusMass_JpsiVETO);
  609. h_BplusMass_GDVETO->SetFillColor(kOrange-3);
  610. h_BplusMass_GDVETO->SetLineColor(kOrange-3);
  611. tmp->Add(h_BplusMass_GDVETO);
  612. h_BplusMass_correct->SetFillColor(kRed);
  613. h_BplusMass_correct->SetLineColor(kRed);
  614. tmp->Add(h_BplusMass_correct);
  615. tmp->Write();
  616. TCanvas *c1 = new TCanvas("c1","all",900,700);
  617. c1->cd();
  618. gStyle->SetOptStat(0);
  619. // h_BplusMass_correct->SetFillColor(0);
  620. h_BplusMass_correct->Draw();
  621. // h_BplusMass_others->SetFillColor(0);
  622. h_BplusMass_others->Draw("SAME");
  623. // h_BplusMass_K1_1270->SetFillColor(0);
  624. h_BplusMass_K1_1270->Draw("SAME");
  625. //h_BplusMass_K1_1400->Draw("SAME");
  626. //h_BplusMass_K1_1410->Draw("SAME");
  627. //h_BplusMass_K_plus->Draw("SAME");
  628. //h_BplusMass_K_plus_misID->Draw("SAME");
  629. // h_BplusMass_B_star->SetFillColor(0);
  630. h_BplusMass_B_star->Draw("SAME");
  631. //h_BplusMass_Kstar_misID->Draw("SAME");
  632. //h_BplusMass_combinatorics->Draw("SAME");
  633. // h_BplusMass_bquark->SetFillColor(0);
  634. h_BplusMass_bquark->Draw("SAME");
  635. // h_BplusMass_JpsiVETO->SetFillColor(0);
  636. h_BplusMass_JpsiVETO->Draw("SAME");
  637. // h_BplusMass_GDVETO->SetFillColor(0);
  638. h_BplusMass_GDVETO->Draw("SAME");
  639. c1->Write();
  640. TCanvas *c2 = new TCanvas("c2","al2",900,700);
  641. c2->cd();
  642. tmp->Draw();
  643. h_BplusMass_tot->SetLineWidth(3);
  644. h_BplusMass_tot->SetLineColor(kBlack);
  645. h_BplusMass_tot->Draw("SAMEE");
  646. c2->Write();
  647. c2->SaveAs(Form("%s/data/MC/BtoXJpsi/%s%s/%s%s_pi0Resolved%s_BKG.eps",path_to_output_KplusPizero.c_str(), year.c_str(),magnet.c_str(),year.c_str(),magnet.c_str(),(smallSample ? "_small":"") ),"eps");
  648. }
  649. // Kst2Kpluspi0Merged case
  650. else if(Kst2Kpluspi0Merged){
  651. //TODO
  652. }
  653. // Kst2Kspiplus case
  654. else if(Kst2Kspiplus){
  655. //TODO
  656. }
  657. else return 0;
  658. if(!outputFile->IsOpen()){
  659. std::cout << "[ERROR]\t\tFile was not opened succesfully!" << std::endl;
  660. return 0;
  661. }
  662. outputFile->cd();
  663. //treeTruthMatched->Write("",TObject::kWriteDelete);
  664. if (Kst2Kpluspi0Resolved){
  665. h_pi0_mismatched_mass->SetLineColor(kRed);
  666. h_pi0_mismatched_mass->SetLineWidth(3);
  667. h_pi0_resolved_mass->SetLineColor(kBlue);
  668. h_pi0_resolved_mass->SetLineWidth(3);
  669. h_pi0_mismatched_mass->Write("",TObject::kWriteDelete);
  670. h_pi0_resolved_mass->Write("",TObject::kWriteDelete);
  671. h_B_plus_TRUEID ->Write("",TObject::kWriteDelete);
  672. h_K_star_plus_TRUEID ->Write("",TObject::kWriteDelete);
  673. h_K_plus_TRUEID ->Write("",TObject::kWriteDelete);
  674. h_pi_zero_TRUEID ->Write("",TObject::kWriteDelete);
  675. h_B_plus_TRUEID_rm ->Write("",TObject::kWriteDelete);
  676. h_K_star_plus_TRUEID_rm ->Write("",TObject::kWriteDelete);
  677. h_K_plus_TRUEID_rm ->Write("",TObject::kWriteDelete);
  678. h_pi_zero_TRUEID_rm ->Write("",TObject::kWriteDelete);
  679. h_B_plus_K1 ->Write("",TObject::kWriteDelete);
  680. h_B_plus_Kst ->Write("",TObject::kWriteDelete);
  681. h_B_plus_Kpl ->Write("",TObject::kWriteDelete);
  682. }
  683. delete outputFile;//->Close();
  684. delete h_pi0_mismatched_mass;
  685. delete h_pi0_resolved_mass;
  686. delete tree;
  687. std::cout << "[DONE]\t\tFinished Truth-Matching for INC sample: " << year << " " << magnet << std::endl;
  688. return 1;
  689. }
  690. int plotIncSampleAll() {
  691. if ( plotIncSample("2011","down") == 0) return 0;
  692. if ( plotIncSample("2011","up") == 0) return 0;
  693. if ( plotIncSample("2012","down") == 0) return 0;
  694. if ( plotIncSample("2012","up") == 0) return 0;
  695. if ( plotIncSample("2015","down") == 0) return 0;
  696. if ( plotIncSample("2015","up") == 0) return 0;
  697. if ( plotIncSample("2016","down") == 0) return 0;
  698. if ( plotIncSample("2016","up") == 0) return 0;
  699. return 1;
  700. }