//////////////////////////////////////////////////////////////////////// /// \class RAT::VolumeList /// /// \brief An object containing a list of unique volumes, and methods to /// add new volumes by point or name. /// /// \author Daniel Asher Resnick /// \author Phil Jones -- contact person /// /// REVISION HISTORY:\n /// 27 Jun, 2011 : Daniel Resnick - Created \n /// /// \details An object of this class contains a list of volumes, /// as well as methods to add new volumes, /// either by specifying the volume's name, or a point in the volume. \n /// It also keeps an associated Local-to-Global coordinate transform for /// each volume. //////////////////////////////////////////////////////////////////////// #ifndef __VolumeList_h__ #define __VolumeList_h__ #include #include #include #include class G4VPhysicalVolume; namespace RAT { class VolumeList { public: enum volumes { SELF, DAUGHTERS, BOTH }; /// A struct to package a volume with its coordinate transform. struct VolTransform { /// A volume const G4VPhysicalVolume* fVolume; /// The corresponding Local-to-Global coordinate transform G4AffineTransform fTransform; VolTransform(G4VPhysicalVolume* volume, G4AffineTransform transform) : fVolume(volume), fTransform(transform) {} VolTransform(){} }; /// Add a VolTransform directly to the list virtual void AddVolTransform(VolTransform const& vol); /// Add a volume to the list by specifying its name virtual void AddVolume(std::string const& name, volumes vol=BOTH); /// Add a volume to the list by specifying a point within it virtual void AddVolume(G4ThreeVector const& point, volumes vol=BOTH); /// Add a volume to the list with a string that represents either /// the name of the volume or the coordinates of a point within it virtual void AddString(std::string const& value, volumes vol=BOTH); /// Remove all volumes from the list virtual void Clear() { fList.clear(); } /// Return the i'th VolTransform virtual const VolTransform Get(int i) const { return fList.at(i); } /// Return the i'th Volume virtual const G4VPhysicalVolume* GetVolume(int i) const { return Get(i).fVolume; } /// Memoized volume computation static double ComputeVolume(const G4VPhysicalVolume* volume); /// A map of solid names to their cubic volumes, in mm^3 static std::map fSolidVolumes; /// Return the Local-to-Global coordinate transform /// for the i'th volume virtual const G4AffineTransform GetTransform(int i) const { return Get(i).fTransform; } /// Return the number of volumes in the list virtual unsigned int Size() const { return fList.size(); } protected: virtual void AddDaughters(VolTransform const& vol); private: ///The internal vector used to store the volumes and transforms std::vector fList; }; } //namespace RAT #endif //VolumeList_h