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]
17 // det switch objects are deleted in
18 // tbe base class (AliModulesCompositions) destructor
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);
41 detSwitch = new AliDetSwitch("MUON", 2, 0);
42 AddDetSwitch(detSwitch);
43 detSwitch = new AliDetSwitch("PHOS", 5, 1);
44 AddDetSwitch(detSwitch);
45 detSwitch = new AliDetSwitch("PMD", 3, 0);
46 AddDetSwitch(detSwitch);
47 detSwitch = new AliDetSwitch("RICH", 3, 1);
48 AddDetSwitch(detSwitch);
49 detSwitch = new AliDetSwitch("START", 2, 0);
50 AddDetSwitch(detSwitch);
51 detSwitch = new AliDetSwitch("TOF", 5, 1, kDetector, false);
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);
61 AliDetConstruction::AliDetConstruction(const AliDetConstruction& right)
62 : AliModulesComposition(right)
64 // AliModuleComposition is protected from copying
67 AliDetConstruction::~AliDetConstruction() {
74 AliDetConstruction::operator=(const AliDetConstruction& right)
76 // check assignement to self
77 if (this == &right) return *this;
79 // base class assignement
80 // AliModuleComposition is protected from assigning
81 AliModulesComposition::operator=(right);
88 void AliDetConstruction::BuildDetectors()
90 // Create module constructions for AliModules
91 // that have been created and registered by gAlice
94 TObjArray* pDetectors = gAlice->Detectors();
95 TIter next(pDetectors);
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);
105 AddSingleModuleConstruction("BODY", 0, kStructure);
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();
114 // skip registering of the top volume
117 SwitchDetOn(modName, modVersion);
119 // all modules will be processed alltogether
120 AddMoreModuleConstruction(modName, modVersion);
122 G4cout << "Created module construction for "
123 << modName << "v" << modVersion << "." << G4endl;
126 // do not process Config.C
127 // (it was processed when creating modules by gAlice)
128 SetProcessConfigToModules(false);
131 void AliDetConstruction::CreateDetectors()
133 // Creates AliModules and their module constructions
134 // according to the fDetSwitchVector
137 // add top volume (AliBODY) construction first
138 AddSingleModuleConstruction("BODY", 0, kStructure);
140 // add modules constructions
141 const G4RWTPtrOrderedVector<AliDetSwitch>& krDetSwitchVector
142 = GetDetSwitchVector();
143 for (G4int id=0; id<krDetSwitchVector.entries(); id++)
145 G4String detName = krDetSwitchVector[id]->GetDetName();
146 G4int version = krDetSwitchVector[id]->GetSwitchedVersion();
147 G4bool isStandalone = krDetSwitchVector[id]->IsStandalone();
148 AliModuleType type = krDetSwitchVector[id]->GetType();
152 AddSingleModuleConstruction(detName, version, type);
154 AddMoreModuleConstruction(detName, version, type);
158 void AliDetConstruction::CheckDetDependencies()
160 // Checks modules dependencies.
161 // Dependent modules FRAME, TOF, TRD
162 // TOF always requires FRAMEv1
163 // TRD can be built with both (??)
166 const G4RWTPtrOrderedVector<AliDetSwitch>& krDetSwitchVector
167 = GetDetSwitchVector();
169 // get switched versions of dependent modules
170 G4int nofDets = krDetSwitchVector.entries();
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];
181 if (detName == "TOF")
182 verTOF = krDetSwitchVector[id]->GetSwitchedVersion();
183 if (detName == "TRD")
184 verTRD = krDetSwitchVector[id]->GetSwitchedVersion();
187 // check dependencies
188 if (verTRD > -1 && verTOF > -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);
198 else if (verTRD > -1 && verTOF == -1) {
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);
208 else if (verTRD == -1 && verTOF > -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);
222 G4VPhysicalVolume* AliDetConstruction::Construct()
224 // Constructs geometry.
225 // This method is called by G4RunManager in initialization.
228 if (gAlice->Modules()->GetLast() < 0) {
229 // create geometry (including AliModules) according to
230 // the fDetSwitchVector
231 CheckDetDependencies();
235 // create geometry for AliModules
236 // that have been created and registered by gAlice
239 // construct modules geometry
242 return AliSingleModuleConstruction::GetWorld();