/* * makeResponseGraphs.C * * Created on: Mar 14 23, 2019 * Author: John Russell * * Update to "makeResponseGraphs.C" to look at the new responses to the updated KL bases. */ //void produceMVASampleGraphs(TString MVAType, TString sampleType) { // // int ww = 600; // Canvas width. // int wh = int(0.78 * ww); // Canvas height. // // // Open file from which to draw graphs, access the relevant tree, then add friends if necessary. // TFile sampleFile; // TTree * sampleTree; // // if (sampleType.EqualTo("thermal") || sampleType.EqualTo("signal")) { // // TString sampleFileName; // sampleFileName.Form("backgroundCut_New/" + sampleType + "/backgroundCut-" + sampleType + "-part_all-%d.root", 0); // sampleFile.Open(sampleFileName); // sampleTree = (TTree *) sampleFile.Get(sampleType + "ResponseTree"); // // sampleFileName.Form("backgroundCut_New/" + sampleType + "/backgroundCut-" + sampleType + "-part_all-%d.root", 1); // sampleTree -> AddFriend(sampleType+ "ResponseTree", sampleFileName); // // sampleFileName.Form("backgroundCut_New/" + sampleType + "/backgroundCut-" + sampleType + "-part_all-%d.root", 2); // sampleTree -> AddFriend(sampleType + "ResponseTree", sampleFileName + "2.root"); // // sampleFileName.Form("backgroundCut_New/" + sampleType + "/backgroundCut-" + sampleType + "-part_all-%d.root", 3); // sampleTree -> AddFriend(sampleType + "ResponseTree", sampleFileName + "3.root"); // // } else { // // sampleFile.Open("backgroundCut_New/" + sampleType + "/backgroundCut-" + sampleType + "-part_all.root"); // // sampleTree = (TTree *) sampleFile.Get(sampleType + "ResponseTree"); // // sampleTree -> Print(); // } // // // Create canvases for response plots. // TCanvas cResponse("cResponse", "Canvas for " + MVAType + " " + sampleType + ".", 200, 0, ww, wh); // TCanvas cWeightedResponse("cWeightedResponse", "Canvas for weighted " + MVAType + " " + sampleType + ".", 200, 0, ww, wh); // // TCanvas cCutResponse("cCutResponse", "Canvas for " + MVAType + " " + sampleType + " satisfying cut.", 200, 0, ww, wh); // TCanvas cWeightedCutResponse("cWeightedCutResponse", "Canvas for weighted " + MVAType + " " + sampleType + " satisfying cut.", 200, 0, ww, wh); // // sampleTree -> Print(); // // // Draw the responses on the canvas, set to log scale, then save it. // cResponse.cd(); // sampleTree -> Draw("unweighted." + MVAType); // cResponse.SetLogy(); // cResponse.SaveAs("AllNewResults/responseHists/" + MVAType + "_" + sampleType + ".png"); // // cWeightedResponse.cd(); // sampleTree -> Draw("weighted." + MVAType); // cWeightedResponse.SetLogy(); // cWeightedResponse.SaveAs("AllNewResults/responseHists/" + MVAType + "_" + sampleType + "Weighted.png"); // // // Do the same for the events satisfying the cut. // cCutResponse.cd(); // sampleTree -> Draw("unweighted." + MVAType, "unweighted." + MVAType + " > 0"); // cCutResponse.SetLogy(); // cCutResponse.SaveAs("AllNewResults/responseHists/" + MVAType + "_" + sampleType + "_cut.png"); // // cWeightedCutResponse.cd(); // sampleTree -> Draw("weighted." + MVAType, "weighted." + MVAType + " > 0"); // cWeightedCutResponse.SetLogy(); // cWeightedCutResponse.SaveAs("AllNewResults/responseHists/" + MVAType + "_" + sampleType + "Weighted_cut.png"); // // // Close the opened file. // sampleFile.Close(); //} void produceMVASampleGraphs(TString MVAType, TString sampleType) { int ww = 600; // Canvas width. int wh = int(0.78 * ww); // Canvas height. // Create TChain from which to plot. TChain sampleChain(sampleType + "ResponseTree"); // sampleChain.SetAutoDelete(); if (sampleType.EqualTo("thermal") || sampleType.EqualTo("signal")) { sampleChain.Add("backgroundCut_New/" + sampleType + "/backgroundCut-" + sampleType + "-part_all-0.root"); sampleChain.Add("backgroundCut_New/" + sampleType + "/backgroundCut-" + sampleType + "-part_all-1.root"); sampleChain.Add("backgroundCut_New/" + sampleType + "/backgroundCut-" + sampleType + "-part_all-2.root"); sampleChain.Add("backgroundCut_New/" + sampleType + "/backgroundCut-" + sampleType + "-part_all-3.root"); } else sampleChain.Add("backgroundCut_New/" + sampleType + "/backgroundCut-" + sampleType + "-part_all.root"); // if (sampleType.EqualTo("thermal") || sampleType.EqualTo("signal")) { // // sampleChain.AddFile("backgroundCut_New/" + sampleType + "/backgroundCut-" + sampleType + "-part_all-0.root"); // sampleChain.AddFile("backgroundCut_New/" + sampleType + "/backgroundCut-" + sampleType + "-part_all-1.root"); // sampleChain.AddFile("backgroundCut_New/" + sampleType + "/backgroundCut-" + sampleType + "-part_all-2.root"); // sampleChain.AddFile("backgroundCut_New/" + sampleType + "/backgroundCut-" + sampleType + "-part_all-3.root"); // // } else sampleChain.AddFile("backgroundCut_New/" + sampleType + "/backgroundCut-" + sampleType + "-part_all.root"); // Create canvases for response plots. TCanvas * cResponse = new TCanvas("cResponse" + MVAType + sampleType, "Canvas for " + MVAType + " " + sampleType + ".", 200, 0, ww, wh); TCanvas * cWeightedResponse = new TCanvas("cWeightedResponse" + MVAType + sampleType + "Weighted", "Canvas for weighted " + MVAType + " " + sampleType + ".", 200, 0, ww, wh); TCanvas * cCutResponse = new TCanvas("cCutResponse" + MVAType + sampleType, "Canvas for " + MVAType + " " + sampleType + " satisfying cut.", 200, 0, ww, wh); TCanvas * cWeightedCutResponse = new TCanvas("cWeightedCutResponse" + MVAType + sampleType + "Weighted", "Canvas for weighted " + MVAType + " " + sampleType + " satisfying cut.", 200, 0, ww, wh); // TCanvas cResponse("cResponse" + MVAType + sampleType, "Canvas for " + MVAType + " " + sampleType + ".", 200, 0, ww, wh); // TCanvas cWeightedResponse("cWeightedResponse" + MVAType + sampleType, "Canvas for weighted " + MVAType + " " + sampleType + ".", 200, 0, ww, wh); // // TCanvas cCutResponse("cCutResponse" + MVAType + sampleType, "Canvas for " + MVAType + " " + sampleType + " satisfying cut.", 200, 0, ww, wh); // TCanvas cWeightedCutResponse("cWeightedCutResponse" + MVAType + sampleType, "Canvas for weighted " + MVAType + " " + sampleType + " satisfying cut.", 200, 0, ww, wh); // Draw the responses on the canvas, set to log scale, then save it. cResponse -> cd(); // cResponse.Update(); sampleChain.Draw("unweighted." + MVAType); cResponse -> SetLogy(); // cResponse.Update(); cResponse -> SaveAs("AllNewResults/responseHists/" + MVAType + "_" + sampleType + ".png"); // cResponse.Close(); cWeightedResponse -> cd(); // cWeightedResponse.Update(); sampleChain.Draw("weighted." + MVAType); cWeightedResponse -> SetLogy(); // cWeightedResponse.Update(); cWeightedResponse -> SaveAs("AllNewResults/responseHists/" + MVAType + "_" + sampleType + "Weighted.png"); // cWeightedResponse.Close(); // Do the same for the events satisfying the cut. cCutResponse -> cd(); // cCutResponse.Update(); sampleChain.Draw("unweighted." + MVAType, "unweighted." + MVAType + " > 0"); cCutResponse -> SetLogy(); // cCutResponse.Update(); cCutResponse -> SaveAs("AllNewResults/responseHists/" + MVAType + "_" + sampleType + "_cut.png"); // cCutResponse.Close(); cWeightedCutResponse -> cd(); // cWeightedCutResponse.Update(); sampleChain.Draw("weighted." + MVAType, "weighted." + MVAType + " > 0"); cWeightedCutResponse -> SetLogy(); // cWeightedCutResponse.Update(); cWeightedCutResponse -> SaveAs("AllNewResults/responseHists/" + MVAType + "_" + sampleType + "Weighted_cut.png"); // cWeightedCutResponse.Close(); // Maybe the canvases need to be deleted? delete cResponse, cWeightedResponse, cCutResponse, cWeightedCutResponse; // Is it the chain that needs to be reset? // sampleChain.Reset(); } void produceMVAGraphs(TString MVAType) { produceMVASampleGraphs(MVAType, "refinedHiCal2A"); // produceMVASampleGraphs(MVAType, "refinedHiCal2B"); // produceMVASampleGraphs(MVAType, "refinedWAISHPol"); // produceMVASampleGraphs(MVAType, "refinedWAISVPol"); // produceMVASampleGraphs(MVAType, "minBias"); // produceMVASampleGraphs(MVAType, "payloadBlast"); // produceMVASampleGraphs(MVAType, "strongCW"); // produceMVASampleGraphs(MVAType, "signal"); // produceMVASampleGraphs(MVAType, "thermal"); } void makeResponseGraphsNew() { // produceMVASampleGraphs(MVAType, "refinedHiCal2A"); // produceMVASampleGraphs(MVAType, "refinedHiCal2B"); // produceMVASampleGraphs(MVAType, "refinedWAISHPol"); // produceMVASampleGraphs(MVAType, "refinedWAISVPol"); // produceMVASampleGraphs(MVAType, "minBias"); // produceMVASampleGraphs(MVAType, "payloadBlast"); // produceMVASampleGraphs(MVAType, "strongCW"); // produceMVASampleGraphs(MVAType, "signal"); // produceMVASampleGraphs(MVAType, "thermal"); produceMVAGraphs("hPolIdealFisher"); produceMVAGraphs("vPolIdealFisher"); produceMVAGraphs("hPolFisher"); produceMVAGraphs("vPolFisher"); produceMVAGraphs("hiCal2ABDT"); produceMVAGraphs("hiCal2BBDT"); produceMVAGraphs("waisHPolBDT"); produceMVAGraphs("hPolBDT"); produceMVAGraphs("waisVPolBDT"); }