]> git.uio.no Git - u/mrichter/AliRoot.git/blame - AliGeant4/AliDetConstruction.cxx
Updated class description: added class title, author;
[u/mrichter/AliRoot.git] / AliGeant4 / AliDetConstruction.cxx
CommitLineData
676fb573 1// $Id$
2// Category: geometry
3//
4// See the class description in the header file.
5
6#include "AliDetConstruction.h"
7#include "AliSingleModuleConstruction.h"
c97337f9 8#include "AliDetSwitch.h"
676fb573 9#include "AliGlobals.h"
10#include "AliRun.h"
11#include "AliModule.h"
12
78ca1e9c 13//_____________________________________________________________________________
676fb573 14AliDetConstruction::AliDetConstruction()
15 : fTopVolumeName("ALIC")
16{
17 // initialize det switch vector:
a168ab9b 18 // moduleName nofVersions defaultVersion PPRVersion [type isStandalone]
e28abd7f 19 // det switch objects are deleted in
20 // tbe base class (AliModulesCompositions) destructor
676fb573 21
22 AliDetSwitch* detSwitch;
a168ab9b 23 detSwitch = new AliDetSwitch("ABSO", 1, 0, 0, kStructure);
676fb573 24 AddDetSwitch(detSwitch);
a168ab9b 25 detSwitch = new AliDetSwitch("DIPO", 3, 2, 2, kStructure, false);
676fb573 26 AddDetSwitch(detSwitch);
89dc29b2 27 detSwitch = new AliDetSwitch("FRAME", 3, 2, 2, kStructure, false);
676fb573 28 AddDetSwitch(detSwitch);
a168ab9b 29 detSwitch = new AliDetSwitch("HALL", 1, 0, 0, kStructure);
676fb573 30 AddDetSwitch(detSwitch);
a168ab9b 31 detSwitch = new AliDetSwitch("MAG", 1, 0, 0, kStructure);
676fb573 32 AddDetSwitch(detSwitch);
043ee3b8 33 detSwitch = new AliDetSwitch("PIPE", 5, 0, 0, kStructure);
676fb573 34 AddDetSwitch(detSwitch);
a168ab9b 35 detSwitch = new AliDetSwitch("SHIL", 1, 0, 0, kStructure);
676fb573 36 AddDetSwitch(detSwitch);
a168ab9b 37 detSwitch = new AliDetSwitch("CASTOR", 2, 1, 1);
676fb573 38 AddDetSwitch(detSwitch);
f8360829 39 detSwitch = new AliDetSwitch("FMD", 2, 0, 0);
676fb573 40 AddDetSwitch(detSwitch);
89dc29b2 41 detSwitch = new AliDetSwitch("ITS", 7, 5, 5);
676fb573 42 AddDetSwitch(detSwitch);
5300eb81 43 detSwitch = new AliDetSwitch("MUON", 2, 1, 1);
676fb573 44 AddDetSwitch(detSwitch);
a168ab9b 45 detSwitch = new AliDetSwitch("PHOS", 5, 1, 1);
676fb573 46 AddDetSwitch(detSwitch);
f8360829 47 detSwitch = new AliDetSwitch("PMD", 3, 1, 1);
676fb573 48 AddDetSwitch(detSwitch);
a168ab9b 49 detSwitch = new AliDetSwitch("RICH", 3, 1, 1);
676fb573 50 AddDetSwitch(detSwitch);
a168ab9b 51 detSwitch = new AliDetSwitch("START", 2, 1, 1);
676fb573 52 AddDetSwitch(detSwitch);
f8360829 53 detSwitch = new AliDetSwitch("TOF", 5, 2, 2, kDetector, false);
676fb573 54 AddDetSwitch(detSwitch);
f8360829 55 detSwitch = new AliDetSwitch("TPC", 4, 2, 2);
676fb573 56 AddDetSwitch(detSwitch);
f8360829 57 detSwitch = new AliDetSwitch("TRD", 2, 1, 1, kDetector, false);
676fb573 58 AddDetSwitch(detSwitch);
a168ab9b 59 detSwitch = new AliDetSwitch("ZDC", 2, 1, 1, kDetector, false);
676fb573 60 AddDetSwitch(detSwitch);
61}
62
78ca1e9c 63//_____________________________________________________________________________
676fb573 64AliDetConstruction::AliDetConstruction(const AliDetConstruction& right)
65 : AliModulesComposition(right)
66{
67 // AliModuleComposition is protected from copying
68}
69
78ca1e9c 70//_____________________________________________________________________________
676fb573 71AliDetConstruction::~AliDetConstruction() {
72//
73}
74
75// operators
76
78ca1e9c 77//_____________________________________________________________________________
676fb573 78AliDetConstruction&
79AliDetConstruction::operator=(const AliDetConstruction& right)
80{
81 // check assignement to self
82 if (this == &right) return *this;
83
84 // base class assignement
85 // AliModuleComposition is protected from assigning
86 AliModulesComposition::operator=(right);
87
88 return *this;
89}
90
91// private methods
92
78ca1e9c 93//_____________________________________________________________________________
676fb573 94void AliDetConstruction::BuildDetectors()
95{
96// Create module constructions for AliModules
97// that have been created and registered by gAlice
98// ---
99
100 TObjArray* pDetectors = gAlice->Detectors();
101 TIter next(pDetectors);
102
103 // the first AliModule is expected to be the top volume
104 AliModule *module = (AliModule*)next();
105 if (G4String(module->GetName()) != "BODY") {
106 G4String text = "AliDetConstruction::BuildDetectors():\n";
107 text = text + " Instead of BODY - the first module ";
108 text = text + module->GetName() + " has been found.";
109 AliGlobals::Exception(text);
110 }
111 AddSingleModuleConstruction("BODY", 0, kStructure);
112
113 G4bool first = true;
114 while ((module = (AliModule*)next())) {
115 // register moduleConstruction in fDetSwitchVector
116 // in order to keep availability of /AlDet/list command
117 G4String modName = module->GetName();
118 G4int modVersion = module->IsVersion();
119 if (first)
120 // skip registering of the top volume
121 first = false;
122 else
123 SwitchDetOn(modName, modVersion);
124
125 // all modules will be processed alltogether
126 AddMoreModuleConstruction(modName, modVersion);
127
128 G4cout << "Created module construction for "
5f1d09c5 129 << modName << "v" << modVersion << "." << G4endl;
676fb573 130 }
131
132 // do not process Config.C
133 // (it was processed when creating modules by gAlice)
134 SetProcessConfigToModules(false);
135}
136
78ca1e9c 137//_____________________________________________________________________________
676fb573 138void AliDetConstruction::CreateDetectors()
139{
140// Creates AliModules and their module constructions
141// according to the fDetSwitchVector
142// ---
143
144 // add top volume (AliBODY) construction first
145 AddSingleModuleConstruction("BODY", 0, kStructure);
146
147 // add modules constructions
5300eb81 148 for (G4int id=0; id<fDetSwitchVector.entries(); id++)
676fb573 149 {
5300eb81 150 G4String detName = fDetSwitchVector[id]->GetDetName();
151 G4int version = fDetSwitchVector[id]->GetSwitchedVersion();
152 G4bool isStandalone = fDetSwitchVector[id]->IsStandalone();
153 AliModuleType type = fDetSwitchVector[id]->GetType();
676fb573 154
155 if (version > -1)
156 if (isStandalone)
157 AddSingleModuleConstruction(detName, version, type);
158 else
159 AddMoreModuleConstruction(detName, version, type);
160 }
161}
162
78ca1e9c 163//_____________________________________________________________________________
676fb573 164void AliDetConstruction::CheckDetDependencies()
165{
166// Checks modules dependencies.
167// Dependent modules FRAME, TOF, TRD
168// TOF always requires FRAMEv1
169// TRD can be built with both (??)
a168ab9b 170// ZDC requires DIPO
676fb573 171// ---
172
676fb573 173 // get switched versions of dependent modules
5300eb81 174 G4int verTOF = GetDetSwitch("TOF")->GetSwitchedVersion();
175 G4int verTRD = GetDetSwitch("TRD")->GetSwitchedVersion();
176 G4int verZDC = GetDetSwitch("ZDC")->GetSwitchedVersion();
177 G4int verFRAME = GetDetSwitch("FRAME")->GetSwitchedVersion();
676fb573 178
179 // check dependencies
5300eb81 180 if (verTOF > -1) {
89dc29b2 181 // TOF requires FRAMEv1 - obsolete?
182 if (verFRAME != 2) {
183 GetDetSwitch("FRAME")->SwitchOn(2);
676fb573 184 G4String text = "AliDetConstruction::CheckDetDependencies: \n";
5300eb81 185 text = text + " Switched TOF requires FRAME v1.\n";
676fb573 186 text = text + " The det switch for FRAME has been changed.";
187 AliGlobals::Warning(text);
188 }
189 }
5300eb81 190 if (verTRD > -1) {
191 // TRD requires FRAME
192 verFRAME = GetDetSwitch("FRAME")->GetSwitchedVersion();
676fb573 193 if (verFRAME < 0) {
5300eb81 194 GetDetSwitch("FRAME")->SwitchOnDefault();
676fb573 195 G4String text = "AliDetConstruction::CheckDetDependencies: \n";
5300eb81 196 text = text + " Switched TRD requires FRAME.\n";
676fb573 197 text = text + " The det switch for FRAME has been changed.";
198 AliGlobals::Warning(text);
199 }
200 }
5300eb81 201 if (verZDC > 0) {
202 // ZDC requires PIPE, ABSO, DIPO, SHIL
203 G4int verPIPE = GetDetSwitch("PIPE")->GetSwitchedVersion();
204 G4int verABSO = GetDetSwitch("ABSO")->GetSwitchedVersion();
205 G4int verDIPO = GetDetSwitch("DIPO")->GetSwitchedVersion();
206 G4int verSHIL = GetDetSwitch("SHIL")->GetSwitchedVersion();
207 if ( verPIPE != 1 || verABSO !=0 || verDIPO == -1 || verSHIL == -1) {
676fb573 208 G4String text = "AliDetConstruction::CheckDetDependencies: \n";
5300eb81 209 text = text + " Switched ZDC requires PIPE, ABSO, DIPO and SHIL.\n";
210 if (verPIPE == -1) {
211 GetDetSwitch("PIPE")->SwitchOnDefault();
212 text = text + " The det switch for PIPE has been changed.\n";
213 }
214 if (verABSO == -1) {
215 GetDetSwitch("ABSO")->SwitchOnDefault();
216 text = text + " The det switch for ABSO has been changed.\n";
217 }
218 if (verDIPO == -1) {
219 GetDetSwitch("DIPO")->SwitchOnDefault();
220 text = text + " The det switch for DIPO has been changed.\n";
221 }
222 if (verSHIL == -1) {
223 GetDetSwitch("SHIL")->SwitchOnDefault();
224 text = text + " The det switch for SHIL has been changed.";
225 }
676fb573 226 AliGlobals::Warning(text);
227 }
a168ab9b 228 }
676fb573 229}
230
231// public methods
232
78ca1e9c 233//_____________________________________________________________________________
676fb573 234G4VPhysicalVolume* AliDetConstruction::Construct()
235{
236// Constructs geometry.
237// This method is called by G4RunManager in initialization.
238// ---
239
240 if (gAlice->Modules()->GetLast() < 0) {
241 // create geometry (including AliModules) according to
242 // the fDetSwitchVector
243 CheckDetDependencies();
244 CreateDetectors();
245 }
246 else {
247 // create geometry for AliModules
248 // that have been created and registered by gAlice
249 BuildDetectors();
250 }
251 // construct modules geometry
252 ConstructModules();
253
254 return AliSingleModuleConstruction::GetWorld();
255}
256