4 // See the class description in the header file.
6 #include "AliMoreModulesConstruction.h"
7 #include "AliSingleModuleConstruction.h"
9 #include "AliGlobals.h"
12 #include "TG4GeometryManager.h"
14 #include <G4LogicalVolume.hh>
15 #include <G4LogicalVolumeStore.hh>
17 //_____________________________________________________________________________
18 AliMoreModulesConstruction::AliMoreModulesConstruction() {
22 //_____________________________________________________________________________
23 AliMoreModulesConstruction::AliMoreModulesConstruction(
24 const AliMoreModulesConstruction& right)
31 //_____________________________________________________________________________
32 AliMoreModulesConstruction::~AliMoreModulesConstruction()
34 // delete module constructions
35 fModuleConstructionVector.erase(
36 fModuleConstructionVector.begin(), fModuleConstructionVector.end());
41 //_____________________________________________________________________________
42 AliMoreModulesConstruction&
43 AliMoreModulesConstruction::operator=(const AliMoreModulesConstruction& right)
45 // check assignement to self
46 if (this == &right) return *this;
48 // delete current module constructions
49 fModuleConstructionVector.erase(
50 fModuleConstructionVector.begin(), fModuleConstructionVector.end());
52 // create new module constructions
53 G4int nofModules = right.fModuleConstructionVector.size();
54 for (G4int i=0; i<nofModules; i++) {
55 G4String name = right.fModuleConstructionVector[i]->GetDetName();
56 G4int version = right.fModuleConstructionVector[i]->GetVersion();
57 AliModuleType type = right.fModuleConstructionVector[i]->GetType();
58 AddModule(name, version, type);
66 //_____________________________________________________________________________
67 void AliMoreModulesConstruction::AddModule(G4String moduleName, G4int version,
68 AliModuleType moduleType)
70 // Adds module specified by name, version and type.
73 // create module construction
74 AliSingleModuleConstruction* moduleConstruction
75 = new AliSingleModuleConstruction(moduleName, version, moduleType);
77 // add module, module construction to vectors
78 fModuleConstructionVector.push_back(moduleConstruction);
81 //_____________________________________________________________________________
82 void AliMoreModulesConstruction::Configure(const AliFiles& files)
84 // Executes the detectors setup Root macros
85 // (extracted from AliRoot Config.C) and
90 G4int nofModules = fModuleConstructionVector.size();
92 if (nofModules == 0) {
94 "AliMoreModulesConstruction::Construct(): No modules are defined.");
97 for (G4int i=0; i<nofModules; i++)
98 fModuleConstructionVector[i]->Configure(files);
101 //_____________________________________________________________________________
102 void AliMoreModulesConstruction::Construct()
104 // Constructs geometry.
105 // G3 tables are process for all modules alltogether.
109 G4int nofModules = fModuleConstructionVector.size();
111 if (nofModules == 0) {
113 "AliMoreModulesConstruction::Construct(): No modules are defined.");
116 // get geometry manager
117 TG4GeometryManager* pGeometryManager = TG4GeometryManager::Instance();
120 for (i=0; i<nofModules; i++) {
122 // fModuleConstructionVector[i]->Configure(files);
124 // register module name in the name map
125 AliModule* module = fModuleConstructionVector[i]->GetAliModule();
126 pGeometryManager->SetMapSecond(module->GetName());
128 G4bool readGeometry = fModuleConstructionVector[i]->GetReadGeometry();
129 G4bool writeGeometry = fModuleConstructionVector[i]->GetWriteGeometry();
130 G4String dataFilePath = fModuleConstructionVector[i]->GetDataFilePath();
133 // TG4GeometryManager uses g3tog4 methods for reading
134 // g3calls.dat files - as these methods do not fill name map
135 // they cannot be used for constructing more modules
138 // pGeometryManager->SetWriteGeometry(false);
139 // pGeometryManager->ReadG3Geometry(dataFilePath);
141 G4String text = "AliMoreModulesConstruction::Construct - Limitation:\n";
142 text = text + " Reading g3calls.dat is not implemented.";
143 AliGlobals::Exception(text);
146 // set geometry output stream for this module
147 pGeometryManager->SetWriteGeometry(writeGeometry);
149 pGeometryManager->OpenOutFile(dataFilePath);
151 // create geometry from AliRoot
153 // construct materials
154 module->CreateMaterials();
156 // construct G3 geometry
157 module->CreateGeometry();
160 pGeometryManager->CloseOutFile();
164 // construct G4 geometry
165 pGeometryManager->CreateG4Geometry();
168 // pGeometryManager->PrintNameMap();
170 for (i=0; i<nofModules; i++) {
171 // set the detector frame (envelope)
172 // (without warning output if enevelope is not defined)
173 fModuleConstructionVector[i]->SetDetFrame(false);
175 // construct geometry for display
176 fModuleConstructionVector[i]->GetAliModule()->BuildGeometry();
179 // reset TG4GeometryManager
180 pGeometryManager->ClearG3Tables();
182 #ifdef ALICE_VISUALIZE
183 // set visualization attributes
184 for (i=0; i<nofModules; i++) {
185 if (fModuleConstructionVector[i]->GetDetFrame()) {
186 fModuleConstructionVector[i]->SetDetVisibility(true);
187 fModuleConstructionVector[i]->SetDetColour("Yellow");