#ifndef DemoTouchable_hh #define DemoTouchable_hh 1 // $Id: DemoTouchable.hh,v 1.3 2011/10/06 21:00:34 kelsey Exp $ //////////////////////////////////////////////////////////////////////// // File: DemoTouchable.hh // // // // Description: Subclass of G4VTouchable to provide additional data // // about associated volume. // // Adapted from Pedro Arce, GAMOS/GmTouchable // // // // Author: Michael Kelsey (SLAC) // // Date: 30 September 2011 // // // // 20111001 M. Kelsey -- Provide arg and no-arg interface for // // transforamtion access. // // 20111006 M. Kelsey -- Add accessor for full transformations and // // access to volumes. // // 20170309 M. Kelsey -- Must implement GetReplicaNumber(). // //////////////////////////////////////////////////////////////////////// #include "G4VTouchable.hh" #include "globals.hh" #include "G4ThreeVector.hh" #include "G4RotationMatrix.hh" #include "G4Transform3D.hh" #include class G4VPhysicalVolume; class G4VSolid; class DemoTouchable : public G4VTouchable { public: DemoTouchable(G4int verbose=0) : verboseLevel(verbose), theCopyNo(0) {} DemoTouchable(std::vector vpv, std::vector& ancestorsCopyNo, G4int verbose=0); // Effective down-casting operators DemoTouchable(const G4VTouchable* g4touch, G4int verbose=0); DemoTouchable(const G4VTouchable& g4touch, G4int verbose=0); ~DemoTouchable(); void setVerboseLevel(G4int verbose=0) { verboseLevel = verbose; } const G4String& GetName() const { return theName; } const G4String& GetShortName() const { return theName; } const G4String& GetLongName() const { return theLongName; } G4int GetReplicaNumber(G4int=0) const { return GetCopyNo(); } G4int GetCopyNo() const { return theCopyNo; } const G4String& GetMaterialName() const { return theMaterialName; } const G4ThreeVector& GetGlobalPosition() const { return theGlobalPos; } const G4RotationMatrix& GetGlobalRotation() const { return theGlobalRotMat; } const G4ThreeVector& GetLocalPosition() const { return theLocalPos; } const G4RotationMatrix& GetLocalRotation() const { return theLocalRotMat; } // NOTE: Numeric argument to base-class functions is ignored G4VPhysicalVolume* GetVolume(G4int) const { return GetVolume(); } G4VPhysicalVolume* GetVolume() const { return theVolume; } G4VSolid* GetSolid(G4int) const { return GetSolid(); } G4VSolid* GetSolid() const; const G4ThreeVector& GetTranslation(G4int) const { return GetTranslation(); } const G4ThreeVector& GetTranslation() const { return GetGlobalPosition(); } const G4RotationMatrix* GetRotation(G4int) const { return GetRotation(); } const G4RotationMatrix* GetRotation() const { return &(GetGlobalRotation()); } // For convenience, construct the full transformation here const G4Transform3D GetTransformation(G4int lvl) const { return G4Transform3D(*GetRotation(lvl),GetTranslation(lvl)); } const G4Transform3D GetTransformation() const { return G4Transform3D(*GetRotation(),GetTranslation()); } private: void BuildTouchable(const G4VTouchable* g4touch); void BuildTouchable(std::vector vpv, std::vector& ancestorsCopyNo); G4Transform3D CalculateTransformation(G4VPhysicalVolume* pv, G4int index); private: G4int verboseLevel; G4String theName; // Base name of volume G4String theLongName; // Name, copy number, and ancestry G4int theCopyNo; // Copy number, or division index G4ThreeVector theGlobalPos; // position in global reference frame G4RotationMatrix theGlobalRotMat; // rotation matrix in global frame G4ThreeVector theLocalPos; // position in local reference frame G4RotationMatrix theLocalRotMat; // rotation matrix in local frame G4String theMaterialName; G4VPhysicalVolume* theVolume; // Actual volume for accessors }; std::ostream& operator<<(std::ostream& os, const DemoTouchable& touch); #endif /* DemoTouchable_hh */