From b0d8df96d5f1197f369362e5f82c1e5c6a5647a0 Mon Sep 17 00:00:00 2001 From: morsch Date: Fri, 31 Jan 2003 14:01:51 +0000 Subject: [PATCH] Major update on - Getters related to geometry. - Communication with run manager (event steering) --- TFluka/TFluka.cxx | 159 +++++++++++++++++++++++++++++++++++++++++++--- TFluka/TFluka.h | 29 +++------ 2 files changed, 160 insertions(+), 28 deletions(-) diff --git a/TFluka/TFluka.cxx b/TFluka/TFluka.cxx index e8aa67a429d..be1a1e98213 100644 --- a/TFluka/TFluka.cxx +++ b/TFluka/TFluka.cxx @@ -15,6 +15,9 @@ /* $Log$ +Revision 1.12 2003/01/31 12:18:53 morsch +Corrected indices. (E. Futo) + Revision 1.9 2002/12/06 12:41:29 morsch Mess from last merge cleaned up. @@ -244,7 +247,8 @@ void TFluka::FinishGeometry() { printf("Finish Geometry: volName, media %d %s %d \n", i, volName.Data(), media); strcpy(tmp, volName.Data()); tmp[4] = '\0'; - flugg->SetMediumFromName(tmp, media); + flugg->SetMediumFromName(tmp, media, i+1); + fMediaByRegion[i] = media; } flugg->BuildMediaMap(); @@ -265,7 +269,9 @@ void TFluka::BuildPhysics() { 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; } @@ -280,13 +286,14 @@ void TFluka::ProcessRun(Int_t nevent) { cout << "\t* GLOBAL.fdrtr = " << (GLOBAL.lfdrtr?'T':'F') << endl; cout << "\t* Calling flukam again..." << endl; } - fApplication->GeneratePrimaries(); - EPISOR.lsouit = true; - flukam(1); - + fApplication->InitGeometry(); + fApplication->BeginEvent(); + ProcessEvent(); + fApplication->FinishEvent(); if (fVerbosityLevel >=3) cout << "<== TFluka::ProcessRun(" << nevent << ") called." << endl; + } //_____________________________________________________________________________ @@ -373,6 +380,8 @@ Int_t TFluka::Gsvolu(const char *name, const char *shape, Int_t nmed, Float_t *upar, Int_t np) { // // fVolumeMediaMap[TString(name)] = nmed; + printf("TFluka::Gsvolu() name = %s, nmed = %d\n", name, nmed); + TClonesArray &lvols = *fVolumeMediaMap; new(lvols[fNVolumes++]) FlukaVolume(name, nmed); @@ -391,6 +400,12 @@ Int_t TFluka::Gsvolu(const char *name, const char *shape, Int_t nmed, 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); } @@ -476,6 +491,9 @@ void TFluka::WriteEuclid(const char* fileName, const char* topVol, //____________________________________________________________________________ Int_t TFluka::GetMedium() const { +// +// Get the medium number for the current fluka region +// FGeometryInit* flugg = FGeometryInit::GetInstance(); return flugg->GetMedium(fCurrentFlukaRegion); } @@ -502,8 +520,18 @@ Int_t TFluka::PDGFromId(Int_t id) const // Return PDG code and pseudo ENDF code from Fluka code //IPTOKP array goes from official to internal + if (id == 0) { + printf("PDGFromId: Error id = 0"); + return -1; + } + Int_t intfluka = GetFlukaIPTOKP(id); - //MPKDHA() goes from internal to PDG + if (intfluka == 0) { + printf("PDGFromId: Error intfluka = 0"); + return -1; + } + + //MPKDHA() goes from internal to PDG return mpdgha(intfluka); } @@ -859,8 +887,8 @@ TMCProcess TFluka::ProdProcess(Int_t isec) const const TMCProcess kIpPMuonNuclear = kPMuonNuclear; const TMCProcess kIpPPhotoFission = kPPhotoFission; const TMCProcess kIpPRayleigh = kPRayleigh; - const TMCProcess kIpPCerenkov = kPCerenkov; - const TMCProcess kIpPSynchrotron = kPSynchrotron; +// const TMCProcess kIpPCerenkov = kPCerenkov; +// const TMCProcess kIpPSynchrotron = kPSynchrotron; Int_t mugamma = TRACKR.jtrack == 7 || TRACKR.jtrack == 10 || TRACKR.jtrack == 11; if (fIcode == 102) return kIpPDecay; @@ -897,6 +925,118 @@ TMCProcess TFluka::ProdProcess(Int_t isec) const //} +Int_t TFluka::VolId2Mate(Int_t id) const +{ +// +// Returns the material number for a given volume ID +// + printf("VolId2Mate %d %d\n", id, fMediaByRegion[id]); + return fMediaByRegion[id-1]; +} + +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(); + printf("VolName %d %s \n", id, name); + return name; +} + +Int_t TFluka::VolId(const Text_t* volName) const +{ +// +// Converts from volume name to volume ID. +// 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; +} + + +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); + printf("CurrentVolID: %d %d %d \n", ir, id, copyNo); + 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); + + printf("CurrentVolOffID: %d %d %d \n", ir, id, copyNo); + if (id == -1) + printf("CurrentVolOffID: Warning Mother not found !!!\n"); + return id; +} + + +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); + printf("CurrentVolumeName: %d %s \n", fCurrentFlukaRegion, name); + return name; +} + +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); + printf("CurrentVolumeOffName: %d %s \n", fCurrentFlukaRegion, name); + return name; +} + +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 +// + Int_t copy; + Int_t id = TFluka::CurrentVolID(copy); + Int_t med = TFluka::VolId2Mate(id); + printf("CurrentMaterial: %d %d \n", fCurrentFlukaRegion, med); + return med; +} + + // =============================================================== void TFluka::FutoTest() { @@ -1053,3 +1193,4 @@ void TFluka::FutoTest() } // end of FutoTest + diff --git a/TFluka/TFluka.h b/TFluka/TFluka.h index 45b3936cf3d..1b88c3ea68c 100644 --- a/TFluka/TFluka.h +++ b/TFluka/TFluka.h @@ -115,15 +115,11 @@ class TFluka : public TVirtualMC { virtual void WriteEuclid(const char*, const char*, Int_t, Int_t); // get methods - virtual Int_t VolId(const Text_t* volName) const - {printf("WARNING: VolId not yet implemented !\n"); return -1;} - virtual const char* VolName(Int_t id) const - {printf("WARNING: VolName not yet implemented !\n"); return "void";} + virtual Int_t VolId(const Text_t* volName) const; + virtual const char* VolName(Int_t id) const; virtual Int_t NofVolumes() const - {printf("WARNING: NofVolumes not yet implemented !\n"); return -1;} - virtual Int_t VolId2Mate(Int_t id) const - {printf("WARNING: VolId2Mate not yet implemented !\n"); return -1;} - + {printf("NofVolumes %d\n", fNVolumes); return fNVolumes;} + virtual Int_t VolId2Mate(Int_t id) const; // // methods for physics management // ------------------------------------------------ @@ -161,19 +157,14 @@ class TFluka : public TVirtualMC { // get methods // tracking volume(s) - virtual Int_t CurrentVolID(Int_t& copyNo) const - {printf("WARNING: CurrentVolID not yet implemented !\n"); return -1;} - virtual Int_t CurrentVolOffID(Int_t off, Int_t& copyNo) const - {printf("WARNING: CurrentVolOffID not yet implemented !\n"); return -1;} - virtual const char* CurrentVolName() const - {printf("WARNING: CurrentVolName not yet implemented !\n"); return "void";} - virtual const char* CurrentVolOffName(Int_t off) const - {printf("WARNING: CurrentVolOffName not yet implemented !\n"); return "void";} + virtual Int_t CurrentVolID(Int_t& copyNo) const; + virtual Int_t CurrentVolOffID(Int_t off, Int_t& copyNo) const; + virtual const char* CurrentVolName() const; + virtual const char* CurrentVolOffName(Int_t off) const; virtual Int_t CurrentMaterial(Float_t &a, Float_t &z, - Float_t &dens, Float_t &radl, Float_t &absl) const - {printf("WARNING: CurrentMaterial not yet implemented !\n"); return -1;} + Float_t &dens, Float_t &radl, Float_t &absl) const; virtual Int_t CurrentEvent() const - {printf("WARNING: CurrentEvent not yet implemented !\n"); return -1;} + {printf("WARNING: CurrentEvent not yet implemented !\n"); return -1;} virtual void Gmtod(Float_t* xm, Float_t* xd, Int_t iflag) {printf("WARNING: Gmtod not yet implemented !\n");} virtual void Gmtod(Double_t* xm, Double_t* xd, Int_t iflag) -- 2.31.1