GENIEGenerator
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
GSLUtils.cxx
Go to the documentation of this file.
1 //____________________________________________________________________________
2 /*
3  Copyright (c) 2003-2024, The GENIE Collaboration
4  For the full text of the license visit http://copyright.genie-mc.org
5 
6  Costas Andreopoulos <c.andreopoulos \at cern.ch>
7  University of Liverpool
8 */
9 //____________________________________________________________________________
10 
11 #include <RVersion.h>
12 
13 #if ROOT_VERSION_CODE <= ROOT_VERSION(5,18,0)
14 #define _OLD_GSL_INTEGRATION_ENUM_TYPES_
15 #endif
16 
20 
21 //____________________________________________________________________________
22 ROOT::Math::IntegrationOneDim::Type
24 {
25 // Returns the appropriate IntegrationOneDim type based on the input string
26 
27  string t = genie::utils::str::ToLower(type);
28 
29 
30 #ifdef _OLD_GSL_INTEGRATION_ENUM_TYPES_
31 
32  if (t=="adaptive") return ROOT::Math::IntegrationOneDim::ADAPTIVE;
33  else if (t=="adaptive_singular") return ROOT::Math::IntegrationOneDim::ADAPTIVESINGULAR;
34  else if (t=="non_adaptive") return ROOT::Math::IntegrationOneDim::NONADAPTIVE;
35 
36  LOG("GSL", pWARN)
37  << "Unknown 1-dim GSL integration type = " << type
38  << ". Setting it to default [adaptive].";
39 
40  return ROOT::Math::IntegrationOneDim::ADAPTIVE;
41 
42 #else
43 
44  if (t=="gauss") return ROOT::Math::IntegrationOneDim::kGAUSS;
45  else if (t=="adaptive") return ROOT::Math::IntegrationOneDim::kADAPTIVE;
46  else if (t=="adaptive_singular") return ROOT::Math::IntegrationOneDim::kADAPTIVESINGULAR;
47  else if (t=="non_adaptive") return ROOT::Math::IntegrationOneDim::kNONADAPTIVE;
48 
49  LOG("GSL", pWARN)
50  << "Unknown 1-dim GSL integration type = " << type
51  << ". Setting it to default [adaptive].";
52 
53  return ROOT::Math::IntegrationOneDim::kADAPTIVE;
54 
55 #endif
56 }
57 //____________________________________________________________________________
58 ROOT::Math::IntegrationMultiDim::Type
60 {
61 // Returns the appropriate IntegrationMultiDim type based on the input string
62 
63  string t = genie::utils::str::ToLower(type);
64 
65 #ifdef _OLD_GSL_INTEGRATION_ENUM_TYPES_
66 
67  if (t=="adaptive") return ROOT::Math::IntegrationMultiDim::ADAPTIVE;
68  else if (t=="plain") return ROOT::Math::IntegrationMultiDim::PLAIN;
69  else if (t=="vegas") return ROOT::Math::IntegrationMultiDim::VEGAS;
70  else if (t=="miser") return ROOT::Math::IntegrationMultiDim::MISER;
71 
72  LOG("GSL", pWARN)
73  << "Unknown N-dim GSL integration type = " << type
74  << ". Setting it to default [adaptive].";
75 
76  return ROOT::Math::IntegrationMultiDim::ADAPTIVE;
77 
78 #else
79 
80  if (t=="adaptive") return ROOT::Math::IntegrationMultiDim::kADAPTIVE;
81  else if (t=="plain") return ROOT::Math::IntegrationMultiDim::kPLAIN;
82  else if (t=="vegas") return ROOT::Math::IntegrationMultiDim::kVEGAS;
83  else if (t=="miser") return ROOT::Math::IntegrationMultiDim::kMISER;
84 
85  LOG("GSL", pWARN)
86  << "Unknown N-dim GSL integration type = " << type
87  << ". Setting it to default [adaptive].";
88 
89  return ROOT::Math::IntegrationMultiDim::kADAPTIVE;
90 
91 #endif
92 
93 }
94 //____________________________________________________________________________
ROOT::Math::IntegrationOneDim::Type Integration1DimTypeFromString(string type)
Definition: GSLUtils.cxx:23
ROOT::Math::IntegrationMultiDim::Type IntegrationNDimTypeFromString(string type)
Definition: GSLUtils.cxx:59
#define LOG(stream, priority)
A macro that returns the requested log4cpp::Category appending a string (using the FILE...
Definition: Messenger.h:96
string ToLower(string input)
Definition: StringUtils.cxx:98
#define pWARN
Definition: Messenger.h:60