]> git.uio.no Git - u/mrichter/AliRoot.git/blob - TGeant4/TGeant4.cxx
added printing of logical volumes (with verbose level>2) in LateInitialize()
[u/mrichter/AliRoot.git] / TGeant4 / TGeant4.cxx
1 // $Id$
2 // Category: run
3 //
4 // Author: I. Hrivnacova
5 //
6 // Class TGeant4
7 // -------------
8 // See the class description in the header file.
9
10 #include "TGeant4.h"
11 #include "TG4VRunConfiguration.h"
12 #include "TG4GeometryManager.h" 
13 #include "TG4SDManager.h" 
14 #include "TG4PhysicsManager.h" 
15 #include "TG4StepManager.h" 
16 #include "TG4VisManager.h"
17 #include "TG4RunManager.h"
18 #include "TG4Globals.h"
19
20 #include "AliDecayer.h"
21
22 //_____________________________________________________________________________
23 TGeant4::TGeant4(const char* name, const char* title,
24                  TG4VRunConfiguration* configuration, int argc, char** argv)
25   : AliMC(name, title),
26     fVisManager(0)
27 {
28   // create run manager
29   fRunManager = new TG4RunManager(configuration, argc, argv);
30   // add verbose level
31   //G4cout << "TG4RunManager has been created." << endl;
32
33   // create geometry manager
34   fGeometryManager = new TG4GeometryManager();
35   // add verbose level
36   //G4cout << "TG4GeometryManager has been created." << endl;
37   
38   // create sensitive detectors manager
39   fSDManager = new TG4SDManager(configuration->GetSDConstruction());
40   // add verbose level
41   //G4cout << "TG4SDManager has been created." << endl;
42   
43   // create physics manager  
44   fPhysicsManager = new TG4PhysicsManager(configuration->GetPhysicsList());
45   // add verbose level
46   //G4cout << "TG4GeometryManager has been created." << endl;
47   
48   // create step manager 
49   fStepManager = new TG4StepManager();
50   // add verbose level
51   //G4cout << "TG4StepManager has been created." << endl;
52   
53 #ifdef G4VIS_USE
54   // create visualization manager
55   fVisManager = new TG4VisManager();
56   fVisManager->Initialize();
57 #endif
58 }
59     
60 //_____________________________________________________________________________
61 TGeant4::TGeant4(const char* name, const char* title,
62                  TG4VRunConfiguration* configuration)
63   : AliMC(name, title),
64     fVisManager(0)
65 {
66   // create run manager
67   fRunManager = new TG4RunManager(configuration);
68   // add verbose level
69   //G4cout << "TG4RunManager has been created." << endl;
70
71   // create geometry manager
72   fGeometryManager = new TG4GeometryManager();
73   // add verbose level
74   //G4cout << "TG4GeometryManager has been created." << endl;
75   
76   // create sensitive detectors manager
77   fSDManager = new TG4SDManager(configuration->GetSDConstruction());
78   // add verbose level
79   //G4cout << "TG4SDManager has been created." << endl;
80   
81   // create physics manager  
82   fPhysicsManager = new TG4PhysicsManager(configuration->GetPhysicsList());
83   // add verbose level
84   //G4cout << "TG4GeometryManager has been created." << endl;
85   
86   // create step manager 
87   fStepManager = new TG4StepManager();
88   // add verbose level
89   //G4cout << "TG4StepManager has been created." << endl;
90   
91 #ifdef G4VIS_USE
92   // create visualization manager
93   fVisManager = new TG4VisManager();
94   fVisManager->Initialize();
95 #endif
96 }
97     
98 //_____________________________________________________________________________
99 TGeant4::TGeant4() {
100 //
101 }
102
103 //_____________________________________________________________________________
104 TGeant4::TGeant4(const TGeant4& right) {
105 // 
106   TG4Globals::Exception("TGeant4 is protected from copying.");
107 }
108
109 //_____________________________________________________________________________
110 TGeant4::~TGeant4() {
111 //
112   delete fRunManager;
113   delete fGeometryManager;
114   delete fSDManager;
115   delete fPhysicsManager;
116   delete fStepManager;
117   // fVisManager is deleted with G4RunManager destructor
118 }
119
120 // operators
121
122 //_____________________________________________________________________________
123 TGeant4& TGeant4::operator=(const TGeant4& right)
124 {
125   // check assignement to self
126   if (this == &right) return *this;
127
128   TG4Globals::Exception("TGeant4 is protected from assigning.");
129     
130   return *this;  
131 }    
132           
133
134 // methods for building/management of geometry
135 // ------------------------------------------------
136
137 //_____________________________________________________________________________
138 void TGeant4::FinishGeometry() {
139 //
140   fGeometryManager->Ggclos();
141
142
143 //_____________________________________________________________________________
144 void TGeant4::Gfmate(Int_t imat, char *name, Float_t &a, Float_t &z,  
145                          Float_t &dens, Float_t &radl, Float_t &absl,
146                          Float_t* ubuf, Int_t& nbuf) {
147 //
148   fGeometryManager
149     ->Gfmate(imat, name, a, z, dens, radl, absl, ubuf, nbuf);
150
151
152 //_____________________________________________________________________________
153 void TGeant4::Material(Int_t& kmat, const char* name, Float_t a, 
154                      Float_t z, Float_t dens, Float_t radl, Float_t absl,
155                      Float_t* buf, Int_t nwbuf) {
156 //
157   fGeometryManager
158     ->Material(kmat, name, a, z, dens, radl, absl, buf, nwbuf); 
159
160
161 //_____________________________________________________________________________
162 void TGeant4::Mixture(Int_t& kmat, const char *name, Float_t *a, 
163                      Float_t *z, Float_t dens, Int_t nlmat, Float_t *wmat) {
164 //
165    fGeometryManager
166      ->Mixture(kmat, name, a, z, dens, nlmat, wmat); 
167
168
169 //_____________________________________________________________________________
170 void TGeant4::Medium(Int_t& kmed, const char *name, Int_t nmat, 
171                      Int_t isvol, Int_t ifield, Float_t fieldm, Float_t tmaxfd, 
172                      Float_t stemax, Float_t deemax, Float_t epsil, 
173                      Float_t stmin, Float_t* ubuf, Int_t nbuf) { 
174 //
175   fGeometryManager
176     ->Medium(kmed, name, nmat, isvol, ifield, fieldm, tmaxfd, stemax, deemax, 
177         epsil, stmin, ubuf, nbuf);
178
179
180 //_____________________________________________________________________________
181 void TGeant4::Matrix(Int_t& krot, Double_t thetaX, Double_t phiX, 
182                      Double_t thetaY, Double_t phiY, Double_t thetaZ, 
183                      Double_t phiZ) {
184 //                   
185   fGeometryManager
186     ->Matrix(krot, thetaX, phiX, thetaY, phiY, thetaZ, phiZ); 
187
188
189 //_____________________________________________________________________________
190 void TGeant4::Matrix(Int_t& krot, Float_t thetaX, Float_t phiX, 
191                      Float_t thetaY, Float_t phiY, Float_t thetaZ, 
192                      Float_t phiZ) {
193 //                   
194   fGeometryManager
195     ->Matrix(krot, thetaX, phiX, thetaY, phiY, thetaZ, phiZ); 
196
197
198 //_____________________________________________________________________________
199 Int_t TGeant4::Gsvolu(const char *name, const char *shape, Int_t nmed,  
200                          Double_t *upar, Int_t np)  {
201 //
202   return fGeometryManager->Gsvolu(name, shape, nmed, upar, np); 
203 }
204  
205 //_____________________________________________________________________________
206 Int_t TGeant4::Gsvolu(const char *name, const char *shape, Int_t nmed,  
207                          Float_t *upar, Int_t np)  {
208 //
209   return fGeometryManager->Gsvolu(name, shape, nmed, upar, np); 
210 }
211  
212 //_____________________________________________________________________________
213 void TGeant4::Gsdvn(const char *name, const char *mother, Int_t ndiv, 
214                         Int_t iaxis) {
215 //
216   fGeometryManager->Gsdvn(name, mother, ndiv, iaxis); 
217
218
219 //_____________________________________________________________________________
220 void TGeant4::Gsdvn2(const char *name, const char *mother, Int_t ndiv, 
221                          Int_t iaxis, Double_t c0i, Int_t numed) {
222 //
223   fGeometryManager->Gsdvn2(name, mother, ndiv, iaxis, c0i, numed); 
224
225
226 //_____________________________________________________________________________
227 void TGeant4::Gsdvn2(const char *name, const char *mother, Int_t ndiv, 
228                          Int_t iaxis, Float_t c0i, Int_t numed) {
229 //
230   fGeometryManager->Gsdvn2(name, mother, ndiv, iaxis, c0i, numed); 
231
232
233 //_____________________________________________________________________________
234 void TGeant4::Gsdvt(const char *name, const char *mother, Double_t step, 
235                         Int_t iaxis, Int_t numed, Int_t ndvmx) {
236 //                      
237   fGeometryManager->Gsdvt(name, mother, step, iaxis, numed, ndvmx); 
238
239
240 //_____________________________________________________________________________
241 void TGeant4::Gsdvt(const char *name, const char *mother, Float_t step, 
242                         Int_t iaxis, Int_t numed, Int_t ndvmx) {
243 //                      
244   fGeometryManager->Gsdvt(name, mother, step, iaxis, numed, ndvmx); 
245
246
247 //_____________________________________________________________________________
248 void TGeant4::Gsdvt2(const char *name, const char *mother, Double_t step, 
249                          Int_t iaxis, Double_t c0, Int_t numed, Int_t ndvmx) { 
250 //
251   fGeometryManager->Gsdvt2(name, mother, step, iaxis, c0, numed, ndvmx); 
252
253
254 //_____________________________________________________________________________
255 void TGeant4::Gsdvt2(const char *name, const char *mother, Float_t step, 
256                          Int_t iaxis, Float_t c0, Int_t numed, Int_t ndvmx) { 
257 //
258   fGeometryManager->Gsdvt2(name, mother, step, iaxis, c0, numed, ndvmx); 
259
260
261 //_____________________________________________________________________________
262 void TGeant4::Gsord(const char *name, Int_t iax) {
263 //
264   fGeometryManager->Gsord(name, iax); 
265
266
267 //_____________________________________________________________________________
268 void TGeant4::Gspos(const char *name, Int_t nr, const char *mother,  
269                         Double_t x, Double_t y, Double_t z, Int_t irot, 
270                         const char *konly) {
271 //
272   fGeometryManager->Gspos(name, nr, mother, x, y, z, irot, konly); 
273
274
275 //_____________________________________________________________________________
276 void TGeant4::Gspos(const char *name, Int_t nr, const char *mother,  
277                         Float_t x, Float_t y, Float_t z, Int_t irot, 
278                         const char *konly) {
279 //
280   fGeometryManager->Gspos(name, nr, mother, x, y, z, irot, konly); 
281
282
283 //_____________________________________________________________________________
284 void TGeant4::Gsposp(const char *name, Int_t nr, const char *mother,  
285                          Double_t x, Double_t y, Double_t z, Int_t irot,
286                          const char *konly, Double_t *upar, Int_t np)  {
287 //
288   fGeometryManager->Gsposp(name, nr, mother, x, y, z, irot, konly, upar, np); 
289
290
291 //_____________________________________________________________________________
292 void TGeant4::Gsposp(const char *name, Int_t nr, const char *mother,  
293                          Float_t x, Float_t y, Float_t z, Int_t irot,
294                          const char *konly, Float_t *upar, Int_t np)  {
295 //
296   fGeometryManager->Gsposp(name, nr, mother, x, y, z, irot, konly, upar, np); 
297
298
299 //_____________________________________________________________________________
300 void TGeant4::Gsbool(const char* onlyVolName, const char* manyVolName) {
301 //
302   fGeometryManager->Gsbool(onlyVolName, manyVolName); 
303
304
305 //_____________________________________________________________________________
306 void TGeant4::SetCerenkov(Int_t itmed, Int_t npckov, Float_t *ppckov,
307                   Float_t *absco, Float_t *effic, Float_t *rindex) {
308 //
309   fGeometryManager->SetCerenkov(itmed, npckov, ppckov, absco, effic, rindex);
310 }  
311     
312 //_____________________________________________________________________________
313 void TGeant4::WriteEuclid(const char* fileName, const char* topVol, 
314                           Int_t number, Int_t nlevel) {
315 //
316   fGeometryManager->WriteEuclid(fileName, topVol, number, nlevel); 
317
318                                
319 //_____________________________________________________________________________
320 Int_t TGeant4::VolId(const Text_t* volName) const {
321 //
322   return fSDManager->VolId(volName); 
323
324
325 //_____________________________________________________________________________
326 const char* TGeant4::VolName(Int_t id) const {
327 //
328   return fSDManager->VolName(id); 
329 }
330  
331 //_____________________________________________________________________________
332 Int_t TGeant4::NofVolumes() const {
333 //
334   return fSDManager->NofVolumes(); 
335
336
337 //_____________________________________________________________________________
338 Int_t TGeant4::VolId2Mate(Int_t id) const {
339 //
340   return fSDManager->VolId2Mate(id); 
341
342
343
344
345 // methods for physics management
346 // ------------------------------------------------
347  
348 //_____________________________________________________________________________
349 void TGeant4::Gstpar(Int_t itmed, const char *param, Float_t parval) {
350 //
351   fGeometryManager->Gstpar(itmed, param, parval); 
352   fPhysicsManager->Gstpar(itmed, param, parval); 
353 }    
354
355 //_____________________________________________________________________________
356 void TGeant4::SetCut(const char* cutName, Float_t cutValue) { 
357 //
358   fPhysicsManager->SetCut(cutName, cutValue);
359 }  
360
361 //_____________________________________________________________________________
362 void TGeant4::SetProcess(const char* flagName, Int_t flagValue) {
363 //
364   fPhysicsManager->SetProcess(flagName, flagValue);
365 }  
366  
367 //_____________________________________________________________________________
368 Float_t TGeant4::Xsec(char* reac, Float_t energy, Int_t part, Int_t mate) {
369 //
370   return fPhysicsManager->Xsec(reac, energy, part, mate);
371 }  
372
373 //_____________________________________________________________________________
374 void TGeant4::SetExternalDecayer(AliDecayer* decayer) {
375 //
376   fPhysicsManager->SetExternalDecayer(decayer);
377 }
378
379 //_____________________________________________________________________________
380 AliDecayer* TGeant4::Decayer() const {
381 //
382   return fPhysicsManager->Decayer(); 
383 }
384   
385
386 //_____________________________________________________________________________
387 Int_t TGeant4::IdFromPDG(Int_t pdgID) const { 
388 //
389   return fPhysicsManager->IdFromPDG(pdgID);
390 }  
391
392 //_____________________________________________________________________________
393 Int_t TGeant4::PDGFromId(Int_t mcID) const {
394 //
395   return fPhysicsManager->PDGFromId(mcID);
396 }  
397
398 //_____________________________________________________________________________
399 void TGeant4::DefineParticles() { 
400 //
401   fPhysicsManager->DefineParticles();
402 }  
403
404 // methods for step management
405 // ------------------------------------------------
406 // inlined (in TGeant4.icc)
407
408 // methods for visualization
409 // ------------------------------------------------
410
411 #ifdef G4VIS_USE
412 //_____________________________________________________________________________
413 void TGeant4::DrawOneSpec(const char* name) {
414 //
415   fVisManager->DrawOneSpec(name); 
416
417
418 //_____________________________________________________________________________
419 void TGeant4::Gsatt(const char* name, const char* att, Int_t val) {
420 //
421   fVisManager->Gsatt(name, att, val); 
422
423
424 //_____________________________________________________________________________
425 void TGeant4::Gdraw(const char* name, Float_t theta, Float_t phi,
426                         Float_t psi, Float_t u0, Float_t v0,
427                         Float_t ul, Float_t vl) {
428 //
429   fVisManager->Gdraw(name, theta, phi, psi, u0, v0, ul, vl); 
430
431
432 #else
433 //_____________________________________________________________________________
434 void TGeant4::DrawOneSpec(const char* name) {
435 //
436   TG4Globals:: Warning("TGeant4::DrawOneSpec(): no visualization available."); 
437
438
439 //_____________________________________________________________________________
440 void TGeant4::Gsatt(const char* name, const char* att, Int_t val) {
441 //
442   TG4Globals:: Warning("TGeant4::Gsatt(): no visualization available."); 
443
444
445 //_____________________________________________________________________________
446 void TGeant4::Gdraw(const char* p1, Float_t theta, Float_t phi,
447                         Float_t psi, Float_t u0, Float_t v0,
448                         Float_t ul, Float_t vl) {
449 //
450   TG4Globals:: Warning("TGeant4::Gdraw(): no visualization available."); 
451
452
453 #endif //G4VIS_USE
454
455 // methods for run control
456 // ------------------------------------------------
457
458 //_____________________________________________________________________________
459 void TGeant4::Init() { 
460 //
461   fRunManager->Initialize();
462 }  
463   
464 //_____________________________________________________________________________
465 void TGeant4::BuildPhysics() {
466 //
467   fRunManager->LateInitialize();
468 }  
469
470 //_____________________________________________________________________________
471 void TGeant4::ProcessEvent() { 
472 //
473   fRunManager->ProcessEvent();
474 }  
475
476 //_____________________________________________________________________________
477 void TGeant4::ProcessRun(Int_t nofEvents) {
478 //
479   fRunManager->ProcessRun(nofEvents);
480 }  
481
482 //_____________________________________________________________________________
483 void TGeant4::StartGeantUI() {
484 //
485   fRunManager->StartGeantUI();
486 }  
487
488 //_____________________________________________________________________________
489 void TGeant4::StartRootUI() {
490 //
491   fRunManager->StartRootUI();
492 }  
493
494 //_____________________________________________________________________________
495 void TGeant4::ProcessGeantMacro(const char* macroName) {
496 //
497   fRunManager->ProcessGeantMacro(macroName);
498 }  
499   
500 //_____________________________________________________________________________
501 void TGeant4::ProcessGeantCommand(const char* command) {
502 //
503   fRunManager->ProcessGeantCommand(command);
504 }  
505   
506 //_____________________________________________________________________________
507 Int_t TGeant4::CurrentEvent() const {
508 //
509   return fRunManager->CurrentEvent(); 
510
511
512 // Geant3 specific methods
513 // !!! need to be transformed to common interface
514 // ------------------------------------------------
515     
516 //_____________________________________________________________________________
517 void TGeant4::Gdopt(const char* name, const char* value) {
518 //
519   TG4Globals:: Warning("TGeant4::Gdopt(..) is not implemented."); 
520 }
521
522 //_____________________________________________________________________________
523 void TGeant4::SetClipBox(const char *name, Float_t xmin, Float_t xmax,
524                      Float_t ymin, Float_t ymax, Float_t zmin, Float_t zmax) { 
525 //
526   TG4Globals:: Warning("TGeant4::SetClipBox(..) is not implemented."); 
527 }
528
529 //_____________________________________________________________________________
530 void TGeant4::DefaultRange() { 
531 //
532   TG4Globals:: Warning("TGeant4::DefaultRange() is not implemented."); 
533 }
534
535 //_____________________________________________________________________________
536 void TGeant4::Gdhead(Int_t isel, const char* name, Float_t chrsiz) { 
537 //
538   TG4Globals:: Warning("TGeant4::Gdhead(..) is not implemented."); 
539 }
540
541 //_____________________________________________________________________________
542 void TGeant4::Gdman(Float_t u, Float_t v, const char* type) { 
543 //
544   TG4Globals:: Warning("TGeant4::Gdman(..) is not implemented."); 
545 }
546
547 //_____________________________________________________________________________
548 void TGeant4::SetColors() { 
549 //
550   TG4Globals:: Warning("TGeant4::SetColours() is not implemented."); 
551 }
552
553 //_____________________________________________________________________________
554 void TGeant4::Gtreve() { 
555 //
556   TG4Globals:: Warning("TGeant4::Gtreve() is not implemented."); 
557 }
558
559 //_____________________________________________________________________________
560 void TGeant4::GtreveRoot() { 
561 //
562   TG4Globals:: Warning("TGeant4::GtreveRoot() is not implemented."); 
563 }
564
565 //_____________________________________________________________________________
566 void TGeant4::Gckmat(Int_t itmed, char* natmed) { 
567 //
568   TG4Globals:: Warning("TGeant4::Gckmat(..) is not implemented."); 
569 }
570
571 //_____________________________________________________________________________
572 void TGeant4::InitLego() { 
573 //
574   TG4Globals:: Warning("TGeant4::InitLego() is not implemented."); 
575 }
576
577 //_____________________________________________________________________________
578 void TGeant4::Gfpart(Int_t ipart, char *name, Int_t& itrtyp,  
579                      Float_t& amass, Float_t& charge, Float_t& tlife) { 
580 //
581   TG4Globals:: Warning("TGeant4::Gfpart(..) is not implemented."); 
582 }
583
584 //_____________________________________________________________________________
585 void TGeant4::Gspart(Int_t ipart, const char *name, Int_t itrtyp,  
586                      Float_t amass, Float_t charge, Float_t tlife) {  
587 //
588   TG4Globals:: Warning("TGeant4::Gspart(..) is not implemented."); 
589 }