]> git.uio.no Git - u/mrichter/AliRoot.git/blame - AliGeant4/AliDetConstruction.cxx
added comment lines separating methods
[u/mrichter/AliRoot.git] / AliGeant4 / AliDetConstruction.cxx
CommitLineData
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
13AliDetConstruction::AliDetConstruction()
14 : fTopVolumeName("ALIC")
15{
16 // initialize det switch vector:
a168ab9b 17 // moduleName nofVersions defaultVersion PPRVersion [type isStandalone]
e28abd7f 18 // det switch objects are deleted in
19 // tbe base class (AliModulesCompositions) destructor
676fb573 20
21 AliDetSwitch* detSwitch;
a168ab9b 22 detSwitch = new AliDetSwitch("ABSO", 1, 0, 0, kStructure);
676fb573 23 AddDetSwitch(detSwitch);
a168ab9b 24 detSwitch = new AliDetSwitch("DIPO", 3, 2, 2, kStructure, false);
676fb573 25 AddDetSwitch(detSwitch);
89dc29b2 26 detSwitch = new AliDetSwitch("FRAME", 3, 2, 2, kStructure, false);
676fb573 27 AddDetSwitch(detSwitch);
a168ab9b 28 detSwitch = new AliDetSwitch("HALL", 1, 0, 0, kStructure);
676fb573 29 AddDetSwitch(detSwitch);
a168ab9b 30 detSwitch = new AliDetSwitch("MAG", 1, 0, 0, kStructure);
676fb573 31 AddDetSwitch(detSwitch);
043ee3b8 32 detSwitch = new AliDetSwitch("PIPE", 5, 0, 0, kStructure);
676fb573 33 AddDetSwitch(detSwitch);
a168ab9b 34 detSwitch = new AliDetSwitch("SHIL", 1, 0, 0, kStructure);
676fb573 35 AddDetSwitch(detSwitch);
a168ab9b 36 detSwitch = new AliDetSwitch("CASTOR", 2, 1, 1);
676fb573 37 AddDetSwitch(detSwitch);
f8360829 38 detSwitch = new AliDetSwitch("FMD", 2, 0, 0);
676fb573 39 AddDetSwitch(detSwitch);
89dc29b2 40 detSwitch = new AliDetSwitch("ITS", 7, 5, 5);
676fb573 41 AddDetSwitch(detSwitch);
5300eb81 42 detSwitch = new AliDetSwitch("MUON", 2, 1, 1);
676fb573 43 AddDetSwitch(detSwitch);
a168ab9b 44 detSwitch = new AliDetSwitch("PHOS", 5, 1, 1);
676fb573 45 AddDetSwitch(detSwitch);
f8360829 46 detSwitch = new AliDetSwitch("PMD", 3, 1, 1);
676fb573 47 AddDetSwitch(detSwitch);
a168ab9b 48 detSwitch = new AliDetSwitch("RICH", 3, 1, 1);
676fb573 49 AddDetSwitch(detSwitch);
a168ab9b 50 detSwitch = new AliDetSwitch("START", 2, 1, 1);
676fb573 51 AddDetSwitch(detSwitch);
f8360829 52 detSwitch = new AliDetSwitch("TOF", 5, 2, 2, kDetector, false);
676fb573 53 AddDetSwitch(detSwitch);
f8360829 54 detSwitch = new AliDetSwitch("TPC", 4, 2, 2);
676fb573 55 AddDetSwitch(detSwitch);
f8360829 56 detSwitch = new AliDetSwitch("TRD", 2, 1, 1, kDetector, false);
676fb573 57 AddDetSwitch(detSwitch);
a168ab9b 58 detSwitch = new AliDetSwitch("ZDC", 2, 1, 1, kDetector, false);
676fb573 59 AddDetSwitch(detSwitch);
60}
61
62AliDetConstruction::AliDetConstruction(const AliDetConstruction& right)
63 : AliModulesComposition(right)
64{
65 // AliModuleComposition is protected from copying
66}
67
68AliDetConstruction::~AliDetConstruction() {
69//
70}
71
72// operators
73
74AliDetConstruction&
75AliDetConstruction::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
89void 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
132void 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
5300eb81 142 for (G4int id=0; id<fDetSwitchVector.entries(); id++)
676fb573 143 {
5300eb81 144 G4String detName = fDetSwitchVector[id]->GetDetName();
145 G4int version = fDetSwitchVector[id]->GetSwitchedVersion();
146 G4bool isStandalone = fDetSwitchVector[id]->IsStandalone();
147 AliModuleType type = fDetSwitchVector[id]->GetType();
676fb573 148
149 if (version > -1)
150 if (isStandalone)
151 AddSingleModuleConstruction(detName, version, type);
152 else
153 AddMoreModuleConstruction(detName, version, type);
154 }
155}
156
157void AliDetConstruction::CheckDetDependencies()
158{
159// Checks modules dependencies.
160// Dependent modules FRAME, TOF, TRD
161// TOF always requires FRAMEv1
162// TRD can be built with both (??)
a168ab9b 163// ZDC requires DIPO
676fb573 164// ---
165
676fb573 166 // get switched versions of dependent modules
5300eb81 167 G4int verTOF = GetDetSwitch("TOF")->GetSwitchedVersion();
168 G4int verTRD = GetDetSwitch("TRD")->GetSwitchedVersion();
169 G4int verZDC = GetDetSwitch("ZDC")->GetSwitchedVersion();
170 G4int verFRAME = GetDetSwitch("FRAME")->GetSwitchedVersion();
676fb573 171
172 // check dependencies
5300eb81 173 if (verTOF > -1) {
89dc29b2 174 // TOF requires FRAMEv1 - obsolete?
175 if (verFRAME != 2) {
176 GetDetSwitch("FRAME")->SwitchOn(2);
676fb573 177 G4String text = "AliDetConstruction::CheckDetDependencies: \n";
5300eb81 178 text = text + " Switched TOF requires FRAME v1.\n";
676fb573 179 text = text + " The det switch for FRAME has been changed.";
180 AliGlobals::Warning(text);
181 }
182 }
5300eb81 183 if (verTRD > -1) {
184 // TRD requires FRAME
185 verFRAME = GetDetSwitch("FRAME")->GetSwitchedVersion();
676fb573 186 if (verFRAME < 0) {
5300eb81 187 GetDetSwitch("FRAME")->SwitchOnDefault();
676fb573 188 G4String text = "AliDetConstruction::CheckDetDependencies: \n";
5300eb81 189 text = text + " Switched TRD requires FRAME.\n";
676fb573 190 text = text + " The det switch for FRAME has been changed.";
191 AliGlobals::Warning(text);
192 }
193 }
5300eb81 194 if (verZDC > 0) {
195 // ZDC requires PIPE, ABSO, DIPO, SHIL
196 G4int verPIPE = GetDetSwitch("PIPE")->GetSwitchedVersion();
197 G4int verABSO = GetDetSwitch("ABSO")->GetSwitchedVersion();
198 G4int verDIPO = GetDetSwitch("DIPO")->GetSwitchedVersion();
199 G4int verSHIL = GetDetSwitch("SHIL")->GetSwitchedVersion();
200 if ( verPIPE != 1 || verABSO !=0 || verDIPO == -1 || verSHIL == -1) {
676fb573 201 G4String text = "AliDetConstruction::CheckDetDependencies: \n";
5300eb81 202 text = text + " Switched ZDC requires PIPE, ABSO, DIPO and SHIL.\n";
203 if (verPIPE == -1) {
204 GetDetSwitch("PIPE")->SwitchOnDefault();
205 text = text + " The det switch for PIPE has been changed.\n";
206 }
207 if (verABSO == -1) {
208 GetDetSwitch("ABSO")->SwitchOnDefault();
209 text = text + " The det switch for ABSO has been changed.\n";
210 }
211 if (verDIPO == -1) {
212 GetDetSwitch("DIPO")->SwitchOnDefault();
213 text = text + " The det switch for DIPO has been changed.\n";
214 }
215 if (verSHIL == -1) {
216 GetDetSwitch("SHIL")->SwitchOnDefault();
217 text = text + " The det switch for SHIL has been changed.";
218 }
676fb573 219 AliGlobals::Warning(text);
220 }
a168ab9b 221 }
676fb573 222}
223
224// public methods
225
226G4VPhysicalVolume* AliDetConstruction::Construct()
227{
228// Constructs geometry.
229// This method is called by G4RunManager in initialization.
230// ---
231
232 if (gAlice->Modules()->GetLast() < 0) {
233 // create geometry (including AliModules) according to
234 // the fDetSwitchVector
235 CheckDetDependencies();
236 CreateDetectors();
237 }
238 else {
239 // create geometry for AliModules
240 // that have been created and registered by gAlice
241 BuildDetectors();
242 }
243 // construct modules geometry
244 ConstructModules();
245
246 return AliSingleModuleConstruction::GetWorld();
247}
248