4 // Author: I. Hrivnacova
6 // Class AliMoreModulesConstruction
7 // --------------------------------
8 // See the class description in the header file.
10 #include "AliMoreModulesConstruction.h"
11 #include "AliSingleModuleConstruction.h"
12 #include "AliModule.h"
13 #include "AliGlobals.h"
16 #include "TG4GeometryManager.h"
18 #include <G4LogicalVolume.hh>
19 #include <G4LogicalVolumeStore.hh>
21 //_____________________________________________________________________________
22 AliMoreModulesConstruction::AliMoreModulesConstruction() {
26 //_____________________________________________________________________________
27 AliMoreModulesConstruction::AliMoreModulesConstruction(
28 const AliMoreModulesConstruction& right)
35 //_____________________________________________________________________________
36 AliMoreModulesConstruction::~AliMoreModulesConstruction()
38 // delete module constructions
39 fModuleConstructionVector.erase(
40 fModuleConstructionVector.begin(), fModuleConstructionVector.end());
45 //_____________________________________________________________________________
46 AliMoreModulesConstruction&
47 AliMoreModulesConstruction::operator=(const AliMoreModulesConstruction& right)
49 // check assignement to self
50 if (this == &right) return *this;
52 // delete current module constructions
53 fModuleConstructionVector.erase(
54 fModuleConstructionVector.begin(), fModuleConstructionVector.end());
56 // create new module constructions
57 G4int nofModules = right.fModuleConstructionVector.size();
58 for (G4int i=0; i<nofModules; i++) {
59 G4String name = right.fModuleConstructionVector[i]->GetDetName();
60 G4int version = right.fModuleConstructionVector[i]->GetVersion();
61 AliModuleType type = right.fModuleConstructionVector[i]->GetType();
62 AddModule(name, version, type);
70 //_____________________________________________________________________________
71 void AliMoreModulesConstruction::AddModule(G4String moduleName, G4int version,
72 AliModuleType moduleType)
74 // Adds module specified by name, version and type.
77 // create module construction
78 AliSingleModuleConstruction* moduleConstruction
79 = new AliSingleModuleConstruction(moduleName, version, moduleType);
81 // add module, module construction to vectors
82 fModuleConstructionVector.push_back(moduleConstruction);
85 //_____________________________________________________________________________
86 void AliMoreModulesConstruction::Configure(const AliFiles& files)
88 // Executes the detectors setup Root macros
89 // (extracted from AliRoot Config.C) and
94 G4int nofModules = fModuleConstructionVector.size();
96 if (nofModules == 0) {
98 "AliMoreModulesConstruction::Construct(): No modules are defined.");
101 for (G4int i=0; i<nofModules; i++)
102 fModuleConstructionVector[i]->Configure(files);
105 //_____________________________________________________________________________
106 void AliMoreModulesConstruction::Construct()
108 // Constructs geometry.
109 // G3 tables are process for all modules alltogether.
113 G4int nofModules = fModuleConstructionVector.size();
115 if (nofModules == 0) {
117 "AliMoreModulesConstruction::Construct(): No modules are defined.");
120 // get geometry manager
121 TG4GeometryManager* pGeometryManager = TG4GeometryManager::Instance();
124 for (i=0; i<nofModules; i++) {
126 // fModuleConstructionVector[i]->Configure(files);
128 // register module name in the name map
129 AliModule* module = fModuleConstructionVector[i]->GetAliModule();
130 pGeometryManager->SetMapSecond(module->GetName());
132 G4bool readGeometry = fModuleConstructionVector[i]->GetReadGeometry();
133 G4bool writeGeometry = fModuleConstructionVector[i]->GetWriteGeometry();
134 G4String dataFilePath = fModuleConstructionVector[i]->GetDataFilePath();
137 // TG4GeometryManager uses g3tog4 methods for reading
138 // g3calls.dat files - as these methods do not fill name map
139 // they cannot be used for constructing more modules
142 // pGeometryManager->SetWriteGeometry(false);
143 // pGeometryManager->ReadG3Geometry(dataFilePath);
145 G4String text = "AliMoreModulesConstruction::Construct - Limitation:\n";
146 text = text + " Reading g3calls.dat is not implemented.";
147 AliGlobals::Exception(text);
150 // set geometry output stream for this module
151 pGeometryManager->SetWriteGeometry(writeGeometry);
153 pGeometryManager->OpenOutFile(dataFilePath);
155 // create geometry from AliRoot
157 // construct materials
158 module->CreateMaterials();
160 // construct G3 geometry
161 module->CreateGeometry();
164 pGeometryManager->CloseOutFile();
168 // construct G4 geometry
169 pGeometryManager->CreateG4Geometry();
172 // pGeometryManager->PrintNameMap();
174 for (i=0; i<nofModules; i++) {
175 // set the detector frame (envelope)
176 // (without warning output if enevelope is not defined)
177 fModuleConstructionVector[i]->SetDetFrame(false);
179 // construct geometry for display
180 fModuleConstructionVector[i]->GetAliModule()->BuildGeometry();
183 // reset TG4GeometryManager
184 pGeometryManager->ClearG3Tables();
186 #ifdef ALICE_VISUALIZE
187 // set visualization attributes
188 for (i=0; i<nofModules; i++) {
189 if (fModuleConstructionVector[i]->GetDetFrame()) {
190 fModuleConstructionVector[i]->SetDetVisibility(true);
191 fModuleConstructionVector[i]->SetDetColour("Yellow");