X-Git-Url: http://git.uio.no/git/?a=blobdiff_plain;ds=sidebyside;f=TFluka%2FTFluka.cxx;h=2f828adf8f5f4dc38fc395a26f84bbba91982410;hb=71dd9297177fd2e7cd8b275289bf30c0ed4ced2e;hp=b25cc8bd39b4bfdc84facc9c99cf91332881699e;hpb=fbf0810080d65739d2b79701ead4e046daeca471;p=u%2Fmrichter%2FAliRoot.git diff --git a/TFluka/TFluka.cxx b/TFluka/TFluka.cxx index b25cc8bd39b..2f828adf8f5 100644 --- a/TFluka/TFluka.cxx +++ b/TFluka/TFluka.cxx @@ -15,42 +15,68 @@ /* $Id$ */ +// +// Realisation of the TVirtualMC interface for the FLUKA code +// (See official web side http://www.fluka.org/). +// +// This implementation makes use of the TGeo geometry modeller. +// User configuration is via automatic generation of FLUKA input cards. +// +// Authors: +// A. Fasso +// E. Futo +// A. Gheata +// A. Morsch +// + #include -#include "TClonesArray.h" #include "TFluka.h" #include "TCallf77.h" //For the fortran calls #include "Fdblprc.h" //(DBLPRC) fluka common #include "Fepisor.h" //(EPISOR) fluka common -#include "Ffinuc.h" //(FINUC) fluka common +#include "Ffinuc.h" //(FINUC) fluka common #include "Fiounit.h" //(IOUNIT) fluka common #include "Fpaprop.h" //(PAPROP) fluka common #include "Fpart.h" //(PART) fluka common #include "Ftrackr.h" //(TRACKR) fluka common #include "Fpaprop.h" //(PAPROP) fluka common #include "Ffheavy.h" //(FHEAVY) fluka common +#include "Fopphst.h" //(OPPHST) fluka common +#include "Fstack.h" //(STACK) fluka common +#include "Fstepsz.h" //(STEPSZ) fluka common +#include "Fopphst.h" //(OPPHST) fluka common #include "TVirtualMC.h" -#include "TG4GeometryManager.h" //For the geometry management -#include "TG4DetConstruction.h" //For the detector construction - -#include "FGeometryInit.hh" +#include "TMCProcess.h" +#include "TGeoManager.h" +#include "TGeoMaterial.h" +#include "TGeoMedium.h" +#include "TFlukaMCGeometry.h" +#include "TGeoMCGeometry.h" +#include "TFlukaCerenkov.h" +#include "TFlukaConfigOption.h" +#include "TFlukaScoringOption.h" #include "TLorentzVector.h" -#include "FlukaVolume.h" +#include "TArrayI.h" // Fluka methods that may be needed. #ifndef WIN32 # define flukam flukam_ # define fluka_openinp fluka_openinp_ +# define fluka_openout fluka_openout_ # define fluka_closeinp fluka_closeinp_ # define mcihad mcihad_ # define mpdgha mpdgha_ +# define newplo newplo_ #else # define flukam FLUKAM # define fluka_openinp FLUKA_OPENINP +# define fluka_openout FLUKA_OPENOUT # define fluka_closeinp FLUKA_CLOSEINP # define mcihad MCIHAD # define mpdgha MPDGHA +# define newplo NEWPLO #endif extern "C" @@ -59,7 +85,9 @@ extern "C" // Prototypes for FLUKA functions // void type_of_call flukam(const int&); + void type_of_call newplo(); void type_of_call fluka_openinp(const int&, DEFCHARA); + void type_of_call fluka_openout(const int&, DEFCHARA); void type_of_call fluka_closeinp(const int&); int type_of_call mcihad(const int&); int type_of_call mpdgha(const int&); @@ -73,166 +101,228 @@ ClassImp(TFluka) // //---------------------------------------------------------------------------- // TFluka constructors and destructors. -//____________________________________________________________________________ +//______________________________________________________________________________ TFluka::TFluka() :TVirtualMC(), fVerbosityLevel(0), - sInputFileName(""), - fDetector(0), - fCurrentFlukaRegion(-1) + fInputFileName(""), + fUserConfig(0), + fUserScore(0) { // // Default constructor // + fGeneratePemf = kFALSE; + fNVolumes = 0; + fCurrentFlukaRegion = -1; + fGeom = 0; + fMCGeo = 0; + fMaterials = 0; + fDummyBoundary = 0; + fFieldFlag = 1; + fStopped = 0; + fStopEvent = 0; + fStopRun = 0; + fNEvent = 0; } +//______________________________________________________________________________ TFluka::TFluka(const char *title, Int_t verbosity, Bool_t isRootGeometrySupported) :TVirtualMC("TFluka",title, isRootGeometrySupported), fVerbosityLevel(verbosity), - sInputFileName(""), + fInputFileName(""), fTrackIsEntering(0), fTrackIsExiting(0), fTrackIsNew(0), - fDetector(0), - fCurrentFlukaRegion(-1) + fUserConfig(new TObjArray(100)), + fUserScore(new TObjArray(100)) { - if (fVerbosityLevel >=3) - cout << "==> TFluka::TFluka(" << title << ") constructor called." << endl; - - - // create geometry manager - if (fVerbosityLevel >=2) - cout << "\t* Creating G4 Geometry manager..." << endl; - fGeometryManager = new TG4GeometryManager(); - if (fVerbosityLevel >=2) - cout << "\t* Creating G4 Detector..." << endl; - fDetector = new TG4DetConstruction(); - FGeometryInit* geominit = FGeometryInit::GetInstance(); - if (geominit) - geominit->setDetConstruction(fDetector); - else { - cerr << "ERROR: Could not create FGeometryInit!" << endl; - cerr << " Exiting!!!" << endl; - abort(); - } - - if (fVerbosityLevel >=3) - cout << "<== TFluka::TFluka(" << title << ") constructor called." << endl; - - fVolumeMediaMap = new TClonesArray("FlukaVolume",1000); - fNVolumes = 0; - fMediaByRegion = 0; + // create geometry interface + if (fVerbosityLevel >=3) + cout << "<== TFluka::TFluka(" << title << ") constructor called." << endl; + SetCoreInputFileName(); + SetInputFileName(); + SetGeneratePemf(kFALSE); + fNVolumes = 0; + fCurrentFlukaRegion = -1; + fDummyBoundary = 0; + fFieldFlag = 1; + fGeneratePemf = kFALSE; + fMCGeo = new TGeoMCGeometry("MCGeo", "TGeo Implementation of VirtualMCGeometry", kTRUE); + fGeom = new TFlukaMCGeometry("geom", "FLUKA VMC Geometry"); + if (verbosity > 2) fGeom->SetDebugMode(kTRUE); + fMaterials = 0; + fStopped = 0; + fStopEvent = 0; + fStopRun = 0; + fNEvent = 0; + PrintHeader(); } +//______________________________________________________________________________ TFluka::~TFluka() { - if (fVerbosityLevel >=3) - cout << "==> TFluka::~TFluka() destructor called." << endl; - - delete fGeometryManager; - fVolumeMediaMap->Delete(); - delete fVolumeMediaMap; - - - if (fVerbosityLevel >=3) - cout << "<== TFluka::~TFluka() destructor called." << endl; +// Destructor + if (fVerbosityLevel >=3) + cout << "<== TFluka::~TFluka() destructor called." << endl; + + delete fGeom; + delete fMCGeo; + + if (fUserConfig) { + fUserConfig->Delete(); + delete fUserConfig; + } + + if (fUserScore) { + fUserScore->Delete(); + delete fUserScore; + } } // -//_____________________________________________________________________________ +//______________________________________________________________________________ // TFluka control methods -//____________________________________________________________________________ +//______________________________________________________________________________ void TFluka::Init() { +// +// Geometry initialisation +// + if (fVerbosityLevel >=3) cout << "==> TFluka::Init() called." << endl; + + if (!gGeoManager) new TGeoManager("geom", "FLUKA geometry"); + fApplication->ConstructGeometry(); + if (!gGeoManager->IsClosed()) { + TGeoVolume *top = (TGeoVolume*)gGeoManager->GetListOfVolumes()->First(); + gGeoManager->SetTopVolume(top); + gGeoManager->CloseGeometry("di"); + } else { + TGeoNodeCache *cache = gGeoManager->GetCache(); + if (!cache->HasIdArray()) { + printf("Node ID tracking must be enabled with TFluka: enabling...\n"); + cache->BuildIdArray(); + } + } + fNVolumes = fGeom->NofVolumes(); + fGeom->CreateFlukaMatFile("flukaMat.inp"); + if (fVerbosityLevel >=3) { + printf("== Number of volumes: %i\n ==", fNVolumes); + cout << "\t* InitPhysics() - Prepare input file to be called" << endl; + } - FGeometryInit* geominit = FGeometryInit::GetInstance(); - if (fVerbosityLevel >=3) - cout << "==> TFluka::Init() called." << endl; - - cout << "\t* InitPhysics() - Prepare input file to be called" << endl; - geominit->Init(); - // now we have G4 geometry created and we have to patch alice.inp - // with the material mapping file FlukaMat.inp - InitPhysics(); // prepare input file with the current physics settings - cout << "\t* InitPhysics() - Prepare input file was called" << endl; - - if (fVerbosityLevel >=2) - cout << "\t* Changing lfdrtr = (" << (GLOBAL.lfdrtr?'T':'F') - << ") in fluka..." << endl; - GLOBAL.lfdrtr = true; - - if (fVerbosityLevel >=2) - cout << "\t* Opening file " << sInputFileName << endl; - const char* fname = sInputFileName; - fluka_openinp(lunin, PASSCHARA(fname)); - - if (fVerbosityLevel >=2) - cout << "\t* Calling flukam..." << endl; - flukam(1); - - if (fVerbosityLevel >=2) - cout << "\t* Closing file " << sInputFileName << endl; - fluka_closeinp(lunin); - - FinishGeometry(); - - if (fVerbosityLevel >=3) - cout << "<== TFluka::Init() called." << endl; - + fApplication->InitGeometry(); + } + +//______________________________________________________________________________ void TFluka::FinishGeometry() { // // Build-up table with region to medium correspondance // - char tmp[5]; - - if (fVerbosityLevel >=3) + if (fVerbosityLevel >=3) { cout << "==> TFluka::FinishGeometry() called." << endl; - -// fGeometryManager->Ggclos(); - - FGeometryInit* flugg = FGeometryInit::GetInstance(); - - fMediaByRegion = new Int_t[fNVolumes+2]; - for (Int_t i = 0; i < fNVolumes; i++) - { - FlukaVolume* vol = dynamic_cast((*fVolumeMediaMap)[i]); - TString volName = vol->GetName(); - Int_t media = vol->GetMedium(); - if (fVerbosityLevel >= 3) - printf("Finish Geometry: volName, media %d %s %d \n", i, volName.Data(), media); - strcpy(tmp, volName.Data()); - tmp[4] = '\0'; - flugg->SetMediumFromName(tmp, media, i+1); - fMediaByRegion[i] = media; - } - - flugg->BuildMediaMap(); - - if (fVerbosityLevel >=3) + printf("----FinishGeometry - nothing to do with TGeo\n"); cout << "<== TFluka::FinishGeometry() called." << endl; + } } +//______________________________________________________________________________ void TFluka::BuildPhysics() { - if (fVerbosityLevel >=3) - cout << "==> TFluka::BuildPhysics() called." << endl; - +// +// Prepare FLUKA input files and call FLUKA physics initialisation +// + + if (fVerbosityLevel >=3) + cout << "==> TFluka::BuildPhysics() called." << endl; - if (fVerbosityLevel >=3) - cout << "<== TFluka::BuildPhysics() called." << endl; + + if (fVerbosityLevel >=3) { + TList *medlist = gGeoManager->GetListOfMedia(); + TIter next(medlist); + TGeoMedium* med = 0x0; + TGeoMaterial* mat = 0x0; + Int_t ic = 0; + + while((med = (TGeoMedium*)next())) + { + mat = med->GetMaterial(); + printf("Medium %5d %12s %5d %5d\n", ic, (med->GetName()), med->GetId(), mat->GetIndex()); + ic++; + } + } + + // + // At this stage we have the information on materials and cuts available. + // Now create the pemf file + + if (fGeneratePemf) fGeom->CreatePemfFile(); + + // + // Prepare input file with the current physics settings + + InitPhysics(); + + cout << "\t* InitPhysics() - Prepare input file was called" << endl; + + if (fVerbosityLevel >=2) + cout << "\t* Changing lfdrtr = (" << (GLOBAL.lfdrtr?'T':'F') + << ") in fluka..." << endl; + GLOBAL.lfdrtr = true; + + if (fVerbosityLevel >=2) + cout << "\t* Opening file " << fInputFileName << endl; + const char* fname = fInputFileName; + + fluka_openinp(lunin, PASSCHARA(fname)); + fluka_openout(11, PASSCHARA("fluka.out")); + + if (fVerbosityLevel >=2) + cout << "\t* Calling flukam..." << endl; + flukam(1); + + if (fVerbosityLevel >=2) + cout << "\t* Closing file " << fInputFileName << endl; + fluka_closeinp(lunin); + + FinishGeometry(); + + if (fVerbosityLevel >=3) + cout << "<== TFluka::Init() called." << endl; + + if (fVerbosityLevel >=3) + cout << "<== TFluka::BuildPhysics() called." << endl; } +//______________________________________________________________________________ void TFluka::ProcessEvent() { - if (fVerbosityLevel >=3) - cout << "==> TFluka::ProcessEvent() called." << endl; - fApplication->GeneratePrimaries(); - EPISOR.lsouit = true; - flukam(1); - if (fVerbosityLevel >=3) - cout << "<== TFluka::ProcessEvent() called." << endl; +// +// Process one event +// + if (fStopRun) { + printf("User Run Abortion: No more events handled !\n"); + fNEvent += 1; + return; + } + + if (fVerbosityLevel >=3) + cout << "==> TFluka::ProcessEvent() called." << endl; + fApplication->GeneratePrimaries(); + EPISOR.lsouit = true; + flukam(1); + if (fVerbosityLevel >=3) + cout << "<== TFluka::ProcessEvent() called." << endl; + // + // Increase event number + // + fNEvent += 1; } +//______________________________________________________________________________ +Bool_t TFluka::ProcessRun(Int_t nevent) { +// +// Run steering +// -void TFluka::ProcessRun(Int_t nevent) { if (fVerbosityLevel >=3) cout << "==> TFluka::ProcessRun(" << nevent << ") called." << endl; @@ -241,203 +331,465 @@ void TFluka::ProcessRun(Int_t nevent) { cout << "\t* GLOBAL.fdrtr = " << (GLOBAL.lfdrtr?'T':'F') << endl; cout << "\t* Calling flukam again..." << endl; } - fApplication->InitGeometry(); - fApplication->BeginEvent(); - ProcessEvent(); - fApplication->FinishEvent(); + + Int_t todo = TMath::Abs(nevent); + for (Int_t ev = 0; ev < todo; ev++) { + fApplication->BeginEvent(); + ProcessEvent(); + fApplication->FinishEvent(); + } + if (fVerbosityLevel >=3) cout << "<== TFluka::ProcessRun(" << nevent << ") called." << endl; - + // Write fluka specific scoring output + newplo(); + + return kTRUE; } //_____________________________________________________________________________ // methods for building/management of geometry -//____________________________________________________________________________ + // functions from GCONS +//____________________________________________________________________________ void TFluka::Gfmate(Int_t imat, char *name, Float_t &a, Float_t &z, Float_t &dens, Float_t &radl, Float_t &absl, - Float_t* ubuf, Int_t& nbuf) { + Float_t* /*ubuf*/, Int_t& /*nbuf*/) { // - fGeometryManager->Gfmate(imat, name, a, z, dens, radl, absl, ubuf, nbuf); + TGeoMaterial *mat; + TIter next (gGeoManager->GetListOfMaterials()); + while ((mat = (TGeoMaterial*)next())) { + if (mat->GetUniqueID() == (UInt_t)imat) break; + } + if (!mat) { + Error("Gfmate", "no material with index %i found", imat); + return; + } + sprintf(name, "%s", mat->GetName()); + a = mat->GetA(); + z = mat->GetZ(); + dens = mat->GetDensity(); + radl = mat->GetRadLen(); + absl = mat->GetIntLen(); } +//______________________________________________________________________________ void TFluka::Gfmate(Int_t imat, char *name, Double_t &a, Double_t &z, Double_t &dens, Double_t &radl, Double_t &absl, - Double_t* ubuf, Int_t& nbuf) { + Double_t* /*ubuf*/, Int_t& /*nbuf*/) { // - fGeometryManager->Gfmate(imat, name, a, z, dens, radl, absl, ubuf, nbuf); + TGeoMaterial *mat; + TIter next (gGeoManager->GetListOfMaterials()); + while ((mat = (TGeoMaterial*)next())) { + if (mat->GetUniqueID() == (UInt_t)imat) break; + } + if (!mat) { + Error("Gfmate", "no material with index %i found", imat); + return; + } + sprintf(name, "%s", mat->GetName()); + a = mat->GetA(); + z = mat->GetZ(); + dens = mat->GetDensity(); + radl = mat->GetRadLen(); + absl = mat->GetIntLen(); } // detector composition +//______________________________________________________________________________ void TFluka::Material(Int_t& kmat, const char* name, Double_t a, Double_t z, Double_t dens, Double_t radl, Double_t absl, Float_t* buf, Int_t nwbuf) { // - fGeometryManager - ->Material(kmat, name, a, z, dens, radl, absl, buf, nwbuf); + Double_t* dbuf = fGeom->CreateDoubleArray(buf, nwbuf); + Material(kmat, name, a, z, dens, radl, absl, dbuf, nwbuf); + delete [] dbuf; } + +//______________________________________________________________________________ void TFluka::Material(Int_t& kmat, const char* name, Double_t a, Double_t z, Double_t dens, Double_t radl, Double_t absl, - Double_t* buf, Int_t nwbuf) { + Double_t* /*buf*/, Int_t /*nwbuf*/) { // - fGeometryManager - ->Material(kmat, name, a, z, dens, radl, absl, buf, nwbuf); +// Define a material + TGeoMaterial *mat; + kmat = gGeoManager->GetListOfMaterials()->GetSize(); + if ((z-Int_t(z)) > 1E-3) { + mat = fGeom->GetMakeWrongMaterial(z); + if (mat) { + mat->SetRadLen(radl,absl); + mat->SetUniqueID(kmat); + return; + } + } + gGeoManager->Material(name, a, z, dens, kmat, radl, absl); } +//______________________________________________________________________________ void TFluka::Mixture(Int_t& kmat, const char *name, Float_t *a, Float_t *z, Double_t dens, Int_t nlmat, Float_t *wmat) { // - fGeometryManager - ->Mixture(kmat, name, a, z, dens, nlmat, wmat); +// Define a material mixture +// + Double_t* da = fGeom->CreateDoubleArray(a, TMath::Abs(nlmat)); + Double_t* dz = fGeom->CreateDoubleArray(z, TMath::Abs(nlmat)); + Double_t* dwmat = fGeom->CreateDoubleArray(wmat, TMath::Abs(nlmat)); + + Mixture(kmat, name, da, dz, dens, nlmat, dwmat); + for (Int_t i=0; iMixture(kmat, name, a, z, dens, nlmat, wmat); + // Defines mixture OR COMPOUND IMAT as composed by + // THE BASIC NLMAT materials defined by arrays A,Z and WMAT + // + // If NLMAT > 0 then wmat contains the proportion by + // weights of each basic material in the mixture. + // + // If nlmat < 0 then WMAT contains the number of atoms + // of a given kind into the molecule of the COMPOUND + // In this case, WMAT in output is changed to relative + // weigths. + // + Int_t i,j; + if (nlmat < 0) { + nlmat = - nlmat; + Double_t amol = 0; + for (i=0;iGetListOfMaterials()->GetSize(); + // Check if we have elements with fractional Z + TGeoMaterial *mat = 0; + TGeoMixture *mix = 0; + Bool_t mixnew = kFALSE; + for (i=0; i loop mixtures to look for it + for (j=0; jGetListOfMaterials()->At(j); + if (!mat) break; + if (!mat->IsMixture()) continue; + mix = (TGeoMixture*)mat; + if (TMath::Abs(z[i]-mix->GetZ()) >1E-3) continue; +// printf(" FOUND component %i as mixture %s\n", i, mat->GetName()); + mixnew = kTRUE; + break; + } + if (!mixnew) Warning("Mixture","%s : cannot find component %i with fractional Z=%f\n", name, i, z[i]); + break; + } + if (mixnew) { + Int_t nlmatnew = nlmat+mix->GetNelements()-1; + Double_t *anew = new Double_t[nlmatnew]; + Double_t *znew = new Double_t[nlmatnew]; + Double_t *wmatnew = new Double_t[nlmatnew]; + Int_t ind=0; + for (j=0; jGetNelements(); j++) { + anew[ind] = mix->GetAmixt()[j]; + znew[ind] = mix->GetZmixt()[j]; + wmatnew[ind] = wmat[i]*mix->GetWmixt()[j]; + ind++; + } + Mixture(kmat, name, anew, znew, dens, nlmatnew, wmatnew); + delete [] anew; + delete [] znew; + delete [] wmatnew; + return; + } + // Now we need to compact identical elements within the mixture + // First check if this happens + mixnew = kFALSE; + for (i=0; iMixture(name, a, z, dens, nlmat, wmat, kmat); } +//______________________________________________________________________________ void TFluka::Medium(Int_t& kmed, const char *name, Int_t nmat, Int_t isvol, Int_t ifield, Double_t fieldm, Double_t tmaxfd, Double_t stemax, Double_t deemax, Double_t epsil, Double_t stmin, Float_t* ubuf, Int_t nbuf) { - // - fGeometryManager - ->Medium(kmed, name, nmat, isvol, ifield, fieldm, tmaxfd, stemax, deemax, + // Define a medium + // + kmed = gGeoManager->GetListOfMedia()->GetSize()+1; + fMCGeo->Medium(kmed, name, nmat, isvol, ifield, fieldm, tmaxfd, stemax, deemax, epsil, stmin, ubuf, nbuf); } + +//______________________________________________________________________________ void TFluka::Medium(Int_t& kmed, const char *name, Int_t nmat, Int_t isvol, Int_t ifield, Double_t fieldm, Double_t tmaxfd, Double_t stemax, Double_t deemax, Double_t epsil, Double_t stmin, Double_t* ubuf, Int_t nbuf) { - // - fGeometryManager - ->Medium(kmed, name, nmat, isvol, ifield, fieldm, tmaxfd, stemax, deemax, + // Define a medium + // + kmed = gGeoManager->GetListOfMedia()->GetSize()+1; + fMCGeo->Medium(kmed, name, nmat, isvol, ifield, fieldm, tmaxfd, stemax, deemax, epsil, stmin, ubuf, nbuf); } +//______________________________________________________________________________ void TFluka::Matrix(Int_t& krot, Double_t thetaX, Double_t phiX, Double_t thetaY, Double_t phiY, Double_t thetaZ, Double_t phiZ) { // - fGeometryManager - ->Matrix(krot, thetaX, phiX, thetaY, phiY, thetaZ, phiZ); + krot = gGeoManager->GetListOfMatrices()->GetEntriesFast(); + fMCGeo->Matrix(krot, thetaX, phiX, thetaY, phiY, thetaZ, phiZ); } -void TFluka::Gstpar(Int_t itmed, const char *param, Double_t parval) { +//______________________________________________________________________________ +void TFluka::Gstpar(Int_t itmed, const char* param, Double_t parval) { +// +// +// Check if material is used + if (fVerbosityLevel >= 3) + printf("Gstpar called with %6d %5s %12.4e %6d\n", itmed, param, parval, fGeom->GetFlukaMaterial(itmed)); + Int_t* reglist; + Int_t nreg; + reglist = fGeom->GetMaterialList(fGeom->GetFlukaMaterial(itmed), nreg); + if (nreg == 0) { + return; + } + // - fGeometryManager->Gstpar(itmed, param, parval); + Bool_t process = kFALSE; + if (strncmp(param, "DCAY", 4) == 0 || + strncmp(param, "PAIR", 4) == 0 || + strncmp(param, "COMP", 4) == 0 || + strncmp(param, "PHOT", 4) == 0 || + strncmp(param, "PFIS", 4) == 0 || + strncmp(param, "DRAY", 4) == 0 || + strncmp(param, "ANNI", 4) == 0 || + strncmp(param, "BREM", 4) == 0 || + strncmp(param, "MUNU", 4) == 0 || + strncmp(param, "CKOV", 4) == 0 || + strncmp(param, "HADR", 4) == 0 || + strncmp(param, "LOSS", 4) == 0 || + strncmp(param, "MULS", 4) == 0 || + strncmp(param, "RAYL", 4) == 0) + { + process = kTRUE; + } + if (process) { + SetProcess(param, Int_t (parval), fGeom->GetFlukaMaterial(itmed)); + } else { + SetCut(param, parval, fGeom->GetFlukaMaterial(itmed)); + } } // functions from GGEOM +//_____________________________________________________________________________ +void TFluka::Gsatt(const char *name, const char *att, Int_t val) +{ + // Set visualisation attributes for one volume + char vname[5]; + fGeom->Vname(name,vname); + char vatt[5]; + fGeom->Vname(att,vatt); + gGeoManager->SetVolumeAttribute(vname, vatt, val); +} + +//______________________________________________________________________________ Int_t TFluka::Gsvolu(const char *name, const char *shape, Int_t nmed, Float_t *upar, Int_t np) { // -// fVolumeMediaMap[TString(name)] = nmed; - if (fVerbosityLevel >= 3) - printf("TFluka::Gsvolu() name = %s, nmed = %d\n", name, nmed); - - TClonesArray &lvols = *fVolumeMediaMap; - new(lvols[fNVolumes++]) - FlukaVolume(name, nmed); - return fGeometryManager->Gsvolu(name, shape, nmed, upar, np); + return fMCGeo->Gsvolu(name, shape, nmed, upar, np); } + +//______________________________________________________________________________ Int_t TFluka::Gsvolu(const char *name, const char *shape, Int_t nmed, Double_t *upar, Int_t np) { // - TClonesArray &lvols = *fVolumeMediaMap; - new(lvols[fNVolumes++]) - FlukaVolume(name, nmed); - - return fGeometryManager->Gsvolu(name, shape, nmed, upar, np); + return fMCGeo->Gsvolu(name, shape, nmed, upar, np); } +//______________________________________________________________________________ void TFluka::Gsdvn(const char *name, const char *mother, Int_t ndiv, Int_t iaxis) { // -// The medium of the daughter is the one of the mother - Int_t volid = TFluka::VolId(mother); - Int_t med = TFluka::VolId2Mate(volid); - TClonesArray &lvols = *fVolumeMediaMap; - new(lvols[fNVolumes++]) - FlukaVolume(name, med); - fGeometryManager->Gsdvn(name, mother, ndiv, iaxis); + fMCGeo->Gsdvn(name, mother, ndiv, iaxis); } +//______________________________________________________________________________ void TFluka::Gsdvn2(const char *name, const char *mother, Int_t ndiv, Int_t iaxis, Double_t c0i, Int_t numed) { // - TClonesArray &lvols = *fVolumeMediaMap; - new(lvols[fNVolumes++]) - FlukaVolume(name, numed); - fGeometryManager->Gsdvn2(name, mother, ndiv, iaxis, c0i, numed); + fMCGeo->Gsdvn2(name, mother, ndiv, iaxis, c0i, numed); } +//______________________________________________________________________________ void TFluka::Gsdvt(const char *name, const char *mother, Double_t step, Int_t iaxis, Int_t numed, Int_t ndvmx) { // - TClonesArray &lvols = *fVolumeMediaMap; - new(lvols[fNVolumes++]) - FlukaVolume(name, numed); - fGeometryManager->Gsdvt(name, mother, step, iaxis, numed, ndvmx); + fMCGeo->Gsdvt(name, mother, step, iaxis, numed, ndvmx); } +//______________________________________________________________________________ void TFluka::Gsdvt2(const char *name, const char *mother, Double_t step, Int_t iaxis, Double_t c0, Int_t numed, Int_t ndvmx) { // - TClonesArray &lvols = *fVolumeMediaMap; - new(lvols[fNVolumes++]) - FlukaVolume(name, numed); - fGeometryManager->Gsdvt2(name, mother, step, iaxis, c0, numed, ndvmx); + fMCGeo->Gsdvt2(name, mother, step, iaxis, c0, numed, ndvmx); } -void TFluka::Gsord(const char *name, Int_t iax) { +//______________________________________________________________________________ +void TFluka::Gsord(const char * /*name*/, Int_t /*iax*/) { // - fGeometryManager->Gsord(name, iax); +// Nothing to do with TGeo } +//______________________________________________________________________________ void TFluka::Gspos(const char *name, Int_t nr, const char *mother, Double_t x, Double_t y, Double_t z, Int_t irot, const char *konly) { // - fGeometryManager->Gspos(name, nr, mother, x, y, z, irot, konly); + fMCGeo->Gspos(name, nr, mother, x, y, z, irot, konly); } +//______________________________________________________________________________ void TFluka::Gsposp(const char *name, Int_t nr, const char *mother, Double_t x, Double_t y, Double_t z, Int_t irot, const char *konly, Float_t *upar, Int_t np) { // - fGeometryManager->Gsposp(name, nr, mother, x, y, z, irot, konly, upar, np); + fMCGeo->Gsposp(name, nr, mother, x, y, z, irot, konly, upar, np); } + +//______________________________________________________________________________ void TFluka::Gsposp(const char *name, Int_t nr, const char *mother, Double_t x, Double_t y, Double_t z, Int_t irot, const char *konly, Double_t *upar, Int_t np) { // - fGeometryManager->Gsposp(name, nr, mother, x, y, z, irot, konly, upar, np); + fMCGeo->Gsposp(name, nr, mother, x, y, z, irot, konly, upar, np); } -void TFluka::Gsbool(const char* onlyVolName, const char* manyVolName) { +//______________________________________________________________________________ +void TFluka::Gsbool(const char* /*onlyVolName*/, const char* /*manyVolName*/) { // - fGeometryManager->Gsbool(onlyVolName, manyVolName); +// Nothing to do with TGeo } -void TFluka::SetCerenkov(Int_t itmed, Int_t npckov, Float_t *ppckov, - Float_t *absco, Float_t *effic, Float_t *rindex) { +//______________________________________________________________________________ +void TFluka::SetCerenkov(Int_t itmed, Int_t npckov, Float_t* ppckov, + Float_t* absco, Float_t* effic, Float_t* rindex) { +// +// Set Cerenkov properties for medium itmed +// +// npckov: number of sampling points +// ppckov: energy values +// absco: absorption length +// effic: quantum efficiency +// rindex: refraction index +// +// +// +// Create object holding Cerenkov properties +// + TFlukaCerenkov* cerenkovProperties = new TFlukaCerenkov(npckov, ppckov, absco, effic, rindex); +// +// Pass object to medium + TGeoMedium* medium = gGeoManager->GetMedium(itmed); + medium->SetCerenkovProperties(cerenkovProperties); +} + +void TFluka::SetCerenkov(Int_t itmed, Int_t npckov, Float_t* ppckov, + Float_t* absco, Float_t* effic, Float_t* rindex, Float_t* rfl) { // - fGeometryManager->SetCerenkov(itmed, npckov, ppckov, absco, effic, rindex); +// Set Cerenkov properties for medium itmed +// +// npckov: number of sampling points +// ppckov: energy values +// absco: absorption length +// effic: quantum efficiency +// rindex: refraction index +// rfl: reflectivity for boundary to medium itmed +// +// +// Create object holding Cerenkov properties +// + TFlukaCerenkov* cerenkovProperties = new TFlukaCerenkov(npckov, ppckov, absco, effic, rindex, rfl); +// +// Pass object to medium + TGeoMedium* medium = gGeoManager->GetMedium(itmed); + medium->SetCerenkovProperties(cerenkovProperties); } -void TFluka::SetCerenkov(Int_t itmed, Int_t npckov, Double_t *ppckov, - Double_t *absco, Double_t *effic, Double_t *rindex) { + + +//______________________________________________________________________________ +void TFluka::SetCerenkov(Int_t /*itmed*/, Int_t /*npckov*/, Double_t * /*ppckov*/, + Double_t * /*absco*/, Double_t * /*effic*/, Double_t * /*rindex*/) { // - fGeometryManager->SetCerenkov(itmed, npckov, ppckov, absco, effic, rindex); +// Double_t version not implemented } - + +void TFluka::SetCerenkov(Int_t /*itmed*/, Int_t /*npckov*/, Double_t* /*ppckov*/, + Double_t* /*absco*/, Double_t* /*effic*/, Double_t* /*rindex*/, Double_t* /*rfl*/) { +// +// // Double_t version not implemented +} + // Euclid -void TFluka::WriteEuclid(const char* fileName, const char* topVol, - Int_t number, Int_t nlevel) { +//______________________________________________________________________________ +void TFluka::WriteEuclid(const char* /*fileName*/, const char* /*topVol*/, + Int_t /*number*/, Int_t /*nlevel*/) { // - fGeometryManager->WriteEuclid(fileName, topVol, number, nlevel); +// Not with TGeo + Warning("WriteEuclid", "Not implemented with TGeo"); } @@ -450,8 +802,7 @@ Int_t TFluka::GetMedium() const { // // Get the medium number for the current fluka region // - FGeometryInit* flugg = FGeometryInit::GetInstance(); - return flugg->GetMedium(fCurrentFlukaRegion); + return fGeom->GetMedium(); // this I need to check due to remapping !!! } @@ -473,42 +824,56 @@ Int_t TFluka::IdFromPDG(Int_t pdg) const return GetFlukaKPTOIP(intfluka); } +//______________________________________________________________________________ Int_t TFluka::PDGFromId(Int_t id) const { // // Return PDG code and pseudo ENDF code from Fluka code - + // Alpha He3 Triton Deuteron gen. ion opt. photon + Int_t idSpecial[6] = {10020040, 10020030, 10010030, 10010020, 10000000, 50000050}; // IPTOKP array goes from official to internal if (id == -1) { // Cerenkov photon - if (fVerbosityLevel >= 1) + if (fVerbosityLevel >= 3) printf("\n PDGFromId: Cerenkov Photon \n"); return 50000050; } // Error id - if (id == 0) { - if (fVerbosityLevel >= 1) + if (id == 0 || id < -6 || id > 250) { + if (fVerbosityLevel >= 3) printf("PDGFromId: Error id = 0\n"); return -1; } // Good id - Int_t intfluka = GetFlukaIPTOKP(id); - if (intfluka == 0) { - if (fVerbosityLevel >= 1) - printf("PDGFromId: Error intfluka = 0: %d\n", id); - return -1; - } else if (intfluka < 0) { - if (fVerbosityLevel >= 1) - printf("PDGFromId: Error intfluka < 0: %d\n", id); - return -1; + if (id > 0) { + Int_t intfluka = GetFlukaIPTOKP(id); + if (intfluka == 0) { + if (fVerbosityLevel >= 3) + printf("PDGFromId: Error intfluka = 0: %d\n", id); + return -1; + } else if (intfluka < 0) { + if (fVerbosityLevel >= 3) + printf("PDGFromId: Error intfluka < 0: %d\n", id); + return -1; + } + if (fVerbosityLevel >= 3) + printf("mpdgha called with %d %d \n", id, intfluka); + // MPDGHA() goes from fluka internal to pdg. + return mpdgha(intfluka); + } else { + // ions and optical photons + return idSpecial[id + 6]; } - if (fVerbosityLevel >= 3) - printf("mpdgha called with %d %d \n", id, intfluka); - // MPDGHA() goes from fluka internal to pdg. - return mpdgha(intfluka); } +void TFluka::StopTrack() +{ + // Set stopping conditions + // Works for photons and charged particles + fStopped = kTRUE; +} + //_____________________________________________________________________________ // methods for physics management //____________________________________________________________________________ @@ -516,1450 +881,250 @@ Int_t TFluka::PDGFromId(Int_t id) const // set methods // -void TFluka::SetProcess(const char* flagName, Int_t flagValue) +void TFluka::SetProcess(const char* flagName, Int_t flagValue, Int_t imed) { - Int_t i; - if (iNbOfProc < 100) { - for (i=0; iMedium() == imed) { + proc->SetProcess(flagName, flagValue); + return; + } } - strcpy(&sProcessFlag[iNbOfProc][0],flagName); - iProcessValue[iNbOfProc++] = flagValue; - } - else - cout << "Nb of SetProcess calls exceeds 100 - ignored" << endl; -fin: - iNbOfProc = iNbOfProc; + proc = new TFlukaConfigOption(imed); + proc->SetProcess(flagName, flagValue); + fUserConfig->Add(proc); } -void TFluka::SetCut(const char* cutName, Double_t cutValue) +//______________________________________________________________________________ +Bool_t TFluka::SetProcess(const char* flagName, Int_t flagValue) { - Int_t i; - if (iNbOfCut < 100) { - for (i=0; iMedium() == imed) { + proc->SetCut(cutName, cutValue); + return; + } } - strcpy(&sCutFlag[iNbOfCut][0],cutName); - fCutValue[iNbOfCut++] = cutValue; - } - else - cout << "Nb of SetCut calls exceeds 100 - ignored" << endl; -fin: - iNbOfCut = iNbOfCut; + + proc = new TFlukaConfigOption(imed); + proc->SetCut(cutName, cutValue); + fUserConfig->Add(proc); +} + +//______________________________________________________________________________ +Bool_t TFluka::SetCut(const char* cutName, Double_t cutValue) +{ +// Set user cut value +// +// + SetCut(cutName, cutValue, -1); + return kTRUE; } + +void TFluka::SetUserScoring(const char* option, Int_t npr, char* outfile, Float_t* what) +{ +// +// Adds a user scoring option to the list +// + TFlukaScoringOption* opt = new TFlukaScoringOption(option, "User Scoring", npr,outfile,what); + fUserScore->Add(opt); +} +//______________________________________________________________________________ +void TFluka::SetUserScoring(const char* option, Int_t npr, char* outfile, Float_t* what, const char* det1, const char* det2, const char* det3) +{ +// +// Adds a user scoring option to the list +// + TFlukaScoringOption* opt = new TFlukaScoringOption(option, "User Scoring", npr, outfile, what, det1, det2, det3); + fUserScore->Add(opt); +} + +//______________________________________________________________________________ Double_t TFluka::Xsec(char*, Double_t, Int_t, Int_t) { printf("WARNING: Xsec not yet implemented !\n"); return -1.; } +//______________________________________________________________________________ void TFluka::InitPhysics() { -// Last material number taken from the "corealice.inp" file, presently 31 -// !!! it should be available from Flugg !!! - Int_t i, j, k; - Double_t fCut; - FGeometryInit* geominit = FGeometryInit::GetInstance(); - Float_t fLastMaterial = geominit->GetLastMaterialIndex(); - printf(" last FLUKA material is %g\n", fLastMaterial); - -// construct file names - TString sAliceCoreInp = getenv("ALICE_ROOT"); - sAliceCoreInp +="/TFluka/input/"; - TString sAliceTmp = "flukaMat.inp"; - TString sAliceInp = GetInputFileName(); - sAliceCoreInp += GetCoreInputFileName(); - ifstream AliceCoreInp(sAliceCoreInp.Data()); - ifstream AliceFlukaMat(sAliceTmp.Data()); - ofstream AliceInp(sAliceInp.Data()); - -// copy core input file - Char_t sLine[255]; - Float_t fEventsPerRun; - - while (AliceCoreInp.getline(sLine,255)) { - if (strncmp(sLine,"GEOEND",6) != 0) - AliceInp << sLine << endl; // copy until GEOEND card - else { - AliceInp << "GEOEND" << endl; // add GEOEND card - goto flukamat; +// +// Physics initialisation with preparation of FLUKA input cards +// + printf("=>InitPhysics\n"); + +// Construct file names + FILE *pFlukaVmcCoreInp, *pFlukaVmcFlukaMat, *pFlukaVmcInp; + TString sFlukaVmcCoreInp = getenv("ALICE_ROOT"); + sFlukaVmcCoreInp +="/TFluka/input/"; + TString sFlukaVmcTmp = "flukaMat.inp"; + TString sFlukaVmcInp = GetInputFileName(); + sFlukaVmcCoreInp += GetCoreInputFileName(); + +// Open files + if ((pFlukaVmcCoreInp = fopen(sFlukaVmcCoreInp.Data(),"r")) == NULL) { + printf("\nCannot open file %s\n",sFlukaVmcCoreInp.Data()); + exit(1); } - } // end of while until GEOEND card - -flukamat: - while (AliceFlukaMat.getline(sLine,255)) { // copy flukaMat.inp file - AliceInp << sLine << endl; - } - - while (AliceCoreInp.getline(sLine,255)) { - if (strncmp(sLine,"START",5) != 0) - AliceInp << sLine << endl; - else { - sscanf(sLine+10,"%10f",&fEventsPerRun); - goto fin; + if ((pFlukaVmcFlukaMat = fopen(sFlukaVmcTmp.Data(),"r")) == NULL) { + printf("\nCannot open file %s\n",sFlukaVmcTmp.Data()); + exit(1); } - } //end of while until START card - -fin: -// in G3 the process control values meaning can be different for -// different processes, but for most of them is: -// 0 process is not activated -// 1 process is activated WITH generation of secondaries -// 2 process is activated WITHOUT generation of secondaries -// if process does not generate secondaries => 1 same as 2 -// -// Exceptions: -// MULS: also 3 -// LOSS: also 3, 4 -// RAYL: only 0,1 -// HADR: may be > 2 -// - -// Loop over number of SetProcess calls - AliceInp << "*----------------------------------------------------------------------------- "; - AliceInp << endl; - AliceInp << "*----- The following data are generated from SetProcess and SetCut calls ----- "; - AliceInp << endl; - AliceInp << "*----------------------------------------------------------------------------- "; - AliceInp << endl; - for (i=0; iSetProcess("ANNI",1); // EMFCUT -1. 0. 0. 3. lastmat 0. ANNH-THR - if (strncmp(&sProcessFlag[i][0],"ANNI",4) == 0) { - if (iProcessValue[i] == 1 || iProcessValue[i] == 2) { - AliceInp << "*"; - AliceInp << endl; - AliceInp << "*Kinetic energy threshold (GeV) for e+ annihilation - resets to default=0."; - AliceInp << endl; - AliceInp << "*Generated from call: SetProcess('ANNI',1) or SetProcess('ANNI',2)"; - AliceInp << endl; - AliceInp << setw(10) << "EMFCUT "; - AliceInp << setiosflags(ios::scientific) << setprecision(5); - AliceInp << setiosflags(ios::fixed) << setiosflags(ios::showpoint) << setprecision(1); - AliceInp << setw(10) << -1.0; // kinetic energy threshold (GeV) for e+ annihilation (resets to default=0) - AliceInp << setw(10) << 0.0; // not used - AliceInp << setw(10) << 0.0; // not used - AliceInp << setw(10) << 3.0; // lower bound of the material indices in which the respective thresholds apply - AliceInp << setw(10) << setprecision(2); - AliceInp << setw(10) << fLastMaterial; // upper bound of the material indices in which the respective thresholds apply - AliceInp << setprecision(1); - AliceInp << setw(10) << 1.0; // step length in assigning indices - AliceInp << setw(8) << "ANNH-THR"; - AliceInp << endl; - } - else if (iProcessValue[i] == 0) { - AliceInp << "*"; - AliceInp << endl; - AliceInp << "*No annihilation - no FLUKA card generated"; - AliceInp << endl; - AliceInp << "*Generated from call: SetProcess('ANNI',0)"; - AliceInp << endl; - } - else { - AliceInp << "*"; - AliceInp << endl; - AliceInp << "*Illegal flag value in SetProcess('ANNI',?) call."; - AliceInp << endl; - AliceInp << "*No FLUKA card generated"; - AliceInp << endl; - } + if ((pFlukaVmcInp = fopen(sFlukaVmcInp.Data(),"w")) == NULL) { + printf("\nCannot open file %s\n",sFlukaVmcInp.Data()); + exit(1); } - - // bremsstrahlung and pair production are both activated - // G3 default value: 1 - // G4 processes: G4eBremsstrahlung/G4IeBremsstrahlung, - // G4MuBremsstrahlung/G4IMuBremsstrahlung, - // G4LowEnergyBremstrahlung - // Particles: e-/e+; mu+/mu- - // Physics: EM - // flag = 0 no bremsstrahlung - // flag = 1 bremsstrahlung, photon processed - // flag = 2 bremsstrahlung, no photon stored - // gMC ->SetProcess("BREM",1); // PAIRBREM 2. 0. 0. 3. lastmat - // EMFCUT -1. 0. 0. 3. lastmat 0. ELPO-THR - // G3 default value: 1 - // G4 processes: G4GammaConversion, - // G4MuPairProduction/G4IMuPairProduction - // G4LowEnergyGammaConversion - // Particles: gamma, mu - // Physics: EM - // flag = 0 no delta rays - // flag = 1 delta rays, secondaries processed - // flag = 2 delta rays, no secondaries stored - // gMC ->SetProcess("PAIR",1); // PAIRBREM 1. 0. 0. 3. lastmat - // EMFCUT 0. 0. -1. 3. lastmat 0. PHOT-THR - else if ((strncmp(&sProcessFlag[i][0],"PAIR",4) == 0) && (iProcessValue[i] == 1 || iProcessValue[i] == 2)) { - for (j=0; jSetCut("PPCUTM",cut); // total energy cut for direct pair prod. by muons - fCut = 0.0; - for (k=0; kSetCut("BCUTM",cut); // cut for muon and hadron bremsstrahlung - fCut = 0.0; - for (k=0; kSetCut("PPCUTM",cut); // total energy cut for direct pair prod. by muons - AliceInp << setiosflags(ios::fixed) << setiosflags(ios::showpoint) << setprecision(1); - AliceInp << setw(10) << 0.0; // e+, e- kinetic energy threshold (in GeV) for explicit pair production. - AliceInp << setw(10) << 0.0; // no explicit bremsstrahlung production is simulated - AliceInp << setw(10) << 3.0; // lower bound of the material indices in which the respective thresholds apply - AliceInp << setprecision(2); - AliceInp << setw(10) << fLastMaterial; // upper bound of the material indices in which the respective thresholds apply - AliceInp << endl; - - // for e+ and e- - AliceInp << "*"; - AliceInp << endl; - AliceInp << "*Pair production by electrons is activated"; - AliceInp << endl; - AliceInp << "*Generated from call: SetProcess('PAIR',1) or SetProcess('PAIR',2)"; - AliceInp << endl; - AliceInp << setw(10) << "EMFCUT "; - AliceInp << setiosflags(ios::fixed) << setiosflags(ios::showpoint) << setprecision(1); - AliceInp << setw(10) << 0.0; // energy threshold (GeV) for Compton scattering (= 0.0 : ignored) - AliceInp << setw(10) << 0.0; // energy threshold (GeV) for Photoelectric (= 0.0 : ignored) - - fCut = -1.0; - for (j=0; jSetProcess("BREM",1); // PAIRBREM 2. 0. 0. 3. lastmat - // EMFCUT -1. 0. 0. 3. lastmat 0. ELPO-THR - else if (strncmp(&sProcessFlag[i][0],"BREM",4) == 0) { - for (j=0; jSetCut("BCUTM",cut); // cut for muon and hadron bremsstrahlung - fCut = 0.0; - for (j=0; jSetProcess("CKOV",1); // ??? Cerenkov photon generation - else if (strncmp(&sProcessFlag[i][0],"CKOV",4) == 0) { - if (iProcessValue[i] == 1 || iProcessValue[i] == 2) { - AliceInp << "*"; - AliceInp << endl; - AliceInp << "*Cerenkov photon generation"; - AliceInp << endl; - AliceInp << "*Generated from call: SetProcess('CKOV',1) or SetProcess('CKOV',2)"; - AliceInp << endl; - AliceInp << setw(10) << "OPT-PROD "; - AliceInp << setiosflags(ios::scientific) << setprecision(5); - AliceInp << setw(10) << 2.07e-9 ; // minimum Cerenkov photon emission energy (in GeV!). Default: 2.07E-9 GeV (corresponding to 600 nm) - AliceInp << setw(10) << 4.96e-9; // maximum Cerenkov photon emission energy (in GeV!). Default: 4.96E-9 GeV (corresponding to 250 nm) - AliceInp << setiosflags(ios::fixed) << setiosflags(ios::showpoint) << setprecision(1); - AliceInp << setw(10) << 0.0; // not used - AliceInp << setw(10) << 3.0; // lower bound of the material indices in which the respective thresholds apply - AliceInp << setprecision(2); - AliceInp << setw(10) << fLastMaterial; // upper bound of the material indices in which the respective thresholds apply - AliceInp << setprecision(1); - AliceInp << setw(10) << 1.0; // step length in assigning indices - AliceInp << setw(8) << "CERENKOV"; - AliceInp << endl; - } - else if (iProcessValue[i] == 0) { - AliceInp << "*"; - AliceInp << endl; - AliceInp << "*No Cerenkov photon generation"; - AliceInp << endl; - AliceInp << "*Generated from call: SetProcess('CKOV',0)"; - AliceInp << endl; - AliceInp << setw(10) << "OPT-PROD "; - AliceInp << setiosflags(ios::scientific) << setprecision(5); - AliceInp << setiosflags(ios::fixed) << setiosflags(ios::showpoint) << setprecision(1); - AliceInp << setw(10) << 0.0; // not used - AliceInp << setw(10) << 0.0; // not used - AliceInp << setw(10) << 0.0; // not used - AliceInp << setw(10) << 3.0; // lower bound of the material indices in which the respective thresholds apply - AliceInp << setprecision(2); - AliceInp << setw(10) << fLastMaterial; // upper bound of the material indices in which the respective thresholds apply - AliceInp << setprecision(1); - AliceInp << setw(10) << 1.0; // step length in assigning indices - AliceInp << setw(8) << "CERE-OFF"; - AliceInp << endl; - } - else { - AliceInp << "*"; - AliceInp << endl; - AliceInp << "*Illegal flag value in SetProcess('CKOV',?) call."; - AliceInp << endl; - AliceInp << "*No FLUKA card generated"; - AliceInp << endl; - } - } // end of else if (strncmp(&sProcessFlag[i][0],"CKOV",4) == 0) - - - // Compton scattering - // G3 default value: 1 - // G4 processes: G4ComptonScattering, - // G4LowEnergyCompton, - // G4PolarizedComptonScattering - // Particles: gamma - // Physics: EM - // flag = 0 no Compton scattering - // flag = 1 Compton scattering, electron processed - // flag = 2 Compton scattering, no electron stored - // gMC ->SetProcess("COMP",1); // EMFCUT -1. 0. 0. 3. lastmat 0. PHOT-THR - else if (strncmp(&sProcessFlag[i][0],"COMP",4) == 0) { - if (iProcessValue[i] == 1 || iProcessValue[i] == 2) { - AliceInp << "*"; - AliceInp << endl; - AliceInp << "*Energy threshold (GeV) for Compton scattering - resets to default=0."; - AliceInp << endl; - AliceInp << "*Generated from call: SetProcess('COMP',1);"; - AliceInp << endl; - AliceInp << setw(10) << "EMFCUT "; - AliceInp << setiosflags(ios::scientific) << setprecision(5); - AliceInp << setiosflags(ios::fixed) << setiosflags(ios::showpoint) << setprecision(1); - AliceInp << setw(10) << -1.0; // energy threshold (GeV) for Compton scattering - resets to default=0. - AliceInp << setw(10) << 0.0; // not used - AliceInp << setw(10) << 0.0; // not used - AliceInp << setw(10) << 3.0; // lower bound of the material indices in which the respective thresholds apply - AliceInp << setprecision(2); - AliceInp << setw(10) << fLastMaterial; // upper bound of the material indices in which the respective thresholds apply - AliceInp << setprecision(1); - AliceInp << setw(10) << 1.0; // step length in assigning indices - AliceInp << setw(8) << "PHOT-THR"; - AliceInp << endl; - } - else if (iProcessValue[i] == 0) { - AliceInp << "*"; - AliceInp << endl; - AliceInp << "*No Compton scattering - no FLUKA card generated"; - AliceInp << endl; - AliceInp << "*Generated from call: SetProcess('COMP',0)"; - AliceInp << endl; - } - else { - AliceInp << "*"; - AliceInp << endl; - AliceInp << "*Illegal flag value in SetProcess('COMP',?) call."; - AliceInp << endl; - AliceInp << "*No FLUKA card generated"; - AliceInp << endl; - } - } // end of else if (strncmp(&sProcessFlag[i][0],"COMP",4) == 0) - - // decay - // G3 default value: 1 - // G4 process: G4Decay - // - // Particles: all which decay is applicable for - // Physics: General - // flag = 0 no decays - // flag = 1 decays, secondaries processed - // flag = 2 decays, no secondaries stored - //gMC ->SetProcess("DCAY",1); // not available - else if ((strncmp(&sProcessFlag[i][0],"DCAY",4) == 0) && iProcessValue[i] == 1) - cout << "SetProcess for flag=" << &sProcessFlag[i][0] << " value=" << iProcessValue[i] << " not avaliable!" << endl; - - // delta-ray - // G3 default value: 2 - // !! G4 treats delta rays in different way - // G4 processes: G4eIonisation/G4IeIonization, - // G4MuIonisation/G4IMuIonization, - // G4hIonisation/G4IhIonisation - // Particles: charged - // Physics: EM - // flag = 0 no energy loss - // flag = 1 restricted energy loss fluctuations - // flag = 2 complete energy loss fluctuations - // flag = 3 same as 1 - // flag = 4 no energy loss fluctuations - // gMC ->SetProcess("DRAY",0); // DELTARAY 1.E+6 0. 0. 3. lastmat 0. - else if (strncmp(&sProcessFlag[i][0],"DRAY",4) == 0) { - if (iProcessValue[i] == 0 || iProcessValue[i] == 4) { - AliceInp << "*"; - AliceInp << endl; - AliceInp << "*Kinetic energy threshold (GeV) for delta ray production"; - AliceInp << endl; - AliceInp << "*Generated from call: SetProcess('DRAY',0) or SetProcess('DRAY',4)"; - AliceInp << endl; - AliceInp << "*No delta ray production by muons - threshold set artificially high"; - AliceInp << endl; - AliceInp << setw(10) << "DELTARAY "; - AliceInp << setiosflags(ios::scientific) << setprecision(5); - AliceInp << setw(10) << 1.0e+6; // kinetic energy threshold (GeV) for delta ray production (discrete energy transfer) - AliceInp << setiosflags(ios::fixed) << setiosflags(ios::showpoint) << setprecision(1); - AliceInp << setw(10) << 0.0; // ignored - AliceInp << setw(10) << 0.0; // ignored - AliceInp << setw(10) << 3.0; // lower bound of the material indices in which the respective thresholds apply - AliceInp << setw(10) << setprecision(2); - AliceInp << setw(10) << fLastMaterial; // upper bound of the material indices in which the respective thresholds apply - AliceInp << setprecision(1); - AliceInp << setw(10) << 1.0; // step length in assigning indices - AliceInp << endl; - } - else if (iProcessValue[i] == 1 || iProcessValue[i] == 2 || iProcessValue[i] == 3) { - AliceInp << "*"; - AliceInp << endl; - AliceInp << "*Kinetic energy threshold (GeV) for delta ray production"; - AliceInp << endl; - AliceInp << "*Generated from call: SetProcess('DRAY',flag), flag=1,2,3"; - AliceInp << endl; - AliceInp << "*Delta ray production by muons switched on"; - AliceInp << endl; - AliceInp << "*Energy threshold set by call SetCut('DCUTM',cut) or set to 0."; - AliceInp << endl; - AliceInp << setw(10) << "DELTARAY "; - AliceInp << setiosflags(ios::scientific) << setprecision(5); - fCut = 1.0e+6; - for (j=0; jSetProcess("HADR",1); // ??? hadronic process - //Select pure GEANH (HADR 1) or GEANH/NUCRIN (HADR 3) ????? - else if (strncmp(&sProcessFlag[i][0],"HADR",4) == 0) { - if (iProcessValue[i] == 1 || iProcessValue[i] == 2) { - AliceInp << "*"; - AliceInp << endl; - AliceInp << "*Hadronic interaction is ON by default in FLUKA"; - AliceInp << endl; - AliceInp << "*No FLUKA card generated"; - AliceInp << endl; - } - else if (iProcessValue[i] == 0) { - AliceInp << "*"; - AliceInp << endl; - AliceInp << "*Hadronic interaction is set OFF"; - AliceInp << endl; - AliceInp << "*Generated from call: SetProcess('HADR',0);"; - AliceInp << endl; - AliceInp << setw(10) << "MULSOPT "; - AliceInp << setiosflags(ios::scientific) << setprecision(5); - AliceInp << setiosflags(ios::fixed) << setiosflags(ios::showpoint) << setprecision(1); - AliceInp << setw(10) << 0.0; // ignored - AliceInp << setw(10) << 3.0; // multiple scattering for hadrons and muons is completely suppressed - AliceInp << setw(10) << 0.0; // no spin-relativistic corrections - AliceInp << setw(10) << 3.0; // lower bound of the material indices in which the respective thresholds apply - AliceInp << setprecision(2); - AliceInp << setw(10) << fLastMaterial; // upper bound of the material indices in which the respective thresholds apply - AliceInp << endl; - - } - else { - AliceInp << "*"; - AliceInp << endl; - AliceInp << "*Illegal flag value in SetProcess('HADR',?) call."; - AliceInp << endl; - AliceInp << "*No FLUKA card generated"; - AliceInp << endl; - } - } // end of else if (strncmp(&sProcessFlag[i][0],"HADR",4) == 0) - - - // energy loss - // G3 default value: 2 - // G4 processes: G4eIonisation/G4IeIonization, - // G4MuIonisation/G4IMuIonization, - // G4hIonisation/G4IhIonisation - // - // Particles: charged - // Physics: EM - // flag=0 no energy loss - // flag=1 restricted energy loss fluctuations - // flag=2 complete energy loss fluctuations - // flag=3 same as 1 - // flag=4 no energy loss fluctuations - // If the value ILOSS is changed, then (in G3) cross-sections and energy - // loss tables must be recomputed via the command 'PHYSI' - // gMC ->SetProcess("LOSS",2); // ??? IONFLUCT ? energy loss - else if (strncmp(&sProcessFlag[i][0],"LOSS",4) == 0) { - if (iProcessValue[i] == 2) { // complete energy loss fluctuations - AliceInp << "*"; - AliceInp << endl; - AliceInp << "*Complete energy loss fluctuations do not exist in FLUKA"; - AliceInp << endl; - AliceInp << "*Generated from call: SetProcess('LOSS',2);"; - AliceInp << endl; - AliceInp << "*flag=2=complete energy loss fluctuations"; - AliceInp << endl; - AliceInp << "*No input card generated"; - AliceInp << endl; - } - else if (iProcessValue[i] == 1 || iProcessValue[i] == 3) { // restricted energy loss fluctuations - AliceInp << "*"; - AliceInp << endl; - AliceInp << "*Restricted energy loss fluctuations"; - AliceInp << endl; - AliceInp << "*Generated from call: SetProcess('LOSS',1) or SetProcess('LOSS',3)"; - AliceInp << endl; - AliceInp << setw(10) << "IONFLUCT "; - AliceInp << setiosflags(ios::scientific) << setprecision(5); - AliceInp << setiosflags(ios::fixed) << setiosflags(ios::showpoint) << setprecision(1); - AliceInp << setw(10) << 1.0; // restricted energy loss fluctuations (for hadrons and muons) switched on - AliceInp << setw(10) << 1.0; // restricted energy loss fluctuations (for e+ and e-) switched on - AliceInp << setw(10) << 1.0; // minimal accuracy - AliceInp << setw(10) << 3.0; // lower bound of the material indices in which the respective thresholds apply - AliceInp << setprecision(2); - AliceInp << setw(10) << fLastMaterial; // upper bound of the material indices in which the respective thresholds apply - AliceInp << endl; - } - else if (iProcessValue[i] == 4) { // no energy loss fluctuations - AliceInp << "*"; - AliceInp << endl; - AliceInp << "*No energy loss fluctuations"; - AliceInp << endl; - AliceInp << "*Generated from call: SetProcess('LOSS',4)"; - AliceInp << endl; - AliceInp << setw(10) << -1.0; // restricted energy loss fluctuations (for hadrons and muons) switched off - AliceInp << setw(10) << -1.0; // restricted energy loss fluctuations (for e+ and e-) switched off - AliceInp << setw(10) << 1.0; // minimal accuracy - AliceInp << setw(10) << 3.0; // lower bound of the material indices in which the respective thresholds apply - AliceInp << setprecision(2); - AliceInp << setw(10) << fLastMaterial; // upper bound of the material indices in which the respective thresholds apply - AliceInp << endl; - } - else { - AliceInp << "*"; - AliceInp << endl; - AliceInp << "*Illegal flag value in SetProcess('LOSS',?) call."; - AliceInp << endl; - AliceInp << "*No FLUKA card generated"; - AliceInp << endl; - } - } // end of else if (strncmp(&sProcessFlag[i][0],"LOSS",4) == 0) - - - // multiple scattering - // G3 default value: 1 - // G4 process: G4MultipleScattering/G4IMultipleScattering - // - // Particles: charged - // Physics: EM - // flag = 0 no multiple scattering - // flag = 1 Moliere or Coulomb scattering - // flag = 2 Moliere or Coulomb scattering - // flag = 3 Gaussian scattering - // gMC ->SetProcess("MULS",1); // MULSOPT multiple scattering - else if (strncmp(&sProcessFlag[i][0],"MULS",4) == 0) { - if (iProcessValue[i] == 1 || iProcessValue[i] == 2 || iProcessValue[i] == 3) { - AliceInp << "*"; - AliceInp << endl; - AliceInp << "*Multiple scattering is ON by default for e+e- and for hadrons/muons"; - AliceInp << endl; - AliceInp << "*No FLUKA card generated"; - AliceInp << endl; - } - else if (iProcessValue[i] == 0) { - AliceInp << "*"; - AliceInp << endl; - AliceInp << "*Multiple scattering is set OFF"; - AliceInp << endl; - AliceInp << "*Generated from call: SetProcess('MULS',0);"; - AliceInp << endl; - AliceInp << setw(10) << "MULSOPT "; - AliceInp << setiosflags(ios::scientific) << setprecision(5); - AliceInp << setiosflags(ios::fixed) << setiosflags(ios::showpoint) << setprecision(1); - AliceInp << setw(10) << 0.0; // ignored - AliceInp << setw(10) << 3.0; // multiple scattering for hadrons and muons is completely suppressed - AliceInp << setw(10) << 3.0; // multiple scattering for e+ and e- is completely suppressed - AliceInp << setw(10) << 3.0; // lower bound of the material indices in which the respective thresholds apply - AliceInp << setprecision(2); - AliceInp << setw(10) << fLastMaterial; // upper bound of the material indices in which the respective thresholds apply - AliceInp << endl; - } - else { - AliceInp << "*"; - AliceInp << endl; - AliceInp << "*Illegal flag value in SetProcess('MULS',?) call."; - AliceInp << endl; - AliceInp << "*No FLUKA card generated"; - AliceInp << endl; - } - } // end of else if (strncmp(&sProcessFlag[i][0],"MULS",4) == 0) - - - // muon nuclear interaction - // G3 default value: 0 - // G4 processes: G4MuNuclearInteraction, - // G4MuonMinusCaptureAtRest - // - // Particles: mu - // Physics: Not set - // flag = 0 no muon-nuclear interaction - // flag = 1 nuclear interaction, secondaries processed - // flag = 2 nuclear interaction, secondaries not processed - // gMC ->SetProcess("MUNU",1); // MUPHOTON 1. 0. 0. 3. lastmat - else if (strncmp(&sProcessFlag[i][0],"MUNU",4) == 0) { - if (iProcessValue[i] == 1) { - AliceInp << "*"; - AliceInp << endl; - AliceInp << "*Muon nuclear interactions with production of secondary hadrons"; - AliceInp << endl; - AliceInp << "*Generated from call: SetProcess('MUNU',1);"; - AliceInp << endl; - AliceInp << setw(10) << "MUPHOTON "; - AliceInp << setiosflags(ios::scientific) << setprecision(5); - AliceInp << setiosflags(ios::fixed) << setiosflags(ios::showpoint) << setprecision(1); - AliceInp << setw(10) << 1.0; // full simulation of muon nuclear interactions and production of secondary hadrons - AliceInp << setw(10) << 0.0; // ratio of longitudinal to transverse virtual photon cross-section - Default = 0.25. - AliceInp << setw(10) << 0.0; // fraction of rho-like interactions ( must be < 1) - Default = 0.75. - AliceInp << setprecision(1); - AliceInp << setw(10) << 3.0; // lower bound of the material indices in which the respective thresholds apply - AliceInp << setprecision(2); - AliceInp << setw(10) << fLastMaterial; // upper bound of the material indices in which the respective thresholds apply - AliceInp << endl; - } - else if (iProcessValue[i] == 2) { - AliceInp << "*"; - AliceInp << endl; - AliceInp << "*Muon nuclear interactions without production of secondary hadrons"; - AliceInp << endl; - AliceInp << "*Generated from call: SetProcess('MUNU',2);"; - AliceInp << endl; - AliceInp << setw(10) << "MUPHOTON "; - AliceInp << setiosflags(ios::scientific) << setprecision(5); - AliceInp << setiosflags(ios::fixed) << setiosflags(ios::showpoint) << setprecision(1); - AliceInp << setw(10) << 2.0; // full simulation of muon nuclear interactions and production of secondary hadrons - AliceInp << setw(10) << 0.0; // ratio of longitudinal to transverse virtual photon cross-section - Default = 0.25. - AliceInp << setw(10) << 0.0; // fraction of rho-like interactions ( must be < 1) - Default = 0.75. - AliceInp << setprecision(1); - AliceInp << setw(10) << 3.0; // lower bound of the material indices in which the respective thresholds apply - AliceInp << setw(10) << fLastMaterial; // upper bound of the material indices in which the respective thresholds apply - AliceInp << endl; - } - else if (iProcessValue[i] == 0) { - AliceInp << "*"; - AliceInp << endl; - AliceInp << "*No muon nuclear interaction - no FLUKA card generated"; - AliceInp << endl; - AliceInp << "*Generated from call: SetProcess('MUNU',0)"; - AliceInp << endl; - } - else { - AliceInp << "*"; - AliceInp << endl; - AliceInp << "*Illegal flag value in SetProcess('MUNU',?) call."; - AliceInp << endl; - AliceInp << "*No FLUKA card generated"; - AliceInp << endl; - } - } // end of else if (strncmp(&sProcessFlag[i][0],"MUNU",4) == 0) - - - // photofission - // G3 default value: 0 - // G4 process: ?? - // - // Particles: gamma - // Physics: ?? - // gMC ->SetProcess("PFIS",0); // PHOTONUC -1. 0. 0. 3. lastmat 0. - // flag = 0 no photon fission - // flag = 1 photon fission, secondaries processed - // flag = 2 photon fission, no secondaries stored - else if (strncmp(&sProcessFlag[i][0],"PFIS",4) == 0) { - if (iProcessValue[i] == 0) { - AliceInp << "*"; - AliceInp << endl; - AliceInp << "*No photonuclear interactions"; - AliceInp << endl; - AliceInp << "*Generated from call: SetProcess('PFIS',0);"; - AliceInp << endl; - AliceInp << setw(10) << "PHOTONUC "; - AliceInp << setiosflags(ios::fixed) << setiosflags(ios::showpoint) << setprecision(1); - AliceInp << setw(10) << -1.0; // no photonuclear interactions - AliceInp << setw(10) << 0.0; // not used - AliceInp << setw(10) << 0.0; // not used - AliceInp << setw(10) << 3.0; // upper bound of the material indices in which the respective thresholds apply - AliceInp << setprecision(2); - AliceInp << setw(10) << fLastMaterial; - AliceInp << setprecision(1); // upper bound of the material indices in which the respective thresholds apply - AliceInp << setprecision(1); - AliceInp << setw(10) << 1.0; // step length in assigning indices - AliceInp << endl; - } - else if (iProcessValue[i] == 1) { - AliceInp << "*"; - AliceInp << endl; - AliceInp << "*Photon nuclear interactions are activated at all energies"; - AliceInp << endl; - AliceInp << "*Generated from call: SetProcess('PFIS',1);"; - AliceInp << endl; - AliceInp << setw(10) << "PHOTONUC "; - AliceInp << setiosflags(ios::fixed) << setiosflags(ios::showpoint) << setprecision(1); - AliceInp << setw(10) << 1.0; // photonuclear interactions are activated at all energies - AliceInp << setw(10) << 0.0; // not used - AliceInp << setw(10) << 0.0; // not used - AliceInp << setprecision(2); - AliceInp << setw(10) << 3.0; // upper bound of the material indices in which the respective thresholds apply - AliceInp << setw(10) << fLastMaterial; - AliceInp << setprecision(1); // upper bound of the material indices in which the respective thresholds apply - AliceInp << setprecision(1); - AliceInp << setw(10) << 1.0; // step length in assigning indices - AliceInp << endl; - } - else if (iProcessValue[i] == 0) { - AliceInp << "*"; - AliceInp << endl; - AliceInp << "*No photofission - no FLUKA card generated"; - AliceInp << endl; - AliceInp << "*Generated from call: SetProcess('PFIS',0)"; - AliceInp << endl; - } - else { - AliceInp << "*"; - AliceInp << endl; - AliceInp << "*Illegal flag value in SetProcess('PFIS',?) call."; - AliceInp << endl; - AliceInp << "*No FLUKA card generated"; - AliceInp << endl; - } - } - - - // photo electric effect - // G3 default value: 1 - // G4 processes: G4PhotoElectricEffect - // G4LowEnergyPhotoElectric - // Particles: gamma - // Physics: EM - // flag = 0 no photo electric effect - // flag = 1 photo electric effect, electron processed - // flag = 2 photo electric effect, no electron stored - // gMC ->SetProcess("PHOT",1); // EMFCUT 0. -1. 0. 3. lastmat 0. PHOT-THR - else if (strncmp(&sProcessFlag[i][0],"PHOT",4) == 0) { - if (iProcessValue[i] == 1 || iProcessValue[i] == 2) { - AliceInp << "*"; - AliceInp << endl; - AliceInp << "*Photo electric effect is activated"; - AliceInp << endl; - AliceInp << "*Generated from call: SetProcess('PHOT',1);"; - AliceInp << endl; - AliceInp << setw(10) << "EMFCUT "; - AliceInp << setiosflags(ios::fixed) << setiosflags(ios::showpoint) << setprecision(1); - AliceInp << setw(10) << 0.0; // ignored - AliceInp << setw(10) << -1.0; // resets to default=0. - AliceInp << setw(10) << 0.0; // ignored - AliceInp << setw(10) << 3.0; // upper bound of the material indices in which the respective thresholds apply - AliceInp << setprecision(2); - AliceInp << setw(10) << fLastMaterial; // upper bound of the material indices in which the respective thresholds apply - AliceInp << setprecision(1); - AliceInp << setw(10) << 1.0; // step length in assigning indices - AliceInp << setw(8) << "PHOT-THR"; - AliceInp << endl; - } - else if (iProcessValue[i] == 0) { - AliceInp << "*"; - AliceInp << endl; - AliceInp << "*No photo electric effect - no FLUKA card generated"; - AliceInp << endl; - AliceInp << "*Generated from call: SetProcess('PHOT',0)"; - AliceInp << endl; - } - else { - AliceInp << "*"; - AliceInp << endl; - AliceInp << "*Illegal flag value in SetProcess('PHOT',?) call."; - AliceInp << endl; - AliceInp << "*No FLUKA card generated"; - AliceInp << endl; - } - } // else if (strncmp(&sProcessFlag[i][0],"PHOT",4) == 0) - - - // Rayleigh scattering - // G3 default value: 0 - // G4 process: G4OpRayleigh - // - // Particles: optical photon - // Physics: Optical - // flag = 0 Rayleigh scattering off - // flag = 1 Rayleigh scattering on - //xx gMC ->SetProcess("RAYL",1); - else if (strncmp(&sProcessFlag[i][0],"RAYL",4) == 0) { - if (iProcessValue[i] == 1) { - AliceInp << "*"; - AliceInp << endl; - AliceInp << "*Rayleigh scattering is ON by default in FLUKA"; - AliceInp << endl; - AliceInp << "*No FLUKA card generated"; - AliceInp << endl; - } - else if (iProcessValue[i] == 0) { - AliceInp << "*"; - AliceInp << endl; - AliceInp << "*Rayleigh scattering is set OFF"; - AliceInp << endl; - AliceInp << "*Generated from call: SetProcess('RAYL',0);"; - AliceInp << endl; - AliceInp << setw(10) << "EMFRAY "; - AliceInp << setiosflags(ios::scientific) << setprecision(5); - AliceInp << setiosflags(ios::fixed) << setiosflags(ios::showpoint) << setprecision(1); - AliceInp << setw(10) << -1.0; // no Rayleigh scattering and no binding corrections for Compton - AliceInp << setw(10) << 3.0; // lower bound of the material indices in which the respective thresholds apply - AliceInp << setprecision(2); - AliceInp << setw(10) << fLastMaterial; // upper bound of the material indices in which the respective thresholds apply - AliceInp << endl; - } - else { - AliceInp << "*"; - AliceInp << endl; - AliceInp << "*Illegal flag value in SetProcess('RAYL',?) call."; - AliceInp << endl; - AliceInp << "*No FLUKA card generated"; - AliceInp << endl; - } - } // end of else if (strncmp(&sProcessFlag[i][0],"RAYL",4) == 0) - - - // synchrotron radiation in magnetic field - // G3 default value: 0 - // G4 process: G4SynchrotronRadiation - // - // Particles: ?? - // Physics: Not set - // flag = 0 no synchrotron radiation - // flag = 1 synchrotron radiation - //xx gMC ->SetProcess("SYNC",1); // synchrotron radiation generation - else if (strncmp(&sProcessFlag[i][0],"SYNC",4) == 0) { - AliceInp << "*"; - AliceInp << endl; - AliceInp << "*Synchrotron radiation generation is NOT implemented in FLUKA"; - AliceInp << endl; - AliceInp << "*No FLUKA card generated"; - AliceInp << endl; - } - - // Automatic calculation of tracking medium parameters - // flag = 0 no automatic calculation - // flag = 1 automatic calculation - //xx gMC ->SetProcess("AUTO",1); // ??? automatic computation of the tracking medium parameters - else if (strncmp(&sProcessFlag[i][0],"AUTO",4) == 0) { - AliceInp << "*"; - AliceInp << endl; - AliceInp << "*Automatic calculation of tracking medium parameters is always ON in FLUKA"; - AliceInp << endl; - AliceInp << "*No FLUKA card generated"; - AliceInp << endl; + flukamat: + while ((fgets(sLine,255,pFlukaVmcFlukaMat)) != NULL) { // copy flukaMat.inp file + fprintf(pFlukaVmcInp,"%s\n",sLine); } - - - // To control energy loss fluctuation model - // flag = 0 Urban model - // flag = 1 PAI model - // flag = 2 PAI+ASHO model (not active at the moment) - //xx gMC ->SetProcess("STRA",1); // ??? energy fluctuation model - else if (strncmp(&sProcessFlag[i][0],"STRA",4) == 0) { - if (iProcessValue[i] == 0 || iProcessValue[i] == 2 || iProcessValue[i] == 3) { - AliceInp << "*"; - AliceInp << endl; - AliceInp << "*Ionization energy losses calculation is activated"; - AliceInp << endl; - AliceInp << "*Generated from call: SetProcess('STRA',n);, n=0,1,2"; - AliceInp << endl; - AliceInp << setw(10) << "IONFLUCT "; - AliceInp << setiosflags(ios::fixed) << setiosflags(ios::showpoint) << setprecision(1); - AliceInp << setw(10) << 1.0; // restricted energy loss fluctuations - // (for hadrons and muons) switched on - AliceInp << setw(10) << 1.0; // restricted energy loss fluctuations - // (for e+ and e-) switched on - AliceInp << setw(10) << 1.0; // minimal accuracy - AliceInp << setw(10) << 3.0; // upper bound of the material indices in - // which the respective thresholds apply - AliceInp << setprecision(2); - AliceInp << setw(10) << fLastMaterial; // upper bound of the material indices in which the respective thresholds apply - AliceInp << setprecision(1); - AliceInp << setw(10) << 1.0; // step length in assigning indices - AliceInp << endl; - } - else { - AliceInp << "*"; - AliceInp << endl; - AliceInp << "*Illegal flag value in SetProcess('STRA',?) call."; - AliceInp << endl; - AliceInp << "*No FLUKA card generated"; - AliceInp << endl; - } - } // else if (strncmp(&sProcessFlag[i][0],"STRA",4) == 0) - - - - - else { // processes not yet treated - - // light photon absorption (Cerenkov photons) - // it is turned on when Cerenkov process is turned on - // G3 default value: 0 - // G4 process: G4OpAbsorption, G4OpBoundaryProcess - // - // Particles: optical photon - // Physics: Optical - // flag = 0 no absorption of Cerenkov photons - // flag = 1 absorption of Cerenkov photons - // gMC ->SetProcess("LABS",2); // ??? Cerenkov light absorption - - - - cout << "SetProcess for flag=" << &sProcessFlag[i][0] << " value=" << iProcessValue[i] << " not yet implemented!" << endl; - } - } //end of loop number of SetProcess calls + + while ((fgets(sLine,255,pFlukaVmcCoreInp)) != NULL) { + if (strncmp(sLine,"START",5) != 0) + fprintf(pFlukaVmcInp,"%s\n",sLine); + else { + sscanf(sLine+10,"%10f",&fEventsPerRun); + goto fin; + } + } //end of while until START card + + fin: - -// Loop over number of SetCut calls - for (Int_t i=0; iSetCut("CUTGAM",cut); // cut for gammas - else if (strncmp(&sCutFlag[i][0],"CUTGAM",6) == 0) { - AliceInp << "*"; - AliceInp << endl; - AliceInp << "*Cut for gamma"; - AliceInp << endl; - AliceInp << "*Generated from call: SetCut('CUTGAM',cut);"; - AliceInp << endl; - AliceInp << setw(10) << "PART-THR "; - AliceInp << setiosflags(ios::scientific) << setprecision(5); - AliceInp << setw(10) << -fCutValue[i]; - AliceInp << setiosflags(ios::fixed) << setiosflags(ios::showpoint) << setprecision(1); - AliceInp << setw(10) << 7.0; - AliceInp << endl; - } + +// Pass information to configuration objects + + Float_t fLastMaterial = fGeom->GetLastMaterialIndex(); + TFlukaConfigOption::SetStaticInfo(pFlukaVmcInp, 3, fLastMaterial, fGeom); + + TIter next(fUserConfig); + TFlukaConfigOption* proc; + while((proc = dynamic_cast (next()))) proc->WriteFlukaInputCards(); +// +// Process Fluka specific scoring options +// + TFlukaScoringOption::SetStaticInfo(pFlukaVmcInp, fGeom); + Float_t loginp = 49.0; + Int_t inp = 0; + Int_t nscore = fUserScore->GetEntries(); + + TFlukaScoringOption *mopo = 0x0; + TFlukaScoringOption *mopi = 0x0; - // electrons - // G4 particles: "e-" - // ?? positrons - // G3 default value: 0.001 GeV - //gMC ->SetCut("CUTELE",cut); // cut for e+,e- - else if (strncmp(&sCutFlag[i][0],"CUTELE",6) == 0) { - AliceInp << "*"; - AliceInp << endl; - AliceInp << "*Cut for electrons"; - AliceInp << endl; - AliceInp << "*Generated from call: SetCut('CUTELE',cut);"; - AliceInp << endl; - AliceInp << setw(10) << "PART-THR "; - AliceInp << setiosflags(ios::scientific) << setprecision(5); - AliceInp << setw(10) << -fCutValue[i]; - AliceInp << setiosflags(ios::fixed) << setiosflags(ios::showpoint) << setprecision(1); - AliceInp << setw(10) << 3.0; - AliceInp << setw(10) << 4.0; - AliceInp << setw(10) << 1.0; - AliceInp << endl; - } + for (Int_t isc = 0; isc < nscore; isc++) + { + mopo = dynamic_cast (fUserScore->At(isc)); + char* fileName = mopo->GetFileName(); + Int_t size = strlen(fileName); + Float_t lun = -1.; +// +// Check if new output file has to be opened + for (Int_t isci = 0; isci < isc; isci++) { - // neutral hadrons - // G4 particles: of type "baryon", "meson", "nucleus" with zero charge - // G3 default value: 0.01 GeV - //gMC ->SetCut("CUTNEU",cut); // cut for neutral hadrons - else if (strncmp(&sCutFlag[i][0],"CUTNEU",6) == 0) { - AliceInp << "*"; - AliceInp << endl; - AliceInp << "*Cut for neutral hadrons"; - AliceInp << endl; - AliceInp << "*Generated from call: SetCut('CUTNEU',cut);"; - AliceInp << endl; - AliceInp << setw(10) << "PART-THR "; - AliceInp << setiosflags(ios::scientific) << setprecision(5); - AliceInp << setw(10) << -fCutValue[i]; - AliceInp << setiosflags(ios::fixed) << setiosflags(ios::showpoint) << setprecision(1); - AliceInp << setw(10) << 8.0; // Neutron - AliceInp << setw(10) << 9.0; // Antineutron - AliceInp << endl; - AliceInp << setw(10) << "PART-THR "; - AliceInp << setiosflags(ios::scientific) << setprecision(5); - AliceInp << setw(10) << -fCutValue[i]; - AliceInp << setiosflags(ios::fixed) << setiosflags(ios::showpoint) << setprecision(2); - AliceInp << setw(10) << 12.0; // Kaon zero long - AliceInp << setw(10) << 12.0; // Kaon zero long - AliceInp << endl; - AliceInp << setw(10) << "PART-THR "; - AliceInp << setiosflags(ios::scientific) << setprecision(5); - AliceInp << setw(10) << -fCutValue[i]; - AliceInp << setiosflags(ios::fixed) << setiosflags(ios::showpoint) << setprecision(2); - AliceInp << setw(10) << 17.0; // Lambda, 18=Antilambda - AliceInp << setw(10) << 19.0; // Kaon zero short - AliceInp << endl; - AliceInp << setw(10) << "PART-THR "; - AliceInp << setiosflags(ios::scientific) << setprecision(5); - AliceInp << setw(10) << -fCutValue[i]; - AliceInp << setiosflags(ios::fixed) << setiosflags(ios::showpoint) << setprecision(2); - AliceInp << setw(10) << 22.0; // Sigma zero, Pion zero, Kaon zero - AliceInp << setw(10) << 25.0; // Antikaon zero - AliceInp << endl; - AliceInp << setw(10) << "PART-THR "; - AliceInp << setiosflags(ios::scientific) << setprecision(5); - AliceInp << setw(10) << -fCutValue[i]; - AliceInp << setiosflags(ios::fixed) << setiosflags(ios::showpoint) << setprecision(2); - AliceInp << setw(10) << 32.0; // Antisigma zero - AliceInp << setw(10) << 32.0; // Antisigma zero - AliceInp << endl; - AliceInp << setw(10) << "PART-THR "; - AliceInp << setiosflags(ios::scientific) << setprecision(5); - AliceInp << setw(10) << -fCutValue[i]; - AliceInp << setiosflags(ios::fixed) << setiosflags(ios::showpoint) << setprecision(2); - AliceInp << setw(10) << 34.0; // Xi zero - AliceInp << setw(10) << 35.0; // AntiXi zero - AliceInp << endl; - AliceInp << setw(10) << "PART-THR "; - AliceInp << setiosflags(ios::scientific) << setprecision(5); - AliceInp << setw(10) << -fCutValue[i]; - AliceInp << setiosflags(ios::fixed) << setiosflags(ios::showpoint) << setprecision(2); - AliceInp << setw(10) << 47.0; // D zero - AliceInp << setw(10) << 48.0; // AntiD zero - AliceInp << endl; - AliceInp << setw(10) << "PART-THR "; - AliceInp << setiosflags(ios::scientific) << setprecision(5); - AliceInp << setw(10) << -fCutValue[i]; - AliceInp << setiosflags(ios::fixed) << setiosflags(ios::showpoint) << setprecision(2); - AliceInp << setw(10) << 53.0; // Xi_c zero - AliceInp << setw(10) << 53.0; // Xi_c zero - AliceInp << endl; - AliceInp << setw(10) << "PART-THR "; - AliceInp << setiosflags(ios::scientific) << setprecision(5); - AliceInp << setw(10) << -fCutValue[i]; - AliceInp << setiosflags(ios::fixed) << setiosflags(ios::showpoint) << setprecision(2); - AliceInp << setw(10) << 55.0; // Xi'_c zero - AliceInp << setw(10) << 56.0; // Omega_c zero - AliceInp << endl; - AliceInp << setw(10) << "PART-THR "; - AliceInp << setiosflags(ios::scientific) << setprecision(5); - AliceInp << setw(10) << -fCutValue[i]; - AliceInp << setiosflags(ios::fixed) << setiosflags(ios::showpoint) << setprecision(2); - AliceInp << setw(10) << 59.0; // AntiXi_c zero - AliceInp << setw(10) << 59.0; // AntiXi_c zero - AliceInp << endl; - AliceInp << setw(10) << "PART-THR "; - AliceInp << setiosflags(ios::scientific) << setprecision(5); - AliceInp << setw(10) << -fCutValue[i]; - AliceInp << setiosflags(ios::fixed) << setiosflags(ios::showpoint) << setprecision(2); - AliceInp << setw(10) << 61.0; // AntiXi'_c zero - AliceInp << setw(10) << 62.0; // AntiOmega_c zero - AliceInp << endl; + + mopi = dynamic_cast (fUserScore->At(isci)); + if(strncmp(mopi->GetFileName(), fileName, size)==0) { + // + // No, the file already exists + lun = mopi->GetLun(); + mopo->SetLun(lun); + break; + } + } // inner loop + + if (lun == -1.) { + // Open new output file + inp++; + mopo->SetLun(loginp + inp); + mopo->WriteOpenFlukaFile(); + } + mopo->WriteFlukaInputCards(); } + +// Add START and STOP card + fprintf(pFlukaVmcInp,"START %10.1f\n",fEventsPerRun); + fprintf(pFlukaVmcInp,"STOP \n"); + + +// Close files + fclose(pFlukaVmcCoreInp); + fclose(pFlukaVmcFlukaMat); + fclose(pFlukaVmcInp); - // charged hadrons - // G4 particles: of type "baryon", "meson", "nucleus" with non-zero charge - // G3 default value: 0.01 GeV - //gMC ->SetCut("CUTHAD",cut); // cut for charged hadrons - else if (strncmp(&sCutFlag[i][0],"CUTHAD",6) == 0) { - AliceInp << "*"; - AliceInp << endl; - AliceInp << "*Cut for charged hadrons"; - AliceInp << endl; - AliceInp << "*Generated from call: SetCut('CUTHAD',cut);"; - AliceInp << endl; - AliceInp << setw(10) << "PART-THR "; - AliceInp << setiosflags(ios::scientific) << setprecision(5); - AliceInp << setw(10) << -fCutValue[i]; - AliceInp << setiosflags(ios::fixed) << setiosflags(ios::showpoint) << setprecision(1); - AliceInp << setw(10) << 1.0; // Proton - AliceInp << setw(10) << 2.0; // Antiproton - AliceInp << endl; - AliceInp << setw(10) << "PART-THR "; - AliceInp << setiosflags(ios::scientific) << setprecision(5); - AliceInp << setw(10) << -fCutValue[i]; - AliceInp << setiosflags(ios::fixed) << setiosflags(ios::showpoint) << setprecision(2); - AliceInp << setw(10) << 13.0; // Positive Pion, Negative Pion, Positive Kaon - AliceInp << setw(10) << 16.0; // Negative Kaon - AliceInp << endl; - AliceInp << setw(10) << "PART-THR "; - AliceInp << setiosflags(ios::scientific) << setprecision(5); - AliceInp << setw(10) << -fCutValue[i]; - AliceInp << setiosflags(ios::fixed) << setiosflags(ios::showpoint) << setprecision(2); - AliceInp << setw(10) << 20.0; // Negative Sigma - AliceInp << setw(10) << 16.0; // Positive Sigma - AliceInp << endl; - AliceInp << setw(10) << "PART-THR "; - AliceInp << setiosflags(ios::scientific) << setprecision(5); - AliceInp << setw(10) << -fCutValue[i]; - AliceInp << setiosflags(ios::fixed) << setiosflags(ios::showpoint) << setprecision(2); - AliceInp << setw(10) << 31.0; // Antisigma minus - AliceInp << setw(10) << 33.0; // Antisigma plus - AliceInp << setprecision(1); - AliceInp << setw(10) << 2.0; // step length - AliceInp << endl; - AliceInp << setw(10) << "PART-THR "; - AliceInp << setiosflags(ios::scientific) << setprecision(5); - AliceInp << setw(10) << -fCutValue[i]; - AliceInp << setiosflags(ios::fixed) << setiosflags(ios::showpoint) << setprecision(2); - AliceInp << setw(10) << 36.0; // Negative Xi, Positive Xi, Omega minus - AliceInp << setw(10) << 39.0; // Antiomega - AliceInp << endl; - AliceInp << setw(10) << "PART-THR "; - AliceInp << setiosflags(ios::scientific) << setprecision(5); - AliceInp << setw(10) << -fCutValue[i]; - AliceInp << setiosflags(ios::fixed) << setiosflags(ios::showpoint) << setprecision(2); - AliceInp << setw(10) << 45.0; // D plus - AliceInp << setw(10) << 46.0; // D minus - AliceInp << endl; - AliceInp << setw(10) << "PART-THR "; - AliceInp << setiosflags(ios::scientific) << setprecision(5); - AliceInp << setw(10) << -fCutValue[i]; - AliceInp << setiosflags(ios::fixed) << setiosflags(ios::showpoint) << setprecision(2); - AliceInp << setw(10) << 49.0; // D_s plus, D_s minus, Lambda_c plus - AliceInp << setw(10) << 52.0; // Xi_c plus - AliceInp << endl; - AliceInp << setw(10) << "PART-THR "; - AliceInp << setiosflags(ios::scientific) << setprecision(5); - AliceInp << setw(10) << -fCutValue[i]; - AliceInp << setiosflags(ios::fixed) << setiosflags(ios::showpoint) << setprecision(2); - AliceInp << setw(10) << 54.0; // Xi'_c plus - AliceInp << setw(10) << 60.0; // AntiXi'_c minus - AliceInp << setprecision(1); - AliceInp << setw(10) << 6.0; // step length - AliceInp << endl; - AliceInp << setw(10) << "PART-THR "; - AliceInp << setiosflags(ios::scientific) << setprecision(5); - AliceInp << setw(10) << -fCutValue[i]; - AliceInp << setiosflags(ios::fixed) << setiosflags(ios::showpoint) << setprecision(2); - AliceInp << setw(10) << 57.0; // Antilambda_c minus - AliceInp << setw(10) << 58.0; // AntiXi_c minus - AliceInp << endl; - } - // muons - // G4 particles: "mu+", "mu-" - // G3 default value: 0.01 GeV - //gMC ->SetCut("CUTMUO",cut); // cut for mu+, mu- - else if (strncmp(&sCutFlag[i][0],"CUTMUO",6) == 0) { - AliceInp << "*"; - AliceInp << endl; - AliceInp << "*Cut for muons"; - AliceInp << endl; - AliceInp << "*Generated from call: SetCut('CUTMUO',cut);"; - AliceInp << endl; - AliceInp << setw(10) << "PART-THR "; - AliceInp << setiosflags(ios::scientific) << setprecision(5); - AliceInp << setw(10) << -fCutValue[i]; - AliceInp << setiosflags(ios::fixed) << setiosflags(ios::showpoint) << setprecision(1); - AliceInp << setprecision(2); - AliceInp << setw(10) << 10.0; - AliceInp << setw(10) << 11.0; - AliceInp << endl; - } - // delta-rays by electrons - // G4 particles: "e-" - // G3 default value: 10**4 GeV - // gMC ->SetCut("DCUTE",cut); // cut for deltarays by electrons ??????????????? - else if (strncmp(&sCutFlag[i][0],"DCUTE",5) == 0) { - AliceInp << "*"; - AliceInp << endl; - AliceInp << "*Cut for delta rays by electrons ????????????"; - AliceInp << endl; - AliceInp << "*Generated from call: SetCut('DCUTE',cut);"; - AliceInp << endl; - AliceInp << setw(10) << "EMFCUT "; - AliceInp << setiosflags(ios::scientific) << setprecision(5); - AliceInp << setw(10) << -fCutValue[i]; - AliceInp << setiosflags(ios::fixed) << setiosflags(ios::showpoint) << setprecision(1); - AliceInp << setw(10) << 0.0; - AliceInp << setw(10) << 0.0; - AliceInp << setw(10) << 3.0; - AliceInp << setprecision(2); - AliceInp << setw(10) << fLastMaterial; - AliceInp << setprecision(1); - AliceInp << setw(10) << 1.0; - AliceInp << endl; - } +// +// Initialisation needed for Cerenkov photon production and transport + TObjArray *matList = GetFlukaMaterials(); + Int_t nmaterial = matList->GetEntriesFast(); + fMaterials = new Int_t[nmaterial+3]; - // - // time of flight cut in seconds - // G4 particles: all - // G3 default value: 0.01 GeV - //gMC ->SetCut("TOFMAX",tofmax); // time of flight cuts in seconds - else if (strncmp(&sCutFlag[i][0],"TOFMAX",6) == 0) { - AliceInp << "*"; - AliceInp << endl; - AliceInp << "*Time of flight cuts in seconds"; - AliceInp << endl; - AliceInp << "*Generated from call: SetCut('TOFMAX',tofmax);"; - AliceInp << endl; - AliceInp << setw(10) << "TIME-CUT "; - AliceInp << setiosflags(ios::scientific) << setprecision(5); - AliceInp << setw(10) << fCutValue[i]*1.e9; - AliceInp << setiosflags(ios::fixed) << setiosflags(ios::showpoint) << setprecision(1); - AliceInp << setw(10) << 0.0; - AliceInp << setw(10) << 0.0; - AliceInp << setw(10) << -6.0; // lower bound of the particle numbers for which the transport time cut-off and/or the start signal is to be applied - AliceInp << setprecision(2); - AliceInp << setw(10) << 64.0; // upper bound of the particle numbers for which the transport time cut-off and/or the start signal is to be applied - AliceInp << setprecision(1); - AliceInp << setw(10) << 1.0; // step length in assigning numbers - AliceInp << endl; + for (Int_t im = 0; im < nmaterial; im++) + { + TGeoMaterial* material = dynamic_cast (matList->At(im)); + Int_t idmat = material->GetIndex(); + fMaterials[idmat] = im; } +} // end of InitPhysics - else { - cout << "SetCut for flag=" << &sCutFlag[i][0] << " value=" << fCutValue[i] << " not yet implemented!" << endl; - } - } //end of loop over SeCut calls - -// Add START and STOP card - AliceInp << setw(10) << "START "; - AliceInp << setiosflags(ios::fixed) << setiosflags(ios::showpoint); - AliceInp << setw(10) << fEventsPerRun; - AliceInp << endl; - AliceInp << setw(10) << "STOP "; - AliceInp << endl; -} // end of InitPhysics +//______________________________________________________________________________ +void TFluka::SetMaxStep(Double_t step) +{ +// Set the maximum step size + if (step > 1.e4) return; + + Int_t mreg, latt; + fGeom->GetCurrentRegion(mreg, latt); + STEPSZ.stepmx[mreg - 1] = step; +} -void TFluka::SetMaxStep(Double_t) +Double_t TFluka::MaxStep() const { -// SetMaxStep is dummy procedure in TFluka ! - if (fVerbosityLevel >=3) - cout << "SetMaxStep is dummy procedure in TFluka !" << endl; +// Return the maximum for current medium + Int_t mreg, latt; + fGeom->GetCurrentRegion(mreg, latt); + return (STEPSZ.stepmx[mreg - 1]); } +//______________________________________________________________________________ void TFluka::SetMaxNStep(Int_t) { // SetMaxNStep is dummy procedure in TFluka ! @@ -1967,6 +1132,7 @@ void TFluka::SetMaxNStep(Int_t) cout << "SetMaxNStep is dummy procedure in TFluka !" << endl; } +//______________________________________________________________________________ void TFluka::SetUserDecay(Int_t) { // SetUserDecay is dummy procedure in TFluka ! @@ -1977,6 +1143,7 @@ void TFluka::SetUserDecay(Int_t) // // dynamic properties // +//______________________________________________________________________________ void TFluka::TrackPosition(TLorentzVector& position) const { // Return the current position in the master reference frame of the @@ -1986,13 +1153,13 @@ void TFluka::TrackPosition(TLorentzVector& position) const // TRACKR.ytrack = y-position of the last point // TRACKR.ztrack = z-position of the last point Int_t caller = GetCaller(); - if (caller == 3 || caller == 6 || caller == 11 || caller == 12) { //bxdraw,endraw,usdraw + if (caller == 3 || caller == 6 || caller == 11 || caller == 12 || caller == 50) { //bxdraw,endraw,usdraw,ckov position.SetX(GetXsco()); position.SetY(GetYsco()); position.SetZ(GetZsco()); position.SetT(TRACKR.atrack); } - else if (caller == 4) { // mgdraw + else if (caller == 4) { // mgdraw,mgdraw resuming position.SetX(TRACKR.xtrack[TRACKR.ntrack]); position.SetY(TRACKR.ytrack[TRACKR.ntrack]); position.SetZ(TRACKR.ztrack[TRACKR.ntrack]); @@ -2003,12 +1170,17 @@ void TFluka::TrackPosition(TLorentzVector& position) const position.SetY(TRACKR.ytrack[TRACKR.ntrack]); position.SetZ(TRACKR.ztrack[TRACKR.ntrack]); position.SetT(0); + } else if (caller == 40) { // mgdraw resuming transport + position.SetX(TRACKR.spausr[0]); + position.SetY(TRACKR.spausr[1]); + position.SetZ(TRACKR.spausr[2]); + position.SetT(TRACKR.spausr[3]); } else Warning("TrackPosition","position not available"); } -// +//______________________________________________________________________________ void TFluka::TrackPosition(Double_t& x, Double_t& y, Double_t& z) const { // Return the current position in the master reference frame of the @@ -2018,25 +1190,26 @@ void TFluka::TrackPosition(Double_t& x, Double_t& y, Double_t& z) const // TRACKR.ytrack = y-position of the last point // TRACKR.ztrack = z-position of the last point Int_t caller = GetCaller(); - if (caller == 3 || caller == 6 || caller == 11 || caller == 12) { //bxdraw,endraw,usdraw + if (caller == 3 || caller == 6 || caller == 11 || caller == 12 || caller == 50) { //bxdraw,endraw,usdraw,ckov x = GetXsco(); y = GetYsco(); z = GetZsco(); } - else if (caller == 4) { // mgdraw + else if (caller == 4 || caller == 5) { // mgdraw, sodraw, mgdraw resuming x = TRACKR.xtrack[TRACKR.ntrack]; y = TRACKR.ytrack[TRACKR.ntrack]; z = TRACKR.ztrack[TRACKR.ntrack]; } - else if (caller == 5) { // sodraw - x = TRACKR.xtrack[TRACKR.ntrack]; - y = TRACKR.ytrack[TRACKR.ntrack]; - z = TRACKR.ztrack[TRACKR.ntrack]; + else if (caller == 40) { // mgdraw resuming transport + x = TRACKR.spausr[0]; + y = TRACKR.spausr[1]; + z = TRACKR.spausr[2]; } else Warning("TrackPosition","position not available"); } +//______________________________________________________________________________ void TFluka::TrackMomentum(TLorentzVector& momentum) const { // Return the direction and the momentum (GeV/c) of the track @@ -2048,7 +1221,7 @@ void TFluka::TrackMomentum(TLorentzVector& momentum) const // TRACKR.jtrack = identity number of the particle // PAPROP.am[TRACKR.jtrack] = particle mass in gev Int_t caller = GetCaller(); - if (caller != 2) { // not eedraw + if (caller != 2 && caller != 40) { // not eedraw or mgdraw resuming if (TRACKR.ptrack >= 0) { momentum.SetPx(TRACKR.ptrack*TRACKR.cxtrck); momentum.SetPy(TRACKR.ptrack*TRACKR.cytrck); @@ -2064,11 +1237,18 @@ void TFluka::TrackMomentum(TLorentzVector& momentum) const momentum.SetE(TRACKR.etrack); return; } + } else if (caller == 40) { // mgdraw resuming transport + momentum.SetPx(TRACKR.spausr[4]); + momentum.SetPy(TRACKR.spausr[5]); + momentum.SetPz(TRACKR.spausr[6]); + momentum.SetE (TRACKR.spausr[7]); + return; } else Warning("TrackMomentum","momentum not available"); } +//______________________________________________________________________________ void TFluka::TrackMomentum(Double_t& px, Double_t& py, Double_t& pz, Double_t& e) const { // Return the direction and the momentum (GeV/c) of the track @@ -2080,7 +1260,7 @@ void TFluka::TrackMomentum(Double_t& px, Double_t& py, Double_t& pz, Double_t& e // TRACKR.jtrack = identity number of the particle // PAPROP.am[TRACKR.jtrack] = particle mass in gev Int_t caller = GetCaller(); - if (caller != 2) { // not eedraw + if (caller != 2 && caller != 40) { // not eedraw and not mgdraw resuming if (TRACKR.ptrack >= 0) { px = TRACKR.ptrack*TRACKR.cxtrck; py = TRACKR.ptrack*TRACKR.cytrck; @@ -2096,45 +1276,65 @@ void TFluka::TrackMomentum(Double_t& px, Double_t& py, Double_t& pz, Double_t& e e = TRACKR.etrack; return; } + } else if (caller == 40) { // mgdraw resuming transport + px = TRACKR.spausr[4]; + py = TRACKR.spausr[5]; + pz = TRACKR.spausr[6]; + e = TRACKR.spausr[7]; + return; } else Warning("TrackMomentum","momentum not available"); } +//______________________________________________________________________________ Double_t TFluka::TrackStep() const { // Return the length in centimeters of the current step // TRACKR.ctrack = total curved path Int_t caller = GetCaller(); - if (caller == 11 || caller==12 || caller == 3 || caller == 6) //bxdraw,endraw,usdraw + if (caller == 11 || caller==12 || caller == 3 || caller == 6 || caller == 50 || caller == 40) //bxdraw,endraw,usdraw, ckov return 0.0; else if (caller == 4) //mgdraw return TRACKR.ctrack; - else - return -1.0; + else { + Warning("TrackStep", "track step not available"); + return 0.0; + } } +//______________________________________________________________________________ Double_t TFluka::TrackLength() const { // TRACKR.cmtrck = cumulative curved path since particle birth Int_t caller = GetCaller(); - if (caller == 111 || caller==12 || caller == 3 || caller == 4 || caller == 6) //bxdraw,endraw,mgdraw,usdraw + if (caller == 11 || caller==12 || caller == 3 || caller == 4 || caller == 6 || caller == 50) //bxdraw,endraw,mgdraw,usdraw,ckov return TRACKR.cmtrck; - else - return -1.0; + else if (caller == 40) // mgdraw resuming transport + return TRACKR.spausr[8]; + else { + Warning("TrackLength", "track length not available"); + return 0.0; + } } +//______________________________________________________________________________ Double_t TFluka::TrackTime() const { // Return the current time of flight of the track being transported // TRACKR.atrack = age of the particle Int_t caller = GetCaller(); - if (caller == 11 || caller==12 || caller == 3 || caller == 4 || caller == 6) //bxdraw,endraw,mgdraw,usdraw + if (caller == 11 || caller==12 || caller == 3 || caller == 4 || caller == 6 || caller == 50) //bxdraw,endraw,mgdraw,usdraw,ckov return TRACKR.atrack; - else - return -1; + else if (caller == 40) + return TRACKR.spausr[3]; + else { + Warning("TrackTime", "track time not available"); + return 0.0; + } } +//______________________________________________________________________________ Double_t TFluka::Edep() const { // Energy deposition @@ -2145,33 +1345,38 @@ Double_t TFluka::Edep() const // -->no energy loss along the track // if TRACKR.ntrack > 0, TRACKR.mtrack > 0: // -->energy loss distributed along the track -// TRACKR.dtrack = energy deposition of the jth deposition even +// TRACKR.dtrack = energy deposition of the jth deposition event // If coming from bxdraw we have 2 steps of 0 length and 0 edep + // If coming from usdraw we just signal particle production - no edep + // If just first time after resuming, no edep for the primary Int_t caller = GetCaller(); - if (caller == 11 || caller==12) return 0.0; + if (caller == 11 || caller==12 || caller==6 || caller == 40) return 0.0; Double_t sum = 0; for ( Int_t j=0;j= 3) - printf("VolId2Mate %d %d\n", id, fMediaByRegion[id-1]); - return fMediaByRegion[id-1]; + return fMCGeo->VolId2Mate(id); } +//______________________________________________________________________________ const char* TFluka::VolName(Int_t id) const { // // Returns the volume name for a given volume ID // - FlukaVolume* vol = dynamic_cast((*fVolumeMediaMap)[id-1]); - const char* name = vol->GetName(); - if (fVerbosityLevel >= 3) - printf("VolName %d %s \n", id, name); - return name; + return fMCGeo->VolName(id); } +//______________________________________________________________________________ Int_t TFluka::VolId(const Text_t* volName) const { // @@ -2469,98 +1716,93 @@ Int_t TFluka::VolId(const Text_t* volName) const // Time consuming. (Only used during set-up) // Could be replaced by hash-table // - char tmp[5]; - Int_t i =0; - for (i = 0; i < fNVolumes; i++) - { - FlukaVolume* vol = dynamic_cast((*fVolumeMediaMap)[i]); - TString name = vol->GetName(); - strcpy(tmp, name.Data()); - tmp[4] = '\0'; - if (!strcmp(tmp, volName)) break; - } - i++; - - return i; + char sname[20]; + Int_t len; + strncpy(sname, volName, len = strlen(volName)); + sname[len] = 0; + while (sname[len - 1] == ' ') sname[--len] = 0; + return fMCGeo->VolId(sname); } - +//______________________________________________________________________________ Int_t TFluka::CurrentVolID(Int_t& copyNo) const { // // Return the logical id and copy number corresponding to the current fluka region // - int ir = fCurrentFlukaRegion; - int id = (FGeometryInit::GetInstance())->CurrentVolID(ir, copyNo); - copyNo++; - if (fVerbosityLevel >= 3) - printf("CurrentVolID: %d %d %d \n", ir, id, copyNo); - return id; + if (gGeoManager->IsOutside()) return 0; + TGeoNode *node = gGeoManager->GetCurrentNode(); + copyNo = node->GetNumber(); + Int_t id = node->GetVolume()->GetNumber(); + return id; } +//______________________________________________________________________________ Int_t TFluka::CurrentVolOffID(Int_t off, Int_t& copyNo) const { // // Return the logical id and copy number of off'th mother // corresponding to the current fluka region // - if (off == 0) - return CurrentVolID(copyNo); - - int ir = fCurrentFlukaRegion; - int id = (FGeometryInit::GetInstance())->CurrentVolOffID(ir, off, copyNo); - copyNo++; - if (fVerbosityLevel >= 3) - printf("CurrentVolOffID: %d %d %d \n", ir, id, copyNo); - if (id == -1) - if (fVerbosityLevel >= 0) - printf("CurrentVolOffID: Warning Mother not found !!!\n"); - return id; + if (off<0 || off>gGeoManager->GetLevel()) return 0; + if (off==0) return CurrentVolID(copyNo); + TGeoNode *node = gGeoManager->GetMother(off); + if (!node) return 0; + copyNo = node->GetNumber(); + return node->GetVolume()->GetNumber(); } - +//______________________________________________________________________________ const char* TFluka::CurrentVolName() const { // // Return the current volume name // - Int_t copy; - Int_t id = TFluka::CurrentVolID(copy); - const char* name = TFluka::VolName(id); - if (fVerbosityLevel >= 3) - printf("CurrentVolumeName: %d %s \n", fCurrentFlukaRegion, name); - return name; + if (gGeoManager->IsOutside()) return 0; + return gGeoManager->GetCurrentVolume()->GetName(); } +//______________________________________________________________________________ const char* TFluka::CurrentVolOffName(Int_t off) const { // // Return the volume name of the off'th mother of the current volume // - Int_t copy; - Int_t id = TFluka::CurrentVolOffID(off, copy); - const char* name = TFluka::VolName(id); - if (fVerbosityLevel >= 3) - printf("CurrentVolumeOffName: %d %s \n", fCurrentFlukaRegion, name); - return name; + if (off<0 || off>gGeoManager->GetLevel()) return 0; + if (off==0) return CurrentVolName(); + TGeoNode *node = gGeoManager->GetMother(off); + if (!node) return 0; + return node->GetVolume()->GetName(); } -Int_t TFluka::CurrentMaterial(Float_t & /*a*/, Float_t & /*z*/, - Float_t & /*dens*/, Float_t & /*radl*/, Float_t & /*absl*/) const +const char* TFluka::CurrentVolPath() { + // Return the current volume path + return gGeoManager->GetPath(); +} +//______________________________________________________________________________ +Int_t TFluka::CurrentMaterial(Float_t & a, Float_t & z, + Float_t & dens, Float_t & radl, Float_t & absl) const { // -// Return the current medium number +// Return the current medium number and material properties // - Int_t copy; - Int_t id = TFluka::CurrentVolID(copy); - Int_t med = TFluka::VolId2Mate(id); - if (fVerbosityLevel >= 3) - printf("CurrentMaterial: %d %d \n", fCurrentFlukaRegion, med); - return med; + Int_t copy; + Int_t id = TFluka::CurrentVolID(copy); + Int_t med = TFluka::VolId2Mate(id); + TGeoVolume* vol = gGeoManager->GetCurrentVolume(); + TGeoMaterial* mat = vol->GetMaterial(); + a = mat->GetA(); + z = mat->GetZ(); + dens = mat->GetDensity(); + radl = mat->GetRadLen(); + absl = mat->GetIntLen(); + + return med; } +//______________________________________________________________________________ void TFluka::Gmtod(Float_t* xm, Float_t* xd, Int_t iflag) - { +{ // Transforms a position from the world reference frame // to the current volume reference frame. // @@ -2578,37 +1820,24 @@ void TFluka::Gmtod(Float_t* xm, Float_t* xd, Int_t iflag) // IFLAG=2 convert direction cosinus // // --- - Double_t xmD[3], xdD[3]; - xmD[0] = xm[0]; xmD[1] = xm[1]; xmD[2] = xm[2]; - (FGeometryInit::GetInstance())->Gmtod(xmD, xdD, iflag); - xd[0] = xdD[0]; xd[1] = xdD[1]; xd[2] = xdD[2]; - } - + Double_t xmL[3], xdL[3]; + Int_t i; + for (i=0;i<3;i++) xmL[i]=xm[i]; + if (iflag == 1) gGeoManager->MasterToLocal(xmL,xdL); + else gGeoManager->MasterToLocalVect(xmL,xdL); + for (i=0;i<3;i++) xd[i] = xdL[i]; +} +//______________________________________________________________________________ void TFluka::Gmtod(Double_t* xm, Double_t* xd, Int_t iflag) - { -// Transforms a position from the world reference frame -// to the current volume reference frame. -// -// Geant3 desription: -// ================== -// Computes coordinates XD (in DRS) -// from known coordinates XM in MRS -// The local reference system can be initialized by -// - the tracking routines and GMTOD used in GUSTEP -// - a call to GMEDIA(XM,NUMED) -// - a call to GLVOLU(NLEVEL,NAMES,NUMBER,IER) -// (inverse routine is GDTOM) -// -// If IFLAG=1 convert coordinates -// IFLAG=2 convert direction cosinus -// -// --- - (FGeometryInit::GetInstance())->Gmtod(xm, xd, iflag); - } +{ + if (iflag == 1) gGeoManager->MasterToLocal(xm,xd); + else gGeoManager->MasterToLocalVect(xm,xd); +} +//______________________________________________________________________________ void TFluka::Gdtom(Float_t* xd, Float_t* xm, Int_t iflag) - { +{ // Transforms a position from the current volume reference frame // to the world reference frame. // @@ -2625,184 +1854,132 @@ void TFluka::Gdtom(Float_t* xd, Float_t* xm, Int_t iflag) // IFLAG=2 convert direction cosinus // // --- - Double_t xmD[3], xdD[3]; - xdD[0] = xd[0]; xdD[1] = xd[1]; xdD[2] = xd[2]; - (FGeometryInit::GetInstance())->Gdtom(xdD, xmD, iflag); - xm[0] = xmD[0]; xm[1] = xmD[1]; xm[2] = xmD[2]; - } + Double_t xmL[3], xdL[3]; + Int_t i; + for (i=0;i<3;i++) xdL[i] = xd[i]; + if (iflag == 1) gGeoManager->LocalToMaster(xdL,xmL); + else gGeoManager->LocalToMasterVect(xdL,xmL); + for (i=0;i<3;i++) xm[i]=xmL[i]; +} + +//______________________________________________________________________________ void TFluka::Gdtom(Double_t* xd, Double_t* xm, Int_t iflag) - { -// Transforms a position from the current volume reference frame -// to the world reference frame. -// -// Geant3 desription: -// ================== -// Computes coordinates XM (Master Reference System -// knowing the coordinates XD (Detector Ref System) -// The local reference system can be initialized by -// - the tracking routines and GDTOM used in GUSTEP -// - a call to GSCMED(NLEVEL,NAMES,NUMBER) -// (inverse routine is GMTOD) -// -// If IFLAG=1 convert coordinates -// IFLAG=2 convert direction cosinus -// -// --- +{ + if (iflag == 1) gGeoManager->LocalToMaster(xd,xm); + else gGeoManager->LocalToMasterVect(xd,xm); +} - (FGeometryInit::GetInstance())->Gdtom(xd, xm, iflag); - } +//______________________________________________________________________________ +TObjArray *TFluka::GetFlukaMaterials() +{ + return fGeom->GetMatList(); +} -// =============================================================== -void TFluka::FutoTest() +//______________________________________________________________________________ +void TFluka::SetMreg(Int_t l) { - Int_t icode, mreg, newreg, particleId; - Double_t rull, xsco, ysco, zsco; - TLorentzVector position, momentum; - icode = GetIcode(); - if (icode == 0) { - if (fVerbosityLevel >=3) - cout << " icode=" << icode << endl; - } else if (icode > 0 && icode <= 5) { -// mgdraw - mreg = GetMreg(); - if (fVerbosityLevel >=3) - cout << " icode=" << icode - << " mreg=" << mreg - << endl; - TrackPosition(position); - TrackMomentum(momentum); - if (fVerbosityLevel >=3) { - cout << "TLorentzVector positionX=" << position.X() - << "positionY=" << position.Y() - << "positionZ=" << position.Z() - << "timeT=" << position.T() << endl; - cout << "TLorentzVector momentumX=" << momentum.X() - << "momentumY=" << momentum.Y() - << "momentumZ=" << momentum.Z() - << "energyE=" << momentum.E() << endl; - cout << "TrackStep=" << TrackStep() << endl; - cout << "TrackLength=" << TrackLength() << endl; - cout << "TrackTime=" << TrackTime() << endl; - cout << "Edep=" << Edep() << endl; - cout << "TrackPid=" << TrackPid() << endl; - cout << "TrackCharge=" << TrackCharge() << endl; - cout << "TrackMass=" << TrackMass() << endl; - cout << "Etot=" << Etot() << endl; - cout << "IsNewTrack=" << IsNewTrack() << endl; - cout << "IsTrackInside=" << IsTrackInside() << endl; - cout << "IsTrackEntering=" << IsTrackEntering() << endl; - cout << "IsTrackExiting=" << IsTrackExiting() << endl; - cout << "IsTrackOut=" << IsTrackOut() << endl; - cout << "IsTrackDisappeared=" << IsTrackDisappeared() << endl; - cout << "IsTrackAlive=" << IsTrackAlive() << endl; - } - - Float_t x = position.X(); - Float_t y = position.Y(); - Float_t z = position.Z(); - Float_t xm[3]; - Float_t xd[3]; - xm[0] = x; xm[1] = y; xm[2] = z; - if (fVerbosityLevel >= 3) - printf("Global trackPosition: %f %f %f \n", x, y, z); - Gmtod(xm, xd, 1); - if (fVerbosityLevel >= 3) - printf("Local trackPosition: %f %f %f \n", xd[0], xd[1], xd[2]); - Gdtom(xd, xm, 1); - if (fVerbosityLevel >= 3) - printf("New trackPosition: %f %f %f \n", xm[0], xm[1], xm[2]); - } else if((icode >= 10 && icode <= 15) || - (icode >= 20 && icode <= 24) || - (icode >= 30 && icode <= 33) || - (icode >= 40 && icode <= 41) || - (icode >= 50 && icode <= 52)) { -// endraw - mreg = GetMreg(); - rull = GetRull(); - xsco = GetXsco(); - ysco = GetYsco(); - zsco = GetZsco(); +// Set current fluka region + fCurrentFlukaRegion = l; + fGeom->SetMreg(l); +} + + + + +TString TFluka::ParticleName(Int_t pdg) const +{ + // Return particle name for particle with pdg code pdg. + Int_t ifluka = IdFromPDG(pdg); + return TString((CHPPRP.btype[ifluka+6]), 8); +} + + +Double_t TFluka::ParticleMass(Int_t pdg) const +{ + // Return particle mass for particle with pdg code pdg. + Int_t ifluka = IdFromPDG(pdg); + return (PAPROP.am[ifluka+6]); +} + +Double_t TFluka::ParticleCharge(Int_t pdg) const +{ + // Return particle charge for particle with pdg code pdg. + Int_t ifluka = IdFromPDG(pdg); + return Double_t(PAPROP.ichrge[ifluka+6]); +} + +Double_t TFluka::ParticleLifeTime(Int_t pdg) const +{ + // Return particle lifetime for particle with pdg code pdg. + Int_t ifluka = IdFromPDG(pdg); + return (PAPROP.thalf[ifluka+6]); +} + +void TFluka::Gfpart(Int_t pdg, char* name, Int_t& type, Float_t& mass, Float_t& charge, Float_t& tlife) +{ + // Retrieve particle properties for particle with pdg code pdg. + + strcpy(name, ParticleName(pdg).Data()); + type = ParticleMCType(pdg); + mass = ParticleMass(pdg); + charge = ParticleCharge(pdg); + tlife = ParticleLifeTime(pdg); +} + +void TFluka::PrintHeader() +{ + // + // Print a header + printf("\n"); + printf("\n"); + printf("------------------------------------------------------------------------------\n"); + printf("- You are using the TFluka Virtual Monte Carlo Interface to FLUKA. -\n"); + printf("- Please see the file fluka.out for FLUKA output and licensing information. -\n"); + printf("------------------------------------------------------------------------------\n"); + printf("\n"); + printf("\n"); +} + + + +#define pushcerenkovphoton pushcerenkovphoton_ +#define usersteppingckv usersteppingckv_ + + +extern "C" { + void pushcerenkovphoton(Double_t & px, Double_t & py, Double_t & pz, Double_t & e, + Double_t & vx, Double_t & vy, Double_t & vz, Double_t & tof, + Double_t & polx, Double_t & poly, Double_t & polz, Double_t & wgt, Int_t& ntr) + { + // + // Pushes one cerenkov photon to the stack + // - if (fVerbosityLevel >=3) { - cout << " icode=" << icode - << " mreg=" << mreg - << " rull=" << rull - << " xsco=" << xsco - << " ysco=" << ysco - << " zsco=" << zsco << endl; - } - TrackPosition(position); - TrackMomentum(momentum); - if (fVerbosityLevel >=3) { - cout << "Edep=" << Edep() << endl; - cout << "Etot=" << Etot() << endl; - cout << "TrackPid=" << TrackPid() << endl; - cout << "TrackCharge=" << TrackCharge() << endl; - cout << "TrackMass=" << TrackMass() << endl; - cout << "IsTrackOut=" << IsTrackOut() << endl; - cout << "IsTrackDisappeared=" << IsTrackDisappeared() << endl; - cout << "IsTrackStop=" << IsTrackStop() << endl; - cout << "IsTrackAlive=" << IsTrackAlive() << endl; - } - } else if((icode >= 100 && icode <= 105) || - (icode == 208) || - (icode == 210) || - (icode == 212) || - (icode >= 214 && icode <= 215) || - (icode == 217) || - (icode == 219) || - (icode == 221) || - (icode == 225) || - (icode == 300) || - (icode == 400)) { -// usdraw - mreg = GetMreg(); - xsco = GetXsco(); - ysco = GetYsco(); - zsco = GetZsco(); - - if (fVerbosityLevel >=3) { - cout << " icode=" << icode - << " mreg=" << mreg - << " xsco=" << xsco - << " ysco=" << ysco - << " zsco=" << zsco << endl; - cout << "TrackPid=" << TrackPid() << endl; - cout << "NSecondaries=" << NSecondaries() << endl; - } - - for (Int_t isec=0; isec< NSecondaries(); isec++) { - TFluka::GetSecondary(isec, particleId, position, momentum); - if (fVerbosityLevel >=3) { - cout << "TLorentzVector positionX=" << position.X() - << "positionY=" << position.Y() - << "positionZ=" << position.Z() - << "timeT=" << position.T() << endl; - cout << "TLorentzVector momentumX=" << momentum.X() - << "momentumY=" << momentum.Y() - << "momentumZ=" << momentum.Z() - << "energyE=" << momentum.E() << endl; - cout << "TrackPid=" << particleId << endl; - } - } - } else if((icode == 19) || - (icode == 29) || - (icode == 39) || - (icode == 49) || - (icode == 59)) { - mreg = GetMreg(); - newreg = GetNewreg(); - xsco = GetXsco(); - ysco = GetYsco(); - zsco = GetZsco(); - if (fVerbosityLevel >=3) { - cout << " icode=" << icode - << " mreg=" << mreg - << " newreg=" << newreg - << " xsco=" << xsco - << " ysco=" << ysco - << " zsco=" << zsco << endl; - } + TFluka* fluka = (TFluka*) gMC; + TVirtualMCStack* cppstack = fluka->GetStack(); + Int_t parent = TRACKR.ispusr[mkbmx2-1]; + cppstack->PushTrack(0, parent, 50000050, + px, py, pz, e, + vx, vy, vz, tof, + polx, poly, polz, + kPCerenkov, ntr, wgt, 0); + } + + void usersteppingckv(Int_t & nphot, Int_t & mreg, Double_t & x, Double_t & y, Double_t & z) + { + // + // Calls stepping in order to signal cerenkov production + // + TFluka *fluka = (TFluka*)gMC; + fluka->SetMreg(mreg); + fluka->SetXsco(x); + fluka->SetYsco(y); + fluka->SetZsco(z); + fluka->SetNCerenkov(nphot); + fluka->SetCaller(50); + if (fluka->GetVerbosityLevel() >= 3) + printf("userstepping ckv: %10d %10d %13.3f %13.3f %13.2f %s\n", nphot, mreg, x, y, z, fluka->CurrentVolName()); + (TVirtualMCApplication::Instance())->Stepping(); } -} // end of FutoTest +}