1 |
nikolas |
1.1 |
#ifndef PAMVMC_DETECTOR_HIT_H |
2 |
|
|
#define PAMVMC_DETECTOR_HIT_H |
3 |
|
|
#include <cmath> |
4 |
|
|
#include <iostream> |
5 |
|
|
|
6 |
|
|
#include <TObject.h> |
7 |
|
|
#include <TVirtualMC.h> |
8 |
|
|
#include <TParticle.h> |
9 |
|
|
|
10 |
|
|
#include "PamVMCGeoID.h" |
11 |
|
|
|
12 |
|
|
using std::sqrt; |
13 |
|
|
using std::cout; |
14 |
|
|
using std::endl; |
15 |
|
|
|
16 |
|
|
class pHitData: public TObject { |
17 |
|
|
|
18 |
|
|
public: |
19 |
|
|
Int_t fPOS; |
20 |
|
|
Int_t fPDG; //Particle PDG |
21 |
|
|
Double_t fPATH; //PATH length in specific SD in (cm) |
22 |
|
|
Double_t fTOF; |
23 |
|
|
Double_t fPIN; |
24 |
|
|
Double_t fXOUT; |
25 |
|
|
Double_t fYOUT; |
26 |
|
|
Double_t fZOUT; |
27 |
|
|
Double_t fEREL; //Energy released during hit |
28 |
|
|
Double_t fXIN; |
29 |
|
|
Double_t fYIN; |
30 |
|
|
Double_t fZIN; |
31 |
|
|
|
32 |
|
|
pHitData(): fPOS(0), fPDG(0), fPATH(0.), fTOF(0.), fPIN(0.), fXOUT (0.), |
33 |
|
|
fYOUT (0.), fZOUT (0.), fEREL (0.), |
34 |
|
|
fXIN(0.), fYIN (0.), fZIN (0.) { }; |
35 |
|
|
|
36 |
|
|
|
37 |
|
|
// Kept for back-compatibility |
38 |
|
|
virtual void Clean() { |
39 |
|
|
fPOS=fPDG=0; |
40 |
|
|
fPATH= fTOF= fPIN= fXOUT = |
41 |
|
|
fYOUT = fZOUT = fEREL = |
42 |
|
|
fXIN= fYIN = fZIN = 0.; |
43 |
|
|
} |
44 |
|
|
|
45 |
|
|
// Inherithed from TObject |
46 |
|
|
|
47 |
|
|
virtual void Clear( Option_t * = "") { Clean(); } |
48 |
|
|
|
49 |
|
|
virtual void Print(Option_t * ="" ) const |
50 |
|
|
{ cout << "pHitData: "<<endl |
51 |
|
|
<<"ID of SD volume: " << fPOS << endl |
52 |
|
|
<<"HIT INFORMATION: " << endl |
53 |
|
|
<<"Partice PDG: " << fPDG << endl |
54 |
|
|
<<"XIN: " << fXIN << " (cm)"<<endl |
55 |
|
|
<<"YIN: " << fYIN << " (cm)"<<endl |
56 |
|
|
<<"ZIN: " << fZIN << " (cm)"<<endl |
57 |
|
|
<<"PIN: " << fPIN << " (GeV/c)"<<endl |
58 |
|
|
<<"XOUT: " << fXOUT << " (cm)"<<endl |
59 |
|
|
<<"YOUT: " << fYOUT << " (cm)"<<endl |
60 |
|
|
<<"ZOUT: " << fZOUT << " (cm)"<<endl |
61 |
|
|
<<"PATH: " << fPATH << " (cm)"<<endl |
62 |
|
|
<<"EREL: " << fEREL*1E6 << " (keV)"<<endl |
63 |
|
|
<<"TOF: " << fTOF << " (s)"<<endl; } |
64 |
|
|
|
65 |
|
|
ClassDef(pHitData,1) |
66 |
|
|
|
67 |
|
|
}; |
68 |
|
|
|
69 |
|
|
|
70 |
|
|
pHitData & operator+=( pHitData &a, const pHitData & p); |
71 |
|
|
|
72 |
|
|
|
73 |
|
|
class PamVMCDetectorHit : public TObject |
74 |
|
|
{ |
75 |
|
|
public: |
76 |
|
|
PamVMCDetectorHit(); |
77 |
|
|
virtual ~PamVMCDetectorHit(); |
78 |
|
|
|
79 |
|
|
//Set and Add methods |
80 |
|
|
|
81 |
|
|
virtual void CleanHit() { |
82 |
|
|
fhitdata.Clean(); |
83 |
|
|
fnocall=0; |
84 |
|
|
} |
85 |
|
|
|
86 |
|
|
virtual void Clear(Option_t * = ""){ this->~PamVMCDetectorHit(); } |
87 |
|
|
|
88 |
|
|
virtual pHitData * GenHit() { return new pHitData(fhitdata);} |
89 |
|
|
|
90 |
|
|
void operator = (const PamVMCDetectorHit & p ); |
91 |
|
|
|
92 |
|
|
void operator += (const PamVMCDetectorHit & p ); |
93 |
|
|
|
94 |
|
|
virtual void FillHitEntering(pHitData &phd){ |
95 |
|
|
SetHit(phd); } |
96 |
|
|
|
97 |
|
|
virtual void Print(Option_t* option = "") const; |
98 |
|
|
|
99 |
|
|
void FillHit(TVirtualMC *g) { |
100 |
|
|
fnocall++; |
101 |
|
|
double x,y,z,e; |
102 |
|
|
g->TrackPosition(x,y,z); |
103 |
|
|
UpdPDG(g->TrackPid()); |
104 |
|
|
UpdXIN(x); |
105 |
|
|
UpdYIN(y); |
106 |
|
|
UpdZIN(z); |
107 |
|
|
SetXOUT(x); |
108 |
|
|
SetYOUT(y); |
109 |
|
|
SetZOUT(z); |
110 |
|
|
g->TrackMomentum(x,y,z,e); |
111 |
|
|
UpdPIN(sqrt(x*x+y*y+z*z)); |
112 |
|
|
AddTOF((g->GetStack()->GetCurrentTrack()->T())/1.0E9 /*TG4G3Units::Time()*/+(g->TrackTime())); |
113 |
|
|
AddPATH(g->TrackStep()); |
114 |
|
|
AddEREL(g->Edep()); |
115 |
|
|
|
116 |
|
|
} |
117 |
|
|
|
118 |
|
|
void SetHit( const pHitData &phd){ |
119 |
|
|
fnocall++; |
120 |
|
|
SetPOS(phd.fPOS); |
121 |
|
|
AddTOF(phd.fTOF); |
122 |
|
|
AddPATH( phd.fPATH ); |
123 |
|
|
AddEREL( phd.fEREL ); |
124 |
|
|
UpdPDG( phd.fPDG ); |
125 |
|
|
UpdXIN( phd.fXIN ); |
126 |
|
|
UpdYIN( phd.fYIN ); |
127 |
|
|
UpdZIN( phd.fZIN ); |
128 |
|
|
UpdPIN( phd.fPIN ); |
129 |
|
|
SetXOUT( phd.fXOUT ); |
130 |
|
|
SetYOUT( phd.fYOUT ); |
131 |
|
|
SetZOUT( phd.fZOUT ); |
132 |
|
|
} |
133 |
|
|
|
134 |
|
|
void UpdXIN(Double_t x){ |
135 |
|
|
if(! fhitdata.fXIN) SetXIN( x );} |
136 |
|
|
void UpdYIN(Double_t x){ |
137 |
|
|
if(! fhitdata.fYIN) SetYIN( x );} |
138 |
|
|
void UpdZIN(Double_t x){ |
139 |
|
|
if(! fhitdata.fZIN) SetZIN( x );} |
140 |
|
|
void UpdPIN(Double_t x){ |
141 |
|
|
if(! fhitdata.fPIN) SetPIN( x );} |
142 |
|
|
void UpdPDG(Int_t x){ |
143 |
|
|
if(! fhitdata.fPDG) SetPDG( x );} |
144 |
|
|
void SetPOS (Int_t pos) { fhitdata.fPOS = pos; } |
145 |
|
|
void SetPDG (Int_t pdg) { fhitdata.fPDG = pdg; } |
146 |
|
|
void AddPATH (Double_t ln) { fhitdata.fPATH += ln; } |
147 |
|
|
void AddEREL (Double_t de) { fhitdata.fEREL += de; } |
148 |
|
|
void SetXIN (Double_t xin) { fhitdata.fXIN = xin; } |
149 |
|
|
void SetYIN (Double_t yin) { fhitdata.fYIN = yin; } |
150 |
|
|
void SetZIN (Double_t zin) { fhitdata.fZIN = zin; } |
151 |
|
|
void SetTOF (Double_t tofin) { fhitdata.fTOF = tofin; } |
152 |
|
|
void SetPIN (Double_t pxin) { fhitdata.fPIN = pxin; } |
153 |
|
|
void SetXOUT (Double_t xout) { fhitdata.fXOUT = xout; } |
154 |
|
|
void SetYOUT (Double_t yout) { fhitdata.fYOUT = yout; } |
155 |
|
|
void SetZOUT (Double_t zout) { fhitdata.fZOUT = zout; } |
156 |
|
|
void Reset(); |
157 |
|
|
|
158 |
|
|
// Get methods |
159 |
|
|
|
160 |
|
|
const pHitData *GetHit() {return &fhitdata;} |
161 |
|
|
Int_t GetPOS() { return fhitdata.fPOS; }; |
162 |
|
|
Int_t GetPDG() { return fhitdata.fPDG; }; |
163 |
|
|
Double_t GetPATH() { return fhitdata.fPATH; }; |
164 |
|
|
Double_t GetEREL() { return fhitdata.fEREL; }; |
165 |
|
|
Double_t GetXIN() { return fhitdata.fXIN; }; |
166 |
|
|
Double_t GetYIN() { return fhitdata.fYIN; }; |
167 |
|
|
Double_t GetZIN() { return fhitdata.fZIN; }; |
168 |
|
|
Double_t GetTOF() { return fhitdata.fTOF; }; |
169 |
|
|
Double_t GetPIN() { return fhitdata.fPIN; }; |
170 |
|
|
Double_t GetXOUT() { return fhitdata.fXOUT; }; |
171 |
|
|
Double_t GetYOUT() { return fhitdata.fYOUT; }; |
172 |
|
|
Double_t GetZOUT() { return fhitdata.fZOUT; }; |
173 |
|
|
|
174 |
|
|
protected: |
175 |
|
|
|
176 |
|
|
pHitData fhitdata; |
177 |
|
|
Int_t fnocall; |
178 |
|
|
void AddTOF (Double_t tofin) { |
179 |
|
|
if (tofin!=0.) SetTOF((GetTOF()==0.) ? tofin: (GetTOF()+tofin)/2.); |
180 |
|
|
} |
181 |
|
|
|
182 |
|
|
ClassDef(PamVMCDetectorHit,1) //PamVMCDetectorHit |
183 |
|
|
}; |
184 |
|
|
|
185 |
|
|
//PamVMCDetectorHit & operator+=(PamVMCDetectorHit & a, const PamVMCDetectorHit & p ); |
186 |
|
|
|
187 |
|
|
#endif //PAMVMC_DETECTOR_HIT_H |