1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
19 // Realisation of the TVirtualMC interface for the FLUKA code
20 // (See official web side http://www.fluka.org/).
22 // This implementation makes use of the TGeo geometry modeller.
23 // User configuration is via automatic generation of FLUKA input cards.
32 #include <Riostream.h>
35 #include "TCallf77.h" //For the fortran calls
36 #include "Fdblprc.h" //(DBLPRC) fluka common
37 #include "Fepisor.h" //(EPISOR) fluka common
38 #include "Ffinuc.h" //(FINUC) fluka common
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
45 #include "Fopphst.h" //(OPPHST) fluka common
46 #include "Fstack.h" //(STACK) fluka common
48 #include "TVirtualMC.h"
49 #include "TMCProcess.h"
50 #include "TGeoManager.h"
51 #include "TGeoMaterial.h"
52 #include "TGeoMedium.h"
53 #include "TFlukaMCGeometry.h"
54 #include "TGeoMCGeometry.h"
55 #include "TFlukaCerenkov.h"
56 #include "TFlukaConfigOption.h"
57 #include "TLorentzVector.h"
59 // Fluka methods that may be needed.
61 # define flukam flukam_
62 # define fluka_openinp fluka_openinp_
63 # define fluka_closeinp fluka_closeinp_
64 # define mcihad mcihad_
65 # define mpdgha mpdgha_
67 # define flukam FLUKAM
68 # define fluka_openinp FLUKA_OPENINP
69 # define fluka_closeinp FLUKA_CLOSEINP
70 # define mcihad MCIHAD
71 # define mpdgha MPDGHA
77 // Prototypes for FLUKA functions
79 void type_of_call flukam(const int&);
80 void type_of_call fluka_openinp(const int&, DEFCHARA);
81 void type_of_call fluka_closeinp(const int&);
82 int type_of_call mcihad(const int&);
83 int type_of_call mpdgha(const int&);
87 // Class implementation for ROOT
92 //----------------------------------------------------------------------------
93 // TFluka constructors and destructors.
94 //______________________________________________________________________________
104 // Default constructor
106 fGeneratePemf = kFALSE;
108 fCurrentFlukaRegion = -1;
117 //______________________________________________________________________________
118 TFluka::TFluka(const char *title, Int_t verbosity, Bool_t isRootGeometrySupported)
119 :TVirtualMC("TFluka",title, isRootGeometrySupported),
120 fVerbosityLevel(verbosity),
125 fProcesses(new TObjArray(100)),
126 fCuts(new TObjArray(100)),
127 fUserScore(new TObjArray(100))
129 // create geometry interface
130 if (fVerbosityLevel >=3)
131 cout << "<== TFluka::TFluka(" << title << ") constructor called." << endl;
134 fCurrentFlukaRegion = -1;
137 fGeneratePemf = kFALSE;
138 fMCGeo = new TGeoMCGeometry("MCGeo", "TGeo Implementation of VirtualMCGeometry", kTRUE);
139 fGeom = new TFlukaMCGeometry("geom", "ALICE geometry");
140 if (verbosity > 2) fGeom->SetDebugMode(kTRUE);
145 //______________________________________________________________________________
148 if (fVerbosityLevel >=3)
149 cout << "<== TFluka::~TFluka() destructor called." << endl;
160 fProcesses->Delete();
168 //______________________________________________________________________________
169 // TFluka control methods
170 //______________________________________________________________________________
171 void TFluka::Init() {
173 // Geometry initialisation
175 if (fVerbosityLevel >=3) cout << "==> TFluka::Init() called." << endl;
177 if (!gGeoManager) new TGeoManager("geom", "FLUKA geometry");
178 fApplication->ConstructGeometry();
179 TGeoVolume *top = (TGeoVolume*)gGeoManager->GetListOfVolumes()->First();
180 gGeoManager->SetTopVolume(top);
181 gGeoManager->CloseGeometry("di");
182 gGeoManager->DefaultColors(); // to be removed
183 fNVolumes = fGeom->NofVolumes();
184 fGeom->CreateFlukaMatFile("flukaMat.inp");
185 if (fVerbosityLevel >=3) {
186 printf("== Number of volumes: %i\n ==", fNVolumes);
187 cout << "\t* InitPhysics() - Prepare input file to be called" << endl;
189 // now we have TGeo geometry created and we have to patch alice.inp
190 // with the material mapping file FlukaMat.inp
194 //______________________________________________________________________________
195 void TFluka::FinishGeometry() {
197 // Build-up table with region to medium correspondance
199 if (fVerbosityLevel >=3) {
200 cout << "==> TFluka::FinishGeometry() called." << endl;
201 printf("----FinishGeometry - nothing to do with TGeo\n");
202 cout << "<== TFluka::FinishGeometry() called." << endl;
206 //______________________________________________________________________________
207 void TFluka::BuildPhysics() {
209 // Prepare FLUKA input files and call FLUKA physics initialisation
212 if (fVerbosityLevel >=3)
213 cout << "==> TFluka::BuildPhysics() called." << endl;
214 // Prepare input file with the current physics settings
216 cout << "\t* InitPhysics() - Prepare input file was called" << endl;
218 if (fVerbosityLevel >=2)
219 cout << "\t* Changing lfdrtr = (" << (GLOBAL.lfdrtr?'T':'F')
220 << ") in fluka..." << endl;
221 GLOBAL.lfdrtr = true;
223 if (fVerbosityLevel >=2)
224 cout << "\t* Opening file " << fInputFileName << endl;
225 const char* fname = fInputFileName;
226 fluka_openinp(lunin, PASSCHARA(fname));
228 if (fVerbosityLevel >=2)
229 cout << "\t* Calling flukam..." << endl;
232 if (fVerbosityLevel >=2)
233 cout << "\t* Closing file " << fInputFileName << endl;
234 fluka_closeinp(lunin);
238 if (fVerbosityLevel >=3)
239 cout << "<== TFluka::Init() called." << endl;
242 if (fVerbosityLevel >=3)
243 cout << "<== TFluka::BuildPhysics() called." << endl;
246 //______________________________________________________________________________
247 void TFluka::ProcessEvent() {
251 if (fVerbosityLevel >=3)
252 cout << "==> TFluka::ProcessEvent() called." << endl;
253 fApplication->GeneratePrimaries();
254 EPISOR.lsouit = true;
256 if (fVerbosityLevel >=3)
257 cout << "<== TFluka::ProcessEvent() called." << endl;
260 //______________________________________________________________________________
261 Bool_t TFluka::ProcessRun(Int_t nevent) {
266 if (fVerbosityLevel >=3)
267 cout << "==> TFluka::ProcessRun(" << nevent << ") called."
270 if (fVerbosityLevel >=2) {
271 cout << "\t* GLOBAL.fdrtr = " << (GLOBAL.lfdrtr?'T':'F') << endl;
272 cout << "\t* Calling flukam again..." << endl;
275 fApplication->InitGeometry();
276 Int_t todo = TMath::Abs(nevent);
277 for (Int_t ev = 0; ev < todo; ev++) {
278 fApplication->BeginEvent();
280 fApplication->FinishEvent();
283 if (fVerbosityLevel >=3)
284 cout << "<== TFluka::ProcessRun(" << nevent << ") called."
289 //_____________________________________________________________________________
290 // methods for building/management of geometry
292 // functions from GCONS
293 //____________________________________________________________________________
294 void TFluka::Gfmate(Int_t imat, char *name, Float_t &a, Float_t &z,
295 Float_t &dens, Float_t &radl, Float_t &absl,
296 Float_t* /*ubuf*/, Int_t& /*nbuf*/) {
299 TIter next (gGeoManager->GetListOfMaterials());
300 while ((mat = (TGeoMaterial*)next())) {
301 if (mat->GetUniqueID() == (UInt_t)imat) break;
304 Error("Gfmate", "no material with index %i found", imat);
307 sprintf(name, "%s", mat->GetName());
310 dens = mat->GetDensity();
311 radl = mat->GetRadLen();
312 absl = mat->GetIntLen();
315 //______________________________________________________________________________
316 void TFluka::Gfmate(Int_t imat, char *name, Double_t &a, Double_t &z,
317 Double_t &dens, Double_t &radl, Double_t &absl,
318 Double_t* /*ubuf*/, Int_t& /*nbuf*/) {
321 TIter next (gGeoManager->GetListOfMaterials());
322 while ((mat = (TGeoMaterial*)next())) {
323 if (mat->GetUniqueID() == (UInt_t)imat) break;
326 Error("Gfmate", "no material with index %i found", imat);
329 sprintf(name, "%s", mat->GetName());
332 dens = mat->GetDensity();
333 radl = mat->GetRadLen();
334 absl = mat->GetIntLen();
337 // detector composition
338 //______________________________________________________________________________
339 void TFluka::Material(Int_t& kmat, const char* name, Double_t a,
340 Double_t z, Double_t dens, Double_t radl, Double_t absl,
341 Float_t* buf, Int_t nwbuf) {
343 Double_t* dbuf = fGeom->CreateDoubleArray(buf, nwbuf);
344 Material(kmat, name, a, z, dens, radl, absl, dbuf, nwbuf);
348 //______________________________________________________________________________
349 void TFluka::Material(Int_t& kmat, const char* name, Double_t a,
350 Double_t z, Double_t dens, Double_t radl, Double_t absl,
351 Double_t* /*buf*/, Int_t /*nwbuf*/) {
354 kmat = gGeoManager->GetListOfMaterials()->GetSize();
355 if ((z-Int_t(z)) > 1E-3) {
356 mat = fGeom->GetMakeWrongMaterial(z);
358 mat->SetRadLen(radl,absl);
359 mat->SetUniqueID(kmat);
363 gGeoManager->Material(name, a, z, dens, kmat, radl, absl);
366 //______________________________________________________________________________
367 void TFluka::Mixture(Int_t& kmat, const char *name, Float_t *a,
368 Float_t *z, Double_t dens, Int_t nlmat, Float_t *wmat) {
370 Double_t* da = fGeom->CreateDoubleArray(a, TMath::Abs(nlmat));
371 Double_t* dz = fGeom->CreateDoubleArray(z, TMath::Abs(nlmat));
372 Double_t* dwmat = fGeom->CreateDoubleArray(wmat, TMath::Abs(nlmat));
374 Mixture(kmat, name, da, dz, dens, nlmat, dwmat);
375 for (Int_t i=0; i<nlmat; i++) {
376 a[i] = da[i]; z[i] = dz[i]; wmat[i] = dwmat[i];
384 //______________________________________________________________________________
385 void TFluka::Mixture(Int_t& kmat, const char *name, Double_t *a,
386 Double_t *z, Double_t dens, Int_t nlmat, Double_t *wmat) {
388 // Defines mixture OR COMPOUND IMAT as composed by
389 // THE BASIC NLMAT materials defined by arrays A,Z and WMAT
391 // If NLMAT > 0 then wmat contains the proportion by
392 // weights of each basic material in the mixture.
394 // If nlmat < 0 then WMAT contains the number of atoms
395 // of a given kind into the molecule of the COMPOUND
396 // In this case, WMAT in output is changed to relative
403 for (i=0;i<nlmat;i++) {
404 amol += a[i]*wmat[i];
406 for (i=0;i<nlmat;i++) {
407 wmat[i] *= a[i]/amol;
410 kmat = gGeoManager->GetListOfMaterials()->GetSize();
411 // Check if we have elements with fractional Z
412 TGeoMaterial *mat = 0;
413 TGeoMixture *mix = 0;
414 Bool_t mixnew = kFALSE;
415 for (i=0; i<nlmat; i++) {
416 if (z[i]-Int_t(z[i]) < 1E-3) continue;
417 // We have found an element with fractional Z -> loop mixtures to look for it
418 for (j=0; j<kmat; j++) {
419 mat = (TGeoMaterial*)gGeoManager->GetListOfMaterials()->At(j);
421 if (!mat->IsMixture()) continue;
422 mix = (TGeoMixture*)mat;
423 if (TMath::Abs(z[i]-mix->GetZ()) >1E-3) continue;
424 // printf(" FOUND component %i as mixture %s\n", i, mat->GetName());
428 if (!mixnew) Warning("Mixture","%s : cannot find component %i with fractional Z=%f\n", name, i, z[i]);
432 Int_t nlmatnew = nlmat+mix->GetNelements()-1;
433 Double_t *anew = new Double_t[nlmatnew];
434 Double_t *znew = new Double_t[nlmatnew];
435 Double_t *wmatnew = new Double_t[nlmatnew];
437 for (j=0; j<nlmat; j++) {
441 wmatnew[ind] = wmat[j];
444 for (j=0; j<mix->GetNelements(); j++) {
445 anew[ind] = mix->GetAmixt()[j];
446 znew[ind] = mix->GetZmixt()[j];
447 wmatnew[ind] = wmat[i]*mix->GetWmixt()[j];
450 Mixture(kmat, name, anew, znew, dens, nlmatnew, wmatnew);
456 // Now we need to compact identical elements within the mixture
457 // First check if this happens
459 for (i=0; i<nlmat-1; i++) {
460 for (j=i+1; j<nlmat; j++) {
470 Double_t *anew = new Double_t[nlmat];
471 Double_t *znew = new Double_t[nlmat];
472 memset(znew, 0, nlmat*sizeof(Double_t));
473 Double_t *wmatnew = new Double_t[nlmat];
475 for (i=0; i<nlmat; i++) {
477 for (j=0; j<nlmatnew; j++) {
479 wmatnew[j] += wmat[i];
485 anew[nlmatnew] = a[i];
486 znew[nlmatnew] = z[i];
487 wmatnew[nlmatnew] = wmat[i];
490 Mixture(kmat, name, anew, znew, dens, nlmatnew, wmatnew);
496 gGeoManager->Mixture(name, a, z, dens, nlmat, wmat, kmat);
499 //______________________________________________________________________________
500 void TFluka::Medium(Int_t& kmed, const char *name, Int_t nmat,
501 Int_t isvol, Int_t ifield, Double_t fieldm, Double_t tmaxfd,
502 Double_t stemax, Double_t deemax, Double_t epsil,
503 Double_t stmin, Float_t* ubuf, Int_t nbuf) {
505 kmed = gGeoManager->GetListOfMedia()->GetSize()+1;
506 fMCGeo->Medium(kmed, name, nmat, isvol, ifield, fieldm, tmaxfd, stemax, deemax,
507 epsil, stmin, ubuf, nbuf);
510 //______________________________________________________________________________
511 void TFluka::Medium(Int_t& kmed, const char *name, Int_t nmat,
512 Int_t isvol, Int_t ifield, Double_t fieldm, Double_t tmaxfd,
513 Double_t stemax, Double_t deemax, Double_t epsil,
514 Double_t stmin, Double_t* ubuf, Int_t nbuf) {
516 kmed = gGeoManager->GetListOfMedia()->GetSize()+1;
517 fMCGeo->Medium(kmed, name, nmat, isvol, ifield, fieldm, tmaxfd, stemax, deemax,
518 epsil, stmin, ubuf, nbuf);
521 //______________________________________________________________________________
522 void TFluka::Matrix(Int_t& krot, Double_t thetaX, Double_t phiX,
523 Double_t thetaY, Double_t phiY, Double_t thetaZ,
526 krot = gGeoManager->GetListOfMatrices()->GetEntriesFast();
527 fMCGeo->Matrix(krot, thetaX, phiX, thetaY, phiY, thetaZ, phiZ);
530 //______________________________________________________________________________
531 void TFluka::Gstpar(Int_t itmed, const char* param, Double_t parval) {
535 if (fVerbosityLevel >=3) printf("Gstpar called with %6d %5s %12.4e %6d\n", itmed, param, parval, fGeom->GetFlukaMaterial(itmed));
537 Bool_t process = kFALSE;
538 if (strncmp(param, "DCAY", 4) == 0 ||
539 strncmp(param, "PAIR", 4) == 0 ||
540 strncmp(param, "COMP", 4) == 0 ||
541 strncmp(param, "PHOT", 4) == 0 ||
542 strncmp(param, "PFIS", 4) == 0 ||
543 strncmp(param, "DRAY", 4) == 0 ||
544 strncmp(param, "ANNI", 4) == 0 ||
545 strncmp(param, "BREM", 4) == 0 ||
546 strncmp(param, "MUNU", 4) == 0 ||
547 strncmp(param, "CKOV", 4) == 0 ||
548 strncmp(param, "HADR", 4) == 0 ||
549 strncmp(param, "LOSS", 4) == 0 ||
550 strncmp(param, "MULS", 4) == 0 ||
551 strncmp(param, "RAYL", 4) == 0)
556 SetProcess(param, Int_t (parval), fGeom->GetFlukaMaterial(itmed));
558 SetCut(param, parval, fGeom->GetFlukaMaterial(itmed));
562 // functions from GGEOM
563 //_____________________________________________________________________________
564 void TFluka::Gsatt(const char *name, const char *att, Int_t val)
566 // Set visualisation attributes for one volume
568 fGeom->Vname(name,vname);
570 fGeom->Vname(att,vatt);
571 gGeoManager->SetVolumeAttribute(vname, vatt, val);
574 //______________________________________________________________________________
575 Int_t TFluka::Gsvolu(const char *name, const char *shape, Int_t nmed,
576 Float_t *upar, Int_t np) {
578 return fMCGeo->Gsvolu(name, shape, nmed, upar, np);
581 //______________________________________________________________________________
582 Int_t TFluka::Gsvolu(const char *name, const char *shape, Int_t nmed,
583 Double_t *upar, Int_t np) {
585 return fMCGeo->Gsvolu(name, shape, nmed, upar, np);
588 //______________________________________________________________________________
589 void TFluka::Gsdvn(const char *name, const char *mother, Int_t ndiv,
592 fMCGeo->Gsdvn(name, mother, ndiv, iaxis);
595 //______________________________________________________________________________
596 void TFluka::Gsdvn2(const char *name, const char *mother, Int_t ndiv,
597 Int_t iaxis, Double_t c0i, Int_t numed) {
599 fMCGeo->Gsdvn2(name, mother, ndiv, iaxis, c0i, numed);
602 //______________________________________________________________________________
603 void TFluka::Gsdvt(const char *name, const char *mother, Double_t step,
604 Int_t iaxis, Int_t numed, Int_t ndvmx) {
606 fMCGeo->Gsdvt(name, mother, step, iaxis, numed, ndvmx);
609 //______________________________________________________________________________
610 void TFluka::Gsdvt2(const char *name, const char *mother, Double_t step,
611 Int_t iaxis, Double_t c0, Int_t numed, Int_t ndvmx) {
613 fMCGeo->Gsdvt2(name, mother, step, iaxis, c0, numed, ndvmx);
616 //______________________________________________________________________________
617 void TFluka::Gsord(const char * /*name*/, Int_t /*iax*/) {
619 // Nothing to do with TGeo
622 //______________________________________________________________________________
623 void TFluka::Gspos(const char *name, Int_t nr, const char *mother,
624 Double_t x, Double_t y, Double_t z, Int_t irot,
627 fMCGeo->Gspos(name, nr, mother, x, y, z, irot, konly);
630 //______________________________________________________________________________
631 void TFluka::Gsposp(const char *name, Int_t nr, const char *mother,
632 Double_t x, Double_t y, Double_t z, Int_t irot,
633 const char *konly, Float_t *upar, Int_t np) {
635 fMCGeo->Gsposp(name, nr, mother, x, y, z, irot, konly, upar, np);
638 //______________________________________________________________________________
639 void TFluka::Gsposp(const char *name, Int_t nr, const char *mother,
640 Double_t x, Double_t y, Double_t z, Int_t irot,
641 const char *konly, Double_t *upar, Int_t np) {
643 fMCGeo->Gsposp(name, nr, mother, x, y, z, irot, konly, upar, np);
646 //______________________________________________________________________________
647 void TFluka::Gsbool(const char* /*onlyVolName*/, const char* /*manyVolName*/) {
649 // Nothing to do with TGeo
652 //______________________________________________________________________________
653 void TFluka::SetCerenkov(Int_t itmed, Int_t npckov, Float_t* ppckov,
654 Float_t* absco, Float_t* effic, Float_t* rindex) {
656 // Set Cerenkov properties for medium itmed
658 // npckov: number of sampling points
659 // ppckov: energy values
660 // absco: absorption length
661 // effic: quantum efficiency
662 // rindex: refraction index
666 // Create object holding Cerenkov properties
668 TFlukaCerenkov* cerenkovProperties = new TFlukaCerenkov(npckov, ppckov, absco, effic, rindex);
670 // Pass object to medium
671 TGeoMedium* medium = gGeoManager->GetMedium(itmed);
672 medium->SetCerenkovProperties(cerenkovProperties);
675 //______________________________________________________________________________
676 void TFluka::SetCerenkov(Int_t /*itmed*/, Int_t /*npckov*/, Double_t * /*ppckov*/,
677 Double_t * /*absco*/, Double_t * /*effic*/, Double_t * /*rindex*/) {
679 // Not implemented with TGeo - what G4 did ? Any FLUKA card generated?
680 Warning("SetCerenkov", "Not implemented with TGeo");
684 //______________________________________________________________________________
685 void TFluka::WriteEuclid(const char* /*fileName*/, const char* /*topVol*/,
686 Int_t /*number*/, Int_t /*nlevel*/) {
689 Warning("WriteEuclid", "Not implemented with TGeo");
694 //_____________________________________________________________________________
695 // methods needed by the stepping
696 //____________________________________________________________________________
698 Int_t TFluka::GetMedium() const {
700 // Get the medium number for the current fluka region
702 return fGeom->GetMedium(); // this I need to check due to remapping !!!
707 //____________________________________________________________________________
708 // particle table usage
709 // ID <--> PDG transformations
710 //_____________________________________________________________________________
711 Int_t TFluka::IdFromPDG(Int_t pdg) const
714 // Return Fluka code from PDG and pseudo ENDF code
716 // Catch the feedback photons
717 if (pdg == 50000051) return (-1);
718 // MCIHAD() goes from pdg to fluka internal.
719 Int_t intfluka = mcihad(pdg);
720 // KPTOIP array goes from internal to official
721 return GetFlukaKPTOIP(intfluka);
724 //______________________________________________________________________________
725 Int_t TFluka::PDGFromId(Int_t id) const
728 // Return PDG code and pseudo ENDF code from Fluka code
729 // Alpha He3 Triton Deuteron gen. ion opt. photon
730 Int_t idSpecial[6] = {10020040, 10020030, 10010030, 10010020, 10000000, 50000050};
731 // IPTOKP array goes from official to internal
735 if (fVerbosityLevel >= 3)
736 printf("\n PDGFromId: Cerenkov Photon \n");
740 if (id == 0 || id < -6 || id > 250) {
741 if (fVerbosityLevel >= 3)
742 printf("PDGFromId: Error id = 0\n");
747 Int_t intfluka = GetFlukaIPTOKP(id);
749 if (fVerbosityLevel >= 3)
750 printf("PDGFromId: Error intfluka = 0: %d\n", id);
752 } else if (intfluka < 0) {
753 if (fVerbosityLevel >= 3)
754 printf("PDGFromId: Error intfluka < 0: %d\n", id);
757 if (fVerbosityLevel >= 3)
758 printf("mpdgha called with %d %d \n", id, intfluka);
759 // MPDGHA() goes from fluka internal to pdg.
760 return mpdgha(intfluka);
762 // ions and optical photons
763 return idSpecial[id + 6];
767 void TFluka::StopTrack()
769 // Set stopping conditions
770 // Works for photons and charged particles
774 //_____________________________________________________________________________
775 // methods for physics management
776 //____________________________________________________________________________
781 void TFluka::SetProcess(const char* flagName, Int_t flagValue, Int_t imed)
783 // Set process user flag for material imat
785 TFlukaConfigOption* proc = new TFlukaConfigOption(flagName, flagValue, imed);
786 fProcesses->Add(proc);
789 //______________________________________________________________________________
790 Bool_t TFluka::SetProcess(const char* flagName, Int_t flagValue)
792 // Set process user flag
795 // Update if already in the list
798 TIter next(fProcesses);
799 TFlukaConfigOption* proc;
800 while((proc = (TFlukaConfigOption*)next()))
802 if (strcmp(proc->GetName(), flagName) == 0) {
803 proc->SetFlag(flagValue);
809 // If not create a new process
812 proc = new TFlukaConfigOption(flagName, flagValue);
813 fProcesses->Add(proc);
818 //______________________________________________________________________________
819 void TFluka::SetCut(const char* cutName, Double_t cutValue, Int_t imed)
821 // Set user cut value for material imed
823 TFlukaConfigOption* cut = new TFlukaConfigOption(cutName, cutValue, imed);
827 //______________________________________________________________________________
828 Bool_t TFluka::SetCut(const char* cutName, Double_t cutValue)
830 // Set user cut value
833 // Update if already in the list
837 TFlukaConfigOption* cut;
838 while((cut = (TFlukaConfigOption*)next()))
840 if (strcmp(cut->GetName(), cutName) == 0) {
841 cut->SetCut(cutValue);
846 // If not create a new process
849 cut = new TFlukaConfigOption(cutName, cutValue);
855 //______________________________________________________________________________
856 Double_t TFluka::Xsec(char*, Double_t, Int_t, Int_t)
858 printf("WARNING: Xsec not yet implemented !\n"); return -1.;
862 //______________________________________________________________________________
863 void TFluka::InitPhysics()
866 // Physics initialisation with preparation of FLUKA input cards
868 printf("=>InitPhysics\n");
872 FILE *pAliceCoreInp, *pAliceFlukaMat, *pAliceInp;
877 Double_t three = 3.0;
879 Float_t fLastMaterial = fGeom->GetLastMaterialIndex();
880 if (fVerbosityLevel >= 3) printf(" last FLUKA material is %g\n", fLastMaterial);
883 TObjArray *matList = GetFlukaMaterials();
884 Int_t nmaterial = matList->GetEntriesFast();
885 fMaterials = new Int_t[nmaterial+3];
887 // construct file names
889 TString sAliceCoreInp = getenv("ALICE_ROOT");
890 sAliceCoreInp +="/TFluka/input/";
891 TString sAliceTmp = "flukaMat.inp";
892 TString sAliceInp = GetInputFileName();
893 sAliceCoreInp += GetCoreInputFileName();
897 if ((pAliceCoreInp = fopen(sAliceCoreInp.Data(),"r")) == NULL) {
898 printf("\nCannot open file %s\n",sAliceCoreInp.Data());
901 if ((pAliceFlukaMat = fopen(sAliceTmp.Data(),"r")) == NULL) {
902 printf("\nCannot open file %s\n",sAliceTmp.Data());
905 if ((pAliceInp = fopen(sAliceInp.Data(),"w")) == NULL) {
906 printf("\nCannot open file %s\n",sAliceInp.Data());
910 // copy core input file
912 Float_t fEventsPerRun;
914 while ((fgets(sLine,255,pAliceCoreInp)) != NULL) {
915 if (strncmp(sLine,"GEOEND",6) != 0)
916 fprintf(pAliceInp,"%s",sLine); // copy until GEOEND card
918 fprintf(pAliceInp,"GEOEND\n"); // add GEOEND card
921 } // end of while until GEOEND card
925 while ((fgets(sLine,255,pAliceFlukaMat)) != NULL) { // copy flukaMat.inp file
926 fprintf(pAliceInp,"%s\n",sLine);
929 while ((fgets(sLine,255,pAliceCoreInp)) != NULL) {
930 if (strncmp(sLine,"START",5) != 0)
931 fprintf(pAliceInp,"%s\n",sLine);
933 sscanf(sLine+10,"%10f",&fEventsPerRun);
936 } //end of while until START card
939 // in G3 the process control values meaning can be different for
940 // different processes, but for most of them is:
941 // 0 process is not activated
942 // 1 process is activated WITH generation of secondaries
943 // 2 process is activated WITHOUT generation of secondaries
944 // if process does not generate secondaries => 1 same as 2
953 // Loop over number of SetProcess calls
954 fprintf(pAliceInp,"*----------------------------------------------------------------------------- \n");
955 fprintf(pAliceInp,"*----- The following data are generated from SetProcess and SetCut calls ----- \n");
956 fprintf(pAliceInp,"*----------------------------------------------------------------------------- \n");
958 // Outer loop over processes
959 TIter next(fProcesses);
960 TFlukaConfigOption *proc;
961 // Inner loop over processes
962 TIter nextp(fProcesses);
963 TFlukaConfigOption *procp;
966 TFlukaConfigOption *cut = 0x0;
968 while((proc = (TFlukaConfigOption*)next())) {
969 Float_t matMin = three;
970 Float_t matMax = fLastMaterial;
971 Bool_t global = kTRUE;
972 if (proc->Medium() != -1) {
973 matMin = Float_t(proc->Medium());
979 // G3 default value: 1
980 // G4 processes: G4eplusAnnihilation/G4IeplusAnnihilation
983 // flag = 0 no annihilation
984 // flag = 1 annihilation, decays processed
985 // flag = 2 annihilation, no decay product stored
986 // gMC ->SetProcess("ANNI",1); // EMFCUT -1. 0. 0. 3. lastmat 0. ANNH-THR
987 if (strncmp(proc->GetName(),"ANNI",4) == 0) {
988 if (proc->Flag() == 1 || proc->Flag() == 2) {
989 fprintf(pAliceInp,"*\n*Kinetic energy threshold (GeV) for e+ annihilation - resets to default=0.\n");
990 fprintf(pAliceInp,"*Generated from call: SetProcess('ANNI',1) or SetProcess('ANNI',2)\n");
991 // -one = kinetic energy threshold (GeV) for e+ annihilation (resets to default=0)
994 // matMin = lower bound of the material indices in which the respective thresholds apply
995 // matMax = upper bound of the material indices in which the respective thresholds apply
996 // one = step length in assigning indices
998 fprintf(pAliceInp,"EMFCUT %10.1f%10.1f%10.1f%10.1f%10.1f%10.1fANNH-THR\n",-one,zero,zero,matMin,matMax,one);
1000 else if (proc->Flag() == 0) {
1001 fprintf(pAliceInp,"*\n*No annihilation - no FLUKA card generated\n");
1002 fprintf(pAliceInp,"*Generated from call: SetProcess('ANNI',0)\n");
1005 fprintf(pAliceInp,"*\n*Illegal flag value in SetProcess('ANNI',?) call.\n");
1006 fprintf(pAliceInp,"*No FLUKA card generated\n");
1010 // bremsstrahlung and pair production are both activated
1011 // G3 default value: 1
1012 // G4 processes: G4eBremsstrahlung/G4IeBremsstrahlung,
1013 // G4MuBremsstrahlung/G4IMuBremsstrahlung,
1014 // G4LowEnergyBremstrahlung
1015 // Particles: e-/e+; mu+/mu-
1017 // flag = 0 no bremsstrahlung
1018 // flag = 1 bremsstrahlung, photon processed
1019 // flag = 2 bremsstrahlung, no photon stored
1020 // gMC ->SetProcess("BREM",1); // PAIRBREM 2. 0. 0. 3. lastmat
1021 // EMFCUT -1. 0. 0. 3. lastmat 0. ELPO-THR
1022 // G3 default value: 1
1023 // G4 processes: G4GammaConversion,
1024 // G4MuPairProduction/G4IMuPairProduction
1025 // G4LowEnergyGammaConversion
1026 // Particles: gamma, mu
1028 // flag = 0 no delta rays
1029 // flag = 1 delta rays, secondaries processed
1030 // flag = 2 delta rays, no secondaries stored
1031 // gMC ->SetProcess("PAIR",1); // PAIRBREM 1. 0. 0. 3. lastmat
1032 // EMFCUT 0. 0. -1. 3. lastmat 0. PHOT-THR
1033 else if ((strncmp(proc->GetName(),"PAIR",4) == 0) && (proc->Flag() == 1 || proc->Flag() == 2)) {
1037 while ((procp = (TFlukaConfigOption*)nextp())) {
1038 if ((strncmp(procp->GetName(),"BREM",4) == 0) &&
1039 (proc->Flag() == 1 || procp->Flag() == 2) &&
1040 (procp->Medium() == proc->Medium())) {
1041 fprintf(pAliceInp,"*\n*Bremsstrahlung and pair production by muons and charged hadrons both activated\n");
1042 fprintf(pAliceInp,"*Generated from call: SetProcess('BREM',1) and SetProcess('PAIR',1)\n");
1043 fprintf(pAliceInp,"*Energy threshold set by call SetCut('BCUTM',cut) or set to 0.\n");
1044 fprintf(pAliceInp,"*Energy threshold set by call SetCut('PPCUTM',cut) or set to 0.\n");
1045 // three = bremsstrahlung and pair production by muons and charged hadrons both are activated
1046 fprintf(pAliceInp,"PAIRBREM %10.1f",three);
1047 // direct pair production by muons
1048 // G4 particles: "e-", "e+"
1049 // G3 default value: 0.01 GeV
1050 //gMC ->SetCut("PPCUTM",cut); // total energy cut for direct pair prod. by muons
1053 while ((cut = (TFlukaConfigOption*)nextc())) {
1054 if (strncmp(cut->GetName(), "PPCUTM", 6) == 0 &&
1055 (cut->Medium() == proc->Medium())) fCut = cut->Cut();
1057 fprintf(pAliceInp,"%10.4g",fCut);
1058 // fCut; = e+, e- kinetic energy threshold (in GeV) for explicit pair production.
1059 // muon and hadron bremsstrahlung
1060 // G4 particles: "gamma"
1061 // G3 default value: CUTGAM=0.001 GeV
1062 //gMC ->SetCut("BCUTM",cut); // cut for muon and hadron bremsstrahlung
1065 while ((cut = (TFlukaConfigOption*)nextc())) {
1066 if (strncmp(cut->GetName(), "BCUTM", 5) == 0 &&
1067 (cut->Medium() == proc->Medium())) fCut = cut->Cut();
1069 fprintf(pAliceInp,"%10.4g%10.1f%10.1f\n",fCut,matMin,matMax);
1070 // fCut = photon energy threshold (GeV) for explicit bremsstrahlung production
1071 // matMin = lower bound of the material indices in which the respective thresholds apply
1072 // matMax = upper bound of the material indices in which the respective thresholds apply
1075 fprintf(pAliceInp,"*\n*Kinetic energy threshold (GeV) for e+/e- bremsstrahlung - resets to default=0.\n");
1076 fprintf(pAliceInp,"*Generated from call: SetProcess('BREM',1);\n");
1079 while ((cut = (TFlukaConfigOption*)nextc())) {
1080 if (strncmp(cut->GetName(), "BCUTE", 5) == 0 &&
1081 (cut->Medium() == proc->Medium())) fCut = cut->Cut();
1083 //fCut = kinetic energy threshold (GeV) for e+/e- bremsstrahlung (resets to default=0)
1086 // matMin = lower bound of the material indices in which the respective thresholds apply
1087 // matMax = upper bound of the material indices in which the respective thresholds apply
1088 // one = step length in assigning indices
1090 fprintf(pAliceInp,"EMFCUT %10.4g%10.1f%10.1f%10.1f%10.1f%10.1fELPO-THR\n",fCut,zero,zero,matMin,matMax,one);
1093 fprintf(pAliceInp,"*\n*Pair production by electrons is activated\n");
1094 fprintf(pAliceInp,"*Generated from call: SetProcess('PAIR',1);\n");
1097 while ((cut = (TFlukaConfigOption*)nextc())) {
1098 if (strncmp(cut->GetName(), "CUTGAM", 6) == 0 &&
1099 (cut->Medium() == proc->Medium())) fCut = cut->Cut();
1101 // fCut = energy threshold (GeV) for gamma pair production (< 0.0 : resets to default, = 0.0 : ignored)
1102 // matMin = lower bound of the material indices in which the respective thresholds apply
1103 // matMax = upper bound of the material indices in which the respective thresholds apply
1104 // one = step length in assigning indices
1105 fprintf(pAliceInp,"EMFCUT %10.1f%10.1f%10.4g%10.1f%10.1f%10.1fPHOT-THR\n",zero,zero,fCut,matMin,matMax,one);
1107 } // end of if for BREM
1108 } // end of loop for BREM
1110 // only pair production by muons and charged hadrons is activated
1111 fprintf(pAliceInp,"*\n*Pair production by muons and charged hadrons is activated\n");
1112 fprintf(pAliceInp,"*Generated from call: SetProcess('PAIR',1) or SetProcess('PAIR',2)\n");
1113 fprintf(pAliceInp,"*Energy threshold set by call SetCut('PPCUTM',cut) or set to 0.\n");
1114 // direct pair production by muons
1115 // G4 particles: "e-", "e+"
1116 // G3 default value: 0.01 GeV
1117 //gMC ->SetCut("PPCUTM",cut); // total energy cut for direct pair prod. by muons
1118 // one = pair production by muons and charged hadrons is activated
1119 // zero = e+, e- kinetic energy threshold (in GeV) for explicit pair production.
1120 // zero = no explicit bremsstrahlung production is simulated
1121 // matMin = lower bound of the material indices in which the respective thresholds apply
1122 // matMax = upper bound of the material indices in which the respective thresholds apply
1123 fprintf(pAliceInp,"PAIRBREM %10.1f%10.1f%10.1f%10.1f%10.1f\n",one,zero,zero,matMin,matMax);
1126 fprintf(pAliceInp,"*\n*Pair production by electrons is activated\n");
1127 fprintf(pAliceInp,"*Generated from call: SetProcess('PAIR',1) or SetProcess('PAIR',2)\n");
1130 while ((cut = (TFlukaConfigOption*)nextc())) {
1131 if (strncmp(cut->GetName(), "CUTGAM", 6) == 0 &&
1132 (cut->Medium() == proc->Medium())) fCut = cut->Cut();
1134 // zero = energy threshold (GeV) for Compton scattering (= 0.0 : ignored)
1135 // zero = energy threshold (GeV) for Photoelectric (= 0.0 : ignored)
1136 // fCut = energy threshold (GeV) for gamma pair production (< 0.0 : resets to default, = 0.0 : ignored)
1137 // matMin = lower bound of the material indices in which the respective thresholds apply
1138 // matMax = upper bound of the material indices in which the respective thresholds apply
1139 // one = step length in assigning indices
1140 fprintf(pAliceInp,"EMFCUT %10.1f%10.1f%10.4g%10.1f%10.1f%10.1fPHOT-THR\n",zero,zero,fCut,matMin,matMax,one);
1144 } // end of if for PAIR
1149 // G3 default value: 1
1150 // G4 processes: G4eBremsstrahlung/G4IeBremsstrahlung,
1151 // G4MuBremsstrahlung/G4IMuBremsstrahlung,
1152 // G4LowEnergyBremstrahlung
1153 // Particles: e-/e+; mu+/mu-
1155 // flag = 0 no bremsstrahlung
1156 // flag = 1 bremsstrahlung, photon processed
1157 // flag = 2 bremsstrahlung, no photon stored
1158 // gMC ->SetProcess("BREM",1); // PAIRBREM 2. 0. 0. 3. lastmat
1159 // EMFCUT -1. 0. 0. 3. lastmat 0. ELPO-THR
1160 else if (strncmp(proc->GetName(),"BREM",4) == 0) {
1162 while((procp = (TFlukaConfigOption*)nextp())) {
1163 if ((strncmp(procp->GetName(),"PAIR",4) == 0) &&
1164 procp->Flag() == 1 &&
1165 (procp->Medium() == proc->Medium())) goto NOBREM;
1167 if (proc->Flag() == 1 || proc->Flag() == 2) {
1168 fprintf(pAliceInp,"*\n*Bremsstrahlung by muons and charged hadrons is activated\n");
1169 fprintf(pAliceInp,"*Generated from call: SetProcess('BREM',1) or SetProcess('BREM',2)\n");
1170 fprintf(pAliceInp,"*Energy threshold set by call SetCut('BCUTM',cut) or set to 0.\n");
1171 // two = bremsstrahlung by muons and charged hadrons is activated
1172 // zero = no meaning
1173 // muon and hadron bremsstrahlung
1174 // G4 particles: "gamma"
1175 // G3 default value: CUTGAM=0.001 GeV
1176 //gMC ->SetCut("BCUTM",cut); // cut for muon and hadron bremsstrahlung
1179 while ((cut = (TFlukaConfigOption*)nextc())) {
1180 if (strncmp(cut->GetName(), "BCUTM", 5) == 0 &&
1181 (cut->Medium() == proc->Medium())) fCut = cut->Cut();
1183 // fCut = photon energy threshold (GeV) for explicit bremsstrahlung production
1184 // matMin = lower bound of the material indices in which the respective thresholds apply
1185 // matMax = upper bound of the material indices in which the respective thresholds apply
1186 fprintf(pAliceInp,"PAIRBREM %10.1f%10.1f%10.4g%10.1f%10.1f\n",two,zero,fCut,matMin,matMax);
1189 fprintf(pAliceInp,"*\n*Kinetic energy threshold (GeV) for e+/e- bremsstrahlung - resets to default=0.\n");
1190 fprintf(pAliceInp,"*Generated from call: SetProcess('BREM',1);");
1191 // - one = kinetic energy threshold (GeV) for e+/e- bremsstrahlung (resets to default=0)
1194 // matMin = lower bound of the material indices in which the respective thresholds apply
1195 // matMax = upper bound of the material indices in which the respective thresholds apply
1196 // one = step length in assigning indices
1198 fprintf(pAliceInp,"EMFCUT %10.1f%10.1f%10.1f%10.1f%10.1f%10.1fELPO-THR\n",-one,zero,zero,matMin,matMax,one);
1200 else if (proc->Flag() == 0) {
1201 fprintf(pAliceInp,"*\n*No bremsstrahlung - no FLUKA card generated\n");
1202 fprintf(pAliceInp,"*Generated from call: SetProcess('BREM',0)\n");
1205 fprintf(pAliceInp,"*\n*Illegal flag value in SetProcess('BREM',?) call.\n");
1206 fprintf(pAliceInp,"*No FLUKA card generated\n");
1210 } // end of else if (strncmp(proc->GetName(),"BREM",4) == 0)
1212 // Cerenkov photon generation
1213 // G3 default value: 0
1214 // G4 process: G4Cerenkov
1216 // Particles: charged
1218 // flag = 0 no Cerenkov photon generation
1219 // flag = 1 Cerenkov photon generation
1220 // flag = 2 Cerenkov photon generation with primary stopped at each step
1221 //xx gMC ->SetProcess("CKOV",1); // ??? Cerenkov photon generation
1223 else if (strncmp(proc->GetName(),"CKOV",4) == 0) {
1224 if ((proc->Flag() == 1 || proc->Flag() == 2) && global) {
1226 fprintf(pAliceInp, "* \n");
1227 fprintf(pAliceInp, "*Cerenkov photon generation\n");
1228 fprintf(pAliceInp, "*Generated from call: SetProcess('CKOV',1) or SetProcess('CKOV',2)\n");
1230 for (Int_t im = 0; im < nmaterial; im++)
1232 TGeoMaterial* material = dynamic_cast<TGeoMaterial*> (matList->At(im));
1233 Int_t idmat = material->GetIndex();
1235 if (!global && idmat != proc->Medium()) continue;
1237 fMaterials[idmat] = im;
1238 // Skip media with no Cerenkov properties
1239 TFlukaCerenkov* cerenkovProp;
1240 if (!(cerenkovProp = dynamic_cast<TFlukaCerenkov*>(material->GetCerenkovProperties()))) continue;
1242 // This medium has Cerenkov properties
1245 // Write OPT-PROD card for each medium
1246 Float_t emin = cerenkovProp->GetMinimumEnergy();
1247 Float_t emax = cerenkovProp->GetMaximumEnergy();
1248 fprintf(pAliceInp, "OPT-PROD %10.4g%10.4g%10.4g%10.4g%10.4g%10.4gCERENKOV\n", emin, emax, 0.,
1249 Float_t(idmat), Float_t(idmat), 0.);
1251 // Write OPT-PROP card for each medium
1252 // Forcing FLUKA to call user routines (queffc.cxx, rflctv.cxx, rfrndx.cxx)
1254 fprintf(pAliceInp, "OPT-PROP %10.4g%10.4g%10.4g%10.1f%10.1f%10.1fWV-LIMIT\n",
1255 cerenkovProp->GetMinimumWavelength(),
1256 cerenkovProp->GetMaximumWavelength(),
1257 cerenkovProp->GetMaximumWavelength(),
1258 Float_t(idmat), Float_t(idmat), 0.0);
1260 if (cerenkovProp->IsMetal()) {
1261 fprintf(pAliceInp, "OPT-PROP %10.1f%10.1f%10.1f%10.1f%10.1f%10.1fMETAL\n",
1262 -100., -100., -100.,
1263 Float_t(idmat), Float_t(idmat), 0.0);
1265 fprintf(pAliceInp, "OPT-PROP %10.1f%10.1f%10.1f%10.1f%10.1f%10.1f\n",
1266 -100., -100., -100.,
1267 Float_t(idmat), Float_t(idmat), 0.0);
1271 for (Int_t j = 0; j < 3; j++) {
1272 fprintf(pAliceInp, "OPT-PROP %10.1f%10.1f%10.1f%10.1f%10.1f%10.1f&\n",
1273 -100., -100., -100.,
1274 Float_t(idmat), Float_t(idmat), 0.0);
1276 // Photon detection efficiency user defined
1278 if (cerenkovProp->IsSensitive())
1279 fprintf(pAliceInp, "OPT-PROP %10.1f%10.1f%10.1f%10.1f%10.1f%10.1fSENSITIV\n",
1280 -100., -100., -100.,
1281 Float_t(idmat), Float_t(idmat), 0.0);
1284 } else if (proc->Flag() == 0) {
1285 fprintf(pAliceInp,"*\n*No Cerenkov photon generation\n");
1286 fprintf(pAliceInp,"*Generated from call: SetProcess('CKOV',0)\n");
1290 // matMin = lower bound of the material indices in which the respective thresholds apply
1291 // matMax = upper bound of the material indices in which the respective thresholds apply
1292 // one = step length in assigning indices
1294 fprintf(pAliceInp,"OPT-PROD %10.1f%10.1f%10.1f%10.1f%10.1f%10.1fCERE-OFF\n",zero,zero,zero,matMin,matMax,one);
1297 fprintf(pAliceInp,"*\n*Illegal flag value in SetProcess('CKOV',?) call.\n");
1298 fprintf(pAliceInp,"*No FLUKA card generated\n");
1300 } // end of else if (strncmp(proc->GetName(),"CKOV",4) == 0)
1302 // Compton scattering
1303 // G3 default value: 1
1304 // G4 processes: G4ComptonScattering,
1305 // G4LowEnergyCompton,
1306 // G4PolarizedComptonScattering
1309 // flag = 0 no Compton scattering
1310 // flag = 1 Compton scattering, electron processed
1311 // flag = 2 Compton scattering, no electron stored
1312 // gMC ->SetProcess("COMP",1); // EMFCUT -1. 0. 0. 3. lastmat 0. PHOT-THR
1313 else if (strncmp(proc->GetName(),"COMP",4) == 0) {
1314 if (proc->Flag() == 1 || proc->Flag() == 2) {
1315 fprintf(pAliceInp,"*\n*Energy threshold (GeV) for Compton scattering - resets to default=0.\n");
1316 fprintf(pAliceInp,"*Generated from call: SetProcess('COMP',1);\n");
1317 // - one = energy threshold (GeV) for Compton scattering - resets to default=0.
1320 // matMin = lower bound of the material indices in which the respective thresholds apply
1321 // matMax = upper bound of the material indices in which the respective thresholds apply
1322 // one = step length in assigning indices
1324 fprintf(pAliceInp,"EMFCUT %10.1f%10.1f%10.1f%10.1f%10.1f%10.1fPHOT-THR\n",-one,zero,zero,matMin,matMax,one);
1326 else if (proc->Flag() == 0) {
1327 fprintf(pAliceInp,"*\n*No Compton scattering - no FLUKA card generated\n");
1328 fprintf(pAliceInp,"*Generated from call: SetProcess('COMP',0)\n");
1331 fprintf(pAliceInp,"*\n*Illegal flag value in SetProcess('COMP',?) call.\n");
1332 fprintf(pAliceInp,"*No FLUKA card generated\n");
1334 } // end of else if (strncmp(proc->GetName(),"COMP",4) == 0)
1337 // G3 default value: 1
1338 // G4 process: G4Decay
1340 // Particles: all which decay is applicable for
1342 // flag = 0 no decays
1343 // flag = 1 decays, secondaries processed
1344 // flag = 2 decays, no secondaries stored
1345 //gMC ->SetProcess("DCAY",1); // not available
1346 else if ((strncmp(proc->GetName(),"DCAY",4) == 0) && proc->Flag() == 1)
1347 cout << "SetProcess for flag=" << proc->GetName() << " value=" << proc->Flag() << " not avaliable!" << endl;
1350 // G3 default value: 2
1351 // !! G4 treats delta rays in different way
1352 // G4 processes: G4eIonisation/G4IeIonization,
1353 // G4MuIonisation/G4IMuIonization,
1354 // G4hIonisation/G4IhIonisation
1355 // Particles: charged
1357 // flag = 0 no energy loss
1358 // flag = 1 restricted energy loss fluctuations
1359 // flag = 2 complete energy loss fluctuations
1360 // flag = 3 same as 1
1361 // flag = 4 no energy loss fluctuations
1362 // gMC ->SetProcess("DRAY",0); // DELTARAY 1.E+6 0. 0. 3. lastmat 0.
1363 else if (strncmp(proc->GetName(),"DRAY",4) == 0) {
1364 if (proc->Flag() == 0 || proc->Flag() == 4) {
1365 fprintf(pAliceInp,"*\n*Kinetic energy threshold (GeV) for delta ray production\n");
1366 fprintf(pAliceInp,"*Generated from call: SetProcess('DRAY',0) or SetProcess('DRAY',4)\n");
1367 fprintf(pAliceInp,"*No delta ray production by muons - threshold set artificially high\n");
1368 Double_t emin = 1.0e+6; // kinetic energy threshold (GeV) for delta ray production (discrete energy transfer)
1371 // matMin = lower bound of the material indices in which the respective thresholds apply
1372 // matMax = upper bound of the material indices in which the respective thresholds apply
1373 // one = step length in assigning indices
1374 fprintf(pAliceInp,"DELTARAY %10.4g%10.1f%10.1f%10.1f%10.1f%10.1f\n",emin,zero,zero,matMin,matMax,one);
1376 else if (proc->Flag() == 1 || proc->Flag() == 2 || proc->Flag() == 3) {
1377 fprintf(pAliceInp,"*\n*Kinetic energy threshold (GeV) for delta ray production\n");
1378 fprintf(pAliceInp,"*Generated from call: SetProcess('DRAY',flag), flag=1,2,3\n");
1379 fprintf(pAliceInp,"*Delta ray production by muons switched on\n");
1380 fprintf(pAliceInp,"*Energy threshold set by call SetCut('DCUTM',cut) or set to 1.0e+6.\n");
1383 while ((cut = (TFlukaConfigOption*)nextc())) {
1384 if (strncmp(cut->GetName(), "DCUTM", 5) == 0 &&
1385 cut->Medium() == proc->Medium()) fCut = cut->Cut();
1387 // fCut = kinetic energy threshold (GeV) for delta ray production (discrete energy transfer)
1390 // matMin = lower bound of the material indices in which the respective thresholds apply
1391 // matMax = upper bound of the material indices in which the respective thresholds apply
1392 // one = step length in assigning indices
1393 fprintf(pAliceInp,"DELTARAY %10.4g%10.1f%10.1f%10.1f%10.1f%10.1f\n",fCut,zero,zero,matMin,matMax,one);
1396 fprintf(pAliceInp,"*\n*Illegal flag value in SetProcess('DRAY',?) call.\n");
1397 fprintf(pAliceInp,"*No FLUKA card generated\n");
1399 } // end of else if (strncmp(proc->GetName(),"DRAY",4) == 0)
1402 // G3 default value: 1
1403 // G4 processes: all defined by TG4PhysicsConstructorHadron
1405 // Particles: hadrons
1407 // flag = 0 no multiple scattering
1408 // flag = 1 hadronic interactions, secondaries processed
1409 // flag = 2 hadronic interactions, no secondaries stored
1410 // gMC ->SetProcess("HADR",1); // ??? hadronic process
1411 //Select pure GEANH (HADR 1) or GEANH/NUCRIN (HADR 3) ?????
1412 else if (strncmp(proc->GetName(),"HADR",4) == 0) {
1413 if (proc->Flag() == 1 || proc->Flag() == 2) {
1414 fprintf(pAliceInp,"*\n*Hadronic interaction is ON by default in FLUKA\n");
1415 fprintf(pAliceInp,"*No FLUKA card generated\n");
1417 else if (proc->Flag() == 0) {
1418 fprintf(pAliceInp,"*\n*Hadronic interaction is set OFF\n");
1419 fprintf(pAliceInp,"*Generated from call: SetProcess('HADR',0);\n");
1420 fprintf(pAliceInp,"*Switching off hadronic interactions not foreseen in FLUKA\n");
1421 fprintf(pAliceInp,"THRESHOL %10.1f%10.1f%10.1f%10.1e%10.1f\n",zero, zero, zero, 1.e10, zero);
1424 fprintf(pAliceInp,"*\n*Illegal flag value in SetProcess('HADR',?) call.\n");
1425 fprintf(pAliceInp,"*No FLUKA card generated\n");
1427 } // end of else if (strncmp(proc->GetName(),"HADR",4) == 0)
1431 // G3 default value: 2
1432 // G4 processes: G4eIonisation/G4IeIonization,
1433 // G4MuIonisation/G4IMuIonization,
1434 // G4hIonisation/G4IhIonisation
1436 // Particles: charged
1438 // flag=0 no energy loss
1439 // flag=1 restricted energy loss fluctuations
1440 // flag=2 complete energy loss fluctuations
1442 // flag=4 no energy loss fluctuations
1443 // If the value ILOSS is changed, then (in G3) cross-sections and energy
1444 // loss tables must be recomputed via the command 'PHYSI'
1445 // gMC ->SetProcess("LOSS",2); // ??? IONFLUCT ? energy loss
1446 else if (strncmp(proc->GetName(),"LOSS",4) == 0) {
1447 if (proc->Flag() == 2) { // complete energy loss fluctuations
1448 fprintf(pAliceInp,"*\n*Complete energy loss fluctuations do not exist in FLUKA\n");
1449 fprintf(pAliceInp,"*Generated from call: SetProcess('LOSS',2);\n");
1450 fprintf(pAliceInp,"*flag=2=complete energy loss fluctuations\n");
1451 fprintf(pAliceInp,"*No FLUKA card generated\n");
1453 else if (proc->Flag() == 1 || proc->Flag() == 3) { // restricted energy loss fluctuations
1454 fprintf(pAliceInp,"*\n*Restricted energy loss fluctuations\n");
1455 fprintf(pAliceInp,"*Generated from call: SetProcess('LOSS',1) or SetProcess('LOSS',3)\n");
1456 // one = restricted energy loss fluctuations (for hadrons and muons) switched on
1457 // one = restricted energy loss fluctuations (for e+ and e-) switched on
1458 // one = minimal accuracy
1459 // matMin = lower bound of the material indices in which the respective thresholds apply
1460 // upper bound of the material indices in which the respective thresholds apply
1461 fprintf(pAliceInp,"IONFLUCT %10.1f%10.1f%10.1f%10.1f%10.1f\n",one,one,one,matMin,matMax);
1463 else if (proc->Flag() == 4) { // no energy loss fluctuations
1464 fprintf(pAliceInp,"*\n*No energy loss fluctuations\n");
1465 fprintf(pAliceInp,"*\n*Generated from call: SetProcess('LOSS',4)\n");
1466 // - one = restricted energy loss fluctuations (for hadrons and muons) switched off
1467 // - one = restricted energy loss fluctuations (for e+ and e-) switched off
1468 // one = minimal accuracy
1469 // matMin = lower bound of the material indices in which the respective thresholds apply
1470 // matMax = upper bound of the material indices in which the respective thresholds apply
1471 fprintf(pAliceInp,"IONFLUCT %10.1f%10.1f%10.1f%10.1f%10.1f\n",-one,-one,one,matMin,matMax);
1474 fprintf(pAliceInp,"*\n*Illegal flag value in SetProcess('LOSS',?) call.\n");
1475 fprintf(pAliceInp,"*No FLUKA card generated\n");
1477 } // end of else if (strncmp(proc->GetName(),"LOSS",4) == 0)
1480 // multiple scattering
1481 // G3 default value: 1
1482 // G4 process: G4MultipleScattering/G4IMultipleScattering
1484 // Particles: charged
1486 // flag = 0 no multiple scattering
1487 // flag = 1 Moliere or Coulomb scattering
1488 // flag = 2 Moliere or Coulomb scattering
1489 // flag = 3 Gaussian scattering
1490 // gMC ->SetProcess("MULS",1); // MULSOPT multiple scattering
1491 else if (strncmp(proc->GetName(),"MULS",4) == 0) {
1492 if (proc->Flag() == 1 || proc->Flag() == 2 || proc->Flag() == 3) {
1493 fprintf(pAliceInp,"*\n*Multiple scattering is ON by default for e+e- and for hadrons/muons\n");
1494 fprintf(pAliceInp,"*No FLUKA card generated\n");
1496 else if (proc->Flag() == 0) {
1497 fprintf(pAliceInp,"*\n*Multiple scattering is set OFF\n");
1498 fprintf(pAliceInp,"*Generated from call: SetProcess('MULS',0);\n");
1500 // three = multiple scattering for hadrons and muons is completely suppressed
1501 // three = multiple scattering for e+ and e- is completely suppressed
1502 // matMin = lower bound of the material indices in which the respective thresholds apply
1503 // matMax = upper bound of the material indices in which the respective thresholds apply
1504 fprintf(pAliceInp,"MULSOPT %10.1f%10.1f%10.1f%10.1f%10.1f\n",zero,three,three,matMin,matMax);
1507 fprintf(pAliceInp,"*\n*Illegal flag value in SetProcess('MULS',?) call.\n");
1508 fprintf(pAliceInp,"*No FLUKA card generated\n");
1510 } // end of else if (strncmp(proc->GetName(),"MULS",4) == 0)
1513 // muon nuclear interaction
1514 // G3 default value: 0
1515 // G4 processes: G4MuNuclearInteraction,
1516 // G4MuonMinusCaptureAtRest
1520 // flag = 0 no muon-nuclear interaction
1521 // flag = 1 nuclear interaction, secondaries processed
1522 // flag = 2 nuclear interaction, secondaries not processed
1523 // gMC ->SetProcess("MUNU",1); // MUPHOTON 1. 0. 0. 3. lastmat
1524 else if (strncmp(proc->GetName(),"MUNU",4) == 0) {
1525 if (proc->Flag() == 1) {
1526 fprintf(pAliceInp,"*\n*Muon nuclear interactions with production of secondary hadrons\n");
1527 fprintf(pAliceInp,"*\n*Generated from call: SetProcess('MUNU',1);\n");
1528 // one = full simulation of muon nuclear interactions and production of secondary hadrons
1529 // zero = ratio of longitudinal to transverse virtual photon cross-section - Default = 0.25.
1530 // zero = fraction of rho-like interactions ( must be < 1) - Default = 0.75.
1531 // matMin = lower bound of the material indices in which the respective thresholds apply
1532 // matMax = upper bound of the material indices in which the respective thresholds apply
1533 fprintf(pAliceInp,"MUPHOTON %10.1f%10.1f%10.1f%10.1f%10.1f\n",one,zero,zero,matMin,matMax);
1535 else if (proc->Flag() == 2) {
1536 fprintf(pAliceInp,"*\n*Muon nuclear interactions without production of secondary hadrons\n");
1537 fprintf(pAliceInp,"*Generated from call: SetProcess('MUNU',2);\n");
1538 // two = full simulation of muon nuclear interactions and production of secondary hadrons
1539 // zero = ratio of longitudinal to transverse virtual photon cross-section - Default = 0.25.
1540 // zero = fraction of rho-like interactions ( must be < 1) - Default = 0.75.
1541 // matMin = lower bound of the material indices in which the respective thresholds apply
1542 // matMax = upper bound of the material indices in which the respective thresholds apply
1543 fprintf(pAliceInp,"MUPHOTON %10.1f%10.1f%10.1f%10.1f%10.1f\n",two,zero,zero,matMin,matMax);
1545 else if (proc->Flag() == 0) {
1546 fprintf(pAliceInp,"*\n*No muon nuclear interaction - no FLUKA card generated\n");
1547 fprintf(pAliceInp,"*Generated from call: SetProcess('MUNU',0)\n");
1550 fprintf(pAliceInp,"*\n*Illegal flag value in SetProcess('MUNU',?) call.\n");
1551 fprintf(pAliceInp,"*No FLUKA card generated\n");
1553 } // end of else if (strncmp(proc->GetName(),"MUNU",4) == 0)
1557 // G3 default value: 0
1562 // gMC ->SetProcess("PFIS",0); // PHOTONUC -1. 0. 0. 3. lastmat 0.
1563 // flag = 0 no photon fission
1564 // flag = 1 photon fission, secondaries processed
1565 // flag = 2 photon fission, no secondaries stored
1566 else if (strncmp(proc->GetName(),"PFIS",4) == 0) {
1567 if (proc->Flag() == 0) {
1568 fprintf(pAliceInp,"*\n*No photonuclear interactions\n");
1569 fprintf(pAliceInp,"*Generated from call: SetProcess('PFIS',0);\n");
1570 // - one = no photonuclear interactions
1573 // matMin = lower bound of the material indices in which the respective thresholds apply
1574 // matMax = upper bound of the material indices in which the respective thresholds apply
1575 fprintf(pAliceInp,"PHOTONUC %10.1f%10.1f%10.1f%10.1f%10.1f\n",-one,zero,zero,matMin,matMax);
1577 else if (proc->Flag() == 1) {
1578 fprintf(pAliceInp,"*\n*Photon nuclear interactions are activated at all energies\n");
1579 fprintf(pAliceInp,"*Generated from call: SetProcess('PFIS',1);\n");
1580 // one = photonuclear interactions are activated at all energies
1583 // matMin = lower bound of the material indices in which the respective thresholds apply
1584 // matMax = upper bound of the material indices in which the respective thresholds apply
1585 fprintf(pAliceInp,"PHOTONUC %10.1f%10.1f%10.1f%10.1f%10.1f\n",one,zero,zero,matMin,matMax);
1587 else if (proc->Flag() == 0) {
1588 fprintf(pAliceInp,"*\n*No photofission - no FLUKA card generated\n");
1589 fprintf(pAliceInp,"*Generated from call: SetProcess('PFIS',0)\n");
1592 fprintf(pAliceInp,"*\n*Illegal flag value in SetProcess('PFIS',?) call.\n");
1593 fprintf(pAliceInp,"*No FLUKA card generated\n");
1598 // photo electric effect
1599 // G3 default value: 1
1600 // G4 processes: G4PhotoElectricEffect
1601 // G4LowEnergyPhotoElectric
1604 // flag = 0 no photo electric effect
1605 // flag = 1 photo electric effect, electron processed
1606 // flag = 2 photo electric effect, no electron stored
1607 // gMC ->SetProcess("PHOT",1); // EMFCUT 0. -1. 0. 3. lastmat 0. PHOT-THR
1608 else if (strncmp(proc->GetName(),"PHOT",4) == 0) {
1609 if (proc->Flag() == 1 || proc->Flag() == 2) {
1610 fprintf(pAliceInp,"*\n*Photo electric effect is activated\n");
1611 fprintf(pAliceInp,"*Generated from call: SetProcess('PHOT',1);\n");
1613 // - one = resets to default=0.
1615 // matMin = lower bound of the material indices in which the respective thresholds apply
1616 // matMax = upper bound of the material indices in which the respective thresholds apply
1617 // one = step length in assigning indices
1619 fprintf(pAliceInp,"EMFCUT %10.1f%10.1f%10.1f%10.1f%10.1f%10.1fPHOT-THR\n",zero,-one,zero,matMin,matMax,one);
1621 else if (proc->Flag() == 0) {
1622 fprintf(pAliceInp,"*\n*No photo electric effect - no FLUKA card generated\n");
1623 fprintf(pAliceInp,"*Generated from call: SetProcess('PHOT',0)\n");
1626 fprintf(pAliceInp,"*\n*Illegal flag value in SetProcess('PHOT',?) call.\n");
1627 fprintf(pAliceInp,"*No FLUKA card generated\n");
1629 } // else if (strncmp(proc->GetName(),"PHOT",4) == 0)
1632 // Rayleigh scattering
1633 // G3 default value: 0
1634 // G4 process: G4OpRayleigh
1636 // Particles: optical photon
1638 // flag = 0 Rayleigh scattering off
1639 // flag = 1 Rayleigh scattering on
1640 //xx gMC ->SetProcess("RAYL",1);
1641 else if (strncmp(proc->GetName(),"RAYL",4) == 0) {
1642 if (proc->Flag() == 1) {
1643 fprintf(pAliceInp,"*\n*Rayleigh scattering is ON by default in FLUKA\n");
1644 fprintf(pAliceInp,"*No FLUKA card generated\n");
1646 else if (proc->Flag() == 0) {
1647 fprintf(pAliceInp,"*\n*Rayleigh scattering is set OFF\n");
1648 fprintf(pAliceInp,"*Generated from call: SetProcess('RAYL',0);\n");
1649 // - one = no Rayleigh scattering and no binding corrections for Compton
1650 // matMin = lower bound of the material indices in which the respective thresholds apply
1651 // matMax = upper bound of the material indices in which the respective thresholds apply
1652 fprintf(pAliceInp,"EMFRAY %10.1f%10.1f%10.1f%10.1f\n",-one,three,matMin,matMax);
1655 fprintf(pAliceInp,"*\n*Illegal flag value in SetProcess('RAYL',?) call.\n");
1656 fprintf(pAliceInp,"*No FLUKA card generated\n");
1658 } // end of else if (strncmp(proc->GetName(),"RAYL",4) == 0)
1661 // synchrotron radiation in magnetic field
1662 // G3 default value: 0
1663 // G4 process: G4SynchrotronRadiation
1667 // flag = 0 no synchrotron radiation
1668 // flag = 1 synchrotron radiation
1669 //xx gMC ->SetProcess("SYNC",1); // synchrotron radiation generation
1670 else if (strncmp(proc->GetName(),"SYNC",4) == 0) {
1671 fprintf(pAliceInp,"*\n*Synchrotron radiation generation is NOT implemented in FLUKA\n");
1672 fprintf(pAliceInp,"*No FLUKA card generated\n");
1676 // Automatic calculation of tracking medium parameters
1677 // flag = 0 no automatic calculation
1678 // flag = 1 automatic calculation
1679 //xx gMC ->SetProcess("AUTO",1); // ??? automatic computation of the tracking medium parameters
1680 else if (strncmp(proc->GetName(),"AUTO",4) == 0) {
1681 fprintf(pAliceInp,"*\n*Automatic calculation of tracking medium parameters is always ON in FLUKA\n");
1682 fprintf(pAliceInp,"*No FLUKA card generated\n");
1686 // To control energy loss fluctuation model
1687 // flag = 0 Urban model
1688 // flag = 1 PAI model
1689 // flag = 2 PAI+ASHO model (not active at the moment)
1690 //xx gMC ->SetProcess("STRA",1); // ??? energy fluctuation model
1691 else if (strncmp(proc->GetName(),"STRA",4) == 0) {
1692 if (proc->Flag() == 0 || proc->Flag() == 2 || proc->Flag() == 3) {
1693 fprintf(pAliceInp,"*\n*Ionization energy losses calculation is activated\n");
1694 fprintf(pAliceInp,"*Generated from call: SetProcess('STRA',n);, n=0,1,2\n");
1695 // one = restricted energy loss fluctuations (for hadrons and muons) switched on
1696 // one = restricted energy loss fluctuations (for e+ and e-) switched on
1697 // one = minimal accuracy
1698 // matMin = lower bound of the material indices in which the respective thresholds apply
1699 // matMax = upper bound of the material indices in which the respective thresholds apply
1700 fprintf(pAliceInp,"IONFLUCT %10.1f%10.1f%10.1f%10.1f%10.1f\n",one,one,one,matMin,matMax);
1703 fprintf(pAliceInp,"*\n*Illegal flag value in SetProcess('STRA',?) call.\n");
1704 fprintf(pAliceInp,"*No FLUKA card generated\n");
1706 } // else if (strncmp(proc->GetName(),"STRA",4) == 0)
1711 else { // processes not yet treated
1713 // light photon absorption (Cerenkov photons)
1714 // it is turned on when Cerenkov process is turned on
1715 // G3 default value: 0
1716 // G4 process: G4OpAbsorption, G4OpBoundaryProcess
1718 // Particles: optical photon
1720 // flag = 0 no absorption of Cerenkov photons
1721 // flag = 1 absorption of Cerenkov photons
1722 // gMC ->SetProcess("LABS",2); // ??? Cerenkov light absorption
1726 cout << "SetProcess for flag=" << proc->GetName() << " value=" << proc->Flag() << " not yet implemented!" << endl;
1728 } //end of loop number of SetProcess calls
1731 // Loop over number of SetCut calls
1734 while ((cut = (TFlukaConfigOption*)nextc())) {
1735 Float_t matMin = three;
1736 Float_t matMax = fLastMaterial;
1737 Bool_t global = kTRUE;
1738 if (cut->Medium() != -1) {
1739 matMin = Float_t(cut->Medium());
1744 // cuts handled in SetProcess calls
1745 if (strncmp(cut->GetName(),"BCUTM",5) == 0) continue;
1746 else if (strncmp(cut->GetName(),"BCUTE",5) == 0) continue;
1747 else if (strncmp(cut->GetName(),"DCUTM",5) == 0) continue;
1748 else if (strncmp(cut->GetName(),"PPCUTM",6) == 0) continue;
1750 // delta-rays by electrons
1751 // G4 particles: "e-"
1752 // G3 default value: 10**4 GeV
1753 // gMC ->SetCut("DCUTE",cut); // cut for deltarays by electrons
1754 else if (strncmp(cut->GetName(),"DCUTE",5) == 0) {
1755 fprintf(pAliceInp,"*\n*Cut for delta rays by electrons\n");
1756 fprintf(pAliceInp,"*Generated from call: SetCut('DCUTE',cut);\n");
1760 // matMin = lower bound of the material indices in which the respective thresholds apply
1761 // matMax = upper bound of the material indices in which the respective thresholds apply
1762 // loop over materials for EMFCUT FLUKA cards
1763 for (j=0; j < matMax-matMin+1; j++) {
1764 Int_t nreg, imat, *reglist;
1766 imat = (Int_t) matMin + j;
1767 reglist = fGeom->GetMaterialList(imat, nreg);
1768 // loop over regions of a given material
1769 for (k=0; k<nreg; k++) {
1771 fprintf(pAliceInp,"EMFCUT %10.4g%10.1f%10.1f%10.1f%10.1f\n",-cut->Cut(),zero,zero,ireg,ireg);
1774 fprintf(pAliceInp,"DELTARAY %10.4g%10.3f%10.3f%10.1f%10.1f%10.1f\n",cut->Cut(), 100., 1.03, matMin, matMax, 1.0);
1775 } // end of if for delta-rays by electrons
1779 // G4 particles: "gamma"
1780 // G3 default value: 0.001 GeV
1781 // gMC ->SetCut("CUTGAM",cut); // cut for gammas
1783 else if (strncmp(cut->GetName(),"CUTGAM",6) == 0 && global) {
1784 fprintf(pAliceInp,"*\n*Cut for gamma\n");
1785 fprintf(pAliceInp,"*Generated from call: SetCut('CUTGAM',cut);\n");
1787 // 7.0 = lower bound of the particle id-numbers to which the cut-off
1788 fprintf(pAliceInp,"PART-THR %10.4g%10.1f\n",-cut->Cut(),7.0);
1790 else if (strncmp(cut->GetName(),"CUTGAM",6) == 0 && !global) {
1791 fprintf(pAliceInp,"*\n*Cut specific to material for gamma\n");
1792 fprintf(pAliceInp,"*Generated from call: SetCut('CUTGAM',cut);\n");
1794 // loop over materials for EMFCUT FLUKA cards
1795 for (j=0; j < matMax-matMin+1; j++) {
1796 Int_t nreg, imat, *reglist;
1798 imat = (Int_t) matMin + j;
1799 reglist = fGeom->GetMaterialList(imat, nreg);
1800 // loop over regions of a given material
1801 for (Int_t k=0; k<nreg; k++) {
1803 fprintf(pAliceInp,"EMFCUT %10.4g%10.4g%10.1f%10.1f%10.1f%10.1f\n", zero, cut->Cut(), zero, ireg, ireg, one);
1806 } // end of else if for gamma
1810 // G4 particles: "e-"
1812 // G3 default value: 0.001 GeV
1813 //gMC ->SetCut("CUTELE",cut); // cut for e+,e-
1814 else if (strncmp(cut->GetName(),"CUTELE",6) == 0 && global) {
1815 fprintf(pAliceInp,"*\n*Cut for electrons\n");
1816 fprintf(pAliceInp,"*Generated from call: SetCut('CUTELE',cut);\n");
1818 // three = lower bound of the particle id-numbers to which the cut-off
1819 // 4.0 = upper bound of the particle id-numbers to which the cut-off
1820 // one = step length in assigning numbers
1821 fprintf(pAliceInp,"PART-THR %10.4g%10.1f%10.1f%10.1f\n",-cut->Cut(),three,4.0,one);
1823 else if (strncmp(cut->GetName(),"CUTELE",6) == 0 && !global) {
1824 fprintf(pAliceInp,"*\n*Cut specific to material for electrons\n");
1825 fprintf(pAliceInp,"*Generated from call: SetCut('CUTELE',cut);\n");
1827 // loop over materials for EMFCUT FLUKA cards
1828 for (j=0; j < matMax-matMin+1; j++) {
1829 Int_t nreg, imat, *reglist;
1831 imat = (Int_t) matMin + j;
1832 reglist = fGeom->GetMaterialList(imat, nreg);
1833 // loop over regions of a given material
1834 for (k=0; k<nreg; k++) {
1836 fprintf(pAliceInp,"EMFCUT %10.4g%10.4g%10.1f%10.1f%10.1f%10.1f\n", -cut->Cut(), zero, zero, ireg, ireg, one);
1839 } // end of else if for electrons
1843 // G4 particles: of type "baryon", "meson", "nucleus" with zero charge
1844 // G3 default value: 0.01 GeV
1845 //gMC ->SetCut("CUTNEU",cut); // cut for neutral hadrons
1846 else if (strncmp(cut->GetName(),"CUTNEU",6) == 0 && global) {
1847 fprintf(pAliceInp,"*\n*Cut for neutral hadrons\n");
1848 fprintf(pAliceInp,"*Generated from call: SetCut('CUTNEU',cut);\n");
1851 // 9.0 = Antineutron
1852 fprintf(pAliceInp,"PART-THR %10.4g%10.1f%10.1f\n",-cut->Cut(),8.0,9.0);
1854 // 12.0 = Kaon zero long
1855 // 12.0 = Kaon zero long
1856 fprintf(pAliceInp,"PART-THR %10.4g%10.1f%10.1f\n",-cut->Cut(),12.0,12.0);
1858 // 17.0 = Lambda, 18.0 = Antilambda
1859 // 19.0 = Kaon zero short
1860 fprintf(pAliceInp,"PART-THR %10.4g%10.1f%10.1f\n",-cut->Cut(),17.0,19.0);
1862 // 22.0 = Sigma zero, Pion zero, Kaon zero
1863 // 25.0 = Antikaon zero
1864 fprintf(pAliceInp,"PART-THR %10.4g%10.1f%10.1f\n",-cut->Cut(),22.0,25.0);
1866 // 32.0 = Antisigma zero
1867 // 32.0 = Antisigma zero
1868 fprintf(pAliceInp,"PART-THR %10.4g%10.1f%10.1f\n",-cut->Cut(),32.0,32.0);
1871 // 35.0 = AntiXi zero
1872 fprintf(pAliceInp,"PART-THR %10.4g%10.1f%10.1f\n",-cut->Cut(),34.0,35.0);
1875 // 48.0 = AntiD zero
1876 fprintf(pAliceInp,"PART-THR %10.4g%10.1f%10.1f\n",-cut->Cut(),47.0,48.0);
1880 fprintf(pAliceInp,"PART-THR %10.4g%10.1f%10.1f\n",-cut->Cut(),53.0,53.0);
1882 // 55.0 = Xi'_c zero
1883 // 56.0 = Omega_c zero
1884 fprintf(pAliceInp,"PART-THR %10.4g%10.1f%10.1f\n",-cut->Cut(),55.0,56.0);
1886 // 59.0 = AntiXi_c zero
1887 // 59.0 = AntiXi_c zero
1888 fprintf(pAliceInp,"PART-THR %10.4g%10.1f%10.1f\n",-cut->Cut(),59.0,59.0);
1890 // 61.0 = AntiXi'_c zero
1891 // 62.0 = AntiOmega_c zero
1892 fprintf(pAliceInp,"PART-THR %10.4g%10.1f%10.1f\n",-cut->Cut(),61.0,62.0);
1896 // G4 particles: of type "baryon", "meson", "nucleus" with non-zero charge
1897 // G3 default value: 0.01 GeV
1898 //gMC ->SetCut("CUTHAD",cut); // cut for charged hadrons
1899 else if (strncmp(cut->GetName(),"CUTHAD",6) == 0 && global) {
1900 fprintf(pAliceInp,"*\n*Cut for charged hadrons\n");
1901 fprintf(pAliceInp,"*Generated from call: SetCut('CUTHAD',cut);\n");
1905 fprintf(pAliceInp,"PART-THR %10.4g%10.1f%10.1f\n",-cut->Cut(),1.0,2.0);
1907 // 13.0 = Positive Pion, Negative Pion, Positive Kaon
1908 // 16.0 = Negative Kaon
1909 fprintf(pAliceInp,"PART-THR %10.4g%10.1f%10.1f\n",-cut->Cut(),13.0,16.0);
1911 // 20.0 = Negative Sigma
1912 // 21.0 = Positive Sigma
1913 fprintf(pAliceInp,"PART-THR %10.4g%10.1f%10.1f\n",-cut->Cut(),20.0,21.0);
1915 // 31.0 = Antisigma minus
1916 // 33.0 = Antisigma plus
1917 // 2.0 = step length
1918 fprintf(pAliceInp,"PART-THR %10.4g%10.1f%10.1f%10.1f\n",-cut->Cut(),31.0,33.0,2.0);
1920 // 36.0 = Negative Xi, Positive Xi, Omega minus
1922 fprintf(pAliceInp,"PART-THR %10.4g%10.1f%10.1f\n",-cut->Cut(),36.0,39.0);
1926 fprintf(pAliceInp,"PART-THR %10.4g%10.1f%10.1f\n",-cut->Cut(),45.0,46.0);
1928 // 49.0 = D_s plus, D_s minus, Lambda_c plus
1930 fprintf(pAliceInp,"PART-THR %10.4g%10.1f%10.1f\n",-cut->Cut(),49.0,52.0);
1932 // 54.0 = Xi'_c plus
1933 // 60.0 = AntiXi'_c minus
1934 // 6.0 = step length
1935 fprintf(pAliceInp,"PART-THR %10.4g%10.1f%10.1f%10.1f\n",-cut->Cut(),54.0,60.0,6.0);
1937 // 57.0 = Antilambda_c minus
1938 // 58.0 = AntiXi_c minus
1939 fprintf(pAliceInp,"PART-THR %10.4g%10.1f%10.1f\n",-cut->Cut(),57.0,58.0);
1943 // G4 particles: "mu+", "mu-"
1944 // G3 default value: 0.01 GeV
1945 //gMC ->SetCut("CUTMUO",cut); // cut for mu+, mu-
1946 else if (strncmp(cut->GetName(),"CUTMUO",6)== 0 && global) {
1947 fprintf(pAliceInp,"*\n*Cut for muons\n");
1948 fprintf(pAliceInp,"*Generated from call: SetCut('CUTMUO',cut);\n");
1951 fprintf(pAliceInp,"PART-THR %10.4g%10.1f%10.1f\n",-cut->Cut(),10.0,11.0);
1955 // time of flight cut in seconds
1956 // G4 particles: all
1957 // G3 default value: 0.01 GeV
1958 //gMC ->SetCut("TOFMAX",tofmax); // time of flight cuts in seconds
1959 else if (strncmp(cut->GetName(),"TOFMAX",6) == 0) {
1960 fprintf(pAliceInp,"*\n*Time of flight cuts in seconds\n");
1961 fprintf(pAliceInp,"*Generated from call: SetCut('TOFMAX',tofmax);\n");
1964 // -6.0 = lower bound of the particle numbers for which the transport time cut-off and/or the start signal is to be applied
1965 // 64.0 = upper bound of the particle numbers for which the transport time cut-off and/or the start signal is to be applied
1966 fprintf(pAliceInp,"TIME-CUT %10.4g%10.1f%10.1f%10.1f%10.1f\n",cut->Cut()*1.e9,zero,zero,-6.0,64.0);
1970 cout << "SetCut for flag=" << cut->GetName() << " value=" << cut->Cut() << " not yet implemented!" << endl;
1973 cout << "SetCut for flag=" << cut->GetName() << " value=" << cut->Cut() << " (material specific) not yet implemented!" << endl;
1976 } //end of loop over SetCut calls
1978 // Add START and STOP card
1979 fprintf(pAliceInp,"START %10.1f\n",fEventsPerRun);
1980 fprintf(pAliceInp,"STOP \n");
1985 fclose(pAliceCoreInp);
1986 fclose(pAliceFlukaMat);
1989 } // end of InitPhysics
1992 //______________________________________________________________________________
1993 void TFluka::SetMaxStep(Double_t)
1995 // SetMaxStep is dummy procedure in TFluka !
1996 if (fVerbosityLevel >=3)
1997 cout << "SetMaxStep is dummy procedure in TFluka !" << endl;
2000 //______________________________________________________________________________
2001 void TFluka::SetMaxNStep(Int_t)
2003 // SetMaxNStep is dummy procedure in TFluka !
2004 if (fVerbosityLevel >=3)
2005 cout << "SetMaxNStep is dummy procedure in TFluka !" << endl;
2008 //______________________________________________________________________________
2009 void TFluka::SetUserDecay(Int_t)
2011 // SetUserDecay is dummy procedure in TFluka !
2012 if (fVerbosityLevel >=3)
2013 cout << "SetUserDecay is dummy procedure in TFluka !" << endl;
2017 // dynamic properties
2019 //______________________________________________________________________________
2020 void TFluka::TrackPosition(TLorentzVector& position) const
2022 // Return the current position in the master reference frame of the
2023 // track being transported
2024 // TRACKR.atrack = age of the particle
2025 // TRACKR.xtrack = x-position of the last point
2026 // TRACKR.ytrack = y-position of the last point
2027 // TRACKR.ztrack = z-position of the last point
2028 Int_t caller = GetCaller();
2029 if (caller == 3 || caller == 6 || caller == 11 || caller == 12) { //bxdraw,endraw,usdraw
2030 position.SetX(GetXsco());
2031 position.SetY(GetYsco());
2032 position.SetZ(GetZsco());
2033 position.SetT(TRACKR.atrack);
2035 else if (caller == 4) { // mgdraw
2036 position.SetX(TRACKR.xtrack[TRACKR.ntrack]);
2037 position.SetY(TRACKR.ytrack[TRACKR.ntrack]);
2038 position.SetZ(TRACKR.ztrack[TRACKR.ntrack]);
2039 position.SetT(TRACKR.atrack);
2041 else if (caller == 5) { // sodraw
2042 position.SetX(TRACKR.xtrack[TRACKR.ntrack]);
2043 position.SetY(TRACKR.ytrack[TRACKR.ntrack]);
2044 position.SetZ(TRACKR.ztrack[TRACKR.ntrack]);
2048 Warning("TrackPosition","position not available");
2051 //______________________________________________________________________________
2052 void TFluka::TrackPosition(Double_t& x, Double_t& y, Double_t& z) const
2054 // Return the current position in the master reference frame of the
2055 // track being transported
2056 // TRACKR.atrack = age of the particle
2057 // TRACKR.xtrack = x-position of the last point
2058 // TRACKR.ytrack = y-position of the last point
2059 // TRACKR.ztrack = z-position of the last point
2060 Int_t caller = GetCaller();
2061 if (caller == 3 || caller == 6 || caller == 11 || caller == 12) { //bxdraw,endraw,usdraw
2066 else if (caller == 4 || caller == 5) { // mgdraw, sodraw
2067 x = TRACKR.xtrack[TRACKR.ntrack];
2068 y = TRACKR.ytrack[TRACKR.ntrack];
2069 z = TRACKR.ztrack[TRACKR.ntrack];
2072 Warning("TrackPosition","position not available");
2075 //______________________________________________________________________________
2076 void TFluka::TrackMomentum(TLorentzVector& momentum) const
2078 // Return the direction and the momentum (GeV/c) of the track
2079 // currently being transported
2080 // TRACKR.ptrack = momentum of the particle (not always defined, if
2081 // < 0 must be obtained from etrack)
2082 // TRACKR.cx,y,ztrck = direction cosines of the current particle
2083 // TRACKR.etrack = total energy of the particle
2084 // TRACKR.jtrack = identity number of the particle
2085 // PAPROP.am[TRACKR.jtrack] = particle mass in gev
2086 Int_t caller = GetCaller();
2087 if (caller != 2) { // not eedraw
2088 if (TRACKR.ptrack >= 0) {
2089 momentum.SetPx(TRACKR.ptrack*TRACKR.cxtrck);
2090 momentum.SetPy(TRACKR.ptrack*TRACKR.cytrck);
2091 momentum.SetPz(TRACKR.ptrack*TRACKR.cztrck);
2092 momentum.SetE(TRACKR.etrack);
2096 Double_t p = sqrt(TRACKR.etrack*TRACKR.etrack - PAPROP.am[TRACKR.jtrack+6]*PAPROP.am[TRACKR.jtrack+6]);
2097 momentum.SetPx(p*TRACKR.cxtrck);
2098 momentum.SetPy(p*TRACKR.cytrck);
2099 momentum.SetPz(p*TRACKR.cztrck);
2100 momentum.SetE(TRACKR.etrack);
2105 Warning("TrackMomentum","momentum not available");
2108 //______________________________________________________________________________
2109 void TFluka::TrackMomentum(Double_t& px, Double_t& py, Double_t& pz, Double_t& e) const
2111 // Return the direction and the momentum (GeV/c) of the track
2112 // currently being transported
2113 // TRACKR.ptrack = momentum of the particle (not always defined, if
2114 // < 0 must be obtained from etrack)
2115 // TRACKR.cx,y,ztrck = direction cosines of the current particle
2116 // TRACKR.etrack = total energy of the particle
2117 // TRACKR.jtrack = identity number of the particle
2118 // PAPROP.am[TRACKR.jtrack] = particle mass in gev
2119 Int_t caller = GetCaller();
2120 if (caller != 2) { // not eedraw
2121 if (TRACKR.ptrack >= 0) {
2122 px = TRACKR.ptrack*TRACKR.cxtrck;
2123 py = TRACKR.ptrack*TRACKR.cytrck;
2124 pz = TRACKR.ptrack*TRACKR.cztrck;
2129 Double_t p = sqrt(TRACKR.etrack*TRACKR.etrack - PAPROP.am[TRACKR.jtrack+6]*PAPROP.am[TRACKR.jtrack+6]);
2130 px = p*TRACKR.cxtrck;
2131 py = p*TRACKR.cytrck;
2132 pz = p*TRACKR.cztrck;
2138 Warning("TrackMomentum","momentum not available");
2141 //______________________________________________________________________________
2142 Double_t TFluka::TrackStep() const
2144 // Return the length in centimeters of the current step
2145 // TRACKR.ctrack = total curved path
2146 Int_t caller = GetCaller();
2147 if (caller == 11 || caller==12 || caller == 3 || caller == 6) //bxdraw,endraw,usdraw
2149 else if (caller == 4) //mgdraw
2150 return TRACKR.ctrack;
2155 //______________________________________________________________________________
2156 Double_t TFluka::TrackLength() const
2158 // TRACKR.cmtrck = cumulative curved path since particle birth
2159 Int_t caller = GetCaller();
2160 if (caller == 11 || caller==12 || caller == 3 || caller == 4 || caller == 6) //bxdraw,endraw,mgdraw,usdraw
2161 return TRACKR.cmtrck;
2166 //______________________________________________________________________________
2167 Double_t TFluka::TrackTime() const
2169 // Return the current time of flight of the track being transported
2170 // TRACKR.atrack = age of the particle
2171 Int_t caller = GetCaller();
2172 if (caller == 11 || caller==12 || caller == 3 || caller == 4 || caller == 6) //bxdraw,endraw,mgdraw,usdraw
2173 return TRACKR.atrack;
2178 //______________________________________________________________________________
2179 Double_t TFluka::Edep() const
2181 // Energy deposition
2182 // if TRACKR.ntrack = 0, TRACKR.mtrack = 0:
2183 // -->local energy deposition (the value and the point are not recorded in TRACKR)
2184 // but in the variable "rull" of the procedure "endraw.cxx"
2185 // if TRACKR.ntrack > 0, TRACKR.mtrack = 0:
2186 // -->no energy loss along the track
2187 // if TRACKR.ntrack > 0, TRACKR.mtrack > 0:
2188 // -->energy loss distributed along the track
2189 // TRACKR.dtrack = energy deposition of the jth deposition even
2191 // If coming from bxdraw we have 2 steps of 0 length and 0 edep
2192 Int_t caller = GetCaller();
2193 if (caller == 11 || caller==12) return 0.0;
2195 for ( Int_t j=0;j<TRACKR.mtrack;j++) {
2196 sum +=TRACKR.dtrack[j];
2198 if (TRACKR.ntrack == 0 && TRACKR.mtrack == 0)
2205 //______________________________________________________________________________
2206 Int_t TFluka::TrackPid() const
2208 // Return the id of the particle transported
2209 // TRACKR.jtrack = identity number of the particle
2210 Int_t caller = GetCaller();
2211 if (caller != 2) { // not eedraw
2212 return PDGFromId(TRACKR.jtrack);
2218 //______________________________________________________________________________
2219 Double_t TFluka::TrackCharge() const
2221 // Return charge of the track currently transported
2222 // PAPROP.ichrge = electric charge of the particle
2223 // TRACKR.jtrack = identity number of the particle
2224 Int_t caller = GetCaller();
2225 if (caller != 2) // not eedraw
2226 return PAPROP.ichrge[TRACKR.jtrack+6];
2231 //______________________________________________________________________________
2232 Double_t TFluka::TrackMass() const
2234 // PAPROP.am = particle mass in GeV
2235 // TRACKR.jtrack = identity number of the particle
2236 Int_t caller = GetCaller();
2237 if (caller != 2) // not eedraw
2238 return PAPROP.am[TRACKR.jtrack+6];
2243 //______________________________________________________________________________
2244 Double_t TFluka::Etot() const
2246 // TRACKR.etrack = total energy of the particle
2247 Int_t caller = GetCaller();
2248 if (caller != 2) // not eedraw
2249 return TRACKR.etrack;
2257 //______________________________________________________________________________
2258 Bool_t TFluka::IsNewTrack() const
2260 // Return true for the first call of Stepping()
2264 void TFluka::SetTrackIsNew(Bool_t flag)
2266 // Return true for the first call of Stepping()
2272 //______________________________________________________________________________
2273 Bool_t TFluka::IsTrackInside() const
2275 // True if the track is not at the boundary of the current volume
2276 // In Fluka a step is always inside one kind of material
2277 // If the step would go behind the region of one material,
2278 // it will be shortened to reach only the boundary.
2279 // Therefore IsTrackInside() is always true.
2280 Int_t caller = GetCaller();
2281 if (caller == 11 || caller==12) // bxdraw
2287 //______________________________________________________________________________
2288 Bool_t TFluka::IsTrackEntering() const
2290 // True if this is the first step of the track in the current volume
2292 Int_t caller = GetCaller();
2293 if (caller == 11) // bxdraw entering
2298 //______________________________________________________________________________
2299 Bool_t TFluka::IsTrackExiting() const
2301 // True if track is exiting volume
2303 Int_t caller = GetCaller();
2304 if (caller == 12) // bxdraw exiting
2309 //______________________________________________________________________________
2310 Bool_t TFluka::IsTrackOut() const
2312 // True if the track is out of the setup
2314 // Icode = 14: escape - call from Kaskad
2315 // Icode = 23: escape - call from Emfsco
2316 // Icode = 32: escape - call from Kasneu
2317 // Icode = 40: escape - call from Kashea
2318 // Icode = 51: escape - call from Kasoph
2323 fIcode == 51) return 1;
2327 //______________________________________________________________________________
2328 Bool_t TFluka::IsTrackDisappeared() const
2330 // means all inelastic interactions and decays
2331 // fIcode from usdraw
2332 if (fIcode == 101 || // inelastic interaction
2333 fIcode == 102 || // particle decay
2334 fIcode == 103 || // delta ray generation by hadron
2335 fIcode == 104 || // direct pair production
2336 fIcode == 105 || // bremsstrahlung (muon)
2337 fIcode == 208 || // bremsstrahlung (electron)
2338 fIcode == 214 || // in-flight annihilation
2339 fIcode == 215 || // annihilation at rest
2340 fIcode == 217 || // pair production
2341 fIcode == 219 || // Compton scattering
2342 fIcode == 221 || // Photoelectric effect
2343 fIcode == 300 || // hadronic interaction
2344 fIcode == 400 // delta-ray
2349 //______________________________________________________________________________
2350 Bool_t TFluka::IsTrackStop() const
2352 // True if the track energy has fallen below the threshold
2353 // means stopped by signal or below energy threshold
2354 // Icode = 12: stopping particle - call from Kaskad
2355 // Icode = 15: time kill - call from Kaskad
2356 // Icode = 21: below threshold, iarg=1 - call from Emfsco
2357 // Icode = 22: below threshold, iarg=2 - call from Emfsco
2358 // Icode = 24: time kill - call from Emfsco
2359 // Icode = 31: below threshold - call from Kasneu
2360 // Icode = 33: time kill - call from Kasneu
2361 // Icode = 41: time kill - call from Kashea
2362 // Icode = 52: time kill - call from Kasoph
2371 fIcode == 52) return 1;
2375 //______________________________________________________________________________
2376 Bool_t TFluka::IsTrackAlive() const
2378 // means not disappeared or not out
2379 if (IsTrackDisappeared() || IsTrackOut() ) return 0;
2387 //______________________________________________________________________________
2388 Int_t TFluka::NSecondaries() const
2391 // Number of secondary particles generated in the current step
2392 // FINUC.np = number of secondaries except light and heavy ions
2393 // FHEAVY.npheav = number of secondaries for light and heavy secondary ions
2394 Int_t caller = GetCaller();
2395 if (caller == 6) // valid only after usdraw
2396 return FINUC.np + FHEAVY.npheav;
2399 } // end of NSecondaries
2401 //______________________________________________________________________________
2402 void TFluka::GetSecondary(Int_t isec, Int_t& particleId,
2403 TLorentzVector& position, TLorentzVector& momentum)
2405 // Copy particles from secondary stack to vmc stack
2408 Int_t caller = GetCaller();
2409 if (caller == 6) { // valid only after usdraw
2410 if (isec >= 0 && isec < FINUC.np) {
2411 particleId = PDGFromId(FINUC.kpart[isec]);
2412 position.SetX(fXsco);
2413 position.SetY(fYsco);
2414 position.SetZ(fZsco);
2415 position.SetT(TRACKR.atrack);
2416 momentum.SetPx(FINUC.plr[isec]*FINUC.cxr[isec]);
2417 momentum.SetPy(FINUC.plr[isec]*FINUC.cyr[isec]);
2418 momentum.SetPz(FINUC.plr[isec]*FINUC.czr[isec]);
2419 momentum.SetE(FINUC.tki[isec] + PAPROP.am[FINUC.kpart[isec]+6]);
2421 else if (isec >= FINUC.np && isec < FINUC.np + FHEAVY.npheav) {
2422 Int_t jsec = isec - FINUC.np;
2423 particleId = FHEAVY.kheavy[jsec]; // this is Fluka id !!!
2424 position.SetX(fXsco);
2425 position.SetY(fYsco);
2426 position.SetZ(fZsco);
2427 position.SetT(TRACKR.atrack);
2428 momentum.SetPx(FHEAVY.pheavy[jsec]*FHEAVY.cxheav[jsec]);
2429 momentum.SetPy(FHEAVY.pheavy[jsec]*FHEAVY.cyheav[jsec]);
2430 momentum.SetPz(FHEAVY.pheavy[jsec]*FHEAVY.czheav[jsec]);
2431 if (FHEAVY.tkheav[jsec] >= 3 && FHEAVY.tkheav[jsec] <= 6)
2432 momentum.SetE(FHEAVY.tkheav[jsec] + PAPROP.am[jsec+6]);
2433 else if (FHEAVY.tkheav[jsec] > 6)
2434 momentum.SetE(FHEAVY.tkheav[jsec] + FHEAVY.amnhea[jsec]); // to be checked !!!
2437 Warning("GetSecondary","isec out of range");
2440 Warning("GetSecondary","no secondaries available");
2441 } // end of GetSecondary
2443 //______________________________________________________________________________
2444 TMCProcess TFluka::ProdProcess(Int_t) const
2447 // Name of the process that has produced the secondary particles
2448 // in the current step
2450 Int_t mugamma = (TRACKR.jtrack == 7 || TRACKR.jtrack == 10 || TRACKR.jtrack == 11);
2452 if (fIcode == 102) return kPDecay;
2453 else if (fIcode == 104 || fIcode == 217) return kPPair;
2454 else if (fIcode == 219) return kPCompton;
2455 else if (fIcode == 221) return kPPhotoelectric;
2456 else if (fIcode == 105 || fIcode == 208) return kPBrem;
2457 else if (fIcode == 103 || fIcode == 400) return kPDeltaRay;
2458 else if (fIcode == 210 || fIcode == 212) return kPDeltaRay;
2459 else if (fIcode == 214 || fIcode == 215) return kPAnnihilation;
2460 else if (fIcode == 101) return kPHadronic;
2461 else if (fIcode == 101) {
2462 if (!mugamma) return kPHadronic;
2463 else if (TRACKR.jtrack == 7) return kPPhotoFission;
2464 else return kPMuonNuclear;
2466 else if (fIcode == 225) return kPRayleigh;
2467 // Fluka codes 100, 300 and 400 still to be investigasted
2468 else return kPNoProcess;
2472 //______________________________________________________________________________
2473 Int_t TFluka::VolId2Mate(Int_t id) const
2476 // Returns the material number for a given volume ID
2478 return fMCGeo->VolId2Mate(id);
2481 //______________________________________________________________________________
2482 const char* TFluka::VolName(Int_t id) const
2485 // Returns the volume name for a given volume ID
2487 return fMCGeo->VolName(id);
2490 //______________________________________________________________________________
2491 Int_t TFluka::VolId(const Text_t* volName) const
2494 // Converts from volume name to volume ID.
2495 // Time consuming. (Only used during set-up)
2496 // Could be replaced by hash-table
2498 return fMCGeo->VolId(volName);
2501 //______________________________________________________________________________
2502 Int_t TFluka::CurrentVolID(Int_t& copyNo) const
2505 // Return the logical id and copy number corresponding to the current fluka region
2507 if (gGeoManager->IsOutside()) return 0;
2508 TGeoNode *node = gGeoManager->GetCurrentNode();
2509 copyNo = node->GetNumber();
2510 Int_t id = node->GetVolume()->GetNumber();
2514 //______________________________________________________________________________
2515 Int_t TFluka::CurrentVolOffID(Int_t off, Int_t& copyNo) const
2518 // Return the logical id and copy number of off'th mother
2519 // corresponding to the current fluka region
2521 if (off<0 || off>gGeoManager->GetLevel()) return 0;
2522 if (off==0) return CurrentVolID(copyNo);
2523 TGeoNode *node = gGeoManager->GetMother(off);
2524 if (!node) return 0;
2525 copyNo = node->GetNumber();
2526 return node->GetVolume()->GetNumber();
2529 //______________________________________________________________________________
2530 const char* TFluka::CurrentVolName() const
2533 // Return the current volume name
2535 if (gGeoManager->IsOutside()) return 0;
2536 return gGeoManager->GetCurrentVolume()->GetName();
2539 //______________________________________________________________________________
2540 const char* TFluka::CurrentVolOffName(Int_t off) const
2543 // Return the volume name of the off'th mother of the current volume
2545 if (off<0 || off>gGeoManager->GetLevel()) return 0;
2546 if (off==0) return CurrentVolName();
2547 TGeoNode *node = gGeoManager->GetMother(off);
2548 if (!node) return 0;
2549 return node->GetVolume()->GetName();
2552 //______________________________________________________________________________
2553 Int_t TFluka::CurrentMaterial(Float_t & /*a*/, Float_t & /*z*/,
2554 Float_t & /*dens*/, Float_t & /*radl*/, Float_t & /*absl*/) const
2557 // Return the current medium number ??? what about material properties
2560 Int_t id = TFluka::CurrentVolID(copy);
2561 Int_t med = TFluka::VolId2Mate(id);
2565 //______________________________________________________________________________
2566 void TFluka::Gmtod(Float_t* xm, Float_t* xd, Int_t iflag)
2568 // Transforms a position from the world reference frame
2569 // to the current volume reference frame.
2571 // Geant3 desription:
2572 // ==================
2573 // Computes coordinates XD (in DRS)
2574 // from known coordinates XM in MRS
2575 // The local reference system can be initialized by
2576 // - the tracking routines and GMTOD used in GUSTEP
2577 // - a call to GMEDIA(XM,NUMED)
2578 // - a call to GLVOLU(NLEVEL,NAMES,NUMBER,IER)
2579 // (inverse routine is GDTOM)
2581 // If IFLAG=1 convert coordinates
2582 // IFLAG=2 convert direction cosinus
2585 Double_t xmL[3], xdL[3];
2587 for (i=0;i<3;i++) xmL[i]=xm[i];
2588 if (iflag == 1) gGeoManager->MasterToLocal(xmL,xdL);
2589 else gGeoManager->MasterToLocalVect(xmL,xdL);
2590 for (i=0;i<3;i++) xd[i] = xdL[i];
2593 //______________________________________________________________________________
2594 void TFluka::Gmtod(Double_t* xm, Double_t* xd, Int_t iflag)
2596 if (iflag == 1) gGeoManager->MasterToLocal(xm,xd);
2597 else gGeoManager->MasterToLocalVect(xm,xd);
2600 //______________________________________________________________________________
2601 void TFluka::Gdtom(Float_t* xd, Float_t* xm, Int_t iflag)
2603 // Transforms a position from the current volume reference frame
2604 // to the world reference frame.
2606 // Geant3 desription:
2607 // ==================
2608 // Computes coordinates XM (Master Reference System
2609 // knowing the coordinates XD (Detector Ref System)
2610 // The local reference system can be initialized by
2611 // - the tracking routines and GDTOM used in GUSTEP
2612 // - a call to GSCMED(NLEVEL,NAMES,NUMBER)
2613 // (inverse routine is GMTOD)
2615 // If IFLAG=1 convert coordinates
2616 // IFLAG=2 convert direction cosinus
2619 Double_t xmL[3], xdL[3];
2621 for (i=0;i<3;i++) xdL[i] = xd[i];
2622 if (iflag == 1) gGeoManager->LocalToMaster(xdL,xmL);
2623 else gGeoManager->LocalToMasterVect(xdL,xmL);
2624 for (i=0;i<3;i++) xm[i]=xmL[i];
2627 //______________________________________________________________________________
2628 void TFluka::Gdtom(Double_t* xd, Double_t* xm, Int_t iflag)
2630 if (iflag == 1) gGeoManager->LocalToMaster(xd,xm);
2631 else gGeoManager->LocalToMasterVect(xd,xm);
2634 //______________________________________________________________________________
2635 TObjArray *TFluka::GetFlukaMaterials()
2637 return fGeom->GetMatList();
2640 //______________________________________________________________________________
2641 void TFluka::SetMreg(Int_t l)
2643 // Set current fluka region
2644 fCurrentFlukaRegion = l;
2649 #define pushcerenkovphoton pushcerenkovphoton_
2653 void pushcerenkovphoton(Double_t & px, Double_t & py, Double_t & pz, Double_t & e,
2654 Double_t & vx, Double_t & vy, Double_t & vz, Double_t & tof,
2655 Double_t & polx, Double_t & poly, Double_t & polz, Double_t & wgt, Int_t& ntr)
2658 // Pushes one cerenkov photon to the stack
2661 TFluka* fluka = (TFluka*) gMC;
2662 TVirtualMCStack* cppstack = fluka->GetStack();
2663 Int_t parent = TRACKR.ispusr[mkbmx2-1];
2664 cppstack->PushTrack(0, parent, 50000050,
2668 kPCerenkov, ntr, wgt, 0);