4 #include "TTreeFormula.h"
12 TString foldername =
"dataset",
13 TString taggername =
"MLP",
14 Float_t bkg_eff = 0.004) {
16 TTree *TestTree = static_cast < TTree * > (_file0->Get(Form(
"%s/TestTree", foldername.Data())));
17 TTree *TrainTree = static_cast < TTree * > (_file0->Get(Form(
"%s/TrainTree", foldername.Data())));
19 Float_t nlight = TestTree->GetEntries(
"jet_flavor<4 || jet_flavor==22");
20 Float_t ncharm = TestTree->GetEntries(
"jet_flavor==4");
23 Float_t opt_cut = 0.000;
24 Float_t min_dist = 1000.0;
26 for (Float_t mva_cut = 0.000; mva_cut < 1.000; mva_cut += 0.001) {
27 Float_t nlight_pass = TestTree->GetEntries(Form(
"jet_pt>5.0 && TMath::Abs(jet_eta) < 3.0 && met_et > 10.0 && (jet_flavor<4 || jet_flavor==22) && %s>%f", taggername.Data(), mva_cut));
28 Float_t ncharm_pass = TestTree->GetEntries(Form(
"jet_pt>5.0 && TMath::Abs(jet_eta) < 3.0 && met_et > 10.0 && (jet_flavor==4) && %s>%f", taggername.Data(), mva_cut));
30 Float_t light_eff = nlight_pass / nlight;
32 if (TMath::Abs(light_eff - bkg_eff) < min_dist) {
33 min_dist = TMath::Abs(light_eff - bkg_eff);
39 Float_t nlight_pass = TestTree->GetEntries(Form(
"jet_pt>5.0 && TMath::Abs(jet_eta) < 3.0 && met_et > 10.0 && (jet_flavor<4 || jet_flavor==22) && %s>%f", taggername.Data(), opt_cut));
40 Float_t ncharm_pass = TestTree->GetEntries(Form(
"jet_pt>5.0 && TMath::Abs(jet_eta) < 3.0 && met_et > 10.0 && (jet_flavor==4) && %s>%f", taggername.Data(), opt_cut));
42 std::cout << Form(
"MLP cut %.3f", opt_cut) <<
" yields Eff_c = "
43 << Form(
"%.3f", ncharm_pass / ncharm) <<
" and Eff_light = "
44 << Form(
"%.3e", nlight_pass / nlight) << std::endl;
49 std::cout <<
"Over-Training Study" << std::endl;
50 std::cout <<
"=============================================" << std::endl;
51 std::map < TString, TCut > samples;
52 samples[
"Signal"] = TCut(
"jet_flavor==4");
53 samples[
"Background"] = TCut(
"(jet_flavor<4 || jet_flavor==22)");
55 for (
auto sample : samples) {
56 TH1F *h_train =
new TH1F(
"h_train",
62 auto h_test = static_cast < TH1F * > (h_train->Clone(
"h_test"));
64 TrainTree->Project(h_train->GetName(), Form(
"%s",taggername.Data()), sample.second);
65 TestTree->Project(h_test->GetName(), Form(
"%s",taggername.Data()), sample.second);
66 Float_t KS_Test = h_test->KolmogorovTest(h_train);
67 std::cout << sample.first <<
": K-S Test p-value = " << KS_Test << std::endl;
69 if (h_test)
delete h_test;
71 if (h_train)
delete h_train;