ATLAS Offline Software
Functions
JCT::utils Namespace Reference

Functions

template<typename T >
bool isTypeObjFromString (const std::string &str)
 
template<typename T >
bool isTypeObjFromString (const TString &str)
 
template<typename T >
bool getTypeObjFromString (const std::string &str, T &obj)
 
template<typename T >
getTypeObjFromString (const std::string &str)
 
template<typename T >
bool getTypeObjFromString (const TString &str, T &obj)
 
template<typename T >
getTypeObjFromString (const TString &str)
 
template<>
bool getTypeObjFromString< std::string > (const std::string &str, std::string &obj)
 
template<>
bool getTypeObjFromString< TString > (const std::string &str, TString &obj)
 
template<>
bool getTypeObjFromString< bool > (const std::string &str, bool &obj)
 
template<>
bool getTypeObjFromString< std::string > (const TString &str, std::string &obj)
 
template<>
bool getTypeObjFromString< TString > (const TString &str, TString &obj)
 
template<>
bool getTypeObjFromString< bool > (const TString &str, bool &obj)
 
template<typename T >
bool vectorize (const TString &str, const TString &sep, std::vector< T > &result)
 
template<typename T >
std::vector< T > vectorize (const TString &str, const TString &sep)
 
bool fileExists (const TString &fileName)
 
bool fileExists (const std::string &fileName)
 

Function Documentation

◆ fileExists() [1/2]

bool JCT::utils::fileExists ( const std::string &  fileName)

Definition at line 96 of file PhysicsAnalysis/JetMissingEtID/JetSelectorTools/Root/Helpers.cxx.

97 {
98  return fileExists(TString(fileName.c_str()));
99 }

◆ fileExists() [2/2]

bool JCT::utils::fileExists ( const TString &  fileName)

Definition at line 91 of file PhysicsAnalysis/JetMissingEtID/JetSelectorTools/Root/Helpers.cxx.

92 {
93  return gSystem->AccessPathName(fileName) == false;
94 }

◆ getTypeObjFromString() [1/4]

template<typename T >
T JCT::utils::getTypeObjFromString ( const std::string &  str)

Definition at line 89 of file PhysicsAnalysis/JetMissingEtID/JetSelectorTools/JetSelectorTools/Helpers.h.

90 {
91  T toReturn;
92  if (!getTypeObjFromString(str,toReturn))
93  printf("Failed to convert object: %s\n",str.c_str());
94 
95  return toReturn;
96 }

◆ getTypeObjFromString() [2/4]

template<typename T >
bool JCT::utils::getTypeObjFromString ( const std::string &  str,
T &  obj 
)

Definition at line 83 of file PhysicsAnalysis/JetMissingEtID/JetSelectorTools/JetSelectorTools/Helpers.h.

84 {
85  std::istringstream iss(str);
86  return !(iss >> obj).fail();
87 }

◆ getTypeObjFromString() [3/4]

template<typename T >
T JCT::utils::getTypeObjFromString ( const TString &  str)

Definition at line 104 of file PhysicsAnalysis/JetMissingEtID/JetSelectorTools/JetSelectorTools/Helpers.h.

105 {
106  T toReturn;
107  if (!getTypeObjFromString(str,toReturn))
108  printf("ERROR: Failed to convert object: %s\n",str.Data());
109 
110  return toReturn;
111 }

◆ getTypeObjFromString() [4/4]

template<typename T >
bool JCT::utils::getTypeObjFromString ( const TString &  str,
T &  obj 
)

Definition at line 98 of file PhysicsAnalysis/JetMissingEtID/JetSelectorTools/JetSelectorTools/Helpers.h.

99 {
100  std::string stdstr = str.Data();
101  return getTypeObjFromString(stdstr,obj);
102 }

◆ getTypeObjFromString< bool >() [1/2]

template<>
bool JCT::utils::getTypeObjFromString< bool > ( const std::string &  str,
bool &  obj 
)

Definition at line 30 of file PhysicsAnalysis/JetMissingEtID/JetSelectorTools/Root/Helpers.cxx.

31 {
32  bool toReturn = false;
33  if (str == "true" || str == "True" || str == "TRUE")
34  {
35  obj = true;
36  toReturn = true;
37  }
38  else if (str == "false" || str == "False" || str == "FALSE")
39  {
40  obj = false;
41  toReturn = true;
42  }
43  else
44  {
45  int value;
46  toReturn = getTypeObjFromString<int>(str,value);
47  if (toReturn)
48  obj = static_cast<bool>(value);
49  }
50  return toReturn;
51 }

◆ getTypeObjFromString< bool >() [2/2]

template<>
bool JCT::utils::getTypeObjFromString< bool > ( const TString &  str,
bool &  obj 
)

Definition at line 68 of file PhysicsAnalysis/JetMissingEtID/JetSelectorTools/Root/Helpers.cxx.

69 {
70  bool toReturn = false;
71  if (str.EqualTo("true",TString::kIgnoreCase))
72  {
73  obj = true;
74  toReturn = true;
75  }
76  else if (str.EqualTo("false",TString::kIgnoreCase))
77  {
78  obj = false;
79  toReturn = true;
80  }
81  else
82  {
83  int value;
84  toReturn = getTypeObjFromString<int>(str,value);
85  if (toReturn)
86  obj = static_cast<bool>(value);
87  }
88  return toReturn;
89 }

◆ getTypeObjFromString< std::string >() [1/2]

template<>
bool JCT::utils::getTypeObjFromString< std::string > ( const std::string &  str,
std::string &  obj 
)

Definition at line 16 of file PhysicsAnalysis/JetMissingEtID/JetSelectorTools/Root/Helpers.cxx.

17 {
18  obj = str;
19  return true;
20 }

◆ getTypeObjFromString< std::string >() [2/2]

template<>
bool JCT::utils::getTypeObjFromString< std::string > ( const TString &  str,
std::string &  obj 
)

Definition at line 54 of file PhysicsAnalysis/JetMissingEtID/JetSelectorTools/Root/Helpers.cxx.

55 {
56  obj = str.Data();
57  return true;
58 }

◆ getTypeObjFromString< TString >() [1/2]

template<>
bool JCT::utils::getTypeObjFromString< TString > ( const std::string &  str,
TString &  obj 
)

Definition at line 23 of file PhysicsAnalysis/JetMissingEtID/JetSelectorTools/Root/Helpers.cxx.

24 {
25  obj = str.c_str();
26  return true;
27 }

◆ getTypeObjFromString< TString >() [2/2]

template<>
bool JCT::utils::getTypeObjFromString< TString > ( const TString &  str,
TString &  obj 
)

Definition at line 61 of file PhysicsAnalysis/JetMissingEtID/JetSelectorTools/Root/Helpers.cxx.

62 {
63  obj = str;
64  return true;
65 }

◆ isTypeObjFromString() [1/2]

template<typename T >
bool JCT::utils::isTypeObjFromString ( const std::string &  str)

Definition at line 68 of file PhysicsAnalysis/JetMissingEtID/JetSelectorTools/JetSelectorTools/Helpers.h.

69 {
70  std::istringstream iss(str);
71  T obj;
72  return !(iss >> obj).fail();
73 }

◆ isTypeObjFromString() [2/2]

template<typename T >
bool JCT::utils::isTypeObjFromString ( const TString &  str)

Definition at line 76 of file PhysicsAnalysis/JetMissingEtID/JetSelectorTools/JetSelectorTools/Helpers.h.

77 {
78  std::string stdstr = str.Data();
79  return isTypeObjFromString<T>(stdstr);
80 }

◆ vectorize() [1/2]

template<typename T >
std::vector< T > JCT::utils::vectorize ( const TString &  str,
const TString &  sep 
)

Definition at line 138 of file PhysicsAnalysis/JetMissingEtID/JetSelectorTools/JetSelectorTools/Helpers.h.

139 {
140  std::vector<T> result;
141  TObjArray* tokens = str.Tokenize(sep);
142  TIter istr(tokens);
143 
144  while(TObjString* os=(TObjString*)istr())
145  {
146  T obj;
147  if (!getTypeObjFromString(os->GetString(),obj))
148  printf("ERROR: String \"%s\" is not the requested type\n",os->GetString().Data());
149  result.push_back(obj);
150  }
151  delete tokens;
152 
153  return result;
154 }

◆ vectorize() [2/2]

template<typename T >
bool JCT::utils::vectorize ( const TString &  str,
const TString &  sep,
std::vector< T > &  result 
)

Definition at line 114 of file PhysicsAnalysis/JetMissingEtID/JetSelectorTools/JetSelectorTools/Helpers.h.

115 {
116  bool success = true;
117  result.clear();
118 
119  TObjArray* tokens = str.Tokenize(sep);
120  TIter istr(tokens);
121  while(TObjString* os=(TObjString*)istr())
122  {
123  T obj;
124  if (!getTypeObjFromString(os->GetString(),obj))
125  {
126  success = false;
127  break;
128  }
129  else
130  result.push_back(obj);
131  }
132  delete tokens;
133 
134  return success;
135 }
get_generator_info.result
result
Definition: get_generator_info.py:21
JCT::utils::getTypeObjFromString
T getTypeObjFromString(const TString &str)
Definition: PhysicsAnalysis/JetMissingEtID/JetSelectorTools/JetSelectorTools/Helpers.h:104
athena.value
value
Definition: athena.py:124
beamspotman.tokens
tokens
Definition: beamspotman.py:1284
FortranAlgorithmOptions.fileName
fileName
Definition: FortranAlgorithmOptions.py:13
CreateTrfArgs.fileExists
def fileExists(fp)
Definition: CreateTrfArgs.py:4
ReadFromCoolCompare.os
os
Definition: ReadFromCoolCompare.py:231
grepfile.sep
sep
Definition: grepfile.py:38
python.CaloScaleNoiseConfig.str
str
Definition: CaloScaleNoiseConfig.py:78
str
Definition: BTagTrackIpAccessor.cxx:11
python.PyAthena.obj
obj
Definition: PyAthena.py:132
TSU::T
unsigned long long T
Definition: L1TopoDataTypes.h:35
beamspotman.fail
def fail(message)
Definition: beamspotman.py:201