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