4 // See the class description in the header file.
6 #include "AliSingleModuleConstruction.h"
7 #include "AliGlobals.h"
10 #include "AliModule.h"
12 #include "TG4GeometryManager.h"
14 #include <G4UImanager.hh>
15 //#include <G4Element.hh>
20 G4VPhysicalVolume* AliSingleModuleConstruction::fgWorld = 0;
22 //_____________________________________________________________________________
23 AliSingleModuleConstruction::AliSingleModuleConstruction(
24 G4String moduleName, G4int version,
25 AliModuleType moduleType)
26 : AliModuleConstruction(moduleName),
34 //_____________________________________________________________________________
35 AliSingleModuleConstruction::AliSingleModuleConstruction(
36 const AliSingleModuleConstruction& right)
37 : AliModuleConstruction(right)
44 //_____________________________________________________________________________
45 AliSingleModuleConstruction::AliSingleModuleConstruction() {
49 //_____________________________________________________________________________
50 AliSingleModuleConstruction::~AliSingleModuleConstruction() {
56 //_____________________________________________________________________________
57 AliSingleModuleConstruction&
58 AliSingleModuleConstruction::operator=(const AliSingleModuleConstruction& right)
60 // check assignement to self
61 if (this == &right) return *this;
63 // base class assignement
64 AliModuleConstruction::operator=(right);
66 fVersion = right.fVersion;
68 fProcessConfig = right.fProcessConfig;
75 //_____________________________________________________________________________
76 void AliSingleModuleConstruction::Configure(const AliFiles& files)
78 // Executes the detector setup Root macro
79 // (extracted from AliRoot Config.C) and
83 // filepaths and macro names
84 G4bool isStructure = (fType == kStructure);
86 = files.GetRootMacroPath(fModuleName, isStructure);
88 = files.GetG4MacroPath(fModuleName, isStructure);
90 = files.GetG3CallsDatPath(fModuleName, fVersion, isStructure);
92 // load and execute aliroot config macro
94 gROOT->LoadMacro(rootFilePath);
95 G4String macroName = files.GetDefaultMacroName();
96 //macroName = macroName + "_" + fModuleName;
97 macroName = macroName + "(";
98 AliGlobals::AppendNumberToString(macroName, fVersion);
99 macroName = macroName + ")";
100 gInterpreter->ProcessLine(macroName);
103 // process g4 config macro
104 G4String command = "/control/execute ";
105 G4UImanager* pUI = G4UImanager::GetUIpointer();
106 pUI->ApplyCommand(command + g4FilePath);
108 // get AliModule created in Config.C macro
109 fAliModule = gAlice->GetModule(fModuleName);
111 G4String text = "AliSingleModuleConstruction::Configure:\n";
112 text = text + " AliModule " + fModuleName;
113 text = text + " has not been found in gAlice.";
114 AliGlobals::Exception(text);
118 //_____________________________________________________________________________
119 void AliSingleModuleConstruction::Construct()
121 // Constructs geometry.
124 // print default element table
125 // const G4ElementTable* table = G4Element::GetElementTable();
126 // G4cout << "Default elemnt table: " << G4endl;
127 // for (G4int i=0; i<table->entries(); i++) {
128 // G4cout << *(*table)[i] << G4endl;
133 // get geometry manager
134 TG4GeometryManager* pGeometryManager = TG4GeometryManager::Instance();
136 // register module name in the name map
137 pGeometryManager->SetMapSecond(fAliModule->GetName());
140 // create G3 geometry from g3calls.dat
141 pGeometryManager->SetWriteGeometry(false);
142 pGeometryManager->ReadG3Geometry(fDataFilePath);
145 // set geometry output stream for this module
146 pGeometryManager->SetWriteGeometry(fWriteGeometry);
148 pGeometryManager->OpenOutFile(fDataFilePath);
150 // create geometry from AliRoot
152 // construct materials
153 fAliModule->CreateMaterials();
155 // construct G3 geometry
156 fAliModule->CreateGeometry();
159 pGeometryManager->CloseOutFile();
162 // construct G4 geometry
163 G4VPhysicalVolume* world = pGeometryManager->CreateG4Geometry();
164 if (!fgWorld) fgWorld = world;
166 // set the detector frame (envelope)
167 // (without warning output if enevelope is not defined)
170 // construct geometry for display
171 fAliModule->BuildGeometry();
173 // reset TG4GeometryManager
174 pGeometryManager->ClearG3Tables();
176 #ifdef ALICE_VISUALIZE
178 // set visualization attributes
179 // if detector envelope is defined
180 SetDetVisibility(true);
181 SetDetColour("Yellow");