4 #include "TEfficiency.h"
6 #include "TGraphErrors.h"
14 #include "TRatioPlot.h"
16 #include "TMVA/Factory.h"
17 #include "TMVA/DataLoader.h"
18 #include "TMVA/Tools.h"
31 gStyle->SetOptStat(0);
34 TCanvas *pad =
new TCanvas(
"pad",
38 TLegend *legend =
nullptr;
39 TH1F *htemplate =
nullptr;
41 auto default_data =
new TChain(
"tree");
42 default_data->SetTitle(input.Data());
43 auto files =
fileVector(Form(
"%s/%s/%s", dir.Data(), input.Data(), filePattern.Data()));
47 default_data->Add(
file.c_str());
52 auto signal_train = default_data->CopyTree(
"jet_flavor==4 && jet_n>0",
"", TMath::Floor(default_data->GetEntries() / 1.0));
53 std::cout <<
"Signal Tree (Training): " << signal_train->GetEntries() << std::endl;
55 auto background_train = default_data->CopyTree(
"(jet_flavor<4||jet_flavor==21) && jet_n>0",
"", TMath::Floor(default_data->GetEntries() / 1.0));
56 std::cout <<
"Background Tree (Training): " << background_train->GetEntries() << std::endl;
74 TMVA::Tools::Instance();
76 auto outputFile = TFile::Open(
"CharmJetGlobalTagger_Results.root",
"RECREATE");
78 TMVA::Factory factory(
"TMVAClassification",
80 "!V:ROC:!Correlations:!Silent:Color:DrawProgressBar:AnalysisType=Classification");
86 TMVA::DataLoader
loader(
"dataset");
94 loader.AddSpectator(
"jet_pt");
95 loader.AddSpectator(
"jet_eta");
96 loader.AddSpectator(
"jet_flavor");
97 loader.AddSpectator(
"met_et");
98 loader.AddVariable(
"jet_mlp_ip3dtagger");
99 loader.AddVariable(
"jet_mlp_ktagger");
100 loader.AddVariable(
"jet_mlp_eltagger");
101 loader.AddVariable(
"jet_mlp_mutagger");
102 loader.AddSignalTree(signal_train, 1.0);
103 loader.AddBackgroundTree(background_train, 1.0);
118 loader.PrepareTrainingAndTestTree(TCut(
"jet_pt>5.0 && TMath::Abs(jet_eta) < 3.0 && jet_flavor==4 && met_et > 10"),
119 TCut(
"jet_pt>5.0 && TMath::Abs(jet_eta) < 3.0 && (jet_flavor<4||jet_flavor==21) && met_et > 10"),
120 "nTrain_Signal=50000:nTrain_Background=500000:nTest_Signal=50000:nTest_Background=500000:SplitMode=Random:NormMode=NumEvents:!V");
128 factory.BookMethod(&loader, TMVA::Types::kMLP,
"CharmGlobalTagger",
129 "!H:!V:NeuronType=ReLU:VarTransform=Norm:NCycles=1000:HiddenLayers=N+8:TestRate=5:!UseRegulator");
132 factory.TrainAllMethods();
135 factory.TestAllMethods();
136 factory.EvaluateAllMethods();
140 pad = factory.GetROCCurve(&loader);
143 pad->SaveAs(
"CharmJetGlobalTagger_ROC.pdf");