source: trunk/examples/novice/gemc/src/BST_hitprocess.cc @ 1282

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

update

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