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