SToGS
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros
SToGS_G4_CopClusterHit.hh
Go to the documentation of this file.
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 
27 #ifndef SToGS_CopClusterHit_h
28 #define SToGS_CopClusterHit_h 1
29 
30 #include "G4VHit.hh"
31 #include "G4THitsCollection.hh"
32 #include "G4Allocator.hh"
33 #include "G4ThreeVector.hh"
34 #include "G4Types.hh"
35 
36 #ifndef G4MULTITHREADED
37 #define G4ThreadLocal
38 #endif
39 
41 namespace SToGS {
43 
58  class CopClusterHit : public G4VHit
59  {
60  public:
61  CopClusterHit();
62  virtual ~CopClusterHit();
63  CopClusterHit(const CopClusterHit &right);
64 
65  const CopClusterHit& operator=(const CopClusterHit &right);
66  G4int operator==(const CopClusterHit &right) const;
67 
68  inline void *operator new(size_t);
69  inline void operator delete(void *aHit);
70 
71  public:
72 // setters
73  void SetDetID (G4int id)
74  {
75  detID = id;
76  }
77  void SetMotherID(G4int id)
78  {
79  motherID = id;
80  }
81  void SetEdep(G4double de = 0.0)
82  {
83  edep = de;
84  }
85  void SetToF (G4double de, G4double tf = 0.0)
86  {
87  ToF = de*tf;
88  }
89  void SetPos(G4double de, G4ThreeVector xyz = G4ThreeVector(0.,0.,0.))
90  {
91  pos = de*xyz;
92  }
93  void SetDetName(G4String name)
94  {
95  detName = name;
96  }
97  void SetMotherDetName(G4String name)
98  {
99  motherDetName = name;
100  }
101  void SetNbHits(G4int nb = 0)
102  {
103  NbHits = nb;
104  }
105 // getters
106  G4int GetDetID() const
107  {
108  return detID;
109  }
110  G4int GetMotherID() const
111  {
112  return motherID;
113  }
114  G4double GetEdep() const
115  {
116  return edep;
117  }
118  G4double GetToF() const
119  {
120  return ToF;
121  }
122  const G4ThreeVector &GetPos()
123  {
124  return pos;
125  }
126  G4int GetNbHits() const
127  {
128  return NbHits;
129  }
130 // others
131  void AddOneHit()
132  {
133  NbHits++;
134  }
135  void AddEdep(G4double de)
136  {
137  edep += de;
138  }
139  void AddToF (G4double de, G4double t)
140  {
141  ToF += de*t;
142  }
143  void AddPos (G4double de, G4ThreeVector xyz)
144  {
145  pos.setX(pos.x()+de*xyz.x()); pos.setY(pos.y()+de*xyz.y()); pos.setZ(pos.z()+de*xyz.z());
146  }
148  void EndOfEvent();
149 
150  void Draw();
151  void Print();
152 
153  private:
154  G4int detID;
155  G4int motherID;
156 
157  G4double edep;
158  G4double ToF;
159 
160  G4ThreeVector pos;
161 
162  G4String detName;
163  G4String motherDetName;
164 
165  G4int NbHits;
166  };
167 
168  typedef G4THitsCollection<CopClusterHit> CopClusterHitsCollection;
169  extern G4ThreadLocal G4Allocator<CopClusterHit> *CopClusterHitAllocator;
170 
171  inline void* CopClusterHit::operator new(size_t)
172  {
174  CopClusterHitAllocator = new G4Allocator<CopClusterHit>;
175  return CopClusterHitAllocator->MallocSingle();
176  }
177  inline void CopClusterHit::operator delete(void *aHit)
178  {
179  CopClusterHitAllocator->FreeSingle((CopClusterHit*) aHit);
180  }
181 } // SToGS Namespace
182 
183 #endif
G4ThreadLocal G4Allocator< CopClusterHit > * CopClusterHitAllocator
void SetDetName(G4String name)
void EndOfEvent()
to be applied at the end of an event to calculate properly the mean values
#define G4ThreadLocal
G4THitsCollection< CopClusterHit > CopClusterHitsCollection
void AddToF(G4double de, G4double t)
void SetMotherDetName(G4String name)
void SetToF(G4double de, G4double tf=0.0)
void AddPos(G4double de, G4ThreeVector xyz)
void SetEdep(G4double de=0.0)
Informations to keep the energy is in a sensitive detector.
const G4ThreeVector & GetPos()
G4int operator==(const CopClusterHit &right) const
void SetPos(G4double de, G4ThreeVector xyz=G4ThreeVector(0., 0., 0.))
const CopClusterHit & operator=(const CopClusterHit &right)