source: trunk/examples/novice/gemc/src/FST_hitprocess.cc

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

update

File size: 3.0 KB
Line 
1// %%%%%%%%%%%%
2// gemc headers
3// %%%%%%%%%%%%
4#include "FST_hitprocess.h"
5#include "fst_strip.h"
6
7PH_output FST_HitProcess :: ProcessHit(MHit* aHit, gemc_opts Opt)
8{
9 string hd_msg   = Opt.args["LOG_MSG"].args + " FST Hit Process " ;
10 double VERB     = Opt.args["HIT_VERBOSITY"].arg;
11 
12 PH_output out;
13 out.identity = aHit->GetId();
14     
15 HCname = "FST Hit Process";
16 
17 // %%%%%%%%%%%%%%%%%%%
18 // Raw hit information
19 // %%%%%%%%%%%%%%%%%%%
20 int nsteps = aHit->GetPos().size();
21 
22 // Get Total Energy deposited
23 double Etot = 0;
24 vector<G4double> Edep = aHit->GetEdep();
25 for(int s=0; s<nsteps; s++) Etot = Etot + Edep[s];
26 
27 // average global, local positions of the hit
28 double x, y, z;
29 double lx, ly, lz;
30 x = y = z = lx = ly = lz = 0;
31 vector<G4ThreeVector> pos  = aHit->GetPos();
32 vector<G4ThreeVector> Lpos = aHit->GetLPos();
33 
34 if(Etot>0)
35 for(int s=0; s<nsteps; s++)
36 {   
37    x  = x  +  pos[s].x()*Edep[s]/Etot;
38    y  = y  +  pos[s].y()*Edep[s]/Etot;
39    z  = z  +  pos[s].z()*Edep[s]/Etot;
40    lx = lx + Lpos[s].x()*Edep[s]/Etot;
41    ly = ly + Lpos[s].y()*Edep[s]/Etot;
42    lz = lz + Lpos[s].z()*Edep[s]/Etot;
43 }
44 else
45 {
46   x  = pos[0].x();
47   y  = pos[0].y();
48   z  = pos[0].z();
49   lx = Lpos[0].x();
50   ly = Lpos[0].y();
51   lz = Lpos[0].z();
52 }   
53
54 
55 // average time
56 double time = 0;
57 vector<G4double> times = aHit->GetTime();
58 for(int s=0; s<nsteps; s++) time = time + times[s]/nsteps;
59
60 // Energy of the track
61 double Ene = aHit->GetE();
62 
63 out.raws.push_back(Etot);
64 out.raws.push_back(x);
65 out.raws.push_back(y);
66 out.raws.push_back(z);
67 out.raws.push_back(lx);
68 out.raws.push_back(ly);
69 out.raws.push_back(lz);
70 out.raws.push_back(time);
71 out.raws.push_back((double) aHit->GetPID());
72 out.raws.push_back(aHit->GetVert().getX());
73 out.raws.push_back(aHit->GetVert().getY());
74 out.raws.push_back(aHit->GetVert().getZ());
75 out.raws.push_back(Ene);
76 out.raws.push_back((double) aHit->GetmPID());
77 out.raws.push_back(aHit->GetmVert().getX());
78 out.raws.push_back(aHit->GetmVert().getY());
79 out.raws.push_back(aHit->GetmVert().getZ());
80 
81
82 // %%%%%%%%%%%%%%%%%%%%%%%%%%
83 // Digitization
84 // FST ID:
85 // layer, type, sector, strip
86 // %%%%%%%%%%%%%%%%%%%%%%%%%%
87 int layer  = 2*out.identity[0].id + out.identity[1].id - 2 ;
88 int sector = out.identity[2].id;
89 int strip  = out.identity[3].id;
90 
91 if(VERB>4)
92 cout <<  hd_msg << " layer: " << layer << "  sector: " << sector
93      << "  Strip: " << strip << " x=" << x << " y=" << y << " z=" << z << endl; 
94
95 out.dgtz.push_back(layer);
96 out.dgtz.push_back(sector);
97 out.dgtz.push_back(strip); 
98
99 return out;
100}
101
102
103
104vector<identifier>  FST_HitProcess :: ProcessID(vector<identifier> id, G4Step* aStep, detector Detector)
105{
106 double x, y, z;
107 G4ThreeVector   xyz    = aStep->GetPostStepPoint()->GetPosition();
108 x = xyz.x()/mm; 
109 y = xyz.y()/mm; 
110 z = xyz.z()/mm; 
111 
112 vector<identifier> yid = id; 
113 class fst_strip fsts;
114 fsts.fill_infos(); 
115 
116 int layer  = 2*yid[0].id + yid[1].id - 2 ;
117 int sector = yid[2].id;
118 
119 yid[3].id = fsts.FindStrip(layer-1, sector-1, x, y, z);
120 
121 return yid;
122}
123
124
125
126
127
128
129
130
131
132
Note: See TracBrowser for help on using the repository browser.