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

Contents of /PamCAL/include/PamVMCDetectorHit.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1 - (show annotations) (download)
Mon Nov 12 10:10:18 2007 UTC (17 years, 1 month ago) by nikolas
Branch: MAIN
CVS Tags: HEAD
File MIME type: text/plain
More basic files added

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 #include <TG4G3Units.h>
10
11 #include "PamVMCGeoID.h"
12
13 using std::sqrt;
14 using std::cout;
15 using std::endl;
16
17 class pHitData: public TObject {
18
19 public:
20 Int_t fPOS;
21 Int_t fPDG; //Particle PDG
22 Double_t fPATH; //PATH length in specific SD in (cm)
23 Double_t fTOF;
24 Double_t fPIN;
25 Double_t fXOUT;
26 Double_t fYOUT;
27 Double_t fZOUT;
28 Double_t fEREL; //Energy released during hit
29 Double_t fXIN;
30 Double_t fYIN;
31 Double_t fZIN;
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.) { };
36
37 // pHitData( pHitData & p ): fPOS(p.fPOS), fPDG(p.fPDG), fPATH(p.fPATH), fTOF(p.fTOF),
38 // fPIN(p.fPIN), fXOUT (p.fXOUT),
39 // fYOUT( p.fYOUT), fZOUT (p.fZOUT), fEREL( p.fEREL),
40 // fXIN(p.fXIN), fYIN( p.fYIN), fZIN( p.fZIN) { };
41
42
43 void Clean() {
44 fPOS=fPDG=0;
45 fPATH= fTOF= fPIN= fXOUT =
46 fYOUT = fZOUT = fEREL =
47 fXIN= fYIN = fZIN = 0.;
48 }
49
50 // pHitData & operator+=( const pHitData &a);//, const pHitData & p) ;
51 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 <<"XOUT: " << fXOUT << " (cm)"<<endl
62 <<"YOUT: " << fYOUT << " (cm)"<<endl
63 <<"ZOUT: " << fZOUT << " (cm)"<<endl
64 <<"PATH: " << fPATH << " (cm)"<<endl
65 <<"EREL: " << fEREL*1E6 << " (keV)"<<endl
66 <<"TOF: " << fTOF << " (s)"<<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 void CleanHit() {
85 fhitdata.Clean();
86 fnocall=0;
87 }
88 pHitData * GenHit() { return new pHitData(fhitdata);}
89
90
91 virtual void FillHitEntering(pHitData &phd){
92 SetHit(phd); }
93
94 virtual void Print(Option_t* option = "") const;
95
96 void FillHit(TVirtualMC *g) {
97 fnocall++;
98 // SetPOS(pos);
99 /// TLorentzVector k;
100 double x,y,z,e;
101 g->TrackPosition(x,y,z);
102 UpdPDG(g->TrackPid());
103 UpdXIN(x);
104 UpdYIN(y);
105 UpdZIN(z);
106 SetXOUT(x);
107 SetYOUT(y);
108 SetZOUT(z);
109 g->TrackMomentum(x,y,z,e);
110 UpdPIN(sqrt(x*x+y*y+z*z));
111 AddTOF((g->GetStack()->GetCurrentTrack()->T())/TG4G3Units::Time()+(g->TrackTime()));
112 AddPATH(g->TrackStep());
113 AddEREL(g->Edep());
114
115 }
116
117 void SetHit( const pHitData &phd){
118 fnocall++;
119 SetPOS(phd.fPOS);
120 AddTOF(phd.fTOF);
121 AddPATH( phd.fPATH );
122 AddEREL( phd.fEREL );
123 UpdPDG( phd.fPDG );
124 UpdXIN( phd.fXIN );
125 UpdYIN( phd.fYIN );
126 UpdZIN( phd.fZIN );
127 UpdPIN( phd.fPIN );
128 SetXOUT( phd.fXOUT );
129 SetYOUT( phd.fYOUT );
130 SetZOUT( phd.fZOUT );
131 }
132
133 void UpdXIN(Double_t x){
134 if(! fhitdata.fXIN) SetXIN( x );}
135 void UpdYIN(Double_t x){
136 if(! fhitdata.fYIN) SetYIN( x );}
137 void UpdZIN(Double_t x){
138 if(! fhitdata.fZIN) SetZIN( x );}
139 void UpdPIN(Double_t x){
140 if(! fhitdata.fPIN) SetPIN( x );}
141 void UpdPDG(Int_t x){
142 if(! fhitdata.fPDG) SetPDG( x );}
143 // void Incnocall () {fnocall++;}
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(); //{ fhitdata.Clean(); }
157
158 // Get methods
159
160 const pHitData *GetHit() {return &fhitdata;}
161 //Int_t Getnocall() { return fnocall; };
162 Int_t GetPOS() { return fhitdata.fPOS; };
163 Int_t GetPDG() { return fhitdata.fPDG; };
164 Double_t GetPATH() { return fhitdata.fPATH; };
165 Double_t GetEREL() { return fhitdata.fEREL; };
166 Double_t GetXIN() { return fhitdata.fXIN; };
167 Double_t GetYIN() { return fhitdata.fYIN; };
168 Double_t GetZIN() { return fhitdata.fZIN; };
169 Double_t GetTOF() { return fhitdata.fTOF; };
170 Double_t GetPIN() { return fhitdata.fPIN; };
171 Double_t GetXOUT() { return fhitdata.fXOUT; };
172 Double_t GetYOUT() { return fhitdata.fYOUT; };
173 Double_t GetZOUT() { return fhitdata.fZOUT; };
174
175 protected:
176
177 pHitData fhitdata;
178 // Int_t fHITN;
179 // Int_t fPOS; //Number, defines copy number of SD volume;
180 Int_t fnocall;
181 // Double_t IncrementAve ( Double_t t, Double_t d)
182 // { return (t*(fnocall-1) + d)/fnocall; }
183 void AddTOF (Double_t tofin) {
184 //fhitdata.fTOF = IncrementAve(fhitdata.fTOF,tofin);
185 if (tofin!=0.) SetTOF((GetTOF()==0.) ? tofin: (GetTOF()+tofin)/2.);
186 }
187
188 ClassDef(PamVMCDetectorHit,1) //PamVMCDetectorHit
189 };
190
191 #endif //PAMVMC_DETECTOR_HIT_H

  ViewVC Help
Powered by ViewVC 1.1.23