Macros

Line Code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42
/*
 * =====================================================================================
 *
 *       Filename:  TMVAZipReader.h
 *
 *    Description:  A stupid function that initializes a TMVA Reader
 *                  using a gzipped or non-zipped xml file.
 *
 *                  The file will be unzipped if it ends in .gz or .gzip
 *                  It will be passed as normal if it ends in .xml
 *
 *                  This file is header-only.
 *
 *          Usage:  loadTMVAWeights(&myReader, "BDT", "path_to_file.xml.gz");
 *
 *
 *         Author:  Evan Friis, evan.friis@cern.ch
 *        Company:  UW Madison
 *
 * =====================================================================================
 */

#ifndef CommonTools_MVAUtils_TMVAZipReader_h
#define CommonTools_MVAUtils_TMVAZipReader_h

#include "TMVA/IMethod.h"
#include "TMVA/Reader.h"
#include <string>

namespace reco::details {

  bool hasEnding(std::string const& fullString, std::string const& ending);
  char* readGzipFile(const std::string& weightFile);

  TMVA::IMethod* loadTMVAWeights(TMVA::Reader* reader,
                                 const std::string& method,
                                 const std::string& weightFile,
                                 bool verbose = false);

}  // namespace reco::details

#endif