]> git.uio.no Git - u/mrichter/AliRoot.git/blame - TFluka/TFluka.cxx
Fixing a memory leak.
[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"
a9ea1616 35#include "TFlukaCodes.h"
829fb838 36#include "TCallf77.h" //For the fortran calls
37#include "Fdblprc.h" //(DBLPRC) fluka common
81f1d030 38#include "Fsourcm.h" //(SOURCM) fluka common
39#include "Fgenstk.h" //(GENSTK) fluka common
829fb838 40#include "Fiounit.h" //(IOUNIT) fluka common
41#include "Fpaprop.h" //(PAPROP) fluka common
42#include "Fpart.h" //(PART) fluka common
43#include "Ftrackr.h" //(TRACKR) fluka common
44#include "Fpaprop.h" //(PAPROP) fluka common
45#include "Ffheavy.h" //(FHEAVY) fluka common
3a625972 46#include "Fopphst.h" //(OPPHST) fluka common
81f1d030 47#include "Fflkstk.h" //(FLKSTK) fluka common
07f5b33e 48#include "Fstepsz.h" //(STEPSZ) fluka common
7b203b6e 49#include "Fopphst.h" //(OPPHST) fluka common
a9ea1616 50#include "Fltclcm.h" //(LTCLCM) fluka common
f2a98602 51#include "Falldlt.h" //(ALLDLT) fluka common
829fb838 52
53#include "TVirtualMC.h"
3a625972 54#include "TMCProcess.h"
829fb838 55#include "TGeoManager.h"
56#include "TGeoMaterial.h"
57#include "TGeoMedium.h"
58#include "TFlukaMCGeometry.h"
6f5667d1 59#include "TGeoMCGeometry.h"
829fb838 60#include "TFlukaCerenkov.h"
1df5fa54 61#include "TFlukaConfigOption.h"
b496f27c 62#include "TFlukaScoringOption.h"
829fb838 63#include "TLorentzVector.h"
b496f27c 64#include "TArrayI.h"
a9ea1616 65#include "TArrayD.h"
78df7be0 66#include "TDatabasePDG.h"
4aba9d66 67#include "TStopwatch.h"
68
829fb838 69
70// Fluka methods that may be needed.
71#ifndef WIN32
72# define flukam flukam_
73# define fluka_openinp fluka_openinp_
8e5bf079 74# define fluka_openout fluka_openout_
829fb838 75# define fluka_closeinp fluka_closeinp_
76# define mcihad mcihad_
77# define mpdgha mpdgha_
2047b055 78# define newplo newplo_
4aba9d66 79# define genout genout_
80# define flkend flkend_
829fb838 81#else
82# define flukam FLUKAM
83# define fluka_openinp FLUKA_OPENINP
8e5bf079 84# define fluka_openout FLUKA_OPENOUT
829fb838 85# define fluka_closeinp FLUKA_CLOSEINP
86# define mcihad MCIHAD
87# define mpdgha MPDGHA
eea53470 88# define newplo NEWPLO
4aba9d66 89# define genout GENOUT
90# define flkend FLKEND
829fb838 91#endif
92
93extern "C"
94{
95 //
96 // Prototypes for FLUKA functions
97 //
98 void type_of_call flukam(const int&);
eea53470 99 void type_of_call newplo();
4aba9d66 100 void type_of_call genout();
101 void type_of_call flkend();
829fb838 102 void type_of_call fluka_openinp(const int&, DEFCHARA);
8e5bf079 103 void type_of_call fluka_openout(const int&, DEFCHARA);
829fb838 104 void type_of_call fluka_closeinp(const int&);
105 int type_of_call mcihad(const int&);
106 int type_of_call mpdgha(const int&);
107}
108
109//
110// Class implementation for ROOT
111//
112ClassImp(TFluka)
113
114//
115//----------------------------------------------------------------------------
116// TFluka constructors and destructors.
117//______________________________________________________________________________
118TFluka::TFluka()
119 :TVirtualMC(),
120 fVerbosityLevel(0),
4aba9d66 121 fNEvent(0),
1df5fa54 122 fInputFileName(""),
4aba9d66 123 fCoreInputFileName(""),
124 fCaller(kNoCaller),
125 fIcode(kNoProcess),
126 fNewReg(-1),
127 fRull(0),
128 fXsco(0),
129 fYsco(0),
130 fZsco(0),
131 fTrackIsEntering(kFALSE),
132 fTrackIsExiting(kFALSE),
133 fTrackIsNew(kFALSE),
134 fFieldFlag(kTRUE),
135 fGeneratePemf(kFALSE),
136 fDummyBoundary(kFALSE),
137 fStopped(kFALSE),
138 fStopEvent(kFALSE),
139 fStopRun(kFALSE),
5125d6e5 140 fPrimaryElectronIndex(-1),
4aba9d66 141 fMaterials(0),
142 fNVolumes(0),
143 fCurrentFlukaRegion(-1),
144 fNCerenkov(0),
145 fGeom(0),
146 fMCGeo(0),
fb2cbbec 147 fUserConfig(0),
1df5fa54 148 fUserScore(0)
829fb838 149{
150 //
151 // Default constructor
152 //
829fb838 153}
154
155//______________________________________________________________________________
156TFluka::TFluka(const char *title, Int_t verbosity, Bool_t isRootGeometrySupported)
157 :TVirtualMC("TFluka",title, isRootGeometrySupported),
158 fVerbosityLevel(verbosity),
4aba9d66 159 fNEvent(0),
829fb838 160 fInputFileName(""),
4aba9d66 161 fCoreInputFileName(""),
162 fCaller(kNoCaller),
163 fIcode(kNoProcess),
164 fNewReg(-1),
165 fRull(0),
166 fXsco(0),
167 fYsco(0),
168 fZsco(0),
169 fTrackIsEntering(kFALSE),
170 fTrackIsExiting(kFALSE),
171 fTrackIsNew(kFALSE),
172 fFieldFlag(kTRUE),
173 fGeneratePemf(kFALSE),
174 fDummyBoundary(kFALSE),
175 fStopped(kFALSE),
176 fStopEvent(kFALSE),
177 fStopRun(kFALSE),
5125d6e5 178 fPrimaryElectronIndex(-1),
4aba9d66 179 fMaterials(0),
180 fNVolumes(0),
181 fCurrentFlukaRegion(-1),
182 fNCerenkov(0),
183 fGeom(0),
184 fMCGeo(0),
fb2cbbec 185 fUserConfig(new TObjArray(100)),
1df5fa54 186 fUserScore(new TObjArray(100))
829fb838 187{
188 // create geometry interface
7f13be31 189 if (fVerbosityLevel >=3)
190 cout << "<== TFluka::TFluka(" << title << ") constructor called." << endl;
191 SetCoreInputFileName();
192 SetInputFileName();
11e4ab84 193 fMCGeo = new TGeoMCGeometry("MCGeo", "TGeo Implementation of VirtualMCGeometry", kFALSE);
fb2cbbec 194 fGeom = new TFlukaMCGeometry("geom", "FLUKA VMC Geometry");
829fb838 195 if (verbosity > 2) fGeom->SetDebugMode(kTRUE);
8e5bf079 196 PrintHeader();
829fb838 197}
198
199//______________________________________________________________________________
4aba9d66 200TFluka::~TFluka()
201{
202 // Destructor
1df5fa54 203 if (fVerbosityLevel >=3)
4aba9d66 204 cout << "<== TFluka::~TFluka() destructor called." << endl;
205 if (fMaterials) delete [] fMaterials;
1df5fa54 206
207 delete fGeom;
208 delete fMCGeo;
209
fb2cbbec 210 if (fUserConfig) {
4aba9d66 211 fUserConfig->Delete();
212 delete fUserConfig;
1df5fa54 213 }
6d184c54 214
215 if (fUserScore) {
4aba9d66 216 fUserScore->Delete();
217 delete fUserScore;
6d184c54 218 }
829fb838 219}
220
221//
222//______________________________________________________________________________
223// TFluka control methods
224//______________________________________________________________________________
225void TFluka::Init() {
226//
227// Geometry initialisation
228//
229 if (fVerbosityLevel >=3) cout << "==> TFluka::Init() called." << endl;
230
231 if (!gGeoManager) new TGeoManager("geom", "FLUKA geometry");
232 fApplication->ConstructGeometry();
d59acfe7 233 if (!gGeoManager->IsClosed()) {
234 TGeoVolume *top = (TGeoVolume*)gGeoManager->GetListOfVolumes()->First();
235 gGeoManager->SetTopVolume(top);
236 gGeoManager->CloseGeometry("di");
237 } else {
238 TGeoNodeCache *cache = gGeoManager->GetCache();
239 if (!cache->HasIdArray()) {
a9ea1616 240 Warning("Init", "Node ID tracking must be enabled with TFluka: enabling...\n");
d59acfe7 241 cache->BuildIdArray();
242 }
243 }
829fb838 244 fNVolumes = fGeom->NofVolumes();
245 fGeom->CreateFlukaMatFile("flukaMat.inp");
246 if (fVerbosityLevel >=3) {
247 printf("== Number of volumes: %i\n ==", fNVolumes);
248 cout << "\t* InitPhysics() - Prepare input file to be called" << endl;
6d184c54 249 }
881cb248 250
251 fApplication->InitGeometry();
78df7be0 252
253 //
254 // Add ions to PDG Data base
255 //
256 AddParticlesToPdgDataBase();
829fb838 257}
258
259
260//______________________________________________________________________________
261void TFluka::FinishGeometry() {
262//
263// Build-up table with region to medium correspondance
264//
265 if (fVerbosityLevel >=3) {
266 cout << "==> TFluka::FinishGeometry() called." << endl;
267 printf("----FinishGeometry - nothing to do with TGeo\n");
268 cout << "<== TFluka::FinishGeometry() called." << endl;
269 }
270}
271
272//______________________________________________________________________________
273void TFluka::BuildPhysics() {
274//
275// Prepare FLUKA input files and call FLUKA physics initialisation
276//
277
278 if (fVerbosityLevel >=3)
4aba9d66 279 cout << "==> TFluka::BuildPhysics() called." << endl;
6d184c54 280
281
282 if (fVerbosityLevel >=3) {
4aba9d66 283 TList *medlist = gGeoManager->GetListOfMedia();
284 TIter next(medlist);
285 TGeoMedium* med = 0x0;
286 TGeoMaterial* mat = 0x0;
287 Int_t ic = 0;
288
289 while((med = (TGeoMedium*)next()))
290 {
291 mat = med->GetMaterial();
292 printf("Medium %5d %12s %5d %5d\n", ic, (med->GetName()), med->GetId(), mat->GetIndex());
293 ic++;
294 }
6d184c54 295 }
296
297 //
298 // At this stage we have the information on materials and cuts available.
299 // Now create the pemf file
300
301 if (fGeneratePemf) fGeom->CreatePemfFile();
302
303 //
304 // Prepare input file with the current physics settings
305
829fb838 306 InitPhysics();
b8a8a88c 307// Open fortran files
829fb838 308 const char* fname = fInputFileName;
309 fluka_openinp(lunin, PASSCHARA(fname));
8e5bf079 310 fluka_openout(11, PASSCHARA("fluka.out"));
b8a8a88c 311// Read input cards
4aba9d66 312 cout << "==> TFluka::BuildPhysics() Read input cards." << endl;
313 TStopwatch timer;
314 timer.Start();
b8a8a88c 315 GLOBAL.lfdrtr = true;
829fb838 316 flukam(1);
4aba9d66 317 cout << "<== TFluka::BuildPhysics() Read input cards End"
318 << Form(" R:%.2fs C:%.2fs", timer.RealTime(),timer.CpuTime()) << endl;
b8a8a88c 319// Close input file
829fb838 320 fluka_closeinp(lunin);
b8a8a88c 321// Finish geometry
829fb838 322 FinishGeometry();
829fb838 323}
324
325//______________________________________________________________________________
326void TFluka::ProcessEvent() {
327//
328// Process one event
329//
b496f27c 330 if (fStopRun) {
4aba9d66 331 Warning("ProcessEvent", "User Run Abortion: No more events handled !\n");
332 fNEvent += 1;
333 return;
b496f27c 334 }
335
336 if (fVerbosityLevel >=3)
4aba9d66 337 cout << "==> TFluka::ProcessEvent() called." << endl;
b496f27c 338 fApplication->GeneratePrimaries();
81f1d030 339 SOURCM.lsouit = true;
b496f27c 340 flukam(1);
341 if (fVerbosityLevel >=3)
4aba9d66 342 cout << "<== TFluka::ProcessEvent() called." << endl;
b496f27c 343 //
344 // Increase event number
345 //
346 fNEvent += 1;
829fb838 347}
348
349//______________________________________________________________________________
350Bool_t TFluka::ProcessRun(Int_t nevent) {
351//
352// Run steering
353//
354
355 if (fVerbosityLevel >=3)
356 cout << "==> TFluka::ProcessRun(" << nevent << ") called."
4aba9d66 357 << endl;
829fb838 358
359 if (fVerbosityLevel >=2) {
360 cout << "\t* GLOBAL.fdrtr = " << (GLOBAL.lfdrtr?'T':'F') << endl;
361 cout << "\t* Calling flukam again..." << endl;
362 }
363
829fb838 364 Int_t todo = TMath::Abs(nevent);
365 for (Int_t ev = 0; ev < todo; ev++) {
4aba9d66 366 TStopwatch timer;
367 timer.Start();
829fb838 368 fApplication->BeginEvent();
369 ProcessEvent();
370 fApplication->FinishEvent();
4aba9d66 371 cout << "Event: "<< ev
372 << Form(" R:%.2fs C:%.2fs", timer.RealTime(),timer.CpuTime()) << endl;
829fb838 373 }
374
375 if (fVerbosityLevel >=3)
376 cout << "<== TFluka::ProcessRun(" << nevent << ") called."
4aba9d66 377 << endl;
378
eea53470 379 // Write fluka specific scoring output
4aba9d66 380 genout();
eea53470 381 newplo();
4aba9d66 382 flkend();
eea53470 383
829fb838 384 return kTRUE;
385}
386
387//_____________________________________________________________________________
388// methods for building/management of geometry
389
390// functions from GCONS
391//____________________________________________________________________________
392void TFluka::Gfmate(Int_t imat, char *name, Float_t &a, Float_t &z,
4aba9d66 393 Float_t &dens, Float_t &radl, Float_t &absl,
394 Float_t* /*ubuf*/, Int_t& /*nbuf*/) {
829fb838 395//
396 TGeoMaterial *mat;
397 TIter next (gGeoManager->GetListOfMaterials());
398 while ((mat = (TGeoMaterial*)next())) {
399 if (mat->GetUniqueID() == (UInt_t)imat) break;
400 }
401 if (!mat) {
402 Error("Gfmate", "no material with index %i found", imat);
403 return;
404 }
405 sprintf(name, "%s", mat->GetName());
406 a = mat->GetA();
407 z = mat->GetZ();
408 dens = mat->GetDensity();
409 radl = mat->GetRadLen();
410 absl = mat->GetIntLen();
411}
412
413//______________________________________________________________________________
414void TFluka::Gfmate(Int_t imat, char *name, Double_t &a, Double_t &z,
4aba9d66 415 Double_t &dens, Double_t &radl, Double_t &absl,
416 Double_t* /*ubuf*/, Int_t& /*nbuf*/) {
829fb838 417//
418 TGeoMaterial *mat;
419 TIter next (gGeoManager->GetListOfMaterials());
420 while ((mat = (TGeoMaterial*)next())) {
421 if (mat->GetUniqueID() == (UInt_t)imat) break;
422 }
423 if (!mat) {
424 Error("Gfmate", "no material with index %i found", imat);
425 return;
426 }
427 sprintf(name, "%s", mat->GetName());
428 a = mat->GetA();
429 z = mat->GetZ();
430 dens = mat->GetDensity();
431 radl = mat->GetRadLen();
432 absl = mat->GetIntLen();
433}
434
435// detector composition
436//______________________________________________________________________________
437void TFluka::Material(Int_t& kmat, const char* name, Double_t a,
4aba9d66 438 Double_t z, Double_t dens, Double_t radl, Double_t absl,
439 Float_t* buf, Int_t nwbuf) {
829fb838 440//
441 Double_t* dbuf = fGeom->CreateDoubleArray(buf, nwbuf);
442 Material(kmat, name, a, z, dens, radl, absl, dbuf, nwbuf);
443 delete [] dbuf;
444}
445
446//______________________________________________________________________________
447void TFluka::Material(Int_t& kmat, const char* name, Double_t a,
4aba9d66 448 Double_t z, Double_t dens, Double_t radl, Double_t absl,
449 Double_t* /*buf*/, Int_t /*nwbuf*/) {
829fb838 450//
fb2cbbec 451// Define a material
829fb838 452 TGeoMaterial *mat;
453 kmat = gGeoManager->GetListOfMaterials()->GetSize();
454 if ((z-Int_t(z)) > 1E-3) {
455 mat = fGeom->GetMakeWrongMaterial(z);
456 if (mat) {
457 mat->SetRadLen(radl,absl);
458 mat->SetUniqueID(kmat);
459 return;
460 }
461 }
462 gGeoManager->Material(name, a, z, dens, kmat, radl, absl);
463}
464
465//______________________________________________________________________________
466void TFluka::Mixture(Int_t& kmat, const char *name, Float_t *a,
4aba9d66 467 Float_t *z, Double_t dens, Int_t nlmat, Float_t *wmat) {
fb2cbbec 468//
469// Define a material mixture
829fb838 470//
471 Double_t* da = fGeom->CreateDoubleArray(a, TMath::Abs(nlmat));
472 Double_t* dz = fGeom->CreateDoubleArray(z, TMath::Abs(nlmat));
473 Double_t* dwmat = fGeom->CreateDoubleArray(wmat, TMath::Abs(nlmat));
474
475 Mixture(kmat, name, da, dz, dens, nlmat, dwmat);
476 for (Int_t i=0; i<nlmat; i++) {
477 a[i] = da[i]; z[i] = dz[i]; wmat[i] = dwmat[i];
478 }
479
480 delete [] da;
481 delete [] dz;
482 delete [] dwmat;
483}
484
485//______________________________________________________________________________
486void TFluka::Mixture(Int_t& kmat, const char *name, Double_t *a,
4aba9d66 487 Double_t *z, Double_t dens, Int_t nlmat, Double_t *wmat) {
829fb838 488//
489 // Defines mixture OR COMPOUND IMAT as composed by
490 // THE BASIC NLMAT materials defined by arrays A,Z and WMAT
491 //
492 // If NLMAT > 0 then wmat contains the proportion by
493 // weights of each basic material in the mixture.
494 //
495 // If nlmat < 0 then WMAT contains the number of atoms
496 // of a given kind into the molecule of the COMPOUND
497 // In this case, WMAT in output is changed to relative
498 // weigths.
499 //
500 Int_t i,j;
501 if (nlmat < 0) {
502 nlmat = - nlmat;
503 Double_t amol = 0;
504 for (i=0;i<nlmat;i++) {
505 amol += a[i]*wmat[i];
506 }
507 for (i=0;i<nlmat;i++) {
508 wmat[i] *= a[i]/amol;
509 }
510 }
511 kmat = gGeoManager->GetListOfMaterials()->GetSize();
512 // Check if we have elements with fractional Z
513 TGeoMaterial *mat = 0;
514 TGeoMixture *mix = 0;
515 Bool_t mixnew = kFALSE;
516 for (i=0; i<nlmat; i++) {
517 if (z[i]-Int_t(z[i]) < 1E-3) continue;
518 // We have found an element with fractional Z -> loop mixtures to look for it
519 for (j=0; j<kmat; j++) {
520 mat = (TGeoMaterial*)gGeoManager->GetListOfMaterials()->At(j);
521 if (!mat) break;
522 if (!mat->IsMixture()) continue;
523 mix = (TGeoMixture*)mat;
524 if (TMath::Abs(z[i]-mix->GetZ()) >1E-3) continue;
829fb838 525 mixnew = kTRUE;
526 break;
527 }
528 if (!mixnew) Warning("Mixture","%s : cannot find component %i with fractional Z=%f\n", name, i, z[i]);
529 break;
530 }
531 if (mixnew) {
532 Int_t nlmatnew = nlmat+mix->GetNelements()-1;
533 Double_t *anew = new Double_t[nlmatnew];
534 Double_t *znew = new Double_t[nlmatnew];
535 Double_t *wmatnew = new Double_t[nlmatnew];
536 Int_t ind=0;
537 for (j=0; j<nlmat; j++) {
538 if (j==i) continue;
539 anew[ind] = a[j];
540 znew[ind] = z[j];
541 wmatnew[ind] = wmat[j];
542 ind++;
543 }
544 for (j=0; j<mix->GetNelements(); j++) {
545 anew[ind] = mix->GetAmixt()[j];
546 znew[ind] = mix->GetZmixt()[j];
547 wmatnew[ind] = wmat[i]*mix->GetWmixt()[j];
548 ind++;
549 }
550 Mixture(kmat, name, anew, znew, dens, nlmatnew, wmatnew);
551 delete [] anew;
552 delete [] znew;
553 delete [] wmatnew;
554 return;
555 }
556 // Now we need to compact identical elements within the mixture
557 // First check if this happens
558 mixnew = kFALSE;
559 for (i=0; i<nlmat-1; i++) {
560 for (j=i+1; j<nlmat; j++) {
561 if (z[i] == z[j]) {
562 mixnew = kTRUE;
563 break;
564 }
565 }
566 if (mixnew) break;
567 }
568 if (mixnew) {
569 Int_t nlmatnew = 0;
570 Double_t *anew = new Double_t[nlmat];
571 Double_t *znew = new Double_t[nlmat];
572 memset(znew, 0, nlmat*sizeof(Double_t));
573 Double_t *wmatnew = new Double_t[nlmat];
574 Bool_t skipi;
575 for (i=0; i<nlmat; i++) {
576 skipi = kFALSE;
577 for (j=0; j<nlmatnew; j++) {
578 if (z[i] == z[j]) {
579 wmatnew[j] += wmat[i];
580 skipi = kTRUE;
581 break;
582 }
583 }
584 if (skipi) continue;
585 anew[nlmatnew] = a[i];
586 znew[nlmatnew] = z[i];
587 wmatnew[nlmatnew] = wmat[i];
588 nlmatnew++;
589 }
590 Mixture(kmat, name, anew, znew, dens, nlmatnew, wmatnew);
591 delete [] anew;
592 delete [] znew;
593 delete [] wmatnew;
594 return;
595 }
596 gGeoManager->Mixture(name, a, z, dens, nlmat, wmat, kmat);
597}
598
599//______________________________________________________________________________
600void TFluka::Medium(Int_t& kmed, const char *name, Int_t nmat,
4aba9d66 601 Int_t isvol, Int_t ifield, Double_t fieldm, Double_t tmaxfd,
602 Double_t stemax, Double_t deemax, Double_t epsil,
603 Double_t stmin, Float_t* ubuf, Int_t nbuf) {
b2129742 604 // Define a medium
605 //
829fb838 606 kmed = gGeoManager->GetListOfMedia()->GetSize()+1;
607 fMCGeo->Medium(kmed, name, nmat, isvol, ifield, fieldm, tmaxfd, stemax, deemax,
4aba9d66 608 epsil, stmin, ubuf, nbuf);
829fb838 609}
610
611//______________________________________________________________________________
612void TFluka::Medium(Int_t& kmed, const char *name, Int_t nmat,
4aba9d66 613 Int_t isvol, Int_t ifield, Double_t fieldm, Double_t tmaxfd,
614 Double_t stemax, Double_t deemax, Double_t epsil,
615 Double_t stmin, Double_t* ubuf, Int_t nbuf) {
b2129742 616 // Define a medium
617 //
829fb838 618 kmed = gGeoManager->GetListOfMedia()->GetSize()+1;
619 fMCGeo->Medium(kmed, name, nmat, isvol, ifield, fieldm, tmaxfd, stemax, deemax,
4aba9d66 620 epsil, stmin, ubuf, nbuf);
829fb838 621}
622
623//______________________________________________________________________________
624void TFluka::Matrix(Int_t& krot, Double_t thetaX, Double_t phiX,
4aba9d66 625 Double_t thetaY, Double_t phiY, Double_t thetaZ,
626 Double_t phiZ) {
627//
829fb838 628 krot = gGeoManager->GetListOfMatrices()->GetEntriesFast();
629 fMCGeo->Matrix(krot, thetaX, phiX, thetaY, phiY, thetaZ, phiZ);
630}
631
632//______________________________________________________________________________
633void TFluka::Gstpar(Int_t itmed, const char* param, Double_t parval) {
634//
635//
7b203b6e 636//
829fb838 637 Bool_t process = kFALSE;
acf2e119 638 Bool_t modelp = kFALSE;
639
829fb838 640 if (strncmp(param, "DCAY", 4) == 0 ||
641 strncmp(param, "PAIR", 4) == 0 ||
642 strncmp(param, "COMP", 4) == 0 ||
643 strncmp(param, "PHOT", 4) == 0 ||
644 strncmp(param, "PFIS", 4) == 0 ||
645 strncmp(param, "DRAY", 4) == 0 ||
646 strncmp(param, "ANNI", 4) == 0 ||
647 strncmp(param, "BREM", 4) == 0 ||
648 strncmp(param, "MUNU", 4) == 0 ||
649 strncmp(param, "CKOV", 4) == 0 ||
650 strncmp(param, "HADR", 4) == 0 ||
651 strncmp(param, "LOSS", 4) == 0 ||
652 strncmp(param, "MULS", 4) == 0 ||
653 strncmp(param, "RAYL", 4) == 0)
654 {
655 process = kTRUE;
656 }
81f1d030 657
acf2e119 658 if (strncmp(param, "PRIMIO_N", 8) == 0 ||
659 strncmp(param, "PRIMIO_E", 8) == 0)
660 {
661 modelp = kTRUE;
662 }
663
829fb838 664 if (process) {
acf2e119 665 // Process switch
81f1d030 666 SetProcess(param, Int_t (parval), itmed);
acf2e119 667 } else if (modelp) {
668 // Model parameters
669 SetModelParameter(param, parval, itmed);
829fb838 670 } else {
acf2e119 671 // Cuts
81f1d030 672 SetCut(param, parval, itmed);
829fb838 673 }
acf2e119 674
675
829fb838 676}
677
678// functions from GGEOM
679//_____________________________________________________________________________
680void TFluka::Gsatt(const char *name, const char *att, Int_t val)
681{
6f5667d1 682 // Set visualisation attributes for one volume
829fb838 683 char vname[5];
684 fGeom->Vname(name,vname);
685 char vatt[5];
686 fGeom->Vname(att,vatt);
687 gGeoManager->SetVolumeAttribute(vname, vatt, val);
688}
689
690//______________________________________________________________________________
691Int_t TFluka::Gsvolu(const char *name, const char *shape, Int_t nmed,
4aba9d66 692 Float_t *upar, Int_t np) {
829fb838 693//
694 return fMCGeo->Gsvolu(name, shape, nmed, upar, np);
695}
696
697//______________________________________________________________________________
698Int_t TFluka::Gsvolu(const char *name, const char *shape, Int_t nmed,
4aba9d66 699 Double_t *upar, Int_t np) {
829fb838 700//
701 return fMCGeo->Gsvolu(name, shape, nmed, upar, np);
702}
703
704//______________________________________________________________________________
705void TFluka::Gsdvn(const char *name, const char *mother, Int_t ndiv,
4aba9d66 706 Int_t iaxis) {
829fb838 707//
708 fMCGeo->Gsdvn(name, mother, ndiv, iaxis);
709}
710
711//______________________________________________________________________________
712void TFluka::Gsdvn2(const char *name, const char *mother, Int_t ndiv,
4aba9d66 713 Int_t iaxis, Double_t c0i, Int_t numed) {
829fb838 714//
715 fMCGeo->Gsdvn2(name, mother, ndiv, iaxis, c0i, numed);
716}
717
718//______________________________________________________________________________
719void TFluka::Gsdvt(const char *name, const char *mother, Double_t step,
4aba9d66 720 Int_t iaxis, Int_t numed, Int_t ndvmx) {
721//
829fb838 722 fMCGeo->Gsdvt(name, mother, step, iaxis, numed, ndvmx);
723}
724
725//______________________________________________________________________________
726void TFluka::Gsdvt2(const char *name, const char *mother, Double_t step,
4aba9d66 727 Int_t iaxis, Double_t c0, Int_t numed, Int_t ndvmx) {
829fb838 728//
729 fMCGeo->Gsdvt2(name, mother, step, iaxis, c0, numed, ndvmx);
730}
731
732//______________________________________________________________________________
733void TFluka::Gsord(const char * /*name*/, Int_t /*iax*/) {
734//
735// Nothing to do with TGeo
736}
737
738//______________________________________________________________________________
739void TFluka::Gspos(const char *name, Int_t nr, const char *mother,
4aba9d66 740 Double_t x, Double_t y, Double_t z, Int_t irot,
741 const char *konly) {
829fb838 742//
743 fMCGeo->Gspos(name, nr, mother, x, y, z, irot, konly);
744}
745
746//______________________________________________________________________________
747void TFluka::Gsposp(const char *name, Int_t nr, const char *mother,
4aba9d66 748 Double_t x, Double_t y, Double_t z, Int_t irot,
749 const char *konly, Float_t *upar, Int_t np) {
829fb838 750 //
751 fMCGeo->Gsposp(name, nr, mother, x, y, z, irot, konly, upar, np);
752}
753
754//______________________________________________________________________________
755void TFluka::Gsposp(const char *name, Int_t nr, const char *mother,
4aba9d66 756 Double_t x, Double_t y, Double_t z, Int_t irot,
757 const char *konly, Double_t *upar, Int_t np) {
829fb838 758 //
759 fMCGeo->Gsposp(name, nr, mother, x, y, z, irot, konly, upar, np);
760}
761
762//______________________________________________________________________________
763void TFluka::Gsbool(const char* /*onlyVolName*/, const char* /*manyVolName*/) {
764//
765// Nothing to do with TGeo
766}
767
a9ea1616 768//______________________________________________________________________
769Bool_t TFluka::GetTransformation(const TString &volumePath,TGeoHMatrix &mat)
770{
771 // Returns the Transformation matrix between the volume specified
772 // by the path volumePath and the Top or mater volume. The format
773 // of the path volumePath is as follows (assuming ALIC is the Top volume)
774 // "/ALIC_1/DDIP_1/S05I_2/S05H_1/S05G_3". Here ALIC is the top most
775 // or master volume which has only 1 instance of. Of all of the daughter
776 // volumes of ALICE, DDIP volume copy #1 is indicated. Similarly for
777 // the daughter volume of DDIP is S05I copy #2 and so on.
778 // Inputs:
779 // TString& volumePath The volume path to the specific volume
780 // for which you want the matrix. Volume name
781 // hierarchy is separated by "/" while the
782 // copy number is appended using a "_".
783 // Outputs:
784 // TGeoHMatrix &mat A matrix with its values set to those
785 // appropriate to the Local to Master transformation
786 // Return:
787 // A logical value if kFALSE then an error occurred and no change to
788 // mat was made.
789
790 // We have to preserve the modeler state
791 return fMCGeo->GetTransformation(volumePath, mat);
792}
793
794//______________________________________________________________________
795Bool_t TFluka::GetShape(const TString &volumePath,TString &shapeType,
796 TArrayD &par)
797{
798 // Returns the shape and its parameters for the volume specified
799 // by volumeName.
800 // Inputs:
801 // TString& volumeName The volume name
802 // Outputs:
803 // TString &shapeType Shape type
804 // TArrayD &par A TArrayD of parameters with all of the
805 // parameters of the specified shape.
806 // Return:
807 // A logical indicating whether there was an error in getting this
808 // information
809 return fMCGeo->GetShape(volumePath, shapeType, par);
810}
811
812//______________________________________________________________________
813Bool_t TFluka::GetMaterial(const TString &volumeName,
814 TString &name,Int_t &imat,
815 Double_t &a,Double_t &z,Double_t &dens,
816 Double_t &radl,Double_t &inter,TArrayD &par)
817{
818 // Returns the Material and its parameters for the volume specified
819 // by volumeName.
820 // Note, Geant3 stores and uses mixtures as an element with an effective
821 // Z and A. Consequently, if the parameter Z is not integer, then
822 // this material represents some sort of mixture.
823 // Inputs:
824 // TString& volumeName The volume name
825 // Outputs:
826 // TSrting &name Material name
827 // Int_t &imat Material index number
828 // Double_t &a Average Atomic mass of material
829 // Double_t &z Average Atomic number of material
830 // Double_t &dens Density of material [g/cm^3]
831 // Double_t &radl Average radiation length of material [cm]
832 // Double_t &inter Average interaction length of material [cm]
833 // TArrayD &par A TArrayD of user defined parameters.
834 // Return:
835 // kTRUE if no errors
836 return fMCGeo->GetMaterial(volumeName,name,imat,a,z,dens,radl,inter,par);
837}
838
839//______________________________________________________________________
840Bool_t TFluka::GetMedium(const TString &volumeName,TString &name,
841 Int_t &imed,Int_t &nmat,Int_t &isvol,Int_t &ifield,
842 Double_t &fieldm,Double_t &tmaxfd,Double_t &stemax,
843 Double_t &deemax,Double_t &epsil, Double_t &stmin,
844 TArrayD &par)
845{
846 // Returns the Medium and its parameters for the volume specified
847 // by volumeName.
848 // Inputs:
849 // TString& volumeName The volume name.
850 // Outputs:
851 // TString &name Medium name
852 // Int_t &nmat Material number defined for this medium
853 // Int_t &imed The medium index number
854 // Int_t &isvol volume number defined for this medium
855 // Int_t &iflield Magnetic field flag
856 // Double_t &fieldm Magnetic field strength
857 // Double_t &tmaxfd Maximum angle of deflection per step
858 // Double_t &stemax Maximum step size
859 // Double_t &deemax Maximum fraction of energy allowed to be lost
860 // to continuous process.
861 // Double_t &epsil Boundary crossing precision
862 // Double_t &stmin Minimum step size allowed
863 // TArrayD &par A TArrayD of user parameters with all of the
864 // parameters of the specified medium.
865 // Return:
866 // kTRUE if there where no errors
867 return fMCGeo->GetMedium(volumeName,name,imed,nmat,isvol,ifield,fieldm,tmaxfd,stemax,deemax,epsil,stmin,par);
868}
869
829fb838 870//______________________________________________________________________________
871void TFluka::SetCerenkov(Int_t itmed, Int_t npckov, Float_t* ppckov,
4aba9d66 872 Float_t* absco, Float_t* effic, Float_t* rindex) {
829fb838 873//
874// Set Cerenkov properties for medium itmed
875//
876// npckov: number of sampling points
877// ppckov: energy values
878// absco: absorption length
879// effic: quantum efficiency
880// rindex: refraction index
881//
882//
883//
884// Create object holding Cerenkov properties
885//
886 TFlukaCerenkov* cerenkovProperties = new TFlukaCerenkov(npckov, ppckov, absco, effic, rindex);
887//
888// Pass object to medium
889 TGeoMedium* medium = gGeoManager->GetMedium(itmed);
890 medium->SetCerenkovProperties(cerenkovProperties);
891}
892
b2be0e73 893void TFluka::SetCerenkov(Int_t itmed, Int_t npckov, Float_t* ppckov,
4aba9d66 894 Float_t* absco, Float_t* effic, Float_t* rindex, Float_t* rfl) {
b2be0e73 895//
896// Set Cerenkov properties for medium itmed
897//
898// npckov: number of sampling points
899// ppckov: energy values
900// absco: absorption length
901// effic: quantum efficiency
902// rindex: refraction index
903// rfl: reflectivity for boundary to medium itmed
904//
905//
906// Create object holding Cerenkov properties
907//
908 TFlukaCerenkov* cerenkovProperties = new TFlukaCerenkov(npckov, ppckov, absco, effic, rindex, rfl);
909//
910// Pass object to medium
911 TGeoMedium* medium = gGeoManager->GetMedium(itmed);
912 medium->SetCerenkovProperties(cerenkovProperties);
913}
914
915
829fb838 916//______________________________________________________________________________
917void TFluka::SetCerenkov(Int_t /*itmed*/, Int_t /*npckov*/, Double_t * /*ppckov*/,
4aba9d66 918 Double_t * /*absco*/, Double_t * /*effic*/, Double_t * /*rindex*/) {
829fb838 919//
b2be0e73 920// Double_t version not implemented
829fb838 921}
b2be0e73 922
923void TFluka::SetCerenkov(Int_t /*itmed*/, Int_t /*npckov*/, Double_t* /*ppckov*/,
4aba9d66 924 Double_t* /*absco*/, Double_t* /*effic*/, Double_t* /*rindex*/, Double_t* /*rfl*/) {
b2be0e73 925//
926// // Double_t version not implemented
927}
928
829fb838 929// Euclid
930//______________________________________________________________________________
931void TFluka::WriteEuclid(const char* /*fileName*/, const char* /*topVol*/,
932 Int_t /*number*/, Int_t /*nlevel*/) {
933//
934// Not with TGeo
a9ea1616 935 Warning("WriteEuclid", "Not implemented !");
829fb838 936}
937
938
939
940//_____________________________________________________________________________
941// methods needed by the stepping
942//____________________________________________________________________________
943
944Int_t TFluka::GetMedium() const {
945//
946// Get the medium number for the current fluka region
947//
948 return fGeom->GetMedium(); // this I need to check due to remapping !!!
949}
950
a9ea1616 951//____________________________________________________________________________
952Int_t TFluka::GetDummyRegion() const
953{
954// Returns index of the dummy region.
955 return fGeom->GetDummyRegion();
956}
829fb838 957
a9ea1616 958//____________________________________________________________________________
959Int_t TFluka::GetDummyLattice() const
960{
961// Returns index of the dummy lattice.
962 return fGeom->GetDummyLattice();
963}
829fb838 964
965//____________________________________________________________________________
966// particle table usage
967// ID <--> PDG transformations
968//_____________________________________________________________________________
969Int_t TFluka::IdFromPDG(Int_t pdg) const
970{
971 //
972 // Return Fluka code from PDG and pseudo ENDF code
973
974 // Catch the feedback photons
a9ea1616 975 if (pdg == 50000051) return (kFLUKAoptical);
829fb838 976 // MCIHAD() goes from pdg to fluka internal.
977 Int_t intfluka = mcihad(pdg);
978 // KPTOIP array goes from internal to official
979 return GetFlukaKPTOIP(intfluka);
980}
981
982//______________________________________________________________________________
983Int_t TFluka::PDGFromId(Int_t id) const
984{
985 //
986 // Return PDG code and pseudo ENDF code from Fluka code
f926898e 987 // Alpha He3 Triton Deuteron gen. ion opt. photon
988 Int_t idSpecial[6] = {10020040, 10020030, 10010030, 10010020, 10000000, 50000050};
829fb838 989 // IPTOKP array goes from official to internal
990
a9ea1616 991 if (id == kFLUKAoptical) {
829fb838 992// Cerenkov photon
4aba9d66 993// if (fVerbosityLevel >= 3)
994// printf("\n PDGFromId: Cerenkov Photon \n");
995 return 50000050;
829fb838 996 }
997// Error id
ece92b30 998 if (id == 0 || id < kFLUKAcodemin || id > kFLUKAcodemax) {
4aba9d66 999 if (fVerbosityLevel >= 3)
1000 printf("PDGFromId: Error id = 0\n");
1001 return -1;
829fb838 1002 }
1003// Good id
f926898e 1004 if (id > 0) {
4aba9d66 1005 Int_t intfluka = GetFlukaIPTOKP(id);
1006 if (intfluka == 0) {
1007 if (fVerbosityLevel >= 3)
1008 printf("PDGFromId: Error intfluka = 0: %d\n", id);
1009 return -1;
1010 } else if (intfluka < 0) {
1011 if (fVerbosityLevel >= 3)
1012 printf("PDGFromId: Error intfluka < 0: %d\n", id);
1013 return -1;
1014 }
1015// if (fVerbosityLevel >= 3)
1016// printf("mpdgha called with %d %d \n", id, intfluka);
1017 return mpdgha(intfluka);
f926898e 1018 } else {
4aba9d66 1019 // ions and optical photons
1020 return idSpecial[id - kFLUKAcodemin];
829fb838 1021 }
829fb838 1022}
1023
bd3d5c8a 1024void TFluka::StopTrack()
1025{
1026 // Set stopping conditions
1027 // Works for photons and charged particles
1028 fStopped = kTRUE;
1029}
1030
829fb838 1031//_____________________________________________________________________________
1032// methods for physics management
1033//____________________________________________________________________________
1034//
1035// set methods
1036//
1037
1df5fa54 1038void TFluka::SetProcess(const char* flagName, Int_t flagValue, Int_t imed)
829fb838 1039{
1040// Set process user flag for material imat
1df5fa54 1041//
1042//
1043// Update if already in the list
829fb838 1044//
fb2cbbec 1045 TIter next(fUserConfig);
1df5fa54 1046 TFlukaConfigOption* proc;
1047 while((proc = (TFlukaConfigOption*)next()))
1048 {
4aba9d66 1049 if (proc->Medium() == imed) {
1050 proc->SetProcess(flagName, flagValue);
1051 return;
1052 }
1df5fa54 1053 }
fb2cbbec 1054 proc = new TFlukaConfigOption(imed);
1055 proc->SetProcess(flagName, flagValue);
1056 fUserConfig->Add(proc);
1057}
1058
1059//______________________________________________________________________________
1060Bool_t TFluka::SetProcess(const char* flagName, Int_t flagValue)
1061{
1062// Set process user flag
1df5fa54 1063//
1df5fa54 1064//
fb2cbbec 1065 SetProcess(flagName, flagValue, -1);
1df5fa54 1066 return kTRUE;
829fb838 1067}
1068
1069//______________________________________________________________________________
1070void TFluka::SetCut(const char* cutName, Double_t cutValue, Int_t imed)
1071{
1072// Set user cut value for material imed
1073//
fb2cbbec 1074 TIter next(fUserConfig);
1075 TFlukaConfigOption* proc;
1076 while((proc = (TFlukaConfigOption*)next()))
1077 {
4aba9d66 1078 if (proc->Medium() == imed) {
1079 proc->SetCut(cutName, cutValue);
1080 return;
1081 }
fb2cbbec 1082 }
1083
1084 proc = new TFlukaConfigOption(imed);
1085 proc->SetCut(cutName, cutValue);
1086 fUserConfig->Add(proc);
829fb838 1087}
1088
acf2e119 1089
1090//______________________________________________________________________________
1091void TFluka::SetModelParameter(const char* parName, Double_t parValue, Int_t imed)
1092{
1093// Set model parameter for material imed
1094//
1095 TIter next(fUserConfig);
1096 TFlukaConfigOption* proc;
1097 while((proc = (TFlukaConfigOption*)next()))
1098 {
4aba9d66 1099 if (proc->Medium() == imed) {
1100 proc->SetModelParameter(parName, parValue);
1101 return;
1102 }
acf2e119 1103 }
1104
1105 proc = new TFlukaConfigOption(imed);
1106 proc->SetModelParameter(parName, parValue);
1107 fUserConfig->Add(proc);
1108}
1109
829fb838 1110//______________________________________________________________________________
1111Bool_t TFluka::SetCut(const char* cutName, Double_t cutValue)
1112{
1113// Set user cut value
1114//
1df5fa54 1115//
fb2cbbec 1116 SetCut(cutName, cutValue, -1);
1117 return kTRUE;
829fb838 1118}
1119
f450e9d0 1120
1121void TFluka::SetUserScoring(const char* option, Int_t npr, char* outfile, Float_t* what)
b496f27c 1122{
1123//
f450e9d0 1124// Adds a user scoring option to the list
b496f27c 1125//
f450e9d0 1126 TFlukaScoringOption* opt = new TFlukaScoringOption(option, "User Scoring", npr,outfile,what);
1127 fUserScore->Add(opt);
1128}
1129//______________________________________________________________________________
1130void TFluka::SetUserScoring(const char* option, Int_t npr, char* outfile, Float_t* what, const char* det1, const char* det2, const char* det3)
1131{
1132//
1133// Adds a user scoring option to the list
1134//
1135 TFlukaScoringOption* opt = new TFlukaScoringOption(option, "User Scoring", npr, outfile, what, det1, det2, det3);
b496f27c 1136 fUserScore->Add(opt);
1137}
b496f27c 1138
829fb838 1139//______________________________________________________________________________
1140Double_t TFluka::Xsec(char*, Double_t, Int_t, Int_t)
1141{
a9ea1616 1142 Warning("Xsec", "Not yet implemented.!\n"); return -1.;
829fb838 1143}
1144
1145
1146//______________________________________________________________________________
1147void TFluka::InitPhysics()
1148{
1149//
1150// Physics initialisation with preparation of FLUKA input cards
1151//
fb2cbbec 1152// Construct file names
1153 FILE *pFlukaVmcCoreInp, *pFlukaVmcFlukaMat, *pFlukaVmcInp;
1154 TString sFlukaVmcCoreInp = getenv("ALICE_ROOT");
1155 sFlukaVmcCoreInp +="/TFluka/input/";
1156 TString sFlukaVmcTmp = "flukaMat.inp";
1157 TString sFlukaVmcInp = GetInputFileName();
1158 sFlukaVmcCoreInp += GetCoreInputFileName();
1159
1160// Open files
1161 if ((pFlukaVmcCoreInp = fopen(sFlukaVmcCoreInp.Data(),"r")) == NULL) {
4aba9d66 1162 Warning("InitPhysics", "\nCannot open file %s\n",sFlukaVmcCoreInp.Data());
1163 exit(1);
fb2cbbec 1164 }
1165 if ((pFlukaVmcFlukaMat = fopen(sFlukaVmcTmp.Data(),"r")) == NULL) {
4aba9d66 1166 Warning("InitPhysics", "\nCannot open file %s\n",sFlukaVmcTmp.Data());
1167 exit(1);
fb2cbbec 1168 }
1169 if ((pFlukaVmcInp = fopen(sFlukaVmcInp.Data(),"w")) == NULL) {
4aba9d66 1170 Warning("InitPhysics", "\nCannot open file %s\n",sFlukaVmcInp.Data());
1171 exit(1);
fb2cbbec 1172 }
829fb838 1173
fb2cbbec 1174// Copy core input file
1175 Char_t sLine[255];
1176 Float_t fEventsPerRun;
829fb838 1177
fb2cbbec 1178 while ((fgets(sLine,255,pFlukaVmcCoreInp)) != NULL) {
4aba9d66 1179 if (strncmp(sLine,"GEOEND",6) != 0)
1180 fprintf(pFlukaVmcInp,"%s",sLine); // copy until GEOEND card
1181 else {
1182 fprintf(pFlukaVmcInp,"GEOEND\n"); // add GEOEND card
1183 goto flukamat;
1184 }
fb2cbbec 1185 } // end of while until GEOEND card
1186
829fb838 1187
fb2cbbec 1188 flukamat:
1189 while ((fgets(sLine,255,pFlukaVmcFlukaMat)) != NULL) { // copy flukaMat.inp file
4aba9d66 1190 fprintf(pFlukaVmcInp,"%s\n",sLine);
fb2cbbec 1191 }
1192
1193 while ((fgets(sLine,255,pFlukaVmcCoreInp)) != NULL) {
4aba9d66 1194 if (strncmp(sLine,"START",5) != 0)
1195 fprintf(pFlukaVmcInp,"%s\n",sLine);
1196 else {
1197 sscanf(sLine+10,"%10f",&fEventsPerRun);
1198 goto fin;
1199 }
fb2cbbec 1200 } //end of while until START card
1201
1202 fin:
829fb838 1203
f450e9d0 1204
1205// Pass information to configuration objects
829fb838 1206
fb2cbbec 1207 Float_t fLastMaterial = fGeom->GetLastMaterialIndex();
1208 TFlukaConfigOption::SetStaticInfo(pFlukaVmcInp, 3, fLastMaterial, fGeom);
1209
1210 TIter next(fUserConfig);
1211 TFlukaConfigOption* proc;
f450e9d0 1212 while((proc = dynamic_cast<TFlukaConfigOption*> (next()))) proc->WriteFlukaInputCards();
1213//
1214// Process Fluka specific scoring options
1215//
1216 TFlukaScoringOption::SetStaticInfo(pFlukaVmcInp, fGeom);
1217 Float_t loginp = 49.0;
1218 Int_t inp = 0;
1219 Int_t nscore = fUserScore->GetEntries();
1220
a9ea1616 1221 TFlukaScoringOption *mopo = 0;
1222 TFlukaScoringOption *mopi = 0;
fb2cbbec 1223
f450e9d0 1224 for (Int_t isc = 0; isc < nscore; isc++)
1225 {
4aba9d66 1226 mopo = dynamic_cast<TFlukaScoringOption*> (fUserScore->At(isc));
1227 char* fileName = mopo->GetFileName();
1228 Int_t size = strlen(fileName);
1229 Float_t lun = -1.;
f450e9d0 1230//
1231// Check if new output file has to be opened
4aba9d66 1232 for (Int_t isci = 0; isci < isc; isci++) {
1233
1234
1235 mopi = dynamic_cast<TFlukaScoringOption*> (fUserScore->At(isci));
1236 if(strncmp(mopi->GetFileName(), fileName, size)==0) {
1237 //
1238 // No, the file already exists
1239 lun = mopi->GetLun();
1240 mopo->SetLun(lun);
1241 break;
1242 }
1243 } // inner loop
1244
1245 if (lun == -1.) {
1246 // Open new output file
1247 inp++;
1248 mopo->SetLun(loginp + inp);
1249 mopo->WriteOpenFlukaFile();
1250 }
1251 mopo->WriteFlukaInputCards();
f450e9d0 1252 }
b8a8a88c 1253
1254// Add RANDOMIZ card
1255 fprintf(pFlukaVmcInp,"RANDOMIZ %10.1f%10.0f\n", 1., Float_t(gRandom->GetSeed()));
829fb838 1256// Add START and STOP card
f450e9d0 1257 fprintf(pFlukaVmcInp,"START %10.1f\n",fEventsPerRun);
1258 fprintf(pFlukaVmcInp,"STOP \n");
829fb838 1259
1260
1261// Close files
3b8c325d 1262 fclose(pFlukaVmcCoreInp);
1263 fclose(pFlukaVmcFlukaMat);
1264 fclose(pFlukaVmcInp);
fb2cbbec 1265
1266
1267//
1268// Initialisation needed for Cerenkov photon production and transport
1269 TObjArray *matList = GetFlukaMaterials();
1270 Int_t nmaterial = matList->GetEntriesFast();
1271 fMaterials = new Int_t[nmaterial+3];
1272
1273 for (Int_t im = 0; im < nmaterial; im++)
1274 {
4aba9d66 1275 TGeoMaterial* material = dynamic_cast<TGeoMaterial*> (matList->At(im));
1276 Int_t idmat = material->GetIndex();
1277 fMaterials[idmat] = im;
fb2cbbec 1278 }
829fb838 1279} // end of InitPhysics
1280
1281
1282//______________________________________________________________________________
07f5b33e 1283void TFluka::SetMaxStep(Double_t step)
829fb838 1284{
07f5b33e 1285// Set the maximum step size
4aba9d66 1286// if (step > 1.e4) return;
07f5b33e 1287
4aba9d66 1288// Int_t mreg=0, latt=0;
1289// fGeom->GetCurrentRegion(mreg, latt);
1290 Int_t mreg = fGeom->GetCurrentRegion();
9c0c08ce 1291 STEPSZ.stepmx[mreg - 1] = step;
829fb838 1292}
1293
2f09b80e 1294
1295Double_t TFluka::MaxStep() const
1296{
1297// Return the maximum for current medium
1298 Int_t mreg, latt;
1299 fGeom->GetCurrentRegion(mreg, latt);
1300 return (STEPSZ.stepmx[mreg - 1]);
1301}
1302
829fb838 1303//______________________________________________________________________________
1304void TFluka::SetMaxNStep(Int_t)
1305{
1306// SetMaxNStep is dummy procedure in TFluka !
1307 if (fVerbosityLevel >=3)
1308 cout << "SetMaxNStep is dummy procedure in TFluka !" << endl;
1309}
1310
1311//______________________________________________________________________________
1312void TFluka::SetUserDecay(Int_t)
1313{
1314// SetUserDecay is dummy procedure in TFluka !
1315 if (fVerbosityLevel >=3)
1316 cout << "SetUserDecay is dummy procedure in TFluka !" << endl;
1317}
1318
1319//
1320// dynamic properties
1321//
1322//______________________________________________________________________________
1323void TFluka::TrackPosition(TLorentzVector& position) const
1324{
1325// Return the current position in the master reference frame of the
1326// track being transported
1327// TRACKR.atrack = age of the particle
1328// TRACKR.xtrack = x-position of the last point
1329// TRACKR.ytrack = y-position of the last point
1330// TRACKR.ztrack = z-position of the last point
a9ea1616 1331 FlukaCallerCode_t caller = GetCaller();
1332 if (caller == kENDRAW || caller == kUSDRAW ||
1333 caller == kBXExiting || caller == kBXEntering ||
1334 caller == kUSTCKV) {
829fb838 1335 position.SetX(GetXsco());
1336 position.SetY(GetYsco());
1337 position.SetZ(GetZsco());
1338 position.SetT(TRACKR.atrack);
1339 }
5125d6e5 1340 else if (caller == kMGDRAW) {
1341 Int_t i = -1;
1342 if ((i = fPrimaryElectronIndex) > -1) {
1343 // Primary Electron Ionisation
1344 Double_t x, y, z;
1345 GetPrimaryElectronPosition(i, x, y, z);
1346 position.SetX(x);
1347 position.SetY(y);
1348 position.SetZ(z);
1349 position.SetT(TRACKR.atrack);
1350 } else {
1351 position.SetX(TRACKR.xtrack[TRACKR.ntrack]);
1352 position.SetY(TRACKR.ytrack[TRACKR.ntrack]);
1353 position.SetZ(TRACKR.ztrack[TRACKR.ntrack]);
1354 position.SetT(TRACKR.atrack);
1355 }
829fb838 1356 }
a9ea1616 1357 else if (caller == kSODRAW) {
829fb838 1358 position.SetX(TRACKR.xtrack[TRACKR.ntrack]);
1359 position.SetY(TRACKR.ytrack[TRACKR.ntrack]);
1360 position.SetZ(TRACKR.ztrack[TRACKR.ntrack]);
1361 position.SetT(0);
a9ea1616 1362 } else if (caller == kMGResumedTrack) {
5d80a015 1363 position.SetX(TRACKR.spausr[0]);
1364 position.SetY(TRACKR.spausr[1]);
1365 position.SetZ(TRACKR.spausr[2]);
1366 position.SetT(TRACKR.spausr[3]);
829fb838 1367 }
1368 else
1369 Warning("TrackPosition","position not available");
1370}
1371
1372//______________________________________________________________________________
1373void TFluka::TrackPosition(Double_t& x, Double_t& y, Double_t& z) const
1374{
1375// Return the current position in the master reference frame of the
1376// track being transported
1377// TRACKR.atrack = age of the particle
1378// TRACKR.xtrack = x-position of the last point
1379// TRACKR.ytrack = y-position of the last point
1380// TRACKR.ztrack = z-position of the last point
a9ea1616 1381 FlukaCallerCode_t caller = GetCaller();
1382 if (caller == kENDRAW || caller == kUSDRAW ||
1383 caller == kBXExiting || caller == kBXEntering ||
1384 caller == kUSTCKV) {
5125d6e5 1385 x = GetXsco();
1386 y = GetYsco();
1387 z = GetZsco();
829fb838 1388 }
a9ea1616 1389 else if (caller == kMGDRAW || caller == kSODRAW) {
5125d6e5 1390 Int_t i = -1;
1391 if ((i = fPrimaryElectronIndex) > -1) {
1392 GetPrimaryElectronPosition(i, x, y, z);
1393 } else {
1394 x = TRACKR.xtrack[TRACKR.ntrack];
1395 y = TRACKR.ytrack[TRACKR.ntrack];
1396 z = TRACKR.ztrack[TRACKR.ntrack];
1397 }
829fb838 1398 }
a9ea1616 1399 else if (caller == kMGResumedTrack) {
5d80a015 1400 x = TRACKR.spausr[0];
1401 y = TRACKR.spausr[1];
1402 z = TRACKR.spausr[2];
1403 }
829fb838 1404 else
1405 Warning("TrackPosition","position not available");
1406}
1407
1408//______________________________________________________________________________
1409void TFluka::TrackMomentum(TLorentzVector& momentum) const
1410{
1411// Return the direction and the momentum (GeV/c) of the track
1412// currently being transported
1413// TRACKR.ptrack = momentum of the particle (not always defined, if
1414// < 0 must be obtained from etrack)
1415// TRACKR.cx,y,ztrck = direction cosines of the current particle
1416// TRACKR.etrack = total energy of the particle
1417// TRACKR.jtrack = identity number of the particle
1418// PAPROP.am[TRACKR.jtrack] = particle mass in gev
a9ea1616 1419 FlukaCallerCode_t caller = GetCaller();
1420 FlukaProcessCode_t icode = GetIcode();
1421
1422 if (caller != kEEDRAW && caller != kMGResumedTrack &&
1423 (caller != kENDRAW || (icode != kEMFSCOstopping1 && icode != kEMFSCOstopping2))) {
829fb838 1424 if (TRACKR.ptrack >= 0) {
1425 momentum.SetPx(TRACKR.ptrack*TRACKR.cxtrck);
1426 momentum.SetPy(TRACKR.ptrack*TRACKR.cytrck);
1427 momentum.SetPz(TRACKR.ptrack*TRACKR.cztrck);
1428 momentum.SetE(TRACKR.etrack);
1429 return;
1430 }
1431 else {
ece92b30 1432 Double_t p = sqrt(TRACKR.etrack * TRACKR.etrack - ParticleMassFPC(TRACKR.jtrack) * ParticleMassFPC(TRACKR.jtrack));
829fb838 1433 momentum.SetPx(p*TRACKR.cxtrck);
1434 momentum.SetPy(p*TRACKR.cytrck);
1435 momentum.SetPz(p*TRACKR.cztrck);
1436 momentum.SetE(TRACKR.etrack);
1437 return;
1438 }
a9ea1616 1439 } else if (caller == kMGResumedTrack) {
5d80a015 1440 momentum.SetPx(TRACKR.spausr[4]);
1441 momentum.SetPy(TRACKR.spausr[5]);
1442 momentum.SetPz(TRACKR.spausr[6]);
1443 momentum.SetE (TRACKR.spausr[7]);
1444 return;
a9ea1616 1445 } else if (caller == kENDRAW && (icode == kEMFSCOstopping1 || icode == kEMFSCOstopping2)) {
1446 momentum.SetPx(0.);
1447 momentum.SetPy(0.);
1448 momentum.SetPz(0.);
1449 momentum.SetE(TrackMass());
829fb838 1450 }
1451 else
1452 Warning("TrackMomentum","momentum not available");
1453}
1454
1455//______________________________________________________________________________
1456void TFluka::TrackMomentum(Double_t& px, Double_t& py, Double_t& pz, Double_t& e) const
1457{
1458// Return the direction and the momentum (GeV/c) of the track
1459// currently being transported
1460// TRACKR.ptrack = momentum of the particle (not always defined, if
1461// < 0 must be obtained from etrack)
1462// TRACKR.cx,y,ztrck = direction cosines of the current particle
1463// TRACKR.etrack = total energy of the particle
1464// TRACKR.jtrack = identity number of the particle
1465// PAPROP.am[TRACKR.jtrack] = particle mass in gev
a9ea1616 1466 FlukaCallerCode_t caller = GetCaller();
1467 FlukaProcessCode_t icode = GetIcode();
1468 if (caller != kEEDRAW && caller != kMGResumedTrack &&
1469 (caller != kENDRAW || (icode != kEMFSCOstopping1 && icode != kEMFSCOstopping2))) {
829fb838 1470 if (TRACKR.ptrack >= 0) {
1471 px = TRACKR.ptrack*TRACKR.cxtrck;
1472 py = TRACKR.ptrack*TRACKR.cytrck;
1473 pz = TRACKR.ptrack*TRACKR.cztrck;
a9ea1616 1474 e = TRACKR.etrack;
829fb838 1475 return;
1476 }
1477 else {
ece92b30 1478 Double_t p = sqrt(TRACKR.etrack * TRACKR.etrack - ParticleMassFPC(TRACKR.jtrack) * ParticleMassFPC(TRACKR.jtrack));
829fb838 1479 px = p*TRACKR.cxtrck;
1480 py = p*TRACKR.cytrck;
1481 pz = p*TRACKR.cztrck;
a9ea1616 1482 e = TRACKR.etrack;
829fb838 1483 return;
1484 }
a9ea1616 1485 } else if (caller == kMGResumedTrack) {
5d80a015 1486 px = TRACKR.spausr[4];
1487 py = TRACKR.spausr[5];
1488 pz = TRACKR.spausr[6];
1489 e = TRACKR.spausr[7];
0773d0ac 1490 return;
a9ea1616 1491 } else if (caller == kENDRAW && (icode == kEMFSCOstopping1 || icode == kEMFSCOstopping2)) {
1492 px = 0.;
1493 py = 0.;
1494 pz = 0.;
1495 e = TrackMass();
829fb838 1496 }
1497 else
1498 Warning("TrackMomentum","momentum not available");
1499}
1500
1501//______________________________________________________________________________
1502Double_t TFluka::TrackStep() const
1503{
1504// Return the length in centimeters of the current step
1505// TRACKR.ctrack = total curved path
a9ea1616 1506 FlukaCallerCode_t caller = GetCaller();
1507 if (caller == kBXEntering || caller == kBXExiting ||
1508 caller == kENDRAW || caller == kUSDRAW ||
1509 caller == kUSTCKV || caller == kMGResumedTrack)
829fb838 1510 return 0.0;
a9ea1616 1511 else if (caller == kMGDRAW)
829fb838 1512 return TRACKR.ctrack;
669cede4 1513 else {
1514 Warning("TrackStep", "track step not available");
1515 return 0.0;
1516 }
829fb838 1517}
1518
1519//______________________________________________________________________________
1520Double_t TFluka::TrackLength() const
1521{
1522// TRACKR.cmtrck = cumulative curved path since particle birth
a9ea1616 1523 FlukaCallerCode_t caller = GetCaller();
1524 if (caller == kBXEntering || caller == kBXExiting ||
1525 caller == kENDRAW || caller == kUSDRAW || caller == kMGDRAW ||
1526 caller == kUSTCKV)
829fb838 1527 return TRACKR.cmtrck;
a9ea1616 1528 else if (caller == kMGResumedTrack)
5d80a015 1529 return TRACKR.spausr[8];
669cede4 1530 else {
1531 Warning("TrackLength", "track length not available");
1532 return 0.0;
1533 }
829fb838 1534}
1535
1536//______________________________________________________________________________
1537Double_t TFluka::TrackTime() const
1538{
1539// Return the current time of flight of the track being transported
1540// TRACKR.atrack = age of the particle
a9ea1616 1541 FlukaCallerCode_t caller = GetCaller();
1542 if (caller == kBXEntering || caller == kBXExiting ||
1543 caller == kENDRAW || caller == kUSDRAW || caller == kMGDRAW ||
1544 caller == kUSTCKV)
829fb838 1545 return TRACKR.atrack;
a9ea1616 1546 else if (caller == kMGResumedTrack)
5d80a015 1547 return TRACKR.spausr[3];
669cede4 1548 else {
1549 Warning("TrackTime", "track time not available");
1550 return 0.0;
1551 }
829fb838 1552}
1553
1554//______________________________________________________________________________
1555Double_t TFluka::Edep() const
1556{
1557// Energy deposition
1558// if TRACKR.ntrack = 0, TRACKR.mtrack = 0:
1559// -->local energy deposition (the value and the point are not recorded in TRACKR)
1560// but in the variable "rull" of the procedure "endraw.cxx"
1561// if TRACKR.ntrack > 0, TRACKR.mtrack = 0:
1562// -->no energy loss along the track
1563// if TRACKR.ntrack > 0, TRACKR.mtrack > 0:
1564// -->energy loss distributed along the track
07f5b33e 1565// TRACKR.dtrack = energy deposition of the jth deposition event
829fb838 1566
1567 // If coming from bxdraw we have 2 steps of 0 length and 0 edep
669cede4 1568 // If coming from usdraw we just signal particle production - no edep
1569 // If just first time after resuming, no edep for the primary
a9ea1616 1570 FlukaCallerCode_t caller = GetCaller();
ada781c7 1571
a9ea1616 1572 if (caller == kBXExiting || caller == kBXEntering ||
1573 caller == kUSDRAW || caller == kMGResumedTrack) return 0.0;
829fb838 1574 Double_t sum = 0;
5125d6e5 1575 Int_t i = -1;
09cdde8a 1576
ada781c7 1577 // Material with primary ionisation activated but number of primary electrons nprim = 0
1578 if (fPrimaryElectronIndex == -2) return 0.0;
1579 // nprim > 0
5125d6e5 1580 if ((i = fPrimaryElectronIndex) > -1) {
1581 // Primary ionisation
ada781c7 1582 sum = GetPrimaryElectronKineticEnergy(i);
1583 if (sum > 100.) {
1584 printf("edep > 100. %d %d %f \n", i, ALLDLT.nalldl, sum);
1585 }
1586 return sum;
5125d6e5 1587 } else {
1588 // Normal ionisation
1589 if (TRACKR.mtrack > 1) printf("Edep: %6d\n", TRACKR.mtrack);
1590
1591 for ( Int_t j=0;j<TRACKR.mtrack;j++) {
1592 sum +=TRACKR.dtrack[j];
1593 }
1594 if (TRACKR.ntrack == 0 && TRACKR.mtrack == 0)
1595 return fRull + sum;
1596 else {
1597 return sum;
1598 }
829fb838 1599 }
1600}
1601
18e0cabb 1602//______________________________________________________________________________
1603Int_t TFluka::CorrectFlukaId() const
1604{
1605 // since we don't put photons and e- created bellow transport cut on the vmc stack
1606 // and there is a call to endraw for energy deposition for each of them
1607 // and they have the track number of their parent, but different identity (pdg)
4aba9d66 1608 // so we want to assign also their parent identity.
18e0cabb 1609 if( (IsTrackStop() )
1610 && TRACKR.ispusr[mkbmx2 - 4] == TRACKR.ispusr[mkbmx2 - 1]
1611 && TRACKR.jtrack != TRACKR.ispusr[mkbmx2 - 3] ) {
1612 if (fVerbosityLevel >=3)
1613 cout << "CorrectFlukaId() for icode=" << GetIcode()
1614 << " track=" << TRACKR.ispusr[mkbmx2 - 1]
1615 << " current PDG=" << PDGFromId(TRACKR.jtrack)
1616 << " assign parent PDG=" << PDGFromId(TRACKR.ispusr[mkbmx2 - 3]) << endl;
1617 return TRACKR.ispusr[mkbmx2 - 3]; // assign parent identity
1618 }
1619 return TRACKR.jtrack;
1620}
1621
1622
829fb838 1623//______________________________________________________________________________
1624Int_t TFluka::TrackPid() const
1625{
1626// Return the id of the particle transported
1627// TRACKR.jtrack = identity number of the particle
a9ea1616 1628 FlukaCallerCode_t caller = GetCaller();
1629 if (caller != kEEDRAW) {
18e0cabb 1630 return PDGFromId( CorrectFlukaId() );
f926898e 1631 }
829fb838 1632 else
1633 return -1000;
1634}
1635
1636//______________________________________________________________________________
1637Double_t TFluka::TrackCharge() const
1638{
1639// Return charge of the track currently transported
1640// PAPROP.ichrge = electric charge of the particle
1641// TRACKR.jtrack = identity number of the particle
a9ea1616 1642 FlukaCallerCode_t caller = GetCaller();
1643 if (caller != kEEDRAW)
18e0cabb 1644 return PAPROP.ichrge[CorrectFlukaId()+6];
829fb838 1645 else
1646 return -1000.0;
1647}
1648
1649//______________________________________________________________________________
1650Double_t TFluka::TrackMass() const
1651{
1652// PAPROP.am = particle mass in GeV
1653// TRACKR.jtrack = identity number of the particle
a9ea1616 1654 FlukaCallerCode_t caller = GetCaller();
1655 if (caller != kEEDRAW)
18e0cabb 1656 return PAPROP.am[CorrectFlukaId()+6];
829fb838 1657 else
1658 return -1000.0;
1659}
1660
1661//______________________________________________________________________________
1662Double_t TFluka::Etot() const
1663{
1664// TRACKR.etrack = total energy of the particle
a9ea1616 1665 FlukaCallerCode_t caller = GetCaller();
1666 if (caller != kEEDRAW)
829fb838 1667 return TRACKR.etrack;
1668 else
1669 return -1000.0;
1670}
1671
1672//
1673// track status
1674//
1675//______________________________________________________________________________
1676Bool_t TFluka::IsNewTrack() const
1677{
1678// Return true for the first call of Stepping()
1679 return fTrackIsNew;
1680}
1681
0dabe425 1682void TFluka::SetTrackIsNew(Bool_t flag)
1683{
1684// Return true for the first call of Stepping()
1685 fTrackIsNew = flag;
1686
1687}
1688
1689
829fb838 1690//______________________________________________________________________________
1691Bool_t TFluka::IsTrackInside() const
1692{
1693// True if the track is not at the boundary of the current volume
1694// In Fluka a step is always inside one kind of material
1695// If the step would go behind the region of one material,
1696// it will be shortened to reach only the boundary.
1697// Therefore IsTrackInside() is always true.
a9ea1616 1698 FlukaCallerCode_t caller = GetCaller();
1699 if (caller == kBXEntering || caller == kBXExiting)
829fb838 1700 return 0;
1701 else
1702 return 1;
1703}
1704
1705//______________________________________________________________________________
1706Bool_t TFluka::IsTrackEntering() const
1707{
1708// True if this is the first step of the track in the current volume
1709
a9ea1616 1710 FlukaCallerCode_t caller = GetCaller();
1711 if (caller == kBXEntering)
829fb838 1712 return 1;
1713 else return 0;
1714}
1715
1716//______________________________________________________________________________
1717Bool_t TFluka::IsTrackExiting() const
1718{
1719// True if track is exiting volume
1720//
a9ea1616 1721 FlukaCallerCode_t caller = GetCaller();
1722 if (caller == kBXExiting)
829fb838 1723 return 1;
1724 else return 0;
1725}
1726
1727//______________________________________________________________________________
1728Bool_t TFluka::IsTrackOut() const
1729{
1730// True if the track is out of the setup
1731// means escape
a9ea1616 1732 FlukaProcessCode_t icode = GetIcode();
1733
1734 if (icode == kKASKADescape ||
1735 icode == kEMFSCOescape ||
1736 icode == kKASNEUescape ||
1737 icode == kKASHEAescape ||
1738 icode == kKASOPHescape)
1739 return 1;
829fb838 1740 else return 0;
1741}
1742
1743//______________________________________________________________________________
1744Bool_t TFluka::IsTrackDisappeared() const
1745{
a9ea1616 1746// All inelastic interactions and decays
829fb838 1747// fIcode from usdraw
a9ea1616 1748 FlukaProcessCode_t icode = GetIcode();
1749 if (icode == kKASKADinelint || // inelastic interaction
1750 icode == kKASKADdecay || // particle decay
1751 icode == kKASKADdray || // delta ray generation by hadron
1752 icode == kKASKADpair || // direct pair production
1753 icode == kKASKADbrems || // bremsstrahlung (muon)
1754 icode == kEMFSCObrems || // bremsstrahlung (electron)
1755 icode == kEMFSCOmoller || // Moller scattering
1756 icode == kEMFSCObhabha || // Bhaba scattering
1757 icode == kEMFSCOanniflight || // in-flight annihilation
1758 icode == kEMFSCOannirest || // annihilation at rest
1759 icode == kEMFSCOpair || // pair production
1760 icode == kEMFSCOcompton || // Compton scattering
1761 icode == kEMFSCOphotoel || // Photoelectric effect
1762 icode == kKASNEUhadronic || // hadronic interaction
2047b055 1763 icode == kKASHEAdray // delta-ray
0dabe425 1764 ) return 1;
829fb838 1765 else return 0;
1766}
1767
1768//______________________________________________________________________________
1769Bool_t TFluka::IsTrackStop() const
1770{
1771// True if the track energy has fallen below the threshold
1772// means stopped by signal or below energy threshold
a9ea1616 1773 FlukaProcessCode_t icode = GetIcode();
18e0cabb 1774 if (icode == kKASKADstopping || // stopping particle
1775 icode == kKASKADtimekill || // time kill
1776 icode == kEMFSCOstopping1 || // below user-defined cut-off
1777 icode == kEMFSCOstopping2 || // below user cut-off
1778 icode == kEMFSCOtimekill || // time kill
1779 icode == kKASNEUstopping || // neutron below threshold
1780 icode == kKASNEUtimekill || // time kill
1781 icode == kKASHEAtimekill || // time kill
1782 icode == kKASOPHtimekill) return 1; // time kill
829fb838 1783 else return 0;
1784}
1785
1786//______________________________________________________________________________
1787Bool_t TFluka::IsTrackAlive() const
1788{
1789// means not disappeared or not out
1790 if (IsTrackDisappeared() || IsTrackOut() ) return 0;
1791 else return 1;
1792}
1793
1794//
1795// secondaries
1796//
1797
1798//______________________________________________________________________________
1799Int_t TFluka::NSecondaries() const
1800
1801{
1802// Number of secondary particles generated in the current step
81f1d030 1803// GENSTK.np = number of secondaries except light and heavy ions
829fb838 1804// FHEAVY.npheav = number of secondaries for light and heavy secondary ions
a9ea1616 1805 FlukaCallerCode_t caller = GetCaller();
1806 if (caller == kUSDRAW) // valid only after usdraw
4aba9d66 1807 return GENSTK.np + FHEAVY.npheav;
a9ea1616 1808 else if (caller == kUSTCKV) {
4aba9d66 1809 // Cerenkov Photon production
1810 return fNCerenkov;
7b203b6e 1811 }
829fb838 1812 return 0;
1813} // end of NSecondaries
1814
1815//______________________________________________________________________________
1816void TFluka::GetSecondary(Int_t isec, Int_t& particleId,
4aba9d66 1817 TLorentzVector& position, TLorentzVector& momentum)
829fb838 1818{
1819// Copy particles from secondary stack to vmc stack
1820//
1821
a9ea1616 1822 FlukaCallerCode_t caller = GetCaller();
1823 if (caller == kUSDRAW) { // valid only after usdraw
4aba9d66 1824 if (GENSTK.np > 0) {
1825 // Hadronic interaction
1826 if (isec >= 0 && isec < GENSTK.np) {
1827 particleId = PDGFromId(GENSTK.kpart[isec]);
1828 position.SetX(fXsco);
1829 position.SetY(fYsco);
1830 position.SetZ(fZsco);
1831 position.SetT(TRACKR.atrack);
1832 momentum.SetPx(GENSTK.plr[isec]*GENSTK.cxr[isec]);
1833 momentum.SetPy(GENSTK.plr[isec]*GENSTK.cyr[isec]);
1834 momentum.SetPz(GENSTK.plr[isec]*GENSTK.czr[isec]);
1835 momentum.SetE(GENSTK.tki[isec] + PAPROP.am[GENSTK.kpart[isec]+6]);
1836 }
1837 else if (isec >= GENSTK.np && isec < GENSTK.np + FHEAVY.npheav) {
1838 Int_t jsec = isec - GENSTK.np;
1839 particleId = FHEAVY.kheavy[jsec]; // this is Fluka id !!!
1840 position.SetX(fXsco);
1841 position.SetY(fYsco);
1842 position.SetZ(fZsco);
1843 position.SetT(TRACKR.atrack);
1844 momentum.SetPx(FHEAVY.pheavy[jsec]*FHEAVY.cxheav[jsec]);
1845 momentum.SetPy(FHEAVY.pheavy[jsec]*FHEAVY.cyheav[jsec]);
1846 momentum.SetPz(FHEAVY.pheavy[jsec]*FHEAVY.czheav[jsec]);
1847 if (FHEAVY.tkheav[jsec] >= 3 && FHEAVY.tkheav[jsec] <= 6)
1848 momentum.SetE(FHEAVY.tkheav[jsec] + PAPROP.am[jsec+6]);
1849 else if (FHEAVY.tkheav[jsec] > 6)
1850 momentum.SetE(FHEAVY.tkheav[jsec] + FHEAVY.amnhea[jsec]); // to be checked !!!
1851 }
1852 else
1853 Warning("GetSecondary","isec out of range");
1854 }
a9ea1616 1855 } else if (caller == kUSTCKV) {
4aba9d66 1856 Int_t index = OPPHST.lstopp - isec;
1857 position.SetX(OPPHST.xoptph[index]);
1858 position.SetY(OPPHST.yoptph[index]);
1859 position.SetZ(OPPHST.zoptph[index]);
1860 position.SetT(OPPHST.agopph[index]);
1861 Double_t p = OPPHST.poptph[index];
1862
1863 momentum.SetPx(p * OPPHST.txopph[index]);
1864 momentum.SetPy(p * OPPHST.tyopph[index]);
1865 momentum.SetPz(p * OPPHST.tzopph[index]);
1866 momentum.SetE(p);
829fb838 1867 }
1868 else
4aba9d66 1869 Warning("GetSecondary","no secondaries available");
7b203b6e 1870
829fb838 1871} // end of GetSecondary
1872
7b203b6e 1873
829fb838 1874//______________________________________________________________________________
1875TMCProcess TFluka::ProdProcess(Int_t) const
1876
1877{
1878// Name of the process that has produced the secondary particles
1879// in the current step
0dabe425 1880
a9ea1616 1881 Int_t mugamma = (TRACKR.jtrack == kFLUKAphoton ||
4aba9d66 1882 TRACKR.jtrack == kFLUKAmuplus ||
1883 TRACKR.jtrack == kFLUKAmuminus);
a9ea1616 1884 FlukaProcessCode_t icode = GetIcode();
1885
1886 if (icode == kKASKADdecay) return kPDecay;
1887 else if (icode == kKASKADpair || icode == kEMFSCOpair) return kPPair;
1888 else if (icode == kEMFSCOcompton) return kPCompton;
1889 else if (icode == kEMFSCOphotoel) return kPPhotoelectric;
1890 else if (icode == kKASKADbrems || icode == kEMFSCObrems) return kPBrem;
1891 else if (icode == kKASKADdray || icode == kKASHEAdray) return kPDeltaRay;
1892 else if (icode == kEMFSCOmoller || icode == kEMFSCObhabha) return kPDeltaRay;
1893 else if (icode == kEMFSCOanniflight || icode == kEMFSCOannirest) return kPAnnihilation;
1894 else if (icode == kKASKADinelint) {
4aba9d66 1895 if (!mugamma) return kPHadronic;
1896 else if (TRACKR.jtrack == kFLUKAphoton) return kPPhotoFission;
1897 else return kPMuonNuclear;
829fb838 1898 }
a9ea1616 1899 else if (icode == kEMFSCOrayleigh) return kPRayleigh;
829fb838 1900// Fluka codes 100, 300 and 400 still to be investigasted
a9ea1616 1901 else return kPNoProcess;
829fb838 1902}
1903
829fb838 1904
b496f27c 1905Int_t TFluka::StepProcesses(TArrayI &proc) const
1906{
1907 //
1908 // Return processes active in the current step
1909 //
a9ea1616 1910 FlukaProcessCode_t icode = GetIcode();
b496f27c 1911 proc.Set(1);
1912 TMCProcess iproc;
a9ea1616 1913 switch (icode) {
1914 case kKASKADtimekill:
1915 case kEMFSCOtimekill:
1916 case kKASNEUtimekill:
1917 case kKASHEAtimekill:
1918 case kKASOPHtimekill:
4aba9d66 1919 iproc = kPTOFlimit;
1920 break;
a9ea1616 1921 case kKASKADstopping:
1922 case kKASKADescape:
1923 case kEMFSCOstopping1:
1924 case kEMFSCOstopping2:
1925 case kEMFSCOescape:
1926 case kKASNEUstopping:
1927 case kKASNEUescape:
1928 case kKASHEAescape:
1929 case kKASOPHescape:
4aba9d66 1930 iproc = kPStop;
1931 break;
a9ea1616 1932 case kKASOPHabsorption:
4aba9d66 1933 iproc = kPLightAbsorption;
1934 break;
a9ea1616 1935 case kKASOPHrefraction:
4aba9d66 1936 iproc = kPLightRefraction;
a9ea1616 1937 case kEMSCOlocaledep :
4aba9d66 1938 iproc = kPPhotoelectric;
1939 break;
b496f27c 1940 default:
4aba9d66 1941 iproc = ProdProcess(0);
b496f27c 1942 }
07f5b33e 1943 proc[0] = iproc;
b496f27c 1944 return 1;
1945}
829fb838 1946//______________________________________________________________________________
1947Int_t TFluka::VolId2Mate(Int_t id) const
1948{
1949//
1950// Returns the material number for a given volume ID
1951//
1952 return fMCGeo->VolId2Mate(id);
1953}
1954
1955//______________________________________________________________________________
1956const char* TFluka::VolName(Int_t id) const
1957{
1958//
1959// Returns the volume name for a given volume ID
1960//
1961 return fMCGeo->VolName(id);
1962}
1963
1964//______________________________________________________________________________
1965Int_t TFluka::VolId(const Text_t* volName) const
1966{
1967//
1968// Converts from volume name to volume ID.
1969// Time consuming. (Only used during set-up)
1970// Could be replaced by hash-table
1971//
09cd6497 1972 char sname[20];
1973 Int_t len;
1974 strncpy(sname, volName, len = strlen(volName));
1975 sname[len] = 0;
1976 while (sname[len - 1] == ' ') sname[--len] = 0;
1977 return fMCGeo->VolId(sname);
829fb838 1978}
1979
1980//______________________________________________________________________________
1981Int_t TFluka::CurrentVolID(Int_t& copyNo) const
1982{
1983//
1984// Return the logical id and copy number corresponding to the current fluka region
1985//
1986 if (gGeoManager->IsOutside()) return 0;
1987 TGeoNode *node = gGeoManager->GetCurrentNode();
1988 copyNo = node->GetNumber();
1989 Int_t id = node->GetVolume()->GetNumber();
1990 return id;
1991}
1992
1993//______________________________________________________________________________
1994Int_t TFluka::CurrentVolOffID(Int_t off, Int_t& copyNo) const
1995{
1996//
1997// Return the logical id and copy number of off'th mother
1998// corresponding to the current fluka region
1999//
2000 if (off<0 || off>gGeoManager->GetLevel()) return 0;
2001 if (off==0) return CurrentVolID(copyNo);
2002 TGeoNode *node = gGeoManager->GetMother(off);
2003 if (!node) return 0;
2004 copyNo = node->GetNumber();
2005 return node->GetVolume()->GetNumber();
2006}
2007
2008//______________________________________________________________________________
2009const char* TFluka::CurrentVolName() const
2010{
2011//
2012// Return the current volume name
2013//
2014 if (gGeoManager->IsOutside()) return 0;
2015 return gGeoManager->GetCurrentVolume()->GetName();
2016}
2017
2018//______________________________________________________________________________
2019const char* TFluka::CurrentVolOffName(Int_t off) const
2020{
2021//
2022// Return the volume name of the off'th mother of the current volume
2023//
2024 if (off<0 || off>gGeoManager->GetLevel()) return 0;
2025 if (off==0) return CurrentVolName();
2026 TGeoNode *node = gGeoManager->GetMother(off);
2027 if (!node) return 0;
2028 return node->GetVolume()->GetName();
2029}
2030
d59acfe7 2031const char* TFluka::CurrentVolPath() {
2032 // Return the current volume path
2033 return gGeoManager->GetPath();
2034}
829fb838 2035//______________________________________________________________________________
a60813de 2036Int_t TFluka::CurrentMaterial(Float_t & a, Float_t & z,
4aba9d66 2037 Float_t & dens, Float_t & radl, Float_t & absl) const
829fb838 2038{
2039//
a60813de 2040// Return the current medium number and material properties
829fb838 2041//
2042 Int_t copy;
2043 Int_t id = TFluka::CurrentVolID(copy);
2044 Int_t med = TFluka::VolId2Mate(id);
a60813de 2045 TGeoVolume* vol = gGeoManager->GetCurrentVolume();
2046 TGeoMaterial* mat = vol->GetMaterial();
2047 a = mat->GetA();
2048 z = mat->GetZ();
2049 dens = mat->GetDensity();
2050 radl = mat->GetRadLen();
2051 absl = mat->GetIntLen();
2052
829fb838 2053 return med;
2054}
2055
2056//______________________________________________________________________________
2057void TFluka::Gmtod(Float_t* xm, Float_t* xd, Int_t iflag)
2058{
2059// Transforms a position from the world reference frame
2060// to the current volume reference frame.
2061//
2062// Geant3 desription:
2063// ==================
2064// Computes coordinates XD (in DRS)
2065// from known coordinates XM in MRS
2066// The local reference system can be initialized by
2067// - the tracking routines and GMTOD used in GUSTEP
2068// - a call to GMEDIA(XM,NUMED)
2069// - a call to GLVOLU(NLEVEL,NAMES,NUMBER,IER)
2070// (inverse routine is GDTOM)
2071//
2072// If IFLAG=1 convert coordinates
2073// IFLAG=2 convert direction cosinus
2074//
2075// ---
2076 Double_t xmL[3], xdL[3];
2077 Int_t i;
2078 for (i=0;i<3;i++) xmL[i]=xm[i];
2079 if (iflag == 1) gGeoManager->MasterToLocal(xmL,xdL);
2080 else gGeoManager->MasterToLocalVect(xmL,xdL);
2081 for (i=0;i<3;i++) xd[i] = xdL[i];
2082}
2083
2084//______________________________________________________________________________
2085void TFluka::Gmtod(Double_t* xm, Double_t* xd, Int_t iflag)
2086{
2047b055 2087//
2088// See Gmtod(Float_t*, Float_t*, Int_t)
2089//
829fb838 2090 if (iflag == 1) gGeoManager->MasterToLocal(xm,xd);
2091 else gGeoManager->MasterToLocalVect(xm,xd);
2092}
2093
2094//______________________________________________________________________________
2095void TFluka::Gdtom(Float_t* xd, Float_t* xm, Int_t iflag)
2096{
2097// Transforms a position from the current volume reference frame
2098// to the world reference frame.
2099//
2100// Geant3 desription:
2101// ==================
2102// Computes coordinates XM (Master Reference System
2103// knowing the coordinates XD (Detector Ref System)
2104// The local reference system can be initialized by
2105// - the tracking routines and GDTOM used in GUSTEP
2106// - a call to GSCMED(NLEVEL,NAMES,NUMBER)
2107// (inverse routine is GMTOD)
2108//
2109// If IFLAG=1 convert coordinates
2110// IFLAG=2 convert direction cosinus
2111//
2112// ---
2113 Double_t xmL[3], xdL[3];
2114 Int_t i;
2115 for (i=0;i<3;i++) xdL[i] = xd[i];
2116 if (iflag == 1) gGeoManager->LocalToMaster(xdL,xmL);
2117 else gGeoManager->LocalToMasterVect(xdL,xmL);
2118 for (i=0;i<3;i++) xm[i]=xmL[i];
2119}
2120
2121//______________________________________________________________________________
2122void TFluka::Gdtom(Double_t* xd, Double_t* xm, Int_t iflag)
2123{
2047b055 2124//
2125// See Gdtom(Float_t*, Float_t*, Int_t)
2126//
829fb838 2127 if (iflag == 1) gGeoManager->LocalToMaster(xd,xm);
2128 else gGeoManager->LocalToMasterVect(xd,xm);
2129}
2130
2131//______________________________________________________________________________
2132TObjArray *TFluka::GetFlukaMaterials()
2133{
2047b055 2134//
2135// Get array of Fluka materials
829fb838 2136 return fGeom->GetMatList();
2137}
2138
2139//______________________________________________________________________________
a9ea1616 2140void TFluka::SetMreg(Int_t l, Int_t lttc)
829fb838 2141{
2142// Set current fluka region
2143 fCurrentFlukaRegion = l;
a9ea1616 2144 fGeom->SetMreg(l,lttc);
829fb838 2145}
2146
2147
b496f27c 2148
2149
4aba9d66 2150//______________________________________________________________________________
b496f27c 2151TString TFluka::ParticleName(Int_t pdg) const
2152{
2153 // Return particle name for particle with pdg code pdg.
2154 Int_t ifluka = IdFromPDG(pdg);
ece92b30 2155 return TString((CHPPRP.btype[ifluka - kFLUKAcodemin]), 8);
b496f27c 2156}
2157
2158
4aba9d66 2159//______________________________________________________________________________
b496f27c 2160Double_t TFluka::ParticleMass(Int_t pdg) const
2161{
2162 // Return particle mass for particle with pdg code pdg.
2163 Int_t ifluka = IdFromPDG(pdg);
ece92b30 2164 return (PAPROP.am[ifluka - kFLUKAcodemin]);
2165}
2166
4aba9d66 2167//______________________________________________________________________________
ece92b30 2168Double_t TFluka::ParticleMassFPC(Int_t fpc) const
2169{
2170 // Return particle mass for particle with Fluka particle code fpc
2171 return (PAPROP.am[fpc - kFLUKAcodemin]);
b496f27c 2172}
2173
4aba9d66 2174//______________________________________________________________________________
b496f27c 2175Double_t TFluka::ParticleCharge(Int_t pdg) const
2176{
2177 // Return particle charge for particle with pdg code pdg.
2178 Int_t ifluka = IdFromPDG(pdg);
ece92b30 2179 return Double_t(PAPROP.ichrge[ifluka - kFLUKAcodemin]);
b496f27c 2180}
2181
4aba9d66 2182//______________________________________________________________________________
b496f27c 2183Double_t TFluka::ParticleLifeTime(Int_t pdg) const
2184{
2185 // Return particle lifetime for particle with pdg code pdg.
2186 Int_t ifluka = IdFromPDG(pdg);
ece92b30 2187 return (PAPROP.tmnlf[ifluka - kFLUKAcodemin]);
b496f27c 2188}
2189
4aba9d66 2190//______________________________________________________________________________
b496f27c 2191void TFluka::Gfpart(Int_t pdg, char* name, Int_t& type, Float_t& mass, Float_t& charge, Float_t& tlife)
2192{
2193 // Retrieve particle properties for particle with pdg code pdg.
2194
2195 strcpy(name, ParticleName(pdg).Data());
2196 type = ParticleMCType(pdg);
2197 mass = ParticleMass(pdg);
2198 charge = ParticleCharge(pdg);
2199 tlife = ParticleLifeTime(pdg);
2200}
2201
4aba9d66 2202//______________________________________________________________________________
8e5bf079 2203void TFluka::PrintHeader()
2204{
2205 //
2206 // Print a header
2207 printf("\n");
2208 printf("\n");
2209 printf("------------------------------------------------------------------------------\n");
2210 printf("- You are using the TFluka Virtual Monte Carlo Interface to FLUKA. -\n");
2211 printf("- Please see the file fluka.out for FLUKA output and licensing information. -\n");
2212 printf("------------------------------------------------------------------------------\n");
2213 printf("\n");
2214 printf("\n");
2215}
2216
b496f27c 2217
81f1d030 2218#define pshckp pshckp_
2219#define ustckv ustckv_
3a625972 2220
2221
2222extern "C" {
81f1d030 2223 void pshckp(Double_t & px, Double_t & py, Double_t & pz, Double_t & e,
4aba9d66 2224 Double_t & vx, Double_t & vy, Double_t & vz, Double_t & tof,
2225 Double_t & polx, Double_t & poly, Double_t & polz, Double_t & wgt, Int_t& ntr)
81f1d030 2226 {
2227 //
2228 // Pushes one cerenkov photon to the stack
2229 //
2230
2231 TFluka* fluka = (TFluka*) gMC;
2232 TVirtualMCStack* cppstack = fluka->GetStack();
2233 Int_t parent = TRACKR.ispusr[mkbmx2-1];
2234 cppstack->PushTrack(0, parent, 50000050,
4aba9d66 2235 px, py, pz, e,
2236 vx, vy, vz, tof,
2237 polx, poly, polz,
2238 kPCerenkov, ntr, wgt, 0);
2239 if (fluka->GetVerbosityLevel() >= 3)
2240 printf("pshckp: track=%d parent=%d lattc=%d %s\n", ntr, parent, TRACKR.lt1trk, fluka->CurrentVolName());
81f1d030 2241 }
2242
2243 void ustckv(Int_t & nphot, Int_t & mreg, Double_t & x, Double_t & y, Double_t & z)
7b203b6e 2244 {
4aba9d66 2245 //
2246 // Calls stepping in order to signal cerenkov production
2247 //
2248 TFluka *fluka = (TFluka*)gMC;
2249 fluka->SetMreg(mreg, TRACKR.lt1trk); //LTCLCM.mlatm1);
2250 fluka->SetXsco(x);
2251 fluka->SetYsco(y);
2252 fluka->SetZsco(z);
2253 fluka->SetNCerenkov(nphot);
2254 fluka->SetCaller(kUSTCKV);
2255 if (fluka->GetVerbosityLevel() >= 3)
2256 printf("ustckv: %10d mreg=%d lattc=%d newlat=%d (%f, %f, %f) edep=%f vol=%s\n",
2257 nphot, mreg, TRACKR.lt1trk, LTCLCM.newlat, x, y, z, fluka->Edep(), fluka->CurrentVolName());
2258
2259 // check region lattice consistency (debug Ernesto)
2260 // *****************************************************
2261 Int_t nodeId;
2262 Int_t volId = fluka->CurrentVolID(nodeId);
2263 Int_t crtlttc = gGeoManager->GetCurrentNodeId()+1;
2264
2265 if( mreg != volId && !gGeoManager->IsOutside() ) {
2266 cout << " ustckv: track=" << TRACKR.ispusr[mkbmx2-1] << " pdg=" << fluka->PDGFromId(TRACKR.jtrack)
2267 << " icode=" << fluka->GetIcode() << " gNstep=" << fluka->GetNstep() << endl
2268 << " fluka mreg=" << mreg << " mlttc=" << TRACKR.lt1trk << endl
2269 << " TGeo volId=" << volId << " crtlttc=" << crtlttc << endl
2270 << " common TRACKR lt1trk=" << TRACKR.lt1trk << " lt2trk=" << TRACKR.lt2trk << endl
2271 << " common LTCLCM newlat=" << LTCLCM.newlat << " mlatld=" << LTCLCM.mlatld << endl
2272 << " mlatm1=" << LTCLCM.mlatm1 << " mltsen=" << LTCLCM.mltsen << endl
2273 << " mltsm1=" << LTCLCM.mltsm1 << " mlattc=" << LTCLCM.mlattc << endl;
2274 if( TRACKR.lt1trk == crtlttc ) cout << " *************************************************************" << endl;
2275 }
2276 // *****************************************************
2277
2278
2279
2280 (TVirtualMCApplication::Instance())->Stepping();
7b203b6e 2281 }
3a625972 2282}
a9ea1616 2283
4aba9d66 2284//______________________________________________________________________________
78df7be0 2285void TFluka::AddParticlesToPdgDataBase() const
2286{
2287
2288//
2289// Add particles to the PDG data base
2290
2291 TDatabasePDG *pdgDB = TDatabasePDG::Instance();
2292
2293 const Int_t kion=10000000;
2294
2295 const Double_t kAu2Gev = 0.9314943228;
2296 const Double_t khSlash = 1.0545726663e-27;
2297 const Double_t kErg2Gev = 1/1.6021773349e-3;
2298 const Double_t khShGev = khSlash*kErg2Gev;
2299 const Double_t kYear2Sec = 3600*24*365.25;
2300//
2301// Ions
2302//
2303
2304 pdgDB->AddParticle("Deuteron","Deuteron",2*kAu2Gev+8.071e-3,kTRUE,
2305 0,3,"Ion",kion+10020);
2306 pdgDB->AddParticle("Triton","Triton",3*kAu2Gev+14.931e-3,kFALSE,
2307 khShGev/(12.33*kYear2Sec),3,"Ion",kion+10030);
2308 pdgDB->AddParticle("Alpha","Alpha",4*kAu2Gev+2.424e-3,kTRUE,
2309 khShGev/(12.33*kYear2Sec),6,"Ion",kion+20040);
2310 pdgDB->AddParticle("HE3","HE3",3*kAu2Gev+14.931e-3,kFALSE,
2311 0,6,"Ion",kion+20030);
2312}
2313
4aba9d66 2314//
2315// Info about primary ionization electrons
2316//
2317
2318//______________________________________________________________________________
2319Int_t TFluka::GetNPrimaryElectrons()
f2a98602 2320{
2321 // Get number of primary electrons
2322 return ALLDLT.nalldl;
2323}
2324
4aba9d66 2325//______________________________________________________________________________
5125d6e5 2326Double_t TFluka::GetPrimaryElectronKineticEnergy(Int_t i) const
f2a98602 2327{
2328 // Returns kinetic energy of primary electron i
5125d6e5 2329
2330 Double_t ekin = -1.;
f2a98602 2331 if (i >= 0 && i < ALLDLT.nalldl) {
4aba9d66 2332 ekin = ALLDLT.talldl[i];
f2a98602 2333 } else {
4aba9d66 2334 Warning("GetPrimaryElectronKineticEnergy",
2335 "Primary electron index out of range %d %d \n",
2336 i, ALLDLT.nalldl);
f2a98602 2337 }
f0734960 2338 return ekin;
f2a98602 2339}
5125d6e5 2340
2341void TFluka::GetPrimaryElectronPosition(Int_t i, Double_t& x, Double_t& y, Double_t& z) const
2342{
2343 // Returns position of primary electron i
2344 if (i >= 0 && i < ALLDLT.nalldl) {
2345 x = ALLDLT.xalldl[i];
2346 y = ALLDLT.yalldl[i];
2347 z = ALLDLT.zalldl[i];
2348 return;
2349 } else {
2350 Warning("GetPrimaryElectronPosition",
2351 "Primary electron index out of range %d %d \n",
2352 i, ALLDLT.nalldl);
2353 return;
2354 }
2355 return;
2356}
2357
2358