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