Geant4 Cross Reference |
1 // 2 // ******************************************************************** 3 // * License and Disclaimer * 4 // * * 5 // * The Geant4 software is copyright of the Copyright Holders of * 6 // * the Geant4 Collaboration. It is provided under the terms and * 7 // * conditions of the Geant4 Software License, included in the file * 8 // * LICENSE and available at http://cern.ch/geant4/license . These * 9 // * include a list of copyright holders. * 10 // * * 11 // * Neither the authors of this software system, nor their employing * 12 // * institutes,nor the agencies providing financial support for this * 13 // * work make any representation or warranty, express or implied, * 14 // * regarding this software system or assume any liability for its * 15 // * use. Please see the license in the file LICENSE and URL above * 16 // * for the full disclaimer and the limitation of liability. * 17 // * * 18 // * This code implementation is the result of the scientific and * 19 // * technical work of the GEANT4 collaboration. * 20 // * By using, copying, modifying or distributing the software (or * 21 // * any work based on the software) you agree to acknowledge its * 22 // * use in resulting scientific publications, and indicate your * 23 // * acceptance of all terms of the Geant4 Software license. * 24 // ******************************************************************** 25 // 26 /// \file runAndEvent/RE04/include/RE04Trajectory.hh 27 /// \brief Definition of the RE04Trajectory class 28 // 29 // 30 #ifndef RE04Trajectory_h 31 #define RE04Trajectory_h 1 32 33 #include "RE04TrajectoryPoint.hh" // Include from 'tracking' 34 35 #include "G4Allocator.hh" 36 #include "G4ParticleDefinition.hh" // Include from 'particle+matter' 37 #include "G4Step.hh" 38 #include "G4Track.hh" 39 #include "G4VTrajectory.hh" 40 #include "G4ios.hh" // Include from 'system' 41 #include "globals.hh" // Include from 'global' 42 43 #include <stdlib.h> // Include from 'system' 44 #include <vector> // G4RWTValOrderedVector 45 46 class G4Polyline; // Forward declaration. 47 48 typedef std::vector<G4VTrajectoryPoint*> TrajectoryPointContainer; 49 50 // 51 /// User trajectory class 52 /// 53 /// - new, delete and "==" operators are overwritten 54 /// 55 /// - get functions 56 /// G4int GetTrackID() const, G4int GetParentID() const, 57 /// G4String GetParticleName() const, G4double GetCharge() const, 58 /// G4int GetPDGEncoding() const, G4double GetInitialKineticEnergy() const 59 /// and G4ThreeVector GetInitialMomentum() const 60 /// 61 /// - void ShowTrajectory(std::ostream& os=G4cout) const 62 /// invokes the default implementation 63 /// 64 /// - void DrawTrajectory() const 65 /// invokes the default implementation 66 /// 67 /// - void AppendStep(const G4Step* aStep) 68 /// adds a user trajectory point object, RE04TrajectoryPoint 69 /// 70 /// - int GetPointEntries() const 71 /// returns the number of point entries 72 /// 73 /// - G4VTrajectoryPoint* GetPoint(G4int i) const 74 /// gets the i-th trajectory point 75 /// 76 /// - void MergeTrajectory(G4VTrajectory* secondTrajectory) 77 /// adds a trajectory to a TrajectoryPointContainer, fPositionRecord 78 /// 79 /// - G4ParticleDefinition* GetParticleDefinition() 80 /// get a particle definition from G4ParticleTable 81 /// 82 /// - const std::map<G4String,G4AttDef>* GetAttDefs() const 83 /// defines the track ID, the parent ID, the particle name, the charge, 84 /// the PDG encoding, the initial kinetic energy, the initial momentum, 85 /// the initial momentum magnitude and the number of points as attiributes 86 /// 87 /// - std::vector<G4AttValue>* CreateAttValues() const 88 /// sets and returns the attributes 89 // 90 /////////////////// 91 class RE04Trajectory : public G4VTrajectory 92 /////////////////// 93 { 94 //-------- 95 public: 96 //-------- 97 98 // Constructor/Destrcutor 99 100 RE04Trajectory(); 101 102 RE04Trajectory(const G4Track* aTrack); 103 RE04Trajectory(RE04Trajectory&); 104 virtual ~RE04Trajectory(); 105 106 // Operators 107 inline void* operator new(size_t); 108 inline void operator delete(void*); 109 inline int operator==(const RE04Trajectory& right) const { return (this == &right); } 110 111 // Get/Set functions 112 inline virtual G4int GetTrackID() const { return fTrackID; } 113 inline virtual G4int GetParentID() const { return fParentID; } 114 inline virtual G4String GetParticleName() const { return fParticleName; } 115 inline virtual G4double GetCharge() const { return fPDGCharge; } 116 inline virtual G4int GetPDGEncoding() const { return fPDGEncoding; } 117 inline virtual G4double GetInitialKineticEnergy() const { return fInitialKineticEnergy; } 118 inline virtual G4ThreeVector GetInitialMomentum() const { return fInitialMomentum; } 119 120 // Other member functions 121 virtual void ShowTrajectory(std::ostream& os = G4cout) const; 122 // virtual void DrawTrajectory() const; 123 virtual void DrawTrajectory() const; 124 virtual void AppendStep(const G4Step* aStep); 125 virtual int GetPointEntries() const { return fPositionRecord->size(); } 126 virtual G4VTrajectoryPoint* GetPoint(G4int i) const { return (*fPositionRecord)[i]; } 127 virtual void MergeTrajectory(G4VTrajectory* secondTrajectory); 128 129 G4ParticleDefinition* GetParticleDefinition(); 130 131 virtual const std::map<G4String, G4AttDef>* GetAttDefs() const; 132 virtual std::vector<G4AttValue>* CreateAttValues() const; 133 134 //--------- 135 private: 136 //--------- 137 138 TrajectoryPointContainer* fPositionRecord; 139 G4int fTrackID; 140 G4int fParentID; 141 G4int fPDGEncoding; 142 G4double fPDGCharge; 143 G4String fParticleName; 144 G4double fInitialKineticEnergy; 145 G4ThreeVector fInitialMomentum; 146 }; 147 148 extern G4ThreadLocal G4Allocator<RE04Trajectory>* faTrajAllocator; 149 150 inline void* RE04Trajectory::operator new(size_t) 151 { 152 if (!faTrajAllocator) faTrajAllocator = new G4Allocator<RE04Trajectory>; 153 return (void*)faTrajAllocator->MallocSingle(); 154 } 155 156 inline void RE04Trajectory::operator delete(void* aTrajectory) 157 { 158 faTrajAllocator->FreeSingle((RE04Trajectory*)aTrajectory); 159 } 160 161 #endif 162