ATLAS Offline Software
Functions
PunchThroughG4Tool.cxx File Reference
#include "PunchThroughPDFCreator.h"
#include "PunchThroughParticle.h"
#include "PunchThroughG4Tool.h"
#include "PathResolver/PathResolver.h"
#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <vector>
#include <numeric>
#include <string_view>
#include <charconv>
#include <cmath>
#include "CLHEP/Random/RandFlat.h"
#include "TFile.h"
#include "TH2F.h"
#include "TH1.h"
#include "TMath.h"
#include "TKey.h"
#include "GeoPrimitives/GeoPrimitivesHelpers.h"

Go to the source code of this file.

Functions

template<typename T >
std::vector< T > str_to_list (const std::string_view str)
 

Function Documentation

◆ str_to_list()

template<typename T >
std::vector<T> str_to_list ( const std::string_view  str)

Definition at line 853 of file PunchThroughG4Tool.cxx.

854 {
855  constexpr char delimiters = ',';
856  std::vector<T> tokens;
857  // Skip delimiters at beginning.
858  std::string_view::size_type lastPos = str.find_first_not_of(delimiters, 0);
859  // Find first "non-delimiter".
860  std::string_view::size_type pos = str.find_first_of(delimiters, lastPos);
861 
862  while (std::string_view::npos != pos || std::string_view::npos != lastPos) {
863  // Found a token, add it to the vector.
864  std::string_view numbStr = str.substr(lastPos, pos - lastPos);
865  T num = -9999;
866  std::from_chars(numbStr.data(), numbStr.data() + numbStr.size(), num);
867  tokens.push_back(num);
868  // Skip delimiters. Note the "not_of"
869  lastPos = str.find_first_not_of(delimiters, pos);
870  // Find next "non-delimiter"
871  pos = str.find_first_of(delimiters, lastPos);
872  }
873  return tokens;
874 }
beamspotman.tokens
tokens
Definition: beamspotman.py:1282
trigbs_pickEvents.num
num
Definition: trigbs_pickEvents.py:76
python.LumiBlobConversion.pos
pos
Definition: LumiBlobConversion.py:16
str
Definition: BTagTrackIpAccessor.cxx:11
TSU::T
unsigned long long T
Definition: L1TopoDataTypes.h:35