/[PAMELA software]/PamVMC_update/include/PamVMCDetectorHit.h
ViewVC logotype

Contents of /PamVMC_update/include/PamVMCDetectorHit.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1.1.1 - (show annotations) (download) (vendor branch)
Tue Oct 15 15:52:30 2013 UTC (11 years, 1 month ago) by formato
Branch: MAIN, rel
CVS Tags: reltag, HEAD
Changes since 1.1: +0 -0 lines
File MIME type: text/plain
PamVMC update

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

  ViewVC Help
Powered by ViewVC 1.1.23