Warning, file /geant4/examples/basic/B4/B4c/include/CalorHit.hh was not indexed
or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030 #ifndef B4cCalorHit_h
0031 #define B4cCalorHit_h 1
0032
0033 #include "G4Allocator.hh"
0034 #include "G4THitsCollection.hh"
0035 #include "G4Threading.hh"
0036 #include "G4ThreeVector.hh"
0037 #include "G4VHit.hh"
0038 #include "globals.hh"
0039
0040 namespace B4c
0041 {
0042
0043
0044
0045
0046
0047
0048
0049 class CalorHit : public G4VHit
0050 {
0051 public:
0052 CalorHit() = default;
0053 CalorHit(const CalorHit&) = default;
0054 ~CalorHit() override = default;
0055
0056
0057 CalorHit& operator=(const CalorHit&) = default;
0058 G4bool operator==(const CalorHit&) const;
0059
0060 inline void* operator new(size_t);
0061 inline void operator delete(void*);
0062
0063
0064 void Draw() override {}
0065 void Print() override;
0066
0067
0068 void Add(G4double de, G4double dl);
0069
0070
0071 G4double GetEdep() const;
0072 G4double GetTrackLength() const;
0073
0074 private:
0075 G4double fEdep = 0.;
0076 G4double fTrackLength = 0.;
0077 };
0078
0079
0080
0081 using CalorHitsCollection = G4THitsCollection<CalorHit>;
0082
0083 extern G4ThreadLocal G4Allocator<CalorHit>* CalorHitAllocator;
0084
0085
0086
0087 inline void* CalorHit::operator new(size_t)
0088 {
0089 if (!CalorHitAllocator) {
0090 CalorHitAllocator = new G4Allocator<CalorHit>;
0091 }
0092 void* hit;
0093 hit = (void*)CalorHitAllocator->MallocSingle();
0094 return hit;
0095 }
0096
0097 inline void CalorHit::operator delete(void* hit)
0098 {
0099 if (!CalorHitAllocator) {
0100 CalorHitAllocator = new G4Allocator<CalorHit>;
0101 }
0102 CalorHitAllocator->FreeSingle((CalorHit*)hit);
0103 }
0104
0105 inline void CalorHit::Add(G4double de, G4double dl)
0106 {
0107 fEdep += de;
0108 fTrackLength += dl;
0109 }
0110
0111 inline G4double CalorHit::GetEdep() const
0112 {
0113 return fEdep;
0114 }
0115
0116 inline G4double CalorHit::GetTrackLength() const
0117 {
0118 return fTrackLength;
0119 }
0120
0121 }
0122
0123
0124
0125 #endif