]> git.uio.no Git - u/mrichter/AliRoot.git/blob - AliGeant4/AliModuleConstruction.cxx
Add const to SolenoidField() method for correct overwriting from the parent class
[u/mrichter/AliRoot.git] / AliGeant4 / AliModuleConstruction.cxx
1 // $Id$
2 // Category: geometry
3 //
4 // Author: I. Hrivnacova
5 //
6 // Class AliModuleConstruction
7 // ---------------------------
8 // See the class description in the header file.
9
10 #include "AliModuleConstruction.h"
11 #include "AliGlobals.h"
12 #include "AliFiles.h"
13 #include "AliRun.h"
14 #include "AliModule.h"
15
16 #include <G4UImanager.hh>
17
18 #include <TROOT.h> 
19 #include <TCint.h> 
20
21
22 //_____________________________________________________________________________
23 AliModuleConstruction::AliModuleConstruction(const G4String& moduleName,
24                                              G4int version, 
25                                              AliModuleType moduleType)
26   : fAliModule(0),
27     fModuleName(moduleName), 
28     fType(moduleType),
29     fVersion(version),
30     fProcessConfig(true),
31     fReadGeometry(false),
32     fWriteGeometry(false),
33     fDataFilePath("") {
34 //
35 }
36
37 //_____________________________________________________________________________
38 AliModuleConstruction::AliModuleConstruction()
39   : fAliModule(0),
40     fModuleName(""), 
41     fType(kDetector),
42     fVersion(-1),
43     fProcessConfig(true),
44     fReadGeometry(false),
45     fWriteGeometry(false),
46     fDataFilePath("") {
47 //
48 }
49
50 //_____________________________________________________________________________
51 AliModuleConstruction::AliModuleConstruction(const AliModuleConstruction& right)
52 {
53 //
54   // copy stuff
55   *this = right;
56 }
57
58 //_____________________________________________________________________________
59 AliModuleConstruction::~AliModuleConstruction()
60 {
61 //
62 }
63
64 // operators
65
66 //_____________________________________________________________________________
67 AliModuleConstruction& 
68 AliModuleConstruction::operator=(const AliModuleConstruction& right)
69 {    
70   // check assignement to self
71   if (this == &right) return *this;
72   
73   fAliModule = right.fAliModule;
74   fModuleName = right.fModuleName; 
75   fVersion = right.fVersion;
76   fType = right.fType;
77   fProcessConfig = right.fProcessConfig;
78   fReadGeometry = right.fReadGeometry;
79   fWriteGeometry = right.fWriteGeometry;
80   fDataFilePath = right.fDataFilePath;
81
82   return *this;
83 }
84
85 //_____________________________________________________________________________
86 G4int 
87 AliModuleConstruction::operator==(const AliModuleConstruction& right) const
88 {
89 //    
90   return 0;
91 }
92
93 //_____________________________________________________________________________
94 G4int 
95 AliModuleConstruction::operator!=(const AliModuleConstruction& right) const
96 {
97 //    
98   G4int returnValue = 1;
99   if (*this == right) returnValue = 0; 
100   
101   return returnValue;
102 }
103
104 //_____________________________________________________________________________
105 void AliModuleConstruction::Configure()
106
107 // Executes the detector setup Root macro
108 // (extracted from AliRoot Config.C) and
109 // G4 macro.
110 // ---
111
112   AliFiles* files = AliFiles::Instance();
113
114   // filepaths and macro names 
115   G4bool isStructure = (fType == kStructure);
116   G4String rootFilePath 
117     = files->GetRootMacroPath(GetDetName(), isStructure);
118   G4String g4FilePath
119     = files->GetG4MacroPath(GetDetName(), isStructure);
120   fDataFilePath 
121     = files->GetG3CallsDatPath(GetDetName(), fVersion, isStructure); 
122   
123   // load and execute aliroot config macro
124   if (fProcessConfig) {
125     gROOT->LoadMacro(rootFilePath);
126     G4String macroName = files->GetDefaultMacroName();
127     //macroName = macroName + "_" + GetDetName();
128     macroName = macroName + "(";
129     AliGlobals::AppendNumberToString(macroName, fVersion);
130     macroName = macroName + ")";
131     gInterpreter->ProcessLine(macroName);
132   } 
133   
134   // process g4 config macro
135   G4String command = "/control/execute ";
136   G4UImanager* pUI = G4UImanager::GetUIpointer();  
137   pUI->ApplyCommand(command + g4FilePath);
138   
139   // get AliModule created in Config.C macro
140   fAliModule = gAlice->GetModule(GetDetName());
141   if (!fAliModule) {
142     G4String text = "AliModuleConstruction::Configure:\n";
143     text = text + "    AliModule " + GetDetName();
144     text = text + " has not been found in gAlice.";
145     AliGlobals::Exception(text);
146   }  
147 }
148