source: trunk/examples/novice/gemc/src/raw_hitprocess.cc @ 1279

Last change on this file since 1279 was 807, checked in by garnier, 16 years ago

update

File size: 2.1 KB
Line 
1// %%%%%%%%%%
2// G4 headers
3// %%%%%%%%%%
4#include "G4UnitsTable.hh"
5
6
7// %%%%%%%%%%%%%
8// gemc headers
9// %%%%%%%%%%%%%
10#include "raw_hitprocess.h"
11
12
13PH_output raw_HitProcess :: ProcessHit(MHit* aHit, gemc_opts)
14{
15 PH_output out;
16 out.identity = aHit->GetId();
17 HCname = "TOF Hit Process";
18
19 // %%%%%%%%%%%%%%%%%%%
20 // Raw hit information
21 // %%%%%%%%%%%%%%%%%%%
22 int nsteps = aHit->GetPos().size();
23 
24 // Get Total Energy deposited
25 double Etot = 0;
26 vector<G4double> Edep = aHit->GetEdep();
27 for(int s=0; s<nsteps; s++) Etot = Etot + Edep[s];
28 
29 // average global, local positions of the hit
30 double x, y, z;
31 double lx, ly, lz;
32 x = y = z = lx = ly = lz = 0;
33 vector<G4ThreeVector> pos  = aHit->GetPos();
34 vector<G4ThreeVector> Lpos = aHit->GetLPos();
35
36 if(Etot>0)
37 for(int s=0; s<nsteps; s++)
38 {
39    x  = x  +  pos[s].x()*Edep[s]/Etot;
40    y  = y  +  pos[s].y()*Edep[s]/Etot;
41    z  = z  +  pos[s].z()*Edep[s]/Etot;
42    lx = lx + Lpos[s].x()*Edep[s]/Etot;
43    ly = ly + Lpos[s].y()*Edep[s]/Etot;
44    lz = lz + Lpos[s].z()*Edep[s]/Etot;
45 }
46 else
47 {
48   x  = pos[0].x();
49   y  = pos[0].y();
50   z  = pos[0].z();
51   lx = Lpos[0].x();
52   ly = Lpos[0].y();
53   lz = Lpos[0].z();
54 }
55
56
57 // average time
58 double time = 0;
59 vector<G4double> times = aHit->GetTime();
60 for(int s=0; s<nsteps; s++) time = time + times[s]/nsteps;
61
62 // Energy of the track
63 double Ene = aHit->GetE();
64
65 out.raws.push_back(Etot);
66 out.raws.push_back(x);
67 out.raws.push_back(y);
68 out.raws.push_back(z);
69 out.raws.push_back(lx);
70 out.raws.push_back(ly);
71 out.raws.push_back(lz);
72 out.raws.push_back(time);
73 out.raws.push_back((double) aHit->GetPID());
74 out.raws.push_back(aHit->GetVert().getX());
75 out.raws.push_back(aHit->GetVert().getY());
76 out.raws.push_back(aHit->GetVert().getZ());
77 out.raws.push_back(Ene);
78 out.raws.push_back((double) aHit->GetmPID());
79 out.raws.push_back(aHit->GetmVert().getX());
80 out.raws.push_back(aHit->GetmVert().getY());
81 out.raws.push_back(aHit->GetmVert().getZ());
82
83
84 return out;
85}
86
87vector<identifier>  raw_HitProcess :: ProcessID(vector<identifier> id, G4Step* aStep, detector Detector)
88{
89 return id;
90}
91
92
93
94
95
96
97
98
99
100
101
Note: See TracBrowser for help on using the repository browser.