4 // See the class description in the header file.
6 #include "AliDetConstruction.h"
7 #include "AliSingleModuleConstruction.h"
8 #include "AliGlobals.h"
10 #include "AliModule.h"
12 AliDetConstruction::AliDetConstruction()
13 : fTopVolumeName("ALIC")
15 // initialize det switch vector:
16 // moduleName nofVersions defaultVersion [type isStandalone]
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);
39 detSwitch = new AliDetSwitch("MUON", 2, 0);
40 AddDetSwitch(detSwitch);
41 detSwitch = new AliDetSwitch("PHOS", 5, 1);
42 AddDetSwitch(detSwitch);
43 detSwitch = new AliDetSwitch("PMD", 3, 0);
44 AddDetSwitch(detSwitch);
45 detSwitch = new AliDetSwitch("RICH", 3, 1);
46 AddDetSwitch(detSwitch);
47 detSwitch = new AliDetSwitch("START", 1, 0);
48 AddDetSwitch(detSwitch);
49 detSwitch = new AliDetSwitch("TOF", 5, 1, kDetector, false);
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);
59 AliDetConstruction::AliDetConstruction(const AliDetConstruction& right)
60 : AliModulesComposition(right)
62 // AliModuleComposition is protected from copying
65 AliDetConstruction::~AliDetConstruction() {
72 AliDetConstruction::operator=(const AliDetConstruction& right)
74 // check assignement to self
75 if (this == &right) return *this;
77 // base class assignement
78 // AliModuleComposition is protected from assigning
79 AliModulesComposition::operator=(right);
86 void AliDetConstruction::BuildDetectors()
88 // Create module constructions for AliModules
89 // that have been created and registered by gAlice
92 TObjArray* pDetectors = gAlice->Detectors();
93 TIter next(pDetectors);
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);
103 AddSingleModuleConstruction("BODY", 0, kStructure);
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();
112 // skip registering of the top volume
115 SwitchDetOn(modName, modVersion);
117 // all modules will be processed alltogether
118 AddMoreModuleConstruction(modName, modVersion);
120 G4cout << "Created module construction for "
121 << modName << "v" << modVersion << "." << G4endl;
124 // do not process Config.C
125 // (it was processed when creating modules by gAlice)
126 SetProcessConfigToModules(false);
129 void AliDetConstruction::CreateDetectors()
131 // Creates AliModules and their module constructions
132 // according to the fDetSwitchVector
135 // add top volume (AliBODY) construction first
136 AddSingleModuleConstruction("BODY", 0, kStructure);
138 // add modules constructions
139 const G4RWTPtrOrderedVector<AliDetSwitch>& krDetSwitchVector
140 = GetDetSwitchVector();
141 for (G4int id=0; id<krDetSwitchVector.entries(); id++)
143 G4String detName = krDetSwitchVector[id]->GetDetName();
144 G4int version = krDetSwitchVector[id]->GetSwitchedVersion();
145 G4bool isStandalone = krDetSwitchVector[id]->IsStandalone();
146 AliModuleType type = krDetSwitchVector[id]->GetType();
150 AddSingleModuleConstruction(detName, version, type);
152 AddMoreModuleConstruction(detName, version, type);
156 void AliDetConstruction::CheckDetDependencies()
158 // Checks modules dependencies.
159 // Dependent modules FRAME, TOF, TRD
160 // TOF always requires FRAMEv1
161 // TRD can be built with both (??)
164 const G4RWTPtrOrderedVector<AliDetSwitch>& krDetSwitchVector
165 = GetDetSwitchVector();
167 // get switched versions of dependent modules
168 G4int nofDets = krDetSwitchVector.entries();
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];
179 if (detName == "TOF")
180 verTOF = krDetSwitchVector[id]->GetSwitchedVersion();
181 if (detName == "TRD")
182 verTRD = krDetSwitchVector[id]->GetSwitchedVersion();
185 // check dependencies
186 if (verTRD > -1 && verTOF > -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);
196 else if (verTRD > -1 && verTOF == -1) {
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);
206 else if (verTRD == -1 && verTOF > -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);
217 if (verTRD > -1 && verTOF > -1) {
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);
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);
232 else if (verTRD > -1 && verTOF == -1) {
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);
242 else if (verTRD == -1 && verTOF > -1) {
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);
251 if ((verTOF == 2 || verTOF == 3 || verTOF == 5 || verTOF == 6) &&
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);
265 G4VPhysicalVolume* AliDetConstruction::Construct()
267 // Constructs geometry.
268 // This method is called by G4RunManager in initialization.
271 if (gAlice->Modules()->GetLast() < 0) {
272 // create geometry (including AliModules) according to
273 // the fDetSwitchVector
274 CheckDetDependencies();
278 // create geometry for AliModules
279 // that have been created and registered by gAlice
282 // construct modules geometry
285 return AliSingleModuleConstruction::GetWorld();