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