]> git.uio.no Git - u/mrichter/AliRoot.git/blob - AliGeant4/AliFiles.cxx
cuts on Q out, side, long added
[u/mrichter/AliRoot.git] / AliGeant4 / AliFiles.cxx
1 // $Id$
2 // Category: global
3 //
4 // Author: I. Hrivnacova
5 //
6 // Class AliFiles
7 // --------------
8 // See the class description in the header file.
9
10 #include "AliFiles.h"
11 #include "AliGlobals.h"
12
13 #include <stdlib.h>
14
15 // static data members
16
17 AliFiles* AliFiles::fgInstance = 0;
18 const G4String AliFiles::fgkTop = getenv("AG4_INSTALL");    
19 const G4String AliFiles::fgkDefaultMacroName = "Config";
20 const G4String AliFiles::fgkDefaultG3CallsName = "g3calls";
21 const G4String AliFiles::fgkRootMacroExtension = ".C";
22 const G4String AliFiles::fgkG4MacroExtension = ".in";
23 const G4String AliFiles::fgkG3CallsExtension = ".dat";
24 const G4String AliFiles::fgkXMLFileExtension = ".xml";   
25
26 //_____________________________________________________________________________
27 AliFiles::AliFiles()
28   : fMacroName(fgkDefaultMacroName),
29     fG3CallsName(fgkDefaultG3CallsName)
30 {
31 //    
32   if (fgInstance) {
33     AliGlobals::Exception(
34       "AliFiles: attempt to create two instances of singleton.");
35   };
36       
37   fgInstance = this;      
38 }
39   
40 //_____________________________________________________________________________
41 AliFiles::AliFiles(const G4String& config)  
42   : fMacroName(config),
43     fG3CallsName(fgkDefaultG3CallsName)
44 {
45 //
46   if (fgInstance) {
47     AliGlobals::Exception(
48       "AliFiles: attempt to create two instances of singleton.");
49   };
50       
51   fgInstance = this;      
52 }
53   
54 //_____________________________________________________________________________
55 AliFiles::AliFiles(const G4String& config, const G4String& g3calls)  
56   : fMacroName(config),
57     fG3CallsName(g3calls)
58 {
59 //
60   if (fgInstance) {
61     AliGlobals::Exception(
62       "AliFiles: attempt to create two instances of singleton.");
63   };
64       
65   fgInstance = this;      
66 }
67   
68 //_____________________________________________________________________________
69 AliFiles::AliFiles(const AliFiles& right) {
70 // 
71   AliGlobals::Exception("Attempt to copy AliFiles singleton.");
72 }
73
74
75 //_____________________________________________________________________________
76 AliFiles::~AliFiles() {
77 //
78 }
79
80 // operators
81
82 //_____________________________________________________________________________
83 AliFiles& 
84 AliFiles::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           
94 // private methods 
95
96 //_____________________________________________________________________________
97 G4String 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/";
107   
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
118 //_____________________________________________________________________________
119 G4String 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                               
131 //_____________________________________________________________________________
132 G4String 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                               
146 //_____________________________________________________________________________
147 G4String 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                                                                                           
161 //_____________________________________________________________________________
162 G4String 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                               
185 //_____________________________________________________________________________
186 G4String 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 }