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