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