4 // Author: I. Hrivnacova
6 // Class AliDetConstruction
7 // ------------------------
8 // See the class description in the header file.
10 #include "AliDetConstruction.h"
11 #include "AliSingleModuleConstruction.h"
12 #include "AliDetSwitch.h"
13 #include "AliGlobals.h"
15 #include "AliModule.h"
17 //_____________________________________________________________________________
18 AliDetConstruction::AliDetConstruction()
19 : fTopVolumeName("ALIC")
21 // initialize det switch vector:
22 // moduleName nofVersions defaultVersion PPRVersion [type isStandalone]
23 // det switch objects are deleted in
24 // tbe base class (AliModulesCompositions) destructor
26 AliDetSwitch* detSwitch;
27 detSwitch = new AliDetSwitch("ABSO", 1, 0, 0, kStructure);
28 AddDetSwitch(detSwitch);
29 detSwitch = new AliDetSwitch("DIPO", 3, 2, 2, kStructure, false);
30 AddDetSwitch(detSwitch);
31 detSwitch = new AliDetSwitch("FRAME", 3, 2, 2, kStructure, false);
32 AddDetSwitch(detSwitch);
33 detSwitch = new AliDetSwitch("HALL", 1, 0, 0, kStructure);
34 AddDetSwitch(detSwitch);
35 detSwitch = new AliDetSwitch("MAG", 1, 0, 0, kStructure);
36 AddDetSwitch(detSwitch);
37 detSwitch = new AliDetSwitch("PIPE", 5, 0, 0, kStructure);
38 AddDetSwitch(detSwitch);
39 detSwitch = new AliDetSwitch("SHIL", 1, 0, 0, kStructure);
40 AddDetSwitch(detSwitch);
41 detSwitch = new AliDetSwitch("CASTOR", 2, 1, 1);
42 AddDetSwitch(detSwitch);
43 detSwitch = new AliDetSwitch("FMD", 2, 0, 0);
44 AddDetSwitch(detSwitch);
45 detSwitch = new AliDetSwitch("ITS", 7, 5, 5);
46 AddDetSwitch(detSwitch);
47 detSwitch = new AliDetSwitch("MUON", 2, 1, 1);
48 AddDetSwitch(detSwitch);
49 detSwitch = new AliDetSwitch("PHOS", 5, 1, 1);
50 AddDetSwitch(detSwitch);
51 detSwitch = new AliDetSwitch("PMD", 3, 1, 1);
52 AddDetSwitch(detSwitch);
53 detSwitch = new AliDetSwitch("RICH", 3, 1, 1);
54 AddDetSwitch(detSwitch);
55 detSwitch = new AliDetSwitch("START", 2, 1, 1);
56 AddDetSwitch(detSwitch);
57 detSwitch = new AliDetSwitch("TOF", 5, 2, 2, kDetector, false);
58 AddDetSwitch(detSwitch);
59 detSwitch = new AliDetSwitch("TPC", 4, 2, 2);
60 AddDetSwitch(detSwitch);
61 detSwitch = new AliDetSwitch("TRD", 2, 1, 1, kDetector, false);
62 AddDetSwitch(detSwitch);
63 detSwitch = new AliDetSwitch("ZDC", 2, 1, 1, kDetector, false);
64 AddDetSwitch(detSwitch);
67 //_____________________________________________________________________________
68 AliDetConstruction::AliDetConstruction(const AliDetConstruction& right)
69 : AliModulesComposition(right)
71 // AliModuleComposition is protected from copying
74 //_____________________________________________________________________________
75 AliDetConstruction::~AliDetConstruction() {
81 //_____________________________________________________________________________
83 AliDetConstruction::operator=(const AliDetConstruction& right)
85 // check assignement to self
86 if (this == &right) return *this;
88 // base class assignement
89 // AliModuleComposition is protected from assigning
90 AliModulesComposition::operator=(right);
97 //_____________________________________________________________________________
98 void AliDetConstruction::BuildDetectors()
100 // Create module constructions for AliModules
101 // that have been created and registered by gAlice
104 TObjArray* pDetectors = gAlice->Detectors();
105 TIter next(pDetectors);
107 // the first AliModule is expected to be the top volume
108 AliModule *module = (AliModule*)next();
109 if (G4String(module->GetName()) != "BODY") {
110 G4String text = "AliDetConstruction::BuildDetectors():\n";
111 text = text + " Instead of BODY - the first module ";
112 text = text + module->GetName() + " has been found.";
113 AliGlobals::Exception(text);
115 AddSingleModuleConstruction("BODY", 0, kStructure);
118 while ((module = (AliModule*)next())) {
119 // register moduleConstruction in fDetSwitchVector
120 // in order to keep availability of /AlDet/list command
121 G4String modName = module->GetName();
122 G4int modVersion = module->IsVersion();
124 // skip registering of the top volume
127 SwitchDetOn(modName, modVersion);
129 // all modules will be processed alltogether
130 AddMoreModuleConstruction(modName, modVersion);
132 G4cout << "Created module construction for "
133 << modName << "v" << modVersion << "." << G4endl;
136 // do not process Config.C
137 // (it was processed when creating modules by gAlice)
138 SetProcessConfigToModules(false);
141 //_____________________________________________________________________________
142 void AliDetConstruction::CreateDetectors()
144 // Creates AliModules and their module constructions
145 // according to the fDetSwitchVector
148 // add top volume (AliBODY) construction first
149 AddSingleModuleConstruction("BODY", 0, kStructure);
151 // add modules constructions
152 for (G4int id=0; id<fDetSwitchVector.size(); id++)
154 G4String detName = fDetSwitchVector[id]->GetDetName();
155 G4int version = fDetSwitchVector[id]->GetSwitchedVersion();
156 G4bool isStandalone = fDetSwitchVector[id]->IsStandalone();
157 AliModuleType type = fDetSwitchVector[id]->GetType();
161 AddSingleModuleConstruction(detName, version, type);
163 AddMoreModuleConstruction(detName, version, type);
167 //_____________________________________________________________________________
168 void AliDetConstruction::CheckDetDependencies()
170 // Checks modules dependencies.
171 // Dependent modules FRAME, TOF, TRD
172 // TOF always requires FRAMEv1
173 // TRD can be built with both (??)
177 // get switched versions of dependent modules
178 G4int verTOF = GetDetSwitch("TOF")->GetSwitchedVersion();
179 G4int verTRD = GetDetSwitch("TRD")->GetSwitchedVersion();
180 G4int verZDC = GetDetSwitch("ZDC")->GetSwitchedVersion();
181 G4int verFRAME = GetDetSwitch("FRAME")->GetSwitchedVersion();
183 // check dependencies
185 // TOF requires FRAMEv1 - obsolete?
187 GetDetSwitch("FRAME")->SwitchOn(2);
188 G4String text = "AliDetConstruction::CheckDetDependencies: \n";
189 text = text + " Switched TOF requires FRAME v1.\n";
190 text = text + " The det switch for FRAME has been changed.";
191 AliGlobals::Warning(text);
195 // TRD requires FRAME
196 verFRAME = GetDetSwitch("FRAME")->GetSwitchedVersion();
198 GetDetSwitch("FRAME")->SwitchOnDefault();
199 G4String text = "AliDetConstruction::CheckDetDependencies: \n";
200 text = text + " Switched TRD requires FRAME.\n";
201 text = text + " The det switch for FRAME has been changed.";
202 AliGlobals::Warning(text);
206 // ZDC requires PIPE, ABSO, DIPO, SHIL
207 G4int verPIPE = GetDetSwitch("PIPE")->GetSwitchedVersion();
208 G4int verABSO = GetDetSwitch("ABSO")->GetSwitchedVersion();
209 G4int verDIPO = GetDetSwitch("DIPO")->GetSwitchedVersion();
210 G4int verSHIL = GetDetSwitch("SHIL")->GetSwitchedVersion();
211 if ( verPIPE != 1 || verABSO !=0 || verDIPO == -1 || verSHIL == -1) {
212 G4String text = "AliDetConstruction::CheckDetDependencies: \n";
213 text = text + " Switched ZDC requires PIPE, ABSO, DIPO and SHIL.\n";
215 GetDetSwitch("PIPE")->SwitchOnDefault();
216 text = text + " The det switch for PIPE has been changed.\n";
219 GetDetSwitch("ABSO")->SwitchOnDefault();
220 text = text + " The det switch for ABSO has been changed.\n";
223 GetDetSwitch("DIPO")->SwitchOnDefault();
224 text = text + " The det switch for DIPO has been changed.\n";
227 GetDetSwitch("SHIL")->SwitchOnDefault();
228 text = text + " The det switch for SHIL has been changed.";
230 AliGlobals::Warning(text);
237 //_____________________________________________________________________________
238 G4VPhysicalVolume* AliDetConstruction::Construct()
240 // Constructs geometry.
241 // This method is called by G4RunManager in initialization.
244 if (gAlice->Modules()->GetLast() < 0) {
245 // create geometry (including AliModules) according to
246 // the fDetSwitchVector
247 CheckDetDependencies();
251 // create geometry for AliModules
252 // that have been created and registered by gAlice
255 // construct modules geometry
258 return AliSingleModuleConstruction::GetWorld();