CMS 3D CMS Logo

Functions
XGBooster.cc File Reference
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <fstream>
#include <iostream>
#include <sstream>
#include <stdexcept>
#include <vector>
#include "PhysicsTools/XGBoost/interface/XGBooster.h"

Go to the source code of this file.

Functions

std::vector< std::string > read_features (const std::string &content)
 

Function Documentation

◆ read_features()

std::vector<std::string> read_features ( const std::string &  content)

Definition at line 16 of file XGBooster.cc.

References Skims_PA_cff::content, mps_fire::result, cms::cuda::stream, and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by pat::XGBooster::XGBooster().

16  {
17  std::vector<std::string> result;
18 
19  std::istringstream stream(content);
20  char ch;
21 
22  // Expect opening '['
23  stream >> ch;
24  if (ch != '[') {
25  throw std::runtime_error("Expected '[' at the beginning of the JSON array!");
26  }
27 
28  while (stream) {
29  stream >> ch;
30 
31  if (ch == ']') {
32  break;
33  } else if (ch == ',') {
34  continue;
35  } else if (ch == '"') {
36  std::string feature;
37  std::getline(stream, feature, '"');
38  result.push_back(feature);
39  } else {
40  throw std::runtime_error("Unexpected character in the JSON array!");
41  }
42  }
43 
44  return result;
45 }
uint32_t T const *__restrict__ uint32_t const *__restrict__ int32_t int Histo::index_type cudaStream_t stream