/*
$Log$
+Revision 1.4 2002/11/04 16:00:46 iglez2
+The conversion between ID and PDG now uses Fluka routines and arrays which is more consistent.
+
+Revision 1.3 2002/10/22 15:12:14 alibrary
+Introducing Riostream.h
+
Revision 1.2 2002/10/14 14:57:40 hristov
Merging the VirtualMC branch to the main development branch (HEAD)
#include "Fdblprc.h" //(DBLPRC) fluka common
#include "Fiounit.h" //(IOUNIT) fluka common
#include "Fepisor.h" //(EPISOR) fluka common
+#include "Fpart.h" //(PART) fluka common
#include "TVirtualMC.h"
+#include "TG4GeometryManager.h" //For the geometry management
+#include "TG4DetConstruction.h" //For the detector construction
+
+#include "FGeometryInit.hh"
+
// Fluka methods that may be needed.
#ifndef WIN32
# define flukam flukam_
# define fluka_openinp fluka_openinp_
# define fluka_closeinp fluka_closeinp_
+# define mcihad mcihad_
+# define mpdgha mpdgha_
#else
# define flukam FLUKAM
# define fluka_openinp FLUKA_OPENINP
# define fluka_closeinp FLUKA_CLOSEINP
+# define mcihad MCIHAD
+# define mpdgha MPDGHA
#endif
extern "C"
void type_of_call flukam(const int&);
void type_of_call fluka_openinp(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&);
}
//
ClassImp(TFluka)
//
-// TFluka methods.
+//----------------------------------------------------------------------------
+// TFluka constructors and destructors.
//____________________________________________________________________________
TFluka::TFluka()
:TVirtualMC(),
fVerbosityLevel(0),
- fInputFileName("")
+ fInputFileName(""),
+ fDetector(0)
{
//
// Default constructor
//
}
-//____________________________________________________________________________
TFluka::TFluka(const char *title, Int_t verbosity)
:TVirtualMC("TFluka",title),
fVerbosityLevel(verbosity),
- fInputFileName("")
+ fInputFileName(""),
+ fDetector(0)
{
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;
}
+TFluka::~TFluka() {
+ if (fVerbosityLevel >=3)
+ cout << "==> TFluka::~TFluka() destructor called." << endl;
+
+ delete fGeometryManager;
+
+ if (fVerbosityLevel >=3)
+ cout << "<== TFluka::~TFluka() destructor called." << endl;
+}
+
+//
+//_____________________________________________________________________________
+// TFluka control methods
//____________________________________________________________________________
void TFluka::Init() {
if (fVerbosityLevel >=3)
if (fVerbosityLevel >=2)
cout << "\t* Calling flukam..." << endl;
- flukam(0);
+ flukam(1);
if (fVerbosityLevel >=2)
cout << "\t* Closing file " << fInputFileName << endl;
cout << "<== TFluka::Init() called." << endl;
}
-//____________________________________________________________________________
+void TFluka::FinishGeometry() {
+ if (fVerbosityLevel >=3)
+ cout << "==> TFluka::FinishGeometry() called." << endl;
+
+ fGeometryManager->Ggclos();
+
+ if (fVerbosityLevel >=3)
+ cout << "<== TFluka::FinishGeometry() called." << endl;
+}
+
+void TFluka::BuildPhysics() {
+ if (fVerbosityLevel >=3)
+ cout << "==> TFluka::BuildPhysics() called." << endl;
+
+
+ if (fVerbosityLevel >=3)
+ cout << "<== TFluka::BuildPhysics() called." << endl;
+}
+
void TFluka::ProcessEvent() {
if (fVerbosityLevel >=3)
cout << "==> TFluka::ProcessEvent() called." << endl;
cout << "<== TFluka::ProcessEvent() called." << endl;
}
-//____________________________________________________________________________
+
void TFluka::ProcessRun(Int_t nevent) {
if (fVerbosityLevel >=3)
cout << "==> TFluka::ProcessRun(" << nevent << ") called."
}
fApplication->GeneratePrimaries();
EPISOR.lsouit = true;
- flukam(0);
+ flukam(1);
if (fVerbosityLevel >=3)
cout << "<== TFluka::ProcessRun(" << nevent << ") called."
}
//_____________________________________________________________________________
-Int_t TFluka::IdFromPDG(Int_t pdg) const
-{
+// 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) {
+//
+ fGeometryManager->Gfmate(imat, name, a, z, dens, radl, absl, ubuf, nbuf);
+}
+
+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) {
+//
+ fGeometryManager->Gfmate(imat, name, a, z, dens, radl, absl, ubuf, nbuf);
+}
+
+// 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);
+}
+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) {
+//
+ fGeometryManager
+ ->Material(kmat, name, a, z, dens, radl, absl, buf, nwbuf);
+}
+
+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);
+}
+void TFluka::Mixture(Int_t& kmat, const char *name, Double_t *a,
+ Double_t *z, Double_t dens, Int_t nlmat, Double_t *wmat) {
+//
+ fGeometryManager
+ ->Mixture(kmat, name, a, z, dens, nlmat, wmat);
+}
+
+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,
+ 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) {
//
- // Return Geant3 code from PDG and pseudo ENDF code
+ fGeometryManager
+ ->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);
+}
+
+void TFluka::Gstpar(Int_t itmed, const char *param, Double_t parval) {
+//
+ fGeometryManager->Gstpar(itmed, param, parval);
+}
+
+// functions from GGEOM
+Int_t TFluka::Gsvolu(const char *name, const char *shape, Int_t nmed,
+ Float_t *upar, Int_t np) {
+//
+ return fGeometryManager->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) {
+//
+ return fGeometryManager->Gsvolu(name, shape, nmed, upar, np);
+}
+
+void TFluka::Gsdvn(const char *name, const char *mother, Int_t ndiv,
+ Int_t iaxis) {
+//
+ fGeometryManager->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) {
+//
+ fGeometryManager->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) {
+//
+ fGeometryManager->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) {
+//
+ fGeometryManager->Gsdvt2(name, mother, step, iaxis, c0, numed, ndvmx);
+}
+
+void TFluka::Gsord(const char *name, Int_t iax) {
+//
+ fGeometryManager->Gsord(name, iax);
+}
+
+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);
+}
+
+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);
+}
+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) {
//
- for(Int_t i=0;i<fNPDGCodes;++i)
- if(pdg==fPDGCode[i])
- return i;
- return -99;
+ fGeometryManager->Gsposp(name, nr, mother, x, y, z, irot, konly, upar, np);
+}
+
+void TFluka::Gsbool(const char* onlyVolName, const char* manyVolName) {
+//
+ fGeometryManager->Gsbool(onlyVolName, manyVolName);
}
+void TFluka::SetCerenkov(Int_t itmed, Int_t npckov, Float_t *ppckov,
+ Float_t *absco, Float_t *effic, Float_t *rindex) {
+//
+ fGeometryManager->SetCerenkov(itmed, npckov, ppckov, absco, effic, 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);
+}
+
+// Euclid
+void TFluka::WriteEuclid(const char* fileName, const char* topVol,
+ Int_t number, Int_t nlevel) {
+//
+ fGeometryManager->WriteEuclid(fileName, topVol, number, nlevel);
+}
+
+
+
+
+
+
+//____________________________________________________________________________
+// ID <--> PDG transformations
//_____________________________________________________________________________
-Int_t TFluka::PDGFromId(Int_t id) const
+Int_t TFluka::IdFromPDG(Int_t pdg) const
{
//
- // Return PDG code and pseudo ENDF code from Geant3 code
- //
- if(id>0 && id<fNPDGCodes)
- return fPDGCode[id];
- else
- return -1;
+ // Return Fluka code from PDG and pseudo ENDF code
+
+ // MCIHAD() goes from pdg to fluka internal.
+ Int_t intfluka = mcihad(pdg);
+ // KPTOIP array goes from internal to official
+ return GetFlukaKPTOIP(intfluka);
}
-//_____________________________________________________________________________
-void TFluka::DefineParticles()
+Int_t TFluka::PDGFromId(Int_t id) const
{
- // Load standard numbers for GEANT particles and PDG conversion
- fPDGCode[fNPDGCodes++]= -99; // 0 = Psudoparticle (Ray)
- fPDGCode[fNPDGCodes++]= 2212; // 1 = Proton
- fPDGCode[fNPDGCodes++]=-2212; // 2 = Anti Proton
- fPDGCode[fNPDGCodes++]= 11; // 3 = Electron
- fPDGCode[fNPDGCodes++]= -11; // 4 = Positron
- fPDGCode[fNPDGCodes++]= 12; // 5 = Electron Neutrino
- fPDGCode[fNPDGCodes++]= -12; // 6 = Electron Antineutrino
- fPDGCode[fNPDGCodes++]= 22; // 7 = Photon
- fPDGCode[fNPDGCodes++]= 2112; // 8 = Neutron
- fPDGCode[fNPDGCodes++]=-2112; // 9 = Anti Neutron
- fPDGCode[fNPDGCodes++]= -13; // 10 = Mu+
- fPDGCode[fNPDGCodes++]= 13; // 11 = Mu-
- fPDGCode[fNPDGCodes++]= 130; // 12 = Kaon 0 long
- fPDGCode[fNPDGCodes++]= 211; // 13 = Pi+
- fPDGCode[fNPDGCodes++]= -211; // 14 = Pi-
- fPDGCode[fNPDGCodes++]= 321; // 15 = Kaon+
- fPDGCode[fNPDGCodes++]= -321; // 16 = Kaon-
- fPDGCode[fNPDGCodes++]= 3122; // 17 = Lambda
- fPDGCode[fNPDGCodes++]=-3122; // 18 = Anti Lambda
- fPDGCode[fNPDGCodes++]= 310; // 19 = Kaon 0 short
- fPDGCode[fNPDGCodes++]= 3112; // 20 = Sigma -
- fPDGCode[fNPDGCodes++]= 3222; // 21 = Sigma +
- fPDGCode[fNPDGCodes++]= 3212; // 22 = Sigma 0
- fPDGCode[fNPDGCodes++]= 111; // 23 = Pi0
- fPDGCode[fNPDGCodes++]= 311; // 24 = Kaon 0
- fPDGCode[fNPDGCodes++]= -311; // 25 = Antikaon 0
- fPDGCode[fNPDGCodes++]= -99; // 26 = --Reserved
- fPDGCode[fNPDGCodes++]= 14; // 27 = Muon neutrino
- fPDGCode[fNPDGCodes++]= -14; // 28 = Muon antineutrino
- fPDGCode[fNPDGCodes++]= -99; // 29 = --Reserved
- fPDGCode[fNPDGCodes++]= -99; // 30 = --Reserved
- fPDGCode[fNPDGCodes++]=-3222; // 31 = Antisigma -
- fPDGCode[fNPDGCodes++]=-3212; // 32 = Antisigma 0
- fPDGCode[fNPDGCodes++]=-3112; // 33 = Antisigma +
- fPDGCode[fNPDGCodes++]= 3322; // 34 = Xi 0
- fPDGCode[fNPDGCodes++]=-3322; // 35 = AntiXi 0
- fPDGCode[fNPDGCodes++]= 3312; // 36 = Xi -
- fPDGCode[fNPDGCodes++]=-3312; // 37 = Xi +
- fPDGCode[fNPDGCodes++]= 3334; // 38 = Omega -
- fPDGCode[fNPDGCodes++]=-3334; // 39 = Antiomega
- fPDGCode[fNPDGCodes++]= -99; // 40 = --Reserved
- fPDGCode[fNPDGCodes++]= -15; // 41 = Tau+
- fPDGCode[fNPDGCodes++]= 15; // 42 = Tau-
- fPDGCode[fNPDGCodes++]= 16; // 43 = Tau neutrino
- fPDGCode[fNPDGCodes++]= -16; // 44 = Tau antineutrino
- fPDGCode[fNPDGCodes++]= 411; // 45 = D+
- fPDGCode[fNPDGCodes++]= -411; // 46 = D-
- fPDGCode[fNPDGCodes++]= 421; // 47 = D0
- fPDGCode[fNPDGCodes++]= -421; // 48 = AntiD 0
- fPDGCode[fNPDGCodes++]= 431; // 49 = D_s +
- fPDGCode[fNPDGCodes++]= -431; // 50 = D_s -
- fPDGCode[fNPDGCodes++]= 4122; // 51 = Lambda_c +
- fPDGCode[fNPDGCodes++]= 4232; // 52 = Xi_c +
- fPDGCode[fNPDGCodes++]= 4112; // 53 = Xi_c -
- fPDGCode[fNPDGCodes++]= 4322; // 54 = Xi'_c +
- fPDGCode[fNPDGCodes++]= 4312; // 55 = Xi'_c 0
- fPDGCode[fNPDGCodes++]= 4332; // 56 = Omega_c 0
- fPDGCode[fNPDGCodes++]=-4122; // 57 = Antilambda_c -
- fPDGCode[fNPDGCodes++]=-4232; // 58 = Antixsi_c -
- fPDGCode[fNPDGCodes++]=-4112; // 59 = Antixsi_c 0
- fPDGCode[fNPDGCodes++]=-4322; // 60 = AntiXi'_c -
- fPDGCode[fNPDGCodes++]=-4312; // 61 = AntiXi'_c 0
- fPDGCode[fNPDGCodes++]=-4332; // 62 = AntiOmega_c 0
- fPDGCode[fNPDGCodes++]= -99; // 63 = --Reserved
- fPDGCode[fNPDGCodes++]= -99; // 64 = --Reserved
+ //
+ // Return PDG code and pseudo ENDF code from Fluka code
+
+ //IPTOKP array goes from official to internal
+ Int_t intfluka = GetFlukaIPTOKP(id);
+ //MPKDHA() goes from internal to PDG
+ return mpdgha(intfluka);
+
}