/search.css" rel="stylesheet" type="text/css"/> /search.js">
00001 #ifndef TOUCHABLETODETECTORELEMENTFAST_H 00002 #define TOUCHABLETODETECTORELEMENTFAST_H 00003 00007 00008 #include "G4DataHelpers/ITouchableToDetectorElement.h" 00009 #include "GaudiAlg/GaudiTool.h" 00010 #include "DetDesc/ILVolume.h" 00011 #include <list> 00012 00013 class TouchableToDetectorElementFast : public GaudiTool, virtual ITouchableToDetectorElement 00014 { 00015 public: 00016 TouchableToDetectorElementFast(const std::string& type, 00017 const std::string& name, 00018 const IInterface* parent); 00019 virtual ~TouchableToDetectorElementFast() {}; 00020 00022 virtual StatusCode GetBestDetectorElement( 00023 const G4TouchableHistory* inHistory, // The current particle location 00024 const std::vector<std::string>& inPath,// Name(s) of specific detElements, or paths to be searched 00025 const IDetectorElement* &outElement, // output: The best element (may be zero!) 00026 int& outCompatibility ); // output: the goodness of the match (lower is better, <=0 means no match.) 00027 00029 virtual StatusCode G4VolumeToDetDesc( const G4VPhysicalVolume* inVol, 00030 const IPVolume* &outVol 00031 ); 00032 00034 virtual StatusCode ClearCache(); 00035 00036 private: 00037 00038 // Things to store in the cache: 00039 struct Relation { 00040 Relation() : mLogVol(0), mPhysVol(0), mRpath(0) {}; 00041 bool isNull() const { return mLogVol==0; }; 00042 const ILVolume* mLogVol; // The supporting volume 00043 const IPVolume* mPhysVol; 00044 ILVolume::ReplicaPath mRpath; // Empty if it is not under the mWorldElement. 00045 }; 00046 00047 // The Cache: 00048 const IDetectorElement* mWorldElement; // From recent calls. Changing this causes cache flushing. 00049 std::string mWorldElementName; // The name of above. 00050 typedef std::map<const G4VPhysicalVolume*,Relation> G4ToRelationMap_t; 00051 typedef std::map<const IDetectorElement* ,Relation> DetElemToRelationMap_t; 00052 typedef std::list<const IDetectorElement*> ElementList_t; 00053 G4ToRelationMap_t mG4ToRelationMap; 00054 DetElemToRelationMap_t mDetElemToRelationMap; 00055 std::vector<std::string> mLastSearchPaths; 00056 ElementList_t mElementList; 00057 00058 StatusCode GetRelation(const G4VPhysicalVolume* inVol, Relation* &outRelation ); 00059 StatusCode GetRelation(const IDetectorElement* inElem, Relation* &outRelation ); 00060 00062 int Compatability(const ILVolume::ReplicaPath& inPlace, const ILVolume::ReplicaPath& inContainer); 00063 00064 template < class T > 00065 StatusCode FindObjectsInDirectory(const std::string& dirname, std::list<const T*>& outList); 00066 00067 }; 00068 00069 00070 #endif /* TOUCHABLETODETECTORELEMENTFAST_H */