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 "HepPDT/ParticleDataTable.hh"
#include "TruthUtils/MagicNumbers.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 744 of file PunchThroughTool.cxx.

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