Codes for processes, callers and particles used in FLUKA/TFluka.
[u/mrichter/AliRoot.git] / TFluka / TFluka.cxx
CommitLineData
829fb838 1/**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3 * *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
6 * *
7 * Permission to use, copy, modify and distribute this software and its *
8 * documentation strictly for non-commercial purposes is hereby granted *
9 * without fee, provided that the above copyright notice appears in all *
10 * copies and that both the copyright notice and this permission notice *
11 * appear in the supporting documentation. The authors make no claims *
12 * about the suitability of this software for any purpose. It is *
13 * provided "as is" without express or implied warranty. *
14 **************************************************************************/
15
16/* $Id$ */
17
18//
19// Realisation of the TVirtualMC interface for the FLUKA code
20// (See official web side http://www.fluka.org/).
21//
22// This implementation makes use of the TGeo geometry modeller.
23// User configuration is via automatic generation of FLUKA input cards.
24//
25// Authors:
26// A. Fasso
27// E. Futo
28// A. Gheata
29// A. Morsch
30//
31
32#include <Riostream.h>
33
829fb838 34#include "TFluka.h"
35#include "TCallf77.h" //For the fortran calls
36#include "Fdblprc.h" //(DBLPRC) fluka common
81f1d030 37#include "Fsourcm.h" //(SOURCM) fluka common
38#include "Fgenstk.h" //(GENSTK) fluka common
829fb838 39#include "Fiounit.h" //(IOUNIT) fluka common
40#include "Fpaprop.h" //(PAPROP) fluka common
41#include "Fpart.h" //(PART) fluka common
42#include "Ftrackr.h" //(TRACKR) fluka common
43#include "Fpaprop.h" //(PAPROP) fluka common
44#include "Ffheavy.h" //(FHEAVY) fluka common
3a625972 45#include "Fopphst.h" //(OPPHST) fluka common
81f1d030 46#include "Fflkstk.h" //(FLKSTK) fluka common
07f5b33e 47#include "Fstepsz.h" //(STEPSZ) fluka common
7b203b6e 48#include "Fopphst.h" //(OPPHST) fluka common
829fb838 49
50#include "TVirtualMC.h"
3a625972 51#include "TMCProcess.h"
829fb838 52#include "TGeoManager.h"
53#include "TGeoMaterial.h"
54#include "TGeoMedium.h"
55#include "TFlukaMCGeometry.h"
6f5667d1 56#include "TGeoMCGeometry.h"
829fb838 57#include "TFlukaCerenkov.h"
1df5fa54 58#include "TFlukaConfigOption.h"
b496f27c 59#include "TFlukaScoringOption.h"
829fb838 60#include "TLorentzVector.h"
b496f27c 61#include "TArrayI.h"
829fb838 62
63// Fluka methods that may be needed.
64#ifndef WIN32
65# define flukam flukam_
66# define fluka_openinp fluka_openinp_
8e5bf079 67# define fluka_openout fluka_openout_
829fb838 68# define fluka_closeinp fluka_closeinp_
69# define mcihad mcihad_
70# define mpdgha mpdgha_
eea53470 71# define newplo newplo_
829fb838 72#else
73# define flukam FLUKAM
74# define fluka_openinp FLUKA_OPENINP
8e5bf079 75# define fluka_openout FLUKA_OPENOUT
829fb838 76# define fluka_closeinp FLUKA_CLOSEINP
77# define mcihad MCIHAD
78# define mpdgha MPDGHA
eea53470 79# define newplo NEWPLO
829fb838 80#endif
81
82extern "C"
83{
84 //
85 // Prototypes for FLUKA functions
86 //
87 void type_of_call flukam(const int&);
eea53470 88 void type_of_call newplo();
829fb838 89 void type_of_call fluka_openinp(const int&, DEFCHARA);
8e5bf079 90 void type_of_call fluka_openout(const int&, DEFCHARA);
829fb838 91 void type_of_call fluka_closeinp(const int&);
92 int type_of_call mcihad(const int&);
93 int type_of_call mpdgha(const int&);
94}
95
96//
97// Class implementation for ROOT
98//
99ClassImp(TFluka)
100
101//
102//----------------------------------------------------------------------------
103// TFluka constructors and destructors.
104//______________________________________________________________________________
105TFluka::TFluka()
106 :TVirtualMC(),
107 fVerbosityLevel(0),
1df5fa54 108 fInputFileName(""),
fb2cbbec 109 fUserConfig(0),
1df5fa54 110 fUserScore(0)
829fb838 111{
112 //
113 // Default constructor
114 //
115 fGeneratePemf = kFALSE;
116 fNVolumes = 0;
117 fCurrentFlukaRegion = -1;
118 fGeom = 0;
119 fMCGeo = 0;
120 fMaterials = 0;
121 fDummyBoundary = 0;
122 fFieldFlag = 1;
bd3d5c8a 123 fStopped = 0;
b496f27c 124 fStopEvent = 0;
125 fStopRun = 0;
126 fNEvent = 0;
829fb838 127}
128
129//______________________________________________________________________________
130TFluka::TFluka(const char *title, Int_t verbosity, Bool_t isRootGeometrySupported)
131 :TVirtualMC("TFluka",title, isRootGeometrySupported),
132 fVerbosityLevel(verbosity),
133 fInputFileName(""),
134 fTrackIsEntering(0),
135 fTrackIsExiting(0),
1df5fa54 136 fTrackIsNew(0),
fb2cbbec 137 fUserConfig(new TObjArray(100)),
1df5fa54 138 fUserScore(new TObjArray(100))
829fb838 139{
140 // create geometry interface
7f13be31 141 if (fVerbosityLevel >=3)
142 cout << "<== TFluka::TFluka(" << title << ") constructor called." << endl;
143 SetCoreInputFileName();
144 SetInputFileName();
145 SetGeneratePemf(kFALSE);
829fb838 146 fNVolumes = 0;
147 fCurrentFlukaRegion = -1;
148 fDummyBoundary = 0;
149 fFieldFlag = 1;
150 fGeneratePemf = kFALSE;
151 fMCGeo = new TGeoMCGeometry("MCGeo", "TGeo Implementation of VirtualMCGeometry", kTRUE);
fb2cbbec 152 fGeom = new TFlukaMCGeometry("geom", "FLUKA VMC Geometry");
829fb838 153 if (verbosity > 2) fGeom->SetDebugMode(kTRUE);
154 fMaterials = 0;
bd3d5c8a 155 fStopped = 0;
b496f27c 156 fStopEvent = 0;
157 fStopRun = 0;
158 fNEvent = 0;
8e5bf079 159 PrintHeader();
829fb838 160}
161
162//______________________________________________________________________________
163TFluka::~TFluka() {
164// Destructor
1df5fa54 165 if (fVerbosityLevel >=3)
166 cout << "<== TFluka::~TFluka() destructor called." << endl;
167
168 delete fGeom;
169 delete fMCGeo;
170
fb2cbbec 171 if (fUserConfig) {
172 fUserConfig->Delete();
173 delete fUserConfig;
1df5fa54 174 }
6d184c54 175
176 if (fUserScore) {
177 fUserScore->Delete();
178 delete fUserScore;
179 }
829fb838 180}
181
182//
183//______________________________________________________________________________
184// TFluka control methods
185//______________________________________________________________________________
186void TFluka::Init() {
187//
188// Geometry initialisation
189//
190 if (fVerbosityLevel >=3) cout << "==> TFluka::Init() called." << endl;
191
192 if (!gGeoManager) new TGeoManager("geom", "FLUKA geometry");
193 fApplication->ConstructGeometry();
d59acfe7 194 if (!gGeoManager->IsClosed()) {
195 TGeoVolume *top = (TGeoVolume*)gGeoManager->GetListOfVolumes()->First();
196 gGeoManager->SetTopVolume(top);
197 gGeoManager->CloseGeometry("di");
198 } else {
199 TGeoNodeCache *cache = gGeoManager->GetCache();
200 if (!cache->HasIdArray()) {
201 printf("Node ID tracking must be enabled with TFluka: enabling...\n");
202 cache->BuildIdArray();
203 }
204 }
829fb838 205 fNVolumes = fGeom->NofVolumes();
206 fGeom->CreateFlukaMatFile("flukaMat.inp");
207 if (fVerbosityLevel >=3) {
208 printf("== Number of volumes: %i\n ==", fNVolumes);
209 cout << "\t* InitPhysics() - Prepare input file to be called" << endl;
6d184c54 210 }
881cb248 211
212 fApplication->InitGeometry();
213
829fb838 214}
215
216
217//______________________________________________________________________________
218void TFluka::FinishGeometry() {
219//
220// Build-up table with region to medium correspondance
221//
222 if (fVerbosityLevel >=3) {
223 cout << "==> TFluka::FinishGeometry() called." << endl;
224 printf("----FinishGeometry - nothing to do with TGeo\n");
225 cout << "<== TFluka::FinishGeometry() called." << endl;
226 }
227}
228
229//______________________________________________________________________________
230void TFluka::BuildPhysics() {
231//
232// Prepare FLUKA input files and call FLUKA physics initialisation
233//
234
235 if (fVerbosityLevel >=3)
236 cout << "==> TFluka::BuildPhysics() called." << endl;
6d184c54 237
238
239 if (fVerbosityLevel >=3) {
240 TList *medlist = gGeoManager->GetListOfMedia();
241 TIter next(medlist);
242 TGeoMedium* med = 0x0;
243 TGeoMaterial* mat = 0x0;
244 Int_t ic = 0;
245
246 while((med = (TGeoMedium*)next()))
247 {
248 mat = med->GetMaterial();
249 printf("Medium %5d %12s %5d %5d\n", ic, (med->GetName()), med->GetId(), mat->GetIndex());
250 ic++;
251 }
252 }
253
254 //
255 // At this stage we have the information on materials and cuts available.
256 // Now create the pemf file
257
258 if (fGeneratePemf) fGeom->CreatePemfFile();
259
260 //
261 // Prepare input file with the current physics settings
262
829fb838 263 InitPhysics();
6d184c54 264
829fb838 265 cout << "\t* InitPhysics() - Prepare input file was called" << endl;
266
267 if (fVerbosityLevel >=2)
268 cout << "\t* Changing lfdrtr = (" << (GLOBAL.lfdrtr?'T':'F')
269 << ") in fluka..." << endl;
270 GLOBAL.lfdrtr = true;
271
272 if (fVerbosityLevel >=2)
273 cout << "\t* Opening file " << fInputFileName << endl;
274 const char* fname = fInputFileName;
6d184c54 275
829fb838 276 fluka_openinp(lunin, PASSCHARA(fname));
8e5bf079 277 fluka_openout(11, PASSCHARA("fluka.out"));
829fb838 278
279 if (fVerbosityLevel >=2)
280 cout << "\t* Calling flukam..." << endl;
281 flukam(1);
282
283 if (fVerbosityLevel >=2)
284 cout << "\t* Closing file " << fInputFileName << endl;
285 fluka_closeinp(lunin);
286
287 FinishGeometry();
288
289 if (fVerbosityLevel >=3)
290 cout << "<== TFluka::Init() called." << endl;
291
829fb838 292 if (fVerbosityLevel >=3)
293 cout << "<== TFluka::BuildPhysics() called." << endl;
294}
295
296//______________________________________________________________________________
297void TFluka::ProcessEvent() {
298//
299// Process one event
300//
b496f27c 301 if (fStopRun) {
302 printf("User Run Abortion: No more events handled !\n");
303 fNEvent += 1;
304 return;
305 }
306
307 if (fVerbosityLevel >=3)
308 cout << "==> TFluka::ProcessEvent() called." << endl;
309 fApplication->GeneratePrimaries();
81f1d030 310 SOURCM.lsouit = true;
b496f27c 311 flukam(1);
312 if (fVerbosityLevel >=3)
313 cout << "<== TFluka::ProcessEvent() called." << endl;
314 //
315 // Increase event number
316 //
317 fNEvent += 1;
829fb838 318}
319
320//______________________________________________________________________________
321Bool_t TFluka::ProcessRun(Int_t nevent) {
322//
323// Run steering
324//
325
326 if (fVerbosityLevel >=3)
327 cout << "==> TFluka::ProcessRun(" << nevent << ") called."
328 << endl;
329
330 if (fVerbosityLevel >=2) {
331 cout << "\t* GLOBAL.fdrtr = " << (GLOBAL.lfdrtr?'T':'F') << endl;
332 cout << "\t* Calling flukam again..." << endl;
333 }
334
829fb838 335 Int_t todo = TMath::Abs(nevent);
336 for (Int_t ev = 0; ev < todo; ev++) {
337 fApplication->BeginEvent();
338 ProcessEvent();
339 fApplication->FinishEvent();
340 }
341
342 if (fVerbosityLevel >=3)
343 cout << "<== TFluka::ProcessRun(" << nevent << ") called."
344 << endl;
eea53470 345 // Write fluka specific scoring output
346 newplo();
347
829fb838 348 return kTRUE;
349}
350
351//_____________________________________________________________________________
352// methods for building/management of geometry
353
354// functions from GCONS
355//____________________________________________________________________________
356void TFluka::Gfmate(Int_t imat, char *name, Float_t &a, Float_t &z,
357 Float_t &dens, Float_t &radl, Float_t &absl,
358 Float_t* /*ubuf*/, Int_t& /*nbuf*/) {
359//
360 TGeoMaterial *mat;
361 TIter next (gGeoManager->GetListOfMaterials());
362 while ((mat = (TGeoMaterial*)next())) {
363 if (mat->GetUniqueID() == (UInt_t)imat) break;
364 }
365 if (!mat) {
366 Error("Gfmate", "no material with index %i found", imat);
367 return;
368 }
369 sprintf(name, "%s", mat->GetName());
370 a = mat->GetA();
371 z = mat->GetZ();
372 dens = mat->GetDensity();
373 radl = mat->GetRadLen();
374 absl = mat->GetIntLen();
375}
376
377//______________________________________________________________________________
378void TFluka::Gfmate(Int_t imat, char *name, Double_t &a, Double_t &z,
379 Double_t &dens, Double_t &radl, Double_t &absl,
380 Double_t* /*ubuf*/, Int_t& /*nbuf*/) {
381//
382 TGeoMaterial *mat;
383 TIter next (gGeoManager->GetListOfMaterials());
384 while ((mat = (TGeoMaterial*)next())) {
385 if (mat->GetUniqueID() == (UInt_t)imat) break;
386 }
387 if (!mat) {
388 Error("Gfmate", "no material with index %i found", imat);
389 return;
390 }
391 sprintf(name, "%s", mat->GetName());
392 a = mat->GetA();
393 z = mat->GetZ();
394 dens = mat->GetDensity();
395 radl = mat->GetRadLen();
396 absl = mat->GetIntLen();
397}
398
399// detector composition
400//______________________________________________________________________________
401void TFluka::Material(Int_t& kmat, const char* name, Double_t a,
402 Double_t z, Double_t dens, Double_t radl, Double_t absl,
403 Float_t* buf, Int_t nwbuf) {
404//
405 Double_t* dbuf = fGeom->CreateDoubleArray(buf, nwbuf);
406 Material(kmat, name, a, z, dens, radl, absl, dbuf, nwbuf);
407 delete [] dbuf;
408}
409
410//______________________________________________________________________________
411void TFluka::Material(Int_t& kmat, const char* name, Double_t a,
412 Double_t z, Double_t dens, Double_t radl, Double_t absl,
413 Double_t* /*buf*/, Int_t /*nwbuf*/) {
414//
fb2cbbec 415// Define a material
829fb838 416 TGeoMaterial *mat;
417 kmat = gGeoManager->GetListOfMaterials()->GetSize();
418 if ((z-Int_t(z)) > 1E-3) {
419 mat = fGeom->GetMakeWrongMaterial(z);
420 if (mat) {
421 mat->SetRadLen(radl,absl);
422 mat->SetUniqueID(kmat);
423 return;
424 }
425 }
426 gGeoManager->Material(name, a, z, dens, kmat, radl, absl);
427}
428
429//______________________________________________________________________________
430void TFluka::Mixture(Int_t& kmat, const char *name, Float_t *a,
431 Float_t *z, Double_t dens, Int_t nlmat, Float_t *wmat) {
432//
fb2cbbec 433// Define a material mixture
434//
829fb838 435 Double_t* da = fGeom->CreateDoubleArray(a, TMath::Abs(nlmat));
436 Double_t* dz = fGeom->CreateDoubleArray(z, TMath::Abs(nlmat));
437 Double_t* dwmat = fGeom->CreateDoubleArray(wmat, TMath::Abs(nlmat));
438
439 Mixture(kmat, name, da, dz, dens, nlmat, dwmat);
440 for (Int_t i=0; i<nlmat; i++) {
441 a[i] = da[i]; z[i] = dz[i]; wmat[i] = dwmat[i];
442 }
443
444 delete [] da;
445 delete [] dz;
446 delete [] dwmat;
447}
448
449//______________________________________________________________________________
450void TFluka::Mixture(Int_t& kmat, const char *name, Double_t *a,
451 Double_t *z, Double_t dens, Int_t nlmat, Double_t *wmat) {
452//
453 // Defines mixture OR COMPOUND IMAT as composed by
454 // THE BASIC NLMAT materials defined by arrays A,Z and WMAT
455 //
456 // If NLMAT > 0 then wmat contains the proportion by
457 // weights of each basic material in the mixture.
458 //
459 // If nlmat < 0 then WMAT contains the number of atoms
460 // of a given kind into the molecule of the COMPOUND
461 // In this case, WMAT in output is changed to relative
462 // weigths.
463 //
464 Int_t i,j;
465 if (nlmat < 0) {
466 nlmat = - nlmat;
467 Double_t amol = 0;
468 for (i=0;i<nlmat;i++) {
469 amol += a[i]*wmat[i];
470 }
471 for (i=0;i<nlmat;i++) {
472 wmat[i] *= a[i]/amol;
473 }
474 }
475 kmat = gGeoManager->GetListOfMaterials()->GetSize();
476 // Check if we have elements with fractional Z
477 TGeoMaterial *mat = 0;
478 TGeoMixture *mix = 0;
479 Bool_t mixnew = kFALSE;
480 for (i=0; i<nlmat; i++) {
481 if (z[i]-Int_t(z[i]) < 1E-3) continue;
482 // We have found an element with fractional Z -> loop mixtures to look for it
483 for (j=0; j<kmat; j++) {
484 mat = (TGeoMaterial*)gGeoManager->GetListOfMaterials()->At(j);
485 if (!mat) break;
486 if (!mat->IsMixture()) continue;
487 mix = (TGeoMixture*)mat;
488 if (TMath::Abs(z[i]-mix->GetZ()) >1E-3) continue;
489// printf(" FOUND component %i as mixture %s\n", i, mat->GetName());
490 mixnew = kTRUE;
491 break;
492 }
493 if (!mixnew) Warning("Mixture","%s : cannot find component %i with fractional Z=%f\n", name, i, z[i]);
494 break;
495 }
496 if (mixnew) {
497 Int_t nlmatnew = nlmat+mix->GetNelements()-1;
498 Double_t *anew = new Double_t[nlmatnew];
499 Double_t *znew = new Double_t[nlmatnew];
500 Double_t *wmatnew = new Double_t[nlmatnew];
501 Int_t ind=0;
502 for (j=0; j<nlmat; j++) {
503 if (j==i) continue;
504 anew[ind] = a[j];
505 znew[ind] = z[j];
506 wmatnew[ind] = wmat[j];
507 ind++;
508 }
509 for (j=0; j<mix->GetNelements(); j++) {
510 anew[ind] = mix->GetAmixt()[j];
511 znew[ind] = mix->GetZmixt()[j];
512 wmatnew[ind] = wmat[i]*mix->GetWmixt()[j];
513 ind++;
514 }
515 Mixture(kmat, name, anew, znew, dens, nlmatnew, wmatnew);
516 delete [] anew;
517 delete [] znew;
518 delete [] wmatnew;
519 return;
520 }
521 // Now we need to compact identical elements within the mixture
522 // First check if this happens
523 mixnew = kFALSE;
524 for (i=0; i<nlmat-1; i++) {
525 for (j=i+1; j<nlmat; j++) {
526 if (z[i] == z[j]) {
527 mixnew = kTRUE;
528 break;
529 }
530 }
531 if (mixnew) break;
532 }
533 if (mixnew) {
534 Int_t nlmatnew = 0;
535 Double_t *anew = new Double_t[nlmat];
536 Double_t *znew = new Double_t[nlmat];
537 memset(znew, 0, nlmat*sizeof(Double_t));
538 Double_t *wmatnew = new Double_t[nlmat];
539 Bool_t skipi;
540 for (i=0; i<nlmat; i++) {
541 skipi = kFALSE;
542 for (j=0; j<nlmatnew; j++) {
543 if (z[i] == z[j]) {
544 wmatnew[j] += wmat[i];
545 skipi = kTRUE;
546 break;
547 }
548 }
549 if (skipi) continue;
550 anew[nlmatnew] = a[i];
551 znew[nlmatnew] = z[i];
552 wmatnew[nlmatnew] = wmat[i];
553 nlmatnew++;
554 }
555 Mixture(kmat, name, anew, znew, dens, nlmatnew, wmatnew);
556 delete [] anew;
557 delete [] znew;
558 delete [] wmatnew;
559 return;
560 }
561 gGeoManager->Mixture(name, a, z, dens, nlmat, wmat, kmat);
562}
563
564//______________________________________________________________________________
565void TFluka::Medium(Int_t& kmed, const char *name, Int_t nmat,
566 Int_t isvol, Int_t ifield, Double_t fieldm, Double_t tmaxfd,
567 Double_t stemax, Double_t deemax, Double_t epsil,
568 Double_t stmin, Float_t* ubuf, Int_t nbuf) {
b2129742 569 // Define a medium
570 //
829fb838 571 kmed = gGeoManager->GetListOfMedia()->GetSize()+1;
572 fMCGeo->Medium(kmed, name, nmat, isvol, ifield, fieldm, tmaxfd, stemax, deemax,
573 epsil, stmin, ubuf, nbuf);
574}
575
576//______________________________________________________________________________
577void TFluka::Medium(Int_t& kmed, const char *name, Int_t nmat,
578 Int_t isvol, Int_t ifield, Double_t fieldm, Double_t tmaxfd,
579 Double_t stemax, Double_t deemax, Double_t epsil,
580 Double_t stmin, Double_t* ubuf, Int_t nbuf) {
b2129742 581 // Define a medium
582 //
829fb838 583 kmed = gGeoManager->GetListOfMedia()->GetSize()+1;
584 fMCGeo->Medium(kmed, name, nmat, isvol, ifield, fieldm, tmaxfd, stemax, deemax,
585 epsil, stmin, ubuf, nbuf);
586}
587
588//______________________________________________________________________________
589void TFluka::Matrix(Int_t& krot, Double_t thetaX, Double_t phiX,
590 Double_t thetaY, Double_t phiY, Double_t thetaZ,
591 Double_t phiZ) {
592//
593 krot = gGeoManager->GetListOfMatrices()->GetEntriesFast();
594 fMCGeo->Matrix(krot, thetaX, phiX, thetaY, phiY, thetaZ, phiZ);
595}
596
597//______________________________________________________________________________
598void TFluka::Gstpar(Int_t itmed, const char* param, Double_t parval) {
599//
600//
7b203b6e 601//
829fb838 602 Bool_t process = kFALSE;
603 if (strncmp(param, "DCAY", 4) == 0 ||
604 strncmp(param, "PAIR", 4) == 0 ||
605 strncmp(param, "COMP", 4) == 0 ||
606 strncmp(param, "PHOT", 4) == 0 ||
607 strncmp(param, "PFIS", 4) == 0 ||
608 strncmp(param, "DRAY", 4) == 0 ||
609 strncmp(param, "ANNI", 4) == 0 ||
610 strncmp(param, "BREM", 4) == 0 ||
611 strncmp(param, "MUNU", 4) == 0 ||
612 strncmp(param, "CKOV", 4) == 0 ||
613 strncmp(param, "HADR", 4) == 0 ||
614 strncmp(param, "LOSS", 4) == 0 ||
615 strncmp(param, "MULS", 4) == 0 ||
616 strncmp(param, "RAYL", 4) == 0)
617 {
618 process = kTRUE;
619 }
81f1d030 620
829fb838 621 if (process) {
81f1d030 622 SetProcess(param, Int_t (parval), itmed);
829fb838 623 } else {
81f1d030 624 SetCut(param, parval, itmed);
829fb838 625 }
626}
627
628// functions from GGEOM
629//_____________________________________________________________________________
630void TFluka::Gsatt(const char *name, const char *att, Int_t val)
631{
6f5667d1 632 // Set visualisation attributes for one volume
829fb838 633 char vname[5];
634 fGeom->Vname(name,vname);
635 char vatt[5];
636 fGeom->Vname(att,vatt);
637 gGeoManager->SetVolumeAttribute(vname, vatt, val);
638}
639
640//______________________________________________________________________________
641Int_t TFluka::Gsvolu(const char *name, const char *shape, Int_t nmed,
642 Float_t *upar, Int_t np) {
643//
644 return fMCGeo->Gsvolu(name, shape, nmed, upar, np);
645}
646
647//______________________________________________________________________________
648Int_t TFluka::Gsvolu(const char *name, const char *shape, Int_t nmed,
649 Double_t *upar, Int_t np) {
650//
651 return fMCGeo->Gsvolu(name, shape, nmed, upar, np);
652}
653
654//______________________________________________________________________________
655void TFluka::Gsdvn(const char *name, const char *mother, Int_t ndiv,
656 Int_t iaxis) {
657//
658 fMCGeo->Gsdvn(name, mother, ndiv, iaxis);
659}
660
661//______________________________________________________________________________
662void TFluka::Gsdvn2(const char *name, const char *mother, Int_t ndiv,
663 Int_t iaxis, Double_t c0i, Int_t numed) {
664//
665 fMCGeo->Gsdvn2(name, mother, ndiv, iaxis, c0i, numed);
666}
667
668//______________________________________________________________________________
669void TFluka::Gsdvt(const char *name, const char *mother, Double_t step,
670 Int_t iaxis, Int_t numed, Int_t ndvmx) {
671//
672 fMCGeo->Gsdvt(name, mother, step, iaxis, numed, ndvmx);
673}
674
675//______________________________________________________________________________
676void TFluka::Gsdvt2(const char *name, const char *mother, Double_t step,
677 Int_t iaxis, Double_t c0, Int_t numed, Int_t ndvmx) {
678//
679 fMCGeo->Gsdvt2(name, mother, step, iaxis, c0, numed, ndvmx);
680}
681
682//______________________________________________________________________________
683void TFluka::Gsord(const char * /*name*/, Int_t /*iax*/) {
684//
685// Nothing to do with TGeo
686}
687
688//______________________________________________________________________________
689void TFluka::Gspos(const char *name, Int_t nr, const char *mother,
690 Double_t x, Double_t y, Double_t z, Int_t irot,
691 const char *konly) {
692//
693 fMCGeo->Gspos(name, nr, mother, x, y, z, irot, konly);
694}
695
696//______________________________________________________________________________
697void TFluka::Gsposp(const char *name, Int_t nr, const char *mother,
698 Double_t x, Double_t y, Double_t z, Int_t irot,
699 const char *konly, Float_t *upar, Int_t np) {
700 //
701 fMCGeo->Gsposp(name, nr, mother, x, y, z, irot, konly, upar, np);
702}
703
704//______________________________________________________________________________
705void TFluka::Gsposp(const char *name, Int_t nr, const char *mother,
706 Double_t x, Double_t y, Double_t z, Int_t irot,
707 const char *konly, Double_t *upar, Int_t np) {
708 //
709 fMCGeo->Gsposp(name, nr, mother, x, y, z, irot, konly, upar, np);
710}
711
712//______________________________________________________________________________
713void TFluka::Gsbool(const char* /*onlyVolName*/, const char* /*manyVolName*/) {
714//
715// Nothing to do with TGeo
716}
717
718//______________________________________________________________________________
719void TFluka::SetCerenkov(Int_t itmed, Int_t npckov, Float_t* ppckov,
720 Float_t* absco, Float_t* effic, Float_t* rindex) {
721//
722// Set Cerenkov properties for medium itmed
723//
724// npckov: number of sampling points
725// ppckov: energy values
726// absco: absorption length
727// effic: quantum efficiency
728// rindex: refraction index
729//
730//
731//
732// Create object holding Cerenkov properties
733//
734 TFlukaCerenkov* cerenkovProperties = new TFlukaCerenkov(npckov, ppckov, absco, effic, rindex);
735//
736// Pass object to medium
737 TGeoMedium* medium = gGeoManager->GetMedium(itmed);
738 medium->SetCerenkovProperties(cerenkovProperties);
739}
740
b2be0e73 741void TFluka::SetCerenkov(Int_t itmed, Int_t npckov, Float_t* ppckov,
742 Float_t* absco, Float_t* effic, Float_t* rindex, Float_t* rfl) {
743//
744// Set Cerenkov properties for medium itmed
745//
746// npckov: number of sampling points
747// ppckov: energy values
748// absco: absorption length
749// effic: quantum efficiency
750// rindex: refraction index
751// rfl: reflectivity for boundary to medium itmed
752//
753//
754// Create object holding Cerenkov properties
755//
756 TFlukaCerenkov* cerenkovProperties = new TFlukaCerenkov(npckov, ppckov, absco, effic, rindex, rfl);
757//
758// Pass object to medium
759 TGeoMedium* medium = gGeoManager->GetMedium(itmed);
760 medium->SetCerenkovProperties(cerenkovProperties);
761}
762
763
829fb838 764//______________________________________________________________________________
765void TFluka::SetCerenkov(Int_t /*itmed*/, Int_t /*npckov*/, Double_t * /*ppckov*/,
766 Double_t * /*absco*/, Double_t * /*effic*/, Double_t * /*rindex*/) {
767//
b2be0e73 768// Double_t version not implemented
829fb838 769}
b2be0e73 770
771void TFluka::SetCerenkov(Int_t /*itmed*/, Int_t /*npckov*/, Double_t* /*ppckov*/,
772 Double_t* /*absco*/, Double_t* /*effic*/, Double_t* /*rindex*/, Double_t* /*rfl*/) {
773//
774// // Double_t version not implemented
775}
776
829fb838 777// Euclid
778//______________________________________________________________________________
779void TFluka::WriteEuclid(const char* /*fileName*/, const char* /*topVol*/,
780 Int_t /*number*/, Int_t /*nlevel*/) {
781//
782// Not with TGeo
783 Warning("WriteEuclid", "Not implemented with TGeo");
784}
785
786
787
788//_____________________________________________________________________________
789// methods needed by the stepping
790//____________________________________________________________________________
791
792Int_t TFluka::GetMedium() const {
793//
794// Get the medium number for the current fluka region
795//
796 return fGeom->GetMedium(); // this I need to check due to remapping !!!
797}
798
799
800
801//____________________________________________________________________________
802// particle table usage
803// ID <--> PDG transformations
804//_____________________________________________________________________________
805Int_t TFluka::IdFromPDG(Int_t pdg) const
806{
807 //
808 // Return Fluka code from PDG and pseudo ENDF code
809
810 // Catch the feedback photons
811 if (pdg == 50000051) return (-1);
812 // MCIHAD() goes from pdg to fluka internal.
813 Int_t intfluka = mcihad(pdg);
814 // KPTOIP array goes from internal to official
815 return GetFlukaKPTOIP(intfluka);
816}
817
818//______________________________________________________________________________
819Int_t TFluka::PDGFromId(Int_t id) const
820{
821 //
822 // Return PDG code and pseudo ENDF code from Fluka code
f926898e 823 // Alpha He3 Triton Deuteron gen. ion opt. photon
824 Int_t idSpecial[6] = {10020040, 10020030, 10010030, 10010020, 10000000, 50000050};
829fb838 825 // IPTOKP array goes from official to internal
826
827 if (id == -1) {
828// Cerenkov photon
bd3d5c8a 829 if (fVerbosityLevel >= 3)
829fb838 830 printf("\n PDGFromId: Cerenkov Photon \n");
831 return 50000050;
832 }
833// Error id
834 if (id == 0 || id < -6 || id > 250) {
f926898e 835 if (fVerbosityLevel >= 3)
829fb838 836 printf("PDGFromId: Error id = 0\n");
837 return -1;
838 }
839// Good id
f926898e 840 if (id > 0) {
841 Int_t intfluka = GetFlukaIPTOKP(id);
842 if (intfluka == 0) {
843 if (fVerbosityLevel >= 3)
844 printf("PDGFromId: Error intfluka = 0: %d\n", id);
845 return -1;
846 } else if (intfluka < 0) {
847 if (fVerbosityLevel >= 3)
848 printf("PDGFromId: Error intfluka < 0: %d\n", id);
849 return -1;
850 }
851 if (fVerbosityLevel >= 3)
852 printf("mpdgha called with %d %d \n", id, intfluka);
853 // MPDGHA() goes from fluka internal to pdg.
854 return mpdgha(intfluka);
855 } else {
856 // ions and optical photons
857 return idSpecial[id + 6];
829fb838 858 }
829fb838 859}
860
bd3d5c8a 861void TFluka::StopTrack()
862{
863 // Set stopping conditions
864 // Works for photons and charged particles
865 fStopped = kTRUE;
866}
867
829fb838 868//_____________________________________________________________________________
869// methods for physics management
870//____________________________________________________________________________
871//
872// set methods
873//
874
1df5fa54 875void TFluka::SetProcess(const char* flagName, Int_t flagValue, Int_t imed)
829fb838 876{
877// Set process user flag for material imat
878//
1df5fa54 879//
880// Update if already in the list
881//
fb2cbbec 882 TIter next(fUserConfig);
1df5fa54 883 TFlukaConfigOption* proc;
884 while((proc = (TFlukaConfigOption*)next()))
885 {
fb2cbbec 886 if (proc->Medium() == imed) {
887 proc->SetProcess(flagName, flagValue);
888 return;
889 }
1df5fa54 890 }
fb2cbbec 891 proc = new TFlukaConfigOption(imed);
892 proc->SetProcess(flagName, flagValue);
893 fUserConfig->Add(proc);
894}
895
896//______________________________________________________________________________
897Bool_t TFluka::SetProcess(const char* flagName, Int_t flagValue)
898{
899// Set process user flag
1df5fa54 900//
1df5fa54 901//
fb2cbbec 902 SetProcess(flagName, flagValue, -1);
1df5fa54 903 return kTRUE;
829fb838 904}
905
906//______________________________________________________________________________
907void TFluka::SetCut(const char* cutName, Double_t cutValue, Int_t imed)
908{
909// Set user cut value for material imed
910//
fb2cbbec 911 TIter next(fUserConfig);
912 TFlukaConfigOption* proc;
913 while((proc = (TFlukaConfigOption*)next()))
914 {
915 if (proc->Medium() == imed) {
916 proc->SetCut(cutName, cutValue);
917 return;
918 }
919 }
920
921 proc = new TFlukaConfigOption(imed);
922 proc->SetCut(cutName, cutValue);
923 fUserConfig->Add(proc);
829fb838 924}
925
926//______________________________________________________________________________
927Bool_t TFluka::SetCut(const char* cutName, Double_t cutValue)
928{
929// Set user cut value
930//
1df5fa54 931//
fb2cbbec 932 SetCut(cutName, cutValue, -1);
933 return kTRUE;
829fb838 934}
935
f450e9d0 936
937void TFluka::SetUserScoring(const char* option, Int_t npr, char* outfile, Float_t* what)
b496f27c 938{
939//
f450e9d0 940// Adds a user scoring option to the list
b496f27c 941//
f450e9d0 942 TFlukaScoringOption* opt = new TFlukaScoringOption(option, "User Scoring", npr,outfile,what);
943 fUserScore->Add(opt);
944}
945//______________________________________________________________________________
946void TFluka::SetUserScoring(const char* option, Int_t npr, char* outfile, Float_t* what, const char* det1, const char* det2, const char* det3)
947{
948//
949// Adds a user scoring option to the list
950//
951 TFlukaScoringOption* opt = new TFlukaScoringOption(option, "User Scoring", npr, outfile, what, det1, det2, det3);
b496f27c 952 fUserScore->Add(opt);
953}
b496f27c 954
829fb838 955//______________________________________________________________________________
956Double_t TFluka::Xsec(char*, Double_t, Int_t, Int_t)
957{
958 printf("WARNING: Xsec not yet implemented !\n"); return -1.;
959}
960
961
962//______________________________________________________________________________
963void TFluka::InitPhysics()
964{
965//
966// Physics initialisation with preparation of FLUKA input cards
967//
fb2cbbec 968 printf("=>InitPhysics\n");
829fb838 969
fb2cbbec 970// Construct file names
971 FILE *pFlukaVmcCoreInp, *pFlukaVmcFlukaMat, *pFlukaVmcInp;
972 TString sFlukaVmcCoreInp = getenv("ALICE_ROOT");
973 sFlukaVmcCoreInp +="/TFluka/input/";
974 TString sFlukaVmcTmp = "flukaMat.inp";
975 TString sFlukaVmcInp = GetInputFileName();
976 sFlukaVmcCoreInp += GetCoreInputFileName();
977
978// Open files
979 if ((pFlukaVmcCoreInp = fopen(sFlukaVmcCoreInp.Data(),"r")) == NULL) {
980 printf("\nCannot open file %s\n",sFlukaVmcCoreInp.Data());
981 exit(1);
982 }
983 if ((pFlukaVmcFlukaMat = fopen(sFlukaVmcTmp.Data(),"r")) == NULL) {
984 printf("\nCannot open file %s\n",sFlukaVmcTmp.Data());
985 exit(1);
986 }
987 if ((pFlukaVmcInp = fopen(sFlukaVmcInp.Data(),"w")) == NULL) {
988 printf("\nCannot open file %s\n",sFlukaVmcInp.Data());
989 exit(1);
990 }
829fb838 991
fb2cbbec 992// Copy core input file
993 Char_t sLine[255];
994 Float_t fEventsPerRun;
829fb838 995
fb2cbbec 996 while ((fgets(sLine,255,pFlukaVmcCoreInp)) != NULL) {
997 if (strncmp(sLine,"GEOEND",6) != 0)
998 fprintf(pFlukaVmcInp,"%s",sLine); // copy until GEOEND card
999 else {
1000 fprintf(pFlukaVmcInp,"GEOEND\n"); // add GEOEND card
1001 goto flukamat;
829fb838 1002 }
fb2cbbec 1003 } // end of while until GEOEND card
1004
829fb838 1005
fb2cbbec 1006 flukamat:
1007 while ((fgets(sLine,255,pFlukaVmcFlukaMat)) != NULL) { // copy flukaMat.inp file
1008 fprintf(pFlukaVmcInp,"%s\n",sLine);
1009 }
1010
1011 while ((fgets(sLine,255,pFlukaVmcCoreInp)) != NULL) {
1012 if (strncmp(sLine,"START",5) != 0)
1013 fprintf(pFlukaVmcInp,"%s\n",sLine);
1014 else {
1015 sscanf(sLine+10,"%10f",&fEventsPerRun);
1016 goto fin;
1017 }
1018 } //end of while until START card
1019
1020 fin:
829fb838 1021
f450e9d0 1022
1023// Pass information to configuration objects
829fb838 1024
fb2cbbec 1025 Float_t fLastMaterial = fGeom->GetLastMaterialIndex();
1026 TFlukaConfigOption::SetStaticInfo(pFlukaVmcInp, 3, fLastMaterial, fGeom);
1027
1028 TIter next(fUserConfig);
1029 TFlukaConfigOption* proc;
f450e9d0 1030 while((proc = dynamic_cast<TFlukaConfigOption*> (next()))) proc->WriteFlukaInputCards();
1031//
1032// Process Fluka specific scoring options
1033//
1034 TFlukaScoringOption::SetStaticInfo(pFlukaVmcInp, fGeom);
1035 Float_t loginp = 49.0;
1036 Int_t inp = 0;
1037 Int_t nscore = fUserScore->GetEntries();
1038
1039 TFlukaScoringOption *mopo = 0x0;
1040 TFlukaScoringOption *mopi = 0x0;
fb2cbbec 1041
f450e9d0 1042 for (Int_t isc = 0; isc < nscore; isc++)
1043 {
1044 mopo = dynamic_cast<TFlukaScoringOption*> (fUserScore->At(isc));
1045 char* fileName = mopo->GetFileName();
1046 Int_t size = strlen(fileName);
1047 Float_t lun = -1.;
1048//
1049// Check if new output file has to be opened
1050 for (Int_t isci = 0; isci < isc; isci++) {
a9d74780 1051
1052
1053 mopi = dynamic_cast<TFlukaScoringOption*> (fUserScore->At(isci));
f450e9d0 1054 if(strncmp(mopi->GetFileName(), fileName, size)==0) {
1055 //
1056 // No, the file already exists
1057 lun = mopi->GetLun();
1058 mopo->SetLun(lun);
1059 break;
1060 }
1061 } // inner loop
1062
1063 if (lun == -1.) {
1064 // Open new output file
1065 inp++;
1066 mopo->SetLun(loginp + inp);
1067 mopo->WriteOpenFlukaFile();
1068 }
1069 mopo->WriteFlukaInputCards();
1070 }
1071
829fb838 1072// Add START and STOP card
f450e9d0 1073 fprintf(pFlukaVmcInp,"START %10.1f\n",fEventsPerRun);
1074 fprintf(pFlukaVmcInp,"STOP \n");
829fb838 1075
1076
1077// Close files
3b8c325d 1078 fclose(pFlukaVmcCoreInp);
1079 fclose(pFlukaVmcFlukaMat);
1080 fclose(pFlukaVmcInp);
fb2cbbec 1081
1082
1083//
1084// Initialisation needed for Cerenkov photon production and transport
1085 TObjArray *matList = GetFlukaMaterials();
1086 Int_t nmaterial = matList->GetEntriesFast();
1087 fMaterials = new Int_t[nmaterial+3];
1088
1089 for (Int_t im = 0; im < nmaterial; im++)
1090 {
1091 TGeoMaterial* material = dynamic_cast<TGeoMaterial*> (matList->At(im));
1092 Int_t idmat = material->GetIndex();
1093 fMaterials[idmat] = im;
1094 }
829fb838 1095} // end of InitPhysics
1096
1097
1098//______________________________________________________________________________
07f5b33e 1099void TFluka::SetMaxStep(Double_t step)
829fb838 1100{
07f5b33e 1101// Set the maximum step size
1102 if (step > 1.e4) return;
1103
1104 Int_t mreg, latt;
1105 fGeom->GetCurrentRegion(mreg, latt);
9c0c08ce 1106 STEPSZ.stepmx[mreg - 1] = step;
829fb838 1107}
1108
2f09b80e 1109
1110Double_t TFluka::MaxStep() const
1111{
1112// Return the maximum for current medium
1113 Int_t mreg, latt;
1114 fGeom->GetCurrentRegion(mreg, latt);
1115 return (STEPSZ.stepmx[mreg - 1]);
1116}
1117
829fb838 1118//______________________________________________________________________________
1119void TFluka::SetMaxNStep(Int_t)
1120{
1121// SetMaxNStep is dummy procedure in TFluka !
1122 if (fVerbosityLevel >=3)
1123 cout << "SetMaxNStep is dummy procedure in TFluka !" << endl;
1124}
1125
1126//______________________________________________________________________________
1127void TFluka::SetUserDecay(Int_t)
1128{
1129// SetUserDecay is dummy procedure in TFluka !
1130 if (fVerbosityLevel >=3)
1131 cout << "SetUserDecay is dummy procedure in TFluka !" << endl;
1132}
1133
1134//
1135// dynamic properties
1136//
1137//______________________________________________________________________________
1138void TFluka::TrackPosition(TLorentzVector& position) const
1139{
1140// Return the current position in the master reference frame of the
1141// track being transported
1142// TRACKR.atrack = age of the particle
1143// TRACKR.xtrack = x-position of the last point
1144// TRACKR.ytrack = y-position of the last point
1145// TRACKR.ztrack = z-position of the last point
1146 Int_t caller = GetCaller();
669cede4 1147 if (caller == 3 || caller == 6 || caller == 11 || caller == 12 || caller == 50) { //bxdraw,endraw,usdraw,ckov
829fb838 1148 position.SetX(GetXsco());
1149 position.SetY(GetYsco());
1150 position.SetZ(GetZsco());
1151 position.SetT(TRACKR.atrack);
1152 }
669cede4 1153 else if (caller == 4) { // mgdraw,mgdraw resuming
829fb838 1154 position.SetX(TRACKR.xtrack[TRACKR.ntrack]);
1155 position.SetY(TRACKR.ytrack[TRACKR.ntrack]);
1156 position.SetZ(TRACKR.ztrack[TRACKR.ntrack]);
1157 position.SetT(TRACKR.atrack);
1158 }
1159 else if (caller == 5) { // sodraw
1160 position.SetX(TRACKR.xtrack[TRACKR.ntrack]);
1161 position.SetY(TRACKR.ytrack[TRACKR.ntrack]);
1162 position.SetZ(TRACKR.ztrack[TRACKR.ntrack]);
1163 position.SetT(0);
5d80a015 1164 } else if (caller == 40) { // mgdraw resuming transport
1165 position.SetX(TRACKR.spausr[0]);
1166 position.SetY(TRACKR.spausr[1]);
1167 position.SetZ(TRACKR.spausr[2]);
1168 position.SetT(TRACKR.spausr[3]);
829fb838 1169 }
1170 else
1171 Warning("TrackPosition","position not available");
1172}
1173
1174//______________________________________________________________________________
1175void TFluka::TrackPosition(Double_t& x, Double_t& y, Double_t& z) const
1176{
1177// Return the current position in the master reference frame of the
1178// track being transported
1179// TRACKR.atrack = age of the particle
1180// TRACKR.xtrack = x-position of the last point
1181// TRACKR.ytrack = y-position of the last point
1182// TRACKR.ztrack = z-position of the last point
1183 Int_t caller = GetCaller();
669cede4 1184 if (caller == 3 || caller == 6 || caller == 11 || caller == 12 || caller == 50) { //bxdraw,endraw,usdraw,ckov
829fb838 1185 x = GetXsco();
1186 y = GetYsco();
1187 z = GetZsco();
1188 }
669cede4 1189 else if (caller == 4 || caller == 5) { // mgdraw, sodraw, mgdraw resuming
829fb838 1190 x = TRACKR.xtrack[TRACKR.ntrack];
1191 y = TRACKR.ytrack[TRACKR.ntrack];
1192 z = TRACKR.ztrack[TRACKR.ntrack];
1193 }
5d80a015 1194 else if (caller == 40) { // mgdraw resuming transport
1195 x = TRACKR.spausr[0];
1196 y = TRACKR.spausr[1];
1197 z = TRACKR.spausr[2];
1198 }
829fb838 1199 else
1200 Warning("TrackPosition","position not available");
1201}
1202
1203//______________________________________________________________________________
1204void TFluka::TrackMomentum(TLorentzVector& momentum) const
1205{
1206// Return the direction and the momentum (GeV/c) of the track
1207// currently being transported
1208// TRACKR.ptrack = momentum of the particle (not always defined, if
1209// < 0 must be obtained from etrack)
1210// TRACKR.cx,y,ztrck = direction cosines of the current particle
1211// TRACKR.etrack = total energy of the particle
1212// TRACKR.jtrack = identity number of the particle
1213// PAPROP.am[TRACKR.jtrack] = particle mass in gev
1214 Int_t caller = GetCaller();
0773d0ac 1215 if (caller != 2 && caller != 40) { // not eedraw or mgdraw resuming
829fb838 1216 if (TRACKR.ptrack >= 0) {
1217 momentum.SetPx(TRACKR.ptrack*TRACKR.cxtrck);
1218 momentum.SetPy(TRACKR.ptrack*TRACKR.cytrck);
1219 momentum.SetPz(TRACKR.ptrack*TRACKR.cztrck);
1220 momentum.SetE(TRACKR.etrack);
1221 return;
1222 }
1223 else {
1224 Double_t p = sqrt(TRACKR.etrack*TRACKR.etrack - PAPROP.am[TRACKR.jtrack+6]*PAPROP.am[TRACKR.jtrack+6]);
1225 momentum.SetPx(p*TRACKR.cxtrck);
1226 momentum.SetPy(p*TRACKR.cytrck);
1227 momentum.SetPz(p*TRACKR.cztrck);
1228 momentum.SetE(TRACKR.etrack);
1229 return;
1230 }
5d80a015 1231 } else if (caller == 40) { // mgdraw resuming transport
1232 momentum.SetPx(TRACKR.spausr[4]);
1233 momentum.SetPy(TRACKR.spausr[5]);
1234 momentum.SetPz(TRACKR.spausr[6]);
1235 momentum.SetE (TRACKR.spausr[7]);
1236 return;
829fb838 1237 }
1238 else
1239 Warning("TrackMomentum","momentum not available");
1240}
1241
1242//______________________________________________________________________________
1243void TFluka::TrackMomentum(Double_t& px, Double_t& py, Double_t& pz, Double_t& e) const
1244{
1245// Return the direction and the momentum (GeV/c) of the track
1246// currently being transported
1247// TRACKR.ptrack = momentum of the particle (not always defined, if
1248// < 0 must be obtained from etrack)
1249// TRACKR.cx,y,ztrck = direction cosines of the current particle
1250// TRACKR.etrack = total energy of the particle
1251// TRACKR.jtrack = identity number of the particle
1252// PAPROP.am[TRACKR.jtrack] = particle mass in gev
1253 Int_t caller = GetCaller();
0773d0ac 1254 if (caller != 2 && caller != 40) { // not eedraw and not mgdraw resuming
829fb838 1255 if (TRACKR.ptrack >= 0) {
1256 px = TRACKR.ptrack*TRACKR.cxtrck;
1257 py = TRACKR.ptrack*TRACKR.cytrck;
1258 pz = TRACKR.ptrack*TRACKR.cztrck;
1259 e = TRACKR.etrack;
1260 return;
1261 }
1262 else {
1263 Double_t p = sqrt(TRACKR.etrack*TRACKR.etrack - PAPROP.am[TRACKR.jtrack+6]*PAPROP.am[TRACKR.jtrack+6]);
1264 px = p*TRACKR.cxtrck;
1265 py = p*TRACKR.cytrck;
1266 pz = p*TRACKR.cztrck;
1267 e = TRACKR.etrack;
1268 return;
1269 }
5d80a015 1270 } else if (caller == 40) { // mgdraw resuming transport
1271 px = TRACKR.spausr[4];
1272 py = TRACKR.spausr[5];
1273 pz = TRACKR.spausr[6];
1274 e = TRACKR.spausr[7];
0773d0ac 1275 return;
829fb838 1276 }
1277 else
1278 Warning("TrackMomentum","momentum not available");
1279}
1280
1281//______________________________________________________________________________
1282Double_t TFluka::TrackStep() const
1283{
1284// Return the length in centimeters of the current step
1285// TRACKR.ctrack = total curved path
1286 Int_t caller = GetCaller();
5d80a015 1287 if (caller == 11 || caller==12 || caller == 3 || caller == 6 || caller == 50 || caller == 40) //bxdraw,endraw,usdraw, ckov
829fb838 1288 return 0.0;
1289 else if (caller == 4) //mgdraw
1290 return TRACKR.ctrack;
669cede4 1291 else {
1292 Warning("TrackStep", "track step not available");
1293 return 0.0;
1294 }
829fb838 1295}
1296
1297//______________________________________________________________________________
1298Double_t TFluka::TrackLength() const
1299{
1300// TRACKR.cmtrck = cumulative curved path since particle birth
1301 Int_t caller = GetCaller();
669cede4 1302 if (caller == 11 || caller==12 || caller == 3 || caller == 4 || caller == 6 || caller == 50) //bxdraw,endraw,mgdraw,usdraw,ckov
829fb838 1303 return TRACKR.cmtrck;
5d80a015 1304 else if (caller == 40) // mgdraw resuming transport
1305 return TRACKR.spausr[8];
669cede4 1306 else {
1307 Warning("TrackLength", "track length not available");
1308 return 0.0;
1309 }
829fb838 1310}
1311
1312//______________________________________________________________________________
1313Double_t TFluka::TrackTime() const
1314{
1315// Return the current time of flight of the track being transported
1316// TRACKR.atrack = age of the particle
1317 Int_t caller = GetCaller();
669cede4 1318 if (caller == 11 || caller==12 || caller == 3 || caller == 4 || caller == 6 || caller == 50) //bxdraw,endraw,mgdraw,usdraw,ckov
829fb838 1319 return TRACKR.atrack;
5d80a015 1320 else if (caller == 40)
1321 return TRACKR.spausr[3];
669cede4 1322 else {
1323 Warning("TrackTime", "track time not available");
1324 return 0.0;
1325 }
829fb838 1326}
1327
1328//______________________________________________________________________________
1329Double_t TFluka::Edep() const
1330{
1331// Energy deposition
1332// if TRACKR.ntrack = 0, TRACKR.mtrack = 0:
1333// -->local energy deposition (the value and the point are not recorded in TRACKR)
1334// but in the variable "rull" of the procedure "endraw.cxx"
1335// if TRACKR.ntrack > 0, TRACKR.mtrack = 0:
1336// -->no energy loss along the track
1337// if TRACKR.ntrack > 0, TRACKR.mtrack > 0:
1338// -->energy loss distributed along the track
07f5b33e 1339// TRACKR.dtrack = energy deposition of the jth deposition event
829fb838 1340
1341 // If coming from bxdraw we have 2 steps of 0 length and 0 edep
669cede4 1342 // If coming from usdraw we just signal particle production - no edep
1343 // If just first time after resuming, no edep for the primary
829fb838 1344 Int_t caller = GetCaller();
5d80a015 1345 if (caller == 11 || caller==12 || caller==6 || caller == 40) return 0.0;
829fb838 1346 Double_t sum = 0;
1347 for ( Int_t j=0;j<TRACKR.mtrack;j++) {
b2be0e73 1348 sum +=TRACKR.dtrack[j];
829fb838 1349 }
1350 if (TRACKR.ntrack == 0 && TRACKR.mtrack == 0)
b2be0e73 1351 return fRull + sum;
829fb838 1352 else {
b2be0e73 1353 return sum;
829fb838 1354 }
1355}
1356
1357//______________________________________________________________________________
1358Int_t TFluka::TrackPid() const
1359{
1360// Return the id of the particle transported
1361// TRACKR.jtrack = identity number of the particle
1362 Int_t caller = GetCaller();
f926898e 1363 if (caller != 2) { // not eedraw
1364 return PDGFromId(TRACKR.jtrack);
1365 }
829fb838 1366 else
1367 return -1000;
1368}
1369
1370//______________________________________________________________________________
1371Double_t TFluka::TrackCharge() const
1372{
1373// Return charge of the track currently transported
1374// PAPROP.ichrge = electric charge of the particle
1375// TRACKR.jtrack = identity number of the particle
1376 Int_t caller = GetCaller();
1377 if (caller != 2) // not eedraw
1378 return PAPROP.ichrge[TRACKR.jtrack+6];
1379 else
1380 return -1000.0;
1381}
1382
1383//______________________________________________________________________________
1384Double_t TFluka::TrackMass() const
1385{
1386// PAPROP.am = particle mass in GeV
1387// TRACKR.jtrack = identity number of the particle
1388 Int_t caller = GetCaller();
1389 if (caller != 2) // not eedraw
1390 return PAPROP.am[TRACKR.jtrack+6];
1391 else
1392 return -1000.0;
1393}
1394
1395//______________________________________________________________________________
1396Double_t TFluka::Etot() const
1397{
1398// TRACKR.etrack = total energy of the particle
1399 Int_t caller = GetCaller();
1400 if (caller != 2) // not eedraw
1401 return TRACKR.etrack;
1402 else
1403 return -1000.0;
1404}
1405
1406//
1407// track status
1408//
1409//______________________________________________________________________________
1410Bool_t TFluka::IsNewTrack() const
1411{
1412// Return true for the first call of Stepping()
1413 return fTrackIsNew;
1414}
1415
0dabe425 1416void TFluka::SetTrackIsNew(Bool_t flag)
1417{
1418// Return true for the first call of Stepping()
1419 fTrackIsNew = flag;
1420
1421}
1422
1423
829fb838 1424//______________________________________________________________________________
1425Bool_t TFluka::IsTrackInside() const
1426{
1427// True if the track is not at the boundary of the current volume
1428// In Fluka a step is always inside one kind of material
1429// If the step would go behind the region of one material,
1430// it will be shortened to reach only the boundary.
1431// Therefore IsTrackInside() is always true.
1432 Int_t caller = GetCaller();
1433 if (caller == 11 || caller==12) // bxdraw
1434 return 0;
1435 else
1436 return 1;
1437}
1438
1439//______________________________________________________________________________
1440Bool_t TFluka::IsTrackEntering() const
1441{
1442// True if this is the first step of the track in the current volume
1443
1444 Int_t caller = GetCaller();
1445 if (caller == 11) // bxdraw entering
1446 return 1;
1447 else return 0;
1448}
1449
1450//______________________________________________________________________________
1451Bool_t TFluka::IsTrackExiting() const
1452{
1453// True if track is exiting volume
1454//
1455 Int_t caller = GetCaller();
1456 if (caller == 12) // bxdraw exiting
1457 return 1;
1458 else return 0;
1459}
1460
1461//______________________________________________________________________________
1462Bool_t TFluka::IsTrackOut() const
1463{
1464// True if the track is out of the setup
1465// means escape
1466// Icode = 14: escape - call from Kaskad
1467// Icode = 23: escape - call from Emfsco
1468// Icode = 32: escape - call from Kasneu
1469// Icode = 40: escape - call from Kashea
1470// Icode = 51: escape - call from Kasoph
1471 if (fIcode == 14 ||
1472 fIcode == 23 ||
1473 fIcode == 32 ||
1474 fIcode == 40 ||
1475 fIcode == 51) return 1;
1476 else return 0;
1477}
1478
1479//______________________________________________________________________________
1480Bool_t TFluka::IsTrackDisappeared() const
1481{
1482// means all inelastic interactions and decays
1483// fIcode from usdraw
1484 if (fIcode == 101 || // inelastic interaction
1485 fIcode == 102 || // particle decay
0dabe425 1486 fIcode == 103 || // delta ray generation by hadron
1487 fIcode == 104 || // direct pair production
1488 fIcode == 105 || // bremsstrahlung (muon)
1489 fIcode == 208 || // bremsstrahlung (electron)
829fb838 1490 fIcode == 214 || // in-flight annihilation
1491 fIcode == 215 || // annihilation at rest
1492 fIcode == 217 || // pair production
0dabe425 1493 fIcode == 219 || // Compton scattering
1494 fIcode == 221 || // Photoelectric effect
1495 fIcode == 300 || // hadronic interaction
1496 fIcode == 400 // delta-ray
1497 ) return 1;
829fb838 1498 else return 0;
1499}
1500
1501//______________________________________________________________________________
1502Bool_t TFluka::IsTrackStop() const
1503{
1504// True if the track energy has fallen below the threshold
1505// means stopped by signal or below energy threshold
1506// Icode = 12: stopping particle - call from Kaskad
1507// Icode = 15: time kill - call from Kaskad
1508// Icode = 21: below threshold, iarg=1 - call from Emfsco
1509// Icode = 22: below threshold, iarg=2 - call from Emfsco
1510// Icode = 24: time kill - call from Emfsco
1511// Icode = 31: below threshold - call from Kasneu
1512// Icode = 33: time kill - call from Kasneu
1513// Icode = 41: time kill - call from Kashea
1514// Icode = 52: time kill - call from Kasoph
1515 if (fIcode == 12 ||
1516 fIcode == 15 ||
1517 fIcode == 21 ||
1518 fIcode == 22 ||
1519 fIcode == 24 ||
1520 fIcode == 31 ||
1521 fIcode == 33 ||
1522 fIcode == 41 ||
1523 fIcode == 52) return 1;
1524 else return 0;
1525}
1526
1527//______________________________________________________________________________
1528Bool_t TFluka::IsTrackAlive() const
1529{
1530// means not disappeared or not out
1531 if (IsTrackDisappeared() || IsTrackOut() ) return 0;
1532 else return 1;
1533}
1534
1535//
1536// secondaries
1537//
1538
1539//______________________________________________________________________________
1540Int_t TFluka::NSecondaries() const
1541
1542{
1543// Number of secondary particles generated in the current step
81f1d030 1544// GENSTK.np = number of secondaries except light and heavy ions
829fb838 1545// FHEAVY.npheav = number of secondaries for light and heavy secondary ions
7b203b6e 1546 Int_t caller = GetCaller();
1547 if (caller == 6) // valid only after usdraw
81f1d030 1548 return GENSTK.np + FHEAVY.npheav;
7b203b6e 1549 else if (caller == 50) {
1550 // Cerenkov Photon production
1551 return fNCerenkov;
1552 }
829fb838 1553 return 0;
1554} // end of NSecondaries
1555
1556//______________________________________________________________________________
1557void TFluka::GetSecondary(Int_t isec, Int_t& particleId,
1558 TLorentzVector& position, TLorentzVector& momentum)
1559{
1560// Copy particles from secondary stack to vmc stack
1561//
1562
7b203b6e 1563 Int_t caller = GetCaller();
1564 if (caller == 6) { // valid only after usdraw
81f1d030 1565 if (GENSTK.np > 0) {
7b203b6e 1566 // Hadronic interaction
81f1d030 1567 if (isec >= 0 && isec < GENSTK.np) {
1568 particleId = PDGFromId(GENSTK.kpart[isec]);
7b203b6e 1569 position.SetX(fXsco);
1570 position.SetY(fYsco);
1571 position.SetZ(fZsco);
1572 position.SetT(TRACKR.atrack);
81f1d030 1573 momentum.SetPx(GENSTK.plr[isec]*GENSTK.cxr[isec]);
1574 momentum.SetPy(GENSTK.plr[isec]*GENSTK.cyr[isec]);
1575 momentum.SetPz(GENSTK.plr[isec]*GENSTK.czr[isec]);
1576 momentum.SetE(GENSTK.tki[isec] + PAPROP.am[GENSTK.kpart[isec]+6]);
7b203b6e 1577 }
81f1d030 1578 else if (isec >= GENSTK.np && isec < GENSTK.np + FHEAVY.npheav) {
1579 Int_t jsec = isec - GENSTK.np;
7b203b6e 1580 particleId = FHEAVY.kheavy[jsec]; // this is Fluka id !!!
1581 position.SetX(fXsco);
1582 position.SetY(fYsco);
1583 position.SetZ(fZsco);
1584 position.SetT(TRACKR.atrack);
1585 momentum.SetPx(FHEAVY.pheavy[jsec]*FHEAVY.cxheav[jsec]);
1586 momentum.SetPy(FHEAVY.pheavy[jsec]*FHEAVY.cyheav[jsec]);
1587 momentum.SetPz(FHEAVY.pheavy[jsec]*FHEAVY.czheav[jsec]);
1588 if (FHEAVY.tkheav[jsec] >= 3 && FHEAVY.tkheav[jsec] <= 6)
1589 momentum.SetE(FHEAVY.tkheav[jsec] + PAPROP.am[jsec+6]);
1590 else if (FHEAVY.tkheav[jsec] > 6)
1591 momentum.SetE(FHEAVY.tkheav[jsec] + FHEAVY.amnhea[jsec]); // to be checked !!!
1592 }
1593 else
1594 Warning("GetSecondary","isec out of range");
1595 }
1596 } else if (caller == 50) {
1597 Int_t index = OPPHST.lstopp - isec;
1598 position.SetX(OPPHST.xoptph[index]);
1599 position.SetY(OPPHST.yoptph[index]);
1600 position.SetZ(OPPHST.zoptph[index]);
1601 position.SetT(OPPHST.agopph[index]);
1602 Double_t p = OPPHST.poptph[index];
1603
1604 momentum.SetPx(p * OPPHST.txopph[index]);
1605 momentum.SetPy(p * OPPHST.tyopph[index]);
1606 momentum.SetPz(p * OPPHST.tzopph[index]);
1607 momentum.SetE(p);
829fb838 1608 }
1609 else
7b203b6e 1610 Warning("GetSecondary","no secondaries available");
1611
829fb838 1612} // end of GetSecondary
1613
7b203b6e 1614
829fb838 1615//______________________________________________________________________________
1616TMCProcess TFluka::ProdProcess(Int_t) const
1617
1618{
1619// Name of the process that has produced the secondary particles
1620// in the current step
0dabe425 1621
1622 Int_t mugamma = (TRACKR.jtrack == 7 || TRACKR.jtrack == 10 || TRACKR.jtrack == 11);
1623
b496f27c 1624 if (fIcode == 102) return kPDecay;
0dabe425 1625 else if (fIcode == 104 || fIcode == 217) return kPPair;
b496f27c 1626 else if (fIcode == 219) return kPCompton;
1627 else if (fIcode == 221) return kPPhotoelectric;
0dabe425 1628 else if (fIcode == 105 || fIcode == 208) return kPBrem;
1629 else if (fIcode == 103 || fIcode == 400) return kPDeltaRay;
1630 else if (fIcode == 210 || fIcode == 212) return kPDeltaRay;
1631 else if (fIcode == 214 || fIcode == 215) return kPAnnihilation;
b496f27c 1632 else if (fIcode == 101) return kPHadronic;
829fb838 1633 else if (fIcode == 101) {
b496f27c 1634 if (!mugamma) return kPHadronic;
1635 else if (TRACKR.jtrack == 7) return kPPhotoFission;
1636 else return kPMuonNuclear;
829fb838 1637 }
b496f27c 1638 else if (fIcode == 225) return kPRayleigh;
829fb838 1639// Fluka codes 100, 300 and 400 still to be investigasted
b496f27c 1640 else return kPNoProcess;
829fb838 1641}
1642
829fb838 1643
b496f27c 1644Int_t TFluka::StepProcesses(TArrayI &proc) const
1645{
1646 //
1647 // Return processes active in the current step
1648 //
1649 proc.Set(1);
1650 TMCProcess iproc;
1651 switch (fIcode) {
1652 case 15:
1653 case 24:
1654 case 33:
1655 case 41:
1656 case 52:
1657 iproc = kPTOFlimit;
1658 break;
1659 case 12:
1660 case 14:
1661 case 21:
1662 case 22:
1663 case 23:
1664 case 31:
1665 case 32:
1666 case 40:
1667 case 51:
6fd5baa4 1668 iproc = kPStop;
b496f27c 1669 break;
1670 case 50:
1671 iproc = kPLightAbsorption;
1672 break;
6fd5baa4 1673 case 59:
1674 iproc = kPLightRefraction;
b496f27c 1675 case 20:
1676 iproc = kPPhotoelectric;
1677 break;
1678 default:
1679 iproc = ProdProcess(0);
1680 }
07f5b33e 1681 proc[0] = iproc;
b496f27c 1682 return 1;
1683}
829fb838 1684//______________________________________________________________________________
1685Int_t TFluka::VolId2Mate(Int_t id) const
1686{
1687//
1688// Returns the material number for a given volume ID
1689//
1690 return fMCGeo->VolId2Mate(id);
1691}
1692
1693//______________________________________________________________________________
1694const char* TFluka::VolName(Int_t id) const
1695{
1696//
1697// Returns the volume name for a given volume ID
1698//
1699 return fMCGeo->VolName(id);
1700}
1701
1702//______________________________________________________________________________
1703Int_t TFluka::VolId(const Text_t* volName) const
1704{
1705//
1706// Converts from volume name to volume ID.
1707// Time consuming. (Only used during set-up)
1708// Could be replaced by hash-table
1709//
09cd6497 1710 char sname[20];
1711 Int_t len;
1712 strncpy(sname, volName, len = strlen(volName));
1713 sname[len] = 0;
1714 while (sname[len - 1] == ' ') sname[--len] = 0;
1715 return fMCGeo->VolId(sname);
829fb838 1716}
1717
1718//______________________________________________________________________________
1719Int_t TFluka::CurrentVolID(Int_t& copyNo) const
1720{
1721//
1722// Return the logical id and copy number corresponding to the current fluka region
1723//
1724 if (gGeoManager->IsOutside()) return 0;
1725 TGeoNode *node = gGeoManager->GetCurrentNode();
1726 copyNo = node->GetNumber();
1727 Int_t id = node->GetVolume()->GetNumber();
1728 return id;
1729}
1730
1731//______________________________________________________________________________
1732Int_t TFluka::CurrentVolOffID(Int_t off, Int_t& copyNo) const
1733{
1734//
1735// Return the logical id and copy number of off'th mother
1736// corresponding to the current fluka region
1737//
1738 if (off<0 || off>gGeoManager->GetLevel()) return 0;
1739 if (off==0) return CurrentVolID(copyNo);
1740 TGeoNode *node = gGeoManager->GetMother(off);
1741 if (!node) return 0;
1742 copyNo = node->GetNumber();
1743 return node->GetVolume()->GetNumber();
1744}
1745
1746//______________________________________________________________________________
1747const char* TFluka::CurrentVolName() const
1748{
1749//
1750// Return the current volume name
1751//
1752 if (gGeoManager->IsOutside()) return 0;
1753 return gGeoManager->GetCurrentVolume()->GetName();
1754}
1755
1756//______________________________________________________________________________
1757const char* TFluka::CurrentVolOffName(Int_t off) const
1758{
1759//
1760// Return the volume name of the off'th mother of the current volume
1761//
1762 if (off<0 || off>gGeoManager->GetLevel()) return 0;
1763 if (off==0) return CurrentVolName();
1764 TGeoNode *node = gGeoManager->GetMother(off);
1765 if (!node) return 0;
1766 return node->GetVolume()->GetName();
1767}
1768
d59acfe7 1769const char* TFluka::CurrentVolPath() {
1770 // Return the current volume path
1771 return gGeoManager->GetPath();
1772}
829fb838 1773//______________________________________________________________________________
a60813de 1774Int_t TFluka::CurrentMaterial(Float_t & a, Float_t & z,
1775 Float_t & dens, Float_t & radl, Float_t & absl) const
829fb838 1776{
1777//
a60813de 1778// Return the current medium number and material properties
829fb838 1779//
1780 Int_t copy;
1781 Int_t id = TFluka::CurrentVolID(copy);
1782 Int_t med = TFluka::VolId2Mate(id);
a60813de 1783 TGeoVolume* vol = gGeoManager->GetCurrentVolume();
1784 TGeoMaterial* mat = vol->GetMaterial();
1785 a = mat->GetA();
1786 z = mat->GetZ();
1787 dens = mat->GetDensity();
1788 radl = mat->GetRadLen();
1789 absl = mat->GetIntLen();
1790
829fb838 1791 return med;
1792}
1793
1794//______________________________________________________________________________
1795void TFluka::Gmtod(Float_t* xm, Float_t* xd, Int_t iflag)
1796{
1797// Transforms a position from the world reference frame
1798// to the current volume reference frame.
1799//
1800// Geant3 desription:
1801// ==================
1802// Computes coordinates XD (in DRS)
1803// from known coordinates XM in MRS
1804// The local reference system can be initialized by
1805// - the tracking routines and GMTOD used in GUSTEP
1806// - a call to GMEDIA(XM,NUMED)
1807// - a call to GLVOLU(NLEVEL,NAMES,NUMBER,IER)
1808// (inverse routine is GDTOM)
1809//
1810// If IFLAG=1 convert coordinates
1811// IFLAG=2 convert direction cosinus
1812//
1813// ---
1814 Double_t xmL[3], xdL[3];
1815 Int_t i;
1816 for (i=0;i<3;i++) xmL[i]=xm[i];
1817 if (iflag == 1) gGeoManager->MasterToLocal(xmL,xdL);
1818 else gGeoManager->MasterToLocalVect(xmL,xdL);
1819 for (i=0;i<3;i++) xd[i] = xdL[i];
1820}
1821
1822//______________________________________________________________________________
1823void TFluka::Gmtod(Double_t* xm, Double_t* xd, Int_t iflag)
1824{
1825 if (iflag == 1) gGeoManager->MasterToLocal(xm,xd);
1826 else gGeoManager->MasterToLocalVect(xm,xd);
1827}
1828
1829//______________________________________________________________________________
1830void TFluka::Gdtom(Float_t* xd, Float_t* xm, Int_t iflag)
1831{
1832// Transforms a position from the current volume reference frame
1833// to the world reference frame.
1834//
1835// Geant3 desription:
1836// ==================
1837// Computes coordinates XM (Master Reference System
1838// knowing the coordinates XD (Detector Ref System)
1839// The local reference system can be initialized by
1840// - the tracking routines and GDTOM used in GUSTEP
1841// - a call to GSCMED(NLEVEL,NAMES,NUMBER)
1842// (inverse routine is GMTOD)
1843//
1844// If IFLAG=1 convert coordinates
1845// IFLAG=2 convert direction cosinus
1846//
1847// ---
1848 Double_t xmL[3], xdL[3];
1849 Int_t i;
1850 for (i=0;i<3;i++) xdL[i] = xd[i];
1851 if (iflag == 1) gGeoManager->LocalToMaster(xdL,xmL);
1852 else gGeoManager->LocalToMasterVect(xdL,xmL);
1853 for (i=0;i<3;i++) xm[i]=xmL[i];
1854}
1855
1856//______________________________________________________________________________
1857void TFluka::Gdtom(Double_t* xd, Double_t* xm, Int_t iflag)
1858{
1859 if (iflag == 1) gGeoManager->LocalToMaster(xd,xm);
1860 else gGeoManager->LocalToMasterVect(xd,xm);
1861}
1862
1863//______________________________________________________________________________
1864TObjArray *TFluka::GetFlukaMaterials()
1865{
1866 return fGeom->GetMatList();
1867}
1868
1869//______________________________________________________________________________
1870void TFluka::SetMreg(Int_t l)
1871{
1872// Set current fluka region
1873 fCurrentFlukaRegion = l;
1874 fGeom->SetMreg(l);
1875}
1876
1877
b496f27c 1878
1879
1880TString TFluka::ParticleName(Int_t pdg) const
1881{
1882 // Return particle name for particle with pdg code pdg.
1883 Int_t ifluka = IdFromPDG(pdg);
1884 return TString((CHPPRP.btype[ifluka+6]), 8);
1885}
1886
1887
1888Double_t TFluka::ParticleMass(Int_t pdg) const
1889{
1890 // Return particle mass for particle with pdg code pdg.
1891 Int_t ifluka = IdFromPDG(pdg);
1892 return (PAPROP.am[ifluka+6]);
1893}
1894
1895Double_t TFluka::ParticleCharge(Int_t pdg) const
1896{
1897 // Return particle charge for particle with pdg code pdg.
1898 Int_t ifluka = IdFromPDG(pdg);
1899 return Double_t(PAPROP.ichrge[ifluka+6]);
1900}
1901
1902Double_t TFluka::ParticleLifeTime(Int_t pdg) const
1903{
1904 // Return particle lifetime for particle with pdg code pdg.
1905 Int_t ifluka = IdFromPDG(pdg);
81f1d030 1906 return (PAPROP.tmnlf[ifluka+6]);
b496f27c 1907}
1908
1909void TFluka::Gfpart(Int_t pdg, char* name, Int_t& type, Float_t& mass, Float_t& charge, Float_t& tlife)
1910{
1911 // Retrieve particle properties for particle with pdg code pdg.
1912
1913 strcpy(name, ParticleName(pdg).Data());
1914 type = ParticleMCType(pdg);
1915 mass = ParticleMass(pdg);
1916 charge = ParticleCharge(pdg);
1917 tlife = ParticleLifeTime(pdg);
1918}
1919
8e5bf079 1920void TFluka::PrintHeader()
1921{
1922 //
1923 // Print a header
1924 printf("\n");
1925 printf("\n");
1926 printf("------------------------------------------------------------------------------\n");
1927 printf("- You are using the TFluka Virtual Monte Carlo Interface to FLUKA. -\n");
1928 printf("- Please see the file fluka.out for FLUKA output and licensing information. -\n");
1929 printf("------------------------------------------------------------------------------\n");
1930 printf("\n");
1931 printf("\n");
1932}
1933
b496f27c 1934
1935
81f1d030 1936#define pshckp pshckp_
1937#define ustckv ustckv_
3a625972 1938
1939
1940extern "C" {
81f1d030 1941 void pshckp(Double_t & px, Double_t & py, Double_t & pz, Double_t & e,
1942 Double_t & vx, Double_t & vy, Double_t & vz, Double_t & tof,
1943 Double_t & polx, Double_t & poly, Double_t & polz, Double_t & wgt, Int_t& ntr)
1944 {
1945 //
1946 // Pushes one cerenkov photon to the stack
1947 //
1948
1949 TFluka* fluka = (TFluka*) gMC;
1950 TVirtualMCStack* cppstack = fluka->GetStack();
1951 Int_t parent = TRACKR.ispusr[mkbmx2-1];
1952 cppstack->PushTrack(0, parent, 50000050,
1953 px, py, pz, e,
1954 vx, vy, vz, tof,
1955 polx, poly, polz,
1956 kPCerenkov, ntr, wgt, 0);
1957 }
1958
1959 void ustckv(Int_t & nphot, Int_t & mreg, Double_t & x, Double_t & y, Double_t & z)
7b203b6e 1960 {
1961 //
1962 // Calls stepping in order to signal cerenkov production
1963 //
1964 TFluka *fluka = (TFluka*)gMC;
1965 fluka->SetMreg(mreg);
1966 fluka->SetXsco(x);
1967 fluka->SetYsco(y);
1968 fluka->SetZsco(z);
1969 fluka->SetNCerenkov(nphot);
1970 fluka->SetCaller(50);
d59acfe7 1971 if (fluka->GetVerbosityLevel() >= 3)
7b203b6e 1972 (TVirtualMCApplication::Instance())->Stepping();
81f1d030 1973
7b203b6e 1974 }
3a625972 1975}