CMS 3D CMS Logo

convertXMLToGBRForestROOT.cc
Go to the documentation of this file.
2 
3 #include "TFile.h"
4 #include "TTree.h"
5 
6 #include <filesystem>
7 #include <iostream>
8 
9 int main(int argc, char **argv) {
10  if (argc != 3) {
11  std::cout << "Please pass a (gzipped) BDT weight file and a name for the output ROOT file." << std::endl;
12  return 1;
13  }
14 
15  char *inputFileName = argv[1];
16  char *outputFileName = argv[2];
17 
18  if (!std::filesystem::exists(inputFileName)) {
19  std::cout << "Input file " << inputFileName << " does not exists." << std::endl;
20  return 1;
21  }
22 
23  if (std::filesystem::exists(outputFileName)) {
24  std::cout << "Output file " << outputFileName << " already exists." << std::endl;
25  return 1;
26  }
27 
28  std::vector<std::string> variableNames;
29  auto gbrForest = createGBRForest(inputFileName, variableNames);
30  std::cout << "Read GBRForest " << inputFileName << " successfully." << std::endl;
31 
32  {
33  TFile f{outputFileName, "RECREATE"};
34  f.WriteObject(gbrForest.get(), "gbrForest");
35  f.WriteObject(&variableNames, "variableNames");
36  }
37  std::cout << "GBRForest written to " << outputFileName << " successfully." << std::endl;
38 
39  return 0;
40 }
int main(int argc, char **argv)
double f[11][100]
std::unique_ptr< const GBRForest > createGBRForest(const std::string &weightsFile)