]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - AliGeant4/AliFiles.cxx
AliHBTReaderKineTree.cxx
[u/mrichter/AliRoot.git] / AliGeant4 / AliFiles.cxx
index c3d30f4a8192433f00f48bac5c7208fd4f3b1968..fced8f72b4a4611a7045ef9f502b8c8190a8f11e 100644 (file)
 // $Id$
 // Category: global
 //
+// Author: I. Hrivnacova
+//
+// Class AliFiles
+// --------------
 // See the class description in the header file.
 
 #include "AliFiles.h"
+#include "AliGlobals.h"
 
 #include <stdlib.h>
 
 // static data members
 
-const G4String AliFiles::fgTop =    getenv("AG4_INSTALL");    
-const G4String AliFiles::fgConfig = fgTop + "/../macros/Config.C";    
-const G4String AliFiles::fgDetConfig1 = fgTop + "/macro/";    
-const G4String AliFiles::fgDetConfig2 = "/Config";    
-const G4String AliFiles::fgDetConfig3 = ".C";    
-const G4String AliFiles::fgDetConfig4 = ".in";    
-const G4String AliFiles::fgDetConfigName1 = "Config(";    
-const G4String AliFiles::fgDetConfigName2 = ")";    
-const G4String AliFiles::fgDetData1 = fgTop + "/macro/";
-const G4String AliFiles::fgDetData2 = "/g3calls_";    
-const G4String AliFiles::fgDetData3 = ".dat";    
-const G4String AliFiles::fgSTRUCT = "STRUCT/";
-
-AliFiles::AliFiles() {
+AliFiles* AliFiles::fgInstance = 0;
+const G4String AliFiles::fgkTop = getenv("AG4_INSTALL");    
+const G4String AliFiles::fgkDefaultMacroName = "Config";
+const G4String AliFiles::fgkDefaultG3CallsName = "g3calls";
+const G4String AliFiles::fgkRootMacroExtension = ".C";
+const G4String AliFiles::fgkG4MacroExtension = ".in";
+const G4String AliFiles::fgkG3CallsExtension = ".dat";
+const G4String AliFiles::fgkXMLFileExtension = ".xml";   
+
+//_____________________________________________________________________________
+AliFiles::AliFiles()
+  : fMacroName(fgkDefaultMacroName),
+    fG3CallsName(fgkDefaultG3CallsName)
+{
+//    
+  if (fgInstance) {
+    AliGlobals::Exception(
+      "AliFiles: attempt to create two instances of singleton.");
+  };
+      
+  fgInstance = this;      
+}
+  
+//_____________________________________________________________________________
+AliFiles::AliFiles(const G4String& config)  
+  : fMacroName(config),
+    fG3CallsName(fgkDefaultG3CallsName)
+{
 //
+  if (fgInstance) {
+    AliGlobals::Exception(
+      "AliFiles: attempt to create two instances of singleton.");
+  };
+      
+  fgInstance = this;      
 }
   
+//_____________________________________________________________________________
+AliFiles::AliFiles(const G4String& config, const G4String& g3calls)  
+  : fMacroName(config),
+    fG3CallsName(g3calls)
+{
+//
+  if (fgInstance) {
+    AliGlobals::Exception(
+      "AliFiles: attempt to create two instances of singleton.");
+  };
+      
+  fgInstance = this;      
+}
+  
+//_____________________________________________________________________________
+AliFiles::AliFiles(const AliFiles& right) {
+// 
+  AliGlobals::Exception("Attempt to copy AliFiles singleton.");
+}
+
+
+//_____________________________________________________________________________
 AliFiles::~AliFiles() {
 //
 }
+
+// operators
+
+//_____________________________________________________________________________
+AliFiles& 
+AliFiles::operator=(const AliFiles& right)
+{
+  // check assignement to self
+  if (this == &right) return *this;
+
+  AliGlobals::Exception("Attempt to assign AliFiles singleton.");
+    
+  return *this;  
+}    
+          
+// private methods 
+
+//_____________________________________________________________________________
+G4String AliFiles::GetMacroPath(const G4String& macroName,
+                                const G4String& moduleName,
+                                G4bool isStructure) const
+{
+// Returns the filepath to Config.C/in with filename extension:
+// $AG4_INSTALL/macro/XXX/Config
+// $AG4_INSTALL/macro/STRUCT/XXXConfig
+// ---
+    
+  G4String name = fgkTop + "/macro/";
+  
+  if (!isStructure) 
+    name = name + moduleName + "/" + macroName;
+  else                               
+    name = name + "STRUCT/"+ fgkDefaultMacroName + moduleName;
+                             
+  return name;
+}                            
+                             
+// public methods
+
+//_____________________________________________________________________________
+G4String AliFiles::GetRootMacroPath() const
+{
+// Returns the filepath:
+// $ALICE_ROOT/macros/Config.C
+// ---
+    
+  G4String name 
+    = fgkTop + "/../macros/" + fMacroName + fgkRootMacroExtension;
+                             
+  return name;
+}                            
+                             
+//_____________________________________________________________________________
+G4String AliFiles::GetRootMacroPath(const G4String& moduleName,
+                                    G4bool isStructure) const
+{
+// Returns the filepath:
+// $AG4_INSTALL/macro/XXX/Config.C
+// $AG4_INSTALL/macro/STRUCT/XXXConfig.C
+// ---
+    
+  G4String name = GetMacroPath(fMacroName, moduleName, isStructure);
+  name = name + fgkRootMacroExtension;
+                             
+  return name;
+}                            
+                             
+//_____________________________________________________________________________
+G4String AliFiles::GetG4MacroPath(const G4String& moduleName, 
+                                  G4bool isStructure) const
+{
+// Returns the filepath:
+// $AG4_INSTALL/macro/XXX/Config.in
+// $AG4_INSTALL/macro/STRUCT/XXXConfig.in
+// ---
+    
+  G4String name = GetMacroPath(fgkDefaultMacroName, moduleName, isStructure); 
+  name = name + fgkG4MacroExtension;
+                             
+  return name;
+}                            
+                                                                                         
+//_____________________________________________________________________________
+G4String AliFiles::GetG3CallsDatPath(const G4String& moduleName, 
+                              G4int moduleVersion, G4bool isStructure) const
+{
+// Returns the filepath:
+// $AG4_INSTALL/macro/XXX/g3calls_vN.dat
+// $AG4_INSTALL/macro/STRUCT/g3calls_XXXvN.dat
+// ---
+    
+  G4String version("v");
+  AliGlobals::AppendNumberToString(version, moduleVersion);
+
+  G4String name = fgkTop + "/macro/";
   
+  if (!isStructure) 
+    name = name + moduleName + "/" + fG3CallsName + "_";
+  else                               
+    name = name + "STRUCT/" + fG3CallsName + "_" + moduleName;
+
+  name = name + version + fgkG3CallsExtension;
+                             
+  return name;
+}                            
+                             
+//_____________________________________________________________________________
+G4String AliFiles::GetXMLFilePath(const G4String& moduleName,
+                                  G4int moduleVersion) const
+{
+// Returns the filepath:
+// $AG4_INSTALL/xml/XXXvN.xml
+// ---
+    
+  G4String version = "v";
+  AliGlobals::AppendNumberToString(version, moduleVersion); 
+
+  G4String name 
+    = fgkTop + "/xml/" + moduleName + version + fgkXMLFileExtension;
+  
+  return name;
+}