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