load_dk2nu.C
Go to the documentation of this file.
1 int load_dk2nu(bool genie_too = false, bool cnvtinc = false,
2  bool verbose = false)
3 {
4  // load the dk2nuTree library
5  // if "genie_too" load the library that had the GENIE flux driver
6  // if "cvntinc" add include paths to convert areas
7 
8  const char* path = gSystem->ExpandPathName("$(DK2NU)");
9  if ( ! path ) {
10  cout << "DK2NU not defined?!" << endl;
11  }
12 
13  // add to the library path
14  if ( path ) {
15  TString libs = gSystem->GetDynamicPath();
16  libs += ":";
17  libs += path;
18  libs += "/lib";
19  gSystem->SetDynamicPath(libs.Data());
20  }
21 
22  /// Add dk2nu libraries
23  const char* libname[2] = { "libdk2nuTree", "libdk2nuGenie" };
24  size_t nlib = ( genie_too ? 2 : 1 );
25  for ( size_t ilib = 0; ilib < nlib; ++ilib ) {
26  if ( verbose ) cout << "Load: " << libname[ilib] << endl;
27  gSystem->Load(libname[ilib]);
28  }
29 
30  // none of the rest makes sense unless we know the DK2NU path
31  if ( ! path ) return -1;
32 
33  /// Add locations for include files
34  TString ip = gSystem->GetIncludePath();
35  ip += " -I";
36  ip += path;
37 
38  ip += " -I";
39  ip += path;
40  ip += "/include";
41 
42  ip += " -I";
43  ip += path;
44  ip += "/include/dk2nu";
45 
46  ip += " -I";
47  ip += path;
48  ip += "/scripts";
49 
50  const char* cnvt[5] = { "g3numi", "flugg", "g4numi", "g4minerva", "g4lbne" };
51  size_t ncnvt = sizeof(cnvt)/sizeof(const char*);
52  if ( cnvtinc ) {
53  for (size_t i = 0; i < ncnvt; ++i ) {
54  ip += " -I";
55  ip += path;
56  ip += "/scripts/convert/";
57  ip += cnvt[i];
58  }
59  }
60 
61  gSystem->SetIncludePath(ip);
62  if ( verbose ) cout << "SetIncludePath: " << ip << endl;
63 
64  // additions to .include must be done individually or CINT will
65  // try to quote all the spaces as a single path
66  TString dip;
67 
68  dip = ".include ";
69  dip += path;
70  gROOT->ProcessLine(dip.Data());
71 
72  dip = ".include ";
73  dip += path;
74  dip += "/include";
75  gROOT->ProcessLine(dip.Data());
76 
77  dip = ".include ";
78  dip += path;
79  dip += "/include/dk2nu";
80  gROOT->ProcessLine(dip.Data());
81 
82  dip = ".include ";
83  dip += path;
84  dip += "/scripts";
85  gROOT->ProcessLine(dip.Data());
86 
87  if ( cnvtinc ) {
88  for (size_t i = 0; i < ncnvt; ++i ) {
89  dip = ".include ";
90  dip += path;
91  dip += "/scripts/convert/";
92  dip += cnvt[i];
93  gROOT->ProcessLine(dip.Data());
94  }
95  }
96 
97  return 0;
98 }
TString ip
Definition: loadincs.C:5
TString dip
Definition: loadincs.C:25
Definition: __init__.py:1
OStream cout
Definition: OStream.cxx:6
const std::string path
Definition: plot_BEN.C:43
int load_dk2nu(bool genie_too=false, bool cnvtinc=false, bool verbose=false)
Definition: load_dk2nu.C:1