File indexing completed on 2024-04-06 12:01:05
0001 #include "CommonTools/MVAUtils/interface/GBRForestTools.h"
0002
0003 #include "TFile.h"
0004 #include "TTree.h"
0005
0006 #include <filesystem>
0007 #include <iostream>
0008
0009 int main(int argc, char **argv) {
0010 if (argc != 3) {
0011 std::cout << "Please pass a (gzipped) BDT weight file and a name for the output ROOT file." << std::endl;
0012 return 1;
0013 }
0014
0015 char *inputFileName = argv[1];
0016 char *outputFileName = argv[2];
0017
0018 if (!std::filesystem::exists(inputFileName)) {
0019 std::cout << "Input file " << inputFileName << " does not exists." << std::endl;
0020 return 1;
0021 }
0022
0023 if (std::filesystem::exists(outputFileName)) {
0024 std::cout << "Output file " << outputFileName << " already exists." << std::endl;
0025 return 1;
0026 }
0027
0028 std::vector<std::string> variableNames;
0029 auto gbrForest = createGBRForest(inputFileName, variableNames);
0030 std::cout << "Read GBRForest " << inputFileName << " successfully." << std::endl;
0031
0032 {
0033 TFile f{outputFileName, "RECREATE"};
0034 f.WriteObject(gbrForest.get(), "gbrForest");
0035 f.WriteObject(&variableNames, "variableNames");
0036 }
0037 std::cout << "GBRForest written to " << outputFileName << " successfully." << std::endl;
0038
0039 return 0;
0040 }