ATLAS Offline Software
Loading...
Searching...
No Matches
PunchThroughTool.cxx File Reference
#include "PunchThroughTool.h"
#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <vector>
#include <numeric>
#include <string_view>
#include <charconv>
#include <cmath>
#include "AthContainers/DataVector.h"
#include "AtlasHepMC/SimpleVector.h"
#include "AtlasHepMC/GenVertex.h"
#include "AtlasHepMC/GenParticle.h"
#include "AtlasHepMC/GenEvent.h"
#include "TruthUtils/MagicNumbers.h"
#include "TruthUtils/HepMCHelpers.h"
#include "CLHEP/Random/RandFlat.h"
#include "XMLCoreParser/XMLCoreParser.h"
#include "XMLCoreParser/XMLCoreNode.h"
#include "TFile.h"
#include "TH2F.h"
#include "TAxis.h"
#include "TH1.h"
#include "TMath.h"
#include "TROOT.h"
#include "TKey.h"
#include "TClass.h"
#include "PathResolver/PathResolver.h"
#include "ISF_Event/ISFParticle.h"
#include "PDFcreator.h"
#include "PunchThroughParticle.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 735 of file PunchThroughTool.cxx.

736{
737 constexpr char delimiters = ',';
738 std::vector<T> tokens;
739 // Skip delimiters at beginning.
740 std::string_view::size_type lastPos = str.find_first_not_of(delimiters, 0);
741 // Find first "non-delimiter".
742 std::string_view::size_type pos = str.find_first_of(delimiters, lastPos);
743
744 while (std::string_view::npos != pos || std::string_view::npos != lastPos) {
745 // Found a token, add it to the vector.
746 std::string_view numbStr = str.substr(lastPos, pos - lastPos);
747 T num = -9999;
748 std::from_chars(numbStr.data(), numbStr.data() + numbStr.size(), num);
749 tokens.push_back(num);
750 // Skip delimiters. Note the "not_of"
751 lastPos = str.find_first_not_of(delimiters, pos);
752 // Find next "non-delimiter"
753 pos = str.find_first_of(delimiters, lastPos);
754 }
755 return tokens;
756}