Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2022-01-17 23:31:58

0001 #ifndef SimG4Core_TrackInformationExtractor_H
0002 #define SimG4Core_TrackInformationExtractor_H
0003 
0004 #include "SimG4Core/Notification/interface/TrackInformation.h"
0005 
0006 class G4Track;
0007 
0008 /** Provides safe access to the TrackInformation part of a G4Track.
0009  *  If the G4Track pointer/reference is const, a const reference to
0010  *  the TrackInformation is returned, else a non-const reference
0011  *  is  returned.
0012  *  The TrackInformationExtractor checks for the existance of 
0013  *  TrackInformation and for the validity of the dynamic_cast;
0014  *  It will throw an excepton if it is not possible to return 
0015  *  TrackInformation, but it will do it's best to satisfy the request
0016  *  (in some cases it may even create the TrackInformation on-the-fly).
0017  */
0018 
0019 class TrackInformationExtractor {
0020 public:
0021   /** for a const G4Track pointer/reference a const TrackInformation&
0022      *  is returned.
0023      */
0024   const TrackInformation& operator()(const G4Track& gtk) const;
0025   const TrackInformation& operator()(const G4Track* gtk) const { return operator()(*gtk); }
0026   /** for a non-const G4Track pointer/reference the TrackInformation&
0027      *  is also non-const.
0028      */
0029   TrackInformation& operator()(G4Track& gtk) const;
0030   TrackInformation& operator()(G4Track* gtk) const { return operator()(*gtk); }
0031 
0032 private:
0033   void missing(const G4Track& gtk) const;
0034   void wrongType() const;
0035 };
0036 
0037 #endif