G4OCCT 0.1.0
Geant4 interface to Open CASCADE Technology (OCCT) geometry definitions
Loading...
Searching...
No Matches
CalorHit.hh
Go to the documentation of this file.
1// ********************************************************************
2// * License and Disclaimer *
3// * *
4// * The Geant4 software is copyright of the Copyright Holders of *
5// * the Geant4 Collaboration. It is provided under the terms and *
6// * conditions of the Geant4 Software License, included in the file *
7// * LICENSE and available at http://cern.ch/geant4/license . These *
8// * include a list of copyright holders. *
9// * *
10// * Neither the authors of this software system, nor their employing *
11// * institutes,nor the agencies providing financial support for this *
12// * work make any representation or warranty, express or implied, *
13// * regarding this software system or assume any liability for its *
14// * use. Please see the license in the file LICENSE and URL above *
15// * for the full disclaimer and the limitation of liability. *
16// * *
17// * This code implementation is the result of the scientific and *
18// * technical work of the GEANT4 collaboration. *
19// * By using, copying, modifying or distributing the software (or *
20// * any work based on the software) you agree to acknowledge its *
21// * use in resulting scientific publications, and indicate your *
22// * acceptance of all terms of the Geant4 Software license. *
23// ********************************************************************
24//
27
28#ifndef B4cCalorHit_h
29#define B4cCalorHit_h 1
30
31#include "G4Allocator.hh"
32#include "G4THitsCollection.hh"
33#include "G4Threading.hh"
34#include "G4ThreeVector.hh"
35#include "G4VHit.hh"
36#include "globals.hh"
37
38namespace B4c {
39
45
46class CalorHit : public G4VHit {
47public:
48 CalorHit() = default;
49 CalorHit(const CalorHit&) = default;
50 ~CalorHit() override = default;
51
52 // operators
53 CalorHit& operator=(const CalorHit&) = default;
54 G4bool operator==(const CalorHit&) const;
55
56 inline void* operator new(size_t);
57 inline void operator delete(void*);
58
59 // methods from base class
60 void Draw() override {}
61 void Print() override;
62
63 // methods to handle data
64 void Add(G4double de, G4double dl);
65
66 // get methods
67 G4double GetEdep() const;
68 G4double GetTrackLength() const;
69
70private:
71 G4double fEdep = 0.;
72 G4double fTrackLength = 0.;
73};
74
75//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
76
77using CalorHitsCollection = G4THitsCollection<CalorHit>;
78
79extern G4ThreadLocal G4Allocator<CalorHit>* CalorHitAllocator;
80
81//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
82
83inline void* CalorHit::operator new(size_t) {
84 if (!CalorHitAllocator) {
85 CalorHitAllocator = new G4Allocator<CalorHit>;
86 }
87 void* hit;
88 hit = (void*)CalorHitAllocator->MallocSingle();
89 return hit;
90}
91
92inline void CalorHit::operator delete(void* hit) {
93 if (!CalorHitAllocator) {
94 CalorHitAllocator = new G4Allocator<CalorHit>;
95 }
96 CalorHitAllocator->FreeSingle((CalorHit*)hit);
97}
98
99inline void CalorHit::Add(G4double de, G4double dl) {
100 fEdep += de;
101 fTrackLength += dl;
102}
103
104inline G4double CalorHit::GetEdep() const { return fEdep; }
105
106inline G4double CalorHit::GetTrackLength() const { return fTrackLength; }
107
108} // namespace B4c
109
110//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
111
112#endif
G4double GetEdep() const
Definition CalorHit.hh:104
void Print() override
Definition CalorHit.cc:44
void Add(G4double de, G4double dl)
Definition CalorHit.hh:99
CalorHit & operator=(const CalorHit &)=default
~CalorHit() override=default
G4bool operator==(const CalorHit &) const
Definition CalorHit.cc:40
CalorHit()=default
void Draw() override
Definition CalorHit.hh:60
CalorHit(const CalorHit &)=default
G4double GetTrackLength() const
Definition CalorHit.hh:106
G4ThreadLocal G4Allocator< CalorHit > * CalorHitAllocator
Definition CalorHit.cc:36
G4THitsCollection< CalorHit > CalorHitsCollection
Definition CalorHit.hh:77