ATLAS Offline Software
PhysicsAnalysis/JetMissingEtID/JetSelectorTools/Root/Helpers.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration
3 */
4 
6 
7 #include "TSystem.h"
8 
9 #include <math.h>
10 
11 namespace JCT
12 {
13 namespace utils
14 {
15 template <>
16 bool getTypeObjFromString<std::string>(const std::string& str, std::string& obj)
17 {
18  obj = str;
19  return true;
20 }
21 
22 template <>
23 bool getTypeObjFromString<TString>(const std::string& str, TString& obj)
24 {
25  obj = str.c_str();
26  return true;
27 }
28 
29 template <>
30 bool getTypeObjFromString<bool>(const std::string& str, bool& obj)
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 }
52 
53 template <>
54 bool getTypeObjFromString<std::string>(const TString& str, std::string& obj)
55 {
56  obj = str.Data();
57  return true;
58 }
59 
60 template <>
61 bool getTypeObjFromString<TString>(const TString& str, TString& obj)
62 {
63  obj = str;
64  return true;
65 }
66 
67 template <>
68 bool getTypeObjFromString<bool>(const TString& str, bool& obj)
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 }
90 
91 bool fileExists(const TString& fileName)
92 {
93  return gSystem->AccessPathName(fileName) == false;
94 }
95 
96 bool fileExists(const std::string& fileName)
97 {
98  return fileExists(TString(fileName.c_str()));
99 }
100 
101 } // End utils namespace
102 } // End JCT namespace
103 
JCT::utils::getTypeObjFromString< bool >
bool getTypeObjFromString< bool >(const std::string &str, bool &obj)
Definition: PhysicsAnalysis/JetMissingEtID/JetSelectorTools/Root/Helpers.cxx:30
Helpers.h
athena.value
value
Definition: athena.py:122
JCT::utils::fileExists
bool fileExists(const TString &fileName)
Definition: PhysicsAnalysis/JetMissingEtID/JetSelectorTools/Root/Helpers.cxx:91
FortranAlgorithmOptions.fileName
fileName
Definition: FortranAlgorithmOptions.py:13
JCT
Definition: PhysicsAnalysis/JetMissingEtID/JetSelectorTools/JetSelectorTools/Helpers.h:22
JCT::utils::getTypeObjFromString< TString >
bool getTypeObjFromString< TString >(const std::string &str, TString &obj)
Definition: PhysicsAnalysis/JetMissingEtID/JetSelectorTools/Root/Helpers.cxx:23
python.CaloScaleNoiseConfig.str
str
Definition: CaloScaleNoiseConfig.py:78
utils
Definition: Trigger/TrigMonitoring/TrigMinBiasMonitoring/python/utils.py:1
str
Definition: BTagTrackIpAccessor.cxx:11
python.PyAthena.obj
obj
Definition: PyAthena.py:135