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.

664 lines
20 KiB

  1. //Functions to make pretty plots from ROOT TMVA training output
  2. //Renata Kopecna
  3. #include "GlobalFunctions.hh"
  4. #include "Design.hpp"
  5. #include "Paths.hpp"
  6. #include "MVAclass.hpp"
  7. #include <sys/stat.h> //mkdir
  8. using namespace std;
  9. TFile *GetTMVAfile(int year, int Run, bool SplitYears, bool KShortDecaysInVelo, int nConfiguration, bool UseLowQ2Range, string customTMbranch, bool gammaTM){
  10. TFile * file = new TFile(GetBDTConfigFile(SplitYears,year,Run,KShortDecaysInVelo,nConfiguration,UseLowQ2Range, customTMbranch, gammaTM).c_str(),"OPEN");
  11. if (file == NULL) coutERROR("Cannot read input file " + GetBDTConfigFile(SplitYears,year,Run,KShortDecaysInVelo,nConfiguration,UseLowQ2Range, customTMbranch, gammaTM) + "!");
  12. std::cout << "Reading file '" << GetBDTConfigFile(SplitYears,year,Run,KShortDecaysInVelo,nConfiguration,UseLowQ2Range, customTMbranch, gammaTM) << "'" << std::endl;
  13. return file;
  14. }
  15. TH2F *GetCorrelationMatrix(TFile *file, string type){ //type = S,B
  16. string path = "CorrelationMatrix" + type;
  17. TH2F *h2_corrMatrix = (TH2F*)file->Get(path.c_str());
  18. if (h2_corrMatrix == NULL) coutERROR("Couldn't get correlation matrix for " + type + "!");
  19. return h2_corrMatrix;
  20. }
  21. TH2F *GetCorrelationMatrixSignal(TFile *file){
  22. return GetCorrelationMatrix(file,"S");
  23. }
  24. TH2F *GetCorrelationMatrixBackground(TFile *file){
  25. return GetCorrelationMatrix(file,"B");
  26. }
  27. string oberFolder(string method){
  28. return (method.find("BDT") != std::string::npos ? "BDT" : method);
  29. }
  30. TH1F *GetTMVAresponse(TFile *file, string method, string type){ //type = S,B, Train_S, Train_B
  31. string path = "Method_" + oberFolder(method) + "/" + method + "/MVA_" + method + "_" + type;
  32. TH1F *h_TMVAresp = (TH1F*)file->Get(path.c_str());
  33. if (h_TMVAresp == NULL) coutERROR("Couldn't get TMVA response for " + method + " and type " + type + "!");
  34. return h_TMVAresp;
  35. }
  36. TH1F *GetTMVAresponseSignal(TFile *file, string method){
  37. return GetTMVAresponse(file, method,"S");
  38. }
  39. TH1F *GetTMVAresponseBackground(TFile *file, string method){
  40. return GetTMVAresponse(file, method,"B");
  41. }
  42. TH1F *GetTMVAresponseTrainingSignal(TFile *file, string method){
  43. return GetTMVAresponse(file, method,"Train_S");
  44. }
  45. TH1F *GetTMVAresponseTrainingBackground(TFile *file, string method){
  46. return GetTMVAresponse(file, method,"Train_B");
  47. }
  48. TH1F *GetVariableSignal(TFile *file, string variable){
  49. string path = "InputVariables_Id/"+variable+"__Signal_Id";
  50. TH1F *h_varS = (TH1F*)file->Get(path.c_str());
  51. if (h_varS == NULL) coutERROR("Couldn't get " + variable + "_S distribution!");
  52. return h_varS;
  53. }
  54. TH1F *GetVariableBackground(TFile *file, string variable){
  55. string path = "InputVariables_Id/"+variable+"__Background_Id";
  56. TH1F *h_varB = (TH1F*)file->Get(path.c_str());
  57. if (h_varB == NULL) coutERROR("Couldn't get " + variable + "_B distribution!");
  58. return h_varB;
  59. }
  60. TH1F *GetEfficiencySignal(TFile *file, string method){
  61. string path = "Method_" + oberFolder(method) + "/" +method + "/MVA_" + method + "_effS";
  62. TH1F *h_effS = (TH1F*)file->Get(path.c_str());
  63. if (h_effS == NULL) coutERROR("Couldn't get signal efficiency for " + method + "!");
  64. return h_effS;
  65. }
  66. TH1F *GetEfficiencyBackground(TFile *file, string method){
  67. string path = "Method_" + oberFolder(method) + "/" +method + "/MVA_" + method + "_effB";
  68. TH1F *h_effB = (TH1F*)file->Get(path.c_str());
  69. if (h_effB == NULL) coutERROR("Couldn't get background efficiency for " + method + "!");
  70. return h_effB;
  71. }
  72. TH1F *GetROC(TFile *file, string method){
  73. string path = "Method_" + oberFolder(method) + "/" +method + "/MVA_" + method + "_rejBvsS";
  74. TH1F *h_ROC = (TH1F*)file->Get(path.c_str());
  75. if (h_ROC == NULL) coutERROR("Couldn't get ROC curve for " + method + "!");
  76. return h_ROC;
  77. }
  78. TTree *GetTrainTree(TFile *file){
  79. TTree *t_train = (TTree*)file->Get("TrainTree");
  80. return t_train;
  81. }
  82. TTree *GetTestTree(TFile *file){
  83. TTree *t_test = (TTree*)file->Get("TestTree");
  84. return t_test;
  85. }
  86. int GetTrainEvents(TFile *file){
  87. TTree *t_train = (TTree*)file->Get("TrainTree");
  88. int n = t_train->GetEntries();
  89. delete t_train;
  90. return n;
  91. }
  92. int GetTrainSignalEvents(TFile *file){
  93. TTree *t_train = (TTree*)file->Get("TrainTree");
  94. int nSig = t_train->Draw("classID","classID==0");
  95. delete t_train;
  96. coutDebug("nSig = " + to_string(nSig));
  97. return nSig;
  98. }
  99. int GetTrainBackgroundEvents(TFile *file){
  100. TTree *t_train = (TTree*)file->Get("TrainTree");
  101. int nBkg = t_train->Draw("classID","classID==1");
  102. delete t_train;
  103. coutDebug("nBkg = " + to_string(nBkg));
  104. return nBkg;
  105. }
  106. //Make plots from file
  107. bool SaveCorrelationPlot(TFile *file, string type, string savePath){
  108. TH2F *h_corr = GetCorrelationMatrix(file, type); //S or B
  109. if (h_corr == NULL) return 0;
  110. DesignCorrelationPlots(h_corr);
  111. TCanvas *c_corr= c_Correlation(type);
  112. c_corr->cd();
  113. h_corr->Draw("COLZTEXT");
  114. string path = savePath + "Correlation"+ type +".eps";
  115. c_corr->SaveAs(path.c_str());
  116. replace(path,".eps",".root");
  117. c_corr->SaveAs(path.c_str());
  118. h_corr->Clear();
  119. delete h_corr;
  120. c_corr->Clear();
  121. delete c_corr;
  122. return 1;
  123. }
  124. //Load all variable names from MVA reader
  125. vector <string> v_variables(string DL="") {
  126. MVA_variables * InputVariables = new MVA_variables(DL);
  127. vector <string> v_var;
  128. for (auto & var : InputVariables->GetAllReaderNames()){
  129. size_t pos = var.find(":");
  130. if (pos != string::npos){
  131. string tmp = var;
  132. tmp.erase(tmp.begin()+pos,tmp.end());
  133. v_var.push_back(tmp);//var.erase(var.begin(),var.end()));
  134. }
  135. else v_var.push_back(var);
  136. }
  137. return v_var;
  138. }
  139. bool SaveVariablesSignalVsBackground(TFile *file, string savePath, string DL=""){
  140. //Check if folder for the plots exists and if not, create one
  141. string folder_path = savePath + "variables/";
  142. struct stat st;
  143. if (stat(folder_path.c_str(),&st)!=0 && mkdir(folder_path.c_str(), 0755)==-1){
  144. coutERROR("Folder "+folder_path+" couldn't be created!");
  145. return 0;
  146. }
  147. //get vector of variables
  148. vector <string> v_var = v_variables(DL);
  149. if (v_var.empty()){
  150. coutERROR("Variable vector is empty!");
  151. return 0;
  152. }
  153. //loop over variables
  154. for (auto& var : v_var){
  155. //Create a TCanvas
  156. TCanvas *c_variable = c_VariablesSignalVsBackground(var);
  157. c_variable->cd();
  158. //Get signal and background histograms
  159. TH1F *h_variableS = GetVariableSignal(file,var);
  160. TH1F *h_variableB = GetVariableBackground(file,var);
  161. //normalize them
  162. h_variableS->Scale(1.0/(h_variableS->GetEntries()*h_variableS->GetXaxis()->GetBinWidth(3)));
  163. h_variableB->Scale(1.0/(h_variableB->GetEntries()*h_variableB->GetXaxis()->GetBinWidth(3)));
  164. //Make it pretty
  165. designVariablesSignalVsBackground(h_variableS,h_variableB);
  166. //Plot it
  167. h_variableS->Draw("HIST");
  168. h_variableB->Draw("HIST SAME");
  169. //Save it
  170. string path = folder_path+var+".eps";
  171. c_variable->SaveAs(path.c_str());
  172. replace(path,".eps",".root");
  173. c_variable->SaveAs(path.c_str());
  174. //Delete it (the comments would make a cool DaftPunk song)
  175. h_variableS->Clear();
  176. h_variableB->Clear();
  177. delete h_variableS;
  178. delete h_variableB;
  179. c_variable->Clear();
  180. delete c_variable;
  181. }
  182. return 1;
  183. }
  184. bool SaveMVAResponse(TFile *file, string savePath, string method){ //Check if folder for the plots exists and if not, create one
  185. //Check for valid method
  186. if (method != "BDT" && method !="BDTG" && method != "MLP"){
  187. coutERROR("Wrong method used in SaveMVAResponse! Choose from [BDT, BDTG, MLP]!");
  188. return 0;
  189. }
  190. //Create a TCanvas
  191. string c_name = method + "_response";
  192. TCanvas *c_response = c_VariablesSignalVsBackground(c_name.c_str());
  193. c_response->cd();
  194. //Get signal and background histograms
  195. TH1F *h_responseS = GetTMVAresponseSignal(file,method);
  196. TH1F *h_responseB = GetTMVAresponseBackground(file,method);
  197. //Set log scale if not BDT
  198. if (method != "BDT") c_response->SetLogy();
  199. //Make it pretty
  200. designResponseSignalVsBackground(h_responseS,h_responseB, method);
  201. //Plot it
  202. h_responseS->Draw("BAR");
  203. h_responseB->Draw("BAR SAME");
  204. //Add legend
  205. TLegend *leg = new TLegend(0.13,0.9,0.4,0.79);
  206. leg->AddEntry(h_responseS, "Signal","f");
  207. leg->AddEntry(h_responseB, "Background","f");
  208. leg->Draw("SAME");
  209. //Save it
  210. string path = savePath+method+"_Response.eps";
  211. c_response->SaveAs(path.c_str());
  212. replace(path,".eps",".root");
  213. c_response->SaveAs(path.c_str());
  214. //Delete it (the comments would make a cool DaftPunk song)
  215. h_responseS->Clear();
  216. h_responseB->Clear();
  217. delete h_responseS;
  218. delete h_responseB;
  219. c_response->Clear();
  220. delete c_response;
  221. return 1;
  222. }
  223. bool SaveMVAOvertraining(TFile *file, string savePath, string method){ //Check if folder for the plots exists and if not, create one
  224. //Check for valid method
  225. if (method != "BDT" && method !="BDTG" && method != "MLP"){
  226. coutERROR("Wrong method used in SaveMVAOvertraining! Choose from [BDT, BDTG, MLP]!");
  227. return 0;
  228. }
  229. //Create a TCanvas
  230. string c_name = method + "_overtrain";
  231. TCanvas *c_overtrain = c_VariablesSignalVsBackground(c_name.c_str());
  232. c_overtrain->cd();
  233. //Get signal and background histograms
  234. TH1F *h_overtrainS = GetTMVAresponseSignal(file,method);
  235. TH1F *h_overtrainB = GetTMVAresponseBackground(file,method);
  236. //Get signal and background histograms from training
  237. TH1F *h_overtrainTrainS = GetTMVAresponseTrainingSignal(file,method);
  238. TH1F *h_overtrainTrainB = GetTMVAresponseTrainingBackground(file,method);
  239. //Set log scale if not BDT
  240. if (method != "BDT") c_overtrain->SetLogy();
  241. //Make it pretty
  242. designResponseSignalVsBackground(h_overtrainS,h_overtrainB, method);
  243. designOvertraining(h_overtrainTrainS,h_overtrainTrainB);
  244. //Plot it
  245. h_overtrainS->Draw("][ HIST");
  246. h_overtrainB->Draw("][ HIST SAME");
  247. h_overtrainTrainS->Draw("PSAME");
  248. h_overtrainTrainB->Draw("PSAME");
  249. //Add legends
  250. TLegend *leg = new TLegend(0.2,0.93,0.55,0.82);;
  251. leg->AddEntry(h_overtrainS, "Signal (test)","f");
  252. leg->AddEntry(h_overtrainB, "Background (test)","f");
  253. leg->Draw("SAME");
  254. TLegend *legTrain = new TLegend(0.55,0.93,0.89,0.82);
  255. legTrain->AddEntry(h_overtrainTrainS, "Signal (training)","lep");
  256. legTrain->AddEntry(h_overtrainTrainB, "Background (training)","lep");
  257. legTrain->Draw("SAME");
  258. //Save it
  259. string path = savePath+method+"_Overtraining.eps";
  260. c_overtrain->SaveAs(path.c_str());
  261. replace(path,".eps",".root");
  262. c_overtrain->SaveAs(path.c_str());
  263. //Delete it
  264. h_overtrainS->Clear();
  265. h_overtrainB->Clear();
  266. h_overtrainTrainS->Clear();
  267. h_overtrainTrainB->Clear();
  268. delete h_overtrainS;
  269. delete h_overtrainB;
  270. delete h_overtrainTrainS;
  271. delete h_overtrainTrainB;
  272. c_overtrain->Clear();
  273. delete c_overtrain;
  274. return 1;
  275. }
  276. bool SaveEfficiency(TFile *file, string savePath, string method, int nSig, int nBkg){
  277. //Create a TCanvas
  278. string c_name = method + "_efficiency";
  279. TCanvas *c_eff = c_Efficiency(c_name.c_str());
  280. c_eff->cd();
  281. //Create two pads (to get significance y-axis on the right)
  282. TPad *pad1 = new TPad("pad1","",0,0,1,1);
  283. TPad *pad2 = new TPad("pad2","",0,0,1,1);
  284. pad2->SetFillStyle(4000); //will be transparent
  285. pad2->SetFrameFillStyle(0);
  286. pad1->SetRightMargin(0.16);
  287. pad2->SetRightMargin(0.16);
  288. pad1->Draw();
  289. pad1->cd();
  290. //Get signal+background efficiency
  291. TH1F *h_efficiencyS = GetEfficiencySignal(file,method);
  292. TH1F *h_efficiencyB = GetEfficiencyBackground(file,method);
  293. //Calculate purity
  294. TH1F *h_purity = (TH1F*)h_efficiencyS->Clone();
  295. h_purity->Scale(nSig);
  296. TH1F *h_SplusB = (TH1F*)h_efficiencyS->Clone();
  297. h_SplusB->Scale(nSig);
  298. h_SplusB->Add(h_efficiencyB,nBkg);
  299. h_purity->Divide(h_SplusB);
  300. //Calculate significance
  301. TH1F *h_significance = (TH1F*)h_efficiencyS->Clone();
  302. h_significance->Scale(nSig);
  303. for (int b = 0; b < h_SplusB->GetNbinsX(); b++){
  304. h_SplusB->SetBinContent(b,TMath::Sqrt(h_SplusB->GetBinContent(b))); //TODO check width
  305. }
  306. h_significance->Divide(h_SplusB);
  307. //Make it pretty
  308. designEfficiency(h_efficiencyS,h_efficiencyB,h_purity,h_significance, method);
  309. //Add legends
  310. TLegend *leg = new TLegend(0.15,0.93,0.52,0.82);
  311. leg->AddEntry(h_efficiencyS, "Signal efficiency","l");
  312. leg->AddEntry(h_efficiencyB, "Background efficiency","l");
  313. TLegend *legSignificance = new TLegend(0.52,0.93,0.8,0.82);
  314. legSignificance->AddEntry(h_purity, "Purity","l");
  315. legSignificance->AddEntry(h_significance, "Significance","l");
  316. //Calculate highest significance
  317. double maxSignificance = h_significance->GetMaximum();
  318. double maxSignificanceMLPcut = h_significance->GetBinCenter(h_significance->GetMaximumBin());
  319. double xmin = h_efficiencyS->GetBinLowEdge(1);
  320. TPaveText *text = significanceText(xmin,nSig, nBkg, maxSignificance, maxSignificanceMLPcut);
  321. //Plot it
  322. pad1->cd();
  323. pad1->SetGridy();
  324. pad1->SetGridx();
  325. h_efficiencyS->Draw("SAME");
  326. h_efficiencyB->Draw("SAME");
  327. h_purity->Draw("SAME");
  328. leg->Draw("SAME");
  329. text->Draw("SAME");
  330. pad1->Update();
  331. c_eff->cd();
  332. pad2->Draw();
  333. pad2->cd();
  334. h_significance->Draw("Y+");
  335. h_significance->Draw("SAME");
  336. legSignificance->Draw("SAME");
  337. pad2->Update();
  338. c_eff->cd();
  339. //Save it
  340. string path = savePath+method+"_Efficiency.eps";
  341. c_eff->SaveAs(path.c_str());
  342. replace(path,".eps",".root");
  343. c_eff->SaveAs(path.c_str());
  344. //Delete it
  345. h_efficiencyS->Clear();
  346. h_efficiencyB->Clear();
  347. h_purity->Clear();
  348. h_significance->Clear();
  349. delete h_efficiencyS;
  350. delete h_efficiencyB;
  351. delete h_purity;
  352. delete h_significance;
  353. c_eff->Clear();
  354. delete c_eff;
  355. return 1;
  356. }
  357. string getROCmethod(TH1F *h_ROC){
  358. string name = h_ROC->GetTitle();
  359. name.erase(0,4); //removes MVA_ from the title
  360. return name;
  361. }
  362. bool SaveROCs(TFile *file, string savePath, vector <string> methods){
  363. //Create a TCanvas
  364. TCanvas *c_ROC = c_ROCplot("ROCs");
  365. c_ROC->cd();
  366. //Get all the histograms
  367. vector <TH1F*> v_h_ROC;
  368. for (auto & method:methods){
  369. if (GetROC(file,method)==NULL){ //Check if histogram exists
  370. coutERROR("Method " +method + "is not in the MVA output file!");
  371. return 0;
  372. }
  373. else v_h_ROC.push_back(GetROC(file,method));
  374. }
  375. //add Legend
  376. TLegend *leg = new TLegend(0.25,0.25,0.5,0.35);
  377. //make it pretty and draw it
  378. for_indexed(auto & h_ROC : v_h_ROC){
  379. leg->AddEntry(h_ROC,getROCmethod(h_ROC).c_str(),"l");
  380. designROC(h_ROC,i);
  381. if (i>0) h_ROC->Draw("C SAME");
  382. else h_ROC->Draw("C");
  383. }
  384. leg->SetBorderSize(0);
  385. leg->SetFillStyle(0);
  386. leg->Draw();
  387. //Save it
  388. string path = savePath+"ROCs.eps";
  389. c_ROC->SaveAs(path.c_str());
  390. replace(path,".eps",".root");
  391. c_ROC->SaveAs(path.c_str());
  392. //Delete it
  393. v_h_ROC.clear();
  394. c_ROC->Clear();
  395. delete c_ROC;
  396. return 1;
  397. }
  398. bool SaveMultipleROCS(vector <TFile *> files, string savePath, string method){
  399. //Create a TCanvas
  400. TCanvas *c_ROC = c_ROCplot("ROCs");
  401. c_ROC->cd();
  402. //Get all the histograms
  403. vector <TH1F*> v_h_ROC;
  404. for (auto & file:files){
  405. if (GetROC(file,method)==NULL){ //Check if histogram exists
  406. coutERROR("Method " +method + "is not in the MVA output file " + file->GetPath() + "!");
  407. return 0;
  408. }
  409. else v_h_ROC.push_back(GetROC(file,method));
  410. }
  411. //add Legend
  412. TLegend *leg = new TLegend(0.22,0.22,0.5,0.38);
  413. //make it pretty and draw it
  414. for_indexed(auto & h_ROC : v_h_ROC){
  415. leg->AddEntry(h_ROC,Form("%s_%i",method.c_str(),((int) i)),"l");
  416. designROC(h_ROC,i);
  417. if (i>0) h_ROC->Draw("C SAME");
  418. else h_ROC->Draw("C");
  419. }
  420. leg->SetBorderSize(0);
  421. leg->SetFillStyle(0);
  422. leg->Draw();
  423. //Save it
  424. string path = savePath+"multipleROCs.eps";
  425. c_ROC->SaveAs(path.c_str());
  426. replace(path,".eps",".root");
  427. c_ROC->SaveAs(path.c_str());
  428. //Delete it
  429. v_h_ROC.clear();
  430. c_ROC->Clear();
  431. delete c_ROC;
  432. return 1;
  433. }
  434. void nEvents(int year, int Run, bool SplitYears, bool KshortDecaysInVelo,int nConfiguration,bool UseLowQ2Range, int& nSig, int& nBkg){
  435. //I haven't figured out a better way to get the total number of signal+background events
  436. int arr[2]={0,0};
  437. nSig = 0;
  438. nBkg = 0;
  439. if (KshortChannel){
  440. //TO FILL
  441. if (!SplitYears){
  442. if (Run==1){
  443. if (KshortDecaysInVelo){ //Run1 LL
  444. arr[0] = 97;
  445. arr[1] = 451;
  446. }
  447. else{ //Run1 DD
  448. arr[0] = 158;
  449. arr[1] = 2035;
  450. }
  451. }
  452. else if (Run == 2){
  453. if (KshortDecaysInVelo){ //Run2 LL
  454. arr[0] = 291;
  455. arr[1] = 1016;
  456. }
  457. else{ //Run2 DD
  458. arr[0] = 492;
  459. arr[1] = 4813;
  460. }
  461. }
  462. else if (Run ==12){
  463. //TO FILL
  464. }
  465. else return;
  466. }
  467. else{ //Split Years
  468. //TO FILL
  469. }
  470. }
  471. else{
  472. if (!SplitYears){
  473. if (Run ==1) {
  474. arr[0] = 67;
  475. arr[1] = 14;
  476. }
  477. else if (Run == 2){
  478. arr[0] = 297;
  479. arr[1] = 203;
  480. }
  481. else if (Run ==12){
  482. //TO FILL
  483. }
  484. else return;
  485. }
  486. else{ //Split Years
  487. //TO FILL
  488. }
  489. }
  490. if(arr[0]==0 && arr[1]==0)
  491. coutWarning("No event numbers have been assigned! Please fill in the hardcoded values in Test.cpp");
  492. else
  493. cout << "[INFO]\t\t nSig=" << arr[0] << " nBkg=" << arr[1] << endl;
  494. nSig = arr[0];
  495. nBkg = arr[1];
  496. return;
  497. }
  498. bool SaveAllFromOneFile(int year, int Run, bool SplitYears, bool KshortDecaysInVelo,int nConfiguration, bool UseLowQ2Range, string customTMbranch, bool gammaTM){
  499. vector <string> methods;
  500. if (KshortChannel) methods = {"BDT","BDTG"};
  501. else methods = {"BDT","BDTG","MLP"};
  502. TFile *file= GetTMVAfile(year, Run, SplitYears, KshortDecaysInVelo, nConfiguration, UseLowQ2Range, customTMbranch, gammaTM);
  503. if (file == NULL) return 0;
  504. //Check if folder for the plots exists and if not, create one
  505. string folder_path = GetTMVAplotsFolder(year, Run, SplitYears, KshortDecaysInVelo,nConfiguration,UseLowQ2Range, customTMbranch, gammaTM);
  506. //First, try through Unix command (easier than trying to make a workaround in c++)
  507. string command = "mkdir -p " + folder_path;
  508. system(command.c_str());
  509. //Now check if it has been created indeed
  510. struct stat st;
  511. if (stat(folder_path.c_str(),&st)!=0){
  512. coutERROR("Folder "+folder_path+" couldn't be created!");
  513. return 0;
  514. }
  515. //Save correlations plots
  516. if (!SaveCorrelationPlot(file,"S",folder_path)) return 0;
  517. if (!SaveCorrelationPlot(file,"B",folder_path)) return 0;
  518. //Save all variables plots
  519. SaveVariablesSignalVsBackground(file, folder_path, (KshortChannel ? (KshortDecaysInVelo ? "LL" : "DD") : ""));
  520. int nSig = 0;
  521. int nBkg = 0;
  522. nEvents(year, Run, SplitYears,KshortDecaysInVelo,nConfiguration,UseLowQ2Range, nSig, nBkg);
  523. for (auto &method : methods){
  524. //Save overtraining
  525. if (!SaveMVAOvertraining(file,folder_path,method)) return 0;
  526. //Save efficiency
  527. if (!SaveEfficiency(file,folder_path,method,nSig, nBkg)) return 0;
  528. }
  529. //Save ROCs
  530. if (!SaveROCs(file, folder_path,methods)) return 0;
  531. return 1;
  532. }
  533. bool SaveMultipleROCS(int Run, int nLow, int nHigh){
  534. vector <TFile*> testFiles;
  535. for (int f = nLow; f < nHigh; f++){
  536. testFiles.push_back(GetTMVAfile(2011,Run,false,false,f,false,"",true));
  537. }
  538. string path = GetTMVAplotsFolder(2011,Run,false,false,0,false);
  539. replace(path,"Config0/","");
  540. coutDebug(path);
  541. return (SaveMultipleROCS(testFiles,path,"MLP"));
  542. }