GEMC  1.8
Geant4 Monte-Carlo Framework
BST_hitprocess.cc
Go to the documentation of this file.
1 // %%%%%%%%%%%%
2 // gemc headers
3 // %%%%%%%%%%%%
4 #include "BST_hitprocess.h"
5 #include "bst_strip.h"
6 
7 
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 SensorLength = 2.0*aHit->GetDetector().dimensions[2]/mm; // length of 1 card
93  double SensorWidth = 2.0*aHit->GetDetector().dimensions[0]/mm; // width 1 card
94  if(SensorLength != bsts.SensorLength || SensorWidth != bsts.SensorWidth)
95  cout << " Warning: dimensions mismatch between sensor 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 
115 vector<identifier> BST_HitProcess :: ProcessID(vector<identifier> id, G4Step* aStep, detector Detector, gemc_opts Opt)
116 {
117  vector<identifier> yid = id;
118 
119  double x, y, z;
120  G4ThreeVector xyz = aStep->GetPostStepPoint()->GetPosition();
121 
122  G4ThreeVector Lxyz = aStep->GetPreStepPoint()->GetTouchableHandle()->GetHistory()
123  ->GetTopTransform().TransformPoint(xyz);
124 
125  x = xyz.x()/mm;
126  y = xyz.y()/mm;
127  z = xyz.z()/mm;
128 
129 
130  class bst_strip bsts;
131  bsts.fill_infos();
132 
133  int layer = 2*yid[0].id + yid[1].id - 2 ;
134  int sector = yid[2].id;
135  int isensor = yid[3].id;
136 
137  vector<double> multi_hit = bsts.FindStrip(layer-1, sector-1, isensor, Lxyz);
138 
139  int n_multi_hits = multi_hit.size()/2;
140 
141  // closest strip
142  yid[4].id = (int) multi_hit[0];
143 
144  yid[0].id_sharing = multi_hit[1];
145  yid[1].id_sharing = multi_hit[1];
146  yid[2].id_sharing = multi_hit[1];
147  yid[3].id_sharing = multi_hit[1];
148  yid[4].id_sharing = multi_hit[1];
149 
150  // additional strip
151  for(int h=1; h<n_multi_hits; h++)
152  {
153  for(int j=0; j<4; j++)
154  {
155  identifier this_id;
156  this_id.name = yid[j].name;
157  this_id.rule = yid[j].rule;
158  this_id.id = yid[j].id;
159  this_id.time = yid[j].time;
160  this_id.TimeWindow = yid[j].TimeWindow;
161  this_id.TrackId = yid[j].TrackId;
162  this_id.id_sharing = multi_hit[3];
163  yid.push_back(this_id);
164  }
165  // last id is strip
166  identifier this_id;
167  this_id.name = yid[4].name;
168  this_id.rule = yid[4].rule;
169  this_id.id = (int) multi_hit[2];
170  this_id.time = yid[4].time;
171  this_id.TimeWindow = yid[4].TimeWindow;
172  this_id.TrackId = yid[4].TrackId;
173  this_id.id_sharing = multi_hit[3];
174  yid.push_back(this_id);
175 
176  }
177 
178 
179 
180  return yid;
181 }
182 
183 
184 
185 
186 
187 
188 
189 
190 
191 
192 
G4ThreeVector GetVert()
Definition: MHit.h:72
vector< double > raws
Raw information.
Definition: MPHBaseClass.h:26
vector< identifier > ProcessID(vector< identifier >, G4Step *, detector, gemc_opts)
Method to calculate new identifier.
int GetPID()
Definition: MHit.h:107
int GetmPID()
Definition: MHit.h:122
void fill_infos()
Definition: bst_strip.cc:10
vector< identifier > GetId()
Definition: MHit.h:96
string HCname
Hit Collection name.
Definition: MPHBaseClass.h:41
int id
manually assing ID. 0 if "ncopy" (will be set at hit processing time)
Definition: identifier.h:31
G4ThreeVector GetmVert()
Definition: MHit.h:127
string name
Name of the detector.
Definition: identifier.h:28
vector< identifier > identity
Identifier.
Definition: MPHBaseClass.h:28
vector< G4ThreeVector > GetLPos()
Definition: MHit.h:69
double TimeWindow
Time Window. If abs(steptime - time) is smaller than TimeWindow, it&#39;s the same hit.
Definition: identifier.h:33
int TrackId
If Time Window is 0, it&#39;s a "flux" detector: if it&#39;s the same track, it&#39;s the same hit...
Definition: identifier.h:34
double GetE()
Definition: MHit.h:89
vector< G4ThreeVector > GetPos()
Definition: MHit.h:65
PH_output ProcessHit(MHit *, gemc_opts)
Method to process the hit.
double SensorWidth
Definition: bst_strip.h:20
double SensorLength
Definition: bst_strip.h:19
Definition: MHit.h:29
vector< double > GetTime()
Definition: MHit.h:82
map< string, opts > args
Options map.
Definition: usage.h:68
vector< double > FindStrip(int layer, int sector, int isens, G4ThreeVector Lxyz)
Definition: bst_strip.cc:34
double id_sharing
A single step can generate multiple identifiers. This variable represent the percentage sharing of th...
Definition: identifier.h:35
double time
Time of the first step.
Definition: identifier.h:32
vector< double > dimensions
vector of dimensions. Size, units depends on solid type
Definition: detector.h:63
vector< double > GetEdep()
Definition: MHit.h:76
detector GetDetector()
Definition: MHit.h:101
string rule
"manual" or "ncopy"
Definition: identifier.h:30
vector< int > dgtz
Digitized information.
Definition: MPHBaseClass.h:27