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.

3801 lines
189 KiB

  1. #include "../GlobalFunctions.hh"
  2. //////////////////////////////////////////////////////////////////////
  3. /// PiZeroResolution()
  4. /// #Check pi0 resolution with/without using DTF
  5. ///
  6. /// AngularEff() #todo
  7. /// # Check angular efficiency based on K* pT cut
  8. ///
  9. using namespace std;
  10. string figureFormat = "eps";
  11. std::array<string, 5> ParticlesPiZero {"B",
  12. //"muplus",
  13. //"muminus",
  14. "Kstar",
  15. "pi0",
  16. "gamma1",
  17. "gamma2"
  18. };
  19. std::array<string, 3> ParticlesKShort {"B",
  20. //"muplus",
  21. //"muminus",
  22. "Kstar",
  23. "Kshort"
  24. };
  25. std::array<string, 3> Variables{ "M",
  26. "PT",
  27. "ETA"
  28. };
  29. std::array<string,5> ExtraVariables{
  30. "ThetaK",
  31. "ThetaL",
  32. "Phi",
  33. "PVZ",
  34. "OpenAngle",
  35. };
  36. std::array<string, 2> DTFoptions{//"DTF_PDG",
  37. //"PDG",
  38. "DTF",
  39. ""
  40. };
  41. string particleLatex(string particle){ //one doesn't have to think much when making labels and titles
  42. if (particle == "B") return ("B^{+}");
  43. if (particle == "B+") return ("B^{+}");
  44. if (particle == "Bplus") return ("B^{+}");
  45. if (particle == "B_plus") return ("B^{+}");
  46. if (particle == "Kstar") return ("K^{*+}");
  47. if (particle == "K_star") return ("K^{*+}");
  48. if (particle == "Kplus") return ("K^{+}");
  49. if (particle == "K+") return ("K^{+}");
  50. if (particle == "K_plus") return ("K^{+}");
  51. if (particle == "Kshort") return ("K_{s}");
  52. if (particle == "K_short") return ("K_{s}");
  53. if (particle == "piplus") return ("#pi^{+}");
  54. if (particle == "pi_plus") return ("#pi^{+}");
  55. if (particle == "pizero") return ("#pi^{0}");
  56. if (particle == "pi_zero") return ("#pi^{0}");
  57. if (particle == "pi0") return ("#pi^{0}");
  58. if (particle == "mu") return ("#mu");
  59. if (particle == "mu_plus") return ("#mu^{+}");
  60. if (particle == "muplus") return ("#mu^{+}");
  61. if (particle == "mu_minus") return ("#mu^{-}");
  62. if (particle == "muminus") return ("#mu^{-}");
  63. if (particle == "gamma") return ("#gamma");
  64. if (particle == "gamma") return ("#gamma");
  65. if (particle=="ThetaK") return ("#theta_{K}"); //just easier to put it here
  66. if (particle=="ThetaL") return ("#theta_{L}");//just easier to put it here
  67. if (particle=="Phi") return ("#Phi");//just easier to put it here
  68. cout << "Particle "<< particle <<" not in the list!" << endl;
  69. return "";
  70. }
  71. string variableLatex(string var){
  72. if (var=="PT") return ("p_{T}");
  73. if (var=="PX") return ("p_{X}");
  74. if (var=="PY") return ("p_{Y}");
  75. if (var=="PZ") return ("p_{Z}");
  76. if (var=="ETA") return ("#eta");
  77. if (var=="M") return ("m");
  78. if (var=="PVZ") return ("PVZ [mm]");
  79. if (var=="KstPt") return ("K* p_{T} [MeV]");
  80. if (var=="ThetaK") return ("#theta_{K}");
  81. if (var=="ThetaL") return ("#theta_{L}");
  82. if (var=="Phi") return ("#Phi");
  83. if (var=="OpenAngle") return ("Open angle (#gamma#gamma angle)");
  84. cout << "Variable "<< var <<" is not in the list!" << endl;
  85. return "";
  86. }
  87. string optionLatex(string opt){
  88. if (opt=="DTF_PDG") return ("#splitline{info from DTF}{with masses fixed to PDG}");
  89. if (opt=="DTF") return ("info from DTF");
  90. if (opt=="TRUE") return ("TRUE info");
  91. if (opt=="PDG") return ("#splitline{info from TupleTool}{with masses fixed to PDG}");
  92. if (opt=="") return ("info from TupleTool");
  93. if (opt=="PULL") return ("pull (TupleTool)");
  94. if (opt=="PULL_DTF") return ("pull (DTF)");
  95. if (opt=="RES_SYS") return ("Systematics #pm resolution (TupleTool)");
  96. if (opt=="RES_SYS_DTF") return ("Systematics #pm resolution (DTF)");
  97. if (opt=="RES") return ("Resolution (TupleTool)");
  98. if (opt=="RES_DTF") return ("Resolution (DTF)");
  99. if (opt=="SYS") return ("Systematics (TupleTool)");
  100. if (opt=="SYS_DTF") return ("Systematics (DTF)");
  101. cout << "Option " << opt << " not in the list!" << endl;
  102. return "";
  103. }
  104. string histName(string particle, string var, string opt){
  105. return (variableLatex(var)+"("+ particleLatex(particle)+ "):" + optionLatex(opt));
  106. }
  107. void init_1D(TH1 *&hist, string particle, string var, string opt, string opt_plot, string YaxisTitle, int bins, double low_edge, double up_edge){
  108. string tmpName = variableLatex(var) + "{"+ particleLatex(particle) +"}" + (opt_plot == "" ? "" : ": " + opt_plot);
  109. string tmpTitle = "h_" + particle + "_" + var +"_" + opt;
  110. hist = new TH1D(tmpTitle.c_str(), histName(particle, var, opt).c_str(), bins, low_edge, up_edge);
  111. hist->GetXaxis()->SetTitle(tmpName.c_str());
  112. hist->GetYaxis()->SetTitle(YaxisTitle.c_str());
  113. return;
  114. }
  115. void init_1D(TH1 *&hist, string particle, string var, string opt, string opt_plot, string YaxisTitle, int bins, const double *array){
  116. string tmpName = variableLatex(var) + "{"+ particleLatex(particle) +"}" + (opt_plot == "" ? "" : ": " + opt_plot);
  117. string tmpTitle = "h_" + particle + "_" + var + "_" +opt;
  118. hist = new TH1D(tmpTitle.c_str(), histName(particle, var, opt).c_str(),bins, array);
  119. hist->GetXaxis()->SetTitle(tmpName.c_str());
  120. hist->GetYaxis()->SetTitle(YaxisTitle.c_str());
  121. return;
  122. }
  123. void init_2D(TH2 *&hist, string particle, string varX, string varY, string opt, string YaxisTitle, string ZaxisTitle, int bins, double low_edge, double up_edge){
  124. string tmpXName = variableLatex(varX) + "{"+ particleLatex(particle) +"}";
  125. string tmpTitle = "h2_" + particle + "_" + varX +"_" + varY + "_" + opt;
  126. hist = new TH2D(tmpTitle.c_str(), histName(particle, varX, opt).c_str(),bins, low_edge, up_edge, bins, low_edge, up_edge);
  127. hist->GetXaxis()->SetTitle(tmpXName.c_str());
  128. YaxisTitle = YaxisTitle + variableLatex(varY) + "{"+ particleLatex(particle) +"}";
  129. hist->GetYaxis()->SetTitle(YaxisTitle.c_str());
  130. hist->GetZaxis()->SetTitle(ZaxisTitle.c_str());
  131. return;
  132. }
  133. void init_2D(TH2 *&hist, string particle, string varX, string varY, string opt, string YaxisTitle, string ZaxisTitle, int Xbins, double Xlow_edge, double Xup_edge, int Ybins, double Ylow_edge, double Yup_edge){
  134. string tmpName = variableLatex(varX) + "{"+ particleLatex(particle) +"}";
  135. string tmpTitle = "h2_" + particle + "_" + varX + "_" + varY + "_" + opt;
  136. hist = new TH2D(tmpTitle.c_str(), histName(particle, varX, opt).c_str(),Xbins, Xlow_edge, Xup_edge, Ybins, Ylow_edge, Yup_edge);
  137. hist->GetXaxis()->SetTitle(tmpName.c_str());
  138. YaxisTitle = YaxisTitle + variableLatex(varY) + "{"+ particleLatex(particle) +"}";
  139. hist->GetYaxis()->SetTitle(YaxisTitle.c_str());
  140. hist->GetZaxis()->SetTitle(ZaxisTitle.c_str());
  141. return;
  142. }
  143. void init_2D(TH2 *&hist, string particle, string varX, string varY, string opt, string YaxisTitle, string ZaxisTitle, int bins, const double *array){
  144. string tmpName = variableLatex(varX) + "{"+ particleLatex(particle) +"}";
  145. string tmpTitle = "h2_" + particle + "_" + varX + "_" +varY + "_" + opt;
  146. hist = new TH2D(tmpTitle.c_str(), histName(particle, varX, opt).c_str(),bins, array, bins, array);
  147. hist->GetXaxis()->SetTitle(tmpName.c_str());
  148. YaxisTitle = YaxisTitle + variableLatex(varY) + "{"+ particleLatex(particle) +"}";
  149. hist->GetYaxis()->SetTitle(YaxisTitle.c_str());
  150. hist->GetZaxis()->SetTitle(ZaxisTitle.c_str());
  151. return;
  152. }
  153. void init_2D(TH2 *&hist, string particle, string varX, string varY, string opt, string YaxisTitle, string ZaxisTitle, int Xbins, double *Xarray, int Ybins, double *Yarray){
  154. string tmpName = variableLatex(varX) + "{"+ particleLatex(particle) +"}";
  155. string tmpTitle = "h2_" + particle + "_" + varX+ "_" +varY + "_" + opt;
  156. hist = new TH2D(tmpTitle.c_str(), histName(particle, varX, opt).c_str(),Xbins, Xarray, Ybins, Yarray);
  157. hist->GetXaxis()->SetTitle(tmpName.c_str());
  158. YaxisTitle = YaxisTitle + variableLatex(varY) + "{"+ particleLatex(particle) +"}";
  159. hist->GetYaxis()->SetTitle(YaxisTitle.c_str());
  160. hist->GetZaxis()->SetTitle(ZaxisTitle.c_str());
  161. return;
  162. }
  163. void designCanvas(TCanvas* canvas){
  164. canvas->SetRightMargin(0.04);
  165. canvas->SetTopMargin(0.08);
  166. canvas->SetLeftMargin(0.14);
  167. canvas->SetBottomMargin(0.12);
  168. }
  169. void designCanvas2D(TCanvas* canvas){
  170. canvas->SetRightMargin(0.2);
  171. canvas->SetTopMargin(0.08);
  172. canvas->SetLeftMargin(0.12);
  173. canvas->SetBottomMargin(0.1);
  174. }
  175. void designPlots(TH1D *hist, int color){
  176. hist->SetLineWidth(2);
  177. hist->SetLineColor(color);
  178. hist->GetYaxis()->SetTitleOffset(1.7);
  179. hist->GetXaxis()->SetTitleOffset(1.0);
  180. hist->SetTitle("");
  181. }
  182. void designLegend(TLegend *leg, string legTitle, TH1D *hist, string opt){
  183. leg->SetTextSize(0.03);
  184. leg->SetHeader(legTitle.c_str());
  185. leg->AddEntry(hist,optionLatex(opt).c_str(),"l");
  186. }
  187. string output_path(string year, string magnet, bool MC = true, bool ReferenceChannel = false, bool PHSP = false){
  188. if(Kst2Kpluspi0Resolved){
  189. if(!MC){
  190. return Form("%s/resolution/data/%s%s/",path_to_output_KplusPizero.c_str(), year.c_str(),magnet.c_str());
  191. }
  192. else{
  193. if(ReferenceChannel){
  194. return Form("%s/resolution/MC/RefKplusPi0/%s%s/",path_to_output_KplusPizero.c_str(), year.c_str(),magnet.c_str());
  195. }
  196. else if(PHSP){
  197. return Form("%s/resolution/PHSP/KplusPi0/%s%s/",path_to_output_KplusPizero.c_str(), year.c_str(),magnet.c_str());
  198. }
  199. else{
  200. return Form("%s/resolution/MC/KplusPi0/%s%s/",path_to_output_KplusPizero.c_str(), year.c_str(),magnet.c_str());
  201. }
  202. }
  203. }
  204. }
  205. void design_pull(TH1 *pull, bool preselected, string year, string magnet, bool MC = true, bool ReferenceChannel = false, bool PHSP = false, bool truthMatched = false){
  206. string selection = preselected? "Preselected" : "Stripped";
  207. string name = output_path(year, magnet, MC, ReferenceChannel, PHSP) + pull->GetName() + "_" + selection;
  208. TCanvas *canvas = new TCanvas(Form("c_%s",pull->GetName()), "", 10,10,600,600);
  209. designCanvas(canvas);
  210. canvas->cd();
  211. //add two 3-sigma lines:
  212. TLine * lzero = new TLine(pull->GetXaxis()->GetXmin(), 0.,pull->GetXaxis()->GetXmin(), 0.);
  213. lzero->SetLineStyle(5);
  214. lzero->SetLineWidth(gStyle->GetLineWidth());
  215. pull->GetYaxis()->SetRangeUser(-1,1);
  216. pull->GetYaxis()->SetTitleOffset(1.4);
  217. pull->GetXaxis()->SetTitleOffset(1.6);
  218. pull->SetMarkerSize(1);
  219. pull->SetMarkerStyle(47);
  220. pull->SetMarkerColor(kCyan+2);
  221. pull->Draw("P");
  222. lzero->Draw("SAME");
  223. canvas->SaveAs((name+ (truthMatched ? "_TM" : "")+".eps").c_str(),"eps");
  224. canvas->Clear();
  225. delete canvas;
  226. }
  227. void design_fit(TH1 *hist, bool preselected, string year, string magnet, bool MC = true, bool ReferenceChannel = false, bool PHSP = false, bool truthMatched = false){
  228. string selection = preselected? "Preselected" : "Stripped";
  229. string name = output_path(year, magnet, MC, ReferenceChannel, PHSP) + hist->GetName() + "_" + selection;
  230. TCanvas *canvas = new TCanvas(Form("c_%s",hist->GetName()), "", 10,10,600,600);
  231. designCanvas(canvas);
  232. canvas->cd();
  233. if (name.find("Theta") != string::npos) {
  234. hist->GetYaxis()->SetRangeUser(-0.25,0.25);
  235. hist->GetYaxis()->SetTitleOffset(1.6);
  236. }
  237. else if (name.find("Phi") != string::npos) {
  238. hist->GetYaxis()->SetTitleOffset(1.6);
  239. hist->GetYaxis()->SetRangeUser(-0.25,0.25);
  240. }
  241. else{
  242. hist->GetYaxis()->SetTitleOffset(1.6);
  243. hist->GetYaxis()->SetRangeUser(-0.25,0.25);
  244. }
  245. hist->GetXaxis()->SetTitleOffset(1.4);
  246. hist->SetMarkerSize(1);
  247. hist->SetMarkerStyle(47);
  248. hist->SetMarkerColor(kCyan+2);
  249. hist->Draw("PE");
  250. canvas->SaveAs((name+ (truthMatched ? "_TM" : "")+".eps").c_str(),"eps");
  251. canvas->Clear();
  252. delete canvas;
  253. }
  254. void design_resolution(TH1 *res, bool preselected, string year, string magnet, bool MC = true, bool ReferenceChannel = false, bool PHSP = false, bool truthMatched = false){
  255. string name = res->GetName();
  256. TCanvas *canvas = new TCanvas(Form("c_%s",res->GetName()), "", 10,10,600,600);
  257. designCanvas(canvas);
  258. canvas->cd();
  259. if (name.find("Theta") != string::npos) {
  260. res->GetYaxis()->SetTitleOffset(1.6);
  261. res->GetYaxis()->SetRangeUser(0.0,0.05);
  262. }
  263. else if (name.find("Kplus") != string::npos) {
  264. res->GetYaxis()->SetTitleOffset(1.6);
  265. res->GetYaxis()->SetRangeUser(0.0,0.3);
  266. }
  267. else if (name.find("Phi") != string::npos) {
  268. res->GetYaxis()->SetTitleOffset(1.6);
  269. res->GetYaxis()->SetRangeUser(0.0,0.05);
  270. }
  271. else{
  272. res->GetYaxis()->SetTitleOffset(1.6);
  273. res->GetYaxis()->SetRangeUser(0.0,0.05);
  274. }
  275. res->GetXaxis()->SetTitleOffset(1.4);
  276. res->SetMarkerSize(1);
  277. res->SetMarkerStyle(47);
  278. res->SetMarkerColor(kCyan+2);
  279. res->Draw("PE");
  280. name = output_path(year, magnet, MC, ReferenceChannel, PHSP) + name + (preselected ? "_Preselected" : "_Stripped");
  281. canvas->SaveAs((name+ (truthMatched ? "_TM" : "")+".eps").c_str(),"eps");
  282. canvas->Clear();
  283. delete canvas;
  284. }
  285. void design_systematics(TH1 *sys, bool preselected, string year, string magnet, bool MC = true, bool ReferenceChannel = false, bool PHSP = false, bool truthMatched = false){
  286. string selection = preselected? "Preselected" : "Stripped";
  287. string name = output_path(year, magnet, MC, ReferenceChannel, PHSP) + sys->GetName() + "_" + selection;
  288. TCanvas *canvas = new TCanvas(Form("c_%s",sys->GetName()), "", 10,10,600,600);
  289. designCanvas(canvas);
  290. canvas->cd();
  291. if (name.find("Theta") != string::npos) {
  292. sys->GetYaxis()->SetRangeUser(-0.05,0.05);
  293. sys->GetYaxis()->SetTitleOffset(1.6);
  294. }
  295. else if (name.find("Phi") != string::npos) {
  296. sys->GetYaxis()->SetTitleOffset(1.6);
  297. sys->GetYaxis()->SetRangeUser(-0.05,0.05);
  298. }
  299. else{
  300. sys->GetYaxis()->SetTitleOffset(1.6);
  301. sys->GetYaxis()->SetRangeUser(-0.05,0.05);
  302. }
  303. sys->GetXaxis()->SetTitleOffset(1.4);
  304. sys->SetMarkerSize(1);
  305. sys->SetMarkerStyle(47);
  306. sys->SetMarkerColor(kCyan+2);
  307. sys->Draw("PE");
  308. canvas->SaveAs((name+ (truthMatched ? "_TM" : "")+".eps").c_str(),"eps");
  309. canvas->Clear();
  310. delete canvas;
  311. }
  312. void design_comparison(TH1 *rec, TH1 *trueMC, bool preselected, string year, string magnet, bool MC = true, bool ReferenceChannel = false, bool PHSP = false, bool truthMatched = false){
  313. string selection = preselected? "Preselected" : "Stripped";
  314. string name = output_path(year, magnet, MC, ReferenceChannel, PHSP) + rec->GetName() + "_" + selection;
  315. TCanvas *canvas = new TCanvas(Form("c_%s",rec->GetName()), "", 10,10,600,600);
  316. designCanvas(canvas);
  317. canvas->cd();
  318. //rec->GetYaxis()->SetRangeUser(-0.25,0.25);
  319. rec->GetYaxis()->SetTitleOffset(1.3);
  320. rec->GetXaxis()->SetTitleOffset(1.4);
  321. rec->SetLineColor(1);
  322. rec->SetLineWidth(3);
  323. //MC->GetYaxis()->SetRangeUser(-0.25,0.25);
  324. trueMC->GetYaxis()->SetTitleOffset(1.3);
  325. trueMC->GetXaxis()->SetTitleOffset(1.4);
  326. trueMC->SetLineColor(2);
  327. trueMC->SetLineWidth(3);
  328. trueMC->Draw("");
  329. rec->Draw("SAME");
  330. canvas->SaveAs((name + "_comparison" + (truthMatched ? "_TM" : "")+".eps").c_str(),"eps");
  331. canvas->Clear();
  332. delete canvas;
  333. }
  334. void design_corr(TH2 *corr, bool preselected, string year, string magnet, bool MC = true, bool ReferenceChannel = false, bool PHSP = false, bool truthMatched = false){
  335. string selection = preselected? "Preselected" : "Stripped";
  336. string name = output_path(year, magnet, MC, ReferenceChannel, PHSP) + corr->GetName() + "_" + selection;
  337. TCanvas *canvas = new TCanvas(Form("c_%s",corr->GetName()), "", 10,10,700,600);
  338. designCanvas2D(canvas);
  339. canvas->cd();
  340. corr->GetYaxis()->SetTitleOffset(1.5);
  341. corr->GetXaxis()->SetTitleOffset(1.0);
  342. corr->GetZaxis()->SetTitleOffset(1.25);
  343. corr->Draw("COLZ");
  344. canvas->SaveAs((name+ (truthMatched ? "_TM" : "")+".eps").c_str(),"eps");
  345. canvas->Clear();
  346. delete canvas;
  347. }
  348. void design_diff(TH2 *diff, bool preselected, string year, string magnet, bool MC = true, bool ReferenceChannel = false, bool PHSP = false, bool truthMatched = false){
  349. string selection = preselected? "Preselected" : "Stripped";
  350. string name = output_path(year, magnet, MC, ReferenceChannel, PHSP) + diff->GetName() + "_" + selection;
  351. TCanvas *canvas = new TCanvas(Form("c_%s",diff->GetName()), "", 10,10,700,600);
  352. designCanvas2D(canvas);
  353. canvas->cd();
  354. if (name.find("Theta") != string::npos) {
  355. diff->GetYaxis()->SetRangeUser(-0.5,0.5);
  356. }
  357. if (name.find("Phi") != string::npos) {
  358. diff->GetYaxis()->SetRangeUser(-0.5,0.5);
  359. }
  360. diff->GetYaxis()->SetTitleOffset(1.5);
  361. diff->GetXaxis()->SetTitleOffset(1.0);
  362. diff->GetZaxis()->SetTitleOffset(1.25);
  363. diff->Draw("COLZ");
  364. canvas->SaveAs((name+ (truthMatched ? "_TM" : "")+".eps").c_str(),"eps");
  365. canvas->Clear();
  366. delete canvas;
  367. }
  368. int ResPresel(std::string year = "2011", std::string magnet = "down",
  369. bool MC = true, bool ReferenceChannel = false, bool PHSP = false, bool preselected = true, bool truthMatched = true) {
  370. //no point in keepeng the MC option, but it doesn't hurt neither
  371. MC = true;
  372. TFile* output = 0;
  373. TChain *tree;
  374. if (!(MC || ReferenceChannel || PHSP)) truthMatched = false;
  375. if (!preselected){
  376. //Kst2Kpluspi0Resolved case
  377. if(Kst2Kpluspi0Resolved){
  378. if(!MC){
  379. tree=new TChain("b2KstKpi0mumuResolvedTuple/DecayTree");
  380. if(smallSample) tree->Add(Form("%s/data/%s%s/*B2Kstmumu*13.root",path_to_data.c_str(), year.c_str(),magnet.c_str()));
  381. else{
  382. tree->Add(Form("%s/data/%s%s/*.root",path_to_data.c_str(),year.c_str(),magnet.c_str()));
  383. std::cout << "Adding " << Form("%s/data/%s%s/*B2Kstmumu*.root",path_to_data.c_str(),year.c_str(),magnet.c_str()) << endl;
  384. }
  385. }
  386. else{
  387. tree=new TChain("b2KstKpi0mumuResolvedTuple/DecayTree");
  388. if(ReferenceChannel){
  389. if(smallSample) tree->Add(Form("%s/data/MC/RefKplusPi0/%s%s/*B2KstJpsi*1.root",path_to_data.c_str(), year.c_str(),magnet.c_str()));
  390. else tree->Add(Form("%s/data/MC/RefKplusPi0/%s%s/*B2KstJpsi*.root",path_to_data.c_str(), year.c_str(),magnet.c_str()));
  391. }
  392. else if(PHSP){
  393. if(smallSample) tree->Add(Form("%s/data/PHSP/KplusPi0/%s%s/*B2Kstmumu*1.root",path_to_data.c_str(), year.c_str(),magnet.c_str()));
  394. else tree->Add(Form("%s/data/PHSP/KplusPi0/%s%s/*B2Kstmumu*.root",path_to_data.c_str(), year.c_str(),magnet.c_str()));
  395. }
  396. else{
  397. if(smallSample) tree->Add(Form("%s/data/MC/KplusPi0/%s%s/*B2Kstmumu*1.root",path_to_data.c_str(), year.c_str(),magnet.c_str()));
  398. else tree->Add(Form("%s/data/MC/KplusPi0/%s%s/*B2Kstmumu*.root",path_to_data.c_str(), year.c_str(),magnet.c_str()));
  399. }
  400. }
  401. }
  402. //Kst2Kpluspi0Merged case
  403. if(Kst2Kpluspi0Merged){
  404. tree=new TChain("b2KstKpi0mumuMergedTuple/DecayTree");
  405. if(!MC){
  406. if(smallSample) tree->Add(Form("%s/data/%s%s/*B2Kstmumu*13.root",path_to_data.c_str(), year.c_str(),magnet.c_str()));
  407. else tree->Add(Form("%s/data/%s%s/*B2Kstmumu*.root",path_to_data.c_str(), year.c_str(),magnet.c_str()));
  408. }
  409. else{
  410. if(smallSample) tree->Add(Form("%s/data/MC/KplusPi0/%s%s/*B2Kstmumu*1.root",path_to_data.c_str(), year.c_str(),magnet.c_str()));
  411. else tree->Add(Form("%s/data/MC/KplusPi0/%s%s/*B2Kstmumu*.root",path_to_data.c_str(), year.c_str(),magnet.c_str()));
  412. }
  413. }
  414. //Kst2Kspiplus case
  415. if(Kst2Kspiplus){
  416. if(!MC){
  417. tree=new TChain("b2KstKs0pimumu_Tuple/DecayTree");
  418. if(smallSample) tree->Add(Form("%s/data/%s%s/*B2Kstmumu*23.root",path_to_data.c_str(), year.c_str(),magnet.c_str()));
  419. else tree->Add(Form("%s/data/%s%s/*B2Kstmumu*.root",path_to_data.c_str(), year.c_str(),magnet.c_str()));
  420. }
  421. else{
  422. tree=new TChain("b2KstKs0pimumu_Tuple/DecayTree");
  423. if(ReferenceChannel){
  424. if(smallSample) tree->Add(Form("%s/data/MC/RefKshortPiplus/%s%s/*B2KstJpsi*13.root",path_to_data.c_str(), year.c_str(),magnet.c_str()));
  425. else tree->Add(Form("%s/data/MC/RefKshortPiplus/%s%s/*B2KstJpsi*.root",path_to_data.c_str(), year.c_str(),magnet.c_str()));
  426. }
  427. else if(PHSP){
  428. if(smallSample) tree->Add(Form("%s/data/PHSP/KshortPiplus/%s%s/*B2Kstmumu*1.root",path_to_data.c_str(), year.c_str(),magnet.c_str()));
  429. else tree->Add(Form("%s/data/PHSP/KshortPiplus/%s%s/*B2Kstmumu*.root",path_to_data.c_str(), year.c_str(),magnet.c_str()));
  430. }
  431. else{
  432. if(smallSample) tree->Add(Form("%s/data/MC/KshortPiplus/%s%s/*B2Kstmumu*1.root",path_to_data.c_str(), year.c_str(),magnet.c_str()));
  433. else tree->Add(Form("%s/data/MC/KshortPiplus/%s%s/*B2Kstmumu*.root",path_to_data.c_str(), year.c_str(),magnet.c_str()));
  434. }
  435. }
  436. }
  437. }
  438. else{ //preselected
  439. string name = (truthMatched ? "DecayTreeTruthMatched" : "DecayTree");
  440. tree=new TChain(name.c_str());
  441. // Kst2Kpluspi0Resolved case
  442. if(Kst2Kpluspi0Resolved){
  443. if(!MC){
  444. tree->Add(Form("%s/data/%s%s/%s%s_pi0Resolved.root",path_to_output_KplusPizero.c_str(), year.c_str(),magnet.c_str(),year.c_str(),magnet.c_str()));
  445. cout << Form("%s/data/%s%s/%s%s_pi0Resolved.root",path_to_output_KplusPizero.c_str(), year.c_str(),magnet.c_str(),year.c_str(),magnet.c_str()) << endl;
  446. }
  447. else{
  448. if(ReferenceChannel){
  449. tree->Add(Form("%s/data/MC/RefKplusPi0/%s%s/%s%s_pi0Resolved.root",path_to_output_KplusPizero.c_str(), year.c_str(),magnet.c_str(),year.c_str(),magnet.c_str()));
  450. }
  451. else if(PHSP){
  452. tree->Add(Form("%s/data/PHSP/KplusPi0/%s%s/%s%s_pi0Resolved.root",path_to_output_KplusPizero.c_str(), year.c_str(),magnet.c_str(),year.c_str(),magnet.c_str()));
  453. }
  454. else{
  455. tree->Add(Form("%s/data/MC/KplusPi0/%s%s/%s%s_pi0Resolved.root",path_to_output_KplusPizero.c_str(), year.c_str(),magnet.c_str(),year.c_str(),magnet.c_str()));
  456. }
  457. }
  458. }
  459. // Kst2Kpluspi0Merged case
  460. if(Kst2Kpluspi0Merged){
  461. if(!MC){
  462. tree->Add(Form("%s/data/%s%s/%s%s_pi0Merged.root",path_to_output_KplusPizero.c_str(), year.c_str(),magnet.c_str(),year.c_str(),magnet.c_str()));
  463. }
  464. else{
  465. if(ReferenceChannel){
  466. tree->Add(Form("%s/data/MC/RefKplusPi0/%s%s/%s%s_pi0Merged.root",path_to_output_KplusPizero.c_str(), year.c_str(),magnet.c_str(),year.c_str(),magnet.c_str()));
  467. }
  468. else if(PHSP){
  469. tree->Add(Form("%s/data/PHSP/KplusPi0/%s%s/%s%s_pi0Merged.root",path_to_output_KplusPizero.c_str(), year.c_str(),magnet.c_str(),year.c_str(),magnet.c_str()));
  470. }
  471. else{
  472. tree->Add(Form("%s/data/MC/KplusPi0/%s%s/%s%s_pi0Mergedroot",path_to_output_KplusPizero.c_str(), year.c_str(),magnet.c_str(),year.c_str(),magnet.c_str()));
  473. }
  474. }
  475. }
  476. // Kst2Kspiplus case
  477. if(Kst2Kspiplus){
  478. if(!MC){
  479. tree->Add(Form("%s/data/%s%s/%s%s_piplus.root",path_to_output_KshortPiplus.c_str(), year.c_str(),magnet.c_str(),year.c_str(),magnet.c_str()));
  480. }
  481. else{
  482. if(ReferenceChannel){
  483. tree->Add(Form("%s/data/MC/RefKshortPiplus/%s%s/%s%s_piplus.root",path_to_output_KshortPiplus.c_str(), year.c_str(),magnet.c_str(),year.c_str(),magnet.c_str()));
  484. }
  485. else if(PHSP){
  486. tree->Add(Form("%s/data/PHSP/KshortPiplus/%s%s/%s%s_piplus.root",path_to_output_KshortPiplus.c_str(), year.c_str(),magnet.c_str(),year.c_str(),magnet.c_str()));
  487. }
  488. else{
  489. tree->Add(Form("%s/data/MC/KshortPiplus/%s%s/%s%s_piplus.root",path_to_output_KshortPiplus.c_str(), year.c_str(),magnet.c_str(),year.c_str(),magnet.c_str()));
  490. }
  491. }
  492. }
  493. }
  494. int N = tree->GetEntries();
  495. if(N == 0){
  496. std::cout << "[ERROR]\t\tNo events found!" << std::endl;
  497. return 0;
  498. }
  499. /////////////////////
  500. // Detector values //
  501. /////////////////////
  502. TLorentzVector LorVec_B_plus;
  503. TLorentzVector LorVec_K_star_plus;
  504. TLorentzVector LorVec_K_plus;
  505. TLorentzVector LorVec_pi_zero_merged;
  506. TLorentzVector LorVec_pi_zero_resolved;
  507. TLorentzVector LorVec_K_short;
  508. TLorentzVector LorVec_pi_plus;
  509. TLorentzVector LorVec_KS_pi_plus;
  510. TLorentzVector LorVec_KS_pi_minus;
  511. TLorentzVector LorVec_mu_minus;
  512. TLorentzVector LorVec_mu_plus;
  513. TLorentzVector LorVec_gamma1;
  514. TLorentzVector LorVec_gamma2;
  515. TLorentzVector LorVec_DiGamma;
  516. //potentially misIDed particles:
  517. TLorentzVector LorVec_pi_plus_MisIDed;
  518. TLorentzVector LorVec_mu_plus_MisIDed;
  519. TLorentzVector LorVec_B_plus_From_DoubleMisIDed;
  520. TLorentzVector LorVec_Jpsi_From_DoubleMisIDed;
  521. TLorentzVector LorVec_K_star_plus_From_DoubleMisIDed;
  522. //recombined particles:
  523. TLorentzVector LorVec_DiMuon;
  524. TLorentzVector LorVec_KaonPion;
  525. TLorentzVector LorVec_ReconB;
  526. TLorentzVector LorVec_ReconBPiZero;
  527. TLorentzVector LorVec_KshortMuMu;
  528. TLorentzVector LorVec_KplusMuMu;
  529. //Other variables:
  530. Double_t OpenAngle;
  531. /////////////////////
  532. // DTF values //
  533. /////////////////////
  534. TLorentzVector LorVec_DTF_B_plus;
  535. TLorentzVector LorVec_DTF_K_star_plus;
  536. TLorentzVector LorVec_DTF_K_plus;
  537. TLorentzVector LorVec_DTF_pi_zero_merged;
  538. TLorentzVector LorVec_DTF_pi_zero_resolved;
  539. TLorentzVector LorVec_DTF_K_short;
  540. TLorentzVector LorVec_DTF_pi_plus;
  541. TLorentzVector LorVec_DTF_KS_pi_plus;
  542. TLorentzVector LorVec_DTF_KS_pi_minus;
  543. TLorentzVector LorVec_DTF_mu_minus;
  544. TLorentzVector LorVec_DTF_mu_plus;
  545. TLorentzVector LorVec_DTF_gamma1;
  546. TLorentzVector LorVec_DTF_gamma2;
  547. TLorentzVector LorVec_DTF_DiGamma;
  548. //potentially misIDed particles:
  549. TLorentzVector LorVec_DTF_pi_plus_MisIDed;
  550. TLorentzVector LorVec_DTF_mu_plus_MisIDed;
  551. TLorentzVector LorVec_DTF_B_plus_From_DoubleMisIDed;
  552. TLorentzVector LorVec_DTF_Jpsi_From_DoubleMisIDed;
  553. TLorentzVector LorVec_DTF_K_star_plus_From_DoubleMisIDed;
  554. //recombined particles:
  555. TLorentzVector LorVec_DTF_DiMuon;
  556. TLorentzVector LorVec_DTF_KaonPion;
  557. TLorentzVector LorVec_DTF_ReconB;
  558. TLorentzVector LorVec_DTF_ReconBPiZero;
  559. TLorentzVector LorVec_DTF_KshortMuMu;
  560. TLorentzVector LorVec_DTF_KplusMuMu;
  561. //Other variables:
  562. Double_t OpenAngle_DTF;
  563. /////////////////////
  564. // TRUE values //
  565. /////////////////////
  566. TLorentzVector LorVec_TRUE_B_plus;
  567. TLorentzVector LorVec_TRUE_K_star_plus;
  568. TLorentzVector LorVec_TRUE_K_plus;
  569. TLorentzVector LorVec_TRUE_pi_zero_merged;
  570. TLorentzVector LorVec_TRUE_pi_zero_resolved;
  571. TLorentzVector LorVec_TRUE_K_short;
  572. TLorentzVector LorVec_TRUE_pi_plus;
  573. TLorentzVector LorVec_TRUE_KS_pi_plus;
  574. TLorentzVector LorVec_TRUE_KS_pi_minus;
  575. TLorentzVector LorVec_TRUE_mu_minus;
  576. TLorentzVector LorVec_TRUE_mu_plus;
  577. TLorentzVector LorVec_TRUE_gamma1;
  578. TLorentzVector LorVec_TRUE_gamma2;
  579. TLorentzVector LorVec_TRUE_DiGamma;
  580. //potentially misIDed particles:
  581. TLorentzVector LorVec_TRUE_pi_plus_MisIDed;
  582. TLorentzVector LorVec_TRUE_mu_plus_MisIDed;
  583. TLorentzVector LorVec_TRUE_B_plus_From_DoubleMisIDed;
  584. TLorentzVector LorVec_TRUE_Jpsi_From_DoubleMisIDed;
  585. TLorentzVector LorVec_TRUE_K_star_plus_From_DoubleMisIDed;
  586. //recombined particles:
  587. TLorentzVector LorVec_TRUE_DiMuon;
  588. TLorentzVector LorVec_TRUE_KaonPion;
  589. //Other variables:
  590. Double_t OpenAngle_TRUE;
  591. /////////////////////
  592. // Branches //
  593. /////////////////////
  594. ///B+
  595. Double_t B_plus_PX = 0.;
  596. Double_t B_plus_PY = 0.;
  597. Double_t B_plus_PZ = 0.;
  598. Double_t B_plus_PT = 0.;
  599. Double_t B_plus_PE = 0.;
  600. Double_t B_plus_ETA = 0.;
  601. Double_t B_plus_PHI = 0.;
  602. Double_t B_plus_TRUE_PX = 0.;
  603. Double_t B_plus_TRUE_PY = 0.;
  604. Double_t B_plus_TRUE_PZ = 0.;
  605. Double_t B_plus_TRUE_PT = 0.;
  606. Double_t B_plus_TRUE_PE = 0.;
  607. Double_t B_plus_TRUE_ETA = 0.;
  608. Double_t B_plus_TRUE_PHI = 0.;
  609. Double_t B_plus_PX_DTF = 0.;
  610. Double_t B_plus_PY_DTF = 0.;
  611. Double_t B_plus_PZ_DTF = 0.;
  612. Double_t B_plus_PT_DTF = 0.;
  613. Double_t B_plus_PE_DTF = 0.;
  614. Double_t B_plus_ETA_DTF = 0.;
  615. Double_t B_plus_PHI_DTF = 0.;
  616. ///K*+
  617. Double_t K_star_plus_PX = 0.;
  618. Double_t K_star_plus_PY = 0.;
  619. Double_t K_star_plus_PZ = 0.;
  620. Double_t K_star_plus_PT = 0.;
  621. Double_t K_star_plus_PE = 0.;
  622. Double_t K_star_plus_ETA = 0.;
  623. Double_t K_star_plus_PHI = 0.;
  624. Double_t K_star_plus_TRUE_PX = 0.;
  625. Double_t K_star_plus_TRUE_PY = 0.;
  626. Double_t K_star_plus_TRUE_PZ = 0.;
  627. Double_t K_star_plus_TRUE_PT = 0.;
  628. Double_t K_star_plus_TRUE_PE = 0.;
  629. Double_t K_star_plus_TRUE_ETA = 0.;
  630. Double_t K_star_plus_TRUE_PHI = 0.;
  631. Double_t K_star_plus_PX_DTF = 0.;
  632. Double_t K_star_plus_PY_DTF = 0.;
  633. Double_t K_star_plus_PZ_DTF = 0.;
  634. Double_t K_star_plus_PT_DTF = 0.;
  635. Double_t K_star_plus_PE_DTF = 0.;
  636. Double_t K_star_plus_ETA_DTF = 0.;
  637. Double_t K_star_plus_PHI_DTF = 0.;
  638. ///K+
  639. Double_t K_plus_PX = 0.;
  640. Double_t K_plus_PY = 0.;
  641. Double_t K_plus_PZ = 0.;
  642. Double_t K_plus_PT = 0.;
  643. Double_t K_plus_PE = 0.;
  644. Double_t K_plus_ETA = 0.;
  645. Double_t K_plus_PHI = 0.;
  646. Double_t K_plus_TRUE_PX = 0.;
  647. Double_t K_plus_TRUE_PY = 0.;
  648. Double_t K_plus_TRUE_PZ = 0.;
  649. Double_t K_plus_TRUE_PT = 0.;
  650. Double_t K_plus_TRUE_PE = 0.;
  651. Double_t K_plus_TRUE_ETA = 0.;
  652. Double_t K_plus_TRUE_PHI = 0.;
  653. Double_t K_plus_PX_DTF = 0.;
  654. Double_t K_plus_PY_DTF = 0.;
  655. Double_t K_plus_PZ_DTF = 0.;
  656. Double_t K_plus_PE_DTF = 0.;
  657. Double_t K_plus_PT_DTF = 0.;
  658. Double_t K_plus_ETA_DTF = 0.;
  659. Double_t K_plus_PHI_DTF = 0.;
  660. Float_t f_K_plus_PX_DTF[100];
  661. Float_t f_K_plus_PY_DTF[100];
  662. Float_t f_K_plus_PZ_DTF[100];
  663. Float_t f_K_plus_PE_DTF[100];
  664. ///pi0 (merged)
  665. Double_t pi_zero_merged_PX = 0.;
  666. Double_t pi_zero_merged_PY = 0.;
  667. Double_t pi_zero_merged_PZ = 0.;
  668. Double_t pi_zero_merged_PT = 0.;
  669. Double_t pi_zero_merged_PE = 0.;
  670. Double_t pi_zero_merged_ETA = 0.;
  671. Double_t pi_zero_merged_PHI = 0.;
  672. Double_t pi_zero_merged_TRUE_PX = 0.;
  673. Double_t pi_zero_merged_TRUE_PY = 0.;
  674. Double_t pi_zero_merged_TRUE_PZ = 0.;
  675. Double_t pi_zero_merged_TRUE_PT = 0.;
  676. Double_t pi_zero_merged_TRUE_PE = 0.;
  677. Double_t pi_zero_merged_TRUE_ETA = 0.;
  678. Double_t pi_zero_merged_TRUE_PHI = 0.;
  679. Double_t pi_zero_merged_PX_DTF = 0.;
  680. Double_t pi_zero_merged_PY_DTF = 0.;
  681. Double_t pi_zero_merged_PZ_DTF = 0.;
  682. Double_t pi_zero_merged_PT_DTF = 0.;
  683. Double_t pi_zero_merged_PE_DTF = 0.;
  684. Double_t pi_zero_merged_ETA_DTF = 0.;
  685. Double_t pi_zero_merged_PHI_DTF = 0.;
  686. ///pi0 (resolved)
  687. Double_t pi_zero_resolved_PX = 0.;
  688. Double_t pi_zero_resolved_PY = 0.;
  689. Double_t pi_zero_resolved_PZ = 0.;
  690. Double_t pi_zero_resolved_PT = 0.;
  691. Double_t pi_zero_resolved_PE = 0.;
  692. Double_t pi_zero_resolved_ETA = 0.;
  693. Double_t pi_zero_resolved_PHI = 0.;
  694. Double_t pi_zero_resolved_TRUE_PX = 0.;
  695. Double_t pi_zero_resolved_TRUE_PY = 0.;
  696. Double_t pi_zero_resolved_TRUE_PZ = 0.;
  697. Double_t pi_zero_resolved_TRUE_PT = 0.;
  698. Double_t pi_zero_resolved_TRUE_PE = 0.;
  699. Double_t pi_zero_resolved_TRUE_ETA = 0.;
  700. Double_t pi_zero_resolved_TRUE_PHI = 0.;
  701. Double_t pi_zero_resolved_PX_DTF = 0.;
  702. Double_t pi_zero_resolved_PY_DTF = 0.;
  703. Double_t pi_zero_resolved_PZ_DTF = 0.;
  704. Double_t pi_zero_resolved_PT_DTF = 0.;
  705. Double_t pi_zero_resolved_PE_DTF = 0.;
  706. Double_t pi_zero_resolved_ETA_DTF = 0.;
  707. Double_t pi_zero_resolved_PHI_DTF = 0.;
  708. ///Kshort
  709. Double_t K_short_PX = 0.;
  710. Double_t K_short_PY = 0.;
  711. Double_t K_short_PZ = 0.;
  712. Double_t K_short_PT = 0.;
  713. Double_t K_short_PE = 0.;
  714. Double_t K_short_ETA = 0.;
  715. Double_t K_short_PHI = 0.;
  716. Double_t K_short_TRUE_PX = 0.;
  717. Double_t K_short_TRUE_PY = 0.;
  718. Double_t K_short_TRUE_PZ = 0.;
  719. Double_t K_short_TRUE_PT = 0.;
  720. Double_t K_short_TRUE_PE = 0.;
  721. Double_t K_short_TRUE_ETA = 0.;
  722. Double_t K_short_TRUE_PHI = 0.;
  723. Double_t K_short_PX_DTF = 0.;
  724. Double_t K_short_PY_DTF = 0.;
  725. Double_t K_short_PZ_DTF = 0.;
  726. Double_t K_short_PT_DTF = 0.;
  727. Double_t K_short_PE_DTF = 0.;
  728. Double_t K_short_ETA_DTF = 0.;
  729. Double_t K_short_PHI_DTF = 0.;
  730. Float_t f_K_short_M_DTF[100];
  731. Double_t K_short_M_DTF = 0.;
  732. ///pi+ (KS)
  733. Double_t Ks_pi_plus_PX = 0.;
  734. Double_t Ks_pi_plus_PY = 0.;
  735. Double_t Ks_pi_plus_PZ = 0.;
  736. Double_t Ks_pi_plus_PT = 0.;
  737. Double_t Ks_pi_plus_PE = 0.;
  738. Double_t Ks_pi_plus_ETA = 0.;
  739. Double_t Ks_pi_plus_PHI = 0.;
  740. Double_t Ks_pi_plus_TRUE_PX = 0.;
  741. Double_t Ks_pi_plus_TRUE_PY = 0.;
  742. Double_t Ks_pi_plus_TRUE_PZ = 0.;
  743. Double_t Ks_pi_plus_TRUE_PT = 0.;
  744. Double_t Ks_pi_plus_TRUE_PE = 0.;
  745. Double_t Ks_pi_plus_TRUE_ETA = 0.;
  746. Double_t Ks_pi_plus_TRUE_PHI = 0.;
  747. Float_t f_Ks_pi_plus_PX_DTF[100];
  748. Float_t f_Ks_pi_plus_PY_DTF[100];
  749. Float_t f_Ks_pi_plus_PZ_DTF[100];
  750. Float_t f_Ks_pi_plus_PT_DTF[100];
  751. Float_t f_Ks_pi_plus_PE_DTF[100];
  752. Float_t f_Ks_pi_plus_ID_DTF[100];
  753. Double_t Ks_pi_plus_PX_DTF = 0.;
  754. Double_t Ks_pi_plus_PY_DTF = 0.;
  755. Double_t Ks_pi_plus_PZ_DTF = 0.;
  756. Double_t Ks_pi_plus_PT_DTF = 0.;
  757. Double_t Ks_pi_plus_PE_DTF = 0.;
  758. Double_t Ks_pi_plus_ETA_DTF = 0.;
  759. Double_t Ks_pi_plus_PHI_DTF = 0.;
  760. ///pi- (KS)
  761. Double_t Ks_pi_minus_PX = 0.;
  762. Double_t Ks_pi_minus_PY = 0.;
  763. Double_t Ks_pi_minus_PZ = 0.;
  764. Double_t Ks_pi_minus_PT = 0.;
  765. Double_t Ks_pi_minus_PE = 0.;
  766. Double_t Ks_pi_minus_ETA = 0.;
  767. Double_t Ks_pi_minus_PHI = 0.;
  768. Double_t Ks_pi_minus_TRUE_PX = 0.;
  769. Double_t Ks_pi_minus_TRUE_PY = 0.;
  770. Double_t Ks_pi_minus_TRUE_PZ = 0.;
  771. Double_t Ks_pi_minus_TRUE_PT = 0.;
  772. Double_t Ks_pi_minus_TRUE_PE = 0.;
  773. Double_t Ks_pi_minus_TRUE_ETA = 0.;
  774. Double_t Ks_pi_minus_TRUE_PHI = 0.;
  775. Float_t f_Ks_pi_minus_PX_DTF[100];
  776. Float_t f_Ks_pi_minus_PY_DTF[100];
  777. Float_t f_Ks_pi_minus_PZ_DTF[100];
  778. Float_t f_Ks_pi_minus_PT_DTF[100];
  779. Float_t f_Ks_pi_minus_PE_DTF[100];
  780. Float_t f_Ks_pi_minus_ID_DTF[100];
  781. Double_t Ks_pi_minus_PX_DTF = 0.;
  782. Double_t Ks_pi_minus_PY_DTF = 0.;
  783. Double_t Ks_pi_minus_PZ_DTF = 0.;
  784. Double_t Ks_pi_minus_PT_DTF = 0.;
  785. Double_t Ks_pi_minus_PE_DTF = 0.;
  786. Double_t Ks_pi_minus_ETA_DTF = 0.;
  787. Double_t Ks_pi_minus_PHI_DTF = 0.;
  788. ///pi+
  789. Double_t pi_plus_PX = 0.;
  790. Double_t pi_plus_PY = 0.;
  791. Double_t pi_plus_PZ = 0.;
  792. Double_t pi_plus_PT = 0.;
  793. Double_t pi_plus_PE = 0.;
  794. Double_t pi_plus_ETA = 0.;
  795. Double_t pi_plus_PHI = 0.;
  796. Double_t pi_plus_TRUE_PX = 0.;
  797. Double_t pi_plus_TRUE_PY = 0.;
  798. Double_t pi_plus_TRUE_PZ = 0.;
  799. Double_t pi_plus_TRUE_PT = 0.;
  800. Double_t pi_plus_TRUE_PE = 0.;
  801. Double_t pi_plus_TRUE_ETA = 0.;
  802. Double_t pi_plus_TRUE_PHI = 0.;
  803. Float_t f_pi_plus_PX_DTF[100];
  804. Float_t f_pi_plus_PY_DTF[100];
  805. Float_t f_pi_plus_PZ_DTF[100];
  806. Float_t f_pi_plus_PE_DTF[100];
  807. Float_t f_pi_plus_PT_DTF[100];
  808. Float_t f_pi_plus_ID_DTF[100];
  809. Double_t pi_plus_PX_DTF = 0.;
  810. Double_t pi_plus_PY_DTF = 0.;
  811. Double_t pi_plus_PZ_DTF = 0.;
  812. Double_t pi_plus_PT_DTF = 0.;
  813. Double_t pi_plus_PE_DTF = 0.;
  814. Double_t pi_plus_ETA_DTF = 0.;
  815. Double_t pi_plus_PHI_DTF = 0.;
  816. ///mu+
  817. Double_t mu_minus_PX = 0.;
  818. Double_t mu_minus_PY = 0.;
  819. Double_t mu_minus_PZ = 0.;
  820. Double_t mu_minus_PT = 0.;
  821. Double_t mu_minus_PE = 0.;
  822. Double_t mu_minus_ETA = 0.;
  823. Double_t mu_minus_PHI = 0.;
  824. Double_t mu_minus_TRUE_PX = 0.;
  825. Double_t mu_minus_TRUE_PY = 0.;
  826. Double_t mu_minus_TRUE_PZ = 0.;
  827. Double_t mu_minus_TRUE_PT = 0.;
  828. Double_t mu_minus_TRUE_PE = 0.;
  829. Double_t mu_minus_TRUE_ETA = 0.;
  830. Double_t mu_minus_TRUE_PHI = 0.;
  831. Double_t mu_minus_PX_DTF = 0.;
  832. Double_t mu_minus_PY_DTF = 0.;
  833. Double_t mu_minus_PZ_DTF = 0.;
  834. Double_t mu_minus_PT_DTF = 0.;
  835. Double_t mu_minus_PE_DTF = 0.;
  836. Double_t mu_minus_ETA_DTF = 0.;
  837. Double_t mu_minus_PHI_DTF = 0.;
  838. Float_t f_mu_minus_PX_DTF[100];
  839. Float_t f_mu_minus_PY_DTF[100];
  840. Float_t f_mu_minus_PZ_DTF[100];
  841. Float_t f_mu_minus_PT_DTF[100];
  842. Float_t f_mu_minus_PE_DTF[100];
  843. ///mu+
  844. Double_t mu_plus_PX = 0.;
  845. Double_t mu_plus_PY = 0.;
  846. Double_t mu_plus_PZ = 0.;
  847. Double_t mu_plus_PT = 0.;
  848. Double_t mu_plus_PE = 0.;
  849. Double_t mu_plus_ETA = 0.;
  850. Double_t mu_plus_PHI = 0.;
  851. Double_t mu_plus_TRUE_PX = 0.;
  852. Double_t mu_plus_TRUE_PY = 0.;
  853. Double_t mu_plus_TRUE_PZ = 0.;
  854. Double_t mu_plus_TRUE_PT = 0.;
  855. Double_t mu_plus_TRUE_PE = 0.;
  856. Double_t mu_plus_TRUE_ETA = 0.;
  857. Double_t mu_plus_TRUE_PHI = 0.;
  858. Double_t mu_plus_PX_DTF = 0.;
  859. Double_t mu_plus_PY_DTF = 0.;
  860. Double_t mu_plus_PZ_DTF = 0.;
  861. Double_t mu_plus_PT_DTF = 0.;
  862. Double_t mu_plus_PE_DTF = 0.;
  863. Double_t mu_plus_ETA_DTF = 0.;
  864. Double_t mu_plus_PHI_DTF = 0.;
  865. Float_t f_mu_plus_PX_DTF[100];
  866. Float_t f_mu_plus_PY_DTF[100];
  867. Float_t f_mu_plus_PZ_DTF[100];
  868. Float_t f_mu_plus_PE_DTF[100];
  869. ///gamma1
  870. Double_t gamma1_PX = 0.;
  871. Double_t gamma1_PY = 0.;
  872. Double_t gamma1_PZ = 0.;
  873. Double_t gamma1_PT = 0.;
  874. Double_t gamma1_PE = 0.;
  875. Double_t gamma1_ETA = 0.;
  876. Double_t gamma1_PHI = 0.;
  877. Double_t gamma1_TRUE_PX = 0.;
  878. Double_t gamma1_TRUE_PY = 0.;
  879. Double_t gamma1_TRUE_PZ = 0.;
  880. Double_t gamma1_TRUE_PT = 0.;
  881. Double_t gamma1_TRUE_PE = 0.;
  882. Double_t gamma1_TRUE_ETA = 0.;
  883. Double_t gamma1_TRUE_PHI = 0.;
  884. Double_t gamma1_PX_DTF = 0.;
  885. Double_t gamma1_PY_DTF = 0.;
  886. Double_t gamma1_PZ_DTF = 0.;
  887. Double_t gamma1_PT_DTF = 0.;
  888. Double_t gamma1_PE_DTF = 0.;
  889. Double_t gamma1_ETA_DTF = 0.;
  890. Double_t gamma1_PHI_DTF = 0.;
  891. Float_t f_gamma1_PX_DTF[100];
  892. Float_t f_gamma1_PY_DTF[100];
  893. Float_t f_gamma1_PZ_DTF[100];
  894. Float_t f_gamma1_PE_DTF[100];
  895. ///gamma2
  896. Double_t gamma2_PX = 0.;
  897. Double_t gamma2_PY = 0.;
  898. Double_t gamma2_PZ = 0.;
  899. Double_t gamma2_PT = 0.;
  900. Double_t gamma2_PE = 0.;
  901. Double_t gamma2_ETA = 0.;
  902. Double_t gamma2_PHI = 0.;
  903. Double_t gamma2_PX_DTF = 0.;
  904. Double_t gamma2_PY_DTF = 0.;
  905. Double_t gamma2_PZ_DTF = 0.;
  906. Double_t gamma2_PT_DTF = 0.;
  907. Double_t gamma2_PE_DTF = 0.;
  908. Double_t gamma2_ETA_DTF = 0.;
  909. Double_t gamma2_PHI_DTF = 0.;
  910. Double_t gamma2_TRUE_PX = 0.;
  911. Double_t gamma2_TRUE_PY = 0.;
  912. Double_t gamma2_TRUE_PZ = 0.;
  913. Double_t gamma2_TRUE_PT = 0.;
  914. Double_t gamma2_TRUE_PE = 0.;
  915. Double_t gamma2_TRUE_ETA = 0.;
  916. Double_t gamma2_TRUE_PHI = 0.;
  917. Float_t f_gamma2_PX_DTF[100];
  918. Float_t f_gamma2_PY_DTF[100];
  919. Float_t f_gamma2_PZ_DTF[100];
  920. Float_t f_gamma2_PE_DTF[100];
  921. //angles
  922. Double_t B_plus_ThetaL = 0.;
  923. Double_t B_plus_ThetaK = 0.;
  924. Double_t B_plus_Phi = 0.;
  925. Double_t B_plus_ThetaL_DTF = 0.;
  926. Double_t B_plus_ThetaK_DTF = 0.;
  927. Double_t B_plus_Phi_DTF = 0.;
  928. Double_t B_plus_TRUE_ThetaL = 0.;
  929. Double_t B_plus_TRUE_ThetaK = 0.;
  930. Double_t B_plus_TRUE_Phi = 0.;
  931. Double_t open_angle = 0.;
  932. Double_t open_angle_DTF = 0.;
  933. Double_t TRUE_open_angle = 0.;
  934. //global variables
  935. Double_t B_plus_ENDVERTEX_Z = 0.;
  936. Double_t B_plus_ENDVERTEX_ZERR = 0.;
  937. Double_t B_plus_OWNPV_Z = 0.;
  938. Double_t B_plus_OWNPV_ZERR = 0.;
  939. Double_t B_plus_TRUEORIGINVERTEX_Z = 0.;
  940. Double_t B_plus_TRUEENDVERTEX_Z = 0.;
  941. Double_t B_plus_TOPPV_Z = 0.;//TODO: what is this?
  942. Float_t f_B_plus_DTF_PV_Z[100];
  943. Double_t B_plus_DTF_PV_Z = 0.;
  944. Double_t K_star_plus_ENDVERTEX_Z = 0.;
  945. Double_t K_star_plus_ENDVERTEX_ZERR = 0.;
  946. Double_t K_star_plus_OWNPV_Z = 0.;
  947. Double_t K_star_plus_OWNPV_ZERR = 0.;
  948. Double_t K_star_plus_TRUEORIGINVERTEX_Z = 0.;
  949. Double_t K_star_plus_TRUEENDVERTEX_Z = 0.;
  950. Double_t K_plus_OWNPV_Z = 0.;
  951. Double_t K_plus_OWNPV_ZERR = 0.;
  952. Double_t K_plus_TRUEORIGINVERTEX_Z = 0.;
  953. Double_t K_plus_TRUEENDVERTEX_Z = 0.;
  954. Double_t pi_zero_resolved_TRUEORIGINVERTEX_Z = 0.;
  955. Double_t pi_zero_resolved_TRUEENDVERTEX_Z = 0.;
  956. Double_t gamma1_TRUEORIGINVERTEX_Z = 0.;
  957. Double_t gamma1_TRUEENDVERTEX_Z = 0.;
  958. Double_t gamma2_TRUEORIGINVERTEX_Z = 0.;
  959. Double_t gamma2_TRUEENDVERTEX_Z = 0.;
  960. Double_t mu_plus_OWNPV_Z = 0.;
  961. Double_t mu_plus_OWNPV_ZERR = 0.;
  962. Double_t mu_plus_TRUEORIGINVERTEX_Z = 0.;
  963. Double_t mu_plus_TRUEENDVERTEX_Z = 0.;
  964. Double_t mu_minus_OWNPV_Z = 0.;
  965. Double_t mu_minus_OWNPV_ZERR = 0.;
  966. Double_t mu_minus_TRUEORIGINVERTEX_Z = 0.;
  967. Double_t mu_minus_TRUEENDVERTEX_Z = 0.;
  968. tree->SetBranchStatus("*",0);
  969. tree->SetBranchStatus( "*P", 1 );
  970. tree->SetBranchStatus( "*PX", 1 );
  971. tree->SetBranchStatus( "*PY", 1);
  972. tree->SetBranchStatus( "*PZ", 1);
  973. tree->SetBranchStatus( "*PE", 1);
  974. tree->SetBranchStatus( "*PT", 1 );
  975. tree->SetBranchStatus( "*TRUEP*", 1 );
  976. tree->SetBranchStatus( "*ETA*", 1 );
  977. tree->SetBranchStatus( "*PHI", 1 );
  978. tree->SetBranchStatus( "*Phi",1 );
  979. tree->SetBranchStatus( "*ThetaL",1 );
  980. tree->SetBranchStatus( "*ThetaK",1 );
  981. tree->SetBranchStatus("*ENDVERTEX_Z*",1);
  982. tree->SetBranchStatus("*OWNPV_Z*",1);
  983. tree->SetBranchStatus("*TRUEORIGINVERTEX_Z*",1);
  984. tree->SetBranchStatus("*TRUEENDVERTEX_Z*",1);
  985. //particle masses and momenta
  986. tree -> SetBranchAddress( "B_plus_PX" , &B_plus_PX );
  987. tree -> SetBranchAddress( "B_plus_PY" , &B_plus_PY );
  988. tree -> SetBranchAddress( "B_plus_PZ" , &B_plus_PZ );
  989. tree -> SetBranchAddress( "B_plus_PT" , &B_plus_PT );
  990. tree -> SetBranchAddress( "B_plus_PE" , &B_plus_PE );
  991. tree -> SetBranchAddress( "B_plus_ETA" , &B_plus_ETA );
  992. if (!preselected) tree -> SetBranchAddress( "B_plus_PHI" , &B_plus_PHI );
  993. tree -> SetBranchAddress( "B_plus_TRUEP_X" , &B_plus_TRUE_PX );
  994. tree -> SetBranchAddress( "B_plus_TRUEP_Y" , &B_plus_TRUE_PY );
  995. tree -> SetBranchAddress( "B_plus_TRUEP_Z" , &B_plus_TRUE_PZ );
  996. tree -> SetBranchAddress( "B_plus_TRUEP_E" , &B_plus_TRUE_PE );
  997. tree -> SetBranchAddress( "B_plus_TRUEPT" , &B_plus_TRUE_PT );
  998. tree -> SetBranchAddress( "K_star_plus_PX" , &K_star_plus_PX );
  999. tree -> SetBranchAddress( "K_star_plus_PY" , &K_star_plus_PY );
  1000. tree -> SetBranchAddress( "K_star_plus_PZ" , &K_star_plus_PZ );
  1001. tree -> SetBranchAddress( "K_star_plus_PE" , &K_star_plus_PE );
  1002. tree -> SetBranchAddress( "K_star_plus_PT" , &K_star_plus_PT );
  1003. tree -> SetBranchAddress( "K_star_plus_TRUEP_X" , &K_star_plus_TRUE_PX );
  1004. tree -> SetBranchAddress( "K_star_plus_TRUEP_Y" , &K_star_plus_TRUE_PY );
  1005. tree -> SetBranchAddress( "K_star_plus_TRUEP_Z" , &K_star_plus_TRUE_PZ );
  1006. tree -> SetBranchAddress( "K_star_plus_TRUEP_E" , &K_star_plus_TRUE_PE );
  1007. tree -> SetBranchAddress( "K_star_plus_TRUEPT" , &K_star_plus_TRUE_PT );
  1008. if(Kst2Kpluspi0Merged){ //TODO: in case one really wants to do that, add DTF info
  1009. tree -> SetBranchAddress( "pi_zero_merged_PX" , &pi_zero_merged_PX );
  1010. tree -> SetBranchAddress( "pi_zero_merged_PY" , &pi_zero_merged_PY );
  1011. tree -> SetBranchAddress( "pi_zero_merged_PZ" , &pi_zero_merged_PZ );
  1012. tree -> SetBranchAddress( "pi_zero_merged_PE" , &pi_zero_merged_PE );
  1013. tree -> SetBranchAddress( "pi_zero_merged_PT" , &pi_zero_merged_PT );
  1014. tree -> SetBranchAddress( "pi_zero_merged_ETA" , &pi_zero_merged_ETA );
  1015. tree -> SetBranchAddress( "pi_zero_merged_PHI" , &pi_zero_merged_PHI );
  1016. tree -> SetBranchAddress( "pi_zero_merged_TRUEP_X" , &pi_zero_merged_TRUE_PX );
  1017. tree -> SetBranchAddress( "pi_zero_merged_TRUEP_Y" , &pi_zero_merged_TRUE_PY );
  1018. tree -> SetBranchAddress( "pi_zero_merged_TRUEP_Z" , &pi_zero_merged_TRUE_PZ );
  1019. tree -> SetBranchAddress( "pi_zero_merged_TRUEP_E" , &pi_zero_merged_TRUE_PE );
  1020. tree -> SetBranchAddress( "pi_zero_merged_TRUEPT" , &pi_zero_merged_TRUE_PT );
  1021. tree -> SetBranchAddress( "pi_zero_merged_PX_DTF" , &pi_zero_merged_PX_DTF );
  1022. tree -> SetBranchAddress( "pi_zero_merged_PY_DTF" , &pi_zero_merged_PY_DTF );
  1023. tree -> SetBranchAddress( "pi_zero_merged_PZ_DTF" , &pi_zero_merged_PZ_DTF );
  1024. tree -> SetBranchAddress( "pi_zero_merged_PE_DTF" , &pi_zero_merged_PE_DTF );
  1025. tree -> SetBranchAddress( "pi_zero_merged_PT_DTF" , &pi_zero_merged_PT_DTF );
  1026. tree -> SetBranchAddress( "pi_zero_merged_ETA_DTF" , &pi_zero_merged_ETA_DTF );
  1027. tree -> SetBranchAddress( "pi_zero_merged_PHI_DTF" , &pi_zero_merged_PHI_DTF );
  1028. }
  1029. if(Kst2Kpluspi0Resolved){
  1030. tree -> SetBranchAddress( "pi_zero_resolved_PX" , &pi_zero_resolved_PX );
  1031. tree -> SetBranchAddress( "pi_zero_resolved_PY" , &pi_zero_resolved_PY );
  1032. tree -> SetBranchAddress( "pi_zero_resolved_PZ" , &pi_zero_resolved_PZ );
  1033. tree -> SetBranchAddress( "pi_zero_resolved_PT" , &pi_zero_resolved_PT );
  1034. tree -> SetBranchAddress( "pi_zero_resolved_PE" , &pi_zero_resolved_PE );
  1035. tree -> SetBranchAddress( "pi_zero_resolved_ETA" , &pi_zero_resolved_ETA );
  1036. if (!preselected) tree -> SetBranchAddress( "pi_zero_resolved_PHI" , &pi_zero_resolved_PHI );
  1037. tree -> SetBranchAddress( "pi_zero_resolved_TRUEP_X" , &pi_zero_resolved_TRUE_PX );
  1038. tree -> SetBranchAddress( "pi_zero_resolved_TRUEP_Y" , &pi_zero_resolved_TRUE_PY );
  1039. tree -> SetBranchAddress( "pi_zero_resolved_TRUEP_Z" , &pi_zero_resolved_TRUE_PZ );
  1040. tree -> SetBranchAddress( "pi_zero_resolved_TRUEP_E" , &pi_zero_resolved_TRUE_PE );
  1041. tree -> SetBranchAddress( "pi_zero_resolved_TRUEPT" , &pi_zero_resolved_TRUE_PT );
  1042. tree -> SetBranchAddress( "gamma1_PX" , &gamma1_PX );
  1043. tree -> SetBranchAddress( "gamma1_PY" , &gamma1_PY );
  1044. tree -> SetBranchAddress( "gamma1_PZ" , &gamma1_PZ );
  1045. tree -> SetBranchAddress( "gamma1_PE" , &gamma1_PE );
  1046. tree -> SetBranchAddress( "gamma1_PT" , &gamma1_PT );
  1047. tree -> SetBranchAddress( "gamma1_TRUEP_X" , &gamma1_TRUE_PX );
  1048. tree -> SetBranchAddress( "gamma1_TRUEP_Y" , &gamma1_TRUE_PY );
  1049. tree -> SetBranchAddress( "gamma1_TRUEP_Z" , &gamma1_TRUE_PZ );
  1050. tree -> SetBranchAddress( "gamma1_TRUEP_E" , &gamma1_TRUE_PE );
  1051. tree -> SetBranchAddress( "gamma1_TRUEPT" , &gamma1_TRUE_PT );
  1052. tree -> SetBranchAddress( "gamma2_PX" , &gamma2_PX );
  1053. tree -> SetBranchAddress( "gamma2_PY" , &gamma2_PY );
  1054. tree -> SetBranchAddress( "gamma2_PZ" , &gamma2_PZ );
  1055. tree -> SetBranchAddress( "gamma2_PE" , &gamma2_PE );
  1056. tree -> SetBranchAddress( "gamma2_PT" , &gamma2_PT );
  1057. tree -> SetBranchAddress( "gamma2_TRUEP_X" , &gamma2_TRUE_PX );
  1058. tree -> SetBranchAddress( "gamma2_TRUEP_Y" , &gamma2_TRUE_PY );
  1059. tree -> SetBranchAddress( "gamma2_TRUEP_Z" , &gamma2_TRUE_PZ );
  1060. tree -> SetBranchAddress( "gamma2_TRUEP_E" , &gamma2_TRUE_PE );
  1061. tree -> SetBranchAddress( "gamma2_TRUEPT" , &gamma2_TRUE_PT );
  1062. tree -> SetBranchAddress( "B_plus_DTF_Kst_892_plus_pi0_gamma_0_PX" , &f_gamma1_PX_DTF );
  1063. tree -> SetBranchAddress( "B_plus_DTF_Kst_892_plus_pi0_gamma_0_PY" , &f_gamma1_PY_DTF );
  1064. tree -> SetBranchAddress( "B_plus_DTF_Kst_892_plus_pi0_gamma_0_PZ" , &f_gamma1_PZ_DTF );
  1065. tree -> SetBranchAddress( "B_plus_DTF_Kst_892_plus_pi0_gamma_0_PE" , &f_gamma1_PE_DTF );
  1066. tree -> SetBranchAddress( "B_plus_DTF_Kst_892_plus_pi0_gamma_PX" , &f_gamma2_PX_DTF );
  1067. tree -> SetBranchAddress( "B_plus_DTF_Kst_892_plus_pi0_gamma_PY" , &f_gamma2_PY_DTF );
  1068. tree -> SetBranchAddress( "B_plus_DTF_Kst_892_plus_pi0_gamma_PZ" , &f_gamma2_PZ_DTF );
  1069. tree -> SetBranchAddress( "B_plus_DTF_Kst_892_plus_pi0_gamma_PE" , &f_gamma2_PE_DTF );
  1070. }
  1071. if(Kst2Kpluspi0Merged || Kst2Kpluspi0Resolved){
  1072. tree -> SetBranchAddress( "K_plus_PX" , &K_plus_PX );
  1073. tree -> SetBranchAddress( "K_plus_PY" , &K_plus_PY );
  1074. tree -> SetBranchAddress( "K_plus_PZ" , &K_plus_PZ );
  1075. tree -> SetBranchAddress( "K_plus_PE" , &K_plus_PE );
  1076. tree -> SetBranchAddress( "K_plus_PT" , &K_plus_PT );
  1077. tree -> SetBranchAddress( "K_plus_ETA" , &K_plus_ETA );
  1078. tree -> SetBranchAddress( "K_plus_TRUEP_X" , &K_plus_TRUE_PX );
  1079. tree -> SetBranchAddress( "K_plus_TRUEP_Y" , &K_plus_TRUE_PY );
  1080. tree -> SetBranchAddress( "K_plus_TRUEP_Z" , &K_plus_TRUE_PZ );
  1081. tree -> SetBranchAddress( "K_plus_TRUEP_E" , &K_plus_TRUE_PE );
  1082. tree -> SetBranchAddress( "K_plus_TRUEPT" , &K_plus_TRUE_PT );
  1083. tree -> SetBranchAddress( "B_plus_DTF_Kst_892_plus_Kplus_PX" , &f_K_plus_PX_DTF );
  1084. tree -> SetBranchAddress( "B_plus_DTF_Kst_892_plus_Kplus_PY" , &f_K_plus_PY_DTF );
  1085. tree -> SetBranchAddress( "B_plus_DTF_Kst_892_plus_Kplus_PZ" , &f_K_plus_PZ_DTF );
  1086. tree -> SetBranchAddress( "B_plus_DTF_Kst_892_plus_Kplus_PE" , &f_K_plus_PE_DTF );
  1087. if (!preselected) tree -> SetBranchAddress( "K_plus_PHI" , &K_plus_PHI );
  1088. }
  1089. tree -> SetBranchAddress( "mu_minus_PX" , &mu_minus_PX );
  1090. tree -> SetBranchAddress( "mu_minus_PY" , &mu_minus_PY );
  1091. tree -> SetBranchAddress( "mu_minus_PZ" , &mu_minus_PZ );
  1092. tree -> SetBranchAddress( "mu_minus_PE" , &mu_minus_PE );
  1093. tree -> SetBranchAddress( "mu_minus_PT" , &mu_minus_PT );
  1094. tree -> SetBranchAddress( "mu_minus_TRUEP_X" , &mu_minus_TRUE_PX );
  1095. tree -> SetBranchAddress( "mu_minus_TRUEP_Y" , &mu_minus_TRUE_PY );
  1096. tree -> SetBranchAddress( "mu_minus_TRUEP_Z" , &mu_minus_TRUE_PZ );
  1097. tree -> SetBranchAddress( "mu_minus_TRUEP_E" , &mu_minus_TRUE_PE );
  1098. tree -> SetBranchAddress( "mu_minus_TRUEPT" , &mu_minus_TRUE_PT );
  1099. tree -> SetBranchAddress( "mu_plus_PX" , &mu_plus_PX );
  1100. tree -> SetBranchAddress( "mu_plus_PY" , &mu_plus_PY );
  1101. tree -> SetBranchAddress( "mu_plus_PZ" , &mu_plus_PZ );
  1102. tree -> SetBranchAddress( "mu_plus_PE" , &mu_plus_PE );
  1103. tree -> SetBranchAddress( "mu_plus_PT" , &mu_plus_PT );
  1104. tree -> SetBranchAddress( "mu_plus_TRUEP_X" , &mu_plus_TRUE_PX );
  1105. tree -> SetBranchAddress( "mu_plus_TRUEP_Y" , &mu_plus_TRUE_PY );
  1106. tree -> SetBranchAddress( "mu_plus_TRUEP_Z" , &mu_plus_TRUE_PZ );
  1107. tree -> SetBranchAddress( "mu_plus_TRUEP_E" , &mu_plus_TRUE_PE );
  1108. tree -> SetBranchAddress( "mu_plus_TRUEPT" , &mu_plus_TRUE_PT );
  1109. tree -> SetBranchAddress( "B_plus_DTF_J_psi_1S_muminus_0_PX" , &f_mu_minus_PX_DTF );
  1110. tree -> SetBranchAddress( "B_plus_DTF_J_psi_1S_muminus_0_PY" , &f_mu_minus_PY_DTF );
  1111. tree -> SetBranchAddress( "B_plus_DTF_J_psi_1S_muminus_0_PZ" , &f_mu_minus_PZ_DTF );
  1112. tree -> SetBranchAddress( "B_plus_DTF_J_psi_1S_muminus_0_PE" , &f_mu_minus_PE_DTF );
  1113. tree -> SetBranchAddress( "B_plus_DTF_J_psi_1S_muminus_PX" , &f_mu_plus_PX_DTF );
  1114. tree -> SetBranchAddress( "B_plus_DTF_J_psi_1S_muminus_PY" , &f_mu_plus_PY_DTF );
  1115. tree -> SetBranchAddress( "B_plus_DTF_J_psi_1S_muminus_PZ" , &f_mu_plus_PZ_DTF );
  1116. tree -> SetBranchAddress( "B_plus_DTF_J_psi_1S_muminus_PE" , &f_mu_plus_PE_DTF );
  1117. /* TODO
  1118. tree -> SetBranchAddress( "B_plus_ThetaL_DTF" , &B_plus_ThetaL_DTF);
  1119. tree -> SetBranchAddress( "B_plus_ThetaK_DTF" , &B_plus_ThetaK_DTF);
  1120. tree -> SetBranchAddress( "B_plus_Phi_DTF" , &B_plus_Phi_DTF );
  1121. */
  1122. tree -> SetBranchAddress( "B_plus_ThetaL" , &B_plus_ThetaL);
  1123. tree -> SetBranchAddress( "B_plus_ThetaK" , &B_plus_ThetaK);
  1124. tree -> SetBranchAddress( "B_plus_Phi" , &B_plus_Phi );
  1125. tree -> SetBranchAddress( "B_plus_TRUEThetaL" , &B_plus_TRUE_ThetaL);
  1126. tree -> SetBranchAddress( "B_plus_TRUEThetaK" , &B_plus_TRUE_ThetaK);
  1127. tree -> SetBranchAddress( "B_plus_TRUEPhi" , &B_plus_TRUE_Phi );
  1128. //global variables
  1129. tree -> SetBranchAddress( "B_plus_ENDVERTEX_Z", &B_plus_ENDVERTEX_Z);
  1130. tree -> SetBranchAddress( "B_plus_ENDVERTEX_ZERR", &B_plus_ENDVERTEX_ZERR);
  1131. tree -> SetBranchAddress( "B_plus_OWNPV_Z", &B_plus_OWNPV_Z);
  1132. tree -> SetBranchAddress( "B_plus_OWNPV_ZERR", &B_plus_OWNPV_ZERR);
  1133. tree -> SetBranchAddress( "B_plus_TRUEORIGINVERTEX_Z", &B_plus_TRUEORIGINVERTEX_Z);
  1134. tree -> SetBranchAddress( "B_plus_TRUEENDVERTEX_Z", &B_plus_TRUEENDVERTEX_Z);
  1135. tree -> SetBranchAddress( "B_plus_DTF_PV_Z", &f_B_plus_DTF_PV_Z);
  1136. tree -> SetBranchAddress( "B_plus_TOPPV_Z", &B_plus_TOPPV_Z);//TODO: what is this?
  1137. tree -> SetBranchAddress( "K_star_plus_ENDVERTEX_Z", &K_star_plus_ENDVERTEX_Z);
  1138. tree -> SetBranchAddress( "K_star_plus_ENDVERTEX_ZERR", &K_star_plus_ENDVERTEX_ZERR);
  1139. tree -> SetBranchAddress( "K_star_plus_OWNPV_Z", &K_star_plus_OWNPV_Z);
  1140. tree -> SetBranchAddress( "K_star_plus_OWNPV_ZERR", &K_star_plus_OWNPV_ZERR);
  1141. tree -> SetBranchAddress( "K_star_plus_TRUEORIGINVERTEX_Z", &K_star_plus_TRUEORIGINVERTEX_Z);
  1142. tree -> SetBranchAddress( "K_star_plus_TRUEENDVERTEX_Z", &K_star_plus_TRUEENDVERTEX_Z);
  1143. tree -> SetBranchAddress( "K_plus_OWNPV_Z", &K_plus_OWNPV_Z);
  1144. tree -> SetBranchAddress( "K_plus_OWNPV_ZERR", &K_plus_OWNPV_ZERR);
  1145. tree -> SetBranchAddress( "K_plus_TRUEORIGINVERTEX_Z", &K_plus_TRUEORIGINVERTEX_Z);
  1146. tree -> SetBranchAddress( "K_plus_TRUEENDVERTEX_Z", &K_plus_TRUEENDVERTEX_Z);
  1147. tree -> SetBranchAddress( "pi_zero_resolved_TRUEORIGINVERTEX_Z", &pi_zero_resolved_TRUEORIGINVERTEX_Z);
  1148. tree -> SetBranchAddress( "pi_zero_resolved_TRUEENDVERTEX_Z", &pi_zero_resolved_TRUEENDVERTEX_Z);
  1149. tree -> SetBranchAddress( "gamma1_TRUEORIGINVERTEX_Z", &gamma1_TRUEORIGINVERTEX_Z);
  1150. tree -> SetBranchAddress( "gamma1_TRUEENDVERTEX_Z", &gamma1_TRUEENDVERTEX_Z);
  1151. tree -> SetBranchAddress( "gamma2_TRUEORIGINVERTEX_Z", &gamma2_TRUEORIGINVERTEX_Z);
  1152. tree -> SetBranchAddress( "gamma2_TRUEENDVERTEX_Z", &gamma2_TRUEENDVERTEX_Z);
  1153. tree -> SetBranchAddress( "mu_plus_OWNPV_Z", &mu_plus_OWNPV_Z);
  1154. tree -> SetBranchAddress( "mu_plus_OWNPV_ZERR", &mu_plus_OWNPV_ZERR);
  1155. tree -> SetBranchAddress( "mu_plus_TRUEORIGINVERTEX_Z", &mu_plus_TRUEORIGINVERTEX_Z);
  1156. tree -> SetBranchAddress( "mu_plus_TRUEENDVERTEX_Z", &mu_plus_TRUEENDVERTEX_Z);
  1157. tree -> SetBranchAddress( "mu_minus_OWNPV_Z", &mu_minus_OWNPV_Z);
  1158. tree -> SetBranchAddress( "mu_minus_OWNPV_ZERR", &mu_minus_OWNPV_ZERR);
  1159. tree -> SetBranchAddress( "mu_minus_TRUEORIGINVERTEX_Z", &mu_minus_TRUEORIGINVERTEX_Z);
  1160. tree -> SetBranchAddress( "mu_minus_TRUEENDVERTEX_Z", &mu_minus_TRUEENDVERTEX_Z);
  1161. // Create outputfile
  1162. // Kst2Kpluspi0Resolved case
  1163. string newName = "";
  1164. preselected ? newName = "_resolution_preselected" : newName ="_resolution";
  1165. if (truthMatched) newName = newName + "_TM";
  1166. if(Kst2Kpluspi0Resolved){
  1167. if(!MC){
  1168. output = new TFile(Form("%s/data/%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(),newName.c_str()),"RECREATE");
  1169. }
  1170. else{
  1171. if(ReferenceChannel){
  1172. output = new TFile(Form("%s/data/MC/RefKplusPi0/%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(),newName.c_str()),"RECREATE");
  1173. }
  1174. else if(PHSP){
  1175. output = new TFile(Form("%s/data/PHSP/KplusPi0/%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(),newName.c_str()),"RECREATE");
  1176. }
  1177. else{
  1178. output = new TFile(Form("%s/data/MC/KplusPi0/%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(),newName.c_str()),"RECREATE");
  1179. }
  1180. }
  1181. }
  1182. // Kst2Kpluspi0Merged case
  1183. if(Kst2Kpluspi0Merged){
  1184. if(!MC){
  1185. output = new TFile(Form("%s/data/%s%s/%s%s_pi0Merged%s.root",path_to_output_KplusPizero.c_str(), year.c_str(),magnet.c_str(),year.c_str(),magnet.c_str(),newName.c_str()),"RECREATE");
  1186. }
  1187. else{
  1188. if(ReferenceChannel){
  1189. output = new TFile(Form("%s/data/MC/RefKplusPi0/%s%s/%s%s_pi0Merged%s.root",path_to_output_KplusPizero.c_str(), year.c_str(),magnet.c_str(),year.c_str(),magnet.c_str(),newName.c_str()),"RECREATE");
  1190. }
  1191. else if(PHSP){
  1192. output = new TFile(Form("%s/data/PHSP/KplusPi0/%s%s/%s%s_pi0Merged%s.root",path_to_output_KplusPizero.c_str(), year.c_str(),magnet.c_str(),year.c_str(),magnet.c_str(),newName.c_str()),"RECREATE");
  1193. }
  1194. else{
  1195. output = new TFile(Form("%s/data/MC/KplusPi0/%s%s/%s%s_pi0Merged%s.root",path_to_output_KplusPizero.c_str(), year.c_str(),magnet.c_str(),year.c_str(),magnet.c_str(),newName.c_str()),"RECREATE");
  1196. }
  1197. }
  1198. }
  1199. // Kst2Kspiplus case
  1200. if(Kst2Kspiplus){
  1201. if(!MC){
  1202. output = new TFile(Form("%s/data/%s%s/%s%s_piplus%s.root",path_to_output_KshortPiplus.c_str(), year.c_str(),magnet.c_str(),year.c_str(),magnet.c_str(),newName.c_str()),"RECREATE");
  1203. }
  1204. else{
  1205. if(ReferenceChannel){
  1206. output = new TFile(Form("%s/data/MC/RefKshortPiplus/%s%s/%s%s_piplus%s.root",path_to_output_KshortPiplus.c_str(), year.c_str(),magnet.c_str(),year.c_str(),magnet.c_str(),newName.c_str()),"RECREATE");
  1207. }
  1208. else if(PHSP){
  1209. output = new TFile(Form("%s/data/PHSP/KshortPiplus/%s%s/%s%s_piplus%s.root",path_to_output_KshortPiplus.c_str(), year.c_str(),magnet.c_str(),year.c_str(),magnet.c_str(),newName.c_str()),"RECREATE");
  1210. }
  1211. else{
  1212. output = new TFile(Form("%s/data/MC/KshortPiplus/%s%s/%s%s_piplus%s.root",path_to_output_KshortPiplus.c_str(), year.c_str(),magnet.c_str(),year.c_str(),magnet.c_str(),newName.c_str()),"RECREATE");
  1213. }
  1214. }
  1215. }
  1216. //Initialize new tree
  1217. output->cd();
  1218. TTree * resolution_tree = tree->CloneTree(0);
  1219. /////////////////////////////
  1220. // Initialize branches //
  1221. /////////////////////////////
  1222. // Rename true branches
  1223. // Initialize DTF branches
  1224. //-----------------------------------------------------------------------------------
  1225. if (preselected) resolution_tree -> Branch( "B_plus_PHI" , &B_plus_PHI, "B_plus_PHI/D");
  1226. resolution_tree -> Branch( "B_plus_TRUE_PX" , &B_plus_TRUE_PX, "B_plus_TRUE_PX/D");
  1227. resolution_tree -> Branch( "B_plus_TRUE_PY" , &B_plus_TRUE_PY, "B_plus_TRUE_PY/D");
  1228. resolution_tree -> Branch( "B_plus_TRUE_PZ" , &B_plus_TRUE_PZ, "B_plus_TRUE_PZ/D");
  1229. resolution_tree -> Branch( "B_plus_TRUE_PE" , &B_plus_TRUE_PE, "B_plus_TRUE_PE/D");
  1230. resolution_tree -> Branch( "B_plus_TRUE_PT" , &B_plus_TRUE_PT, "B_plus_TRUE_PT/D");
  1231. resolution_tree -> Branch( "B_plus_TRUE_ETA" , &B_plus_TRUE_ETA, "B_plus_TRUE_ETA/D");
  1232. resolution_tree -> Branch( "B_plus_TRUE_PHI" , &B_plus_TRUE_PHI, "B_plus_TRUE_PHI/D");
  1233. resolution_tree -> Branch( "B_plus_PX_DTF" , &B_plus_PX_DTF, "B_plus_PX_DTF/D");
  1234. resolution_tree -> Branch( "B_plus_PY_DTF" , &B_plus_PY_DTF, "B_plus_PY_DTF/D");
  1235. resolution_tree -> Branch( "B_plus_PZ_DTF" , &B_plus_PZ_DTF, "B_plus_PZ_DTF/D");
  1236. resolution_tree -> Branch( "B_plus_PT_DTF" , &B_plus_PT_DTF, "B_plus_PT_DTF/D");
  1237. resolution_tree -> Branch( "B_plus_PE_DTF" , &B_plus_PE_DTF, "B_plus_PE_DTF/D");
  1238. resolution_tree -> Branch( "B_plus_ETA_DTF", &B_plus_ETA_DTF, "B_plus_ETA_DTF/D");
  1239. resolution_tree -> Branch( "B_plus_PHI_DTF", &B_plus_PHI_DTF, "B_plus_PHI_DTF/D");
  1240. //-----------------------------------------------------------------------------------
  1241. resolution_tree -> Branch( "K_star_plus_TRUE_PX" , &K_star_plus_TRUE_PX, "K_star_plus_TRUE_PX/D");
  1242. resolution_tree -> Branch( "K_star_plus_TRUE_PY" , &K_star_plus_TRUE_PY, "K_star_plus_TRUE_PY/D");
  1243. resolution_tree -> Branch( "K_star_plus_TRUE_PZ" , &K_star_plus_TRUE_PZ, "K_star_plus_TRUE_PZ/D");
  1244. resolution_tree -> Branch( "K_star_plus_TRUE_PE" , &K_star_plus_TRUE_PE, "K_star_plus_TRUE_PE/D");
  1245. resolution_tree -> Branch( "K_star_plus_TRUE_PT" , &K_star_plus_TRUE_PT, "K_star_plus_TRUE_PT/D");
  1246. resolution_tree -> Branch( "K_star_plus_TRUE_ETA" , &K_star_plus_TRUE_ETA, "K_star_plus_TRUE_ETA/D");
  1247. resolution_tree -> Branch( "K_star_plus_TRUE_PHI" , &K_star_plus_TRUE_PHI, "K_star_plus_TRUE_PHI/D");
  1248. resolution_tree -> Branch( "K_star_plus_PX_DTF" , &K_star_plus_PX_DTF, "K_star_plus_PX_DTF/D");
  1249. resolution_tree -> Branch( "K_star_plus_PY_DTF" , &K_star_plus_PY_DTF, "K_star_plus_PY_DTF/D");
  1250. resolution_tree -> Branch( "K_star_plus_PZ_DTF" , &K_star_plus_PZ_DTF, "K_star_plus_PZ_DTF/D");
  1251. resolution_tree -> Branch( "K_star_plus_PT_DTF" , &K_star_plus_PT_DTF, "K_star_plus_PT_DTF/D");
  1252. resolution_tree -> Branch( "K_star_plus_PE_DTF" , &K_star_plus_PE_DTF, "K_star_plus_PE_DTF/D");
  1253. resolution_tree -> Branch( "K_star_plus_ETA_DTF", &K_star_plus_ETA_DTF, "K_star_plus_ETA_DTF/D");
  1254. resolution_tree -> Branch( "K_star_plus_PHI_DTF", &K_star_plus_PHI_DTF, "K_star_plus_PHI_DTF/D");
  1255. //-----------------------------------------------------------------------------------
  1256. if(Kst2Kpluspi0Merged){ //TODO: in case one really wants to do that, add DTF info
  1257. resolution_tree -> Branch( "pi_zero_merged_TRUE_PX" , &pi_zero_merged_TRUE_PX, "pi_zero_merged_TRUE_PX/D" );
  1258. resolution_tree -> Branch( "pi_zero_merged_TRUE_PY" , &pi_zero_merged_TRUE_PY, "pi_zero_merged_TRUE_PY/D" );
  1259. resolution_tree -> Branch( "pi_zero_merged_TRUE_PZ" , &pi_zero_merged_TRUE_PZ, "pi_zero_merged_TRUE_PZ/D" );
  1260. resolution_tree -> Branch( "pi_zero_merged_TRUE_PE" , &pi_zero_merged_TRUE_PE, "pi_zero_merged_TRUE_PE/D" );
  1261. resolution_tree -> Branch( "pi_zero_merged_TRUE_PT" , &pi_zero_merged_TRUE_PT, "pi_zero_merged_TRUE_PT/D" );
  1262. resolution_tree -> Branch( "pi_zero_merged_TRUE_ETA", &pi_zero_merged_TRUE_ETA, "pi_zero_merged_TRUE_ETA/D" );
  1263. resolution_tree -> Branch( "pi_zero_merged_TRUE_PHI", &pi_zero_merged_TRUE_PHI, "pi_zero_merged_TRUE_PHI/D" );
  1264. resolution_tree -> Branch( "pi_zero_merged_PX_DTF" , &pi_zero_merged_PX_DTF, "pi_zero_merged_PX_DTF/D" );
  1265. resolution_tree -> Branch( "pi_zero_merged_PY_DTF" , &pi_zero_merged_PY_DTF, "pi_zero_merged_PY_DTF/D" );
  1266. resolution_tree -> Branch( "pi_zero_merged_PZ_DTF" , &pi_zero_merged_PZ_DTF, "pi_zero_merged_PZ_DTF/D" );
  1267. resolution_tree -> Branch( "pi_zero_merged_PE_DTF" , &pi_zero_merged_PE_DTF, "pi_zero_merged_PE_DTF/D" );
  1268. resolution_tree -> Branch( "pi_zero_merged_PT_DTF" , &pi_zero_merged_PT_DTF, "pi_zero_merged_PT_DTF/D" );
  1269. resolution_tree -> Branch( "pi_zero_merged_ETA_DTF" , &pi_zero_merged_ETA_DTF, "pi_zero_merged_ETA_DTF/D" );
  1270. resolution_tree -> Branch( "pi_zero_merged_PHI_DTF" , &pi_zero_merged_PHI_DTF, "pi_zero_merged_PHI_DTF/D" );
  1271. }
  1272. //-----------------------------------------------------------------------------------
  1273. if(Kst2Kpluspi0Resolved){
  1274. resolution_tree -> Branch( "pi_zero_resolved_PHI", &pi_zero_resolved_PHI, "pi_zero_resolved_PHI/D" );
  1275. resolution_tree -> Branch( "pi_zero_resolved_TRUE_PX" , &pi_zero_resolved_TRUE_PX , "pi_zero_resolved_TRUE_PX/D" );
  1276. resolution_tree -> Branch( "pi_zero_resolved_TRUE_PY" , &pi_zero_resolved_TRUE_PY , "pi_zero_resolved_TRUE_PY/D" );
  1277. resolution_tree -> Branch( "pi_zero_resolved_TRUE_PZ" , &pi_zero_resolved_TRUE_PZ, "pi_zero_resolved_TRUE_PZ/D" );
  1278. resolution_tree -> Branch( "pi_zero_resolved_TRUE_PE" , &pi_zero_resolved_TRUE_PE, "pi_zero_resolved_TRUE_PE/D" );
  1279. resolution_tree -> Branch( "pi_zero_resolved_TRUE_PT" , &pi_zero_resolved_TRUE_PT , "pi_zero_resolved_TRUE_PT/D" );
  1280. resolution_tree -> Branch( "pi_zero_resolved_TRUE_ETA", &pi_zero_resolved_TRUE_ETA , "pi_zero_resolved_TRUE_ETA/D" );
  1281. resolution_tree -> Branch( "pi_zero_resolved_TRUE_PHI", &pi_zero_resolved_TRUE_PHI, "pi_zero_resolved_TRUE_PHI/D" );
  1282. resolution_tree -> Branch( "pi_zero_resolved_PX_DTF" , &pi_zero_resolved_PX_DTF , "pi_zero_resolved_PX_DTF/D" );
  1283. resolution_tree -> Branch( "pi_zero_resolved_PY_DTF" , &pi_zero_resolved_PY_DTF, "pi_zero_resolved_PY_DTF/D" );
  1284. resolution_tree -> Branch( "pi_zero_resolved_PZ_DTF" , &pi_zero_resolved_PZ_DTF , "pi_zero_resolved_PZ_DTF/D" );
  1285. resolution_tree -> Branch( "pi_zero_resolved_PT_DTF" , &pi_zero_resolved_PT_DTF , "pi_zero_resolved_PT_DTF/D" );
  1286. resolution_tree -> Branch( "pi_zero_resolved_PE_DTF" , &pi_zero_resolved_PE_DTF , "pi_zero_resolved_PE_DTF/D" );
  1287. resolution_tree -> Branch( "pi_zero_resolved_ETA_DTF" , &pi_zero_resolved_ETA_DTF , "pi_zero_resolved_ETA_DTF/D" );
  1288. resolution_tree -> Branch( "pi_zero_resolved_PHI_DTF" , &pi_zero_resolved_PHI_DTF, "pi_zero_resolved_PHI_DTF/D" );
  1289. //-----------------------------------------------------------------------------------
  1290. resolution_tree -> Branch( "gamma1_TRUE_PX" , &gamma1_TRUE_PX , "gamma1_TRUE_PX/D");
  1291. resolution_tree -> Branch( "gamma1_TRUE_PY" , &gamma1_TRUE_PY , "gamma1_TRUE_PY/D" );
  1292. resolution_tree -> Branch( "gamma1_TRUE_PZ" , &gamma1_TRUE_PZ , "gamma1_TRUE_PZ/D" );
  1293. resolution_tree -> Branch( "gamma1_TRUE_PE" , &gamma1_TRUE_PE , "gamma1_TRUE_PE/D");
  1294. resolution_tree -> Branch( "gamma1_TRUE_PT" , &gamma1_TRUE_PT , "gamma1_TRUE_PT/D");
  1295. resolution_tree -> Branch( "gamma1_TRUE_ETA", &gamma1_TRUE_ETA, "gamma1_TRUE_ETA/D" );
  1296. resolution_tree -> Branch( "gamma1_TRUE_PHI", &gamma1_TRUE_PHI, "gamma1_TRUE_PHI/D" );
  1297. resolution_tree -> Branch( "gamma2_TRUE_PX" , &gamma2_TRUE_PX, "gamma2_TRUE_PX/D" );
  1298. resolution_tree -> Branch( "gamma2_TRUE_PY" , &gamma2_TRUE_PY, "gamma2_TRUE_PY/D" );
  1299. resolution_tree -> Branch( "gamma2_TRUE_PZ" , &gamma2_TRUE_PZ, "gamma2_TRUE_PZ/D" );
  1300. resolution_tree -> Branch( "gamma2_TRUE_PE" , &gamma2_TRUE_PE , "gamma2_TRUE_PE/D");
  1301. resolution_tree -> Branch( "gamma2_TRUE_PT" , &gamma2_TRUE_PT, "gamma2_TRUE_PT/D" );
  1302. resolution_tree -> Branch( "gamma2_TRUE_ETA", &gamma2_TRUE_ETA, "gamma2_TRUE_ETA/D" );
  1303. resolution_tree -> Branch( "gamma2_TRUE_PHI", &gamma2_TRUE_PHI, "gamma2_TRUE_PHI/D" );
  1304. resolution_tree -> Branch( "gamma1_PX_DTF" , &gamma1_PX_DTF, "gamma1_PX_DTF/D");
  1305. resolution_tree -> Branch( "gamma1_PY_DTF" , &gamma1_PY_DTF, "gamma1_PY_DTF/D" );
  1306. resolution_tree -> Branch( "gamma1_PZ_DTF" , &gamma1_PZ_DTF, "gamma1_PZ_DTF/D" );
  1307. resolution_tree -> Branch( "gamma1_PE_DTF" , &gamma1_PE_DTF, "gamma1_PE_DTF/D" );
  1308. resolution_tree -> Branch( "gamma1_PT_DTF" , &gamma1_PT_DTF, "gamma1_PT_DTF/D");
  1309. resolution_tree -> Branch( "gamma1_ETA_DTF" , &gamma1_ETA_DTF , "gamma1_ETA_DTF/D");
  1310. resolution_tree -> Branch( "gamma1_PHI_DTF" , &gamma1_PHI_DTF , "gamma1_PHI_DTF/D");
  1311. resolution_tree -> Branch( "gamma2_PX_DTF" , &gamma2_PX_DTF, "gamma2_PX_DTF/D" );
  1312. resolution_tree -> Branch( "gamma2_PY_DTF" , &gamma2_PY_DTF, "gamma2_PY_DTF/D");
  1313. resolution_tree -> Branch( "gamma2_PZ_DTF" , &gamma2_PZ_DTF, "gamma2_PZ_DTF/D");
  1314. resolution_tree -> Branch( "gamma2_PE_DTF" , &gamma2_PE_DTF, "gamma2_PE_DTF/D" );
  1315. resolution_tree -> Branch( "gamma2_PT_DTF" , &gamma2_PT_DTF, "gamma2_PT_DTF/D");
  1316. resolution_tree -> Branch( "gamma2_ETA_DTF" , &gamma2_ETA_DTF , "gamma2_ETA_DTF/D");
  1317. resolution_tree -> Branch( "gamma2_PHI_DTF" , &gamma2_PHI_DTF , "gamma2_PHI_DTF/D");
  1318. }
  1319. //-----------------------------------------------------------------------------------
  1320. if(Kst2Kpluspi0Merged || Kst2Kpluspi0Resolved){
  1321. resolution_tree -> Branch( "K_plus_TRUE_PX" , &K_plus_TRUE_PX , "K_plus_TRUE_PY/D");
  1322. resolution_tree -> Branch( "K_plus_TRUE_PY" , &K_plus_TRUE_PY , "K_plus_TRUE_PY/D");
  1323. resolution_tree -> Branch( "K_plus_TRUE_PZ" , &K_plus_TRUE_PZ , "K_plus_TRUE_PY/D" );
  1324. resolution_tree -> Branch( "K_plus_TRUE_PE" , &K_plus_TRUE_PE , "K_plus_TRUE_PY/D" );
  1325. resolution_tree -> Branch( "K_plus_TRUE_PT" , &K_plus_TRUE_PT , "K_plus_TRUE_PY/D" );
  1326. resolution_tree -> Branch( "K_plus_TRUE_ETA" , &K_plus_TRUE_ETA , "K_plus_TRUE_PY/D" );
  1327. resolution_tree -> Branch( "K_plus_TRUE_PHI" , &K_plus_TRUE_PHI , "K_plus_TRUE_PY/D" );
  1328. resolution_tree -> Branch( "K_plus_PX_DTF" , &K_plus_PX_DTF , "K_plus_PX_DTF/D");
  1329. resolution_tree -> Branch( "K_plus_PY_DTF" , &K_plus_PY_DTF , "K_plus_PY_DTF/D");
  1330. resolution_tree -> Branch( "K_plus_PZ_DTF" , &K_plus_PZ_DTF , "K_plus_PZ_DTF/D");
  1331. resolution_tree -> Branch( "K_plus_PE_DTF" , &K_plus_PE_DTF , "K_plus_PE_DTF/D");
  1332. resolution_tree -> Branch( "K_plus_PT_DTF" , &K_plus_PT_DTF , "K_plus_PT_DTF/D");
  1333. resolution_tree -> Branch( "K_plus_ETA_DTF" , &K_plus_ETA_DTF , "K_plus_ETA_DTF/D");
  1334. resolution_tree -> Branch( "K_plus_PHI_DTF" , &K_plus_PHI_DTF , "K_plus_PHI_DTF/D");
  1335. }
  1336. //-----------------------------------------------------------------------------------
  1337. resolution_tree -> Branch( "mu_minus_TRUE_PX" , &mu_minus_TRUE_PX , "mu_minus_TRUE_PX/D");
  1338. resolution_tree -> Branch( "mu_minus_TRUE_PY" , &mu_minus_TRUE_PY , "mu_minus_TRUE_PY/D");
  1339. resolution_tree -> Branch( "mu_minus_TRUE_PZ" , &mu_minus_TRUE_PZ , "mu_minus_TRUE_PZ/D");
  1340. resolution_tree -> Branch( "mu_minus_TRUE_PE" , &mu_minus_TRUE_PE , "mu_minus_TRUE_PE/D");
  1341. resolution_tree -> Branch( "mu_minus_TRUE_PT" , &mu_minus_TRUE_PT , "mu_minus_TRUE_PT/D");
  1342. resolution_tree -> Branch( "mu_minus_TRUE_ETA" , &mu_minus_TRUE_ETA , "mu_minus_TRUE_ETA/D");
  1343. resolution_tree -> Branch( "mu_minus_TRUE_PHI" , &mu_minus_TRUE_PHI , "mu_minus_TRUE_PHI/D");
  1344. resolution_tree -> Branch( "mu_plus_TRUE_PX" , &mu_plus_TRUE_PX , "mu_plus_TRUE_PX/D");
  1345. resolution_tree -> Branch( "mu_plus_TRUE_PY" , &mu_plus_TRUE_PY , "mu_plus_TRUE_PY/D");
  1346. resolution_tree -> Branch( "mu_plus_TRUE_PZ" , &mu_plus_TRUE_PZ , "mu_plus_TRUE_PZ/D");
  1347. resolution_tree -> Branch( "mu_plus_TRUE_PE" , &mu_plus_TRUE_PE , "mu_plus_TRUE_PE/D");
  1348. resolution_tree -> Branch( "mu_plus_TRUE_PT" , &mu_plus_TRUE_PT , "mu_plus_TRUE_PT/D");
  1349. resolution_tree -> Branch( "mu_plus_TRUE_ETA" , &mu_plus_TRUE_ETA , "mu_plus_TRUE_ETA/D");
  1350. resolution_tree -> Branch( "mu_plus_TRUE_PHI" , &mu_plus_TRUE_PHI , "mu_plus_TRUE_PHI/D");
  1351. resolution_tree -> Branch( "mu_minus_PX_DTF" , &mu_minus_PX_DTF , "mu_minus_PX_DTF/D");
  1352. resolution_tree -> Branch( "mu_minus_PY_DTF" , &mu_minus_PY_DTF , "mu_minus_PY_DTF/D");
  1353. resolution_tree -> Branch( "mu_minus_PZ_DTF" , &mu_minus_PZ_DTF , "mu_minus_PZ_DTF/D");
  1354. resolution_tree -> Branch( "mu_minus_PE_DTF" , &mu_minus_PE_DTF , "mu_minus_PE_DTF/D");
  1355. resolution_tree -> Branch( "mu_minus_PT_DTF" , &mu_minus_PT_DTF , "mu_minus_PT_DTF/D");
  1356. resolution_tree -> Branch( "mu_minus_ETA_DTF" , &mu_minus_ETA_DTF , "mu_minus_ETA_DTF/D");
  1357. resolution_tree -> Branch( "mu_minus_PHI_DTF" , &mu_minus_PHI_DTF , "mu_minus_PHI_DTF/D");
  1358. resolution_tree -> Branch( "mu_plus_PX_DTF" , &mu_plus_PX_DTF , "mu_plus_PX_DTF/D");
  1359. resolution_tree -> Branch( "mu_plus_PY_DTF" , &mu_plus_PY_DTF , "mu_plus_PY_DTF/D");
  1360. resolution_tree -> Branch( "mu_plus_PZ_DTF" , &mu_plus_PZ_DTF , "mu_plus_PZ_DTF/D");
  1361. resolution_tree -> Branch( "mu_plus_PE_DTF" , &mu_plus_PE_DTF , "mu_plus_PE_DTF/D");
  1362. resolution_tree -> Branch( "mu_plus_PT_DTF" , &mu_plus_PT_DTF , "mu_plus_PT_DTF/D");
  1363. resolution_tree -> Branch( "mu_plus_ETA_DTF" , &mu_plus_ETA_DTF , "mu_plus_ETA_DTF/D");
  1364. resolution_tree -> Branch( "mu_plus_PHI_DTF" , &mu_plus_PHI_DTF , "mu_plus_PHI_DTF/D");
  1365. //-----------------------------------------------------------------------------------
  1366. resolution_tree -> Branch( "B_plus_DTF_PV_Z" , &B_plus_DTF_PV_Z, "B_plus_DTF_PV_Z/D");
  1367. resolution_tree -> Branch( "open_angle" , &open_angle, "open_angle/D");
  1368. resolution_tree -> Branch( "open_angle_DTF" , &open_angle_DTF, "open_angle_DTF/D");
  1369. resolution_tree -> Branch( "TRUE_open_angle", &TRUE_open_angle , "TRUE_open_angle/D");
  1370. resolution_tree -> Branch( "B_plus_ThetaL_DTF" , &B_plus_ThetaL_DTF, "B_plus_ThetaL_DTF/D");
  1371. resolution_tree -> Branch( "B_plus_ThetaK_DTF" , &B_plus_ThetaK_DTF, "B_plus_ThetaK_DTF/D");
  1372. resolution_tree -> Branch( "B_plus_Phi_DTF" , &B_plus_Phi_DTF , "B_plus_Phi_DTF/D");
  1373. //////////////////////////////////
  1374. ///// //////
  1375. //// Loop over events /////
  1376. ///// //////
  1377. //////////////////////////////////
  1378. for (int i=0; i<N; i++){
  1379. //output the different counters!
  1380. if ((0ul == (i % 10000ul) || i + 1 == N) && i != 0) {
  1381. cout << "Read event " << i + 1 << "/" << N
  1382. << endl;
  1383. }
  1384. tree->GetEntry(i);
  1385. /////////////////////
  1386. // DTF-values //
  1387. /////////////////////
  1388. LorVec_DTF_mu_minus = TLorentzVector (f_mu_minus_PX_DTF[0], f_mu_minus_PY_DTF[0], f_mu_minus_PZ_DTF[0], f_mu_minus_PE_DTF[0]);
  1389. LorVec_DTF_mu_plus = TLorentzVector (f_mu_plus_PX_DTF[0], f_mu_plus_PY_DTF[0], f_mu_plus_PZ_DTF[0], f_mu_plus_PE_DTF[0]);
  1390. if(Kst2Kspiplus){
  1391. /// Ks, pi+
  1392. LorVec_DTF_pi_plus = TLorentzVector (f_pi_plus_PX_DTF[0], f_pi_plus_PY_DTF[0], f_pi_plus_PZ_DTF[0], f_pi_plus_PE_DTF[0]);
  1393. LorVec_DTF_KS_pi_plus = TLorentzVector (f_Ks_pi_plus_PX_DTF[0], f_Ks_pi_plus_PY_DTF[0], f_Ks_pi_plus_PZ_DTF[0], f_Ks_pi_plus_PE_DTF[0]);
  1394. LorVec_DTF_KS_pi_minus = TLorentzVector (f_Ks_pi_minus_PX_DTF[0], f_Ks_pi_minus_PY_DTF[0], f_Ks_pi_minus_PZ_DTF[0], f_Ks_pi_minus_PE_DTF[0]);
  1395. LorVec_DTF_pi_plus_MisIDed.SetXYZM (f_pi_plus_PX_DTF[0], f_pi_plus_PY_DTF[0], f_pi_plus_PZ_DTF[0], PDGMASS.MU);
  1396. LorVec_DTF_mu_plus_MisIDed.SetXYZM (f_mu_plus_PX_DTF[0], f_mu_plus_PY_DTF[0], f_mu_plus_PZ_DTF[0], PDGMASS.PI_PLUS);
  1397. }
  1398. else{
  1399. /// K+, pi0
  1400. LorVec_DTF_K_plus = TLorentzVector (f_K_plus_PX_DTF[0], f_K_plus_PY_DTF[0], f_K_plus_PZ_DTF[0], f_K_plus_PE_DTF[0]);
  1401. LorVec_DTF_gamma1 = TLorentzVector (f_gamma1_PX_DTF[0], f_gamma1_PY_DTF[0], f_gamma1_PZ_DTF[0], f_gamma1_PE_DTF[0]);
  1402. LorVec_DTF_gamma2 = TLorentzVector (f_gamma2_PX_DTF[0], f_gamma2_PY_DTF[0], f_gamma2_PZ_DTF[0], f_gamma2_PE_DTF[0]);
  1403. }
  1404. //directly recombine the non-stable particles for later use (K*+ not really needed/used for Kst2Kspiplus)
  1405. if(Kst2Kspiplus){
  1406. LorVec_DTF_K_short = LorVec_DTF_KS_pi_plus + LorVec_DTF_KS_pi_minus;
  1407. LorVec_DTF_KaonPion = LorVec_DTF_K_short + LorVec_DTF_pi_plus;
  1408. }
  1409. if(Kst2Kpluspi0Resolved){
  1410. LorVec_DTF_DiGamma = LorVec_DTF_gamma1 + LorVec_DTF_gamma2;
  1411. LorVec_DTF_pi_zero_resolved = LorVec_DTF_DiGamma;
  1412. LorVec_DTF_KaonPion = LorVec_DTF_K_plus + LorVec_DTF_pi_zero_resolved;
  1413. }
  1414. LorVec_DTF_K_star_plus = LorVec_DTF_KaonPion;
  1415. LorVec_DTF_DiMuon = LorVec_DTF_mu_minus + LorVec_DTF_mu_plus;
  1416. LorVec_DTF_B_plus = LorVec_DTF_K_star_plus + LorVec_DTF_DiMuon;
  1417. open_angle_DTF =LorVec_DTF_gamma1.Angle(LorVec_DTF_gamma2.Vect());
  1418. /////////////////////
  1419. // TRUE values //
  1420. /////////////////////
  1421. LorVec_TRUE_B_plus.SetXYZM (B_plus_TRUE_PX, B_plus_TRUE_PY, B_plus_TRUE_PZ, PDGMASS.B_PLUS);
  1422. LorVec_TRUE_K_star_plus.SetXYZM (K_star_plus_TRUE_PX, K_star_plus_TRUE_PY, K_star_plus_TRUE_PZ, PDGMASS.K_STAR_PLUS);
  1423. LorVec_TRUE_mu_minus.SetXYZM (mu_minus_TRUE_PX, mu_minus_TRUE_PY, mu_minus_TRUE_PZ, PDGMASS.MU);
  1424. LorVec_TRUE_mu_plus.SetXYZM (mu_plus_TRUE_PX, mu_plus_TRUE_PY, mu_plus_TRUE_PZ, PDGMASS.MU);
  1425. if(Kst2Kspiplus){
  1426. /// Ks, pi+
  1427. LorVec_TRUE_K_short.SetXYZM (K_short_TRUE_PX, K_short_TRUE_PY, K_short_TRUE_PZ, PDGMASS.K_SHORT);
  1428. LorVec_TRUE_pi_plus.SetXYZM (pi_plus_TRUE_PX, pi_plus_TRUE_PY, pi_plus_TRUE_PZ, PDGMASS.PI_PLUS);
  1429. }
  1430. else{
  1431. /// K+, pi0
  1432. LorVec_TRUE_K_plus.SetXYZM (K_plus_TRUE_PX, K_plus_TRUE_PY, K_plus_TRUE_PZ, PDGMASS.K_PLUS);
  1433. LorVec_TRUE_pi_zero_merged.SetXYZM (pi_zero_merged_TRUE_PX, pi_zero_merged_TRUE_PY, pi_zero_merged_TRUE_PZ, PDGMASS.PI_ZERO);
  1434. LorVec_TRUE_pi_zero_resolved.SetXYZM (pi_zero_resolved_TRUE_PX, pi_zero_resolved_TRUE_PY, pi_zero_resolved_TRUE_PZ, PDGMASS.PI_ZERO);
  1435. LorVec_TRUE_gamma1.SetXYZM (gamma1_TRUE_PX, gamma1_TRUE_PY, gamma1_TRUE_PZ, PDGMASS.GAMMA);
  1436. LorVec_TRUE_gamma2.SetXYZM (gamma2_TRUE_PX, gamma2_TRUE_PY, gamma2_TRUE_PZ, PDGMASS.GAMMA);
  1437. }
  1438. //Recombination of 'Parent'-Particles
  1439. LorVec_TRUE_DiMuon = LorVec_TRUE_mu_minus + LorVec_TRUE_mu_plus;
  1440. if(Kst2Kspiplus){
  1441. LorVec_TRUE_KaonPion = LorVec_TRUE_K_short + LorVec_TRUE_pi_plus;
  1442. }
  1443. if(Kst2Kpluspi0Merged){
  1444. LorVec_TRUE_KaonPion = LorVec_TRUE_K_plus + LorVec_TRUE_pi_zero_merged;
  1445. }
  1446. if(Kst2Kpluspi0Resolved){
  1447. LorVec_TRUE_DiGamma = LorVec_TRUE_gamma1 + LorVec_TRUE_gamma2;
  1448. LorVec_TRUE_KaonPion = LorVec_TRUE_K_plus + LorVec_TRUE_DiGamma;
  1449. }
  1450. TRUE_open_angle =LorVec_TRUE_gamma1.Angle(LorVec_TRUE_gamma2.Vect());
  1451. //////////////////////
  1452. // detector values //
  1453. //////////////////////
  1454. LorVec_B_plus = TLorentzVector (B_plus_PX, B_plus_PY, B_plus_PZ, B_plus_PE);
  1455. LorVec_K_star_plus = TLorentzVector (K_star_plus_PX, K_star_plus_PY, K_star_plus_PZ, K_star_plus_PE);
  1456. LorVec_mu_minus = TLorentzVector (mu_minus_PX, mu_minus_PY, mu_minus_PZ, mu_minus_PE);
  1457. LorVec_mu_plus = TLorentzVector (mu_plus_PX, mu_plus_PY, mu_plus_PZ, mu_plus_PE);
  1458. if(Kst2Kspiplus){
  1459. /// Ks, pi+
  1460. LorVec_K_short = TLorentzVector (K_short_PX, K_short_PY, K_short_PZ, K_short_PE);
  1461. LorVec_pi_plus = TLorentzVector (pi_plus_PX, pi_plus_PY, pi_plus_PZ, pi_plus_PE);
  1462. LorVec_KS_pi_plus = TLorentzVector (Ks_pi_plus_PX, Ks_pi_plus_PY, Ks_pi_plus_PZ, Ks_pi_plus_PE);
  1463. LorVec_KS_pi_minus = TLorentzVector (Ks_pi_minus_PX, Ks_pi_minus_PY, Ks_pi_minus_PZ, Ks_pi_minus_PE);
  1464. LorVec_pi_plus_MisIDed.SetXYZM (pi_plus_PX, pi_plus_PY, pi_plus_PZ, PDGMASS.MU);
  1465. LorVec_mu_plus_MisIDed.SetXYZM (mu_plus_PX, mu_plus_PY, mu_plus_PZ, PDGMASS.PI_PLUS);
  1466. }
  1467. else{
  1468. /// K+, pi0
  1469. LorVec_K_plus = TLorentzVector (K_plus_PX, K_plus_PY, K_plus_PZ, K_plus_PE);
  1470. LorVec_pi_zero_merged = TLorentzVector (pi_zero_merged_PX, pi_zero_merged_PY, pi_zero_merged_PZ, pi_zero_merged_PE);
  1471. LorVec_pi_zero_resolved = TLorentzVector (pi_zero_resolved_PX, pi_zero_resolved_PY, pi_zero_resolved_PZ, pi_zero_resolved_PE);
  1472. LorVec_gamma1 = TLorentzVector (gamma1_PX, gamma1_PY, gamma1_PZ, gamma1_PE);
  1473. LorVec_gamma2 = TLorentzVector (gamma2_PX, gamma2_PY, gamma2_PZ, gamma2_PE);
  1474. }
  1475. //Recombination of 'Parent'-Particles
  1476. LorVec_DiMuon = LorVec_mu_minus + LorVec_mu_plus;
  1477. if(Kst2Kspiplus){
  1478. LorVec_KaonPion = LorVec_K_short + LorVec_pi_plus;
  1479. }
  1480. if(Kst2Kpluspi0Merged){
  1481. LorVec_KaonPion = LorVec_K_plus + LorVec_pi_zero_merged;
  1482. }
  1483. if(Kst2Kpluspi0Resolved){
  1484. LorVec_DiGamma = LorVec_gamma1 + LorVec_gamma2;
  1485. LorVec_KaonPion = LorVec_K_plus + LorVec_DiGamma;
  1486. }
  1487. TRUE_open_angle =LorVec_gamma1.Angle(LorVec_gamma2.Vect());
  1488. //Recombination of Particles
  1489. if(Kst2Kspiplus){
  1490. LorVec_DTF_KshortMuMu = LorVec_DTF_K_short + LorVec_DTF_DiMuon;
  1491. LorVec_KshortMuMu = LorVec_K_short + LorVec_DiMuon;
  1492. }
  1493. if(Kst2Kpluspi0Merged){
  1494. LorVec_DTF_KplusMuMu = LorVec_DTF_K_plus + LorVec_DTF_DiMuon;
  1495. LorVec_KplusMuMu = LorVec_K_plus + LorVec_DiMuon;
  1496. }
  1497. if(Kst2Kpluspi0Resolved){
  1498. LorVec_DTF_KplusMuMu = LorVec_DTF_K_plus + LorVec_DTF_DiMuon;
  1499. LorVec_KplusMuMu = LorVec_K_plus + LorVec_DiMuon;
  1500. LorVec_DTF_ReconBPiZero = LorVec_DTF_DiMuon + LorVec_DTF_K_plus + LorVec_DTF_pi_zero_resolved;
  1501. LorVec_ReconBPiZero = LorVec_DiMuon + LorVec_K_plus + LorVec_pi_zero_resolved;
  1502. LorVec_DTF_pi_zero_resolved = LorVec_DTF_DiGamma;
  1503. LorVec_pi_zero_resolved = LorVec_DiGamma;
  1504. }
  1505. LorVec_DTF_K_star_plus = LorVec_DTF_KaonPion;
  1506. LorVec_K_star_plus = LorVec_KaonPion;
  1507. LorVec_DTF_ReconB = LorVec_DTF_DiMuon + LorVec_DTF_K_star_plus;
  1508. LorVec_ReconB = LorVec_DiMuon + LorVec_K_star_plus;
  1509. //-----------------------------------------------------------------------------------
  1510. B_plus_TRUE_ETA = LorVec_TRUE_B_plus.Eta();
  1511. B_plus_TRUE_PHI = LorVec_TRUE_B_plus.Phi();
  1512. if(preselected) B_plus_PHI = LorVec_ReconB.Phi();
  1513. B_plus_PX_DTF = LorVec_DTF_B_plus.Px();
  1514. B_plus_PY_DTF = LorVec_DTF_B_plus.Py();
  1515. B_plus_PZ_DTF = LorVec_DTF_B_plus.Pz();
  1516. B_plus_PT_DTF = LorVec_DTF_B_plus.Pt();
  1517. B_plus_PE_DTF = LorVec_DTF_B_plus.E();
  1518. B_plus_ETA_DTF = LorVec_DTF_B_plus.Eta();
  1519. B_plus_PHI_DTF = LorVec_DTF_B_plus.Phi();
  1520. //-----------------------------------------------------------------------------------
  1521. K_star_plus_TRUE_ETA = LorVec_TRUE_K_star_plus.Eta();
  1522. K_star_plus_TRUE_PHI = LorVec_TRUE_K_star_plus.Phi();
  1523. K_star_plus_PX_DTF = LorVec_DTF_K_star_plus.Px();
  1524. K_star_plus_PY_DTF = LorVec_DTF_K_star_plus.Py();
  1525. K_star_plus_PZ_DTF = LorVec_DTF_K_star_plus.Pz();
  1526. K_star_plus_PT_DTF = LorVec_DTF_K_star_plus.Pt();
  1527. K_star_plus_PE_DTF = LorVec_DTF_K_star_plus.E();
  1528. K_star_plus_ETA_DTF = LorVec_DTF_K_star_plus.Eta();
  1529. K_star_plus_PHI_DTF = LorVec_DTF_K_star_plus.Phi();
  1530. //-----------------------------------------------------------------------------------
  1531. if(Kst2Kpluspi0Merged){ //TODO: in case one really wants to do that, add DTF info
  1532. pi_zero_merged_TRUE_ETA = LorVec_TRUE_pi_zero_merged.Eta();
  1533. pi_zero_merged_TRUE_PHI = LorVec_TRUE_pi_zero_merged.Phi();
  1534. pi_zero_merged_PX_DTF = LorVec_DTF_pi_zero_merged.Px();
  1535. pi_zero_merged_PY_DTF = LorVec_DTF_pi_zero_merged.Py();
  1536. pi_zero_merged_PZ_DTF = LorVec_DTF_pi_zero_merged.Pz();
  1537. pi_zero_merged_PT_DTF = LorVec_DTF_pi_zero_merged.Pt();
  1538. pi_zero_merged_PE_DTF = LorVec_DTF_pi_zero_merged.E();
  1539. pi_zero_merged_ETA_DTF = LorVec_DTF_pi_zero_merged.Eta();
  1540. pi_zero_merged_PHI_DTF = LorVec_DTF_pi_zero_merged.Phi();
  1541. }
  1542. //-----------------------------------------------------------------------------------
  1543. if(Kst2Kpluspi0Resolved){
  1544. if(preselected) pi_zero_resolved_PHI = LorVec_pi_zero_resolved.Phi();
  1545. pi_zero_resolved_TRUE_ETA = LorVec_TRUE_pi_zero_resolved.Eta();
  1546. pi_zero_resolved_TRUE_PHI = LorVec_TRUE_pi_zero_resolved.Phi();
  1547. pi_zero_resolved_PX_DTF = LorVec_DTF_pi_zero_resolved.Px();
  1548. pi_zero_resolved_PY_DTF = LorVec_DTF_pi_zero_resolved.Py();
  1549. pi_zero_resolved_PZ_DTF = LorVec_DTF_pi_zero_resolved.Pz();
  1550. pi_zero_resolved_PT_DTF = LorVec_DTF_pi_zero_resolved.Pt();
  1551. pi_zero_resolved_PE_DTF = LorVec_DTF_pi_zero_resolved.E();
  1552. pi_zero_resolved_ETA_DTF = LorVec_DTF_pi_zero_resolved.Eta();
  1553. pi_zero_resolved_PHI_DTF = LorVec_DTF_pi_zero_resolved.Phi();
  1554. //-----------------------------------------------------------------------------------
  1555. gamma1_TRUE_ETA = LorVec_TRUE_gamma1.Eta();
  1556. gamma1_TRUE_PHI = LorVec_TRUE_gamma1.Phi();
  1557. gamma2_TRUE_ETA = LorVec_TRUE_gamma2.Eta();
  1558. gamma2_TRUE_PHI = LorVec_TRUE_gamma2.Phi();
  1559. if(preselected){
  1560. gamma1_ETA= LorVec_gamma1.Eta();
  1561. gamma1_PHI= LorVec_gamma1.Phi();
  1562. gamma2_ETA= LorVec_gamma2.Eta();
  1563. gamma2_PHI= LorVec_gamma2.Phi();
  1564. }
  1565. gamma1_PX_DTF = LorVec_DTF_gamma1.Px();
  1566. gamma1_PY_DTF = LorVec_DTF_gamma1.Py();
  1567. gamma1_PZ_DTF = LorVec_DTF_gamma1.Pz();
  1568. gamma1_PT_DTF = LorVec_DTF_gamma1.Pt();
  1569. gamma1_PE_DTF = LorVec_DTF_gamma1.E();
  1570. gamma1_ETA_DTF = LorVec_DTF_gamma1.Eta();
  1571. gamma1_PHI_DTF = LorVec_DTF_gamma1.Phi();
  1572. gamma2_PX_DTF = LorVec_DTF_gamma2.Px();
  1573. gamma2_PY_DTF = LorVec_DTF_gamma2.Py();
  1574. gamma2_PZ_DTF = LorVec_DTF_gamma2.Pz();
  1575. gamma2_PT_DTF = LorVec_DTF_gamma2.Pt();
  1576. gamma2_PE_DTF = LorVec_DTF_gamma2.E();
  1577. gamma2_ETA_DTF = LorVec_DTF_gamma2.Eta();
  1578. gamma2_PHI_DTF = LorVec_DTF_gamma2.Phi();
  1579. }
  1580. //-----------------------------------------------------------------------------------
  1581. if(Kst2Kpluspi0Merged || Kst2Kpluspi0Resolved){
  1582. K_plus_TRUE_ETA = LorVec_TRUE_K_star_plus.Eta();
  1583. K_plus_TRUE_PHI = LorVec_TRUE_K_star_plus.Phi();
  1584. if(preselected){
  1585. K_plus_PHI = LorVec_K_plus.Phi();
  1586. }
  1587. K_plus_PX_DTF = LorVec_DTF_K_plus.Px();
  1588. K_plus_PY_DTF = LorVec_DTF_K_plus.Py();
  1589. K_plus_PZ_DTF = LorVec_DTF_K_plus.Pz();
  1590. K_plus_PT_DTF = LorVec_DTF_K_plus.Pt();
  1591. K_plus_PE_DTF = LorVec_DTF_K_plus.E();
  1592. K_plus_ETA_DTF = LorVec_DTF_K_plus.Eta();
  1593. K_plus_PHI_DTF = LorVec_DTF_K_plus.Phi();
  1594. }
  1595. //-----------------------------------------------------------------------------------
  1596. mu_minus_TRUE_ETA = LorVec_TRUE_mu_minus.Eta();
  1597. mu_minus_TRUE_PHI = LorVec_TRUE_mu_minus.Phi();
  1598. mu_plus_TRUE_ETA = LorVec_TRUE_mu_plus.Eta();
  1599. mu_plus_TRUE_PHI = LorVec_TRUE_mu_plus.Phi();
  1600. if(preselected){
  1601. mu_minus_ETA= LorVec_mu_minus.Eta();
  1602. mu_minus_PHI= LorVec_mu_minus.Phi();
  1603. mu_plus_ETA= LorVec_mu_plus.Eta();
  1604. mu_plus_PHI= LorVec_mu_plus.Phi();
  1605. }
  1606. mu_minus_PX_DTF = LorVec_DTF_mu_minus.Px();
  1607. mu_minus_PY_DTF = LorVec_DTF_mu_minus.Py();
  1608. mu_minus_PZ_DTF = LorVec_DTF_mu_minus.Pz();
  1609. mu_minus_PT_DTF = LorVec_DTF_mu_minus.Pt();
  1610. mu_minus_PE_DTF = LorVec_DTF_mu_minus.E();
  1611. mu_minus_ETA_DTF = LorVec_DTF_mu_minus.Eta();
  1612. mu_minus_PHI_DTF = LorVec_DTF_mu_minus.Phi();
  1613. mu_plus_PX_DTF = LorVec_DTF_mu_plus.Px();
  1614. mu_plus_PY_DTF = LorVec_DTF_mu_plus.Py();
  1615. mu_plus_PZ_DTF = LorVec_DTF_mu_plus.Pz();
  1616. mu_plus_PT_DTF = LorVec_DTF_mu_plus.Pt();
  1617. mu_plus_PE_DTF = LorVec_DTF_mu_plus.E();
  1618. mu_plus_ETA_DTF = LorVec_DTF_mu_plus.Eta();
  1619. mu_plus_PHI_DTF = LorVec_DTF_mu_plus.Phi();
  1620. resolution_tree->Fill();
  1621. } //end of event loop
  1622. //-----------------------------------------------------------------------------------
  1623. B_plus_DTF_PV_Z = (Double_t)(f_B_plus_DTF_PV_Z[0]);
  1624. //TODO
  1625. resolution_tree -> Branch( "B_plus_ThetaL_DTF" , &B_plus_ThetaL_DTF);
  1626. resolution_tree -> Branch( "B_plus_ThetaK_DTF" , &B_plus_ThetaK_DTF);
  1627. resolution_tree -> Branch( "B_plus_Phi_DTF" , &B_plus_Phi_DTF );
  1628. //-----------------------------------------------------------------------------------
  1629. resolution_tree->SetBranchStatus("*TRUEPT*",0);
  1630. resolution_tree->SetBranchStatus("*TRUEP_*",0);
  1631. resolution_tree->SetBranchStatus("*CONE*",0);
  1632. resolution_tree->SetBranchStatus("*892*",0);
  1633. resolution_tree->SetBranchStatus("*0.*",0);
  1634. resolution_tree->SetBranchStatus("*J_psi_1S*",0);
  1635. resolution_tree->SetBranchStatus("*TRUETAU*",0);
  1636. if (preselected) resolution_tree->SetBranchStatus("*NEW*",0);
  1637. tree->Delete();
  1638. resolution_tree->CloneTree(-1)->Write();
  1639. output->Close();
  1640. cout << "[INFO]\t\t Histograms created." << endl;
  1641. return 1;
  1642. }
  1643. int ResPreselAllMC(Int_t Run = 1, bool preselected = true, bool truthMatched = false) {
  1644. if(Run != 1 && Run != 2){
  1645. std::cout << "[ERROR]\t\tInvalid Run number given: " << Run << ". Exit program!" << std::endl;
  1646. return 0;
  1647. }
  1648. if ( ResPresel((Run == 1 ? "2011" : "2015"),"down", true, false, false, preselected, truthMatched) == 0) return 0;
  1649. if ( ResPresel((Run == 1 ? "2011" : "2015"),"up" , true, false, false, preselected, truthMatched) == 0) return 0;
  1650. if ( ResPresel((Run == 1 ? "2012" : "2016"),"down", true, false, false, preselected, truthMatched) == 0) return 0;
  1651. if ( ResPresel((Run == 1 ? "2012" : "2016"),"up" , true, false, false, preselected, truthMatched) == 0) return 0;
  1652. return 1;
  1653. }
  1654. int ResPreselAllRefChannel(Int_t Run = 1, bool preselected = true, bool truthMatched = false) {
  1655. if(Run != 1 && Run != 2){
  1656. std::cout << "[ERROR]\t\tInvalid Run number given: " << Run << ". Exit program!" << std::endl;
  1657. return 0;
  1658. }
  1659. if ( ResPresel((Run == 1 ? "2011" : "2015"),"down", true, true, false, preselected, truthMatched) == 0) return 0;
  1660. if ( ResPresel((Run == 1 ? "2011" : "2015"),"up" , true, true, false, preselected, truthMatched) == 0) return 0;
  1661. if ( ResPresel((Run == 1 ? "2012" : "2016"),"down", true, true, false, preselected, truthMatched) == 0) return 0;
  1662. if ( ResPresel((Run == 1 ? "2012" : "2016"),"up" , true, true, false, preselected, truthMatched) == 0) return 0;
  1663. return 1;
  1664. }
  1665. int ResPreselAllPHSP(Int_t Run = 1, bool preselected = true, bool truthMatched = false) {
  1666. if(Run != 1 && Run != 2){
  1667. std::cout << "[ERROR]\t\tInvalid Run number given: " << Run << ". Exit program!" << std::endl;
  1668. return 0;
  1669. }
  1670. if ( ResPresel((Run == 1 ? "2011" : "2015"),"down", true, false, true, preselected, truthMatched) == 0) return 0;
  1671. if ( ResPresel((Run == 1 ? "2011" : "2015"),"up" , true, false, true, preselected, truthMatched) == 0) return 0;
  1672. if ( ResPresel((Run == 1 ? "2012" : "2016"),"down", true, false, true, preselected, truthMatched) == 0) return 0;
  1673. if ( ResPresel((Run == 1 ? "2012" : "2016"),"up" , true, false, true, preselected, truthMatched) == 0) return 0;
  1674. return 1;
  1675. }
  1676. int ResPreselAll( Int_t Run = 1, bool preselected = true, bool truthMatched = false) {
  1677. if (ResPreselAllMC (Run, preselected, truthMatched)==0) return 0;
  1678. if (Run == 2) cout << "[INFO]\tNo reference channel for run 2, Skipping.";
  1679. else{
  1680. if (ResPreselAllRefChannel (Run, preselected, truthMatched)==0) return 0;
  1681. }
  1682. if (ResPreselAllPHSP (Run, preselected, truthMatched)==0) return 0;
  1683. return 1;
  1684. }
  1685. int ResPreselComplete( Int_t Run = 1){
  1686. if (ResPreselAllMC (Run, 0, 0)==0) return 0;
  1687. if (ResPreselAllMC (Run, 1, 0)==0) return 0;
  1688. if (ResPreselAllMC (Run, 1, 1)==0) return 0;
  1689. if (ResPreselAllRefChannel (Run, 0, 0)==0) return 0;
  1690. if (ResPreselAllRefChannel (Run, 1, 0)==0) return 0;
  1691. if (ResPreselAllRefChannel (Run, 1, 1)==0) return 0;
  1692. if (ResPreselAllPHSP (Run, 0, 0)==0) return 0;
  1693. if (ResPreselAllPHSP (Run, 1, 0)==0) return 0;
  1694. if (ResPreselAllPHSP (Run, 1, 1)==0) return 0;
  1695. return 1;
  1696. }
  1697. double pull(double rec, double truth){
  1698. return double(rec-truth);
  1699. }
  1700. void res_sys(TH2* ref,TH1* res_sys, TH1* sys, TH1* res, TF1 *func, int nBins, TFile *output,
  1701. bool preselected, string year, string magnet, bool MC = true, bool ReferenceChannel = false, bool PHSP = false, bool truthMatched = false){
  1702. gStyle->SetOptStat(0);
  1703. string name = ref->GetName();
  1704. //--------------------------------------------
  1705. // output->cd(); //remove to improve performance
  1706. design_diff(ref,preselected, year, magnet, MC, ReferenceChannel, PHSP, truthMatched);
  1707. ref->FitSlicesY(func,0,-1,0);
  1708. TH2F *ref_0 = (TH2F*)output->Get((name +"_0").c_str()); //const
  1709. TH2F *ref_1 = (TH2F*)output->Get((name +"_1").c_str()); //mean
  1710. TH2F *ref_2 = (TH2F*)output->Get((name +"_2").c_str()); //sigma
  1711. ref_0->Write();
  1712. ref_1->Write();
  1713. ref_2->Write();
  1714. for (int b = 1; b < nBins+1; b++){
  1715. res_sys->SetBinContent(b,ref_1->GetBinContent(b));
  1716. res_sys->SetBinError(b,ref_2->GetBinContent(b));
  1717. res->SetBinContent(b,ref_2->GetBinContent(b));
  1718. res->SetBinError(b,ref_2->GetBinError(b));
  1719. sys->SetBinContent(b,ref_1->GetBinContent(b));
  1720. sys->SetBinError(b,ref_1->GetBinError(b));
  1721. }
  1722. design_fit (res_sys, preselected, year, magnet, MC, ReferenceChannel, PHSP, truthMatched);
  1723. design_systematics (sys, preselected, year, magnet, MC, ReferenceChannel, PHSP, truthMatched);
  1724. design_resolution (res, preselected, year, magnet, MC, ReferenceChannel, PHSP, truthMatched);
  1725. res_sys->Write();
  1726. sys->Write();
  1727. res->Write();
  1728. ref_0->Clear();
  1729. ref_1->Clear();
  1730. ref_2->Clear();
  1731. delete ref_0;
  1732. delete ref_1;
  1733. delete ref_2;
  1734. return;
  1735. }
  1736. void pull(TH1* res,TH1* pull, int nBins, bool preselected, string year, string magnet, bool MC = true, bool ReferenceChannel = false, bool PHSP = false, bool truthMatched = false){
  1737. // output->cd(); //remove to improve performance
  1738. for (int b = 1; b < nBins+1; b++){
  1739. if (res->GetBinError(b) < 1e-8){
  1740. cout << "[ERROR]\tIn " << res->GetName() << " zero error. Check the fits!" << endl;
  1741. cout << "[ERROR]\tSetting pull to 0" << endl;
  1742. pull->SetBinContent(b,0);
  1743. continue;
  1744. }
  1745. // cout << b << " " << res->GetBinContent(b) << endl;
  1746. pull->SetBinContent(b,double(res->GetBinContent(b))/res->GetBinError(b));
  1747. }
  1748. pull->Write();
  1749. design_pull(pull,preselected, year, magnet, MC, ReferenceChannel, PHSP, truthMatched);
  1750. return;
  1751. }
  1752. void res(TH1* res_sys,TH1* res, int nBins, bool preselected, string year, string magnet, bool MC = true, bool ReferenceChannel = false, bool PHSP = false, bool truthMatched = false){
  1753. // output->cd(); //remove to improve performance
  1754. /*
  1755. for (int b = 1; b < nBins+1; b++){
  1756. res->SetBinContent(b,res_sys->GetBinError(b));
  1757. }
  1758. res->Write();
  1759. design_resolution(res,preselected, year, magnet, MC, ReferenceChannel, PHSP, truthMatched);
  1760. */
  1761. return;
  1762. }
  1763. void sys(TH1* res_sys,TH1* sys, int nBins, bool preselected, string year, string magnet, bool MC = true, bool ReferenceChannel = false, bool PHSP = false, bool truthMatched = false){
  1764. /*
  1765. // output->cd(); //remove to improve performance
  1766. for (int b = 1; b < nBins+1; b++){
  1767. sys->SetBinContent(b,res_sys->GetBinContent(b));
  1768. }
  1769. sys->Write();
  1770. design_systematics(sys,preselected, year, magnet, MC, ReferenceChannel, PHSP, truthMatched);
  1771. */
  1772. return;
  1773. }
  1774. int ResHist(std::string year = "2011", std::string magnet = "down", bool MC = true, bool ReferenceChannel = false, bool PHSP = false, bool preselected = true, bool truthMatched = false){
  1775. MC = true;
  1776. // Kst2Kpluspi0Resolved case
  1777. bool OnlyDTF = false; //don't save non-DTF var
  1778. TFile *input = 0;
  1779. string newName = "";
  1780. string legTitle = "";
  1781. string TM = "";
  1782. preselected ? newName = "_resolution_preselected" : newName ="_resolution";
  1783. truthMatched ? TM = "_TM" : "";
  1784. newName = newName + TM;
  1785. Kst2Kspiplus? legTitle= particleLatex("Kstar") +" #rightarrow " +particleLatex("Kshort") + particleLatex("piplus") :legTitle= particleLatex("Kstar") +" #rightarrow " +particleLatex("Kplus") + particleLatex("pizero");
  1786. preselected ? legTitle= legTitle + ": preselected" : legTitle = legTitle+": stripped";
  1787. truthMatched ? legTitle= "#splitline{" + legTitle+":}{TruthMatched}" : legTitle = legTitle;
  1788. if (MC){
  1789. if(ReferenceChannel) legTitle = legTitle + " {MCRef}";
  1790. else if (PHSP) legTitle = legTitle + " {PHSP MC}";
  1791. else legTitle = legTitle + " {MC}";
  1792. }
  1793. TChain *tree =new TChain(truthMatched ? "DecayTreeTruthMatched" : "DecayTree");
  1794. bool bothPol = false;
  1795. if (magnet == "downup" || magnet == "updown"){
  1796. bothPol = true;
  1797. magnet = "down";
  1798. }
  1799. if(Kst2Kpluspi0Resolved){
  1800. if(!MC){
  1801. tree->Add(Form("%s/data/%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(),newName.c_str()));
  1802. if (bothPol){
  1803. magnet = "down";
  1804. tree->Add(Form("%s/data/%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(),newName.c_str()));
  1805. }
  1806. }
  1807. else{
  1808. if(ReferenceChannel){
  1809. tree->Add(Form("%s/data/MC/RefKplusPi0/%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(),newName.c_str()));
  1810. if (bothPol){
  1811. magnet = "down";
  1812. tree->Add(Form("%s/data/MC/RefKplusPi0/%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(),newName.c_str()));
  1813. }
  1814. }
  1815. else if(PHSP){
  1816. tree->Add(Form("%s/data/PHSP/KplusPi0/%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(),newName.c_str()));
  1817. if (bothPol){
  1818. magnet = "down";
  1819. tree->Add(Form("%s/data/PHSP/KplusPi0/%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(),newName.c_str()));
  1820. }
  1821. }
  1822. else{
  1823. tree->Add(Form("%s/data/MC/KplusPi0/%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(),newName.c_str()));
  1824. if (bothPol){
  1825. magnet = "down";
  1826. tree->Add(Form("%s/data/MC/KplusPi0/%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(),newName.c_str()));
  1827. }
  1828. }
  1829. }
  1830. }
  1831. // Kst2Kpluspi0Merged case
  1832. if(Kst2Kpluspi0Merged){
  1833. if(!MC){
  1834. tree->Add(Form("%s/data/%s%s/%s%s_pi0Merged%s.root",path_to_output_KplusPizero.c_str(), year.c_str(),magnet.c_str(),year.c_str(),magnet.c_str(),newName.c_str()));
  1835. if (bothPol){
  1836. magnet = "down";
  1837. tree->Add(Form("%s/data/%s%s/%s%s_pi0Merged%s.root",path_to_output_KplusPizero.c_str(), year.c_str(),magnet.c_str(),year.c_str(),magnet.c_str(),newName.c_str()));
  1838. }
  1839. }
  1840. else{
  1841. if(ReferenceChannel){
  1842. tree->Add(Form("%s/data/MC/RefKplusPi0/%s%s/%s%s_pi0Merged%s.root",path_to_output_KplusPizero.c_str(), year.c_str(),magnet.c_str(),year.c_str(),magnet.c_str(),newName.c_str()));
  1843. if (bothPol){
  1844. magnet = "down";
  1845. tree->Add(Form("%s/data/MC/RefKplusPi0/%s%s/%s%s_pi0Merged%s.root",path_to_output_KplusPizero.c_str(), year.c_str(),magnet.c_str(),year.c_str(),magnet.c_str(),newName.c_str()));
  1846. }
  1847. }
  1848. else if(PHSP){
  1849. tree->Add(Form("%s/data/PHSP/KplusPi0/%s%s/%s%s_pi0Merged%s.root",path_to_output_KplusPizero.c_str(), year.c_str(),magnet.c_str(),year.c_str(),magnet.c_str(),newName.c_str()));
  1850. if (bothPol){
  1851. magnet = "down";
  1852. tree->Add(Form("%s/data/PHSP/KplusPi0/%s%s/%s%s_pi0Merged%s.root",path_to_output_KplusPizero.c_str(), year.c_str(),magnet.c_str(),year.c_str(),magnet.c_str(),newName.c_str()));
  1853. }
  1854. }
  1855. else{
  1856. tree->Add(Form("%s/data/MC/KplusPi0/%s%s/%s%s_pi0Merged%s.root",path_to_output_KplusPizero.c_str(), year.c_str(),magnet.c_str(),year.c_str(),magnet.c_str(),newName.c_str()));
  1857. if (bothPol){
  1858. magnet = "down";
  1859. tree->Add(Form("%s/data/MC/KplusPi0/%s%s/%s%s_pi0Merged%s.root",path_to_output_KplusPizero.c_str(), year.c_str(),magnet.c_str(),year.c_str(),magnet.c_str(),newName.c_str()));
  1860. }
  1861. }
  1862. }
  1863. }
  1864. // Kst2Kspiplus case
  1865. if(Kst2Kspiplus){
  1866. if(!MC){
  1867. tree->Add(Form("%s/data/%s%s/%s%s_piplus%s.root",path_to_output_KshortPiplus.c_str(), year.c_str(),magnet.c_str(),year.c_str(),magnet.c_str(),newName.c_str()));
  1868. if (bothPol){
  1869. magnet = "down";
  1870. tree->Add(Form("%s/data/MC/KplusPi0/%s%s/%s%s_pi0Merged%s.root",path_to_output_KplusPizero.c_str(), year.c_str(),magnet.c_str(),year.c_str(),magnet.c_str(),newName.c_str()));
  1871. }
  1872. }
  1873. else{
  1874. if(ReferenceChannel){
  1875. tree->Add(Form("%s/data/MC/RefKshortPiplus/%s%s/%s%s_piplus%s.root",path_to_output_KshortPiplus.c_str(), year.c_str(),magnet.c_str(),year.c_str(),magnet.c_str(),newName.c_str()));
  1876. if (bothPol){
  1877. magnet = "down";
  1878. tree->Add(Form("%s/data/MC/RefKshortPiplus/%s%s/%s%s_piplus%s.root",path_to_output_KshortPiplus.c_str(), year.c_str(),magnet.c_str(),year.c_str(),magnet.c_str(),newName.c_str()));
  1879. }
  1880. }
  1881. else if(PHSP){
  1882. tree->Add(Form("%s/data/PHSP/KshortPiplus/%s%s/%s%s_piplus%s.root",path_to_output_KshortPiplus.c_str(), year.c_str(),magnet.c_str(),year.c_str(),magnet.c_str(),newName.c_str()));
  1883. if (bothPol){
  1884. magnet = "down";
  1885. tree->Add(Form("%s/data/PHSP/KshortPiplus/%s%s/%s%s_piplus%s.root",path_to_output_KshortPiplus.c_str(), year.c_str(),magnet.c_str(),year.c_str(),magnet.c_str(),newName.c_str()));
  1886. }
  1887. }
  1888. else{
  1889. tree->Add(Form("%s/data/MC/KshortPiplus/%s%s/%s%s_piplus%s.root",path_to_output_KshortPiplus.c_str(), year.c_str(),magnet.c_str(),year.c_str(),magnet.c_str(),newName.c_str()));
  1890. if (bothPol){
  1891. magnet = "down";
  1892. tree->Add(Form("%s/data/MC/KshortPiplus/%s%s/%s%s_piplus%s.root",path_to_output_KshortPiplus.c_str(), year.c_str(),magnet.c_str(),year.c_str(),magnet.c_str(),newName.c_str()));
  1893. }
  1894. }
  1895. }
  1896. }
  1897. if (bothPol) magnet = "both";
  1898. /////////////////////
  1899. // Branches //
  1900. /////////////////////
  1901. //Just load everything in case it's needed later
  1902. /////////////////////
  1903. ///B+
  1904. Double_t B_plus_PX = 0.;
  1905. Double_t B_plus_PY = 0.;
  1906. Double_t B_plus_PZ = 0.;
  1907. Double_t B_plus_PT = 0.;
  1908. Double_t B_plus_PE = 0.;
  1909. Double_t B_plus_ETA = 0.;
  1910. Double_t B_plus_PHI = 0.;
  1911. Double_t B_plus_TRUE_PX = 0.;
  1912. Double_t B_plus_TRUE_PY = 0.;
  1913. Double_t B_plus_TRUE_PZ = 0.;
  1914. Double_t B_plus_TRUE_PT = 0.;
  1915. Double_t B_plus_TRUE_PE = 0.;
  1916. Double_t B_plus_TRUE_ETA = 0.;
  1917. Double_t B_plus_TRUE_PHI = 0.;
  1918. Double_t B_plus_PX_DTF = 0.;
  1919. Double_t B_plus_PY_DTF = 0.;
  1920. Double_t B_plus_PZ_DTF = 0.;
  1921. Double_t B_plus_PT_DTF = 0.;
  1922. Double_t B_plus_PE_DTF = 0.;
  1923. Double_t B_plus_ETA_DTF = 0.;
  1924. Double_t B_plus_PHI_DTF = 0.;
  1925. ///K*+
  1926. Double_t K_star_plus_PX = 0.;
  1927. Double_t K_star_plus_PY = 0.;
  1928. Double_t K_star_plus_PZ = 0.;
  1929. Double_t K_star_plus_PT = 0.;
  1930. Double_t K_star_plus_PE = 0.;
  1931. Double_t K_star_plus_ETA = 0.;
  1932. Double_t K_star_plus_PHI = 0.;
  1933. Double_t K_star_plus_TRUE_PX = 0.;
  1934. Double_t K_star_plus_TRUE_PY = 0.;
  1935. Double_t K_star_plus_TRUE_PZ = 0.;
  1936. Double_t K_star_plus_TRUE_PT = 0.;
  1937. Double_t K_star_plus_TRUE_PE = 0.;
  1938. Double_t K_star_plus_TRUE_ETA = 0.;
  1939. Double_t K_star_plus_TRUE_PHI = 0.;
  1940. Double_t K_star_plus_PX_DTF = 0.;
  1941. Double_t K_star_plus_PY_DTF = 0.;
  1942. Double_t K_star_plus_PZ_DTF = 0.;
  1943. Double_t K_star_plus_PT_DTF = 0.;
  1944. Double_t K_star_plus_PE_DTF = 0.;
  1945. Double_t K_star_plus_ETA_DTF = 0.;
  1946. Double_t K_star_plus_PHI_DTF = 0.;
  1947. ///K+
  1948. Double_t K_plus_PX = 0.;
  1949. Double_t K_plus_PY = 0.;
  1950. Double_t K_plus_PZ = 0.;
  1951. Double_t K_plus_PT = 0.;
  1952. Double_t K_plus_PE = 0.;
  1953. Double_t K_plus_ETA = 0.;
  1954. Double_t K_plus_PHI = 0.;
  1955. Double_t K_plus_TRUE_PX = 0.;
  1956. Double_t K_plus_TRUE_PY = 0.;
  1957. Double_t K_plus_TRUE_PZ = 0.;
  1958. Double_t K_plus_TRUE_PT = 0.;
  1959. Double_t K_plus_TRUE_PE = 0.;
  1960. Double_t K_plus_TRUE_ETA = 0.;
  1961. Double_t K_plus_TRUE_PHI = 0.;
  1962. Double_t K_plus_PX_DTF = 0.;
  1963. Double_t K_plus_PY_DTF = 0.;
  1964. Double_t K_plus_PZ_DTF = 0.;
  1965. Double_t K_plus_PE_DTF = 0.;
  1966. Double_t K_plus_PT_DTF = 0.;
  1967. Double_t K_plus_ETA_DTF = 0.;
  1968. Double_t K_plus_PHI_DTF = 0.;
  1969. ///pi0 (merged)
  1970. Double_t pi_zero_merged_PX = 0.;
  1971. Double_t pi_zero_merged_PY = 0.;
  1972. Double_t pi_zero_merged_PZ = 0.;
  1973. Double_t pi_zero_merged_PT = 0.;
  1974. Double_t pi_zero_merged_PE = 0.;
  1975. Double_t pi_zero_merged_ETA = 0.;
  1976. Double_t pi_zero_merged_PHI = 0.;
  1977. Double_t pi_zero_merged_TRUE_PX = 0.;
  1978. Double_t pi_zero_merged_TRUE_PY = 0.;
  1979. Double_t pi_zero_merged_TRUE_PZ = 0.;
  1980. Double_t pi_zero_merged_TRUE_PT = 0.;
  1981. Double_t pi_zero_merged_TRUE_PE = 0.;
  1982. Double_t pi_zero_merged_TRUE_ETA = 0.;
  1983. Double_t pi_zero_merged_TRUE_PHI = 0.;
  1984. Double_t pi_zero_merged_PX_DTF = 0.;
  1985. Double_t pi_zero_merged_PY_DTF = 0.;
  1986. Double_t pi_zero_merged_PZ_DTF = 0.;
  1987. Double_t pi_zero_merged_PT_DTF = 0.;
  1988. Double_t pi_zero_merged_PE_DTF = 0.;
  1989. Double_t pi_zero_merged_ETA_DTF = 0.;
  1990. Double_t pi_zero_merged_PHI_DTF = 0.;
  1991. ///pi0 (resolved)
  1992. Double_t pi_zero_resolved_PX = 0.;
  1993. Double_t pi_zero_resolved_PY = 0.;
  1994. Double_t pi_zero_resolved_PZ = 0.;
  1995. Double_t pi_zero_resolved_PT = 0.;
  1996. Double_t pi_zero_resolved_PE = 0.;
  1997. Double_t pi_zero_resolved_ETA = 0.;
  1998. Double_t pi_zero_resolved_PHI = 0.;
  1999. Double_t pi_zero_resolved_TRUE_PX = 0.;
  2000. Double_t pi_zero_resolved_TRUE_PY = 0.;
  2001. Double_t pi_zero_resolved_TRUE_PZ = 0.;
  2002. Double_t pi_zero_resolved_TRUE_PT = 0.;
  2003. Double_t pi_zero_resolved_TRUE_PE = 0.;
  2004. Double_t pi_zero_resolved_TRUE_ETA = 0.;
  2005. Double_t pi_zero_resolved_TRUE_PHI = 0.;
  2006. Double_t pi_zero_resolved_PX_DTF = 0.;
  2007. Double_t pi_zero_resolved_PY_DTF = 0.;
  2008. Double_t pi_zero_resolved_PZ_DTF = 0.;
  2009. Double_t pi_zero_resolved_PT_DTF = 0.;
  2010. Double_t pi_zero_resolved_PE_DTF = 0.;
  2011. Double_t pi_zero_resolved_ETA_DTF = 0.;
  2012. Double_t pi_zero_resolved_PHI_DTF = 0.;
  2013. ///Kshort
  2014. Double_t K_short_PX = 0.;
  2015. Double_t K_short_PY = 0.;
  2016. Double_t K_short_PZ = 0.;
  2017. Double_t K_short_PT = 0.;
  2018. Double_t K_short_PE = 0.;
  2019. Double_t K_short_ETA = 0.;
  2020. Double_t K_short_PHI = 0.;
  2021. Double_t K_short_TRUE_PX = 0.;
  2022. Double_t K_short_TRUE_PY = 0.;
  2023. Double_t K_short_TRUE_PZ = 0.;
  2024. Double_t K_short_TRUE_PT = 0.;
  2025. Double_t K_short_TRUE_PE = 0.;
  2026. Double_t K_short_TRUE_ETA = 0.;
  2027. Double_t K_short_TRUE_PHI = 0.;
  2028. Double_t K_short_PX_DTF = 0.;
  2029. Double_t K_short_PY_DTF = 0.;
  2030. Double_t K_short_PZ_DTF = 0.;
  2031. Double_t K_short_PT_DTF = 0.;
  2032. Double_t K_short_PE_DTF = 0.;
  2033. Double_t K_short_ETA_DTF = 0.;
  2034. Double_t K_short_PHI_DTF = 0.;
  2035. Float_t f_K_short_M_DTF[100];
  2036. Double_t K_short_M_DTF = 0.;
  2037. ///pi+ (KS)
  2038. Double_t Ks_pi_plus_PX = 0.;
  2039. Double_t Ks_pi_plus_PY = 0.;
  2040. Double_t Ks_pi_plus_PZ = 0.;
  2041. Double_t Ks_pi_plus_PT = 0.;
  2042. Double_t Ks_pi_plus_PE = 0.;
  2043. Double_t Ks_pi_plus_ETA = 0.;
  2044. Double_t Ks_pi_plus_PHI = 0.;
  2045. Double_t Ks_pi_plus_TRUE_PX = 0.;
  2046. Double_t Ks_pi_plus_TRUE_PY = 0.;
  2047. Double_t Ks_pi_plus_TRUE_PZ = 0.;
  2048. Double_t Ks_pi_plus_TRUE_PT = 0.;
  2049. Double_t Ks_pi_plus_TRUE_PE = 0.;
  2050. Double_t Ks_pi_plus_TRUE_ETA = 0.;
  2051. Double_t Ks_pi_plus_TRUE_PHI = 0.;
  2052. Double_t Ks_pi_plus_PX_DTF = 0.;
  2053. Double_t Ks_pi_plus_PY_DTF = 0.;
  2054. Double_t Ks_pi_plus_PZ_DTF = 0.;
  2055. Double_t Ks_pi_plus_PT_DTF = 0.;
  2056. Double_t Ks_pi_plus_PE_DTF = 0.;
  2057. Double_t Ks_pi_plus_ETA_DTF = 0.;
  2058. Double_t Ks_pi_plus_PHI_DTF = 0.;
  2059. ///pi- (KS)
  2060. Double_t Ks_pi_minus_PX = 0.;
  2061. Double_t Ks_pi_minus_PY = 0.;
  2062. Double_t Ks_pi_minus_PZ = 0.;
  2063. Double_t Ks_pi_minus_PT = 0.;
  2064. Double_t Ks_pi_minus_PE = 0.;
  2065. Double_t Ks_pi_minus_ETA = 0.;
  2066. Double_t Ks_pi_minus_PHI = 0.;
  2067. Double_t Ks_pi_minus_TRUE_PX = 0.;
  2068. Double_t Ks_pi_minus_TRUE_PY = 0.;
  2069. Double_t Ks_pi_minus_TRUE_PZ = 0.;
  2070. Double_t Ks_pi_minus_TRUE_PT = 0.;
  2071. Double_t Ks_pi_minus_TRUE_PE = 0.;
  2072. Double_t Ks_pi_minus_TRUE_ETA = 0.;
  2073. Double_t Ks_pi_minus_TRUE_PHI = 0.;
  2074. Double_t Ks_pi_minus_PX_DTF = 0.;
  2075. Double_t Ks_pi_minus_PY_DTF = 0.;
  2076. Double_t Ks_pi_minus_PZ_DTF = 0.;
  2077. Double_t Ks_pi_minus_PT_DTF = 0.;
  2078. Double_t Ks_pi_minus_PE_DTF = 0.;
  2079. Double_t Ks_pi_minus_ETA_DTF = 0.;
  2080. Double_t Ks_pi_minus_PHI_DTF = 0.;
  2081. ///pi+
  2082. Double_t pi_plus_PX = 0.;
  2083. Double_t pi_plus_PY = 0.;
  2084. Double_t pi_plus_PZ = 0.;
  2085. Double_t pi_plus_PT = 0.;
  2086. Double_t pi_plus_PE = 0.;
  2087. Double_t pi_plus_ETA = 0.;
  2088. Double_t pi_plus_PHI = 0.;
  2089. Double_t pi_plus_TRUE_PX = 0.;
  2090. Double_t pi_plus_TRUE_PY = 0.;
  2091. Double_t pi_plus_TRUE_PZ = 0.;
  2092. Double_t pi_plus_TRUE_PT = 0.;
  2093. Double_t pi_plus_TRUE_PE = 0.;
  2094. Double_t pi_plus_TRUE_ETA = 0.;
  2095. Double_t pi_plus_TRUE_PHI = 0.;
  2096. Double_t pi_plus_PX_DTF = 0.;
  2097. Double_t pi_plus_PY_DTF = 0.;
  2098. Double_t pi_plus_PZ_DTF = 0.;
  2099. Double_t pi_plus_PT_DTF = 0.;
  2100. Double_t pi_plus_PE_DTF = 0.;
  2101. Double_t pi_plus_ETA_DTF = 0.;
  2102. Double_t pi_plus_PHI_DTF = 0.;
  2103. ///mu+
  2104. Double_t mu_minus_PX = 0.;
  2105. Double_t mu_minus_PY = 0.;
  2106. Double_t mu_minus_PZ = 0.;
  2107. Double_t mu_minus_PT = 0.;
  2108. Double_t mu_minus_PE = 0.;
  2109. Double_t mu_minus_ETA = 0.;
  2110. Double_t mu_minus_PHI = 0.;
  2111. Double_t mu_minus_TRUE_PX = 0.;
  2112. Double_t mu_minus_TRUE_PY = 0.;
  2113. Double_t mu_minus_TRUE_PZ = 0.;
  2114. Double_t mu_minus_TRUE_PT = 0.;
  2115. Double_t mu_minus_TRUE_PE = 0.;
  2116. Double_t mu_minus_TRUE_ETA = 0.;
  2117. Double_t mu_minus_TRUE_PHI = 0.;
  2118. Double_t mu_minus_PX_DTF = 0.;
  2119. Double_t mu_minus_PY_DTF = 0.;
  2120. Double_t mu_minus_PZ_DTF = 0.;
  2121. Double_t mu_minus_PT_DTF = 0.;
  2122. Double_t mu_minus_PE_DTF = 0.;
  2123. Double_t mu_minus_ETA_DTF = 0.;
  2124. Double_t mu_minus_PHI_DTF = 0.;
  2125. ///mu+
  2126. Double_t mu_plus_PX = 0.;
  2127. Double_t mu_plus_PY = 0.;
  2128. Double_t mu_plus_PZ = 0.;
  2129. Double_t mu_plus_PT = 0.;
  2130. Double_t mu_plus_PE = 0.;
  2131. Double_t mu_plus_ETA = 0.;
  2132. Double_t mu_plus_PHI = 0.;
  2133. Double_t mu_plus_TRUE_PX = 0.;
  2134. Double_t mu_plus_TRUE_PY = 0.;
  2135. Double_t mu_plus_TRUE_PZ = 0.;
  2136. Double_t mu_plus_TRUE_PT = 0.;
  2137. Double_t mu_plus_TRUE_PE = 0.;
  2138. Double_t mu_plus_TRUE_ETA = 0.;
  2139. Double_t mu_plus_TRUE_PHI = 0.;
  2140. Double_t mu_plus_PX_DTF = 0.;
  2141. Double_t mu_plus_PY_DTF = 0.;
  2142. Double_t mu_plus_PZ_DTF = 0.;
  2143. Double_t mu_plus_PT_DTF = 0.;
  2144. Double_t mu_plus_PE_DTF = 0.;
  2145. Double_t mu_plus_ETA_DTF = 0.;
  2146. Double_t mu_plus_PHI_DTF = 0.;
  2147. ///gamma1
  2148. Double_t gamma1_PX = 0.;
  2149. Double_t gamma1_PY = 0.;
  2150. Double_t gamma1_PZ = 0.;
  2151. Double_t gamma1_PT = 0.;
  2152. Double_t gamma1_PE = 0.;
  2153. Double_t gamma1_ETA = 0.;
  2154. Double_t gamma1_PHI = 0.;
  2155. Double_t gamma1_TRUE_PX = 0.;
  2156. Double_t gamma1_TRUE_PY = 0.;
  2157. Double_t gamma1_TRUE_PZ = 0.;
  2158. Double_t gamma1_TRUE_PT = 0.;
  2159. Double_t gamma1_TRUE_PE = 0.;
  2160. Double_t gamma1_TRUE_ETA = 0.;
  2161. Double_t gamma1_TRUE_PHI = 0.;
  2162. Double_t gamma1_PX_DTF = 0.;
  2163. Double_t gamma1_PY_DTF = 0.;
  2164. Double_t gamma1_PZ_DTF = 0.;
  2165. Double_t gamma1_PT_DTF = 0.;
  2166. Double_t gamma1_PE_DTF = 0.;
  2167. Double_t gamma1_ETA_DTF = 0.;
  2168. Double_t gamma1_PHI_DTF = 0.;
  2169. ///gamma2
  2170. Double_t gamma2_PX = 0.;
  2171. Double_t gamma2_PY = 0.;
  2172. Double_t gamma2_PZ = 0.;
  2173. Double_t gamma2_PT = 0.;
  2174. Double_t gamma2_PE = 0.;
  2175. Double_t gamma2_ETA = 0.;
  2176. Double_t gamma2_PHI = 0.;
  2177. Double_t gamma2_PX_DTF = 0.;
  2178. Double_t gamma2_PY_DTF = 0.;
  2179. Double_t gamma2_PZ_DTF = 0.;
  2180. Double_t gamma2_PT_DTF = 0.;
  2181. Double_t gamma2_PE_DTF = 0.;
  2182. Double_t gamma2_ETA_DTF = 0.;
  2183. Double_t gamma2_PHI_DTF = 0.;
  2184. Double_t gamma2_TRUE_PX = 0.;
  2185. Double_t gamma2_TRUE_PY = 0.;
  2186. Double_t gamma2_TRUE_PZ = 0.;
  2187. Double_t gamma2_TRUE_PT = 0.;
  2188. Double_t gamma2_TRUE_PE = 0.;
  2189. Double_t gamma2_TRUE_ETA = 0.;
  2190. Double_t gamma2_TRUE_PHI = 0.;
  2191. //angles
  2192. Double_t B_plus_ThetaL = 0.;
  2193. Double_t B_plus_ThetaK = 0.;
  2194. Double_t B_plus_Phi = 0.;
  2195. Double_t B_plus_ThetaL_DTF = 0.;
  2196. Double_t B_plus_ThetaK_DTF = 0.;
  2197. Double_t B_plus_Phi_DTF = 0.;
  2198. Double_t B_plus_TRUE_ThetaL = 0.;
  2199. Double_t B_plus_TRUE_ThetaK = 0.;
  2200. Double_t B_plus_TRUE_Phi = 0.;
  2201. Double_t open_angle = 0.;
  2202. Double_t open_angle_DTF = 0.;
  2203. Double_t TRUE_open_angle = 0.;
  2204. //global variables
  2205. Double_t B_plus_ENDVERTEX_Z = 0.;
  2206. Double_t B_plus_ENDVERTEX_ZERR = 0.;
  2207. Double_t B_plus_OWNPV_Z = 0.;
  2208. Double_t B_plus_OWNPV_ZERR = 0.;
  2209. Double_t B_plus_TRUEORIGINVERTEX_Z = 0.;
  2210. Double_t B_plus_TRUEENDVERTEX_Z = 0.;
  2211. Double_t B_plus_TOPPV_Z = 0.;//TODO: what is this?
  2212. Double_t B_plus_DTF_PV_Z = 0.;
  2213. Double_t K_star_plus_ENDVERTEX_Z = 0.;
  2214. Double_t K_star_plus_ENDVERTEX_ZERR = 0.;
  2215. Double_t K_star_plus_OWNPV_Z = 0.;
  2216. Double_t K_star_plus_OWNPV_ZERR = 0.;
  2217. Double_t K_star_plus_TRUEORIGINVERTEX_Z = 0.;
  2218. Double_t K_star_plus_TRUEENDVERTEX_Z = 0.;
  2219. Double_t K_plus_OWNPV_Z = 0.;
  2220. Double_t K_plus_OWNPV_ZERR = 0.;
  2221. Double_t K_plus_TRUEORIGINVERTEX_Z = 0.;
  2222. Double_t K_plus_TRUEENDVERTEX_Z = 0.;
  2223. Double_t pi_zero_resolved_TRUEORIGINVERTEX_Z = 0.;
  2224. Double_t pi_zero_resolved_TRUEENDVERTEX_Z = 0.;
  2225. Double_t gamma1_TRUEORIGINVERTEX_Z = 0.;
  2226. Double_t gamma1_TRUEENDVERTEX_Z = 0.;
  2227. Double_t gamma2_TRUEORIGINVERTEX_Z = 0.;
  2228. Double_t gamma2_TRUEENDVERTEX_Z = 0.;
  2229. Double_t mu_plus_OWNPV_Z = 0.;
  2230. Double_t mu_plus_OWNPV_ZERR = 0.;
  2231. Double_t mu_plus_TRUEORIGINVERTEX_Z = 0.;
  2232. Double_t mu_plus_TRUEENDVERTEX_Z = 0.;
  2233. Double_t mu_minus_OWNPV_Z = 0.;
  2234. Double_t mu_minus_OWNPV_ZERR = 0.;
  2235. Double_t mu_minus_TRUEORIGINVERTEX_Z = 0.;
  2236. Double_t mu_minus_TRUEENDVERTEX_Z = 0.;
  2237. tree->SetBranchStatus("*",1);
  2238. //particle masses and momenta
  2239. tree -> SetBranchAddress( "B_plus_PX" , &B_plus_PX );
  2240. tree -> SetBranchAddress( "B_plus_PY" , &B_plus_PY );
  2241. tree -> SetBranchAddress( "B_plus_PZ" , &B_plus_PZ );
  2242. tree -> SetBranchAddress( "B_plus_PT" , &B_plus_PT );
  2243. tree -> SetBranchAddress( "B_plus_PE" , &B_plus_PE );
  2244. tree -> SetBranchAddress( "B_plus_ETA" , &B_plus_ETA );
  2245. tree -> SetBranchAddress( "B_plus_PHI" , &B_plus_PHI );
  2246. tree -> SetBranchAddress( "B_plus_TRUE_PX" , &B_plus_TRUE_PX );
  2247. tree -> SetBranchAddress( "B_plus_TRUE_PY" , &B_plus_TRUE_PY );
  2248. tree -> SetBranchAddress( "B_plus_TRUE_PZ" , &B_plus_TRUE_PZ );
  2249. tree -> SetBranchAddress( "B_plus_TRUE_PE" , &B_plus_TRUE_PE );
  2250. tree -> SetBranchAddress( "B_plus_TRUE_PT" , &B_plus_TRUE_PT );
  2251. tree -> SetBranchAddress( "B_plus_TRUE_ETA" , &B_plus_TRUE_ETA );
  2252. tree -> SetBranchAddress( "B_plus_TRUE_PHI" , &B_plus_TRUE_PHI );
  2253. tree -> SetBranchAddress( "B_plus_PX_DTF" , &B_plus_PX_DTF );
  2254. tree -> SetBranchAddress( "B_plus_PY_DTF" , &B_plus_PY_DTF );
  2255. tree -> SetBranchAddress( "B_plus_PZ_DTF" , &B_plus_PZ_DTF );
  2256. tree -> SetBranchAddress( "B_plus_PT_DTF" , &B_plus_PT_DTF );
  2257. tree -> SetBranchAddress( "B_plus_PE_DTF" , &B_plus_PE_DTF );
  2258. tree -> SetBranchAddress( "B_plus_ETA_DTF" , &B_plus_ETA_DTF );
  2259. tree -> SetBranchAddress( "B_plus_PHI_DTF" , &B_plus_PHI_DTF );
  2260. tree -> SetBranchAddress( "K_star_plus_PX" , &K_star_plus_PX );
  2261. tree -> SetBranchAddress( "K_star_plus_PY" , &K_star_plus_PY );
  2262. tree -> SetBranchAddress( "K_star_plus_PZ" , &K_star_plus_PZ );
  2263. tree -> SetBranchAddress( "K_star_plus_PE" , &K_star_plus_PE );
  2264. tree -> SetBranchAddress( "K_star_plus_PT" , &K_star_plus_PT );
  2265. tree -> SetBranchAddress( "K_star_plus_PHI" , &K_star_plus_PHI );
  2266. tree -> SetBranchAddress( "K_star_plus_ETA" , &K_star_plus_ETA );
  2267. tree -> SetBranchAddress( "K_star_plus_TRUE_PX" , &K_star_plus_TRUE_PX );
  2268. tree -> SetBranchAddress( "K_star_plus_TRUE_PY" , &K_star_plus_TRUE_PY );
  2269. tree -> SetBranchAddress( "K_star_plus_TRUE_PZ" , &K_star_plus_TRUE_PZ );
  2270. tree -> SetBranchAddress( "K_star_plus_TRUE_PE" , &K_star_plus_TRUE_PE );
  2271. tree -> SetBranchAddress( "K_star_plus_TRUE_PT" , &K_star_plus_TRUE_PT );
  2272. tree -> SetBranchAddress( "K_star_plus_TRUE_ETA" , &K_star_plus_TRUE_ETA );
  2273. tree -> SetBranchAddress( "K_star_plus_TRUE_PHI" , &K_star_plus_TRUE_PHI );
  2274. tree -> SetBranchAddress( "K_star_plus_PX_DTF" , &K_star_plus_PX_DTF );
  2275. tree -> SetBranchAddress( "K_star_plus_PY_DTF" , &K_star_plus_PY_DTF );
  2276. tree -> SetBranchAddress( "K_star_plus_PZ_DTF" , &K_star_plus_PZ_DTF );
  2277. tree -> SetBranchAddress( "K_star_plus_PE_DTF" , &K_star_plus_PE_DTF );
  2278. tree -> SetBranchAddress( "K_star_plus_PT_DTF" , &K_star_plus_PT_DTF );
  2279. tree -> SetBranchAddress( "K_star_plus_PHI_DTF" , &K_star_plus_PHI_DTF );
  2280. tree -> SetBranchAddress( "K_star_plus_ETA_DTF" , &K_star_plus_ETA_DTF );
  2281. if(Kst2Kpluspi0Merged){ //TODO: in case one really wants to do that, add DTF info
  2282. tree -> SetBranchAddress( "pi_zero_merged_PX" , &pi_zero_merged_PX );
  2283. tree -> SetBranchAddress( "pi_zero_merged_PY" , &pi_zero_merged_PY );
  2284. tree -> SetBranchAddress( "pi_zero_merged_PZ" , &pi_zero_merged_PZ );
  2285. tree -> SetBranchAddress( "pi_zero_merged_PE" , &pi_zero_merged_PE );
  2286. tree -> SetBranchAddress( "pi_zero_merged_PT" , &pi_zero_merged_PT );
  2287. tree -> SetBranchAddress( "pi_zero_merged_ETA" , &pi_zero_merged_ETA );
  2288. tree -> SetBranchAddress( "pi_zero_merged_PHI" , &pi_zero_merged_PHI );
  2289. tree -> SetBranchAddress( "pi_zero_merged_TRUE_PX" , &pi_zero_merged_TRUE_PX );
  2290. tree -> SetBranchAddress( "pi_zero_merged_TRUE_PY" , &pi_zero_merged_TRUE_PY );
  2291. tree -> SetBranchAddress( "pi_zero_merged_TRUE_PZ" , &pi_zero_merged_TRUE_PZ );
  2292. tree -> SetBranchAddress( "pi_zero_merged_TRUE_PE" , &pi_zero_merged_TRUE_PE );
  2293. tree -> SetBranchAddress( "pi_zero_merged_TRUE_PT" , &pi_zero_merged_TRUE_PT );
  2294. tree -> SetBranchAddress( "pi_zero_merged_TRUE_ETA" , &pi_zero_merged_TRUE_ETA );
  2295. tree -> SetBranchAddress( "pi_zero_merged_TRUE_PHI" , &pi_zero_merged_TRUE_PHI );
  2296. tree -> SetBranchAddress( "pi_zero_merged_PX_DTF" , &pi_zero_merged_PX_DTF );
  2297. tree -> SetBranchAddress( "pi_zero_merged_PY_DTF" , &pi_zero_merged_PY_DTF );
  2298. tree -> SetBranchAddress( "pi_zero_merged_PZ_DTF" , &pi_zero_merged_PZ_DTF );
  2299. tree -> SetBranchAddress( "pi_zero_merged_PE_DTF" , &pi_zero_merged_PE_DTF );
  2300. tree -> SetBranchAddress( "pi_zero_merged_PT_DTF" , &pi_zero_merged_PT_DTF );
  2301. tree -> SetBranchAddress( "pi_zero_merged_ETA_DTF" , &pi_zero_merged_ETA_DTF );
  2302. tree -> SetBranchAddress( "pi_zero_merged_PHI_DTF" , &pi_zero_merged_PHI_DTF );
  2303. }
  2304. if(Kst2Kpluspi0Resolved){
  2305. tree -> SetBranchAddress( "pi_zero_resolved_PX" , &pi_zero_resolved_PX );
  2306. tree -> SetBranchAddress( "pi_zero_resolved_PY" , &pi_zero_resolved_PY );
  2307. tree -> SetBranchAddress( "pi_zero_resolved_PZ" , &pi_zero_resolved_PZ );
  2308. tree -> SetBranchAddress( "pi_zero_resolved_PT" , &pi_zero_resolved_PT );
  2309. tree -> SetBranchAddress( "pi_zero_resolved_PE" , &pi_zero_resolved_PE );
  2310. tree -> SetBranchAddress( "pi_zero_resolved_ETA" , &pi_zero_resolved_ETA );
  2311. tree -> SetBranchAddress( "pi_zero_resolved_PHI" , &pi_zero_resolved_PHI );
  2312. tree -> SetBranchAddress( "pi_zero_resolved_TRUE_PX" , &pi_zero_resolved_TRUE_PX );
  2313. tree -> SetBranchAddress( "pi_zero_resolved_TRUE_PY" , &pi_zero_resolved_TRUE_PY );
  2314. tree -> SetBranchAddress( "pi_zero_resolved_TRUE_PZ" , &pi_zero_resolved_TRUE_PZ );
  2315. tree -> SetBranchAddress( "pi_zero_resolved_TRUE_PE" , &pi_zero_resolved_TRUE_PE );
  2316. tree -> SetBranchAddress( "pi_zero_resolved_TRUE_PT" , &pi_zero_resolved_TRUE_PT );
  2317. tree -> SetBranchAddress( "pi_zero_resolved_TRUE_ETA" , &pi_zero_resolved_TRUE_ETA );
  2318. tree -> SetBranchAddress( "pi_zero_resolved_TRUE_PHI" , &pi_zero_resolved_TRUE_PHI );
  2319. tree -> SetBranchAddress( "pi_zero_resolved_PX_DTF" , &pi_zero_resolved_PX_DTF );
  2320. tree -> SetBranchAddress( "pi_zero_resolved_PY_DTF" , &pi_zero_resolved_PY_DTF );
  2321. tree -> SetBranchAddress( "pi_zero_resolved_PZ_DTF" , &pi_zero_resolved_PZ_DTF );
  2322. tree -> SetBranchAddress( "pi_zero_resolved_PE_DTF" , &pi_zero_resolved_PE_DTF );
  2323. tree -> SetBranchAddress( "pi_zero_resolved_PT_DTF" , &pi_zero_resolved_PT_DTF );
  2324. tree -> SetBranchAddress( "pi_zero_resolved_ETA_DTF" , &pi_zero_resolved_ETA_DTF );
  2325. tree -> SetBranchAddress( "pi_zero_resolved_PHI_DTF" , &pi_zero_resolved_PHI_DTF );
  2326. tree -> SetBranchAddress( "gamma1_PX" , &gamma1_PX );
  2327. tree -> SetBranchAddress( "gamma1_PY" , &gamma1_PY );
  2328. tree -> SetBranchAddress( "gamma1_PZ" , &gamma1_PZ );
  2329. tree -> SetBranchAddress( "gamma1_PE" , &gamma1_PE );
  2330. tree -> SetBranchAddress( "gamma1_PT" , &gamma1_PT );
  2331. tree -> SetBranchAddress( "gamma1_ETA" , &gamma1_ETA );
  2332. tree -> SetBranchAddress( "gamma1_PHI" , &gamma1_PHI );
  2333. tree -> SetBranchAddress( "gamma1_TRUE_PX" , &gamma1_TRUE_PX );
  2334. tree -> SetBranchAddress( "gamma1_TRUE_PY" , &gamma1_TRUE_PY );
  2335. tree -> SetBranchAddress( "gamma1_TRUE_PZ" , &gamma1_TRUE_PZ );
  2336. tree -> SetBranchAddress( "gamma1_TRUE_PE" , &gamma1_TRUE_PE );
  2337. tree -> SetBranchAddress( "gamma1_TRUE_PT" , &gamma1_TRUE_PT );
  2338. tree -> SetBranchAddress( "gamma1_TRUE_ETA" , &gamma1_TRUE_ETA );
  2339. tree -> SetBranchAddress( "gamma1_TRUE_PHI" , &gamma1_TRUE_PHI );
  2340. tree -> SetBranchAddress( "gamma1_PX_DTF" , &gamma1_PX_DTF );
  2341. tree -> SetBranchAddress( "gamma1_PY_DTF" , &gamma1_PY_DTF );
  2342. tree -> SetBranchAddress( "gamma1_PZ_DTF" , &gamma1_PZ_DTF );
  2343. tree -> SetBranchAddress( "gamma1_PE_DTF" , &gamma1_PE_DTF );
  2344. tree -> SetBranchAddress( "gamma1_PT_DTF" , &gamma1_PT_DTF );
  2345. tree -> SetBranchAddress( "gamma1_ETA_DTF" , &gamma1_ETA_DTF );
  2346. tree -> SetBranchAddress( "gamma1_PHI_DTF" , &gamma1_PHI_DTF );
  2347. tree -> SetBranchAddress( "gamma2_PX" , &gamma2_PX );
  2348. tree -> SetBranchAddress( "gamma2_PY" , &gamma2_PY );
  2349. tree -> SetBranchAddress( "gamma2_PZ" , &gamma2_PZ );
  2350. tree -> SetBranchAddress( "gamma2_PE" , &gamma2_PE );
  2351. tree -> SetBranchAddress( "gamma2_PT" , &gamma2_PT );
  2352. tree -> SetBranchAddress( "gamma2_ETA" , &gamma2_ETA );
  2353. tree -> SetBranchAddress( "gamma2_PHI" , &gamma2_PHI );
  2354. tree -> SetBranchAddress( "gamma2_TRUE_PX" , &gamma2_TRUE_PX );
  2355. tree -> SetBranchAddress( "gamma2_TRUE_PY" , &gamma2_TRUE_PY );
  2356. tree -> SetBranchAddress( "gamma2_TRUE_PZ" , &gamma2_TRUE_PZ );
  2357. tree -> SetBranchAddress( "gamma2_TRUE_PE" , &gamma2_TRUE_PE );
  2358. tree -> SetBranchAddress( "gamma2_TRUE_PT" , &gamma2_TRUE_PT );
  2359. tree -> SetBranchAddress( "gamma2_TRUE_ETA" , &gamma2_TRUE_ETA );
  2360. tree -> SetBranchAddress( "gamma2_TRUE_PHI" , &gamma2_TRUE_PHI );
  2361. tree -> SetBranchAddress( "gamma2_PX_DTF" , &gamma2_PX_DTF );
  2362. tree -> SetBranchAddress( "gamma2_PY_DTF" , &gamma2_PY_DTF );
  2363. tree -> SetBranchAddress( "gamma2_PZ_DTF" , &gamma2_PZ_DTF );
  2364. tree -> SetBranchAddress( "gamma2_PE_DTF" , &gamma2_PE_DTF );
  2365. tree -> SetBranchAddress( "gamma2_PT_DTF" , &gamma2_PT_DTF );
  2366. tree -> SetBranchAddress( "gamma2_ETA_DTF" , &gamma2_ETA_DTF );
  2367. tree -> SetBranchAddress( "gamma2_PHI_DTF" , &gamma2_PHI_DTF );
  2368. }
  2369. if(Kst2Kpluspi0Merged || Kst2Kpluspi0Resolved){
  2370. tree -> SetBranchAddress( "K_plus_PX" , &K_plus_PX );
  2371. tree -> SetBranchAddress( "K_plus_PY" , &K_plus_PY );
  2372. tree -> SetBranchAddress( "K_plus_PZ" , &K_plus_PZ );
  2373. tree -> SetBranchAddress( "K_plus_PE" , &K_plus_PE );
  2374. tree -> SetBranchAddress( "K_plus_PT" , &K_plus_PT );
  2375. tree -> SetBranchAddress( "K_plus_ETA" , &K_plus_ETA );
  2376. tree -> SetBranchAddress( "K_plus_PHI" , &K_plus_PHI );
  2377. tree -> SetBranchAddress( "K_plus_TRUE_PX" , &K_plus_TRUE_PX );
  2378. tree -> SetBranchAddress( "K_plus_TRUE_PY" , &K_plus_TRUE_PY );
  2379. tree -> SetBranchAddress( "K_plus_TRUE_PZ" , &K_plus_TRUE_PZ );
  2380. tree -> SetBranchAddress( "K_plus_TRUE_PE" , &K_plus_TRUE_PE );
  2381. tree -> SetBranchAddress( "K_plus_TRUE_PT" , &K_plus_TRUE_PT );
  2382. tree -> SetBranchAddress( "K_plus_TRUE_ETA" , &K_plus_TRUE_ETA );
  2383. tree -> SetBranchAddress( "K_plus_TRUE_PHI" , &K_plus_TRUE_PHI );
  2384. tree -> SetBranchAddress( "K_plus_PX_DTF" , &K_plus_PX_DTF );
  2385. tree -> SetBranchAddress( "K_plus_PY_DTF" , &K_plus_PY_DTF );
  2386. tree -> SetBranchAddress( "K_plus_PZ_DTF" , &K_plus_PZ_DTF );
  2387. tree -> SetBranchAddress( "K_plus_PE_DTF" , &K_plus_PE_DTF );
  2388. tree -> SetBranchAddress( "K_plus_PT_DTF" , &K_plus_PT_DTF );
  2389. tree -> SetBranchAddress( "K_plus_ETA_DTF" , &K_plus_ETA_DTF );
  2390. tree -> SetBranchAddress( "K_plus_PHI_DTF" , &K_plus_PHI_DTF );
  2391. }
  2392. tree -> SetBranchAddress( "mu_minus_PX" , &mu_minus_PX );
  2393. tree -> SetBranchAddress( "mu_minus_PY" , &mu_minus_PY );
  2394. tree -> SetBranchAddress( "mu_minus_PZ" , &mu_minus_PZ );
  2395. tree -> SetBranchAddress( "mu_minus_PE" , &mu_minus_PE );
  2396. tree -> SetBranchAddress( "mu_minus_PT" , &mu_minus_PT );
  2397. tree -> SetBranchAddress( "mu_minus_PT" , &mu_minus_PT );
  2398. tree -> SetBranchAddress( "mu_minus_PT" , &mu_minus_PT );
  2399. tree -> SetBranchAddress( "mu_minus_TRUE_PX" , &mu_minus_TRUE_PX );
  2400. tree -> SetBranchAddress( "mu_minus_TRUE_PY" , &mu_minus_TRUE_PY );
  2401. tree -> SetBranchAddress( "mu_minus_TRUE_PZ" , &mu_minus_TRUE_PZ );
  2402. tree -> SetBranchAddress( "mu_minus_TRUE_PE" , &mu_minus_TRUE_PE );
  2403. tree -> SetBranchAddress( "mu_minus_TRUE_PT" , &mu_minus_TRUE_PT );
  2404. tree -> SetBranchAddress( "mu_minus_TRUE_ETA" , &mu_minus_TRUE_ETA );
  2405. tree -> SetBranchAddress( "mu_minus_TRUE_PHI" , &mu_minus_TRUE_PHI );
  2406. tree -> SetBranchAddress( "mu_minus_PX_DTF" , &mu_minus_PX_DTF );
  2407. tree -> SetBranchAddress( "mu_minus_PY_DTF" , &mu_minus_PY_DTF );
  2408. tree -> SetBranchAddress( "mu_minus_PZ_DTF" , &mu_minus_PZ_DTF );
  2409. tree -> SetBranchAddress( "mu_minus_PE_DTF" , &mu_minus_PE_DTF );
  2410. tree -> SetBranchAddress( "mu_minus_PT_DTF" , &mu_minus_PT_DTF );
  2411. tree -> SetBranchAddress( "mu_minus_ETA_DTF" , &mu_minus_ETA_DTF );
  2412. tree -> SetBranchAddress( "mu_minus_PHI_DTF" , &mu_minus_PHI_DTF );
  2413. tree -> SetBranchAddress( "mu_plus_PX" , &mu_plus_PX );
  2414. tree -> SetBranchAddress( "mu_plus_PY" , &mu_plus_PY );
  2415. tree -> SetBranchAddress( "mu_plus_PZ" , &mu_plus_PZ );
  2416. tree -> SetBranchAddress( "mu_plus_PE" , &mu_plus_PE );
  2417. tree -> SetBranchAddress( "mu_plus_PT" , &mu_plus_PT );
  2418. tree -> SetBranchAddress( "mu_plus_ETA" , &mu_plus_ETA );
  2419. tree -> SetBranchAddress( "mu_plus_PHI" , &mu_plus_PHI );
  2420. tree -> SetBranchAddress( "mu_plus_TRUE_PX" , &mu_plus_TRUE_PX );
  2421. tree -> SetBranchAddress( "mu_plus_TRUE_PY" , &mu_plus_TRUE_PY );
  2422. tree -> SetBranchAddress( "mu_plus_TRUE_PZ" , &mu_plus_TRUE_PZ );
  2423. tree -> SetBranchAddress( "mu_plus_TRUE_PE" , &mu_plus_TRUE_PE );
  2424. tree -> SetBranchAddress( "mu_plus_TRUE_PT" , &mu_plus_TRUE_PT );
  2425. tree -> SetBranchAddress( "mu_plus_TRUE_ETA" , &mu_plus_TRUE_ETA );
  2426. tree -> SetBranchAddress( "mu_plus_TRUE_PHI" , &mu_plus_TRUE_PHI );
  2427. tree -> SetBranchAddress( "mu_plus_PX_DTF" , &mu_plus_PX_DTF );
  2428. tree -> SetBranchAddress( "mu_plus_PY_DTF" , &mu_plus_PY_DTF);
  2429. tree -> SetBranchAddress( "mu_plus_PZ_DTF" , &mu_plus_PZ_DTF );
  2430. tree -> SetBranchAddress( "mu_plus_PE_DTF" , &mu_plus_PE_DTF );
  2431. tree -> SetBranchAddress( "mu_plus_PT_DTF" , &mu_plus_PT_DTF );
  2432. tree -> SetBranchAddress( "mu_plus_ETA_DTF" , &mu_plus_ETA_DTF );
  2433. tree -> SetBranchAddress( "mu_plus_PHI_DTF" , &mu_plus_PHI_DTF );
  2434. /* TODO
  2435. tree -> SetBranchAddress( "B_plus_ThetaL_DTF" , &B_plus_ThetaL_DTF);
  2436. tree -> SetBranchAddress( "B_plus_ThetaK_DTF" , &B_plus_ThetaK_DTF);
  2437. tree -> SetBranchAddress( "B_plus_Phi_DTF" , &B_plus_Phi_DTF );
  2438. */
  2439. tree -> SetBranchAddress( "B_plus_ThetaL" , &B_plus_ThetaL);
  2440. tree -> SetBranchAddress( "B_plus_ThetaK" , &B_plus_ThetaK);
  2441. tree -> SetBranchAddress( "B_plus_Phi" , &B_plus_Phi );
  2442. tree -> SetBranchAddress( "B_plus_TRUEThetaL" , &B_plus_TRUE_ThetaL);
  2443. tree -> SetBranchAddress( "B_plus_TRUEThetaK" , &B_plus_TRUE_ThetaK);
  2444. tree -> SetBranchAddress( "B_plus_TRUEPhi" , &B_plus_TRUE_Phi );
  2445. tree -> SetBranchAddress( "open_angle" , &open_angle);
  2446. tree -> SetBranchAddress( "open_angle_DTF" , &open_angle_DTF);
  2447. tree -> SetBranchAddress( "TRUE_open_angle" , &TRUE_open_angle );
  2448. //global variables
  2449. tree -> SetBranchAddress( "B_plus_ENDVERTEX_Z", &B_plus_ENDVERTEX_Z);
  2450. tree -> SetBranchAddress( "B_plus_ENDVERTEX_ZERR", &B_plus_ENDVERTEX_ZERR);
  2451. tree -> SetBranchAddress( "B_plus_OWNPV_Z", &B_plus_OWNPV_Z);
  2452. tree -> SetBranchAddress( "B_plus_OWNPV_ZERR", &B_plus_OWNPV_ZERR);
  2453. tree -> SetBranchAddress( "B_plus_TRUEORIGINVERTEX_Z", &B_plus_TRUEORIGINVERTEX_Z);
  2454. tree -> SetBranchAddress( "B_plus_TRUEENDVERTEX_Z", &B_plus_TRUEENDVERTEX_Z);
  2455. tree -> SetBranchAddress( "B_plus_DTF_PV_Z", &B_plus_DTF_PV_Z);
  2456. tree -> SetBranchAddress( "B_plus_TOPPV_Z", &B_plus_TOPPV_Z);//TODO: what is this?
  2457. tree -> SetBranchAddress( "K_star_plus_ENDVERTEX_Z", &K_star_plus_ENDVERTEX_Z);
  2458. tree -> SetBranchAddress( "K_star_plus_ENDVERTEX_ZERR", &K_star_plus_ENDVERTEX_ZERR);
  2459. tree -> SetBranchAddress( "K_star_plus_OWNPV_Z", &K_star_plus_OWNPV_Z);
  2460. tree -> SetBranchAddress( "K_star_plus_OWNPV_ZERR", &K_star_plus_OWNPV_ZERR);
  2461. tree -> SetBranchAddress( "K_star_plus_TRUEORIGINVERTEX_Z", &K_star_plus_TRUEORIGINVERTEX_Z);
  2462. tree -> SetBranchAddress( "K_star_plus_TRUEENDVERTEX_Z", &K_star_plus_TRUEENDVERTEX_Z);
  2463. tree -> SetBranchAddress( "K_plus_OWNPV_Z", &K_plus_OWNPV_Z);
  2464. tree -> SetBranchAddress( "K_plus_OWNPV_ZERR", &K_plus_OWNPV_ZERR);
  2465. tree -> SetBranchAddress( "K_plus_TRUEORIGINVERTEX_Z", &K_plus_TRUEORIGINVERTEX_Z);
  2466. tree -> SetBranchAddress( "K_plus_TRUEENDVERTEX_Z", &K_plus_TRUEENDVERTEX_Z);
  2467. tree -> SetBranchAddress( "pi_zero_resolved_TRUEORIGINVERTEX_Z", &pi_zero_resolved_TRUEORIGINVERTEX_Z);
  2468. tree -> SetBranchAddress( "pi_zero_resolved_TRUEENDVERTEX_Z", &pi_zero_resolved_TRUEENDVERTEX_Z);
  2469. tree -> SetBranchAddress( "gamma1_TRUEORIGINVERTEX_Z", &gamma1_TRUEORIGINVERTEX_Z);
  2470. tree -> SetBranchAddress( "gamma1_TRUEENDVERTEX_Z", &gamma1_TRUEENDVERTEX_Z);
  2471. tree -> SetBranchAddress( "gamma2_TRUEORIGINVERTEX_Z", &gamma2_TRUEORIGINVERTEX_Z);
  2472. tree -> SetBranchAddress( "gamma2_TRUEENDVERTEX_Z", &gamma2_TRUEENDVERTEX_Z);
  2473. tree -> SetBranchAddress( "mu_plus_OWNPV_Z", &mu_plus_OWNPV_Z);
  2474. tree -> SetBranchAddress( "mu_plus_OWNPV_ZERR", &mu_plus_OWNPV_ZERR);
  2475. tree -> SetBranchAddress( "mu_plus_TRUEORIGINVERTEX_Z", &mu_plus_TRUEORIGINVERTEX_Z);
  2476. tree -> SetBranchAddress( "mu_plus_TRUEENDVERTEX_Z", &mu_plus_TRUEENDVERTEX_Z);
  2477. tree -> SetBranchAddress( "mu_minus_OWNPV_Z", &mu_minus_OWNPV_Z);
  2478. tree -> SetBranchAddress( "mu_minus_OWNPV_ZERR", &mu_minus_OWNPV_ZERR);
  2479. tree -> SetBranchAddress( "mu_minus_TRUEORIGINVERTEX_Z", &mu_minus_TRUEORIGINVERTEX_Z);
  2480. tree -> SetBranchAddress( "mu_minus_TRUEENDVERTEX_Z", &mu_minus_TRUEENDVERTEX_Z);
  2481. int N = tree->GetEntries();
  2482. if(N == 0){
  2483. std::cout << "[ERROR]\t\tNo events found!" << std::endl;
  2484. return 0;
  2485. }
  2486. // Create outputfile
  2487. TFile *output = 0;
  2488. preselected ? newName = "_resolution_preselected_histos" : newName ="_resolution_histos";
  2489. if (truthMatched) newName = newName + "_TM";
  2490. if(Kst2Kpluspi0Resolved){
  2491. if(!MC){
  2492. output = new TFile(Form("%s/resolution/data/%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(),newName.c_str()),"RECREATE");
  2493. }
  2494. else{
  2495. if(ReferenceChannel){
  2496. output = new TFile(Form("%s/resolution/MC/RefKplusPi0/%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(),newName.c_str()),"RECREATE");
  2497. }
  2498. else if(PHSP){
  2499. output = new TFile(Form("%s/resolution/PHSP/KplusPi0/%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(),newName.c_str()),"RECREATE");
  2500. }
  2501. else{
  2502. output = new TFile(Form("%s/resolution/MC/KplusPi0/%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(),newName.c_str()),"RECREATE");
  2503. }
  2504. }
  2505. }
  2506. // Kst2Kpluspi0Merged case
  2507. if(Kst2Kpluspi0Merged){
  2508. if(!MC){
  2509. output = new TFile(Form("%s/resolution/data/%s%s/%s%s_pi0Merged%s.root",path_to_output_KplusPizero.c_str(), year.c_str(),magnet.c_str(),year.c_str(),magnet.c_str(),newName.c_str()),"RECREATE");
  2510. }
  2511. else{
  2512. if(ReferenceChannel){
  2513. output = new TFile(Form("%s/resolution/MC/RefKplusPi0/%s%s/%s%s_pi0Merged%s.root",path_to_output_KplusPizero.c_str(), year.c_str(),magnet.c_str(),year.c_str(),magnet.c_str(),newName.c_str()),"RECREATE");
  2514. }
  2515. else if(PHSP){
  2516. output = new TFile(Form("%s/resolution/PHSP/KplusPi0/%s%s/%s%s_pi0Merged%s.root",path_to_output_KplusPizero.c_str(), year.c_str(),magnet.c_str(),year.c_str(),magnet.c_str(),newName.c_str()),"RECREATE");
  2517. }
  2518. else{
  2519. output = new TFile(Form("%s/resolution/MC/KplusPi0/%s%s/%s%s_pi0Merged%s.root",path_to_output_KplusPizero.c_str(), year.c_str(),magnet.c_str(),year.c_str(),magnet.c_str(),newName.c_str()),"RECREATE");
  2520. }
  2521. }
  2522. }
  2523. // Kst2Kspiplus case
  2524. if(Kst2Kspiplus){
  2525. if(!MC){
  2526. output = new TFile(Form("%s/resolution/data/%s%s/%s%s_piplus%s.root",path_to_output_KshortPiplus.c_str(), year.c_str(),magnet.c_str(),year.c_str(),magnet.c_str(),newName.c_str()),"RECREATE");
  2527. }
  2528. else{
  2529. if(ReferenceChannel){
  2530. output = new TFile(Form("%s/resolution/MC/RefKshortPiplus/%s%s/%s%s_piplus%s.root",path_to_output_KshortPiplus.c_str(), year.c_str(),magnet.c_str(),year.c_str(),magnet.c_str(),newName.c_str()),"RECREATE");
  2531. }
  2532. else if(PHSP){
  2533. output = new TFile(Form("%s/resolution/PHSP/KshortPiplus/%s%s/%s%s_piplus%s.root",path_to_output_KshortPiplus.c_str(), year.c_str(),magnet.c_str(),year.c_str(),magnet.c_str(),newName.c_str()),"RECREATE");
  2534. }
  2535. else{
  2536. output = new TFile(Form("%s/resolution/MC/KshortPiplus/%s%s/%s%s_piplus%s.root",path_to_output_KshortPiplus.c_str(), year.c_str(),magnet.c_str(),year.c_str(),magnet.c_str(),newName.c_str()),"RECREATE");
  2537. }
  2538. }
  2539. }
  2540. //Initialize new tree
  2541. output->cd();
  2542. string tmpName = "";
  2543. string tmpYaxis= "";
  2544. double eta_low_edge = 1.4;
  2545. double eta_high_edge = 5;
  2546. int eta_bins = 36;///2;
  2547. double eta_low_edge_B = 1.4;
  2548. double eta_high_edge_B = 6;
  2549. int eta_bins_B = 46;///2;
  2550. int PVZ_bins = 40;
  2551. double PVZ_low_edge = -90;
  2552. double PVZ_high_edge = 180;
  2553. double KstPt_bins = 50;
  2554. double KstPt_low_edge = 800;
  2555. double KstPt_high_edge = 5000;
  2556. double angle_low_edge = -3.15;
  2557. double angle_high_edge = 3.15;
  2558. double angle_bins = 30;
  2559. //////////////////////////////////
  2560. ///// //////
  2561. //// Basic eta histos /////
  2562. ///// //////
  2563. //////////////////////////////////
  2564. ///
  2565. //pi0
  2566. tmpYaxis = "Counts / 0.2";
  2567. //pi0
  2568. TH1 * h_pi0_ETA_DTF,*h_pi0_ETA, *h_pi0_ETA_TRUE;
  2569. init_1D(h_pi0_ETA_DTF, "pi0", "ETA", "DTF", "", tmpYaxis,eta_bins, eta_low_edge, eta_high_edge);
  2570. init_1D(h_pi0_ETA, "pi0", "ETA", "", "", tmpYaxis,eta_bins, eta_low_edge, eta_high_edge);
  2571. init_1D(h_pi0_ETA_TRUE, "pi0", "ETA", "TRUE", "", tmpYaxis,eta_bins, eta_low_edge, eta_high_edge);
  2572. //K+
  2573. TH1 *h_Kplus_ETA_DTF,*h_Kplus_ETA,*h_Kplus_ETA_TRUE;
  2574. init_1D(h_Kplus_ETA_DTF, "Kplus","ETA", "DTF", "", tmpYaxis, eta_bins, eta_low_edge, eta_high_edge);
  2575. init_1D(h_Kplus_ETA, "Kplus","ETA", "", "", tmpYaxis, eta_bins, eta_low_edge, eta_high_edge);
  2576. init_1D(h_Kplus_ETA_TRUE, "Kplus","ETA", "TRUE", "", tmpYaxis, eta_bins, eta_low_edge, eta_high_edge);
  2577. //K*
  2578. TH1 *h_Kstar_ETA_DTF,*h_Kstar_ETA,*h_Kstar_ETA_TRUE;
  2579. init_1D(h_Kstar_ETA_DTF, "Kstar","ETA", "DTF", "", tmpYaxis, eta_bins, eta_low_edge, eta_high_edge);
  2580. init_1D(h_Kstar_ETA, "Kstar","ETA", "", "", tmpYaxis, eta_bins, eta_low_edge, eta_high_edge);
  2581. init_1D(h_Kstar_ETA_TRUE, "Kstar","ETA", "TRUE", "", tmpYaxis, eta_bins, eta_low_edge, eta_high_edge);
  2582. //B+
  2583. TH1 *h_Bplus_ETA_DTF,*h_Bplus_ETA,*h_Bplus_ETA_TRUE;
  2584. init_1D(h_Bplus_ETA_DTF, "Bplus","ETA", "DTF", "", tmpYaxis, eta_bins, eta_low_edge, eta_high_edge);
  2585. cout << h_Bplus_ETA_DTF->GetName() << endl;
  2586. init_1D(h_Bplus_ETA, "Bplus","ETA", "", "", tmpYaxis, eta_bins, eta_low_edge, eta_high_edge);
  2587. init_1D(h_Bplus_ETA_TRUE, "Bplus","ETA", "TRUE", "", tmpYaxis, eta_bins, eta_low_edge, eta_high_edge);
  2588. //if (Kst2Kpluspi0Resolved) tmpName = variableLatex("ETA") + "{" + particleLatex("Kplus") + particleLatex("pi0") + particleLatex("mu") + particleLatex("mu") + "}";
  2589. //else if (Kst2Kspiplus) tmpName = variableLatex("ETA") + "{" + particleLatex("Kshort") + particleLatex("piplus") + particleLatex("mu") + particleLatex("mu") + "}";
  2590. tmpYaxis = Form("Counts / %.3f",(6.3/angle_bins));
  2591. //ThetaK
  2592. TH1 *h_ThetaK_DTF,*h_ThetaK,*h_ThetaK_TRUE;
  2593. init_1D(h_ThetaK_DTF, "","ThetaK", "DTF", "", tmpYaxis, angle_bins, 0, angle_high_edge);
  2594. init_1D(h_ThetaK, "","ThetaK", "", "", tmpYaxis, angle_bins, 0, angle_high_edge);
  2595. init_1D(h_ThetaK_TRUE, "","ThetaK", "TRUE", "", tmpYaxis, angle_bins, 0, angle_high_edge);
  2596. //ThetaL
  2597. TH1 *h_ThetaL_DTF,*h_ThetaL,*h_ThetaL_TRUE;
  2598. init_1D(h_ThetaL_DTF, "","ThetaL", "DTF", "", tmpYaxis, angle_bins, 0, angle_high_edge);
  2599. init_1D(h_ThetaL, "","ThetaL", "", "", tmpYaxis, angle_bins, 0, angle_high_edge);;
  2600. init_1D(h_ThetaL_TRUE, "","ThetaL", "TRUE", "", tmpYaxis, angle_bins, 0, angle_high_edge);
  2601. //Phi
  2602. TH1 *h_Phi_DTF,*h_Phi,*h_Phi_TRUE;
  2603. init_1D(h_Phi_DTF, "","Phi", "DTF", "", tmpYaxis, angle_bins, 0, angle_high_edge);
  2604. init_1D(h_Phi, "","Phi", "", "", tmpYaxis, angle_bins, 0, angle_high_edge);
  2605. init_1D(h_Phi_TRUE, "","Phi", "TRUE", "", tmpYaxis, angle_bins, 0, angle_high_edge);
  2606. tmpYaxis = Form("Counts / %.3f",(PVZ_high_edge-PVZ_low_edge/PVZ_bins));
  2607. //PVZ
  2608. TH1 *h_PVZ_DTF,*h_PVZ,*h_PVZ_TRUE;
  2609. init_1D(h_PVZ_DTF, "","PVZ", "DTF", "", tmpYaxis, PVZ_bins, PVZ_low_edge, PVZ_high_edge);
  2610. init_1D(h_PVZ, "","PVZ", "", "", tmpYaxis, PVZ_bins, PVZ_low_edge, PVZ_high_edge);
  2611. init_1D(h_PVZ_TRUE, "","PVZ", "TRUE", "", tmpYaxis, PVZ_bins, PVZ_low_edge, PVZ_high_edge);
  2612. //////////////////////////////////
  2613. ///// //////
  2614. //// Pull histos /////
  2615. ///// //////
  2616. //////////////////////////////////
  2617. ///
  2618. tmpYaxis = "#frac{REC - MC}{#sigma}";
  2619. //pi0
  2620. TH1 * h_pi0_ETA_DTF_pull,*h_pi0_ETA_pull;
  2621. tmpYaxis = variableLatex("ETA")+"{"+particleLatex("pi0")+"}" + " #frac{REC - MC}{#sigma}";
  2622. init_1D(h_pi0_ETA_DTF_pull, "pi0", "ETA", "PULL_DTF", "", tmpYaxis, eta_bins, eta_low_edge, eta_high_edge);
  2623. init_1D(h_pi0_ETA_pull, "pi0", "ETA", "PULL", "", tmpYaxis, eta_bins, eta_low_edge, eta_high_edge);
  2624. //K+
  2625. TH1 *h_Kplus_ETA_DTF_pull,*h_Kplus_ETA_pull;
  2626. tmpYaxis = variableLatex("ETA")+"{"+particleLatex("Kplus")+"}" + " #frac{REC - MC}{#sigma}";
  2627. init_1D(h_Kplus_ETA_DTF_pull, "Kplus","ETA", "PULL_DTF", "", tmpYaxis, eta_bins, eta_low_edge, eta_high_edge);
  2628. init_1D(h_Kplus_ETA_pull, "Kplus","ETA", "PULL", "", tmpYaxis, eta_bins, eta_low_edge, eta_high_edge);
  2629. //K*
  2630. TH1 *h_Kstar_ETA_DTF_pull,*h_Kstar_ETA_pull;
  2631. tmpYaxis = variableLatex("ETA")+"{"+particleLatex("Kstar")+"}" + " #frac{REC - MC}{#sigma}";
  2632. init_1D(h_Kstar_ETA_DTF_pull, "Kstar","ETA", "PULL_DTF", "", tmpYaxis, eta_bins, eta_low_edge, eta_high_edge);
  2633. init_1D(h_Kstar_ETA_pull, "Kstar","ETA", "PULL", "", tmpYaxis, eta_bins, eta_low_edge, eta_high_edge);
  2634. //B+
  2635. TH1 *h_Bplus_ETA_DTF_pull,*h_Bplus_ETA_pull;
  2636. tmpYaxis = variableLatex("ETA")+"{"+particleLatex("Bplus")+"}" + " #frac{REC - MC}{#sigma}";
  2637. init_1D(h_Bplus_ETA_DTF_pull, "Bplus","ETA", "PULL_DTF", "", tmpYaxis, eta_bins_B, eta_low_edge_B, eta_high_edge_B);
  2638. init_1D(h_Bplus_ETA_pull, "Bplus","ETA", "PULL", "", tmpYaxis, eta_bins_B, eta_low_edge_B, eta_high_edge_B);
  2639. //pi0 in Kstar_end_vertex
  2640. TH1 * h_pi0_PVZ_DTF_pull,*h_pi0_PVZ_pull;
  2641. tmpYaxis = variableLatex("ETA")+"{"+particleLatex("pi0")+"}" + " #frac{REC - MC}{#sigma}";
  2642. init_1D(h_pi0_PVZ_DTF_pull, "Bplus", "PVZ", "PULL_DTF", "", tmpYaxis, PVZ_bins, PVZ_low_edge, PVZ_high_edge);
  2643. init_1D(h_pi0_PVZ_pull, "Bplus", "PVZ", "PULL", "", tmpYaxis, PVZ_bins, PVZ_low_edge, PVZ_high_edge);
  2644. TH1 * h_pi0_KstPt_DTF_pull,*h_pi0_KstPt_pull;
  2645. tmpYaxis = variableLatex("ETA") + "{"+particleLatex("pi0")+"}" + " #frac{REC - MC}{#sigma}";
  2646. init_1D(h_pi0_KstPt_DTF_pull, "pi0", "KstPt", "PULL_DTF", "", tmpYaxis, KstPt_bins, KstPt_low_edge, KstPt_high_edge);
  2647. init_1D(h_pi0_KstPt_pull, "pi0", "KstPt", "PULL", "", tmpYaxis, KstPt_bins, KstPt_low_edge, KstPt_high_edge);
  2648. //ThetaK in Kstar pT
  2649. TH1 *h_ThetaK_KstPt_DTF_pull,*h_ThetaK_KstPt_pull;
  2650. tmpYaxis = variableLatex("ThetaK") + " #frac{REC - MC}{#sigma}";
  2651. init_1D(h_ThetaK_KstPt_DTF_pull, "ThetaK","KstPt", "PULL_DTF", "",tmpYaxis, KstPt_bins, KstPt_low_edge, KstPt_high_edge);
  2652. init_1D(h_ThetaK_KstPt_pull, "ThetaK","KstPt", "PULL", "",tmpYaxis, KstPt_bins, KstPt_low_edge, KstPt_high_edge);
  2653. //ThetaL in Kstar pT
  2654. TH1 *h_ThetaL_KstPt_DTF_pull,*h_ThetaL_KstPt_pull;
  2655. tmpYaxis = variableLatex("ThetaL") + " #frac{REC - MC}{#sigma}";
  2656. init_1D(h_ThetaL_KstPt_DTF_pull, "ThetaL","KstPt", "PULL_DTF", "", tmpYaxis, KstPt_bins, KstPt_low_edge, KstPt_high_edge);
  2657. init_1D(h_ThetaL_KstPt_pull, "ThetaL","KstPt", "PULL", "", tmpYaxis, KstPt_bins, KstPt_low_edge, KstPt_high_edge);
  2658. //Phi in Kstar pT
  2659. TH1 *h_Phi_KstPt_DTF_pull,*h_Phi_KstPt_pull;
  2660. tmpYaxis = variableLatex("Phi") + " #frac{REC - MC}{#sigma}";
  2661. init_1D(h_Phi_KstPt_DTF_pull, "Phi","KstPt", "PULL_DTF", "", tmpYaxis, KstPt_bins, KstPt_low_edge, KstPt_high_edge);
  2662. init_1D(h_Phi_KstPt_pull, "Phi","KstPt", "PULL", "", tmpYaxis, KstPt_bins, KstPt_low_edge, KstPt_high_edge);
  2663. //////////////////////////////////
  2664. ///// //////
  2665. //// Resolution histos /////
  2666. ///// 2D //////
  2667. //////////////////////////////////
  2668. //pi0
  2669. TH2 *h_pi0_ETA_DTF_ref, *h_pi0_ETA_ref;
  2670. string tmpZaxis = "Counts a.u.";
  2671. tmpYaxis = "#mu_{REC - TRUE}";
  2672. init_2D(h_pi0_ETA_DTF_ref, "pi0","ETA","ETA", "RES_DTF", tmpYaxis, tmpZaxis, eta_bins, eta_low_edge, eta_high_edge, 100, -1, 1);
  2673. init_2D(h_pi0_ETA_ref, "pi0","ETA","ETA", "RES", tmpYaxis, tmpZaxis, eta_bins, eta_low_edge, eta_high_edge, 100, -1, 1);
  2674. //pi0 (B_plus_ENDVERTEX_Z) PVZ
  2675. TH2 *h_pi0_PVZ_DTF_ref, *h_pi0_PVZ_ref;
  2676. init_2D(h_pi0_PVZ_DTF_ref, "pi0","PVZ","ETA", "RES_DTF", tmpYaxis, tmpZaxis, PVZ_bins, PVZ_low_edge, PVZ_high_edge, 100, -1, 1);
  2677. init_2D(h_pi0_PVZ_ref, "pi0","PVZ","ETA", "RES", tmpYaxis, tmpZaxis, PVZ_bins, PVZ_low_edge, PVZ_high_edge, 100, -1, 1);
  2678. //pi0 (K_star_plus_pT)
  2679. TH2 *h_pi0_KstPt_DTF_ref, *h_pi0_KstPt_ref;
  2680. init_2D(h_pi0_KstPt_DTF_ref, "pi0","ETA","KstPt", "RES_DTF", tmpYaxis, tmpZaxis, KstPt_bins, KstPt_low_edge, KstPt_high_edge, 100, -1, 1);
  2681. init_2D(h_pi0_KstPt_ref, "pi0","ETA","KstPt", "RES", tmpYaxis, tmpZaxis, KstPt_bins, KstPt_low_edge, KstPt_high_edge, 100, -1, 1);
  2682. //K+
  2683. TH2 *h_Kplus_ETA_DTF_ref, *h_Kplus_ETA_ref;
  2684. init_2D(h_Kplus_ETA_DTF_ref, "Kplus","ETA","ETA", "RES_DTF", tmpYaxis, tmpZaxis, eta_bins, eta_low_edge, eta_high_edge, 100, -1, 1);
  2685. init_2D(h_Kplus_ETA_ref, "Kplus","ETA","ETA", "RES", tmpYaxis, tmpZaxis, eta_bins, eta_low_edge, eta_high_edge, 100, -1, 1);
  2686. //K*
  2687. TH2 *h_Kstar_ETA_DTF_ref, *h_Kstar_ETA_ref;
  2688. init_2D(h_Kstar_ETA_DTF_ref, "Kstar","ETA","ETA", "RES_DTF", tmpYaxis, tmpZaxis, eta_bins, eta_low_edge, eta_high_edge, 100, -1, 1);
  2689. init_2D(h_Kstar_ETA_ref, "Kstar","ETA","ETA", "RES", tmpYaxis, tmpZaxis, eta_bins, eta_low_edge, eta_high_edge, 100, -1, 1);
  2690. //B+
  2691. TH2 *h_Bplus_ETA_DTF_ref, *h_Bplus_ETA_ref;
  2692. init_2D(h_Bplus_ETA_DTF_ref, "Bplus","ETA","ETA", "RES_DTF", tmpYaxis, tmpZaxis, eta_bins, eta_low_edge, eta_high_edge, 100, -1, 1);
  2693. init_2D(h_Bplus_ETA_ref, "Bplus","ETA","ETA", "RES", tmpYaxis, tmpZaxis, eta_bins, eta_low_edge, eta_high_edge, 100, -1, 1);
  2694. //ThetaK in Kstar pT
  2695. TH2 *h_ThetaK_KstPt_DTF_ref,*h_ThetaK_KstPt_ref;
  2696. init_2D(h_ThetaK_KstPt_DTF_ref, "ThetaK","KstPt","ThetaK", "RES_DTF",tmpYaxis, tmpZaxis, KstPt_bins, KstPt_low_edge, KstPt_high_edge, 150, -2, 1);
  2697. init_2D(h_ThetaK_KstPt_ref, "ThetaK","KstPt","ThetaK", "RES", tmpYaxis, tmpZaxis, KstPt_bins, KstPt_low_edge, KstPt_high_edge, 150, -2, 1);
  2698. //ThetaL in Kstar pT
  2699. TH2 *h_ThetaL_KstPt_DTF_ref,*h_ThetaL_KstPt_ref;
  2700. init_2D(h_ThetaL_KstPt_DTF_ref, "ThetaL","KstPt","ThetaL", "RES_DTF",tmpYaxis, tmpZaxis, KstPt_bins, KstPt_low_edge, KstPt_high_edge, 100, -1, 1);
  2701. init_2D(h_ThetaL_KstPt_ref, "ThetaL","KstPt","ThetaL", "RES", tmpYaxis, tmpZaxis, KstPt_bins, KstPt_low_edge, KstPt_high_edge, 100, -1, 1);
  2702. //Phi in Kstar pT
  2703. TH2 *h_Phi_KstPt_DTF_ref,*h_Phi_KstPt_ref;
  2704. init_2D(h_Phi_KstPt_DTF_ref, "Phi","KstPt","Phi", "RES_DTF", tmpYaxis, tmpZaxis, KstPt_bins, KstPt_low_edge, KstPt_high_edge, 100, -1, 1);
  2705. init_2D(h_Phi_KstPt_ref, "Phi","KstPt","Phi", "RES", tmpYaxis, tmpZaxis, KstPt_bins, KstPt_low_edge, KstPt_high_edge, 100, -1, 1);
  2706. //PVZ (B_plus_ENDVERTEX_Z)
  2707. TH2 *h_PVZ_ref;
  2708. init_2D(h_PVZ_ref, "","PVZ","PVZ", "RES", tmpYaxis, tmpZaxis, PVZ_bins, PVZ_low_edge, PVZ_high_edge, 100, -1, 1);
  2709. //////////////////////////////////
  2710. ///// //////
  2711. //// Res+sys histos /////
  2712. ///// 1D //////
  2713. //////////////////////////////////
  2714. //pi0
  2715. TH1 * h_pi0_ETA_DTF_res_sys,*h_pi0_ETA_res_sys;
  2716. tmpYaxis = variableLatex("ETA")+"{"+particleLatex("pi0")+"}" + " #mu_{REC - TRUE} #pm #sigma_{REC - TRUE}";
  2717. init_1D(h_pi0_ETA_DTF_res_sys, "pi0", "ETA", "RES_SYS_DTF", "", tmpYaxis, eta_bins, eta_low_edge, eta_high_edge);
  2718. init_1D(h_pi0_ETA_res_sys, "pi0", "ETA", "RES_SYS", "", tmpYaxis, eta_bins, eta_low_edge, eta_high_edge);
  2719. //K+
  2720. TH1 *h_Kplus_ETA_DTF_res_sys,*h_Kplus_ETA_res_sys;
  2721. tmpYaxis = variableLatex("ETA")+"{"+particleLatex("Kplus")+"}" + " #mu_{REC - TRUE} #pm #sigma_{REC - TRUE}";
  2722. init_1D(h_Kplus_ETA_DTF_res_sys, "Kplus","ETA", "RES_SYS_DTF", "", tmpYaxis, eta_bins, eta_low_edge, eta_high_edge);
  2723. init_1D(h_Kplus_ETA_res_sys, "Kplus","ETA", "RES_SYS", "", tmpYaxis, eta_bins, eta_low_edge, eta_high_edge);
  2724. //K*
  2725. TH1 *h_Kstar_ETA_DTF_res_sys,*h_Kstar_ETA_res_sys;
  2726. tmpYaxis = variableLatex("ETA")+"{"+particleLatex("Kstar")+"}" + " #mu_{REC - TRUE} #pm #sigma_{REC - TRUE}";
  2727. init_1D(h_Kstar_ETA_DTF_res_sys, "Kstar","ETA", "RES_SYS_DTF", "", tmpYaxis, eta_bins, eta_low_edge, eta_high_edge);
  2728. init_1D(h_Kstar_ETA_res_sys, "Kstar","ETA", "RES_SYS", "", tmpYaxis, eta_bins, eta_low_edge, eta_high_edge);
  2729. //B+
  2730. TH1 *h_Bplus_ETA_DTF_res_sys,*h_Bplus_ETA_res_sys;
  2731. tmpYaxis = variableLatex("ETA")+"{"+particleLatex("Bplus")+"}" + " #mu_{REC - TRUE} #pm #sigma_{REC - TRUE}";
  2732. init_1D(h_Bplus_ETA_DTF_res_sys, "Bplus","ETA", "RES_SYS_DTF", "", tmpYaxis, eta_bins_B, eta_low_edge_B, eta_high_edge_B);
  2733. init_1D(h_Bplus_ETA_res_sys, "Bplus","ETA", "RES_SYS", "", tmpYaxis, eta_bins_B, eta_low_edge_B, eta_high_edge_B);
  2734. //pi0 in Kstar_end_vertex
  2735. TH1 * h_pi0_PVZ_DTF_res_sys,*h_pi0_PVZ_res_sys;
  2736. tmpYaxis = variableLatex("ETA")+"{"+particleLatex("pi0")+"}" + " #mu_{REC - TRUE} #pm #sigma_{REC - TRUE}";
  2737. init_1D(h_pi0_PVZ_DTF_res_sys, "Bplus", "PVZ", "RES_SYS_DTF", "", tmpYaxis, PVZ_bins, PVZ_low_edge, PVZ_high_edge);
  2738. init_1D(h_pi0_PVZ_res_sys, "Bplus", "PVZ", "RES_SYS", "", tmpYaxis, PVZ_bins, PVZ_low_edge, PVZ_high_edge);
  2739. TH1 * h_pi0_KstPt_DTF_res_sys,*h_pi0_KstPt_res_sys;
  2740. init_1D(h_pi0_KstPt_DTF_res_sys, "", "KstPt", "RES_SYS_DTF", "res_sys", tmpYaxis, KstPt_bins, KstPt_low_edge, KstPt_high_edge);
  2741. init_1D(h_pi0_KstPt_res_sys, "", "KstPt", "RES_SYS", "", tmpYaxis, KstPt_bins, KstPt_low_edge, KstPt_high_edge);
  2742. //ThetaK in Kstar pT
  2743. TH1 *h_ThetaK_KstPt_DTF_res_sys,*h_ThetaK_KstPt_res_sys;
  2744. tmpYaxis = variableLatex("ThetaK") + " #mu_{REC - TRUE} #pm #sigma_{REC - TRUE}";
  2745. init_1D(h_ThetaK_KstPt_DTF_res_sys, "ThetaK","KstPt", "RES_SYS_DTF", "",tmpYaxis, KstPt_bins, KstPt_low_edge, KstPt_high_edge);
  2746. init_1D(h_ThetaK_KstPt_res_sys, "ThetaK","KstPt", "RES_SYS", "",tmpYaxis, KstPt_bins, KstPt_low_edge, KstPt_high_edge);
  2747. //ThetaL in Kstar pT
  2748. TH1 *h_ThetaL_KstPt_DTF_res_sys,*h_ThetaL_KstPt_res_sys;
  2749. tmpYaxis = variableLatex("ThetaL") + " #mu_{REC - TRUE} #pm #sigma_{REC - TRUE}";
  2750. init_1D(h_ThetaL_KstPt_DTF_res_sys, "ThetaL","KstPt", "RES_SYS_DTF", "", tmpYaxis, KstPt_bins, KstPt_low_edge, KstPt_high_edge);
  2751. init_1D(h_ThetaL_KstPt_res_sys, "ThetaL","KstPt", "RES_SYS", "", tmpYaxis, KstPt_bins, KstPt_low_edge, KstPt_high_edge);
  2752. //Phi in Kstar pT
  2753. TH1 *h_Phi_KstPt_DTF_res_sys,*h_Phi_KstPt_res_sys;
  2754. tmpYaxis = variableLatex("Phi") + " #mu_{REC - TRUE} #pm #sigma_{REC - TRUE}";
  2755. init_1D(h_Phi_KstPt_DTF_res_sys, "Phi","KstPt", "RES_SYS_DTF", "", tmpYaxis, KstPt_bins, KstPt_low_edge, KstPt_high_edge);
  2756. init_1D(h_Phi_KstPt_res_sys, "Phi","KstPt", "RES_SYS", "", tmpYaxis, KstPt_bins, KstPt_low_edge, KstPt_high_edge);
  2757. //////////////////////////////////
  2758. ///// //////
  2759. //// Resolution histos /////
  2760. ///// 1D //////
  2761. //////////////////////////////////
  2762. //pi0
  2763. TH1 * h_pi0_ETA_DTF_res,*h_pi0_ETA_res;
  2764. tmpYaxis = variableLatex("ETA")+"{"+particleLatex("pi0")+"}" + " #sigma_{REC - TRUE}";
  2765. init_1D(h_pi0_ETA_DTF_res, "pi0", "ETA", "RES_DTF", "", tmpYaxis, eta_bins, eta_low_edge, eta_high_edge);
  2766. init_1D(h_pi0_ETA_res, "pi0", "ETA", "RES", "", tmpYaxis, eta_bins, eta_low_edge, eta_high_edge);
  2767. //K+
  2768. TH1 *h_Kplus_ETA_DTF_res,*h_Kplus_ETA_res;
  2769. tmpYaxis = variableLatex("ETA")+"{"+particleLatex("Kplus")+"}" + " #sigma_{REC - TRUE}";
  2770. init_1D(h_Kplus_ETA_DTF_res, "Kplus","ETA", "RES_DTF", "", tmpYaxis, eta_bins, eta_low_edge, eta_high_edge);
  2771. init_1D(h_Kplus_ETA_res, "Kplus","ETA", "RES", "", tmpYaxis, eta_bins, eta_low_edge, eta_high_edge);
  2772. //K*
  2773. TH1 *h_Kstar_ETA_DTF_res,*h_Kstar_ETA_res;
  2774. tmpYaxis = variableLatex("ETA")+"{"+particleLatex("Kstar")+"}" + " #sigma_{REC - TRUE}";
  2775. init_1D(h_Kstar_ETA_DTF_res, "Kstar","ETA", "RES_DTF", "", tmpYaxis, eta_bins, eta_low_edge, eta_high_edge);
  2776. init_1D(h_Kstar_ETA_res, "Kstar","ETA", "RES", "", tmpYaxis, eta_bins, eta_low_edge, eta_high_edge);
  2777. //B+
  2778. TH1 *h_Bplus_ETA_DTF_res,*h_Bplus_ETA_res;
  2779. tmpYaxis = variableLatex("ETA")+"{"+particleLatex("Bplus")+"}" + " #sigma_{REC - TRUE}";
  2780. init_1D(h_Bplus_ETA_DTF_res, "Bplus","ETA", "RES_DTF", "", tmpYaxis, eta_bins_B, eta_low_edge_B, eta_high_edge_B);
  2781. init_1D(h_Bplus_ETA_res, "Bplus","ETA", "RES", "", tmpYaxis, eta_bins_B, eta_low_edge_B, eta_high_edge_B);
  2782. //pi0 in Kstar_end_vertex
  2783. TH1 * h_pi0_PVZ_DTF_res,*h_pi0_PVZ_res;
  2784. tmpYaxis = variableLatex("ETA")+"{"+particleLatex("pi0")+"}" + " #sigma_{REC - TRUE}";
  2785. init_1D(h_pi0_PVZ_DTF_res, "Bplus", "PVZ", "RES_DTF", "", tmpYaxis, PVZ_bins, PVZ_low_edge, PVZ_high_edge);
  2786. init_1D(h_pi0_PVZ_res, "Bplus", "PVZ", "RES", "", tmpYaxis, PVZ_bins, PVZ_low_edge, PVZ_high_edge);
  2787. TH1 * h_pi0_KstPt_DTF_res,*h_pi0_KstPt_res;
  2788. tmpYaxis = variableLatex("ETA")+"{"+particleLatex("pi0")+"}" + " #sigma_{REC - TRUE}";
  2789. init_1D(h_pi0_KstPt_DTF_res, "pi0", "KstPt", "RES_DTF", "", tmpYaxis, KstPt_bins, KstPt_low_edge, KstPt_high_edge);
  2790. init_1D(h_pi0_KstPt_res, "pi0", "KstPt", "RES", "", tmpYaxis, KstPt_bins, KstPt_low_edge, KstPt_high_edge);
  2791. //ThetaK in Kstar pT
  2792. TH1 *h_ThetaK_KstPt_DTF_res,*h_ThetaK_KstPt_res;
  2793. tmpYaxis = variableLatex("ThetaK")+ " #sigma_{REC - TRUE}";
  2794. init_1D(h_ThetaK_KstPt_DTF_res, "ThetaK","KstPt", "RES_DTF", "",tmpYaxis, KstPt_bins, KstPt_low_edge, KstPt_high_edge);
  2795. init_1D(h_ThetaK_KstPt_res, "ThetaK","KstPt", "RES", "",tmpYaxis, KstPt_bins, KstPt_low_edge, KstPt_high_edge);
  2796. //ThetaL in Kstar pT
  2797. TH1 *h_ThetaL_KstPt_DTF_res,*h_ThetaL_KstPt_res;
  2798. tmpYaxis = variableLatex("ThetaL")+ " #sigma_{REC - TRUE}";
  2799. init_1D(h_ThetaL_KstPt_DTF_res, "ThetaL","KstPt", "RES_DTF", "", tmpYaxis, KstPt_bins, KstPt_low_edge, KstPt_high_edge);
  2800. init_1D(h_ThetaL_KstPt_res, "ThetaL","KstPt", "RES", "", tmpYaxis, KstPt_bins, KstPt_low_edge, KstPt_high_edge);
  2801. //Phi in Kstar pT
  2802. TH1 *h_Phi_KstPt_DTF_res,*h_Phi_KstPt_res;
  2803. tmpYaxis = variableLatex("Phi")+ " #sigma_{REC - TRUE}";
  2804. init_1D(h_Phi_KstPt_DTF_res, "Phi","KstPt", "RES_DTF", "", tmpYaxis, KstPt_bins, KstPt_low_edge, KstPt_high_edge);
  2805. init_1D(h_Phi_KstPt_res, "Phi","KstPt", "RES", "", tmpYaxis, KstPt_bins, KstPt_low_edge, KstPt_high_edge);
  2806. //////////////////////////////////
  2807. ///// //////
  2808. //// Systematics histos /////
  2809. ///// 1D //////
  2810. //////////////////////////////////
  2811. tmpYaxis = "#mu_{REC - TRUE}";
  2812. //pi0
  2813. //pi0
  2814. TH1 * h_pi0_ETA_DTF_sys,*h_pi0_ETA_sys;
  2815. tmpYaxis = variableLatex("ETA")+"{"+particleLatex("pi0")+"}" + " #mu_{REC - TRUE}";
  2816. init_1D(h_pi0_ETA_DTF_sys, "pi0", "ETA", "SYS_DTF", "", tmpYaxis, eta_bins, eta_low_edge, eta_high_edge);
  2817. init_1D(h_pi0_ETA_sys, "pi0", "ETA", "SYS", "", tmpYaxis, eta_bins, eta_low_edge, eta_high_edge);
  2818. //K+
  2819. TH1 *h_Kplus_ETA_DTF_sys,*h_Kplus_ETA_sys;
  2820. tmpYaxis = variableLatex("ETA")+"{"+particleLatex("Kplus")+"}" + " #mu_{REC - TRUE}";
  2821. init_1D(h_Kplus_ETA_DTF_sys, "Kplus","ETA", "SYS_DTF", "", tmpYaxis, eta_bins, eta_low_edge, eta_high_edge);
  2822. init_1D(h_Kplus_ETA_sys, "Kplus","ETA", "SYS", "", tmpYaxis, eta_bins, eta_low_edge, eta_high_edge);
  2823. //K*
  2824. TH1 *h_Kstar_ETA_DTF_sys,*h_Kstar_ETA_sys;
  2825. tmpYaxis = variableLatex("ETA")+"{"+particleLatex("Kstar")+"}" + " #mu_{REC - TRUE}";
  2826. init_1D(h_Kstar_ETA_DTF_sys, "Kstar","ETA", "SYS_DTF", "", tmpYaxis, eta_bins, eta_low_edge, eta_high_edge);
  2827. init_1D(h_Kstar_ETA_sys, "Kstar","ETA", "SYS", "", tmpYaxis, eta_bins, eta_low_edge, eta_high_edge);
  2828. //B+
  2829. TH1 *h_Bplus_ETA_DTF_sys,*h_Bplus_ETA_sys;
  2830. tmpYaxis = variableLatex("ETA")+"{"+particleLatex("Bplus")+"}" + " #mu_{REC - TRUE}";
  2831. init_1D(h_Bplus_ETA_DTF_sys, "Bplus","ETA", "SYS_DTF", "", tmpYaxis, eta_bins_B, eta_low_edge_B, eta_high_edge_B);
  2832. init_1D(h_Bplus_ETA_sys, "Bplus","ETA", "SYS", "", tmpYaxis, eta_bins_B, eta_low_edge_B, eta_high_edge_B);
  2833. //pi0 in Kstar_end_vertex
  2834. TH1 * h_pi0_PVZ_DTF_sys,*h_pi0_PVZ_sys;
  2835. tmpYaxis = variableLatex("ETA")+"{"+particleLatex("pi0")+"}" + " #mu_{REC - TRUE}";
  2836. init_1D(h_pi0_PVZ_DTF_sys, "Bplus", "PVZ", "SYS_DTF", "", tmpYaxis, PVZ_bins, PVZ_low_edge, PVZ_high_edge);
  2837. init_1D(h_pi0_PVZ_sys, "Bplus", "PVZ", "SYS", "", tmpYaxis, PVZ_bins, PVZ_low_edge, PVZ_high_edge);
  2838. TH1 * h_pi0_KstPt_DTF_sys,*h_pi0_KstPt_sys;
  2839. tmpYaxis = variableLatex("ETA")+"{"+particleLatex("pi0")+"}" + " #mu_{REC - TRUE}";
  2840. init_1D(h_pi0_KstPt_DTF_sys, "pi0", "KstPt", "SYS_DTF", "", tmpYaxis, KstPt_bins, KstPt_low_edge, KstPt_high_edge);
  2841. init_1D(h_pi0_KstPt_sys, "pi0", "KstPt", "SYS", "", tmpYaxis, KstPt_bins, KstPt_low_edge, KstPt_high_edge);
  2842. //ThetaK in Kstar pT
  2843. TH1 *h_ThetaK_KstPt_DTF_sys,*h_ThetaK_KstPt_sys;
  2844. tmpYaxis = variableLatex("ThetaK")+ + " #mu_{REC - TRUE}";
  2845. init_1D(h_ThetaK_KstPt_DTF_sys, "ThetaK","KstPt", "SYS_DTF", "",tmpYaxis, KstPt_bins, KstPt_low_edge, KstPt_high_edge);
  2846. init_1D(h_ThetaK_KstPt_sys, "ThetaK","KstPt", "SYS", "",tmpYaxis, KstPt_bins, KstPt_low_edge, KstPt_high_edge);
  2847. //ThetaL in Kstar pT
  2848. TH1 *h_ThetaL_KstPt_DTF_sys,*h_ThetaL_KstPt_sys;
  2849. tmpYaxis = variableLatex("ThetaL")+"{"+particleLatex("pi0")+"}" + " #mu_{REC - TRUE}";
  2850. init_1D(h_ThetaL_KstPt_DTF_sys, "ThetaL","KstPt", "SYS_DTF", "", tmpYaxis, KstPt_bins, KstPt_low_edge, KstPt_high_edge);
  2851. init_1D(h_ThetaL_KstPt_sys, "ThetaL","KstPt", "SYS", "", tmpYaxis, KstPt_bins, KstPt_low_edge, KstPt_high_edge);
  2852. //Phi in Kstar pT
  2853. TH1 *h_Phi_KstPt_DTF_sys,*h_Phi_KstPt_sys;
  2854. tmpYaxis = variableLatex("Phi")+ + " #mu_{REC - TRUE}";
  2855. init_1D(h_Phi_KstPt_DTF_sys, "Phi","KstPt", "SYS_DTF", "", tmpYaxis, KstPt_bins, KstPt_low_edge, KstPt_high_edge);
  2856. init_1D(h_Phi_KstPt_sys, "Phi","KstPt", "SYS", "", tmpYaxis, KstPt_bins, KstPt_low_edge, KstPt_high_edge);
  2857. //////////////////////////////////
  2858. ///// //////
  2859. //// REC vs MC histos /////
  2860. ///// //////
  2861. //////////////////////////////////
  2862. //pi0
  2863. TH2 *h_pi0_ETA_DTF_rec_MC, *h_pi0_ETA_rec_MC;
  2864. tmpZaxis = "Counts a.u.";
  2865. tmpYaxis = "TRUE ";
  2866. init_2D(h_pi0_ETA_DTF_rec_MC, "pi0","ETA","ETA", "DTF", tmpYaxis, tmpZaxis, eta_bins, eta_low_edge, eta_high_edge);
  2867. init_2D(h_pi0_ETA_rec_MC, "pi0","ETA","ETA", "", tmpYaxis, tmpZaxis, eta_bins, eta_low_edge, eta_high_edge);
  2868. //K+
  2869. TH2 *h_Kplus_ETA_DTF_rec_MC, *h_Kplus_ETA_rec_MC;
  2870. init_2D(h_Kplus_ETA_DTF_rec_MC, "Kplus","ETA","ETA", "DTF", tmpYaxis, tmpZaxis, eta_bins, eta_low_edge, eta_high_edge);
  2871. init_2D(h_Kplus_ETA_rec_MC, "Kplus","ETA","ETA", "", tmpYaxis, tmpZaxis, eta_bins, eta_low_edge, eta_high_edge);
  2872. //K*
  2873. TH2 *h_Kstar_ETA_DTF_rec_MC, *h_Kstar_ETA_rec_MC;
  2874. init_2D(h_Kstar_ETA_DTF_rec_MC, "Kstar","ETA","ETA", "DTF", tmpYaxis, tmpZaxis, eta_bins, eta_low_edge, eta_high_edge);
  2875. init_2D(h_Kstar_ETA_rec_MC, "Kstar","ETA","ETA", "", tmpYaxis, tmpZaxis, eta_bins, eta_low_edge, eta_high_edge);
  2876. //B+
  2877. TH2 *h_Bplus_ETA_DTF_rec_MC, *h_Bplus_ETA_rec_MC;
  2878. init_2D(h_Bplus_ETA_DTF_rec_MC, "Bplus","ETA","ETA", "DTF", tmpYaxis, tmpZaxis, eta_bins, eta_low_edge, eta_high_edge);
  2879. init_2D(h_Bplus_ETA_rec_MC, "Bplus","ETA","ETA", "", tmpYaxis, tmpZaxis, eta_bins, eta_low_edge, eta_high_edge);
  2880. //ThetaK in Kstar pT
  2881. TH2 *h_ThetaK_DTF_rec_MC,*h_ThetaK_rec_MC;
  2882. init_2D(h_ThetaK_DTF_rec_MC, "","ThetaK","ThetaK", "DTF",tmpYaxis, tmpZaxis, angle_bins, 0, angle_high_edge);
  2883. init_2D(h_ThetaK_rec_MC, "","ThetaK","ThetaK", "", tmpYaxis, tmpZaxis, angle_bins, 0, angle_high_edge);
  2884. //ThetaL in Kstar pT
  2885. TH2 *h_ThetaL_DTF_rec_MC,*h_ThetaL_rec_MC;
  2886. init_2D(h_ThetaL_DTF_rec_MC, "","ThetaL","ThetaL", "DTF", tmpYaxis, tmpZaxis, angle_bins, 0, angle_high_edge);
  2887. init_2D(h_ThetaL_rec_MC, "","ThetaL","ThetaL", "", tmpYaxis, tmpZaxis, angle_bins, 0, angle_high_edge);
  2888. //Phi in Kstar pT
  2889. TH2 *h_Phi_DTF_rec_MC,*h_Phi_rec_MC;
  2890. init_2D(h_Phi_DTF_rec_MC, "","Phi","Phi", "DTF", tmpYaxis, tmpZaxis, angle_bins, 0, angle_high_edge);
  2891. init_2D(h_Phi_rec_MC, "","Phi","Phi", "", tmpYaxis, tmpZaxis, angle_bins, 0, angle_high_edge);
  2892. //PVZ
  2893. TH2 *h_PVZ_DTF_rec_MC, *h_PVZ_rec_MC;
  2894. init_2D(h_PVZ_DTF_rec_MC, "Bplus", "PVZ", "PVZ", "DTF", tmpYaxis, tmpZaxis, PVZ_bins, PVZ_low_edge, PVZ_high_edge);
  2895. init_2D(h_PVZ_rec_MC, "Bplus", "PVZ", "PVZ", "", tmpYaxis, tmpZaxis, PVZ_bins, PVZ_low_edge, PVZ_high_edge);
  2896. //////////////////////////////////
  2897. ///// //////
  2898. //// Loop over events /////
  2899. ///// //////
  2900. //////////////////////////////////
  2901. for (int i=0; i<N; i++){
  2902. //output the different counters!
  2903. if ((0ul == (i % 10000ul) || i + 1 == N) && i != 0) {
  2904. cout << "Read event " << i + 1 << "/" << N
  2905. << endl;
  2906. }
  2907. tree->GetEntry(i);
  2908. // fill HISTOGRAMS //
  2909. h_Bplus_ETA_DTF ->Fill(B_plus_ETA_DTF);
  2910. h_Bplus_ETA_TRUE ->Fill(B_plus_TRUE_ETA);
  2911. h_Bplus_ETA_DTF_rec_MC ->Fill(B_plus_ETA_DTF,B_plus_TRUE_ETA);
  2912. h_Bplus_ETA_DTF_ref ->Fill(B_plus_ETA_DTF,B_plus_ETA_DTF-B_plus_TRUE_ETA);
  2913. if (!OnlyDTF){
  2914. h_Bplus_ETA ->Fill(B_plus_ETA);
  2915. h_Bplus_ETA_rec_MC ->Fill(B_plus_ETA,B_plus_TRUE_ETA);
  2916. h_Bplus_ETA_ref ->Fill(B_plus_ETA,B_plus_ETA-B_plus_TRUE_ETA);
  2917. }
  2918. h_ThetaK_DTF ->Fill(B_plus_ThetaK_DTF);
  2919. h_ThetaK_TRUE ->Fill(B_plus_TRUE_ThetaK);
  2920. h_ThetaK_DTF_rec_MC ->Fill(B_plus_ThetaK_DTF,B_plus_TRUE_ThetaK);
  2921. h_ThetaK_KstPt_DTF_ref ->Fill(K_star_plus_PT_DTF,B_plus_ThetaK_DTF-B_plus_TRUE_ThetaK);
  2922. // if (!OnlyDTF){
  2923. h_ThetaK ->Fill(B_plus_ThetaK);
  2924. h_ThetaK_rec_MC ->Fill(B_plus_ThetaK,B_plus_TRUE_ThetaK);
  2925. h_ThetaK_KstPt_ref ->Fill(K_star_plus_PT_DTF,B_plus_ThetaK-B_plus_TRUE_ThetaK);
  2926. // }
  2927. h_ThetaL_DTF ->Fill(B_plus_ThetaL_DTF);
  2928. h_ThetaL_TRUE ->Fill(B_plus_TRUE_ThetaL);
  2929. h_ThetaL_DTF_rec_MC ->Fill(B_plus_ThetaL_DTF, B_plus_TRUE_ThetaL);
  2930. h_ThetaL_KstPt_DTF_ref ->Fill(K_star_plus_PT_DTF, B_plus_ThetaL-B_plus_TRUE_ThetaL);
  2931. // if (!OnlyDTF){
  2932. h_ThetaL ->Fill(B_plus_ThetaL);
  2933. h_ThetaL_rec_MC ->Fill(B_plus_ThetaL, B_plus_TRUE_ThetaL);
  2934. h_ThetaL_KstPt_ref ->Fill(K_star_plus_PT_DTF, B_plus_ThetaL-B_plus_TRUE_ThetaL);
  2935. // }
  2936. h_Phi_DTF ->Fill(B_plus_Phi_DTF);
  2937. h_Phi_TRUE ->Fill(B_plus_TRUE_Phi);
  2938. h_Phi_DTF_rec_MC ->Fill(B_plus_Phi_DTF,B_plus_TRUE_Phi);
  2939. h_Phi_KstPt_DTF_ref ->Fill(K_star_plus_PT_DTF, B_plus_Phi-B_plus_TRUE_Phi);
  2940. // if (!OnlyDTF){
  2941. h_Phi ->Fill(TMath::Abs(B_plus_Phi));
  2942. h_Phi_rec_MC ->Fill(TMath::Abs(B_plus_Phi), TMath::Abs(B_plus_TRUE_Phi));
  2943. h_Phi_KstPt_ref ->Fill(K_star_plus_PT_DTF, TMath::Abs(B_plus_Phi)-TMath::Abs(B_plus_TRUE_Phi));
  2944. // }
  2945. //--------------------------------------------------
  2946. h_PVZ_TRUE ->Fill(B_plus_TRUEENDVERTEX_Z);
  2947. h_PVZ ->Fill(B_plus_ENDVERTEX_Z);
  2948. h_PVZ_rec_MC ->Fill(B_plus_ENDVERTEX_Z, B_plus_TRUEENDVERTEX_Z);
  2949. h_PVZ_ref ->Fill(B_plus_ENDVERTEX_Z, B_plus_ENDVERTEX_Z-B_plus_TRUEENDVERTEX_Z);
  2950. h_Kstar_ETA_DTF ->Fill(K_star_plus_ETA_DTF);
  2951. h_Kstar_ETA_TRUE ->Fill(K_star_plus_TRUE_ETA);
  2952. h_Kstar_ETA_DTF_rec_MC ->Fill(K_star_plus_ETA_DTF, K_star_plus_TRUE_ETA);
  2953. h_Kstar_ETA_DTF_ref ->Fill(K_star_plus_ETA_DTF, K_star_plus_ETA_DTF-K_star_plus_TRUE_ETA);
  2954. if (!OnlyDTF){
  2955. h_Kstar_ETA ->Fill(K_star_plus_ETA);
  2956. h_Kstar_ETA_rec_MC ->Fill(K_star_plus_ETA, K_star_plus_TRUE_ETA);
  2957. h_Kstar_ETA_ref ->Fill(K_star_plus_ETA, K_star_plus_ETA-K_star_plus_TRUE_ETA);
  2958. }
  2959. //--------------------------------------------------
  2960. //--------------------------------------------------
  2961. //--------------------------------------------------
  2962. if(Kst2Kspiplus){
  2963. // h_Kshort_ETA_DTF ->Fill(K_short_ETA_DTF);
  2964. // h_Kshort_ETA_TRUE ->Fill(K_short_TRUE_ETA);
  2965. // h_Kshort_ETA ->Fill(K_short_ETA);
  2966. }
  2967. //--------------------------------------------------
  2968. //--------------------------------------------------
  2969. //--------------------------------------------------
  2970. if (Kst2Kpluspi0Resolved){
  2971. h_Kplus_ETA_DTF ->Fill(K_plus_ETA_DTF);
  2972. h_Kplus_ETA_TRUE ->Fill(K_plus_TRUE_ETA);
  2973. h_Kplus_ETA_DTF_rec_MC ->Fill(K_plus_ETA_DTF,K_plus_TRUE_ETA);
  2974. h_Kplus_ETA_DTF_ref ->Fill(K_plus_ETA_DTF,K_plus_ETA_DTF-K_plus_TRUE_ETA);
  2975. if (!OnlyDTF){
  2976. h_Kplus_ETA ->Fill(K_plus_ETA);
  2977. h_Kplus_ETA_rec_MC ->Fill(K_plus_ETA,K_plus_TRUE_ETA);
  2978. h_Kplus_ETA_ref ->Fill(K_plus_ETA,K_plus_ETA-K_plus_TRUE_ETA);
  2979. }
  2980. //--------------------------------------------------
  2981. h_pi0_ETA_DTF ->Fill(pi_zero_resolved_ETA_DTF);
  2982. h_pi0_ETA_TRUE ->Fill(pi_zero_resolved_TRUE_ETA);
  2983. h_pi0_ETA_DTF_rec_MC ->Fill(pi_zero_resolved_ETA_DTF,pi_zero_resolved_TRUE_ETA);
  2984. h_pi0_ETA_DTF_ref ->Fill(pi_zero_resolved_ETA_DTF,pi_zero_resolved_ETA_DTF-pi_zero_resolved_TRUE_ETA);
  2985. h_pi0_PVZ_DTF_ref ->Fill(B_plus_ENDVERTEX_Z,pi_zero_resolved_ETA_DTF-pi_zero_resolved_TRUE_ETA);
  2986. h_pi0_KstPt_DTF_ref ->Fill(K_star_plus_PT_DTF,pi_zero_resolved_ETA_DTF-pi_zero_resolved_TRUE_ETA);
  2987. if (!OnlyDTF){
  2988. h_pi0_ETA ->Fill(pi_zero_resolved_ETA);
  2989. h_pi0_ETA_rec_MC ->Fill(pi_zero_resolved_ETA,pi_zero_resolved_TRUE_ETA);
  2990. h_pi0_ETA_ref ->Fill(pi_zero_resolved_ETA,pi_zero_resolved_ETA-pi_zero_resolved_TRUE_ETA);
  2991. h_pi0_PVZ_ref ->Fill(B_plus_ENDVERTEX_Z,pi_zero_resolved_ETA-pi_zero_resolved_TRUE_ETA);
  2992. h_pi0_KstPt_ref ->Fill(K_star_plus_PT,pi_zero_resolved_ETA-pi_zero_resolved_TRUE_ETA);
  2993. }
  2994. }
  2995. }
  2996. output->cd();
  2997. //////////////////////////////////
  2998. ///// //////
  2999. //// Fill res histos /////
  3000. ///// //////
  3001. //////////////////////////////////
  3002. ///
  3003. TF1 *func = new TF1("func","gaus",-1,1);
  3004. res_sys(h_Bplus_ETA_DTF_ref, h_Bplus_ETA_DTF_res_sys, h_Bplus_ETA_DTF_sys,h_Bplus_ETA_DTF_res, func, eta_bins_B, output ,preselected, year, magnet, MC, ReferenceChannel, PHSP, truthMatched);
  3005. res(h_Bplus_ETA_DTF_res_sys,h_Bplus_ETA_DTF_res, eta_bins_B ,preselected, year, magnet, MC, ReferenceChannel, PHSP, truthMatched);
  3006. sys(h_Bplus_ETA_DTF_res_sys,h_Bplus_ETA_DTF_sys, eta_bins_B ,preselected, year, magnet, MC, ReferenceChannel, PHSP, truthMatched);
  3007. // if (!OnlyDTF){
  3008. res_sys(h_Bplus_ETA_ref, h_Bplus_ETA_res_sys, h_Bplus_ETA_sys, h_Bplus_ETA_res, func, eta_bins_B, output, preselected, year, magnet, MC, ReferenceChannel, PHSP, truthMatched);
  3009. res(h_Bplus_ETA_res_sys, h_Bplus_ETA_res, eta_bins_B ,preselected, year, magnet, MC, ReferenceChannel, PHSP, truthMatched);
  3010. sys(h_Bplus_ETA_res_sys, h_Bplus_ETA_sys , eta_bins_B ,preselected, year, magnet, MC, ReferenceChannel, PHSP, truthMatched);
  3011. // }
  3012. res_sys(h_ThetaK_KstPt_DTF_ref, h_ThetaK_KstPt_DTF_res_sys, h_ThetaK_KstPt_DTF_sys, h_ThetaK_KstPt_DTF_res, func, eta_bins_B, output, preselected, year, magnet, MC, ReferenceChannel, PHSP, truthMatched);
  3013. res(h_ThetaK_KstPt_DTF_res_sys, h_ThetaK_KstPt_DTF_res, KstPt_bins ,preselected, year, magnet, MC, ReferenceChannel, PHSP, truthMatched);
  3014. sys(h_ThetaK_KstPt_DTF_res_sys, h_ThetaK_KstPt_DTF_sys, KstPt_bins ,preselected, year, magnet, MC, ReferenceChannel, PHSP, truthMatched);
  3015. // if (!OnlyDTF){
  3016. res_sys(h_ThetaK_KstPt_ref, h_ThetaK_KstPt_res_sys, h_ThetaK_KstPt_sys, h_ThetaK_KstPt_res, func, eta_bins_B, output, preselected, year, magnet, MC, ReferenceChannel, PHSP, truthMatched);
  3017. res(h_ThetaK_KstPt_res_sys, h_ThetaK_KstPt_res, KstPt_bins ,preselected, year, magnet, MC, ReferenceChannel, PHSP, truthMatched);
  3018. sys(h_ThetaK_KstPt_res_sys, h_ThetaK_KstPt_sys, KstPt_bins ,preselected, year, magnet, MC, ReferenceChannel, PHSP, truthMatched);
  3019. // }
  3020. res_sys(h_ThetaL_KstPt_DTF_ref, h_ThetaL_KstPt_DTF_res_sys, h_ThetaL_KstPt_DTF_sys, h_ThetaL_KstPt_DTF_res, func, eta_bins_B, output, preselected, year, magnet, MC, ReferenceChannel, PHSP, truthMatched);
  3021. res(h_ThetaL_KstPt_DTF_res_sys, h_ThetaL_KstPt_DTF_res, KstPt_bins ,preselected, year, magnet, MC, ReferenceChannel, PHSP, truthMatched);
  3022. sys(h_ThetaL_KstPt_DTF_res_sys, h_ThetaL_KstPt_DTF_sys, KstPt_bins ,preselected, year, magnet, MC, ReferenceChannel, PHSP, truthMatched);
  3023. // if (!OnlyDTF){
  3024. res_sys(h_ThetaL_KstPt_ref, h_ThetaL_KstPt_res_sys, h_ThetaL_KstPt_sys, h_ThetaL_KstPt_res, func, eta_bins_B, output, preselected, year, magnet, MC, ReferenceChannel, PHSP, truthMatched);
  3025. res(h_ThetaL_KstPt_res_sys, h_ThetaL_KstPt_res, KstPt_bins ,preselected, year, magnet, MC, ReferenceChannel, PHSP, truthMatched);
  3026. sys(h_ThetaL_KstPt_res_sys, h_ThetaL_KstPt_sys, KstPt_bins ,preselected, year, magnet, MC, ReferenceChannel, PHSP, truthMatched);
  3027. // }
  3028. res_sys(h_Phi_KstPt_DTF_ref, h_Phi_KstPt_DTF_res_sys, h_Phi_KstPt_DTF_sys, h_Phi_KstPt_DTF_res, func, eta_bins_B, output, preselected, year, magnet, MC, ReferenceChannel, PHSP, truthMatched);
  3029. res(h_Phi_KstPt_DTF_res_sys, h_Phi_KstPt_DTF_res, KstPt_bins ,preselected, year, magnet, MC, ReferenceChannel, PHSP, truthMatched);
  3030. sys(h_Phi_KstPt_DTF_res_sys, h_Phi_KstPt_DTF_sys, KstPt_bins ,preselected, year, magnet, MC, ReferenceChannel, PHSP, truthMatched);
  3031. if (!OnlyDTF){
  3032. res_sys(h_Phi_KstPt_ref, h_Phi_KstPt_res_sys, h_Phi_KstPt_sys, h_Phi_KstPt_res, func, eta_bins_B, output, preselected, year, magnet, MC, ReferenceChannel, PHSP, truthMatched);
  3033. res(h_Phi_KstPt_res_sys, h_Phi_KstPt_res, KstPt_bins ,preselected, year, magnet, MC, ReferenceChannel, PHSP, truthMatched);
  3034. sys(h_Phi_KstPt_res_sys, h_Phi_KstPt_sys, KstPt_bins ,preselected, year, magnet, MC, ReferenceChannel, PHSP, truthMatched);
  3035. }
  3036. res_sys(h_Kstar_ETA_DTF_ref,h_Kstar_ETA_DTF_res_sys,h_Kstar_ETA_DTF_sys,h_Kstar_ETA_DTF_res,func, eta_bins, output, preselected, year, magnet, MC, ReferenceChannel, PHSP, truthMatched);
  3037. res(h_Kstar_ETA_DTF_res_sys, h_Kstar_ETA_DTF_res,eta_bins ,preselected, year, magnet, MC, ReferenceChannel, PHSP, truthMatched);
  3038. sys(h_Kstar_ETA_DTF_res_sys, h_Kstar_ETA_DTF_sys,eta_bins ,preselected, year, magnet, MC, ReferenceChannel, PHSP, truthMatched);
  3039. if (!OnlyDTF){
  3040. res_sys(h_Kstar_ETA_ref, h_Kstar_ETA_res_sys, h_Kstar_ETA_sys,h_Kstar_ETA_res, func, eta_bins, output, preselected, year, magnet, MC, ReferenceChannel, PHSP, truthMatched);
  3041. res(h_Kstar_ETA_res_sys, h_Kstar_ETA_res, eta_bins ,preselected, year, magnet, MC, ReferenceChannel, PHSP, truthMatched);
  3042. sys(h_Kstar_ETA_res_sys, h_Kstar_ETA_sys, eta_bins ,preselected, year, magnet, MC, ReferenceChannel, PHSP, truthMatched);
  3043. }
  3044. res_sys(h_Kplus_ETA_DTF_ref,h_Kplus_ETA_DTF_res_sys,h_Kplus_ETA_DTF_sys,h_Kplus_ETA_DTF_res,func, eta_bins, output, preselected, year, magnet, MC, ReferenceChannel, PHSP, truthMatched);
  3045. res(h_Kplus_ETA_DTF_res_sys, h_Kplus_ETA_DTF_res,eta_bins ,preselected, year, magnet, MC, ReferenceChannel, PHSP, truthMatched);
  3046. sys(h_Kplus_ETA_DTF_res_sys, h_Kplus_ETA_DTF_sys,eta_bins ,preselected, year, magnet, MC, ReferenceChannel, PHSP, truthMatched);
  3047. if (!OnlyDTF){
  3048. res_sys(h_Kplus_ETA_ref, h_Kplus_ETA_res_sys, h_Kplus_ETA_sys, h_Kplus_ETA_res, func, eta_bins, output, preselected, year, magnet, MC, ReferenceChannel, PHSP, truthMatched);
  3049. res(h_Kplus_ETA_res_sys, h_Kplus_ETA_res,eta_bins ,preselected, year, magnet, MC, ReferenceChannel, PHSP, truthMatched);
  3050. sys(h_Kplus_ETA_res_sys, h_Kplus_ETA_sys,eta_bins ,preselected, year, magnet, MC, ReferenceChannel, PHSP, truthMatched);
  3051. }
  3052. res_sys(h_pi0_ETA_DTF_ref, h_pi0_ETA_DTF_res_sys, h_pi0_ETA_DTF_sys, h_pi0_ETA_DTF_res, func, eta_bins, output, preselected, year, magnet, MC, ReferenceChannel, PHSP, truthMatched);
  3053. res_sys(h_pi0_PVZ_DTF_ref, h_pi0_PVZ_DTF_res_sys, h_pi0_PVZ_DTF_sys, h_pi0_PVZ_DTF_res, func, PVZ_bins, output, preselected, year, magnet, MC, ReferenceChannel, PHSP, truthMatched);
  3054. res_sys(h_pi0_KstPt_DTF_ref,h_pi0_KstPt_DTF_res_sys,h_pi0_KstPt_DTF_sys,h_pi0_KstPt_DTF_res,func, KstPt_bins, output, preselected, year, magnet, MC, ReferenceChannel, PHSP, truthMatched);
  3055. res( h_pi0_ETA_DTF_res_sys, h_pi0_ETA_DTF_res, eta_bins ,preselected, year, magnet, MC, ReferenceChannel, PHSP, truthMatched);
  3056. res( h_pi0_PVZ_DTF_res_sys, h_pi0_PVZ_res, PVZ_bins ,preselected, year, magnet, MC, ReferenceChannel, PHSP, truthMatched);
  3057. res( h_pi0_KstPt_DTF_res_sys, h_pi0_KstPt_DTF_res, KstPt_bins ,preselected, year, magnet, MC, ReferenceChannel, PHSP, truthMatched);
  3058. sys( h_pi0_ETA_DTF_res_sys, h_pi0_ETA_DTF_sys, eta_bins ,preselected, year, magnet, MC, ReferenceChannel, PHSP, truthMatched);
  3059. sys( h_pi0_PVZ_DTF_res_sys, h_pi0_PVZ_sys, PVZ_bins ,preselected, year, magnet, MC, ReferenceChannel, PHSP, truthMatched);
  3060. sys( h_pi0_KstPt_DTF_res_sys, h_pi0_KstPt_DTF_sys, KstPt_bins ,preselected, year, magnet, MC, ReferenceChannel, PHSP, truthMatched);
  3061. if (!OnlyDTF){
  3062. res_sys(h_pi0_ETA_ref, h_pi0_ETA_res_sys, h_pi0_ETA_sys, h_pi0_ETA_res, func, eta_bins, output, preselected, year, magnet, MC, ReferenceChannel, PHSP, truthMatched);
  3063. res_sys(h_pi0_PVZ_ref, h_pi0_PVZ_res_sys, h_pi0_PVZ_sys, h_pi0_PVZ_res, func, PVZ_bins, output, preselected, year, magnet, MC, ReferenceChannel, PHSP, truthMatched);
  3064. res_sys(h_pi0_KstPt_ref, h_pi0_KstPt_res_sys, h_pi0_KstPt_sys, h_pi0_KstPt_res, func, KstPt_bins, output, preselected, year, magnet, MC, ReferenceChannel, PHSP, truthMatched);
  3065. res( h_pi0_ETA_res_sys, h_pi0_ETA_res, eta_bins ,preselected, year, magnet, MC, ReferenceChannel, PHSP, truthMatched);
  3066. res( h_pi0_PVZ_res_sys, h_pi0_PVZ_res, PVZ_bins ,preselected, year, magnet, MC, ReferenceChannel, PHSP, truthMatched);
  3067. res( h_pi0_KstPt_res_sys, h_pi0_KstPt_res, KstPt_bins ,preselected, year, magnet, MC, ReferenceChannel, PHSP, truthMatched);
  3068. sys( h_pi0_ETA_res_sys, h_pi0_ETA_sys, eta_bins ,preselected, year, magnet, MC, ReferenceChannel, PHSP, truthMatched);
  3069. sys( h_pi0_PVZ_res_sys, h_pi0_PVZ_sys, PVZ_bins ,preselected, year, magnet, MC, ReferenceChannel, PHSP, truthMatched);
  3070. sys( h_pi0_KstPt_res_sys, h_pi0_KstPt_sys, KstPt_bins ,preselected, year, magnet, MC, ReferenceChannel, PHSP, truthMatched);
  3071. }
  3072. //////////////////////////////////
  3073. ///// //////
  3074. //// Fill pull histos /////
  3075. ///// //////
  3076. //////////////////////////////////
  3077. pull(h_Bplus_ETA_DTF_res, h_Bplus_ETA_DTF_pull, eta_bins_B ,preselected, year, magnet, MC, ReferenceChannel, PHSP, truthMatched);
  3078. pull(h_ThetaK_KstPt_DTF_res_sys,h_ThetaK_KstPt_DTF_pull,KstPt_bins ,preselected, year, magnet, MC, ReferenceChannel, PHSP, truthMatched);
  3079. pull(h_ThetaL_KstPt_DTF_res_sys,h_ThetaL_KstPt_DTF_pull,KstPt_bins ,preselected, year, magnet, MC, ReferenceChannel, PHSP, truthMatched);
  3080. pull(h_Phi_KstPt_DTF_res_sys, h_Phi_KstPt_DTF_pull, KstPt_bins ,preselected, year, magnet, MC, ReferenceChannel, PHSP, truthMatched);
  3081. pull(h_Kstar_ETA_DTF_res_sys, h_Kstar_ETA_DTF_pull, eta_bins ,preselected, year, magnet, MC, ReferenceChannel, PHSP, truthMatched);
  3082. pull(h_Kplus_ETA_DTF_res_sys, h_Kplus_ETA_DTF_pull, eta_bins ,preselected, year, magnet, MC, ReferenceChannel, PHSP, truthMatched);
  3083. pull(h_pi0_ETA_DTF_res_sys, h_pi0_ETA_DTF_pull, eta_bins ,preselected, year, magnet, MC, ReferenceChannel, PHSP, truthMatched);
  3084. pull(h_pi0_PVZ_DTF_res_sys, h_pi0_PVZ_DTF_pull, PVZ_bins ,preselected, year, magnet, MC, ReferenceChannel, PHSP, truthMatched);
  3085. pull(h_pi0_KstPt_DTF_res_sys, h_pi0_KstPt_DTF_pull, KstPt_bins ,preselected, year, magnet, MC, ReferenceChannel, PHSP, truthMatched);
  3086. if (!OnlyDTF){
  3087. pull(h_Bplus_ETA_res, h_Bplus_ETA_pull, eta_bins_B ,preselected, year, magnet, MC, ReferenceChannel, PHSP, truthMatched);
  3088. pull(h_ThetaK_KstPt_res_sys,h_ThetaK_KstPt_pull, KstPt_bins ,preselected, year, magnet, MC, ReferenceChannel, PHSP, truthMatched);
  3089. pull(h_ThetaL_KstPt_res_sys,h_ThetaL_KstPt_pull, KstPt_bins ,preselected, year, magnet, MC, ReferenceChannel, PHSP, truthMatched);
  3090. pull(h_Phi_KstPt_res_sys, h_Phi_KstPt_pull, KstPt_bins ,preselected, year, magnet, MC, ReferenceChannel, PHSP, truthMatched);
  3091. pull(h_Kstar_ETA_res_sys, h_Kstar_ETA_pull, eta_bins ,preselected, year, magnet, MC, ReferenceChannel, PHSP, truthMatched);
  3092. pull(h_Kplus_ETA_res_sys, h_Kplus_ETA_pull, eta_bins ,preselected, year, magnet, MC, ReferenceChannel, PHSP, truthMatched);
  3093. pull(h_pi0_ETA_res_sys, h_pi0_ETA_pull, eta_bins ,preselected, year, magnet, MC, ReferenceChannel, PHSP, truthMatched);
  3094. pull(h_pi0_PVZ_res_sys, h_pi0_PVZ_pull, PVZ_bins ,preselected, year, magnet, MC, ReferenceChannel, PHSP, truthMatched);
  3095. pull(h_pi0_KstPt_res_sys, h_pi0_KstPt_pull, KstPt_bins ,preselected, year, magnet, MC, ReferenceChannel, PHSP, truthMatched);
  3096. }
  3097. //////////////////////////////////
  3098. ///// //////
  3099. //// Save all histos /////
  3100. ///// //////
  3101. //////////////////////////////////
  3102. h_Bplus_ETA_DTF ->Write();
  3103. h_Bplus_ETA_TRUE ->Write();
  3104. h_Bplus_ETA_DTF_ref ->Write();
  3105. h_Bplus_ETA_DTF_rec_MC ->Write();
  3106. design_corr(h_Bplus_ETA_DTF_rec_MC, preselected, year, magnet, MC, ReferenceChannel, PHSP, truthMatched);
  3107. design_comparison(h_Bplus_ETA_DTF,h_Bplus_ETA_TRUE, preselected, year, magnet, MC, ReferenceChannel, PHSP, truthMatched);
  3108. if (!OnlyDTF){
  3109. h_Bplus_ETA ->Write();
  3110. h_Bplus_ETA_ref ->Write();
  3111. h_Bplus_ETA_rec_MC ->Write();
  3112. design_corr(h_Bplus_ETA_rec_MC, preselected, year, magnet, MC, ReferenceChannel, PHSP, truthMatched);
  3113. design_comparison(h_Bplus_ETA,h_Bplus_ETA_TRUE, preselected, year, magnet, MC, ReferenceChannel, PHSP, truthMatched);
  3114. }
  3115. //--------------------------
  3116. h_ThetaK_DTF ->Write();
  3117. h_ThetaK_TRUE ->Write();
  3118. h_ThetaK_KstPt_DTF_ref ->Write();
  3119. h_ThetaK_DTF_rec_MC ->Write();
  3120. design_corr(h_ThetaK_DTF_rec_MC, preselected, year, magnet, MC, ReferenceChannel, PHSP, truthMatched);
  3121. design_comparison(h_ThetaK_DTF,h_ThetaK_TRUE, preselected, year, magnet, MC, ReferenceChannel, PHSP, truthMatched);
  3122. // if (!OnlyDTF){
  3123. h_ThetaK ->Write();
  3124. h_ThetaK_KstPt_ref ->Write();
  3125. h_ThetaK_rec_MC ->Write();
  3126. design_corr(h_ThetaK_rec_MC, preselected, year, magnet, MC, ReferenceChannel, PHSP, truthMatched);
  3127. design_comparison(h_ThetaK,h_ThetaK_TRUE, preselected, year, magnet, MC, ReferenceChannel, PHSP, truthMatched);
  3128. // }
  3129. //--------------------------
  3130. h_ThetaL_DTF ->Write();
  3131. h_ThetaL_TRUE ->Write();
  3132. h_ThetaL_KstPt_DTF_ref ->Write();
  3133. h_ThetaL_DTF_rec_MC ->Write();
  3134. design_corr(h_ThetaL_DTF_rec_MC, preselected, year, magnet, MC, ReferenceChannel, PHSP, truthMatched);
  3135. design_comparison(h_ThetaL_DTF,h_ThetaL_TRUE, preselected, year, magnet, MC, ReferenceChannel, PHSP, truthMatched);
  3136. // if (!OnlyDTF){
  3137. h_ThetaL ->Write();
  3138. h_ThetaL_KstPt_ref ->Write();
  3139. h_ThetaL_rec_MC ->Write();
  3140. design_corr(h_ThetaL_rec_MC, preselected, year, magnet, MC, ReferenceChannel, PHSP, truthMatched);
  3141. design_comparison(h_ThetaL,h_ThetaL_TRUE, preselected, year, magnet, MC, ReferenceChannel, PHSP, truthMatched);
  3142. // }
  3143. //--------------------------
  3144. h_Phi_DTF ->Write();
  3145. h_Phi_TRUE ->Write();
  3146. h_Phi_KstPt_DTF_ref ->Write();
  3147. h_Phi_DTF_rec_MC ->Write();
  3148. design_corr(h_Phi_DTF_rec_MC, preselected, year, magnet, MC, ReferenceChannel, PHSP, truthMatched);
  3149. design_comparison(h_Phi_DTF,h_Phi_TRUE, preselected, year, magnet, MC, ReferenceChannel, PHSP, truthMatched);
  3150. // if (!OnlyDTF){
  3151. h_Phi ->Write();
  3152. h_Phi_KstPt_ref ->Write();
  3153. h_Phi_rec_MC ->Write();
  3154. design_corr(h_Phi_rec_MC, preselected, year, magnet, MC, ReferenceChannel, PHSP, truthMatched);
  3155. design_comparison(h_Phi,h_Phi_TRUE, preselected, year, magnet, MC, ReferenceChannel, PHSP, truthMatched);
  3156. // }
  3157. //--------------------------
  3158. h_Kstar_ETA_DTF ->Write();
  3159. h_Kstar_ETA_TRUE ->Write();
  3160. h_Kstar_ETA_DTF_ref ->Write();
  3161. h_Kstar_ETA_DTF_rec_MC ->Write();
  3162. design_corr(h_Kstar_ETA_DTF_rec_MC, preselected, year, magnet, MC, ReferenceChannel, PHSP, truthMatched);
  3163. design_comparison(h_Kstar_ETA_DTF,h_Kstar_ETA_TRUE, preselected, year, magnet, MC, ReferenceChannel, PHSP, truthMatched);
  3164. if (!OnlyDTF){
  3165. h_Kstar_ETA ->Write();
  3166. h_Kstar_ETA_ref ->Write();
  3167. h_Kstar_ETA_rec_MC ->Write();
  3168. design_corr(h_Kstar_ETA_rec_MC, preselected, year, magnet, MC, ReferenceChannel, PHSP, truthMatched);
  3169. design_comparison(h_Kstar_ETA,h_Kstar_ETA_TRUE, preselected, year, magnet, MC, ReferenceChannel, PHSP, truthMatched);
  3170. }
  3171. //--------------------------
  3172. h_PVZ_TRUE ->Write();
  3173. h_PVZ ->Write();
  3174. h_PVZ_rec_MC ->Write();
  3175. h_PVZ_ref ->Write();
  3176. design_corr(h_PVZ_rec_MC, preselected, year, magnet, MC, ReferenceChannel, PHSP, truthMatched);
  3177. design_diff(h_PVZ_ref, preselected, year, magnet, MC, ReferenceChannel, PHSP, truthMatched);
  3178. design_comparison(h_PVZ,h_PVZ_TRUE, preselected, year, magnet, MC, ReferenceChannel, PHSP, truthMatched);
  3179. //--------------------------
  3180. if (Kst2Kpluspi0Resolved){
  3181. h_Kplus_ETA_DTF ->Write();
  3182. h_Kplus_ETA_TRUE ->Write();
  3183. h_Kplus_ETA_DTF_ref ->Write();
  3184. h_Kplus_ETA_DTF_rec_MC ->Write();
  3185. design_corr(h_Kplus_ETA_DTF_rec_MC, preselected, year, magnet, MC, ReferenceChannel, PHSP, truthMatched);
  3186. design_comparison(h_Kplus_ETA_DTF,h_Kplus_ETA_TRUE, preselected, year, magnet, MC, ReferenceChannel, PHSP, truthMatched);
  3187. if (!OnlyDTF){
  3188. h_Kplus_ETA ->Write();
  3189. h_Kplus_ETA_ref ->Write();
  3190. h_Kplus_ETA_rec_MC ->Write();
  3191. design_corr(h_Kplus_ETA_rec_MC, preselected, year, magnet, MC, ReferenceChannel, PHSP, truthMatched);
  3192. design_comparison(h_Kplus_ETA,h_Kplus_ETA_TRUE, preselected, year, magnet, MC, ReferenceChannel, PHSP, truthMatched);
  3193. }
  3194. //--------------------------
  3195. h_pi0_ETA_DTF ->Write();
  3196. h_pi0_ETA_TRUE ->Write();
  3197. h_pi0_ETA_DTF_ref ->Write();
  3198. h_pi0_PVZ_ref ->Write();
  3199. h_pi0_ETA_DTF_rec_MC->Write();
  3200. design_corr(h_pi0_ETA_DTF_rec_MC, preselected, year, magnet, MC, ReferenceChannel, PHSP, truthMatched);
  3201. design_comparison(h_pi0_ETA_DTF,h_pi0_ETA_TRUE, preselected, year, magnet, MC, ReferenceChannel, PHSP, truthMatched);
  3202. if (!OnlyDTF){
  3203. h_pi0_ETA ->Write();
  3204. h_pi0_ETA_ref ->Write();
  3205. h_pi0_ETA_rec_MC ->Write();
  3206. design_corr(h_pi0_ETA_rec_MC, preselected, year, magnet, MC, ReferenceChannel, PHSP, truthMatched);
  3207. design_comparison(h_pi0_ETA,h_pi0_ETA_TRUE, preselected, year, magnet, MC, ReferenceChannel, PHSP, truthMatched);
  3208. }
  3209. }
  3210. //--------------------------
  3211. output->Close();
  3212. return 1;
  3213. }
  3214. int ResHistAllMC(Int_t Run = 1, bool preselected = true, bool truthMatched = false) {
  3215. if(Run != 1 && Run != 2){
  3216. std::cout << "[ERROR]\t\tInvalid Run number given: " << Run << ". Exit program!" << std::endl;
  3217. return 0;
  3218. }
  3219. if ( ResHist((Run == 1 ? "2011" : "2015"),"down", true, false, false, preselected, truthMatched) == 0) return 0;
  3220. if ( ResHist((Run == 1 ? "2011" : "2015"),"up" , true, false, false, preselected, truthMatched) == 0) return 0;
  3221. if ( ResHist((Run == 1 ? "2012" : "2016"),"down", true, false, false, preselected, truthMatched) == 0) return 0;
  3222. if ( ResHist((Run == 1 ? "2012" : "2016"),"up" , true, false, false, preselected, truthMatched) == 0) return 0;
  3223. return 1;
  3224. }
  3225. int ResHistAllRefChannel(Int_t Run = 1, bool preselected = true, bool truthMatched = false) {
  3226. if(Run != 1 && Run != 2){
  3227. std::cout << "[ERROR]\t\tInvalid Run number given: " << Run << ". Exit program!" << std::endl;
  3228. return 0;
  3229. }
  3230. if ( ResHist((Run == 1 ? "2011" : "2015"),"down", true, true, false, preselected, truthMatched) == 0) return 0;
  3231. if ( ResHist((Run == 1 ? "2011" : "2015"),"up" , true, true, false, preselected, truthMatched) == 0) return 0;
  3232. if ( ResHist((Run == 1 ? "2012" : "2016"),"down", true, true, false, preselected, truthMatched) == 0) return 0;
  3233. if ( ResHist((Run == 1 ? "2012" : "2016"),"up" , true, true, false, preselected, truthMatched) == 0) return 0;
  3234. return 1;
  3235. }
  3236. int ResHistAllPHSP(Int_t Run = 1, bool preselected = true, bool truthMatched = false) {
  3237. if(Run != 1 && Run != 2){
  3238. std::cout << "[ERROR]\t\tInvalid Run number given: " << Run << ". Exit program!" << std::endl;
  3239. return 0;
  3240. }
  3241. if ( ResHist((Run == 1 ? "2011" : "2015"),"down", true, false, true, preselected, truthMatched) == 0) return 0;
  3242. if ( ResHist((Run == 1 ? "2011" : "2015"),"up" , true, false, true, preselected, truthMatched) == 0) return 0;
  3243. if ( ResHist((Run == 1 ? "2012" : "2016"),"down", true, false, true, preselected, truthMatched) == 0) return 0;
  3244. if ( ResHist((Run == 1 ? "2012" : "2016"),"up" , true, false, true, preselected, truthMatched) == 0) return 0;
  3245. return 1;
  3246. }
  3247. int ResHistAll( Int_t Run = 1, bool preselected = true, bool truthMatched = false) {
  3248. if (ResHistAllMC (Run, preselected, truthMatched)==0) return 0;
  3249. if (ResHistAllRefChannel (Run, preselected, truthMatched)==0) return 0;
  3250. if (ResHistAllPHSP (Run, preselected, truthMatched)==0) return 0;
  3251. return 1;
  3252. }
  3253. int ResHistComplete( Int_t Run = 1){
  3254. if (ResHistAllMC (Run, 0, 0)==0) return 0;
  3255. if (ResHistAllMC (Run, 1, 0)==0) return 0;
  3256. if (ResHistAllMC (Run, 1, 1)==0) return 0;
  3257. if (ResHistAllRefChannel (Run, 0, 0)==0) return 0;
  3258. if (ResHistAllRefChannel (Run, 1, 0)==0) return 0;
  3259. if (ResHistAllRefChannel (Run, 1, 1)==0) return 0;
  3260. if (ResHistAllPHSP (Run, 0, 0)==0) return 0;
  3261. if (ResHistAllPHSP (Run, 1, 0)==0) return 0;
  3262. if (ResHistAllPHSP (Run, 1, 1)==0) return 0;
  3263. return 1;
  3264. }