GSLUtils.cxx
Go to the documentation of this file.
1 //____________________________________________________________________________
2 /*
3  Copyright (c) 2003-2019, The GENIE Collaboration
4  For the full text of the license visit http://copyright.genie-mc.org
5  or see $GENIE/LICENSE
6 
7  Author: Costas Andreopoulos <costas.andreopoulos \at stfc.ac.uk>
8  University of Liverpool & STFC Rutherford Appleton Lab
9 
10  For documentation see the corresponding header file.
11 
12  Important revisions after version 2.0.0 :
13  @ Sep 03, 2008 - CA
14  Was first added in GENIE v2.5.1.
15 
16 */
17 //____________________________________________________________________________
18 
19 #include <RVersion.h>
20 
21 #if ROOT_VERSION_CODE <= ROOT_VERSION(5,18,0)
22 #define _OLD_GSL_INTEGRATION_ENUM_TYPES_
23 #endif
24 
28 
29 //____________________________________________________________________________
32 {
33 // Returns the appropriate IntegrationOneDim type based on the input string
34 
35  string t = genie::utils::str::ToLower(type);
36 
37 
38 #ifdef _OLD_GSL_INTEGRATION_ENUM_TYPES_
39 
40  if (t=="adaptive") return ROOT::Math::IntegrationOneDim::ADAPTIVE;
41  else if (t=="adaptive_singular") return ROOT::Math::IntegrationOneDim::ADAPTIVESINGULAR;
42  else if (t=="non_adaptive") return ROOT::Math::IntegrationOneDim::NONADAPTIVE;
43 
44  LOG("GSL", pWARN)
45  << "Unknown 1-dim GSL integration type = " << type
46  << ". Setting it to default [adaptive].";
47 
48  return ROOT::Math::IntegrationOneDim::ADAPTIVE;
49 
50 #else
51 
52  if (t=="gauss") return ROOT::Math::IntegrationOneDim::kGAUSS;
53  else if (t=="adaptive") return ROOT::Math::IntegrationOneDim::kADAPTIVE;
54  else if (t=="adaptive_singular") return ROOT::Math::IntegrationOneDim::kADAPTIVESINGULAR;
55  else if (t=="non_adaptive") return ROOT::Math::IntegrationOneDim::kNONADAPTIVE;
56 
57  LOG("GSL", pWARN)
58  << "Unknown 1-dim GSL integration type = " << type
59  << ". Setting it to default [adaptive].";
60 
61  return ROOT::Math::IntegrationOneDim::kADAPTIVE;
62 
63 #endif
64 }
65 //____________________________________________________________________________
68 {
69 // Returns the appropriate IntegrationMultiDim type based on the input string
70 
71  string t = genie::utils::str::ToLower(type);
72 
73 #ifdef _OLD_GSL_INTEGRATION_ENUM_TYPES_
74 
75  if (t=="adaptive") return ROOT::Math::IntegrationMultiDim::ADAPTIVE;
76  else if (t=="plain") return ROOT::Math::IntegrationMultiDim::PLAIN;
77  else if (t=="vegas") return ROOT::Math::IntegrationMultiDim::VEGAS;
78  else if (t=="miser") return ROOT::Math::IntegrationMultiDim::MISER;
79 
80  LOG("GSL", pWARN)
81  << "Unknown N-dim GSL integration type = " << type
82  << ". Setting it to default [adaptive].";
83 
84  return ROOT::Math::IntegrationMultiDim::ADAPTIVE;
85 
86 #else
87 
88  if (t=="adaptive") return ROOT::Math::IntegrationMultiDim::kADAPTIVE;
89  else if (t=="plain") return ROOT::Math::IntegrationMultiDim::kPLAIN;
90  else if (t=="vegas") return ROOT::Math::IntegrationMultiDim::kVEGAS;
91  else if (t=="miser") return ROOT::Math::IntegrationMultiDim::kMISER;
92 
93  LOG("GSL", pWARN)
94  << "Unknown N-dim GSL integration type = " << type
95  << ". Setting it to default [adaptive].";
96 
97  return ROOT::Math::IntegrationMultiDim::kADAPTIVE;
98 
99 #endif
100 
101 }
102 //____________________________________________________________________________
103 
ROOT::Math::IntegrationOneDim::Type Integration1DimTypeFromString(string type)
Definition: GSLUtils.cxx:31
ROOT::Math::IntegrationMultiDim::Type IntegrationNDimTypeFromString(string type)
Definition: GSLUtils.cxx:67
#define LOG(stream, priority)
A macro that returns the requested log4cpp::Category appending a string (using the FILE...
Definition: Messenger.h:97
string ToLower(string input)
#define pWARN
Definition: Messenger.h:61