]> git.uio.no Git - u/mrichter/AliRoot.git/blob - AliGeant4/AliFiles.cxx
Add ResetDecayTable() and SsetDecayTable() methods.
[u/mrichter/AliRoot.git] / AliGeant4 / AliFiles.cxx
1 // $Id$
2 // Category: global
3 //
4 // See the class description in the header file.
5
6 #include "AliFiles.h"
7 #include "AliGlobals.h"
8
9 #include <stdlib.h>
10
11 // static data members
12
13 AliFiles* AliFiles::fgInstance = 0;
14 const G4String AliFiles::fgkTop = getenv("AG4_INSTALL");    
15 const G4String AliFiles::fgkDefaultMacroName = "Config";
16 const G4String AliFiles::fgkDefaultG3CallsName = "g3calls";
17 const G4String AliFiles::fgkRootMacroExtension = ".C";
18 const G4String AliFiles::fgkG4MacroExtension = ".in";
19 const G4String AliFiles::fgkG3CallsExtension = ".dat";
20 const G4String AliFiles::fgkXMLFileExtension = ".xml";   
21
22 AliFiles::AliFiles()
23   : fMacroName(fgkDefaultMacroName),
24     fG3CallsName(fgkDefaultG3CallsName)
25 {
26 //    
27   if (fgInstance) {
28     AliGlobals::Exception(
29       "AliFiles: attempt to create two instances of singleton.");
30   };
31       
32   fgInstance = this;      
33 }
34   
35 AliFiles::AliFiles(const G4String& config)  
36   : fMacroName(config),
37     fG3CallsName(fgkDefaultG3CallsName)
38 {
39 //
40   if (fgInstance) {
41     AliGlobals::Exception(
42       "AliFiles: attempt to create two instances of singleton.");
43   };
44       
45   fgInstance = this;      
46 }
47   
48 AliFiles::AliFiles(const G4String& config, const G4String& g3calls)  
49   : fMacroName(config),
50     fG3CallsName(g3calls)
51 {
52 //
53   if (fgInstance) {
54     AliGlobals::Exception(
55       "AliFiles: attempt to create two instances of singleton.");
56   };
57       
58   fgInstance = this;      
59 }
60   
61 AliFiles::~AliFiles() {
62 //
63 }
64
65 // private methods 
66
67 G4String AliFiles::GetMacroPath(const G4String& macroName,
68                                 const G4String& moduleName,
69                                 G4bool isStructure) const
70 {
71 // Returns the filepath to Config.C/in with filename extension:
72 // $AG4_INSTALL/macro/XXX/Config
73 // $AG4_INSTALL/macro/STRUCT/XXXConfig
74 // ---
75     
76   G4String name = fgkTop + "/macro/";
77   
78   if (!isStructure) 
79     name = name + moduleName + "/" + macroName;
80   else                                
81     name = name + "STRUCT/"+ fgkDefaultMacroName + moduleName;
82                               
83   return name;
84 }                             
85                               
86 // public methods
87
88 G4String AliFiles::GetRootMacroPath() const
89 {
90 // Returns the filepath:
91 // $ALICE_ROOT/macros/Config.C
92 // ---
93     
94   G4String name 
95     = fgkTop + "/../macros/" + fMacroName + fgkRootMacroExtension;
96                               
97   return name;
98 }                             
99                               
100 G4String AliFiles::GetRootMacroPath(const G4String& moduleName,
101                                     G4bool isStructure) const
102 {
103 // Returns the filepath:
104 // $AG4_INSTALL/macro/XXX/Config.C
105 // $AG4_INSTALL/macro/STRUCT/XXXConfig.C
106 // ---
107     
108   G4String name = GetMacroPath(fMacroName, moduleName, isStructure);
109   name = name + fgkRootMacroExtension;
110                               
111   return name;
112 }                             
113                               
114 G4String AliFiles::GetG4MacroPath(const G4String& moduleName, 
115                                   G4bool isStructure) const
116 {
117 // Returns the filepath:
118 // $AG4_INSTALL/macro/XXX/Config.in
119 // $AG4_INSTALL/macro/STRUCT/XXXConfig.in
120 // ---
121     
122   G4String name = GetMacroPath(fgkDefaultMacroName, moduleName, isStructure); 
123   name = name + fgkG4MacroExtension;
124                               
125   return name;
126 }                             
127                                                                                           
128 G4String AliFiles::GetG3CallsDatPath(const G4String& moduleName, 
129                               G4int moduleVersion, G4bool isStructure) const
130 {
131 // Returns the filepath:
132 // $AG4_INSTALL/macro/XXX/g3calls_vN.dat
133 // $AG4_INSTALL/macro/STRUCT/g3calls_XXXvN.dat
134 // ---
135     
136   G4String version("v");
137   AliGlobals::AppendNumberToString(version, moduleVersion);
138
139   G4String name = fgkTop + "/macro/";
140   
141   if (!isStructure) 
142     name = name + moduleName + "/" + fG3CallsName + "_";
143   else                                
144     name = name + "STRUCT/" + fG3CallsName + "_" + moduleName;
145
146   name = name + version + fgkG3CallsExtension;
147                               
148   return name;
149 }                             
150                               
151 G4String AliFiles::GetXMLFilePath(const G4String& moduleName,
152                                   G4int moduleVersion) const
153 {
154 // Returns the filepath:
155 // $AG4_INSTALL/xml/XXXvN.xml
156 // ---
157     
158   G4String version = "v";
159   AliGlobals::AppendNumberToString(version, moduleVersion); 
160
161   G4String name 
162     = fgkTop + "/xml/" + moduleName + version + fgkXMLFileExtension;
163   
164   return name;
165 }