From dc37cac6e40529664231cadcc88c66d7ea922fcd Mon Sep 17 00:00:00 2001 From: morsch Date: Tue, 18 Feb 2003 12:47:59 +0000 Subject: [PATCH] Gmtod and Gdtom added. --- Flugg/FGeometryInit.cxx | 73 ++++++++++++++++++++++++++++++ Flugg/FGeometryInit.hh | 3 +- TFluka/TFluka.cxx | 98 +++++++++++++++++++++++++++++++++++++++++ TFluka/TFluka.h | 16 +++---- 4 files changed, 181 insertions(+), 9 deletions(-) diff --git a/Flugg/FGeometryInit.cxx b/Flugg/FGeometryInit.cxx index c469adefad9..1149069b36f 100644 --- a/Flugg/FGeometryInit.cxx +++ b/Flugg/FGeometryInit.cxx @@ -829,3 +829,76 @@ int FGeometryInit::CurrentVolOffID(int ir, int off, int& copyNo) } return id; } + +void FGeometryInit::Gmtod(double* xm, double* xd, int 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 +// +// --- + FluggNavigator * ptrNavig = getNavigatorForTracking(); + //setting variables (and dimension: Fluka uses cm.!) + G4ThreeVector pGlob(xm[0],xm[1],xm[2]); + pGlob *= 10.0; // in millimeters + G4ThreeVector pLoc; + + if (iflag == 1) { + pLoc = + ptrNavig->ComputeLocalPoint(pGlob); + } else if (iflag == 2) { + pLoc = + ptrNavig->ComputeLocalAxis(pGlob); + } else { + G4cout << "Flugg FGeometryInit::Gmtod called with undefined flag" << G4endl; + } + + xd[0] = pLoc[0]; xd[1] = pLoc[1]; xd[2] = pLoc[2]; +} + +void FGeometryInit::Gdtom(double* xd, double* xm, int 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 +// +// --- + + FluggNavigator * ptrNavig = getNavigatorForTracking(); + G4ThreeVector pLoc(xd[0],xd[1],xd[2]); + G4ThreeVector pGlob; + if (iflag == 1) { + pGlob = ptrNavig->GetLocalToGlobalTransform(). + TransformPoint(pLoc); + } else if (iflag == 2) { + pGlob = ptrNavig->GetLocalToGlobalTransform(). + TransformAxis(pLoc); + } else { + G4cout << "Flugg FGeometryInit::Gdtom called with undefined flag" << G4endl; + } + + xm[0] = pGlob[0]; xm[1] = pGlob[1]; xm[2] = pGlob[2]; +} diff --git a/Flugg/FGeometryInit.hh b/Flugg/FGeometryInit.hh index 80993fcaf6e..832ab6df16c 100644 --- a/Flugg/FGeometryInit.hh +++ b/Flugg/FGeometryInit.hh @@ -74,7 +74,8 @@ public: G4int GetMedium(int) const; int CurrentVolID(int ir, int& copyNo); int CurrentVolOffID(int ir, int off, int& copyNo); - + void Gmtod(double* xm, double* xd, int iflag); + void Gdtom(double* xd, double* xm, int iflag); protected: void BuildRegionsMap(); diff --git a/TFluka/TFluka.cxx b/TFluka/TFluka.cxx index be1a1e98213..ac2fe364ec0 100644 --- a/TFluka/TFluka.cxx +++ b/TFluka/TFluka.cxx @@ -15,6 +15,11 @@ /* $Log$ +Revision 1.13 2003/01/31 14:01:51 morsch +Major update on +- Getters related to geometry. +- Communication with run manager (event steering) + Revision 1.12 2003/01/31 12:18:53 morsch Corrected indices. (E. Futo) @@ -1036,6 +1041,99 @@ Int_t TFluka::CurrentMaterial(Float_t &a, Float_t &z, 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. +// +// 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 +// +// --- + 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]; + } + + +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 +// +// --- + Double_t xmD[3], xdD[3]; + xdD[0] = xd[0]; xdD[1] = xd[1]; xdD[2] = xd[2]; + (FGeometryInit::GetInstance())->Gdtom(xmD, xdD, iflag); + xm[0] = xmD[0]; xm[1] = xmD[1]; xm[2] = xmD[2]; + } + +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. +// +// 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 +// +// --- + + + } +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 +// +// --- + + (FGeometryInit::GetInstance())->Gdtom(xm, xd, iflag); + } // =============================================================== void TFluka::FutoTest() diff --git a/TFluka/TFluka.h b/TFluka/TFluka.h index 1b88c3ea68c..bc67b95a143 100644 --- a/TFluka/TFluka.h +++ b/TFluka/TFluka.h @@ -165,14 +165,14 @@ class TFluka : public TVirtualMC { Float_t &dens, Float_t &radl, Float_t &absl) const; virtual Int_t CurrentEvent() const {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) - {printf("WARNING: Gmtod not yet implemented !\n");} - virtual void Gdtom(Float_t* xd, Float_t* xm, Int_t iflag) - {printf("WARNING: Gdtom not yet implemented !\n");} - virtual void Gdtom(Double_t* xd, Double_t* xm, Int_t iflag) - {printf("WARNING: Gdtom not yet implemented !\n");} + virtual void Gmtod(Float_t* xm, Float_t* xd, Int_t iflag); + + virtual void Gmtod(Double_t* xm, Double_t* xd, Int_t iflag); + + virtual void Gdtom(Float_t* xd, Float_t* xm, Int_t iflag); + + virtual void Gdtom(Double_t* xd, Double_t* xm, Int_t iflag); + virtual Double_t MaxStep() const {printf("WARNING: MaxStep not yet implemented !\n"); return -1.;} virtual Int_t GetMaxNStep() const -- 2.31.1