GEMC  1.8
Geant4 Monte-Carlo Framework
STR_hitprocess.cc
Go to the documentation of this file.
1 // %%%%%%%%%%%%
2 // gemc headers
3 // %%%%%%%%%%%%
4 #include "STR_hitprocess.h"
5 #include "str_strip.h"
6 
7 
9 {
10  string hd_msg = Opt.args["LOG_MSG"].args + " STR Hit Process " ;
11  double HIT_VERBOSITY = Opt.args["HIT_VERBOSITY"].arg;
12 
13  PH_output out;
14  out.identity = aHit->GetId();
15 
16  HCname = "STR 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  // STR ID:
86  // layer, type, sector, module, strip
87  // %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
88  // class str_strip strs;
89  // strs.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 != strs.CardLength || CardWidth != strs.CardWidth)
95  //cout << hd_msg << " Warning: dimensions mismatch between card reconstruction dimensions and gemc card dimensions." << endl << endl;
96 
97  int slayer = out.identity[0].id;
98  int stype = out.identity[1].id;
99  int segment = out.identity[2].id;
100  int module = out.identity[3].id;
101  int strip = out.identity[4].id;
102  //
103  if(HIT_VERBOSITY>4)
104  cout << hd_msg << " layer: " << slayer << " type: " << stype << " segment: " << segment << " module: "<< module
105  << " Strip: " << strip << " x=" << x << " y=" << y << " z=" << z << endl;
106 
107  out.dgtz.push_back(slayer);
108  out.dgtz.push_back(stype);
109  out.dgtz.push_back(segment);
110  out.dgtz.push_back(module);
111  out.dgtz.push_back(strip);
112 
113  return out;
114 }
115 
116 #define ABS_(x) (x < 0 ? -x : x)
117 
118 vector<identifier> STR_HitProcess :: ProcessID(vector<identifier> id, G4Step* aStep, detector Detector, gemc_opts Opt)
119 {
120  vector<identifier> yid = id;
121 
122  enum STR_identifiers {layer=0,type=1,segment=2,module=3,strip=4};
123 
124  //int slayer = yid[0].id;
125  //int stype = yid[1].id;
126  //int segment = yid[2].id;
127  //int module = yid[3].id;
128  //int strip = yid[4].id;
129 
130 
131 
132  double active_width = 38.34; // mm X-direction
133  double active_height = 98.33; // mm Y-direction
134  double readout_pitch = 0.06; // mm, = 60 micron
135 
136  G4ThreeVector xyz = aStep->GetPostStepPoint()->GetPosition();
137  G4ThreeVector Lxyz = aStep->GetPreStepPoint()->GetTouchableHandle()->GetHistory()->GetTopTransform().TransformPoint(xyz); // Local coordinates
138 
139  double x = Lxyz.x();
140  double y = Lxyz.y();
141 
142  if( x < -active_width/2) yid[strip].id = -10;
143  else if ( x > active_width/2) yid[strip].id = -9;
144  else if( y < -active_height/2)yid[strip].id = -8;
145  else if( y > active_height/2) yid[strip].id = -7;
146  else
147  {
148  int nstrip = (int)((x + active_width/2 )/readout_pitch);
149  yid[strip].id = nstrip;
150  }
151  yid[id.size()-1].id_sharing = 1;
152  return yid;
153 }
154 
155 
156 
157 
158 
159 
160 
161 
162 
163 
164 
G4ThreeVector GetVert()
Definition: MHit.h:72
vector< double > raws
Raw information.
Definition: MPHBaseClass.h:26
int GetPID()
Definition: MHit.h:107
int GetmPID()
Definition: MHit.h:122
vector< identifier > GetId()
Definition: MHit.h:96
string HCname
Hit Collection name.
Definition: MPHBaseClass.h:41
G4ThreeVector GetmVert()
Definition: MHit.h:127
vector< identifier > identity
Identifier.
Definition: MPHBaseClass.h:28
vector< G4ThreeVector > GetLPos()
Definition: MHit.h:69
double GetE()
Definition: MHit.h:89
vector< G4ThreeVector > GetPos()
Definition: MHit.h:65
Definition: MHit.h:29
PH_output ProcessHit(MHit *, gemc_opts)
Method to process the hit.
vector< double > GetTime()
Definition: MHit.h:82
map< string, opts > args
Options map.
Definition: usage.h:68
vector< identifier > ProcessID(vector< identifier >, G4Step *, detector, gemc_opts)
Method to calculate new identifier.
vector< double > GetEdep()
Definition: MHit.h:76
vector< int > dgtz
Digitized information.
Definition: MPHBaseClass.h:27