4 // Author: I. Hrivnacova
6 // Class AliSingleModuleConstruction
7 // ---------------------------------
8 // See the class description in the header file.
10 #include "AliSingleModuleConstruction.h"
11 #include "AliGlobals.h"
14 #include "AliModule.h"
16 #include "TG4GeometryManager.h"
18 #include <G4UImanager.hh>
19 //#include <G4Element.hh>
24 G4VPhysicalVolume* AliSingleModuleConstruction::fgWorld = 0;
26 //_____________________________________________________________________________
27 AliSingleModuleConstruction::AliSingleModuleConstruction(
28 G4String moduleName, G4int version,
29 AliModuleType moduleType)
30 : AliModuleConstruction(moduleName),
38 //_____________________________________________________________________________
39 AliSingleModuleConstruction::AliSingleModuleConstruction(
40 const AliSingleModuleConstruction& right)
41 : AliModuleConstruction(right)
48 //_____________________________________________________________________________
49 AliSingleModuleConstruction::AliSingleModuleConstruction() {
53 //_____________________________________________________________________________
54 AliSingleModuleConstruction::~AliSingleModuleConstruction() {
60 //_____________________________________________________________________________
61 AliSingleModuleConstruction&
62 AliSingleModuleConstruction::operator=(const AliSingleModuleConstruction& right)
64 // check assignement to self
65 if (this == &right) return *this;
67 // base class assignement
68 AliModuleConstruction::operator=(right);
70 fVersion = right.fVersion;
72 fProcessConfig = right.fProcessConfig;
79 //_____________________________________________________________________________
80 void AliSingleModuleConstruction::Configure(const AliFiles& files)
82 // Executes the detector setup Root macro
83 // (extracted from AliRoot Config.C) and
87 // filepaths and macro names
88 G4bool isStructure = (fType == kStructure);
90 = files.GetRootMacroPath(fModuleName, isStructure);
92 = files.GetG4MacroPath(fModuleName, isStructure);
94 = files.GetG3CallsDatPath(fModuleName, fVersion, isStructure);
96 // load and execute aliroot config macro
98 gROOT->LoadMacro(rootFilePath);
99 G4String macroName = files.GetDefaultMacroName();
100 //macroName = macroName + "_" + fModuleName;
101 macroName = macroName + "(";
102 AliGlobals::AppendNumberToString(macroName, fVersion);
103 macroName = macroName + ")";
104 gInterpreter->ProcessLine(macroName);
107 // process g4 config macro
108 G4String command = "/control/execute ";
109 G4UImanager* pUI = G4UImanager::GetUIpointer();
110 pUI->ApplyCommand(command + g4FilePath);
112 // get AliModule created in Config.C macro
113 fAliModule = gAlice->GetModule(fModuleName);
115 G4String text = "AliSingleModuleConstruction::Configure:\n";
116 text = text + " AliModule " + fModuleName;
117 text = text + " has not been found in gAlice.";
118 AliGlobals::Exception(text);
122 //_____________________________________________________________________________
123 void AliSingleModuleConstruction::Construct()
125 // Constructs geometry.
128 // print default element table
129 // const G4ElementTable* table = G4Element::GetElementTable();
130 // G4cout << "Default elemnt table: " << G4endl;
131 // for (G4int i=0; i<table->entries(); i++) {
132 // G4cout << *(*table)[i] << G4endl;
137 // get geometry manager
138 TG4GeometryManager* pGeometryManager = TG4GeometryManager::Instance();
140 // register module name in the name map
141 pGeometryManager->SetMapSecond(fAliModule->GetName());
144 // create G3 geometry from g3calls.dat
145 pGeometryManager->SetWriteGeometry(false);
146 pGeometryManager->ReadG3Geometry(fDataFilePath);
149 // set geometry output stream for this module
150 pGeometryManager->SetWriteGeometry(fWriteGeometry);
152 pGeometryManager->OpenOutFile(fDataFilePath);
154 // create geometry from AliRoot
156 // construct materials
157 fAliModule->CreateMaterials();
159 // construct G3 geometry
160 fAliModule->CreateGeometry();
163 pGeometryManager->CloseOutFile();
166 // construct G4 geometry
167 G4VPhysicalVolume* world = pGeometryManager->CreateG4Geometry();
168 if (!fgWorld) fgWorld = world;
170 // set the detector frame (envelope)
171 // (without warning output if enevelope is not defined)
174 // construct geometry for display
175 fAliModule->BuildGeometry();
177 // reset TG4GeometryManager
178 pGeometryManager->ClearG3Tables();
180 #ifdef ALICE_VISUALIZE
182 // set visualization attributes
183 // if detector envelope is defined
184 SetDetVisibility(true);
185 SetDetColour("Yellow");