CMS 3D CMS Logo

Functions
convertXMLToGBRForestROOT.cc File Reference
#include "CommonTools/MVAUtils/interface/GBRForestTools.h"
#include "TFile.h"
#include "TTree.h"
#include <filesystem>
#include <iostream>

Go to the source code of this file.

Functions

int main (int argc, char **argv)
 

Function Documentation

◆ main()

int main ( int  argc,
char **  argv 
)

Definition at line 9 of file convertXMLToGBRForestROOT.cc.

References dir2webdir::argc, GCPpyPlots::argv, gather_cfg::cout, createGBRForest(), f, InefficientDoubleROC::inputFileName, and makeListRunsInFiles::outputFileName.

9  {
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 }
double f[11][100]
std::unique_ptr< const GBRForest > createGBRForest(const std::string &weightsFile)