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
47 #include "Fstepsz.h" //(STEPSZ) fluka common
48 #include "Fopphst.h" //(OPPHST) fluka common
50 #include "TVirtualMC.h"
51 #include "TMCProcess.h"
52 #include "TGeoManager.h"
53 #include "TGeoMaterial.h"
54 #include "TGeoMedium.h"
55 #include "TFlukaMCGeometry.h"
56 #include "TGeoMCGeometry.h"
57 #include "TFlukaCerenkov.h"
58 #include "TFlukaConfigOption.h"
59 #include "TFlukaScoringOption.h"
60 #include "TLorentzVector.h"
63 // Fluka methods that may be needed.
65 # define flukam flukam_
66 # define fluka_openinp fluka_openinp_
67 # define fluka_closeinp fluka_closeinp_
68 # define mcihad mcihad_
69 # define mpdgha mpdgha_
70 # define newplo newplo_
72 # define flukam FLUKAM
73 # define fluka_openinp FLUKA_OPENINP
74 # define fluka_closeinp FLUKA_CLOSEINP
75 # define mcihad MCIHAD
76 # define mpdgha MPDGHA
77 # define newplo NEWPLO
83 // Prototypes for FLUKA functions
85 void type_of_call flukam(const int&);
86 void type_of_call newplo();
87 void type_of_call fluka_openinp(const int&, DEFCHARA);
88 void type_of_call fluka_closeinp(const int&);
89 int type_of_call mcihad(const int&);
90 int type_of_call mpdgha(const int&);
94 // Class implementation for ROOT
99 //----------------------------------------------------------------------------
100 // TFluka constructors and destructors.
101 //______________________________________________________________________________
111 // Default constructor
113 fGeneratePemf = kFALSE;
115 fCurrentFlukaRegion = -1;
127 //______________________________________________________________________________
128 TFluka::TFluka(const char *title, Int_t verbosity, Bool_t isRootGeometrySupported)
129 :TVirtualMC("TFluka",title, isRootGeometrySupported),
130 fVerbosityLevel(verbosity),
135 fProcesses(new TObjArray(100)),
136 fCuts(new TObjArray(100)),
137 fUserScore(new TObjArray(100))
139 // create geometry interface
140 if (fVerbosityLevel >=3)
141 cout << "<== TFluka::TFluka(" << title << ") constructor called." << endl;
142 SetCoreInputFileName();
144 SetGeneratePemf(kFALSE);
146 fCurrentFlukaRegion = -1;
149 fGeneratePemf = kFALSE;
150 fMCGeo = new TGeoMCGeometry("MCGeo", "TGeo Implementation of VirtualMCGeometry", kTRUE);
151 fGeom = new TFlukaMCGeometry("geom", "FLUKA VMC Geometry");
152 if (verbosity > 2) fGeom->SetDebugMode(kTRUE);
160 //______________________________________________________________________________
163 if (fVerbosityLevel >=3)
164 cout << "<== TFluka::~TFluka() destructor called." << endl;
175 fProcesses->Delete();
183 //______________________________________________________________________________
184 // TFluka control methods
185 //______________________________________________________________________________
186 void TFluka::Init() {
188 // Geometry initialisation
190 if (fVerbosityLevel >=3) cout << "==> TFluka::Init() called." << endl;
192 if (!gGeoManager) new TGeoManager("geom", "FLUKA geometry");
193 fApplication->ConstructGeometry();
194 TGeoVolume *top = (TGeoVolume*)gGeoManager->GetListOfVolumes()->First();
195 gGeoManager->SetTopVolume(top);
196 gGeoManager->CloseGeometry("di");
197 gGeoManager->DefaultColors(); // to be removed
198 fNVolumes = fGeom->NofVolumes();
199 fGeom->CreateFlukaMatFile("flukaMat.inp");
200 if (fVerbosityLevel >=3) {
201 printf("== Number of volumes: %i\n ==", fNVolumes);
202 cout << "\t* InitPhysics() - Prepare input file to be called" << endl;
204 // now we have TGeo geometry created and we have to patch FlukaVmc.inp
205 // with the material mapping file FlukaMat.inp
209 //______________________________________________________________________________
210 void TFluka::FinishGeometry() {
212 // Build-up table with region to medium correspondance
214 if (fVerbosityLevel >=3) {
215 cout << "==> TFluka::FinishGeometry() called." << endl;
216 printf("----FinishGeometry - nothing to do with TGeo\n");
217 cout << "<== TFluka::FinishGeometry() called." << endl;
221 //______________________________________________________________________________
222 void TFluka::BuildPhysics() {
224 // Prepare FLUKA input files and call FLUKA physics initialisation
227 if (fVerbosityLevel >=3)
228 cout << "==> TFluka::BuildPhysics() called." << endl;
229 // Prepare input file with the current physics settings
231 cout << "\t* InitPhysics() - Prepare input file was called" << endl;
233 if (fVerbosityLevel >=2)
234 cout << "\t* Changing lfdrtr = (" << (GLOBAL.lfdrtr?'T':'F')
235 << ") in fluka..." << endl;
236 GLOBAL.lfdrtr = true;
238 if (fVerbosityLevel >=2)
239 cout << "\t* Opening file " << fInputFileName << endl;
240 const char* fname = fInputFileName;
241 fluka_openinp(lunin, PASSCHARA(fname));
243 if (fVerbosityLevel >=2)
244 cout << "\t* Calling flukam..." << endl;
247 if (fVerbosityLevel >=2)
248 cout << "\t* Closing file " << fInputFileName << endl;
249 fluka_closeinp(lunin);
253 if (fVerbosityLevel >=3)
254 cout << "<== TFluka::Init() called." << endl;
257 if (fVerbosityLevel >=3)
258 cout << "<== TFluka::BuildPhysics() called." << endl;
261 //______________________________________________________________________________
262 void TFluka::ProcessEvent() {
267 printf("User Run Abortion: No more events handled !\n");
272 if (fVerbosityLevel >=3)
273 cout << "==> TFluka::ProcessEvent() called." << endl;
274 fApplication->GeneratePrimaries();
275 EPISOR.lsouit = true;
277 if (fVerbosityLevel >=3)
278 cout << "<== TFluka::ProcessEvent() called." << endl;
280 // Increase event number
285 //______________________________________________________________________________
286 Bool_t TFluka::ProcessRun(Int_t nevent) {
291 if (fVerbosityLevel >=3)
292 cout << "==> TFluka::ProcessRun(" << nevent << ") called."
295 if (fVerbosityLevel >=2) {
296 cout << "\t* GLOBAL.fdrtr = " << (GLOBAL.lfdrtr?'T':'F') << endl;
297 cout << "\t* Calling flukam again..." << endl;
300 fApplication->InitGeometry();
301 Int_t todo = TMath::Abs(nevent);
302 for (Int_t ev = 0; ev < todo; ev++) {
303 fApplication->BeginEvent();
305 fApplication->FinishEvent();
308 if (fVerbosityLevel >=3)
309 cout << "<== TFluka::ProcessRun(" << nevent << ") called."
311 // Write fluka specific scoring output
317 //_____________________________________________________________________________
318 // methods for building/management of geometry
320 // functions from GCONS
321 //____________________________________________________________________________
322 void TFluka::Gfmate(Int_t imat, char *name, Float_t &a, Float_t &z,
323 Float_t &dens, Float_t &radl, Float_t &absl,
324 Float_t* /*ubuf*/, Int_t& /*nbuf*/) {
327 TIter next (gGeoManager->GetListOfMaterials());
328 while ((mat = (TGeoMaterial*)next())) {
329 if (mat->GetUniqueID() == (UInt_t)imat) break;
332 Error("Gfmate", "no material with index %i found", imat);
335 sprintf(name, "%s", mat->GetName());
338 dens = mat->GetDensity();
339 radl = mat->GetRadLen();
340 absl = mat->GetIntLen();
343 //______________________________________________________________________________
344 void TFluka::Gfmate(Int_t imat, char *name, Double_t &a, Double_t &z,
345 Double_t &dens, Double_t &radl, Double_t &absl,
346 Double_t* /*ubuf*/, Int_t& /*nbuf*/) {
349 TIter next (gGeoManager->GetListOfMaterials());
350 while ((mat = (TGeoMaterial*)next())) {
351 if (mat->GetUniqueID() == (UInt_t)imat) break;
354 Error("Gfmate", "no material with index %i found", imat);
357 sprintf(name, "%s", mat->GetName());
360 dens = mat->GetDensity();
361 radl = mat->GetRadLen();
362 absl = mat->GetIntLen();
365 // detector composition
366 //______________________________________________________________________________
367 void TFluka::Material(Int_t& kmat, const char* name, Double_t a,
368 Double_t z, Double_t dens, Double_t radl, Double_t absl,
369 Float_t* buf, Int_t nwbuf) {
371 Double_t* dbuf = fGeom->CreateDoubleArray(buf, nwbuf);
372 Material(kmat, name, a, z, dens, radl, absl, dbuf, nwbuf);
376 //______________________________________________________________________________
377 void TFluka::Material(Int_t& kmat, const char* name, Double_t a,
378 Double_t z, Double_t dens, Double_t radl, Double_t absl,
379 Double_t* /*buf*/, Int_t /*nwbuf*/) {
382 kmat = gGeoManager->GetListOfMaterials()->GetSize();
383 if ((z-Int_t(z)) > 1E-3) {
384 mat = fGeom->GetMakeWrongMaterial(z);
386 mat->SetRadLen(radl,absl);
387 mat->SetUniqueID(kmat);
391 gGeoManager->Material(name, a, z, dens, kmat, radl, absl);
394 //______________________________________________________________________________
395 void TFluka::Mixture(Int_t& kmat, const char *name, Float_t *a,
396 Float_t *z, Double_t dens, Int_t nlmat, Float_t *wmat) {
398 Double_t* da = fGeom->CreateDoubleArray(a, TMath::Abs(nlmat));
399 Double_t* dz = fGeom->CreateDoubleArray(z, TMath::Abs(nlmat));
400 Double_t* dwmat = fGeom->CreateDoubleArray(wmat, TMath::Abs(nlmat));
402 Mixture(kmat, name, da, dz, dens, nlmat, dwmat);
403 for (Int_t i=0; i<nlmat; i++) {
404 a[i] = da[i]; z[i] = dz[i]; wmat[i] = dwmat[i];
412 //______________________________________________________________________________
413 void TFluka::Mixture(Int_t& kmat, const char *name, Double_t *a,
414 Double_t *z, Double_t dens, Int_t nlmat, Double_t *wmat) {
416 // Defines mixture OR COMPOUND IMAT as composed by
417 // THE BASIC NLMAT materials defined by arrays A,Z and WMAT
419 // If NLMAT > 0 then wmat contains the proportion by
420 // weights of each basic material in the mixture.
422 // If nlmat < 0 then WMAT contains the number of atoms
423 // of a given kind into the molecule of the COMPOUND
424 // In this case, WMAT in output is changed to relative
431 for (i=0;i<nlmat;i++) {
432 amol += a[i]*wmat[i];
434 for (i=0;i<nlmat;i++) {
435 wmat[i] *= a[i]/amol;
438 kmat = gGeoManager->GetListOfMaterials()->GetSize();
439 // Check if we have elements with fractional Z
440 TGeoMaterial *mat = 0;
441 TGeoMixture *mix = 0;
442 Bool_t mixnew = kFALSE;
443 for (i=0; i<nlmat; i++) {
444 if (z[i]-Int_t(z[i]) < 1E-3) continue;
445 // We have found an element with fractional Z -> loop mixtures to look for it
446 for (j=0; j<kmat; j++) {
447 mat = (TGeoMaterial*)gGeoManager->GetListOfMaterials()->At(j);
449 if (!mat->IsMixture()) continue;
450 mix = (TGeoMixture*)mat;
451 if (TMath::Abs(z[i]-mix->GetZ()) >1E-3) continue;
452 // printf(" FOUND component %i as mixture %s\n", i, mat->GetName());
456 if (!mixnew) Warning("Mixture","%s : cannot find component %i with fractional Z=%f\n", name, i, z[i]);
460 Int_t nlmatnew = nlmat+mix->GetNelements()-1;
461 Double_t *anew = new Double_t[nlmatnew];
462 Double_t *znew = new Double_t[nlmatnew];
463 Double_t *wmatnew = new Double_t[nlmatnew];
465 for (j=0; j<nlmat; j++) {
469 wmatnew[ind] = wmat[j];
472 for (j=0; j<mix->GetNelements(); j++) {
473 anew[ind] = mix->GetAmixt()[j];
474 znew[ind] = mix->GetZmixt()[j];
475 wmatnew[ind] = wmat[i]*mix->GetWmixt()[j];
478 Mixture(kmat, name, anew, znew, dens, nlmatnew, wmatnew);
484 // Now we need to compact identical elements within the mixture
485 // First check if this happens
487 for (i=0; i<nlmat-1; i++) {
488 for (j=i+1; j<nlmat; j++) {
498 Double_t *anew = new Double_t[nlmat];
499 Double_t *znew = new Double_t[nlmat];
500 memset(znew, 0, nlmat*sizeof(Double_t));
501 Double_t *wmatnew = new Double_t[nlmat];
503 for (i=0; i<nlmat; i++) {
505 for (j=0; j<nlmatnew; j++) {
507 wmatnew[j] += wmat[i];
513 anew[nlmatnew] = a[i];
514 znew[nlmatnew] = z[i];
515 wmatnew[nlmatnew] = wmat[i];
518 Mixture(kmat, name, anew, znew, dens, nlmatnew, wmatnew);
524 gGeoManager->Mixture(name, a, z, dens, nlmat, wmat, kmat);
527 //______________________________________________________________________________
528 void TFluka::Medium(Int_t& kmed, const char *name, Int_t nmat,
529 Int_t isvol, Int_t ifield, Double_t fieldm, Double_t tmaxfd,
530 Double_t stemax, Double_t deemax, Double_t epsil,
531 Double_t stmin, Float_t* ubuf, Int_t nbuf) {
534 kmed = gGeoManager->GetListOfMedia()->GetSize()+1;
535 fMCGeo->Medium(kmed, name, nmat, isvol, ifield, fieldm, tmaxfd, stemax, deemax,
536 epsil, stmin, ubuf, nbuf);
539 //______________________________________________________________________________
540 void TFluka::Medium(Int_t& kmed, const char *name, Int_t nmat,
541 Int_t isvol, Int_t ifield, Double_t fieldm, Double_t tmaxfd,
542 Double_t stemax, Double_t deemax, Double_t epsil,
543 Double_t stmin, Double_t* ubuf, Int_t nbuf) {
546 kmed = gGeoManager->GetListOfMedia()->GetSize()+1;
547 fMCGeo->Medium(kmed, name, nmat, isvol, ifield, fieldm, tmaxfd, stemax, deemax,
548 epsil, stmin, ubuf, nbuf);
551 //______________________________________________________________________________
552 void TFluka::Matrix(Int_t& krot, Double_t thetaX, Double_t phiX,
553 Double_t thetaY, Double_t phiY, Double_t thetaZ,
556 krot = gGeoManager->GetListOfMatrices()->GetEntriesFast();
557 fMCGeo->Matrix(krot, thetaX, phiX, thetaY, phiY, thetaZ, phiZ);
560 //______________________________________________________________________________
561 void TFluka::Gstpar(Int_t itmed, const char* param, Double_t parval) {
564 // Check if material is used
565 if (fVerbosityLevel >=3)
566 printf("Gstpar called with %6d %5s %12.4e %6d\n", itmed, param, parval, fGeom->GetFlukaMaterial(itmed));
569 reglist = fGeom->GetMaterialList(fGeom->GetFlukaMaterial(itmed), nreg);
575 Bool_t process = kFALSE;
576 if (strncmp(param, "DCAY", 4) == 0 ||
577 strncmp(param, "PAIR", 4) == 0 ||
578 strncmp(param, "COMP", 4) == 0 ||
579 strncmp(param, "PHOT", 4) == 0 ||
580 strncmp(param, "PFIS", 4) == 0 ||
581 strncmp(param, "DRAY", 4) == 0 ||
582 strncmp(param, "ANNI", 4) == 0 ||
583 strncmp(param, "BREM", 4) == 0 ||
584 strncmp(param, "MUNU", 4) == 0 ||
585 strncmp(param, "CKOV", 4) == 0 ||
586 strncmp(param, "HADR", 4) == 0 ||
587 strncmp(param, "LOSS", 4) == 0 ||
588 strncmp(param, "MULS", 4) == 0 ||
589 strncmp(param, "RAYL", 4) == 0)
594 SetProcess(param, Int_t (parval), fGeom->GetFlukaMaterial(itmed));
596 SetCut(param, parval, fGeom->GetFlukaMaterial(itmed));
600 // functions from GGEOM
601 //_____________________________________________________________________________
602 void TFluka::Gsatt(const char *name, const char *att, Int_t val)
604 // Set visualisation attributes for one volume
606 fGeom->Vname(name,vname);
608 fGeom->Vname(att,vatt);
609 gGeoManager->SetVolumeAttribute(vname, vatt, val);
612 //______________________________________________________________________________
613 Int_t TFluka::Gsvolu(const char *name, const char *shape, Int_t nmed,
614 Float_t *upar, Int_t np) {
616 return fMCGeo->Gsvolu(name, shape, nmed, upar, np);
619 //______________________________________________________________________________
620 Int_t TFluka::Gsvolu(const char *name, const char *shape, Int_t nmed,
621 Double_t *upar, Int_t np) {
623 return fMCGeo->Gsvolu(name, shape, nmed, upar, np);
626 //______________________________________________________________________________
627 void TFluka::Gsdvn(const char *name, const char *mother, Int_t ndiv,
630 fMCGeo->Gsdvn(name, mother, ndiv, iaxis);
633 //______________________________________________________________________________
634 void TFluka::Gsdvn2(const char *name, const char *mother, Int_t ndiv,
635 Int_t iaxis, Double_t c0i, Int_t numed) {
637 fMCGeo->Gsdvn2(name, mother, ndiv, iaxis, c0i, numed);
640 //______________________________________________________________________________
641 void TFluka::Gsdvt(const char *name, const char *mother, Double_t step,
642 Int_t iaxis, Int_t numed, Int_t ndvmx) {
644 fMCGeo->Gsdvt(name, mother, step, iaxis, numed, ndvmx);
647 //______________________________________________________________________________
648 void TFluka::Gsdvt2(const char *name, const char *mother, Double_t step,
649 Int_t iaxis, Double_t c0, Int_t numed, Int_t ndvmx) {
651 fMCGeo->Gsdvt2(name, mother, step, iaxis, c0, numed, ndvmx);
654 //______________________________________________________________________________
655 void TFluka::Gsord(const char * /*name*/, Int_t /*iax*/) {
657 // Nothing to do with TGeo
660 //______________________________________________________________________________
661 void TFluka::Gspos(const char *name, Int_t nr, const char *mother,
662 Double_t x, Double_t y, Double_t z, Int_t irot,
665 fMCGeo->Gspos(name, nr, mother, x, y, z, irot, konly);
668 //______________________________________________________________________________
669 void TFluka::Gsposp(const char *name, Int_t nr, const char *mother,
670 Double_t x, Double_t y, Double_t z, Int_t irot,
671 const char *konly, Float_t *upar, Int_t np) {
673 fMCGeo->Gsposp(name, nr, mother, x, y, z, irot, konly, upar, np);
676 //______________________________________________________________________________
677 void TFluka::Gsposp(const char *name, Int_t nr, const char *mother,
678 Double_t x, Double_t y, Double_t z, Int_t irot,
679 const char *konly, Double_t *upar, Int_t np) {
681 fMCGeo->Gsposp(name, nr, mother, x, y, z, irot, konly, upar, np);
684 //______________________________________________________________________________
685 void TFluka::Gsbool(const char* /*onlyVolName*/, const char* /*manyVolName*/) {
687 // Nothing to do with TGeo
690 //______________________________________________________________________________
691 void TFluka::SetCerenkov(Int_t itmed, Int_t npckov, Float_t* ppckov,
692 Float_t* absco, Float_t* effic, Float_t* rindex) {
694 // Set Cerenkov properties for medium itmed
696 // npckov: number of sampling points
697 // ppckov: energy values
698 // absco: absorption length
699 // effic: quantum efficiency
700 // rindex: refraction index
704 // Create object holding Cerenkov properties
706 TFlukaCerenkov* cerenkovProperties = new TFlukaCerenkov(npckov, ppckov, absco, effic, rindex);
708 // Pass object to medium
709 TGeoMedium* medium = gGeoManager->GetMedium(itmed);
710 medium->SetCerenkovProperties(cerenkovProperties);
713 //______________________________________________________________________________
714 void TFluka::SetCerenkov(Int_t /*itmed*/, Int_t /*npckov*/, Double_t * /*ppckov*/,
715 Double_t * /*absco*/, Double_t * /*effic*/, Double_t * /*rindex*/) {
717 // Not implemented with TGeo - what G4 did ? Any FLUKA card generated?
718 Warning("SetCerenkov", "Not implemented with TGeo");
722 //______________________________________________________________________________
723 void TFluka::WriteEuclid(const char* /*fileName*/, const char* /*topVol*/,
724 Int_t /*number*/, Int_t /*nlevel*/) {
727 Warning("WriteEuclid", "Not implemented with TGeo");
732 //_____________________________________________________________________________
733 // methods needed by the stepping
734 //____________________________________________________________________________
736 Int_t TFluka::GetMedium() const {
738 // Get the medium number for the current fluka region
740 return fGeom->GetMedium(); // this I need to check due to remapping !!!
745 //____________________________________________________________________________
746 // particle table usage
747 // ID <--> PDG transformations
748 //_____________________________________________________________________________
749 Int_t TFluka::IdFromPDG(Int_t pdg) const
752 // Return Fluka code from PDG and pseudo ENDF code
754 // Catch the feedback photons
755 if (pdg == 50000051) return (-1);
756 // MCIHAD() goes from pdg to fluka internal.
757 Int_t intfluka = mcihad(pdg);
758 // KPTOIP array goes from internal to official
759 return GetFlukaKPTOIP(intfluka);
762 //______________________________________________________________________________
763 Int_t TFluka::PDGFromId(Int_t id) const
766 // Return PDG code and pseudo ENDF code from Fluka code
767 // Alpha He3 Triton Deuteron gen. ion opt. photon
768 Int_t idSpecial[6] = {10020040, 10020030, 10010030, 10010020, 10000000, 50000050};
769 // IPTOKP array goes from official to internal
773 if (fVerbosityLevel >= 3)
774 printf("\n PDGFromId: Cerenkov Photon \n");
778 if (id == 0 || id < -6 || id > 250) {
779 if (fVerbosityLevel >= 3)
780 printf("PDGFromId: Error id = 0\n");
785 Int_t intfluka = GetFlukaIPTOKP(id);
787 if (fVerbosityLevel >= 3)
788 printf("PDGFromId: Error intfluka = 0: %d\n", id);
790 } else if (intfluka < 0) {
791 if (fVerbosityLevel >= 3)
792 printf("PDGFromId: Error intfluka < 0: %d\n", id);
795 if (fVerbosityLevel >= 3)
796 printf("mpdgha called with %d %d \n", id, intfluka);
797 // MPDGHA() goes from fluka internal to pdg.
798 return mpdgha(intfluka);
800 // ions and optical photons
801 return idSpecial[id + 6];
805 void TFluka::StopTrack()
807 // Set stopping conditions
808 // Works for photons and charged particles
812 //_____________________________________________________________________________
813 // methods for physics management
814 //____________________________________________________________________________
819 void TFluka::SetProcess(const char* flagName, Int_t flagValue, Int_t imed)
821 // Set process user flag for material imat
823 TFlukaConfigOption* proc = new TFlukaConfigOption(flagName, flagValue, imed);
824 fProcesses->Add(proc);
827 //______________________________________________________________________________
828 Bool_t TFluka::SetProcess(const char* flagName, Int_t flagValue)
830 // Set process user flag
833 // Update if already in the list
836 TIter next(fProcesses);
837 TFlukaConfigOption* proc;
838 while((proc = (TFlukaConfigOption*)next()))
840 if (strcmp(proc->GetName(), flagName) == 0) {
841 proc->SetFlag(flagValue);
847 // If not create a new process
850 proc = new TFlukaConfigOption(flagName, flagValue);
851 fProcesses->Add(proc);
856 //______________________________________________________________________________
857 void TFluka::SetCut(const char* cutName, Double_t cutValue, Int_t imed)
859 // Set user cut value for material imed
861 TFlukaConfigOption* cut = new TFlukaConfigOption(cutName, cutValue, imed);
865 //______________________________________________________________________________
866 Bool_t TFluka::SetCut(const char* cutName, Double_t cutValue)
868 // Set user cut value
871 // Update if already in the list
875 TFlukaConfigOption* cut;
876 while((cut = (TFlukaConfigOption*)next()))
878 if (strcmp(cut->GetName(), cutName) == 0) {
879 cut->SetCut(cutValue);
884 // If not create a new process
887 cut = new TFlukaConfigOption(cutName, cutValue);
893 void TFluka::SetUserScoring(const char* option, Int_t npar, Float_t what[12])
896 // Ads a user scoring option to th list
898 TFlukaScoringOption* opt = new TFlukaScoringOption(option, "User Scoring", npar, what);
899 fUserScore->Add(opt);
903 //______________________________________________________________________________
904 Double_t TFluka::Xsec(char*, Double_t, Int_t, Int_t)
906 printf("WARNING: Xsec not yet implemented !\n"); return -1.;
910 //______________________________________________________________________________
911 void TFluka::InitPhysics()
914 // Physics initialisation with preparation of FLUKA input cards
916 printf("=>InitPhysics\n");
920 FILE *pFlukaVmcCoreInp, *pFlukaVmcFlukaMat, *pFlukaVmcInp;
925 Double_t three = 3.0;
927 Float_t fLastMaterial = fGeom->GetLastMaterialIndex();
928 if (fVerbosityLevel >= 3) printf(" last FLUKA material is %g\n", fLastMaterial);
931 TObjArray *matList = GetFlukaMaterials();
932 Int_t nmaterial = matList->GetEntriesFast();
933 fMaterials = new Int_t[nmaterial+3];
935 // construct file names
937 TString sFlukaVmcCoreInp = getenv("ALICE_ROOT");
938 sFlukaVmcCoreInp +="/TFluka/input/";
939 TString sFlukaVmcTmp = "flukaMat.inp";
940 TString sFlukaVmcInp = GetInputFileName();
941 sFlukaVmcCoreInp += GetCoreInputFileName();
945 if ((pFlukaVmcCoreInp = fopen(sFlukaVmcCoreInp.Data(),"r")) == NULL) {
946 printf("\nCannot open file %s\n",sFlukaVmcCoreInp.Data());
949 if ((pFlukaVmcFlukaMat = fopen(sFlukaVmcTmp.Data(),"r")) == NULL) {
950 printf("\nCannot open file %s\n",sFlukaVmcTmp.Data());
953 if ((pFlukaVmcInp = fopen(sFlukaVmcInp.Data(),"w")) == NULL) {
954 printf("\nCannot open file %s\n",sFlukaVmcInp.Data());
958 // copy core input file
960 Float_t fEventsPerRun;
962 while ((fgets(sLine,255,pFlukaVmcCoreInp)) != NULL) {
963 if (strncmp(sLine,"GEOEND",6) != 0)
964 fprintf(pFlukaVmcInp,"%s",sLine); // copy until GEOEND card
966 fprintf(pFlukaVmcInp,"GEOEND\n"); // add GEOEND card
969 } // end of while until GEOEND card
973 while ((fgets(sLine,255,pFlukaVmcFlukaMat)) != NULL) { // copy flukaMat.inp file
974 fprintf(pFlukaVmcInp,"%s\n",sLine);
977 while ((fgets(sLine,255,pFlukaVmcCoreInp)) != NULL) {
978 if (strncmp(sLine,"START",5) != 0)
979 fprintf(pFlukaVmcInp,"%s\n",sLine);
981 sscanf(sLine+10,"%10f",&fEventsPerRun);
984 } //end of while until START card
987 // in G3 the process control values meaning can be different for
988 // different processes, but for most of them is:
989 // 0 process is not activated
990 // 1 process is activated WITH generation of secondaries
991 // 2 process is activated WITHOUT generation of secondaries
992 // if process does not generate secondaries => 1 same as 2
1001 // Loop over number of SetProcess calls
1002 fprintf(pFlukaVmcInp,"*----------------------------------------------------------------------------- \n");
1003 fprintf(pFlukaVmcInp,"*----- The following data are generated from SetProcess and SetCut calls ----- \n");
1004 fprintf(pFlukaVmcInp,"*----------------------------------------------------------------------------- \n");
1006 // Outer loop over processes
1007 TIter next(fProcesses);
1008 TFlukaConfigOption *proc;
1009 // Inner loop over processes
1010 TIter nextp(fProcesses);
1011 TFlukaConfigOption *procp;
1014 TFlukaConfigOption *cut = 0x0;
1016 while((proc = (TFlukaConfigOption*)next())) {
1017 Float_t matMin = three;
1018 Float_t matMax = fLastMaterial;
1019 Bool_t global = kTRUE;
1020 if (proc->Medium() != -1) {
1022 if ((mat = proc->Medium()) >= GetFlukaMaterials()->GetEntries()) continue;
1023 matMin = Float_t(mat);
1027 fprintf(pFlukaVmcInp,"*\n*Material specific process setting for #%8d \n", mat);
1031 // G3 default value: 1
1032 // G4 processes: G4eplusAnnihilation/G4IeplusAnnihilation
1035 // flag = 0 no annihilation
1036 // flag = 1 annihilation, decays processed
1037 // flag = 2 annihilation, no decay product stored
1038 // gMC ->SetProcess("ANNI",1); // EMFCUT -1. 0. 0. 3. lastmat 0. ANNH-THR
1039 if (strncmp(proc->GetName(),"ANNI",4) == 0) {
1040 if (proc->Flag() == 1 || proc->Flag() == 2) {
1041 fprintf(pFlukaVmcInp,"*\n*Kinetic energy threshold (GeV) for e+ annihilation - resets to default=0.\n");
1042 fprintf(pFlukaVmcInp,"*Generated from call: SetProcess('ANNI',1) or SetProcess('ANNI',2)\n");
1043 // -one = kinetic energy threshold (GeV) for e+ annihilation (resets to default=0)
1046 // matMin = lower bound of the material indices in which the respective thresholds apply
1047 // matMax = upper bound of the material indices in which the respective thresholds apply
1048 // one = step length in assigning indices
1050 fprintf(pFlukaVmcInp,"EMFCUT %10.1f%10.1f%10.1f%10.1f%10.1f%10.1fANNH-THR\n",-one,zero,zero,matMin,matMax,one);
1052 else if (proc->Flag() == 0) {
1053 fprintf(pFlukaVmcInp,"*\n*No annihilation - no FLUKA card generated\n");
1054 fprintf(pFlukaVmcInp,"*Generated from call: SetProcess('ANNI',0)\n");
1057 fprintf(pFlukaVmcInp,"*\n*Illegal flag value in SetProcess('ANNI',?) call.\n");
1058 fprintf(pFlukaVmcInp,"*No FLUKA card generated\n");
1062 // bremsstrahlung and pair production are both activated
1063 // G3 default value: 1
1064 // G4 processes: G4eBremsstrahlung/G4IeBremsstrahlung,
1065 // G4MuBremsstrahlung/G4IMuBremsstrahlung,
1066 // G4LowEnergyBremstrahlung
1067 // Particles: e-/e+; mu+/mu-
1069 // flag = 0 no bremsstrahlung
1070 // flag = 1 bremsstrahlung, photon processed
1071 // flag = 2 bremsstrahlung, no photon stored
1072 // gMC ->SetProcess("BREM",1); // PAIRBREM 2. 0. 0. 3. lastmat
1073 // EMFCUT -1. 0. 0. 3. lastmat 0. ELPO-THR
1074 // G3 default value: 1
1075 // G4 processes: G4GammaConversion,
1076 // G4MuPairProduction/G4IMuPairProduction
1077 // G4LowEnergyGammaConversion
1078 // Particles: gamma, mu
1080 // flag = 0 no delta rays
1081 // flag = 1 delta rays, secondaries processed
1082 // flag = 2 delta rays, no secondaries stored
1084 else if ((strncmp(proc->GetName(),"PAIR",4) == 0) && (proc->Flag() == 1 || proc->Flag() == 2)) {
1088 while ((procp = (TFlukaConfigOption*)nextp())) {
1089 if ((strncmp(procp->GetName(),"BREM",4) == 0) &&
1090 (proc->Flag() == 1) &&
1091 (procp->Medium() == proc->Medium())) {
1092 fprintf(pFlukaVmcInp,"*\n*Bremsstrahlung and pair production by muons and charged hadrons both activated\n");
1093 fprintf(pFlukaVmcInp,"*Generated from call: SetProcess('BREM',1) and SetProcess('PAIR',1)\n");
1094 fprintf(pFlukaVmcInp,"*Energy threshold set by call SetCut('BCUTM',cut) or set to 0.\n");
1095 fprintf(pFlukaVmcInp,"*Energy threshold set by call SetCut('PPCUTM',cut) or set to 0.\n");
1096 // three = bremsstrahlung and pair production by muons and charged hadrons both are activated
1097 fprintf(pFlukaVmcInp,"PAIRBREM %10.1f",three);
1098 // direct pair production by muons
1099 // G4 particles: "e-", "e+"
1100 // G3 default value: 0.01 GeV
1101 //gMC ->SetCut("PPCUTM",cut); // total energy cut for direct pair prod. by muons
1104 while ((cut = (TFlukaConfigOption*)nextc())) {
1105 if (strncmp(cut->GetName(), "PPCUTM", 6) == 0 &&
1106 (cut->Medium() == proc->Medium())) theCut = cut->Cut();
1108 fprintf(pFlukaVmcInp,"%10.4g",theCut);
1109 // theCut; = e+, e- kinetic energy threshold (in GeV) for explicit pair production.
1110 // muon and hadron bremsstrahlung
1111 // G4 particles: "gamma"
1112 // G3 default value: CUTGAM=0.001 GeV
1113 //gMC ->SetCut("BCUTM",cut); // cut for muon and hadron bremsstrahlung
1116 while ((cut = (TFlukaConfigOption*)nextc())) {
1117 if (strncmp(cut->GetName(), "BCUTM", 5) == 0 &&
1118 (cut->Medium() == proc->Medium())) theCut = cut->Cut();
1120 fprintf(pFlukaVmcInp,"%10.4g%10.1f%10.1f\n",theCut,matMin,matMax);
1121 // theCut = photon energy threshold (GeV) for explicit bremsstrahlung production
1122 // matMin = lower bound of the material indices in which the respective thresholds apply
1123 // matMax = upper bound of the material indices in which the respective thresholds apply
1126 fprintf(pFlukaVmcInp,"*\n*Kinetic energy threshold (GeV) for e+/e- bremsstrahlung - resets to default=0.\n");
1127 fprintf(pFlukaVmcInp,"*Generated from call: SetProcess('BREM',1);\n");
1130 while ((cut = (TFlukaConfigOption*)nextc())) {
1131 if (strncmp(cut->GetName(), "BCUTE", 5) == 0 &&
1132 (cut->Medium() == proc->Medium())) theCut = cut->Cut();
1134 //theCut = kinetic energy threshold (GeV) for e+/e- bremsstrahlung (resets to default=0)
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
1141 fprintf(pFlukaVmcInp,"EMFCUT %10.4g%10.1f%10.1f%10.1f%10.1f%10.1fELPO-THR\n",theCut,zero,zero,matMin,matMax,one);
1143 // for gamma -> e+ and e-
1144 fprintf(pFlukaVmcInp,"*\n*Pair production by photons is activated\n");
1145 fprintf(pFlukaVmcInp,"*Generated from call: SetProcess('PAIR',1);\n");
1148 while ((cut = (TFlukaConfigOption*)nextc())) {
1149 if (strncmp(cut->GetName(), "CUTELE", 6) == 0 &&
1150 (cut->Medium() == proc->Medium())) theCut = cut->Cut();
1152 // theCut = energy threshold (GeV) for gamma pair production (< 0.0 : resets to default, = 0.0 : ignored)
1153 // matMin = lower bound of the material indices in which the respective thresholds apply
1154 // matMax = upper bound of the material indices in which the respective thresholds apply
1155 // one = step length in assigning indices
1156 fprintf(pFlukaVmcInp,"EMFCUT %10.1f%10.1f%10.4g%10.1f%10.1f%10.1fPHOT-THR\n",zero,zero,theCut,matMin,matMax,one);
1158 } // end of if for BREM
1159 } // end of loop for BREM
1161 // only pair production by muons and charged hadrons is activated
1162 fprintf(pFlukaVmcInp,"*\n*Pair production by muons and charged hadrons is activated\n");
1163 fprintf(pFlukaVmcInp,"*Generated from call: SetProcess('PAIR',1) or SetProcess('PAIR',2)\n");
1164 fprintf(pFlukaVmcInp,"*Energy threshold set by call SetCut('PPCUTM',cut) or set to 0.\n");
1165 // direct pair production by muons
1166 // G4 particles: "e-", "e+"
1167 // G3 default value: 0.01 GeV
1168 //gMC ->SetCut("PPCUTM",cut); // total energy cut for direct pair prod. by muons
1169 // one = pair production by muons and charged hadrons is activated
1170 // zero = e+, e- kinetic energy threshold (in GeV) for explicit pair production.
1171 // zero = no explicit bremsstrahlung production is simulated
1172 // matMin = lower bound of the material indices in which the respective thresholds apply
1173 // matMax = upper bound of the material indices in which the respective thresholds apply
1174 fprintf(pFlukaVmcInp,"PAIRBREM %10.1f%10.1f%10.1f%10.1f%10.1f\n",one,zero,zero,matMin,matMax);
1176 // for gamma -> e+ and e-
1177 fprintf(pFlukaVmcInp,"*\n*Pair production by electrons is activated\n");
1178 fprintf(pFlukaVmcInp,"*Generated from call: SetProcess('PAIR',1) or SetProcess('PAIR',2)\n");
1181 while ((cut = (TFlukaConfigOption*)nextc())) {
1182 if (strncmp(cut->GetName(), "CUTELE", 6) == 0 &&
1183 (cut->Medium() == proc->Medium())) theCut = cut->Cut();
1185 // zero = energy threshold (GeV) for Compton scattering (= 0.0 : ignored)
1186 // zero = energy threshold (GeV) for Photoelectric (= 0.0 : ignored)
1187 // theCut = energy threshold (GeV) for gamma pair production (< 0.0 : resets to default, = 0.0 : ignored)
1188 // matMin = lower bound of the material indices in which the respective thresholds apply
1189 // matMax = upper bound of the material indices in which the respective thresholds apply
1190 // one = step length in assigning indices
1191 fprintf(pFlukaVmcInp,"EMFCUT %10.1f%10.1f%10.4g%10.1f%10.1f%10.1fPHOT-THR\n",zero,zero,theCut,matMin,matMax,one);
1195 } // end of if for PAIR
1200 // G3 default value: 1
1201 // G4 processes: G4eBremsstrahlung/G4IeBremsstrahlung,
1202 // G4MuBremsstrahlung/G4IMuBremsstrahlung,
1203 // G4LowEnergyBremstrahlung
1204 // Particles: e-/e+; mu+/mu-
1206 // flag = 0 no bremsstrahlung
1207 // flag = 1 bremsstrahlung, photon processed
1208 // flag = 2 bremsstrahlung, no photon stored
1209 // gMC ->SetProcess("BREM",1); // PAIRBREM 2. 0. 0. 3. lastmat
1210 // EMFCUT -1. 0. 0. 3. lastmat 0. ELPO-THR
1211 else if (strncmp(proc->GetName(),"BREM",4) == 0) {
1213 while((procp = (TFlukaConfigOption*)nextp())) {
1214 if ((strncmp(procp->GetName(),"PAIR",4) == 0) &&
1215 procp->Flag() == 1 &&
1216 (procp->Medium() == proc->Medium())) goto NOBREM;
1218 if (proc->Flag() == 1) {
1219 fprintf(pFlukaVmcInp,"*\n*Bremsstrahlung by muons and charged hadrons is activated\n");
1220 fprintf(pFlukaVmcInp,"*Generated from call: SetProcess('BREM',1) or SetProcess('BREM',2)\n");
1221 fprintf(pFlukaVmcInp,"*Energy threshold set by call SetCut('BCUTM',cut) or set to 0.\n");
1222 // two = bremsstrahlung by muons and charged hadrons is activated
1223 // zero = no meaning
1224 // muon and hadron bremsstrahlung
1225 // G4 particles: "gamma"
1226 // G3 default value: CUTGAM=0.001 GeV
1227 //gMC ->SetCut("BCUTM",cut); // cut for muon and hadron bremsstrahlung
1230 while ((cut = (TFlukaConfigOption*)nextc())) {
1231 if (strncmp(cut->GetName(), "BCUTM", 5) == 0 &&
1232 (cut->Medium() == proc->Medium())) theCut = cut->Cut();
1234 // theCut = photon energy threshold (GeV) for explicit bremsstrahlung production
1235 // matMin = lower bound of the material indices in which the respective thresholds apply
1236 // matMax = upper bound of the material indices in which the respective thresholds apply
1237 fprintf(pFlukaVmcInp,"PAIRBREM %10.1f%10.1f%10.4g%10.1f%10.1f\n",two,zero,theCut,matMin,matMax);
1240 fprintf(pFlukaVmcInp,"*\n*Kinetic energy threshold (GeV) for e+/e- bremsstrahlung - resets to default=0.\n");
1241 fprintf(pFlukaVmcInp,"*Generated from call: SetProcess('BREM',1);");
1242 // - one = kinetic energy threshold (GeV) for e+/e- bremsstrahlung (resets to default=0)
1245 // matMin = lower bound of the material indices in which the respective thresholds apply
1246 // matMax = upper bound of the material indices in which the respective thresholds apply
1247 // one = step length in assigning indices
1251 while ((cut = (TFlukaConfigOption*)nextc())) {
1252 if (strncmp(cut->GetName(), "CUTGAM", 6) == 0 &&
1253 (cut->Medium() == proc->Medium())) theCut = cut->Cut();
1255 fprintf(pFlukaVmcInp,"EMFCUT %10.4g%10.1f%10.1f%10.1f%10.1f%10.1fELPO-THR\n", theCut,zero,zero,matMin,matMax,one);
1257 else if (proc->Flag() == 0) {
1258 fprintf(pFlukaVmcInp,"*\n*No bremsstrahlung - no FLUKA card generated\n");
1259 fprintf(pFlukaVmcInp,"*Generated from call: SetProcess('BREM',0)\n");
1262 fprintf(pFlukaVmcInp,"*\n*Illegal flag value in SetProcess('BREM',?) call.\n");
1263 fprintf(pFlukaVmcInp,"*No FLUKA card generated\n");
1267 } // end of else if (strncmp(proc->GetName(),"BREM",4) == 0)
1269 // Cerenkov photon generation
1270 // G3 default value: 0
1271 // G4 process: G4Cerenkov
1273 // Particles: charged
1275 // flag = 0 no Cerenkov photon generation
1276 // flag = 1 Cerenkov photon generation
1277 // flag = 2 Cerenkov photon generation with primary stopped at each step
1278 //xx gMC ->SetProcess("CKOV",1); // ??? Cerenkov photon generation
1280 else if (strncmp(proc->GetName(),"CKOV",4) == 0) {
1281 if ((proc->Flag() == 1 || proc->Flag() == 2) && global) {
1283 fprintf(pFlukaVmcInp, "* \n");
1284 fprintf(pFlukaVmcInp, "*Cerenkov photon generation\n");
1285 fprintf(pFlukaVmcInp, "*Generated from call: SetProcess('CKOV',1) or SetProcess('CKOV',2)\n");
1287 for (Int_t im = 0; im < nmaterial; im++)
1289 TGeoMaterial* material = dynamic_cast<TGeoMaterial*> (matList->At(im));
1290 Int_t idmat = material->GetIndex();
1292 if (!global && idmat != proc->Medium()) continue;
1294 fMaterials[idmat] = im;
1295 // Skip media with no Cerenkov properties
1296 TFlukaCerenkov* cerenkovProp;
1297 if (!(cerenkovProp = dynamic_cast<TFlukaCerenkov*>(material->GetCerenkovProperties()))) continue;
1299 // This medium has Cerenkov properties
1302 // Write OPT-PROD card for each medium
1303 Float_t emin = cerenkovProp->GetMinimumEnergy();
1304 Float_t emax = cerenkovProp->GetMaximumEnergy();
1305 fprintf(pFlukaVmcInp, "OPT-PROD %10.4g%10.4g%10.4g%10.4g%10.4g%10.4gCERENKOV\n", emin, emax, 0.,
1306 Float_t(idmat), Float_t(idmat), 0.);
1308 // Write OPT-PROP card for each medium
1309 // Forcing FLUKA to call user routines (queffc.cxx, rflctv.cxx, rfrndx.cxx)
1311 fprintf(pFlukaVmcInp, "OPT-PROP %10.4g%10.4g%10.4g%10.1f%10.1f%10.1fWV-LIMIT\n",
1312 cerenkovProp->GetMinimumWavelength(),
1313 cerenkovProp->GetMaximumWavelength(),
1314 cerenkovProp->GetMaximumWavelength(),
1315 Float_t(idmat), Float_t(idmat), 0.0);
1317 if (cerenkovProp->IsMetal()) {
1318 fprintf(pFlukaVmcInp, "OPT-PROP %10.1f%10.1f%10.1f%10.1f%10.1f%10.1fMETAL\n",
1319 -100., -100., -100.,
1320 Float_t(idmat), Float_t(idmat), 0.0);
1322 fprintf(pFlukaVmcInp, "OPT-PROP %10.1f%10.1f%10.1f%10.1f%10.1f%10.1f\n",
1323 -100., -100., -100.,
1324 Float_t(idmat), Float_t(idmat), 0.0);
1328 for (Int_t j = 0; j < 3; j++) {
1329 fprintf(pFlukaVmcInp, "OPT-PROP %10.1f%10.1f%10.1f%10.1f%10.1f%10.1f&\n",
1330 -100., -100., -100.,
1331 Float_t(idmat), Float_t(idmat), 0.0);
1333 // Photon detection efficiency user defined
1335 if (cerenkovProp->IsSensitive())
1336 fprintf(pFlukaVmcInp, "OPT-PROP %10.1f%10.1f%10.1f%10.1f%10.1f%10.1fSENSITIV\n",
1337 -100., -100., -100.,
1338 Float_t(idmat), Float_t(idmat), 0.0);
1341 } else if (proc->Flag() == 0) {
1342 fprintf(pFlukaVmcInp,"*\n*No Cerenkov photon generation\n");
1343 fprintf(pFlukaVmcInp,"*Generated from call: SetProcess('CKOV',0)\n");
1347 // matMin = lower bound of the material indices in which the respective thresholds apply
1348 // matMax = upper bound of the material indices in which the respective thresholds apply
1349 // one = step length in assigning indices
1351 fprintf(pFlukaVmcInp,"OPT-PROD %10.1f%10.1f%10.1f%10.1f%10.1f%10.1fCERE-OFF\n",zero,zero,zero,matMin,matMax,one);
1354 fprintf(pFlukaVmcInp,"*\n*Illegal flag value in SetProcess('CKOV',?) call.\n");
1355 fprintf(pFlukaVmcInp,"*No FLUKA card generated\n");
1357 } // end of else if (strncmp(proc->GetName(),"CKOV",4) == 0)
1359 // Compton scattering
1360 // G3 default value: 1
1361 // G4 processes: G4ComptonScattering,
1362 // G4LowEnergyCompton,
1363 // G4PolarizedComptonScattering
1366 // flag = 0 no Compton scattering
1367 // flag = 1 Compton scattering, electron processed
1368 // flag = 2 Compton scattering, no electron stored
1369 // gMC ->SetProcess("COMP",1); // EMFCUT -1. 0. 0. 3. lastmat 0. PHOT-THR
1370 else if (strncmp(proc->GetName(),"COMP",4) == 0) {
1371 if (proc->Flag() == 1 || proc->Flag() == 2) {
1372 fprintf(pFlukaVmcInp,"*\n*Energy threshold (GeV) for Compton scattering - resets to default=0.\n");
1373 fprintf(pFlukaVmcInp,"*Generated from call: SetProcess('COMP',1);\n");
1374 // - one = energy threshold (GeV) for Compton scattering - resets to default=0.
1377 // matMin = lower bound of the material indices in which the respective thresholds apply
1378 // matMax = upper bound of the material indices in which the respective thresholds apply
1379 // one = step length in assigning indices
1383 while ((cut = (TFlukaConfigOption*)nextc())) {
1384 if (strncmp(cut->GetName(), "CUTELE", 6) == 0 &&
1385 (cut->Medium() == proc->Medium())) theCut = cut->Cut();
1387 fprintf(pFlukaVmcInp,"EMFCUT %10.4g%10.1f%10.1f%10.1f%10.1f%10.1fPHOT-THR\n",theCut,zero,zero,matMin,matMax,one);
1389 else if (proc->Flag() == 0) {
1390 fprintf(pFlukaVmcInp,"*\n*No Compton scattering - no FLUKA card generated\n");
1391 fprintf(pFlukaVmcInp,"*Generated from call: SetProcess('COMP',0)\n");
1394 fprintf(pFlukaVmcInp,"*\n*Illegal flag value in SetProcess('COMP',?) call.\n");
1395 fprintf(pFlukaVmcInp,"*No FLUKA card generated\n");
1397 } // end of else if (strncmp(proc->GetName(),"COMP",4) == 0)
1400 // G3 default value: 1
1401 // G4 process: G4Decay
1403 // Particles: all which decay is applicable for
1405 // flag = 0 no decays
1406 // flag = 1 decays, secondaries processed
1407 // flag = 2 decays, no secondaries stored
1408 //gMC ->SetProcess("DCAY",0); // not available
1409 else if ((strncmp(proc->GetName(),"DCAY",4) == 0) && proc->Flag() == 0)
1410 cout << "SetProcess for flag =" << proc->GetName() << " value=" << proc->Flag() << " not avaliable!" << endl;
1411 else if ((strncmp(proc->GetName(),"DCAY",4) == 0) && proc->Flag() == 1) {
1412 // Nothing to do decays are switched on by default
1417 // G3 default value: 2
1418 // !! G4 treats delta rays in different way
1419 // G4 processes: G4eIonisation/G4IeIonization,
1420 // G4MuIonisation/G4IMuIonization,
1421 // G4hIonisation/G4IhIonisation
1422 // Particles: charged
1424 // flag = 0 no energy loss
1425 // flag = 1 restricted energy loss fluctuations
1426 // flag = 2 complete energy loss fluctuations
1427 // flag = 3 same as 1
1428 // flag = 4 no energy loss fluctuations
1429 // gMC ->SetProcess("DRAY",0); // DELTARAY 1.E+6 0. 0. 3. lastmat 0.
1430 else if (strncmp(proc->GetName(),"DRAY",4) == 0) {
1431 if (proc->Flag() == 0 || proc->Flag() == 4) {
1432 fprintf(pFlukaVmcInp,"*\n*Kinetic energy threshold (GeV) for delta ray production\n");
1433 fprintf(pFlukaVmcInp,"*Generated from call: SetProcess('DRAY',0) or SetProcess('DRAY',4)\n");
1434 fprintf(pFlukaVmcInp,"*No delta ray production by muons - threshold set artificially high\n");
1435 Double_t emin = 1.0e+6; // kinetic energy threshold (GeV) for delta ray production (discrete energy transfer)
1438 // matMin = lower bound of the material indices in which the respective thresholds apply
1439 // matMax = upper bound of the material indices in which the respective thresholds apply
1440 // one = step length in assigning indices
1441 fprintf(pFlukaVmcInp,"DELTARAY %10.4g%10.1f%10.1f%10.1f%10.1f%10.1f\n",emin,zero,zero,matMin,matMax,one);
1443 else if (proc->Flag() == 1 || proc->Flag() == 2 || proc->Flag() == 3) {
1444 fprintf(pFlukaVmcInp,"*\n*Kinetic energy threshold (GeV) for delta ray production\n");
1445 fprintf(pFlukaVmcInp,"*Generated from call: SetProcess('DRAY',flag), flag=1,2,3\n");
1446 fprintf(pFlukaVmcInp,"*Delta ray production by muons switched on\n");
1447 fprintf(pFlukaVmcInp,"*Energy threshold set by call SetCut('DCUTM',cut) or set to 1.0e+6.\n");
1451 // Check cut one delta-rays from electrons
1453 while ((cut = (TFlukaConfigOption*)nextc())) {
1454 if (strncmp(cut->GetName(), "DCUTM", 5) == 0 &&
1455 cut->Medium() == proc->Medium()) theCut = cut->Cut();
1457 // theCut = kinetic energy threshold (GeV) for delta ray production (discrete energy transfer)
1460 // matMin = lower bound of the material indices in which the respective thresholds apply
1461 // matMax = upper bound of the material indices in which the respective thresholds apply
1462 // one = step length in assigning indices
1463 fprintf(pFlukaVmcInp,"DELTARAY %10.4g%10.1f%10.1f%10.1f%10.1f%10.1f\n",theCut,zero,zero,matMin,matMax,one);
1466 fprintf(pFlukaVmcInp,"*\n*Illegal flag value in SetProcess('DRAY',?) call.\n");
1467 fprintf(pFlukaVmcInp,"*No FLUKA card generated\n");
1469 } // end of else if (strncmp(proc->GetName(),"DRAY",4) == 0)
1472 // G3 default value: 1
1473 // G4 processes: all defined by TG4PhysicsConstructorHadron
1475 // Particles: hadrons
1477 // flag = 0 no multiple scattering
1478 // flag = 1 hadronic interactions, secondaries processed
1479 // flag = 2 hadronic interactions, no secondaries stored
1480 // gMC ->SetProcess("HADR",1); // ??? hadronic process
1481 //Select pure GEANH (HADR 1) or GEANH/NUCRIN (HADR 3) ?????
1482 else if (strncmp(proc->GetName(),"HADR",4) == 0) {
1483 if (proc->Flag() == 1 || proc->Flag() == 2) {
1484 fprintf(pFlukaVmcInp,"*\n*Hadronic interaction is ON by default in FLUKA\n");
1485 fprintf(pFlukaVmcInp,"*No FLUKA card generated\n");
1487 else if (proc->Flag() == 0) {
1488 fprintf(pFlukaVmcInp,"*\n*Hadronic interaction is set OFF\n");
1489 fprintf(pFlukaVmcInp,"*Generated from call: SetProcess('HADR',0);\n");
1490 fprintf(pFlukaVmcInp,"*Switching off hadronic interactions not foreseen in FLUKA\n");
1491 fprintf(pFlukaVmcInp,"THRESHOL %10.1f%10.1f%10.1f%10.1e%10.1f\n",zero, zero, zero, 1.e10, zero);
1494 fprintf(pFlukaVmcInp,"*\n*Illegal flag value in SetProcess('HADR',?) call.\n");
1495 fprintf(pFlukaVmcInp,"*No FLUKA card generated\n");
1497 } // end of else if (strncmp(proc->GetName(),"HADR",4) == 0)
1501 // G3 default value: 2
1502 // G4 processes: G4eIonisation/G4IeIonization,
1503 // G4MuIonisation/G4IMuIonization,
1504 // G4hIonisation/G4IhIonisation
1506 // Particles: charged
1508 // flag=0 no energy loss
1509 // flag=1 restricted energy loss fluctuations
1510 // flag=2 complete energy loss fluctuations
1512 // flag=4 no energy loss fluctuations
1513 // If the value ILOSS is changed, then (in G3) cross-sections and energy
1514 // loss tables must be recomputed via the command 'PHYSI'
1515 // gMC ->SetProcess("LOSS",2); // ??? IONFLUCT ? energy loss
1516 else if (strncmp(proc->GetName(),"LOSS",4) == 0) {
1517 if (proc->Flag() > 0 || proc->Flag() < 4) { // restricted energy loss fluctuations
1518 fprintf(pFlukaVmcInp,"*\n*Restricted energy loss fluctuations\n");
1519 fprintf(pFlukaVmcInp,"*Generated from call: SetProcess('LOSS',1) or SetProcess('LOSS',3)\n");
1520 // one = restricted energy loss fluctuations (for hadrons and muons) switched on
1521 // one = restricted energy loss fluctuations (for e+ and e-) switched on
1522 // one = minimal accuracy
1523 // matMin = lower bound of the material indices in which the respective thresholds apply
1524 // upper bound of the material indices in which the respective thresholds apply
1525 fprintf(pFlukaVmcInp,"IONFLUCT %10.1f%10.1f%10.1f%10.1f%10.1f\n",one, one, 4., matMin, matMax);
1527 else if (proc->Flag() == 4) { // no energy loss fluctuations
1528 fprintf(pFlukaVmcInp,"*\n*No energy loss fluctuations\n");
1529 fprintf(pFlukaVmcInp,"*\n*Generated from call: SetProcess('LOSS',4)\n");
1530 // - one = restricted energy loss fluctuations (for hadrons and muons) switched off
1531 // - one = restricted energy loss fluctuations (for e+ and e-) switched off
1532 // one = minimal accuracy
1533 // matMin = lower bound of the material indices in which the respective thresholds apply
1534 // matMax = upper bound of the material indices in which the respective thresholds apply
1535 fprintf(pFlukaVmcInp,"IONFLUCT %10.1f%10.1f%10.1f%10.1f%10.1f\n",-one,-one,one,matMin,matMax);
1538 fprintf(pFlukaVmcInp,"*\n*Illegal flag value in SetProcess('LOSS',?) call.\n");
1539 fprintf(pFlukaVmcInp,"*No FLUKA card generated\n");
1541 } // end of else if (strncmp(proc->GetName(),"LOSS",4) == 0)
1544 // multiple scattering
1545 // G3 default value: 1
1546 // G4 process: G4MultipleScattering/G4IMultipleScattering
1548 // Particles: charged
1550 // flag = 0 no multiple scattering
1551 // flag = 1 Moliere or Coulomb scattering
1552 // flag = 2 Moliere or Coulomb scattering
1553 // flag = 3 Gaussian scattering
1554 // gMC ->SetProcess("MULS",1); // MULSOPT multiple scattering
1555 else if (strncmp(proc->GetName(),"MULS",4) == 0) {
1556 if (proc->Flag() == 1 || proc->Flag() == 2 || proc->Flag() == 3) {
1557 fprintf(pFlukaVmcInp,"*\n*Multiple scattering is ON by default for e+e- and for hadrons/muons\n");
1558 fprintf(pFlukaVmcInp,"*No FLUKA card generated\n");
1560 else if (proc->Flag() == 0) {
1561 fprintf(pFlukaVmcInp,"*\n*Multiple scattering is set OFF\n");
1562 fprintf(pFlukaVmcInp,"*Generated from call: SetProcess('MULS',0);\n");
1564 // three = multiple scattering for hadrons and muons is completely suppressed
1565 // three = multiple scattering for e+ and e- is completely suppressed
1566 // matMin = lower bound of the material indices in which the respective thresholds apply
1567 // matMax = upper bound of the material indices in which the respective thresholds apply
1568 fprintf(pFlukaVmcInp,"MULSOPT %10.1f%10.1f%10.1f%10.1f%10.1f\n",zero,three,three,matMin,matMax);
1571 fprintf(pFlukaVmcInp,"*\n*Illegal flag value in SetProcess('MULS',?) call.\n");
1572 fprintf(pFlukaVmcInp,"*No FLUKA card generated\n");
1574 } // end of else if (strncmp(proc->GetName(),"MULS",4) == 0)
1577 // muon nuclear interaction
1578 // G3 default value: 0
1579 // G4 processes: G4MuNuclearInteraction,
1580 // G4MuonMinusCaptureAtRest
1584 // flag = 0 no muon-nuclear interaction
1585 // flag = 1 nuclear interaction, secondaries processed
1586 // flag = 2 nuclear interaction, secondaries not processed
1587 // gMC ->SetProcess("MUNU",1); // MUPHOTON 1. 0. 0. 3. lastmat
1588 else if (strncmp(proc->GetName(),"MUNU",4) == 0) {
1589 if (proc->Flag() == 1) {
1590 fprintf(pFlukaVmcInp,"*\n*Muon nuclear interactions with production of secondary hadrons\n");
1591 fprintf(pFlukaVmcInp,"*\n*Generated from call: SetProcess('MUNU',1);\n");
1592 // one = full simulation of muon nuclear interactions and production of secondary hadrons
1593 // zero = ratio of longitudinal to transverse virtual photon cross-section - Default = 0.25.
1594 // zero = fraction of rho-like interactions ( must be < 1) - Default = 0.75.
1595 // matMin = lower bound of the material indices in which the respective thresholds apply
1596 // matMax = upper bound of the material indices in which the respective thresholds apply
1597 fprintf(pFlukaVmcInp,"MUPHOTON %10.1f%10.1f%10.1f%10.1f%10.1f\n",one,zero,zero,matMin,matMax);
1599 else if (proc->Flag() == 2) {
1600 fprintf(pFlukaVmcInp,"*\n*Muon nuclear interactions without production of secondary hadrons\n");
1601 fprintf(pFlukaVmcInp,"*Generated from call: SetProcess('MUNU',2);\n");
1602 // two = full simulation of muon nuclear interactions and production of secondary hadrons
1603 // zero = ratio of longitudinal to transverse virtual photon cross-section - Default = 0.25.
1604 // zero = fraction of rho-like interactions ( must be < 1) - Default = 0.75.
1605 // matMin = lower bound of the material indices in which the respective thresholds apply
1606 // matMax = upper bound of the material indices in which the respective thresholds apply
1607 fprintf(pFlukaVmcInp,"MUPHOTON %10.1f%10.1f%10.1f%10.1f%10.1f\n",two,zero,zero,matMin,matMax);
1609 else if (proc->Flag() == 0) {
1610 fprintf(pFlukaVmcInp,"*\n*No muon nuclear interaction - no FLUKA card generated\n");
1611 fprintf(pFlukaVmcInp,"*Generated from call: SetProcess('MUNU',0)\n");
1614 fprintf(pFlukaVmcInp,"*\n*Illegal flag value in SetProcess('MUNU',?) call.\n");
1615 fprintf(pFlukaVmcInp,"*No FLUKA card generated\n");
1617 } // end of else if (strncmp(proc->GetName(),"MUNU",4) == 0)
1621 // G3 default value: 0
1626 // gMC ->SetProcess("PFIS",0); // PHOTONUC -1. 0. 0. 3. lastmat 0.
1627 // flag = 0 no photon fission
1628 // flag = 1 photon fission, secondaries processed
1629 // flag = 2 photon fission, no secondaries stored
1630 else if (strncmp(proc->GetName(),"PFIS",4) == 0) {
1631 if (proc->Flag() == 0) {
1632 fprintf(pFlukaVmcInp,"*\n*No photonuclear interactions\n");
1633 fprintf(pFlukaVmcInp,"*Generated from call: SetProcess('PFIS',0);\n");
1634 // - one = no photonuclear interactions
1637 // matMin = lower bound of the material indices in which the respective thresholds apply
1638 // matMax = upper bound of the material indices in which the respective thresholds apply
1639 fprintf(pFlukaVmcInp,"PHOTONUC %10.1f%10.1f%10.1f%10.1f%10.1f\n",-one,zero,zero,matMin,matMax);
1641 else if (proc->Flag() == 1) {
1642 fprintf(pFlukaVmcInp,"*\n*Photon nuclear interactions are activated at all energies\n");
1643 fprintf(pFlukaVmcInp,"*Generated from call: SetProcess('PFIS',1);\n");
1644 // one = photonuclear interactions are activated at all energies
1647 // matMin = lower bound of the material indices in which the respective thresholds apply
1648 // matMax = upper bound of the material indices in which the respective thresholds apply
1649 fprintf(pFlukaVmcInp,"PHOTONUC %10.1f%10.1f%10.1f%10.1f%10.1f\n",one,zero,zero,matMin,matMax);
1651 else if (proc->Flag() == 0) {
1652 fprintf(pFlukaVmcInp,"*\n*No photofission - no FLUKA card generated\n");
1653 fprintf(pFlukaVmcInp,"*Generated from call: SetProcess('PFIS',0)\n");
1656 fprintf(pFlukaVmcInp,"*\n*Illegal flag value in SetProcess('PFIS',?) call.\n");
1657 fprintf(pFlukaVmcInp,"*No FLUKA card generated\n");
1662 // photo electric effect
1663 // G3 default value: 1
1664 // G4 processes: G4PhotoElectricEffect
1665 // G4LowEnergyPhotoElectric
1668 // flag = 0 no photo electric effect
1669 // flag = 1 photo electric effect, electron processed
1670 // flag = 2 photo electric effect, no electron stored
1671 // gMC ->SetProcess("PHOT",1); // EMFCUT 0. -1. 0. 3. lastmat 0. PHOT-THR
1672 else if (strncmp(proc->GetName(),"PHOT",4) == 0) {
1673 if (proc->Flag() == 1) {
1674 fprintf(pFlukaVmcInp,"*\n*Photo electric effect is activated\n");
1675 fprintf(pFlukaVmcInp,"*Generated from call: SetProcess('PHOT',1);\n");
1677 // - one = resets to default=0.
1679 // matMin = lower bound of the material indices in which the respective thresholds apply
1680 // matMax = upper bound of the material indices in which the respective thresholds apply
1681 // one = step length in assigning indices
1685 while ((cut = (TFlukaConfigOption*)nextc())) {
1686 if (strncmp(cut->GetName(), "CUTELE", 6) == 0 &&
1687 (cut->Medium() == proc->Medium())) theCut = cut->Cut();
1689 fprintf(pFlukaVmcInp,"EMFCUT %10.1f%10.4g%10.1f%10.1f%10.1f%10.1fPHOT-THR\n",zero,theCut,zero,matMin,matMax,one);
1691 else if (proc->Flag() == 0) {
1692 fprintf(pFlukaVmcInp,"*\n*No photo electric effect - no FLUKA card generated\n");
1693 fprintf(pFlukaVmcInp,"*Generated from call: SetProcess('PHOT',0)\n");
1696 fprintf(pFlukaVmcInp,"*\n*Illegal flag value in SetProcess('PHOT',?) call.\n");
1697 fprintf(pFlukaVmcInp,"*No FLUKA card generated\n");
1699 } // else if (strncmp(proc->GetName(),"PHOT",4) == 0)
1702 // Rayleigh scattering
1703 // G3 default value: 0
1704 // G4 process: G4OpRayleigh
1706 // Particles: optical photon
1708 // flag = 0 Rayleigh scattering off
1709 // flag = 1 Rayleigh scattering on
1710 //xx gMC ->SetProcess("RAYL",1);
1711 else if (strncmp(proc->GetName(),"RAYL",4) == 0) {
1712 if (proc->Flag() == 1) {
1713 fprintf(pFlukaVmcInp,"*\n*Rayleigh scattering is ON by default in FLUKA\n");
1714 fprintf(pFlukaVmcInp,"*No FLUKA card generated\n");
1716 else if (proc->Flag() == 0) {
1717 fprintf(pFlukaVmcInp,"*\n*Rayleigh scattering is set OFF\n");
1718 fprintf(pFlukaVmcInp,"*Generated from call: SetProcess('RAYL',0);\n");
1719 // - one = no Rayleigh scattering and no binding corrections for Compton
1720 // matMin = lower bound of the material indices in which the respective thresholds apply
1721 // matMax = upper bound of the material indices in which the respective thresholds apply
1722 fprintf(pFlukaVmcInp,"EMFRAY %10.1f%10.1f%10.1f%10.1f\n",-one,three,matMin,matMax);
1725 fprintf(pFlukaVmcInp,"*\n*Illegal flag value in SetProcess('RAYL',?) call.\n");
1726 fprintf(pFlukaVmcInp,"*No FLUKA card generated\n");
1728 } // end of else if (strncmp(proc->GetName(),"RAYL",4) == 0)
1731 // synchrotron radiation in magnetic field
1732 // G3 default value: 0
1733 // G4 process: G4SynchrotronRadiation
1737 // flag = 0 no synchrotron radiation
1738 // flag = 1 synchrotron radiation
1739 //xx gMC ->SetProcess("SYNC",1); // synchrotron radiation generation
1740 else if (strncmp(proc->GetName(),"SYNC",4) == 0) {
1741 fprintf(pFlukaVmcInp,"*\n*Synchrotron radiation generation is NOT implemented in FLUKA\n");
1742 fprintf(pFlukaVmcInp,"*No FLUKA card generated\n");
1746 // Automatic calculation of tracking medium parameters
1747 // flag = 0 no automatic calculation
1748 // flag = 1 automatic calculation
1749 //xx gMC ->SetProcess("AUTO",1); // ??? automatic computation of the tracking medium parameters
1750 else if (strncmp(proc->GetName(),"AUTO",4) == 0) {
1751 fprintf(pFlukaVmcInp,"*\n*Automatic calculation of tracking medium parameters is always ON in FLUKA\n");
1752 fprintf(pFlukaVmcInp,"*No FLUKA card generated\n");
1756 // To control energy loss fluctuation model
1757 // flag = 0 Urban model
1758 // flag = 1 PAI model
1759 // flag = 2 PAI+ASHO model (not active at the moment)
1760 //xx gMC ->SetProcess("STRA",1); // ??? energy fluctuation model
1761 else if (strncmp(proc->GetName(),"STRA",4) == 0) {
1762 if (proc->Flag() == 0 || proc->Flag() == 2 || proc->Flag() == 3) {
1763 fprintf(pFlukaVmcInp,"*\n*Ionization energy losses calculation is activated\n");
1764 fprintf(pFlukaVmcInp,"*Generated from call: SetProcess('STRA',n);, n=0,1,2\n");
1765 // one = restricted energy loss fluctuations (for hadrons and muons) switched on
1766 // one = restricted energy loss fluctuations (for e+ and e-) switched on
1767 // one = minimal accuracy
1768 // matMin = lower bound of the material indices in which the respective thresholds apply
1769 // matMax = upper bound of the material indices in which the respective thresholds apply
1770 fprintf(pFlukaVmcInp,"IONFLUCT %10.1f%10.1f%10.1f%10.1f%10.1f\n",one,one,one,matMin,matMax);
1773 fprintf(pFlukaVmcInp,"*\n*Illegal flag value in SetProcess('STRA',?) call.\n");
1774 fprintf(pFlukaVmcInp,"*No FLUKA card generated\n");
1776 } // else if (strncmp(proc->GetName(),"STRA",4) == 0)
1781 else { // processes not yet treated
1783 // light photon absorption (Cerenkov photons)
1784 // it is turned on when Cerenkov process is turned on
1785 // G3 default value: 0
1786 // G4 process: G4OpAbsorption, G4OpBoundaryProcess
1788 // Particles: optical photon
1790 // flag = 0 no absorption of Cerenkov photons
1791 // flag = 1 absorption of Cerenkov photons
1792 // gMC ->SetProcess("LABS",2); // ??? Cerenkov light absorption
1796 cout << "SetProcess for flag=" << proc->GetName() << " value=" << proc->Flag() << " not yet implemented!" << endl;
1798 } //end of loop number of SetProcess calls
1801 // Loop over number of SetCut calls
1804 while ((cut = (TFlukaConfigOption*)nextc())) {
1805 Float_t matMin = three;
1806 Float_t matMax = fLastMaterial;
1807 Bool_t global = kTRUE;
1808 if (cut->Medium() != -1) {
1810 if ((mat = cut->Medium()) >= GetFlukaMaterials()->GetEntries()) continue;
1811 matMin = Float_t(mat);
1814 TGeoMaterial* material = (TGeoMaterial*) (GetFlukaMaterials())->At(GetMaterialIndex(mat));
1815 fprintf(pFlukaVmcInp,"*\n*Material specific cut setting for #%8d %s %s %13.3e\n",
1816 mat, material->GetName(), cut->GetName(), cut->Cut());
1820 // cuts handled in SetProcess calls
1821 if (strncmp(cut->GetName(),"BCUTM",5) == 0) continue;
1822 else if (strncmp(cut->GetName(),"BCUTE",5) == 0) continue;
1823 else if (strncmp(cut->GetName(),"DCUTM",5) == 0) continue;
1824 else if (strncmp(cut->GetName(),"PPCUTM",6) == 0) continue;
1827 // G4 particles: "gamma"
1828 // G3 default value: 0.001 GeV
1829 // gMC ->SetCut("CUTGAM",cut); // cut for gammas
1831 else if (strncmp(cut->GetName(),"CUTGAM",6) == 0 && global) {
1832 fprintf(pFlukaVmcInp,"*\n*Cut for gamma\n");
1833 fprintf(pFlukaVmcInp,"*Generated from call: SetCut('CUTGAM',cut);\n");
1834 fprintf(pFlukaVmcInp,"EMFCUT %10.4g%10.4g%10.1f%10.1f%10.1f%10.1f\n",
1835 zero, cut->Cut(), zero, zero, Float_t(fGeom->NofVolumes()), one);
1837 else if (strncmp(cut->GetName(),"CUTGAM",6) == 0 && !global) {
1838 // loop over materials for EMFCUT FLUKA cards
1839 for (j=0; j < matMax-matMin+1; j++) {
1840 Int_t nreg, imat, *reglist;
1842 imat = (Int_t) matMin + j;
1843 reglist = fGeom->GetMaterialList(imat, nreg);
1844 // loop over regions of a given material
1845 for (Int_t k = 0; k < nreg; k++) {
1847 fprintf(pFlukaVmcInp,"EMFCUT %10.4g%10.4g%10.1f%10.1f%10.1f%10.1f\n", zero, cut->Cut(), zero, ireg, ireg, one);
1850 } // end of else if for gamma
1854 // G4 particles: "e-"
1856 // G3 default value: 0.001 GeV
1857 //gMC ->SetCut("CUTELE",cut); // cut for e+,e-
1858 else if (strncmp(cut->GetName(),"CUTELE",6) == 0 && global) {
1859 fprintf(pFlukaVmcInp,"*\n*Cut for electrons\n");
1860 fprintf(pFlukaVmcInp,"*Generated from call: SetCut('CUTELE',cut);\n");
1861 fprintf(pFlukaVmcInp,"EMFCUT %10.4g%10.4g%10.1f%10.1f%10.1f%10.1f\n",
1862 -cut->Cut(), zero, zero, zero, Float_t(fGeom->NofVolumes()), one);
1864 else if (strncmp(cut->GetName(),"CUTELE",6) == 0 && !global) {
1865 // loop over materials for EMFCUT FLUKA cards
1866 for (j=0; j < matMax-matMin+1; j++) {
1867 Int_t nreg, imat, *reglist;
1869 imat = (Int_t) matMin + j;
1870 reglist = fGeom->GetMaterialList(imat, nreg);
1871 // loop over regions of a given material
1872 for (k=0; k<nreg; k++) {
1874 fprintf(pFlukaVmcInp,"EMFCUT %10.4g%10.4g%10.1f%10.1f%10.1f%10.1f\n", -cut->Cut(), zero, zero, ireg, ireg, one);
1877 } // end of else if for electrons
1881 // G4 particles: of type "baryon", "meson", "nucleus" with zero charge
1882 // G3 default value: 0.01 GeV
1883 //gMC ->SetCut("CUTNEU",cut); // cut for neutral hadrons
1884 else if (strncmp(cut->GetName(),"CUTNEU",6) == 0 && global) {
1885 fprintf(pFlukaVmcInp,"*\n*Cut for neutral hadrons\n");
1886 fprintf(pFlukaVmcInp,"*Generated from call: SetCut('CUTNEU',cut);\n");
1889 // 9.0 = Antineutron
1890 fprintf(pFlukaVmcInp,"PART-THR %10.4g%10.1f%10.1f\n",-cut->Cut(),8.0,9.0);
1892 // 12.0 = Kaon zero long
1893 // 12.0 = Kaon zero long
1894 fprintf(pFlukaVmcInp,"PART-THR %10.4g%10.1f%10.1f\n",-cut->Cut(),12.0,12.0);
1896 // 17.0 = Lambda, 18.0 = Antilambda
1897 // 19.0 = Kaon zero short
1898 fprintf(pFlukaVmcInp,"PART-THR %10.4g%10.1f%10.1f\n",-cut->Cut(),17.0,19.0);
1900 // 22.0 = Sigma zero, Pion zero, Kaon zero
1901 // 25.0 = Antikaon zero
1902 fprintf(pFlukaVmcInp,"PART-THR %10.4g%10.1f%10.1f\n",-cut->Cut(),22.0,25.0);
1904 // 32.0 = Antisigma zero
1905 // 32.0 = Antisigma zero
1906 fprintf(pFlukaVmcInp,"PART-THR %10.4g%10.1f%10.1f\n",-cut->Cut(),32.0,32.0);
1909 // 35.0 = AntiXi zero
1910 fprintf(pFlukaVmcInp,"PART-THR %10.4g%10.1f%10.1f\n",-cut->Cut(),34.0,35.0);
1913 // 48.0 = AntiD zero
1914 fprintf(pFlukaVmcInp,"PART-THR %10.4g%10.1f%10.1f\n",-cut->Cut(),47.0,48.0);
1918 fprintf(pFlukaVmcInp,"PART-THR %10.4g%10.1f%10.1f\n",-cut->Cut(),53.0,53.0);
1920 // 55.0 = Xi'_c zero
1921 // 56.0 = Omega_c zero
1922 fprintf(pFlukaVmcInp,"PART-THR %10.4g%10.1f%10.1f\n",-cut->Cut(),55.0,56.0);
1924 // 59.0 = AntiXi_c zero
1925 // 59.0 = AntiXi_c zero
1926 fprintf(pFlukaVmcInp,"PART-THR %10.4g%10.1f%10.1f\n",-cut->Cut(),59.0,59.0);
1928 // 61.0 = AntiXi'_c zero
1929 // 62.0 = AntiOmega_c zero
1930 fprintf(pFlukaVmcInp,"PART-THR %10.4g%10.1f%10.1f\n",-cut->Cut(),61.0,62.0);
1934 // G4 particles: of type "baryon", "meson", "nucleus" with non-zero charge
1935 // G3 default value: 0.01 GeV
1936 //gMC ->SetCut("CUTHAD",cut); // cut for charged hadrons
1937 else if (strncmp(cut->GetName(),"CUTHAD",6) == 0 && global) {
1938 fprintf(pFlukaVmcInp,"*\n*Cut for charged hadrons\n");
1939 fprintf(pFlukaVmcInp,"*Generated from call: SetCut('CUTHAD',cut);\n");
1943 fprintf(pFlukaVmcInp,"PART-THR %10.4g%10.1f%10.1f\n",-cut->Cut(),1.0,2.0);
1945 // 13.0 = Positive Pion, Negative Pion, Positive Kaon
1946 // 16.0 = Negative Kaon
1947 fprintf(pFlukaVmcInp,"PART-THR %10.4g%10.1f%10.1f\n",-cut->Cut(),13.0,16.0);
1949 // 20.0 = Negative Sigma
1950 // 21.0 = Positive Sigma
1951 fprintf(pFlukaVmcInp,"PART-THR %10.4g%10.1f%10.1f\n",-cut->Cut(),20.0,21.0);
1953 // 31.0 = Antisigma minus
1954 // 33.0 = Antisigma plus
1955 // 2.0 = step length
1956 fprintf(pFlukaVmcInp,"PART-THR %10.4g%10.1f%10.1f%10.1f\n",-cut->Cut(),31.0,33.0,2.0);
1958 // 36.0 = Negative Xi, Positive Xi, Omega minus
1960 fprintf(pFlukaVmcInp,"PART-THR %10.4g%10.1f%10.1f\n",-cut->Cut(),36.0,39.0);
1964 fprintf(pFlukaVmcInp,"PART-THR %10.4g%10.1f%10.1f\n",-cut->Cut(),45.0,46.0);
1966 // 49.0 = D_s plus, D_s minus, Lambda_c plus
1968 fprintf(pFlukaVmcInp,"PART-THR %10.4g%10.1f%10.1f\n",-cut->Cut(),49.0,52.0);
1970 // 54.0 = Xi'_c plus
1971 // 60.0 = AntiXi'_c minus
1972 // 6.0 = step length
1973 fprintf(pFlukaVmcInp,"PART-THR %10.4g%10.1f%10.1f%10.1f\n",-cut->Cut(),54.0,60.0,6.0);
1975 // 57.0 = Antilambda_c minus
1976 // 58.0 = AntiXi_c minus
1977 fprintf(pFlukaVmcInp,"PART-THR %10.4g%10.1f%10.1f\n",-cut->Cut(),57.0,58.0);
1981 // G4 particles: "mu+", "mu-"
1982 // G3 default value: 0.01 GeV
1983 //gMC ->SetCut("CUTMUO",cut); // cut for mu+, mu-
1984 else if (strncmp(cut->GetName(),"CUTMUO",6)== 0 && global) {
1985 fprintf(pFlukaVmcInp,"*\n*Cut for muons\n");
1986 fprintf(pFlukaVmcInp,"*Generated from call: SetCut('CUTMUO',cut);\n");
1989 fprintf(pFlukaVmcInp,"PART-THR %10.4g%10.1f%10.1f\n",-cut->Cut(),10.0,11.0);
1993 // time of flight cut in seconds
1994 // G4 particles: all
1995 // G3 default value: 0.01 GeV
1996 //gMC ->SetCut("TOFMAX",tofmax); // time of flight cuts in seconds
1997 else if (strncmp(cut->GetName(),"TOFMAX",6) == 0) {
1998 fprintf(pFlukaVmcInp,"*\n*Time of flight cuts in seconds\n");
1999 fprintf(pFlukaVmcInp,"*Generated from call: SetCut('TOFMAX',tofmax);\n");
2002 // -6.0 = lower bound of the particle numbers for which the transport time cut-off and/or the start signal is to be applied
2003 // 64.0 = upper bound of the particle numbers for which the transport time cut-off and/or the start signal is to be applied
2004 fprintf(pFlukaVmcInp,"TIME-CUT %10.4g%10.1f%10.1f%10.1f%10.1f\n",cut->Cut()*1.e9,zero,zero,-6.0,64.0);
2008 cout << "SetCut for flag=" << cut->GetName() << " value=" << cut->Cut() << " not yet implemented!" << endl;
2011 cout << "SetCut for flag=" << cut->GetName() << " value=" << cut->Cut() << " (material specific) not yet implemented!" << endl;
2014 } //end of loop over SetCut calls
2016 // Add START and STOP card
2017 fprintf(pFlukaVmcInp,"START %10.1f\n",fEventsPerRun);
2018 fprintf(pFlukaVmcInp,"STOP \n");
2023 fclose(pFlukaVmcCoreInp);
2024 fclose(pFlukaVmcFlukaMat);
2025 fclose(pFlukaVmcInp);
2027 } // end of InitPhysics
2030 //______________________________________________________________________________
2031 void TFluka::SetMaxStep(Double_t step)
2033 // Set the maximum step size
2034 if (step > 1.e4) return;
2037 fGeom->GetCurrentRegion(mreg, latt);
2038 STEPSZ.stepmx[mreg - 1] = step;
2042 Double_t TFluka::MaxStep() const
2044 // Return the maximum for current medium
2046 fGeom->GetCurrentRegion(mreg, latt);
2047 return (STEPSZ.stepmx[mreg - 1]);
2050 //______________________________________________________________________________
2051 void TFluka::SetMaxNStep(Int_t)
2053 // SetMaxNStep is dummy procedure in TFluka !
2054 if (fVerbosityLevel >=3)
2055 cout << "SetMaxNStep is dummy procedure in TFluka !" << endl;
2058 //______________________________________________________________________________
2059 void TFluka::SetUserDecay(Int_t)
2061 // SetUserDecay is dummy procedure in TFluka !
2062 if (fVerbosityLevel >=3)
2063 cout << "SetUserDecay is dummy procedure in TFluka !" << endl;
2067 // dynamic properties
2069 //______________________________________________________________________________
2070 void TFluka::TrackPosition(TLorentzVector& position) const
2072 // Return the current position in the master reference frame of the
2073 // track being transported
2074 // TRACKR.atrack = age of the particle
2075 // TRACKR.xtrack = x-position of the last point
2076 // TRACKR.ytrack = y-position of the last point
2077 // TRACKR.ztrack = z-position of the last point
2078 Int_t caller = GetCaller();
2079 if (caller == 3 || caller == 6 || caller == 11 || caller == 12) { //bxdraw,endraw,usdraw
2080 position.SetX(GetXsco());
2081 position.SetY(GetYsco());
2082 position.SetZ(GetZsco());
2083 position.SetT(TRACKR.atrack);
2085 else if (caller == 4) { // mgdraw
2086 position.SetX(TRACKR.xtrack[TRACKR.ntrack]);
2087 position.SetY(TRACKR.ytrack[TRACKR.ntrack]);
2088 position.SetZ(TRACKR.ztrack[TRACKR.ntrack]);
2089 position.SetT(TRACKR.atrack);
2091 else if (caller == 5) { // sodraw
2092 position.SetX(TRACKR.xtrack[TRACKR.ntrack]);
2093 position.SetY(TRACKR.ytrack[TRACKR.ntrack]);
2094 position.SetZ(TRACKR.ztrack[TRACKR.ntrack]);
2098 Warning("TrackPosition","position not available");
2101 //______________________________________________________________________________
2102 void TFluka::TrackPosition(Double_t& x, Double_t& y, Double_t& z) const
2104 // Return the current position in the master reference frame of the
2105 // track being transported
2106 // TRACKR.atrack = age of the particle
2107 // TRACKR.xtrack = x-position of the last point
2108 // TRACKR.ytrack = y-position of the last point
2109 // TRACKR.ztrack = z-position of the last point
2110 Int_t caller = GetCaller();
2111 if (caller == 3 || caller == 6 || caller == 11 || caller == 12) { //bxdraw,endraw,usdraw
2116 else if (caller == 4 || caller == 5) { // mgdraw, sodraw
2117 x = TRACKR.xtrack[TRACKR.ntrack];
2118 y = TRACKR.ytrack[TRACKR.ntrack];
2119 z = TRACKR.ztrack[TRACKR.ntrack];
2122 Warning("TrackPosition","position not available");
2125 //______________________________________________________________________________
2126 void TFluka::TrackMomentum(TLorentzVector& momentum) const
2128 // Return the direction and the momentum (GeV/c) of the track
2129 // currently being transported
2130 // TRACKR.ptrack = momentum of the particle (not always defined, if
2131 // < 0 must be obtained from etrack)
2132 // TRACKR.cx,y,ztrck = direction cosines of the current particle
2133 // TRACKR.etrack = total energy of the particle
2134 // TRACKR.jtrack = identity number of the particle
2135 // PAPROP.am[TRACKR.jtrack] = particle mass in gev
2136 Int_t caller = GetCaller();
2137 if (caller != 2) { // not eedraw
2138 if (TRACKR.ptrack >= 0) {
2139 momentum.SetPx(TRACKR.ptrack*TRACKR.cxtrck);
2140 momentum.SetPy(TRACKR.ptrack*TRACKR.cytrck);
2141 momentum.SetPz(TRACKR.ptrack*TRACKR.cztrck);
2142 momentum.SetE(TRACKR.etrack);
2146 Double_t p = sqrt(TRACKR.etrack*TRACKR.etrack - PAPROP.am[TRACKR.jtrack+6]*PAPROP.am[TRACKR.jtrack+6]);
2147 momentum.SetPx(p*TRACKR.cxtrck);
2148 momentum.SetPy(p*TRACKR.cytrck);
2149 momentum.SetPz(p*TRACKR.cztrck);
2150 momentum.SetE(TRACKR.etrack);
2155 Warning("TrackMomentum","momentum not available");
2158 //______________________________________________________________________________
2159 void TFluka::TrackMomentum(Double_t& px, Double_t& py, Double_t& pz, Double_t& e) const
2161 // Return the direction and the momentum (GeV/c) of the track
2162 // currently being transported
2163 // TRACKR.ptrack = momentum of the particle (not always defined, if
2164 // < 0 must be obtained from etrack)
2165 // TRACKR.cx,y,ztrck = direction cosines of the current particle
2166 // TRACKR.etrack = total energy of the particle
2167 // TRACKR.jtrack = identity number of the particle
2168 // PAPROP.am[TRACKR.jtrack] = particle mass in gev
2169 Int_t caller = GetCaller();
2170 if (caller != 2) { // not eedraw
2171 if (TRACKR.ptrack >= 0) {
2172 px = TRACKR.ptrack*TRACKR.cxtrck;
2173 py = TRACKR.ptrack*TRACKR.cytrck;
2174 pz = TRACKR.ptrack*TRACKR.cztrck;
2179 Double_t p = sqrt(TRACKR.etrack*TRACKR.etrack - PAPROP.am[TRACKR.jtrack+6]*PAPROP.am[TRACKR.jtrack+6]);
2180 px = p*TRACKR.cxtrck;
2181 py = p*TRACKR.cytrck;
2182 pz = p*TRACKR.cztrck;
2188 Warning("TrackMomentum","momentum not available");
2191 //______________________________________________________________________________
2192 Double_t TFluka::TrackStep() const
2194 // Return the length in centimeters of the current step
2195 // TRACKR.ctrack = total curved path
2196 Int_t caller = GetCaller();
2197 if (caller == 11 || caller==12 || caller == 3 || caller == 6) //bxdraw,endraw,usdraw
2199 else if (caller == 4) //mgdraw
2200 return TRACKR.ctrack;
2205 //______________________________________________________________________________
2206 Double_t TFluka::TrackLength() const
2208 // TRACKR.cmtrck = cumulative curved path since particle birth
2209 Int_t caller = GetCaller();
2210 if (caller == 11 || caller==12 || caller == 3 || caller == 4 || caller == 6) //bxdraw,endraw,mgdraw,usdraw
2211 return TRACKR.cmtrck;
2216 //______________________________________________________________________________
2217 Double_t TFluka::TrackTime() const
2219 // Return the current time of flight of the track being transported
2220 // TRACKR.atrack = age of the particle
2221 Int_t caller = GetCaller();
2222 if (caller == 11 || caller==12 || caller == 3 || caller == 4 || caller == 6) //bxdraw,endraw,mgdraw,usdraw
2223 return TRACKR.atrack;
2228 //______________________________________________________________________________
2229 Double_t TFluka::Edep() const
2231 // Energy deposition
2232 // if TRACKR.ntrack = 0, TRACKR.mtrack = 0:
2233 // -->local energy deposition (the value and the point are not recorded in TRACKR)
2234 // but in the variable "rull" of the procedure "endraw.cxx"
2235 // if TRACKR.ntrack > 0, TRACKR.mtrack = 0:
2236 // -->no energy loss along the track
2237 // if TRACKR.ntrack > 0, TRACKR.mtrack > 0:
2238 // -->energy loss distributed along the track
2239 // TRACKR.dtrack = energy deposition of the jth deposition event
2241 // If coming from bxdraw we have 2 steps of 0 length and 0 edep
2242 Int_t caller = GetCaller();
2243 if (caller == 11 || caller==12) return 0.0;
2245 for ( Int_t j=0;j<TRACKR.mtrack;j++) {
2246 sum +=TRACKR.dtrack[j];
2248 if (TRACKR.ntrack == 0 && TRACKR.mtrack == 0)
2255 //______________________________________________________________________________
2256 Int_t TFluka::TrackPid() const
2258 // Return the id of the particle transported
2259 // TRACKR.jtrack = identity number of the particle
2260 Int_t caller = GetCaller();
2261 if (caller != 2) { // not eedraw
2262 return PDGFromId(TRACKR.jtrack);
2268 //______________________________________________________________________________
2269 Double_t TFluka::TrackCharge() const
2271 // Return charge of the track currently transported
2272 // PAPROP.ichrge = electric charge of the particle
2273 // TRACKR.jtrack = identity number of the particle
2274 Int_t caller = GetCaller();
2275 if (caller != 2) // not eedraw
2276 return PAPROP.ichrge[TRACKR.jtrack+6];
2281 //______________________________________________________________________________
2282 Double_t TFluka::TrackMass() const
2284 // PAPROP.am = particle mass in GeV
2285 // TRACKR.jtrack = identity number of the particle
2286 Int_t caller = GetCaller();
2287 if (caller != 2) // not eedraw
2288 return PAPROP.am[TRACKR.jtrack+6];
2293 //______________________________________________________________________________
2294 Double_t TFluka::Etot() const
2296 // TRACKR.etrack = total energy of the particle
2297 Int_t caller = GetCaller();
2298 if (caller != 2) // not eedraw
2299 return TRACKR.etrack;
2307 //______________________________________________________________________________
2308 Bool_t TFluka::IsNewTrack() const
2310 // Return true for the first call of Stepping()
2314 void TFluka::SetTrackIsNew(Bool_t flag)
2316 // Return true for the first call of Stepping()
2322 //______________________________________________________________________________
2323 Bool_t TFluka::IsTrackInside() const
2325 // True if the track is not at the boundary of the current volume
2326 // In Fluka a step is always inside one kind of material
2327 // If the step would go behind the region of one material,
2328 // it will be shortened to reach only the boundary.
2329 // Therefore IsTrackInside() is always true.
2330 Int_t caller = GetCaller();
2331 if (caller == 11 || caller==12) // bxdraw
2337 //______________________________________________________________________________
2338 Bool_t TFluka::IsTrackEntering() const
2340 // True if this is the first step of the track in the current volume
2342 Int_t caller = GetCaller();
2343 if (caller == 11) // bxdraw entering
2348 //______________________________________________________________________________
2349 Bool_t TFluka::IsTrackExiting() const
2351 // True if track is exiting volume
2353 Int_t caller = GetCaller();
2354 if (caller == 12) // bxdraw exiting
2359 //______________________________________________________________________________
2360 Bool_t TFluka::IsTrackOut() const
2362 // True if the track is out of the setup
2364 // Icode = 14: escape - call from Kaskad
2365 // Icode = 23: escape - call from Emfsco
2366 // Icode = 32: escape - call from Kasneu
2367 // Icode = 40: escape - call from Kashea
2368 // Icode = 51: escape - call from Kasoph
2373 fIcode == 51) return 1;
2377 //______________________________________________________________________________
2378 Bool_t TFluka::IsTrackDisappeared() const
2380 // means all inelastic interactions and decays
2381 // fIcode from usdraw
2382 if (fIcode == 101 || // inelastic interaction
2383 fIcode == 102 || // particle decay
2384 fIcode == 103 || // delta ray generation by hadron
2385 fIcode == 104 || // direct pair production
2386 fIcode == 105 || // bremsstrahlung (muon)
2387 fIcode == 208 || // bremsstrahlung (electron)
2388 fIcode == 214 || // in-flight annihilation
2389 fIcode == 215 || // annihilation at rest
2390 fIcode == 217 || // pair production
2391 fIcode == 219 || // Compton scattering
2392 fIcode == 221 || // Photoelectric effect
2393 fIcode == 300 || // hadronic interaction
2394 fIcode == 400 // delta-ray
2399 //______________________________________________________________________________
2400 Bool_t TFluka::IsTrackStop() const
2402 // True if the track energy has fallen below the threshold
2403 // means stopped by signal or below energy threshold
2404 // Icode = 12: stopping particle - call from Kaskad
2405 // Icode = 15: time kill - call from Kaskad
2406 // Icode = 21: below threshold, iarg=1 - call from Emfsco
2407 // Icode = 22: below threshold, iarg=2 - call from Emfsco
2408 // Icode = 24: time kill - call from Emfsco
2409 // Icode = 31: below threshold - call from Kasneu
2410 // Icode = 33: time kill - call from Kasneu
2411 // Icode = 41: time kill - call from Kashea
2412 // Icode = 52: time kill - call from Kasoph
2421 fIcode == 52) return 1;
2425 //______________________________________________________________________________
2426 Bool_t TFluka::IsTrackAlive() const
2428 // means not disappeared or not out
2429 if (IsTrackDisappeared() || IsTrackOut() ) return 0;
2437 //______________________________________________________________________________
2438 Int_t TFluka::NSecondaries() const
2441 // Number of secondary particles generated in the current step
2442 // FINUC.np = number of secondaries except light and heavy ions
2443 // FHEAVY.npheav = number of secondaries for light and heavy secondary ions
2444 Int_t caller = GetCaller();
2445 if (caller == 6) // valid only after usdraw
2446 return FINUC.np + FHEAVY.npheav;
2447 else if (caller == 50) {
2448 // Cerenkov Photon production
2452 } // end of NSecondaries
2454 //______________________________________________________________________________
2455 void TFluka::GetSecondary(Int_t isec, Int_t& particleId,
2456 TLorentzVector& position, TLorentzVector& momentum)
2458 // Copy particles from secondary stack to vmc stack
2461 Int_t caller = GetCaller();
2462 if (caller == 6) { // valid only after usdraw
2464 // Hadronic interaction
2465 if (isec >= 0 && isec < FINUC.np) {
2466 particleId = PDGFromId(FINUC.kpart[isec]);
2467 position.SetX(fXsco);
2468 position.SetY(fYsco);
2469 position.SetZ(fZsco);
2470 position.SetT(TRACKR.atrack);
2471 momentum.SetPx(FINUC.plr[isec]*FINUC.cxr[isec]);
2472 momentum.SetPy(FINUC.plr[isec]*FINUC.cyr[isec]);
2473 momentum.SetPz(FINUC.plr[isec]*FINUC.czr[isec]);
2474 momentum.SetE(FINUC.tki[isec] + PAPROP.am[FINUC.kpart[isec]+6]);
2476 else if (isec >= FINUC.np && isec < FINUC.np + FHEAVY.npheav) {
2477 Int_t jsec = isec - FINUC.np;
2478 particleId = FHEAVY.kheavy[jsec]; // this is Fluka id !!!
2479 position.SetX(fXsco);
2480 position.SetY(fYsco);
2481 position.SetZ(fZsco);
2482 position.SetT(TRACKR.atrack);
2483 momentum.SetPx(FHEAVY.pheavy[jsec]*FHEAVY.cxheav[jsec]);
2484 momentum.SetPy(FHEAVY.pheavy[jsec]*FHEAVY.cyheav[jsec]);
2485 momentum.SetPz(FHEAVY.pheavy[jsec]*FHEAVY.czheav[jsec]);
2486 if (FHEAVY.tkheav[jsec] >= 3 && FHEAVY.tkheav[jsec] <= 6)
2487 momentum.SetE(FHEAVY.tkheav[jsec] + PAPROP.am[jsec+6]);
2488 else if (FHEAVY.tkheav[jsec] > 6)
2489 momentum.SetE(FHEAVY.tkheav[jsec] + FHEAVY.amnhea[jsec]); // to be checked !!!
2492 Warning("GetSecondary","isec out of range");
2494 } else if (caller == 50) {
2495 Int_t index = OPPHST.lstopp - isec;
2496 position.SetX(OPPHST.xoptph[index]);
2497 position.SetY(OPPHST.yoptph[index]);
2498 position.SetZ(OPPHST.zoptph[index]);
2499 position.SetT(OPPHST.agopph[index]);
2500 Double_t p = OPPHST.poptph[index];
2502 momentum.SetPx(p * OPPHST.txopph[index]);
2503 momentum.SetPy(p * OPPHST.tyopph[index]);
2504 momentum.SetPz(p * OPPHST.tzopph[index]);
2508 Warning("GetSecondary","no secondaries available");
2510 } // end of GetSecondary
2513 //______________________________________________________________________________
2514 TMCProcess TFluka::ProdProcess(Int_t) const
2517 // Name of the process that has produced the secondary particles
2518 // in the current step
2520 Int_t mugamma = (TRACKR.jtrack == 7 || TRACKR.jtrack == 10 || TRACKR.jtrack == 11);
2522 if (fIcode == 102) return kPDecay;
2523 else if (fIcode == 104 || fIcode == 217) return kPPair;
2524 else if (fIcode == 219) return kPCompton;
2525 else if (fIcode == 221) return kPPhotoelectric;
2526 else if (fIcode == 105 || fIcode == 208) return kPBrem;
2527 else if (fIcode == 103 || fIcode == 400) return kPDeltaRay;
2528 else if (fIcode == 210 || fIcode == 212) return kPDeltaRay;
2529 else if (fIcode == 214 || fIcode == 215) return kPAnnihilation;
2530 else if (fIcode == 101) return kPHadronic;
2531 else if (fIcode == 101) {
2532 if (!mugamma) return kPHadronic;
2533 else if (TRACKR.jtrack == 7) return kPPhotoFission;
2534 else return kPMuonNuclear;
2536 else if (fIcode == 225) return kPRayleigh;
2537 // Fluka codes 100, 300 and 400 still to be investigasted
2538 else return kPNoProcess;
2542 Int_t TFluka::StepProcesses(TArrayI &proc) const
2545 // Return processes active in the current step
2569 iproc = kPLightAbsorption;
2572 iproc = kPLightRefraction;
2574 iproc = kPPhotoelectric;
2577 iproc = ProdProcess(0);
2582 //______________________________________________________________________________
2583 Int_t TFluka::VolId2Mate(Int_t id) const
2586 // Returns the material number for a given volume ID
2588 return fMCGeo->VolId2Mate(id);
2591 //______________________________________________________________________________
2592 const char* TFluka::VolName(Int_t id) const
2595 // Returns the volume name for a given volume ID
2597 return fMCGeo->VolName(id);
2600 //______________________________________________________________________________
2601 Int_t TFluka::VolId(const Text_t* volName) const
2604 // Converts from volume name to volume ID.
2605 // Time consuming. (Only used during set-up)
2606 // Could be replaced by hash-table
2608 return fMCGeo->VolId(volName);
2611 //______________________________________________________________________________
2612 Int_t TFluka::CurrentVolID(Int_t& copyNo) const
2615 // Return the logical id and copy number corresponding to the current fluka region
2617 if (gGeoManager->IsOutside()) return 0;
2618 TGeoNode *node = gGeoManager->GetCurrentNode();
2619 copyNo = node->GetNumber();
2620 Int_t id = node->GetVolume()->GetNumber();
2624 //______________________________________________________________________________
2625 Int_t TFluka::CurrentVolOffID(Int_t off, Int_t& copyNo) const
2628 // Return the logical id and copy number of off'th mother
2629 // corresponding to the current fluka region
2631 if (off<0 || off>gGeoManager->GetLevel()) return 0;
2632 if (off==0) return CurrentVolID(copyNo);
2633 TGeoNode *node = gGeoManager->GetMother(off);
2634 if (!node) return 0;
2635 copyNo = node->GetNumber();
2636 return node->GetVolume()->GetNumber();
2639 //______________________________________________________________________________
2640 const char* TFluka::CurrentVolName() const
2643 // Return the current volume name
2645 if (gGeoManager->IsOutside()) return 0;
2646 return gGeoManager->GetCurrentVolume()->GetName();
2649 //______________________________________________________________________________
2650 const char* TFluka::CurrentVolOffName(Int_t off) const
2653 // Return the volume name of the off'th mother of the current volume
2655 if (off<0 || off>gGeoManager->GetLevel()) return 0;
2656 if (off==0) return CurrentVolName();
2657 TGeoNode *node = gGeoManager->GetMother(off);
2658 if (!node) return 0;
2659 return node->GetVolume()->GetName();
2662 //______________________________________________________________________________
2663 Int_t TFluka::CurrentMaterial(Float_t & a, Float_t & z,
2664 Float_t & dens, Float_t & radl, Float_t & absl) const
2667 // Return the current medium number and material properties
2670 Int_t id = TFluka::CurrentVolID(copy);
2671 Int_t med = TFluka::VolId2Mate(id);
2672 TGeoVolume* vol = gGeoManager->GetCurrentVolume();
2673 TGeoMaterial* mat = vol->GetMaterial();
2676 dens = mat->GetDensity();
2677 radl = mat->GetRadLen();
2678 absl = mat->GetIntLen();
2683 //______________________________________________________________________________
2684 void TFluka::Gmtod(Float_t* xm, Float_t* xd, Int_t iflag)
2686 // Transforms a position from the world reference frame
2687 // to the current volume reference frame.
2689 // Geant3 desription:
2690 // ==================
2691 // Computes coordinates XD (in DRS)
2692 // from known coordinates XM in MRS
2693 // The local reference system can be initialized by
2694 // - the tracking routines and GMTOD used in GUSTEP
2695 // - a call to GMEDIA(XM,NUMED)
2696 // - a call to GLVOLU(NLEVEL,NAMES,NUMBER,IER)
2697 // (inverse routine is GDTOM)
2699 // If IFLAG=1 convert coordinates
2700 // IFLAG=2 convert direction cosinus
2703 Double_t xmL[3], xdL[3];
2705 for (i=0;i<3;i++) xmL[i]=xm[i];
2706 if (iflag == 1) gGeoManager->MasterToLocal(xmL,xdL);
2707 else gGeoManager->MasterToLocalVect(xmL,xdL);
2708 for (i=0;i<3;i++) xd[i] = xdL[i];
2711 //______________________________________________________________________________
2712 void TFluka::Gmtod(Double_t* xm, Double_t* xd, Int_t iflag)
2714 if (iflag == 1) gGeoManager->MasterToLocal(xm,xd);
2715 else gGeoManager->MasterToLocalVect(xm,xd);
2718 //______________________________________________________________________________
2719 void TFluka::Gdtom(Float_t* xd, Float_t* xm, Int_t iflag)
2721 // Transforms a position from the current volume reference frame
2722 // to the world reference frame.
2724 // Geant3 desription:
2725 // ==================
2726 // Computes coordinates XM (Master Reference System
2727 // knowing the coordinates XD (Detector Ref System)
2728 // The local reference system can be initialized by
2729 // - the tracking routines and GDTOM used in GUSTEP
2730 // - a call to GSCMED(NLEVEL,NAMES,NUMBER)
2731 // (inverse routine is GMTOD)
2733 // If IFLAG=1 convert coordinates
2734 // IFLAG=2 convert direction cosinus
2737 Double_t xmL[3], xdL[3];
2739 for (i=0;i<3;i++) xdL[i] = xd[i];
2740 if (iflag == 1) gGeoManager->LocalToMaster(xdL,xmL);
2741 else gGeoManager->LocalToMasterVect(xdL,xmL);
2742 for (i=0;i<3;i++) xm[i]=xmL[i];
2745 //______________________________________________________________________________
2746 void TFluka::Gdtom(Double_t* xd, Double_t* xm, Int_t iflag)
2748 if (iflag == 1) gGeoManager->LocalToMaster(xd,xm);
2749 else gGeoManager->LocalToMasterVect(xd,xm);
2752 //______________________________________________________________________________
2753 TObjArray *TFluka::GetFlukaMaterials()
2755 return fGeom->GetMatList();
2758 //______________________________________________________________________________
2759 void TFluka::SetMreg(Int_t l)
2761 // Set current fluka region
2762 fCurrentFlukaRegion = l;
2769 TString TFluka::ParticleName(Int_t pdg) const
2771 // Return particle name for particle with pdg code pdg.
2772 Int_t ifluka = IdFromPDG(pdg);
2773 return TString((CHPPRP.btype[ifluka+6]), 8);
2777 Double_t TFluka::ParticleMass(Int_t pdg) const
2779 // Return particle mass for particle with pdg code pdg.
2780 Int_t ifluka = IdFromPDG(pdg);
2781 return (PAPROP.am[ifluka+6]);
2784 Double_t TFluka::ParticleCharge(Int_t pdg) const
2786 // Return particle charge for particle with pdg code pdg.
2787 Int_t ifluka = IdFromPDG(pdg);
2788 return Double_t(PAPROP.ichrge[ifluka+6]);
2791 Double_t TFluka::ParticleLifeTime(Int_t pdg) const
2793 // Return particle lifetime for particle with pdg code pdg.
2794 Int_t ifluka = IdFromPDG(pdg);
2795 return (PAPROP.thalf[ifluka+6]);
2798 void TFluka::Gfpart(Int_t pdg, char* name, Int_t& type, Float_t& mass, Float_t& charge, Float_t& tlife)
2800 // Retrieve particle properties for particle with pdg code pdg.
2802 strcpy(name, ParticleName(pdg).Data());
2803 type = ParticleMCType(pdg);
2804 mass = ParticleMass(pdg);
2805 charge = ParticleCharge(pdg);
2806 tlife = ParticleLifeTime(pdg);
2811 #define pushcerenkovphoton pushcerenkovphoton_
2812 #define usersteppingckv usersteppingckv_
2816 void pushcerenkovphoton(Double_t & px, Double_t & py, Double_t & pz, Double_t & e,
2817 Double_t & vx, Double_t & vy, Double_t & vz, Double_t & tof,
2818 Double_t & polx, Double_t & poly, Double_t & polz, Double_t & wgt, Int_t& ntr)
2821 // Pushes one cerenkov photon to the stack
2824 TFluka* fluka = (TFluka*) gMC;
2825 TVirtualMCStack* cppstack = fluka->GetStack();
2826 Int_t parent = TRACKR.ispusr[mkbmx2-1];
2827 cppstack->PushTrack(0, parent, 50000050,
2831 kPCerenkov, ntr, wgt, 0);
2834 void usersteppingckv(Int_t & nphot, Int_t & mreg, Double_t & x, Double_t & y, Double_t & z)
2837 // Calls stepping in order to signal cerenkov production
2839 TFluka *fluka = (TFluka*)gMC;
2840 fluka->SetMreg(mreg);
2844 fluka->SetNCerenkov(nphot);
2845 fluka->SetCaller(50);
2846 printf("userstepping ckv: %10d %10d %13.3f %13.3f %13.2f\n", nphot, mreg, x, y, z);
2847 (TVirtualMCApplication::Instance())->Stepping();